* [PATCH v2] KVM: PPC: bookehv: Fix save/restore of guest accessible SPRGs.
@ 2012-04-13 11:19 Varun Sethi
2012-04-13 14:15 ` Scott Wood
0 siblings, 1 reply; 2+ messages in thread
From: Varun Sethi @ 2012-04-13 11:19 UTC (permalink / raw)
To: kvm-ppc
For Guest accessible SPRGs 4-7, save/restore must be handled differently for 64bit and
non-64 bit case. The registers are maintained as 64 bit copies by KVM. While saving/restoring
for the non-64 bit case we should always take the lower 4 bytes.
Signed-off-by: Varun Sethi <Varun.Sethi@freescale.com>
---
arch/powerpc/kvm/bookehv_interrupts.S | 24 ++++++++++++++++--------
1 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/kvm/bookehv_interrupts.S b/arch/powerpc/kvm/bookehv_interrupts.S
index 909e96e..98751af 100644
--- a/arch/powerpc/kvm/bookehv_interrupts.S
+++ b/arch/powerpc/kvm/bookehv_interrupts.S
@@ -40,6 +40,14 @@
#define VCPU_GPR(n) (VCPU_GPRS + (n * LONGBYTES))
#define VCPU_GUEST_SPRG(n) (VCPU_GUEST_SPRGS + (n * LONGBYTES))
+#ifdef CONFIG_64BIT
+#define PPC_STD(sreg, offset, areg) std sreg, offset(areg)
+#define PPC_LD(treg, offset, areg) ld treg, offset(areg)
+#else
+#define PPC_STD(sreg, offset, areg) stw sreg, offset+4(areg)
+#define PPC_LD(treg, offset, areg) lwz treg, offset+4(areg)
+#endif
+
/* The host stack layout: */
#define HOST_R1 (0 * LONGBYTES) /* Implied by stwu. */
#define HOST_CALLEE_LR (1 * LONGBYTES)
@@ -320,13 +328,13 @@ _GLOBAL(kvmppc_resume_host)
PPC_STL r5, VCPU_LR(r4)
mfspr r7, SPRN_SPRG5
PPC_STL r3, VCPU_VRSAVE(r4)
- PPC_STL r6, VCPU_SHARED_SPRG4(r11)
+ PPC_STD(r6, VCPU_SHARED_SPRG4, r11)
mfspr r8, SPRN_SPRG6
- PPC_STL r7, VCPU_SHARED_SPRG5(r11)
+ PPC_STD(r7, VCPU_SHARED_SPRG5, r11)
mfspr r9, SPRN_SPRG7
- PPC_STL r8, VCPU_SHARED_SPRG6(r11)
+ PPC_STD(r8, VCPU_SHARED_SPRG6, r11)
mfxer r3
- PPC_STL r9, VCPU_SHARED_SPRG7(r11)
+ PPC_STD(r9, VCPU_SHARED_SPRG7, r11)
/* save guest MAS registers and restore host mas4 & mas6 */
mfspr r5, SPRN_MAS0
@@ -549,13 +557,13 @@ lightweight_exit:
* SPRGs, so we need to reload them here with the guest's values.
*/
lwz r3, VCPU_VRSAVE(r4)
- lwz r5, VCPU_SHARED_SPRG4(r11)
+ PPC_LD(r5, VCPU_SHARED_SPRG4, r11)
mtspr SPRN_VRSAVE, r3
- lwz r6, VCPU_SHARED_SPRG5(r11)
+ PPC_LD(r6, VCPU_SHARED_SPRG5, r11)
mtspr SPRN_SPRG4W, r5
- lwz r7, VCPU_SHARED_SPRG6(r11)
+ PPC_LD(r7, VCPU_SHARED_SPRG6, r11)
mtspr SPRN_SPRG5W, r6
- lwz r8, VCPU_SHARED_SPRG7(r11)
+ PPC_LD(r8, VCPU_SHARED_SPRG7, r11)
mtspr SPRN_SPRG6W, r7
mtspr SPRN_SPRG7W, r8
--
1.7.2.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] KVM: PPC: bookehv: Fix save/restore of guest accessible SPRGs.
2012-04-13 11:19 [PATCH v2] KVM: PPC: bookehv: Fix save/restore of guest accessible SPRGs Varun Sethi
@ 2012-04-13 14:15 ` Scott Wood
0 siblings, 0 replies; 2+ messages in thread
From: Scott Wood @ 2012-04-13 14:15 UTC (permalink / raw)
To: kvm-ppc
On 04/13/2012 06:07 AM, Varun Sethi wrote:
> For Guest accessible SPRGs 4-7, save/restore must be handled differently for 64bit and
> non-64 bit case. The registers are maintained as 64 bit copies by KVM. While saving/restoring
> for the non-64 bit case we should always take the lower 4 bytes.
>
> Signed-off-by: Varun Sethi<Varun.Sethi@freescale.com>
> ---
> arch/powerpc/kvm/bookehv_interrupts.S | 24 ++++++++++++++++--------
> 1 files changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/arch/powerpc/kvm/bookehv_interrupts.S b/arch/powerpc/kvm/bookehv_interrupts.S
> index 909e96e..98751af 100644
> --- a/arch/powerpc/kvm/bookehv_interrupts.S
> +++ b/arch/powerpc/kvm/bookehv_interrupts.S
> @@ -40,6 +40,14 @@
> #define VCPU_GPR(n) (VCPU_GPRS + (n * LONGBYTES))
> #define VCPU_GUEST_SPRG(n) (VCPU_GUEST_SPRGS + (n * LONGBYTES))
>
> +#ifdef CONFIG_64BIT
> +#define PPC_STD(sreg, offset, areg) std sreg, offset(areg)
> +#define PPC_LD(treg, offset, areg) ld treg, offset(areg)
> +#else
> +#define PPC_STD(sreg, offset, areg) stw sreg, offset+4(areg)
> +#define PPC_LD(treg, offset, areg) lwz treg, offset+4(areg)
Please use parentheses around "offset".
-Scott
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-04-13 14:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-13 11:19 [PATCH v2] KVM: PPC: bookehv: Fix save/restore of guest accessible SPRGs Varun Sethi
2012-04-13 14:15 ` Scott Wood
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox