2019-05-29 17:12:40 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2009-10-30 08:47:07 +03:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright SUSE Linux Products GmbH 2009
|
|
|
|
*
|
|
|
|
* Authors: Alexander Graf <agraf@suse.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <asm/ppc_asm.h>
|
|
|
|
#include <asm/kvm_asm.h>
|
|
|
|
#include <asm/reg.h>
|
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/asm-offsets.h>
|
|
|
|
#include <asm/exception-64s.h>
|
2018-07-05 19:24:57 +03:00
|
|
|
#include <asm/asm-compat.h>
|
2009-10-30 08:47:07 +03:00
|
|
|
|
2010-04-16 02:11:47 +04:00
|
|
|
#if defined(CONFIG_PPC_BOOK3S_64)
|
2016-06-06 19:56:10 +03:00
|
|
|
#ifdef PPC64_ELF_ABI_v2
|
2014-06-16 16:37:53 +04:00
|
|
|
#define FUNC(name) name
|
|
|
|
#else
|
2010-04-16 02:11:47 +04:00
|
|
|
#define FUNC(name) GLUE(.,name)
|
2014-06-16 16:37:53 +04:00
|
|
|
#endif
|
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>
2013-09-20 08:52:43 +04:00
|
|
|
#define GET_SHADOW_VCPU(reg) addi reg, r13, PACA_SVCPU
|
|
|
|
|
2010-04-16 02:11:47 +04:00
|
|
|
#elif defined(CONFIG_PPC_BOOK3S_32)
|
|
|
|
#define FUNC(name) name
|
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>
2013-09-20 08:52:43 +04:00
|
|
|
#define GET_SHADOW_VCPU(reg) lwz reg, (THREAD + THREAD_KVM_SVCPU)(r2)
|
|
|
|
|
2010-04-16 02:11:47 +04:00
|
|
|
#endif /* CONFIG_PPC_BOOK3S_XX */
|
|
|
|
|
2010-01-05 00:19:25 +03:00
|
|
|
#define VCPU_LOAD_NVGPRS(vcpu) \
|
2012-06-25 17:33:10 +04:00
|
|
|
PPC_LL r14, VCPU_GPR(R14)(vcpu); \
|
|
|
|
PPC_LL r15, VCPU_GPR(R15)(vcpu); \
|
|
|
|
PPC_LL r16, VCPU_GPR(R16)(vcpu); \
|
|
|
|
PPC_LL r17, VCPU_GPR(R17)(vcpu); \
|
|
|
|
PPC_LL r18, VCPU_GPR(R18)(vcpu); \
|
|
|
|
PPC_LL r19, VCPU_GPR(R19)(vcpu); \
|
|
|
|
PPC_LL r20, VCPU_GPR(R20)(vcpu); \
|
|
|
|
PPC_LL r21, VCPU_GPR(R21)(vcpu); \
|
|
|
|
PPC_LL r22, VCPU_GPR(R22)(vcpu); \
|
|
|
|
PPC_LL r23, VCPU_GPR(R23)(vcpu); \
|
|
|
|
PPC_LL r24, VCPU_GPR(R24)(vcpu); \
|
|
|
|
PPC_LL r25, VCPU_GPR(R25)(vcpu); \
|
|
|
|
PPC_LL r26, VCPU_GPR(R26)(vcpu); \
|
|
|
|
PPC_LL r27, VCPU_GPR(R27)(vcpu); \
|
|
|
|
PPC_LL r28, VCPU_GPR(R28)(vcpu); \
|
|
|
|
PPC_LL r29, VCPU_GPR(R29)(vcpu); \
|
|
|
|
PPC_LL r30, VCPU_GPR(R30)(vcpu); \
|
|
|
|
PPC_LL r31, VCPU_GPR(R31)(vcpu); \
|
2010-01-05 00:19:25 +03:00
|
|
|
|
2009-10-30 08:47:07 +03:00
|
|
|
/*****************************************************************************
|
|
|
|
* *
|
|
|
|
* Guest entry / exit code that is in kernel module memory (highmem) *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* Registers:
|
|
|
|
* r3: kvm_run pointer
|
|
|
|
* r4: vcpu pointer
|
|
|
|
*/
|
2011-06-29 04:19:50 +04:00
|
|
|
_GLOBAL(__kvmppc_vcpu_run)
|
2009-10-30 08:47:07 +03:00
|
|
|
|
|
|
|
kvm_start_entry:
|
|
|
|
/* Write correct stack frame */
|
2010-04-16 02:11:47 +04:00
|
|
|
mflr r0
|
|
|
|
PPC_STL r0,PPC_LR_STKOFF(r1)
|
2009-10-30 08:47:07 +03:00
|
|
|
|
|
|
|
/* Save host state to the stack */
|
2010-04-16 02:11:47 +04:00
|
|
|
PPC_STLU r1, -SWITCH_FRAME_SIZE(r1)
|
2009-10-30 08:47:07 +03:00
|
|
|
|
|
|
|
/* Save r3 (kvm_run) and r4 (vcpu) */
|
|
|
|
SAVE_2GPRS(3, r1)
|
|
|
|
|
|
|
|
/* Save non-volatile registers (r14 - r31) */
|
|
|
|
SAVE_NVGPRS(r1)
|
|
|
|
|
2012-03-05 19:00:28 +04:00
|
|
|
/* Save CR */
|
|
|
|
mfcr r14
|
|
|
|
stw r14, _CCR(r1)
|
|
|
|
|
2009-10-30 08:47:07 +03:00
|
|
|
/* Save LR */
|
2010-04-16 02:11:47 +04:00
|
|
|
PPC_STL r0, _LINK(r1)
|
2010-01-05 00:19:25 +03:00
|
|
|
|
|
|
|
/* Load non-volatile guest state from the vcpu */
|
|
|
|
VCPU_LOAD_NVGPRS(r4)
|
2009-10-30 08:47:07 +03:00
|
|
|
|
2011-06-29 04:20:58 +04:00
|
|
|
kvm_start_lightweight:
|
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>
2013-09-20 08:52:43 +04:00
|
|
|
/* Copy registers into shadow vcpu so we can access them in real mode */
|
2018-02-01 00:24:58 +03:00
|
|
|
mr r3, r4
|
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>
2013-09-20 08:52:43 +04:00
|
|
|
bl FUNC(kvmppc_copy_to_svcpu)
|
|
|
|
nop
|
|
|
|
REST_GPR(4, r1)
|
2010-01-08 04:58:03 +03:00
|
|
|
|
2010-04-16 02:11:47 +04:00
|
|
|
#ifdef CONFIG_PPC_BOOK3S_64
|
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>
2013-09-20 08:52:43 +04:00
|
|
|
/* Get the dcbz32 flag */
|
2010-04-16 02:11:47 +04:00
|
|
|
PPC_LL r3, VCPU_HFLAGS(r4)
|
2011-07-23 11:41:44 +04:00
|
|
|
rldicl r3, r3, 0, 63 /* r3 &= 1 */
|
|
|
|
stb r3, HSTATE_RESTORE_HID5(r13)
|
2013-07-11 15:49:43 +04:00
|
|
|
|
|
|
|
/* Load up guest SPRG3 value, since it's user readable */
|
2014-04-24 15:46:24 +04:00
|
|
|
lwz r3, VCPU_SHAREDBE(r4)
|
|
|
|
cmpwi r3, 0
|
|
|
|
ld r5, VCPU_SHARED(r4)
|
|
|
|
beq sprg3_little_endian
|
|
|
|
sprg3_big_endian:
|
|
|
|
#ifdef __BIG_ENDIAN__
|
|
|
|
ld r3, VCPU_SHARED_SPRG3(r5)
|
|
|
|
#else
|
|
|
|
addi r5, r5, VCPU_SHARED_SPRG3
|
|
|
|
ldbrx r3, 0, r5
|
|
|
|
#endif
|
|
|
|
b after_sprg3_load
|
|
|
|
sprg3_little_endian:
|
|
|
|
#ifdef __LITTLE_ENDIAN__
|
|
|
|
ld r3, VCPU_SHARED_SPRG3(r5)
|
|
|
|
#else
|
|
|
|
addi r5, r5, VCPU_SHARED_SPRG3
|
|
|
|
ldbrx r3, 0, r5
|
|
|
|
#endif
|
|
|
|
|
|
|
|
after_sprg3_load:
|
2013-07-11 15:49:43 +04:00
|
|
|
mtspr SPRN_SPRG3, r3
|
2010-04-16 02:11:47 +04:00
|
|
|
#endif /* CONFIG_PPC_BOOK3S_64 */
|
|
|
|
|
2011-07-23 11:41:44 +04:00
|
|
|
PPC_LL r4, VCPU_SHADOW_MSR(r4) /* get shadow_msr */
|
2010-01-08 04:58:03 +03:00
|
|
|
|
2010-04-16 02:11:47 +04:00
|
|
|
/* Jump to segment patching handler and into our guest */
|
2011-07-23 11:41:44 +04:00
|
|
|
bl FUNC(kvmppc_entry_trampoline)
|
|
|
|
nop
|
2009-10-30 08:47:07 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the handler in module memory. It gets jumped at from the
|
|
|
|
* lowmem trampoline code, so it's basically the guest exit code.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Register usage at this point:
|
|
|
|
*
|
2010-04-16 02:11:47 +04:00
|
|
|
* R1 = host R1
|
|
|
|
* R2 = host R2
|
|
|
|
* R12 = exit handler id
|
|
|
|
* R13 = PACA
|
|
|
|
* SVCPU.* = guest *
|
2013-11-29 05:32:31 +04:00
|
|
|
* MSR.EE = 1
|
2009-10-30 08:47:07 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-11-29 05:24:18 +04:00
|
|
|
PPC_LL r3, GPR4(r1) /* vcpu pointer */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* kvmppc_copy_from_svcpu can clobber volatile registers, save
|
|
|
|
* the exit handler id to the vcpu and restore it from there later.
|
|
|
|
*/
|
|
|
|
stw r12, VCPU_TRAP(r3)
|
|
|
|
|
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>
2013-09-20 08:52:43 +04:00
|
|
|
/* Transfer reg values from shadow vcpu back to vcpu struct */
|
2013-11-29 05:24:18 +04:00
|
|
|
|
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>
2013-09-20 08:52:43 +04:00
|
|
|
bl FUNC(kvmppc_copy_from_svcpu)
|
|
|
|
nop
|
2009-10-30 08:47:07 +03:00
|
|
|
|
2013-07-11 15:49:43 +04:00
|
|
|
#ifdef CONFIG_PPC_BOOK3S_64
|
|
|
|
/*
|
|
|
|
* Reload kernel SPRG3 value.
|
|
|
|
* No need to save guest value as usermode can't modify SPRG3.
|
|
|
|
*/
|
2014-03-11 02:29:38 +04:00
|
|
|
ld r3, PACA_SPRG_VDSO(r13)
|
|
|
|
mtspr SPRN_SPRG_VDSO_WRITE, r3
|
2013-07-11 15:49:43 +04:00
|
|
|
#endif /* CONFIG_PPC_BOOK3S_64 */
|
|
|
|
|
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>
2013-09-20 08:52:43 +04:00
|
|
|
/* R7 = vcpu */
|
|
|
|
PPC_LL r7, GPR4(r1)
|
|
|
|
|
2012-06-25 17:33:10 +04:00
|
|
|
PPC_STL r14, VCPU_GPR(R14)(r7)
|
|
|
|
PPC_STL r15, VCPU_GPR(R15)(r7)
|
|
|
|
PPC_STL r16, VCPU_GPR(R16)(r7)
|
|
|
|
PPC_STL r17, VCPU_GPR(R17)(r7)
|
|
|
|
PPC_STL r18, VCPU_GPR(R18)(r7)
|
|
|
|
PPC_STL r19, VCPU_GPR(R19)(r7)
|
|
|
|
PPC_STL r20, VCPU_GPR(R20)(r7)
|
|
|
|
PPC_STL r21, VCPU_GPR(R21)(r7)
|
|
|
|
PPC_STL r22, VCPU_GPR(R22)(r7)
|
|
|
|
PPC_STL r23, VCPU_GPR(R23)(r7)
|
|
|
|
PPC_STL r24, VCPU_GPR(R24)(r7)
|
|
|
|
PPC_STL r25, VCPU_GPR(R25)(r7)
|
|
|
|
PPC_STL r26, VCPU_GPR(R26)(r7)
|
|
|
|
PPC_STL r27, VCPU_GPR(R27)(r7)
|
|
|
|
PPC_STL r28, VCPU_GPR(R28)(r7)
|
|
|
|
PPC_STL r29, VCPU_GPR(R29)(r7)
|
|
|
|
PPC_STL r30, VCPU_GPR(R30)(r7)
|
|
|
|
PPC_STL r31, VCPU_GPR(R31)(r7)
|
2009-10-30 08:47:07 +03:00
|
|
|
|
2010-01-05 00:19:25 +03:00
|
|
|
/* Pass the exit number as 3rd argument to kvmppc_handle_exit */
|
2013-11-29 05:24:18 +04:00
|
|
|
lwz r5, VCPU_TRAP(r7)
|
2010-01-05 00:19:25 +03:00
|
|
|
|
2009-10-30 08:47:07 +03:00
|
|
|
/* Restore r3 (kvm_run) and r4 (vcpu) */
|
|
|
|
REST_2GPRS(3, r1)
|
2013-10-07 20:47:53 +04:00
|
|
|
bl FUNC(kvmppc_handle_exit_pr)
|
2009-10-30 08:47:07 +03:00
|
|
|
|
2010-01-05 00:19:25 +03:00
|
|
|
/* If RESUME_GUEST, get back in the loop */
|
2009-10-30 08:47:07 +03:00
|
|
|
cmpwi r3, RESUME_GUEST
|
2010-01-05 00:19:25 +03:00
|
|
|
beq kvm_loop_lightweight
|
2009-10-30 08:47:07 +03:00
|
|
|
|
2010-01-05 00:19:25 +03:00
|
|
|
cmpwi r3, RESUME_GUEST_NV
|
|
|
|
beq kvm_loop_heavyweight
|
2009-10-30 08:47:07 +03:00
|
|
|
|
2010-01-05 00:19:25 +03:00
|
|
|
kvm_exit_loop:
|
2009-10-30 08:47:07 +03:00
|
|
|
|
2010-04-16 02:11:47 +04:00
|
|
|
PPC_LL r4, _LINK(r1)
|
2009-10-30 08:47:07 +03:00
|
|
|
mtlr r4
|
|
|
|
|
2012-03-05 19:00:28 +04:00
|
|
|
lwz r14, _CCR(r1)
|
|
|
|
mtcr r14
|
|
|
|
|
2010-01-05 00:19:25 +03:00
|
|
|
/* Restore non-volatile host registers (r14 - r31) */
|
|
|
|
REST_NVGPRS(r1)
|
|
|
|
|
|
|
|
addi r1, r1, SWITCH_FRAME_SIZE
|
|
|
|
blr
|
|
|
|
|
|
|
|
kvm_loop_heavyweight:
|
2009-10-30 08:47:07 +03:00
|
|
|
|
2010-04-16 02:11:47 +04:00
|
|
|
PPC_LL r4, _LINK(r1)
|
|
|
|
PPC_STL r4, (PPC_LR_STKOFF + SWITCH_FRAME_SIZE)(r1)
|
2010-01-05 00:19:25 +03:00
|
|
|
|
|
|
|
/* Load vcpu and cpu_run */
|
2009-10-30 08:47:07 +03:00
|
|
|
REST_2GPRS(3, r1)
|
|
|
|
|
2010-01-05 00:19:25 +03:00
|
|
|
/* Load non-volatile guest state from the vcpu */
|
|
|
|
VCPU_LOAD_NVGPRS(r4)
|
2009-10-30 08:47:07 +03:00
|
|
|
|
2010-01-05 00:19:25 +03:00
|
|
|
/* Jump back into the beginning of this function */
|
|
|
|
b kvm_start_lightweight
|
2009-10-30 08:47:07 +03:00
|
|
|
|
2010-01-05 00:19:25 +03:00
|
|
|
kvm_loop_lightweight:
|
2009-10-30 08:47:07 +03:00
|
|
|
|
2010-01-05 00:19:25 +03:00
|
|
|
/* We'll need the vcpu pointer */
|
|
|
|
REST_GPR(4, r1)
|
|
|
|
|
|
|
|
/* Jump back into the beginning of this function */
|
|
|
|
b kvm_start_lightweight
|