提交 abbed4fa 编写于 作者: S Sean Christopherson 提交者: Paolo Bonzini

KVM: x86: Fix warning due to implicit truncation on 32-bit KVM

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: NSean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 96d47010
...@@ -9735,8 +9735,12 @@ int __x86_set_memory_region(struct kvm *kvm, int id, gpa_t gpa, u32 size) ...@@ -9735,8 +9735,12 @@ int __x86_set_memory_region(struct kvm *kvm, int id, gpa_t gpa, u32 size)
if (!slot || !slot->npages) if (!slot || !slot->npages)
return 0; 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; old_npages = slot->npages;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册