[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <28219c6a-5200-b8f3-09e1-6aa08565030a@redhat.com>
Date: Wed, 12 Jan 2022 10:33:50 +0800
From: Gavin Shan <gshan@...hat.com>
To: Eric Auger <eauger@...hat.com>, kvmarm@...ts.cs.columbia.edu
Cc: maz@...nel.org, linux-kernel@...r.kernel.org,
Jonathan.Cameron@...wei.com, pbonzini@...hat.com, will@...nel.org
Subject: Re: [PATCH v4 06/21] KVM: arm64: Support SDEI_EVENT_CONTEXT hypercall
Hi Eric,
On 11/10/21 7:16 PM, Eric Auger wrote:
> On 8/15/21 2:13 AM, Gavin Shan wrote:
>> This supports SDEI_EVENT_CONTEXT hypercall. It's used by the guest
>> to retrieved the original registers (R0 - R17) in its SDEI event
>> handler. Those registers can be corrupted during the SDEI event
>> delivery.
>>
>> Signed-off-by: Gavin Shan <gshan@...hat.com>
>> ---
>> arch/arm64/kvm/sdei.c | 40 ++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 40 insertions(+)
>>
>> diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c
>> index b022ce0a202b..b4162efda470 100644
>> --- a/arch/arm64/kvm/sdei.c
>> +++ b/arch/arm64/kvm/sdei.c
>> @@ -270,6 +270,44 @@ static unsigned long kvm_sdei_hypercall_enable(struct kvm_vcpu *vcpu,
>> return ret;
>> }
>>
>> +static unsigned long kvm_sdei_hypercall_context(struct kvm_vcpu *vcpu)
>> +{
>> + struct kvm *kvm = vcpu->kvm;
>> + struct kvm_sdei_kvm *ksdei = kvm->arch.sdei;
>> + struct kvm_sdei_vcpu *vsdei = vcpu->arch.sdei;
>> + struct kvm_sdei_vcpu_regs *regs;
>> + unsigned long index = smccc_get_arg1(vcpu);
> s/index/param_id to match the spec?
Sure, but "reg_id" seems better here. As the parameter indicates the GPR index
to be fetched on request of the guest kernel.
>> + unsigned long ret = SDEI_SUCCESS;
>> +
>> + /* Sanity check */
>> + if (!(ksdei && vsdei)) {
>> + ret = SDEI_NOT_SUPPORTED;
>> + goto out;
>> + }
>> +
>> + if (index > ARRAY_SIZE(vsdei->state.critical_regs.regs)) {
>> + ret = SDEI_INVALID_PARAMETERS;
>> + goto out;
>> + }
> I would move the above after regs = and use regs there (although the
> regs ARRAY_SIZE of both is identifical)
Ok.
>> +
>> + /* Check if the pending event exists */
>> + spin_lock(&vsdei->lock);
>> + if (!(vsdei->critical_event || vsdei->normal_event)) {
>> + ret = SDEI_DENIED;
>> + goto unlock;
>> + }
>> +
>> + /* Fetch the requested register */
>> + regs = vsdei->critical_event ? &vsdei->state.critical_regs :
>> + &vsdei->state.normal_regs;
>> + ret = regs->regs[index];
>> +
>> +unlock:
>> + spin_unlock(&vsdei->lock);
>> +out:
>> + return ret;
>> +}
>> +
>> int kvm_sdei_hypercall(struct kvm_vcpu *vcpu)
>> {
>> u32 func = smccc_get_function(vcpu);
>> @@ -290,6 +328,8 @@ int kvm_sdei_hypercall(struct kvm_vcpu *vcpu)
>> ret = kvm_sdei_hypercall_enable(vcpu, false);
>> break;
>> case SDEI_1_0_FN_SDEI_EVENT_CONTEXT:
>> + ret = kvm_sdei_hypercall_context(vcpu);
>> + break;
>> case SDEI_1_0_FN_SDEI_EVENT_COMPLETE:
>> case SDEI_1_0_FN_SDEI_EVENT_COMPLETE_AND_RESUME:
>> case SDEI_1_0_FN_SDEI_EVENT_UNREGISTER:
>>
Thanks,
Gavin
Powered by blists - more mailing lists