From nobody Wed Feb 11 02:54:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1770723051; cv=none; d=zohomail.com; s=zohoarc; b=LQ6KUnzDL2fFJiMg/xzacuUmJH3N1QdyMp6oAw+meq1kX3qwJs5sI1gRVKu5pj0LbTrBuZRrYe5f33BYG7NR+oAtZUswsT0r5GA18qSfuS/6eQO0xArvbz5acj4ojNR7A+zG1zsOVbaREgwd+LdqpmugvbEDiYeNmlUlx3IB7T4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770723051; h=Content-Type: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:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=PbZj+MJ7ZvB1UDK3MKfN9VG/9j0a+ZXm8vyyR4l7ieE=; b=Htco8w/iWj6HK2HUczVOyR3sOZb2hIZOOMd6FgTx1/VexEsoj+dB+IEiSVgco27j/HJr42f0PuPw17tf7/jnsKrEeeKM78+OeI/FUFpn1HIeBaHwdPogw2acz2od54cmo69qwxoyia+abGaT4Jpu0cN7PrtP0h2evPOzmO1DNbs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1770723051213815.9729395251777; Tue, 10 Feb 2026 03:30:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vplwk-0005KA-I9; Tue, 10 Feb 2026 06:30:22 -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 ) id 1vplwi-0005Hu-9n for qemu-devel@nongnu.org; Tue, 10 Feb 2026 06:30:20 -0500 Received: from rev.ng ([94.130.142.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vplwg-0008IJ-C7 for qemu-devel@nongnu.org; Tue, 10 Feb 2026 06:30:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rev.ng; s=dkim; h=Cc:To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive:List-Unsubscribe:List-Unsubscribe-Post: List-Help; bh=PbZj+MJ7ZvB1UDK3MKfN9VG/9j0a+ZXm8vyyR4l7ieE=; b=a1E+kMWjrTLs1pY GSgpMZ+ScVT+bP64qmH5g1NDmVGELGCxBkLXnPHs1McW068+T5aY0e6e1Jso/h+CdBmHf11kNSflb EkjFeTkZWCbs5ceYeOPq8BtvNSRSvRlyo7Mrp2BAYEDNxQDjWjmcVKkGmhIHz8w1PuFOaxJHHvQIs gU=; Date: Tue, 10 Feb 2026 12:33:13 +0100 Subject: [PATCH v4 2/8] target/hppa: Define PA[20|1X] physical address space size MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260210-phys_addr-v4-2-725a589e83c8@rev.ng> References: <20260210-phys_addr-v4-0-725a589e83c8@rev.ng> In-Reply-To: <20260210-phys_addr-v4-0-725a589e83c8@rev.ng> To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Anton Johansson , palmer@dabbelt.com, alistair.francis@wdc.com, pbonzini@redhat.com, gaosong@loongson.cn, maobibo@loongson.cn, deller@gmx.de 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=94.130.142.21; envelope-from=anjo@rev.ng; helo=rev.ng 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Anton Johansson From: Anton Johansson via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1770723053638154100 When converting virtual to physical addresses, TARGET_PHYS_ADDR_SPACE_BITS is used under PA-RISC 2.0, and an explicit cast to uint32_t is used under PA-RISC 1.X. Replace the former with a more specific macro limited to mem_helper.c, and make the latter conversion explicit by defining the size of the physical address space for PA-RISC 1.X. Note: while 44 bits should be used for the 64-bit address space running a C3700, 40 bits is still chosen as this is expected by the SeaBIOS functional test. Reviewed-by: Richard Henderson Signed-off-by: Anton Johansson --- target/hppa/cpu.h | 1 + target/hppa/mem_helper.c | 32 +++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 012e54f8f6..092e647ccf 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -336,6 +336,7 @@ static inline vaddr hppa_form_gva(CPUHPPAState *env, ui= nt64_t spc, return hppa_form_gva_mask(env->gva_offset_mask, spc, off); } =20 +hwaddr hppa_abs_to_phys_pa1x(vaddr addr); hwaddr hppa_abs_to_phys_pa2_w0(vaddr addr); hwaddr hppa_abs_to_phys_pa2_w1(vaddr addr); =20 diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index cce82e6599..9199d1e06a 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -29,6 +29,28 @@ #include "hw/core/cpu.h" #include "trace.h" =20 +/* + * 64-bit (PA-RISC 2.0) machines are assumed to run PA-8700, and 32-bit + * machines 7300LC. This should give 44 and 32 bits of physical address + * space respectively. + * + * CPU model Physical address space bits + * PA-7000--7300LC 32 + * PA-8000--8600 40 + * PA-8700--8900 44 + * + * FIXME: However, the SeaBIOS firmware that is that tested against + * uses 40-bit physical addresses, despite supposedly running a C3700 + * with a PA-8700 cpu, so use 40-bits for 64-bit. + */ +#define HPPA_PHYS_ADDR_SPACE_BITS_PA20 40 +#define HPPA_PHYS_ADDR_SPACE_BITS_PA1X 32 + +hwaddr hppa_abs_to_phys_pa1x(vaddr addr) +{ + return extract64(addr, 0, HPPA_PHYS_ADDR_SPACE_BITS_PA1X); +} + hwaddr hppa_abs_to_phys_pa2_w1(vaddr addr) { /* @@ -42,8 +64,8 @@ hwaddr hppa_abs_to_phys_pa2_w1(vaddr addr) * Since the supported physical address space is below 54 bits, the * H-8 algorithm is moot and all that is left is to truncate. */ - QEMU_BUILD_BUG_ON(TARGET_PHYS_ADDR_SPACE_BITS > 54); - return sextract64(addr, 0, TARGET_PHYS_ADDR_SPACE_BITS); + QEMU_BUILD_BUG_ON(HPPA_PHYS_ADDR_SPACE_BITS_PA20 > 54); + return sextract64(addr, 0, HPPA_PHYS_ADDR_SPACE_BITS_PA20); } =20 hwaddr hppa_abs_to_phys_pa2_w0(vaddr addr) @@ -67,7 +89,7 @@ hwaddr hppa_abs_to_phys_pa2_w0(vaddr addr) * is what can be seen on physical machines too. */ addr =3D (uint32_t)addr; - addr |=3D -1ull << (TARGET_PHYS_ADDR_SPACE_BITS - 4); + addr |=3D -1ull << (HPPA_PHYS_ADDR_SPACE_BITS_PA20 - 4); } return addr; } @@ -217,7 +239,7 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr = addr, int mmu_idx, if (hppa_is_pa20(env)) { phys =3D hppa_abs_to_phys_pa2_w0(addr); } else { - phys =3D (uint32_t)addr; + phys =3D hppa_abs_to_phys_pa1x(addr); } break; default: @@ -558,7 +580,7 @@ static void itlbt_pa20(CPUHPPAState *env, target_ulong = r1, /* Align per the page size. */ ent->pa &=3D TARGET_PAGE_MASK << mask_shift; /* Ignore the bits beyond physical address space. */ - ent->pa =3D sextract64(ent->pa, 0, TARGET_PHYS_ADDR_SPACE_BITS); + ent->pa =3D sextract64(ent->pa, 0, HPPA_PHYS_ADDR_SPACE_BITS_PA20); =20 ent->t =3D extract64(r2, 61, 1); ent->d =3D extract64(r2, 60, 1); --=20 2.52.0