From: Alexander Graf <agraf@suse.de> To: kvm-ppc@vger.kernel.org Cc: kvm@vger.kernel.org, anton@samba.org Subject: [PATCH 03/13] KVM: PPC: Book3S_32: PR: Access HTAB in big endian Date: Thu, 24 Apr 2014 15:12:30 +0200 [thread overview] Message-ID: <1398345160-4830-4-git-send-email-agraf@suse.de> (raw) In-Reply-To: <1398345160-4830-1-git-send-email-agraf@suse.de> The HTAB is always big endian. We access the guest's HTAB using copy_from/to_user, but don't yet take care of the fact that we might be running on an LE host. Wrap all accesses to the guest HTAB with big endian accessors. Signed-off-by: Alexander Graf <agraf@suse.de> --- arch/powerpc/kvm/book3s_32_mmu.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/kvm/book3s_32_mmu.c b/arch/powerpc/kvm/book3s_32_mmu.c index 60fc3f4..0e42b16 100644 --- a/arch/powerpc/kvm/book3s_32_mmu.c +++ b/arch/powerpc/kvm/book3s_32_mmu.c @@ -208,6 +208,7 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr, u32 sre; hva_t ptegp; u32 pteg[16]; + u32 pte0, pte1; u32 ptem = 0; int i; int found = 0; @@ -233,11 +234,13 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr, } for (i=0; i<16; i+=2) { - if (ptem == pteg[i]) { + pte0 = be32_to_cpu(pteg[i]); + pte1 = be32_to_cpu(pteg[i + 1]); + if (ptem == pte0) { u8 pp; - pte->raddr = (pteg[i+1] & ~(0xFFFULL)) | (eaddr & 0xFFF); - pp = pteg[i+1] & 3; + pte->raddr = (pte1 & ~(0xFFFULL)) | (eaddr & 0xFFF); + pp = pte1 & 3; if ((sr_kp(sre) && (vcpu->arch.shared->msr & MSR_PR)) || (sr_ks(sre) && !(vcpu->arch.shared->msr & MSR_PR))) @@ -260,7 +263,7 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr, } dprintk_pte("MMU: Found PTE -> %x %x - %x\n", - pteg[i], pteg[i+1], pp); + pte0, pte1, pp); found = 1; break; } @@ -269,7 +272,7 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr, /* Update PTE C and A bits, so the guest's swapper knows we used the page */ if (found) { - u32 pte_r = pteg[i+1]; + u32 pte_r = pte1; char __user *addr = (char __user *) (ptegp + (i+1) * sizeof(u32)); /* @@ -296,7 +299,8 @@ no_page_found: to_book3s(vcpu)->sdr1, ptegp); for (i=0; i<16; i+=2) { dprintk_pte(" %02d: 0x%x - 0x%x (0x%x)\n", - i, pteg[i], pteg[i+1], ptem); + i, be32_to_cpu(pteg[i]), + be32_to_cpu(pteg[i+1]), ptem); } } -- 1.8.1.4
WARNING: multiple messages have this Message-ID (diff)
From: Alexander Graf <agraf@suse.de> To: kvm-ppc@vger.kernel.org Cc: kvm@vger.kernel.org, anton@samba.org Subject: [PATCH 03/13] KVM: PPC: Book3S_32: PR: Access HTAB in big endian Date: Thu, 24 Apr 2014 13:12:30 +0000 [thread overview] Message-ID: <1398345160-4830-4-git-send-email-agraf@suse.de> (raw) In-Reply-To: <1398345160-4830-1-git-send-email-agraf@suse.de> The HTAB is always big endian. We access the guest's HTAB using copy_from/to_user, but don't yet take care of the fact that we might be running on an LE host. Wrap all accesses to the guest HTAB with big endian accessors. Signed-off-by: Alexander Graf <agraf@suse.de> --- arch/powerpc/kvm/book3s_32_mmu.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/kvm/book3s_32_mmu.c b/arch/powerpc/kvm/book3s_32_mmu.c index 60fc3f4..0e42b16 100644 --- a/arch/powerpc/kvm/book3s_32_mmu.c +++ b/arch/powerpc/kvm/book3s_32_mmu.c @@ -208,6 +208,7 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr, u32 sre; hva_t ptegp; u32 pteg[16]; + u32 pte0, pte1; u32 ptem = 0; int i; int found = 0; @@ -233,11 +234,13 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr, } for (i=0; i<16; i+=2) { - if (ptem = pteg[i]) { + pte0 = be32_to_cpu(pteg[i]); + pte1 = be32_to_cpu(pteg[i + 1]); + if (ptem = pte0) { u8 pp; - pte->raddr = (pteg[i+1] & ~(0xFFFULL)) | (eaddr & 0xFFF); - pp = pteg[i+1] & 3; + pte->raddr = (pte1 & ~(0xFFFULL)) | (eaddr & 0xFFF); + pp = pte1 & 3; if ((sr_kp(sre) && (vcpu->arch.shared->msr & MSR_PR)) || (sr_ks(sre) && !(vcpu->arch.shared->msr & MSR_PR))) @@ -260,7 +263,7 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr, } dprintk_pte("MMU: Found PTE -> %x %x - %x\n", - pteg[i], pteg[i+1], pp); + pte0, pte1, pp); found = 1; break; } @@ -269,7 +272,7 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr, /* Update PTE C and A bits, so the guest's swapper knows we used the page */ if (found) { - u32 pte_r = pteg[i+1]; + u32 pte_r = pte1; char __user *addr = (char __user *) (ptegp + (i+1) * sizeof(u32)); /* @@ -296,7 +299,8 @@ no_page_found: to_book3s(vcpu)->sdr1, ptegp); for (i=0; i<16; i+=2) { dprintk_pte(" %02d: 0x%x - 0x%x (0x%x)\n", - i, pteg[i], pteg[i+1], ptem); + i, be32_to_cpu(pteg[i]), + be32_to_cpu(pteg[i+1]), ptem); } } -- 1.8.1.4
next prev parent reply other threads:[~2014-04-24 13:12 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-04-24 13:12 [PATCH 00/13] PPC: KVM: Enable PR KVM on ppc64le Alexander Graf 2014-04-24 13:12 ` Alexander Graf 2014-04-24 13:12 ` [PATCH 01/13] KVM: PPC: Book3S PR: Implement LPCR ONE_REG Alexander Graf 2014-04-24 13:12 ` Alexander Graf 2014-04-24 13:12 ` [PATCH 02/13] KVM: PPC: Book3S: PR: Fix C/R bit setting Alexander Graf 2014-04-24 13:12 ` Alexander Graf 2014-05-10 7:11 ` Paul Mackerras 2014-05-10 7:11 ` Paul Mackerras 2014-04-24 13:12 ` Alexander Graf [this message] 2014-04-24 13:12 ` [PATCH 03/13] KVM: PPC: Book3S_32: PR: Access HTAB in big endian Alexander Graf 2014-04-24 13:12 ` [PATCH 04/13] KVM: PPC: Book3S_64 " Alexander Graf 2014-04-24 13:12 ` Alexander Graf 2014-04-24 13:12 ` [PATCH 05/13] KVM: PPC: Book3S_64 PR: Access shadow slb " Alexander Graf 2014-04-24 13:12 ` Alexander Graf 2014-04-24 13:12 ` [PATCH 06/13] KVM: PPC: Book3S PR: Give guest control over MSR_LE Alexander Graf 2014-04-24 13:12 ` Alexander Graf 2014-04-24 13:12 ` [PATCH 07/13] KVM: PPC: Book3S PR: Default to big endian guest Alexander Graf 2014-04-24 13:12 ` Alexander Graf 2014-04-24 13:12 ` [PATCH 08/13] KVM: PPC: Book3S PR: PAPR: Access HTAB in big endian Alexander Graf 2014-04-24 13:12 ` Alexander Graf 2014-04-24 13:12 ` [PATCH 09/13] KVM: PPC: Book3S PR: PAPR: Access RTAS " Alexander Graf 2014-04-24 13:12 ` Alexander Graf 2014-04-24 13:12 ` [PATCH 10/13] KVM: PPC: PR: Fill pvinfo hcall instructions " Alexander Graf 2014-04-24 13:12 ` Alexander Graf 2014-04-24 13:12 ` [PATCH 11/13] KVM: PPC: Make shared struct aka magic page guest endian Alexander Graf 2014-04-24 13:12 ` Alexander Graf 2014-04-24 13:12 ` [PATCH 12/13] KVM: PPC: Book3S PR: Do dcbz32 patching with big endian instructions Alexander Graf 2014-04-24 13:12 ` Alexander Graf 2014-04-24 13:12 ` [PATCH 13/13] KVM: PPC: Book3S: Move little endian conflict to HV KVM Alexander Graf 2014-04-24 13:12 ` 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=1398345160-4830-4-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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.