mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH gmem] KVM: Fix off-by-one error when querying attributes in xarray
@ 2023-10-23 20:35 Sean Christopherson
  2023-10-24  2:52 ` Binbin Wu
  0 siblings, 1 reply; 2+ messages in thread
From: Sean Christopherson @ 2023-10-23 20:35 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, linux-kernel, Binbin Wu, Sean Christopherson

Subtract -1 from kvm_range_has_memory_attributes()'s @end when using
xas_find(), as "end" is exclusive whereas xas_find() takes an inclusive
"max" as the maximal index to find/return.

Reported-by: Binbin Wu <binbin.wu@linux.intel.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 virt/kvm/kvm_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 959e866c84f0..12458959dd25 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2447,7 +2447,7 @@ bool kvm_range_has_memory_attributes(struct kvm *kvm, gfn_t start, gfn_t end,
 	rcu_read_lock();
 
 	if (!attrs) {
-		has_attrs = !xas_find(&xas, end);
+		has_attrs = !xas_find(&xas, end - 1);
 		goto out;
 	}
 

base-commit: 911b515af3ec5f53992b9cc162cf7d3893c2fbe2
-- 
2.42.0.758.gaed0368e0e-goog


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-24  2:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-23 20:35 [PATCH gmem] KVM: Fix off-by-one error when querying attributes in xarray Sean Christopherson
2023-10-24  2:52 ` Binbin Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome