public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: kvm-ppc@vger.kernel.org
Cc: kvm@vger.kernel.org, anton@samba.org
Subject: [PATCH 4/6] KVM: PPC: Book3S HV: Access host lppaca and shadow slb in BE
Date: Wed, 11 Jun 2014 12:33:49 +0200	[thread overview]
Message-ID: <1402482831-8941-5-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1402482831-8941-1-git-send-email-agraf@suse.de>

Some data structures are always stored in big endian. Among those are the LPPACA
fields as well as the shadow slb. These structures might be shared with a
hypervisor.

So whenever we access those fields, make sure we do so in big endian byte order.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/powerpc/kvm/book3s_hv_rmhandlers.S | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index 220aefb..3530d06 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -32,10 +32,6 @@
 
 #define VCPU_GPRS_TM(reg) (((reg) * ULONG_SIZE) + VCPU_GPR_TM)
 
-#ifdef __LITTLE_ENDIAN__
-#error Need to fix lppaca and SLB shadow accesses in little endian mode
-#endif
-
 /* Values in HSTATE_NAPPING(r13) */
 #define NAPPING_CEDE	1
 #define NAPPING_NOVCPU	2
@@ -585,9 +581,10 @@ kvmppc_got_guest:
 	ld	r3, VCPU_VPA(r4)
 	cmpdi	r3, 0
 	beq	25f
-	lwz	r5, LPPACA_YIELDCOUNT(r3)
+	li	r6, LPPACA_YIELDCOUNT
+	LWZX_BE	r5, r3, r6
 	addi	r5, r5, 1
-	stw	r5, LPPACA_YIELDCOUNT(r3)
+	STWX_BE	r5, r3, r6
 	li	r6, 1
 	stb	r6, VCPU_VPA_DIRTY(r4)
 25:
@@ -1328,9 +1325,10 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
 	ld	r8, VCPU_VPA(r9)	/* do they have a VPA? */
 	cmpdi	r8, 0
 	beq	25f
-	lwz	r3, LPPACA_YIELDCOUNT(r8)
+	li	r4, LPPACA_YIELDCOUNT
+	LWZX_BE	r3, r8, r4
 	addi	r3, r3, 1
-	stw	r3, LPPACA_YIELDCOUNT(r8)
+	STWX_BE	r3, r8, r4
 	li	r3, 1
 	stb	r3, VCPU_VPA_DIRTY(r9)
 25:
@@ -1643,8 +1641,10 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 33:	ld	r8,PACA_SLBSHADOWPTR(r13)
 
 	.rept	SLB_NUM_BOLTED
-	ld	r5,SLBSHADOW_SAVEAREA(r8)
-	ld	r6,SLBSHADOW_SAVEAREA+8(r8)
+	li	r3, SLBSHADOW_SAVEAREA
+	LDX_BE	r5, r8, r3
+	addi	r3, r3, 8
+	LDX_BE	r6, r8, r3
 	andis.	r7,r5,SLB_ESID_V@h
 	beq	1f
 	slbmte	r6,r5
-- 
1.8.1.4

  parent reply	other threads:[~2014-06-11 10:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-11 10:33 [PATCH 0/6] KVM: PPC: Book3S HV: Enable on little endian hosts Alexander Graf
2014-06-11 10:33 ` [PATCH 1/6] PPC: Add asm helpers for BE 32bit load/store Alexander Graf
2014-06-17  0:51   ` Paul Mackerras
2014-06-17  8:34     ` Alexander Graf
2014-06-11 10:33 ` [PATCH 2/6] KVM: PPC: Book3S HV: Make HTAB code LE host aware Alexander Graf
2014-06-11 10:33 ` [PATCH 3/6] KVM: PPC: Book3S HV: Access guest VPA in BE Alexander Graf
2014-06-11 10:33 ` Alexander Graf [this message]
2014-06-11 10:33 ` [PATCH 5/6] KVM: PPC: Book3S HV: Access XICS " Alexander Graf
2014-06-17  1:02   ` Paul Mackerras
2014-06-17  8:37     ` Alexander Graf
2014-06-17 10:22       ` Alexander Graf
2014-06-17 12:13         ` Paul Mackerras
2014-06-17 12:14           ` Alexander Graf
2014-06-11 10:33 ` [PATCH 6/6] KVM: PPC: Book3S HV: Enable for little endian hosts Alexander Graf
2014-06-16  4:22 ` [PATCH 0/6] KVM: PPC: Book3S HV: Enable on " Aneesh Kumar K.V
2014-06-16 12:17   ` Alexander Graf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1402482831-8941-5-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=anton@samba.org \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox