From patchwork Mon Oct 1 12:46:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 147907 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp3866816lji; Mon, 1 Oct 2018 05:49:09 -0700 (PDT) X-Google-Smtp-Source: ACcGV61luSuIj7pClCJg6osflLgI5yB/vurFDbt4ewkBrenQcCmSqSHAhrHJIxPIT33Mrf7EPcQz X-Received: by 2002:a24:7957:: with SMTP id z84-v6mr3019433itc.88.1538398149809; Mon, 01 Oct 2018 05:49:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538398149; cv=none; d=google.com; s=arc-20160816; b=TxA3WcLLNtmm3c5+ynGvIepQuGiSptG/GIWY5V4d2dImzt6k+IQepu0vLUJ/SvxX2V nIjtNDJMrB4FdHo6/x8+Ly4zfD+MMXxC95mTAt5hiPM7JtIOycGJQEnn/GeK7QWGBdAs KCzogftpE7YspKM3fx7EUZb+MrHVvBU0VAeK6MqoOa52igxNTSotxsZlYwIdi0FRcGx/ 2UjB45W8ibjRy63+Bo03iMzqikuh5HDdb25njK4618a33rpVkXbbZfnompPAxOryJlth pc4OVHj4ZhAg+6cwkEFdbt7ueS65MPCtGC9ZSi4DN/kXf3emnxiQj+uLHbJkxb7URdU+ FsOg== 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=cPjyxrXj/Fo0Se1bRh3QjKDRZHTerZ0YaHrcj41FBkip5dehEPPdNIaBJ9L7T8T2Zb HjmwxjMswpevsM6/RkrCk1rfe6Kw5xTeZFfgXzJuYqiUf1mZaAbKELsd42DOuVBaNDh8 4zicN92MMXmIVarOCBH/KGy76E3p3MOTsN8iG0W8fB14mHAm0a+ad14j1np/9eTV7XqJ 4mMPfx5899RRU0dAQHAtBzfd1T++U+4EEYrcVxIuZ95zUQzRoY4hMhBigAmMExEeQHLm a4rH0daJXU2nzZkzhx7Cmcz91Cid1hu6vb3vhxBehPH58T2MQJDa505b6iFmFXOOXEA7 rJaA== 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 e19-v6si5987015itb.116.2018.10.01.05.49.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Oct 2018 05:49:09 -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 1g6xbB-0008Jc-Pd; Mon, 01 Oct 2018 12:46:53 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1g6xbA-0008Iw-I4 for xen-devel@lists.xen.org; Mon, 01 Oct 2018 12:46:52 +0000 X-Inumbo-ID: bd3b2e45-c577-11e8-a8a5-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id bd3b2e45-c577-11e8-a8a5-bc764e045a96; Mon, 01 Oct 2018 14:44:30 +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 165E47A9; Mon, 1 Oct 2018 05:46:50 -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 233DB3F5A0; Mon, 1 Oct 2018 05:46:48 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 1 Oct 2018 13:46:37 +0100 Message-Id: <20181001124639.22885-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181001124639.22885-1-julien.grall@arm.com> References: <20181001124639.22885-1-julien.grall@arm.com> Subject: [Xen-devel] [[PATCH v3] 2/4] 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 Reviewed-by: Stefano Stabellini --- 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)