From nobody Mon Nov 23 04:34:31 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=1792755829; cv=none; d=zohomail.com; s=zohoarc; b=X2l8308g99R6zURDdo02GFqN+CiG23Fjpue2UtQBmGcwO/k5kp6LN28ol8AQZ/EpdbeRMaYVzsPPQCKfVHWoLru7vQiQYGzgWK11sVjNMUPg8LS/h8SGrMOTrqEeafSAzA/G587CGGHO6K4y1wIYU5blgY39R/gedanMXTSW3iw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792755829; 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=G72Ty5s5MZE1t0UB1o8UW1dNTu+Fa9Rzkj1yQvMWqjg=; b=SJFjTBlWEKawhgpRVoGy2yVCA+6WghB8fL7/8XnosYrIymg/SFoQJN8TECnGI3agWgF8uyfRKc4zog+RP4XEoCBBBe+0VcyvgIEu2tNIj6wuFH5k2qKgAVDSx3lFuzUOQ3ok234o8e8LLrbNBUbSt1eU+KGW8KGkrNnsqOemANE= 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 17927558295851.1581974393807286; Fri, 23 Oct 2026 04:43:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xKDgK-0003hs-6Z; Fri, 23 Oct 2026 07:43:32 -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 1xKDgB-0003h4-2K for qemu-devel@nongnu.org; Fri, 23 Oct 2026 07:43:24 -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 1xKDg7-0006oL-F3 for qemu-devel@nongnu.org; Fri, 23 Oct 2026 07:43:22 -0400 From: Stian Halseth DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=itx.no; s=mx.itx.no; t=1792755797; 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=G72Ty5s5MZE1t0UB1o8UW1dNTu+Fa9Rzkj1yQvMWqjg=; b=NtCwDwBZQ3rN9Eq4S5U4Zx4Hug5ivNMtumLvyGjpZUvCErFzAwKdeckN9MVG9/zb8RCfao tqyJ7rPIxNIWYkuFCkBR1S1EwQpbhtOS+MzVZozTnXn74b9UCj9Bp58ggFnoNmMO+aQmnm y5zs+UwK4IQz8otOE5mFqU7SVfcvfag= 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 1/2] target/sparc: Model block-initializing stores Date: Fri, 23 Oct 2026 13:43:01 +0200 Message-ID: <20261023114303.576319-2-stian@itx.no> In-Reply-To: <20261023114303.576319-1-stian@itx.no> References: <20261023114303.576319-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: 1792755830966158500 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 --- target/sparc/translate.c | 42 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 1fc8439a47..009340a3bb 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -1853,6 +1853,26 @@ 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) +{ + TCGLabel *skip =3D gen_new_label(); + TCGv t =3D tcg_temp_new(); + TCGv_i64 zero =3D tcg_constant_i64(0); + + tcg_gen_andi_tl(t, addr, 31); + tcg_gen_brcondi_tl(TCG_COND_NE, t, 0, skip); + for (int i =3D 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 +1883,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); + } /* fall through */ =20 case GET_ASI_DIRECT: @@ -2169,6 +2196,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); + 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:34:31 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=1792755826; cv=none; d=zohomail.com; s=zohoarc; b=Aacc82FYnYnxh2pdmpPQ5ELF+a5lsen5+moiAAo+CnQJGxphcRMPAR3aX+rJ7u2heU+Di5VuNAAA8vlI41NZWuHuEcIBt4VN+gXppW8TTP9ThWqhYzA010pO41p5FJpFQoLSyxieztY6hpBW+T25+35/wSRwwV4DmKkakTdbMq0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792755826; 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=U0OHZWSo2eSCQ1EXfOA4V7jfGjqQwSbWKZ6oyoBHj+2+YVgn8CKHgZdOtSXm/cJqgm8LDaINMt33hTZuuKq1b0KsRCQNIsrKAy5P5NYyVeysNB3w4QdMPmjLLVYqY8Pc8ozLI3IxiS5xgc5d0Wmsa6AHG5b1IDZsEjlZemSo0xU= 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 1792755826559451.05564945386186; Fri, 23 Oct 2026 04:43:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xKDgJ-0003ho-4W; Fri, 23 Oct 2026 07:43:31 -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 1xKDg9-0003gX-OS for qemu-devel@nongnu.org; Fri, 23 Oct 2026 07:43:21 -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 1xKDg7-0006oM-Et for qemu-devel@nongnu.org; Fri, 23 Oct 2026 07:43:21 -0400 From: Stian Halseth DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=itx.no; s=mx.itx.no; t=1792755797; 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=QsuaL1N0A8BgrJmKrLJd2/lfzyo+5/Qb8/gpKb4qiH64UOcre3J8jX5t0fKJ+S6IqK3uI0 HKFEsmvsvjNmMTVWyom3VIJ8LIIm4btY81nP/OVG5RCuhfTdF0as6sMfhs+/bGsx7jyrQn eoaBtzqS3jQZ1fjbhVMibORtTGeafBM= 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 2/2] linux-user/sparc: Report HWCAP_SPARC_CRYPTO for crypto CPU feature Date: Fri, 23 Oct 2026 13:43:02 +0200 Message-ID: <20261023114303.576319-3-stian@itx.no> In-Reply-To: <20261023114303.576319-1-stian@itx.no> References: <20261023114303.576319-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: 1792755828989158500 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