From patchwork Wed Jul 20 16:10:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 72451 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp66590qga; Wed, 20 Jul 2016 09:14:28 -0700 (PDT) X-Received: by 10.36.36.86 with SMTP id f83mr30219116ita.43.1469031263911; Wed, 20 Jul 2016 09:14:23 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id z198si2538187iod.137.2016.07.20.09.14.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jul 2016 09:14:23 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bPu5w-0007aZ-Iz; Wed, 20 Jul 2016 16:11:36 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bPu5v-0007ZF-FD for xen-devel@lists.xen.org; Wed, 20 Jul 2016 16:11:35 +0000 Received: from [85.158.137.68] by server-14.bemta-3.messagelabs.com id ED/EB-20915-6B2AF875; Wed, 20 Jul 2016 16:11:34 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrBLMWRWlGSWpSXmKPExsVysyfVTXfbov5 wg2l32CyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oy2rUtYChbxVCz9u5ilgbGBq4uRi0NIYBOj xNsdj5khnNOMEq2Hj7N3MXJysAloStz5/IkJxBYRkJa49vkyI0gRs0A7o8Tyjf9YQBLCAr4SU 3+tYgaxWQRUJVb9mc4KYvMKuEiseNcKFpcQkJM4eWwyWJxTwFXi/MmfjCC2EFDNprffmCcwci 9gZFjFqFGcWlSWWqRrbKCXVJSZnlGSm5iZo2toYKyXm1pcnJiempOYVKyXnJ+7iRHo43oGBsY djJ0n/A4xSnIwKYnyqor2hgvxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4F28sD9cSLAoNT21Ii0z BxhsMGkJDh4lEd7jIGne4oLE3OLMdIjUKUZFKXHebSAJAZBERmkeXBsswC8xykoJ8zIyMDAI8 RSkFuVmlqDKv2IU52BUEuZtBZnCk5lXAjf9FdBiJqDFcwTAFpckIqSkGhj9XottzZyy4WR0yO XtqStOTpeZ7v3xkfrDxeWvjvRU2R0+/or33bUf4i/vNATVX3nCbZl479He+H4FQxEmfeW/E6c V9yYuXZEb8pud2WzVGdY6s8uzpI7dN1od2nn517qttlyynZcTHm17qWKkMzvX4WLWD/ssvYfH dH/L3zJLmpIpLvXFdoayEktxRqKhFnNRcSIALiiXZmsCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-31.messagelabs.com!1469031093!51570287!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 49956 invoked from network); 20 Jul 2016 16:11:33 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-31.messagelabs.com with SMTP; 20 Jul 2016 16:11:33 -0000 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 E80C4BB4; Wed, 20 Jul 2016 09:12:43 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.218.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 47D673F387; Wed, 20 Jul 2016 09:11:32 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 20 Jul 2016 17:10:50 +0100 Message-Id: <1469031064-23344-9-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469031064-23344-1-git-send-email-julien.grall@arm.com> References: <1469031064-23344-1-git-send-email-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org, wei.chen@linaro.org, steve.capper@arm.com Subject: [Xen-devel] [PATCH 08/22] xen/arm: p2m: Simplify p2m type check by using bitmask X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The resulting assembly code for the macros is much simpler and will never contain more than one instruction branch. The idea is taken from x86 (see include/asm-x86/p2m.h). Also move the two helpers earlier to keep all the p2m type definitions together. Signed-off-by: Julien Grall --- xen/include/asm-arm/p2m.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index dbbcefe..3091c04 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -97,6 +97,17 @@ typedef enum { p2m_max_real_type, /* Types after this won't be store in the p2m */ } p2m_type_t; +/* We use bitmaps and mask to handle groups of types */ +#define p2m_to_mask(_t) (1UL << (_t)) + +/* RAM types, which map to real machine frames */ +#define P2M_RAM_TYPES (p2m_to_mask(p2m_ram_rw) | \ + p2m_to_mask(p2m_ram_ro)) + +/* Useful predicates */ +#define p2m_is_ram(_t) (p2m_to_mask(_t) & P2M_RAM_TYPES) +#define p2m_is_foreign(_t) (p2m_to_mask(_t) & p2m_to_mask(p2m_map_foreign)) + static inline void p2m_mem_access_emulate_check(struct vcpu *v, const vm_event_response_t *rsp) @@ -110,9 +121,6 @@ void p2m_altp2m_check(struct vcpu *v, uint16_t idx) /* Not supported on ARM. */ } -#define p2m_is_foreign(_t) ((_t) == p2m_map_foreign) -#define p2m_is_ram(_t) ((_t) == p2m_ram_rw || (_t) == p2m_ram_ro) - /* Initialise vmid allocator */ void p2m_vmid_allocator_init(void);