From 09b7f81686c7a63bd7e9e91892236e91eef48693 Mon Sep 17 00:00:00 2001 From: Jiabo Feng Date: Thu, 24 Apr 2025 17:19:10 +0800 Subject: [PATCH] QEMU update to version 8.2.0-31: - target/arm: Change arm_cpu_mp_affinity when enabled IPIV feature - fw_cfg: Don't set callback_opaque NULL in fw_cfg_modify_bytes_read() Signed-off-by: Jiabo Feng (cherry picked from commit 519065adc4ba430c349a235e25b346829814f0d9) --- ...-callback_opaque-NULL-in-fw_cfg_modi.patch | 64 +++++++++++++++++ qemu.spec | 8 ++- ...e-arm_cpu_mp_affinity-when-enabled-I.patch | 70 +++++++++++++++++++ 3 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 fw_cfg-Don-t-set-callback_opaque-NULL-in-fw_cfg_modi.patch create mode 100644 target-arm-Change-arm_cpu_mp_affinity-when-enabled-I.patch diff --git a/fw_cfg-Don-t-set-callback_opaque-NULL-in-fw_cfg_modi.patch b/fw_cfg-Don-t-set-callback_opaque-NULL-in-fw_cfg_modi.patch new file mode 100644 index 00000000..dfab1f98 --- /dev/null +++ b/fw_cfg-Don-t-set-callback_opaque-NULL-in-fw_cfg_modi.patch @@ -0,0 +1,64 @@ +From b93ac4e4fd07e36b95ce211faefd0c7912b6f62a Mon Sep 17 00:00:00 2001 +From: Shameer Kolothum +Date: Tue, 3 Dec 2024 13:18:06 +0000 +Subject: [PATCH] fw_cfg: Don't set callback_opaque NULL in + fw_cfg_modify_bytes_read() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +On arm/virt platform, Chen Xiang reported a Guest crash while +attempting the below steps, + +1. Launch the Guest with nvdimm=on +2. Hot-add a NVDIMM dev +3. Reboot +4. Guest boots fine. +5. Reboot again. +6. Guest boot fails. + +QEMU_EFI reports the below error: +ProcessCmdAddPointer: invalid pointer value in "etc/acpi/tables" +OnRootBridgesConnected: InstallAcpiTables: Protocol Error + +Debugging shows that on first reboot(after hot adding NVDIMM), +Qemu updates the etc/table-loader len, + +qemu_ram_resize() +  fw_cfg_modify_file() +     fw_cfg_modify_bytes_read() + +And in fw_cfg_modify_bytes_read() we set the "callback_opaque" for +the key entry to NULL. Because of this, on the second reboot, +virt_acpi_build_update() is called with a NULL "build_state" and +returns without updating the ACPI tables. This seems to be +upsetting the firmware. + +To fix this, don't change the callback_opaque in fw_cfg_modify_bytes_read(). + +Fixes: bdbb5b1706d165 ("fw_cfg: add fw_cfg_machine_reset function") +Reported-by: chenxiang +Acked-by: Igor Mammedov +Acked-by: Gerd Hoffmann +Signed-off-by: Shameer Kolothum +Message-ID: <20241203131806.37548-1-shameerali.kolothum.thodi@huawei.com> +Signed-off-by: Philippe Mathieu-Daudé +--- + hw/nvram/fw_cfg.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c +index 4e4524673a..d32079ebdf 100644 +--- a/hw/nvram/fw_cfg.c ++++ b/hw/nvram/fw_cfg.c +@@ -729,7 +729,6 @@ static void *fw_cfg_modify_bytes_read(FWCfgState *s, uint16_t key, + ptr = s->entries[arch][key].data; + s->entries[arch][key].data = data; + s->entries[arch][key].len = len; +- s->entries[arch][key].callback_opaque = NULL; + s->entries[arch][key].allow_write = false; + + return ptr; +-- +2.41.0.windows.1 + diff --git a/qemu.spec b/qemu.spec index 93534bb8..80dffeb6 100644 --- a/qemu.spec +++ b/qemu.spec @@ -3,7 +3,7 @@ Name: qemu Version: 8.2.0 -Release: 30 +Release: 31 Epoch: 11 Summary: QEMU is a generic and open source machine emulator and virtualizer License: GPLv2 and BSD and MIT and CC-BY-SA-4.0 @@ -794,6 +794,8 @@ Patch0777: smmuv3-Change-arm-smmuv3-nested-name-to-arm-smmuv3-a.patch Patch0778: smmuv3-Use-default-bus-for-arm-smmuv3-accel.patch Patch0779: gpex-acpi-Remove-duplicate-DSM-5.patch Patch0780: Revert-linux-user-Print-tid-not-pid-with-strace.patch +Patch0781: fw_cfg-Don-t-set-callback_opaque-NULL-in-fw_cfg_modi.patch +Patch0782: target-arm-Change-arm_cpu_mp_affinity-when-enabled-I.patch BuildRequires: flex BuildRequires: gcc @@ -1392,6 +1394,10 @@ getent passwd qemu >/dev/null || \ %endif %changelog +* Thu Apr 24 2025 Jiabo Feng - 11:8.2.0-31 +- target/arm: Change arm_cpu_mp_affinity when enabled IPIV feature +- fw_cfg: Don't set callback_opaque NULL in fw_cfg_modify_bytes_read() + * Tue Apr 22 2025 Jiabo Feng - 11:8.2.0-30 - Revert "linux-user: Print tid not pid with strace" - gpex-acpi: Remove duplicate DSM #5 diff --git a/target-arm-Change-arm_cpu_mp_affinity-when-enabled-I.patch b/target-arm-Change-arm_cpu_mp_affinity-when-enabled-I.patch new file mode 100644 index 00000000..db5b4648 --- /dev/null +++ b/target-arm-Change-arm_cpu_mp_affinity-when-enabled-I.patch @@ -0,0 +1,70 @@ +From 33aa02dc05bed8316b1c64131e8269f404287598 Mon Sep 17 00:00:00 2001 +From: Xiang Chen +Date: Tue, 15 Apr 2025 20:10:50 +0800 +Subject: [PATCH] target/arm: Change arm_cpu_mp_affinity when enabled IPIV + feature + +virt inclusion +category: feature +bugzilla: https://gitee.com/openeuler/qemu/issues/IC1EV7 + +--------------------------------------------------------------- + +Before IPIV feature, it gets mpidr from vcpu id, but after +the feature, we need to know whether IPIV is enabled. + +Signed-off-by: Xiang Chen +--- + linux-headers/linux/kvm.h | 2 ++ + target/arm/cpu.c | 22 +++++++++++++++++++--- + 2 files changed, 21 insertions(+), 3 deletions(-) + +diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h +index b94c5fd90f..a9d407eace 100644 +--- a/linux-headers/linux/kvm.h ++++ b/linux-headers/linux/kvm.h +@@ -1205,6 +1205,8 @@ 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 09d391bd34..b0f70de018 100644 +--- a/target/arm/cpu.c ++++ b/target/arm/cpu.c +@@ -1324,9 +1324,25 @@ static void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) + + uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz) + { +- uint32_t Aff1 = idx / clustersz; +- uint32_t Aff0 = idx % clustersz; +- return (Aff1 << ARM_AFF1_SHIFT) | Aff0; ++ 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; + } + + static void arm_cpu_initfn(Object *obj) +-- +2.41.0.windows.1 + -- Gitee