From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:59886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLRWV-0000pO-JQ for qemu-devel@nongnu.org; Tue, 30 Apr 2019 08:06:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLRWU-0001p9-CM for qemu-devel@nongnu.org; Tue, 30 Apr 2019 08:06:11 -0400 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:41620) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLRWU-0001os-7B for qemu-devel@nongnu.org; Tue, 30 Apr 2019 08:06:10 -0400 Received: by mail-ot1-x342.google.com with SMTP id g8so10637220otl.8 for ; Tue, 30 Apr 2019 05:06:10 -0700 (PDT) MIME-Version: 1.0 References: <20190430031238.40499-1-yangchuanlong@huawei.com> In-Reply-To: <20190430031238.40499-1-yangchuanlong@huawei.com> From: Peter Maydell Date: Tue, 30 Apr 2019 13:05:58 +0100 Message-ID: Content-Type: text/plain; charset="UTF-8" Subject: Re: [Qemu-devel] [PATCH v1] target/arm/arm-powerctl: mask the cpuid with affinity bits when get cpu List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Yang Chuanlong Cc: QEMU Developers , gengdongjiu On Tue, 30 Apr 2019 at 04:22, Yang Chuanlong wrote: > > 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. > > Signed-off-by: Yang Chuanlong > --- > target/arm/arm-powerctl.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/target/arm/arm-powerctl.c b/target/arm/arm-powerctl.c > index f77a950db6..ef9fec0b4d 100644 > --- a/target/arm/arm-powerctl.c > +++ b/target/arm/arm-powerctl.c > @@ -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); 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