From nobody Sat May 10 16:49:12 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=pass(p=none dis=none)  header.from=gmail.com
ARC-Seal: i=1; a=rsa-sha256; t=1734579735; cv=none;
	d=zohomail.com; s=zohoarc;
	b=XE2QK+75VlIsStrK8rf1JFLFoyGKvme6b9vwdrPDvqT5n8v9HFNqQSOE1MnTlEu6DBLmp0+ci4zaKUdq8MOg2evGIzN0fBeTtNT5Zc/+RDEhe+3m/H20xcaux+z5ChzREOs6UbNJlgOicuOAPnhPxh0JWZA4JN/dEwE/KvV+dp8=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1734579735;
 h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To;
	bh=Vwlpe1MB5sgsXYOFPBQEhsgxZTpLhzeJKWOWZzIcj+E=;
	b=JCLBZ6kJfdh4REOE+e6OklyarTFjS/XyXFsYmYszdZjINU55f3RXMGP113JmDFKv/h71YJRScP2tghoEMFL271znBcJWPxUi7DUdqXcmFU0ahg4qOa+WVp4jVDFoY4xEz3ju6Yoh92LFEe5TuZE/ejkFnFVkNBHbzBSNo09rBfw=
ARC-Authentication-Results: i=1; mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=pass header.from=<npiggin@gmail.com> (p=none dis=none)
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1734579735811472.5888207232209;
 Wed, 18 Dec 2024 19:42:15 -0800 (PST)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces@nongnu.org>)
	id 1tO7PI-00076L-Ug; Wed, 18 Dec 2024 22:41:00 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <npiggin@gmail.com>)
 id 1tO7PF-00075T-UO; Wed, 18 Dec 2024 22:40:58 -0500
Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <npiggin@gmail.com>)
 id 1tO7PE-0004Iv-B0; Wed, 18 Dec 2024 22:40:57 -0500
Received: by mail-pl1-x62c.google.com with SMTP id
 d9443c01a7336-21683192bf9so3405345ad.3;
 Wed, 18 Dec 2024 19:40:55 -0800 (PST)
Received: from wheely.local0.net (14-200-18-130.tpgi.com.au. [14.200.18.130])
 by smtp.gmail.com with ESMTPSA id
 d9443c01a7336-219dc970520sm2881595ad.75.2024.12.18.19.40.51
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 18 Dec 2024 19:40:54 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1734579654; x=1735184454; darn=nongnu.org;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=Vwlpe1MB5sgsXYOFPBQEhsgxZTpLhzeJKWOWZzIcj+E=;
 b=db5PAK6hvpNrSUJ8WNibKh11xgdJvDq2G6dqYkJSC1tNvaGRmEW39HbNzWuNxn1I87
 rtCwMrDdSC/Nl5fk10dpFycKqzvTsBPcE9Ezc7S3MeyzAtTKk+KyBCuMMJBLOQCZjNBA
 Li2w+ttDAyLn/l3SEBByuLw1yTcIIRN69qSLSiOpGYpwNVLLgOY7OmfnqNXuGb0sh6GP
 KQ99hHlwceR4gWJ5JPkES/NCDqM/hiIAzcb86mnaRX0py8YFV+a1Rjrd4/B0mnZ8v+XI
 6uU7XuUszKD4q9tGoRzffRwGfIIGR0r6qz5/e5ByFeYR/wDoXVMp6usTb1XrtDYmDlmd
 jKtQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1734579654; x=1735184454;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=Vwlpe1MB5sgsXYOFPBQEhsgxZTpLhzeJKWOWZzIcj+E=;
 b=QdcO2TWQa05wIvoYhx+Og9+lfD26s++pDom/+JaV3qqGIm/tasG/oEQnYOrpMSSNum
 9zz+g/Nbe5bmrBSJeyPMBREZdePze6dbhOrNkVNcP44JgGQ8H53+t8Jauqww8ZLC4DGH
 4WDvP4GHXpvtIr4dZ6HGDMDD8ufk6t08p3Tlh/7p5TyXWqC6wxSqryVAkezGlX3d4Hnm
 7TFFbnwSijom3dAIu/LG5ciSw/R35e/83j2819VDFN6mahDpP0l5R0hua9HAm6MGQ8bd
 fsbb+yB+X8px+sGyNESI080qeoHXP1llIyt1FkGXymFez6GpbuhFb5Tx1iFWTlqbSh8f
 ryFw==
