From: "Thomson, Jack" <jackabt.amazon@gmail.com>
To: Marc Zyngier <maz@kernel.org>
Cc: oliver.upton@linux.dev, pbonzini@redhat.com, joey.gouly@arm.com,
suzuki.poulose@arm.com, yuzenghui@huawei.com,
catalin.marinas@arm.com, will@kernel.org, shuah@kernel.org,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
isaku.yamahata@intel.com, xmarcalx@amazon.co.uk,
kalyazin@amazon.co.uk, jackabt@amazon.com
Subject: Re: [PATCH v3 1/3] KVM: arm64: Add pre_fault_memory implementation
Date: Wed, 26 Nov 2025 17:14:05 +0000 [thread overview]
Message-ID: <5cffcb56-26f7-4dac-a0ae-44329084d27d@gmail.com> (raw)
In-Reply-To: <86pl97r3ox.wl-maz@kernel.org>
On 24/11/2025 12:54 pm, Marc Zyngier wrote:
> On Mon, 24 Nov 2025 11:34:38 +0000,
> Marc Zyngier <maz@kernel.org> wrote:
>>
>> On Wed, 19 Nov 2025 15:49:08 +0000,
>> Jack Thomson <jackabt.amazon@gmail.com> wrote:
>>>
>
> [...]
>
>>> + fault_info->hpfar_el2 = HPFAR_EL2_NS |
>>> + FIELD_PREP(HPFAR_EL2_FIPA, ipa >> 12);
>>> +
>>> + if (kvm_slot_has_gmem(memslot)) {
>>> + ret = gmem_abort(vcpu, ipa, NULL, memslot, false);
>>> + } else {
>>> + hva = gfn_to_hva_memslot_prot(memslot, gfn, NULL);
>>> + if (kvm_is_error_hva(hva)) {
>>> + ret = -EFAULT;
>>> + goto out;
>>> + }
>>> + ret = user_mem_abort(vcpu, ipa, NULL, memslot, &page_size, hva,
>>> + false);
>>> + }
>
> And thinking of it a bit more, this is completely broken. What happens
> if the vcpu is in a nested context? You just populate random pages in
> an IPA space that is not relevant at all, corrupting the guest state.
>
> You must correctly handle the context the vcpu is in, instead of
> assuming that this is the canonical context. This means going via the
> *guest's* S2 translation, just like handle_mem_abort() does.
>
> M.
>
Thanks Marc for taking a look, I'll update to fix these issues and
address the other comments.
--
Thanks,
Jack
next prev parent reply other threads:[~2025-11-26 17:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-19 15:49 [PATCH v3 0/3] KVM ARM64 pre_fault_memory Jack Thomson
2025-11-19 15:49 ` [PATCH v3 1/3] KVM: arm64: Add pre_fault_memory implementation Jack Thomson
2025-11-24 10:38 ` Vladimir Murzin
2025-11-24 11:34 ` Marc Zyngier
2025-11-24 12:54 ` Marc Zyngier
2025-11-26 17:14 ` Thomson, Jack [this message]
2025-12-15 11:43 ` Thomson, Jack
2025-11-19 15:49 ` [PATCH v3 2/3] KVM: selftests: Enable pre_fault_memory_test for arm64 Jack Thomson
2025-12-05 17:33 ` Vincent Donnefort
2025-11-19 15:49 ` [PATCH v3 3/3] KVM: selftests: Add option for different backing in pre-fault tests Jack Thomson
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=5cffcb56-26f7-4dac-a0ae-44329084d27d@gmail.com \
--to=jackabt.amazon@gmail.com \
--cc=catalin.marinas@arm.com \
--cc=isaku.yamahata@intel.com \
--cc=jackabt@amazon.com \
--cc=joey.gouly@arm.com \
--cc=kalyazin@amazon.co.uk \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
--cc=shuah@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
--cc=xmarcalx@amazon.co.uk \
--cc=yuzenghui@huawei.com \
/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