linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: <oliver.upton@linux.dev>, Yicong Yang <yangyicong@huawei.com>
Cc: <yangyicong@hisilicon.com>, <catalin.marinas@arm.com>,
	<will@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>, <wangzhou1@hisilicon.com>
Subject: Re: [PATCH v3 3/7] KVM: arm64: Handle DABT caused by LS64* instructions on unsupported memory
Date: Fri, 27 Jun 2025 14:12:29 +0100	[thread overview]
Message-ID: <86v7ohba6a.wl-maz@kernel.org> (raw)
In-Reply-To: <44993060-7eb1-400c-9887-3d438aeb8ee9@huawei.com>

On Thu, 26 Jun 2025 12:39:41 +0100,
Yicong Yang <yangyicong@huawei.com> wrote:
> 
> On 2025/6/26 16:51, Marc Zyngier wrote:
> > On Thu, 26 Jun 2025 09:09:02 +0100,
> > Yicong Yang <yangyicong@huawei.com> wrote:

[...]

> >>
> >> +	/*
> >> +	 * Target address is normal memory on the Host. We come here
> >> +	 * because:
> >> +	 * 1) Guest map it as device memory and perform LS64 operations
> >> +	 * 2) VMM report it as device memory mistakenly
> >> +	 * Hand it to the userspace.
> >> +	 */
> >> +	if (esr_fsc_is_excl_atomic_fault(kvm_vcpu_get_esr(vcpu))) {
> >> +		struct kvm_run *run = vcpu->run;
> >> +
> >> +		run->exit_reason = KVM_EXIT_ARM_LDST64B;
> >> +		run->arm_nisv.esr_iss = kvm_vcpu_dabt_iss_nisv_sanitized(vcpu);
> >> +		run->arm_nisv.fault_ipa = fault_ipa |
> >> +			(kvm_vcpu_get_hfar(vcpu) & (vma_pagesize - 1));
> >> +
> >> +		return -EAGAIN;
> >> +	}
> > 
> > I'm not sure that's the right thing to do.
> > 
> > If:
> > 
> > - the guest was told it doesn't have LS64WB,
> > 
> > - it was told that some range is memory,
> > 
> > - it uses that range as device,
> > 
> > - thanks to FWB the resulting memory type is "Normal-Cacheable"
> > 
> > - which results in an Unsupported Atomic exception
> > 
> > why would we involve the VMM at all? The VMM clearly said it didn't
> > want to be involved in this (we have a memslot).
> > 
> 
> ok I thought we should make VMM do the decision in all the cases(both
> here and emulated MMIO) based on the last discussion[*], I may
> misunderstand it. If this is the case...
> 
> > I think we should simply inject the corresponding S1 fault back into
> > the guest.
> > 
> 
> let's simply inject a corresponding DABT back here and only make the VMM
> handle the emulated MMIO case. will update if no further comment.

A permission fault at S2 for a R/O memslot should definitely be
relayed to userspace. But the question is whether the HW would report
a permission fault or an unsupported atomic or exclusive fault (UAoEF
for short).

If the HW supports LS64WB, I'd fully expect to get a permission fault,
not an UAoEF, and we can perfectly report this to userspace with full
decode information (though this doesn't fit in the KVM_EXIT_MMIO
structure -- that's "only" an ABI problem).

If it doesn't, then we have a much bigger issue, and I don't think we
can realistically triage the exception in a meaningful way -- we just
can't know the reason why we failed, and we don't even know whether
this was a load or store.

Overall, I can see two options here:

- we limit the LS64 support to HW that supports LS64WB (too bad for
  the other implementations, which is 100% of them). We can always
  triage the exception correctly, and we're unlikely to ever take an
  UAoEF in this context.

- we define that R/O memslots do not support LS64 accesses at all,
  which is always a valid implementation -- the architecture makes no
  provision of which pieces of addressable memory supports an access
  type or another. With that, we can always inject the UAoEF back into
  the guest without any further triaging.

Oliver, what do you think?

	M.

-- 
Without deviation from the norm, progress is not possible.

  reply	other threads:[~2025-06-27 13:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-26  8:08 [PATCH v3 0/7] Add support for FEAT_{LS64, LS64_V} and related tests Yicong Yang
2025-06-26  8:09 ` [PATCH v3 1/7] KVM: arm64: Add exit to userspace on {LD,ST}64B* outside of memslots Yicong Yang
2025-06-26  8:09 ` [PATCH v3 2/7] KVM: arm64: Add documentation for KVM_EXIT_ARM_LDST64B Yicong Yang
2025-06-26  8:09 ` [PATCH v3 3/7] KVM: arm64: Handle DABT caused by LS64* instructions on unsupported memory Yicong Yang
2025-06-26  8:51   ` Marc Zyngier
2025-06-26 11:39     ` Yicong Yang
2025-06-27 13:12       ` Marc Zyngier [this message]
2025-07-01 12:31         ` Yicong Yang
2025-06-26  8:09 ` [PATCH v3 4/7] KVM: arm/arm64: Allow user injection of unsupported exclusive/atomic DABT Yicong Yang
2025-06-26  8:11   ` Yicong Yang
2025-06-26  8:09 ` [PATCH v3 5/7] arm64: Provide basic EL2 setup for FEAT_{LS64, LS64_V} usage at EL0/1 Yicong Yang
2025-06-26  8:09 ` [PATCH v3 6/7] arm64: Add support for FEAT_{LS64, LS64_V} Yicong Yang
2025-06-26  8:09 ` [PATCH v3 7/7] KVM: arm64: Enable FEAT_{LS64, LS64_V} in the supported guest 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=86v7ohba6a.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --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=oliver.upton@linux.dev \
    --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=wangzhou1@hisilicon.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).