From nobody Sat Apr 27 16:29:56 2024 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.zohomail.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 15028903294052.4503299950656583; Wed, 16 Aug 2017 06:32:09 -0700 (PDT) Received: from localhost ([::1]:46758 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhyQZ-0007jV-O0 for importer@patchew.org; Wed, 16 Aug 2017 09:32:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhyPc-000752-3N for qemu-devel@nongnu.org; Wed, 16 Aug 2017 09:31:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dhyPY-00087Y-SO for qemu-devel@nongnu.org; Wed, 16 Aug 2017 09:31:08 -0400 Received: from 19.mo5.mail-out.ovh.net ([46.105.35.78]:51437) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dhyPY-00083n-Mh for qemu-devel@nongnu.org; Wed, 16 Aug 2017 09:31:04 -0400 Received: from player734.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 1F47011B63D for ; Wed, 16 Aug 2017 15:30:56 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player734.ha.ovh.net (Postfix) with ESMTPA id 15116280084; Wed, 16 Aug 2017 15:30:50 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Wed, 16 Aug 2017 15:30:44 +0200 Message-ID: <150289024450.6512.7645802616766236425.stgit@bahia.lan> User-Agent: StGit/0.17.1-46-g6855-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 5264707965009697107 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrleelgdeiiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.35.78 Subject: [Qemu-devel] [PATCH] spapr: fallback to raw mode if best compat mode cannot be set during CAS 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: qemu-ppc@nongnu.org, Suraj Jitindar Singh , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 KVM PR doesn't allow to set a compat mode. This causes ppc_set_compat_all() to fail and we return H_HARDWARE to the guest right away. This is excessive: even if we favor compat mode since commit 152ef803ceb19, we should at least fallback to raw mode if the guest supports it. This patch modifies cas_check_pvr() so that it also reports that the real PVR was found in the table supplied by the guest. Note that this is only makes sense if raw mode isn't explicitely disabled (ie, the user didn't set the machine "max-cpu-compat" property). If this is the case, we can simply ignore ppc_set_compat_all() failures, and let the guest run in raw mode. Signed-off-by: Greg Kurz --- hw/ppc/spapr_hcall.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 07b3da8dc4cd..7e9f7752afd5 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1441,7 +1441,8 @@ static target_ulong h_signal_sys_reset(PowerPCCPU *cp= u, } =20 static uint32_t cas_check_pvr(sPAPRMachineState *spapr, PowerPCCPU *cpu, - target_ulong *addr, Error **errp) + target_ulong *addr, bool *raw_mode_supported, + Error **errp) { bool explicit_match =3D false; /* Matched the CPU's real PVR */ uint32_t max_compat =3D spapr->max_compat_pvr; @@ -1481,6 +1482,8 @@ static uint32_t cas_check_pvr(sPAPRMachineState *spap= r, PowerPCCPU *cpu, return 0; } =20 + *raw_mode_supported =3D explicit_match; + /* Parsing finished */ trace_spapr_cas_pvr(cpu->compat_pvr, explicit_match, best_compat); =20 @@ -1499,8 +1502,9 @@ static target_ulong h_client_architecture_support(Pow= erPCCPU *cpu, sPAPROptionVector *ov1_guest, *ov5_guest, *ov5_cas_old, *ov5_updates; bool guest_radix; Error *local_err =3D NULL; + bool raw_mode_supported; =20 - cas_pvr =3D cas_check_pvr(spapr, cpu, &addr, &local_err); + cas_pvr =3D cas_check_pvr(spapr, cpu, &addr, &raw_mode_supported, &loc= al_err); if (local_err) { error_report_err(local_err); return H_HARDWARE; @@ -1510,8 +1514,14 @@ static target_ulong h_client_architecture_support(Po= werPCCPU *cpu, if (cpu->compat_pvr !=3D cas_pvr) { ppc_set_compat_all(cas_pvr, &local_err); if (local_err) { - error_report_err(local_err); - return H_HARDWARE; + /* We fail to set compat mode (likely because running with KVM= PR), + * but maybe we can fallback to raw mode if the guest supports= it. + */ + if (!raw_mode_supported) { + error_report_err(local_err); + return H_HARDWARE; + } + local_err =3D NULL; } } =20