kvm_para_powerpc.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License, version 2, as
  5. * published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software
  14. * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  15. *
  16. * Copyright IBM Corp. 2008
  17. *
  18. * Authors: Hollis Blanchard <hollisb@us.ibm.com>
  19. */
  20. #ifndef __POWERPC_KVM_PARA_H__
  21. #define __POWERPC_KVM_PARA_H__
  22. #include <linux/types.h>
  23. /*
  24. * Additions to this struct must only occur at the end, and should be
  25. * accompanied by a KVM_MAGIC_FEAT flag to advertise that they are present
  26. * (albeit not necessarily relevant to the current target hardware platform).
  27. *
  28. * Struct fields are always 32 or 64 bit aligned, depending on them being 32
  29. * or 64 bit wide respectively.
  30. *
  31. * See Documentation/virt/kvm/ppc-pv.rst
  32. */
  33. struct kvm_vcpu_arch_shared {
  34. __u64 scratch1;
  35. __u64 scratch2;
  36. __u64 scratch3;
  37. __u64 critical; /* Guest may not get interrupts if == r1 */
  38. __u64 sprg0;
  39. __u64 sprg1;
  40. __u64 sprg2;
  41. __u64 sprg3;
  42. __u64 srr0;
  43. __u64 srr1;
  44. __u64 dar; /* dear on BookE */
  45. __u64 msr;
  46. __u32 dsisr;
  47. __u32 int_pending; /* Tells the guest if we have an interrupt */
  48. __u32 sr[16];
  49. __u32 mas0;
  50. __u32 mas1;
  51. __u64 mas7_3;
  52. __u64 mas2;
  53. __u32 mas4;
  54. __u32 mas6;
  55. __u32 esr;
  56. __u32 pir;
  57. /*
  58. * SPRG4-7 are user-readable, so we can only keep these consistent
  59. * between the shared area and the real registers when there's an
  60. * intervening exit to KVM. This also applies to SPRG3 on some
  61. * chips.
  62. *
  63. * This suffices for access by guest userspace, since in PR-mode
  64. * KVM, an exit must occur when changing the guest's MSR[PR].
  65. * If the guest kernel writes to SPRG3-7 via the shared area, it
  66. * must also use the shared area for reading while in kernel space.
  67. */
  68. __u64 sprg4;
  69. __u64 sprg5;
  70. __u64 sprg6;
  71. __u64 sprg7;
  72. };
  73. #define KVM_SC_MAGIC_R0 0x4b564d21 /* "KVM!" */
  74. #define KVM_HCALL_TOKEN(num) _EV_HCALL_TOKEN(EV_KVM_VENDOR_ID, num)
  75. #include <asm/epapr_hcalls.h>
  76. #define KVM_FEATURE_MAGIC_PAGE 1
  77. /* Magic page flags from host to guest */
  78. #define KVM_MAGIC_FEAT_SR (1 << 0)
  79. /* MASn, ESR, PIR, and high SPRGs */
  80. #define KVM_MAGIC_FEAT_MAS0_TO_SPRG7 (1 << 1)
  81. /* Magic page flags from guest to host */
  82. #define MAGIC_PAGE_FLAG_NOT_MAPPED_NX (1 << 0)
  83. #endif /* __POWERPC_KVM_PARA_H__ */