From patchwork Tue May 16 19:40:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 682428 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp21144wrt; Tue, 16 May 2023 12:59:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6EYrs+Z2B4XO17fGFux7Gldr/bI1xezuupRtg8a+ABMCsSmqpiTWSh2cBtoRkuMQGcf2Ry X-Received: by 2002:a7b:c454:0:b0:3f4:2297:630a with SMTP id l20-20020a7bc454000000b003f42297630amr22878945wmi.20.1684267185613; Tue, 16 May 2023 12:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684267185; cv=none; d=google.com; s=arc-20160816; b=zCtSWnwAIuI/Iuy5kPBvO7X0nZ9PO256o1EWwSr2HbKtVzhr/q67VQNdpVc1nPhY98 /VdgGa4LyLt9tWe15uY/ofTH/S5ilVx7tC1EJXPNl7z2XNEHqnyQcaQFrppBuU4UYQs9 lY5wi9SLzi7MnFEWl6btQHQWBkl4o62POoQwUk2IMzRvd5waXKSZlB/8cdU9xOODWk+t CbZSbC5WyA77/eSq6af29aQtcVEmN+5HZ9ab49ngM/9kcaM/hRLc+f3EwzobmoInuOHw 3pRrX4+fgDW2DRlkyO3iiascOlyQA9HLGQ1/z4FglEhaWz4HOXhbAR6uzADwlPL1DB5J ko+w== 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=nP6uwN475NI4kEPgZuacjyw/HnU7r6xvn2JKlD8Wx/Y=; b=BfHvASdY5oGb89QIjjfSzl2nNEHbXSgIQsOWrm9H77byuLhCISBcwcyK0yZKaX4Kr6 XWgR/vFQrT8DmW74C4JY8WcYHZ2sr6IUTau0pI6xHMPOA8JDdVGTj1Ho6pP0JeSe0VBQ sDc4cXBURCvP+bRPjPNrB6fDrPwbtjh9rlba/4NY0CQrS/LjRvj62T41YaAwG92u8kHf fxHku+Yx3J1GOpX0fbpNWSHgLga6dKC82OmleINj5DuB/8vohj3EEAWysgZTf2pAvoS5 xXi6X/2vHhWQTlEU0+RMfwWe0awhzLi4xDyvrv89DzhrvVCz8+hOYF/3hKWTr1Y+VT6F I7Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fwWcOFw0; 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 a22-20020a05600c349600b003f419da97dbsi161006wmq.30.2023.05.16.12.59.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 May 2023 12:59:45 -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=fwWcOFw0; 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 1pz0Yc-0006e4-Up; Tue, 16 May 2023 15:42:02 -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 1pz0Yb-0006di-BZ for qemu-devel@nongnu.org; Tue, 16 May 2023 15:42:01 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pz0YZ-0002lw-Ke for qemu-devel@nongnu.org; Tue, 16 May 2023 15:42:01 -0400 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-52caed90d17so9528070a12.0 for ; Tue, 16 May 2023 12:41:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684266118; x=1686858118; 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=nP6uwN475NI4kEPgZuacjyw/HnU7r6xvn2JKlD8Wx/Y=; b=fwWcOFw0g3RNCfIsNcyJc89wsK0h5ZExv7lKDKVHJ4oy5iOuGeT4aUJq0rOw3IRM2C 1mLpyCICrHPRWEf5w0n3RDOL8uDG6kxroY7sVGSTZE+GTiX9dQubAwDRc4xBdB5muy2z XXrCSuR+fEDc+UuXJaeNYGwHLdaUuo1UL5YBKDJ6w45EwRDzFDVIiaiVUgcWaQqGI5Vr YLF6sTTd5uq3SRPDI+xdc7BK4S8uykD3jJ1sqpNf4Kgi/O5xMEoQdHw2v/H6yR4aDYZH Ij9NTVPjr9Qwb6Wox7PDLry4kwacBNERNyHK9R53lgCiVcehCqqTo0ll5d06eesHKAWB Syzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684266118; x=1686858118; 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=nP6uwN475NI4kEPgZuacjyw/HnU7r6xvn2JKlD8Wx/Y=; b=J6By+6AdDTDeAKRImkS98ZN85yEG60dERKojMIaHTHQ4bwKD6FpOSSsgz/9lSTj63t quLK2ZyDeoS11lmLDZYLoHGy0SQYAbtj29PDLig5bSAHq8u/+CVzZcxTFiEekzlNqYYK pX9Dy8oiGkXUpSwKPh8Kv9ZO6Re58kRIzFJJZhyUjIETJdPNc1VMWEpwmTqf7QrswrJg 7FYdvlzT2lr3abLvmHyu9YtOFogI2IdnRZsHAo4T/Od0cyHEWdaJknqMUPHbCjU3ugao H35E7+SWK9wptMW2yTviZrntmA7eK290YifADvQp+Cuw0ggbAP3luZyML8iu5F5CLlwB xh7g== X-Gm-Message-State: AC+VfDzTuHUbOlYdpErf6lPfDzEARY/Sp6trMpwwVktzfBMR1Pdjr/8I d0G9l/klxsI6d6jWCH0sfEGH6zC1GRA/WyoyRHc= X-Received: by 2002:a05:6a20:8e06:b0:101:ab2:eaa8 with SMTP id y6-20020a056a208e0600b001010ab2eaa8mr37857010pzj.18.1684266118248; Tue, 16 May 2023 12:41:58 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:ec81:440e:33a4:40b9]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b006260526cf0csm13771165pfa.116.2023.05.16.12.41.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 12:41:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell Subject: [PULL 12/80] tcg/aarch64: Detect have_lse, have_lse2 for darwin Date: Tue, 16 May 2023 12:40:37 -0700 Message-Id: <20230516194145.1749305-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230516194145.1749305-1-richard.henderson@linaro.org> References: <20230516194145.1749305-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x535.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, T_SCC_BODY_TEXT_LINE=-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 These features are present for Apple M1. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.c.inc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index fc551a3d10..c64606af5b 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -16,6 +16,9 @@ #ifdef __linux__ #include #endif +#ifdef CONFIG_DARWIN +#include +#endif /* We're going to re-use TCGType in setting of the SF bit, which controls the size of the operation performed. If we know the values match, it @@ -2903,6 +2906,27 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) } } +#ifdef CONFIG_DARWIN +static bool sysctl_for_bool(const char *name) +{ + int val = 0; + size_t len = sizeof(val); + + if (sysctlbyname(name, &val, &len, NULL, 0) == 0) { + return val != 0; + } + + /* + * We might in the future ask for properties not present in older kernels, + * but we're only asking about static properties, all of which should be + * 'int'. So we shouln't see ENOMEM (val too small), or any of the other + * more exotic errors. + */ + assert(errno == ENOENT); + return false; +} +#endif + static void tcg_target_init(TCGContext *s) { #ifdef __linux__ @@ -2910,6 +2934,10 @@ static void tcg_target_init(TCGContext *s) have_lse = hwcap & HWCAP_ATOMICS; have_lse2 = hwcap & HWCAP_USCAT; #endif +#ifdef CONFIG_DARWIN + have_lse = sysctl_for_bool("hw.optional.arm.FEAT_LSE"); + have_lse2 = sysctl_for_bool("hw.optional.arm.FEAT_LSE2"); +#endif tcg_target_available_regs[TCG_TYPE_I32] = 0xffffffffu; tcg_target_available_regs[TCG_TYPE_I64] = 0xffffffffu;