MIPS: KVM: Restore host EBase from ebase variable
authorJames Hogan <james.hogan@imgtec.com>
Thu, 9 Jun 2016 13:19:14 +0000 (14:19 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 14 Jun 2016 09:02:44 +0000 (11:02 +0200)
The host kernel's exception vector base address is currently saved in
the VCPU structure at creation time, and restored on a guest exit.
However it doesn't change and can already be easily accessed from the
'ebase' variable (arch/mips/kernel/traps.c), so drop the host_ebase
member of kvm_vcpu_arch, export the 'ebase' variable to modules and load
from there instead.

This does result in a single extra instruction (lui) on the guest exit
path, but simplifies the code a bit and removes the redundant storage of
the host exception base address.

Credit for the idea goes to Cavium's VZ KVM implementation.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: kvm@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/mips/include/asm/kvm_host.h
arch/mips/kernel/asm-offsets.c
arch/mips/kernel/traps.c
arch/mips/kvm/locore.S
arch/mips/kvm/mips.c

index f68293b4a598f846e291849769a7698bc5c1ee3f..24a8e557db887fe301e1a8dd7a26d3a46aa7922e 100644 (file)
@@ -334,7 +334,7 @@ struct kvm_mips_tlb {
 
 #define KVM_MIPS_GUEST_TLB_SIZE        64
 struct kvm_vcpu_arch {
-       void *host_ebase, *guest_ebase;
+       void *guest_ebase;
        int (*vcpu_run)(struct kvm_run *run, struct kvm_vcpu *vcpu);
        unsigned long host_stack;
        unsigned long host_gp;
index 420808899c700405acc6733525da747544d14d86..a1263d188a5a8c732b4154b4cce8aeca82b8d4a2 100644 (file)
@@ -355,7 +355,6 @@ void output_kvm_defines(void)
        OFFSET(VCPU_RUN, kvm_vcpu, run);
        OFFSET(VCPU_HOST_ARCH, kvm_vcpu, arch);
 
-       OFFSET(VCPU_HOST_EBASE, kvm_vcpu_arch, host_ebase);
        OFFSET(VCPU_GUEST_EBASE, kvm_vcpu_arch, guest_ebase);
 
        OFFSET(VCPU_HOST_STACK, kvm_vcpu_arch, host_stack);
index 4a1712b5abdff6a2d3f3548901a479a05cb250ea..66e5820bfdae4334a0a5ff5655acb3cece637f8d 100644 (file)
@@ -1859,6 +1859,7 @@ void __noreturn nmi_exception_handler(struct pt_regs *regs)
 #define VECTORSPACING 0x100    /* for EI/VI mode */
 
 unsigned long ebase;
+EXPORT_SYMBOL_GPL(ebase);
 unsigned long exception_handlers[32];
 unsigned long vi_handlers[64];
 
index 43c8ef847efaaf42e93dde8e83ef9d0befa9d22d..f87bec546366f2e211d792f03367457b522d1540 100644 (file)
@@ -319,7 +319,7 @@ NESTED (MIPSX(GuestException), CALLFRAME_SIZ, ra)
        mtc0    k0, CP0_STATUS
        ehb
 
-       LONG_L  k0, VCPU_HOST_EBASE(k1)
+       LONG_L  k0, ebase
        mtc0    k0,CP0_EBASE
 
        /*
index c1ab6110ca1dcd8ebf5191d34de77315889f9786..6e753761b5d6e526d0352e02986f1c9306c55fa3 100644 (file)
@@ -273,9 +273,6 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id)
        else
                size = 0x4000;
 
-       /* Save Linux EBASE */
-       vcpu->arch.host_ebase = (void *)read_c0_ebase();
-
        gebase = kzalloc(ALIGN(size, PAGE_SIZE), GFP_KERNEL);
 
        if (!gebase) {
This page took 0.029279 seconds and 5 git commands to generate.