From patchwork Wed Oct 4 18:15:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9985281 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 E7DE660586 for ; Wed, 4 Oct 2017 18:17:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEBB728BD5 for ; Wed, 4 Oct 2017 18:17:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3AC328BDB; Wed, 4 Oct 2017 18:17:53 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID 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 59AFE28BD5 for ; Wed, 4 Oct 2017 18:17:53 +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 1dzoCt-00022D-NI; Wed, 04 Oct 2017 18:15:43 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dzoCr-000219-U2 for xen-devel@lists.xen.org; Wed, 04 Oct 2017 18:15:42 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id DC/72-03093-D4525D95; Wed, 04 Oct 2017 18:15:41 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGIsWRWlGSWpSXmKPExsVyMfTGBl0v1au RBu+PqVss+biYxYHR4+ju30wBjFGsmXlJ+RUJrBmr96xkLLgoU3Hw+wPWBsZW8S5GLg4hgUmM Els3/WYDcVgE5jFL7PuzhRHEkRDoZ5VYcnkykMMJ5ORJtNy8xgJhp0msnfkVyi6T6Hn9EKiGA 2iUmsSaN1EQU/uZJO7dXwgWZxPQkVg3oxakXERAWuLa58tgI5kFPjBKPH0jDlIiLJAkcfizDk iYRUBV4uvHHewgNq+AtcSjBUuZITbJS+xqu8gKYnMK2EjMmtIONkYIqKav/TTrBEbBBYwMqxg 1ilOLylKLdI0N9JKKMtMzSnITM3N0DQ3M9HJTi4sT01NzEpOK9ZLzczcxAsONAQh2MP5dG3iI UZKDSUmUd5b81UghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErxBKkA5waLU9NSKtMwcYODDpCU4e JREeB+ApHmLCxJzizPTIVKnGC05Lty59IeJ48CeW0Cy4+bdP0xCLHn5ealS4rytIA0CIA0ZpX lw42DReYlRVkqYlxHoQCGegtSi3MwSVPlXjOIcjErCvKYgU3gy80rgtr4COogJ6KA5TVdADip JREhJNTAm1TzePlk41/TnhOK/U9/8Om5wsnOapvryy22d8QWX63P5nMIvqP1qWuH5wHCr4BWV Vx0Rwo+ED3Zo2u+xn9HG8Xtxn/ZiD76MW2v2Z9pG7qtf4/lNUPyhuJtGvy7D2kebQ/r/lGgkr 7KyYpX/aqARt37f87erRJRUnx/9tE/TnSujoHLPfW8lluKMREMt5qLiRAAnxAtfyQIAAA== X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-10.tower-21.messagelabs.com!1507140937!69687595!1 X-Originating-IP: [209.85.216.176] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 46441 invoked from network); 4 Oct 2017 18:15:38 -0000 Received: from mail-qt0-f176.google.com (HELO mail-qt0-f176.google.com) (209.85.216.176) by server-10.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 4 Oct 2017 18:15:38 -0000 Received: by mail-qt0-f176.google.com with SMTP id v28so12067152qtv.1 for ; Wed, 04 Oct 2017 11:15:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aRdFrwiTD4UX5v5ltXe1CpiEqn4ogsYcz2iO7snB93w=; b=HbNr78Q8f3tRS7LL9EUlZW6z2Lg46Y+thBY2NgIuq/J/PH0BqTJhHMaaUhaO/e6kpD olxr6QZAU5XcgZFQJFIwkbYEX64fXJ4wT8x9e0Tfap66RZxu2lJNlbBJt7EROgBbKXeX 2PCOI/MRn+wOWgL4tSCTbWicB/J25+8/dzDiA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aRdFrwiTD4UX5v5ltXe1CpiEqn4ogsYcz2iO7snB93w=; b=WBCjaQ+aqcnTyjJrS4bQDe/Rue9Nn9dCXZPNgbDz59hd0IoGAjxJWwXFUrOZVbZTOK iHw9x3Rg9b1+zspPA1eK89XEJ5isJ0CZYoK79KosIyfxLqOr0fjLn8d+9DJjH/+MJqdi 7jnZaE7WLvvW7Cq3DB9QEVYsylQ70hNkpvUULJJfHQ784OWFXUVg5gl0zQy+s/uy4w04 6g7dQop4aO6RFmcxnvP83Ux/4mfTM3lTQl19i9S6FNcaCaKuF0St/popeASA4woAlPvo nsB2YiZxiwm7MatYwexKoP5ljC59UENIYIfuF8k+5H3yDTwSv/PYmw043pkiorYQv8yo BuXA== X-Gm-Message-State: AMCzsaXMC3Wgm4P9KDA0ur6V+pxxL9DKUrXzu3NazhpLA79eX7DZRz1l QvIZnFoiVPvIQM1fGl67rSSsavDD6Zc= X-Google-Smtp-Source: AOwi7QBvkLB7KVOdCthGGBLLPtr/j5TO1b1cXCqxo/fdaY8RyUXuUYZoBAUhUUPSZ2/nafYvCRs7Dg== X-Received: by 10.200.37.8 with SMTP id 8mr30026905qtm.77.1507140937464; Wed, 04 Oct 2017 11:15:37 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id l188sm10210622qkd.43.2017.10.04.11.15.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 11:15:37 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 4 Oct 2017 19:15:22 +0100 Message-Id: <20171004181526.9405-4-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171004181526.9405-1-julien.grall@linaro.org> References: <20171004181526.9405-1-julien.grall@linaro.org> Cc: Elena Ufimtseva , George Dunlap , Andrew Cooper , Julien Grall , Tim Deegan , Jan Beulich Subject: [Xen-devel] [PATCH 3/7] xen/x86: Use maddr_to_page and maddr_to_mfn to avoid open-coded >> PAGE_SHIFT 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" X-Virus-Scanned: ClamAV using ClamSMTP The constructions _mfn(... > PAGE_SHIFT) and mfn_to_page(... >> PAGE_SHIFT) could respectively be replaced by maddr_to_mfn(...) and maddr_to_page(...). Signed-off-by: Julien Grall Reviewed-by: Andrew Cooper --- Cc: Elena Ufimtseva Cc: Jan Beulich Cc: Andrew Cooper Cc: Tim Deegan Cc: George Dunlap --- xen/arch/x86/debug.c | 2 +- xen/arch/x86/mm/shadow/common.c | 2 +- xen/arch/x86/mm/shadow/multi.c | 6 +++--- xen/common/kimage.c | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/debug.c b/xen/arch/x86/debug.c index 1c10b84a16..9159f32db4 100644 --- a/xen/arch/x86/debug.c +++ b/xen/arch/x86/debug.c @@ -98,7 +98,7 @@ dbg_pv_va2mfn(dbgva_t vaddr, struct domain *dp, uint64_t pgd3val) l2_pgentry_t l2e, *l2t; l1_pgentry_t l1e, *l1t; unsigned long cr3 = (pgd3val ? pgd3val : dp->vcpu[0]->arch.cr3); - mfn_t mfn = _mfn(cr3 >> PAGE_SHIFT); + mfn_t mfn = maddr_to_mfn(cr3); DBGP2("vaddr:%lx domid:%d cr3:%lx pgd3:%lx\n", vaddr, dp->domain_id, cr3, pgd3val); diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c index 86186cccdf..f65d2a6523 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -2640,7 +2640,7 @@ static int sh_remove_shadow_via_pointer(struct domain *d, mfn_t smfn) ASSERT(sh_type_has_up_pointer(d, sp->u.sh.type)); if (sp->up == 0) return 0; - pmfn = _mfn(sp->up >> PAGE_SHIFT); + pmfn = maddr_to_mfn(sp->up); ASSERT(mfn_valid(pmfn)); vaddr = map_domain_page(pmfn); ASSERT(vaddr); diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index 28030acbf6..1e42e1d8ab 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -2425,7 +2425,7 @@ int sh_safe_not_to_sync(struct vcpu *v, mfn_t gl1mfn) sp = mfn_to_page(smfn); if ( sp->u.sh.count != 1 || !sp->up ) return 0; - smfn = _mfn(sp->up >> PAGE_SHIFT); + smfn = maddr_to_mfn(sp->up); ASSERT(mfn_valid(smfn)); #if (SHADOW_PAGING_LEVELS == 4) @@ -2434,7 +2434,7 @@ int sh_safe_not_to_sync(struct vcpu *v, mfn_t gl1mfn) ASSERT(sh_type_has_up_pointer(d, SH_type_l2_shadow)); if ( sp->u.sh.count != 1 || !sp->up ) return 0; - smfn = _mfn(sp->up >> PAGE_SHIFT); + smfn = maddr_to_mfn(sp->up); ASSERT(mfn_valid(smfn)); /* up to l4 */ @@ -2442,7 +2442,7 @@ int sh_safe_not_to_sync(struct vcpu *v, mfn_t gl1mfn) if ( sp->u.sh.count != 1 || !sh_type_has_up_pointer(d, SH_type_l3_64_shadow) || !sp->up ) return 0; - smfn = _mfn(sp->up >> PAGE_SHIFT); + smfn = maddr_to_mfn(sp->up); ASSERT(mfn_valid(smfn)); #endif diff --git a/xen/common/kimage.c b/xen/common/kimage.c index cf624d10fd..ebc71affd1 100644 --- a/xen/common/kimage.c +++ b/xen/common/kimage.c @@ -504,7 +504,7 @@ static void kimage_free_entry(kimage_entry_t entry) { struct page_info *page; - page = mfn_to_page(entry >> PAGE_SHIFT); + page = maddr_to_page(entry); free_domheap_page(page); } @@ -636,8 +636,8 @@ static struct page_info *kimage_alloc_page(struct kexec_image *image, if ( old ) { /* If so move it. */ - mfn_t old_mfn = _mfn(*old >> PAGE_SHIFT); - mfn_t mfn = _mfn(addr >> PAGE_SHIFT); + mfn_t old_mfn = maddr_to_mfn(*old); + mfn_t mfn = maddr_to_mfn(addr); copy_domain_page(mfn, old_mfn); clear_domain_page(old_mfn);