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