From: Catalin Marinas <catalin.marinas@arm.com>
To: Kristina Martsenko <kristina.martsenko@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>,
Oliver Upton <oliver.upton@linux.dev>,
James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Mark Rutland <mark.rutland@arm.com>,
Mark Brown <broonie@kernel.org>,
Luis Machado <luis.machado@arm.com>,
Vladimir Murzin <vladimir.murzin@arm.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 04/10] arm64: mops: document boot requirements for MOPS
Date: Tue, 4 Apr 2023 11:50:34 +0100 [thread overview]
Message-ID: <ZCwA+rbmFT2HaZ7G@arm.com> (raw)
In-Reply-To: <61b0e30a-568c-d7f6-7b67-e9fc8b68de25@arm.com>
On Fri, Mar 24, 2023 at 01:00:43AM +0000, Kristina Martsenko wrote:
> On 17/03/2023 15:07, Catalin Marinas wrote:
> > On Thu, Feb 16, 2023 at 04:00:06PM +0000, Kristina Martsenko wrote:
> >> + For CPUs with Memory Copy and Memory Set instructions (FEAT_MOPS):
> >> +
> >> + - If the kernel is entered at EL1 and EL2 is present:
> >> +
> >> + - HCRX_EL2.MSCEn (bit 11) must be initialised to 0b1.
> >> +
> >> + - HCRX_EL2.MCE2 (bit 10) must be initialised to 0b0.
> >
> > Regarding MCE2, does EL1 actually care if EL2 wants to handle all the
> > memcpy/memset exceptions?
>
> No, EL1 does not need to handle the exceptions itself, but I don't see any
> current use case for allowing EL2 to handle it.
>
> If it was allowed, I think booting.txt would need to specify exactly what Linux
> expects EL2 to do if MCE2 is set (eg, that EL2 handles the exception by
> reformatting registers, modifying single step state, etc).
What I meant is that an EL1 kernel shouldn't care if MCE2 is 0 or 1. We
could clarify that if set to 1, it is expected that the hypervisor
handles the memory copy/set exceptions accordingly.
> > There may even be a valid case to do this at
> > EL2 if you run a guest that uses these instructions but has no clue on
> > how to deal with the specific exception like WrongOption.
>
> Not sure I follow - this series adds the exception handling, so how can a Linux
> guest not know how to handle the exception?
The guest may not always be Linux (e.g. some microkernel) and may not
expect the hardware implementation to change underneath.
> Or do you mean that there may be times when EL1 can't take the exception but
> EL2 may move it to another CPU, and so EL2 would need to handle the exception?
I haven't thought of this but it's actually a good point. Are there any
cases where Linux can't handle a memcpy exception? I guess we need to be
careful with taking such exception in an atomic context (e.g. no
rescheduling on the return path).
> I'm not sure if Linux ever uses mops instructions at times like that.
The compiler may generate a memcpy() call by simply assigning a
structure to another. So we can't control where those instructions are
used.
> Note that this series does not add support for mops in guests yet.
You mean there's no KVM support. But Linux may be run under a different
hypervisor (e.g. Hyper-V) as a guest.
> I think booting.txt can be updated when that support is added.
In booting.txt, when you say the kernel entered at EL1, it implies that
it may be run as a guest under a random hypervisor.
So maybe we should detail the MCE2 requirement a bit, saying that it can
be either 0 or 1 but, for the latter, the hypervisor must handle the
corresponding exceptions.
--
Catalin
next prev parent reply other threads:[~2023-04-04 10:50 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-16 16:00 [PATCH 00/10] arm64: support Armv8.8 memcpy instructions in userspace Kristina Martsenko
2023-02-16 16:00 ` [PATCH 01/10] KVM: arm64: initialize HCRX_EL2 Kristina Martsenko
2023-03-17 14:25 ` Catalin Marinas
2023-02-16 16:00 ` [PATCH 02/10] arm64: cpufeature: detect FEAT_HCX Kristina Martsenko
2023-03-17 14:25 ` Catalin Marinas
2023-02-16 16:00 ` [PATCH 03/10] KVM: arm64: switch HCRX_EL2 between host and guest Kristina Martsenko
2023-02-16 16:20 ` Mark Brown
2023-02-22 18:36 ` Kristina Martsenko
2023-02-16 16:35 ` Marc Zyngier
2023-02-22 18:42 ` Kristina Martsenko
2023-02-16 16:00 ` [PATCH 04/10] arm64: mops: document boot requirements for MOPS Kristina Martsenko
2023-03-17 15:07 ` Catalin Marinas
2023-03-24 1:00 ` Kristina Martsenko
2023-04-04 10:50 ` Catalin Marinas [this message]
2023-04-11 16:57 ` Kristina Martsenko
2023-02-16 16:00 ` [PATCH 05/10] arm64: mops: don't disable host MOPS instructions from EL2 Kristina Martsenko
2023-03-17 15:07 ` Catalin Marinas
2023-02-16 16:00 ` [PATCH 06/10] KVM: arm64: hide MOPS from guests Kristina Martsenko
2023-03-17 15:09 ` Catalin Marinas
2023-02-16 16:00 ` [PATCH 07/10] arm64: mops: handle MOPS exceptions Kristina Martsenko
2023-03-17 15:45 ` Catalin Marinas
2023-02-16 16:00 ` [PATCH 08/10] arm64: mops: handle single stepping after MOPS exception Kristina Martsenko
2023-03-17 16:02 ` Catalin Marinas
2023-02-16 16:00 ` [PATCH 09/10] arm64: mops: detect and enable FEAT_MOPS Kristina Martsenko
2023-02-16 16:22 ` Mark Brown
2023-03-17 16:03 ` Catalin Marinas
2023-02-16 16:00 ` [PATCH 10/10] arm64: mops: allow disabling MOPS from the kernel command line Kristina Martsenko
2023-03-17 16:04 ` Catalin Marinas
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=ZCwA+rbmFT2HaZ7G@arm.com \
--to=catalin.marinas@arm.com \
--cc=broonie@kernel.org \
--cc=james.morse@arm.com \
--cc=kristina.martsenko@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luis.machado@arm.com \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=suzuki.poulose@arm.com \
--cc=vladimir.murzin@arm.com \
--cc=will@kernel.org \
--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).