From patchwork Fri Aug 11 13:20:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9895847 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 5A18260325 for ; Fri, 11 Aug 2017 13:22:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 495C51FFDA for ; Fri, 11 Aug 2017 13:22:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DE1628C2C; Fri, 11 Aug 2017 13:22:35 +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 B21831FFDA for ; Fri, 11 Aug 2017 13:22:34 +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 1dg9rS-0000nQ-8S; Fri, 11 Aug 2017 13:20:22 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dg9rR-0000nC-Gs for xen-devel@lists.xenproject.org; Fri, 11 Aug 2017 13:20:21 +0000 Received: from [85.158.137.68] by server-16.bemta-3.messagelabs.com id 98/EA-01732-41FAD895; Fri, 11 Aug 2017 13:20:20 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrLIsWRWlGSWpSXmKPExsXS6fjDS1d4fW+ kwcXP5hbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0bX9JNsBTs0K46+u87cwPhDvouRk0NIIE/i XkMPO4jNK2An0fNkGhOILSFgKHF64U0WEJtFQFWibcpERhCbTUBdou3ZdtYuRg4OEQEDiXNHk 7oYuTiYBdYzSpxddQ6sV1jAWWLT133MEPOLJCb8O8cKYnMK2EssOraDDaSXV0BQ4u8OYZAws4 CWxMNft1ggbG2JZQtfM4OUMAtISyz/xzGBkW8WQsMsJA2zkDTMQmhYwMiyilGjOLWoLLVI18h CL6koMz2jJDcxM0fX0MBYLze1uDgxPTUnMalYLzk/dxMjMPjqGRgYdzC2n/A7xCjJwaQkypvg 0xspxJeUn1KZkVicEV9UmpNafIhRg4NDYNuu1RcYpVjy8vNSlSR4N64FqhMsSk1PrUjLzAHGB 0ypBAePkgjvFZA0b3FBYm5xZjpE6hSjLserCf+/MQmBzZAS5/0HUiQAUpRRmgc3AharlxhlpY R5GRkYGIR4ClKLcjNLUOVfMYpzMCoJ8wquA5rCk5lXArfpFdARTEBH9PmAHVGSiJCSamD0CLl XNHFtIdffrOQc26VmwlL+xcwNCwMv+q7d4TX77DTOBW6Lb1tuP3l1jrSGpbj0VZVZ7TmhEcGm T4/Fb+ndXnhv1lmDx7sadtutanmmunda5L+Th9RD7ybHv9invqH6Vt6jf2EPD+7kqL04eWfby 3v25z3fses9kEn7HfLFiLM8q+Z23r0+JZbijERDLeai4kQAnwf0CtACAAA= X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1502457618!105042218!1 X-Originating-IP: [137.65.248.74] 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 36323 invoked from network); 11 Aug 2017 13:20:19 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-13.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 11 Aug 2017 13:20:19 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Fri, 11 Aug 2017 07:20:17 -0600 Message-Id: <598DCB31020000780016EE10@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.2 Date: Fri, 11 Aug 2017 07:20:17 -0600 From: "Jan Beulich" To: "xen-devel" References: <598DC9B2020000780016EDF1@prv-mh.provo.novell.com> <598DC9B2020000780016EDF1@prv-mh.provo.novell.com> In-Reply-To: <598DC9B2020000780016EDF1@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Disposition: inline Cc: George Dunlap , Andrew Cooper , Kevin Tian , Jun Nakajima Subject: [Xen-devel] [PATCH v3 2/3] x86/p2m: make p2m_alloc_ptp() return an MFN 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 None of the callers really needs the struct page_info pointer. Signed-off-by: Jan Beulich Acked-by: George Dunlap Reviewed-by: Kevin Tian --- v3: Re-base over changes to patch 1. v2: Re-base over changes to patch 1. --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -569,7 +569,7 @@ int p2m_set_entry(struct p2m_domain *p2m return rc; } -struct page_info *p2m_alloc_ptp(struct p2m_domain *p2m, unsigned long type) +mfn_t p2m_alloc_ptp(struct p2m_domain *p2m, unsigned long type) { struct page_info *pg; @@ -577,13 +577,13 @@ struct page_info *p2m_alloc_ptp(struct p ASSERT(p2m->domain); ASSERT(p2m->domain->arch.paging.alloc_page); pg = p2m->domain->arch.paging.alloc_page(p2m->domain); - if (pg == NULL) - return NULL; + if ( !pg ) + return INVALID_MFN; page_list_add_tail(pg, &p2m->pages); pg->u.inuse.type_info = type | 1 | PGT_validated; - return pg; + return page_to_mfn(pg); } void p2m_free_ptp(struct p2m_domain *p2m, struct page_info *pg) @@ -609,7 +609,7 @@ void p2m_free_ptp(struct p2m_domain *p2m */ int p2m_alloc_table(struct p2m_domain *p2m) { - struct page_info *p2m_top; + mfn_t top_mfn; struct domain *d = p2m->domain; int rc = 0; @@ -632,14 +632,14 @@ int p2m_alloc_table(struct p2m_domain *p P2M_PRINTK("allocating p2m table\n"); - p2m_top = p2m_alloc_ptp(p2m, PGT_l4_page_table); - if ( p2m_top == NULL ) + top_mfn = p2m_alloc_ptp(p2m, PGT_l4_page_table); + if ( mfn_eq(top_mfn, INVALID_MFN) ) { p2m_unlock(p2m); return -ENOMEM; } - p2m->phys_table = pagetable_from_mfn(page_to_mfn(p2m_top)); + p2m->phys_table = pagetable_from_mfn(top_mfn); if ( hap_enabled(d) ) iommu_share_p2m_table(d); --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -225,16 +225,16 @@ static void ept_p2m_type_to_flags(struct /* Fill in middle levels of ept table */ static int ept_set_middle_entry(struct p2m_domain *p2m, ept_entry_t *ept_entry) { - struct page_info *pg; + mfn_t mfn; ept_entry_t *table; unsigned int i; - pg = p2m_alloc_ptp(p2m, 0); - if ( pg == NULL ) + mfn = p2m_alloc_ptp(p2m, 0); + if ( mfn_eq(mfn, INVALID_MFN) ) return 0; ept_entry->epte = 0; - ept_entry->mfn = page_to_mfn(pg); + ept_entry->mfn = mfn_x(mfn); ept_entry->access = p2m->default_access; ept_entry->r = ept_entry->w = ept_entry->x = 1; @@ -243,7 +243,7 @@ static int ept_set_middle_entry(struct p ept_entry->suppress_ve = 1; - table = __map_domain_page(pg); + table = map_domain_page(mfn); for ( i = 0; i < EPT_PAGETABLE_ENTRIES; i++ ) table[i].suppress_ve = 1; --- a/xen/arch/x86/mm/p2m-pt.c +++ b/xen/arch/x86/mm/p2m-pt.c @@ -204,14 +204,12 @@ p2m_next_level(struct p2m_domain *p2m, v /* PoD/paging: Not present doesn't imply empty. */ if ( !flags ) { - struct page_info *pg; + mfn_t mfn = p2m_alloc_ptp(p2m, type); - pg = p2m_alloc_ptp(p2m, type); - if ( pg == NULL ) + if ( mfn_eq(mfn, INVALID_MFN) ) return -ENOMEM; - new_entry = l1e_from_pfn(mfn_x(page_to_mfn(pg)), - P2M_BASE_FLAGS | _PAGE_RW); + new_entry = l1e_from_pfn(mfn_x(mfn), P2M_BASE_FLAGS | _PAGE_RW); switch ( type ) { case PGT_l3_page_table: @@ -235,7 +233,7 @@ p2m_next_level(struct p2m_domain *p2m, v { /* Split superpages pages into smaller ones. */ unsigned long pfn = l1e_get_pfn(*p2m_entry); - struct page_info *pg; + mfn_t mfn; l1_pgentry_t *l1_entry; unsigned int i, level; @@ -263,11 +261,11 @@ p2m_next_level(struct p2m_domain *p2m, v return -EINVAL; } - pg = p2m_alloc_ptp(p2m, type); - if ( pg == NULL ) + mfn = p2m_alloc_ptp(p2m, type); + if ( mfn_eq(mfn, INVALID_MFN) ) return -ENOMEM; - l1_entry = __map_domain_page(pg); + l1_entry = map_domain_page(mfn); /* Inherit original IOMMU permissions, but update Next Level. */ if ( iommu_hap_pt_share ) @@ -285,8 +283,7 @@ p2m_next_level(struct p2m_domain *p2m, v unmap_domain_page(l1_entry); - new_entry = l1e_from_pfn(mfn_x(page_to_mfn(pg)), - P2M_BASE_FLAGS | _PAGE_RW); + new_entry = l1e_from_pfn(mfn_x(mfn), P2M_BASE_FLAGS | _PAGE_RW); p2m_add_iommu_flags(&new_entry, level, IOMMUF_readable|IOMMUF_writable); p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry, level + 1); } --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -684,7 +684,7 @@ void p2m_mem_paging_resume(struct domain * Internal functions, only called by other p2m code */ -struct page_info *p2m_alloc_ptp(struct p2m_domain *p2m, unsigned long type); +mfn_t p2m_alloc_ptp(struct p2m_domain *p2m, unsigned long type); void p2m_free_ptp(struct p2m_domain *p2m, struct page_info *pg); /* Directly set a p2m entry: only for use by p2m code. Does not need