diff options
author | Alexander Graf <agraf@suse.de> | 2012-03-05 10:00:28 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2012-04-08 07:01:02 -0400 |
commit | f6127716c346c73ab1513edee53231800188c5ba (patch) | |
tree | 3b3867d5fb239c2f03f0011cb752e6d816f853f9 | |
parent | 3aaefef200f618dc455cdf18053a7aeb262b5a11 (diff) |
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: Avi Kivity <avi@redhat.com>
-rw-r--r-- | arch/powerpc/kvm/bookehv_interrupts.S | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/arch/powerpc/kvm/bookehv_interrupts.S b/arch/powerpc/kvm/bookehv_interrupts.S index 2d1f56cad48c..57e2fa414444 100644 --- a/arch/powerpc/kvm/bookehv_interrupts.S +++ b/arch/powerpc/kvm/bookehv_interrupts.S | |||
@@ -49,7 +49,8 @@ | |||
49 | * kernel with the -ffixed-r2 gcc option. | 49 | * kernel with the -ffixed-r2 gcc option. |
50 | */ | 50 | */ |
51 | #define HOST_R2 (3 * LONGBYTES) | 51 | #define HOST_R2 (3 * LONGBYTES) |
52 | #define HOST_NV_GPRS (4 * LONGBYTES) | 52 | #define HOST_CR (4 * LONGBYTES) |
53 | #define HOST_NV_GPRS (5 * LONGBYTES) | ||
53 | #define HOST_NV_GPR(n) (HOST_NV_GPRS + ((n - 14) * LONGBYTES)) | 54 | #define HOST_NV_GPR(n) (HOST_NV_GPRS + ((n - 14) * LONGBYTES)) |
54 | #define HOST_MIN_STACK_SIZE (HOST_NV_GPR(31) + LONGBYTES) | 55 | #define HOST_MIN_STACK_SIZE (HOST_NV_GPR(31) + LONGBYTES) |
55 | #define HOST_STACK_SIZE ((HOST_MIN_STACK_SIZE + 15) & ~15) /* Align. */ | 56 | #define HOST_STACK_SIZE ((HOST_MIN_STACK_SIZE + 15) & ~15) /* Align. */ |
@@ -396,6 +397,7 @@ skip_nv_load: | |||
396 | heavyweight_exit: | 397 | heavyweight_exit: |
397 | /* Not returning to guest. */ | 398 | /* Not returning to guest. */ |
398 | PPC_LL r5, HOST_STACK_LR(r1) | 399 | PPC_LL r5, HOST_STACK_LR(r1) |
400 | lwz r6, HOST_CR(r1) | ||
399 | 401 | ||
400 | /* | 402 | /* |
401 | * We already saved guest volatile register state; now save the | 403 | * We already saved guest volatile register state; now save the |
@@ -442,6 +444,7 @@ heavyweight_exit: | |||
442 | 444 | ||
443 | /* Return to kvm_vcpu_run(). */ | 445 | /* Return to kvm_vcpu_run(). */ |
444 | mtlr r5 | 446 | mtlr r5 |
447 | mtcr r6 | ||
445 | addi r1, r1, HOST_STACK_SIZE | 448 | addi r1, r1, HOST_STACK_SIZE |
446 | /* r3 still contains the return code from kvmppc_handle_exit(). */ | 449 | /* r3 still contains the return code from kvmppc_handle_exit(). */ |
447 | blr | 450 | blr |
@@ -457,8 +460,11 @@ _GLOBAL(__kvmppc_vcpu_run) | |||
457 | /* Save host state to stack. */ | 460 | /* Save host state to stack. */ |
458 | PPC_STL r3, HOST_RUN(r1) | 461 | PPC_STL r3, HOST_RUN(r1) |
459 | mflr r3 | 462 | mflr r3 |
463 | mfcr r5 | ||
460 | PPC_STL r3, HOST_STACK_LR(r1) | 464 | PPC_STL r3, HOST_STACK_LR(r1) |
461 | 465 | ||
466 | stw r5, HOST_CR(r1) | ||
467 | |||
462 | /* Save host non-volatile register state to stack. */ | 468 | /* Save host non-volatile register state to stack. */ |
463 | PPC_STL r14, HOST_NV_GPR(r14)(r1) | 469 | PPC_STL r14, HOST_NV_GPR(r14)(r1) |
464 | PPC_STL r15, HOST_NV_GPR(r15)(r1) | 470 | PPC_STL r15, HOST_NV_GPR(r15)(r1) |