public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm•com>
To: Heyi Guo <guoheyi@huawei•com>
Cc: "Mark Rutland" <mark.rutland@arm•com>,
	"Peter Maydell" <peter.maydell@linaro•org>,
	kvm@vger•kernel.org, "Suzuki K Poulose" <suzuki.poulose@arm•com>,
	"Marc Zyngier" <marc.zyngier@arm•com>,
	"Catalin Marinas" <catalin.marinas@arm•com>,
	"Radim Krčmář" <rkrcmar@redhat•com>,
	linux-kernel@vger•kernel.org, "Dave Martin" <Dave.Martin@arm•com>,
	qemu-arm@nongnu•org,
	"Julien Thierry" <julien.thierry.kdev@gmail•com>,
	"Paolo Bonzini" <pbonzini@redhat•com>,
	wanghaibin.wang@huawei•com, "Will Deacon" <will@kernel•org>,
	kvmarm@lists•cs.columbia.edu,
	linux-arm-kernel@lists•infradead.org
Subject: Re: [RFC PATCH 2/2] kvm/arm64: expose hypercall_forwarding capability
Date: Tue, 1 Oct 2019 18:19:30 +0100	[thread overview]
Message-ID: <bd2c398b-7703-03a2-052b-1414630d0b43@arm.com> (raw)
In-Reply-To: <1569338454-26202-3-git-send-email-guoheyi@huawei.com>

Hi Heyi,

On 24/09/2019 16:20, Heyi Guo wrote:
> Add new KVM capability "KVM_CAP_FORWARD_HYPERCALL" for user space to
> probe whether KVM supports forwarding hypercall.
> 
> The capability should be enabled by user space explicitly, for we
> don't want user space application to deal with unexpected hypercall
> exits. We also use an additional argument to pass exception bit mask,
> to request KVM to forward all hypercalls except the classes specified
> in the bit mask.
> 
> Currently only PSCI can be set as exception, so that we can still keep
> consistent with the old PSCI processing flow.

I agree this needs to be default-on, but I don't think this exclusion mechanism is extensible.


> diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c
> index f4a8ae9..2201b62 100644
> --- a/arch/arm64/kvm/reset.c
> +++ b/arch/arm64/kvm/reset.c
> @@ -102,6 +105,28 @@ int kvm_arch_vm_ioctl_check_extension(struct kvm *kvm, long ext)
>  	return r;
>  }
>  
> +int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
> +			    struct kvm_enable_cap *cap)
> +{
> +	if (cap->flags)
> +		return -EINVAL;
> +
> +	switch (cap->cap) {
> +	case KVM_CAP_FORWARD_HYPERCALL: {
> +		__u64 exclude_flags = cap->args[0];

and if there are more than 64 things to exclude?


> +		/* Only support excluding PSCI right now */
> +		if (exclude_flags & ~KVM_CAP_FORWARD_HYPERCALL_EXCL_PSCI)
> +			return -EINVAL;

Once we have a 65th bit, older kernels will let user-space set it, but nothing happens.


> +		kvm->arch.hypercall_forward = true;
> +		if (exclude_flags & KVM_CAP_FORWARD_HYPERCALL_EXCL_PSCI)
> +			kvm->arch.hypercall_excl_psci = true;
> +		return 0;
> +	}
> +	}
> +
> +	return -EINVAL;
> +}

While 4*64 'named bits' for SMC/HVC ranges might be enough, it is tricky to work with.
Both the kernel and user-space have to maintain a list of bit->name and
name->call-number-range, which may change over time.

A case in point: According to PSCI's History (Section 7 of DEN022D), PSCIv1.1 added
SYSTEM_RESET2, MEM_PROTECT and MEM_PROTECT_CHECK_RANGE.

I think its simpler for the HYPERCALL thing to act as a catch-all, and we provide
something to enumerate the list of function id's the kernel implements.

We can then add controls to disable the PSCI (which I think is the only one we have a case
for disabling). I think the PSCI disable should wait until it has a user.


Thanks,

James

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists•infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      reply	other threads:[~2019-10-01 17:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-24 15:20 [RFC PATCH 0/2] Add virtual SDEI support for arm64 Heyi Guo
2019-09-24 15:20 ` [RFC PATCH 1/2] kvm/arm: add capability to forward hypercall to user space Heyi Guo
2019-10-01 17:19   ` James Morse
2019-10-09 12:33     ` Guoheyi
2019-10-21 16:42       ` James Morse
2019-10-31 13:07         ` Guoheyi
2019-09-24 15:20 ` [RFC PATCH 2/2] kvm/arm64: expose hypercall_forwarding capability Heyi Guo
2019-10-01 17:19   ` James Morse [this message]

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=bd2c398b-7703-03a2-052b-1414630d0b43@arm.com \
    --to=james.morse@arm$(echo .)com \
    --cc=Dave.Martin@arm$(echo .)com \
    --cc=catalin.marinas@arm$(echo .)com \
    --cc=guoheyi@huawei$(echo .)com \
    --cc=julien.thierry.kdev@gmail$(echo .)com \
    --cc=kvm@vger$(echo .)kernel.org \
    --cc=kvmarm@lists$(echo .)cs.columbia.edu \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=marc.zyngier@arm$(echo .)com \
    --cc=mark.rutland@arm$(echo .)com \
    --cc=pbonzini@redhat$(echo .)com \
    --cc=peter.maydell@linaro$(echo .)org \
    --cc=qemu-arm@nongnu$(echo .)org \
    --cc=rkrcmar@redhat$(echo .)com \
    --cc=suzuki.poulose@arm$(echo .)com \
    --cc=wanghaibin.wang@huawei$(echo .)com \
    --cc=will@kernel$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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