arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 2 + arch/arm64/kvm/hyp/include/nvhe/mm.h | 1 + arch/arm64/kvm/hyp/nvhe/mem_protect.c | 20 +++++ arch/arm64/kvm/hyp/nvhe/mm.c | 79 ++++++++++++++++--- arch/arm64/kvm/hyp/nvhe/setup.c | 16 +++- 5 files changed, 108 insertions(+), 10 deletions(-)
Hi folks, The per-CPU EL2 stacks are initialised as host-owned after pKVM init. fix_host_ownership() walks only the linear-map alias of each memblock region, and the stacks, mapped in the private VA range for their guard pages, have none. Patch 1 is the fix, and it needs none of the other three. Patch 4 adds the check that would have caught it and would catch similar instances in the future: once the transfer is done, walk the private VA range and fail init unless every valid leaf is hyp-owned, or is hyp text mapped without write access. Patch 2 is a fix in its own right, but to a different bug. fix_host_ownership_walker() matches hyp text on its stage-1 permissions, and that test hasn't matched on a non-hVHE host since 7.0, so hyp text is donated there rather than left read-only. Nothing crashes, but the instruction dump on hyp panic reads a page the host can't access, so the Code: line comes out as question marks. It matches by physical address instead, which is what patch 4 needs too. Patch 3 splits the start of the range from the allocation cursor, with no functional change, so patch 4 knows where the range begins. Based on Linux 7.3-rc2 (df2908090cda3). Cheers, /fuad Fuad Tabba (4): KVM: arm64: Transfer the hyp stack pages out of the host stage-2 KVM: arm64: Match hyp text by physical address in fix_host_ownership() KVM: arm64: Move the private VA allocation cursor to __io_map_next KVM: arm64: Check every private mapping is hyp-owned at pKVM init arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 2 + arch/arm64/kvm/hyp/include/nvhe/mm.h | 1 + arch/arm64/kvm/hyp/nvhe/mem_protect.c | 20 +++++ arch/arm64/kvm/hyp/nvhe/mm.c | 79 ++++++++++++++++--- arch/arm64/kvm/hyp/nvhe/setup.c | 16 +++- 5 files changed, 108 insertions(+), 10 deletions(-) base-commit: df2908090cda368b01ff43709f51890076c56157 -- 2.39.5
On Tue, 08 Sep 2026 12:07:09 +0100, Fuad Tabba wrote:
> The per-CPU EL2 stacks are initialised as host-owned after pKVM init.
> fix_host_ownership() walks only the linear-map alias of each memblock
> region, and the stacks, mapped in the private VA range for their guard
> pages, have none.
>
> Patch 1 is the fix, and it needs none of the other three. Patch 4 adds
> the check that would have caught it and would catch similar instances
> in the future: once the transfer is done, walk the private VA range and
> fail init unless every valid leaf is hyp-owned, or is hyp text mapped
> without write access.
>
> [...]
Applied to fixes, thanks!
[1/4] KVM: arm64: Transfer the hyp stack pages out of the host stage-2
https://git.kernel.org/kvmarm/kvmarm/c/3a8c562892b9
[2/4] KVM: arm64: Match hyp text by physical address in fix_host_ownership()
https://git.kernel.org/kvmarm/kvmarm/c/5a8b505ede13
[3/4] KVM: arm64: Move the private VA allocation cursor to __io_map_next
https://git.kernel.org/kvmarm/kvmarm/c/224584140114
[4/4] KVM: arm64: Check every private mapping is hyp-owned at pKVM init
https://git.kernel.org/kvmarm/kvmarm/c/cfe80c3837f9
--
Best,
Oliver
On Tue, Sep 08, 2026 at 12:07:09PM +0100, Fuad Tabba wrote: > Hi folks, > > The per-CPU EL2 stacks are initialised as host-owned after pKVM init. > fix_host_ownership() walks only the linear-map alias of each memblock > region, and the stacks, mapped in the private VA range for their guard > pages, have none. > > Patch 1 is the fix, and it needs none of the other three. Patch 4 adds > the check that would have caught it and would catch similar instances > in the future: once the transfer is done, walk the private VA range and > fail init unless every valid leaf is hyp-owned, or is hyp text mapped > without write access. > > Patch 2 is a fix in its own right, but to a different bug. > fix_host_ownership_walker() matches hyp text on its stage-1 permissions, > and that test hasn't matched on a non-hVHE host since 7.0, so hyp text > is donated there rather than left read-only. Nothing crashes, but the > instruction dump on hyp panic reads a page the host can't access, so > the Code: line comes out as question marks. It matches by physical > address instead, which is what patch 4 needs too. Patch 3 splits the > start of the range from the allocation cursor, with no functional > change, so patch 4 knows where the range begins. > > Based on Linux 7.3-rc2 (df2908090cda3). > > Cheers, > /fuad > > Fuad Tabba (4): > KVM: arm64: Transfer the hyp stack pages out of the host stage-2 > KVM: arm64: Match hyp text by physical address in fix_host_ownership() > KVM: arm64: Move the private VA allocation cursor to __io_map_next > KVM: arm64: Check every private mapping is hyp-owned at pKVM init > > arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 2 + > arch/arm64/kvm/hyp/include/nvhe/mm.h | 1 + > arch/arm64/kvm/hyp/nvhe/mem_protect.c | 20 +++++ > arch/arm64/kvm/hyp/nvhe/mm.c | 79 ++++++++++++++++--- > arch/arm64/kvm/hyp/nvhe/setup.c | 16 +++- > 5 files changed, 108 insertions(+), 10 deletions(-) > > > base-commit: df2908090cda368b01ff43709f51890076c56157 > -- > 2.39.5 > Reviewed-by: Vincent Donnefort <vdonnefort@google.com> Tested-by: Vincent Donnefort <vdonnefort@google.com> -- Vincent
On Tue, 08 Sep 2026 12:07:09 +0100, Fuad Tabba <fuad.tabba@linux.dev> wrote: > > Hi folks, > > The per-CPU EL2 stacks are initialised as host-owned after pKVM init. > fix_host_ownership() walks only the linear-map alias of each memblock > region, and the stacks, mapped in the private VA range for their guard > pages, have none. > > Patch 1 is the fix, and it needs none of the other three. Patch 4 adds > the check that would have caught it and would catch similar instances > in the future: once the transfer is done, walk the private VA range and > fail init unless every valid leaf is hyp-owned, or is hyp text mapped > without write access. > > Patch 2 is a fix in its own right, but to a different bug. > fix_host_ownership_walker() matches hyp text on its stage-1 permissions, > and that test hasn't matched on a non-hVHE host since 7.0, so hyp text > is donated there rather than left read-only. Nothing crashes, but the > instruction dump on hyp panic reads a page the host can't access, so > the Code: line comes out as question marks. It matches by physical > address instead, which is what patch 4 needs too. Patch 3 splits the > start of the range from the allocation cursor, with no functional > change, so patch 4 knows where the range begins. Reviewed-by: Marc Zyngier <maz@kernel.org> M. -- Without deviation from the norm, progress is not possible.
© 2016 - 2026 Red Hat, Inc.