From nobody Mon Nov 23 04:18:41 2026 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=reject dis=none) header.from=itx.no ARC-Seal: i=1; a=rsa-sha256; t=1793187555; cv=none; d=zohomail.com; s=zohoarc; b=iuP0i+dsDqM9R3xpy6ejaGZEzThFoJx86PZA2Nad3CGZ6PGwJ73HXPlc7riI8Jb1MNrkK6yFl5relmNl+WR7TTsve02ziJj0/bjMfT+PaR9ovA6Lqyqc59D3Y1UcgJ4MQqxXrTyypKP2i76vrEnznkxAFuagfnqANwZXfDvx4YQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793187555; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xTZs+Lns1/b4AnhUVORelQx5nKbYh6wBYvhBhL9TKwI=; b=fBN82y+/OVaVti0pgPBF8JpZ0vgYbQ7qFhhL+RO3UsuT3wBlDWLQp47eFfbbUr+OVQXxjXIb8PtXCLTNVQCIHpcBh627gJ2440WBi614N7Sq/blhOe8/epfqLwItDPqOpp9sdUtOUDQ1Wvcx2mY0ElG8irGIi0tAumRSFcn82Dg= 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= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793187555464999.4032391762742; Wed, 28 Oct 2026 04:39:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xM1zL-0007Ol-U3; Wed, 28 Oct 2026 07:38:39 -0400 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 1xM1zJ-0007No-BM for qemu-devel@nongnu.org; Wed, 28 Oct 2026 07:38:37 -0400 Received: from itx-kvm-14.itxnorge.no ([91.189.121.228] helo=mx.itxnorge.no) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xM1zH-0004JL-50 for qemu-devel@nongnu.org; Wed, 28 Oct 2026 07:38:37 -0400 From: Stian Halseth DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=itx.no; s=mx.itx.no; t=1793187512; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xTZs+Lns1/b4AnhUVORelQx5nKbYh6wBYvhBhL9TKwI=; b=K6Zn50BRL7HXvv7JFekmSNT9h4C4dmRNoqeUtiBwZTdm52VWeUzwx2UFR8prJZ3+2iEFHP bhgIxVSsQalXvI9UjIBqNyUm7gZ9iFJN/jyyvnF3TH3yz91q94LJExONDh+Ps57/hmCV1a txBM4Cl0W0j0zxJNkDRABtm7XW1MM8I= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Artyom Tarasenko , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , Helge Deller , Pierrick Bouvier , Eric Biggers , Stian Halseth Subject: [PATCH v2 1/2] target/sparc: Model block-initializing stores Date: Wed, 28 Oct 2026 12:38:15 +0100 Message-ID: <20261028113816.1651212-2-stian@itx.no> In-Reply-To: <20261028113816.1651212-1-stian@itx.no> References: <20261028113816.1651212-1-stian@itx.no> 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=lists1p.gnu.org; Received-SPF: pass client-ip=91.189.121.228; envelope-from=stian@itx.no; helo=mx.itxnorge.no 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: pass (identity @itx.no) X-ZM-MESSAGEID: 1793187559041154100 Content-Type: text/plain; charset="utf-8" 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 --- 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 1fc8439a47..416625c6dc 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.43.0 From nobody Mon Nov 23 04:18:41 2026 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=reject dis=none) header.from=itx.no ARC-Seal: i=1; a=rsa-sha256; t=1793187562; cv=none; d=zohomail.com; s=zohoarc; b=ms4wZne0KzCTvNWtCrx43gHYHxilT/b1RPF9d+uOewGDgT8x6tgRzP/4Lwx5HyOkcGMCpHVdGHoaGHc8a4yL1EV5wyfGkbZzszFDcdgElF2r1X5quB2E4OTBGjEE8UR5Ecsl5WxMz26Oujo1KKBiAbN1Aoc5JIQMVKIR8sUckT4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793187562; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OCaTJUC4dwkFe1W+CD7W9hxaFCIou6nzQaE+yRoN21U=; b=XdwxsTfXZ892RrpFRAGYDO+2RI0ZwwH72eVPub5RE044tDYDd2YMgyFBIf/wGviwgH/aS/MRTfae9cNKOcY1EKmhbqzej+5Aie3U7cpiq2W8VmgZbDGklUrgxyx8WwYvZD5RffQDdUSdVl5BcEgHnmH/dvF9nZvrDhAvMHpeLoY= 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= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793187562467431.640122024549; Wed, 28 Oct 2026 04:39:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xM1zM-0007On-Ps; Wed, 28 Oct 2026 07:38:40 -0400 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 1xM1zK-0007O8-MH for qemu-devel@nongnu.org; Wed, 28 Oct 2026 07:38:38 -0400 Received: from itx-kvm-14.itxnorge.no ([91.189.121.228] helo=mx.itxnorge.no) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xM1zH-0004JK-8I for qemu-devel@nongnu.org; Wed, 28 Oct 2026 07:38:38 -0400 From: Stian Halseth DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=itx.no; s=mx.itx.no; t=1793187513; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OCaTJUC4dwkFe1W+CD7W9hxaFCIou6nzQaE+yRoN21U=; b=EjV8iIJ9CsMoPcBmFQCwOZ/3JJWtNwBy3vqo7SW0krrF+dkPuz+ngl6AL8ZdZG3FDEfnqD B7Y1KTvzVUQ8TWmXOdrv39yYP9c2VPzeN+Yffd7ImslLtbJ0FQy3ckRaM1CbKDZJO9NKsp m5tbPOEXMdMwuLpGmn//o2m4NoYBgOM= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Artyom Tarasenko , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , Helge Deller , Pierrick Bouvier , Eric Biggers , Stian Halseth Subject: [PATCH v2 2/2] linux-user/sparc: Report HWCAP_SPARC_CRYPTO for crypto CPU feature Date: Wed, 28 Oct 2026 12:38:16 +0100 Message-ID: <20261028113816.1651212-3-stian@itx.no> In-Reply-To: <20261028113816.1651212-1-stian@itx.no> References: <20261028113816.1651212-1-stian@itx.no> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=lists1p.gnu.org; Received-SPF: pass client-ip=91.189.121.228; envelope-from=stian@itx.no; helo=mx.itxnorge.no 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: pass (identity @itx.no) X-ZM-MESSAGEID: 1793187564891154100 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 --- 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 181f1e00b5..0412741285 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.43.0