From nobody Mon Nov 23 04:18:37 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=1793440195; cv=none; d=zohomail.com; s=zohoarc; b=Dvtiam7r0lWVus6L7/0Z9/Vkx55SEzYGPRzRq7FpmoLeS0CbOIv5qPyJEI1W2wytUQTU0pQuG/jMrlGGURUhiRkICNAvC2DYU5q97DrzzCbXhHagYnqx7D9YrQmp8Tu+I4HVKG+Lp/xb3QCzZJ00326LRbijsuMrdTJA12hT2ko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793440195; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From: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=er2xiGtxOe2P3MW6n23aYjlwEeEu8uKKelweYlZSXYA=; b=KajWfThnbbnumHCmWWyIEec9KGTDZctif4ssYL+lDHJDew4u4mI/YMn8k5k/7gH73xCscWjc1Gnd0i31eVjrZsWiA7O+M01akzWxZjoLmvCH8XUXAsbXV+P9c1D8tmnK4qZyYW0+Puin2xORzhwLqlYEfmzWob5o6R1kFCo91PM= 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 1793440195931343.49247405763697; Sat, 31 Oct 2026 02:49:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xN5i5-0001y1-CO; Sat, 31 Oct 2026 05:49:13 -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 1xN5hu-0001xi-K8 for qemu-devel@nongnu.org; Sat, 31 Oct 2026 05:49:03 -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 1xN5hr-0007ss-Lt for qemu-devel@nongnu.org; Sat, 31 Oct 2026 05:49:02 -0400 From: Stian Halseth DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=itx.no; s=mx.itx.no; t=1793440136; 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; bh=er2xiGtxOe2P3MW6n23aYjlwEeEu8uKKelweYlZSXYA=; b=EVXkJJQhIx1LE4oFLCt0ssLqJ7+Zx5Yg49zMZAizY2ean5cNnAqJwkuvxBqnkVex9stjnf zaubfxdd/g0JwN3hMhgL9bsAJEV7phfpSzgWSfeLQE7vTouzC3CeYBBF/yUdkGbjGQkDcX VgWYyAGlIsfLe6mzQppuSfSn0NfoDzY= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Artyom Tarasenko , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stian Halseth Subject: [PATCH v2] hw/sparc64: Pass hwcap-list to OpenBIOS via fw_cfg Date: Sat, 31 Oct 2026 10:48:41 +0100 Message-ID: <20261031094841.3407049-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: 1793440198021158500 Content-Type: text/plain; charset="utf-8" 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 --- v2: - The property is now "qemu,hwcap-list", to mark it as emulator-only (Mark). The fw_cfg file name is unchanged. - Comment that the crypto entries are the groups in the CFR value (Mark) v1: https://lore.kernel.org/qemu-devel/20261028190729.1941434-1-stian@itx.n= o/ Based-on: <20261028113816.1651212-1-stian@itx.no> This exposes the crypto hwcap to guests, so it should land after the block-init series, which glibc's memset needs. The OpenBIOS side, v2 with the same rename, is on the OpenBIOS list as "SPARC64: set qemu,hwcap-list on the cpu node from fw_cfg". The kernel change to read the property on sun4u goes to sparclinux. hw/sparc64/sun4u.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index a348096aee..1057c59152 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.43.0