From patchwork Fri Sep 2 10:15:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9310665 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A6BE260760 for ; Fri, 2 Sep 2016 10:18:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 983A72975D for ; Fri, 2 Sep 2016 10:18:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CE5729760; Fri, 2 Sep 2016 10:18:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5700B2975D for ; Fri, 2 Sep 2016 10:18:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bflVv-000861-8S; Fri, 02 Sep 2016 10:15:59 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bflVu-00085r-AW for xen-devel@lists.xenproject.org; Fri, 02 Sep 2016 10:15:58 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id 57/AD-29421-D5159C75; Fri, 02 Sep 2016 10:15:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprDIsWRWlGSWpSXmKPExsVysyfVTTcm8GS 4wemZlhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bL+x4FbaoVE3cVNzB+keti5OIQEtjEKHHw 2RYmCGc3o8T2y/uAHE4OYQFvieadT4FsDg4RAT+JO1cDIWquMEq8vDSTESTOLKAvcW5HOUg5m 4CmxJ3Pn8BaeQWsJP4t6mQFsVkEVCRuXj0PZosKhEusnPmMBaJGUOLkzCdgNqeAo8TRxy1gNc wC6hJ/5l1ihrDlJba/ncM8gZFvFpKWWUjKZiEpW8DIvIpRozi1qCy1SNfYWC+pKDM9oyQ3MTN H19DATC83tbg4MT01JzGpWC85P3cTIzDUGIBgB+PO9YGHGCU5mJREeZcEnAwX4kvKT6nMSCzO iC8qzUktPsQow8GhJMEbBJITLEpNT61Iy8wBBj1MWoKDR0mENxUkzVtckJhbnJkOkTrFqCglz hsHkhAASWSU5sG1wSLtEqOslDAvI9AhQjwFqUW5mSWo8q8YxTkYlYR5uUCm8GTmlcBNfwW0mA loccm14yCLSxIRUlINjI/jNL+53JC60HZwjzFXgusxSdOZ72xOfHs1L9TJp21VzaXQuEcJxZc trjxYHJL+lWnnDeuXIWxeurYG4o+Un5+/+Ot63apZ8ce2PL5/jf1v6wfl9MjOmb4fPy9Q4Heu 3vS96tgeN5esBx8XHO13zjBPmP1+k9Qao7mR4RYhjzbF52ocSq6rYFZiKc5INNRiLipOBAApz ylhrwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-8.tower-27.messagelabs.com!1472811356!46843126!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.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 44683 invoked from network); 2 Sep 2016 10:15:56 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-8.tower-27.messagelabs.com with SMTP; 2 Sep 2016 10:15:56 -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 1739DBD7; Fri, 2 Sep 2016 03:15:56 -0700 (PDT) Received: from [10.1.218.32] (e108454-lin.cambridge.arm.com [10.1.218.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 785013F220; Fri, 2 Sep 2016 03:15:55 -0700 (PDT) To: Sergej Proskurin , xen-devel@lists.xenproject.org References: <20160816221714.22041-1-proskurin@sec.in.tum.de> <20160816221714.22041-3-proskurin@sec.in.tum.de> <541cd8a9-af17-234b-cf77-b23efb03e3ed@arm.com> <805c636a-5adc-731e-5a20-119ef591aa64@sec.in.tum.de> From: Julien Grall Message-ID: <9ade638a-6a63-8f32-9d09-cf9207964f45@arm.com> Date: Fri, 2 Sep 2016 11:15:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <805c636a-5adc-731e-5a20-119ef591aa64@sec.in.tum.de> Cc: Stefano Stabellini Subject: Re: [Xen-devel] [PATCH v3 02/38] arm/p2m: Expose p2m_*lock helpers 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP On 02/09/16 11:12, Sergej Proskurin wrote: > Hi Julien, Hello Sergej, > On 09/01/2016 05:48 PM, Julien Grall wrote: >> Hello Sergej, >> >> On 16/08/16 23:16, Sergej Proskurin wrote: >>> This commit exposes the "p2m_*lock" helpers, as they will be used within >>> the file ./xen/arch/arm/altp2m.c, as will be shown in the following >>> commits. >>> >>> Signed-off-by: Sergej Proskurin >>> --- >>> Cc: Stefano Stabellini >>> Cc: Julien Grall >>> --- >>> xen/arch/arm/p2m.c | 12 ++++++------ >>> xen/include/asm-arm/p2m.h | 16 ++++++++++++++++ >>> 2 files changed, 22 insertions(+), 6 deletions(-) >>> >>> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c >>> index da6c7d4..08114d8 100644 >>> --- a/xen/arch/arm/p2m.c >>> +++ b/xen/arch/arm/p2m.c >>> @@ -62,14 +62,14 @@ static inline bool_t p2m_is_superpage(lpae_t pte, >>> unsigned int level) >>> return (level < 3) && p2m_mapping(pte); >>> } >>> >>> -static inline void p2m_write_lock(struct p2m_domain *p2m) >>> +void p2m_write_lock(struct p2m_domain *p2m) >> >> This will introduce an overhead when locking the p2m. Those helpers >> should be moved a inline in p2m.h and not transform to a functions. >> > > I did not move the definitions of the functions into the header file to > avoid exposing the static function p2m_flush_tlb. However, what I can do > is to declare the function prototypes in p2m.h and define them as inline > in p2m.c, which should provide the same effect. It will not have the same effect for call of p2m_*lock outside of p2m.c. p2m_flush_tlb is only used in p2m_write_unlock, so what is the problem to move the implement of all p2m_*lock but p2m_write_unlock in p2m.h? commit 57b5214c6225c113b3cc50edbadce81b84e0a32c Author: Julien Grall Date: Tue Aug 2 15:48:48 2016 +0100 xen/arm: p2m: Export p2m_*_lock helpers Early patch exported the p2m interface (p2m_get_entry and p2m_set_entry) to allow splitting xen/arch/arm/p2m.c. Those functions require the callers to lock the p2m, so we need to export p2m_*_lock helpers. All helpers but p2m_write_unlock but p2m_write_unlock are moved in xen/include/asm-arm/p2m.h to allow inlining. The helpers p2m_write_unlock is kept in p2m.c because it depends on a static function. Signed-off-by: Julien Grall --- Changes in v2: - Patch added diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index f4a808c..e41ed3c 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -62,14 +62,10 @@ static inline bool_t p2m_is_superpage(lpae_t pte, unsigned int level) return (level < 3) && p2m_mapping(pte); } -static inline void p2m_write_lock(struct p2m_domain *p2m) -{ - write_lock(&p2m->lock); -} - static void p2m_flush_tlb(struct p2m_domain *p2m); -static inline void p2m_write_unlock(struct p2m_domain *p2m) +/* Unlock the flush and do a P2M TLB flush if necessary */ +void p2m_write_unlock(struct p2m_domain *p2m) { if ( p2m->need_flush ) { @@ -85,26 +81,6 @@ static inline void p2m_write_unlock(struct p2m_domain *p2m) write_unlock(&p2m->lock); } -static inline void p2m_read_lock(struct p2m_domain *p2m) -{ - read_lock(&p2m->lock); -} - -static inline void p2m_read_unlock(struct p2m_domain *p2m) -{ - read_unlock(&p2m->lock); -} - -static inline int p2m_is_locked(struct p2m_domain *p2m) -{ - return rw_is_locked(&p2m->lock); -} - -static inline int p2m_is_write_locked(struct p2m_domain *p2m) -{ - return rw_is_write_locked(&p2m->lock); -} - void p2m_dump_info(struct domain *d) { struct p2m_domain *p2m = &d->arch.p2m; diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index c2f4f98..9b0cade 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -173,6 +173,33 @@ void p2m_restore_state(struct vcpu *n); /* Print debugging/statistial info about a domain's p2m */ void p2m_dump_info(struct domain *d); +static inline void p2m_write_lock(struct p2m_domain *p2m) +{ + write_lock(&p2m->lock); +} + +void p2m_write_unlock(struct p2m_domain *p2m); + +static inline void p2m_read_lock(struct p2m_domain *p2m) +{ + read_lock(&p2m->lock); +} + +static inline void p2m_read_unlock(struct p2m_domain *p2m) +{ + read_unlock(&p2m->lock); +} + +static inline int p2m_is_locked(struct p2m_domain *p2m) +{ + return rw_is_locked(&p2m->lock); +} + +static inline int p2m_is_write_locked(struct p2m_domain *p2m) +{ + return rw_is_write_locked(&p2m->lock); +} + /* Look up the MFN corresponding to a domain's GFN. */ mfn_t p2m_lookup(struct domain *d, gfn_t gfn, p2m_type_t *t);