KVM: PPC: Save/Restore CR over vcpu_run
On PPC, CR2-CR4 are nonvolatile, thus have to be saved across function calls. We didn't respect that for any architecture until Paul spotted it in his patch for Book3S-HV. This patch saves/restores CR for all KVM capable PPC hosts. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
Родитель
a5ddea0e78
Коммит
e1f8acf838
|
@ -84,6 +84,10 @@ kvm_start_entry:
|
||||||
/* Save non-volatile registers (r14 - r31) */
|
/* Save non-volatile registers (r14 - r31) */
|
||||||
SAVE_NVGPRS(r1)
|
SAVE_NVGPRS(r1)
|
||||||
|
|
||||||
|
/* Save CR */
|
||||||
|
mfcr r14
|
||||||
|
stw r14, _CCR(r1)
|
||||||
|
|
||||||
/* Save LR */
|
/* Save LR */
|
||||||
PPC_STL r0, _LINK(r1)
|
PPC_STL r0, _LINK(r1)
|
||||||
|
|
||||||
|
@ -165,6 +169,9 @@ kvm_exit_loop:
|
||||||
PPC_LL r4, _LINK(r1)
|
PPC_LL r4, _LINK(r1)
|
||||||
mtlr r4
|
mtlr r4
|
||||||
|
|
||||||
|
lwz r14, _CCR(r1)
|
||||||
|
mtcr r14
|
||||||
|
|
||||||
/* Restore non-volatile host registers (r14 - r31) */
|
/* Restore non-volatile host registers (r14 - r31) */
|
||||||
REST_NVGPRS(r1)
|
REST_NVGPRS(r1)
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,8 @@
|
||||||
/* r2 is special: it holds 'current', and it made nonvolatile in the
|
/* r2 is special: it holds 'current', and it made nonvolatile in the
|
||||||
* kernel with the -ffixed-r2 gcc option. */
|
* kernel with the -ffixed-r2 gcc option. */
|
||||||
#define HOST_R2 12
|
#define HOST_R2 12
|
||||||
#define HOST_NV_GPRS 16
|
#define HOST_CR 16
|
||||||
|
#define HOST_NV_GPRS 20
|
||||||
#define HOST_NV_GPR(n) (HOST_NV_GPRS + ((n - 14) * 4))
|
#define HOST_NV_GPR(n) (HOST_NV_GPRS + ((n - 14) * 4))
|
||||||
#define HOST_MIN_STACK_SIZE (HOST_NV_GPR(31) + 4)
|
#define HOST_MIN_STACK_SIZE (HOST_NV_GPR(31) + 4)
|
||||||
#define HOST_STACK_SIZE (((HOST_MIN_STACK_SIZE + 15) / 16) * 16) /* Align. */
|
#define HOST_STACK_SIZE (((HOST_MIN_STACK_SIZE + 15) / 16) * 16) /* Align. */
|
||||||
|
@ -296,8 +297,10 @@ heavyweight_exit:
|
||||||
|
|
||||||
/* Return to kvm_vcpu_run(). */
|
/* Return to kvm_vcpu_run(). */
|
||||||
lwz r4, HOST_STACK_LR(r1)
|
lwz r4, HOST_STACK_LR(r1)
|
||||||
|
lwz r5, HOST_CR(r1)
|
||||||
addi r1, r1, HOST_STACK_SIZE
|
addi r1, r1, HOST_STACK_SIZE
|
||||||
mtlr r4
|
mtlr r4
|
||||||
|
mtcr r5
|
||||||
/* r3 still contains the return code from kvmppc_handle_exit(). */
|
/* r3 still contains the return code from kvmppc_handle_exit(). */
|
||||||
blr
|
blr
|
||||||
|
|
||||||
|
@ -314,6 +317,8 @@ _GLOBAL(__kvmppc_vcpu_run)
|
||||||
stw r3, HOST_RUN(r1)
|
stw r3, HOST_RUN(r1)
|
||||||
mflr r3
|
mflr r3
|
||||||
stw r3, HOST_STACK_LR(r1)
|
stw r3, HOST_STACK_LR(r1)
|
||||||
|
mfcr r5
|
||||||
|
stw r5, HOST_CR(r1)
|
||||||
|
|
||||||
/* Save host non-volatile register state to stack. */
|
/* Save host non-volatile register state to stack. */
|
||||||
stw r14, HOST_NV_GPR(r14)(r1)
|
stw r14, HOST_NV_GPR(r14)(r1)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче