Re: [PATCH v4 11/21] KVM: arm64: Support SDEI_PE_{MASK, UNMASK} hypercall

Eric Auger
2021-11-09T20:31:43Z

Hi Gavin,

On 8/15/21 2:13 AM, Gavin Shan wrote:
> This supports SDEI_PE_{MASK, UNMASK} hypercall. They are used by
> the guest to stop the specific vCPU from receiving SDEI events.
>
> Signed-off-by: Gavin Shan <gshan@redhat.com>
> ---
> arch/arm64/kvm/sdei.c | 35 +++++++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c
> index 458695c2394f..3fb33258b494 100644
> --- a/arch/arm64/kvm/sdei.c
> +++ b/arch/arm64/kvm/sdei.c
> @@ -551,6 +551,37 @@ static unsigned long kvm_sdei_hypercall_route(struct kvm_vcpu *vcpu)
> return ret;
> }
>
> +static unsigned long kvm_sdei_hypercall_mask(struct kvm_vcpu *vcpu,
> + bool mask)
> +{
> + struct kvm *kvm = vcpu->kvm;
> + struct kvm_sdei_kvm *ksdei = kvm->arch.sdei;
> + struct kvm_sdei_vcpu *vsdei = vcpu->arch.sdei;
> + unsigned long ret = SDEI_SUCCESS;
> +
> + /* Sanity check */
> + if (!(ksdei && vsdei)) {
> + ret = SDEI_NOT_SUPPORTED;
> + goto out;
> + }
> +
> + spin_lock(&vsdei->lock);
> +
> + /* Check the state */
> + if (mask == vsdei->state.masked) {
> + ret = SDEI_DENIED;
are you sure? I don't this error documented in 5.1.12?

Besides the spec says:
"
This call can be invoked by the client to mask the PE, whether or not
the PE is already masked."
> + goto unlock;
> + }
> +
> + /* Update the state */
> + vsdei->state.masked = mask ? 1 : 0;
> +
> +unlock:
> + spin_unlock(&vsdei->lock);
> +out:
> + return ret;
In case of success the returned value is SUCESS for UNMASK but not for
MASK (see table in 5.1.12).

By the way I have just noticed there is a more recent of the spec than
the A:

ARM_DEN0054C

You should update the cover letter and [PATCH v4 02/21] KVM: arm64: Add
SDEI virtualization infrastructure commit msg

> +}
> +
> int kvm_sdei_hypercall(struct kvm_vcpu *vcpu)
> {
> u32 func = smccc_get_function(vcpu);
> @@ -588,7 +619,11 @@ int kvm_sdei_hypercall(struct kvm_vcpu *vcpu)
> ret = kvm_sdei_hypercall_route(vcpu);
> break;
> case SDEI_1_0_FN_SDEI_PE_MASK:
> + ret = kvm_sdei_hypercall_mask(vcpu, true);
> + break;
> case SDEI_1_0_FN_SDEI_PE_UNMASK:
> + ret = kvm_sdei_hypercall_mask(vcpu, false);
> + break;
> case SDEI_1_0_FN_SDEI_INTERRUPT_BIND:
> case SDEI_1_0_FN_SDEI_INTERRUPT_RELEASE:
> case SDEI_1_0_FN_SDEI_PRIVATE_RESET:
>
Eric