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: 114788 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3428500qgn; Wed, 4 Oct 2017 11:17:34 -0700 (PDT) X-Received: by 10.36.86.205 with SMTP id o196mr29175285itb.149.1507141053981; Wed, 04 Oct 2017 11:17:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507141053; cv=none; d=google.com; s=arc-20160816; b=T4w9dA0inWinNZ44JLyOooUClHXOZAZUjPHX2H5jbhIFQeOuFr3HO1RsQsbGDiXHBR ZCXTupE04nr4Kiz/HIWpET+DOrhzLUwCruNetjU/o1pCzuxcvfnxBrOjiWcL0MKXzLY4 o8dCFbCIEVvbEgm1/zaGKmOUVao73HgNqg+M7Jw8hCvb9shqxAVfLK+TWJBOJRMq6Ddb BISczIiIhicF/byNTklYvNrv/S4apcr01UFEiG63hDn2XtleddylUGsMnOMo+p9Jm8hI ZXP8M878QTXUMTO9FTCX5Cbx2Y9nfZTrC7MXWaChFpCzKAsVdj/srIEHQngN6El3qsuU nnyQ== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=Kbyl9IknoXJ7HE3xn635r/4Ap9ZYnopryjeX3xroLN4=; b=XQituP9kyLbIokXm/sqrOycKDJ2VmFBDDl9x3cnSTBxF/hby/rmda5RprUhhgUUVsp /Kp32Y18EJwCk79dIslOk/GVlZq/8hZnsijzSm08C5QyqRCAMqajUqF9C0lpzQwmdANx HydWcL4sx9xyiT5oG9G0d2Hw6XFwNXl0z7vvinsdo0ko5Keu7R9qmWK25CKDr3Ntr7+U DAkQ8EKMSORNXH/Hu7bfqxivW6P1THilrs942KlH93hTe2XGxMpJiQLfly8EnE1nNtdx 0C9dTqyDCNSCnAw1MABMQ8KH+fPxIY9a/WYNjxlWEcOa+AdPdYGg4lzYlASO3LVUgYu5 ZdOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HbNr78Q8; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id n68si427847ioe.50.2017.10.04.11.17.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 11:17:33 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HbNr78Q8; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.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 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" 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);