From 23a7d46a9bf6b0d692155eca9be0b7607db5d861 Mon Sep 17 00:00:00 2001 From: Jinqian Yang Date: Fri, 16 May 2025 18:20:10 +0800 Subject: [PATCH 1/2] Revert "target/arm: Change arm_cpu_mp_affinity when enabled IPIV feature" virt inclusion category: feature bugzilla: https://gitee.com/openeuler/qemu/issues/IC1EV7 ------------------------------------------------------------------------ This reverts commit 33aa02dc05bed8316b1c64131e8269f404287598. OpenEuler kernel OLK-6.6 add the SMCCC interface so that the guest OS can control the enabling of IPIV. When IPIV is enabled, the guest OS uses multiple unicast to implement multicast. So do not need to modify the MPIDR. Signed-off-by: Jinqian Yang --- linux-headers/linux/kvm.h | 2 -- target/arm/cpu.c | 22 +++------------------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index a19683f1e9..b711c04506 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -1205,8 +1205,6 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_SEV_ES_GHCB 500 #define KVM_CAP_HYGON_COCO_EXT 501 - -#define KVM_CAP_ARM_IPIV_MODE 503 /* support userspace to request firmware to build CSV3 guest's memory space */ #define KVM_CAP_HYGON_COCO_EXT_CSV3_SET_PRIV_MEM (1 << 0) /* support request to update CSV3 guest's memory region multiple times */ diff --git a/target/arm/cpu.c b/target/arm/cpu.c index b0f70de018..09d391bd34 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1324,25 +1324,9 @@ static void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz) { - uint64_t Aff0 = 0, Aff1 = 0, Aff2 = 0, Aff3 = 0; - int mode; - - if (!kvm_enabled()) { - Aff1 = idx / clustersz; - Aff0 = idx % clustersz; - return (Aff1 << ARM_AFF1_SHIFT) | Aff0; - } - - mode = kvm_check_extension(kvm_state, KVM_CAP_ARM_IPIV_MODE); - if (mode) { - Aff1 = idx % 16; - Aff2 = idx / 16; - } else { - Aff1 = idx / clustersz; - Aff0 = idx % clustersz; - } - return (Aff3 << ARM_AFF3_SHIFT) | (Aff2 << ARM_AFF2_SHIFT) | - (Aff1 << ARM_AFF1_SHIFT) | Aff0; + uint32_t Aff1 = idx / clustersz; + uint32_t Aff0 = idx % clustersz; + return (Aff1 << ARM_AFF1_SHIFT) | Aff0; } static void arm_cpu_initfn(Object *obj) -- Gitee From 4db69439ab84a108795f7dc1ea218aa746f1d2be Mon Sep 17 00:00:00 2001 From: Jinqian Yang Date: Fri, 16 May 2025 18:20:17 +0800 Subject: [PATCH 2/2] target/arm: support the IPIV feature virt inclusion category: feature bugzilla: https://gitee.com/openeuler/qemu/issues/IC1EV7 ------------------------------------------------------------------------ QEMU uses ioctl to enable IPIV. Signed-off-by: Jinqian Yang --- linux-headers/linux/kvm.h | 1 + target/arm/kvm.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index b711c04506..92fc1fbb85 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -1214,6 +1214,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_ARM_HW_DIRTY_STATE_TRACK 502 +#define KVM_CAP_ARM_HISI_IPIV 798 #define KVM_CAP_ARM_VIRT_MSI_BYPASS 799 #define KVM_EXIT_HYPERCALL_VALID_MASK (1 << KVM_HC_MAP_GPA_RANGE) diff --git a/target/arm/kvm.c b/target/arm/kvm.c index ee5ba68305..ab31515a2a 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -257,6 +257,22 @@ int kvm_arch_get_default_type(MachineState *ms) return fixed_ipa ? 0 : size; } +static void kvm_update_ipiv_cap(KVMState *s) +{ + int ret; + + if (!kvm_check_extension(s, KVM_CAP_ARM_HISI_IPIV)) { + return; + } + + ret = kvm_vm_enable_cap(s, KVM_CAP_ARM_HISI_IPIV, 0); + if (ret) { + fprintf(stderr, "Could not enable KVM_CAP_ARM_HISI_IPIV: %d\n", ret); + } + + return; +} + int kvm_arch_init(MachineState *ms, KVMState *s) { MachineClass *mc = MACHINE_GET_CLASS(ms); @@ -330,6 +346,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } kvm_arm_init_debug(s); + kvm_update_ipiv_cap(s); return ret; } -- Gitee