From patchwork Wed Jul 3 17:42:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 809353 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp807983wru; Wed, 3 Jul 2024 10:44:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVTwNfvn/7/kDmTR+ME6g2pU7vbhGgF6/SbW/WA7WnSGl0ahC9CUBpqQ7PR3IBP6Qtm0+0hQPZDlXEObiPIkKVv X-Google-Smtp-Source: AGHT+IHc0/S71aUBR6/QlfOB6m34OoIseR4ZhzpmdRXj2ok4qD3eyyMSh5KAICdJm8VoqjchchEE X-Received: by 2002:a25:1ed6:0:b0:dff:1a17:dcbc with SMTP id 3f1490d57ef6-e036eaf9798mr12002924276.2.1720028650897; Wed, 03 Jul 2024 10:44:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720028650; cv=none; d=google.com; s=arc-20160816; b=mOtVP+/CGgKTms4g9duZOztt6sHwH2NALeVMEkKnK8716Hd6j0HfLvtwIamfrqKxh3 qtHDSCqUKADZCqVsoDPQqf8e+MLea/gnQDzwCXD7e1IToLpE1uGX4A17y7XtuWbzQ6wC 8BfNcWC501CUIG8lEJSX6nshYB2Lg/4jlhitPaoFBP4y/9DF95IH3xgJ+Zmi69jWcQRN 8K7BYw98ArK5qImasbnyTB6iuSaI6OhTK6VoVjt8/td7ODKKTQQVXkC2f5Llp3DF3JPQ 706aa1vvRN8CKvXuCxzCnYg22H5qCATbTwT76Lm4JqUNyeRa0lSvP68otCnxtdgUWwJW Koyg== 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=De3e0JkeF4KrU8mLyYHH4oWICuiNeCJT2yMY2MkLLPg=; fh=MoQL7SW1hNgADG9l4BUkyxqt3uxuhggF6Ub9Dq9ba3k=; b=dRC6jBH3JZtUKyPuATeaLJm+Q6/dlNzKycCFigLqVkHKIGWBBaIdSNlReiw3P7TrXQ n5Hx1y/uJGzd5fL3PJHG2hClMNp7EG00n3L4BuHIKk4gbRTOnYPbha0rTL/VdEEPXWNj rECy95Kfk7kf7TFOVndBXXhZ2zBEOgiaJ8Dx6hCV0tVPS/wh7+HpAd5iClnn0K9B63EF aXIBUEFxRNwjOWUJAJbaco3J0skyu+zDuPzbzZNJqzJSiOD2WI/QXNQgJHfvgIi9AF+8 lE0CFTaj+DO0yk56i95Kg5bbcMhNKLjg4WMuj+nZBEaBBByclJFtV+lcLOGT60uKhZot bWlQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lI0wgVBb; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-446514af754si137680761cf.525.2024.07.03.10.44.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Jul 2024 10:44:10 -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=lI0wgVBb; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP40R-0003N5-02; Wed, 03 Jul 2024 13:42:59 -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 1sP40A-0003Iw-Hf for qemu-devel@nongnu.org; Wed, 03 Jul 2024 13:42:42 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sP400-0005LJ-LS for qemu-devel@nongnu.org; Wed, 03 Jul 2024 13:42:38 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-2c983d8bdc7so496334a91.0 for ; Wed, 03 Jul 2024 10:42:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720028551; x=1720633351; 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=De3e0JkeF4KrU8mLyYHH4oWICuiNeCJT2yMY2MkLLPg=; b=lI0wgVBbdL/OkbCQcICAWcRfrbJ7YWtCZHPrcQ/j6lPob9O5sunqiZpttDePhRiGRl aowGQ3837CC1oKgXl9hediY795a8xOgd8lWTQMHbMl5DL+TOejFDiUS2ZphUiRN/FO4b JVtYmp3RN5oKAHLg7XIXc36VRqZHuCj+3RuzN6XziqQ4zFR9uNvcWPBsrHTO7WATiDLC GfLmUtEjm66MfcAQxnXa1JBToxN1MJZAUcGhalp2cna3ORwsKr6XveoF84WXUAsZP6rL DV1duOPnRbLVBUZaRsdbV3MVTbwpUk76+AqLVFw9TV5gW87V4zPzYH2q34rkoJu2OesS DCAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720028551; x=1720633351; 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=De3e0JkeF4KrU8mLyYHH4oWICuiNeCJT2yMY2MkLLPg=; b=LVoo44MGadxGTd0kvCEUPc4rqtWP1osafdUR1MPjexqCLxpqe5bbu+hKH8GN3dI8Y0 SmYWGaRDL+Eks6Gtj+F9AgKTQBAA1cEFoaIku47cuDTGcJARJXTVonn2Kx9OPuYZN8T9 9J6tPsqiH4tfbZFg4WS/uvCEHOum6Kg5LwlJkyYlH1TcZiFOr1NuWKzqkulT6s6TIMfy Ww4ZJ+qabP+aOp/0LeJTwyT+Sy3rWE6LPFTAu1OSYM3yuJCAbnf1kgqYGB/6stNcsmM8 y/N4n7N0/Or9QGD8ltMyFZE2+M+qVSde0aqLQxfz1USwSKkx55nIhDftAT5SWVDzWze4 +djw== X-Gm-Message-State: AOJu0YwmFCTJ2nucvKVPPXdMPYwBezpcPkqRDoqSq8a/nIqQzLQnvfnd l9Nwcip8Yw/nwlcGifN9Wize+MX+BJihzEpI8F9Tae8KYlnozaLaH1B3Ymo8+C8kAPtg+HlPB1h B X-Received: by 2002:a17:90a:4e4f:b0:2c9:75a4:cc71 with SMTP id 98e67ed59e1d1-2c975a4cf19mr2066075a91.32.1720028550686; Wed, 03 Jul 2024 10:42:30 -0700 (PDT) Received: from stoup.. (174-21-76-141.tukw.qwest.net. [174.21.76.141]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c91d3e7d7bsm11070030a91.47.2024.07.03.10.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 10:42:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Brad Smith Subject: [PULL 3/7] util/cpuinfo-aarch64: Add OpenBSD support Date: Wed, 3 Jul 2024 10:42:22 -0700 Message-Id: <20240703174226.2117169-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240703174226.2117169-1-richard.henderson@linaro.org> References: <20240703174226.2117169-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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, T_SPF_TEMPERROR=0.01 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 Reviewed-by: Richard Henderson Message-Id: Signed-off-by: Richard Henderson --- util/cpuinfo-aarch64.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/util/cpuinfo-aarch64.c b/util/cpuinfo-aarch64.c index 4c8a005715..8ca775a14b 100644 --- a/util/cpuinfo-aarch64.c +++ b/util/cpuinfo-aarch64.c @@ -20,6 +20,12 @@ #ifdef CONFIG_DARWIN # include #endif +#ifdef __OpenBSD__ +# include +# include +# include +# include +#endif unsigned cpuinfo; @@ -72,6 +78,36 @@ 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__ + int mib[2]; + uint64_t isar0; + uint64_t pfr1; + size_t len; + + mib[0] = CTL_MACHDEP; + mib[1] = CPU_ID_AA64ISAR0; + len = sizeof(isar0); + if (sysctl(mib, 2, &isar0, &len, NULL, 0) != -1) { + if (ID_AA64ISAR0_ATOMIC(isar0) >= ID_AA64ISAR0_ATOMIC_IMPL) { + info |= CPUINFO_LSE; + } + if (ID_AA64ISAR0_AES(isar0) >= ID_AA64ISAR0_AES_BASE) { + info |= CPUINFO_AES; + } + if (ID_AA64ISAR0_AES(isar0) >= ID_AA64ISAR0_AES_PMULL) { + info |= CPUINFO_PMULL; + } + } + + mib[0] = CTL_MACHDEP; + mib[1] = CPU_ID_AA64PFR1; + len = sizeof(pfr1); + if (sysctl(mib, 2, &pfr1, &len, NULL, 0) != -1) { + if (ID_AA64PFR1_BT(pfr1) >= ID_AA64PFR1_BT_IMPL) { + info |= CPUINFO_BTI; + } + } +#endif cpuinfo = info; return info;