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