From patchwork Tue Sep 25 17:20:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 147514 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp987359lji; Tue, 25 Sep 2018 10:23:04 -0700 (PDT) X-Google-Smtp-Source: ACcGV63Ysuxks66Ex0IFYzs76C0GZkRDB+62AD9V97pHHiTKwy8cexUT+XzsKe96W2VQeEPmZIaL X-Received: by 2002:a24:1013:: with SMTP id 19-v6mr1667340ity.141.1537896184079; Tue, 25 Sep 2018 10:23:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537896184; cv=none; d=google.com; s=arc-20160816; b=nKNaGEoNOPyMwUp0Wz0UCLVU+8TLbZqaYVmiKmGcwulT+VGhGiDLqoRoCv+YKbVIR7 R9q+qJLLeQ3XEXAWDcMm5Lri+jR+YTXMHuYN5NaUstnaWOqQGnIVyzulvQf+NkFfOVXT HTC5B1VqN1XDFHJdPxm8IfIEwav09k0OiTBU5LwH08M4FFpBvusGBqh/3xoBaQjHnBK8 kx6jrkkVNZwtqzlBhZeZJnMPa11gvTJOj7FxCoJRRQFjqG1GwzjWpdCvUOIgnVyzSD+b 8kfpWjs8M18/e07LgzoCOS/Gzum80slW/nhg5QTX+X/cuV5HIX4Hfz7raupgLry/AILq nK1w== 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; bh=fuP275Aei9SsYHD16C2EdYWFnQpMU28/ZnkxthUc8dI=; b=0LCloLHsklUjsjX+0S9n1c5ygAp+ky0FeRJFYdqWZm2TAfE1SkrrYgsgSAkMyVXFr9 OOF2REqXYYVCwNeo/HBslzl5aR6h2jPbSiOVIJXVuxEvmQ7mlWiOWtwPaM3ilVpaX2OQ 21CLdXyasMAi29uoJ62/an44sjEVzc0CVgBIT4wVFwTKASMyk7mrY7dE+uRz/O5F6Fpr ippw4/wOZGPbPAEsNdO5MJKfqNB/LdIX7LCqi7ouURxkRuEthCc9kXqIFqoNT2CBWUFK OzGTDwtJj52cGI+9GoY3iLBPQqHppXcxNHz7bjiBXZKbWwnxSUKL1iWkC29RcHUP4ZOl nnwA== 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 w4-v6si1890488ioa.62.2018.09.25.10.23.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Sep 2018 10:23:04 -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 1g4r16-0004BL-MZ; Tue, 25 Sep 2018 17:20:56 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1g4r15-0004Aj-Rc for xen-devel@lists.xen.org; Tue, 25 Sep 2018 17:20:55 +0000 X-Inumbo-ID: 83a8f17e-c0e7-11e8-a6a9-d7ebe60f679a Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 83a8f17e-c0e7-11e8-a6a9-d7ebe60f679a; Tue, 25 Sep 2018 17:22:01 +0000 (UTC) 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 35CCD7A9; Tue, 25 Sep 2018 10:20:55 -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 48DEA3F5BD; Tue, 25 Sep 2018 10:20:54 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 25 Sep 2018 18:20:41 +0100 Message-Id: <20180925172043.20248-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180925172043.20248-1-julien.grall@arm.com> References: <20180925172043.20248-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH v2 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. Changes in v2: - Use unlikely --- 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..c6cbc2ec84 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)); \ + \ + unlikely(__ret); \ + }) + static inline void cpus_set_cap(unsigned int num) { if (num >= ARM_NCAPS)