From nobody Mon Nov 23 04:32:01 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=fail(p=none dis=none) header.from=ilande.co.uk Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793543035498629.647917634056; Sun, 1 Nov 2026 06:23:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xNWT5-0004SZ-Qs; Sun, 01 Nov 2026 09:23:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xNWSz-0004Ry-QH for qemu-devel@nongnu.org; Sun, 01 Nov 2026 09:23:26 -0500 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xNWSw-0007aS-84 for qemu-devel@nongnu.org; Sun, 01 Nov 2026 09:23:25 -0500 Received: from [2a02:8012:2f01:0:fe49:60b9:9856:b8ef] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1xNWS7-0055Ed-EN for qemu-devel@nongnu.org; Sun, 01 Nov 2026 14:22:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=PyVwOcN/hhc1g3laVb5jXTXsEpSrES2SHBXCp7jARMs=; b=xEhxojOFi/PuGcyRhTgqsRbT94 Mz4v8Sa1L144ywhCg8rSQrKq/H/QuYkGGYbwtiEbimFuK5luFZZu05Z9P1ZRVwJXV9F2VBKdzts0U TJ7RnP0uJfVUCoRw6qIwl89zITUDUsJKXGYjysW32ALfJx19mFfUkUz76aXo7M5yGp7jg02bCu5SB XSEJ+DIVV8qV7u5oZ2btseWPj/Evluptl0M+AepjGBp0hMmkQIPxbLahMZJA33Av4iy1foCUmt+53 ke1hfPA2c3+J8KHy02pWNLxTpIJ98L6iEkNcuY4567TV6l4Ee9Q1P+T5NojNvPrGHf/iE1BEZKpYB At3ZLo0BXBLxGMgRj/uRHsvJzeajtCkKpLvnlv0XLxLENe0tfc8K9zwHzNVbUm15HCdOwIaGBnnKO UIJfESDLDThe4vMjK4+haHZttTRd5+IpbvJ5mRnVgB1byXg+eKHWFxAwywi6I+QbukbGsJMin8Bo3 7CofJ4ltPpxIMFtTnA8e5H0H77kiXul+Tlpq1CxNvvwu5KwXwMEaD+CaB7/j11pc1gRFGj55M3mtd /SedqvP+uYuXSGPq++OztygiNGO6Wq2WWA/h+yjySZcBJNPHUU22GYpSOSr0pi6O4vm5YZE6wFlCa uuwSBjtfwQ5auq//JIHaP+SqsgkUeB7Cs4HQ60BKQ=; From: Mark Cave-Ayland To: qemu-devel@nongnu.org Date: Sun, 1 Nov 2026 14:22:51 +0000 Message-ID: <20261101142312.983515-2-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261101142312.983515-1-mark.cave-ayland@ilande.co.uk> References: <20261101142312.983515-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a02:8012:2f01:0:fe49:60b9:9856:b8ef X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 1/3] target/sparc: Model block-initializing stores X-SA-Exim-Version: 4.2.1 (built Sat, 13 Feb 2021 17:57:42 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) 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=lists1p.gnu.org; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, 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 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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: 1793543038171158500 Content-Type: text/plain; charset="utf-8" From: Stian Halseth On T4 and later, a block-initializing store to the first doubleword of a 32-byte block zeroes the rest of the block (measured on a T4). glibc's niagara4 memset and Linux's NG4memset rely on this, and OpenSSL's T4 AES code uses the FP form, stdfa. QEMU only accepted the integer form, on HYPV CPUs, as a plain store, so with the crypto hwcap a multiarch glibc memset leaves stale data. Accept both forms when the CPU has the crypto feature, which implies T4 or later, and zero the 32-byte block as T4 does. Signed-off-by: Stian Halseth Reviewed-by: Mark Cave-Ayland Reviewed-by: Richard Henderson Message-ID: <20261028113816.1651212-2-stian@itx.no> Signed-off-by: Mark Cave-Ayland --- target/sparc/translate.c | 43 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 1fc8439a475..416625c6dc9 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -1853,6 +1853,27 @@ static void gen_ld_asi(DisasContext *dc, DisasASI *d= a, TCGv dst, TCGv addr) } } =20 +/* + * On T4 and later, a block-initializing store to the first doubleword of + * a 32-byte block zeroes the rest of the block. glibc and Linux memset + * rely on this and store only one doubleword per block when zeroing. + */ +static void gen_blkinit_zero(DisasContext *dc, DisasASI *da, TCGv addr, + MemOp size) +{ + TCGLabel *skip =3D gen_new_label(); + TCGv t =3D tcg_temp_new(); + TCGv_i64 zero =3D tcg_constant_i64(0); + + tcg_gen_brcondi_tl(TCG_COND_TSTNE, addr, 31, skip); + /* A narrower store also zeroes the rest of the first doubleword. */ + for (int i =3D size =3D=3D MO_64 ? 8 : 0; i < 32; i +=3D 8) { + tcg_gen_addi_tl(t, addr, i); + tcg_gen_qemu_st_i64(zero, t, da->mem_idx, MO_UQ); + } + gen_set_label(skip); +} + static void gen_st_asi(DisasContext *dc, DisasASI *da, TCGv src, TCGv addr) { switch (da->type) { @@ -1863,12 +1884,19 @@ static void gen_st_asi(DisasContext *dc, DisasASI *= da, TCGv src, TCGv addr) if (TARGET_LONG_BITS =3D=3D 32) { gen_exception(dc, TT_ILL_INSN); break; - } else if (!(dc->def->features & CPU_FEATURE_HYPV)) { - /* Pre OpenSPARC CPUs don't have these */ + } else if (!(dc->def->features & + (CPU_FEATURE_HYPV | CPU_FEATURE_CRYPTO))) { + /* + * Pre-OpenSPARC CPUs lack block-init stores. Crypto + * instructions imply T4 or later, which has them. + */ gen_exception(dc, TT_ILL_INSN); break; } /* In OpenSPARC T1+ CPUs TWINX ASIs in store are ST_BLKINIT_ ASIs = */ + if (dc->def->features & CPU_FEATURE_CRYPTO) { + gen_blkinit_zero(dc, da, addr, da->memop & MO_SIZE); + } /* fall through */ =20 case GET_ASI_DIRECT: @@ -2169,6 +2197,17 @@ static void gen_stf_asi(DisasContext *dc, DisasASI *= da, MemOp orig_size, } break; =20 + case GET_ASI_DTWINX: + /* stdfa with a block-initializing ASI, T4 and later */ + if (orig_size =3D=3D MO_64 && (dc->def->features & CPU_FEATURE_CRY= PTO)) { + gen_blkinit_zero(dc, da, addr, MO_64); + d64 =3D gen_load_fpr_D(dc, rd); + tcg_gen_qemu_st_i64(d64, addr, da->mem_idx, memop | MO_ALIGN); + } else { + gen_exception(dc, TT_ILL_INSN); + } + break; + case GET_ASI_BLOCK: /* Valid for stdfa on aligned registers only. */ if (orig_size =3D=3D MO_64 && (rd & 7) =3D=3D 0) { --=20 2.47.3 From nobody Mon Nov 23 04:32:01 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=fail(p=none dis=none) header.from=ilande.co.uk Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793543035890331.55949507170385; Sun, 1 Nov 2026 06:23:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xNWT9-0004TI-SV; Sun, 01 Nov 2026 09:23:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xNWSz-0004Rz-QM for qemu-devel@nongnu.org; Sun, 01 Nov 2026 09:23:26 -0500 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xNWSw-0007aU-AG for qemu-devel@nongnu.org; Sun, 01 Nov 2026 09:23:25 -0500 Received: from [2a02:8012:2f01:0:fe49:60b9:9856:b8ef] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1xNWS7-0055Ed-RZ for qemu-devel@nongnu.org; Sun, 01 Nov 2026 14:22:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender:Reply-To: Cc:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=IcGSRwcoccQDdisKc79r7UVkewokgafoSbc99lF6Xq8=; b=mj/kChj2Sp5/udbQwmdwnzqCeH kSahhZnFEPyRZZNVaiZLkCo9rSPadTATZisHXlpCI3mCfyZsrWRXIp8TPKZgeV9pDj9dbB79bmvzU PxJ+25EIKfemBvxrkZxA0E5PBn2xcJ8vgESu08y4ZYLDJyU8/X2coyrBaXkiKXPifIPlC5tWZ3nwj OPOO98Q1cpuSlGH80zROlhXJhtBKI//1m5ahTbg8HWMBbqiDE5emN1fk2aJa6uKOEzhICHGhGj01V SuMrXrO+eNZSbdyOauZ9awxRfhtHdsykRuSc1uTGhzKRziJrkxTZgT3vw5ZtADG8sQlBeXANJ8YHE K8aGMDjP/iyQBwq4XwksYYsmKZaO+8PmHtuqlwxSrVwlyoyV7bV+nNhqnAGi4PQLv4OYYxpoZ1uNI K5h+QZaEu3OqNStkvkj5cyeXf/GjIRfT9xr0psGHYcN5/E7h2/hmKxT2PZCZi+x+qNw7uZxHWvR5g guX/Bu6MFJqXdRywB4flehUSf5K0UYng6nbfRAqMXX9X8+2B5ha6xwHqWLQekqRPDbIBPYjyo7FWd cFIq8T5sHrt0hNMd1FnrW7ZQdDNqnVSKyY2A7oB32kRpaz4yidt8oJnfa1uoK1+aMUdDwyFJLQFSo CaX3QYQH8vC33Ribm9uKtKa600ZBneRS4z+v69+Ac=; From: Mark Cave-Ayland To: qemu-devel@nongnu.org Date: Sun, 1 Nov 2026 14:22:52 +0000 Message-ID: <20261101142312.983515-3-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261101142312.983515-1-mark.cave-ayland@ilande.co.uk> References: <20261101142312.983515-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a02:8012:2f01:0:fe49:60b9:9856:b8ef X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 2/3] linux-user/sparc: Report HWCAP_SPARC_CRYPTO for crypto CPU feature X-SA-Exim-Version: 4.2.1 (built Sat, 13 Feb 2021 17:57:42 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) 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=lists1p.gnu.org; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, 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 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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: 1793543037951158500 From: Stian Halseth Set HWCAP_SPARC_CRYPTO in AT_HWCAP like Linux does on real hardware that supports it. qemu-sparc64 defaults to "TI UltraSparc II", which has no crypto feature, so it must be enabled explicitly, e.g. -cpu TI-UltraSparc-II,+crypto Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Mark Cave-Ayland Signed-off-by: Stian Halseth Message-ID: <20261028113816.1651212-3-stian@itx.no> Signed-off-by: Mark Cave-Ayland --- linux-user/sparc/elfload.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/sparc/elfload.c b/linux-user/sparc/elfload.c index 181f1e00b59..04127412857 100644 --- a/linux-user/sparc/elfload.c +++ b/linux-user/sparc/elfload.c @@ -90,6 +90,7 @@ abi_ulong get_elf_hwcap(CPUState *cs) r |=3D features & CPU_FEATURE_FMAF ? HWCAP_SPARC_FMAF : 0; r |=3D features & CPU_FEATURE_VIS3 ? HWCAP_SPARC_VIS3 : 0; r |=3D features & CPU_FEATURE_IMA ? HWCAP_SPARC_IMA : 0; + r |=3D features & CPU_FEATURE_CRYPTO ? HWCAP_SPARC_CRYPTO : 0; #endif =20 return r; --=20 2.47.3 From nobody Mon Nov 23 04:32:01 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=fail(p=none dis=none) header.from=ilande.co.uk Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179354306491493.01452468957586; Sun, 1 Nov 2026 06:24:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xNWTL-0004U8-4N; Sun, 01 Nov 2026 09:23:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xNWT0-0004SF-Qj for qemu-devel@nongnu.org; Sun, 01 Nov 2026 09:23:27 -0500 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xNWSy-0007aX-3M for qemu-devel@nongnu.org; Sun, 01 Nov 2026 09:23:26 -0500 Received: from [2a02:8012:2f01:0:fe49:60b9:9856:b8ef] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1xNWS8-0055Ed-4Q for qemu-devel@nongnu.org; Sun, 01 Nov 2026 14:22:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=8zNnqYIDSCvwYak7neqsQryPbDLAbo8KJnEBAhHIPQs=; b=TwePJzXnIJBoTljlMQ6aFk74Wt nOqgbcWHzdsqI+5VwuHaGckp8JegxZ0In4kFKBrPz61btUZOcraaXPMyN2s9uR5E/nQrALVA5r118 6YF0BZvnx1RfqIw91mKZLqPOZXdJxCx+qLBUPXnz1QM3N7OjQRY+XxWYdPvk7OPTd/flFp1IvRM3f oDeLxn2zzxsySadFjqKW46obLoyqm+YgCeenyWIfqvtwaHS4mNGmVJqOQENIdA814WjupH6G4ewyI Dro8h/z/2581q0PeUzOcqy7Z3i+hk/TzXcaTJ7kvwbTo+DyiKa30KZCeUhw1w8ycxQDJAHCkt6V2C ZGDOGorhqOyD4HNMLIsGgXZ4mQbfknuuPcLq8aU+Ab3iu6Aykx9PYJ+sVaa5B4YGr/92zR9vK4BPH G45Pwz2NWqUWxndVatiJxC7kLlBsVqxhYuTJQxXJUsEH1H1S0DhbNs/Nc1e65NNaDh/MMOigsBgyF an7GYfz/ioIwypiox1x9RgXvFvtSMjKgxzGQZAWb4x68c5rcvi3gnrNa3JAdewDnrI0wKK6lMByGr lcDD81yEjRmBNriYfICUINFgUWior/MRqopEWgC8gE+kXcGCbVg/NkwzaafkiTvylYwVcl/rvsc/J NkHJ3QZGz9aJLj0+wE1RSwc0AsYpcQBEAtsSuv/tc=; From: Mark Cave-Ayland To: qemu-devel@nongnu.org Date: Sun, 1 Nov 2026 14:22:53 +0000 Message-ID: <20261101142312.983515-4-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261101142312.983515-1-mark.cave-ayland@ilande.co.uk> References: <20261101142312.983515-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a02:8012:2f01:0:fe49:60b9:9856:b8ef X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 3/3] hw/sparc64: Pass hwcap-list to OpenBIOS via fw_cfg X-SA-Exim-Version: 4.2.1 (built Sat, 13 Feb 2021 17:57:42 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) 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=lists1p.gnu.org; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, 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 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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: 1793543066177158502 Content-Type: text/plain; charset="utf-8" From: Stian Halseth Linux needs hwcap-list to enable crypto instructions, but only sun4v firmware provides it. When the CPU has crypto, pass the list through fw_cfg for OpenBIOS to copy onto the cpu node as qemu,hwcap-list. Include the capabilities linux-user reports, since Linux trusts the list instead of guessing. Without crypto, nothing changes. Signed-off-by: Stian Halseth Reviewed-by: Mark Cave-Ayland Message-ID: <20261031094841.3407049-1-stian@itx.no> Signed-off-by: Mark Cave-Ayland --- hw/sparc64/sun4u.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index a348096aee6..1057c591526 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -121,6 +121,52 @@ static void fw_cfg_boot_set(void *opaque, const char *= boot_device, fw_cfg_modify_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); } =20 +/* + * OpenBIOS copies this list to the cpu node's qemu,hwcap-list property + * for Linux, which gets it from the machine description on sun4v. + */ +static void fw_cfg_build_hwcap_list(FWCfgState *fw_cfg, SPARCCPU *cpu) +{ + static const struct { + uint32_t mask; + const char *name; + } capabilities[] =3D { + { 0, "popc" }, + { CPU_FEATURE_FSMULD, "fsmuld" }, + { CPU_FEATURE_VIS1, "vis" }, + { CPU_FEATURE_VIS2, "vis2" }, + { CPU_FEATURE_FMAF, "fmaf" }, + { CPU_FEATURE_VIS3, "vis3" }, + { CPU_FEATURE_IMA, "ima" }, + /* The groups in the CFR value, see CFR_* in target/sparc/translat= e.c */ + { CPU_FEATURE_CRYPTO, "aes" }, + { CPU_FEATURE_CRYPTO, "sha1" }, + { CPU_FEATURE_CRYPTO, "sha256" }, + { CPU_FEATURE_CRYPTO, "sha512" }, + { CPU_FEATURE_CRYPTO, "crc32c" }, + }; + uint32_t features =3D cpu->env.def.features; + GByteArray *array; + size_t len; + + if (!(features & CPU_FEATURE_CRYPTO)) { + return; + } + + array =3D g_byte_array_new(); + for (size_t i =3D 0; i < ARRAY_SIZE(capabilities); i++) { + if ((features & capabilities[i].mask) =3D=3D capabilities[i].mask)= { + const char *name =3D capabilities[i].name; + + g_byte_array_append(array, (const guint8 *)name, strlen(name) = + 1); + } + } + + len =3D array->len; + fw_cfg_add_file(fw_cfg, "etc/sparc64/hwcap-list", + g_byte_array_free(array, FALSE), len); +} + static int sun4u_NVRAM_set_params(Nvram *nvram, uint16_t NVRAM_size, const char *arch, ram_addr_t RAM_size, const char *boot_devices, @@ -717,6 +763,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem, fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_WIDTH, graphic_width); fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_HEIGHT, graphic_height); fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_DEPTH, graphic_depth); + fw_cfg_build_hwcap_list(fw_cfg, cpu); =20 qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); =20 --=20 2.47.3