Skip to contentSkip to conversation

target/arm/arm-powerctl: mask the cpuid with affinity bits when get cpu

PATCH In review Yang Chuanlong 3 participants 4 messages Apr 30, 2019 – May 1, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/arm/arm-powerctl: mask the cpuid with affinity bits when get cpu

Currently, the cpuid passed from the device tree may still contain non-affinity fields, which will cause arm_set_cpu_on failure. Therefore, we mask the cpuid with affinity fields here to improve qemu compatibility.

---
 target/arm/arm-powerctl.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
target/arm/arm-powerctl.c +7 -1
index f77a950db6..ef9fec0b4d 100644
@@ -31,7 +31,13 @@ CPUState *arm_get_cpu_by_id(uint64_t id)
 {
     CPUState *cpu;
 
-    DPRINTF("cpu %" PRId64 "\n", id);
+#ifdef TARGET_AARCH64
+    id &= ARM64_AFFINITY_MASK;
+#else
+    id &= ARM32_AFFINITY_MASK;
+#endif
+
+    DPRINTF("cpu %" PRId64 " after mask affinity\n", id);
 
     CPU_FOREACH(cpu) {
         ARMCPU *armcpu = ARM_CPU(cpu);
Signature · 1 line
2.21.0
#1 lore raw
Quoted 20 lines · Yang Chuanlong

Currently, the cpuid passed from the device tree may still contain non-affinity fields, which will cause arm_set_cpu_on failure. Therefore, we mask the cpuid with affinity fields here to improve qemu compatibility.

---
 target/arm/arm-powerctl.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
target/arm/arm-powerctl.c +0 -1
index f77a950db6..ef9fec0b4d 100644
@@ -31,7 +31,13 @@ CPUState *arm_get_cpu_by_id(uint64_t id)
 {
     CPUState *cpu;
 
-    DPRINTF("cpu %" PRId64 "\n", id);

target/arm/arm-powerctl.c CPUState *arm_get_cpu_by_id(uint64_t id) · line 43

Quoted 10 lines
target/arm/arm-powerctl.c +7 -0
+#ifdef TARGET_AARCH64
+    id &= ARM64_AFFINITY_MASK;
+#else
+    id &= ARM32_AFFINITY_MASK;
+#endif
+
+    DPRINTF("cpu %" PRId64 " after mask affinity\n", id);
 
     CPU_FOREACH(cpu) {
         ARMCPU *armcpu = ARM_CPU(cpu);

Hi -- could you explain what the code path is where we end up passing a wrong value into this function? I'm wondering if this is the best place to fix it, or if maybe the calling function is at fault.

Also, you can't use #ifdef TARGET_AARCH64 here to distinguish a 64-bit from a 32-bit CPU, because the qemu-system-aarch64 binary (which is built with TARGET_AARCH64) also supports all the 32-bit CPUs.

thanks
-- PMM

#2 lore raw
In reply to Yang Chuanlong
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the asan build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-debug@fedora TARGET_LIST=x86_64-softmmu J=14 NETWORK=1 === TEST SCRIPT END ===

The full log is available at
http://patchew.org/logs/[email protected]/testing.asan/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#3 lore raw
In reply to Yang Chuanlong
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-mingw@fedora SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===

The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]