From patchwork Thu May 2 06:58:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 10926101 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 11A451390 for ; Thu, 2 May 2019 07:00:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1EE228DCE for ; Thu, 2 May 2019 07:00:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E087828BC8; Thu, 2 May 2019 07:00:12 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7644928BC8 for ; Thu, 2 May 2019 07:00:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hM5fX-0000Ua-D5; Thu, 02 May 2019 06:58:11 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hM5fV-0000UU-Fm for xen-devel@lists.xenproject.org; Thu, 02 May 2019 06:58:09 +0000 X-Inumbo-ID: a3a6c216-6ca7-11e9-843c-bc764e045a96 Received: from prv1-mh.provo.novell.com (unknown [137.65.248.33]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id a3a6c216-6ca7-11e9-843c-bc764e045a96; Thu, 02 May 2019 06:58:07 +0000 (UTC) Received: from INET-PRV1-MTA by prv1-mh.provo.novell.com with Novell_GroupWise; Thu, 02 May 2019 00:58:06 -0600 Message-Id: <5CCA94F9020000780022B02A@prv1-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 18.1.0 Date: Thu, 02 May 2019 00:58:01 -0600 From: "Jan Beulich" To: "xen-devel" Mime-Version: 1.0 Content-Disposition: inline Subject: [Xen-devel] [PATCH] x86/mm: subsume set_gpfn_from_mfn() into guest_physmap_add_entry() 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: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This is what both callers of guest_physmap_add_page() in memory.c want (for the !paging_mode_translate() case), and it is also what both callers in gnttab_transfer() need (but have been lacking). The other (x86-specific) callers are all HVM-only, and hence unaffected by this change. Sadly this isn't enough yet to drop Arm's dummy macro, as there's one more use in page_alloc.c. Signed-off-by: Jan Beulich Acked-by: Julien Grall --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -841,15 +841,19 @@ guest_physmap_add_entry(struct domain *d * any guest-requested type changes succeed and remove the IOMMU * entry). */ - if ( !need_iommu_pt_sync(d) || t != p2m_ram_rw ) + if ( t != p2m_ram_rw ) return 0; for ( i = 0; i < (1UL << page_order); ++i, ++page ) { - if ( get_page_and_type(page, d, PGT_writable_page) ) + if ( !need_iommu_pt_sync(d) ) + /* nothing */; + else if ( get_page_and_type(page, d, PGT_writable_page) ) put_page_and_type(page); else return -EINVAL; + + set_gpfn_from_mfn(mfn_x(mfn) + i, gfn_x(gfn) + i); } return 0; --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -270,16 +270,10 @@ static void populate_physmap(struct memo guest_physmap_add_page(d, _gfn(gpfn), mfn, a->extent_order); - if ( !paging_mode_translate(d) ) - { - for ( j = 0; j < (1U << a->extent_order); j++ ) - set_gpfn_from_mfn(mfn_x(mfn_add(mfn, j)), gpfn + j); - - /* Inform the domain of the new page's machine address. */ - if ( unlikely(__copy_mfn_to_guest_offset(a->extent_list, i, - mfn)) ) - goto out; - } + if ( !paging_mode_translate(d) && + /* Inform the domain of the new page's machine address. */ + unlikely(__copy_mfn_to_guest_offset(a->extent_list, i, mfn)) ) + goto out; } } @@ -755,15 +749,11 @@ static long memory_exchange(XEN_GUEST_HA guest_physmap_add_page(d, _gfn(gpfn), mfn, exch.out.extent_order); - if ( !paging_mode_translate(d) ) - { - for ( k = 0; k < (1UL << exch.out.extent_order); k++ ) - set_gpfn_from_mfn(mfn_x(mfn_add(mfn, k)), gpfn + k); - if ( __copy_mfn_to_guest_offset(exch.out.extent_start, - (i << out_chunk_order) + j, - mfn) ) - rc = -EFAULT; - } + if ( !paging_mode_translate(d) && + __copy_mfn_to_guest_offset(exch.out.extent_start, + (i << out_chunk_order) + j, + mfn) ) + rc = -EFAULT; } BUG_ON( !(d->is_dying) && (j != (1UL << out_chunk_order)) );