From nobody Sat Jul 25 22:32:28 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1783906608; cv=none; d=zohomail.com; s=zohoarc; b=gxtOCUXusOTBNmB3goHm40hoT68Uhlclcp1R3QnOOwt6uyoZ+IgAFhp9TfHoezuzohG2k4Ln6J+JFWdrsI+kJKoJ6LoMA/tCb603sP+FKz9BRjvZm6jU0y17vb07DfeEnqL+4ycTT9+wgQRbwZnyVc3c/MaWT2xlMNQEvUD7Q0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783906608; h=Content-Type: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=7rWQIUX8PpQ5NxVKonL7S1py2DeqtMM2zWHNywk2IBY=; b=ayEEQlko/dm4kmfTIkuDm3akzgEW7F9nCfmPzKrMx+hnQIoNb8Jdj4x9DVdKBQ8IUE7uxuTt5JD756qT+jZJwjCglM7Dd7HsaqvTujK36O63bJd50UIwD555EtBhJHBvuAhIsZ6uQm2e0M6CRPxM97ebtfQvK5znANrfK8DqgCs= 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=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1783906608533878.389120852966; Sun, 12 Jul 2026 18:36:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wj5au-0003bl-5t; Sun, 12 Jul 2026 21:36:28 -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 1wj5aq-0003bK-Ei for qemu-devel@nongnu.org; Sun, 12 Jul 2026 21:36:25 -0400 Received: from mail-yx1-xb129.google.com ([2607:f8b0:4864:20::b129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wj5ap-0001wJ-1A for qemu-devel@nongnu.org; Sun, 12 Jul 2026 21:36:24 -0400 Received: by mail-yx1-xb129.google.com with SMTP id 956f58d0204a3-6647bc8f900so4460090d50.0 for ; Sun, 12 Jul 2026 18:36:22 -0700 (PDT) Received: from localhost ([2600:1702:7a90:6f9f:8bc4:8aec:108d:7a04]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-667c2efa583sm8245709d50.15.2026.07.12.18.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2026 18:36:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783906581; x=1784511381; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=7rWQIUX8PpQ5NxVKonL7S1py2DeqtMM2zWHNywk2IBY=; b=fnonOWl914BqWjT8oVaUkmXXTlhXVGqUzq/UZWbpUEbqgII17Q+HvPzZpla3riyS/5 mjPIkdNB4oQjE5mIzSgzV4oYRWNJ14PDuHE+gVQ8ICn3yx/jKxkwNkg2Uzm4zHqKuYs/ pJ6/253RYNfyPg+hs0ChcZNqhWTpNJKM46ficPADK5MxTqdiEvHPq9ulyL2S5esZQEfo hN/eMRuhXj0Xv51nMYbASeYNPja1LRf1bvpQbYs1GfNUbeFu/WDIW5hY2FuTULNaKFE/ sfmLrJK+6OpT7gAC0xmCKS0RERmOaI0tKmvQSapOlnBDYmeldfivPv56yjeHKpAn57+J b+lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783906581; x=1784511381; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=7rWQIUX8PpQ5NxVKonL7S1py2DeqtMM2zWHNywk2IBY=; b=go0S5H330M4iEX6H0TfEyzaI+3TUdhBS/twFTEGzAtDc0XeaaV/XkDiPtZ8rs5aAVT BhWSucIWI6qKmw2U9jStW5jt7fijtfo/ZhpciL0QIHq09wuakpthgr5WfEo4liFUB/BP JE2ee9K7cyYnxXyzSSlghpeKH+jB7cj+9awk6HsdsXRovpj/T014xzuOFqB87B6Cin9x fDDe85nUngU5Pw/vgzrsYDX3uAwwJsMSpwH6uLZVXo9eao3oAieo8nBmySrkE9j2Ez/Y fZllSjqDEOphod2fgodv1fDQ0f3FiBs4+FHSpMSBZTNnxJv8aXTmsFmhWKWfzc6D2pwd SHaA== X-Gm-Message-State: AOJu0YwMvG0Nt50gXV2ni6UsQy+Vi1oTZWZdZ/xmd/plW29n6X1NZN1q 1Y3Em2bIVLT7XsocUyUCC80g5h1ubUqSzPpC1oUHARd46VVMP0vwogyc1NJQIw== X-Gm-Gg: AfdE7cmsVWFkloeLBmhR1OHv4dLKal8XYOQnkuRYwwBCEh3qseT6Iz5OUd5Mwp5UnVD TCsZxbK/8fdET+GjKPOQmLSM4KQEm9p3tesQHHUeEuuDoQaVDoFYUJPf4vQpj0ybJfUjcEi4L5Y 455UqEbvH+1WuuTfzpD3Yff6Vp3pS/i8DX8I928uoD2/r57mNCkC69/NkWisO2XCTjGJsZSQjvI LyqqZapMzFOERAI27f8aiU4+E21aE9svF7hh1jhHBjeY9pl6sYOUOZpJhIWIh3RmQHERFxp2fwN yTvgYAPnfyp+tEOcYMc7YSuRTOTreTPLaz1ZRM1dczqt4eM8RzCVBYM4npRjmMvLrr/8x3faSH9 d7vBQOHCQTYr/eABkLf87i2h3IJf1toW5Z3S2r7imX9Jn3PXhIgD7iHHFzjdlKRVyOZCCMobdbA mqkI7F9jaTQH8RAHXAoK4Hxf0= X-Received: by 2002:a05:690e:4009:b0:667:db66:eb47 with SMTP id 956f58d0204a3-667db66f36emr4425148d50.10.1783906581404; Sun, 12 Jul 2026 18:36:21 -0700 (PDT) From: Matt Turner To: qemu-devel@nongnu.org Cc: Richard Henderson , Laurent Vivier , Helge Deller , Pierrick Bouvier , Matt Turner Subject: [PATCH] linux-user/alpha: populate AT_HWCAP from env->amask Date: Sun, 12 Jul 2026 21:36:07 -0400 Message-ID: <20260713013610.2691128-1-mattst88@gmail.com> X-Mailer: git-send-email 2.54.0 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=2607:f8b0:4864:20::b129; envelope-from=mattst88@gmail.com; helo=mail-yx1-xb129.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 @gmail.com) X-ZM-MESSAGEID: 1783906610738158500 Alpha has never set AT_HWCAP in linux-user emulation, so getauxval(AT_HWCAP) always returned 0 regardless of the emulated CPU model. The Linux kernel computes ELF_HWCAP as ~amask(-1), i.e. the set of ISA extension bits that the amask instruction reports as supported (cleared in its output). env->amask stores exactly those bits with the same layout (BWX=3D0x1, FIX=3D0x2, CIX=3D0x4, MVI=3D0x100, TRAP=3D0x200, PREFETCH=3D0x1= 000), so returning it directly from get_elf_hwcap matches the kernel convention. Add HAVE_ELF_HWCAP to target_elf.h and implement get_elf_hwcap() in elfload.c to expose the emulated CPU's capability mask to user-space programs via the auxiliary vector. Without this fix, programs using getauxval(AT_HWCAP) to detect BWX/FIX/CIX (such as glibc's memcpy or JIT compilers targeting Alpha) incorrectly concluded that no extensions were available even when emulating ev56+. Reviewed-by: Helge Deller --- linux-user/alpha/elfload.c | 11 +++++++++++ linux-user/alpha/target_elf.h | 1 + 2 files changed, 12 insertions(+) diff --git ./linux-user/alpha/elfload.c ./linux-user/alpha/elfload.c index 1969f620a5..7be9e466b6 100644 --- ./linux-user/alpha/elfload.c +++ ./linux-user/alpha/elfload.c @@ -6,6 +6,17 @@ #include "target_elf.h" =20 =20 +abi_ulong get_elf_hwcap(CPUState *cs) +{ + /* + * The Linux kernel computes ELF_HWCAP as ~amask(-1), which clears a b= it + * for each supported ISA extension. env->amask stores exactly those = bits + * set for the extensions supported by the emulated CPU model, matching + * the kernel's convention: bit set in AT_HWCAP =E2=86=94 extension pr= esent. + */ + return cpu_env(cs)->amask; +} + void elf_core_copy_regs(target_elf_gregset_t *r, const CPUAlphaState *env) { int i; diff --git ./linux-user/alpha/target_elf.h ./linux-user/alpha/target_elf.h index 4987ae3944..dd90c6f783 100644 --- ./linux-user/alpha/target_elf.h +++ ./linux-user/alpha/target_elf.h @@ -12,6 +12,7 @@ #define ELF_MACHINE EM_ALPHA =20 #define HAVE_ELF_CORE_DUMP 1 +#define HAVE_ELF_HWCAP 1 =20 /* * Matches the kernel's elf_gregset_t (ELF_NGREG =3D 33): --=20 2.54.0