* [PATCH v5 0/4] KVM: arm64: Errata management for VM Live migration
@ 2025-01-24 15:17 Shameer Kolothum
2025-01-24 15:17 ` [PATCH v5 1/4] arm64: Modify _midr_range() functions to read MIDR/REVIDR internally Shameer Kolothum
` (4 more replies)
0 siblings, 5 replies; 18+ messages in thread
From: Shameer Kolothum @ 2025-01-24 15:17 UTC (permalink / raw)
To: kvmarm, maz, oliver.upton
Cc: catalin.marinas, will, mark.rutland, cohuck, eric.auger, sebott,
yuzenghui, wangzhou1, jiangkunkun, jonathan.cameron,
anthony.jebson, linux-arm-kernel, linuxarm
Hi,
v4 --> v5
https://lore.kernel.org/kvmarm/20241218105345.73472-1-shameerali.kolothum.thodi@huawei.com/
-Addressed comments from Marc,
-Added an hypercall to retrieve version and number of supported target
impl CPUs.
-Added a check for KVM hypercall services availability.
-Removed R-by tags from Connie & Sebastian as patches 2 & 4 changed a bit.
Please take another look.
This can be sanity tested by the Qemu branch here,
https://github.com/hisilicon/qemu/tree/v9.0-nv-rfcv4-vcpu-model-v2-target-cpu-errata
(branch based on Eric's/Connie's NV + custom CPU series)
Eg: to specify target impl CPUs,
-machine virt,.., x-target-impl-cpus=0xMIDR1:0xREVIDR1-0xMIDR2:REVIDR2
Please take a look and let me know your feedback.
Thanks,
Shameer
v3 --> v4(Minor updates)
https://lore.kernel.org/kvmarm/20241209115311.40496-1-shameerali.kolothum.thodi@huawei.com/
-Changed MIDR/REVIDR to 64 bits based on feedback from Connie
and Marc(Patch #3).
-Added R-by tags from Sebastian (Thanks!).
RFC v2 --> v3
https://lore.kernel.org/kvmarm/20241024094012.29452-1-shameerali.kolothum.thodi@huawei.com/
-Addressed comments from Oliver(Thanks!).
-Using implementation CPUs MIDR/REVIDR when it is set for
_midr_range() functions(Patch 1 & 3)
-New hypercall for retrieving implementation CPUs(Patch #2).
-Dropped RFC.
RFC v1 --> RFCv2:
https://lore.kernel.org/kvmarm/20241011075053.80540-1-shameerali.kolothum.thodi@huawei.com/
-Introduced hypercalls to retrieve target CPUs info from user space VMM.
see patch #1 for details.
-Patch #2 uses the hypercall to retrieve the target CPU info if any.
-Use the target CPUs MIDR/REVIDR in errata enablement. See patch #3.
Background from v1:
On ARM64 platforms most of the errata workarounds are based on CPU
MIDR/REVIDR values and a number of these workarounds need to be
implemented by the Guest kernel as well. This creates a problem when
Guest needs to be migrated to a platform that differs in these
MIDR/REVIDR values even if the VMM can come up with a common minimum
feature list for the Guest using the recently introduced "Writable
ID registers" support.
(This is roughly based on a discussion I had with Marc and Oliver
at KVM forum. Marc outlined his idea for a solution and this is an
attempt to implement it. Thanks to both and I take all the blame
if this is nowhere near what is intended/required)
Shameer Kolothum (4):
arm64: Modify _midr_range() functions to read MIDR/REVIDR internally
KVM: arm64: Introduce hypercall support for retrieving target
implementations
KVM: arm64: Report all the KVM/arm64-specific hypercalls
arm64: paravirt: Enable errata based on implementation CPUs
Documentation/virt/kvm/arm/hypercalls.rst | 59 +++++++++++++++++++++++
arch/arm64/include/asm/cputype.h | 50 +++++++++++++------
arch/arm64/include/asm/mmu.h | 3 +-
arch/arm64/include/asm/paravirt.h | 3 ++
arch/arm64/kernel/cpu_errata.c | 37 ++++++++++----
arch/arm64/kernel/cpufeature.c | 8 +--
arch/arm64/kernel/image-vars.h | 2 +
arch/arm64/kernel/paravirt.c | 58 ++++++++++++++++++++++
arch/arm64/kernel/proton-pack.c | 17 +++----
arch/arm64/kvm/hypercalls.c | 6 ++-
arch/arm64/kvm/vgic/vgic-v3.c | 2 +-
drivers/clocksource/arm_arch_timer.c | 2 +-
include/linux/arm-smccc.h | 17 +++++++
13 files changed, 222 insertions(+), 42 deletions(-)
--
2.47.0
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v5 1/4] arm64: Modify _midr_range() functions to read MIDR/REVIDR internally
2025-01-24 15:17 [PATCH v5 0/4] KVM: arm64: Errata management for VM Live migration Shameer Kolothum
@ 2025-01-24 15:17 ` Shameer Kolothum
2025-01-24 15:17 ` [PATCH v5 2/4] KVM: arm64: Introduce hypercall support for retrieving target implementations Shameer Kolothum
` (3 subsequent siblings)
4 siblings, 0 replies; 18+ messages in thread
From: Shameer Kolothum @ 2025-01-24 15:17 UTC (permalink / raw)
To: kvmarm, maz, oliver.upton
Cc: catalin.marinas, will, mark.rutland, cohuck, eric.auger, sebott,
yuzenghui, wangzhou1, jiangkunkun, jonathan.cameron,
anthony.jebson, linux-arm-kernel, linuxarm
These changes lay the groundwork for adding support for guest kernels,
allowing them to leverage target CPU implementations provided by the
VMM.
No functional changes intended.
Suggested-by: Oliver Upton <oliver.upton@linux.dev>
Reviewed-by: Sebastian Ott <sebott@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
---
arch/arm64/include/asm/cputype.h | 28 ++++++++++++++--------------
arch/arm64/include/asm/mmu.h | 3 +--
arch/arm64/kernel/cpu_errata.c | 23 +++++++++++++----------
arch/arm64/kernel/cpufeature.c | 6 +++---
arch/arm64/kernel/proton-pack.c | 17 ++++++++---------
arch/arm64/kvm/vgic/vgic-v3.c | 2 +-
drivers/clocksource/arm_arch_timer.c | 2 +-
7 files changed, 41 insertions(+), 40 deletions(-)
diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h
index 488f8e751349..dcf0e1ce892d 100644
--- a/arch/arm64/include/asm/cputype.h
+++ b/arch/arm64/include/asm/cputype.h
@@ -229,6 +229,16 @@
#define read_cpuid(reg) read_sysreg_s(SYS_ ## reg)
+/*
+ * The CPU ID never changes at run time, so we might as well tell the
+ * compiler that it's constant. Use this function to read the CPU ID
+ * rather than directly reading processor_id or read_cpuid() directly.
+ */
+static inline u32 __attribute_const__ read_cpuid_id(void)
+{
+ return read_cpuid(MIDR_EL1);
+}
+
/*
* Represent a range of MIDR values for a given CPU model and a
* range of variant/revision values.
@@ -264,31 +274,21 @@ static inline bool midr_is_cpu_model_range(u32 midr, u32 model, u32 rv_min,
return _model == model && rv >= rv_min && rv <= rv_max;
}
-static inline bool is_midr_in_range(u32 midr, struct midr_range const *range)
+static inline bool is_midr_in_range(struct midr_range const *range)
{
- return midr_is_cpu_model_range(midr, range->model,
+ return midr_is_cpu_model_range(read_cpuid_id(), range->model,
range->rv_min, range->rv_max);
}
static inline bool
-is_midr_in_range_list(u32 midr, struct midr_range const *ranges)
+is_midr_in_range_list(struct midr_range const *ranges)
{
while (ranges->model)
- if (is_midr_in_range(midr, ranges++))
+ if (is_midr_in_range(ranges++))
return true;
return false;
}
-/*
- * The CPU ID never changes at run time, so we might as well tell the
- * compiler that it's constant. Use this function to read the CPU ID
- * rather than directly reading processor_id or read_cpuid() directly.
- */
-static inline u32 __attribute_const__ read_cpuid_id(void)
-{
- return read_cpuid(MIDR_EL1);
-}
-
static inline u64 __attribute_const__ read_cpuid_mpidr(void)
{
return read_cpuid(MPIDR_EL1);
diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h
index 2ec96d91acc6..bfd303e074be 100644
--- a/arch/arm64/include/asm/mmu.h
+++ b/arch/arm64/include/asm/mmu.h
@@ -101,8 +101,7 @@ static inline bool kaslr_requires_kpti(void)
if (IS_ENABLED(CONFIG_CAVIUM_ERRATUM_27456)) {
extern const struct midr_range cavium_erratum_27456_cpus[];
- if (is_midr_in_range_list(read_cpuid_id(),
- cavium_erratum_27456_cpus))
+ if (is_midr_in_range_list(cavium_erratum_27456_cpus))
return false;
}
diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
index a78f247029ae..929685c00263 100644
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -15,30 +15,34 @@
#include <asm/smp_plat.h>
static bool __maybe_unused
-is_affected_midr_range(const struct arm64_cpu_capabilities *entry, int scope)
+__is_affected_midr_range(const struct arm64_cpu_capabilities *entry,
+ u32 midr, u32 revidr)
{
const struct arm64_midr_revidr *fix;
- u32 midr = read_cpuid_id(), revidr;
-
- WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
- if (!is_midr_in_range(midr, &entry->midr_range))
+ if (!is_midr_in_range(&entry->midr_range))
return false;
midr &= MIDR_REVISION_MASK | MIDR_VARIANT_MASK;
- revidr = read_cpuid(REVIDR_EL1);
for (fix = entry->fixed_revs; fix && fix->revidr_mask; fix++)
if (midr == fix->midr_rv && (revidr & fix->revidr_mask))
return false;
-
return true;
}
+static bool __maybe_unused
+is_affected_midr_range(const struct arm64_cpu_capabilities *entry, int scope)
+{
+ WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
+ return __is_affected_midr_range(entry, read_cpuid_id(),
+ read_cpuid(REVIDR_EL1));
+}
+
static bool __maybe_unused
is_affected_midr_range_list(const struct arm64_cpu_capabilities *entry,
int scope)
{
WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
- return is_midr_in_range_list(read_cpuid_id(), entry->midr_range_list);
+ return is_midr_in_range_list(entry->midr_range_list);
}
static bool __maybe_unused
@@ -186,12 +190,11 @@ static bool __maybe_unused
has_neoverse_n1_erratum_1542419(const struct arm64_cpu_capabilities *entry,
int scope)
{
- u32 midr = read_cpuid_id();
bool has_dic = read_cpuid_cachetype() & BIT(CTR_EL0_DIC_SHIFT);
const struct midr_range range = MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1);
WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
- return is_midr_in_range(midr, &range) && has_dic;
+ return is_midr_in_range(&range) && has_dic;
}
#ifdef CONFIG_ARM64_WORKAROUND_REPEAT_TLBI
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 6ce71f444ed8..4cc4ae16b28d 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -1783,7 +1783,7 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry,
char const *str = "kpti command line option";
bool meltdown_safe;
- meltdown_safe = is_midr_in_range_list(read_cpuid_id(), kpti_safe_list);
+ meltdown_safe = is_midr_in_range_list(kpti_safe_list);
/* Defer to CPU feature registers */
if (has_cpuid_feature(entry, scope))
@@ -1853,7 +1853,7 @@ static bool has_nv1(const struct arm64_cpu_capabilities *entry, int scope)
return (__system_matches_cap(ARM64_HAS_NESTED_VIRT) &&
!(has_cpuid_feature(entry, scope) ||
- is_midr_in_range_list(read_cpuid_id(), nv1_ni_list)));
+ is_midr_in_range_list(nv1_ni_list)));
}
#if defined(ID_AA64MMFR0_EL1_TGRAN_LPA2) && defined(ID_AA64MMFR0_EL1_TGRAN_2_SUPPORTED_LPA2)
@@ -2036,7 +2036,7 @@ static bool cpu_has_broken_dbm(void)
{},
};
- return is_midr_in_range_list(read_cpuid_id(), cpus);
+ return is_midr_in_range_list(cpus);
}
static bool cpu_can_use_dbm(const struct arm64_cpu_capabilities *cap)
diff --git a/arch/arm64/kernel/proton-pack.c b/arch/arm64/kernel/proton-pack.c
index da53722f95d4..a573fa40d4b6 100644
--- a/arch/arm64/kernel/proton-pack.c
+++ b/arch/arm64/kernel/proton-pack.c
@@ -172,7 +172,7 @@ static enum mitigation_state spectre_v2_get_cpu_hw_mitigation_state(void)
return SPECTRE_UNAFFECTED;
/* Alternatively, we have a list of unaffected CPUs */
- if (is_midr_in_range_list(read_cpuid_id(), spectre_v2_safe_list))
+ if (is_midr_in_range_list(spectre_v2_safe_list))
return SPECTRE_UNAFFECTED;
return SPECTRE_VULNERABLE;
@@ -331,7 +331,7 @@ bool has_spectre_v3a(const struct arm64_cpu_capabilities *entry, int scope)
};
WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
- return is_midr_in_range_list(read_cpuid_id(), spectre_v3a_unsafe_list);
+ return is_midr_in_range_list(spectre_v3a_unsafe_list);
}
void spectre_v3a_enable_mitigation(const struct arm64_cpu_capabilities *__unused)
@@ -475,7 +475,7 @@ static enum mitigation_state spectre_v4_get_cpu_hw_mitigation_state(void)
{ /* sentinel */ },
};
- if (is_midr_in_range_list(read_cpuid_id(), spectre_v4_safe_list))
+ if (is_midr_in_range_list(spectre_v4_safe_list))
return SPECTRE_UNAFFECTED;
/* CPU features are detected first */
@@ -878,13 +878,13 @@ u8 spectre_bhb_loop_affected(int scope)
{},
};
- if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k32_list))
+ if (is_midr_in_range_list(spectre_bhb_k32_list))
k = 32;
- else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k24_list))
+ else if (is_midr_in_range_list(spectre_bhb_k24_list))
k = 24;
- else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k11_list))
+ else if (is_midr_in_range_list(spectre_bhb_k11_list))
k = 11;
- else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k8_list))
+ else if (is_midr_in_range_list(spectre_bhb_k8_list))
k = 8;
max_bhb_k = max(max_bhb_k, k);
@@ -926,8 +926,7 @@ static bool is_spectre_bhb_fw_affected(int scope)
MIDR_ALL_VERSIONS(MIDR_CORTEX_A75),
{},
};
- bool cpu_in_list = is_midr_in_range_list(read_cpuid_id(),
- spectre_bhb_firmware_mitigated_list);
+ bool cpu_in_list = is_midr_in_range_list(spectre_bhb_firmware_mitigated_list);
if (scope != SCOPE_LOCAL_CPU)
return system_affected;
diff --git a/arch/arm64/kvm/vgic/vgic-v3.c b/arch/arm64/kvm/vgic/vgic-v3.c
index f267bc2486a1..b815d910c7e4 100644
--- a/arch/arm64/kvm/vgic/vgic-v3.c
+++ b/arch/arm64/kvm/vgic/vgic-v3.c
@@ -632,7 +632,7 @@ static const struct midr_range broken_seis[] = {
static bool vgic_v3_broken_seis(void)
{
return ((kvm_vgic_global_state.ich_vtr_el2 & ICH_VTR_SEIS_MASK) &&
- is_midr_in_range_list(read_cpuid_id(), broken_seis));
+ is_midr_in_range_list(broken_seis));
}
/**
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 808f259781fd..981a578043a5 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -842,7 +842,7 @@ static u64 __arch_timer_check_delta(void)
{},
};
- if (is_midr_in_range_list(read_cpuid_id(), broken_cval_midrs)) {
+ if (is_midr_in_range_list(broken_cval_midrs)) {
pr_warn_once("Broken CNTx_CVAL_EL1, using 31 bit TVAL instead.\n");
return CLOCKSOURCE_MASK(31);
}
--
2.47.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v5 2/4] KVM: arm64: Introduce hypercall support for retrieving target implementations
2025-01-24 15:17 [PATCH v5 0/4] KVM: arm64: Errata management for VM Live migration Shameer Kolothum
2025-01-24 15:17 ` [PATCH v5 1/4] arm64: Modify _midr_range() functions to read MIDR/REVIDR internally Shameer Kolothum
@ 2025-01-24 15:17 ` Shameer Kolothum
2025-01-27 12:50 ` Cornelia Huck
2025-01-27 17:26 ` Oliver Upton
2025-01-24 15:17 ` [PATCH v5 3/4] KVM: arm64: Report all the KVM/arm64-specific hypercalls Shameer Kolothum
` (2 subsequent siblings)
4 siblings, 2 replies; 18+ messages in thread
From: Shameer Kolothum @ 2025-01-24 15:17 UTC (permalink / raw)
To: kvmarm, maz, oliver.upton
Cc: catalin.marinas, will, mark.rutland, cohuck, eric.auger, sebott,
yuzenghui, wangzhou1, jiangkunkun, jonathan.cameron,
anthony.jebson, linux-arm-kernel, linuxarm
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 |
+| | | +---------------------------------------------+
+| | | | 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
--
2.47.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v5 3/4] KVM: arm64: Report all the KVM/arm64-specific hypercalls
2025-01-24 15:17 [PATCH v5 0/4] KVM: arm64: Errata management for VM Live migration Shameer Kolothum
2025-01-24 15:17 ` [PATCH v5 1/4] arm64: Modify _midr_range() functions to read MIDR/REVIDR internally Shameer Kolothum
2025-01-24 15:17 ` [PATCH v5 2/4] KVM: arm64: Introduce hypercall support for retrieving target implementations Shameer Kolothum
@ 2025-01-24 15:17 ` Shameer Kolothum
2025-01-27 12:47 ` Cornelia Huck
2025-01-27 17:05 ` Oliver Upton
2025-01-24 15:17 ` [PATCH v5 4/4] arm64: paravirt: Enable errata based on implementation CPUs Shameer Kolothum
2025-02-04 16:45 ` [PATCH v5 0/4] KVM: arm64: Errata management for VM Live migration Sebastian Ott
4 siblings, 2 replies; 18+ messages in thread
From: Shameer Kolothum @ 2025-01-24 15:17 UTC (permalink / raw)
To: kvmarm, maz, oliver.upton
Cc: catalin.marinas, will, mark.rutland, cohuck, eric.auger, sebott,
yuzenghui, wangzhou1, jiangkunkun, jonathan.cameron,
anthony.jebson, linux-arm-kernel, linuxarm
Currently ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID returns the
bitmap corresponding to KVM_REG_ARM_VENDOR_HYP_BMAP and it only
returns _KVM_FEATURES_FUNC_ID and _KVM_PTP_FUNC_ID. Change that
to return all the KVM/arm64-specific hypercalls exposed by
KVM/arm64 to guest operating systems.
Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
---
arch/arm64/kvm/hypercalls.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/kvm/hypercalls.c b/arch/arm64/kvm/hypercalls.c
index 27ce4cb44904..6132cb542200 100644
--- a/arch/arm64/kvm/hypercalls.c
+++ b/arch/arm64/kvm/hypercalls.c
@@ -359,7 +359,11 @@ int kvm_smccc_call_handler(struct kvm_vcpu *vcpu)
val[3] = ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_3;
break;
case ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID:
- val[0] = smccc_feat->vendor_hyp_bmap;
+ val[0] = GENMASK(ARM_SMCCC_KVM_FUNC_MMIO_GUARD,
+ ARM_SMCCC_KVM_FUNC_FEATURES);
+ /* Function numbers 8-63 are reserved for pKVM for now */
+ val[2] = GENMASK((ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_CPUS - 64),
+ (ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_VER - 64));
break;
case ARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID:
kvm_ptp_get_time(vcpu, val);
--
2.47.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v5 4/4] arm64: paravirt: Enable errata based on implementation CPUs
2025-01-24 15:17 [PATCH v5 0/4] KVM: arm64: Errata management for VM Live migration Shameer Kolothum
` (2 preceding siblings ...)
2025-01-24 15:17 ` [PATCH v5 3/4] KVM: arm64: Report all the KVM/arm64-specific hypercalls Shameer Kolothum
@ 2025-01-24 15:17 ` Shameer Kolothum
2025-01-27 12:53 ` Cornelia Huck
2025-01-27 17:37 ` Oliver Upton
2025-02-04 16:45 ` [PATCH v5 0/4] KVM: arm64: Errata management for VM Live migration Sebastian Ott
4 siblings, 2 replies; 18+ messages in thread
From: Shameer Kolothum @ 2025-01-24 15:17 UTC (permalink / raw)
To: kvmarm, maz, oliver.upton
Cc: catalin.marinas, will, mark.rutland, cohuck, eric.auger, sebott,
yuzenghui, wangzhou1, jiangkunkun, jonathan.cameron,
anthony.jebson, linux-arm-kernel, linuxarm
Retrieve any migration target implementation CPUs using the hypercall
and enable associated errata.
Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
---
arch/arm64/include/asm/cputype.h | 24 +++++++++++--
arch/arm64/include/asm/paravirt.h | 3 ++
arch/arm64/kernel/cpu_errata.c | 20 +++++++++--
arch/arm64/kernel/cpufeature.c | 2 ++
arch/arm64/kernel/image-vars.h | 2 ++
arch/arm64/kernel/paravirt.c | 58 +++++++++++++++++++++++++++++++
include/linux/arm-smccc.h | 2 ++
7 files changed, 106 insertions(+), 5 deletions(-)
diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h
index dcf0e1ce892d..f95f04ec6f66 100644
--- a/arch/arm64/include/asm/cputype.h
+++ b/arch/arm64/include/asm/cputype.h
@@ -265,6 +265,15 @@ struct midr_range {
#define MIDR_REV(m, v, r) MIDR_RANGE(m, v, r, v, r)
#define MIDR_ALL_VERSIONS(m) MIDR_RANGE(m, 0, 0, 0xf, 0xf)
+struct target_impl_cpu {
+ u64 midr;
+ u64 revidr;
+ u64 aidr;
+};
+
+extern u32 target_impl_cpu_num;
+extern struct target_impl_cpu *target_impl_cpus;
+
static inline bool midr_is_cpu_model_range(u32 midr, u32 model, u32 rv_min,
u32 rv_max)
{
@@ -276,8 +285,19 @@ static inline bool midr_is_cpu_model_range(u32 midr, u32 model, u32 rv_min,
static inline bool is_midr_in_range(struct midr_range const *range)
{
- return midr_is_cpu_model_range(read_cpuid_id(), range->model,
- range->rv_min, range->rv_max);
+ int i;
+
+ if (!target_impl_cpu_num)
+ return midr_is_cpu_model_range(read_cpuid_id(), range->model,
+ range->rv_min, range->rv_max);
+
+ for (i = 0; i < target_impl_cpu_num; i++) {
+ if (midr_is_cpu_model_range(target_impl_cpus[i].midr,
+ range->model,
+ range->rv_min, range->rv_max))
+ return true;
+ }
+ return false;
}
static inline bool
diff --git a/arch/arm64/include/asm/paravirt.h b/arch/arm64/include/asm/paravirt.h
index 9aa193e0e8f2..95f1c15bbb7d 100644
--- a/arch/arm64/include/asm/paravirt.h
+++ b/arch/arm64/include/asm/paravirt.h
@@ -19,11 +19,14 @@ static inline u64 paravirt_steal_clock(int cpu)
}
int __init pv_time_init(void);
+void __init pv_target_impl_cpu_init(void);
#else
#define pv_time_init() do {} while (0)
+#define pv_target_impl_cpu_init() do {} while (0)
+
#endif // CONFIG_PARAVIRT
#endif
diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
index 929685c00263..147b036d8bbd 100644
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -14,6 +14,9 @@
#include <asm/kvm_asm.h>
#include <asm/smp_plat.h>
+u32 target_impl_cpu_num;
+struct target_impl_cpu *target_impl_cpus;
+
static bool __maybe_unused
__is_affected_midr_range(const struct arm64_cpu_capabilities *entry,
u32 midr, u32 revidr)
@@ -32,9 +35,20 @@ __is_affected_midr_range(const struct arm64_cpu_capabilities *entry,
static bool __maybe_unused
is_affected_midr_range(const struct arm64_cpu_capabilities *entry, int scope)
{
- WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
- return __is_affected_midr_range(entry, read_cpuid_id(),
- read_cpuid(REVIDR_EL1));
+ int i;
+
+ if (!target_impl_cpu_num) {
+ WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
+ return __is_affected_midr_range(entry, read_cpuid_id(),
+ read_cpuid(REVIDR_EL1));
+ }
+
+ for (i = 0; i < target_impl_cpu_num; i++) {
+ if (__is_affected_midr_range(entry, target_impl_cpus[i].midr,
+ target_impl_cpus[i].midr))
+ return true;
+ }
+ return false;
}
static bool __maybe_unused
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 4cc4ae16b28d..d32c767bf189 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -85,6 +85,7 @@
#include <asm/kvm_host.h>
#include <asm/mmu_context.h>
#include <asm/mte.h>
+#include <asm/paravirt.h>
#include <asm/processor.h>
#include <asm/smp.h>
#include <asm/sysreg.h>
@@ -3642,6 +3643,7 @@ unsigned long cpu_get_elf_hwcap3(void)
static void __init setup_boot_cpu_capabilities(void)
{
+ pv_target_impl_cpu_init();
/*
* The boot CPU's feature register values have been recorded. Detect
* boot cpucaps and local cpucaps for the boot CPU, then enable and
diff --git a/arch/arm64/kernel/image-vars.h b/arch/arm64/kernel/image-vars.h
index 8f5422ed1b75..694e19709c46 100644
--- a/arch/arm64/kernel/image-vars.h
+++ b/arch/arm64/kernel/image-vars.h
@@ -49,6 +49,8 @@ PROVIDE(__pi_arm64_sw_feature_override = arm64_sw_feature_override);
PROVIDE(__pi_arm64_use_ng_mappings = arm64_use_ng_mappings);
#ifdef CONFIG_CAVIUM_ERRATUM_27456
PROVIDE(__pi_cavium_erratum_27456_cpus = cavium_erratum_27456_cpus);
+PROVIDE(__pi_target_impl_cpu_num = target_impl_cpu_num);
+PROVIDE(__pi_target_impl_cpus = target_impl_cpus);
#endif
PROVIDE(__pi__ctype = _ctype);
PROVIDE(__pi_memstart_offset_seed = memstart_offset_seed);
diff --git a/arch/arm64/kernel/paravirt.c b/arch/arm64/kernel/paravirt.c
index aa718d6a9274..4547dc2ddc13 100644
--- a/arch/arm64/kernel/paravirt.c
+++ b/arch/arm64/kernel/paravirt.c
@@ -13,6 +13,7 @@
#include <linux/export.h>
#include <linux/io.h>
#include <linux/jump_label.h>
+#include <linux/memblock.h>
#include <linux/printk.h>
#include <linux/psci.h>
#include <linux/reboot.h>
@@ -20,6 +21,7 @@
#include <linux/types.h>
#include <linux/static_call.h>
+#include <asm/hypervisor.h>
#include <asm/paravirt.h>
#include <asm/pvclock-abi.h>
#include <asm/smp_plat.h>
@@ -153,6 +155,62 @@ static bool __init has_pv_steal_clock(void)
return (res.a0 == SMCCC_RET_SUCCESS);
}
+void __init pv_target_impl_cpu_init(void)
+{
+ int i;
+ unsigned long max_cpus;
+ struct arm_smccc_res res;
+ const u32 funcs[] = {
+ ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_VER,
+ ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_CPUS,
+ };
+
+ /* Check we have already set targets */
+ if (target_impl_cpu_num)
+ return;
+
+ for (i = 0; i < ARRAY_SIZE(funcs); ++i) {
+ if (!kvm_arm_hyp_service_available(funcs[i]))
+ return;
+ }
+
+ arm_smccc_1_1_invoke(ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_VER_FUNC_ID,
+ 0, &res);
+ if (res.a0 != SMCCC_RET_SUCCESS)
+ return;
+
+ if (res.a1 != ARM_SMCCC_KVM_DISCOVER_IMPL_VER_1_0 || !res.a2) {
+ pr_warn("Unsupported target impl version or CPU implementations\n");
+ return;
+ }
+
+ max_cpus = res.a2;
+ target_impl_cpus = memblock_alloc(sizeof(*target_impl_cpus) * max_cpus,
+ __alignof__(*target_impl_cpus));
+ if (!target_impl_cpus) {
+ pr_warn("Not enough memory for struct target_impl_cpu\n");
+ return;
+ }
+
+ for (i = 0; i < max_cpus; i++) {
+ arm_smccc_1_1_invoke(ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_CPUS_FUNC_ID,
+ i, &res);
+ if (res.a0 != SMCCC_RET_SUCCESS) {
+ memblock_free(target_impl_cpus,
+ sizeof(*target_impl_cpus) * max_cpus);
+ target_impl_cpus = NULL;
+ pr_warn("Discovering target implementation CPUs failed\n");
+ return;
+ }
+ target_impl_cpus[i].midr = res.a1;
+ target_impl_cpus[i].revidr = res.a2;
+ target_impl_cpus[i].aidr = res.a3;
+ };
+
+ target_impl_cpu_num = max_cpus;
+ pr_info("Number of target implementation CPUs is %d\n", target_impl_cpu_num);
+}
+
int __init pv_time_init(void)
{
int ret;
diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h
index f19be5754090..4b4ce6ecac0a 100644
--- a/include/linux/arm-smccc.h
+++ b/include/linux/arm-smccc.h
@@ -228,6 +228,8 @@
ARM_SMCCC_OWNER_VENDOR_HYP, \
ARM_SMCCC_KVM_FUNC_MMIO_GUARD)
+#define ARM_SMCCC_KVM_DISCOVER_IMPL_VER_1_0 0x100000000
+
#define ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_VER_FUNC_ID \
ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \
ARM_SMCCC_SMC_64, \
--
2.47.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v5 3/4] KVM: arm64: Report all the KVM/arm64-specific hypercalls
2025-01-24 15:17 ` [PATCH v5 3/4] KVM: arm64: Report all the KVM/arm64-specific hypercalls Shameer Kolothum
@ 2025-01-27 12:47 ` Cornelia Huck
2025-01-27 13:35 ` Shameerali Kolothum Thodi
2025-01-27 17:05 ` Oliver Upton
1 sibling, 1 reply; 18+ messages in thread
From: Cornelia Huck @ 2025-01-27 12:47 UTC (permalink / raw)
To: Shameer Kolothum, kvmarm, maz, oliver.upton
Cc: catalin.marinas, will, mark.rutland, eric.auger, sebott,
yuzenghui, wangzhou1, jiangkunkun, jonathan.cameron,
anthony.jebson, linux-arm-kernel, linuxarm
On Fri, Jan 24 2025, Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> wrote:
> Currently ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID returns the
> bitmap corresponding to KVM_REG_ARM_VENDOR_HYP_BMAP and it only
> returns _KVM_FEATURES_FUNC_ID and _KVM_PTP_FUNC_ID. Change that
> to return all the KVM/arm64-specific hypercalls exposed by
> KVM/arm64 to guest operating systems.
>
> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
> ---
> arch/arm64/kvm/hypercalls.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kvm/hypercalls.c b/arch/arm64/kvm/hypercalls.c
> index 27ce4cb44904..6132cb542200 100644
> --- a/arch/arm64/kvm/hypercalls.c
> +++ b/arch/arm64/kvm/hypercalls.c
> @@ -359,7 +359,11 @@ int kvm_smccc_call_handler(struct kvm_vcpu *vcpu)
> val[3] = ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_3;
> break;
> case ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID:
> - val[0] = smccc_feat->vendor_hyp_bmap;
> + val[0] = GENMASK(ARM_SMCCC_KVM_FUNC_MMIO_GUARD,
> + ARM_SMCCC_KVM_FUNC_FEATURES);
Don't you need to exclude the reserved ids 5 and 6?
> + /* Function numbers 8-63 are reserved for pKVM for now */
> + val[2] = GENMASK((ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_CPUS - 64),
> + (ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_VER - 64));
> break;
> case ARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID:
> kvm_ptp_get_time(vcpu, val);
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v5 2/4] KVM: arm64: Introduce hypercall support for retrieving target implementations
2025-01-24 15:17 ` [PATCH v5 2/4] KVM: arm64: Introduce hypercall support for retrieving target implementations Shameer Kolothum
@ 2025-01-27 12:50 ` Cornelia Huck
2025-01-27 17:26 ` Oliver Upton
1 sibling, 0 replies; 18+ messages in thread
From: Cornelia Huck @ 2025-01-27 12:50 UTC (permalink / raw)
To: Shameer Kolothum, kvmarm, maz, oliver.upton
Cc: catalin.marinas, will, mark.rutland, eric.auger, sebott,
yuzenghui, wangzhou1, jiangkunkun, jonathan.cameron,
anthony.jebson, linux-arm-kernel, linuxarm
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>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v5 4/4] arm64: paravirt: Enable errata based on implementation CPUs
2025-01-24 15:17 ` [PATCH v5 4/4] arm64: paravirt: Enable errata based on implementation CPUs Shameer Kolothum
@ 2025-01-27 12:53 ` Cornelia Huck
2025-01-27 17:37 ` Oliver Upton
1 sibling, 0 replies; 18+ messages in thread
From: Cornelia Huck @ 2025-01-27 12:53 UTC (permalink / raw)
To: Shameer Kolothum, kvmarm, maz, oliver.upton
Cc: catalin.marinas, will, mark.rutland, eric.auger, sebott,
yuzenghui, wangzhou1, jiangkunkun, jonathan.cameron,
anthony.jebson, linux-arm-kernel, linuxarm
On Fri, Jan 24 2025, Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> wrote:
> Retrieve any migration target implementation CPUs using the hypercall
> and enable associated errata.
>
> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
> ---
> arch/arm64/include/asm/cputype.h | 24 +++++++++++--
> arch/arm64/include/asm/paravirt.h | 3 ++
> arch/arm64/kernel/cpu_errata.c | 20 +++++++++--
> arch/arm64/kernel/cpufeature.c | 2 ++
> arch/arm64/kernel/image-vars.h | 2 ++
> arch/arm64/kernel/paravirt.c | 58 +++++++++++++++++++++++++++++++
> include/linux/arm-smccc.h | 2 ++
> 7 files changed, 106 insertions(+), 5 deletions(-)
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
^ permalink raw reply [flat|nested] 18+ messages in thread
* RE: [PATCH v5 3/4] KVM: arm64: Report all the KVM/arm64-specific hypercalls
2025-01-27 12:47 ` Cornelia Huck
@ 2025-01-27 13:35 ` Shameerali Kolothum Thodi
0 siblings, 0 replies; 18+ messages in thread
From: Shameerali Kolothum Thodi @ 2025-01-27 13:35 UTC (permalink / raw)
To: Cornelia Huck, kvmarm@lists.linux.dev, maz@kernel.org,
oliver.upton@linux.dev
Cc: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com,
eric.auger@redhat.com, sebott@redhat.com, yuzenghui, Wangzhou (B),
jiangkunkun, Jonathan Cameron, Anthony Jebson,
linux-arm-kernel@lists.infradead.org, Linuxarm
> -----Original Message-----
> From: Cornelia Huck <cohuck@redhat.com>
> Sent: Monday, January 27, 2025 12:47 PM
> To: Shameerali Kolothum Thodi
> <shameerali.kolothum.thodi@huawei.com>; kvmarm@lists.linux.dev;
> maz@kernel.org; oliver.upton@linux.dev
> Cc: catalin.marinas@arm.com; will@kernel.org; mark.rutland@arm.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 3/4] KVM: arm64: Report all the KVM/arm64-specific
> hypercalls
>
> On Fri, Jan 24 2025, Shameer Kolothum
> <shameerali.kolothum.thodi@huawei.com> wrote:
>
> > Currently ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID returns
> the
> > bitmap corresponding to KVM_REG_ARM_VENDOR_HYP_BMAP and it
> only
> > returns _KVM_FEATURES_FUNC_ID and _KVM_PTP_FUNC_ID. Change that
> > to return all the KVM/arm64-specific hypercalls exposed by
> > KVM/arm64 to guest operating systems.
> >
> > Signed-off-by: Shameer Kolothum
> <shameerali.kolothum.thodi@huawei.com>
> > ---
> > arch/arm64/kvm/hypercalls.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm64/kvm/hypercalls.c b/arch/arm64/kvm/hypercalls.c
> > index 27ce4cb44904..6132cb542200 100644
> > --- a/arch/arm64/kvm/hypercalls.c
> > +++ b/arch/arm64/kvm/hypercalls.c
> > @@ -359,7 +359,11 @@ int kvm_smccc_call_handler(struct kvm_vcpu
> *vcpu)
> > val[3] = ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_3;
> > break;
> > case ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID:
> > - val[0] = smccc_feat->vendor_hyp_bmap;
> > + val[0] = GENMASK(ARM_SMCCC_KVM_FUNC_MMIO_GUARD,
> > + ARM_SMCCC_KVM_FUNC_FEATURES);
>
> Don't you need to exclude the reserved ids 5 and 6?
Oops...I overlooked it. Will correct.
Thanks,
Shameer
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v5 3/4] KVM: arm64: Report all the KVM/arm64-specific hypercalls
2025-01-24 15:17 ` [PATCH v5 3/4] KVM: arm64: Report all the KVM/arm64-specific hypercalls Shameer Kolothum
2025-01-27 12:47 ` Cornelia Huck
@ 2025-01-27 17:05 ` Oliver Upton
2025-01-27 17:24 ` Shameerali Kolothum Thodi
1 sibling, 1 reply; 18+ messages in thread
From: Oliver Upton @ 2025-01-27 17:05 UTC (permalink / raw)
To: Shameer Kolothum
Cc: kvmarm, maz, catalin.marinas, will, mark.rutland, cohuck,
eric.auger, sebott, yuzenghui, wangzhou1, jiangkunkun,
jonathan.cameron, anthony.jebson, linux-arm-kernel, linuxarm
Hi Shameer,
On Fri, Jan 24, 2025 at 03:17:31PM +0000, Shameer Kolothum wrote:
> Currently ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID returns the
> bitmap corresponding to KVM_REG_ARM_VENDOR_HYP_BMAP and it only
> returns _KVM_FEATURES_FUNC_ID and _KVM_PTP_FUNC_ID. Change that
> to return all the KVM/arm64-specific hypercalls exposed by
> KVM/arm64 to guest operating systems.
>
> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
> ---
> arch/arm64/kvm/hypercalls.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kvm/hypercalls.c b/arch/arm64/kvm/hypercalls.c
> index 27ce4cb44904..6132cb542200 100644
> --- a/arch/arm64/kvm/hypercalls.c
> +++ b/arch/arm64/kvm/hypercalls.c
> @@ -359,7 +359,11 @@ int kvm_smccc_call_handler(struct kvm_vcpu *vcpu)
> val[3] = ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_3;
> break;
> case ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID:
> - val[0] = smccc_feat->vendor_hyp_bmap;
> + val[0] = GENMASK(ARM_SMCCC_KVM_FUNC_MMIO_GUARD,
> + ARM_SMCCC_KVM_FUNC_FEATURES);
> + /* Function numbers 8-63 are reserved for pKVM for now */
> + val[2] = GENMASK((ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_CPUS - 64),
> + (ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_VER - 64));
> break;
This isn't right. The pKVM carveout exists for some KVM-internal
bookkeeping to (hopefully) avoid breaking guest ABI between what's in
the downstream android kernel and what eventually gets accepted
upstream.
The purpose of this hypercall is for the guest to discover what
interfaces are actually implemented by the hypervisor, and we definitely
do not implement these upstream at the moment.
--
Thanks,
Oliver
^ permalink raw reply [flat|nested] 18+ messages in thread
* RE: [PATCH v5 3/4] KVM: arm64: Report all the KVM/arm64-specific hypercalls
2025-01-27 17:05 ` Oliver Upton
@ 2025-01-27 17:24 ` Shameerali Kolothum Thodi
0 siblings, 0 replies; 18+ messages in thread
From: Shameerali Kolothum Thodi @ 2025-01-27 17:24 UTC (permalink / raw)
To: Oliver Upton
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, Wangzhou (B),
jiangkunkun, Jonathan Cameron, Anthony Jebson,
linux-arm-kernel@lists.infradead.org, Linuxarm
> -----Original Message-----
> From: Oliver Upton <oliver.upton@linux.dev>
> Sent: Monday, January 27, 2025 5:06 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 3/4] KVM: arm64: Report all the KVM/arm64-specific
> hypercalls
>
> Hi Shameer,
>
> On Fri, Jan 24, 2025 at 03:17:31PM +0000, Shameer Kolothum wrote:
> > Currently ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID returns
> the bitmap
> > corresponding to KVM_REG_ARM_VENDOR_HYP_BMAP and it only
> returns
> > _KVM_FEATURES_FUNC_ID and _KVM_PTP_FUNC_ID. Change that to
> return all
> > the KVM/arm64-specific hypercalls exposed by
> > KVM/arm64 to guest operating systems.
> >
> > Signed-off-by: Shameer Kolothum
> <shameerali.kolothum.thodi@huawei.com>
> > ---
> > arch/arm64/kvm/hypercalls.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm64/kvm/hypercalls.c b/arch/arm64/kvm/hypercalls.c
> > index 27ce4cb44904..6132cb542200 100644
> > --- a/arch/arm64/kvm/hypercalls.c
> > +++ b/arch/arm64/kvm/hypercalls.c
> > @@ -359,7 +359,11 @@ int kvm_smccc_call_handler(struct kvm_vcpu
> *vcpu)
> > val[3] = ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_3;
> > break;
> > case ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID:
> > - val[0] = smccc_feat->vendor_hyp_bmap;
> > + val[0] = GENMASK(ARM_SMCCC_KVM_FUNC_MMIO_GUARD,
> > + ARM_SMCCC_KVM_FUNC_FEATURES);
> > + /* Function numbers 8-63 are reserved for pKVM for now */
> > + val[2] =
> GENMASK((ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_CPUS - 64),
> > +
> (ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_VER - 64));
> > break;
>
> This isn't right. The pKVM carveout exists for some KVM-internal
> bookkeeping to (hopefully) avoid breaking guest ABI between what's in the
> downstream android kernel and what eventually gets accepted upstream.
>
> The purpose of this hypercall is for the guest to discover what interfaces are
> actually implemented by the hypervisor, and we definitely do not
> implement these upstream at the moment.
Ok. I had some confusion on pKVM ones as I could see the kvm_arm_hyp_service_available()
being called with those in arm-pkvm-guest.c. So that explains it.
.
I will remove the pKVM ones and just add support to report the ones introduced
in this series.
Thanks,
Shameer
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v5 2/4] KVM: arm64: Introduce hypercall support for retrieving target implementations
2025-01-24 15:17 ` [PATCH v5 2/4] KVM: arm64: Introduce hypercall support for retrieving target implementations Shameer Kolothum
2025-01-27 12:50 ` Cornelia Huck
@ 2025-01-27 17:26 ` Oliver Upton
2025-01-28 14:16 ` Shameerali Kolothum Thodi
1 sibling, 1 reply; 18+ messages in thread
From: Oliver Upton @ 2025-01-27 17:26 UTC (permalink / raw)
To: Shameer Kolothum
Cc: kvmarm, maz, catalin.marinas, will, mark.rutland, cohuck,
eric.auger, sebott, yuzenghui, wangzhou1, jiangkunkun,
jonathan.cameron, anthony.jebson, linux-arm-kernel, linuxarm
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.
--
Thanks,
Oliver
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v5 4/4] arm64: paravirt: Enable errata based on implementation CPUs
2025-01-24 15:17 ` [PATCH v5 4/4] arm64: paravirt: Enable errata based on implementation CPUs Shameer Kolothum
2025-01-27 12:53 ` Cornelia Huck
@ 2025-01-27 17:37 ` Oliver Upton
1 sibling, 0 replies; 18+ messages in thread
From: Oliver Upton @ 2025-01-27 17:37 UTC (permalink / raw)
To: Shameer Kolothum
Cc: kvmarm, maz, catalin.marinas, will, mark.rutland, cohuck,
eric.auger, sebott, yuzenghui, wangzhou1, jiangkunkun,
jonathan.cameron, anthony.jebson, linux-arm-kernel, linuxarm
On Fri, Jan 24, 2025 at 03:17:32PM +0000, Shameer Kolothum wrote:
> +void __init pv_target_impl_cpu_init(void)
I get the sense that this implementation should actually be part of the
KVM guest services driver in drivers/firmware/smccc/kvm_guest.c
> +{
> + int i;
> + unsigned long max_cpus;
> + struct arm_smccc_res res;
> + const u32 funcs[] = {
> + ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_VER,
> + ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_CPUS,
> + };
> +
> + /* Check we have already set targets */
> + if (target_impl_cpu_num)
> + return;
> +
> + for (i = 0; i < ARRAY_SIZE(funcs); ++i) {
> + if (!kvm_arm_hyp_service_available(funcs[i]))
> + return;
> + }
nit: drop the for loop and just use the literal values.
> + arm_smccc_1_1_invoke(ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_VER_FUNC_ID,
> + 0, &res);
> + if (res.a0 != SMCCC_RET_SUCCESS)
> + return;
> +
> + if (res.a1 != ARM_SMCCC_KVM_DISCOVER_IMPL_VER_1_0 || !res.a2) {
This is brittle. The versioning scheme really should match that of PSCI
/ SMCCC, where minor revisions within the same major are backwards
compatible with older clients.
So consider just checking that the major version is 1.
> + pr_warn("Unsupported target impl version or CPU implementations\n");
This would be more useful if you provide context (i.e. the detected
version).
--
Thanks,
Oliver
^ permalink raw reply [flat|nested] 18+ messages in thread
* RE: [PATCH v5 2/4] KVM: arm64: Introduce hypercall support for retrieving target implementations
2025-01-27 17:26 ` Oliver Upton
@ 2025-01-28 14:16 ` Shameerali Kolothum Thodi
0 siblings, 0 replies; 18+ messages in thread
From: Shameerali Kolothum Thodi @ 2025-01-28 14:16 UTC (permalink / raw)
To: Oliver Upton
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, Wangzhou (B),
jiangkunkun, Jonathan Cameron, Anthony Jebson,
linux-arm-kernel@lists.infradead.org, Linuxarm
> -----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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v5 0/4] KVM: arm64: Errata management for VM Live migration
2025-01-24 15:17 [PATCH v5 0/4] KVM: arm64: Errata management for VM Live migration Shameer Kolothum
` (3 preceding siblings ...)
2025-01-24 15:17 ` [PATCH v5 4/4] arm64: paravirt: Enable errata based on implementation CPUs Shameer Kolothum
@ 2025-02-04 16:45 ` Sebastian Ott
2025-02-04 17:11 ` Marc Zyngier
4 siblings, 1 reply; 18+ messages in thread
From: Sebastian Ott @ 2025-02-04 16:45 UTC (permalink / raw)
To: Shameer Kolothum
Cc: kvmarm, maz, oliver.upton, catalin.marinas, will, mark.rutland,
Cornelia Huck, eric.auger, yuzenghui, wangzhou1, jiangkunkun,
jonathan.cameron, anthony.jebson, linux-arm-kernel, linuxarm
Hey,
On Fri, 24 Jan 2025, Shameer Kolothum wrote:
> On ARM64 platforms most of the errata workarounds are based on CPU
> MIDR/REVIDR values and a number of these workarounds need to be
> implemented by the Guest kernel as well. This creates a problem when
> Guest needs to be migrated to a platform that differs in these
> MIDR/REVIDR values even if the VMM can come up with a common minimum
> feature list for the Guest using the recently introduced "Writable
> ID registers" support.
Currently MIDR/REVIDR are still RO and guest access is not trapped - so
even with the errata management patches in place the guest state would
change and a migration (between hosts that differ in these regs) would
not be possible. Are there any plans to allow to actually change these?
Thanks,
Sebastian
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v5 0/4] KVM: arm64: Errata management for VM Live migration
2025-02-04 16:45 ` [PATCH v5 0/4] KVM: arm64: Errata management for VM Live migration Sebastian Ott
@ 2025-02-04 17:11 ` Marc Zyngier
2025-02-04 17:42 ` Sebastian Ott
0 siblings, 1 reply; 18+ messages in thread
From: Marc Zyngier @ 2025-02-04 17:11 UTC (permalink / raw)
To: Sebastian Ott
Cc: Shameer Kolothum, kvmarm, oliver.upton, catalin.marinas, will,
mark.rutland, Cornelia Huck, eric.auger, yuzenghui, wangzhou1,
jiangkunkun, jonathan.cameron, anthony.jebson, linux-arm-kernel,
linuxarm
On Tue, 04 Feb 2025 16:45:38 +0000,
Sebastian Ott <sebott@redhat.com> wrote:
>
> Hey,
>
> On Fri, 24 Jan 2025, Shameer Kolothum wrote:
> > On ARM64 platforms most of the errata workarounds are based on CPU
> > MIDR/REVIDR values and a number of these workarounds need to be
> > implemented by the Guest kernel as well. This creates a problem when
> > Guest needs to be migrated to a platform that differs in these
> > MIDR/REVIDR values even if the VMM can come up with a common minimum
> > feature list for the Guest using the recently introduced "Writable
> > ID registers" support.
>
> Currently MIDR/REVIDR are still RO and guest access is not trapped - so
> even with the errata management patches in place the guest state would
> change and a migration (between hosts that differ in these regs) would
> not be possible. Are there any plans to allow to actually change these?
Sure thing. We only need a victim! :)
M.
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v5 0/4] KVM: arm64: Errata management for VM Live migration
2025-02-04 17:11 ` Marc Zyngier
@ 2025-02-04 17:42 ` Sebastian Ott
2025-02-04 18:15 ` Marc Zyngier
0 siblings, 1 reply; 18+ messages in thread
From: Sebastian Ott @ 2025-02-04 17:42 UTC (permalink / raw)
To: Marc Zyngier
Cc: Shameer Kolothum, kvmarm, oliver.upton, catalin.marinas, will,
mark.rutland, Cornelia Huck, eric.auger, yuzenghui, wangzhou1,
jiangkunkun, jonathan.cameron, anthony.jebson, linux-arm-kernel,
linuxarm
On Tue, 4 Feb 2025, Marc Zyngier wrote:
> On Tue, 04 Feb 2025 16:45:38 +0000,
> Sebastian Ott <sebott@redhat.com> wrote:
>>
>> Hey,
>>
>> On Fri, 24 Jan 2025, Shameer Kolothum wrote:
>>> On ARM64 platforms most of the errata workarounds are based on CPU
>>> MIDR/REVIDR values and a number of these workarounds need to be
>>> implemented by the Guest kernel as well. This creates a problem when
>>> Guest needs to be migrated to a platform that differs in these
>>> MIDR/REVIDR values even if the VMM can come up with a common minimum
>>> feature list for the Guest using the recently introduced "Writable
>>> ID registers" support.
>>
>> Currently MIDR/REVIDR are still RO and guest access is not trapped - so
>> even with the errata management patches in place the guest state would
>> change and a migration (between hosts that differ in these regs) would
>> not be possible. Are there any plans to allow to actually change these?
>
> Sure thing. We only need a victim! :)
;-) Nice. I'll hack smth up then.
Sebastian
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v5 0/4] KVM: arm64: Errata management for VM Live migration
2025-02-04 17:42 ` Sebastian Ott
@ 2025-02-04 18:15 ` Marc Zyngier
0 siblings, 0 replies; 18+ messages in thread
From: Marc Zyngier @ 2025-02-04 18:15 UTC (permalink / raw)
To: Sebastian Ott
Cc: Shameer Kolothum, kvmarm, oliver.upton, catalin.marinas, will,
mark.rutland, Cornelia Huck, eric.auger, yuzenghui, wangzhou1,
jiangkunkun, jonathan.cameron, anthony.jebson, linux-arm-kernel,
linuxarm
On Tue, 04 Feb 2025 17:42:04 +0000,
Sebastian Ott <sebott@redhat.com> wrote:
>
> On Tue, 4 Feb 2025, Marc Zyngier wrote:
> > On Tue, 04 Feb 2025 16:45:38 +0000,
> > Sebastian Ott <sebott@redhat.com> wrote:
> >>
> >> Hey,
> >>
> >> On Fri, 24 Jan 2025, Shameer Kolothum wrote:
> >>> On ARM64 platforms most of the errata workarounds are based on CPU
> >>> MIDR/REVIDR values and a number of these workarounds need to be
> >>> implemented by the Guest kernel as well. This creates a problem when
> >>> Guest needs to be migrated to a platform that differs in these
> >>> MIDR/REVIDR values even if the VMM can come up with a common minimum
> >>> feature list for the Guest using the recently introduced "Writable
> >>> ID registers" support.
> >>
> >> Currently MIDR/REVIDR are still RO and guest access is not trapped - so
> >> even with the errata management patches in place the guest state would
> >> change and a migration (between hosts that differ in these regs) would
> >> not be possible. Are there any plans to allow to actually change these?
> >
> > Sure thing. We only need a victim! :)
>
> ;-) Nice. I'll hack smth up then.
Great.
Ideally, you would get rid of all the remaining invariant registers
(MIDR, REVIDR and AIDR). But you must preserve the current behaviour
as the default, sampling these registers on the CPU that initialises
KVM, and preserve the values for userspace to observe unless they are
written to (yes, that's broken, but we're stuck with that).
Also, please don't trap MIDR_EL1. That's very pointless. You only need
to trap REVIDR and AIDR via HCR_EL2.TID1.
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2025-02-04 21:16 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-24 15:17 [PATCH v5 0/4] KVM: arm64: Errata management for VM Live migration Shameer Kolothum
2025-01-24 15:17 ` [PATCH v5 1/4] arm64: Modify _midr_range() functions to read MIDR/REVIDR internally Shameer Kolothum
2025-01-24 15:17 ` [PATCH v5 2/4] KVM: arm64: Introduce hypercall support for retrieving target implementations Shameer Kolothum
2025-01-27 12:50 ` Cornelia Huck
2025-01-27 17:26 ` Oliver Upton
2025-01-28 14:16 ` Shameerali Kolothum Thodi
2025-01-24 15:17 ` [PATCH v5 3/4] KVM: arm64: Report all the KVM/arm64-specific hypercalls Shameer Kolothum
2025-01-27 12:47 ` Cornelia Huck
2025-01-27 13:35 ` Shameerali Kolothum Thodi
2025-01-27 17:05 ` Oliver Upton
2025-01-27 17:24 ` Shameerali Kolothum Thodi
2025-01-24 15:17 ` [PATCH v5 4/4] arm64: paravirt: Enable errata based on implementation CPUs Shameer Kolothum
2025-01-27 12:53 ` Cornelia Huck
2025-01-27 17:37 ` Oliver Upton
2025-02-04 16:45 ` [PATCH v5 0/4] KVM: arm64: Errata management for VM Live migration Sebastian Ott
2025-02-04 17:11 ` Marc Zyngier
2025-02-04 17:42 ` Sebastian Ott
2025-02-04 18:15 ` Marc Zyngier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).