aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include/asm
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2011-06-28 20:20:58 -0400
committerAvi Kivity <avi@redhat.com>2011-07-12 06:16:53 -0400
commit3c42bf8a717cb636e0ed2ed77194669e2ac3ed56 (patch)
tree4f543088e6a64ce7f1a771c1618668ff27752ecc /arch/powerpc/include/asm
parent923c53caea446d246949c94703be83e68f251af7 (diff)
KVM: PPC: Split host-state fields out of kvmppc_book3s_shadow_vcpu
There are several fields in struct kvmppc_book3s_shadow_vcpu that temporarily store bits of host state while a guest is running, rather than anything relating to the particular guest or vcpu. This splits them out into a new kvmppc_host_state structure and modifies the definitions in asm-offsets.c to suit. On 32-bit, we have a kvmppc_host_state structure inside the kvmppc_book3s_shadow_vcpu since the assembly code needs to be able to get to them both with one pointer. On 64-bit they are separate fields in the PACA. This means that on 64-bit we don't need to copy the kvmppc_host_state in and out on vcpu load/unload, and in future will mean that the book3s_hv code doesn't need a shadow_vcpu struct in the PACA at all. That does mean that we have to be careful not to rely on any values persisting in the hstate field of the paca across any point where we could block or get preempted. Signed-off-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc/include/asm')
-rw-r--r--arch/powerpc/include/asm/exception-64s.h10
-rw-r--r--arch/powerpc/include/asm/kvm_book3s_asm.h27
-rw-r--r--arch/powerpc/include/asm/paca.h1
3 files changed, 25 insertions, 13 deletions
diff --git a/arch/powerpc/include/asm/exception-64s.h b/arch/powerpc/include/asm/exception-64s.h
index b6a3a443fbde..296c9b66c04a 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -96,16 +96,16 @@
96 EXCEPTION_PROLOG_PSERIES_1(label, h); 96 EXCEPTION_PROLOG_PSERIES_1(label, h);
97 97
98#define __KVMTEST(n) \ 98#define __KVMTEST(n) \
99 lbz r10,PACA_KVM_SVCPU+SVCPU_IN_GUEST(r13); \ 99 lbz r10,HSTATE_IN_GUEST(r13); \
100 cmpwi r10,0; \ 100 cmpwi r10,0; \
101 bne do_kvm_##n 101 bne do_kvm_##n
102 102
103#define __KVM_HANDLER(area, h, n) \ 103#define __KVM_HANDLER(area, h, n) \
104do_kvm_##n: \ 104do_kvm_##n: \
105 ld r10,area+EX_R10(r13); \ 105 ld r10,area+EX_R10(r13); \
106 stw r9,PACA_KVM_SVCPU+SVCPU_SCRATCH1(r13); \ 106 stw r9,HSTATE_SCRATCH1(r13); \
107 ld r9,area+EX_R9(r13); \ 107 ld r9,area+EX_R9(r13); \
108 std r12,PACA_KVM_SVCPU+SVCPU_SCRATCH0(r13); \ 108 std r12,HSTATE_SCRATCH0(r13); \
109 li r12,n; \ 109 li r12,n; \
110 b kvmppc_interrupt 110 b kvmppc_interrupt
111 111
@@ -114,9 +114,9 @@ do_kvm_##n: \
114 cmpwi r10,KVM_GUEST_MODE_SKIP; \ 114 cmpwi r10,KVM_GUEST_MODE_SKIP; \
115 ld r10,area+EX_R10(r13); \ 115 ld r10,area+EX_R10(r13); \
116 beq 89f; \ 116 beq 89f; \
117 stw r9,PACA_KVM_SVCPU+SVCPU_SCRATCH1(r13); \ 117 stw r9,HSTATE_SCRATCH1(r13); \
118 ld r9,area+EX_R9(r13); \ 118 ld r9,area+EX_R9(r13); \
119 std r12,PACA_KVM_SVCPU+SVCPU_SCRATCH0(r13); \ 119 std r12,HSTATE_SCRATCH0(r13); \
120 li r12,n; \ 120 li r12,n; \
121 b kvmppc_interrupt; \ 121 b kvmppc_interrupt; \
12289: mtocrf 0x80,r9; \ 12289: mtocrf 0x80,r9; \
diff --git a/arch/powerpc/include/asm/kvm_book3s_asm.h b/arch/powerpc/include/asm/kvm_book3s_asm.h
index d5a8a3861635..312617529864 100644
--- a/arch/powerpc/include/asm/kvm_book3s_asm.h
+++ b/arch/powerpc/include/asm/kvm_book3s_asm.h
@@ -60,6 +60,22 @@ kvmppc_resume_\intno:
60 60
61#else /*__ASSEMBLY__ */ 61#else /*__ASSEMBLY__ */
62 62
63/*
64 * This struct goes in the PACA on 64-bit processors. It is used
65 * to store host state that needs to be saved when we enter a guest
66 * and restored when we exit, but isn't specific to any particular
67 * guest or vcpu. It also has some scratch fields used by the guest
68 * exit code.
69 */
70struct kvmppc_host_state {
71 ulong host_r1;
72 ulong host_r2;
73 ulong vmhandler;
74 ulong scratch0;
75 ulong scratch1;
76 u8 in_guest;
77};
78
63struct kvmppc_book3s_shadow_vcpu { 79struct kvmppc_book3s_shadow_vcpu {
64 ulong gpr[14]; 80 ulong gpr[14];
65 u32 cr; 81 u32 cr;
@@ -73,17 +89,12 @@ struct kvmppc_book3s_shadow_vcpu {
73 ulong shadow_srr1; 89 ulong shadow_srr1;
74 ulong fault_dar; 90 ulong fault_dar;
75 91
76 ulong host_r1;
77 ulong host_r2;
78 ulong handler;
79 ulong scratch0;
80 ulong scratch1;
81 ulong vmhandler;
82 u8 in_guest;
83
84#ifdef CONFIG_PPC_BOOK3S_32 92#ifdef CONFIG_PPC_BOOK3S_32
85 u32 sr[16]; /* Guest SRs */ 93 u32 sr[16]; /* Guest SRs */
94
95 struct kvmppc_host_state hstate;
86#endif 96#endif
97
87#ifdef CONFIG_PPC_BOOK3S_64 98#ifdef CONFIG_PPC_BOOK3S_64
88 u8 slb_max; /* highest used guest slb entry */ 99 u8 slb_max; /* highest used guest slb entry */
89 struct { 100 struct {
diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h
index 74126765106a..58f4a18ef60c 100644
--- a/arch/powerpc/include/asm/paca.h
+++ b/arch/powerpc/include/asm/paca.h
@@ -149,6 +149,7 @@ struct paca_struct {
149#ifdef CONFIG_KVM_BOOK3S_HANDLER 149#ifdef CONFIG_KVM_BOOK3S_HANDLER
150 /* We use this to store guest state in */ 150 /* We use this to store guest state in */
151 struct kvmppc_book3s_shadow_vcpu shadow_vcpu; 151 struct kvmppc_book3s_shadow_vcpu shadow_vcpu;
152 struct kvmppc_host_state kvm_hstate;
152#endif 153#endif
153}; 154};
154 155