From: Tian Zheng <zhengtian10@huawei.com>
To: <sashiko-reviews@lists.linux.dev>
Cc: <kvmarm@lists.linux.dev>, Oliver Upton <oupton@kernel.org>,
Marc Zyngier <maz@kernel.org>, <kvm@vger.kernel.org>
Subject: Re: [PATCH v5 04/15] KVM: arm64: Add KVM_REQ_RELOAD_STAGE2
Date: Wed, 30 Sep 2026 09:44:36 +0800 [thread overview]
Message-ID: <c624d394-d4c4-4335-9419-e83fdd0eae8f@huawei.com> (raw)
In-Reply-To: <20260929105038.ED3781F000FF@smtp.kernel.org>
On 9/29/2026 6:50 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Critical] kvm: arm64: host panic on nVHE due to EL1 access of EL2 sysregs in __load_stage2
> --
>
> commit 982e8feb07630370c5da59ed6e47706db5188e18
> Author: Leonardo Bras <leo.bras@arm.com>
> Subject: KVM: arm64: Add KVM_REQ_RELOAD_STAGE2
>
> This commit adds a vcpu request to exit the guest, reload stage-2, and come
> back to the guest, anticipating subsequent patches for S2 HAFDBS and HDBSS.
>
> Link: https://lore.kernel.org/all/20260901171558.2674031-5-leo.bras@arm.com/
>
>> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
>> index 0576c2022ef57..d9ad765943d9e 100644
>> --- a/arch/arm64/kvm/arm.c
>> +++ b/arch/arm64/kvm/arm.c
>
> [ ... ]
>
>> @@ -1175,6 +1175,14 @@ static int check_vcpu_requests(struct kvm_vcpu *vcpu)
>> if (kvm_dirty_ring_check_request(vcpu))
>> return 0;
>>
>> + if (kvm_check_request(KVM_REQ_RELOAD_STAGE2, vcpu)) {
>> + unsigned long flags;
>> +
>> + local_irq_save(flags);
>> + __load_stage2(vcpu->arch.hw_mmu);
>
> [Severity: Critical]
> Could this trigger a host kernel panic on systems running in nVHE or
> pKVM mode?
>
> In nVHE or pKVM mode, the host kernel runs at EL1. The check_vcpu_requests()
> function executes from the host context. If a KVM_REQ_RELOAD_STAGE2 request
> is processed here, it calls __load_stage2(), which performs the following:
>
> arch/arm64/include/asm/kvm_mmu.h:__load_stage2() {
> write_sysreg(mmu->vtcr, vtcr_el2);
> write_sysreg(kvm_get_vttbr(mmu), vttbr_el2);
> ...
> }
>
> Because vtcr_el2 and vttbr_el2 are EL2 system registers, writing to them
> from EL1 will cause an UNDEFINED instruction exception. This causes the CPU
> to trap to the hypervisor, which will intentionally panic upon receiving an
> unexpected sysreg trap from the host, crashing the system.
>
> Since any unprivileged user with access to /dev/kvm could potentially trigger
> a memory region update that sets KVM_REQ_RELOAD_STAGE2, it seems this might
> provide a trivial path to trigger a host Denial of Service.
>
> Would it be possible to add a has_vhe() guard here or handle the reload via
> a hypercall for non-VHE systems?
>
Yes, you're right, that's my mistake. I'll add a has_vhe() guard in
check_vcpu_requests() as a defensive check, and also prevent the request
from being raised on nVHE at the source.
>> + local_irq_restore(flags);
>> + }
>> +
>> check_nested_vcpu_requests(vcpu);
>> }
>>
>
next prev parent reply other threads:[~2026-09-30 1:44 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 10:36 [PATCH v5 00/15] KVM: arm64: FEAT_HDBSS support for stage-2 dirty tracking Tian Zheng
2026-09-29 10:36 ` [PATCH v5 01/15] KVM: arm64: pgtables: Change write bit from S2AP_W to DBM Tian Zheng
2026-09-30 0:25 ` Oliver Upton
2026-09-30 2:44 ` Tian Zheng
2026-09-29 10:36 ` [PATCH v5 02/15] KVM: arm64: Add KVM_PGTABLE_PROT_DIRTY Tian Zheng
2026-09-30 0:35 ` Oliver Upton
2026-09-30 2:57 ` Tian Zheng
2026-09-29 10:36 ` [PATCH v5 03/15] KVM: arm64: Introduce a dedicated walker for stage2 write-protect Tian Zheng
2026-09-29 10:36 ` [PATCH v5 04/15] KVM: arm64: Add KVM_REQ_RELOAD_STAGE2 Tian Zheng
2026-09-29 10:50 ` sashiko-bot
2026-09-30 1:44 ` Tian Zheng [this message]
2026-09-29 10:36 ` [PATCH v5 05/15] KVM: arm64: Harvest stage-2 dirty state into the host folio account Tian Zheng
2026-09-29 10:36 ` [PATCH v5 06/15] KVM: arm64: Add support for FEAT_HDBSS Tian Zheng
2026-09-29 10:36 ` [PATCH v5 07/15] KVM: arm64: Add HDBSS per-vCPU buffer management Tian Zheng
2026-09-29 10:36 ` [PATCH v5 08/15] KVM: arm64: Flush the HDBSS buffer on VM exit Tian Zheng
2026-09-29 10:36 ` [PATCH v5 09/15] KVM: arm64: Handle HDBSS faults Tian Zheng
2026-09-29 10:53 ` sashiko-bot
2026-09-29 10:36 ` [PATCH v5 10/15] KVM: Add kvm_arch_dirty_ring_size_updated() hook Tian Zheng
2026-09-29 10:52 ` sashiko-bot
2026-09-29 10:36 ` [PATCH v5 11/15] KVM: arm64: Reserve dirty ring space for the HDBSS buffer Tian Zheng
2026-09-29 11:00 ` sashiko-bot
2026-09-29 10:36 ` [PATCH v5 12/15] KVM: arm64: Derive the VM hardware dirty mode from dirty logging Tian Zheng
2026-09-29 11:16 ` sashiko-bot
2026-09-30 8:27 ` Tian Zheng
2026-09-29 10:36 ` [PATCH v5 13/15] KVM: arm64: Add HDBSS buffer size ioctl for dirty-bitmap mode Tian Zheng
2026-09-29 10:36 ` [PATCH v5 14/15] KVM: arm64: Document HDBSS buffer size ioctl Tian Zheng
2026-09-29 11:06 ` sashiko-bot
2026-09-29 10:36 ` [PATCH v5 15/15] KVM: arm64: selftests: Add HDBSS buffer size ioctl interface test Tian Zheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c624d394-d4c4-4335-9419-e83fdd0eae8f@huawei.com \
--to=zhengtian10@huawei.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox