Skip to content

Commit

Permalink
KVM: PPC: Book3S HV: Save and restore CR in __kvmppc_vcore_entry
Browse files Browse the repository at this point in the history
The ABI specifies that CR fields CR2--CR4 are nonvolatile across function
calls.  Currently __kvmppc_vcore_entry doesn't save and restore the CR,
leading to CR2--CR4 getting corrupted with guest values, possibly leading
to incorrect behaviour in its caller.  This adds instructions to save
and restore CR at the points where we save and restore the nonvolatile
GPRs.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Paul Mackerras committed Apr 3, 2012
1 parent b4e5122 commit a5ddea0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions arch/powerpc/kvm/book3s_hv_interrupts.S
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ _GLOBAL(__kvmppc_vcore_entry)
/* Save host state to the stack */
stdu r1, -SWITCH_FRAME_SIZE(r1)

/* Save non-volatile registers (r14 - r31) */
/* Save non-volatile registers (r14 - r31) and CR */
SAVE_NVGPRS(r1)
mfcr r3
std r3, _CCR(r1)

/* Save host DSCR */
BEGIN_FTR_SECTION
Expand Down Expand Up @@ -157,8 +159,10 @@ kvmppc_handler_highmem:
* R13 = PACA
*/

/* Restore non-volatile host registers (r14 - r31) */
/* Restore non-volatile host registers (r14 - r31) and CR */
REST_NVGPRS(r1)
ld r4, _CCR(r1)
mtcr r4

addi r1, r1, SWITCH_FRAME_SIZE
ld r0, PPC_LR_STKOFF(r1)
Expand Down

0 comments on commit a5ddea0

Please sign in to comment.