* [PATCH] KVM: x86: Fix warning due to implicit truncation on 32-bit KVM
@ 2020-03-05 0:24 Sean Christopherson
2020-03-05 10:00 ` Vitaly Kuznetsov
2020-03-05 14:29 ` Paolo Bonzini
0 siblings, 2 replies; 4+ messages in thread
From: Sean Christopherson @ 2020-03-05 0:24 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
Joerg Roedel, kvm, linux-kernel
Explicitly cast the integer literal to an unsigned long when stuffing a
non-canonical value into the host virtual address during private memslot
deletion. The explicit cast fixes a warning that gets promoted to an
error when running with KVM's newfangled -Werror setting.
arch/x86/kvm/x86.c:9739:9: error: large integer implicitly truncated
to unsigned type [-Werror=overflow]
Fixes: a3e967c0b87d3 ("KVM: Terminate memslot walks via used_slots"
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
arch/x86/kvm/x86.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index ba4d476b79ad..fa03f31ab33c 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -9735,8 +9735,12 @@ int __x86_set_memory_region(struct kvm *kvm, int id, gpa_t gpa, u32 size)
if (!slot || !slot->npages)
return 0;
- /* Stuff a non-canonical value to catch use-after-delete. */
- hva = 0xdeadull << 48;
+ /*
+ * Stuff a non-canonical value to catch use-after-delete. This
+ * ends up being 0 on 32-bit KVM, but there's no better
+ * alternative.
+ */
+ hva = (unsigned long)(0xdeadull << 48);
old_npages = slot->npages;
}
--
2.24.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] KVM: x86: Fix warning due to implicit truncation on 32-bit KVM
2020-03-05 0:24 [PATCH] KVM: x86: Fix warning due to implicit truncation on 32-bit KVM Sean Christopherson
@ 2020-03-05 10:00 ` Vitaly Kuznetsov
2020-03-05 16:04 ` Sean Christopherson
2020-03-05 14:29 ` Paolo Bonzini
1 sibling, 1 reply; 4+ messages in thread
From: Vitaly Kuznetsov @ 2020-03-05 10:00 UTC (permalink / raw)
To: Sean Christopherson
Cc: Paolo Bonzini, Wanpeng Li, Jim Mattson, Joerg Roedel, kvm,
linux-kernel
Sean Christopherson <sean.j.christopherson@intel.com> writes:
> Explicitly cast the integer literal to an unsigned long when stuffing a
> non-canonical value into the host virtual address during private memslot
> deletion. The explicit cast fixes a warning that gets promoted to an
> error when running with KVM's newfangled -Werror setting.
>
> arch/x86/kvm/x86.c:9739:9: error: large integer implicitly truncated
> to unsigned type [-Werror=overflow]
>
> Fixes: a3e967c0b87d3 ("KVM: Terminate memslot walks via used_slots"
Missing ')'
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
> arch/x86/kvm/x86.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index ba4d476b79ad..fa03f31ab33c 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -9735,8 +9735,12 @@ int __x86_set_memory_region(struct kvm *kvm, int id, gpa_t gpa, u32 size)
> if (!slot || !slot->npages)
> return 0;
>
> - /* Stuff a non-canonical value to catch use-after-delete. */
> - hva = 0xdeadull << 48;
> + /*
> + * Stuff a non-canonical value to catch use-after-delete. This
> + * ends up being 0 on 32-bit KVM, but there's no better
> + * alternative.
> + */
> + hva = (unsigned long)(0xdeadull << 48);
> old_npages = slot->npages;
> }
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
--
Vitaly
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] KVM: x86: Fix warning due to implicit truncation on 32-bit KVM
2020-03-05 10:00 ` Vitaly Kuznetsov
@ 2020-03-05 16:04 ` Sean Christopherson
0 siblings, 0 replies; 4+ messages in thread
From: Sean Christopherson @ 2020-03-05 16:04 UTC (permalink / raw)
To: Vitaly Kuznetsov
Cc: Paolo Bonzini, Wanpeng Li, Jim Mattson, Joerg Roedel, kvm,
linux-kernel
On Thu, Mar 05, 2020 at 11:00:20AM +0100, Vitaly Kuznetsov wrote:
> Sean Christopherson <sean.j.christopherson@intel.com> writes:
>
> > Explicitly cast the integer literal to an unsigned long when stuffing a
> > non-canonical value into the host virtual address during private memslot
> > deletion. The explicit cast fixes a warning that gets promoted to an
> > error when running with KVM's newfangled -Werror setting.
> >
> > arch/x86/kvm/x86.c:9739:9: error: large integer implicitly truncated
> > to unsigned type [-Werror=overflow]
> >
> > Fixes: a3e967c0b87d3 ("KVM: Terminate memslot walks via used_slots"
>
> Missing ')'
Hrm, surprised checkpatch didn't catch that.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: x86: Fix warning due to implicit truncation on 32-bit KVM
2020-03-05 0:24 [PATCH] KVM: x86: Fix warning due to implicit truncation on 32-bit KVM Sean Christopherson
2020-03-05 10:00 ` Vitaly Kuznetsov
@ 2020-03-05 14:29 ` Paolo Bonzini
1 sibling, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2020-03-05 14:29 UTC (permalink / raw)
To: Sean Christopherson
Cc: Vitaly Kuznetsov, Wanpeng Li, Jim Mattson, Joerg Roedel, kvm,
linux-kernel
On 05/03/20 01:24, Sean Christopherson wrote:
> Explicitly cast the integer literal to an unsigned long when stuffing a
> non-canonical value into the host virtual address during private memslot
> deletion. The explicit cast fixes a warning that gets promoted to an
> error when running with KVM's newfangled -Werror setting.
>
> arch/x86/kvm/x86.c:9739:9: error: large integer implicitly truncated
> to unsigned type [-Werror=overflow]
>
> Fixes: a3e967c0b87d3 ("KVM: Terminate memslot walks via used_slots"
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
> arch/x86/kvm/x86.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index ba4d476b79ad..fa03f31ab33c 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -9735,8 +9735,12 @@ int __x86_set_memory_region(struct kvm *kvm, int id, gpa_t gpa, u32 size)
> if (!slot || !slot->npages)
> return 0;
>
> - /* Stuff a non-canonical value to catch use-after-delete. */
> - hva = 0xdeadull << 48;
> + /*
> + * Stuff a non-canonical value to catch use-after-delete. This
> + * ends up being 0 on 32-bit KVM, but there's no better
> + * alternative.
> + */
> + hva = (unsigned long)(0xdeadull << 48);
> old_npages = slot->npages;
> }
>
>
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-03-05 16:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-05 0:24 [PATCH] KVM: x86: Fix warning due to implicit truncation on 32-bit KVM Sean Christopherson
2020-03-05 10:00 ` Vitaly Kuznetsov
2020-03-05 16:04 ` Sean Christopherson
2020-03-05 14:29 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox