Re: [PATCH 2/5] KVM: arm64: Implement PV_LOCK_FEATURES call
From: yezengruan
Date: Thu Dec 19 2019 - 06:59:13 EST
Hi Steve,
On 2019/12/17 22:28, Steven Price wrote:
> On Tue, Dec 17, 2019 at 01:55:46PM +0000, yezengruan@xxxxxxxxxx wrote:
>> From: Zengruan Ye <yezengruan@xxxxxxxxxx>
>>
>> This provides a mechanism for querying which paravirtualized lock
>> features are available in this hypervisor.
>>
>> Also add the header file which defines the ABI for the paravirtualized
>> lock features we're about to add.
>>
>> Signed-off-by: Zengruan Ye <yezengruan@xxxxxxxxxx>
>> ---
>> arch/arm64/include/asm/pvlock-abi.h | 16 ++++++++++++++++
>> include/linux/arm-smccc.h | 13 +++++++++++++
>> virt/kvm/arm/hypercalls.c | 3 +++
>> 3 files changed, 32 insertions(+)
>> create mode 100644 arch/arm64/include/asm/pvlock-abi.h
>>
>> diff --git a/arch/arm64/include/asm/pvlock-abi.h b/arch/arm64/include/asm/pvlock-abi.h
>> new file mode 100644
>> index 000000000000..06e0c3d7710a
>> --- /dev/null
>> +++ b/arch/arm64/include/asm/pvlock-abi.h
>> @@ -0,0 +1,16 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +/*
>> + * Copyright(c) 2019 Huawei Technologies Co., Ltd
>> + * Author: Zengruan Ye <yezengruan@xxxxxxxxxx>
>> + */
>> +
>> +#ifndef __ASM_PVLOCK_ABI_H
>> +#define __ASM_PVLOCK_ABI_H
>> +
>> +struct pvlock_vcpu_state {
>> + __le64 preempted;
>
> Somewhere we need to document when 'preempted' is. It looks like it's a
> 1-bit field from the later patches.
Good point, I'll document this in the pvlock doc.
>
>> + /* Structure must be 64 byte aligned, pad to that size */
>> + u8 padding[56];
>> +} __packed;
>> +
>> +#endif
>> diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h
>> index 59494df0f55b..59e65a951959 100644
>> --- a/include/linux/arm-smccc.h
>> +++ b/include/linux/arm-smccc.h
>> @@ -377,5 +377,18 @@ asmlinkage void __arm_smccc_hvc(unsigned long a0, unsigned long a1,
>> ARM_SMCCC_OWNER_STANDARD_HYP, \
>> 0x21)
>>
>> +/* Paravirtualised lock calls */
>> +#define ARM_SMCCC_HV_PV_LOCK_FEATURES \
>> + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \
>> + ARM_SMCCC_SMC_64, \
>> + ARM_SMCCC_OWNER_STANDARD_HYP, \
>> + 0x40)
>> +
>> +#define ARM_SMCCC_HV_PV_LOCK_PREEMPTED \
>> + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \
>> + ARM_SMCCC_SMC_64, \
>> + ARM_SMCCC_OWNER_STANDARD_HYP, \
>> + 0x41)
>> +
>> #endif /*__ASSEMBLY__*/
>> #endif /*__LINUX_ARM_SMCCC_H*/
>> diff --git a/virt/kvm/arm/hypercalls.c b/virt/kvm/arm/hypercalls.c
>> index 550dfa3e53cd..ff13871fd85a 100644
>> --- a/virt/kvm/arm/hypercalls.c
>> +++ b/virt/kvm/arm/hypercalls.c
>> @@ -52,6 +52,9 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)
>> case ARM_SMCCC_HV_PV_TIME_FEATURES:
>> val = SMCCC_RET_SUCCESS;
>> break;
>> + case ARM_SMCCC_HV_PV_LOCK_FEATURES:
>> + val = SMCCC_RET_SUCCESS;
>> + break;
>
> Ideally you wouldn't report that PV_LOCK_FEATURES exists until the
> actual hypercalls are wired up to avoid breaking a bisect.
Thanks for pointing it out to me! I'll update the code.
>
> Steve
>
>> }
>> break;
>> case ARM_SMCCC_HV_PV_TIME_FEATURES:
>> --
>> 2.19.1
>>
>>
>
> .
>
Thanks,
Zengruan