Commit 654b901d authored by Quentin Perret's avatar Quentin Perret Committed by Lee Jones
Browse files

ANDROID: KVM: arm64: Check PGD alignment when creating a pVM



Martijn reported a hypervisor crash when providing pKVM with an
undersized PGD allocation. Indeed, although the size of the PGD
allocation at EL2 is not under host control, a smaller host-side
allocation can lead to providing pKVM with a misaligned PGD, which will
cause the guest stage-2 init to fail in a bad way. Specifically,
guest_s2_zalloc_pages_exact() expects a successful allocation from
hyp_alloc_pages(), which can only happen if the pool has been pre-filled
with a physically aligned high-order page.

In order to guarantee allocation success in this path, check the
host-provided PGD alignment early on.

Bug: 443668075
Change-Id: I170963edc5721cf368a506bcdc4b2d0cdb462f78
Fixes: a1ec5c70 ("KVM: arm64: Add infrastructure to create and track pKVM instances at EL2")
Reported-by: default avatarMartijn Bogaard <martijnbogaard@google.com>
Signed-off-by: default avatarQuentin Perret <qperret@google.com>
(cherry picked from commit 42eff3b2)
Signed-off-by: default avatarLee Jones <joneslee@google.com>
parent 4c6df78f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment