2023-07-29 01:17:08

by Sean Christopherson

[permalink] [raw]
Subject: [PATCH v3 04/12] KVM: x86/mmu: Avoid pointer arithmetic when iterating over SPTEs

Replace the pointer arithmetic used to iterate over SPTEs in
is_empty_shadow_page() with more standard interger-based iteration.

No functional change intended.

Signed-off-by: Sean Christopherson <[email protected]>
---
arch/x86/kvm/mmu/mmu.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index b16092d71d3f..08d08f34e6a3 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -1696,15 +1696,15 @@ bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
#ifdef MMU_DEBUG
static int is_empty_shadow_page(u64 *spt)
{
- u64 *pos;
- u64 *end;
+ int i;

- for (pos = spt, end = pos + SPTE_ENT_PER_PAGE; pos != end; pos++)
- if (is_shadow_present_pte(*pos)) {
+ for (i = 0; i < SPTE_ENT_PER_PAGE; i++) {
+ if (is_shadow_present_pte(spt[i])) {
printk(KERN_ERR "%s: %p %llx\n", __func__,
- pos, *pos);
+ &spt[i], spt[i]);
return 0;
}
+ }
return 1;
}
#endif
--
2.41.0.487.g6d72f3e995-goog



2023-08-01 15:22:30

by Philippe Mathieu-Daudé

[permalink] [raw]
Subject: Re: [PATCH v3 04/12] KVM: x86/mmu: Avoid pointer arithmetic when iterating over SPTEs

On 29/7/23 02:47, Sean Christopherson wrote:
> Replace the pointer arithmetic used to iterate over SPTEs in
> is_empty_shadow_page() with more standard interger-based iteration.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <[email protected]>
> ---
> arch/x86/kvm/mmu/mmu.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>