lkml.org 
[lkml]   [2020]   [Dec]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v3 16/23] kvm: arm64: Forward safe PSCI SMCs coming from host
On Fri, Nov 27, 2020 at 04:51:59PM +0000, Sudeep Holla wrote:
> On Thu, Nov 26, 2020 at 03:54:14PM +0000, David Brazdil wrote:
> > Forward the following PSCI SMCs issued by host to EL3 as they do not
> > require the hypervisor's intervention. This assumes that EL3 correctly
> > implements the PSCI specification.
> >
> > Only function IDs implemented in Linux are included.
> >
> > Where both 32-bit and 64-bit variants exist, it is assumed that the host
> > will always use the 64-bit variant.
> >
> > * SMCs that only return information about the system
> > * PSCI_VERSION - PSCI version implemented by EL3
> > * PSCI_FEATURES - optional features supported by EL3
> > * AFFINITY_INFO - power state of core/cluster
> > * MIGRATE_INFO_TYPE - whether Trusted OS can be migrated
> > * MIGRATE_INFO_UP_CPU - resident core of Trusted OS
> > * operations which do not affect the hypervisor
> > * MIGRATE - migrate Trusted OS to a different core
> > * SET_SUSPEND_MODE - toggle OS-initiated mode
> > * system shutdown/reset
> > * SYSTEM_OFF
> > * SYSTEM_RESET
> > * SYSTEM_RESET2
> >
> > Signed-off-by: David Brazdil <dbrazdil@google.com>
> > ---
> > arch/arm64/kvm/hyp/nvhe/psci-relay.c | 43 +++++++++++++++++++++++++++-
> > 1 file changed, 42 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm64/kvm/hyp/nvhe/psci-relay.c b/arch/arm64/kvm/hyp/nvhe/psci-relay.c
> > index e7091d89f0fc..7aa87ab7f5ce 100644
> > --- a/arch/arm64/kvm/hyp/nvhe/psci-relay.c
> > +++ b/arch/arm64/kvm/hyp/nvhe/psci-relay.c
> > @@ -57,14 +57,51 @@ static bool is_psci_call(u64 func_id)
> > }
> > }
> >
> > +static unsigned long psci_call(unsigned long fn, unsigned long arg0,
> > + unsigned long arg1, unsigned long arg2)
> > +{
> > + struct arm_smccc_res res;
> > +
> > + arm_smccc_1_1_smc(fn, arg0, arg1, arg2, &res);
> > + return res.a0;
> > +}
> > +
> > +static unsigned long psci_forward(struct kvm_cpu_context *host_ctxt)
> > +{
> > + return psci_call(cpu_reg(host_ctxt, 0), cpu_reg(host_ctxt, 1),
> > + cpu_reg(host_ctxt, 2), cpu_reg(host_ctxt, 3));
> > +}
> > +
> > +static __noreturn unsigned long psci_forward_noreturn(struct kvm_cpu_context *host_ctxt)
> > +{
> > + psci_forward(host_ctxt);
> > + hyp_panic(); /* unreachable */
> > +}
> > +
> > static unsigned long psci_0_1_handler(u64 func_id, struct kvm_cpu_context *host_ctxt)
> > {
> > - return PSCI_RET_NOT_SUPPORTED;
> > + if (func_id == kvm_host_psci_function_id[PSCI_FN_CPU_OFF])
> > + return psci_forward(host_ctxt);
> > + else if (func_id == kvm_host_psci_function_id[PSCI_FN_MIGRATE])
> > + return psci_forward(host_ctxt);
>
> Looks weird or I am not seeing something right ? Same action for both
> right ? Can't they be combined ?

Sure, happy to combine them. I thought visually it made sense to have one
action per ID.

\
 
 \ /
  Last update: 2020-12-01 14:22    [W:0.062 / U:3.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site