Message ID | 20250124151732.6072-3-shameerali.kolothum.thodi@huawei.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | KVM: arm64: Errata management for VM Live migration | expand |
On Fri, Jan 24 2025, Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> wrote: > If the Guest requires migration to multiple targets, these hypercalls > will provide a way to retrieve the target CPU implementations from > the user space VMM. > > Subsequent patch will use this to enable the associated errata. > > Suggested-by: Oliver Upton <oliver.upton@linux.dev> > Suggested-by: Marc Zyngier <maz@kernel.org> > Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> > --- > Documentation/virt/kvm/arm/hypercalls.rst | 59 +++++++++++++++++++++++ > include/linux/arm-smccc.h | 15 ++++++ > 2 files changed, 74 insertions(+) Reviewed-by: Cornelia Huck <cohuck@redhat.com>
On Fri, Jan 24, 2025 at 03:17:30PM +0000, Shameer Kolothum wrote: > If the Guest requires migration to multiple targets, these hypercalls > will provide a way to retrieve the target CPU implementations from > the user space VMM. > > Subsequent patch will use this to enable the associated errata. > > Suggested-by: Oliver Upton <oliver.upton@linux.dev> > Suggested-by: Marc Zyngier <maz@kernel.org> > Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> > --- > Documentation/virt/kvm/arm/hypercalls.rst | 59 +++++++++++++++++++++++ > include/linux/arm-smccc.h | 15 ++++++ > 2 files changed, 74 insertions(+) > > diff --git a/Documentation/virt/kvm/arm/hypercalls.rst b/Documentation/virt/kvm/arm/hypercalls.rst > index af7bc2c2e0cb..718725cbf6c7 100644 > --- a/Documentation/virt/kvm/arm/hypercalls.rst > +++ b/Documentation/virt/kvm/arm/hypercalls.rst > @@ -142,3 +142,62 @@ region is equal to the memory protection granule advertised by > | | | +---------------------------------------------+ > | | | | ``INVALID_PARAMETER (-3)`` | > +---------------------+----------+----+---------------------------------------------+ > + > +``ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_VER_FUNC_ID`` > +------------------------------------------------------- > +Request the target CPU implementation version information and the number of target > +implementations for the Guest VM. > + > ++---------------------+-------------------------------------------------------------+ > +| Presence: | Optional; KVM/ARM64 Guests only | > ++---------------------+-------------------------------------------------------------+ > +| Calling convention: | HVC64 | > ++---------------------+----------+--------------------------------------------------+ > +| Function ID: | (uint32) | 0xC6000040 | > ++---------------------+----------+--------------------------------------------------+ > +| Arguments: | None | > ++---------------------+----------+----+---------------------------------------------+ > +| Return Values: | (int64) | R0 | ``SUCCESS (0)`` | > +| | | +---------------------------------------------+ > +| | | | ``NOT_SUPPORTED (-1)`` | > +| +----------+----+---------------------------------------------+ > +| | (uint64) | R1 | Bit[63] Must be zero | > +| | | +---------------------------------------------+ Why? R0 is sufficient to determine if the hypercall was successful, and this is already defined as an unsigned quantity to the guest. > +| | | | Bits [62:32] Major version | > +| | | +---------------------------------------------+ > +| | | | Bits [31:0] Minor version | > +| +----------+----+---------------------------------------------+ Do we really need a full u64 of version information? If you collapse this down to a u32 it'd align with the versioning scheme for PSCI / SMCCC.
> -----Original Message----- > From: Oliver Upton <oliver.upton@linux.dev> > Sent: Monday, January 27, 2025 5:26 PM > To: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com> > Cc: kvmarm@lists.linux.dev; maz@kernel.org; catalin.marinas@arm.com; > will@kernel.org; mark.rutland@arm.com; cohuck@redhat.com; > eric.auger@redhat.com; sebott@redhat.com; yuzenghui > <yuzenghui@huawei.com>; Wangzhou (B) <wangzhou1@hisilicon.com>; > jiangkunkun <jiangkunkun@huawei.com>; Jonathan Cameron > <jonathan.cameron@huawei.com>; Anthony Jebson > <anthony.jebson@huawei.com>; linux-arm-kernel@lists.infradead.org; > Linuxarm <linuxarm@huawei.com> > Subject: Re: [PATCH v5 2/4] KVM: arm64: Introduce hypercall support for > retrieving target implementations > > On Fri, Jan 24, 2025 at 03:17:30PM +0000, Shameer Kolothum wrote: > > If the Guest requires migration to multiple targets, these hypercalls > > will provide a way to retrieve the target CPU implementations from > > the user space VMM. > > > > Subsequent patch will use this to enable the associated errata. > > > > Suggested-by: Oliver Upton <oliver.upton@linux.dev> > > Suggested-by: Marc Zyngier <maz@kernel.org> > > Signed-off-by: Shameer Kolothum > <shameerali.kolothum.thodi@huawei.com> > > --- > > Documentation/virt/kvm/arm/hypercalls.rst | 59 > +++++++++++++++++++++++ > > include/linux/arm-smccc.h | 15 ++++++ > > 2 files changed, 74 insertions(+) > > > > diff --git a/Documentation/virt/kvm/arm/hypercalls.rst > b/Documentation/virt/kvm/arm/hypercalls.rst > > index af7bc2c2e0cb..718725cbf6c7 100644 > > --- a/Documentation/virt/kvm/arm/hypercalls.rst > > +++ b/Documentation/virt/kvm/arm/hypercalls.rst > > @@ -142,3 +142,62 @@ region is equal to the memory protection granule > advertised by > > | | | +---------------------------------------------+ > > | | | | ``INVALID_PARAMETER (-3)`` | > > +---------------------+----------+----+---------------------------------------------+ > > + > > +``ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_VER_FUNC_ID`` > > +------------------------------------------------------- > > +Request the target CPU implementation version information and the > number of target > > +implementations for the Guest VM. > > + > > ++---------------------+-------------------------------------------------------------+ > > +| Presence: | Optional; KVM/ARM64 Guests only | > > ++---------------------+-------------------------------------------------------------+ > > +| Calling convention: | HVC64 | > > ++---------------------+----------+--------------------------------------------------+ > > +| Function ID: | (uint32) | 0xC6000040 | > > ++---------------------+----------+--------------------------------------------------+ > > +| Arguments: | None | > > ++---------------------+----------+----+---------------------------------------------+ > > +| Return Values: | (int64) | R0 | ``SUCCESS (0)`` | > > +| | | +---------------------------------------------+ > > +| | | | ``NOT_SUPPORTED (-1)`` | > > +| +----------+----+---------------------------------------------+ > > +| | (uint64) | R1 | Bit[63] Must be zero | > > +| | | +---------------------------------------------+ > > Why? R0 is sufficient to determine if the hypercall was successful, and > this is already defined as an unsigned quantity to the guest. Hmm..I was trying to imitate(badly ofcourse) the SMCCC_VERSION where bit 31 must be zero but again in that case it is Int32 so it makes sense there. > > > +| | | | Bits [62:32] Major version | > > +| | | +---------------------------------------------+ > > +| | | | Bits [31:0] Minor version | > > +| +----------+----+---------------------------------------------+ > > Do we really need a full u64 of version information? If you collapse > this down to a u32 it'd align with the versioning scheme for PSCI / > SMCCC. Ok. How about this, Bits [63:32] Reserved/] Must be zero Bits [31:16] Major Rev (Should we leave the bit 31 to zero here to match SMCCC_VERSION?) Bits [15:0] Minor Rev Thanks, Shameer
diff --git a/Documentation/virt/kvm/arm/hypercalls.rst b/Documentation/virt/kvm/arm/hypercalls.rst index af7bc2c2e0cb..718725cbf6c7 100644 --- a/Documentation/virt/kvm/arm/hypercalls.rst +++ b/Documentation/virt/kvm/arm/hypercalls.rst @@ -142,3 +142,62 @@ region is equal to the memory protection granule advertised by | | | +---------------------------------------------+ | | | | ``INVALID_PARAMETER (-3)`` | +---------------------+----------+----+---------------------------------------------+ + +``ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_VER_FUNC_ID`` +------------------------------------------------------- +Request the target CPU implementation version information and the number of target +implementations for the Guest VM. + ++---------------------+-------------------------------------------------------------+ +| Presence: | Optional; KVM/ARM64 Guests only | ++---------------------+-------------------------------------------------------------+ +| Calling convention: | HVC64 | ++---------------------+----------+--------------------------------------------------+ +| Function ID: | (uint32) | 0xC6000040 | ++---------------------+----------+--------------------------------------------------+ +| Arguments: | None | ++---------------------+----------+----+---------------------------------------------+ +| Return Values: | (int64) | R0 | ``SUCCESS (0)`` | +| | | +---------------------------------------------+ +| | | | ``NOT_SUPPORTED (-1)`` | +| +----------+----+---------------------------------------------+ +| | (uint64) | R1 | Bit[63] Must be zero | +| | | +---------------------------------------------+ +| | | | Bits [62:32] Major version | +| | | +---------------------------------------------+ +| | | | Bits [31:0] Minor version | +| +----------+----+---------------------------------------------+ +| | (uint64) | R2 | Number of target implementations | +| +----------+----+---------------------------------------------+ +| | (uint64) | R3 | Reserved / Must be zero | ++---------------------+----------+----+---------------------------------------------+ + +``ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_CPUS_FUNC_ID`` +------------------------------------------------------- + +Request the target CPU implementation information for the Guest VM. The Guest kernel +will use this information to enable the associated errata. + ++---------------------+-------------------------------------------------------------+ +| Presence: | Optional; KVM/ARM64 Guests only | ++---------------------+-------------------------------------------------------------+ +| Calling convention: | HVC64 | ++---------------------+----------+--------------------------------------------------+ +| Function ID: | (uint32) | 0xC6000041 | ++---------------------+----------+----+---------------------------------------------+ +| Arguments: | (uint64) | R1 | selected implementation index | +| +----------+----+---------------------------------------------+ +| | (uint64) | R2 | Reserved / Must be zero | +| +----------+----+---------------------------------------------+ +| | (uint64) | R3 | Reserved / Must be zero | ++---------------------+----------+----+---------------------------------------------+ +| Return Values: | (int64) | R0 | ``SUCCESS (0)`` | +| | | +---------------------------------------------+ +| | | | ``INVALID_PARAMETER (-3)`` | +| +----------+----+---------------------------------------------+ +| | (uint64) | R1 | MIDR_EL1 of the selected implementation | +| +----------+----+---------------------------------------------+ +| | (uint64) | R2 | REVIDR_EL1 of the selected implementation | +| +----------+----+---------------------------------------------+ +| | (uint64) | R3 | AIDR_EL1 of the selected implementation | ++---------------------+----------+----+---------------------------------------------+ diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h index 67f6fdf2e7cd..f19be5754090 100644 --- a/include/linux/arm-smccc.h +++ b/include/linux/arm-smccc.h @@ -179,6 +179,9 @@ #define ARM_SMCCC_KVM_FUNC_PKVM_RESV_62 62 #define ARM_SMCCC_KVM_FUNC_PKVM_RESV_63 63 /* End of pKVM hypercall range */ +#define ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_VER 64 +#define ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_CPUS 65 + #define ARM_SMCCC_KVM_FUNC_FEATURES_2 127 #define ARM_SMCCC_KVM_NUM_FUNCS 128 @@ -225,6 +228,18 @@ ARM_SMCCC_OWNER_VENDOR_HYP, \ ARM_SMCCC_KVM_FUNC_MMIO_GUARD) +#define ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_VER_FUNC_ID \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_SMC_64, \ + ARM_SMCCC_OWNER_VENDOR_HYP, \ + ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_VER) + +#define ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_CPUS_FUNC_ID \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_SMC_64, \ + ARM_SMCCC_OWNER_VENDOR_HYP, \ + ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_CPUS) + /* ptp_kvm counter type ID */ #define KVM_PTP_VIRT_COUNTER 0 #define KVM_PTP_PHYS_COUNTER 1
If the Guest requires migration to multiple targets, these hypercalls will provide a way to retrieve the target CPU implementations from the user space VMM. Subsequent patch will use this to enable the associated errata. Suggested-by: Oliver Upton <oliver.upton@linux.dev> Suggested-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> --- Documentation/virt/kvm/arm/hypercalls.rst | 59 +++++++++++++++++++++++ include/linux/arm-smccc.h | 15 ++++++ 2 files changed, 74 insertions(+)