diff options
| author | Fuad Tabba <tabba@google.com> | 2026-05-01 14:21:48 +0300 |
|---|---|---|
| committer | Marc Zyngier <maz@kernel.org> | 2026-05-07 16:12:42 +0300 |
| commit | 8234409ffb656970e2f5b29e416f041419980bef (patch) | |
| tree | d1577fdb8e6fd3d34e268e530b9e844b0694cf5d /tools/lib/python/__init__.py | |
| parent | 5130d450d1488e62e1b5310f41910a3c7320e827 (diff) | |
| download | linux-8234409ffb656970e2f5b29e416f041419980bef.tar.xz | |
KVM: arm64: Pre-check vcpu memcache for host->guest share
__pkvm_host_share_guest() ends with kvm_pgtable_stage2_map() to
install the guest stage-2 mapping, after a forward pass that mutates
the host vmemmap (sets PKVM_PAGE_SHARED_OWNED and increments
host_share_guest_count) for every page in the range. The map's
return value is wrapped in WARN_ON() and otherwise discarded,
asserting that the call cannot fail.
WARN_ON() at nVHE EL2 panics, so this assertion is only correct if
the call genuinely cannot fail. kvm_pgtable_stage2_map() can fail
with -ENOMEM when the stage-2 walker exhausts the caller's
memcache, and the host controls the vcpu memcache via the topup
interface, so an under-provisioned share request would otherwise
turn a recoverable -ENOMEM into a fatal hyp panic.
Bound the worst-case walker allocation in the existing pre-check
pass so that kvm_pgtable_stage2_map() cannot fail at the call
site, using kvm_mmu_cache_min_pages() -- the same bound host EL1
uses for its own stage-2 maps. If the vcpu memcache holds fewer
pages, return -ENOMEM before any state mutation.
Fixes: d0bd3e6570ae ("KVM: arm64: Introduce __pkvm_host_share_guest()")
Assisted-by: Gemini:gemini-3.1-pro review-prompts
Signed-off-by: Fuad Tabba <tabba@google.com>
Link: https://patch.msgid.link/20260501112149.2824881-6-tabba@google.com
Signed-off-by: Marc Zyngier <maz@kernel.org>
Diffstat (limited to 'tools/lib/python/__init__.py')
0 files changed, 0 insertions, 0 deletions
