From patchwork Tue Jul 30 01:12:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 815269 Delivered-To: patch@linaro.org Received: by 2002:a5d:4acf:0:b0:367:895a:4699 with SMTP id y15csp111785wrs; Mon, 29 Jul 2024 19:26:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWyjhznqsiO1Fx2nYuLiP8NgvA6elicxmW78XLzCdOyc0A75T+OR7gPBEuRcU0Czn9Kj22DD72RE9tTgLe3S1hB X-Google-Smtp-Source: AGHT+IHJrYOc8gJWNtmmPDUrTkOVk8OntpERpb4x00KC2va0OE/Qvak1PsjBskOfV6cqjKoxq6Ju X-Received: by 2002:a05:6122:3c53:b0:4ec:f6f2:f1cd with SMTP id 71dfb90a1353d-4f6e697214cmr6626419e0c.9.1722306360129; Mon, 29 Jul 2024 19:26:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722306360; cv=none; d=google.com; s=arc-20160816; b=S3dV+rcJAJrPh3PnYfDEUc1eBQp79L3Carb+IGJrfSvczr1uTUaDE4s4e02bbvDcRk p3Ed+avvcpp92X/SanfK4klScHeyhwgI810yIZZd2TdpVTWWbgoI/8/+y+2q3p5n+sgi q94lKlP9SA+bclKcR6L4kAS8ACR1AljGAoCHfFa1MS6Nqa9NY1nBh7/vsBoj4MOwuOBm MMOTtssBhKD+dZHL3LsJAGwnPLAsimjpKewJlsQrSTPSL2rV4zHB16GOpEHqVkqC8r4a s7KwKMnfA5gLfRg5h6g7xOyhMZ4VN7t8SJ1umD92J/MAQd/sXyqzx6nobgYn/KiHnZZk cLIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=a2wtDHUY+HHrfRWzkSo3Bk34wWAfi1Yqji+v1/RaSkc=; fh=MoQL7SW1hNgADG9l4BUkyxqt3uxuhggF6Ub9Dq9ba3k=; b=txDqvoDmBn0vCpoxwfT/GGcbSqOQ1dMODqF/ny+n8hTKJrYqulcfrnSF3KDx3GI1VG 3WnMm+w9epme+8M+ICwvaWJrj0EDuEknsRWO2bF71TIO1SHI7oHrYs0LvkV936+HayLR ywSI7bKTzDrofwlAik3LpQbbchRRpvFC+LWItVjXNIRg4BtSpOjY+uhJ5Ilrg3kLTntk GWW3sz2rsOUM3jsNIr8ANaoCuiy1sUf39TWpmq7F+wmPnUwGKxpxRuNTS445Q5iyOUU3 bDuUFOLjtmuPHLBFjvU/G1S+hWTH51pdYdJbJhwVAL6lUKR3xr7XVgwigSu9jd6GE2Cj P3qg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JyG5lpzK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44fe842581bsi114653571cf.629.2024.07.29.19.25.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 29 Jul 2024 19:26:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JyG5lpzK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sYcYW-0007S1-4U; Mon, 29 Jul 2024 22:25:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sYcYT-0007OP-3h for qemu-devel@nongnu.org; Mon, 29 Jul 2024 22:25:38 -0400 Received: from mail-oo1-xc2f.google.com ([2607:f8b0:4864:20::c2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sYcYR-0007U6-BY for qemu-devel@nongnu.org; Mon, 29 Jul 2024 22:25:36 -0400 Received: by mail-oo1-xc2f.google.com with SMTP id 006d021491bc7-5d5e1c86b83so1443039eaf.3 for ; Mon, 29 Jul 2024 19:25:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722306334; x=1722911134; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a2wtDHUY+HHrfRWzkSo3Bk34wWAfi1Yqji+v1/RaSkc=; b=JyG5lpzK8Fx3c8ZzS38saCfzuw4XepZ5xv32R8KrA8wcykE90EkTtv3Tt0XiAgEJHq s2vo+1IB8U1v6j1X1DpjkQgmy6EJwfI321ekTpPqP5/n5PaM5aNlJvvAcwnhQoJsWWD5 TRGLIqYY6WmJ8VQHp0sQ5PHmTYABAophEq1RvzNLnGxSIDSTpWCiUxmMpSneAi+22WkV vYvzGLD6+ac42wddIAbsLaPs4cg/lmQV0bj53ycBdU8EJa7SZd2f9hNaZNFPOUZd5Ra6 E4U6U8I1bV0YtePox/2KCNhvbWNLG+WTBXRNU3Vnq9xBP8LWWWdrkKjtfsJxL45TPpLU VUjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722306334; x=1722911134; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a2wtDHUY+HHrfRWzkSo3Bk34wWAfi1Yqji+v1/RaSkc=; b=nQyeemPqQdb+aGO7aVFaz6u+2iJ6krvNwV7VcHcG4zx/jtpIia7tiPKVo1ka30pXgD m1f2Q9AQKAstINYgT5rZuowBCeAyUJ110UE2eB76xp9Isww7Ylllo+3cxq2tn58tVFTR 5WYxJ26oeOB9LMvFmhv7sSq6IoaKrpSfrDffeF2FMozsVE4+lvTmWxbYpxbtCI6JoC8k o2Li6uTwn29XTArnn59GnPjFJes/yrrmt9EOhKRTnjHqQkl/zO3+nMYcsSsolh96pxm7 Is6H4ToNa0BlII/PsNER3gnk56CmQ6KPDvVgLU5iDtzAyAjQ0UPM4cHAOx4LXC+QxpSN 5b5g== X-Gm-Message-State: AOJu0Yw5X5DZcGvrV/0Hr/t2T+8jAPOKonFQJTTZDMAI9q7LXnE7IEa3 jfDWNYc97w0rWEY+ceqa71pu3fErKU1fswfjIz7AoETcteKPnhXFK0bJfvjJ5iIMeXd3hX6JhcB drdg= X-Received: by 2002:a05:6870:b28e:b0:261:f4c:e08c with SMTP id 586e51a60fabf-267d4dd3eb0mr11718340fac.29.1722301939544; Mon, 29 Jul 2024 18:12:19 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7a9f7c6ff4bsm6750206a12.4.2024.07.29.18.12.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 18:12:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Brad Smith Subject: [PULL 4/5] util/cpuinfo: Make use of elf_aux_info(3) on OpenBSD Date: Tue, 30 Jul 2024 11:12:01 +1000 Message-ID: <20240730011202.480829-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240730011202.480829-1-richard.henderson@linaro.org> References: <20240730011202.480829-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::c2f; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2f.google.com 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, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Brad Smith Signed-off-by: Brad Smith Message-ID: Signed-off-by: Richard Henderson --- util/cpuinfo-aarch64.c | 9 ++++++--- util/cpuinfo-ppc.c | 5 +++-- util/getauxval.c | 2 +- meson.build | 8 ++++++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/util/cpuinfo-aarch64.c b/util/cpuinfo-aarch64.c index 8ca775a14b..57468890c3 100644 --- a/util/cpuinfo-aarch64.c +++ b/util/cpuinfo-aarch64.c @@ -17,10 +17,13 @@ # define HWCAP2_BTI 0 /* added in glibc 2.32 */ # endif #endif +#ifdef CONFIG_ELF_AUX_INFO +#include +#endif #ifdef CONFIG_DARWIN # include #endif -#ifdef __OpenBSD__ +#if defined(__OpenBSD__) && !defined(CONFIG_ELF_AUX_INFO) # include # include # include @@ -61,7 +64,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(void) info = CPUINFO_ALWAYS; -#ifdef CONFIG_LINUX +#if defined(CONFIG_LINUX) || defined(CONFIG_ELF_AUX_INFO) unsigned long hwcap = qemu_getauxval(AT_HWCAP); info |= (hwcap & HWCAP_ATOMICS ? CPUINFO_LSE : 0); info |= (hwcap & HWCAP_USCAT ? CPUINFO_LSE2 : 0); @@ -78,7 +81,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(void) info |= sysctl_for_bool("hw.optional.arm.FEAT_PMULL") * CPUINFO_PMULL; info |= sysctl_for_bool("hw.optional.arm.FEAT_BTI") * CPUINFO_BTI; #endif -#ifdef __OpenBSD__ +#if defined(__OpenBSD__) && !defined(CONFIG_ELF_AUX_INFO) int mib[2]; uint64_t isar0; uint64_t pfr1; diff --git a/util/cpuinfo-ppc.c b/util/cpuinfo-ppc.c index 1304f9aa80..4d3d3aae0b 100644 --- a/util/cpuinfo-ppc.c +++ b/util/cpuinfo-ppc.c @@ -14,7 +14,8 @@ # include "elf.h" # endif #endif -#ifdef __FreeBSD__ +#if defined(CONFIG_ELF_AUX_INFO) +# include # include # ifndef PPC_FEATURE2_ARCH_3_1 # define PPC_FEATURE2_ARCH_3_1 0 @@ -35,7 +36,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(void) info = CPUINFO_ALWAYS; -#if defined(CONFIG_LINUX) || defined(__FreeBSD__) +#if defined(CONFIG_LINUX) || defined(CONFIG_ELF_AUX_INFO) unsigned long hwcap = qemu_getauxval(AT_HWCAP); unsigned long hwcap2 = qemu_getauxval(AT_HWCAP2); diff --git a/util/getauxval.c b/util/getauxval.c index ad4f6686a8..0735cd8271 100644 --- a/util/getauxval.c +++ b/util/getauxval.c @@ -99,7 +99,7 @@ unsigned long qemu_getauxval(unsigned long type) return 0; } -#elif defined(__FreeBSD__) +#elif defined(CONFIG_ELF_AUX_INFO) #include unsigned long qemu_getauxval(unsigned long type) diff --git a/meson.build b/meson.build index 5613b62a4f..97f63aa86c 100644 --- a/meson.build +++ b/meson.build @@ -2835,6 +2835,14 @@ config_host_data.set('CONFIG_GETAUXVAL', cc.links(gnu_source_prefix + ''' return getauxval(AT_HWCAP) == 0; }''')) +config_host_data.set('CONFIG_ELF_AUX_INFO', cc.links(gnu_source_prefix + ''' + #include + int main(void) { + unsigned long hwcap = 0; + elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); + return hwcap; + }''')) + config_host_data.set('CONFIG_USBFS', have_linux_user and cc.compiles(''' #include