From a468e7b520d3ee3e8d2f490f61ce876dcc192d07 Mon Sep 17 00:00:00 2001 From: "Huawei Technologies Co., Ltd" Date: Wed, 9 Dec 2020 19:35:08 +0800 Subject: [PATCH 1/4] target/arm: Fix write redundant values to kvm After modifying the value of a ID register, we'd better to try to write it to KVM so that we can known the value is acceptable for KVM. Because it may modify the registers' values of KVM, it's not suitable for other registers. (cherry-picked from a0d7a9de807639fcfcbe1fe037cb8772d459a9cf) Signed-off-by: Peng Liang --- ...rm-Fix-write-redundant-values-to-kvm.patch | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 target-arm-Fix-write-redundant-values-to-kvm.patch diff --git a/target-arm-Fix-write-redundant-values-to-kvm.patch b/target-arm-Fix-write-redundant-values-to-kvm.patch new file mode 100644 index 0000000..195554a --- /dev/null +++ b/target-arm-Fix-write-redundant-values-to-kvm.patch @@ -0,0 +1,118 @@ +From 02d02b4ff77a03a9b8b4839891d517dd6db31c5d Mon Sep 17 00:00:00 2001 +From: Peng Liang +Date: Wed, 9 Dec 2020 19:35:08 +0800 +Subject: [PATCH] target/arm: Fix write redundant values to kvm + +After modifying the value of a ID register, we'd better to try to write +it to KVM so that we can known the value is acceptable for KVM. +Because it may modify the registers' values of KVM, it's not suitable +for other registers. + +(cherry-picked from a0d7a9de807639fcfcbe1fe037cb8772d459a9cf) +Signed-off-by: Peng Liang +--- + target/arm/helper.c | 73 ++++++++++++++++++++++++++++++--------------- + 1 file changed, 49 insertions(+), 24 deletions(-) + +diff --git a/target/arm/helper.c b/target/arm/helper.c +index b262f5d6c5..bddd355fa0 100644 +--- a/target/arm/helper.c ++++ b/target/arm/helper.c +@@ -252,6 +252,16 @@ static bool raw_accessors_invalid(const ARMCPRegInfo *ri) + return true; + } + ++static bool is_id_reg(const ARMCPRegInfo *ri) ++{ ++ /* ++ * (Op0, Op1, CRn, CRm, Op2) of ID registers is (3, 0, 0, crm, op2), ++ * where 1<=crm<8, 0<=op2<8. ++ */ ++ return ri->opc0 == 3 && ri->opc1 == 0 && ri->crn == 0 && ++ ri->crm > 0 && ri->crm < 8; ++} ++ + bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync) + { + /* Write the coprocessor state from cpu->env to the (index,value) list. */ +@@ -268,38 +278,53 @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync) + ok = false; + continue; + } +- /* +- * (Op0, Op1, CRn, CRm, Op2) of ID registers is (3, 0, 0, crm, op2), +- * where 1<=crm<8, 0<=op2<8. Let's give ID registers a chance to +- * synchronize to kvm. +- */ +- if ((ri->type & ARM_CP_NO_RAW) && !(kvm_sync && +- ri->opc0 == 3 && ri->opc1 == 0 && ri->crn == 0 && ri->crm > 0)) { ++ if ((ri->type & ARM_CP_NO_RAW) && !(kvm_sync && is_id_reg(ri))) { + continue; + } + + newval = read_raw_cp_reg(&cpu->env, ri); + if (kvm_sync) { +- /* Only sync if we can sync to KVM successfully. */ +- uint64_t oldval; +- uint64_t kvmval; ++ if (is_id_reg(ri)) { ++ /* Only sync if we can sync to KVM successfully. */ ++ uint64_t oldval; ++ uint64_t kvmval; + +- if (kvm_arm_get_one_reg(cpu, cpu->cpreg_indexes[i], &oldval)) { +- continue; +- } +- if (oldval == newval) { +- continue; +- } ++ if (kvm_arm_get_one_reg(cpu, cpu->cpreg_indexes[i], &oldval)) { ++ continue; ++ } ++ if (oldval == newval) { ++ continue; ++ } + +- if (kvm_arm_set_one_reg(cpu, cpu->cpreg_indexes[i], &newval)) { +- continue; +- } +- if (kvm_arm_get_one_reg(cpu, cpu->cpreg_indexes[i], &kvmval) || +- kvmval != newval) { +- continue; +- } ++ if (kvm_arm_set_one_reg(cpu, cpu->cpreg_indexes[i], &newval)) { ++ continue; ++ } ++ if (kvm_arm_get_one_reg(cpu, cpu->cpreg_indexes[i], &kvmval) || ++ kvmval != newval) { ++ continue; ++ } ++ ++ kvm_arm_set_one_reg(cpu, cpu->cpreg_indexes[i], &oldval); ++ } else { ++ /* ++ * Only sync if the previous list->cpustate sync succeeded. ++ * Rather than tracking the success/failure state for every ++ * item in the list, we just recheck "does the raw write we must ++ * have made in write_list_to_cpustate() read back OK" here. ++ */ ++ uint64_t oldval = cpu->cpreg_values[i]; ++ ++ if (oldval == newval) { ++ continue; ++ } + +- kvm_arm_set_one_reg(cpu, cpu->cpreg_indexes[i], &oldval); ++ write_raw_cp_reg(&cpu->env, ri, oldval); ++ if (read_raw_cp_reg(&cpu->env, ri) != oldval) { ++ continue; ++ } ++ ++ write_raw_cp_reg(&cpu->env, ri, newval); ++ } + } + cpu->cpreg_values[i] = newval; + } +-- +2.27.0 + -- Gitee From 183e6f121c8ed16a0c408a0fc8509144a512a590 Mon Sep 17 00:00:00 2001 From: Euler Robot Date: Wed, 6 Jan 2021 11:26:52 +0800 Subject: [PATCH 2/4] spec: Update patch and changelog with !55 target/arm: Fix write redundant values to kvm Signed-off-by: Alex Chen --- qemu.spec | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qemu.spec b/qemu.spec index 7d8090c..3af8323 100644 --- a/qemu.spec +++ b/qemu.spec @@ -232,6 +232,7 @@ Patch0219: hw-usb-hcd-ohci-check-for-processed-TD-before-retire.patch Patch0220: hw-ehci-check-return-value-of-usb_packet_map.patch Patch0221: hw-usb-hcd-ohci-check-len-and-frame_number-variables.patch Patch0222: hw-net-e1000e-advance-desc_offset-in-case-of-null-de.patch +Patch0223: target-arm-Fix-write-redundant-values-to-kvm.patch BuildRequires: flex BuildRequires: bison @@ -577,6 +578,9 @@ getent passwd qemu >/dev/null || \ %endif %changelog +* Wed Dec 9 2020 Huawei Technologies Co., Ltd +- target/arm: Fix write redundant values to kvm + * Wed Nov 11 2020 Huawei Technologies Co., Ltd - hw: usb: hcd-ohci: check for processed TD before retire - hw: ehci: check return value of 'usb_packet_map' -- Gitee From 638d5b2a50db8d31de11dc51fa711104951ef63c Mon Sep 17 00:00:00 2001 From: Euler Robot Date: Wed, 6 Jan 2021 11:26:57 +0800 Subject: [PATCH 3/4] spec: Update release version with !55 increase release verison by one Signed-off-by: Euler Robot --- qemu.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu.spec b/qemu.spec index 3af8323..c640ebf 100644 --- a/qemu.spec +++ b/qemu.spec @@ -1,6 +1,6 @@ Name: qemu Version: 4.1.0 -Release: 31 +Release: 32 Epoch: 2 Summary: QEMU is a generic and open source machine emulator and virtualizer License: GPLv2 and BSD and MIT and CC-BY -- Gitee From b05bad770bbeb726ff6b9fc1442d1841e029fd73 Mon Sep 17 00:00:00 2001 From: Alex Chen Date: Fri, 8 Jan 2021 14:13:33 +0800 Subject: [PATCH 4/4] spec: updating the license info Specify the version of CC-BY license Signed-off-by: Alex Chen --- qemu.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu.spec b/qemu.spec index c640ebf..820c815 100644 --- a/qemu.spec +++ b/qemu.spec @@ -3,7 +3,7 @@ Version: 4.1.0 Release: 32 Epoch: 2 Summary: QEMU is a generic and open source machine emulator and virtualizer -License: GPLv2 and BSD and MIT and CC-BY +License: GPLv2 and BSD and MIT and CC-BY-SA-4.0 URL: http://www.qemu.org Source0: https://www.qemu.org/download/%{name}-%{version}%{?rcstr}.tar.xz Source1: 80-kvm.rules -- Gitee