Commit 29ecd660 authored by Paolo Bonzini's avatar Paolo Bonzini

KVM: x86: avoid uninitialized variable warning

This does not show up on all compiler versions, so it sneaked into the
first 4.3 pull request.  The fix is to mimic the logic of the "print
sptes" loop in the "fill array" loop.  Then leaf and root can be
both initialized unconditionally.

Note that "leaf" now points to the first unused element of the array,
not the last filled element.
Reported-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 4e33d1f0
...@@ -3309,13 +3309,14 @@ walk_shadow_page_get_mmio_spte(struct kvm_vcpu *vcpu, u64 addr, u64 *sptep) ...@@ -3309,13 +3309,14 @@ walk_shadow_page_get_mmio_spte(struct kvm_vcpu *vcpu, u64 addr, u64 *sptep)
walk_shadow_page_lockless_begin(vcpu); walk_shadow_page_lockless_begin(vcpu);
for (shadow_walk_init(&iterator, vcpu, addr), root = iterator.level; for (shadow_walk_init(&iterator, vcpu, addr),
leaf = root = iterator.level;
shadow_walk_okay(&iterator); shadow_walk_okay(&iterator);
__shadow_walk_next(&iterator, spte)) { __shadow_walk_next(&iterator, spte)) {
leaf = iterator.level;
spte = mmu_spte_get_lockless(iterator.sptep); spte = mmu_spte_get_lockless(iterator.sptep);
sptes[leaf - 1] = spte; sptes[leaf - 1] = spte;
leaf--;
if (!is_shadow_present_pte(spte)) if (!is_shadow_present_pte(spte))
break; break;
...@@ -3329,7 +3330,7 @@ walk_shadow_page_get_mmio_spte(struct kvm_vcpu *vcpu, u64 addr, u64 *sptep) ...@@ -3329,7 +3330,7 @@ walk_shadow_page_get_mmio_spte(struct kvm_vcpu *vcpu, u64 addr, u64 *sptep)
if (reserved) { if (reserved) {
pr_err("%s: detect reserved bits on spte, addr 0x%llx, dump hierarchy:\n", pr_err("%s: detect reserved bits on spte, addr 0x%llx, dump hierarchy:\n",
__func__, addr); __func__, addr);
while (root >= leaf) { while (root > leaf) {
pr_err("------ spte 0x%llx level %d.\n", pr_err("------ spte 0x%llx level %d.\n",
sptes[root - 1], root); sptes[root - 1], root);
root--; root--;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment