Commit 05dd85f7 authored by Paul Mackerras's avatar Paul Mackerras Committed by Alexander Graf

KVM: PPC: Book3S HV: Report correct HPT entry index when reading HPT

This fixes a bug in the code which allows userspace to read out the
contents of the guest's hashed page table (HPT).  On the second and
subsequent passes through the HPT, when we are reporting only those
entries that have changed, we were incorrectly initializing the index
field of the header with the index of the first entry we skipped
rather than the first changed entry.  This fixes it.
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
Signed-off-by: default avatarAlexander Graf <agraf@suse.de>
parent a64fd707
...@@ -1282,7 +1282,6 @@ static ssize_t kvm_htab_read(struct file *file, char __user *buf, ...@@ -1282,7 +1282,6 @@ static ssize_t kvm_htab_read(struct file *file, char __user *buf,
while (nb + sizeof(hdr) + HPTE_SIZE < count) { while (nb + sizeof(hdr) + HPTE_SIZE < count) {
/* Initialize header */ /* Initialize header */
hptr = (struct kvm_get_htab_header __user *)buf; hptr = (struct kvm_get_htab_header __user *)buf;
hdr.index = i;
hdr.n_valid = 0; hdr.n_valid = 0;
hdr.n_invalid = 0; hdr.n_invalid = 0;
nw = nb; nw = nb;
...@@ -1298,6 +1297,7 @@ static ssize_t kvm_htab_read(struct file *file, char __user *buf, ...@@ -1298,6 +1297,7 @@ static ssize_t kvm_htab_read(struct file *file, char __user *buf,
++revp; ++revp;
} }
} }
hdr.index = i;
/* Grab a series of valid entries */ /* Grab a series of valid entries */
while (i < kvm->arch.hpt_npte && while (i < kvm->arch.hpt_npte &&
......
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