[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <86h6vwz125.wl-maz@kernel.org>
Date: Wed, 08 Feb 2023 14:25:38 +0000
From: Marc Zyngier <maz@...nel.org>
To: James Morse <james.morse@....com>
Cc: linux-pm@...r.kernel.org, loongarch@...ts.linux.dev,
kvmarm@...ts.linux.dev, kvm@...r.kernel.org,
linux-acpi@...r.kernel.org, linux-arch@...r.kernel.org,
linux-ia64@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, x86@...nel.org,
Thomas Gleixner <tglx@...utronix.de>,
Lorenzo Pieralisi <lpieralisi@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Sudeep Holla <sudeep.holla@....com>,
Borislav Petkov <bp@...en8.de>, H Peter Anvin <hpa@...or.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Ingo Molnar <mingo@...hat.com>, Will Deacon <will@...nel.org>,
Catalin Marinas <catalin.marinas@....com>,
Huacai Chen <chenhuacai@...nel.org>,
Suzuki K Poulose <suzuki.poulose@....com>,
Oliver Upton <oliver.upton@...ux.dev>,
Len Brown <lenb@...nel.org>,
Rafael Wysocki <rafael@...nel.org>,
WANG Xuerui <kernel@...0n.name>,
Salil Mehta <salil.mehta@...wei.com>,
Russell King <linux@...linux.org.uk>,
Jean-Philippe Brucker <jean-philippe@...aro.org>
Subject: Re: [RFC PATCH 29/32] KVM: arm64: Pass hypercalls to userspace
On Wed, 08 Feb 2023 08:40:09 +0000,
Marc Zyngier <maz@...nel.org> wrote:
>
> On Tue, 07 Feb 2023 17:50:58 +0000,
> James Morse <james.morse@....com> wrote:
> >
> > Hi Marc,
> >
> > On 05/02/2023 10:12, Marc Zyngier wrote:
> > > On Fri, 03 Feb 2023 13:50:40 +0000,
> > > James Morse <james.morse@....com> wrote:
> > >>
> > >> From: Jean-Philippe Brucker <jean-philippe@...aro.org>
> > >>
> > >> When capability KVM_CAP_ARM_HVC_TO_USER is available, userspace can
> > >> request to handle all hypercalls that aren't handled by KVM. With the
> > >> help of another capability, this will allow userspace to handle PSCI
> > >> calls.
> >
> > > On top of Oliver's ask not to make this a blanket "steal everything",
> > > but instead to have an actual request for ranges of forwarded
> > > hypercalls:
> > >
> > >> Notes on this implementation:
> > >>
> > >> * A similar mechanism was proposed for SDEI some time ago [1]. This RFC
> > >> generalizes the idea to all hypercalls, since that was suggested on
> > >> the list [2, 3].
> > >>
> > >> * We're reusing kvm_run.hypercall. I copied x0-x5 into
> > >> kvm_run.hypercall.args[] to help userspace but I'm tempted to remove
> > >> this, because:
> > >> - Most user handlers will need to write results back into the
> > >> registers (x0-x3 for SMCCC), so if we keep this shortcut we should
> > >> go all the way and read them back on return to kernel.
> > >> - QEMU doesn't care about this shortcut, it pulls all vcpu regs before
> > >> handling the call.
> > >> - SMCCC uses x0-x16 for parameters.
> > >> x0 does contain the SMCCC function ID and may be useful for fast
> > >> dispatch, we could keep that plus the immediate number.
> > >>
> > >> * Add a flag in the kvm_run.hypercall telling whether this is HVC or
> > >> SMC? Can be added later in those bottom longmode and pad fields.
> >
> > > We definitely need this. A nested hypervisor can (and does) use SMCs
> > > as the conduit.
> >
> > Christoffer's comments last time round on this was that EL2 guests
> > get SMC with this, and EL1 guests get HVC. The VMM could never get
> > both...
>
> I agree with the first half of the statement (EL2 guest using SMC),
> but limiting EL1 guests to HVC is annoying. On systems that have a
> secure side, it would make sense to be able to route the guest's SMC
> calls to userspace and allow it to emulate/proxy/deny such calls.
You also want to look at the TRNG firmware spec (aka DEN0098), which
explicitly calls out for the use of SMC when EL2 and EL3 are
implemented (see 1.5 "Invocation considerations").
Is it mad? Yes. But madness seems to be the direction of travel these
days.
M.
--
Without deviation from the norm, progress is not possible.
Powered by blists - more mailing lists