[RFC PATCH v2 5/6] KVM: arm64: Add support for KVM_EXIT_HYPERCALL

Oliver Upton oliver.upton at linux.dev
Fri Feb 24 13:42:48 PST 2023


Hi James,

On Fri, Feb 24, 2023 at 03:12:33PM +0000, James Morse wrote:
> On 11/02/2023 01:37, Oliver Upton wrote:
> > +static void kvm_prepare_hypercall_exit(struct kvm_vcpu *vcpu, u32 func_id, bool smc)
> > +{
> > +	struct kvm_run *run = vcpu->run;
> > +
> > +	run->exit_reason = KVM_EXIT_HYPERCALL;
> 
> > +	run->hypercall.nr = func_id;
> 
> This is a bit weird. The func_id is the x0 value, so it would more naturally live in
> run->hypercall.args[0].
> 
> User-space also needs the SMC/HVC immediate value, as that is only available in the ESR.
> It makes more sense to put the immediate value here.

Completely buy that userspace has no way of getting at the immediate.
But why do we need to expose it in the first place?

The UAPI here has been constructed around SMCCC, so the immediate should
be zero across the board. Sure, SMCCC says that nonzero values can be
used by the hypervisor, but in that case the register interface needn't
follow SMCCC (i.e. what if the function ID is in x7 for some silly
reason).

Curious if there's a use case you had in mind I haven't thought of.

> > +	if (smc)
> > +		run->hypercall.flags = KVM_HYPERCALL_EXIT_SMC;

Drive by self-review (be warned!): flags needs explicit zeroing,
otherwise this flag will remain up for a subsequent HVC.

-- 
Thanks,
Oliver



More information about the linux-arm-kernel mailing list