diff options
author | Paul Mackerras <paulus@samba.org> | 2013-09-20 00:52:43 -0400 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2013-10-17 08:45:03 -0400 |
commit | a2d56020d1d91934e7bb3e7c8a5a3b5921ce121b (patch) | |
tree | cebd5519ec61284b8db1ddddfc31236aab6c7628 /arch/powerpc/kernel | |
parent | f24817716efe52f3c8fc137c6893963a0416f3cb (diff) |
KVM: PPC: Book3S PR: Keep volatile reg values in vcpu rather than shadow_vcpu
Currently PR-style KVM keeps the volatile guest register values
(R0 - R13, CR, LR, CTR, XER, PC) in a shadow_vcpu struct rather than
the main kvm_vcpu struct. For 64-bit, the shadow_vcpu exists in two
places, a kmalloc'd struct and in the PACA, and it gets copied back
and forth in kvmppc_core_vcpu_load/put(), because the real-mode code
can't rely on being able to access the kmalloc'd struct.
This changes the code to copy the volatile values into the shadow_vcpu
as one of the last things done before entering the guest. Similarly
the values are copied back out of the shadow_vcpu to the kvm_vcpu
immediately after exiting the guest. We arrange for interrupts to be
still disabled at this point so that we can't get preempted on 64-bit
and end up copying values from the wrong PACA.
This means that the accessor functions in kvm_book3s.h for these
registers are greatly simplified, and are same between PR and HV KVM.
In places where accesses to shadow_vcpu fields are now replaced by
accesses to the kvm_vcpu, we can also remove the svcpu_get/put pairs.
Finally, on 64-bit, we don't need the kmalloc'd struct at all any more.
With this, the time to read the PVR one million times in a loop went
from 567.7ms to 575.5ms (averages of 6 values), an increase of about
1.4% for this worse-case test for guest entries and exits. The
standard deviation of the measurements is about 11ms, so the
difference is only marginally significant statistically.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r-- | arch/powerpc/kernel/asm-offsets.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index 5a285efba174..fda7f4020a33 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c | |||
@@ -520,6 +520,7 @@ int main(void) | |||
520 | DEFINE(VCPU_PTID, offsetof(struct kvm_vcpu, arch.ptid)); | 520 | DEFINE(VCPU_PTID, offsetof(struct kvm_vcpu, arch.ptid)); |
521 | DEFINE(VCPU_CFAR, offsetof(struct kvm_vcpu, arch.cfar)); | 521 | DEFINE(VCPU_CFAR, offsetof(struct kvm_vcpu, arch.cfar)); |
522 | DEFINE(VCPU_PPR, offsetof(struct kvm_vcpu, arch.ppr)); | 522 | DEFINE(VCPU_PPR, offsetof(struct kvm_vcpu, arch.ppr)); |
523 | DEFINE(VCPU_SHADOW_SRR1, offsetof(struct kvm_vcpu, arch.shadow_srr1)); | ||
523 | DEFINE(VCORE_ENTRY_EXIT, offsetof(struct kvmppc_vcore, entry_exit_count)); | 524 | DEFINE(VCORE_ENTRY_EXIT, offsetof(struct kvmppc_vcore, entry_exit_count)); |
524 | DEFINE(VCORE_NAP_COUNT, offsetof(struct kvmppc_vcore, nap_count)); | 525 | DEFINE(VCORE_NAP_COUNT, offsetof(struct kvmppc_vcore, nap_count)); |
525 | DEFINE(VCORE_IN_GUEST, offsetof(struct kvmppc_vcore, in_guest)); | 526 | DEFINE(VCORE_IN_GUEST, offsetof(struct kvmppc_vcore, in_guest)); |
@@ -527,14 +528,13 @@ int main(void) | |||
527 | DEFINE(VCORE_TB_OFFSET, offsetof(struct kvmppc_vcore, tb_offset)); | 528 | DEFINE(VCORE_TB_OFFSET, offsetof(struct kvmppc_vcore, tb_offset)); |
528 | DEFINE(VCORE_LPCR, offsetof(struct kvmppc_vcore, lpcr)); | 529 | DEFINE(VCORE_LPCR, offsetof(struct kvmppc_vcore, lpcr)); |
529 | DEFINE(VCORE_PCR, offsetof(struct kvmppc_vcore, pcr)); | 530 | DEFINE(VCORE_PCR, offsetof(struct kvmppc_vcore, pcr)); |
530 | DEFINE(VCPU_SVCPU, offsetof(struct kvmppc_vcpu_book3s, shadow_vcpu) - | ||
531 | offsetof(struct kvmppc_vcpu_book3s, vcpu)); | ||
532 | DEFINE(VCPU_SLB_E, offsetof(struct kvmppc_slb, orige)); | 531 | DEFINE(VCPU_SLB_E, offsetof(struct kvmppc_slb, orige)); |
533 | DEFINE(VCPU_SLB_V, offsetof(struct kvmppc_slb, origv)); | 532 | DEFINE(VCPU_SLB_V, offsetof(struct kvmppc_slb, origv)); |
534 | DEFINE(VCPU_SLB_SIZE, sizeof(struct kvmppc_slb)); | 533 | DEFINE(VCPU_SLB_SIZE, sizeof(struct kvmppc_slb)); |
535 | 534 | ||
536 | #ifdef CONFIG_PPC_BOOK3S_64 | 535 | #ifdef CONFIG_PPC_BOOK3S_64 |
537 | #ifdef CONFIG_KVM_BOOK3S_PR | 536 | #ifdef CONFIG_KVM_BOOK3S_PR |
537 | DEFINE(PACA_SVCPU, offsetof(struct paca_struct, shadow_vcpu)); | ||
538 | # define SVCPU_FIELD(x, f) DEFINE(x, offsetof(struct paca_struct, shadow_vcpu.f)) | 538 | # define SVCPU_FIELD(x, f) DEFINE(x, offsetof(struct paca_struct, shadow_vcpu.f)) |
539 | #else | 539 | #else |
540 | # define SVCPU_FIELD(x, f) | 540 | # define SVCPU_FIELD(x, f) |