All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Mackerras <paulus@samba.org>
To: Alexander Graf <agraf@suse.de>, kvm-ppc@vger.kernel.org
Cc: kvm@vger.kernel.org
Subject: [PATCH 1/5] KVM: PPC: Book3S PR: Fix proto-VSID calculations
Date: Sat, 22 Jun 2013 17:13:32 +1000	[thread overview]
Message-ID: <20130622071332.GB2791@iris.ozlabs.ibm.com> (raw)
In-Reply-To: <20130622071244.GA2791@iris.ozlabs.ibm.com>

This makes sure the calculation of the proto-VSIDs used by PR KVM
is done with 64-bit arithmetic.  Since vcpu3s->context_id[] is int,
when we do vcpu3s->context_id[0] << ESID_BITS the shift will be done
with 32-bit instructions, possibly leading to significant bits
getting lost, as the context id can be up to 524283 and ESID_BITS is
18.  To fix this we cast the context id to u64 before shifting.

Signed-off-by: Paul Mackerras <paulus@samba.org>
---
 arch/powerpc/kvm/book3s_64_mmu_host.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_64_mmu_host.c b/arch/powerpc/kvm/book3s_64_mmu_host.c
index 3a9a1ac..2c6e7ee 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_host.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_host.c
@@ -325,9 +325,9 @@ int kvmppc_mmu_init(struct kvm_vcpu *vcpu)
 		return -1;
 	vcpu3s->context_id[0] = err;
 
-	vcpu3s->proto_vsid_max = ((vcpu3s->context_id[0] + 1)
+	vcpu3s->proto_vsid_max = ((u64)(vcpu3s->context_id[0] + 1)
 				  << ESID_BITS) - 1;
-	vcpu3s->proto_vsid_first = vcpu3s->context_id[0] << ESID_BITS;
+	vcpu3s->proto_vsid_first = (u64)vcpu3s->context_id[0] << ESID_BITS;
 	vcpu3s->proto_vsid_next = vcpu3s->proto_vsid_first;
 
 	kvmppc_mmu_hpte_init(vcpu);
-- 
1.8.3.1

WARNING: multiple messages have this Message-ID (diff)
From: Paul Mackerras <paulus@samba.org>
To: Alexander Graf <agraf@suse.de>, kvm-ppc@vger.kernel.org
Cc: kvm@vger.kernel.org
Subject: [PATCH 1/5] KVM: PPC: Book3S PR: Fix proto-VSID calculations
Date: Sat, 22 Jun 2013 07:13:32 +0000	[thread overview]
Message-ID: <20130622071332.GB2791@iris.ozlabs.ibm.com> (raw)
In-Reply-To: <20130622071244.GA2791@iris.ozlabs.ibm.com>

This makes sure the calculation of the proto-VSIDs used by PR KVM
is done with 64-bit arithmetic.  Since vcpu3s->context_id[] is int,
when we do vcpu3s->context_id[0] << ESID_BITS the shift will be done
with 32-bit instructions, possibly leading to significant bits
getting lost, as the context id can be up to 524283 and ESID_BITS is
18.  To fix this we cast the context id to u64 before shifting.

Signed-off-by: Paul Mackerras <paulus@samba.org>
---
 arch/powerpc/kvm/book3s_64_mmu_host.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_64_mmu_host.c b/arch/powerpc/kvm/book3s_64_mmu_host.c
index 3a9a1ac..2c6e7ee 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_host.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_host.c
@@ -325,9 +325,9 @@ int kvmppc_mmu_init(struct kvm_vcpu *vcpu)
 		return -1;
 	vcpu3s->context_id[0] = err;
 
-	vcpu3s->proto_vsid_max = ((vcpu3s->context_id[0] + 1)
+	vcpu3s->proto_vsid_max = ((u64)(vcpu3s->context_id[0] + 1)
 				  << ESID_BITS) - 1;
-	vcpu3s->proto_vsid_first = vcpu3s->context_id[0] << ESID_BITS;
+	vcpu3s->proto_vsid_first = (u64)vcpu3s->context_id[0] << ESID_BITS;
 	vcpu3s->proto_vsid_next = vcpu3s->proto_vsid_first;
 
 	kvmppc_mmu_hpte_init(vcpu);
-- 
1.8.3.1


  reply	other threads:[~2013-06-22  7:13 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-22  7:12 [PATCH 0/5] Some fixes and improvements for PR KVM Paul Mackerras
2013-06-22  7:12 ` Paul Mackerras
2013-06-22  7:13 ` Paul Mackerras [this message]
2013-06-22  7:13   ` [PATCH 1/5] KVM: PPC: Book3S PR: Fix proto-VSID calculations Paul Mackerras
2013-06-22  7:14 ` [PATCH 2/5] KVM: PPC: Book3S PR: Fix invalidation of SLB entry 0 on guest entry Paul Mackerras
2013-06-22  7:14   ` Paul Mackerras
2013-06-22  7:14 ` [PATCH 3/5] KVM: PPC: Book3S PR: Don't keep scanning HPTEG after we find a match Paul Mackerras
2013-06-22  7:14   ` Paul Mackerras
2013-06-22 17:42   ` Alexander Graf
2013-06-22 17:42     ` Alexander Graf
2013-06-22  7:15 ` [PATCH 4/5] KVM: PPC: Book3S PR: Invalidate SLB entries properly Paul Mackerras
2013-06-22  7:15   ` Paul Mackerras
2013-06-22 17:48   ` Alexander Graf
2013-06-22 17:48     ` Alexander Graf
2013-06-22 23:30     ` Paul Mackerras
2013-06-22 23:30       ` Paul Mackerras
2013-06-22 23:38       ` Alexander Graf
2013-06-22 23:38         ` Alexander Graf
2013-06-22  7:16 ` [PATCH 5/5] KVM: PPC: Book3S PR: Allow guest to use 1TB segments Paul Mackerras
2013-06-22  7:16   ` Paul Mackerras
2013-06-22 17:57 ` [PATCH 0/5] Some fixes and improvements for PR KVM Alexander Graf
2013-06-22 17:57   ` 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=20130622071332.GB2791@iris.ozlabs.ibm.com \
    --to=paulus@samba.org \
    --cc=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 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.