* [PATCH] KVM: PPC: Book3S HV: Fix kvm_unmap_gfn_range_hv() for Hash MMU
@ 2021-05-11 10:54 Michael Ellerman
2021-05-11 16:39 ` Sean Christopherson
2021-05-15 22:43 ` Michael Ellerman
0 siblings, 2 replies; 4+ messages in thread
From: Michael Ellerman @ 2021-05-11 10:54 UTC (permalink / raw)
To: linuxppc-dev; +Cc: npiggin, kvm, kvm-ppc, seanjc, pbonzini
Commit 32b48bf8514c ("KVM: PPC: Book3S HV: Fix conversion to gfn-based
MMU notifier callbacks") fixed kvm_unmap_gfn_range_hv() by adding a for
loop over each gfn in the range.
But for the Hash MMU it repeatedly calls kvm_unmap_rmapp() with the
first gfn of the range, rather than iterating through the range.
This exhibits as strange guest behaviour, sometimes crashing in firmare,
or booting and then guest userspace crashing unexpectedly.
Fix it by passing the iterator, gfn, to kvm_unmap_rmapp().
Fixes: 32b48bf8514c ("KVM: PPC: Book3S HV: Fix conversion to gfn-based MMU notifier callbacks")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/kvm/book3s_64_mmu_hv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
I plan to take this via the powerpc fixes branch.
diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
index 2d9193cd73be..c63e263312a4 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
@@ -840,7 +840,7 @@ bool kvm_unmap_gfn_range_hv(struct kvm *kvm, struct kvm_gfn_range *range)
kvm_unmap_radix(kvm, range->slot, gfn);
} else {
for (gfn = range->start; gfn < range->end; gfn++)
- kvm_unmap_rmapp(kvm, range->slot, range->start);
+ kvm_unmap_rmapp(kvm, range->slot, gfn);
}
return false;
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: PPC: Book3S HV: Fix kvm_unmap_gfn_range_hv() for Hash MMU
2021-05-11 10:54 [PATCH] KVM: PPC: Book3S HV: Fix kvm_unmap_gfn_range_hv() for Hash MMU Michael Ellerman
@ 2021-05-11 16:39 ` Sean Christopherson
2021-05-12 3:20 ` Michael Ellerman
2021-05-15 22:43 ` Michael Ellerman
1 sibling, 1 reply; 4+ messages in thread
From: Sean Christopherson @ 2021-05-11 16:39 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, npiggin, kvm, kvm-ppc, pbonzini
On Tue, May 11, 2021, Michael Ellerman wrote:
> Commit 32b48bf8514c ("KVM: PPC: Book3S HV: Fix conversion to gfn-based
> MMU notifier callbacks") fixed kvm_unmap_gfn_range_hv() by adding a for
> loop over each gfn in the range.
>
> But for the Hash MMU it repeatedly calls kvm_unmap_rmapp() with the
> first gfn of the range, rather than iterating through the range.
>
> This exhibits as strange guest behaviour, sometimes crashing in firmare,
> or booting and then guest userspace crashing unexpectedly.
>
> Fix it by passing the iterator, gfn, to kvm_unmap_rmapp().
>
> Fixes: 32b48bf8514c ("KVM: PPC: Book3S HV: Fix conversion to gfn-based MMU notifier callbacks")
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
> arch/powerpc/kvm/book3s_64_mmu_hv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> I plan to take this via the powerpc fixes branch.
FWIW,
Reviewed-by: Sean Christopherson <seanjc@google.com>
>
> diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
> index 2d9193cd73be..c63e263312a4 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
> @@ -840,7 +840,7 @@ bool kvm_unmap_gfn_range_hv(struct kvm *kvm, struct kvm_gfn_range *range)
> kvm_unmap_radix(kvm, range->slot, gfn);
> } else {
> for (gfn = range->start; gfn < range->end; gfn++)
> - kvm_unmap_rmapp(kvm, range->slot, range->start);
> + kvm_unmap_rmapp(kvm, range->slot, gfn);
> }
>
> return false;
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: PPC: Book3S HV: Fix kvm_unmap_gfn_range_hv() for Hash MMU
2021-05-11 16:39 ` Sean Christopherson
@ 2021-05-12 3:20 ` Michael Ellerman
0 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2021-05-12 3:20 UTC (permalink / raw)
To: Sean Christopherson; +Cc: linuxppc-dev, npiggin, kvm, kvm-ppc, pbonzini
Sean Christopherson <seanjc@google.com> writes:
> On Tue, May 11, 2021, Michael Ellerman wrote:
>> Commit 32b48bf8514c ("KVM: PPC: Book3S HV: Fix conversion to gfn-based
>> MMU notifier callbacks") fixed kvm_unmap_gfn_range_hv() by adding a for
>> loop over each gfn in the range.
>>
>> But for the Hash MMU it repeatedly calls kvm_unmap_rmapp() with the
>> first gfn of the range, rather than iterating through the range.
>>
>> This exhibits as strange guest behaviour, sometimes crashing in firmare,
>> or booting and then guest userspace crashing unexpectedly.
>>
>> Fix it by passing the iterator, gfn, to kvm_unmap_rmapp().
>>
>> Fixes: 32b48bf8514c ("KVM: PPC: Book3S HV: Fix conversion to gfn-based MMU notifier callbacks")
>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>> ---
>> arch/powerpc/kvm/book3s_64_mmu_hv.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> I plan to take this via the powerpc fixes branch.
>
> FWIW,
>
> Reviewed-by: Sean Christopherson <seanjc@google.com>
Thanks.
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: PPC: Book3S HV: Fix kvm_unmap_gfn_range_hv() for Hash MMU
2021-05-11 10:54 [PATCH] KVM: PPC: Book3S HV: Fix kvm_unmap_gfn_range_hv() for Hash MMU Michael Ellerman
2021-05-11 16:39 ` Sean Christopherson
@ 2021-05-15 22:43 ` Michael Ellerman
1 sibling, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2021-05-15 22:43 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev; +Cc: kvm, npiggin, kvm-ppc, pbonzini, seanjc
On Tue, 11 May 2021 20:54:59 +1000, Michael Ellerman wrote:
> Commit 32b48bf8514c ("KVM: PPC: Book3S HV: Fix conversion to gfn-based
> MMU notifier callbacks") fixed kvm_unmap_gfn_range_hv() by adding a for
> loop over each gfn in the range.
>
> But for the Hash MMU it repeatedly calls kvm_unmap_rmapp() with the
> first gfn of the range, rather than iterating through the range.
>
> [...]
Applied to powerpc/fixes.
[1/1] KVM: PPC: Book3S HV: Fix kvm_unmap_gfn_range_hv() for Hash MMU
https://git.kernel.org/powerpc/c/da3bb206c9ceb0736d9e2897ea697acabad35833
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-05-15 22:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11 10:54 [PATCH] KVM: PPC: Book3S HV: Fix kvm_unmap_gfn_range_hv() for Hash MMU Michael Ellerman
2021-05-11 16:39 ` Sean Christopherson
2021-05-12 3:20 ` Michael Ellerman
2021-05-15 22:43 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).