From patchwork Sun Jun 23 02:12:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brad Smith X-Patchwork-Id: 1951156 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=comstyle.com header.i=@comstyle.com header.a=rsa-sha256 header.s=default header.b=mSSjBAFv; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W6F4V44T5z20Wk for ; Sun, 23 Jun 2024 12:13:14 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLCiU-0001Mb-UN; Sat, 22 Jun 2024 22:12:30 -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 1sLCiS-0001M4-0X for qemu-devel@nongnu.org; Sat, 22 Jun 2024 22:12:28 -0400 Received: from speedy.comstyle.com ([2607:f938:3000:8::2] helo=mail.comstyle.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1sLCiQ-0002zM-6f for qemu-devel@nongnu.org; Sat, 22 Jun 2024 22:12:27 -0400 Received: from mail.comstyle.com (localhost [127.0.0.1]) by mail.comstyle.com (Postfix) with ESMTP id 4W6F3Y2cLmz8PbP; Sat, 22 Jun 2024 22:12:25 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=comstyle.com; h=date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=l0itdJ4sWXRO7UKXF3YZz+szFqAoEHcojxY5FRtV7h8=; b=mSSj BAFv1GfPVsMB+JFN93fg5+O2VYFRZr+mbendRU4qrN+KTpDoP1BmR2zCfF+SrEri PZoWwxxFUjAejdF1uQazW2KeGS+T1B1eObTtUOobkYlxU+s8CU9iSEjWLTJgdvj4 +aL11y9xFuoRq5RhthlGhP+dJlAnbOQ7Y28s4cA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=comstyle.com; h=date:from:to :cc:subject:message-id:mime-version:content-type; q=dns; s= default; b=o3KvLYgVTu0oVPLhJCaNOXI5M1mw62u4DV69Yu9suIPUI13cHYfxB jEimX6Bs3Z6Hv2eeY1eyA0S90EJ3oRYTXqNpkH9aNNI8S5gjk2RmmJvffI9rZVS0 SPCTmjHyKVjUuDothzopZi8lqOd6L1K/rSKt7y6dCTs9mD3GVg/ciM= Received: from humpty.home.comstyle.com (unknown [IPv6:2001:470:b050:3:9ee5:c2f5:b033:d60f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA512) (No client certificate requested) (Authenticated sender: brad) by mail.comstyle.com (Postfix) with ESMTPSA id 4W6F3Y219sz8PbN; Sat, 22 Jun 2024 22:12:25 -0400 (EDT) Date: Sat, 22 Jun 2024 22:12:23 -0400 From: Brad Smith To: Richard Henderson , Paolo Bonzini Cc: qemu-devel@nongnu.org Subject: [PATCH] util/cpuinfo-aarch64: Add OpenBSD support Message-ID: MIME-Version: 1.0 Content-Disposition: inline Received-SPF: pass client-ip=2607:f938:3000:8::2; envelope-from=brad@comstyle.com; helo=mail.comstyle.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, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org util/cpuinfo-aarch64: Add OpenBSD support Signed-off-by: Brad Smith Reviewed-by: Richard Henderson --- util/cpuinfo-aarch64.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/util/cpuinfo-aarch64.c b/util/cpuinfo-aarch64.c index 4c8a005715..8a8c0a30a8 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,32 @@ 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;