X-Forwarded-Encrypted: i=1;
 AJvYcCX4gXP5bER6CJbhJc0dCnuxCDON4z44b4t0fYM1b+eVCcY7YZWrql731Ss2jtA2bVjiJDpBeRMjaryD@nongnu.org
X-Gm-Message-State: AOJu0YwD3KAMxZfdetexD1SlPqUItmMDl33GUzbNYWtmMhwK3i47CLIa
 zLP6+6hSC4RUrlPDQpKxjDfaJNgva9oQlydi5yTIW2bbtoZwB+g/qn1aSQ==
X-Gm-Gg: ASbGncs8TKuOMgrj4BKl8nZLC7yuPx9uvFurDlmhAdokc0NikaJ+11RLDXw3cAN1NgA
 2KdMAPVn86kJUBXtvmCY2rdbP3FPOLhjjxdJOYa7eboGYkxICxGyrRMQbX8wftRIWUr4qi2RGlj
 vssQ0CyfNQiXwpbK1JDn2Rjv2QSpb9Xzyi2uK2mdKw6si1U2xDV8OfdvMpjyzgpeNEXsjMb5C4K
 h9mvpFXQMosvO8sM6Thkp+n+D7vI831ExqL4aF0Lw+lp8vH07vrPBm89IbzW9dpEniFmpSZzkcF
 2nafm18n9Q==
X-Google-Smtp-Source: 
 AGHT+IH2M/jisU1OzVQI0W7JexlH48qVb/oF3O9VlP9AZCZ4bUIl3TvcYLglPfAnMi/z+IrdWz3N1A==
X-Received: by 2002:a17:902:e741:b0:216:2dc4:50ab with SMTP id
 d9443c01a7336-218d6fd5f54mr65907225ad.2.1734579654338;
 Wed, 18 Dec 2024 19:40:54 -0800 (PST)
From: Nicholas Piggin <npiggin@gmail.com>
To: qemu-ppc@nongnu.org
Cc: Nicholas Piggin <npiggin@gmail.com>,
 Daniel Henrique Barboza <danielhb413@gmail.com>,
 Harsh Prateek Bora <harshpb@linux.ibm.com>, qemu-devel@nongnu.org
Subject: [PATCH 4/5] target/ppc: Avoid warning message for zero process table
 entries
Date: Thu, 19 Dec 2024 13:40:34 +1000
Message-ID: <20241219034035.1826173-5-npiggin@gmail.com>
X-Mailer: git-send-email 2.45.2
In-Reply-To: <20241219034035.1826173-1-npiggin@gmail.com>
References: <20241219034035.1826173-1-npiggin@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass (zohomail.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;
Received-SPF: pass client-ip=2607:f8b0:4864:20::62c;
 envelope-from=npiggin@gmail.com; helo=mail-pl1-x62c.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org
X-ZohoMail-DKIM: pass (identity @gmail.com)
X-ZM-MESSAGEID: 1734579737597116600
Content-Type: text/plain; charset="utf-8"

A translation that encounters a process table entry that is zero is
something that Linux does to cause certain kernel NULL pointer
dereferences to fault. It is not itself a programming error, so avoid
the guest error log.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 target/ppc/mmu-radix64.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/target/ppc/mmu-radix64.c b/target/ppc/mmu-radix64.c
index be7a45f2549..02099300358 100644
--- a/target/ppc/mmu-radix64.c
+++ b/target/ppc/mmu-radix64.c
@@ -571,6 +571,20 @@ static int ppc_radix64_process_scoped_xlate(PowerPCCPU=
 *cpu,
         prtbe0 =3D ldq_phys(cs->as, h_raddr);
     }
=20
+    /*
+     * Some Linux uses a zero process table entry in PID!=3D0 for kernel c=
ontext
+     * without userspace in order to fault on NULL dereference, because us=
ing
+     * PIDR=3D0 for the kernel causes the Q0 page table to be used to tran=
slate
+     * Q3 as well. Check for that case here to avoid the invalid configura=
tion
+     * message.
+     */
+    if (unlikely(!prtbe0)) {
+        if (guest_visible) {
+            ppc_radix64_raise_si(cpu, access_type, eaddr, DSISR_R_BADCONFI=
G);
+        }
+        return 1;
+    }
+
     /* Walk Radix Tree from Process Table Entry to Convert EA to RA */
     *g_page_size =3D PRTBE_R_GET_RTS(prtbe0);
     base_addr =3D prtbe0 & PRTBE_R_RPDB;
--=20
2.45.2