]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: arm64: Fix masks in stage2_pte_cacheable()
authorWill Deacon <will@kernel.org>
Thu, 29 Oct 2020 14:47:16 +0000 (14:47 +0000)
committerMarc Zyngier <maz@kernel.org>
Thu, 29 Oct 2020 19:49:03 +0000 (19:49 +0000)
commitad876ac9851fe2a5d8c86693ef01a92d535439bc
treec7362c1a7526b438a27376f8333ee9560921ed9d
parentddaf24a8296367b7bca18d84d7b0984f05a16628
KVM: arm64: Fix masks in stage2_pte_cacheable()

stage2_pte_cacheable() tries to figure out whether the mapping installed
in its 'pte' parameter is cacheable or not. Unfortunately, it fails
miserably because it extracts the memory attributes from the entry using
FIELD_GET(), which returns the attributes shifted down to bit 0, but then
compares this with the unshifted value generated by the PAGE_S2_MEMATTR()
macro.

A direct consequence of this bug is that cache maintenance is silently
skipped, which in turn causes 32-bit guests to crash early on when their
set/way maintenance is trapped but not emulated correctly.

Fix the broken masks by avoiding the use of FIELD_GET() altogether.

Fixes: 52b1c29af016 ("KVM: arm64: Add support for stage-2 map()/unmap() in generic page-table")
Reported-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: Quentin Perret <qperret@google.com>
Link: https://lore.kernel.org/r/20201029144716.30476-1-will@kernel.org
arch/arm64/kvm/hyp/pgtable.c