From nobody Sun Nov 9 17:50:08 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551752550266269.58603500035235; Mon, 4 Mar 2019 18:22:30 -0800 (PST) Received: from localhost ([127.0.0.1]:36124 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0zim-0007KK-RA for importer@patchew.org; Mon, 04 Mar 2019 21:22:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0zhl-0006vU-P0 for qemu-devel@nongnu.org; Mon, 04 Mar 2019 21:21:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h0zhk-0003Aq-TO for qemu-devel@nongnu.org; Mon, 04 Mar 2019 21:21:17 -0500 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:35274) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h0zhi-00037A-Ju; Mon, 04 Mar 2019 21:21:14 -0500 Received: by mail-pf1-x441.google.com with SMTP id j5so4438630pfa.2; Mon, 04 Mar 2019 18:21:14 -0800 (PST) Received: from surajjs2.ozlabs.ibm.com.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id e21sm18567174pfh.45.2019.03.04.18.21.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 04 Mar 2019 18:21:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Z2JLPxURU8Isv2wbkJqqazjFdxEGcp6wre+VN12i04A=; b=tCCsiT/75Bv49cX7Pv61g85Ht8lqHxqjjyV4tfNkBioOeV+fXaWnJ7DTar0dZ96FrX YsCFVu1fMMQkdEHW9KJwwO2HfSdI7Jsk/AueQa5p3gZrqsL6/EEfeUzxjaIk0slMLDQl gD/0xQGwhVdHeIV5AxND/0baULt2vVyo/0W6RYw8HZlTf6C+0uiFTnCCRQVNo0abrs9X wji9Loj2O/Y+AE5h5ht9UGdCy7dhip+TVzFTRtPpzHyMd9DF3K/ee20PjjFpm8wPTFM/ tL/cTIezLHtxKrvNikin4uAPYh1LjNjaKkvjfQRq+We5h9TvMM9DADXAzkeXEhVYI2kv aryQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Z2JLPxURU8Isv2wbkJqqazjFdxEGcp6wre+VN12i04A=; b=egJJWiSe7pZQJKoAZT8xG7YloGg3x++LaBYMWzJMeMOkrr055KZ8FDOpO+QDaeOwHj DaOvqzPtyUMKj1qKCSWO02m2OXLrQyFVx7CBJ2+4ws7joJd6A9I6Vahj0RLfG1R0B2c2 kdNMi6akrYS4sAuGY3HOOBQ3suAB0Tf9Npf+hMq1nuWFkyIdT4xrL0mZQ9IjO05fS+ub 8Rj3NrwVTKh1Us+cB3/aeOkxEhuMNQv+6Y0V0yOKlfa32EjgCAcjH02SlbHsVz2LF6GR wo8hB8NfD+1tQQCIh9dNtnFVO/pf58WbG4jPAQZMDTMFdrgEYQtmlQOg68EUlyEjD0oN HsYw== X-Gm-Message-State: APjAAAWfiDrM3rX/8EEgDPVXEtkFpiwC54mwpZJfdyFwugXRmXcuCmfk bHoyplUEnU8jT+5w/Hcr7MggTfuZ X-Google-Smtp-Source: APXvYqyEpJ8VTEmrsgK3S7EoArozv6tcTEupRt8KmsHcJl1oFUkLt5jA+ZSdoKqaQyRVM0294SEH1w== X-Received: by 2002:a17:902:2bc9:: with SMTP id l67mr23884781plb.241.1551752472808; Mon, 04 Mar 2019 18:21:12 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Tue, 5 Mar 2019 13:21:02 +1100 Message-Id: <20190305022102.17610-1-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [QEMU-PPC] [PATCH] target/ppc/spapr: Clear partition table entry when allocating hash table 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: clg@kaod.org, qemu-devel@nongnu.org, Suraj Jitindar Singh , david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If we allocate a hash page table then we know that the guest won't be using process tables, so set the partition table entry maintained for the guest to zero. If this isn't done, then the guest radix bit will remain set in the entry. This means that when the guest calls H_REGISTER_PROCESS_TABLE there will be a mismatch between then flags and the value in spapr->patb_entry, and the call will fail. The guest will then panic: Failed to register process table (rc=3D-4) kernel BUG at arch/powerpc/platforms/pseries/lpar.c:959 The result being that it isn't possible to boot a hash guest on a P9 system. Also fix a bug in the flags parsing in h_register_process_table() which was introduced by the same patch, and simplify the handling to make it less likely that errors will be introduced in the future. The effect would have been setting the host radix bit LPCR_HR for a hash guest using process tables, which currently isn't supported and so couldn't have been triggered. Fixes: 00fd075e18 "target/ppc/spapr: Set LPCR:HR when using Radix mode" Signed-off-by: Suraj Jitindar Singh --- hw/ppc/spapr.c | 1 + hw/ppc/spapr_hcall.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index e39068578e..cf1ef9ebd4 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1632,6 +1632,7 @@ void spapr_reallocate_hpt(sPAPRMachineState *spapr, i= nt shift, } } /* We're setting up a hash table, so that means we're not radix */ + spapr->patb_entry =3D 0; spapr_set_all_lpcrs(0, LPCR_HR | LPCR_UPRT); } =20 diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 8bfdddc964..7016a09386 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1339,6 +1339,7 @@ static target_ulong h_register_process_table(PowerPCC= PU *cpu, target_ulong proc_tbl =3D args[1]; target_ulong page_size =3D args[2]; target_ulong table_size =3D args[3]; + target_ulong update_lpcr =3D 0; uint64_t cproc; =20 if (flags & ~FLAGS_MASK) { /* Check no reserved bits are set */ @@ -1394,10 +1395,13 @@ static target_ulong h_register_process_table(PowerP= CCPU *cpu, spapr->patb_entry =3D cproc; /* Save new process table */ =20 /* Update the UPRT, HR and GTSE bits in the LPCR for all cpus */ - spapr_set_all_lpcrs(((flags & (FLAG_RADIX | FLAG_HASH_PROC_TBL)) ? - (LPCR_UPRT | LPCR_HR) : 0) | - ((flags & FLAG_GTSE) ? LPCR_GTSE : 0), - LPCR_UPRT | LPCR_HR | LPCR_GTSE); + if (flags & FLAG_RADIX) /* Radix must use process tables, also set= HR */ + update_lpcr |=3D (LPCR_UPRT | LPCR_HR); + else if (flags & FLAG_HASH_PROC_TBL) /* Hash with process tables */ + update_lpcr |=3D LPCR_UPRT; + if (flags & FLAG_GTSE) /* Guest translation shootdown enable */ + update_lpcr |=3D FLAG_GTSE; + spapr_set_all_lpcrs(update_lpcr, LPCR_UPRT | LPCR_HR | LPCR_GTSE); =20 if (kvm_enabled()) { return kvmppc_configure_v3_mmu(cpu, flags & FLAG_RADIX, --=20 2.13.6