kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: kvm-ppc@vger.kernel.org
Cc: kvm@vger.kernel.org
Subject: [PULL 19/63] KVM: PPC: Book3S HV: Access host lppaca and shadow slb in BE
Date: Fri,  1 Aug 2014 11:17:50 +0200	[thread overview]
Message-ID: <1406884714-33099-20-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1406884714-33099-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 e66c1e38..bf5270e 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
@@ -595,9 +591,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:
@@ -1442,9 +1439,10 @@ END_FTR_SECTION_IFCLR(CPU_FTR_TM)
 	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:
@@ -1757,8 +1755,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-08-01  9:18 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-01  9:17 [PULL 00/63] ppc patch queue 2014-08-01 Alexander Graf
2014-08-01  9:17 ` [PULL 01/63] KVM: PPC: BOOK3S: PR: Fix PURR and SPURR emulation Alexander Graf
2014-08-01  9:17 ` [PULL 02/63] KVM: PPC: BOOK3S: PR: Emulate virtual timebase register Alexander Graf
2014-08-01  9:17 ` [PULL 03/63] KVM: PPC: BOOK3S: PR: Emulate instruction counter Alexander Graf
2014-08-01  9:17 ` [PULL 04/63] KVM: PPC: Book3s PR: Disable AIL mode with OPAL Alexander Graf
2014-08-01  9:17 ` [PULL 05/63] KVM: PPC: Book3s HV: Fix tlbie compile error Alexander Graf
2014-08-01  9:17 ` [PULL 06/63] KVM: PPC: Book3S PR: Handle hyp doorbell exits Alexander Graf
2014-08-01  9:17 ` [PULL 07/63] KVM: PPC: Book3S HV: Fix ABIv2 indirect branch issue Alexander Graf
2014-08-01  9:17 ` [PULL 08/63] KVM: PPC: Assembly functions exported to modules need _GLOBAL_TOC() Alexander Graf
2014-08-01  9:17 ` [PULL 09/63] KVM: PPC: Book3S PR: Fix ABIv2 on LE Alexander Graf
2014-08-01  9:17 ` [PULL 10/63] KVM: PPC: Book3S PR: Fix sparse endian checks Alexander Graf
2014-08-01  9:17 ` [PULL 11/63] KVM: PPC: e500mc: Enhance tlb invalidation condition on vcpu schedule Alexander Graf
2014-08-01  9:17 ` [PULL 12/63] KVM: PPC: Book3S: Controls for in-kernel sPAPR hypercall handling Alexander Graf
2014-08-01  9:17 ` [PULL 13/63] KVM: PPC: Book3S: Allow only implemented hcalls to be enabled or disabled Alexander Graf
2014-08-01  9:17 ` [PULL 14/63] KVM: PPC: Book3S HV: Add H_SET_MODE hcall handling Alexander Graf
2014-08-01  9:17 ` [PULL 15/63] KVM: PPC: e500: Fix default tlb for victim hint Alexander Graf
2014-08-01  9:17 ` [PULL 16/63] PPC: Add asm helpers for BE 32bit load/store Alexander Graf
2014-08-01 10:19   ` Benjamin Herrenschmidt
2014-08-01  9:17 ` [PULL 17/63] KVM: PPC: Book3S HV: Make HTAB code LE host aware Alexander Graf
2014-08-01  9:17 ` [PULL 18/63] KVM: PPC: Book3S HV: Access guest VPA in BE Alexander Graf
2014-08-01  9:17 ` Alexander Graf [this message]
2014-08-01  9:17 ` [PULL 20/63] KVM: PPC: Book3S HV: Access XICS " Alexander Graf
2014-08-01  9:17 ` [PULL 21/63] KVM: PPC: Book3S HV: Fix ABIv2 on LE Alexander Graf
2014-08-01  9:17 ` [PULL 22/63] KVM: PPC: Book3S HV: Enable for little endian hosts Alexander Graf
2014-08-01  9:17 ` [PULL 23/63] KVM: PPC: e500: Emulate power management control SPR Alexander Graf
2014-08-01  9:17 ` [PULL 24/63] KVM: PPC: Book3S: Move vcore definition to end of kvm_arch struct Alexander Graf
2014-08-01  9:17 ` [PULL 25/63] KVM: PPC: Deflect page write faults properly in kvmppc_st Alexander Graf
2014-08-01  9:17 ` [PULL 26/63] KVM: PPC: Book3S: Stop PTE lookup on write errors Alexander Graf
2014-08-01  9:17 ` [PULL 27/63] KVM: PPC: Book3S: Add hack for split real mode Alexander Graf
2014-08-01  9:17 ` [PULL 28/63] KVM: PPC: Book3S: Make magic page properly 4k mappable Alexander Graf
2014-08-01  9:18 ` [PULL 29/63] kvm: ppc: bookehv: Added wrapper macros for shadow registers Alexander Graf
2014-08-01  9:18 ` [PULL 30/63] kvm: ppc: booke: Use the shared struct helpers of SRR0 and SRR1 Alexander Graf
2014-08-01  9:18 ` [PULL 31/63] kvm: ppc: booke: Use the shared struct helpers of SPRN_DEAR Alexander Graf
2014-08-01  9:18 ` [PULL 32/63] kvm: ppc: booke: Add shared struct helpers of SPRN_ESR Alexander Graf
2014-08-01  9:18 ` [PULL 33/63] kvm: ppc: booke: Use the shared struct helpers for SPRN_SPRG0-7 Alexander Graf
2014-08-01  9:18 ` [PULL 34/63] kvm: ppc: Add SPRN_EPR get helper function Alexander Graf
2014-08-01  9:18 ` [PULL 35/63] KVM: PPC: e500mc: Revert "add load inst fixup" Alexander Graf
2014-08-01  9:18 ` [PULL 36/63] KVM: PPC: Book3e: Add TLBSEL/TSIZE defines for MAS0/1 Alexander Graf
2014-08-01  9:18 ` [PULL 37/63] KVM: PPC: Book3s: Remove kvmppc_read_inst() function Alexander Graf
2014-08-01  9:18 ` [PULL 38/63] KVM: PPC: Allow kvmppc_get_last_inst() to fail Alexander Graf
2014-08-01  9:18 ` [PULL 39/63] KVM: PPC: Bookehv: Get vcpu's last instruction for emulation Alexander Graf
2014-08-01  9:18 ` [PULL 40/63] kvm: ppc: bookehv: Save restore SPRN_SPRG9 on guest entry exit Alexander Graf
2014-08-01  9:18 ` [PULL 41/63] KVM: PPC: Booke-hv: Add one reg interface for SPRG9 Alexander Graf
2014-08-01  9:18 ` [PULL 42/63] KVM: PPC: Remove comment saying SPRG1 is used for vcpu pointer Alexander Graf
2014-08-01  9:18 ` [PULL 43/63] KVM: PPC: Remove 440 support Alexander Graf
2014-08-01  9:18 ` [PULL 44/63] KVM: PPC: Book3S: Fix LPCR one_reg interface Alexander Graf
2014-08-01  9:18 ` [PULL 45/63] KVM: PPC: Book3S PR: Take SRCU read lock around RTAS kvm_read_guest() call Alexander Graf
2014-08-01  9:18 ` [PULL 46/63] KVM: PPC: Book3S: Make kvmppc_ld return a more accurate error indication Alexander Graf
2014-08-01  9:18 ` [PULL 47/63] Split out struct kvmppc_vcore creation to separate function Alexander Graf
2014-08-01  9:18 ` [PULL 48/63] Use the POWER8 Micro Partition Prefetch Engine in KVM HV on POWER8 Alexander Graf
2014-08-01  9:18 ` [PULL 49/63] KVM: Rename and add argument to check_extension Alexander Graf
2014-08-01  9:18 ` [PULL 50/63] KVM: Allow KVM_CHECK_EXTENSION on the vm fd Alexander Graf
2014-08-01  9:18 ` [PULL 51/63] KVM: PPC: Book3S: Provide different CAPs based on HV or PR mode Alexander Graf
2014-08-01  9:18 ` [PULL 52/63] KVM: PPC: BOOK3S: HV: Update compute_tlbie_rb to handle 16MB base page Alexander Graf
2014-08-01  9:18 ` [PULL 53/63] KVM: PPC: Implement kvmppc_xlate for all targets Alexander Graf
2014-08-01  9:18 ` [PULL 54/63] KVM: PPC: Move kvmppc_ld/st to common code Alexander Graf
2014-08-01  9:18 ` [PULL 55/63] KVM: PPC: Remove kvmppc_bad_hva() Alexander Graf
2014-08-01  9:18 ` [PULL 56/63] KVM: PPC: Use kvm_read_guest in kvmppc_ld Alexander Graf
2014-08-01  9:18 ` [PULL 57/63] KVM: PPC: Handle magic page in kvmppc_ld/st Alexander Graf
2014-08-01  9:18 ` [PULL 58/63] KVM: PPC: Separate loadstore emulation from priv emulation Alexander Graf
2014-08-01  9:18 ` [PULL 59/63] KVM: PPC: Expose helper functions for data/inst faults Alexander Graf
2014-08-01  9:18 ` [PULL 60/63] KVM: PPC: Remove DCR handling Alexander Graf
2014-08-01  9:18 ` [PULL 61/63] KVM: PPC: BOOKEHV: rename e500hv_spr to bookehv_spr Alexander Graf
2014-08-01  9:18 ` [PULL 62/63] KVM: PPC: HV: Remove generic instruction emulation Alexander Graf
2014-08-01  9:18 ` [PULL 63/63] KVM: PPC: PR: Handle FSCR feature deselects 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=1406884714-33099-20-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --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;
as well as URLs for NNTP newsgroup(s).