On Tue, 11 Sep 2018 20:01:54 +1000 Paul Mackerras <paulus@xxxxxxxxxx> wrote: > On Tue, Sep 04, 2018 at 06:16:01PM +1000, Nicholas Piggin wrote: > > THP paths can defer splitting compound pages until after the actual > > remap and TLB flushes to split a huge PMD/PUD. This causes radix > > partition scope page table mappings to get out of synch with the host > > qemu page table mappings. > > > > This results in random memory corruption in the guest when running > > with THP. The easiest way to reproduce is use KVM baloon to free up > > a lot of memory in the guest and then shrink the balloon to give the > > memory back, while some work is being done in the guest. > > I'm hitting the WARN_ON you added. I think I have an old qemu that > doesn't 2M-align the guest ram and so we get to the level = 0 case > because of misalignment. The patch below on top of yours seems to > work just fine. In the case where the pte is 2M or 1G but we have > misalignment, it ORs in address bits from hva into the pte so we get > to the specific single page we want. > > Care to fold this in and resend? Thanks for that, I misunderstood the unaligned adjustment case. Good thing you caught it. Thanks, Nick