From patchwork Fri Aug 24 16:58:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 145091 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1475098ljw; Fri, 24 Aug 2018 10:00:49 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZaE0guWECKkgcL0GuNeuds4vluKN7DTT88N8/eLyfYWVTnMECAcTDr58Lddm0M5ds8Sf6Z X-Received: by 2002:a6b:9c50:: with SMTP id f77-v6mr1896446ioe.220.1535130049836; Fri, 24 Aug 2018 10:00:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535130049; cv=none; d=google.com; s=arc-20160816; b=jR2pDRge5LANfGdWKgUNsQ6m7CAF+akueXpCXetaRF6wYwYgt1TOiCmCCAd1buO+AV IoZaPMZlRAAaBQUb2D7zpteGwd/als8T0ss4v1toVBuC39yFxdVyqVxp0cuSmrhcNRSR nUbq7LAkx8NU4mFb109MY2WWeOLt1YbwV5q6LEYpFuzQlwWKD5XTwBOl4oyvaoEavb+Z JABbEdtbH91XkAhTaSLjqzMkDsbkjaNx4k42kMUVdOQ6tLMeLC/HksJegvZrLukFkJ7y Q5gDIBnZYm6NDQDoV7G9dVEaDmkSxVm1jhzD8J82OrYUeY6TTRo92wUcH0aaVL3ZR60w rApw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from :arc-authentication-results; bh=aaRCX2d7mtK2fcZgDx7lNAO+h8KKDnbRutS+/fPckdo=; b=C9otKMcZD7ejqr4uLvunwpAFAYALNaTMrbis5a1BLc4HX/fN48U6iqR3DzckKhXjah eJxY6jwQrGumgpE0KxTZUSWxWCXQTKCCIG00CBUxJ9pO5AiiwsRBQ2Ha+1dFKJbebCbG Rf7Klx+Ub9p4R3+cyzFDqZQ6gSuOOr5lEnk+7j854JHW4Q8j0K3yjOf64kEZznT1SuCH 0Kdt1obTe9erLB7Y0guj28WThcJE9GNwCwlJkLXVgEGrfTljmVDO1TGBWiUV5W5XvwJZ Tu+RVxncnU5tHJkrBRJKbx4CIWZiPEb3YGIv+sOHMyLlj3FMwA+tfqaphsJRwdy32Igr Gkaw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id f9-v6si5037199ioa.191.2018.08.24.10.00.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Aug 2018 10:00:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ftFPu-00005y-0J; Fri, 24 Aug 2018 16:58:34 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ftFPs-00005j-Sb for xen-devel@lists.xen.org; Fri, 24 Aug 2018 16:58:32 +0000 X-Inumbo-ID: be794460-a7be-11e8-a8a5-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id be794460-a7be-11e8-a8a5-bc764e045a96; Fri, 24 Aug 2018 18:57:11 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 43A4380D; Fri, 24 Aug 2018 09:58:32 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.Emea.Arm.com [10.4.12.35]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 58FD43F5A0; Fri, 24 Aug 2018 09:58:31 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 24 Aug 2018 17:58:18 +0100 Message-Id: <20180824165820.32620-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180824165820.32620-1-julien.grall@arm.com> References: <20180824165820.32620-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 4/6] xen/arm: cpufeature: Add helper to check constant caps X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Julien Grall , sstabellini@kernel.org, volodymyr_babchuk@epam.com MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Some capababilities are set right during boot and will never change afterwards. At the moment, the function cpu_have_caps will check whether the cap is enabled from the memory. It is possible to avoid the load from the memory by using an ALTERNATIVE. With that the check is just reduced to 1 instruction. Signed-off-by: Julien Grall --- This is the static key for the poor. At some point we might want to introduce something similar to static key in Xen. --- xen/include/asm-arm/cpufeature.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/xen/include/asm-arm/cpufeature.h b/xen/include/asm-arm/cpufeature.h index 3de6b54301..9c297c521c 100644 --- a/xen/include/asm-arm/cpufeature.h +++ b/xen/include/asm-arm/cpufeature.h @@ -63,6 +63,18 @@ static inline bool cpus_have_cap(unsigned int num) return test_bit(num, cpu_hwcaps); } +/* System capability check for constant cap */ +#define cpus_have_const_cap(num) ({ \ + bool __ret; \ + \ + asm volatile (ALTERNATIVE("mov %0, #0", \ + "mov %0, #1", \ + num) \ + : "=r" (__ret)); \ + \ + __ret; \ + }) + static inline void cpus_set_cap(unsigned int num) { if (num >= ARM_NCAPS)