From nobody Sat Jul 12 15:58:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1486017795277425.76212254570953; Wed, 1 Feb 2017 22:43:15 -0800 (PST) Received: from localhost ([::1]:54707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZB6v-0002J7-1q for importer@patchew.org; Thu, 02 Feb 2017 01:43:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZ9k8-0007mY-JO for qemu-devel@nongnu.org; Thu, 02 Feb 2017 00:15:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZ9k1-00046V-7t for qemu-devel@nongnu.org; Thu, 02 Feb 2017 00:15:36 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:40329) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZ9k0-00043h-PU; Thu, 02 Feb 2017 00:15:29 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vDSqW12N4z9s7P; Thu, 2 Feb 2017 16:14:59 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1486012503; bh=KQJG/B8QAUkfgF8kBFLAxCYIe3wk376WWMm0yzHRlVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YgObG9AUSTtK7HIADYhKktUfgvJ9RF/c7lBuJqcasSgAAPGOSR8xBX6nntNhNxzqj wS6+ELwKXRpbejV3GZoLFjvrHPFxm3m5l2TSVWymeHoGhYtcBAakTmYtACcDnhh3CU 71kF8dbMBDv2iSmQgsLJiWZ0dI86y4Ama4FopV+8= From: David Gibson To: peter.maydell@linaro.org Date: Thu, 2 Feb 2017 16:14:00 +1100 Message-Id: <20170202051445.5735-63-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170202051445.5735-1-david@gibson.dropbear.id.au> References: <20170202051445.5735-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 062/107] ppc: Add ppc_set_compat_all() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, thuth@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Once a compatiblity mode is negotiated with the guest, h_client_architecture_support() uses run_on_cpu() to update each CPU to the new mode. We're going to want this logic somewhere else shortly, so make a helper function to do this global update. We put it in target-ppc/compat.c - it makes as much sense at the CPU level as it does at the machine level. We also move the cpu_synchronize_state() into ppc_set_compat(), since it doesn't really make any sense to call that without synchronizing state. Signed-off-by: David Gibson --- hw/ppc/spapr_hcall.c | 31 +++++-------------------------- target/ppc/compat.c | 35 +++++++++++++++++++++++++++++++++++ target/ppc/cpu.h | 3 +++ 3 files changed, 43 insertions(+), 26 deletions(-) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index f4531c5..42d20e0 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -921,20 +921,6 @@ static target_ulong h_signal_sys_reset(PowerPCCPU *cpu, } } =20 -typedef struct { - uint32_t compat_pvr; - Error *err; -} SetCompatState; - -static void do_set_compat(CPUState *cs, run_on_cpu_data arg) -{ - PowerPCCPU *cpu =3D POWERPC_CPU(cs); - SetCompatState *s =3D arg.host_ptr; - - cpu_synchronize_state(cs); - ppc_set_compat(cpu, s->compat_pvr, &s->err); -} - static target_ulong h_client_architecture_support(PowerPCCPU *cpu, sPAPRMachineState *spapr, target_ulong opcode, @@ -942,7 +928,6 @@ static target_ulong h_client_architecture_support(Power= PCCPU *cpu, { target_ulong list =3D ppc64_phys_to_real(args[0]); target_ulong ov_table; - CPUState *cs; bool explicit_match =3D false; /* Matched the CPU's real PVR */ uint32_t max_compat =3D cpu->max_compat; uint32_t best_compat =3D 0; @@ -986,18 +971,12 @@ static target_ulong h_client_architecture_support(Pow= erPCCPU *cpu, =20 /* Update CPUs */ if (cpu->compat_pvr !=3D best_compat) { - CPU_FOREACH(cs) { - SetCompatState s =3D { - .compat_pvr =3D best_compat, - .err =3D NULL, - }; + Error *local_err =3D NULL; =20 - run_on_cpu(cs, do_set_compat, RUN_ON_CPU_HOST_PTR(&s)); - - if (s.err) { - error_report_err(s.err); - return H_HARDWARE; - } + ppc_set_compat_all(best_compat, &local_err); + if (local_err) { + error_report_err(local_err); + return H_HARDWARE; } } =20 diff --git a/target/ppc/compat.c b/target/ppc/compat.c index 1059555..458da26 100644 --- a/target/ppc/compat.c +++ b/target/ppc/compat.c @@ -18,6 +18,7 @@ */ =20 #include "qemu/osdep.h" +#include "sysemu/hw_accel.h" #include "sysemu/kvm.h" #include "kvm_ppc.h" #include "sysemu/cpus.h" @@ -124,6 +125,8 @@ void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pv= r, Error **errp) pcr =3D compat->pcr; } =20 + cpu_synchronize_state(CPU(cpu)); + cpu->compat_pvr =3D compat_pvr; env->spr[SPR_PCR] =3D pcr & pcc->pcr_mask; =20 @@ -136,6 +139,38 @@ void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_p= vr, Error **errp) } } =20 +typedef struct { + uint32_t compat_pvr; + Error *err; +} SetCompatState; + +static void do_set_compat(CPUState *cs, run_on_cpu_data arg) +{ + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + SetCompatState *s =3D arg.host_ptr; + + ppc_set_compat(cpu, s->compat_pvr, &s->err); +} + +void ppc_set_compat_all(uint32_t compat_pvr, Error **errp) +{ + CPUState *cs; + + CPU_FOREACH(cs) { + SetCompatState s =3D { + .compat_pvr =3D compat_pvr, + .err =3D NULL, + }; + + run_on_cpu(cs, do_set_compat, RUN_ON_CPU_HOST_PTR(&s)); + + if (s.err) { + error_propagate(errp, s.err); + return; + } + } +} + int ppc_compat_max_threads(PowerPCCPU *cpu) { const CompatInfo *compat =3D compat_by_pvr(cpu->compat_pvr); diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 22842dd..4d72d75 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1326,6 +1326,9 @@ static inline int cpu_mmu_index (CPUPPCState *env, bo= ol ifetch) bool ppc_check_compat(PowerPCCPU *cpu, uint32_t compat_pvr, uint32_t min_compat_pvr, uint32_t max_compat_pvr); void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr, Error **errp); +#if !defined(CONFIG_USER_ONLY) +void ppc_set_compat_all(uint32_t compat_pvr, Error **errp); +#endif int ppc_compat_max_threads(PowerPCCPU *cpu); #endif /* defined(TARGET_PPC64) */ =20 --=20 2.9.3