From: Paolo Bonzini Date: Tue, 3 May 2022 11:23:08 +0000 (-0400) Subject: Merge branch 'kvm-tdp-mmu-atomicity-fix' into HEAD X-Git-Tag: baikal/mips/sdk6.1~5866^2~3 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=78cef226414eaa6e24f7cae0dc8835c138d91b57;p=kernel.git Merge branch 'kvm-tdp-mmu-atomicity-fix' into HEAD We are dropping A/D bits (and W bits) in the TDP MMU. Even if mmu_lock is held for write, as volatile SPTEs can be written by other tasks/vCPUs outside of mmu_lock. Attempting to prove that bug exposed another notable goof, which has been lurking for a decade, give or take: KVM treats _all_ MMU-writable SPTEs as volatile, even though KVM never clears WRITABLE outside of MMU lock. As a result, the legacy MMU (and the TDP MMU if not fixed) uses XCHG to update writable SPTEs. The fix does not seem to have an easily-measurable affect on performance; page faults are so slow that wasting even a few hundred cycles is dwarfed by the base cost. --- 78cef226414eaa6e24f7cae0dc8835c138d91b57