From: Oliver Upton <oliver.upton@linux.dev>
To: Yicong Yang <yangyicong@huawei.com>
Cc: yangyicong@hisilicon.com, catalin.marinas@arm.com,
will@kernel.org, maz@kernel.org, corbet@lwn.net,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org,
joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com,
shuah@kernel.org, jonathan.cameron@huawei.com,
shameerali.kolothum.thodi@huawei.com, linuxarm@huawei.com,
prime.zeng@hisilicon.com, xuwei5@huawei.com,
tangchengchang@huawei.com
Subject: Re: [PATCH v2 6/6] KVM: arm64: Handle DABT caused by LS64* instructions on unsupported memory
Date: Sun, 6 Apr 2025 22:35:25 -0700 [thread overview]
Message-ID: <Z_NkHWStDJLo0cmY@linux.dev> (raw)
In-Reply-To: <e9674079-9a22-c3cd-3b00-5989f6926303@huawei.com>
On Mon, Apr 07, 2025 at 11:33:01AM +0800, Yicong Yang wrote:
> On 2025/4/2 0:13, Oliver Upton wrote:
> > On Mon, Mar 31, 2025 at 05:43:20PM +0800, Yicong Yang wrote:
> >> @@ -1658,6 +1658,25 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
> > Keep in mind that data aborts with DFSC == 0x35 can happen for a lot
> > more than LS64 instructions, e.g. an atomic on a Device-* mapping.
> >
>
> got it. 0x35 should be caused by LS64* or IMPLEMENTATION DEFINED fault, but no
> further hint to distinguish between these two faults. hope it's also the right
> behaviour to inject a DABT back for the latter case.
There isn't exactly a 'right' behavior here. The abort could either be
due to a bug in the guest (doing an access on something knows it can't)
or the VMM creating / describing the IPA memory map incorrectly.
Since KVM can't really work out who's to blame in this situation we should
probably exit to userspace + provide a way to reinject the abort.
> >> @@ -1919,6 +1939,21 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu)
> >> goto out_unlock;
> >> }
> >>
> >> + /*
> >> + * If instructions of FEAT_{LS64, LS64_V} operated on
> >> + * unsupported memory regions, a DABT for unsupported
> >> + * Exclusive or atomic access is generated. It's
> >> + * implementation defined whether the exception will
> >> + * be taken to, a stage-1 DABT or the final enabled
> >> + * stage of translation (stage-2 in this case as we
> >> + * hit here). Inject a DABT to the guest to handle it
> >> + * if it's implemented as a stage-2 DABT.
> >> + */
> >> + if (esr_fsc_is_excl_atomic_fault(esr)) {
> >> + kvm_inject_dabt_excl_atomic(vcpu, kvm_vcpu_get_hfar(vcpu));
> >> + return 1;
> >> + }
> >> +
> >
> > A precondition of taking such a data abort is having a valid mapping at
> > stage-2. If KVM can't resolve the HVA of the fault then there couldn't
> > have been a stage-2 mapping.
> >
>
> Here's handling the case for emulated mmio, I thought there's no valid stage-2 mapping
> for the emulated MMIO? so this check is put just before entering io_mem_abort(). should
> it be put into io_mem_abort() or we just don't handle the emulated case?
Right -- there's no valid stage-2 translation for _most_ MMIO. If KVM
cannot find an HVA for the fault (look at the condition that gets us
here) then we know there isn't a stage-2 mapping. How would we know what
to map?
In that case I would expect to take a Translation fault with instruction
syndrome that can can be used to construct an exit to the VMM. Marc had
some patches on list to do exactly that [*].
However, after reading this again there's a rather ugly catch. The KVM
ABI has it that writes to a RO memlot generate an MMIO exit, so it *is*
possible to get here w/ a stage-2 mapping. Unfortunately there's no
instruction syndrome with DFSC = 0x35 so no way to decode the access.
This is starting to sound similar an nISV MMIO abort...
[*]: https://lore.kernel.org/kvmarm/20240815125959.2097734-1-maz@kernel.org/
Thanks,
Oliver
next prev parent reply other threads:[~2025-04-07 5:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-31 9:43 [PATCH v2 0/6] Add support for FEAT_{LS64, LS64_V} and related tests Yicong Yang
2025-03-31 9:43 ` [PATCH v2 1/6] arm64: Provide basic EL2 setup for FEAT_{LS64, LS64_V} usage at EL0/1 Yicong Yang
2025-04-03 9:04 ` Suzuki K Poulose
2025-04-07 3:50 ` Yicong Yang
2025-04-29 14:47 ` Will Deacon
2025-04-29 14:47 ` Will Deacon
2025-03-31 9:43 ` [PATCH v2 2/6] arm64: Add support for FEAT_{LS64, LS64_V} Yicong Yang
2025-03-31 9:43 ` [PATCH v2 3/6] KVM: arm64: Enable FEAT_{LS64, LS64_V} in the supported guest Yicong Yang
2025-03-31 9:43 ` [PATCH v2 4/6] kselftest/arm64: Add HWCAP test for FEAT_{LS64, LS64_V} Yicong Yang
2025-03-31 9:43 ` [PATCH v2 5/6] arm64: Add ESR.DFSC definition of unsupported exclusive or atomic access Yicong Yang
2025-04-01 16:15 ` Oliver Upton
2025-04-07 3:33 ` Yicong Yang
2025-03-31 9:43 ` [PATCH v2 6/6] KVM: arm64: Handle DABT caused by LS64* instructions on unsupported memory Yicong Yang
2025-04-01 16:13 ` Oliver Upton
2025-04-07 3:33 ` Yicong Yang
2025-04-07 5:35 ` Oliver Upton [this message]
2025-04-08 8:11 ` Yicong Yang
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=Z_NkHWStDJLo0cmY@linux.dev \
--to=oliver.upton@linux.dev \
--cc=catalin.marinas@arm.com \
--cc=corbet@lwn.net \
--cc=joey.gouly@arm.com \
--cc=jonathan.cameron@huawei.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=maz@kernel.org \
--cc=prime.zeng@hisilicon.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=shuah@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=tangchengchang@huawei.com \
--cc=will@kernel.org \
--cc=xuwei5@huawei.com \
--cc=yangyicong@hisilicon.com \
--cc=yangyicong@huawei.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.