From: Lai Jiangshan <[email protected]>
The value is only set but never really used.
Signed-off-by: Lai Jiangshan <[email protected]>
---
arch/x86/kvm/mmu/mmu.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 65a2f4a2ce25..dc159db46b34 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -1745,13 +1745,11 @@ static int nonpaging_sync_page(struct kvm_vcpu *vcpu,
struct kvm_mmu_pages {
struct mmu_page_and_offset {
struct kvm_mmu_page *sp;
- unsigned int idx;
} page[KVM_PAGE_ARRAY_NR];
unsigned int nr;
};
-static int mmu_pages_add(struct kvm_mmu_pages *pvec, struct kvm_mmu_page *sp,
- int idx)
+static int mmu_pages_add(struct kvm_mmu_pages *pvec, struct kvm_mmu_page *sp)
{
int i;
@@ -1761,7 +1759,6 @@ static int mmu_pages_add(struct kvm_mmu_pages *pvec, struct kvm_mmu_page *sp,
return 0;
pvec->page[pvec->nr].sp = sp;
- pvec->page[pvec->nr].idx = idx;
pvec->nr++;
return (pvec->nr == KVM_PAGE_ARRAY_NR);
}
@@ -1790,7 +1787,7 @@ static int __mmu_unsync_walk_and_clear(struct kvm_mmu_page *sp,
child = to_shadow_page(ent & PT64_BASE_ADDR_MASK);
if (child->unsync_children) {
- if (mmu_pages_add(pvec, child, i))
+ if (mmu_pages_add(pvec, child))
return -ENOSPC;
ret = __mmu_unsync_walk_and_clear(child, pvec);
@@ -1808,7 +1805,7 @@ static int __mmu_unsync_walk_and_clear(struct kvm_mmu_page *sp,
clear_unsync_child_bit(sp, i);
if (child->unsync) {
nr_unsync_leaf++;
- if (mmu_pages_add(pvec, child, i))
+ if (mmu_pages_add(pvec, child))
return -ENOSPC;
}
}
@@ -1816,8 +1813,6 @@ static int __mmu_unsync_walk_and_clear(struct kvm_mmu_page *sp,
return nr_unsync_leaf;
}
-#define INVALID_INDEX (-1)
-
static int mmu_unsync_walk_and_clear(struct kvm_mmu_page *sp,
struct kvm_mmu_pages *pvec)
{
@@ -1825,7 +1820,7 @@ static int mmu_unsync_walk_and_clear(struct kvm_mmu_page *sp,
if (!sp->unsync_children)
return 0;
- mmu_pages_add(pvec, sp, INVALID_INDEX);
+ mmu_pages_add(pvec, sp);
return __mmu_unsync_walk_and_clear(sp, pvec);
}
@@ -1926,8 +1921,6 @@ static int mmu_pages_first(struct kvm_mmu_pages *pvec)
if (pvec->nr == 0)
return 0;
- WARN_ON(pvec->page[0].idx != INVALID_INDEX);
-
sp = pvec->page[0].sp;
level = sp->role.level;
WARN_ON(level == PG_LEVEL_4K);
--
2.19.1.6.gb485710b
It's arguably not useless, e.g. it's still used for a sanity check. Not sure
how to word that though. Maybe?
KVM: x86/mmu: Drop no-longer-necessary mmu_page_and_offset.idx
On Sun, Jun 05, 2022, Lai Jiangshan wrote:
> From: Lai Jiangshan <[email protected]>
>
> The value is only set but never really used.
Please elaborate on why it's no longer truly used. Something like:
Drop mmu_page_and_offset.idx, it's no longer strictly necessary now that
KVM doesn't recurse up the walk to clear unsync information in parents.
The field is still used for a sanity check, but that sanity check will
soon be made obsolete by further simplifying the gathering of unsync
shadow pages