From patchwork Mon Sep 30 10:32:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166453 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B5FE16B1 for ; Mon, 30 Sep 2019 10:36:48 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DB871216F4 for ; Mon, 30 Sep 2019 10:36:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="q0PEC8y+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DB871216F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt28-0000sm-Qr; Mon, 30 Sep 2019 10:36:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt26-0000on-TL for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:58 +0000 X-Inumbo-ID: 048cd124-e36e-11e9-bf31-bc764e2007e4 Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id 048cd124-e36e-11e9-bf31-bc764e2007e4; Mon, 30 Sep 2019 10:35:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839727; x=1601375727; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=5Q2XE0XvYzUty69qqRlTGEEguqCrML7ftDS0JmcjKEo=; b=q0PEC8y+orhpV0CKHRZ0tdBgLz9oLtbUevV1CyGgvCr4s8zxihkWN/Tu mj3vlwP22IJKuXixI43h3aB5nYxijoyeo78ADbYk1NhK8EECmjJbqYRmi NmpKWaPZFNyh2Ei7a4mzncqr/x1ju1kYtAykzSaamCr+WIMACjhjs9k+g o=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="705521208" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1a-807d4a99.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 30 Sep 2019 10:34:08 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-807d4a99.us-east-1.amazon.com (Postfix) with ESMTPS id 8BFB4A3058; Mon, 30 Sep 2019 10:33:51 +0000 (UTC) Received: from EX13D06UEE001.ant.amazon.com (10.43.62.79) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:51 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D06UEE001.ant.amazon.com (10.43.62.79) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:50 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:33:50 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:32:54 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 02/55] x86: move some xen mm function declarations X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu They were put into page.h but mm.h is more appropriate. The real reason is that I will be adding some new functions which takes mfn_t. It turns out it is a bit difficult to do in page.h. No functional change. Signed-off-by: Wei Liu --- xen/include/asm-x86/mm.h | 5 +++++ xen/include/asm-x86/page.h | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 3863e4ce57..2800106327 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -630,4 +630,9 @@ int arch_acquire_resource(struct domain *d, unsigned int type, unsigned int id, unsigned long frame, unsigned int nr_frames, xen_pfn_t mfn_list[]); +/* Allocator functions for Xen pagetables. */ +void *alloc_xen_pagetable(void); +void free_xen_pagetable(void *v); +l1_pgentry_t *virt_to_xen_l1e(unsigned long v); + #endif /* __ASM_X86_MM_H__ */ diff --git a/xen/include/asm-x86/page.h b/xen/include/asm-x86/page.h index c1e92937c0..05a8b1efa6 100644 --- a/xen/include/asm-x86/page.h +++ b/xen/include/asm-x86/page.h @@ -345,11 +345,6 @@ void efi_update_l4_pgtable(unsigned int l4idx, l4_pgentry_t); #ifndef __ASSEMBLY__ -/* Allocator functions for Xen pagetables. */ -void *alloc_xen_pagetable(void); -void free_xen_pagetable(void *v); -l1_pgentry_t *virt_to_xen_l1e(unsigned long v); - /* Convert between PAT/PCD/PWT embedded in PTE flags and 3-bit cacheattr. */ static inline unsigned int pte_flags_to_cacheattr(unsigned int flags) { From patchwork Mon Sep 30 10:32:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166443 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0AEB16B1 for ; Mon, 30 Sep 2019 10:36:36 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9CDFA20679 for ; Mon, 30 Sep 2019 10:36:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="tLodigHu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9CDFA20679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1y-0000X2-Cq; Mon, 30 Sep 2019 10:35:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1w-0000Ty-Ss for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:48 +0000 X-Inumbo-ID: f7215b22-e36d-11e9-bf31-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id f7215b22-e36d-11e9-bf31-bc764e2007e4; Mon, 30 Sep 2019 10:35:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839704; x=1601375704; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=RDCbfQZPMBLWD5HES/JB4RFQjNpnLWAPbAQJ3Nba6J0=; b=tLodigHuX7j1FB0fa+x0bNjh/vjY3WAkELHRGmw/q5/HKW9W3ZVv2QYI Q2PmWEukPZjFJ8w6RZIS6qHNL/PLCi6FNJTBoykoA2wSkHo6JeQOJryIp 1JlUPgI0XXs19jgnT4RS/5Zgd3mOlRDZ59kIcOirrhbA8jBrQZN7mt/sV U=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="838005474" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1d-9ec21598.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 30 Sep 2019 10:34:05 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-9ec21598.us-east-1.amazon.com (Postfix) with ESMTPS id 7999CA20EF; Mon, 30 Sep 2019 10:33:52 +0000 (UTC) Received: from EX13D08UEE002.ant.amazon.com (10.43.62.92) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:52 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D08UEE002.ant.amazon.com (10.43.62.92) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:51 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:33:51 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:32:55 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 03/55] x86: introduce a new set of APIs to manage Xen page tables X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu We are going to switch to using domheap page for page tables. A new set of APIs is introduced to allocate, map, unmap and free pages for page tables. The allocation and deallocation work on mfn_t but not page_info, because they are required to work even before frame table is set up. Implement the old functions with the new ones. We will rewrite, site by site, other mm functions that manipulate page tables to use the new APIs. Note these new APIs still use xenheap page underneath and no actual map and unmap is done so that we don't break xen half way. They will be switched to use domheap and dynamic mappings when usage of old APIs is eliminated. No functional change intended in this patch. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 39 ++++++++++++++++++++++++++++++++++----- xen/include/asm-x86/mm.h | 11 +++++++++++ 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index e90c8a63a6..e2c8c3f3a1 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -119,6 +119,7 @@ #include #include #include +#include #include #include #include @@ -4847,22 +4848,50 @@ int mmcfg_intercept_write( } void *alloc_xen_pagetable(void) +{ + mfn_t mfn; + + mfn = alloc_xen_pagetable_new(); + ASSERT(!mfn_eq(mfn, INVALID_MFN)); + + return map_xen_pagetable_new(mfn); +} + +void free_xen_pagetable(void *v) +{ + if ( system_state != SYS_STATE_early_boot ) + free_xen_pagetable_new(virt_to_mfn(v)); +} + +mfn_t alloc_xen_pagetable_new(void) { if ( system_state != SYS_STATE_early_boot ) { void *ptr = alloc_xenheap_page(); BUG_ON(!hardware_domain && !ptr); - return ptr; + return virt_to_mfn(ptr); } - return mfn_to_virt(mfn_x(alloc_boot_pages(1, 1))); + return alloc_boot_pages(1, 1); } -void free_xen_pagetable(void *v) +void *map_xen_pagetable_new(mfn_t mfn) { - if ( system_state != SYS_STATE_early_boot ) - free_xenheap_page(v); + return mfn_to_virt(mfn_x(mfn)); +} + +/* v can point to an entry within a table or be NULL */ +void unmap_xen_pagetable_new(void *v) +{ + /* XXX still using xenheap page, no need to do anything. */ +} + +/* mfn can be INVALID_MFN */ +void free_xen_pagetable_new(mfn_t mfn) +{ + if ( system_state != SYS_STATE_early_boot && !mfn_eq(mfn, INVALID_MFN) ) + free_xenheap_page(mfn_to_virt(mfn_x(mfn))); } static DEFINE_SPINLOCK(map_pgdir_lock); diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 2800106327..80173eb4c3 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -633,6 +633,17 @@ int arch_acquire_resource(struct domain *d, unsigned int type, /* Allocator functions for Xen pagetables. */ void *alloc_xen_pagetable(void); void free_xen_pagetable(void *v); +mfn_t alloc_xen_pagetable_new(void); +void *map_xen_pagetable_new(mfn_t mfn); +void unmap_xen_pagetable_new(void *v); +void free_xen_pagetable_new(mfn_t mfn); + +#define UNMAP_XEN_PAGETABLE_NEW(ptr) \ + do { \ + unmap_xen_pagetable_new((ptr)); \ + (ptr) = NULL; \ + } while (0) + l1_pgentry_t *virt_to_xen_l1e(unsigned long v); #endif /* __ASM_X86_MM_H__ */ From patchwork Mon Sep 30 10:32:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166449 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3444213BD for ; Mon, 30 Sep 2019 10:36:45 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 04D1820679 for ; Mon, 30 Sep 2019 10:36:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="BxzFgd2h" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04D1820679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt23-0000i4-HT; Mon, 30 Sep 2019 10:35:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt21-0000ej-Sr for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:53 +0000 X-Inumbo-ID: fec424a4-e36d-11e9-b588-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id fec424a4-e36d-11e9-b588-bc764e2007e4; Mon, 30 Sep 2019 10:35:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839718; x=1601375718; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=IwBygj+RhjB/roSYIAno5ZW1vZEaPnrSx3ay7bN2WgM=; b=BxzFgd2h9n4z90DGTM8+dewTO1MEURgvPMrbAsZfxZ4cAWq5RPvAQBgc s9XvmUCLqWBl87s4ExuuM24GFQFtIZX1lDE7NnIsyLTGX1Sru9MRm4Gz9 lo9DXBiXpCPKWRxyVlb55Aq3Rzi5ltO+cK4T/t/r6Gm0r7kkGzDRfQBA5 0=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="838005521" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1a-af6a10df.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 30 Sep 2019 10:34:19 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1a-af6a10df.us-east-1.amazon.com (Postfix) with ESMTPS id DDD73A18EC; Mon, 30 Sep 2019 10:34:05 +0000 (UTC) Received: from EX13D09UEE004.ant.amazon.com (10.43.62.76) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:55 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D09UEE004.ant.amazon.com (10.43.62.76) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:52 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:33:51 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:32:56 +0100 Message-ID: <92a99f10591b0135e5b3212b00314b7d14121bbe.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 04/55] x86/mm: introduce l{1, 2}t local variables to map_pages_to_xen X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu The pl2e and pl1e variables are heavily (ab)used in that function. It is fine at the moment because all page tables are always mapped so there is no need to track the life time of each variable. We will soon have the requirement to map and unmap page tables. We need to track the life time of each variable to avoid leakage. Introduce some l{1,2}t variables with limited scope so that we can track life time of pointers to xen page tables more easily. No functional change. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 75 ++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index e2c8c3f3a1..2ae8a7736f 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5061,10 +5061,12 @@ int map_pages_to_xen( } else { - pl2e = l3e_to_l2e(ol3e); + l2_pgentry_t *l2t; + + l2t = l3e_to_l2e(ol3e); for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) { - ol2e = pl2e[i]; + ol2e = l2t[i]; if ( !(l2e_get_flags(ol2e) & _PAGE_PRESENT) ) continue; if ( l2e_get_flags(ol2e) & _PAGE_PSE ) @@ -5072,21 +5074,22 @@ int map_pages_to_xen( else { unsigned int j; + l1_pgentry_t *l1t; - pl1e = l2e_to_l1e(ol2e); + l1t = l2e_to_l1e(ol2e); for ( j = 0; j < L1_PAGETABLE_ENTRIES; j++ ) - flush_flags(l1e_get_flags(pl1e[j])); + flush_flags(l1e_get_flags(l1t[j])); } } flush_area(virt, flush_flags); for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) { - ol2e = pl2e[i]; + ol2e = l2t[i]; if ( (l2e_get_flags(ol2e) & _PAGE_PRESENT) && !(l2e_get_flags(ol2e) & _PAGE_PSE) ) free_xen_pagetable(l2e_to_l1e(ol2e)); } - free_xen_pagetable(pl2e); + free_xen_pagetable(l2t); } } @@ -5102,6 +5105,7 @@ int map_pages_to_xen( { unsigned int flush_flags = FLUSH_TLB | FLUSH_ORDER(2 * PAGETABLE_ORDER); + l2_pgentry_t *l2t; /* Skip this PTE if there is no change. */ if ( ((l3e_get_pfn(ol3e) & ~(L2_PAGETABLE_ENTRIES * @@ -5123,12 +5127,12 @@ int map_pages_to_xen( continue; } - pl2e = alloc_xen_pagetable(); - if ( pl2e == NULL ) + l2t = alloc_xen_pagetable(); + if ( l2t == NULL ) return -ENOMEM; for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) - l2e_write(pl2e + i, + l2e_write(l2t + i, l2e_from_pfn(l3e_get_pfn(ol3e) + (i << PAGETABLE_ORDER), l3e_get_flags(ol3e))); @@ -5141,15 +5145,15 @@ int map_pages_to_xen( if ( (l3e_get_flags(*pl3e) & _PAGE_PRESENT) && (l3e_get_flags(*pl3e) & _PAGE_PSE) ) { - l3e_write_atomic(pl3e, l3e_from_mfn(virt_to_mfn(pl2e), + l3e_write_atomic(pl3e, l3e_from_mfn(virt_to_mfn(l2t), __PAGE_HYPERVISOR)); - pl2e = NULL; + l2t = NULL; } if ( locking ) spin_unlock(&map_pgdir_lock); flush_area(virt, flush_flags); - if ( pl2e ) - free_xen_pagetable(pl2e); + if ( l2t ) + free_xen_pagetable(l2t); } pl2e = virt_to_xen_l2e(virt); @@ -5177,11 +5181,13 @@ int map_pages_to_xen( } else { - pl1e = l2e_to_l1e(ol2e); + l1_pgentry_t *l1t; + + l1t = l2e_to_l1e(ol2e); for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) - flush_flags(l1e_get_flags(pl1e[i])); + flush_flags(l1e_get_flags(l1t[i])); flush_area(virt, flush_flags); - free_xen_pagetable(pl1e); + free_xen_pagetable(l1t); } } @@ -5203,6 +5209,7 @@ int map_pages_to_xen( { unsigned int flush_flags = FLUSH_TLB | FLUSH_ORDER(PAGETABLE_ORDER); + l1_pgentry_t *l1t; /* Skip this PTE if there is no change. */ if ( (((l2e_get_pfn(*pl2e) & ~(L1_PAGETABLE_ENTRIES - 1)) + @@ -5222,12 +5229,12 @@ int map_pages_to_xen( goto check_l3; } - pl1e = alloc_xen_pagetable(); - if ( pl1e == NULL ) + l1t = alloc_xen_pagetable(); + if ( l1t == NULL ) return -ENOMEM; for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) - l1e_write(&pl1e[i], + l1e_write(&l1t[i], l1e_from_pfn(l2e_get_pfn(*pl2e) + i, lNf_to_l1f(l2e_get_flags(*pl2e)))); @@ -5239,15 +5246,15 @@ int map_pages_to_xen( if ( (l2e_get_flags(*pl2e) & _PAGE_PRESENT) && (l2e_get_flags(*pl2e) & _PAGE_PSE) ) { - l2e_write_atomic(pl2e, l2e_from_mfn(virt_to_mfn(pl1e), + l2e_write_atomic(pl2e, l2e_from_mfn(virt_to_mfn(l1t), __PAGE_HYPERVISOR)); - pl1e = NULL; + l1t = NULL; } if ( locking ) spin_unlock(&map_pgdir_lock); flush_area(virt, flush_flags); - if ( pl1e ) - free_xen_pagetable(pl1e); + if ( l1t ) + free_xen_pagetable(l1t); } pl1e = l2e_to_l1e(*pl2e) + l1_table_offset(virt); @@ -5272,6 +5279,7 @@ int map_pages_to_xen( ((1u << PAGETABLE_ORDER) - 1)) == 0)) ) { unsigned long base_mfn; + l1_pgentry_t *l1t; if ( locking ) spin_lock(&map_pgdir_lock); @@ -5295,11 +5303,11 @@ int map_pages_to_xen( goto check_l3; } - pl1e = l2e_to_l1e(ol2e); - base_mfn = l1e_get_pfn(*pl1e) & ~(L1_PAGETABLE_ENTRIES - 1); - for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++, pl1e++ ) - if ( (l1e_get_pfn(*pl1e) != (base_mfn + i)) || - (l1e_get_flags(*pl1e) != flags) ) + l1t = l2e_to_l1e(ol2e); + base_mfn = l1e_get_pfn(l1t[0]) & ~(L1_PAGETABLE_ENTRIES - 1); + for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) + if ( (l1e_get_pfn(l1t[i]) != (base_mfn + i)) || + (l1e_get_flags(l1t[i]) != flags) ) break; if ( i == L1_PAGETABLE_ENTRIES ) { @@ -5325,6 +5333,7 @@ int map_pages_to_xen( ((1UL << (L3_PAGETABLE_SHIFT - PAGE_SHIFT)) - 1))) ) { unsigned long base_mfn; + l2_pgentry_t *l2t; if ( locking ) spin_lock(&map_pgdir_lock); @@ -5342,13 +5351,13 @@ int map_pages_to_xen( continue; } - pl2e = l3e_to_l2e(ol3e); - base_mfn = l2e_get_pfn(*pl2e) & ~(L2_PAGETABLE_ENTRIES * + l2t = l3e_to_l2e(ol3e); + base_mfn = l2e_get_pfn(l2t[0]) & ~(L2_PAGETABLE_ENTRIES * L1_PAGETABLE_ENTRIES - 1); - for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++, pl2e++ ) - if ( (l2e_get_pfn(*pl2e) != + for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) + if ( (l2e_get_pfn(l2t[i]) != (base_mfn + (i << PAGETABLE_ORDER))) || - (l2e_get_flags(*pl2e) != l1f_to_lNf(flags)) ) + (l2e_get_flags(l2t[i]) != l1f_to_lNf(flags)) ) break; if ( i == L2_PAGETABLE_ENTRIES ) { From patchwork Mon Sep 30 10:32:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166371 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 309A213BD for ; Mon, 30 Sep 2019 10:35:21 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0CEA8216F4 for ; Mon, 30 Sep 2019 10:35:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="CFUmvNf8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0CEA8216F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0B-0006kP-QI; Mon, 30 Sep 2019 10:33:59 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0A-0006k6-3S for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:33:58 +0000 X-Inumbo-ID: cefc0110-e36d-11e9-bf31-bc764e2007e4 Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id cefc0110-e36d-11e9-bf31-bc764e2007e4; Mon, 30 Sep 2019 10:33:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839637; x=1601375637; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=ylxx4KY9/y4YFgv7nP3EOYtykrPz1aPjA0nz6rqmeOA=; b=CFUmvNf8M6DIop0+/bdrK104EjJFnNishWmoXSnn8iojNJtCJP2urSTN 1ytvLo51zpIgqPEsZLF8kMyDNT5EBsV6P6sxmzm+AIITUpRQY5wN8JSDk e9jGZTYAuhZx9MXxQrEzuiyNTzxLD1Op8vIyWf8DNWfh7OInSXMJO+2wZ k=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="754242108" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1e-c7c08562.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 30 Sep 2019 10:33:55 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1e-c7c08562.us-east-1.amazon.com (Postfix) with ESMTPS id 4E30B241835; Mon, 30 Sep 2019 10:33:54 +0000 (UTC) Received: from EX13D09UEE003.ant.amazon.com (10.43.62.56) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:54 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D09UEE003.ant.amazon.com (10.43.62.56) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:53 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:33:52 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:32:57 +0100 Message-ID: <8806ac6c0bc4e4a80da0c9ddb4ddf9256fd56a60.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 05/55] x86/mm: introduce l{1, 2}t local variables to modify_xen_mappings X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu The pl2e and pl1e variables are heavily (ab)used in that function. It is fine at the moment because all page tables are always mapped so there is no need to track the life time of each variable. We will soon have the requirement to map and unmap page tables. We need to track the life time of each variable to avoid leakage. Introduce some l{1,2}t variables with limited scope so that we can track life time of pointers to xen page tables more easily. No functional change. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 68 ++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 2ae8a7736f..063cacffb8 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5428,6 +5428,8 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) if ( l3e_get_flags(*pl3e) & _PAGE_PSE ) { + l2_pgentry_t *l2t; + if ( l2_table_offset(v) == 0 && l1_table_offset(v) == 0 && ((e - v) >= (1UL << L3_PAGETABLE_SHIFT)) ) @@ -5443,11 +5445,11 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) } /* PAGE1GB: shatter the superpage and fall through. */ - pl2e = alloc_xen_pagetable(); - if ( !pl2e ) + l2t = alloc_xen_pagetable(); + if ( !l2t ) return -ENOMEM; for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) - l2e_write(pl2e + i, + l2e_write(l2t + i, l2e_from_pfn(l3e_get_pfn(*pl3e) + (i << PAGETABLE_ORDER), l3e_get_flags(*pl3e))); @@ -5456,14 +5458,14 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) if ( (l3e_get_flags(*pl3e) & _PAGE_PRESENT) && (l3e_get_flags(*pl3e) & _PAGE_PSE) ) { - l3e_write_atomic(pl3e, l3e_from_mfn(virt_to_mfn(pl2e), + l3e_write_atomic(pl3e, l3e_from_mfn(virt_to_mfn(l2t), __PAGE_HYPERVISOR)); - pl2e = NULL; + l2t = NULL; } if ( locking ) spin_unlock(&map_pgdir_lock); - if ( pl2e ) - free_xen_pagetable(pl2e); + if ( l2t ) + free_xen_pagetable(l2t); } /* @@ -5497,12 +5499,14 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) } else { + l1_pgentry_t *l1t; + /* PSE: shatter the superpage and try again. */ - pl1e = alloc_xen_pagetable(); - if ( !pl1e ) + l1t = alloc_xen_pagetable(); + if ( !l1t ) return -ENOMEM; for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) - l1e_write(&pl1e[i], + l1e_write(&l1t[i], l1e_from_pfn(l2e_get_pfn(*pl2e) + i, l2e_get_flags(*pl2e) & ~_PAGE_PSE)); if ( locking ) @@ -5510,19 +5514,19 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) if ( (l2e_get_flags(*pl2e) & _PAGE_PRESENT) && (l2e_get_flags(*pl2e) & _PAGE_PSE) ) { - l2e_write_atomic(pl2e, l2e_from_mfn(virt_to_mfn(pl1e), + l2e_write_atomic(pl2e, l2e_from_mfn(virt_to_mfn(l1t), __PAGE_HYPERVISOR)); - pl1e = NULL; + l1t = NULL; } if ( locking ) spin_unlock(&map_pgdir_lock); - if ( pl1e ) - free_xen_pagetable(pl1e); + if ( l1t ) + free_xen_pagetable(l1t); } } else { - l1_pgentry_t nl1e; + l1_pgentry_t nl1e, *l1t; /* * Ordinary 4kB mapping: The L2 entry has been verified to be @@ -5569,9 +5573,9 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) continue; } - pl1e = l2e_to_l1e(*pl2e); + l1t = l2e_to_l1e(*pl2e); for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) - if ( l1e_get_intpte(pl1e[i]) != 0 ) + if ( l1e_get_intpte(l1t[i]) != 0 ) break; if ( i == L1_PAGETABLE_ENTRIES ) { @@ -5580,7 +5584,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) if ( locking ) spin_unlock(&map_pgdir_lock); flush_area(NULL, FLUSH_TLB_GLOBAL); /* flush before free */ - free_xen_pagetable(pl1e); + free_xen_pagetable(l1t); } else if ( locking ) spin_unlock(&map_pgdir_lock); @@ -5609,21 +5613,25 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) continue; } - pl2e = l3e_to_l2e(*pl3e); - for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) - if ( l2e_get_intpte(pl2e[i]) != 0 ) - break; - if ( i == L2_PAGETABLE_ENTRIES ) { - /* Empty: zap the L3E and free the L2 page. */ - l3e_write_atomic(pl3e, l3e_empty()); - if ( locking ) + l2_pgentry_t *l2t; + + l2t = l3e_to_l2e(*pl3e); + for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) + if ( l2e_get_intpte(l2t[i]) != 0 ) + break; + if ( i == L2_PAGETABLE_ENTRIES ) + { + /* Empty: zap the L3E and free the L2 page. */ + l3e_write_atomic(pl3e, l3e_empty()); + if ( locking ) + spin_unlock(&map_pgdir_lock); + flush_area(NULL, FLUSH_TLB_GLOBAL); /* flush before free */ + free_xen_pagetable(l2t); + } + else if ( locking ) spin_unlock(&map_pgdir_lock); - flush_area(NULL, FLUSH_TLB_GLOBAL); /* flush before free */ - free_xen_pagetable(pl2e); } - else if ( locking ) - spin_unlock(&map_pgdir_lock); } flush_area(NULL, FLUSH_TLB_GLOBAL); From patchwork Mon Sep 30 10:32:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166379 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 82A9613BD for ; Mon, 30 Sep 2019 10:35:31 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5E706216F4 for ; Mon, 30 Sep 2019 10:35:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="UWzkLOH/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E706216F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0L-0006o5-Kw; Mon, 30 Sep 2019 10:34:09 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0K-0006ni-N1 for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:34:08 +0000 X-Inumbo-ID: d54d122a-e36d-11e9-bf31-bc764e2007e4 Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id d54d122a-e36d-11e9-bf31-bc764e2007e4; Mon, 30 Sep 2019 10:34:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839647; x=1601375647; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=kpUuXZAvzGVSonE9aOxyMJVulSwYJnIv2Ma6gLcbPBA=; b=UWzkLOH/LQtu8A9qBI9ICRGMHyMMHSeAjq7l6SXjt3sUG3wk14wZ/aWd gAs+TsS0aOqs6+kb/2NDoJKLm8DWLNrrcvC08IQ4twYDxmLjpATrT8jvl ilvnLWN3JgOKivMCda3cbmhstLFJ5V7hfnnzS27dn2OqNfku3rvacMK/N 8=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="418649780" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-a70de69e.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:07 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1e-a70de69e.us-east-1.amazon.com (Postfix) with ESMTPS id E6EA8A2773; Mon, 30 Sep 2019 10:34:05 +0000 (UTC) Received: from EX13D11UEE002.ant.amazon.com (10.43.62.113) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:54 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D11UEE002.ant.amazon.com (10.43.62.113) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:54 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:33:53 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:32:58 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 06/55] x86/mm: map_pages_to_xen should have one exit path X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu We will soon rewrite the function to handle dynamically mapping and unmapping of page tables. No functional change. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 063cacffb8..ba38525d36 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5014,9 +5014,11 @@ int map_pages_to_xen( unsigned int flags) { bool locking = system_state > SYS_STATE_boot; + l3_pgentry_t *pl3e, ol3e; l2_pgentry_t *pl2e, ol2e; l1_pgentry_t *pl1e, ol1e; unsigned int i; + int rc = -ENOMEM; #define flush_flags(oldf) do { \ unsigned int o_ = (oldf); \ @@ -5034,10 +5036,13 @@ int map_pages_to_xen( while ( nr_mfns != 0 ) { - l3_pgentry_t ol3e, *pl3e = virt_to_xen_l3e(virt); + pl3e = virt_to_xen_l3e(virt); if ( !pl3e ) - return -ENOMEM; + { + ASSERT(rc == -ENOMEM); + goto out; + } ol3e = *pl3e; if ( cpu_has_page1gb && @@ -5129,7 +5134,10 @@ int map_pages_to_xen( l2t = alloc_xen_pagetable(); if ( l2t == NULL ) - return -ENOMEM; + { + ASSERT(rc == -ENOMEM); + goto out; + } for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) l2e_write(l2t + i, @@ -5158,7 +5166,10 @@ int map_pages_to_xen( pl2e = virt_to_xen_l2e(virt); if ( !pl2e ) - return -ENOMEM; + { + ASSERT(rc == -ENOMEM); + goto out; + } if ( ((((virt >> PAGE_SHIFT) | mfn_x(mfn)) & ((1u << PAGETABLE_ORDER) - 1)) == 0) && @@ -5203,7 +5214,10 @@ int map_pages_to_xen( { pl1e = virt_to_xen_l1e(virt); if ( pl1e == NULL ) - return -ENOMEM; + { + ASSERT(rc == -ENOMEM); + goto out; + } } else if ( l2e_get_flags(*pl2e) & _PAGE_PSE ) { @@ -5231,7 +5245,10 @@ int map_pages_to_xen( l1t = alloc_xen_pagetable(); if ( l1t == NULL ) - return -ENOMEM; + { + ASSERT(rc == -ENOMEM); + goto out; + } for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) l1e_write(&l1t[i], @@ -5377,7 +5394,10 @@ int map_pages_to_xen( #undef flush_flags - return 0; + rc = 0; + + out: + return rc; } int populate_pt_range(unsigned long virt, unsigned long nr_mfns) From patchwork Mon Sep 30 10:32:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166375 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7084F13BD for ; Mon, 30 Sep 2019 10:35:25 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4CC5F216F4 for ; Mon, 30 Sep 2019 10:35:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="UU9dkwhT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4CC5F216F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0M-0006oz-Vv; Mon, 30 Sep 2019 10:34:10 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0L-0006o9-QJ for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:34:09 +0000 X-Inumbo-ID: d5e9f432-e36d-11e9-96cc-12813bfff9fa Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id d5e9f432-e36d-11e9-96cc-12813bfff9fa; Mon, 30 Sep 2019 10:34:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839649; x=1601375649; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=5eAgOpLk7B+gyLwhtLD5m88hf+aaR83vnf4le+j06Qo=; b=UU9dkwhTlpY05BPCDqiAUUgyJNDZoOrYwUlL/i4j7//lsllLV279I7ET BbCU1e987WLhT3V8stBUIX3k2h3zlnYw9vN3lutezVsWKfnNcgjCd0WYd u5rf1atMJZEjE96cXjGNfhD4gn+7B8oaozTrCrjzDAIz66uv1RsE8xXjq w=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="424630032" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-9ec21598.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:08 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-9ec21598.us-east-1.amazon.com (Postfix) with ESMTPS id 8D1B5A20FA; Mon, 30 Sep 2019 10:34:06 +0000 (UTC) Received: from EX13D11UEE003.ant.amazon.com (10.43.62.248) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:55 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D11UEE003.ant.amazon.com (10.43.62.248) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:55 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:33:54 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:32:59 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 07/55] x86/mm: add an end_of_loop label in map_pages_to_xen X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu We will soon need to clean up mappings whenever the out most loop is ended. Add a new label and turn relevant continue's into goto's. No functional change. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index ba38525d36..0916aa74ae 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5102,7 +5102,7 @@ int map_pages_to_xen( if ( !mfn_eq(mfn, INVALID_MFN) ) mfn = mfn_add(mfn, 1UL << (L3_PAGETABLE_SHIFT - PAGE_SHIFT)); nr_mfns -= 1UL << (L3_PAGETABLE_SHIFT - PAGE_SHIFT); - continue; + goto end_of_loop; } if ( (l3e_get_flags(ol3e) & _PAGE_PRESENT) && @@ -5129,7 +5129,7 @@ int map_pages_to_xen( if ( !mfn_eq(mfn, INVALID_MFN) ) mfn = mfn_add(mfn, i); nr_mfns -= i; - continue; + goto end_of_loop; } l2t = alloc_xen_pagetable(); @@ -5310,7 +5310,7 @@ int map_pages_to_xen( { if ( locking ) spin_unlock(&map_pgdir_lock); - continue; + goto end_of_loop; } if ( l2e_get_flags(ol2e) & _PAGE_PSE ) @@ -5365,7 +5365,7 @@ int map_pages_to_xen( { if ( locking ) spin_unlock(&map_pgdir_lock); - continue; + goto end_of_loop; } l2t = l3e_to_l2e(ol3e); @@ -5390,6 +5390,7 @@ int map_pages_to_xen( else if ( locking ) spin_unlock(&map_pgdir_lock); } + end_of_loop:; } #undef flush_flags From patchwork Mon Sep 30 10:33:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166377 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0089F13BD for ; Mon, 30 Sep 2019 10:35:27 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D1235216F4 for ; Mon, 30 Sep 2019 10:35:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="U/72sVq/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D1235216F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0R-0006rR-CM; Mon, 30 Sep 2019 10:34:15 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0Q-0006r9-Qp for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:34:14 +0000 X-Inumbo-ID: d5e9f434-e36d-11e9-96cc-12813bfff9fa Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id d5e9f434-e36d-11e9-96cc-12813bfff9fa; Mon, 30 Sep 2019 10:34:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839649; x=1601375649; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Mauyqd924PdT/m+H441U/gI5RxdAY067bvDgJxjGF/A=; b=U/72sVq/+I7o1MJMffkMtZEiSxZPPlzKzgdhZHjpAi6aphsToanccjZ5 MX8e172rRcPZp1KUBXf1L2pr+Z0JhoLGTXq3/Af4csmmvRGylpBPcjj2a j+AcAS/Rg75sxQgNsqOaI0veix6y56fkciDGklqgy+sHBIOJ7Sx4dmVzK U=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="424630033" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-62350142.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:09 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-62350142.us-east-1.amazon.com (Postfix) with ESMTPS id 0A58BA1F92; Mon, 30 Sep 2019 10:34:07 +0000 (UTC) Received: from EX13D14UEE002.ant.amazon.com (10.43.62.144) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:56 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D14UEE002.ant.amazon.com (10.43.62.144) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:56 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:33:55 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:00 +0100 Message-ID: <2def1647db2dfdf49b00f462acc32b98358feb9c.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 08/55] x86/mm: make sure there is one exit path for modify_xen_mappings X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu We will soon need to handle dynamically mapping / unmapping page tables in the said function. No functional change. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 0916aa74ae..3a799e17e4 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5425,6 +5425,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) l1_pgentry_t *pl1e; unsigned int i; unsigned long v = s; + int rc = -ENOMEM; /* Set of valid PTE bits which may be altered. */ #define FLAGS_MASK (_PAGE_NX|_PAGE_RW|_PAGE_PRESENT) @@ -5468,7 +5469,11 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) /* PAGE1GB: shatter the superpage and fall through. */ l2t = alloc_xen_pagetable(); if ( !l2t ) - return -ENOMEM; + { + ASSERT(rc == -ENOMEM); + goto out; + } + for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) l2e_write(l2t + i, l2e_from_pfn(l3e_get_pfn(*pl3e) + @@ -5525,7 +5530,11 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) /* PSE: shatter the superpage and try again. */ l1t = alloc_xen_pagetable(); if ( !l1t ) - return -ENOMEM; + { + ASSERT(rc == -ENOMEM); + goto out; + } + for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) l1e_write(&l1t[i], l1e_from_pfn(l2e_get_pfn(*pl2e) + i, @@ -5658,7 +5667,10 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) flush_area(NULL, FLUSH_TLB_GLOBAL); #undef FLAGS_MASK - return 0; + rc = 0; + + out: + return rc; } #undef flush_area From patchwork Mon Sep 30 10:33:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166463 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F32A16B1 for ; Mon, 30 Sep 2019 10:37:00 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DF8F3216F4 for ; Mon, 30 Sep 2019 10:36:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="Li48+LBr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF8F3216F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2M-0001IY-Uw; Mon, 30 Sep 2019 10:36:14 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2L-0001Gl-UX for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:36:13 +0000 X-Inumbo-ID: 0c116c20-e36e-11e9-8628-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 0c116c20-e36e-11e9-8628-bc764e2007e4; Mon, 30 Sep 2019 10:35:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839740; x=1601375740; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=swDCRUW0LzPuFtPbYgjWPDHeLL7krWJ7Ji5Wu5oJhuE=; b=Li48+LBr7TC6GX0j+EzkoaYe2tGZa/11nBxIiREBNkshtyEgoIrty3HD KB7kEmoevInMhutsAdycRxngL9im6NyOzdw9EdyWVc/RIFkqhymn7VCm9 uHNhUd6dUmsaH8JZcBOfgHrU4sT6uSVkTIGyf5pqHg/p/TARyx7dzRp7t E=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="838005571" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1e-17c49630.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 30 Sep 2019 10:34:40 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-17c49630.us-east-1.amazon.com (Postfix) with ESMTPS id 91254A229C; Mon, 30 Sep 2019 10:34:09 +0000 (UTC) Received: from EX13D14UEE003.ant.amazon.com (10.43.62.11) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:57 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D14UEE003.ant.amazon.com (10.43.62.11) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:57 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:33:56 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:01 +0100 Message-ID: <1d32f7ba864218222339b87d95be88219743f6d7.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 09/55] x86/mm: add an end_of_loop label in modify_xen_mappings X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu We will soon need to clean up mappings whenever the out most loop is ended. Add a new label and turn relevant continue's into goto's. No functional change. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 3a799e17e4..b20d417fec 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5445,7 +5445,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) v += 1UL << L3_PAGETABLE_SHIFT; v &= ~((1UL << L3_PAGETABLE_SHIFT) - 1); - continue; + goto end_of_loop; } if ( l3e_get_flags(*pl3e) & _PAGE_PSE ) @@ -5463,7 +5463,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) l3e_write_atomic(pl3e, nl3e); v += 1UL << L3_PAGETABLE_SHIFT; - continue; + goto end_of_loop; } /* PAGE1GB: shatter the superpage and fall through. */ @@ -5507,7 +5507,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) v += 1UL << L2_PAGETABLE_SHIFT; v &= ~((1UL << L2_PAGETABLE_SHIFT) - 1); - continue; + goto end_of_loop; } if ( l2e_get_flags(*pl2e) & _PAGE_PSE ) @@ -5581,7 +5581,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) * skip the empty&free check. */ if ( (nf & _PAGE_PRESENT) || ((v != e) && (l1_table_offset(v) != 0)) ) - continue; + goto end_of_loop; if ( locking ) spin_lock(&map_pgdir_lock); @@ -5600,7 +5600,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) { if ( locking ) spin_unlock(&map_pgdir_lock); - continue; + goto end_of_loop; } l1t = l2e_to_l1e(*pl2e); @@ -5627,7 +5627,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) */ if ( (nf & _PAGE_PRESENT) || ((v != e) && (l2_table_offset(v) + l1_table_offset(v) != 0)) ) - continue; + goto end_of_loop; if ( locking ) spin_lock(&map_pgdir_lock); @@ -5640,7 +5640,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) { if ( locking ) spin_unlock(&map_pgdir_lock); - continue; + goto end_of_loop; } { @@ -5662,6 +5662,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) else if ( locking ) spin_unlock(&map_pgdir_lock); } + end_of_loop:; } flush_area(NULL, FLUSH_TLB_GLOBAL); From patchwork Mon Sep 30 10:33:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166381 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7484813BD for ; Mon, 30 Sep 2019 10:35:34 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4FE6C216F4 for ; Mon, 30 Sep 2019 10:35:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="rYSqiBGX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4FE6C216F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0W-0006vG-Ns; Mon, 30 Sep 2019 10:34:20 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0V-0006ul-R0 for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:34:19 +0000 X-Inumbo-ID: d7cb3be5-e36d-11e9-96cc-12813bfff9fa Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id d7cb3be5-e36d-11e9-96cc-12813bfff9fa; Mon, 30 Sep 2019 10:34:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839653; x=1601375653; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=iM0pBRhHPqSu1d/F9uL8ZRB9EnCqA5i0SQPBpzKDfcA=; b=rYSqiBGXdtQeBzxytnV+xRkTxTlg+aq8Otgyb+GmELGZnRMGGFVdr1Wj nB6QjnfFbR09aSExQW2PwZsLYsXLqNfuaK690pn7VkmNuZHsD4DuRlNMI b2TLsNoFfSMI1mzJW+o+1KdJGJHeazjlVKG0pNGjLcNUGPhJ8ftKkud6j c=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="788414632" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 30 Sep 2019 10:34:11 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com (Postfix) with ESMTPS id 5D85DA28C2; Mon, 30 Sep 2019 10:34:10 +0000 (UTC) Received: from EX13MTAUEE002.ant.amazon.com (10.43.62.24) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:58 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13MTAUEE002.ant.amazon.com (10.43.62.24) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:58 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:33:57 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:02 +0100 Message-ID: <61e6298a7016d793bb103e01fb309148d737376b.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 10/55] x86/mm: change pl2e to l2t in virt_to_xen_l2e X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu We will need to have a variable named pl2e when we rewrite virt_to_xen_l2e. Change pl2e to l2t to reflect better its purpose. This will make reviewing later patch easier. No functional change. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index b20d417fec..ea6931e052 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4939,22 +4939,22 @@ static l2_pgentry_t *virt_to_xen_l2e(unsigned long v) if ( !(l3e_get_flags(*pl3e) & _PAGE_PRESENT) ) { bool locking = system_state > SYS_STATE_boot; - l2_pgentry_t *pl2e = alloc_xen_pagetable(); + l2_pgentry_t *l2t = alloc_xen_pagetable(); - if ( !pl2e ) + if ( !l2t ) return NULL; if ( locking ) spin_lock(&map_pgdir_lock); if ( !(l3e_get_flags(*pl3e) & _PAGE_PRESENT) ) { - clear_page(pl2e); - l3e_write(pl3e, l3e_from_paddr(__pa(pl2e), __PAGE_HYPERVISOR)); - pl2e = NULL; + clear_page(l2t); + l3e_write(pl3e, l3e_from_paddr(__pa(l2t), __PAGE_HYPERVISOR)); + l2t = NULL; } if ( locking ) spin_unlock(&map_pgdir_lock); - if ( pl2e ) - free_xen_pagetable(pl2e); + if ( l2t ) + free_xen_pagetable(l2t); } BUG_ON(l3e_get_flags(*pl3e) & _PAGE_PSE); From patchwork Mon Sep 30 10:33:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166389 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 624D51709 for ; Mon, 30 Sep 2019 10:35:40 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3EEB9216F4 for ; Mon, 30 Sep 2019 10:35:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="IrQVl+DT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3EEB9216F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0Y-0006wI-2l; Mon, 30 Sep 2019 10:34:22 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0W-0006vD-Lq for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:34:20 +0000 X-Inumbo-ID: dc96e920-e36d-11e9-97fb-bc764e2007e4 Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id dc96e920-e36d-11e9-97fb-bc764e2007e4; Mon, 30 Sep 2019 10:34:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839660; x=1601375660; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=IWvv3JFE8UC9wDGna0qJ6XB0bPktobco6eb0qHMgbxc=; b=IrQVl+DTgEJdw5ChYs097OsLACS7H6qlhPjSHpC+ZX7+elNXoUPb37fp LGg1dvzhdtCv7g9gHVaQI+tqQ/oU1BidlG1y5sz2ewWaqNM5XcDyjah5x w20nVcbnvyYB41G3GJHTQ/8AMVKFiVgIlF16tXV4NC2Hj5oGDfuZdC/G+ s=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="788414639" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 30 Sep 2019 10:34:20 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com (Postfix) with ESMTPS id C059FA2161; Mon, 30 Sep 2019 10:34:18 +0000 (UTC) Received: from EX13D20UEE002.ant.amazon.com (10.43.62.204) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:02 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D20UEE002.ant.amazon.com (10.43.62.204) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:59 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:33:58 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:03 +0100 Message-ID: <596e44b9d83551de8982ac9a20a47d4bbce32844.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 11/55] x86/mm: change pl1e to l1t in virt_to_xen_l1e X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu We will need to have a variable named pl1e when we rewrite virt_to_xen_l1e. Change pl1e to l1t to reflect better its purpose. This will make reviewing later patch easier. No functional change. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index ea6931e052..7a522d90fe 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4972,22 +4972,22 @@ l1_pgentry_t *virt_to_xen_l1e(unsigned long v) if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) ) { bool locking = system_state > SYS_STATE_boot; - l1_pgentry_t *pl1e = alloc_xen_pagetable(); + l1_pgentry_t *l1t = alloc_xen_pagetable(); - if ( !pl1e ) + if ( !l1t ) return NULL; if ( locking ) spin_lock(&map_pgdir_lock); if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) ) { - clear_page(pl1e); - l2e_write(pl2e, l2e_from_paddr(__pa(pl1e), __PAGE_HYPERVISOR)); - pl1e = NULL; + clear_page(l1t); + l2e_write(pl2e, l2e_from_paddr(__pa(l1t), __PAGE_HYPERVISOR)); + l1t = NULL; } if ( locking ) spin_unlock(&map_pgdir_lock); - if ( pl1e ) - free_xen_pagetable(pl1e); + if ( l1t ) + free_xen_pagetable(l1t); } BUG_ON(l2e_get_flags(*pl2e) & _PAGE_PSE); From patchwork Mon Sep 30 10:33:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166385 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A7CD61709 for ; Mon, 30 Sep 2019 10:35:38 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 83719216F4 for ; Mon, 30 Sep 2019 10:35:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="jRd2fIZp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83719216F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0b-0006zH-Kb; Mon, 30 Sep 2019 10:34:25 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0a-0006yh-Qc for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:34:24 +0000 X-Inumbo-ID: d8f7c5aa-e36d-11e9-96cc-12813bfff9fa Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id d8f7c5aa-e36d-11e9-96cc-12813bfff9fa; Mon, 30 Sep 2019 10:34:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839654; x=1601375654; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=JByvjWRTQDqIZJNIb36YOya7+MZMs5J4FP69RDCf1ls=; b=jRd2fIZp17RmeYFImpr+aO9u7oYrHcK1NOAutUQyEl+QgGL0PCtANve/ rCRWyaCAIMFVrsquf4QGpeIgu+zU8FDkON3xc3A04qXYtSpsctYUJowDZ ah41Rbnc2Gm3EZBrDR44t/KYaffqabgB7x651x3de0VRmRkL4frGq9LlV 4=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="424630047" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-f273de60.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:14 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1d-f273de60.us-east-1.amazon.com (Postfix) with ESMTPS id ABF76A2EC0; Mon, 30 Sep 2019 10:34:12 +0000 (UTC) Received: from EX13D21UEE002.ant.amazon.com (10.43.62.64) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:00 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D21UEE002.ant.amazon.com (10.43.62.64) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:59 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:33:59 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:04 +0100 Message-ID: <088da2d07a2e95892b469c88ac66420e53549ca0.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 12/55] x86/mm: change pl3e to l3t in virt_to_xen_l3e X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu We will need to have a variable named pl3e when we rewrite virt_to_xen_l3e. Change pl3e to l3t to reflect better its purpose. This will make reviewing later patch easier. No functional change. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 7a522d90fe..f8a8f97f81 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4904,25 +4904,25 @@ static l3_pgentry_t *virt_to_xen_l3e(unsigned long v) if ( !(l4e_get_flags(*pl4e) & _PAGE_PRESENT) ) { bool locking = system_state > SYS_STATE_boot; - l3_pgentry_t *pl3e = alloc_xen_pagetable(); + l3_pgentry_t *l3t = alloc_xen_pagetable(); - if ( !pl3e ) + if ( !l3t ) return NULL; if ( locking ) spin_lock(&map_pgdir_lock); if ( !(l4e_get_flags(*pl4e) & _PAGE_PRESENT) ) { - l4_pgentry_t l4e = l4e_from_paddr(__pa(pl3e), __PAGE_HYPERVISOR); + l4_pgentry_t l4e = l4e_from_paddr(__pa(l3t), __PAGE_HYPERVISOR); - clear_page(pl3e); + clear_page(l3t); l4e_write(pl4e, l4e); efi_update_l4_pgtable(l4_table_offset(v), l4e); - pl3e = NULL; + l3t = NULL; } if ( locking ) spin_unlock(&map_pgdir_lock); - if ( pl3e ) - free_xen_pagetable(pl3e); + if ( l3t ) + free_xen_pagetable(l3t); } return l4e_to_l3e(*pl4e) + l3_table_offset(v); From patchwork Mon Sep 30 10:33:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166397 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0F5913BD for ; Mon, 30 Sep 2019 10:35:47 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9D777215EA for ; Mon, 30 Sep 2019 10:35:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="FiiFA8HB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D777215EA Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0g-00073U-Vq; Mon, 30 Sep 2019 10:34:30 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0f-00072V-RJ for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:34:29 +0000 X-Inumbo-ID: d8f7c5ac-e36d-11e9-96cc-12813bfff9fa Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id d8f7c5ac-e36d-11e9-96cc-12813bfff9fa; Mon, 30 Sep 2019 10:34:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839654; x=1601375654; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Py9hgP70m9HBUfBEhr08s8H5V3T2TLC0UE4W9w9lg6s=; b=FiiFA8HB6IhNsu/Uo1D1fAJ3MLQOssuXK+XBuVYBYN+aR2BBWLa91Dju iBM3LNasRTuqI94vUoclsrA29mq/Rp+AUggKLYX29f89tJT6wCdPWsWVx LYdh0wKyKJe1Ru8Yww0vQvWDCQ5IAHvbsnp6rmShWrZdUBMJXz0pyBjYW M=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="424630051" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-7d76a15f.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:14 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-7d76a15f.us-east-1.amazon.com (Postfix) with ESMTPS id 4A897A2FB2; Mon, 30 Sep 2019 10:34:13 +0000 (UTC) Received: from EX13D23UEE003.ant.amazon.com (10.43.62.173) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:01 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D23UEE003.ant.amazon.com (10.43.62.173) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:01 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:00 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:05 +0100 Message-ID: <101d19a92a8104e2a25bc8395aea095945ea80fd.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 13/55] x86/mm: rewrite virt_to_xen_l3e X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Rewrite that function to use the new APIs. Modify its callers to unmap the pointer returned. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 61 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index f8a8f97f81..1dcd4289d1 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4896,45 +4896,70 @@ void free_xen_pagetable_new(mfn_t mfn) static DEFINE_SPINLOCK(map_pgdir_lock); +/* + * Given a virtual address, return a pointer to xen's L3 entry. Caller + * needs to unmap the pointer. + */ static l3_pgentry_t *virt_to_xen_l3e(unsigned long v) { l4_pgentry_t *pl4e; + l3_pgentry_t *pl3e = NULL; pl4e = &idle_pg_table[l4_table_offset(v)]; if ( !(l4e_get_flags(*pl4e) & _PAGE_PRESENT) ) { bool locking = system_state > SYS_STATE_boot; - l3_pgentry_t *l3t = alloc_xen_pagetable(); + l3_pgentry_t *l3t; + mfn_t mfn; + + mfn = alloc_xen_pagetable_new(); + if ( mfn_eq(mfn, INVALID_MFN) ) + goto out; + + l3t = map_xen_pagetable_new(mfn); - if ( !l3t ) - return NULL; if ( locking ) spin_lock(&map_pgdir_lock); if ( !(l4e_get_flags(*pl4e) & _PAGE_PRESENT) ) { - l4_pgentry_t l4e = l4e_from_paddr(__pa(l3t), __PAGE_HYPERVISOR); + l4_pgentry_t l4e = l4e_from_mfn(mfn, __PAGE_HYPERVISOR); clear_page(l3t); l4e_write(pl4e, l4e); efi_update_l4_pgtable(l4_table_offset(v), l4e); + pl3e = l3t + l3_table_offset(v); l3t = NULL; } if ( locking ) spin_unlock(&map_pgdir_lock); if ( l3t ) - free_xen_pagetable(l3t); + { + ASSERT(!pl3e); + ASSERT(!mfn_eq(mfn, INVALID_MFN)); + UNMAP_XEN_PAGETABLE_NEW(l3t); + free_xen_pagetable_new(mfn); + } + } + + if ( !pl3e ) + { + ASSERT(l4e_get_flags(*pl4e) & _PAGE_PRESENT); + pl3e = (l3_pgentry_t *)map_xen_pagetable_new(l4e_get_mfn(*pl4e)) + + l3_table_offset(v); } - return l4e_to_l3e(*pl4e) + l3_table_offset(v); + out: + return pl3e; } static l2_pgentry_t *virt_to_xen_l2e(unsigned long v) { l3_pgentry_t *pl3e; + l2_pgentry_t *pl2e = NULL; pl3e = virt_to_xen_l3e(v); if ( !pl3e ) - return NULL; + goto out; if ( !(l3e_get_flags(*pl3e) & _PAGE_PRESENT) ) { @@ -4942,7 +4967,8 @@ static l2_pgentry_t *virt_to_xen_l2e(unsigned long v) l2_pgentry_t *l2t = alloc_xen_pagetable(); if ( !l2t ) - return NULL; + goto out; + if ( locking ) spin_lock(&map_pgdir_lock); if ( !(l3e_get_flags(*pl3e) & _PAGE_PRESENT) ) @@ -4958,7 +4984,11 @@ static l2_pgentry_t *virt_to_xen_l2e(unsigned long v) } BUG_ON(l3e_get_flags(*pl3e) & _PAGE_PSE); - return l3e_to_l2e(*pl3e) + l2_table_offset(v); + pl2e = l3e_to_l2e(*pl3e) + l2_table_offset(v); + + out: + UNMAP_XEN_PAGETABLE_NEW(pl3e); + return pl2e; } l1_pgentry_t *virt_to_xen_l1e(unsigned long v) @@ -5014,7 +5044,7 @@ int map_pages_to_xen( unsigned int flags) { bool locking = system_state > SYS_STATE_boot; - l3_pgentry_t *pl3e, ol3e; + l3_pgentry_t *pl3e = NULL, ol3e; l2_pgentry_t *pl2e, ol2e; l1_pgentry_t *pl1e, ol1e; unsigned int i; @@ -5390,7 +5420,8 @@ int map_pages_to_xen( else if ( locking ) spin_unlock(&map_pgdir_lock); } - end_of_loop:; + end_of_loop: + UNMAP_XEN_PAGETABLE_NEW(pl3e); } #undef flush_flags @@ -5398,6 +5429,7 @@ int map_pages_to_xen( rc = 0; out: + UNMAP_XEN_PAGETABLE_NEW(pl3e); return rc; } @@ -5421,6 +5453,7 @@ int populate_pt_range(unsigned long virt, unsigned long nr_mfns) int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) { bool locking = system_state > SYS_STATE_boot; + l3_pgentry_t *pl3e = NULL; l2_pgentry_t *pl2e; l1_pgentry_t *pl1e; unsigned int i; @@ -5436,7 +5469,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) while ( v < e ) { - l3_pgentry_t *pl3e = virt_to_xen_l3e(v); + pl3e = virt_to_xen_l3e(v); if ( !pl3e || !(l3e_get_flags(*pl3e) & _PAGE_PRESENT) ) { @@ -5662,7 +5695,8 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) else if ( locking ) spin_unlock(&map_pgdir_lock); } - end_of_loop:; + end_of_loop: + UNMAP_XEN_PAGETABLE_NEW(pl3e); } flush_area(NULL, FLUSH_TLB_GLOBAL); @@ -5671,6 +5705,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) rc = 0; out: + UNMAP_XEN_PAGETABLE_NEW(pl3e); return rc; } From patchwork Mon Sep 30 10:33:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166459 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 98AA516B1 for ; Mon, 30 Sep 2019 10:36:51 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7507920679 for ; Mon, 30 Sep 2019 10:36:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="Cgk7xJLU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7507920679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2C-00010U-JJ; Mon, 30 Sep 2019 10:36:04 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2B-0000z7-Ug for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:36:03 +0000 X-Inumbo-ID: 05795f62-e36e-11e9-8628-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 05795f62-e36e-11e9-8628-bc764e2007e4; Mon, 30 Sep 2019 10:35:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839729; x=1601375729; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=hTkmNlwsOjF0Hl2l2Hvic+lIfqYsmmXAm8fsLU5GbNQ=; b=Cgk7xJLUvaqCFgCf9Bx9b0BkHTkDY22STw6P84tLZeDaaOcC9APvlnxd pMTq9G6q+jT9rQLT/3heTek6ZpGHOzh5+qpNqOrM6fh55UuJLdis51bo1 tKhN+Mlwu/0kAL4bRQRBdnWAKzztWCKJWJMXBxNZIBAH9aQXygsw9vW3O 4=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="838005541" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1d-f273de60.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 30 Sep 2019 10:34:29 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1d-f273de60.us-east-1.amazon.com (Postfix) with ESMTPS id CE25CA2EBA; Mon, 30 Sep 2019 10:34:16 +0000 (UTC) Received: from EX13D15UEE002.ant.amazon.com (10.43.62.80) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:02 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D15UEE002.ant.amazon.com (10.43.62.80) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:01 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:01 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:06 +0100 Message-ID: <12674b11445769ccf7aae2d732580a711bc25bd2.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 14/55] x86/mm: rewrite xen_to_virt_l2e X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Rewrite that function to use the new APIs. Modify its callers to unmap the pointer returned. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 1dcd4289d1..ad0d7a0b80 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4952,6 +4952,10 @@ static l3_pgentry_t *virt_to_xen_l3e(unsigned long v) return pl3e; } +/* + * Given a virtual address, return a pointer to xen's L2 entry. Caller + * needs to unmap the pointer. + */ static l2_pgentry_t *virt_to_xen_l2e(unsigned long v) { l3_pgentry_t *pl3e; @@ -4964,27 +4968,44 @@ static l2_pgentry_t *virt_to_xen_l2e(unsigned long v) if ( !(l3e_get_flags(*pl3e) & _PAGE_PRESENT) ) { bool locking = system_state > SYS_STATE_boot; - l2_pgentry_t *l2t = alloc_xen_pagetable(); + l2_pgentry_t *l2t; + mfn_t mfn; - if ( !l2t ) + mfn = alloc_xen_pagetable_new(); + if ( mfn_eq(mfn, INVALID_MFN) ) goto out; + l2t = map_xen_pagetable_new(mfn); + if ( locking ) spin_lock(&map_pgdir_lock); if ( !(l3e_get_flags(*pl3e) & _PAGE_PRESENT) ) { clear_page(l2t); - l3e_write(pl3e, l3e_from_paddr(__pa(l2t), __PAGE_HYPERVISOR)); + l3e_write(pl3e, l3e_from_mfn(mfn, __PAGE_HYPERVISOR)); + pl2e = l2t + l2_table_offset(v); l2t = NULL; } if ( locking ) spin_unlock(&map_pgdir_lock); + if ( l2t ) - free_xen_pagetable(l2t); + { + ASSERT(!pl2e); + ASSERT(!mfn_eq(mfn, INVALID_MFN)); + UNMAP_XEN_PAGETABLE_NEW(l2t); + free_xen_pagetable_new(mfn); + } } BUG_ON(l3e_get_flags(*pl3e) & _PAGE_PSE); - pl2e = l3e_to_l2e(*pl3e) + l2_table_offset(v); + + if ( !pl2e ) + { + ASSERT(l3e_get_flags(*pl3e) & _PAGE_PRESENT); + pl2e = (l2_pgentry_t *)map_xen_pagetable_new(l3e_get_mfn(*pl3e)) + + l2_table_offset(v); + } out: UNMAP_XEN_PAGETABLE_NEW(pl3e); @@ -4994,10 +5015,11 @@ static l2_pgentry_t *virt_to_xen_l2e(unsigned long v) l1_pgentry_t *virt_to_xen_l1e(unsigned long v) { l2_pgentry_t *pl2e; + l1_pgentry_t *pl1e = NULL; pl2e = virt_to_xen_l2e(v); if ( !pl2e ) - return NULL; + goto out; if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) ) { @@ -5005,7 +5027,7 @@ l1_pgentry_t *virt_to_xen_l1e(unsigned long v) l1_pgentry_t *l1t = alloc_xen_pagetable(); if ( !l1t ) - return NULL; + goto out; if ( locking ) spin_lock(&map_pgdir_lock); if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) ) @@ -5021,7 +5043,11 @@ l1_pgentry_t *virt_to_xen_l1e(unsigned long v) } BUG_ON(l2e_get_flags(*pl2e) & _PAGE_PSE); - return l2e_to_l1e(*pl2e) + l1_table_offset(v); + pl1e = l2e_to_l1e(*pl2e) + l1_table_offset(v); + + out: + UNMAP_XEN_PAGETABLE_NEW(pl2e); + return pl1e; } /* Convert to from superpage-mapping flags for map_pages_to_xen(). */ @@ -5045,7 +5071,7 @@ int map_pages_to_xen( { bool locking = system_state > SYS_STATE_boot; l3_pgentry_t *pl3e = NULL, ol3e; - l2_pgentry_t *pl2e, ol2e; + l2_pgentry_t *pl2e = NULL, ol2e; l1_pgentry_t *pl1e, ol1e; unsigned int i; int rc = -ENOMEM; @@ -5421,6 +5447,7 @@ int map_pages_to_xen( spin_unlock(&map_pgdir_lock); } end_of_loop: + UNMAP_XEN_PAGETABLE_NEW(pl2e); UNMAP_XEN_PAGETABLE_NEW(pl3e); } @@ -5429,6 +5456,7 @@ int map_pages_to_xen( rc = 0; out: + UNMAP_XEN_PAGETABLE_NEW(pl2e); UNMAP_XEN_PAGETABLE_NEW(pl3e); return rc; } From patchwork Mon Sep 30 10:33:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166407 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DBE181709 for ; Mon, 30 Sep 2019 10:35:54 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B770A21855 for ; Mon, 30 Sep 2019 10:35:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="mGRMEXPe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B770A21855 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0m-00077h-DM; Mon, 30 Sep 2019 10:34:36 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0k-00076Z-Sg for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:34:34 +0000 X-Inumbo-ID: df2000d2-e36d-11e9-96cc-12813bfff9fa Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id df2000d2-e36d-11e9-96cc-12813bfff9fa; Mon, 30 Sep 2019 10:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839664; x=1601375664; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=oJedWuo8zlV2fAKG2dDdFVDd+2/P/qJmMMw67NRF0oI=; b=mGRMEXPeBq6JMhi6xbZNzHNhngOKswEGilijwn0JUKVxJPV72QIsIHfW oizwQtVJmsTfkurUV62QMvADRqkprAq/WMdEYapKA7Sr4SH55CoMptX99 oDT4wJHNaTndDxxNiadgd5X8baiOPuswW19zoT4qFKuu0gWgwzOPpjloA Q=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="424630064" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-98acfc19.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:24 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-98acfc19.us-east-1.amazon.com (Postfix) with ESMTPS id 69BC2A1840; Mon, 30 Sep 2019 10:34:22 +0000 (UTC) Received: from EX13D10UEE001.ant.amazon.com (10.43.62.201) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:03 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D10UEE001.ant.amazon.com (10.43.62.201) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:02 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:02 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:07 +0100 Message-ID: <18d6bbf165484f7e97a03fed849cdca77f2842af.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 15/55] x86/mm: rewrite virt_to_xen_l1e X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Rewrite this function to use new APIs. Modify its callers to unmap the pointer returned. Signed-off-by: Wei Liu --- xen/arch/x86/domain_page.c | 10 ++++++---- xen/arch/x86/mm.c | 30 +++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c index 4a07cfb18e..24083e9a86 100644 --- a/xen/arch/x86/domain_page.c +++ b/xen/arch/x86/domain_page.c @@ -333,21 +333,23 @@ void unmap_domain_page_global(const void *ptr) mfn_t domain_page_map_to_mfn(const void *ptr) { unsigned long va = (unsigned long)ptr; - const l1_pgentry_t *pl1e; + l1_pgentry_t l1e; if ( va >= DIRECTMAP_VIRT_START ) return _mfn(virt_to_mfn(ptr)); if ( va >= VMAP_VIRT_START && va < VMAP_VIRT_END ) { - pl1e = virt_to_xen_l1e(va); + l1_pgentry_t *pl1e = virt_to_xen_l1e(va); BUG_ON(!pl1e); + l1e = *pl1e; + UNMAP_XEN_PAGETABLE_NEW(pl1e); } else { ASSERT(va >= MAPCACHE_VIRT_START && va < MAPCACHE_VIRT_END); - pl1e = &__linear_l1_table[l1_linear_offset(va)]; + l1e = __linear_l1_table[l1_linear_offset(va)]; } - return l1e_get_mfn(*pl1e); + return l1e_get_mfn(l1e); } diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index ad0d7a0b80..f7fd0e6bad 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5024,26 +5024,44 @@ l1_pgentry_t *virt_to_xen_l1e(unsigned long v) if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) ) { bool locking = system_state > SYS_STATE_boot; - l1_pgentry_t *l1t = alloc_xen_pagetable(); + l1_pgentry_t *l1t; + mfn_t mfn; - if ( !l1t ) + mfn = alloc_xen_pagetable_new(); + if ( mfn_eq(mfn, INVALID_MFN) ) goto out; + + l1t = map_xen_pagetable_new(mfn); + if ( locking ) spin_lock(&map_pgdir_lock); if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) ) { clear_page(l1t); - l2e_write(pl2e, l2e_from_paddr(__pa(l1t), __PAGE_HYPERVISOR)); + l2e_write(pl2e, l2e_from_mfn(mfn, __PAGE_HYPERVISOR)); + pl1e = l1t + l1_table_offset(v); l1t = NULL; } if ( locking ) spin_unlock(&map_pgdir_lock); + if ( l1t ) - free_xen_pagetable(l1t); + { + ASSERT(!pl1e); + ASSERT(!mfn_eq(mfn, INVALID_MFN)); + UNMAP_XEN_PAGETABLE_NEW(l1t); + free_xen_pagetable_new(mfn); + } } BUG_ON(l2e_get_flags(*pl2e) & _PAGE_PSE); - pl1e = l2e_to_l1e(*pl2e) + l1_table_offset(v); + + if ( !pl1e ) + { + ASSERT(l2e_get_flags(*pl2e) & _PAGE_PRESENT); + pl1e = (l1_pgentry_t *)map_xen_pagetable_new(l2e_get_mfn(*pl2e)) + + l1_table_offset(v); + } out: UNMAP_XEN_PAGETABLE_NEW(pl2e); @@ -5447,6 +5465,7 @@ int map_pages_to_xen( spin_unlock(&map_pgdir_lock); } end_of_loop: + UNMAP_XEN_PAGETABLE_NEW(pl1e); UNMAP_XEN_PAGETABLE_NEW(pl2e); UNMAP_XEN_PAGETABLE_NEW(pl3e); } @@ -5456,6 +5475,7 @@ int map_pages_to_xen( rc = 0; out: + UNMAP_XEN_PAGETABLE_NEW(pl1e); UNMAP_XEN_PAGETABLE_NEW(pl2e); UNMAP_XEN_PAGETABLE_NEW(pl3e); return rc; From patchwork Mon Sep 30 10:33:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166439 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9EAB216B1 for ; Mon, 30 Sep 2019 10:36:35 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7AEC920679 for ; Mon, 30 Sep 2019 10:36:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="QQN2UZy+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7AEC920679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1v-0000Qy-IP; Mon, 30 Sep 2019 10:35:47 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1t-0000NT-TY for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:45 +0000 X-Inumbo-ID: 0ed47cf5-e36e-11e9-96cd-12813bfff9fa Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 0ed47cf5-e36e-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:35:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839745; x=1601375745; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=JW1mEkfXYjbs9OD1jt/4mHgboEXE6nCGeRdIpKSOO9s=; b=QQN2UZy+dsE9k03t6fqOO1qoHafIB2w4IWMohHEVU/70182Hf8zu4Ykn EctYrl7hTCPszeTySIozwf8oOFs/C1wJrpfYx87y/snOOTuFIV65nm9Lr mXoxGHJdNovWzsYjcX1NzfujZ8uiTotjEN49ppAO0Hp36krS9Ssbc0/tq 4=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="838005589" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1a-7d76a15f.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 30 Sep 2019 10:34:45 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-7d76a15f.us-east-1.amazon.com (Postfix) with ESMTPS id 6A48AA21D8; Mon, 30 Sep 2019 10:34:33 +0000 (UTC) Received: from EX13D28EUC003.ant.amazon.com (10.43.164.43) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:06 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D28EUC003.ant.amazon.com (10.43.164.43) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:04 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:03 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:08 +0100 Message-ID: <5bb7b5c4b8a16faf3a68185d7ae042a169085e55.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 16/55] x86/mm: switch to new APIs in map_pages_to_xen X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Hongyan Xia , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Page tables allocated in that function should be mapped and unmapped now. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- Changed since v1: * remove redundant lines --- xen/arch/x86/mm.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index f7fd0e6bad..5bb86935f4 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5185,6 +5185,7 @@ int map_pages_to_xen( unsigned int flush_flags = FLUSH_TLB | FLUSH_ORDER(2 * PAGETABLE_ORDER); l2_pgentry_t *l2t; + mfn_t l2t_mfn; /* Skip this PTE if there is no change. */ if ( ((l3e_get_pfn(ol3e) & ~(L2_PAGETABLE_ENTRIES * @@ -5206,13 +5207,15 @@ int map_pages_to_xen( goto end_of_loop; } - l2t = alloc_xen_pagetable(); - if ( l2t == NULL ) + l2t_mfn = alloc_xen_pagetable_new(); + if ( mfn_eq(l2t_mfn, INVALID_MFN) ) { ASSERT(rc == -ENOMEM); goto out; } + l2t = map_xen_pagetable_new(l2t_mfn); + for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) l2e_write(l2t + i, l2e_from_pfn(l3e_get_pfn(ol3e) + @@ -5227,15 +5230,18 @@ int map_pages_to_xen( if ( (l3e_get_flags(*pl3e) & _PAGE_PRESENT) && (l3e_get_flags(*pl3e) & _PAGE_PSE) ) { - l3e_write_atomic(pl3e, l3e_from_mfn(virt_to_mfn(l2t), - __PAGE_HYPERVISOR)); - l2t = NULL; + l3e_write_atomic(pl3e, + l3e_from_mfn(l2t_mfn, __PAGE_HYPERVISOR)); + UNMAP_XEN_PAGETABLE_NEW(l2t); } if ( locking ) spin_unlock(&map_pgdir_lock); flush_area(virt, flush_flags); if ( l2t ) - free_xen_pagetable(l2t); + { + UNMAP_XEN_PAGETABLE_NEW(l2t); + free_xen_pagetable_new(l2t_mfn); + } } pl2e = virt_to_xen_l2e(virt); @@ -5298,6 +5304,7 @@ int map_pages_to_xen( unsigned int flush_flags = FLUSH_TLB | FLUSH_ORDER(PAGETABLE_ORDER); l1_pgentry_t *l1t; + mfn_t l1t_mfn; /* Skip this PTE if there is no change. */ if ( (((l2e_get_pfn(*pl2e) & ~(L1_PAGETABLE_ENTRIES - 1)) + @@ -5317,13 +5324,15 @@ int map_pages_to_xen( goto check_l3; } - l1t = alloc_xen_pagetable(); - if ( l1t == NULL ) + l1t_mfn = alloc_xen_pagetable_new(); + if ( mfn_eq(l1t_mfn, INVALID_MFN) ) { ASSERT(rc == -ENOMEM); goto out; } + l1t = map_xen_pagetable_new(l1t_mfn); + for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) l1e_write(&l1t[i], l1e_from_pfn(l2e_get_pfn(*pl2e) + i, @@ -5337,15 +5346,18 @@ int map_pages_to_xen( if ( (l2e_get_flags(*pl2e) & _PAGE_PRESENT) && (l2e_get_flags(*pl2e) & _PAGE_PSE) ) { - l2e_write_atomic(pl2e, l2e_from_mfn(virt_to_mfn(l1t), + l2e_write_atomic(pl2e, l2e_from_mfn(l1t_mfn, __PAGE_HYPERVISOR)); - l1t = NULL; + UNMAP_XEN_PAGETABLE_NEW(l1t); } if ( locking ) spin_unlock(&map_pgdir_lock); flush_area(virt, flush_flags); if ( l1t ) - free_xen_pagetable(l1t); + { + UNMAP_XEN_PAGETABLE_NEW(l1t); + free_xen_pagetable_new(l1t_mfn); + } } pl1e = l2e_to_l1e(*pl2e) + l1_table_offset(virt); From patchwork Mon Sep 30 10:33:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166465 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C94FF13BD for ; Mon, 30 Sep 2019 10:37:05 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A4B4221A4A for ; Mon, 30 Sep 2019 10:37:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="R/+wm0m/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4B4221A4A Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2S-0001SG-GI; Mon, 30 Sep 2019 10:36:20 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2Q-0001Pi-TJ for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:36:18 +0000 X-Inumbo-ID: 0eb28838-e36e-11e9-8628-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 0eb28838-e36e-11e9-8628-bc764e2007e4; Mon, 30 Sep 2019 10:35:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839744; x=1601375744; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=SS0f3zuZ4ltH/WUPJ9Ye+o8RgJZJ0qn7mK/0DOMB//E=; b=R/+wm0m/y+ffz8VZ8wVNqCAIRo7FRPZw7XMRCm7G/Se0J8irqil69me6 9WRXvpdGECT//yi7LIUjjCxOb6+8gaa2J/u1EjTCdLrklKxl3+1TR62Fu ue16/IZSNSx+ulu/vViOp/HzDUcxf68/Pl5F10t6KUFSNprAETIXTgAYI 8=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="838005587" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1a-7d76a15f.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 30 Sep 2019 10:34:44 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-7d76a15f.us-east-1.amazon.com (Postfix) with ESMTPS id E45CAA123B; Mon, 30 Sep 2019 10:34:31 +0000 (UTC) Received: from EX13D14UEE001.ant.amazon.com (10.43.62.238) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:06 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D14UEE001.ant.amazon.com (10.43.62.238) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:05 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:04 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:09 +0100 Message-ID: <2ab0430ed5105bf946116dcadff3a14479f9a795.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 17/55] x86/mm: drop lXe_to_lYe invocations in map_pages_to_xen X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Map and unmap page tables where necessary. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 5bb86935f4..08af71a261 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5141,8 +5141,10 @@ int map_pages_to_xen( else { l2_pgentry_t *l2t; + mfn_t l2t_mfn = l3e_get_mfn(ol3e); + + l2t = map_xen_pagetable_new(l2t_mfn); - l2t = l3e_to_l2e(ol3e); for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) { ol2e = l2t[i]; @@ -5154,10 +5156,12 @@ int map_pages_to_xen( { unsigned int j; l1_pgentry_t *l1t; + mfn_t l1t_mfn = l2e_get_mfn(ol2e); - l1t = l2e_to_l1e(ol2e); + l1t = map_xen_pagetable_new(l1t_mfn); for ( j = 0; j < L1_PAGETABLE_ENTRIES; j++ ) flush_flags(l1e_get_flags(l1t[j])); + UNMAP_XEN_PAGETABLE_NEW(l1t); } } flush_area(virt, flush_flags); @@ -5166,9 +5170,9 @@ int map_pages_to_xen( ol2e = l2t[i]; if ( (l2e_get_flags(ol2e) & _PAGE_PRESENT) && !(l2e_get_flags(ol2e) & _PAGE_PSE) ) - free_xen_pagetable(l2e_to_l1e(ol2e)); + free_xen_pagetable_new(l2e_get_mfn(ol2e)); } - free_xen_pagetable(l2t); + free_xen_pagetable_new(l2t_mfn); } } @@ -5273,12 +5277,14 @@ int map_pages_to_xen( else { l1_pgentry_t *l1t; + mfn_t l1t_mfn = l2e_get_mfn(ol2e); - l1t = l2e_to_l1e(ol2e); + l1t = map_xen_pagetable_new(l1t_mfn); for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) flush_flags(l1e_get_flags(l1t[i])); flush_area(virt, flush_flags); - free_xen_pagetable(l1t); + UNMAP_XEN_PAGETABLE_NEW(l1t); + free_xen_pagetable_new(l1t_mfn); } } @@ -5292,12 +5298,14 @@ int map_pages_to_xen( /* Normal page mapping. */ if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) ) { + /* XXX This forces page table to be populated */ pl1e = virt_to_xen_l1e(virt); if ( pl1e == NULL ) { ASSERT(rc == -ENOMEM); goto out; } + UNMAP_XEN_PAGETABLE_NEW(pl1e); } else if ( l2e_get_flags(*pl2e) & _PAGE_PSE ) { @@ -5360,9 +5368,11 @@ int map_pages_to_xen( } } - pl1e = l2e_to_l1e(*pl2e) + l1_table_offset(virt); + pl1e = map_xen_pagetable_new(l2e_get_mfn((*pl2e))); + pl1e += l1_table_offset(virt); ol1e = *pl1e; l1e_write_atomic(pl1e, l1e_from_mfn(mfn, flags)); + UNMAP_XEN_PAGETABLE_NEW(pl1e); if ( (l1e_get_flags(ol1e) & _PAGE_PRESENT) ) { unsigned int flush_flags = FLUSH_TLB | FLUSH_ORDER(0); @@ -5383,6 +5393,7 @@ int map_pages_to_xen( { unsigned long base_mfn; l1_pgentry_t *l1t; + mfn_t l1t_mfn; if ( locking ) spin_lock(&map_pgdir_lock); @@ -5406,12 +5417,15 @@ int map_pages_to_xen( goto check_l3; } - l1t = l2e_to_l1e(ol2e); + l1t_mfn = l2e_get_mfn(ol2e); + l1t = map_xen_pagetable_new(l1t_mfn); + base_mfn = l1e_get_pfn(l1t[0]) & ~(L1_PAGETABLE_ENTRIES - 1); for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) if ( (l1e_get_pfn(l1t[i]) != (base_mfn + i)) || (l1e_get_flags(l1t[i]) != flags) ) break; + UNMAP_XEN_PAGETABLE_NEW(l1t); if ( i == L1_PAGETABLE_ENTRIES ) { l2e_write_atomic(pl2e, l2e_from_pfn(base_mfn, @@ -5421,7 +5435,7 @@ int map_pages_to_xen( flush_area(virt - PAGE_SIZE, FLUSH_TLB_GLOBAL | FLUSH_ORDER(PAGETABLE_ORDER)); - free_xen_pagetable(l2e_to_l1e(ol2e)); + free_xen_pagetable_new(l1t_mfn); } else if ( locking ) spin_unlock(&map_pgdir_lock); @@ -5437,6 +5451,7 @@ int map_pages_to_xen( { unsigned long base_mfn; l2_pgentry_t *l2t; + mfn_t l2t_mfn; if ( locking ) spin_lock(&map_pgdir_lock); @@ -5454,7 +5469,9 @@ int map_pages_to_xen( goto end_of_loop; } - l2t = l3e_to_l2e(ol3e); + l2t_mfn = l3e_get_mfn(ol3e); + l2t = map_xen_pagetable_new(l2t_mfn); + base_mfn = l2e_get_pfn(l2t[0]) & ~(L2_PAGETABLE_ENTRIES * L1_PAGETABLE_ENTRIES - 1); for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) @@ -5462,6 +5479,7 @@ int map_pages_to_xen( (base_mfn + (i << PAGETABLE_ORDER))) || (l2e_get_flags(l2t[i]) != l1f_to_lNf(flags)) ) break; + UNMAP_XEN_PAGETABLE_NEW(l2t); if ( i == L2_PAGETABLE_ENTRIES ) { l3e_write_atomic(pl3e, l3e_from_pfn(base_mfn, @@ -5471,7 +5489,7 @@ int map_pages_to_xen( flush_area(virt - PAGE_SIZE, FLUSH_TLB_GLOBAL | FLUSH_ORDER(2*PAGETABLE_ORDER)); - free_xen_pagetable(l3e_to_l2e(ol3e)); + free_xen_pagetable_new(l2t_mfn); } else if ( locking ) spin_unlock(&map_pgdir_lock); From patchwork Mon Sep 30 10:33:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166399 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F165116B1 for ; Mon, 30 Sep 2019 10:35:50 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CC71121855 for ; Mon, 30 Sep 2019 10:35:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="PkvFeYfI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC71121855 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0p-0007AT-PN; Mon, 30 Sep 2019 10:34:39 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0o-00079n-Q4 for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:34:38 +0000 X-Inumbo-ID: e7467052-e36d-11e9-97fb-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id e7467052-e36d-11e9-97fb-bc764e2007e4; Mon, 30 Sep 2019 10:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839678; x=1601375678; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=5qUXGVLQZ6upgeYLGOcqRG0zacCJFu2/sQ3YGcsLoRs=; b=PkvFeYfI67HwtZ1Y48n3l6RTeP+T2OjW3dVElaVGHe97sobsmlXc8AKS 2sH9dODM6nx7sZD17eU7L44kMw+uZQscHNykWWCW4AXCNllTLBPXJxjaO Sn89ICIk0lcOItYi/jvJ0yBXoHcyU6PdtqcglreBQp8nZR4kUeGEysY+q Y=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="424630092" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-17c49630.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:38 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-17c49630.us-east-1.amazon.com (Postfix) with ESMTPS id 9D5C4A2289; Mon, 30 Sep 2019 10:34:36 +0000 (UTC) Received: from EX13D28EUB002.ant.amazon.com (10.43.166.97) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:08 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D28EUB002.ant.amazon.com (10.43.166.97) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:07 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:05 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:10 +0100 Message-ID: <4a6cbcbb473bcedb50585e1a6d35f1390f8fa0d8.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 18/55] x86/mm: switch to new APIs in modify_xen_mappings X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Hongyan Xia , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Page tables allocated in that function should be mapped and unmapped now. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- Changed since v1: * remove redundant lines --- xen/arch/x86/mm.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 08af71a261..a812ef0244 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5562,6 +5562,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) if ( l3e_get_flags(*pl3e) & _PAGE_PSE ) { l2_pgentry_t *l2t; + mfn_t mfn; if ( l2_table_offset(v) == 0 && l1_table_offset(v) == 0 && @@ -5578,13 +5579,15 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) } /* PAGE1GB: shatter the superpage and fall through. */ - l2t = alloc_xen_pagetable(); - if ( !l2t ) + mfn = alloc_xen_pagetable_new(); + if ( mfn_eq(mfn, INVALID_MFN) ) { ASSERT(rc == -ENOMEM); goto out; } + l2t = map_xen_pagetable_new(mfn); + for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) l2e_write(l2t + i, l2e_from_pfn(l3e_get_pfn(*pl3e) + @@ -5595,14 +5598,16 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) if ( (l3e_get_flags(*pl3e) & _PAGE_PRESENT) && (l3e_get_flags(*pl3e) & _PAGE_PSE) ) { - l3e_write_atomic(pl3e, l3e_from_mfn(virt_to_mfn(l2t), - __PAGE_HYPERVISOR)); - l2t = NULL; + l3e_write_atomic(pl3e, l3e_from_mfn(mfn, __PAGE_HYPERVISOR)); + UNMAP_XEN_PAGETABLE_NEW(l2t); } if ( locking ) spin_unlock(&map_pgdir_lock); if ( l2t ) - free_xen_pagetable(l2t); + { + UNMAP_XEN_PAGETABLE_NEW(l2t); + free_xen_pagetable_new(mfn); + } } /* @@ -5637,15 +5642,18 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) else { l1_pgentry_t *l1t; + mfn_t mfn; /* PSE: shatter the superpage and try again. */ - l1t = alloc_xen_pagetable(); - if ( !l1t ) + mfn = alloc_xen_pagetable_new(); + if ( mfn_eq(mfn, INVALID_MFN) ) { ASSERT(rc == -ENOMEM); goto out; } + l1t = map_xen_pagetable_new(mfn); + for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) l1e_write(&l1t[i], l1e_from_pfn(l2e_get_pfn(*pl2e) + i, @@ -5655,14 +5663,17 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) if ( (l2e_get_flags(*pl2e) & _PAGE_PRESENT) && (l2e_get_flags(*pl2e) & _PAGE_PSE) ) { - l2e_write_atomic(pl2e, l2e_from_mfn(virt_to_mfn(l1t), + l2e_write_atomic(pl2e, l2e_from_mfn(mfn, __PAGE_HYPERVISOR)); - l1t = NULL; + UNMAP_XEN_PAGETABLE_NEW(l1t); } if ( locking ) spin_unlock(&map_pgdir_lock); if ( l1t ) - free_xen_pagetable(l1t); + { + UNMAP_XEN_PAGETABLE_NEW(l1t); + free_xen_pagetable_new(mfn); + } } } else From patchwork Mon Sep 30 10:33:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166481 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8ED9713BD for ; Mon, 30 Sep 2019 10:37:32 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6B6E020679 for ; Mon, 30 Sep 2019 10:37:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="dpmakhl0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B6E020679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2s-0002FP-38; Mon, 30 Sep 2019 10:36:46 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2q-0002BE-16 for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:36:44 +0000 X-Inumbo-ID: 1e2d6d28-e36e-11e9-bf31-bc764e2007e4 Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id 1e2d6d28-e36e-11e9-bf31-bc764e2007e4; Mon, 30 Sep 2019 10:36:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839771; x=1601375771; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=lp/VfoF5NsDrDIRobgIPxhb/BzbxkSd1H84AiLy8DFw=; b=dpmakhl0Kzfn5qZy3C4clEXOUlJ1Jikjms7BXN9QrtGq5fqO97nFI/mn 1GgFFI9Rx0cuegoWThUAu32+w/FHCLOESDXgxdXaP50Pc3+D6Kyjbdwsw 5tdFQe0TfBGeP+5sW2ygsXLLa+LElYTOzwBCGhovCxodHgADaZU7Wk4e0 8=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="705521320" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1d-2c665b5d.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 30 Sep 2019 10:34:53 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-2c665b5d.us-east-1.amazon.com (Postfix) with ESMTPS id D8F54A1F0A; Mon, 30 Sep 2019 10:34:36 +0000 (UTC) Received: from EX13D08UEE003.ant.amazon.com (10.43.62.118) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:08 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D08UEE003.ant.amazon.com (10.43.62.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:08 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:07 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:11 +0100 Message-ID: <32da0ad0d6bdfe050258d4a5013795480d116f6e.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 19/55] x86/mm: drop lXe_to_lYe invocations from modify_xen_mappings X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index a812ef0244..6fb8c92543 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5532,8 +5532,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) { bool locking = system_state > SYS_STATE_boot; l3_pgentry_t *pl3e = NULL; - l2_pgentry_t *pl2e; - l1_pgentry_t *pl1e; + l2_pgentry_t *pl2e = NULL; unsigned int i; unsigned long v = s; int rc = -ENOMEM; @@ -5614,7 +5613,8 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) * The L3 entry has been verified to be present, and we've dealt with * 1G pages as well, so the L2 table cannot require allocation. */ - pl2e = l3e_to_l2e(*pl3e) + l2_table_offset(v); + pl2e = map_xen_pagetable_new(l3e_get_mfn(*pl3e)); + pl2e += l2_table_offset(v); if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) ) { @@ -5678,14 +5678,16 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) } else { - l1_pgentry_t nl1e, *l1t; + l1_pgentry_t nl1e, *l1t, *pl1e; + mfn_t l1t_mfn; /* * Ordinary 4kB mapping: The L2 entry has been verified to be * present, and we've dealt with 2M pages as well, so the L1 table * cannot require allocation. */ - pl1e = l2e_to_l1e(*pl2e) + l1_table_offset(v); + pl1e = map_xen_pagetable_new(l2e_get_mfn(*pl2e)); + pl1e += l1_table_offset(v); /* Confirm the caller isn't trying to create new mappings. */ if ( !(l1e_get_flags(*pl1e) & _PAGE_PRESENT) ) @@ -5696,6 +5698,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) (l1e_get_flags(*pl1e) & ~FLAGS_MASK) | nf); l1e_write_atomic(pl1e, nl1e); + UNMAP_XEN_PAGETABLE_NEW(pl1e); v += PAGE_SIZE; /* @@ -5725,10 +5728,12 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) goto end_of_loop; } - l1t = l2e_to_l1e(*pl2e); + l1t_mfn = l2e_get_mfn(*pl2e); + l1t = map_xen_pagetable_new(l1t_mfn); for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) if ( l1e_get_intpte(l1t[i]) != 0 ) break; + UNMAP_XEN_PAGETABLE_NEW(l1t); if ( i == L1_PAGETABLE_ENTRIES ) { /* Empty: zap the L2E and free the L1 page. */ @@ -5736,7 +5741,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) if ( locking ) spin_unlock(&map_pgdir_lock); flush_area(NULL, FLUSH_TLB_GLOBAL); /* flush before free */ - free_xen_pagetable(l1t); + free_xen_pagetable_new(l1t_mfn); } else if ( locking ) spin_unlock(&map_pgdir_lock); @@ -5767,11 +5772,14 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) { l2_pgentry_t *l2t; + mfn_t l2t_mfn; - l2t = l3e_to_l2e(*pl3e); + l2t_mfn = l3e_get_mfn(*pl3e); + l2t = map_xen_pagetable_new(l2t_mfn); for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) if ( l2e_get_intpte(l2t[i]) != 0 ) break; + UNMAP_XEN_PAGETABLE_NEW(l2t); if ( i == L2_PAGETABLE_ENTRIES ) { /* Empty: zap the L3E and free the L2 page. */ @@ -5779,12 +5787,13 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) if ( locking ) spin_unlock(&map_pgdir_lock); flush_area(NULL, FLUSH_TLB_GLOBAL); /* flush before free */ - free_xen_pagetable(l2t); + free_xen_pagetable_new(l2t_mfn); } else if ( locking ) spin_unlock(&map_pgdir_lock); } end_of_loop: + UNMAP_XEN_PAGETABLE_NEW(pl2e); UNMAP_XEN_PAGETABLE_NEW(pl3e); } @@ -5794,6 +5803,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) rc = 0; out: + UNMAP_XEN_PAGETABLE_NEW(pl2e); UNMAP_XEN_PAGETABLE_NEW(pl3e); return rc; } From patchwork Mon Sep 30 10:33:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166409 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 349E913BD for ; Mon, 30 Sep 2019 10:35:56 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 113FD21855 for ; Mon, 30 Sep 2019 10:35:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="hlt7NrO7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 113FD21855 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0v-0007FG-E7; Mon, 30 Sep 2019 10:34:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0t-0007Df-Qy for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:34:43 +0000 X-Inumbo-ID: e77f60c4-e36d-11e9-97fb-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id e77f60c4-e36d-11e9-97fb-bc764e2007e4; Mon, 30 Sep 2019 10:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839678; x=1601375678; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=nHlDLoGw/1YR58cRbIoTIBNc4eFjZOJefaEjsYgn0Jw=; b=hlt7NrO7P6tREqUN5leH4/be3qeCPQ6eKbHPS7A4B+e5sf2G0rU/f3SL 9zfLeATa1xZVE0/ZW57KLeiY+W09YStStK6TzKc48p67jQb+dOt4L8/hV amICYVfFHynD2Zx/2UDWXtYt1MknO7gsfj2om/b+rCBE8JSqENCGHcTsp A=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="424630094" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-17c49630.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:38 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-17c49630.us-east-1.amazon.com (Postfix) with ESMTPS id 25BCDA2289; Mon, 30 Sep 2019 10:34:38 +0000 (UTC) Received: from EX13D12UEE003.ant.amazon.com (10.43.62.198) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:09 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D12UEE003.ant.amazon.com (10.43.62.198) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:09 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:08 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:12 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 20/55] x86/mm: switch to new APIs in arch_init_memory X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 6fb8c92543..8706dc0174 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -353,19 +353,22 @@ void __init arch_init_memory(void) ASSERT(root_pgt_pv_xen_slots < ROOT_PAGETABLE_PV_XEN_SLOTS); if ( l4_table_offset(split_va) == l4_table_offset(split_va - 1) ) { - l3_pgentry_t *l3tab = alloc_xen_pagetable(); + mfn_t l3tab_mfn = alloc_xen_pagetable_new(); - if ( l3tab ) + if ( !mfn_eq(l3tab_mfn, INVALID_MFN) ) { - const l3_pgentry_t *l3idle = - l4e_to_l3e(idle_pg_table[l4_table_offset(split_va)]); + l3_pgentry_t *l3idle = + map_xen_pagetable_new( + l4e_get_mfn(idle_pg_table[l4_table_offset(split_va)])); + l3_pgentry_t *l3tab = map_xen_pagetable_new(l3tab_mfn); for ( i = 0; i < l3_table_offset(split_va); ++i ) l3tab[i] = l3idle[i]; for ( ; i < L3_PAGETABLE_ENTRIES; ++i ) l3tab[i] = l3e_empty(); - split_l4e = l4e_from_mfn(virt_to_mfn(l3tab), - __PAGE_HYPERVISOR_RW); + split_l4e = l4e_from_mfn(l3tab_mfn, __PAGE_HYPERVISOR_RW); + UNMAP_XEN_PAGETABLE_NEW(l3idle); + UNMAP_XEN_PAGETABLE_NEW(l3tab); } else ++root_pgt_pv_xen_slots; From patchwork Mon Sep 30 10:33:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166387 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5152016B1 for ; Mon, 30 Sep 2019 10:35:40 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2D78C2190F for ; Mon, 30 Sep 2019 10:35:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="FqQbFs2F" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D78C2190F Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt10-0007LL-Dg; Mon, 30 Sep 2019 10:34:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0y-0007JV-Q5 for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:34:48 +0000 X-Inumbo-ID: e8832596-e36d-11e9-8628-bc764e2007e4 Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id e8832596-e36d-11e9-8628-bc764e2007e4; Mon, 30 Sep 2019 10:34:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839680; x=1601375680; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=/Z9WKLMpqFRozBiJpqcif/gsXhYneDnuhvjAsJE3mek=; b=FqQbFs2FzyYtdIgMyTS8OjPjkHYXjP0HzZOdIy68wpwEQxF4HPU3Jqtp rOHqJgndDWChCUiQgCIN+gWX0MwlrGprUXdzF+6oe1fKruPRTwY+VGBz+ 2+e20f8Sw1SYWqib0arhKDrvVWIAtxtVQxg9dB8e2rM/TRvmDMZodrQ58 Q=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="788414671" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-474bcd9f.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 30 Sep 2019 10:34:40 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1d-474bcd9f.us-east-1.amazon.com (Postfix) with ESMTPS id BD8A8A3108; Mon, 30 Sep 2019 10:34:38 +0000 (UTC) Received: from EX13D18UEE003.ant.amazon.com (10.43.62.169) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:10 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D18UEE003.ant.amazon.com (10.43.62.169) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:10 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:09 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:13 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 21/55] x86_64/mm: introduce pl2e in paging_init X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Introduce pl2e so that we can use l2_ro_mpt to point to the page table itself. No functional change. Signed-off-by: Wei Liu --- xen/arch/x86/x86_64/mm.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 795a467462..ac5e366e5b 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -497,7 +497,7 @@ void __init paging_init(void) unsigned long i, mpt_size, va; unsigned int n, memflags; l3_pgentry_t *l3_ro_mpt; - l2_pgentry_t *l2_ro_mpt = NULL; + l2_pgentry_t *pl2e = NULL, *l2_ro_mpt; struct page_info *l1_pg; /* @@ -547,7 +547,7 @@ void __init paging_init(void) (L2_PAGETABLE_SHIFT - 3 + PAGE_SHIFT))); if ( cpu_has_page1gb && - !((unsigned long)l2_ro_mpt & ~PAGE_MASK) && + !((unsigned long)pl2e & ~PAGE_MASK) && (mpt_size >> L3_PAGETABLE_SHIFT) > (i >> PAGETABLE_ORDER) ) { unsigned int k, holes; @@ -607,7 +607,7 @@ void __init paging_init(void) memset((void *)(RDWR_MPT_VIRT_START + (i << L2_PAGETABLE_SHIFT)), 0xFF, 1UL << L2_PAGETABLE_SHIFT); } - if ( !((unsigned long)l2_ro_mpt & ~PAGE_MASK) ) + if ( !((unsigned long)pl2e & ~PAGE_MASK) ) { if ( (l2_ro_mpt = alloc_xen_pagetable()) == NULL ) goto nomem; @@ -615,13 +615,14 @@ void __init paging_init(void) l3e_write(&l3_ro_mpt[l3_table_offset(va)], l3e_from_paddr(__pa(l2_ro_mpt), __PAGE_HYPERVISOR_RO | _PAGE_USER)); + pl2e = l2_ro_mpt; ASSERT(!l2_table_offset(va)); } /* NB. Cannot be GLOBAL: guest user mode should not see it. */ if ( l1_pg ) - l2e_write(l2_ro_mpt, l2e_from_page( + l2e_write(pl2e, l2e_from_page( l1_pg, /*_PAGE_GLOBAL|*/_PAGE_PSE|_PAGE_USER|_PAGE_PRESENT)); - l2_ro_mpt++; + pl2e++; } #undef CNT #undef MFN @@ -637,7 +638,8 @@ void __init paging_init(void) clear_page(l2_ro_mpt); l3e_write(&l3_ro_mpt[l3_table_offset(HIRO_COMPAT_MPT_VIRT_START)], l3e_from_paddr(__pa(l2_ro_mpt), __PAGE_HYPERVISOR_RO)); - l2_ro_mpt += l2_table_offset(HIRO_COMPAT_MPT_VIRT_START); + pl2e = l2_ro_mpt; + pl2e += l2_table_offset(HIRO_COMPAT_MPT_VIRT_START); /* Allocate and map the compatibility mode machine-to-phys table. */ mpt_size = (mpt_size >> 1) + (1UL << (L2_PAGETABLE_SHIFT - 1)); if ( mpt_size > RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START ) @@ -650,7 +652,7 @@ void __init paging_init(void) sizeof(*compat_machine_to_phys_mapping)) BUILD_BUG_ON((sizeof(*frame_table) & ~sizeof(*frame_table)) % \ sizeof(*compat_machine_to_phys_mapping)); - for ( i = 0; i < (mpt_size >> L2_PAGETABLE_SHIFT); i++, l2_ro_mpt++ ) + for ( i = 0; i < (mpt_size >> L2_PAGETABLE_SHIFT); i++, pl2e++ ) { memflags = MEMF_node(phys_to_nid(i << (L2_PAGETABLE_SHIFT - 2 + PAGE_SHIFT))); @@ -672,7 +674,7 @@ void __init paging_init(void) (i << L2_PAGETABLE_SHIFT)), 0xFF, 1UL << L2_PAGETABLE_SHIFT); /* NB. Cannot be GLOBAL as the ptes get copied into per-VM space. */ - l2e_write(l2_ro_mpt, l2e_from_page(l1_pg, _PAGE_PSE|_PAGE_PRESENT)); + l2e_write(pl2e, l2e_from_page(l1_pg, _PAGE_PSE|_PAGE_PRESENT)); } #undef CNT #undef MFN From patchwork Mon Sep 30 10:33:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166413 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C5E4913BD for ; Mon, 30 Sep 2019 10:36:01 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A161020679 for ; Mon, 30 Sep 2019 10:36:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="CgF7X2YF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A161020679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0v-0007Em-2M; Mon, 30 Sep 2019 10:34:45 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0t-0007DY-ON for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:34:43 +0000 X-Inumbo-ID: ea28a326-e36d-11e9-96cd-12813bfff9fa Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id ea28a326-e36d-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:34:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839682; x=1601375682; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=3EOg3dJAoIOvXX3nZt4SmA/nnNSdMZ3kbqjFlTt2+MU=; b=CgF7X2YF+zT8TlrHL9dnFVAEzfFUjNP08lVVkbMykKHkL5xi6UZh7CfM rxySQ2S/CwZLkGRydfEDqBIpqYGMrgcvG+DDUMePdJit2GTERPOMs/8it 7A/c65L4OjTX8qjXUilbkM6+JxrdQxbX6szvEz/q/3xDso5fqrmOiDiMc I=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="418649854" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-7d76a15f.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:42 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-7d76a15f.us-east-1.amazon.com (Postfix) with ESMTPS id 740DFA11F4; Mon, 30 Sep 2019 10:34:41 +0000 (UTC) Received: from EX13D28EUC002.ant.amazon.com (10.43.164.254) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:13 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D28EUC002.ant.amazon.com (10.43.164.254) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:12 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:10 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:14 +0100 Message-ID: <4429f3d4cb3075d3dc2f30b3f8273e3620b8d995.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 22/55] x86_64/mm: switch to new APIs in paging_init X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Hongyan Xia , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- Changed since v1: * use a global mapping for compat_idle_pg_table_l2, otherwise l2_ro_mpt will unmap it. --- xen/arch/x86/x86_64/mm.c | 50 +++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index ac5e366e5b..c8c71564ba 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -496,9 +496,10 @@ void __init paging_init(void) { unsigned long i, mpt_size, va; unsigned int n, memflags; - l3_pgentry_t *l3_ro_mpt; - l2_pgentry_t *pl2e = NULL, *l2_ro_mpt; + l3_pgentry_t *l3_ro_mpt = NULL; + l2_pgentry_t *pl2e = NULL, *l2_ro_mpt = NULL; struct page_info *l1_pg; + mfn_t l3_ro_mpt_mfn, l2_ro_mpt_mfn; /* * We setup the L3s for 1:1 mapping if host support memory hotplug @@ -511,22 +512,29 @@ void __init paging_init(void) if ( !(l4e_get_flags(idle_pg_table[l4_table_offset(va)]) & _PAGE_PRESENT) ) { - l3_pgentry_t *pl3t = alloc_xen_pagetable(); + l3_pgentry_t *pl3t; + mfn_t mfn; - if ( !pl3t ) + mfn = alloc_xen_pagetable_new(); + if ( mfn_eq(mfn, INVALID_MFN) ) goto nomem; + + pl3t = map_xen_pagetable_new(mfn); clear_page(pl3t); l4e_write(&idle_pg_table[l4_table_offset(va)], - l4e_from_paddr(__pa(pl3t), __PAGE_HYPERVISOR_RW)); + l4e_from_mfn(mfn, __PAGE_HYPERVISOR_RW)); + UNMAP_XEN_PAGETABLE_NEW(pl3t); } } /* Create user-accessible L2 directory to map the MPT for guests. */ - if ( (l3_ro_mpt = alloc_xen_pagetable()) == NULL ) + l3_ro_mpt_mfn = alloc_xen_pagetable_new(); + if ( mfn_eq(l3_ro_mpt_mfn, INVALID_MFN) ) goto nomem; + l3_ro_mpt = map_xen_pagetable_new(l3_ro_mpt_mfn); clear_page(l3_ro_mpt); l4e_write(&idle_pg_table[l4_table_offset(RO_MPT_VIRT_START)], - l4e_from_paddr(__pa(l3_ro_mpt), __PAGE_HYPERVISOR_RO | _PAGE_USER)); + l4e_from_mfn(l3_ro_mpt_mfn, __PAGE_HYPERVISOR_RO | _PAGE_USER)); /* * Allocate and map the machine-to-phys table. @@ -609,12 +617,21 @@ void __init paging_init(void) } if ( !((unsigned long)pl2e & ~PAGE_MASK) ) { - if ( (l2_ro_mpt = alloc_xen_pagetable()) == NULL ) + /* + * Unmap l2_ro_mpt, which could've been mapped in previous + * iteration. + */ + unmap_xen_pagetable_new(l2_ro_mpt); + + l2_ro_mpt_mfn = alloc_xen_pagetable_new(); + if ( mfn_eq(l2_ro_mpt_mfn, INVALID_MFN) ) goto nomem; + + l2_ro_mpt = map_xen_pagetable_new(l2_ro_mpt_mfn); clear_page(l2_ro_mpt); l3e_write(&l3_ro_mpt[l3_table_offset(va)], - l3e_from_paddr(__pa(l2_ro_mpt), - __PAGE_HYPERVISOR_RO | _PAGE_USER)); + l3e_from_mfn(l2_ro_mpt_mfn, + __PAGE_HYPERVISOR_RO | _PAGE_USER)); pl2e = l2_ro_mpt; ASSERT(!l2_table_offset(va)); } @@ -626,18 +643,23 @@ void __init paging_init(void) } #undef CNT #undef MFN + UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); + UNMAP_XEN_PAGETABLE_NEW(l3_ro_mpt); /* Create user-accessible L2 directory to map the MPT for compat guests. */ BUILD_BUG_ON(l4_table_offset(RDWR_MPT_VIRT_START) != l4_table_offset(HIRO_COMPAT_MPT_VIRT_START)); l3_ro_mpt = l4e_to_l3e(idle_pg_table[l4_table_offset( HIRO_COMPAT_MPT_VIRT_START)]); - if ( (l2_ro_mpt = alloc_xen_pagetable()) == NULL ) + + l2_ro_mpt_mfn = alloc_xen_pagetable_new(); + if ( mfn_eq(l2_ro_mpt_mfn, INVALID_MFN) ) goto nomem; - compat_idle_pg_table_l2 = l2_ro_mpt; + l2_ro_mpt = map_xen_pagetable_new(l2_ro_mpt_mfn); + compat_idle_pg_table_l2 = map_domain_page_global(l2_ro_mpt_mfn); clear_page(l2_ro_mpt); l3e_write(&l3_ro_mpt[l3_table_offset(HIRO_COMPAT_MPT_VIRT_START)], - l3e_from_paddr(__pa(l2_ro_mpt), __PAGE_HYPERVISOR_RO)); + l3e_from_mfn(l2_ro_mpt_mfn, __PAGE_HYPERVISOR_RO)); pl2e = l2_ro_mpt; pl2e += l2_table_offset(HIRO_COMPAT_MPT_VIRT_START); /* Allocate and map the compatibility mode machine-to-phys table. */ @@ -679,6 +701,8 @@ void __init paging_init(void) #undef CNT #undef MFN + UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); + machine_to_phys_mapping_valid = 1; /* Set up linear page table mapping. */ From patchwork Mon Sep 30 10:33:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166395 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EA1D413BD for ; Mon, 30 Sep 2019 10:35:43 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C68A7215EA for ; Mon, 30 Sep 2019 10:35:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="t0aon9QE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C68A7215EA Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt15-0007RZ-8O; Mon, 30 Sep 2019 10:34:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt13-0007Pt-QF for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:34:53 +0000 X-Inumbo-ID: e98136c2-e36d-11e9-97fb-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id e98136c2-e36d-11e9-97fb-bc764e2007e4; Mon, 30 Sep 2019 10:34:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839682; x=1601375682; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=kfRLGwMAo8qUkUICVo3LN9nmzho78UjN+g9YgNVLCXI=; b=t0aon9QEkkCiSQvroVDo6grZtLn4H0YkeMrIaZ9h582iA6PZlJ6PZfvK 8CFsELNNKhK0/vtsMkJGft2iKQMJ5Clp9x/KbKReDB+adO4jyYtghBNWT js1afYH0DpyiFTsRut3h/bWrsV23rjSdbe7+NdtbCPrhlbau5DrmpJdY3 M=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="424630109" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-2c665b5d.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:41 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-2c665b5d.us-east-1.amazon.com (Postfix) with ESMTPS id 83826A1F55; Mon, 30 Sep 2019 10:34:41 +0000 (UTC) Received: from EX13D20UEE001.ant.amazon.com (10.43.62.84) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:13 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D20UEE001.ant.amazon.com (10.43.62.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:13 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:12 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:15 +0100 Message-ID: <64c26c9c344f68e0377e15e956a9bca3962c896f.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 23/55] x86_64/mm: drop l4e_to_l3e invocation from paging_init X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/x86_64/mm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index c8c71564ba..c1daa04cf5 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -649,8 +649,10 @@ void __init paging_init(void) /* Create user-accessible L2 directory to map the MPT for compat guests. */ BUILD_BUG_ON(l4_table_offset(RDWR_MPT_VIRT_START) != l4_table_offset(HIRO_COMPAT_MPT_VIRT_START)); - l3_ro_mpt = l4e_to_l3e(idle_pg_table[l4_table_offset( - HIRO_COMPAT_MPT_VIRT_START)]); + + l3_ro_mpt_mfn = l4e_get_mfn(idle_pg_table[l4_table_offset( + HIRO_COMPAT_MPT_VIRT_START)]); + l3_ro_mpt = map_xen_pagetable_new(l3_ro_mpt_mfn); l2_ro_mpt_mfn = alloc_xen_pagetable_new(); if ( mfn_eq(l2_ro_mpt_mfn, INVALID_MFN) ) @@ -702,6 +704,7 @@ void __init paging_init(void) #undef MFN UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); + UNMAP_XEN_PAGETABLE_NEW(l3_ro_mpt); machine_to_phys_mapping_valid = 1; From patchwork Mon Sep 30 10:33:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166489 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C31513BD for ; Mon, 30 Sep 2019 10:37:45 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 484C720679 for ; Mon, 30 Sep 2019 10:37:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="ZuPYWDVX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 484C720679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt36-0002jg-JM; Mon, 30 Sep 2019 10:37:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt34-0002gC-Vd for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:36:59 +0000 X-Inumbo-ID: 222ed1aa-e36e-11e9-bf31-bc764e2007e4 Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id 222ed1aa-e36e-11e9-bf31-bc764e2007e4; Mon, 30 Sep 2019 10:36:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839777; x=1601375777; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=FyGQD07umeQncTekgcbfUfStTJLGKuOPm9SHgfgoJt4=; b=ZuPYWDVXaayhIF5KcSxxB5S0jblUSDIcYHCyCeYHoW1Xj2EhzzlZxXSK BeMWaE/I7bhkTemyy51I0ZOGyLFmIhR9bhZSOFwufwUV0Jk44yr0uWthV imECHPLQ90OkUxMJLWY8YyOqCVRdtegupdUZZXjZcUR4Y92BeHsmYUYPF 0=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="705521340" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1d-5dd976cd.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 30 Sep 2019 10:35:00 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-5dd976cd.us-east-1.amazon.com (Postfix) with ESMTPS id 47D7EA2249; Mon, 30 Sep 2019 10:34:43 +0000 (UTC) Received: from EX13D06UEE001.ant.amazon.com (10.43.62.79) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:14 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D06UEE001.ant.amazon.com (10.43.62.79) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:13 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:13 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:16 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 24/55] x86_64/mm.c: remove code that serves no purpose in setup_m2p_table X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/x86_64/mm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index c1daa04cf5..103932720b 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -480,8 +480,6 @@ static int setup_m2p_table(struct mem_hotadd_info *info) l2e_write(l2_ro_mpt, l2e_from_mfn(mfn, /*_PAGE_GLOBAL|*/_PAGE_PSE|_PAGE_USER|_PAGE_PRESENT)); } - if ( !((unsigned long)l2_ro_mpt & ~PAGE_MASK) ) - l2_ro_mpt = NULL; i += ( 1UL << (L2_PAGETABLE_SHIFT - 3)); } #undef CNT From patchwork Mon Sep 30 10:33:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166427 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C4DE13BD for ; Mon, 30 Sep 2019 10:36:16 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 283C621855 for ; Mon, 30 Sep 2019 10:36:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="FjDl5ReA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 283C621855 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1F-0007fO-6J; Mon, 30 Sep 2019 10:35:05 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1D-0007df-R1 for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:03 +0000 X-Inumbo-ID: ec2fc6f4-e36d-11e9-97fb-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id ec2fc6f4-e36d-11e9-97fb-bc764e2007e4; Mon, 30 Sep 2019 10:34:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839686; x=1601375686; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=SQh+B8Qj4A93IoC6Ds2kYPPws3P2iKoUgq/Hi2iZ6RM=; b=FjDl5ReAZI80sVJ7r3sLlLn3BrZMQJvHXtXJtAQ0de5U4CiJa1l+8nZl CF6aru5FF1U4Ot4toybK+0v+yrtdAw3yhe9V0Ke4gzMHh6Nu/ItWTVcE2 tivdv4LnRqBmdYCJZRmrRFnLOCq8eYXY2cA7QCXaMkVTUR/QYVuv/iJo3 U=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="424630114" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-9ec21598.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:45 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-9ec21598.us-east-1.amazon.com (Postfix) with ESMTPS id 48C05A2267; Mon, 30 Sep 2019 10:34:44 +0000 (UTC) Received: from EX13D11UEE001.ant.amazon.com (10.43.62.132) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:15 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D11UEE001.ant.amazon.com (10.43.62.132) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:14 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:14 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:17 +0100 Message-ID: <7686120b7f9e3abdefabd930cf1b89818792cab1.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 25/55] x86_64/mm: introduce pl2e in setup_m2p_table X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/x86_64/mm.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 103932720b..f31bd4ffde 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -397,7 +397,7 @@ static int setup_m2p_table(struct mem_hotadd_info *info) { unsigned long i, va, smap, emap; unsigned int n; - l2_pgentry_t *l2_ro_mpt = NULL; + l2_pgentry_t *pl2e = NULL, *l2_ro_mpt; l3_pgentry_t *l3_ro_mpt = NULL; int ret = 0; @@ -458,7 +458,7 @@ static int setup_m2p_table(struct mem_hotadd_info *info) _PAGE_PSE)); if ( l3e_get_flags(l3_ro_mpt[l3_table_offset(va)]) & _PAGE_PRESENT ) - l2_ro_mpt = l3e_to_l2e(l3_ro_mpt[l3_table_offset(va)]) + + pl2e = l3e_to_l2e(l3_ro_mpt[l3_table_offset(va)]) + l2_table_offset(va); else { @@ -473,11 +473,12 @@ static int setup_m2p_table(struct mem_hotadd_info *info) l3e_write(&l3_ro_mpt[l3_table_offset(va)], l3e_from_paddr(__pa(l2_ro_mpt), __PAGE_HYPERVISOR_RO | _PAGE_USER)); - l2_ro_mpt += l2_table_offset(va); + pl2e = l2_ro_mpt; + pl2e += l2_table_offset(va); } /* NB. Cannot be GLOBAL: guest user mode should not see it. */ - l2e_write(l2_ro_mpt, l2e_from_mfn(mfn, + l2e_write(pl2e, l2e_from_mfn(mfn, /*_PAGE_GLOBAL|*/_PAGE_PSE|_PAGE_USER|_PAGE_PRESENT)); } i += ( 1UL << (L2_PAGETABLE_SHIFT - 3)); From patchwork Mon Sep 30 10:33:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166415 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B1F0913BD for ; Mon, 30 Sep 2019 10:36:02 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8DFCB20679 for ; Mon, 30 Sep 2019 10:36:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="cikTGFjj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DFCB20679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0y-0007IZ-1c; Mon, 30 Sep 2019 10:34:48 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0w-0007HR-Se for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:34:46 +0000 X-Inumbo-ID: ec37fe32-e36d-11e9-96cd-12813bfff9fa Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id ec37fe32-e36d-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:34:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839686; x=1601375686; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Ip5SaJrZGdwG5/dssfQ+/hlVPjGGAQ5ZKNoKItEsnHE=; b=cikTGFjjzHjNL2vxUe2c62/eP5QuIPi8PpuGHBcNQHvX65P6sLmQhK8H EOfK/ao5nkZtiMehhF7WFAWoZeYWF3EJOvpynYd3rEBNF3gfrpuB1H4Li PS3vd1/fvE4QWpNQi3MVHWbE+UJdLhnNuVBVg/EMSxH/++VrjMJYm8TRd 0=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="754242231" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1e-27fb8269.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 30 Sep 2019 10:34:46 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-27fb8269.us-east-1.amazon.com (Postfix) with ESMTPS id EC7FBA065D; Mon, 30 Sep 2019 10:34:44 +0000 (UTC) Received: from EX13D18UEE004.ant.amazon.com (10.43.62.129) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:16 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D18UEE004.ant.amazon.com (10.43.62.129) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:15 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:15 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:18 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 26/55] x86_64/mm: switch to new APIs in setup_m2p_table X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/x86_64/mm.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index f31bd4ffde..d452ed3966 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -397,9 +397,10 @@ static int setup_m2p_table(struct mem_hotadd_info *info) { unsigned long i, va, smap, emap; unsigned int n; - l2_pgentry_t *pl2e = NULL, *l2_ro_mpt; + l2_pgentry_t *pl2e = NULL, *l2_ro_mpt = NULL; l3_pgentry_t *l3_ro_mpt = NULL; int ret = 0; + mfn_t l2_ro_mpt_mfn; ASSERT(l4e_get_flags(idle_pg_table[l4_table_offset(RO_MPT_VIRT_START)]) & _PAGE_PRESENT); @@ -462,17 +463,19 @@ static int setup_m2p_table(struct mem_hotadd_info *info) l2_table_offset(va); else { - l2_ro_mpt = alloc_xen_pagetable(); - if ( !l2_ro_mpt ) + UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); + l2_ro_mpt_mfn = alloc_xen_pagetable_new(); + if ( mfn_eq(l2_ro_mpt_mfn, INVALID_MFN) ) { ret = -ENOMEM; goto error; } + l2_ro_mpt = map_xen_pagetable_new(l2_ro_mpt_mfn); clear_page(l2_ro_mpt); l3e_write(&l3_ro_mpt[l3_table_offset(va)], - l3e_from_paddr(__pa(l2_ro_mpt), - __PAGE_HYPERVISOR_RO | _PAGE_USER)); + l3e_from_mfn(l2_ro_mpt_mfn, + __PAGE_HYPERVISOR_RO | _PAGE_USER)); pl2e = l2_ro_mpt; pl2e += l2_table_offset(va); } @@ -488,6 +491,7 @@ static int setup_m2p_table(struct mem_hotadd_info *info) ret = setup_compat_m2p_table(info); error: + UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); return ret; } From patchwork Mon Sep 30 10:33:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166431 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 70F381709 for ; Mon, 30 Sep 2019 10:36:25 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4D84E21855 for ; Mon, 30 Sep 2019 10:36:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="ClhHi/w1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D84E21855 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1K-0007mU-5D; Mon, 30 Sep 2019 10:35:10 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1I-0007kY-RR for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:08 +0000 X-Inumbo-ID: f0f7263c-e36d-11e9-bf31-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id f0f7263c-e36d-11e9-bf31-bc764e2007e4; Mon, 30 Sep 2019 10:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839694; x=1601375694; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=6nzAStnWYrYC7d4QMPwj7AvyNQB9HFAtnT/it/dtaYg=; b=ClhHi/w1LjmqDI7Uo2RA648PS/b1j6WTmndwdw8BI7YNatcJoqbSwSK+ U3nAyFWfYESNHLmypSTxokVwYFJeGPlGTsIfg6Tg5Gj3RQJZ53z3RwGkj Zyu9H8mopo+rcKw45pOdu3+erF9o0S7MYQFVPvZhusA3Vu8rPYB54p/MH c=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="424630119" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-9ec21598.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:46 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-9ec21598.us-east-1.amazon.com (Postfix) with ESMTPS id 1A5CFA20C7; Mon, 30 Sep 2019 10:34:46 +0000 (UTC) Received: from EX13D06UEE001.ant.amazon.com (10.43.62.79) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:17 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D06UEE001.ant.amazon.com (10.43.62.79) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:16 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:15 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:19 +0100 Message-ID: <9797dfe61ac60fa7239f1757e758ed14ae6bc739.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 27/55] x86_64/mm: drop lXe_to_lYe invocations from setup_m2p_table X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/x86_64/mm.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index d452ed3966..c41715cd56 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -400,11 +400,13 @@ static int setup_m2p_table(struct mem_hotadd_info *info) l2_pgentry_t *pl2e = NULL, *l2_ro_mpt = NULL; l3_pgentry_t *l3_ro_mpt = NULL; int ret = 0; - mfn_t l2_ro_mpt_mfn; + mfn_t l2_ro_mpt_mfn, l3_ro_mpt_mfn; ASSERT(l4e_get_flags(idle_pg_table[l4_table_offset(RO_MPT_VIRT_START)]) & _PAGE_PRESENT); - l3_ro_mpt = l4e_to_l3e(idle_pg_table[l4_table_offset(RO_MPT_VIRT_START)]); + l3_ro_mpt_mfn = l4e_get_mfn(idle_pg_table[l4_table_offset( + RO_MPT_VIRT_START)]); + l3_ro_mpt = map_xen_pagetable_new(l3_ro_mpt_mfn); smap = (info->spfn & (~((1UL << (L2_PAGETABLE_SHIFT - 3)) -1))); emap = ((info->epfn + ((1UL << (L2_PAGETABLE_SHIFT - 3)) - 1 )) & @@ -459,8 +461,13 @@ static int setup_m2p_table(struct mem_hotadd_info *info) _PAGE_PSE)); if ( l3e_get_flags(l3_ro_mpt[l3_table_offset(va)]) & _PAGE_PRESENT ) - pl2e = l3e_to_l2e(l3_ro_mpt[l3_table_offset(va)]) + - l2_table_offset(va); + { + UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); + l2_ro_mpt_mfn = l3e_get_mfn(l3_ro_mpt[l3_table_offset(va)]); + l2_ro_mpt = map_xen_pagetable_new(l2_ro_mpt_mfn); + ASSERT(l2_ro_mpt); + pl2e = l2_ro_mpt + l2_table_offset(va); + } else { UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); @@ -492,6 +499,7 @@ static int setup_m2p_table(struct mem_hotadd_info *info) ret = setup_compat_m2p_table(info); error: UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); + UNMAP_XEN_PAGETABLE_NEW(l3_ro_mpt); return ret; } From patchwork Mon Sep 30 10:33:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166461 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3203116B1 for ; Mon, 30 Sep 2019 10:36:55 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0E46820679 for ; Mon, 30 Sep 2019 10:36:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="KdSd2wYN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E46820679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2I-0001Ab-93; Mon, 30 Sep 2019 10:36:10 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2G-000182-TY for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:36:08 +0000 X-Inumbo-ID: 07f36d3c-e36e-11e9-bf31-bc764e2007e4 Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id 07f36d3c-e36e-11e9-bf31-bc764e2007e4; Mon, 30 Sep 2019 10:35:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839733; x=1601375733; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=WWxC8CaECvf3fPLUIHiBL4xp/pGS6BRlh6hTeTHWnrE=; b=KdSd2wYNeqV7+eRwxrJPjpGupRhboK5mMePtu/BMvzmHASL2elEmmW3U QQZn4iBW7D/J3z6EpVdLt6IfbSAq8tc74J/OK+TUJa+ReKSN45+wKIo3s bm9phjq0LXiwUnk2CUmOX3VdDI7rElK9hHE76MaZYqQTdMW5GclP2TsHT w=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="705521345" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1e-97fdccfd.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 30 Sep 2019 10:35:02 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-97fdccfd.us-east-1.amazon.com (Postfix) with ESMTPS id 7BFACA24D8; Mon, 30 Sep 2019 10:34:46 +0000 (UTC) Received: from EX13D09UEE002.ant.amazon.com (10.43.62.239) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:17 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D09UEE002.ant.amazon.com (10.43.62.239) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:17 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:16 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:20 +0100 Message-ID: <5629b76f1923c6ff4e79a9bc9905ebbaddba189b.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 28/55] efi: use new page table APIs in copy_mapping X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu After inspection ARM doesn't have alloc_xen_pagetable so this function is x86 only, which means it is safe for us to change. Signed-off-by: Wei Liu --- XXX test this in gitlab ci to be sure. --- xen/common/efi/boot.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 79193784ff..62b5944e61 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -1440,16 +1440,22 @@ static __init void copy_mapping(unsigned long mfn, unsigned long end, continue; if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) ) { - l3dst = alloc_xen_pagetable(); - BUG_ON(!l3dst); + mfn_t l3t_mfn; + + l3t_mfn = alloc_xen_pagetable_new(); + BUG_ON(mfn_eq(l3t_mfn, INVALID_MFN)); + l3dst = map_xen_pagetable_new(l3t_mfn); clear_page(l3dst); efi_l4_pgtable[l4_table_offset(mfn << PAGE_SHIFT)] = - l4e_from_paddr(virt_to_maddr(l3dst), __PAGE_HYPERVISOR); + l4e_from_mfn(l3t_mfn, __PAGE_HYPERVISOR); } else - l3dst = l4e_to_l3e(l4e); - l3src = l4e_to_l3e(idle_pg_table[l4_table_offset(va)]); + l3dst = map_xen_pagetable_new(l4e_get_mfn(l4e)); + l3src = map_xen_pagetable_new( + l4e_get_mfn(idle_pg_table[l4_table_offset(va)])); l3dst[l3_table_offset(mfn << PAGE_SHIFT)] = l3src[l3_table_offset(va)]; + UNMAP_XEN_PAGETABLE_NEW(l3src); + UNMAP_XEN_PAGETABLE_NEW(l3dst); } } From patchwork Mon Sep 30 10:33:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166383 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3FE2C13BD for ; Mon, 30 Sep 2019 10:35:38 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1BF8C216F4 for ; Mon, 30 Sep 2019 10:35:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="R5aBm6pF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BF8C216F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt11-0007N7-QX; Mon, 30 Sep 2019 10:34:51 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0z-0007Ka-RN for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:34:49 +0000 X-Inumbo-ID: ecde9abc-e36d-11e9-96cd-12813bfff9fa Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id ecde9abc-e36d-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:34:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839687; x=1601375687; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=3nNvQG1v8uYo6cTIKpiw9dRaihrielmfxq5scEhNceU=; b=R5aBm6pFiCth9Kx2KlDdmHLrjQQ7FVQT8EPnXXwP+5RVQcggoukn3kl7 RaNTQj0cp9L3jn0SEk96hMiP+yY3S11UJQzAmFsSWmtzpVscc99E+ni9V VIt+PlN1n4WS/S+zVXOKs4idKJiLnnVkiJ5mZJLAR1OLmnXY3yLuwhkQt 0=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="788414695" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-c7c08562.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 30 Sep 2019 10:34:47 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1e-c7c08562.us-east-1.amazon.com (Postfix) with ESMTPS id 271E9244235; Mon, 30 Sep 2019 10:34:47 +0000 (UTC) Received: from EX13D15UEE002.ant.amazon.com (10.43.62.80) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:18 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D15UEE002.ant.amazon.com (10.43.62.80) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:17 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:17 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:21 +0100 Message-ID: <75bdd5c41f19bd435bb708f3e3297c89e37bcbf1.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 29/55] efi: avoid using global variable in copy_mapping X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu We will soon switch efi_l4_table to use ephemeral mapping. Make copy_mapping take a pointer to the mapping instead of using the global variable. No functional change intended. Signed-off-by: Wei Liu --- xen/common/efi/boot.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 62b5944e61..64a287690a 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -1423,7 +1423,8 @@ static int __init parse_efi_param(const char *s) custom_param("efi", parse_efi_param); #ifndef USE_SET_VIRTUAL_ADDRESS_MAP -static __init void copy_mapping(unsigned long mfn, unsigned long end, +static __init void copy_mapping(l4_pgentry_t *l4, + unsigned long mfn, unsigned long end, bool (*is_valid)(unsigned long smfn, unsigned long emfn)) { @@ -1431,7 +1432,7 @@ static __init void copy_mapping(unsigned long mfn, unsigned long end, for ( ; mfn < end; mfn = next ) { - l4_pgentry_t l4e = efi_l4_pgtable[l4_table_offset(mfn << PAGE_SHIFT)]; + l4_pgentry_t l4e = l4[l4_table_offset(mfn << PAGE_SHIFT)]; l3_pgentry_t *l3src, *l3dst; unsigned long va = (unsigned long)mfn_to_virt(mfn); @@ -1446,7 +1447,7 @@ static __init void copy_mapping(unsigned long mfn, unsigned long end, BUG_ON(mfn_eq(l3t_mfn, INVALID_MFN)); l3dst = map_xen_pagetable_new(l3t_mfn); clear_page(l3dst); - efi_l4_pgtable[l4_table_offset(mfn << PAGE_SHIFT)] = + l4[l4_table_offset(mfn << PAGE_SHIFT)] = l4e_from_mfn(l3t_mfn, __PAGE_HYPERVISOR); } else @@ -1606,7 +1607,7 @@ void __init efi_init_memory(void) BUG_ON(!efi_l4_pgtable); clear_page(efi_l4_pgtable); - copy_mapping(0, max_page, ram_range_valid); + copy_mapping(efi_l4_pgtable, 0, max_page, ram_range_valid); /* Insert non-RAM runtime mappings inside the direct map. */ for ( i = 0; i < efi_memmap_size; i += efi_mdesc_size ) @@ -1619,7 +1620,7 @@ void __init efi_init_memory(void) desc->Type == EfiBootServicesData))) && desc->VirtualStart != INVALID_VIRTUAL_ADDRESS && desc->VirtualStart != desc->PhysicalStart ) - copy_mapping(PFN_DOWN(desc->PhysicalStart), + copy_mapping(efi_l4_pgtable, PFN_DOWN(desc->PhysicalStart), PFN_UP(desc->PhysicalStart + (desc->NumberOfPages << EFI_PAGE_SHIFT)), rt_range_valid); From patchwork Mon Sep 30 10:33:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166391 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 30D2A13BD for ; Mon, 30 Sep 2019 10:35:42 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0C64621920 for ; Mon, 30 Sep 2019 10:35:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="sHV78O85" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C64621920 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt16-0007TR-KH; Mon, 30 Sep 2019 10:34:56 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt14-0007Qz-RV for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:34:54 +0000 X-Inumbo-ID: ecde9abd-e36d-11e9-96cd-12813bfff9fa Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id ecde9abd-e36d-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:34:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839687; x=1601375687; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=0SYqLn0J8g22MwTPI4ly2IZPEB0g/6dxXq86B5UES/I=; b=sHV78O85U2bfiWLx7A7ExMGD4B5DBByq5EfzK62m9oh9Re+bU49rmfKC GgtbqIr0fi3QODS+/GTJEHNvgBH566Dh0/Mz35Zl1B+ExK5/gJ7i7DAjX 1oyWGdu8UOyaDXBydh0vqMrULBDy/lvGjfx/pwd3q+gdbqqkBGcjE0uJP 0=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="418649869" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-37fd6b3d.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:47 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1d-37fd6b3d.us-east-1.amazon.com (Postfix) with ESMTPS id 705342824BC; Mon, 30 Sep 2019 10:34:47 +0000 (UTC) Received: from EX13D02UEE001.ant.amazon.com (10.43.62.208) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:19 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D02UEE001.ant.amazon.com (10.43.62.208) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:18 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:18 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:22 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 30/55] efi: use new page table APIs in efi_init_memory X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/common/efi/boot.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 64a287690a..1d1420f02c 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -1637,39 +1637,50 @@ void __init efi_init_memory(void) if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) ) { - pl3e = alloc_xen_pagetable(); - BUG_ON(!pl3e); + mfn_t l3t_mfn; + + l3t_mfn = alloc_xen_pagetable_new(); + BUG_ON(mfn_eq(l3t_mfn, INVALID_MFN)); + pl3e = map_xen_pagetable_new(l3t_mfn); clear_page(pl3e); efi_l4_pgtable[l4_table_offset(addr)] = - l4e_from_paddr(virt_to_maddr(pl3e), __PAGE_HYPERVISOR); + l4e_from_mfn(l3t_mfn, __PAGE_HYPERVISOR); } else - pl3e = l4e_to_l3e(l4e); + pl3e = map_xen_pagetable_new(l4e_get_mfn(l4e)); pl3e += l3_table_offset(addr); + if ( !(l3e_get_flags(*pl3e) & _PAGE_PRESENT) ) { - pl2e = alloc_xen_pagetable(); - BUG_ON(!pl2e); + mfn_t l2t_mfn; + + l2t_mfn = alloc_xen_pagetable_new(); + BUG_ON(mfn_eq(l2t_mfn, INVALID_MFN)); + pl2e = map_xen_pagetable_new(l2t_mfn); clear_page(pl2e); - *pl3e = l3e_from_paddr(virt_to_maddr(pl2e), __PAGE_HYPERVISOR); + *pl3e = l3e_from_mfn(l2t_mfn, __PAGE_HYPERVISOR); } else { BUG_ON(l3e_get_flags(*pl3e) & _PAGE_PSE); - pl2e = l3e_to_l2e(*pl3e); + pl2e = map_xen_pagetable_new(l3e_get_mfn(*pl3e)); } pl2e += l2_table_offset(addr); + if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) ) { - l1t = alloc_xen_pagetable(); - BUG_ON(!l1t); + mfn_t l1t_mfn; + + l1t_mfn = alloc_xen_pagetable_new(); + BUG_ON(mfn_eq(l1t_mfn, INVALID_MFN)); + l1t = map_xen_pagetable_new(l1t_mfn); clear_page(l1t); - *pl2e = l2e_from_paddr(virt_to_maddr(l1t), __PAGE_HYPERVISOR); + *pl2e = l2e_from_mfn(l1t_mfn, __PAGE_HYPERVISOR); } else { BUG_ON(l2e_get_flags(*pl2e) & _PAGE_PSE); - l1t = l2e_to_l1e(*pl2e); + l1t = map_xen_pagetable_new(l2e_get_mfn(*pl2e)); } for ( i = l1_table_offset(addr); i < L1_PAGETABLE_ENTRIES && extra->smfn < extra->emfn; @@ -1681,6 +1692,10 @@ void __init efi_init_memory(void) extra_head = extra->next; xfree(extra); } + + UNMAP_XEN_PAGETABLE_NEW(l1t); + UNMAP_XEN_PAGETABLE_NEW(pl2e); + UNMAP_XEN_PAGETABLE_NEW(pl3e); } /* Insert Xen mappings. */ From patchwork Mon Sep 30 10:33:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166423 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92DA413BD for ; Mon, 30 Sep 2019 10:36:14 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6ED0820679 for ; Mon, 30 Sep 2019 10:36:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="ZIiStj8d" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6ED0820679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1B-0007aW-Mr; Mon, 30 Sep 2019 10:35:01 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt19-0007Xy-Rs for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:34:59 +0000 X-Inumbo-ID: ecde9abe-e36d-11e9-96cd-12813bfff9fa Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id ecde9abe-e36d-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:34:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839688; x=1601375688; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=EkbSE2k+c0yDqIG045tLdYR7PyZYrRga2vnlZteckMc=; b=ZIiStj8dE9cXx/c1WO5R/xDBlZ4TJ6mEKnGtgl7fX7RKpzO3o/qdhHkU QE3ForF33izLH2NsygehsimXFPOGC+QqWTULCLIur/HFPe0TafvQorQP5 1MuKNVizFLMaXli2Mx33FxB8w2q0fSqM7DYCuTtu4M5v7McfHATk7INJM Q=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="418649875" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-a70de69e.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:48 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1e-a70de69e.us-east-1.amazon.com (Postfix) with ESMTPS id 26158A2768; Mon, 30 Sep 2019 10:34:48 +0000 (UTC) Received: from EX13D03UEE004.ant.amazon.com (10.43.62.93) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:19 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D03UEE004.ant.amazon.com (10.43.62.93) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:19 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:18 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:23 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 31/55] efi: add emacs block to boot.c X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/common/efi/boot.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 1d1420f02c..3868293d06 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -1705,3 +1705,13 @@ void __init efi_init_memory(void) #endif } #endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ From patchwork Mon Sep 30 10:33:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166403 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E066613BD for ; Mon, 30 Sep 2019 10:35:52 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BC97321855 for ; Mon, 30 Sep 2019 10:35:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="HY+nhe6I" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC97321855 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1F-0007fx-JI; Mon, 30 Sep 2019 10:35:05 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1E-0007ex-Rq for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:04 +0000 X-Inumbo-ID: ee832c70-e36d-11e9-96cd-12813bfff9fa Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id ee832c70-e36d-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:34:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839690; x=1601375690; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=HOlQh5k1oNPRVyL9EqE56c5arborDHenMa3MWF/9pfs=; b=HY+nhe6Ib1orxn5CDGGEDstp8oZoYsU4k+VAuaeQgRdc36v3TmrhQA4x d5N8xfLLpT4G2W1nRTcTuZW0jAzrPFYZmic2o98gr3dHwt3lawHzsryTQ hVICG7pzDwz4HeqCDZjtCfiWPI+npGlaLSRcfwG1AKauR4Zh+4sreAam5 c=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="754242253" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1d-37fd6b3d.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 30 Sep 2019 10:34:50 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1d-37fd6b3d.us-east-1.amazon.com (Postfix) with ESMTPS id CAAA8282413; Mon, 30 Sep 2019 10:34:48 +0000 (UTC) Received: from EX13D09UEE001.ant.amazon.com (10.43.62.205) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:20 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D09UEE001.ant.amazon.com (10.43.62.205) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:20 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:19 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:24 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 32/55] efi: switch EFI L4 table to use new APIs X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu This requires storing the MFN instead of linear address of the L4 table. Adjust code accordingly. Signed-off-by: Wei Liu --- xen/arch/x86/efi/runtime.h | 12 +++++++++--- xen/common/efi/boot.c | 8 ++++++-- xen/common/efi/efi.h | 3 ++- xen/common/efi/runtime.c | 8 ++++---- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/efi/runtime.h b/xen/arch/x86/efi/runtime.h index d9eb8f5c27..277d237953 100644 --- a/xen/arch/x86/efi/runtime.h +++ b/xen/arch/x86/efi/runtime.h @@ -2,11 +2,17 @@ #include #ifndef COMPAT -l4_pgentry_t *__read_mostly efi_l4_pgtable; +mfn_t __read_mostly efi_l4_mfn = INVALID_MFN_INITIALIZER; void efi_update_l4_pgtable(unsigned int l4idx, l4_pgentry_t l4e) { - if ( efi_l4_pgtable ) - l4e_write(efi_l4_pgtable + l4idx, l4e); + if ( !mfn_eq(efi_l4_mfn, INVALID_MFN) ) + { + l4_pgentry_t *l4t; + + l4t = map_xen_pagetable_new(efi_l4_mfn); + l4e_write(l4t + l4idx, l4e); + UNMAP_XEN_PAGETABLE_NEW(l4t); + } } #endif diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 3868293d06..f55d6a6d76 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -1488,6 +1488,7 @@ void __init efi_init_memory(void) unsigned int prot; } *extra, *extra_head = NULL; #endif + l4_pgentry_t *efi_l4_pgtable; free_ebmalloc_unused_mem(); @@ -1603,8 +1604,9 @@ void __init efi_init_memory(void) mdesc_ver, efi_memmap); #else /* Set up 1:1 page tables to do runtime calls in "physical" mode. */ - efi_l4_pgtable = alloc_xen_pagetable(); - BUG_ON(!efi_l4_pgtable); + efi_l4_mfn = alloc_xen_pagetable_new(); + BUG_ON(mfn_eq(efi_l4_mfn, INVALID_MFN)); + efi_l4_pgtable = map_xen_pagetable_new(efi_l4_mfn); clear_page(efi_l4_pgtable); copy_mapping(efi_l4_pgtable, 0, max_page, ram_range_valid); @@ -1703,6 +1705,8 @@ void __init efi_init_memory(void) i < l4_table_offset(DIRECTMAP_VIRT_END); ++i ) efi_l4_pgtable[i] = idle_pg_table[i]; #endif + + UNMAP_XEN_PAGETABLE_NEW(efi_l4_pgtable); } #endif diff --git a/xen/common/efi/efi.h b/xen/common/efi/efi.h index 6b9c56ead1..139b660ed7 100644 --- a/xen/common/efi/efi.h +++ b/xen/common/efi/efi.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -29,7 +30,7 @@ extern UINTN efi_memmap_size, efi_mdesc_size; extern void *efi_memmap; #ifdef CONFIG_X86 -extern l4_pgentry_t *efi_l4_pgtable; +extern mfn_t efi_l4_mfn; #endif extern const struct efi_pci_rom *efi_pci_roms; diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c index ab53ebcc55..d4b04a04f4 100644 --- a/xen/common/efi/runtime.c +++ b/xen/common/efi/runtime.c @@ -85,7 +85,7 @@ struct efi_rs_state efi_rs_enter(void) static const u32 mxcsr = MXCSR_DEFAULT; struct efi_rs_state state = { .cr3 = 0 }; - if ( !efi_l4_pgtable ) + if ( mfn_eq(efi_l4_mfn, INVALID_MFN) ) return state; state.cr3 = read_cr3(); @@ -111,7 +111,7 @@ struct efi_rs_state efi_rs_enter(void) lgdt(&gdt_desc); } - switch_cr3_cr4(virt_to_maddr(efi_l4_pgtable), read_cr4()); + switch_cr3_cr4(mfn_to_maddr(efi_l4_mfn), read_cr4()); return state; } @@ -140,9 +140,9 @@ void efi_rs_leave(struct efi_rs_state *state) bool efi_rs_using_pgtables(void) { - return efi_l4_pgtable && + return !mfn_eq(efi_l4_mfn, INVALID_MFN) && (smp_processor_id() == efi_rs_on_cpu) && - (read_cr3() == virt_to_maddr(efi_l4_pgtable)); + (read_cr3() == mfn_to_maddr(efi_l4_mfn)); } unsigned long efi_get_time(void) From patchwork Mon Sep 30 10:33:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166429 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3259513BD for ; Mon, 30 Sep 2019 10:36:25 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0F5552190F for ; Mon, 30 Sep 2019 10:36:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="HMyQ7zRn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F5552190F Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1P-0007v8-Fh; Mon, 30 Sep 2019 10:35:15 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1N-0007sd-Rj for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:13 +0000 X-Inumbo-ID: f157ae26-e36d-11e9-bf31-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id f157ae26-e36d-11e9-bf31-bc764e2007e4; Mon, 30 Sep 2019 10:34:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839695; x=1601375695; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=y6QRWXt83sqWJchd2RmXZ6+Xv6qUuR82BN4GSwIp7XY=; b=HMyQ7zRnO4sX7HMdQDwpnXPQH+1646UlqjifucfV5FvbmHnX/S9Y/yP6 YK2jsuzgmFT7bTDfFm0Tx/92p88Beh3bea6v3Zo1ydjZJ7QPU3QZxjOQ3 1yuLT6g8EQPrEMwN5jYLwLJgb3sjXvcI/+HBOmFp4sizFZM3VBr/w7MlC 8=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="424630136" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-474bcd9f.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:51 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1d-474bcd9f.us-east-1.amazon.com (Postfix) with ESMTPS id BD8DEA1E1C; Mon, 30 Sep 2019 10:34:49 +0000 (UTC) Received: from EX13D12UEE002.ant.amazon.com (10.43.62.15) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:21 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D12UEE002.ant.amazon.com (10.43.62.15) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:20 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:20 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:25 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 33/55] x86/smpboot: add emacs block X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/smpboot.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 5b3be25f8a..55b99644af 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -1378,3 +1378,13 @@ void __init smp_intr_init(void) set_direct_apic_vector(INVALIDATE_TLB_VECTOR, invalidate_interrupt); set_direct_apic_vector(CALL_FUNCTION_VECTOR, call_function_interrupt); } + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ From patchwork Mon Sep 30 10:33:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166411 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2D4C1709 for ; Mon, 30 Sep 2019 10:35:56 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BEF2120679 for ; Mon, 30 Sep 2019 10:35:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="DZPVkaZg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BEF2120679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1K-0007nA-Gv; Mon, 30 Sep 2019 10:35:10 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1J-0007m1-Sf for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:09 +0000 X-Inumbo-ID: ee832c71-e36d-11e9-96cd-12813bfff9fa Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id ee832c71-e36d-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:34:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839691; x=1601375691; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=bUnFLi/md8eRWeEoW7mOrP7WkthfB/CJcubUNnT+G+o=; b=DZPVkaZgooEtiw8CvAZSak0dTfRLYN7yKgmLr+6TRJrBKcFlWK7lDHf9 w3uF0u8y4c8ax4JGcGQvBiP8t/b3gDYJ4fJk4VcL1l2Je6LdlAMH8WEK+ 6cGUMNwDwnap4rxqtsprPhkRJorHplvjGkvNzBbwrL+RUCqu3WvoGBVY8 s=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="754242261" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1d-37fd6b3d.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 30 Sep 2019 10:34:51 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1d-37fd6b3d.us-east-1.amazon.com (Postfix) with ESMTPS id 5F3DE282413; Mon, 30 Sep 2019 10:34:50 +0000 (UTC) Received: from EX13D14UEE004.ant.amazon.com (10.43.62.145) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:22 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D14UEE004.ant.amazon.com (10.43.62.145) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:22 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:21 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:26 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 34/55] x86/smpboot: clone_mapping should have one exit path X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu We will soon need to clean up page table mappings in the exit path. No functional change. Signed-off-by: Wei Liu --- xen/arch/x86/smpboot.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 55b99644af..716dc1512d 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -667,6 +667,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) l3_pgentry_t *pl3e; l2_pgentry_t *pl2e; l1_pgentry_t *pl1e; + int rc; /* * Sanity check 'linear'. We only allow cloning from the Xen virtual @@ -674,11 +675,17 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) */ if ( root_table_offset(linear) > ROOT_PAGETABLE_LAST_XEN_SLOT || root_table_offset(linear) < ROOT_PAGETABLE_FIRST_XEN_SLOT ) - return -EINVAL; + { + rc = -EINVAL; + goto out; + } if ( linear < XEN_VIRT_START || (linear >= XEN_VIRT_END && linear < DIRECTMAP_VIRT_START) ) - return -EINVAL; + { + rc = -EINVAL; + goto out; + } pl3e = l4e_to_l3e(idle_pg_table[root_table_offset(linear)]) + l3_table_offset(linear); @@ -707,7 +714,10 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) pl1e = l2e_to_l1e(*pl2e) + l1_table_offset(linear); flags = l1e_get_flags(*pl1e); if ( !(flags & _PAGE_PRESENT) ) - return 0; + { + rc = 0; + goto out; + } pfn = l1e_get_pfn(*pl1e); } } @@ -716,7 +726,10 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) { pl3e = alloc_xen_pagetable(); if ( !pl3e ) - return -ENOMEM; + { + rc = -ENOMEM; + goto out; + } clear_page(pl3e); l4e_write(&rpt[root_table_offset(linear)], l4e_from_paddr(__pa(pl3e), __PAGE_HYPERVISOR)); @@ -730,7 +743,10 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) { pl2e = alloc_xen_pagetable(); if ( !pl2e ) - return -ENOMEM; + { + rc = -ENOMEM; + goto out; + } clear_page(pl2e); l3e_write(pl3e, l3e_from_paddr(__pa(pl2e), __PAGE_HYPERVISOR)); } @@ -746,7 +762,10 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) { pl1e = alloc_xen_pagetable(); if ( !pl1e ) - return -ENOMEM; + { + rc = -ENOMEM; + goto out; + } clear_page(pl1e); l2e_write(pl2e, l2e_from_paddr(__pa(pl1e), __PAGE_HYPERVISOR)); } @@ -767,7 +786,9 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) else l1e_write(pl1e, l1e_from_pfn(pfn, flags)); - return 0; + rc = 0; + out: + return rc; } DEFINE_PER_CPU(root_pgentry_t *, root_pgt); From patchwork Mon Sep 30 10:33:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166417 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 11BC213BD for ; Mon, 30 Sep 2019 10:36:09 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E100C20679 for ; Mon, 30 Sep 2019 10:36:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="KlMP5k+M" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E100C20679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1U-00083c-Hb; Mon, 30 Sep 2019 10:35:20 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1S-00081A-RV for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:18 +0000 X-Inumbo-ID: f1d3176e-e36d-11e9-bf31-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id f1d3176e-e36d-11e9-bf31-bc764e2007e4; Mon, 30 Sep 2019 10:34:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839695; x=1601375695; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=P0cwxGL9Za3ub4ggzM1FvUu37oEFscV2CGp82CE/u8M=; b=KlMP5k+ML/R6FGwwVeRvgzUlK3ewkV2CPKI3VyqCp1EvHNgZdw5EAzVG 7W5G142tAXqe3RZVedIHu3py1x70hoPBzt4TtvTjuXTbn02bk31EJmwdR zHCHjTYNTxdymqnC/tMQZHhGrB55eByuz49WKjq8UBO7tAzttPzb4U9Ut 4=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="424630151" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-98acfc19.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:52 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-98acfc19.us-east-1.amazon.com (Postfix) with ESMTPS id 2F2CDA1DD8; Mon, 30 Sep 2019 10:34:51 +0000 (UTC) Received: from EX13D15UEE001.ant.amazon.com (10.43.62.86) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:23 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D15UEE001.ant.amazon.com (10.43.62.86) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:23 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:22 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:27 +0100 Message-ID: <7133eb6c9eb2800c8bc69e9aed279466e1369489.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 35/55] x86/smpboot: switch pl3e to use new APIs in clone_mapping X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/smpboot.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 716dc1512d..db39f5cbb2 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -664,7 +664,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) { unsigned long linear = (unsigned long)ptr, pfn; unsigned int flags; - l3_pgentry_t *pl3e; + l3_pgentry_t *pl3e = NULL; l2_pgentry_t *pl2e; l1_pgentry_t *pl1e; int rc; @@ -687,8 +687,9 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) goto out; } - pl3e = l4e_to_l3e(idle_pg_table[root_table_offset(linear)]) + - l3_table_offset(linear); + pl3e = map_xen_pagetable_new( + l4e_get_mfn(idle_pg_table[root_table_offset(linear)])); + pl3e += l3_table_offset(linear); flags = l3e_get_flags(*pl3e); ASSERT(flags & _PAGE_PRESENT); @@ -722,20 +723,26 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) } } + UNMAP_XEN_PAGETABLE_NEW(pl3e); + if ( !(root_get_flags(rpt[root_table_offset(linear)]) & _PAGE_PRESENT) ) { - pl3e = alloc_xen_pagetable(); - if ( !pl3e ) + mfn_t l3t_mfn = alloc_xen_pagetable_new(); + + if ( mfn_eq(l3t_mfn, INVALID_MFN) ) { rc = -ENOMEM; goto out; } + + pl3e = map_xen_pagetable_new(l3t_mfn); clear_page(pl3e); l4e_write(&rpt[root_table_offset(linear)], - l4e_from_paddr(__pa(pl3e), __PAGE_HYPERVISOR)); + l4e_from_mfn(l3t_mfn, __PAGE_HYPERVISOR)); } else - pl3e = l4e_to_l3e(rpt[root_table_offset(linear)]); + pl3e = map_xen_pagetable_new( + l4e_get_mfn(rpt[root_table_offset(linear)])); pl3e += l3_table_offset(linear); @@ -788,6 +795,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) rc = 0; out: + UNMAP_XEN_PAGETABLE_NEW(pl3e); return rc; } From patchwork Mon Sep 30 10:33:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166467 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92ECE13BD for ; Mon, 30 Sep 2019 10:37:11 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6F40120679 for ; Mon, 30 Sep 2019 10:37:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="vEiXlH3i" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F40120679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2X-0001bM-EU; Mon, 30 Sep 2019 10:36:25 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2V-0001Yi-Uz for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:36:23 +0000 X-Inumbo-ID: 1ad7e4be-e36e-11e9-97fb-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 1ad7e4be-e36e-11e9-97fb-bc764e2007e4; Mon, 30 Sep 2019 10:36:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839765; x=1601375765; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=a1XU9H6o8lt4sM4ZU4RRo0qnivYGLSX0kQ7zNY2lmOA=; b=vEiXlH3iMeYxdYrDwFYu4MFz2q7gZXLvtm2ujsOq1XmdoR9Ossrb8sza rZgKq0oF/GLI8zGnKa1J6E6hDN9zNX3fcIMoBuVWD3RGUW40yJm+Tw+US 8tBmEezpSEYtaNykMLZQ2p1hSPWE/kOAdbmeoVhXXfg9da4wZNsO5e3yv M=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="838005667" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1e-57e1d233.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 30 Sep 2019 10:35:04 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-57e1d233.us-east-1.amazon.com (Postfix) with ESMTPS id 7A51C14178B; Mon, 30 Sep 2019 10:34:51 +0000 (UTC) Received: from EX13MTAUEE002.ant.amazon.com (10.43.62.24) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:24 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13MTAUEE002.ant.amazon.com (10.43.62.24) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:23 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:23 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:28 +0100 Message-ID: <9f89de789707ef89c2b6d6abdbb8c52e7803b4c9.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 36/55] x86/smpboot: switch pl2e to use new APIs in clone_mapping X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/smpboot.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index db39f5cbb2..d327c062b1 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -665,7 +665,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) unsigned long linear = (unsigned long)ptr, pfn; unsigned int flags; l3_pgentry_t *pl3e = NULL; - l2_pgentry_t *pl2e; + l2_pgentry_t *pl2e = NULL; l1_pgentry_t *pl1e; int rc; @@ -701,7 +701,8 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) } else { - pl2e = l3e_to_l2e(*pl3e) + l2_table_offset(linear); + pl2e = map_xen_pagetable_new(l3e_get_mfn(*pl3e)); + pl2e += l2_table_offset(linear); flags = l2e_get_flags(*pl2e); ASSERT(flags & _PAGE_PRESENT); if ( flags & _PAGE_PSE ) @@ -723,6 +724,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) } } + UNMAP_XEN_PAGETABLE_NEW(pl2e); UNMAP_XEN_PAGETABLE_NEW(pl3e); if ( !(root_get_flags(rpt[root_table_offset(linear)]) & _PAGE_PRESENT) ) @@ -748,19 +750,22 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) if ( !(l3e_get_flags(*pl3e) & _PAGE_PRESENT) ) { - pl2e = alloc_xen_pagetable(); - if ( !pl2e ) + mfn_t l2t_mfn = alloc_xen_pagetable_new(); + + if ( mfn_eq(l2t_mfn, INVALID_MFN) ) { rc = -ENOMEM; goto out; } + + pl2e = map_xen_pagetable_new(l2t_mfn); clear_page(pl2e); - l3e_write(pl3e, l3e_from_paddr(__pa(pl2e), __PAGE_HYPERVISOR)); + l3e_write(pl3e, l3e_from_mfn(l2t_mfn, __PAGE_HYPERVISOR)); } else { ASSERT(!(l3e_get_flags(*pl3e) & _PAGE_PSE)); - pl2e = l3e_to_l2e(*pl3e); + pl2e = map_xen_pagetable_new(l3e_get_mfn(*pl3e)); } pl2e += l2_table_offset(linear); @@ -795,6 +800,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) rc = 0; out: + UNMAP_XEN_PAGETABLE_NEW(pl2e); UNMAP_XEN_PAGETABLE_NEW(pl3e); return rc; } From patchwork Mon Sep 30 10:33:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166435 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 607AC13BD for ; Mon, 30 Sep 2019 10:36:30 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3C5B920679 for ; Mon, 30 Sep 2019 10:36:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="UdKy0Kte" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C5B920679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1Q-0007vv-07; Mon, 30 Sep 2019 10:35:16 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1O-0007uK-Ut for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:14 +0000 X-Inumbo-ID: efd5ff08-e36d-11e9-96cd-12813bfff9fa Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id efd5ff08-e36d-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:34:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839692; x=1601375692; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=gu2E4m0AtO6nGVE9CH0eP7a1+B0fb6VtXGPXw6YGSZQ=; b=UdKy0KteZY1KABYAnNw5KDIEjzRdxT9WMakgvMECowII2nbCtfTRdOrK PYdM9Rp0UftZ0NwZ9nfzsAJqTGQPZshw3Txwvyh9izKQ2Or5JJZmS4Xcv hVwkj0LnV5PsMCwDht/6pBP+gC+Pu51iDqLZkqI6js1q1mrp8AeRaBN8+ 8=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="754242266" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1d-37fd6b3d.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 30 Sep 2019 10:34:52 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1d-37fd6b3d.us-east-1.amazon.com (Postfix) with ESMTPS id 3F7A5282413; Mon, 30 Sep 2019 10:34:52 +0000 (UTC) Received: from EX13D20UEE003.ant.amazon.com (10.43.62.146) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:25 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D20UEE003.ant.amazon.com (10.43.62.146) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:25 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:24 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:29 +0100 Message-ID: <2cbd893129d3d74c927d8ce17082ed331f655af6.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 37/55] x86/smpboot: switch pl1e to use new APIs in clone_mapping X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/smpboot.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index d327c062b1..956e1bdbcc 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -666,7 +666,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) unsigned int flags; l3_pgentry_t *pl3e = NULL; l2_pgentry_t *pl2e = NULL; - l1_pgentry_t *pl1e; + l1_pgentry_t *pl1e = NULL; int rc; /* @@ -713,7 +713,8 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) } else { - pl1e = l2e_to_l1e(*pl2e) + l1_table_offset(linear); + pl1e = map_xen_pagetable_new(l2e_get_mfn(*pl2e)); + pl1e += l1_table_offset(linear); flags = l1e_get_flags(*pl1e); if ( !(flags & _PAGE_PRESENT) ) { @@ -724,6 +725,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) } } + UNMAP_XEN_PAGETABLE_NEW(pl1e); UNMAP_XEN_PAGETABLE_NEW(pl2e); UNMAP_XEN_PAGETABLE_NEW(pl3e); @@ -772,19 +774,22 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) ) { - pl1e = alloc_xen_pagetable(); - if ( !pl1e ) + mfn_t l1t_mfn = alloc_xen_pagetable_new(); + + if ( mfn_eq(l1t_mfn, INVALID_MFN) ) { rc = -ENOMEM; goto out; } + + pl1e = map_xen_pagetable_new(l1t_mfn); clear_page(pl1e); - l2e_write(pl2e, l2e_from_paddr(__pa(pl1e), __PAGE_HYPERVISOR)); + l2e_write(pl2e, l2e_from_mfn(l1t_mfn, __PAGE_HYPERVISOR)); } else { ASSERT(!(l2e_get_flags(*pl2e) & _PAGE_PSE)); - pl1e = l2e_to_l1e(*pl2e); + pl1e = map_xen_pagetable_new(l2e_get_mfn(*pl2e)); } pl1e += l1_table_offset(linear); @@ -800,6 +805,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) rc = 0; out: + UNMAP_XEN_PAGETABLE_NEW(pl1e); UNMAP_XEN_PAGETABLE_NEW(pl2e); UNMAP_XEN_PAGETABLE_NEW(pl3e); return rc; From patchwork Mon Sep 30 10:33:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166437 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 254F916B1 for ; Mon, 30 Sep 2019 10:36:33 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 00D5420679 for ; Mon, 30 Sep 2019 10:36:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="MzvShTKw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 00D5420679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1V-00084h-3N; Mon, 30 Sep 2019 10:35:21 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1U-00082j-0W for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:20 +0000 X-Inumbo-ID: f07ef23e-e36d-11e9-96cd-12813bfff9fa Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id f07ef23e-e36d-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:34:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839693; x=1601375693; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=fu4bJoN6T56Ad0vMmXWFUvvsPIUm3UDPU1ArzywSC+U=; b=MzvShTKwqFtbyosWjmCP8p+JDrM2UxC/yiGToNkE4SQRDe0x3/Gq/CNd FwwniYIYgQRVJ/AozuK+UAiZFDeBbbmur1YTKKadq0GYFCmjl36+MtIDj cfr6sXAtTzP+KIe6d2v5o1DvJuNCOCvwbscxwzp5wC53rLUiYTTfZDLks s=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="418649922" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-a70de69e.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:53 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1e-a70de69e.us-east-1.amazon.com (Postfix) with ESMTPS id 71C41A276F; Mon, 30 Sep 2019 10:34:52 +0000 (UTC) Received: from EX13D21UEE003.ant.amazon.com (10.43.62.160) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:26 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D21UEE003.ant.amazon.com (10.43.62.160) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:25 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:25 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:30 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 38/55] x86/smpboot: drop lXe_to_lYe invocations from cleanup_cpu_root_pgt X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/smpboot.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 956e1bdbcc..c55aaa65a2 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -891,23 +891,27 @@ static void cleanup_cpu_root_pgt(unsigned int cpu) r < root_table_offset(HYPERVISOR_VIRT_END); ++r ) { l3_pgentry_t *l3t; + mfn_t l3t_mfn; unsigned int i3; if ( !(root_get_flags(rpt[r]) & _PAGE_PRESENT) ) continue; - l3t = l4e_to_l3e(rpt[r]); + l3t_mfn = l4e_get_mfn(rpt[r]); + l3t = map_xen_pagetable_new(l3t_mfn); for ( i3 = 0; i3 < L3_PAGETABLE_ENTRIES; ++i3 ) { l2_pgentry_t *l2t; + mfn_t l2t_mfn; unsigned int i2; if ( !(l3e_get_flags(l3t[i3]) & _PAGE_PRESENT) ) continue; ASSERT(!(l3e_get_flags(l3t[i3]) & _PAGE_PSE)); - l2t = l3e_to_l2e(l3t[i3]); + l2t_mfn = l3e_get_mfn(l3t[i3]); + l2t = map_xen_pagetable_new(l2t_mfn); for ( i2 = 0; i2 < L2_PAGETABLE_ENTRIES; ++i2 ) { @@ -915,13 +919,15 @@ static void cleanup_cpu_root_pgt(unsigned int cpu) continue; ASSERT(!(l2e_get_flags(l2t[i2]) & _PAGE_PSE)); - free_xen_pagetable(l2e_to_l1e(l2t[i2])); + free_xen_pagetable_new(l2e_get_mfn(l2t[i2])); } - free_xen_pagetable(l2t); + UNMAP_XEN_PAGETABLE_NEW(l2t); + free_xen_pagetable_new(l2t_mfn); } - free_xen_pagetable(l3t); + UNMAP_XEN_PAGETABLE_NEW(l3t); + free_xen_pagetable_new(l3t_mfn); } free_xen_pagetable(rpt); From patchwork Mon Sep 30 10:33:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166469 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C892116B1 for ; Mon, 30 Sep 2019 10:37:14 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A3C8220679 for ; Mon, 30 Sep 2019 10:37:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="LXxXHA+A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A3C8220679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2b-0001ig-5C; Mon, 30 Sep 2019 10:36:29 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2Z-0001g7-R0 for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:36:27 +0000 X-Inumbo-ID: 27f6a162-e36e-11e9-96cd-12813bfff9fa Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id 27f6a162-e36e-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839787; x=1601375787; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=zAmGDTsrkqDrD84a7ePZyWgjTtwq2BJqD/HRmBU5vZQ=; b=LXxXHA+AbHiNgReh+rYOkDuKzfFKWAakZofBS8mPf9b2lN/7XUazkOs3 UdIOLAEF3JwlgGRVgZGLwkZsxDTwiH8oyuFy/Z1u0/9xqOgrKnfK8Vq9h felpF2gVzh8X+sexgzsu4SUlUX6DpZDAbsi9XHMZB/ISVi8kRwrFZQ9wR 0=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="705521373" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1d-474bcd9f.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 30 Sep 2019 10:35:09 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1d-474bcd9f.us-east-1.amazon.com (Postfix) with ESMTPS id C4DC3A1DBA; Mon, 30 Sep 2019 10:34:52 +0000 (UTC) Received: from EX13D23UEE003.ant.amazon.com (10.43.62.173) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:27 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D23UEE003.ant.amazon.com (10.43.62.173) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:26 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:25 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:31 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 39/55] x86: switch root_pgt to mfn_t and use new APIs X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu This then requires moving declaration of root page table mfn into mm.h and modify setup_cpu_root_pgt to have a single exit path. We also need to force map_domain_page to use direct map when switching per-domain mappings. This is contrary to our end goal of removing direct map, but this will be removed once we make map_domain_page context-switch safe in another (large) patch series. Signed-off-by: Wei Liu --- xen/arch/x86/domain.c | 15 ++++++++++--- xen/arch/x86/domain_page.c | 2 +- xen/arch/x86/mm.c | 2 +- xen/arch/x86/pv/domain.c | 2 +- xen/arch/x86/smpboot.c | 40 ++++++++++++++++++++++----------- xen/include/asm-x86/mm.h | 2 ++ xen/include/asm-x86/processor.h | 2 +- 7 files changed, 45 insertions(+), 20 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index dbdf6b1bc2..e9bf47efce 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -69,6 +69,7 @@ #include #include #include +#include DEFINE_PER_CPU(struct vcpu *, curr_vcpu); @@ -1580,12 +1581,20 @@ void paravirt_ctxt_switch_from(struct vcpu *v) void paravirt_ctxt_switch_to(struct vcpu *v) { - root_pgentry_t *root_pgt = this_cpu(root_pgt); + mfn_t rpt_mfn = this_cpu(root_pgt_mfn); - if ( root_pgt ) - root_pgt[root_table_offset(PERDOMAIN_VIRT_START)] = + if ( !mfn_eq(rpt_mfn, INVALID_MFN) ) + { + root_pgentry_t *rpt; + + mapcache_override_current(INVALID_VCPU); + rpt = map_xen_pagetable_new(rpt_mfn); + rpt[root_table_offset(PERDOMAIN_VIRT_START)] = l4e_from_page(v->domain->arch.perdomain_l3_pg, __PAGE_HYPERVISOR_RW); + UNMAP_XEN_PAGETABLE_NEW(rpt); + mapcache_override_current(NULL); + } if ( unlikely(v->arch.dr7 & DR7_ACTIVE_MASK) ) activate_debugregs(v); diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c index 24083e9a86..cfcffd35f3 100644 --- a/xen/arch/x86/domain_page.c +++ b/xen/arch/x86/domain_page.c @@ -57,7 +57,7 @@ static inline struct vcpu *mapcache_current_vcpu(void) return v; } -void __init mapcache_override_current(struct vcpu *v) +void mapcache_override_current(struct vcpu *v) { this_cpu(override) = v; } diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 8706dc0174..5c1d65d267 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -530,7 +530,7 @@ void write_ptbase(struct vcpu *v) if ( is_pv_vcpu(v) && v->domain->arch.pv.xpti ) { cpu_info->root_pgt_changed = true; - cpu_info->pv_cr3 = __pa(this_cpu(root_pgt)); + cpu_info->pv_cr3 = mfn_to_maddr(this_cpu(root_pgt_mfn)); if ( new_cr4 & X86_CR4_PCIDE ) cpu_info->pv_cr3 |= get_pcid_bits(v, true); switch_cr3_cr4(v->arch.cr3, new_cr4); diff --git a/xen/arch/x86/pv/domain.c b/xen/arch/x86/pv/domain.c index 4b6f48dea2..7e70690f03 100644 --- a/xen/arch/x86/pv/domain.c +++ b/xen/arch/x86/pv/domain.c @@ -360,7 +360,7 @@ static void _toggle_guest_pt(struct vcpu *v) if ( d->arch.pv.xpti ) { cpu_info->root_pgt_changed = true; - cpu_info->pv_cr3 = __pa(this_cpu(root_pgt)) | + cpu_info->pv_cr3 = mfn_to_maddr(this_cpu(root_pgt_mfn)) | (d->arch.pv.pcid ? get_pcid_bits(v, true) : 0); } diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index c55aaa65a2..ca8fc6d485 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -811,7 +811,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) return rc; } -DEFINE_PER_CPU(root_pgentry_t *, root_pgt); +DEFINE_PER_CPU(mfn_t, root_pgt_mfn); static root_pgentry_t common_pgt; @@ -819,19 +819,27 @@ extern const char _stextentry[], _etextentry[]; static int setup_cpu_root_pgt(unsigned int cpu) { - root_pgentry_t *rpt; + root_pgentry_t *rpt = NULL; + mfn_t rpt_mfn; unsigned int off; int rc; if ( !opt_xpti_hwdom && !opt_xpti_domu ) - return 0; + { + rc = 0; + goto out; + } - rpt = alloc_xen_pagetable(); - if ( !rpt ) - return -ENOMEM; + rpt_mfn = alloc_xen_pagetable_new(); + if ( mfn_eq(rpt_mfn, INVALID_MFN) ) + { + rc = -ENOMEM; + goto out; + } + rpt = map_xen_pagetable_new(rpt_mfn); clear_page(rpt); - per_cpu(root_pgt, cpu) = rpt; + per_cpu(root_pgt_mfn, cpu) = rpt_mfn; rpt[root_table_offset(RO_MPT_VIRT_START)] = idle_pg_table[root_table_offset(RO_MPT_VIRT_START)]; @@ -848,7 +856,7 @@ static int setup_cpu_root_pgt(unsigned int cpu) rc = clone_mapping(ptr, rpt); if ( rc ) - return rc; + goto out; common_pgt = rpt[root_table_offset(XEN_VIRT_START)]; } @@ -873,19 +881,24 @@ static int setup_cpu_root_pgt(unsigned int cpu) if ( !rc ) rc = clone_mapping((void *)per_cpu(stubs.addr, cpu), rpt); + out: + UNMAP_XEN_PAGETABLE_NEW(rpt); return rc; } static void cleanup_cpu_root_pgt(unsigned int cpu) { - root_pgentry_t *rpt = per_cpu(root_pgt, cpu); + mfn_t rpt_mfn = per_cpu(root_pgt_mfn, cpu); + root_pgentry_t *rpt; unsigned int r; unsigned long stub_linear = per_cpu(stubs.addr, cpu); - if ( !rpt ) + if ( mfn_eq(rpt_mfn, INVALID_MFN) ) return; - per_cpu(root_pgt, cpu) = NULL; + per_cpu(root_pgt_mfn, cpu) = INVALID_MFN; + + rpt = map_xen_pagetable_new(rpt_mfn); for ( r = root_table_offset(DIRECTMAP_VIRT_START); r < root_table_offset(HYPERVISOR_VIRT_END); ++r ) @@ -930,7 +943,8 @@ static void cleanup_cpu_root_pgt(unsigned int cpu) free_xen_pagetable_new(l3t_mfn); } - free_xen_pagetable(rpt); + UNMAP_XEN_PAGETABLE_NEW(rpt); + free_xen_pagetable_new(rpt_mfn); /* Also zap the stub mapping for this CPU. */ if ( stub_linear ) @@ -1134,7 +1148,7 @@ void __init smp_prepare_cpus(void) rc = setup_cpu_root_pgt(0); if ( rc ) panic("Error %d setting up PV root page table\n", rc); - if ( per_cpu(root_pgt, 0) ) + if ( !mfn_eq(per_cpu(root_pgt_mfn, 0), INVALID_MFN) ) { get_cpu_info()->pv_cr3 = 0; diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 80173eb4c3..12a10b270d 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -646,4 +646,6 @@ void free_xen_pagetable_new(mfn_t mfn); l1_pgentry_t *virt_to_xen_l1e(unsigned long v); +DECLARE_PER_CPU(mfn_t, root_pgt_mfn); + #endif /* __ASM_X86_MM_H__ */ diff --git a/xen/include/asm-x86/processor.h b/xen/include/asm-x86/processor.h index c6fc1987a1..68d1d82071 100644 --- a/xen/include/asm-x86/processor.h +++ b/xen/include/asm-x86/processor.h @@ -469,7 +469,7 @@ static inline void disable_each_ist(idt_entry_t *idt) extern idt_entry_t idt_table[]; extern idt_entry_t *idt_tables[]; -DECLARE_PER_CPU(root_pgentry_t *, root_pgt); +DECLARE_PER_CPU(struct tss_struct, init_tss); extern void write_ptbase(struct vcpu *v); From patchwork Mon Sep 30 10:33:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166419 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9B0BE16B1 for ; Mon, 30 Sep 2019 10:36:12 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 774BB20679 for ; Mon, 30 Sep 2019 10:36:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="fjQ8GW7y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 774BB20679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1a-0008D3-AF; Mon, 30 Sep 2019 10:35:26 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1Y-0008Au-Tb for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:24 +0000 X-Inumbo-ID: f07ef241-e36d-11e9-96cd-12813bfff9fa Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id f07ef241-e36d-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839694; x=1601375694; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=3SN61TJ04n0xBCYnr1+TtV3siYlmPBFZgsnjGBXinLs=; b=fjQ8GW7yi4uXR9kzpdooTTvgSGzNfWhqY1WFtrfAjopL1yWQFA2dN3Px SPUitb4V+Y5NSZUX012nt3lcfLjEP93o1FFMCt1v0Ade8qElvFLuH5Xu9 S2vP3/BjaLX70u958urzArextt1fvh32lgSNvIcsZCP8gbBxs1Ke6Q2hZ A=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="418649933" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-62350142.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:54 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-62350142.us-east-1.amazon.com (Postfix) with ESMTPS id 0F3B3A177E; Mon, 30 Sep 2019 10:34:53 +0000 (UTC) Received: from EX13D03UEE003.ant.amazon.com (10.43.62.105) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:28 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D03UEE003.ant.amazon.com (10.43.62.105) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:27 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:26 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:32 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 40/55] x86/shim: map and unmap page tables in replace_va_mapping X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/pv/shim.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c index 324ca27f93..cf638fa965 100644 --- a/xen/arch/x86/pv/shim.c +++ b/xen/arch/x86/pv/shim.c @@ -167,15 +167,25 @@ static void __init replace_va_mapping(struct domain *d, l4_pgentry_t *l4start, unsigned long va, mfn_t mfn) { l4_pgentry_t *pl4e = l4start + l4_table_offset(va); - l3_pgentry_t *pl3e = l4e_to_l3e(*pl4e) + l3_table_offset(va); - l2_pgentry_t *pl2e = l3e_to_l2e(*pl3e) + l2_table_offset(va); - l1_pgentry_t *pl1e = l2e_to_l1e(*pl2e) + l1_table_offset(va); - struct page_info *page = mfn_to_page(l1e_get_mfn(*pl1e)); + l3_pgentry_t *pl3e; + l2_pgentry_t *pl2e; + l1_pgentry_t *pl1e; - put_page_and_type(page); + pl3e = map_xen_pagetable_new(l4e_get_mfn(*pl4e)); + pl3e += l3_table_offset(va); + pl2e = map_xen_pagetable_new(l3e_get_mfn(*pl3e)); + pl2e += l2_table_offset(va); + pl1e = map_xen_pagetable_new(l2e_get_mfn(*pl2e)); + pl1e += l1_table_offset(va); + + put_page_and_type(mfn_to_page(l1e_get_mfn(*pl1e))); *pl1e = l1e_from_mfn(mfn, (!is_pv_32bit_domain(d) ? L1_PROT : COMPAT_L1_PROT)); + + UNMAP_XEN_PAGETABLE_NEW(pl1e); + UNMAP_XEN_PAGETABLE_NEW(pl2e); + UNMAP_XEN_PAGETABLE_NEW(pl3e); } static void evtchn_reserve(struct domain *d, unsigned int port) From patchwork Mon Sep 30 10:33:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166471 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87E8216B1 for ; Mon, 30 Sep 2019 10:37:17 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6490420679 for ; Mon, 30 Sep 2019 10:37:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="LtgBtLKC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6490420679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2c-0001lj-Pw; Mon, 30 Sep 2019 10:36:30 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2a-0001iC-VS for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:36:28 +0000 X-Inumbo-ID: 1c628834-e36e-11e9-97fb-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 1c628834-e36e-11e9-97fb-bc764e2007e4; Mon, 30 Sep 2019 10:36:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839767; x=1601375767; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=njdESk/6JcRZulToFGIspsgQKCCPqIrWPc225saYE8A=; b=LtgBtLKCQvCFGxCMlmj1vaO2lvyaylM7zN/v1uEQi5eTKq0I1Zol5FFP vCoWpeRPNZC6kfeP4iRZlw50kYlyIqm3Af65BjEGg+zEk42vezLP3M1FH SIg1tzg94uQ32Kr6z4OJtQDpfrkA7VVCJkMRGJ3oT1ODMKDA5r8OC8hDG g=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="838005677" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1e-303d0b0e.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 30 Sep 2019 10:35:07 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-303d0b0e.us-east-1.amazon.com (Postfix) with ESMTPS id 9DEB7A27FA; Mon, 30 Sep 2019 10:34:53 +0000 (UTC) Received: from EX13D05UEE004.ant.amazon.com (10.43.62.189) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:28 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D05UEE004.ant.amazon.com (10.43.62.189) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:28 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:27 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:33 +0100 Message-ID: <5cebde845cbd886a723a0207e4412c90c2943151.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 41/55] x86_64/mm: map and unmap page tables in m2p_mapped X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/x86_64/mm.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index c41715cd56..5c5b91b785 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -130,28 +130,36 @@ static int m2p_mapped(unsigned long spfn) { unsigned long va; l3_pgentry_t *l3_ro_mpt; - l2_pgentry_t *l2_ro_mpt; + l2_pgentry_t *l2_ro_mpt = NULL; + int rc = M2P_NO_MAPPED; va = RO_MPT_VIRT_START + spfn * sizeof(*machine_to_phys_mapping); - l3_ro_mpt = l4e_to_l3e(idle_pg_table[l4_table_offset(va)]); + l3_ro_mpt = map_xen_pagetable_new( + l4e_get_mfn(idle_pg_table[l4_table_offset(va)])); switch ( l3e_get_flags(l3_ro_mpt[l3_table_offset(va)]) & (_PAGE_PRESENT |_PAGE_PSE)) { case _PAGE_PSE|_PAGE_PRESENT: - return M2P_1G_MAPPED; + rc = M2P_1G_MAPPED; + goto out; /* Check for next level */ case _PAGE_PRESENT: break; default: - return M2P_NO_MAPPED; + rc = M2P_NO_MAPPED; + goto out; } - l2_ro_mpt = l3e_to_l2e(l3_ro_mpt[l3_table_offset(va)]); + l2_ro_mpt = map_xen_pagetable_new( + l3e_get_mfn(l3_ro_mpt[l3_table_offset(va)])); if (l2e_get_flags(l2_ro_mpt[l2_table_offset(va)]) & _PAGE_PRESENT) - return M2P_2M_MAPPED; + rc = M2P_2M_MAPPED; - return M2P_NO_MAPPED; + out: + UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); + UNMAP_XEN_PAGETABLE_NEW(l3_ro_mpt); + return rc; } static int share_hotadd_m2p_table(struct mem_hotadd_info *info) From patchwork Mon Sep 30 10:33:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166473 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 95E5613BD for ; Mon, 30 Sep 2019 10:37:20 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 71D0A20679 for ; Mon, 30 Sep 2019 10:37:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="VFAvDjos" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 71D0A20679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2g-0001sd-GL; Mon, 30 Sep 2019 10:36:34 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2e-0001pe-Rw for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:36:32 +0000 X-Inumbo-ID: 27f6a163-e36e-11e9-96cd-12813bfff9fa Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id 27f6a163-e36e-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839787; x=1601375787; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=WLaUPO0BICOlTo8lrwIXoV4f6i7Lhrd58+XYW4xXr9k=; b=VFAvDjosPkjiL8SbA1hcVrK/AH5o3SOCoB+JE6Tp3XXqmghNfaoC0Avl GqmzwT5kjUB1WsvmOntkM6Ipd50/3zAlEIsBfwTIxvYWifYxdZkjkd983 y7wlUTqrBePYeJ2w3m84bhM17Q6uhSBPCFDxMamVrh1Nkh/LDqvSisTWQ g=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="705521380" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1a-807d4a99.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 30 Sep 2019 10:35:10 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-807d4a99.us-east-1.amazon.com (Postfix) with ESMTPS id 20A47A3062; Mon, 30 Sep 2019 10:34:54 +0000 (UTC) Received: from EX13D10UEE002.ant.amazon.com (10.43.62.136) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:29 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D10UEE002.ant.amazon.com (10.43.62.136) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:29 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:28 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:34 +0100 Message-ID: <301133c7156c2f2875a62614110fb6ac69c7829a.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 42/55] x86_64/mm: map and unmap page tables in share_hotadd_m2p_table X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/x86_64/mm.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 5c5b91b785..e0d2190be1 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -166,8 +166,8 @@ static int share_hotadd_m2p_table(struct mem_hotadd_info *info) { unsigned long i, n, v; mfn_t m2p_start_mfn = INVALID_MFN; - l3_pgentry_t l3e; - l2_pgentry_t l2e; + l3_pgentry_t l3e, *l3t; + l2_pgentry_t l2e, *l2t; /* M2P table is mappable read-only by privileged domains. */ for ( v = RDWR_MPT_VIRT_START; @@ -175,14 +175,22 @@ static int share_hotadd_m2p_table(struct mem_hotadd_info *info) v += n << PAGE_SHIFT ) { n = L2_PAGETABLE_ENTRIES * L1_PAGETABLE_ENTRIES; - l3e = l4e_to_l3e(idle_pg_table[l4_table_offset(v)])[ - l3_table_offset(v)]; + + l3t = map_xen_pagetable_new( + l4e_get_mfn(idle_pg_table[l4_table_offset(v)])); + l3e = l3t[l3_table_offset(v)]; + UNMAP_XEN_PAGETABLE_NEW(l3t); + if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) continue; if ( !(l3e_get_flags(l3e) & _PAGE_PSE) ) { n = L1_PAGETABLE_ENTRIES; - l2e = l3e_to_l2e(l3e)[l2_table_offset(v)]; + + l2t = map_xen_pagetable_new(l3e_get_mfn(l3e)); + l2e = l2t[l2_table_offset(v)]; + UNMAP_XEN_PAGETABLE_NEW(l2t); + if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) ) continue; m2p_start_mfn = l2e_get_mfn(l2e); @@ -203,11 +211,18 @@ static int share_hotadd_m2p_table(struct mem_hotadd_info *info) v != RDWR_COMPAT_MPT_VIRT_END; v += 1 << L2_PAGETABLE_SHIFT ) { - l3e = l4e_to_l3e(idle_pg_table[l4_table_offset(v)])[ - l3_table_offset(v)]; + l3t = map_xen_pagetable_new( + l4e_get_mfn(idle_pg_table[l4_table_offset(v)])); + l3e = l3t[l3_table_offset(v)]; + UNMAP_XEN_PAGETABLE_NEW(l3t); + if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) continue; - l2e = l3e_to_l2e(l3e)[l2_table_offset(v)]; + + l2t = map_xen_pagetable_new(l3e_get_mfn(l3e)); + l2e = l2t[l2_table_offset(v)]; + UNMAP_XEN_PAGETABLE_NEW(l2t); + if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) ) continue; m2p_start_mfn = l2e_get_mfn(l2e); From patchwork Mon Sep 30 10:33:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166455 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4DFA113BD for ; Mon, 30 Sep 2019 10:36:48 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 29B3C20679 for ; Mon, 30 Sep 2019 10:36:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="ABAetlM1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29B3C20679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1k-0008Um-0z; Mon, 30 Sep 2019 10:35:36 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1i-0008Sk-U1 for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:34 +0000 X-Inumbo-ID: f2aad050-e36d-11e9-96cd-12813bfff9fa Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id f2aad050-e36d-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:34:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839697; x=1601375697; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Ni0X70rMd4HiEival1ohb3qxb2lcIMo1JhaaSjsq/ps=; b=ABAetlM1Kmof1RSxqDsgRwuF8ltxb9wVEm8eTwnQmjdfOPtRGM1+WZaM SrTeJ8PCTfRRaPHX3EQLa8F01bp0qXShg1lz/adPkpLNUTEI7Y29aYIH3 mAACbflDPQ53zh2bgJU5JjnV6R5WmjRcScIOLl6lYr5T+YKyPrDx+OjrH Y=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="418649944" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-62350142.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:56 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-62350142.us-east-1.amazon.com (Postfix) with ESMTPS id E88C4A123A; Mon, 30 Sep 2019 10:34:54 +0000 (UTC) Received: from EX13D14UEE003.ant.amazon.com (10.43.62.11) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:30 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D14UEE003.ant.amazon.com (10.43.62.11) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:30 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:29 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:35 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 43/55] x86_64/mm: map and unmap page tables in destroy_compat_m2p_mapping X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/x86_64/mm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index e0d2190be1..2fff5f9306 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -252,11 +252,13 @@ static void destroy_compat_m2p_mapping(struct mem_hotadd_info *info) if ( emap > ((RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START) >> 2) ) emap = (RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START) >> 2; - l3_ro_mpt = l4e_to_l3e(idle_pg_table[l4_table_offset(HIRO_COMPAT_MPT_VIRT_START)]); + l3_ro_mpt = map_xen_pagetable_new( + l4e_get_mfn(idle_pg_table[l4_table_offset(HIRO_COMPAT_MPT_VIRT_START)])); ASSERT(l3e_get_flags(l3_ro_mpt[l3_table_offset(HIRO_COMPAT_MPT_VIRT_START)]) & _PAGE_PRESENT); - l2_ro_mpt = l3e_to_l2e(l3_ro_mpt[l3_table_offset(HIRO_COMPAT_MPT_VIRT_START)]); + l2_ro_mpt = map_xen_pagetable_new( + l3e_get_mfn(l3_ro_mpt[l3_table_offset(HIRO_COMPAT_MPT_VIRT_START)])); for ( i = smap; i < emap; ) { @@ -278,6 +280,9 @@ static void destroy_compat_m2p_mapping(struct mem_hotadd_info *info) i += 1UL << (L2_PAGETABLE_SHIFT - 2); } + UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); + UNMAP_XEN_PAGETABLE_NEW(l3_ro_mpt); + return; } From patchwork Mon Sep 30 10:33:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166447 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0310613BD for ; Mon, 30 Sep 2019 10:36:40 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D370820679 for ; Mon, 30 Sep 2019 10:36:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="pJoBZzlx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D370820679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1f-0008Mk-Sz; Mon, 30 Sep 2019 10:35:31 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1d-0008JF-TW for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:29 +0000 X-Inumbo-ID: f15782e0-e36d-11e9-96cd-12813bfff9fa Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id f15782e0-e36d-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:34:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839695; x=1601375695; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=GcGaU3T/FyplS83xbErSj/1YIbxmGvXcFYgUGeeyEZg=; b=pJoBZzlxfrI6kiDh0d1A7SoIU0q0Ed/cGfB/M99XZx8N+z1TCbn7jBKy iSN4I2AsiapB+1qqgtrUwmbl2rkNHdguYCWcAAc7+a/0AHtdL91HdGRDs bDsfFqMKZcAASbC//CT4BCb5DBm5Mnc7HremRXjtPnY26VA7E1fn0Q41v w=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="418649938" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-62350142.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:55 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-62350142.us-east-1.amazon.com (Postfix) with ESMTPS id 62441A1CCD; Mon, 30 Sep 2019 10:34:55 +0000 (UTC) Received: from EX13D21UEE003.ant.amazon.com (10.43.62.160) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:31 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D21UEE003.ant.amazon.com (10.43.62.160) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:31 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:30 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:36 +0100 Message-ID: <5f30e1eae274645434f59deee6dfd763dee84c20.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 44/55] x86_64/mm: map and unmap page tables in destroy_m2p_mapping X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/x86_64/mm.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 2fff5f9306..1d2ebd642f 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -292,7 +292,8 @@ static void destroy_m2p_mapping(struct mem_hotadd_info *info) unsigned long i, va, rwva; unsigned long smap = info->spfn, emap = info->epfn; - l3_ro_mpt = l4e_to_l3e(idle_pg_table[l4_table_offset(RO_MPT_VIRT_START)]); + l3_ro_mpt = map_xen_pagetable_new( + l4e_get_mfn(idle_pg_table[l4_table_offset(RO_MPT_VIRT_START)])); /* * No need to clean m2p structure existing before the hotplug @@ -314,26 +315,35 @@ static void destroy_m2p_mapping(struct mem_hotadd_info *info) continue; } - l2_ro_mpt = l3e_to_l2e(l3_ro_mpt[l3_table_offset(va)]); + l2_ro_mpt = map_xen_pagetable_new( + l3e_get_mfn(l3_ro_mpt[l3_table_offset(va)])); if (!(l2e_get_flags(l2_ro_mpt[l2_table_offset(va)]) & _PAGE_PRESENT)) { i = ( i & ~((1UL << (L2_PAGETABLE_SHIFT - 3)) - 1)) + (1UL << (L2_PAGETABLE_SHIFT - 3)) ; + UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); continue; } pt_pfn = l2e_get_pfn(l2_ro_mpt[l2_table_offset(va)]); if ( hotadd_mem_valid(pt_pfn, info) ) { + l2_pgentry_t *l2t; + destroy_xen_mappings(rwva, rwva + (1UL << L2_PAGETABLE_SHIFT)); - l2_ro_mpt = l3e_to_l2e(l3_ro_mpt[l3_table_offset(va)]); - l2e_write(&l2_ro_mpt[l2_table_offset(va)], l2e_empty()); + l2t = map_xen_pagetable_new( + l3e_get_mfn(l3_ro_mpt[l3_table_offset(va)])); + l2e_write(&l2t[l2_table_offset(va)], l2e_empty()); + UNMAP_XEN_PAGETABLE_NEW(l2t); } i = ( i & ~((1UL << (L2_PAGETABLE_SHIFT - 3)) - 1)) + (1UL << (L2_PAGETABLE_SHIFT - 3)); + UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); } + UNMAP_XEN_PAGETABLE_NEW(l3_ro_mpt); + destroy_compat_m2p_mapping(info); /* Brute-Force flush all TLB */ From patchwork Mon Sep 30 10:33:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166475 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 378C11709 for ; Mon, 30 Sep 2019 10:37:21 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 140C420679 for ; Mon, 30 Sep 2019 10:37:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="TOASnwO/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 140C420679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2i-0001vN-2a; Mon, 30 Sep 2019 10:36:36 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2f-0001rf-UT for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:36:33 +0000 X-Inumbo-ID: 1d975824-e36e-11e9-97fb-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 1d975824-e36e-11e9-97fb-bc764e2007e4; Mon, 30 Sep 2019 10:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839769; x=1601375769; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=FkCiWRcyyS94XOIYsLNshumBozBwBJwF/QaEiXmKu/o=; b=TOASnwO/oGNrqyLIBTpUt266SpOCSnmq+c4c978MzxX2K46M037A+JH/ Au/TYbUiisx218wJZI0ir/Iio5ahuvPOH6PWonKB/gI/e3W2MosWX+CAT psRV+HxZJzkwT7DGwLv2sKzd577wvBSJpCi0TcADOs8HD0gI3rcvVGX7i o=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="838005687" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1e-17c49630.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 30 Sep 2019 10:35:09 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-17c49630.us-east-1.amazon.com (Postfix) with ESMTPS id CE308A228C; Mon, 30 Sep 2019 10:34:55 +0000 (UTC) Received: from EX13D06UEE001.ant.amazon.com (10.43.62.79) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:32 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D06UEE001.ant.amazon.com (10.43.62.79) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:32 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:31 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:37 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 45/55] x86_64/mm: map and unmap page tables in setup_compat_m2p_table X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/x86_64/mm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 1d2ebd642f..e8ed04006f 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -382,11 +382,13 @@ static int setup_compat_m2p_table(struct mem_hotadd_info *info) va = HIRO_COMPAT_MPT_VIRT_START + smap * sizeof(*compat_machine_to_phys_mapping); - l3_ro_mpt = l4e_to_l3e(idle_pg_table[l4_table_offset(va)]); + l3_ro_mpt = map_xen_pagetable_new( + l4e_get_mfn(idle_pg_table[l4_table_offset(va)])); ASSERT(l3e_get_flags(l3_ro_mpt[l3_table_offset(va)]) & _PAGE_PRESENT); - l2_ro_mpt = l3e_to_l2e(l3_ro_mpt[l3_table_offset(va)]); + l2_ro_mpt = map_xen_pagetable_new( + l3e_get_mfn(l3_ro_mpt[l3_table_offset(va)])); #define MFN(x) (((x) << L2_PAGETABLE_SHIFT) / sizeof(unsigned int)) #define CNT ((sizeof(*frame_table) & -sizeof(*frame_table)) / \ @@ -424,6 +426,9 @@ static int setup_compat_m2p_table(struct mem_hotadd_info *info) } #undef CNT #undef MFN + + UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); + UNMAP_XEN_PAGETABLE_NEW(l3_ro_mpt); return err; } From patchwork Mon Sep 30 10:33:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166451 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E33D1709 for ; Mon, 30 Sep 2019 10:36:45 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 292FF216F4 for ; Mon, 30 Sep 2019 10:36:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="oa/VuZEF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 292FF216F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1j-0008Ti-Fo; Mon, 30 Sep 2019 10:35:35 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1h-0008R4-Sv for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:33 +0000 X-Inumbo-ID: f3b77aca-e36d-11e9-bf31-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id f3b77aca-e36d-11e9-bf31-bc764e2007e4; Mon, 30 Sep 2019 10:34:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839699; x=1601375699; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=tnsY6sk0GhpJFaaUtzYqCtBKQqlr8VhDGBJrjT/+Ks4=; b=oa/VuZEFRkdRQ6T7SE8FOz+Omk+XNMu5N9TiIdD+lufEZ3Z9Gt7cA6Zk 3mBeFbmB3RgbfQwmc4XtQw4/I3R/vsccqQAx7L3Mb9OFudqUYQ+PVe2+J 1W8cL2vLKp7kiGkK+btsoiRKPsD5YD1iqLb8LItioYqHVbde50YD3LfXj Y=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="424630173" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-7d76a15f.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:58 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-7d76a15f.us-east-1.amazon.com (Postfix) with ESMTPS id 59351A26CE; Mon, 30 Sep 2019 10:34:56 +0000 (UTC) Received: from EX13D11UEE001.ant.amazon.com (10.43.62.132) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:33 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D11UEE001.ant.amazon.com (10.43.62.132) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:33 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:32 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:38 +0100 Message-ID: <33ae537f3170d032a63b3a93b49b5d280e777bec.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 46/55] x86_64/mm: map and unmap page tables in cleanup_frame_table X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/x86_64/mm.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index e8ed04006f..8d13c994af 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -801,8 +801,8 @@ void free_compat_arg_xlat(struct vcpu *v) static void cleanup_frame_table(struct mem_hotadd_info *info) { unsigned long sva, eva; - l3_pgentry_t l3e; - l2_pgentry_t l2e; + l3_pgentry_t l3e, *l3t; + l2_pgentry_t l2e, *l2t; mfn_t spfn, epfn; spfn = _mfn(info->spfn); @@ -816,8 +816,10 @@ static void cleanup_frame_table(struct mem_hotadd_info *info) while (sva < eva) { - l3e = l4e_to_l3e(idle_pg_table[l4_table_offset(sva)])[ - l3_table_offset(sva)]; + l3t = map_xen_pagetable_new( + l4e_get_mfn(idle_pg_table[l4_table_offset(sva)])); + l3e = l3t[l3_table_offset(sva)]; + UNMAP_XEN_PAGETABLE_NEW(l3t); if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) || (l3e_get_flags(l3e) & _PAGE_PSE) ) { @@ -826,7 +828,9 @@ static void cleanup_frame_table(struct mem_hotadd_info *info) continue; } - l2e = l3e_to_l2e(l3e)[l2_table_offset(sva)]; + l2t = map_xen_pagetable_new(l3e_get_mfn(l3e)); + l2e = l2t[l2_table_offset(sva)]; + UNMAP_XEN_PAGETABLE_NEW(l2t); ASSERT(l2e_get_flags(l2e) & _PAGE_PRESENT); if ( (l2e_get_flags(l2e) & (_PAGE_PRESENT | _PAGE_PSE)) == @@ -842,8 +846,14 @@ static void cleanup_frame_table(struct mem_hotadd_info *info) continue; } - ASSERT(l1e_get_flags(l2e_to_l1e(l2e)[l1_table_offset(sva)]) & - _PAGE_PRESENT); +#ifndef NDEBUG + { + l1_pgentry_t *l1t = map_xen_pagetable_new(l2e_get_mfn(l2e)); + ASSERT(l1e_get_flags(l1t[l1_table_offset(sva)]) & + _PAGE_PRESENT); + UNMAP_XEN_PAGETABLE_NEW(l1t); + } +#endif sva = (sva & ~((1UL << PAGE_SHIFT) - 1)) + (1UL << PAGE_SHIFT); } From patchwork Mon Sep 30 10:33:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166425 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D0F801709 for ; Mon, 30 Sep 2019 10:36:14 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD25120679 for ; Mon, 30 Sep 2019 10:36:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="V6URGGHB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD25120679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1Z-0008C4-M6; Mon, 30 Sep 2019 10:35:25 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1X-00089J-S2 for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:23 +0000 X-Inumbo-ID: f2b4fe68-e36d-11e9-b588-bc764e2007e4 Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id f2b4fe68-e36d-11e9-b588-bc764e2007e4; Mon, 30 Sep 2019 10:34:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839697; x=1601375697; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=d/Cw5FF0vm0gT98yS1Zb7tJv/m7TKS2UrIp9mbKuaiY=; b=V6URGGHB5LyANKZBZbPHIAPHXbRfXcbyKjgowMbGa+5/Y1gLQ6qkTM02 /DpfceI/Gln1bIJ0OosCn6u+467NrMNgWcrxxiKS3W7orbvEl0mCRsRx0 JhQBqbbMzibNNVag82OM2ySVMYqgujscPzbrzaz028iA7dAZlIRu3GCqn o=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="418649946" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-98acfc19.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 30 Sep 2019 10:34:57 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-98acfc19.us-east-1.amazon.com (Postfix) with ESMTPS id EB280A03AD; Mon, 30 Sep 2019 10:34:56 +0000 (UTC) Received: from EX13D14UEE004.ant.amazon.com (10.43.62.145) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:34 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D14UEE004.ant.amazon.com (10.43.62.145) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:34 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:33 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:39 +0100 Message-ID: <3cdfbe62e567747a8fa24ecc8bebfd9f0ffdb65f.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 47/55] x86_64/mm: map and unmap page tables in subarch_init_memory X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/x86_64/mm.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 8d13c994af..7a02fcee18 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -930,8 +930,8 @@ static int extend_frame_table(struct mem_hotadd_info *info) void __init subarch_init_memory(void) { unsigned long i, n, v, m2p_start_mfn; - l3_pgentry_t l3e; - l2_pgentry_t l2e; + l3_pgentry_t l3e, *l3t; + l2_pgentry_t l2e, *l2t; BUILD_BUG_ON(RDWR_MPT_VIRT_START & ((1UL << L3_PAGETABLE_SHIFT) - 1)); BUILD_BUG_ON(RDWR_MPT_VIRT_END & ((1UL << L3_PAGETABLE_SHIFT) - 1)); @@ -941,14 +941,22 @@ void __init subarch_init_memory(void) v += n << PAGE_SHIFT ) { n = L2_PAGETABLE_ENTRIES * L1_PAGETABLE_ENTRIES; - l3e = l4e_to_l3e(idle_pg_table[l4_table_offset(v)])[ - l3_table_offset(v)]; + + l3t = map_xen_pagetable_new( + l4e_get_mfn(idle_pg_table[l4_table_offset(v)])); + l3e = l3t[l3_table_offset(v)]; + UNMAP_XEN_PAGETABLE_NEW(l3t); + if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) continue; if ( !(l3e_get_flags(l3e) & _PAGE_PSE) ) { n = L1_PAGETABLE_ENTRIES; - l2e = l3e_to_l2e(l3e)[l2_table_offset(v)]; + + l2t = map_xen_pagetable_new(l3e_get_mfn(l3e)); + l2e = l2t[l2_table_offset(v)]; + UNMAP_XEN_PAGETABLE_NEW(l2t); + if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) ) continue; m2p_start_mfn = l2e_get_pfn(l2e); @@ -967,11 +975,18 @@ void __init subarch_init_memory(void) v != RDWR_COMPAT_MPT_VIRT_END; v += 1 << L2_PAGETABLE_SHIFT ) { - l3e = l4e_to_l3e(idle_pg_table[l4_table_offset(v)])[ - l3_table_offset(v)]; + l3t = map_xen_pagetable_new( + l4e_get_mfn(idle_pg_table[l4_table_offset(v)])); + l3e = l3t[l3_table_offset(v)]; + UNMAP_XEN_PAGETABLE_NEW(l3t); + if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) continue; - l2e = l3e_to_l2e(l3e)[l2_table_offset(v)]; + + l2t = map_xen_pagetable_new(l3e_get_mfn(l3e)); + l2e = l2t[l2_table_offset(v)]; + UNMAP_XEN_PAGETABLE_NEW(l2t); + if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) ) continue; m2p_start_mfn = l2e_get_pfn(l2e); From patchwork Mon Sep 30 10:33:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166445 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B8F1C16B1 for ; Mon, 30 Sep 2019 10:36:39 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9490521855 for ; Mon, 30 Sep 2019 10:36:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="BDgdtcVy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9490521855 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1d-0008JS-Uz; Mon, 30 Sep 2019 10:35:29 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1c-0008Ha-Ri for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:28 +0000 X-Inumbo-ID: f3adf586-e36d-11e9-97fb-bc764e2007e4 Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id f3adf586-e36d-11e9-97fb-bc764e2007e4; Mon, 30 Sep 2019 10:34:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839699; x=1601375699; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=JeCSzuzQJ/zRBnzL/d6gNFIcOFOq1Tdq+RtL5CVDeD8=; b=BDgdtcVys7WIy4oK4mblDXQZQDoXkw5Rw3UyuWlVU0izYif83Vfrt2L0 6BenL/MP6pwbcs0XvRzZiMOFgeTLA1heqnGyyUi0jxSDy5tv4l/xgYn2S m6g7TntwqwAICTOLYSh0m4XcW/kp269uSuNljPYAa0fx55ARBu1Ma+e6X Q=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="788414738" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-74cf8b49.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 30 Sep 2019 10:34:58 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1d-74cf8b49.us-east-1.amazon.com (Postfix) with ESMTPS id 79BEDC18BF; Mon, 30 Sep 2019 10:34:57 +0000 (UTC) Received: from EX13D23UEE001.ant.amazon.com (10.43.62.101) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:35 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D23UEE001.ant.amazon.com (10.43.62.101) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:35 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:34 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:40 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 48/55] x86_64/mm: map and unmap page tables in subarch_memory_op X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/x86_64/mm.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 7a02fcee18..a1c69d7f0e 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -1016,8 +1016,8 @@ void __init subarch_init_memory(void) long subarch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) { struct xen_machphys_mfn_list xmml; - l3_pgentry_t l3e; - l2_pgentry_t l2e; + l3_pgentry_t l3e, *l3t; + l2_pgentry_t l2e, *l2t; unsigned long v, limit; xen_pfn_t mfn, last_mfn; unsigned int i; @@ -1036,13 +1036,18 @@ long subarch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) (v < (unsigned long)(machine_to_phys_mapping + max_page)); i++, v += 1UL << L2_PAGETABLE_SHIFT ) { - l3e = l4e_to_l3e(idle_pg_table[l4_table_offset(v)])[ - l3_table_offset(v)]; + l3t = map_xen_pagetable_new( + l4e_get_mfn(idle_pg_table[l4_table_offset(v)])); + l3e = l3t[l3_table_offset(v)]; + UNMAP_XEN_PAGETABLE_NEW(l3t); + if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) mfn = last_mfn; else if ( !(l3e_get_flags(l3e) & _PAGE_PSE) ) { - l2e = l3e_to_l2e(l3e)[l2_table_offset(v)]; + l2t = map_xen_pagetable_new(l3e_get_mfn(l3e)); + l2e = l2t[l2_table_offset(v)]; + UNMAP_XEN_PAGETABLE_NEW(l2t); if ( l2e_get_flags(l2e) & _PAGE_PRESENT ) mfn = l2e_get_pfn(l2e); else From patchwork Mon Sep 30 10:33:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166433 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5506D16B1 for ; Mon, 30 Sep 2019 10:36:29 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 31B6620679 for ; Mon, 30 Sep 2019 10:36:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="RQF+XDF+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31B6620679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1q-0000Fz-9i; Mon, 30 Sep 2019 10:35:42 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1n-0000Ar-VS for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:40 +0000 X-Inumbo-ID: f3fde294-e36d-11e9-96cd-12813bfff9fa Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id f3fde294-e36d-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:34:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839699; x=1601375699; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=VU/eAywnkNFh7IYkFRbTTN/QOXXVFbVyKonknwX0+iU=; b=RQF+XDF+V6h08x7y53ao9U+7TzQ8yIyADkL1fjjMaHKMzCzfhnUaomgI 6cNtmfDYmUcC1qXjJlWko0O5GZ6OLUKb+ibTqEYuAET/73w8ZudaexbQI iLM+kbdVjATl16WK5FP/6KV8F8RGg/txu/YXUOfy+ollUiyj+epnmhHiR 4=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="754242303" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1e-57e1d233.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 30 Sep 2019 10:34:59 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-57e1d233.us-east-1.amazon.com (Postfix) with ESMTPS id 13C8B1417AB; Mon, 30 Sep 2019 10:34:58 +0000 (UTC) Received: from EX13D08UEE002.ant.amazon.com (10.43.62.92) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:36 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D08UEE002.ant.amazon.com (10.43.62.92) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:35 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:35 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:41 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 49/55] x86/smpboot: remove lXe_to_lYe in cleanup_cpu_root_pgt X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/smpboot.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index ca8fc6d485..9fe0ef18a1 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -949,11 +949,17 @@ static void cleanup_cpu_root_pgt(unsigned int cpu) /* Also zap the stub mapping for this CPU. */ if ( stub_linear ) { - l3_pgentry_t *l3t = l4e_to_l3e(common_pgt); - l2_pgentry_t *l2t = l3e_to_l2e(l3t[l3_table_offset(stub_linear)]); - l1_pgentry_t *l1t = l2e_to_l1e(l2t[l2_table_offset(stub_linear)]); + l3_pgentry_t *l3t = map_xen_pagetable_new(l4e_get_mfn(common_pgt)); + l2_pgentry_t *l2t = map_xen_pagetable_new( + l3e_get_mfn(l3t[l3_table_offset(stub_linear)])); + l1_pgentry_t *l1t = map_xen_pagetable_new( + l2e_get_mfn(l2t[l2_table_offset(stub_linear)])); l1t[l1_table_offset(stub_linear)] = l1e_empty(); + + UNMAP_XEN_PAGETABLE_NEW(l1t); + UNMAP_XEN_PAGETABLE_NEW(l2t); + UNMAP_XEN_PAGETABLE_NEW(l3t); } } From patchwork Mon Sep 30 10:33:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166479 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCF8213BD for ; Mon, 30 Sep 2019 10:37:26 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A9A1620679 for ; Mon, 30 Sep 2019 10:37:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="FEOCfsTh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A9A1620679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2n-00026D-EQ; Mon, 30 Sep 2019 10:36:41 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2l-000214-1d for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:36:39 +0000 X-Inumbo-ID: 1e1bb4de-e36e-11e9-97fb-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 1e1bb4de-e36e-11e9-97fb-bc764e2007e4; Mon, 30 Sep 2019 10:36:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839770; x=1601375770; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=f3D8sT4nLjfsYF+QuArXbr8SObtyun4SFrgHXutwP0A=; b=FEOCfsThBDdxK7Wym0andzGz1dmg+GdRONIn3NavwUHcmdRx6Hoq6CHd J/kM6R1s3KXXhn/Fy+4vtxykCCOVrhHtxR7lxhiPyoPIT58dE81T0AVOt sJuMseItxreCJClsUjV1PQt2wE0XBWJx4ypmHsWyssfTjBB21zIY5E7/i c=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="838005692" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1e-62350142.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 30 Sep 2019 10:35:10 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-62350142.us-east-1.amazon.com (Postfix) with ESMTPS id 6C0DEA00F1; Mon, 30 Sep 2019 10:34:58 +0000 (UTC) Received: from EX13D12UEE001.ant.amazon.com (10.43.62.147) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:37 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D12UEE001.ant.amazon.com (10.43.62.147) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:37 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:36 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:42 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 50/55] x86/pv: properly map and unmap page tables in mark_pv_pt_pages_rdonly X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/pv/dom0_build.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 1bd53e9c08..d7d42568fb 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -50,17 +50,17 @@ static __init void mark_pv_pt_pages_rdonly(struct domain *d, unsigned long count; struct page_info *page; l4_pgentry_t *pl4e; - l3_pgentry_t *pl3e; - l2_pgentry_t *pl2e; - l1_pgentry_t *pl1e; + l3_pgentry_t *pl3e, *l3t; + l2_pgentry_t *pl2e, *l2t; + l1_pgentry_t *pl1e, *l1t; pl4e = l4start + l4_table_offset(vpt_start); - pl3e = l4e_to_l3e(*pl4e); - pl3e += l3_table_offset(vpt_start); - pl2e = l3e_to_l2e(*pl3e); - pl2e += l2_table_offset(vpt_start); - pl1e = l2e_to_l1e(*pl2e); - pl1e += l1_table_offset(vpt_start); + l3t = map_xen_pagetable_new(l4e_get_mfn(*pl4e)); + pl3e = l3t + l3_table_offset(vpt_start); + l2t = map_xen_pagetable_new(l3e_get_mfn(*pl3e)); + pl2e = l2t + l2_table_offset(vpt_start); + l1t = map_xen_pagetable_new(l2e_get_mfn(*pl2e)); + pl1e = l1t + l1_table_offset(vpt_start); for ( count = 0; count < nr_pt_pages; count++ ) { l1e_remove_flags(*pl1e, _PAGE_RW); @@ -85,12 +85,23 @@ static __init void mark_pv_pt_pages_rdonly(struct domain *d, if ( !((unsigned long)++pl2e & (PAGE_SIZE - 1)) ) { if ( !((unsigned long)++pl3e & (PAGE_SIZE - 1)) ) - pl3e = l4e_to_l3e(*++pl4e); - pl2e = l3e_to_l2e(*pl3e); + { + UNMAP_XEN_PAGETABLE_NEW(l3t); + l3t = map_xen_pagetable_new(l4e_get_mfn(*++pl4e)); + pl3e = l3t; + } + UNMAP_XEN_PAGETABLE_NEW(l2t); + l2t = map_xen_pagetable_new(l3e_get_mfn(*pl3e)); + pl2e = l2t; } - pl1e = l2e_to_l1e(*pl2e); + UNMAP_XEN_PAGETABLE_NEW(l1t); + l1t = map_xen_pagetable_new(l2e_get_mfn(*pl2e)); + pl1e = l1t; } } + UNMAP_XEN_PAGETABLE_NEW(l1t); + UNMAP_XEN_PAGETABLE_NEW(l2t); + UNMAP_XEN_PAGETABLE_NEW(l3t); } static __init void setup_pv_physmap(struct domain *d, unsigned long pgtbl_pfn, From patchwork Mon Sep 30 10:33:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166477 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DFC9F13BD for ; Mon, 30 Sep 2019 10:37:25 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BC20920679 for ; Mon, 30 Sep 2019 10:37:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="qkoqpzn2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC20920679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2l-000238-Uo; Mon, 30 Sep 2019 10:36:39 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2j-0001yx-WC for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:36:38 +0000 X-Inumbo-ID: 2a81acda-e36e-11e9-96cd-12813bfff9fa Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id 2a81acda-e36e-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:36:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839792; x=1601375792; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=asXLxl/75rRuYGnWov8wrMv8pQpcv+qWDkmA7y7z49A=; b=qkoqpzn2RVe/DeSZmypi84x/SUA7b2p8XfjOBJFMpNb1hy1E9zEtcV7L sk56tmmqdxnTwIITd/P6agCj7e6Fk8T0UvV4qJrQyrySJ/gRwgrvRqnN+ osurxdXL5aNKJ6DbVq3inuK/X+t42+fVKU5myiGbu/5V1WbSyII4ItimW 8=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="705521395" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1d-f273de60.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 30 Sep 2019 10:35:15 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1d-f273de60.us-east-1.amazon.com (Postfix) with ESMTPS id D5788A2EC5; Mon, 30 Sep 2019 10:34:58 +0000 (UTC) Received: from EX13D15UEE003.ant.amazon.com (10.43.62.19) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:38 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D15UEE003.ant.amazon.com (10.43.62.19) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:37 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:37 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:43 +0100 Message-ID: <0ecfa9b5e9410c2b1f4ebd3bb82f649e0ebde516.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 51/55] x86/pv: properly map and unmap page table in dom0_construct_pv X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu --- xen/arch/x86/pv/dom0_build.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index d7d42568fb..39cb68f7da 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -679,6 +679,8 @@ int __init dom0_construct_pv(struct domain *d, if ( is_pv_32bit_domain(d) ) { + l2_pgentry_t *l2t; + /* Ensure the first four L3 entries are all populated. */ for ( i = 0, l3tab = l3start; i < 4; ++i, ++l3tab ) { @@ -693,7 +695,9 @@ int __init dom0_construct_pv(struct domain *d, l3e_get_page(*l3tab)->u.inuse.type_info |= PGT_pae_xen_l2; } - init_xen_pae_l2_slots(l3e_to_l2e(l3start[3]), d); + l2t = map_xen_pagetable_new(l3e_get_mfn(l3start[3])); + init_xen_pae_l2_slots(l2t, d); + UNMAP_XEN_PAGETABLE_NEW(l2t); } /* Pages that are part of page tables must be read only. */ From patchwork Mon Sep 30 10:33:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166483 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 157FC16B1 for ; Mon, 30 Sep 2019 10:37:37 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E653620679 for ; Mon, 30 Sep 2019 10:37:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="lsFELa8M" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E653620679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2w-0002OW-7Y; Mon, 30 Sep 2019 10:36:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2u-0002MC-VZ for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:36:49 +0000 X-Inumbo-ID: 1fc7b422-e36e-11e9-97fb-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 1fc7b422-e36e-11e9-97fb-bc764e2007e4; Mon, 30 Sep 2019 10:36:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839773; x=1601375773; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=ac2eimXv3IPFD3HqKUmOTeHhR84IFbsA9dhs2/WCnXI=; b=lsFELa8M3P7Dql2TrMRjKhf00mcLB3BMNFD0XyfJKgZW7YiJBdOPgQBG e9vDLUoVZcA0tjLIklR67gVl+16ndYQJvnA7+NGTvt8r/YOkmTzDJBeFv fNbMEbFyl6+ooSujR9H5doNM5TtjsT5jE+0mLo4+8JaZJTo218XttfsQu o=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="838005697" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1a-807d4a99.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 30 Sep 2019 10:35:13 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-807d4a99.us-east-1.amazon.com (Postfix) with ESMTPS id 42D59A306A; Mon, 30 Sep 2019 10:34:59 +0000 (UTC) Received: from EX13D21UEE004.ant.amazon.com (10.43.62.91) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:39 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D21UEE004.ant.amazon.com (10.43.62.91) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:38 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:38 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:44 +0100 Message-ID: <8e25d1ca1b754a9e368ccf12375730ae7b76ca57.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 52/55] x86: remove lXe_to_lYe in __start_xen X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Properly map and unmap page tables where necessary. Signed-off-by: Wei Liu --- xen/arch/x86/setup.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index dec60d0301..d27bcf1724 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1095,13 +1095,17 @@ void __init noreturn __start_xen(unsigned long mbi_p) pl4e = __va(__pa(idle_pg_table)); for ( i = 0 ; i < L4_PAGETABLE_ENTRIES; i++, pl4e++ ) { + l3_pgentry_t *l3t; + if ( !(l4e_get_flags(*pl4e) & _PAGE_PRESENT) ) continue; *pl4e = l4e_from_intpte(l4e_get_intpte(*pl4e) + xen_phys_start); - pl3e = l4e_to_l3e(*pl4e); + pl3e = l3t = map_xen_pagetable_new(l4e_get_mfn(*pl4e)); for ( j = 0; j < L3_PAGETABLE_ENTRIES; j++, pl3e++ ) { + l2_pgentry_t *l2t; + /* Not present, 1GB mapping, or already relocated? */ if ( !(l3e_get_flags(*pl3e) & _PAGE_PRESENT) || (l3e_get_flags(*pl3e) & _PAGE_PSE) || @@ -1109,7 +1113,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) continue; *pl3e = l3e_from_intpte(l3e_get_intpte(*pl3e) + xen_phys_start); - pl2e = l3e_to_l2e(*pl3e); + pl2e = l2t = map_xen_pagetable_new(l3e_get_mfn(*pl3e)); for ( k = 0; k < L2_PAGETABLE_ENTRIES; k++, pl2e++ ) { /* Not present, PSE, or already relocated? */ @@ -1120,7 +1124,9 @@ void __init noreturn __start_xen(unsigned long mbi_p) *pl2e = l2e_from_intpte(l2e_get_intpte(*pl2e) + xen_phys_start); } + UNMAP_XEN_PAGETABLE_NEW(l2t); } + UNMAP_XEN_PAGETABLE_NEW(l3t); } /* The only data mappings to be relocated are in the Xen area. */ From patchwork Mon Sep 30 10:33:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166485 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 319B016B1 for ; Mon, 30 Sep 2019 10:37:41 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0DD1620679 for ; Mon, 30 Sep 2019 10:37:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="JcYC3qBF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0DD1620679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt31-0002Zh-TH; Mon, 30 Sep 2019 10:36:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2z-0002Vy-VG for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:36:53 +0000 X-Inumbo-ID: 204a6cd2-e36e-11e9-97fb-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 204a6cd2-e36e-11e9-97fb-bc764e2007e4; Mon, 30 Sep 2019 10:36:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839774; x=1601375774; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=zFXi/k64yLkM6tHejVb24ikKLaRDehabVXLDoC8Mbn0=; b=JcYC3qBF1+EJV9lU5ZsFyN1NKb+2msnRdSpurFG357t30z/ziT1dxAVX waRPYLKKb4BF0L2ZNBZ1syjwmqkleGTgzs42a1Ml9Wwc5MyLHML2e/+eY JZGu9PdbH/K0rs8JNhH2WGP2f9ivoZLUlTLf0XcISoEyRw7MH+GBC+v2m M=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="838005698" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 30 Sep 2019 10:35:13 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com (Postfix) with ESMTPS id 9BB8FA21DC; Mon, 30 Sep 2019 10:34:59 +0000 (UTC) Received: from EX13D05UEE003.ant.amazon.com (10.43.62.168) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:40 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D05UEE003.ant.amazon.com (10.43.62.168) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:39 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:38 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:45 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 53/55] x86/mm: drop old page table APIs X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Now that we've switched all users to the new APIs, the old ones aren't needed anymore. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 16 ---------------- xen/include/asm-x86/mm.h | 2 -- xen/include/asm-x86/page.h | 5 ----- 3 files changed, 23 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 5c1d65d267..c9be239d53 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4850,22 +4850,6 @@ int mmcfg_intercept_write( return X86EMUL_OKAY; } -void *alloc_xen_pagetable(void) -{ - mfn_t mfn; - - mfn = alloc_xen_pagetable_new(); - ASSERT(!mfn_eq(mfn, INVALID_MFN)); - - return map_xen_pagetable_new(mfn); -} - -void free_xen_pagetable(void *v) -{ - if ( system_state != SYS_STATE_early_boot ) - free_xen_pagetable_new(virt_to_mfn(v)); -} - mfn_t alloc_xen_pagetable_new(void) { if ( system_state != SYS_STATE_early_boot ) diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 12a10b270d..4fb79ab8f0 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -631,8 +631,6 @@ int arch_acquire_resource(struct domain *d, unsigned int type, unsigned int nr_frames, xen_pfn_t mfn_list[]); /* Allocator functions for Xen pagetables. */ -void *alloc_xen_pagetable(void); -void free_xen_pagetable(void *v); mfn_t alloc_xen_pagetable_new(void); void *map_xen_pagetable_new(mfn_t mfn); void unmap_xen_pagetable_new(void *v); diff --git a/xen/include/asm-x86/page.h b/xen/include/asm-x86/page.h index 05a8b1efa6..906ec701a3 100644 --- a/xen/include/asm-x86/page.h +++ b/xen/include/asm-x86/page.h @@ -187,11 +187,6 @@ static inline l4_pgentry_t l4e_from_paddr(paddr_t pa, unsigned int flags) #define l4e_has_changed(x,y,flags) \ ( !!(((x).l4 ^ (y).l4) & ((PADDR_MASK&PAGE_MASK)|put_pte_flags(flags))) ) -/* Pagetable walking. */ -#define l2e_to_l1e(x) ((l1_pgentry_t *)__va(l2e_get_paddr(x))) -#define l3e_to_l2e(x) ((l2_pgentry_t *)__va(l3e_get_paddr(x))) -#define l4e_to_l3e(x) ((l3_pgentry_t *)__va(l4e_get_paddr(x))) - #define map_l1t_from_l2e(x) (l1_pgentry_t *)map_domain_page(l2e_get_mfn(x)) #define map_l2t_from_l3e(x) (l2_pgentry_t *)map_domain_page(l3e_get_mfn(x)) #define map_l3t_from_l4e(x) (l3_pgentry_t *)map_domain_page(l4e_get_mfn(x)) From patchwork Mon Sep 30 10:33:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166457 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E56716B1 for ; Mon, 30 Sep 2019 10:36:49 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2AD80216F4 for ; Mon, 30 Sep 2019 10:36:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="eUWerRXf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2AD80216F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1n-0000AP-Kd; Mon, 30 Sep 2019 10:35:39 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1m-00008r-SL for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:38 +0000 X-Inumbo-ID: f538ab12-e36d-11e9-97fb-bc764e2007e4 Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id f538ab12-e36d-11e9-97fb-bc764e2007e4; Mon, 30 Sep 2019 10:35:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839701; x=1601375701; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=nr+dk+LZcxtUkwKkvUL9TfVJ9eECRYdgkB1jYtP2PtI=; b=eUWerRXfKnr/vZrWfqP7ZmRxddKpPQTzkqTKxm8da8T60kaQbH/MjOrX 1ekCqIbUEWfeY2LetnF0iP7XzNM74svD2ABxLoWgxS8DbE994C1f4SRyE vSKOTKZXC21U1zw6CjF8edE3YaWawf0vwqsjCJv1Vjsr4sNcwwQpOMYzB s=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="788414753" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-17c49630.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 30 Sep 2019 10:35:01 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-17c49630.us-east-1.amazon.com (Postfix) with ESMTPS id 1BFD5A229A; Mon, 30 Sep 2019 10:35:00 +0000 (UTC) Received: from EX13D18UEE003.ant.amazon.com (10.43.62.169) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:41 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D18UEE003.ant.amazon.com (10.43.62.169) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:40 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:39 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:46 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 54/55] x86: switch to use domheap page for page tables X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Modify all the _new APIs to handle domheap pages. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index c9be239d53..a2d2d01660 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4854,10 +4854,10 @@ mfn_t alloc_xen_pagetable_new(void) { if ( system_state != SYS_STATE_early_boot ) { - void *ptr = alloc_xenheap_page(); + struct page_info *pg = alloc_domheap_page(NULL, 0); - BUG_ON(!hardware_domain && !ptr); - return virt_to_mfn(ptr); + BUG_ON(!hardware_domain && !pg); + return pg ? page_to_mfn(pg) : INVALID_MFN; } return alloc_boot_pages(1, 1); @@ -4865,20 +4865,21 @@ mfn_t alloc_xen_pagetable_new(void) void *map_xen_pagetable_new(mfn_t mfn) { - return mfn_to_virt(mfn_x(mfn)); + return map_domain_page(mfn); } /* v can point to an entry within a table or be NULL */ void unmap_xen_pagetable_new(void *v) { - /* XXX still using xenheap page, no need to do anything. */ + if ( v ) + unmap_domain_page((const void *)((unsigned long)v & PAGE_MASK)); } /* mfn can be INVALID_MFN */ void free_xen_pagetable_new(mfn_t mfn) { if ( system_state != SYS_STATE_early_boot && !mfn_eq(mfn, INVALID_MFN) ) - free_xenheap_page(mfn_to_virt(mfn_x(mfn))); + free_domheap_page(mfn_to_page(mfn)); } static DEFINE_SPINLOCK(map_pgdir_lock); From patchwork Mon Sep 30 10:33:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166487 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A7AF13BD for ; Mon, 30 Sep 2019 10:37:42 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1FCE820679 for ; Mon, 30 Sep 2019 10:37:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="biixubPh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FCE820679 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2q-0002By-8K; Mon, 30 Sep 2019 10:36:44 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt2o-00029B-Th for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:36:43 +0000 X-Inumbo-ID: 2d56d4e2-e36e-11e9-96cd-12813bfff9fa Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id 2d56d4e2-e36e-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839795; x=1601375795; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=nfGSWN5Y1rPyNG2ge/RB1cPsx0Tplxti2wvDbpJTwgA=; b=biixubPhygHN6RBVjOGGsJt63UKjF5OncVyfO8+f6KhTm1/jg8JIrDta ABTKVO6k4LdweLYol2iGTUcK3voJINkMNnG5YUfjpDK9YT1JTA2nGQz+T Wvoyqx4plSe4uiw4g+qOWVSjThPlNxGzU9bytOS+LvUKupEIXm9rGJvc3 g=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="705521405" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1e-17c49630.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 30 Sep 2019 10:35:18 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-17c49630.us-east-1.amazon.com (Postfix) with ESMTPS id E69C6A229F; Mon, 30 Sep 2019 10:35:01 +0000 (UTC) Received: from EX13D28EUC004.ant.amazon.com (10.43.164.80) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:43 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D28EUC004.ant.amazon.com (10.43.164.80) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:42 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:40 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:47 +0100 Message-ID: <206a716dacbbc96daca32e683ef11b6edc43725e.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 55/55] x86/mm: drop _new suffix for page table APIs X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Hongyan Xia , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- Changed since v1: - Fix rebase conflicts against new master and other changes since v1. --- xen/arch/x86/domain.c | 4 +- xen/arch/x86/domain_page.c | 2 +- xen/arch/x86/efi/runtime.h | 4 +- xen/arch/x86/mm.c | 164 +++++++++++++++++------------------ xen/arch/x86/pv/dom0_build.c | 28 +++--- xen/arch/x86/pv/shim.c | 12 +-- xen/arch/x86/setup.c | 8 +- xen/arch/x86/smpboot.c | 74 ++++++++-------- xen/arch/x86/x86_64/mm.c | 136 ++++++++++++++--------------- xen/common/efi/boot.c | 42 ++++----- xen/include/asm-x86/mm.h | 18 ++-- 11 files changed, 246 insertions(+), 246 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index e9bf47efce..e49a5af3f2 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1588,11 +1588,11 @@ void paravirt_ctxt_switch_to(struct vcpu *v) root_pgentry_t *rpt; mapcache_override_current(INVALID_VCPU); - rpt = map_xen_pagetable_new(rpt_mfn); + rpt = map_xen_pagetable(rpt_mfn); rpt[root_table_offset(PERDOMAIN_VIRT_START)] = l4e_from_page(v->domain->arch.perdomain_l3_pg, __PAGE_HYPERVISOR_RW); - UNMAP_XEN_PAGETABLE_NEW(rpt); + UNMAP_XEN_PAGETABLE(rpt); mapcache_override_current(NULL); } diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c index cfcffd35f3..9ea74b456c 100644 --- a/xen/arch/x86/domain_page.c +++ b/xen/arch/x86/domain_page.c @@ -343,7 +343,7 @@ mfn_t domain_page_map_to_mfn(const void *ptr) l1_pgentry_t *pl1e = virt_to_xen_l1e(va); BUG_ON(!pl1e); l1e = *pl1e; - UNMAP_XEN_PAGETABLE_NEW(pl1e); + UNMAP_XEN_PAGETABLE(pl1e); } else { diff --git a/xen/arch/x86/efi/runtime.h b/xen/arch/x86/efi/runtime.h index 277d237953..ca15c5aab7 100644 --- a/xen/arch/x86/efi/runtime.h +++ b/xen/arch/x86/efi/runtime.h @@ -10,9 +10,9 @@ void efi_update_l4_pgtable(unsigned int l4idx, l4_pgentry_t l4e) { l4_pgentry_t *l4t; - l4t = map_xen_pagetable_new(efi_l4_mfn); + l4t = map_xen_pagetable(efi_l4_mfn); l4e_write(l4t + l4idx, l4e); - UNMAP_XEN_PAGETABLE_NEW(l4t); + UNMAP_XEN_PAGETABLE(l4t); } } #endif diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index a2d2d01660..615d573961 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -353,22 +353,22 @@ void __init arch_init_memory(void) ASSERT(root_pgt_pv_xen_slots < ROOT_PAGETABLE_PV_XEN_SLOTS); if ( l4_table_offset(split_va) == l4_table_offset(split_va - 1) ) { - mfn_t l3tab_mfn = alloc_xen_pagetable_new(); + mfn_t l3tab_mfn = alloc_xen_pagetable(); if ( !mfn_eq(l3tab_mfn, INVALID_MFN) ) { l3_pgentry_t *l3idle = - map_xen_pagetable_new( + map_xen_pagetable( l4e_get_mfn(idle_pg_table[l4_table_offset(split_va)])); - l3_pgentry_t *l3tab = map_xen_pagetable_new(l3tab_mfn); + l3_pgentry_t *l3tab = map_xen_pagetable(l3tab_mfn); for ( i = 0; i < l3_table_offset(split_va); ++i ) l3tab[i] = l3idle[i]; for ( ; i < L3_PAGETABLE_ENTRIES; ++i ) l3tab[i] = l3e_empty(); split_l4e = l4e_from_mfn(l3tab_mfn, __PAGE_HYPERVISOR_RW); - UNMAP_XEN_PAGETABLE_NEW(l3idle); - UNMAP_XEN_PAGETABLE_NEW(l3tab); + UNMAP_XEN_PAGETABLE(l3idle); + UNMAP_XEN_PAGETABLE(l3tab); } else ++root_pgt_pv_xen_slots; @@ -4850,7 +4850,7 @@ int mmcfg_intercept_write( return X86EMUL_OKAY; } -mfn_t alloc_xen_pagetable_new(void) +mfn_t alloc_xen_pagetable(void) { if ( system_state != SYS_STATE_early_boot ) { @@ -4863,20 +4863,20 @@ mfn_t alloc_xen_pagetable_new(void) return alloc_boot_pages(1, 1); } -void *map_xen_pagetable_new(mfn_t mfn) +void *map_xen_pagetable(mfn_t mfn) { return map_domain_page(mfn); } /* v can point to an entry within a table or be NULL */ -void unmap_xen_pagetable_new(void *v) +void unmap_xen_pagetable(void *v) { if ( v ) unmap_domain_page((const void *)((unsigned long)v & PAGE_MASK)); } /* mfn can be INVALID_MFN */ -void free_xen_pagetable_new(mfn_t mfn) +void free_xen_pagetable(mfn_t mfn) { if ( system_state != SYS_STATE_early_boot && !mfn_eq(mfn, INVALID_MFN) ) free_domheap_page(mfn_to_page(mfn)); @@ -4900,11 +4900,11 @@ static l3_pgentry_t *virt_to_xen_l3e(unsigned long v) l3_pgentry_t *l3t; mfn_t mfn; - mfn = alloc_xen_pagetable_new(); + mfn = alloc_xen_pagetable(); if ( mfn_eq(mfn, INVALID_MFN) ) goto out; - l3t = map_xen_pagetable_new(mfn); + l3t = map_xen_pagetable(mfn); if ( locking ) spin_lock(&map_pgdir_lock); @@ -4924,15 +4924,15 @@ static l3_pgentry_t *virt_to_xen_l3e(unsigned long v) { ASSERT(!pl3e); ASSERT(!mfn_eq(mfn, INVALID_MFN)); - UNMAP_XEN_PAGETABLE_NEW(l3t); - free_xen_pagetable_new(mfn); + UNMAP_XEN_PAGETABLE(l3t); + free_xen_pagetable(mfn); } } if ( !pl3e ) { ASSERT(l4e_get_flags(*pl4e) & _PAGE_PRESENT); - pl3e = (l3_pgentry_t *)map_xen_pagetable_new(l4e_get_mfn(*pl4e)) + pl3e = (l3_pgentry_t *)map_xen_pagetable(l4e_get_mfn(*pl4e)) + l3_table_offset(v); } @@ -4959,11 +4959,11 @@ static l2_pgentry_t *virt_to_xen_l2e(unsigned long v) l2_pgentry_t *l2t; mfn_t mfn; - mfn = alloc_xen_pagetable_new(); + mfn = alloc_xen_pagetable(); if ( mfn_eq(mfn, INVALID_MFN) ) goto out; - l2t = map_xen_pagetable_new(mfn); + l2t = map_xen_pagetable(mfn); if ( locking ) spin_lock(&map_pgdir_lock); @@ -4981,8 +4981,8 @@ static l2_pgentry_t *virt_to_xen_l2e(unsigned long v) { ASSERT(!pl2e); ASSERT(!mfn_eq(mfn, INVALID_MFN)); - UNMAP_XEN_PAGETABLE_NEW(l2t); - free_xen_pagetable_new(mfn); + UNMAP_XEN_PAGETABLE(l2t); + free_xen_pagetable(mfn); } } @@ -4991,12 +4991,12 @@ static l2_pgentry_t *virt_to_xen_l2e(unsigned long v) if ( !pl2e ) { ASSERT(l3e_get_flags(*pl3e) & _PAGE_PRESENT); - pl2e = (l2_pgentry_t *)map_xen_pagetable_new(l3e_get_mfn(*pl3e)) + pl2e = (l2_pgentry_t *)map_xen_pagetable(l3e_get_mfn(*pl3e)) + l2_table_offset(v); } out: - UNMAP_XEN_PAGETABLE_NEW(pl3e); + UNMAP_XEN_PAGETABLE(pl3e); return pl2e; } @@ -5015,11 +5015,11 @@ l1_pgentry_t *virt_to_xen_l1e(unsigned long v) l1_pgentry_t *l1t; mfn_t mfn; - mfn = alloc_xen_pagetable_new(); + mfn = alloc_xen_pagetable(); if ( mfn_eq(mfn, INVALID_MFN) ) goto out; - l1t = map_xen_pagetable_new(mfn); + l1t = map_xen_pagetable(mfn); if ( locking ) spin_lock(&map_pgdir_lock); @@ -5037,8 +5037,8 @@ l1_pgentry_t *virt_to_xen_l1e(unsigned long v) { ASSERT(!pl1e); ASSERT(!mfn_eq(mfn, INVALID_MFN)); - UNMAP_XEN_PAGETABLE_NEW(l1t); - free_xen_pagetable_new(mfn); + UNMAP_XEN_PAGETABLE(l1t); + free_xen_pagetable(mfn); } } @@ -5047,12 +5047,12 @@ l1_pgentry_t *virt_to_xen_l1e(unsigned long v) if ( !pl1e ) { ASSERT(l2e_get_flags(*pl2e) & _PAGE_PRESENT); - pl1e = (l1_pgentry_t *)map_xen_pagetable_new(l2e_get_mfn(*pl2e)) + pl1e = (l1_pgentry_t *)map_xen_pagetable(l2e_get_mfn(*pl2e)) + l1_table_offset(v); } out: - UNMAP_XEN_PAGETABLE_NEW(pl2e); + UNMAP_XEN_PAGETABLE(pl2e); return pl1e; } @@ -5131,7 +5131,7 @@ int map_pages_to_xen( l2_pgentry_t *l2t; mfn_t l2t_mfn = l3e_get_mfn(ol3e); - l2t = map_xen_pagetable_new(l2t_mfn); + l2t = map_xen_pagetable(l2t_mfn); for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) { @@ -5146,10 +5146,10 @@ int map_pages_to_xen( l1_pgentry_t *l1t; mfn_t l1t_mfn = l2e_get_mfn(ol2e); - l1t = map_xen_pagetable_new(l1t_mfn); + l1t = map_xen_pagetable(l1t_mfn); for ( j = 0; j < L1_PAGETABLE_ENTRIES; j++ ) flush_flags(l1e_get_flags(l1t[j])); - UNMAP_XEN_PAGETABLE_NEW(l1t); + UNMAP_XEN_PAGETABLE(l1t); } } flush_area(virt, flush_flags); @@ -5158,9 +5158,9 @@ int map_pages_to_xen( ol2e = l2t[i]; if ( (l2e_get_flags(ol2e) & _PAGE_PRESENT) && !(l2e_get_flags(ol2e) & _PAGE_PSE) ) - free_xen_pagetable_new(l2e_get_mfn(ol2e)); + free_xen_pagetable(l2e_get_mfn(ol2e)); } - free_xen_pagetable_new(l2t_mfn); + free_xen_pagetable(l2t_mfn); } } @@ -5199,14 +5199,14 @@ int map_pages_to_xen( goto end_of_loop; } - l2t_mfn = alloc_xen_pagetable_new(); + l2t_mfn = alloc_xen_pagetable(); if ( mfn_eq(l2t_mfn, INVALID_MFN) ) { ASSERT(rc == -ENOMEM); goto out; } - l2t = map_xen_pagetable_new(l2t_mfn); + l2t = map_xen_pagetable(l2t_mfn); for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) l2e_write(l2t + i, @@ -5224,15 +5224,15 @@ int map_pages_to_xen( { l3e_write_atomic(pl3e, l3e_from_mfn(l2t_mfn, __PAGE_HYPERVISOR)); - UNMAP_XEN_PAGETABLE_NEW(l2t); + UNMAP_XEN_PAGETABLE(l2t); } if ( locking ) spin_unlock(&map_pgdir_lock); flush_area(virt, flush_flags); if ( l2t ) { - UNMAP_XEN_PAGETABLE_NEW(l2t); - free_xen_pagetable_new(l2t_mfn); + UNMAP_XEN_PAGETABLE(l2t); + free_xen_pagetable(l2t_mfn); } } @@ -5267,12 +5267,12 @@ int map_pages_to_xen( l1_pgentry_t *l1t; mfn_t l1t_mfn = l2e_get_mfn(ol2e); - l1t = map_xen_pagetable_new(l1t_mfn); + l1t = map_xen_pagetable(l1t_mfn); for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) flush_flags(l1e_get_flags(l1t[i])); flush_area(virt, flush_flags); - UNMAP_XEN_PAGETABLE_NEW(l1t); - free_xen_pagetable_new(l1t_mfn); + UNMAP_XEN_PAGETABLE(l1t); + free_xen_pagetable(l1t_mfn); } } @@ -5293,7 +5293,7 @@ int map_pages_to_xen( ASSERT(rc == -ENOMEM); goto out; } - UNMAP_XEN_PAGETABLE_NEW(pl1e); + UNMAP_XEN_PAGETABLE(pl1e); } else if ( l2e_get_flags(*pl2e) & _PAGE_PSE ) { @@ -5320,14 +5320,14 @@ int map_pages_to_xen( goto check_l3; } - l1t_mfn = alloc_xen_pagetable_new(); + l1t_mfn = alloc_xen_pagetable(); if ( mfn_eq(l1t_mfn, INVALID_MFN) ) { ASSERT(rc == -ENOMEM); goto out; } - l1t = map_xen_pagetable_new(l1t_mfn); + l1t = map_xen_pagetable(l1t_mfn); for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) l1e_write(&l1t[i], @@ -5344,23 +5344,23 @@ int map_pages_to_xen( { l2e_write_atomic(pl2e, l2e_from_mfn(l1t_mfn, __PAGE_HYPERVISOR)); - UNMAP_XEN_PAGETABLE_NEW(l1t); + UNMAP_XEN_PAGETABLE(l1t); } if ( locking ) spin_unlock(&map_pgdir_lock); flush_area(virt, flush_flags); if ( l1t ) { - UNMAP_XEN_PAGETABLE_NEW(l1t); - free_xen_pagetable_new(l1t_mfn); + UNMAP_XEN_PAGETABLE(l1t); + free_xen_pagetable(l1t_mfn); } } - pl1e = map_xen_pagetable_new(l2e_get_mfn((*pl2e))); + pl1e = map_xen_pagetable(l2e_get_mfn((*pl2e))); pl1e += l1_table_offset(virt); ol1e = *pl1e; l1e_write_atomic(pl1e, l1e_from_mfn(mfn, flags)); - UNMAP_XEN_PAGETABLE_NEW(pl1e); + UNMAP_XEN_PAGETABLE(pl1e); if ( (l1e_get_flags(ol1e) & _PAGE_PRESENT) ) { unsigned int flush_flags = FLUSH_TLB | FLUSH_ORDER(0); @@ -5406,14 +5406,14 @@ int map_pages_to_xen( } l1t_mfn = l2e_get_mfn(ol2e); - l1t = map_xen_pagetable_new(l1t_mfn); + l1t = map_xen_pagetable(l1t_mfn); base_mfn = l1e_get_pfn(l1t[0]) & ~(L1_PAGETABLE_ENTRIES - 1); for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) if ( (l1e_get_pfn(l1t[i]) != (base_mfn + i)) || (l1e_get_flags(l1t[i]) != flags) ) break; - UNMAP_XEN_PAGETABLE_NEW(l1t); + UNMAP_XEN_PAGETABLE(l1t); if ( i == L1_PAGETABLE_ENTRIES ) { l2e_write_atomic(pl2e, l2e_from_pfn(base_mfn, @@ -5423,7 +5423,7 @@ int map_pages_to_xen( flush_area(virt - PAGE_SIZE, FLUSH_TLB_GLOBAL | FLUSH_ORDER(PAGETABLE_ORDER)); - free_xen_pagetable_new(l1t_mfn); + free_xen_pagetable(l1t_mfn); } else if ( locking ) spin_unlock(&map_pgdir_lock); @@ -5458,7 +5458,7 @@ int map_pages_to_xen( } l2t_mfn = l3e_get_mfn(ol3e); - l2t = map_xen_pagetable_new(l2t_mfn); + l2t = map_xen_pagetable(l2t_mfn); base_mfn = l2e_get_pfn(l2t[0]) & ~(L2_PAGETABLE_ENTRIES * L1_PAGETABLE_ENTRIES - 1); @@ -5467,7 +5467,7 @@ int map_pages_to_xen( (base_mfn + (i << PAGETABLE_ORDER))) || (l2e_get_flags(l2t[i]) != l1f_to_lNf(flags)) ) break; - UNMAP_XEN_PAGETABLE_NEW(l2t); + UNMAP_XEN_PAGETABLE(l2t); if ( i == L2_PAGETABLE_ENTRIES ) { l3e_write_atomic(pl3e, l3e_from_pfn(base_mfn, @@ -5477,15 +5477,15 @@ int map_pages_to_xen( flush_area(virt - PAGE_SIZE, FLUSH_TLB_GLOBAL | FLUSH_ORDER(2*PAGETABLE_ORDER)); - free_xen_pagetable_new(l2t_mfn); + free_xen_pagetable(l2t_mfn); } else if ( locking ) spin_unlock(&map_pgdir_lock); } end_of_loop: - UNMAP_XEN_PAGETABLE_NEW(pl1e); - UNMAP_XEN_PAGETABLE_NEW(pl2e); - UNMAP_XEN_PAGETABLE_NEW(pl3e); + UNMAP_XEN_PAGETABLE(pl1e); + UNMAP_XEN_PAGETABLE(pl2e); + UNMAP_XEN_PAGETABLE(pl3e); } #undef flush_flags @@ -5493,9 +5493,9 @@ int map_pages_to_xen( rc = 0; out: - UNMAP_XEN_PAGETABLE_NEW(pl1e); - UNMAP_XEN_PAGETABLE_NEW(pl2e); - UNMAP_XEN_PAGETABLE_NEW(pl3e); + UNMAP_XEN_PAGETABLE(pl1e); + UNMAP_XEN_PAGETABLE(pl2e); + UNMAP_XEN_PAGETABLE(pl3e); return rc; } @@ -5566,14 +5566,14 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) } /* PAGE1GB: shatter the superpage and fall through. */ - mfn = alloc_xen_pagetable_new(); + mfn = alloc_xen_pagetable(); if ( mfn_eq(mfn, INVALID_MFN) ) { ASSERT(rc == -ENOMEM); goto out; } - l2t = map_xen_pagetable_new(mfn); + l2t = map_xen_pagetable(mfn); for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) l2e_write(l2t + i, @@ -5586,14 +5586,14 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) (l3e_get_flags(*pl3e) & _PAGE_PSE) ) { l3e_write_atomic(pl3e, l3e_from_mfn(mfn, __PAGE_HYPERVISOR)); - UNMAP_XEN_PAGETABLE_NEW(l2t); + UNMAP_XEN_PAGETABLE(l2t); } if ( locking ) spin_unlock(&map_pgdir_lock); if ( l2t ) { - UNMAP_XEN_PAGETABLE_NEW(l2t); - free_xen_pagetable_new(mfn); + UNMAP_XEN_PAGETABLE(l2t); + free_xen_pagetable(mfn); } } @@ -5601,7 +5601,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) * The L3 entry has been verified to be present, and we've dealt with * 1G pages as well, so the L2 table cannot require allocation. */ - pl2e = map_xen_pagetable_new(l3e_get_mfn(*pl3e)); + pl2e = map_xen_pagetable(l3e_get_mfn(*pl3e)); pl2e += l2_table_offset(v); if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) ) @@ -5633,14 +5633,14 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) mfn_t mfn; /* PSE: shatter the superpage and try again. */ - mfn = alloc_xen_pagetable_new(); + mfn = alloc_xen_pagetable(); if ( mfn_eq(mfn, INVALID_MFN) ) { ASSERT(rc == -ENOMEM); goto out; } - l1t = map_xen_pagetable_new(mfn); + l1t = map_xen_pagetable(mfn); for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) l1e_write(&l1t[i], @@ -5653,14 +5653,14 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) { l2e_write_atomic(pl2e, l2e_from_mfn(mfn, __PAGE_HYPERVISOR)); - UNMAP_XEN_PAGETABLE_NEW(l1t); + UNMAP_XEN_PAGETABLE(l1t); } if ( locking ) spin_unlock(&map_pgdir_lock); if ( l1t ) { - UNMAP_XEN_PAGETABLE_NEW(l1t); - free_xen_pagetable_new(mfn); + UNMAP_XEN_PAGETABLE(l1t); + free_xen_pagetable(mfn); } } } @@ -5674,7 +5674,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) * present, and we've dealt with 2M pages as well, so the L1 table * cannot require allocation. */ - pl1e = map_xen_pagetable_new(l2e_get_mfn(*pl2e)); + pl1e = map_xen_pagetable(l2e_get_mfn(*pl2e)); pl1e += l1_table_offset(v); /* Confirm the caller isn't trying to create new mappings. */ @@ -5686,7 +5686,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) (l1e_get_flags(*pl1e) & ~FLAGS_MASK) | nf); l1e_write_atomic(pl1e, nl1e); - UNMAP_XEN_PAGETABLE_NEW(pl1e); + UNMAP_XEN_PAGETABLE(pl1e); v += PAGE_SIZE; /* @@ -5717,11 +5717,11 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) } l1t_mfn = l2e_get_mfn(*pl2e); - l1t = map_xen_pagetable_new(l1t_mfn); + l1t = map_xen_pagetable(l1t_mfn); for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) if ( l1e_get_intpte(l1t[i]) != 0 ) break; - UNMAP_XEN_PAGETABLE_NEW(l1t); + UNMAP_XEN_PAGETABLE(l1t); if ( i == L1_PAGETABLE_ENTRIES ) { /* Empty: zap the L2E and free the L1 page. */ @@ -5729,7 +5729,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) if ( locking ) spin_unlock(&map_pgdir_lock); flush_area(NULL, FLUSH_TLB_GLOBAL); /* flush before free */ - free_xen_pagetable_new(l1t_mfn); + free_xen_pagetable(l1t_mfn); } else if ( locking ) spin_unlock(&map_pgdir_lock); @@ -5763,11 +5763,11 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) mfn_t l2t_mfn; l2t_mfn = l3e_get_mfn(*pl3e); - l2t = map_xen_pagetable_new(l2t_mfn); + l2t = map_xen_pagetable(l2t_mfn); for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) if ( l2e_get_intpte(l2t[i]) != 0 ) break; - UNMAP_XEN_PAGETABLE_NEW(l2t); + UNMAP_XEN_PAGETABLE(l2t); if ( i == L2_PAGETABLE_ENTRIES ) { /* Empty: zap the L3E and free the L2 page. */ @@ -5775,14 +5775,14 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) if ( locking ) spin_unlock(&map_pgdir_lock); flush_area(NULL, FLUSH_TLB_GLOBAL); /* flush before free */ - free_xen_pagetable_new(l2t_mfn); + free_xen_pagetable(l2t_mfn); } else if ( locking ) spin_unlock(&map_pgdir_lock); } end_of_loop: - UNMAP_XEN_PAGETABLE_NEW(pl2e); - UNMAP_XEN_PAGETABLE_NEW(pl3e); + UNMAP_XEN_PAGETABLE(pl2e); + UNMAP_XEN_PAGETABLE(pl3e); } flush_area(NULL, FLUSH_TLB_GLOBAL); @@ -5791,8 +5791,8 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) rc = 0; out: - UNMAP_XEN_PAGETABLE_NEW(pl2e); - UNMAP_XEN_PAGETABLE_NEW(pl3e); + UNMAP_XEN_PAGETABLE(pl2e); + UNMAP_XEN_PAGETABLE(pl3e); return rc; } diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 39cb68f7da..02d7f1c27c 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -55,11 +55,11 @@ static __init void mark_pv_pt_pages_rdonly(struct domain *d, l1_pgentry_t *pl1e, *l1t; pl4e = l4start + l4_table_offset(vpt_start); - l3t = map_xen_pagetable_new(l4e_get_mfn(*pl4e)); + l3t = map_xen_pagetable(l4e_get_mfn(*pl4e)); pl3e = l3t + l3_table_offset(vpt_start); - l2t = map_xen_pagetable_new(l3e_get_mfn(*pl3e)); + l2t = map_xen_pagetable(l3e_get_mfn(*pl3e)); pl2e = l2t + l2_table_offset(vpt_start); - l1t = map_xen_pagetable_new(l2e_get_mfn(*pl2e)); + l1t = map_xen_pagetable(l2e_get_mfn(*pl2e)); pl1e = l1t + l1_table_offset(vpt_start); for ( count = 0; count < nr_pt_pages; count++ ) { @@ -86,22 +86,22 @@ static __init void mark_pv_pt_pages_rdonly(struct domain *d, { if ( !((unsigned long)++pl3e & (PAGE_SIZE - 1)) ) { - UNMAP_XEN_PAGETABLE_NEW(l3t); - l3t = map_xen_pagetable_new(l4e_get_mfn(*++pl4e)); + UNMAP_XEN_PAGETABLE(l3t); + l3t = map_xen_pagetable(l4e_get_mfn(*++pl4e)); pl3e = l3t; } - UNMAP_XEN_PAGETABLE_NEW(l2t); - l2t = map_xen_pagetable_new(l3e_get_mfn(*pl3e)); + UNMAP_XEN_PAGETABLE(l2t); + l2t = map_xen_pagetable(l3e_get_mfn(*pl3e)); pl2e = l2t; } - UNMAP_XEN_PAGETABLE_NEW(l1t); - l1t = map_xen_pagetable_new(l2e_get_mfn(*pl2e)); + UNMAP_XEN_PAGETABLE(l1t); + l1t = map_xen_pagetable(l2e_get_mfn(*pl2e)); pl1e = l1t; } } - UNMAP_XEN_PAGETABLE_NEW(l1t); - UNMAP_XEN_PAGETABLE_NEW(l2t); - UNMAP_XEN_PAGETABLE_NEW(l3t); + UNMAP_XEN_PAGETABLE(l1t); + UNMAP_XEN_PAGETABLE(l2t); + UNMAP_XEN_PAGETABLE(l3t); } static __init void setup_pv_physmap(struct domain *d, unsigned long pgtbl_pfn, @@ -695,9 +695,9 @@ int __init dom0_construct_pv(struct domain *d, l3e_get_page(*l3tab)->u.inuse.type_info |= PGT_pae_xen_l2; } - l2t = map_xen_pagetable_new(l3e_get_mfn(l3start[3])); + l2t = map_xen_pagetable(l3e_get_mfn(l3start[3])); init_xen_pae_l2_slots(l2t, d); - UNMAP_XEN_PAGETABLE_NEW(l2t); + UNMAP_XEN_PAGETABLE(l2t); } /* Pages that are part of page tables must be read only. */ diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c index cf638fa965..09c7766ec5 100644 --- a/xen/arch/x86/pv/shim.c +++ b/xen/arch/x86/pv/shim.c @@ -171,11 +171,11 @@ static void __init replace_va_mapping(struct domain *d, l4_pgentry_t *l4start, l2_pgentry_t *pl2e; l1_pgentry_t *pl1e; - pl3e = map_xen_pagetable_new(l4e_get_mfn(*pl4e)); + pl3e = map_xen_pagetable(l4e_get_mfn(*pl4e)); pl3e += l3_table_offset(va); - pl2e = map_xen_pagetable_new(l3e_get_mfn(*pl3e)); + pl2e = map_xen_pagetable(l3e_get_mfn(*pl3e)); pl2e += l2_table_offset(va); - pl1e = map_xen_pagetable_new(l2e_get_mfn(*pl2e)); + pl1e = map_xen_pagetable(l2e_get_mfn(*pl2e)); pl1e += l1_table_offset(va); put_page_and_type(mfn_to_page(l1e_get_mfn(*pl1e))); @@ -183,9 +183,9 @@ static void __init replace_va_mapping(struct domain *d, l4_pgentry_t *l4start, *pl1e = l1e_from_mfn(mfn, (!is_pv_32bit_domain(d) ? L1_PROT : COMPAT_L1_PROT)); - UNMAP_XEN_PAGETABLE_NEW(pl1e); - UNMAP_XEN_PAGETABLE_NEW(pl2e); - UNMAP_XEN_PAGETABLE_NEW(pl3e); + UNMAP_XEN_PAGETABLE(pl1e); + UNMAP_XEN_PAGETABLE(pl2e); + UNMAP_XEN_PAGETABLE(pl3e); } static void evtchn_reserve(struct domain *d, unsigned int port) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index d27bcf1724..e6d8dfb0b3 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1101,7 +1101,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) continue; *pl4e = l4e_from_intpte(l4e_get_intpte(*pl4e) + xen_phys_start); - pl3e = l3t = map_xen_pagetable_new(l4e_get_mfn(*pl4e)); + pl3e = l3t = map_xen_pagetable(l4e_get_mfn(*pl4e)); for ( j = 0; j < L3_PAGETABLE_ENTRIES; j++, pl3e++ ) { l2_pgentry_t *l2t; @@ -1113,7 +1113,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) continue; *pl3e = l3e_from_intpte(l3e_get_intpte(*pl3e) + xen_phys_start); - pl2e = l2t = map_xen_pagetable_new(l3e_get_mfn(*pl3e)); + pl2e = l2t = map_xen_pagetable(l3e_get_mfn(*pl3e)); for ( k = 0; k < L2_PAGETABLE_ENTRIES; k++, pl2e++ ) { /* Not present, PSE, or already relocated? */ @@ -1124,9 +1124,9 @@ void __init noreturn __start_xen(unsigned long mbi_p) *pl2e = l2e_from_intpte(l2e_get_intpte(*pl2e) + xen_phys_start); } - UNMAP_XEN_PAGETABLE_NEW(l2t); + UNMAP_XEN_PAGETABLE(l2t); } - UNMAP_XEN_PAGETABLE_NEW(l3t); + UNMAP_XEN_PAGETABLE(l3t); } /* The only data mappings to be relocated are in the Xen area. */ diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 9fe0ef18a1..cbaff23f7e 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -687,7 +687,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) goto out; } - pl3e = map_xen_pagetable_new( + pl3e = map_xen_pagetable( l4e_get_mfn(idle_pg_table[root_table_offset(linear)])); pl3e += l3_table_offset(linear); @@ -701,7 +701,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) } else { - pl2e = map_xen_pagetable_new(l3e_get_mfn(*pl3e)); + pl2e = map_xen_pagetable(l3e_get_mfn(*pl3e)); pl2e += l2_table_offset(linear); flags = l2e_get_flags(*pl2e); ASSERT(flags & _PAGE_PRESENT); @@ -713,7 +713,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) } else { - pl1e = map_xen_pagetable_new(l2e_get_mfn(*pl2e)); + pl1e = map_xen_pagetable(l2e_get_mfn(*pl2e)); pl1e += l1_table_offset(linear); flags = l1e_get_flags(*pl1e); if ( !(flags & _PAGE_PRESENT) ) @@ -725,13 +725,13 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) } } - UNMAP_XEN_PAGETABLE_NEW(pl1e); - UNMAP_XEN_PAGETABLE_NEW(pl2e); - UNMAP_XEN_PAGETABLE_NEW(pl3e); + UNMAP_XEN_PAGETABLE(pl1e); + UNMAP_XEN_PAGETABLE(pl2e); + UNMAP_XEN_PAGETABLE(pl3e); if ( !(root_get_flags(rpt[root_table_offset(linear)]) & _PAGE_PRESENT) ) { - mfn_t l3t_mfn = alloc_xen_pagetable_new(); + mfn_t l3t_mfn = alloc_xen_pagetable(); if ( mfn_eq(l3t_mfn, INVALID_MFN) ) { @@ -739,20 +739,20 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) goto out; } - pl3e = map_xen_pagetable_new(l3t_mfn); + pl3e = map_xen_pagetable(l3t_mfn); clear_page(pl3e); l4e_write(&rpt[root_table_offset(linear)], l4e_from_mfn(l3t_mfn, __PAGE_HYPERVISOR)); } else - pl3e = map_xen_pagetable_new( + pl3e = map_xen_pagetable( l4e_get_mfn(rpt[root_table_offset(linear)])); pl3e += l3_table_offset(linear); if ( !(l3e_get_flags(*pl3e) & _PAGE_PRESENT) ) { - mfn_t l2t_mfn = alloc_xen_pagetable_new(); + mfn_t l2t_mfn = alloc_xen_pagetable(); if ( mfn_eq(l2t_mfn, INVALID_MFN) ) { @@ -760,21 +760,21 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) goto out; } - pl2e = map_xen_pagetable_new(l2t_mfn); + pl2e = map_xen_pagetable(l2t_mfn); clear_page(pl2e); l3e_write(pl3e, l3e_from_mfn(l2t_mfn, __PAGE_HYPERVISOR)); } else { ASSERT(!(l3e_get_flags(*pl3e) & _PAGE_PSE)); - pl2e = map_xen_pagetable_new(l3e_get_mfn(*pl3e)); + pl2e = map_xen_pagetable(l3e_get_mfn(*pl3e)); } pl2e += l2_table_offset(linear); if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) ) { - mfn_t l1t_mfn = alloc_xen_pagetable_new(); + mfn_t l1t_mfn = alloc_xen_pagetable(); if ( mfn_eq(l1t_mfn, INVALID_MFN) ) { @@ -782,14 +782,14 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) goto out; } - pl1e = map_xen_pagetable_new(l1t_mfn); + pl1e = map_xen_pagetable(l1t_mfn); clear_page(pl1e); l2e_write(pl2e, l2e_from_mfn(l1t_mfn, __PAGE_HYPERVISOR)); } else { ASSERT(!(l2e_get_flags(*pl2e) & _PAGE_PSE)); - pl1e = map_xen_pagetable_new(l2e_get_mfn(*pl2e)); + pl1e = map_xen_pagetable(l2e_get_mfn(*pl2e)); } pl1e += l1_table_offset(linear); @@ -805,9 +805,9 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) rc = 0; out: - UNMAP_XEN_PAGETABLE_NEW(pl1e); - UNMAP_XEN_PAGETABLE_NEW(pl2e); - UNMAP_XEN_PAGETABLE_NEW(pl3e); + UNMAP_XEN_PAGETABLE(pl1e); + UNMAP_XEN_PAGETABLE(pl2e); + UNMAP_XEN_PAGETABLE(pl3e); return rc; } @@ -830,14 +830,14 @@ static int setup_cpu_root_pgt(unsigned int cpu) goto out; } - rpt_mfn = alloc_xen_pagetable_new(); + rpt_mfn = alloc_xen_pagetable(); if ( mfn_eq(rpt_mfn, INVALID_MFN) ) { rc = -ENOMEM; goto out; } - rpt = map_xen_pagetable_new(rpt_mfn); + rpt = map_xen_pagetable(rpt_mfn); clear_page(rpt); per_cpu(root_pgt_mfn, cpu) = rpt_mfn; @@ -882,7 +882,7 @@ static int setup_cpu_root_pgt(unsigned int cpu) rc = clone_mapping((void *)per_cpu(stubs.addr, cpu), rpt); out: - UNMAP_XEN_PAGETABLE_NEW(rpt); + UNMAP_XEN_PAGETABLE(rpt); return rc; } @@ -898,7 +898,7 @@ static void cleanup_cpu_root_pgt(unsigned int cpu) per_cpu(root_pgt_mfn, cpu) = INVALID_MFN; - rpt = map_xen_pagetable_new(rpt_mfn); + rpt = map_xen_pagetable(rpt_mfn); for ( r = root_table_offset(DIRECTMAP_VIRT_START); r < root_table_offset(HYPERVISOR_VIRT_END); ++r ) @@ -911,7 +911,7 @@ static void cleanup_cpu_root_pgt(unsigned int cpu) continue; l3t_mfn = l4e_get_mfn(rpt[r]); - l3t = map_xen_pagetable_new(l3t_mfn); + l3t = map_xen_pagetable(l3t_mfn); for ( i3 = 0; i3 < L3_PAGETABLE_ENTRIES; ++i3 ) { @@ -924,7 +924,7 @@ static void cleanup_cpu_root_pgt(unsigned int cpu) ASSERT(!(l3e_get_flags(l3t[i3]) & _PAGE_PSE)); l2t_mfn = l3e_get_mfn(l3t[i3]); - l2t = map_xen_pagetable_new(l2t_mfn); + l2t = map_xen_pagetable(l2t_mfn); for ( i2 = 0; i2 < L2_PAGETABLE_ENTRIES; ++i2 ) { @@ -932,34 +932,34 @@ static void cleanup_cpu_root_pgt(unsigned int cpu) continue; ASSERT(!(l2e_get_flags(l2t[i2]) & _PAGE_PSE)); - free_xen_pagetable_new(l2e_get_mfn(l2t[i2])); + free_xen_pagetable(l2e_get_mfn(l2t[i2])); } - UNMAP_XEN_PAGETABLE_NEW(l2t); - free_xen_pagetable_new(l2t_mfn); + UNMAP_XEN_PAGETABLE(l2t); + free_xen_pagetable(l2t_mfn); } - UNMAP_XEN_PAGETABLE_NEW(l3t); - free_xen_pagetable_new(l3t_mfn); + UNMAP_XEN_PAGETABLE(l3t); + free_xen_pagetable(l3t_mfn); } - UNMAP_XEN_PAGETABLE_NEW(rpt); - free_xen_pagetable_new(rpt_mfn); + UNMAP_XEN_PAGETABLE(rpt); + free_xen_pagetable(rpt_mfn); /* Also zap the stub mapping for this CPU. */ if ( stub_linear ) { - l3_pgentry_t *l3t = map_xen_pagetable_new(l4e_get_mfn(common_pgt)); - l2_pgentry_t *l2t = map_xen_pagetable_new( + l3_pgentry_t *l3t = map_xen_pagetable(l4e_get_mfn(common_pgt)); + l2_pgentry_t *l2t = map_xen_pagetable( l3e_get_mfn(l3t[l3_table_offset(stub_linear)])); - l1_pgentry_t *l1t = map_xen_pagetable_new( + l1_pgentry_t *l1t = map_xen_pagetable( l2e_get_mfn(l2t[l2_table_offset(stub_linear)])); l1t[l1_table_offset(stub_linear)] = l1e_empty(); - UNMAP_XEN_PAGETABLE_NEW(l1t); - UNMAP_XEN_PAGETABLE_NEW(l2t); - UNMAP_XEN_PAGETABLE_NEW(l3t); + UNMAP_XEN_PAGETABLE(l1t); + UNMAP_XEN_PAGETABLE(l2t); + UNMAP_XEN_PAGETABLE(l3t); } } diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index a1c69d7f0e..842548b925 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -134,7 +134,7 @@ static int m2p_mapped(unsigned long spfn) int rc = M2P_NO_MAPPED; va = RO_MPT_VIRT_START + spfn * sizeof(*machine_to_phys_mapping); - l3_ro_mpt = map_xen_pagetable_new( + l3_ro_mpt = map_xen_pagetable( l4e_get_mfn(idle_pg_table[l4_table_offset(va)])); switch ( l3e_get_flags(l3_ro_mpt[l3_table_offset(va)]) & @@ -150,15 +150,15 @@ static int m2p_mapped(unsigned long spfn) rc = M2P_NO_MAPPED; goto out; } - l2_ro_mpt = map_xen_pagetable_new( + l2_ro_mpt = map_xen_pagetable( l3e_get_mfn(l3_ro_mpt[l3_table_offset(va)])); if (l2e_get_flags(l2_ro_mpt[l2_table_offset(va)]) & _PAGE_PRESENT) rc = M2P_2M_MAPPED; out: - UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); - UNMAP_XEN_PAGETABLE_NEW(l3_ro_mpt); + UNMAP_XEN_PAGETABLE(l2_ro_mpt); + UNMAP_XEN_PAGETABLE(l3_ro_mpt); return rc; } @@ -176,10 +176,10 @@ static int share_hotadd_m2p_table(struct mem_hotadd_info *info) { n = L2_PAGETABLE_ENTRIES * L1_PAGETABLE_ENTRIES; - l3t = map_xen_pagetable_new( + l3t = map_xen_pagetable( l4e_get_mfn(idle_pg_table[l4_table_offset(v)])); l3e = l3t[l3_table_offset(v)]; - UNMAP_XEN_PAGETABLE_NEW(l3t); + UNMAP_XEN_PAGETABLE(l3t); if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) continue; @@ -187,9 +187,9 @@ static int share_hotadd_m2p_table(struct mem_hotadd_info *info) { n = L1_PAGETABLE_ENTRIES; - l2t = map_xen_pagetable_new(l3e_get_mfn(l3e)); + l2t = map_xen_pagetable(l3e_get_mfn(l3e)); l2e = l2t[l2_table_offset(v)]; - UNMAP_XEN_PAGETABLE_NEW(l2t); + UNMAP_XEN_PAGETABLE(l2t); if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) ) continue; @@ -211,17 +211,17 @@ static int share_hotadd_m2p_table(struct mem_hotadd_info *info) v != RDWR_COMPAT_MPT_VIRT_END; v += 1 << L2_PAGETABLE_SHIFT ) { - l3t = map_xen_pagetable_new( + l3t = map_xen_pagetable( l4e_get_mfn(idle_pg_table[l4_table_offset(v)])); l3e = l3t[l3_table_offset(v)]; - UNMAP_XEN_PAGETABLE_NEW(l3t); + UNMAP_XEN_PAGETABLE(l3t); if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) continue; - l2t = map_xen_pagetable_new(l3e_get_mfn(l3e)); + l2t = map_xen_pagetable(l3e_get_mfn(l3e)); l2e = l2t[l2_table_offset(v)]; - UNMAP_XEN_PAGETABLE_NEW(l2t); + UNMAP_XEN_PAGETABLE(l2t); if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) ) continue; @@ -252,12 +252,12 @@ static void destroy_compat_m2p_mapping(struct mem_hotadd_info *info) if ( emap > ((RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START) >> 2) ) emap = (RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START) >> 2; - l3_ro_mpt = map_xen_pagetable_new( + l3_ro_mpt = map_xen_pagetable( l4e_get_mfn(idle_pg_table[l4_table_offset(HIRO_COMPAT_MPT_VIRT_START)])); ASSERT(l3e_get_flags(l3_ro_mpt[l3_table_offset(HIRO_COMPAT_MPT_VIRT_START)]) & _PAGE_PRESENT); - l2_ro_mpt = map_xen_pagetable_new( + l2_ro_mpt = map_xen_pagetable( l3e_get_mfn(l3_ro_mpt[l3_table_offset(HIRO_COMPAT_MPT_VIRT_START)])); for ( i = smap; i < emap; ) @@ -280,8 +280,8 @@ static void destroy_compat_m2p_mapping(struct mem_hotadd_info *info) i += 1UL << (L2_PAGETABLE_SHIFT - 2); } - UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); - UNMAP_XEN_PAGETABLE_NEW(l3_ro_mpt); + UNMAP_XEN_PAGETABLE(l2_ro_mpt); + UNMAP_XEN_PAGETABLE(l3_ro_mpt); return; } @@ -292,7 +292,7 @@ static void destroy_m2p_mapping(struct mem_hotadd_info *info) unsigned long i, va, rwva; unsigned long smap = info->spfn, emap = info->epfn; - l3_ro_mpt = map_xen_pagetable_new( + l3_ro_mpt = map_xen_pagetable( l4e_get_mfn(idle_pg_table[l4_table_offset(RO_MPT_VIRT_START)])); /* @@ -315,13 +315,13 @@ static void destroy_m2p_mapping(struct mem_hotadd_info *info) continue; } - l2_ro_mpt = map_xen_pagetable_new( + l2_ro_mpt = map_xen_pagetable( l3e_get_mfn(l3_ro_mpt[l3_table_offset(va)])); if (!(l2e_get_flags(l2_ro_mpt[l2_table_offset(va)]) & _PAGE_PRESENT)) { i = ( i & ~((1UL << (L2_PAGETABLE_SHIFT - 3)) - 1)) + (1UL << (L2_PAGETABLE_SHIFT - 3)) ; - UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); + UNMAP_XEN_PAGETABLE(l2_ro_mpt); continue; } @@ -332,17 +332,17 @@ static void destroy_m2p_mapping(struct mem_hotadd_info *info) destroy_xen_mappings(rwva, rwva + (1UL << L2_PAGETABLE_SHIFT)); - l2t = map_xen_pagetable_new( + l2t = map_xen_pagetable( l3e_get_mfn(l3_ro_mpt[l3_table_offset(va)])); l2e_write(&l2t[l2_table_offset(va)], l2e_empty()); - UNMAP_XEN_PAGETABLE_NEW(l2t); + UNMAP_XEN_PAGETABLE(l2t); } i = ( i & ~((1UL << (L2_PAGETABLE_SHIFT - 3)) - 1)) + (1UL << (L2_PAGETABLE_SHIFT - 3)); - UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); + UNMAP_XEN_PAGETABLE(l2_ro_mpt); } - UNMAP_XEN_PAGETABLE_NEW(l3_ro_mpt); + UNMAP_XEN_PAGETABLE(l3_ro_mpt); destroy_compat_m2p_mapping(info); @@ -382,12 +382,12 @@ static int setup_compat_m2p_table(struct mem_hotadd_info *info) va = HIRO_COMPAT_MPT_VIRT_START + smap * sizeof(*compat_machine_to_phys_mapping); - l3_ro_mpt = map_xen_pagetable_new( + l3_ro_mpt = map_xen_pagetable( l4e_get_mfn(idle_pg_table[l4_table_offset(va)])); ASSERT(l3e_get_flags(l3_ro_mpt[l3_table_offset(va)]) & _PAGE_PRESENT); - l2_ro_mpt = map_xen_pagetable_new( + l2_ro_mpt = map_xen_pagetable( l3e_get_mfn(l3_ro_mpt[l3_table_offset(va)])); #define MFN(x) (((x) << L2_PAGETABLE_SHIFT) / sizeof(unsigned int)) @@ -427,8 +427,8 @@ static int setup_compat_m2p_table(struct mem_hotadd_info *info) #undef CNT #undef MFN - UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); - UNMAP_XEN_PAGETABLE_NEW(l3_ro_mpt); + UNMAP_XEN_PAGETABLE(l2_ro_mpt); + UNMAP_XEN_PAGETABLE(l3_ro_mpt); return err; } @@ -449,7 +449,7 @@ static int setup_m2p_table(struct mem_hotadd_info *info) & _PAGE_PRESENT); l3_ro_mpt_mfn = l4e_get_mfn(idle_pg_table[l4_table_offset( RO_MPT_VIRT_START)]); - l3_ro_mpt = map_xen_pagetable_new(l3_ro_mpt_mfn); + l3_ro_mpt = map_xen_pagetable(l3_ro_mpt_mfn); smap = (info->spfn & (~((1UL << (L2_PAGETABLE_SHIFT - 3)) -1))); emap = ((info->epfn + ((1UL << (L2_PAGETABLE_SHIFT - 3)) - 1 )) & @@ -505,23 +505,23 @@ static int setup_m2p_table(struct mem_hotadd_info *info) if ( l3e_get_flags(l3_ro_mpt[l3_table_offset(va)]) & _PAGE_PRESENT ) { - UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); + UNMAP_XEN_PAGETABLE(l2_ro_mpt); l2_ro_mpt_mfn = l3e_get_mfn(l3_ro_mpt[l3_table_offset(va)]); - l2_ro_mpt = map_xen_pagetable_new(l2_ro_mpt_mfn); + l2_ro_mpt = map_xen_pagetable(l2_ro_mpt_mfn); ASSERT(l2_ro_mpt); pl2e = l2_ro_mpt + l2_table_offset(va); } else { - UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); - l2_ro_mpt_mfn = alloc_xen_pagetable_new(); + UNMAP_XEN_PAGETABLE(l2_ro_mpt); + l2_ro_mpt_mfn = alloc_xen_pagetable(); if ( mfn_eq(l2_ro_mpt_mfn, INVALID_MFN) ) { ret = -ENOMEM; goto error; } - l2_ro_mpt = map_xen_pagetable_new(l2_ro_mpt_mfn); + l2_ro_mpt = map_xen_pagetable(l2_ro_mpt_mfn); clear_page(l2_ro_mpt); l3e_write(&l3_ro_mpt[l3_table_offset(va)], l3e_from_mfn(l2_ro_mpt_mfn, @@ -541,8 +541,8 @@ static int setup_m2p_table(struct mem_hotadd_info *info) ret = setup_compat_m2p_table(info); error: - UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); - UNMAP_XEN_PAGETABLE_NEW(l3_ro_mpt); + UNMAP_XEN_PAGETABLE(l2_ro_mpt); + UNMAP_XEN_PAGETABLE(l3_ro_mpt); return ret; } @@ -569,23 +569,23 @@ void __init paging_init(void) l3_pgentry_t *pl3t; mfn_t mfn; - mfn = alloc_xen_pagetable_new(); + mfn = alloc_xen_pagetable(); if ( mfn_eq(mfn, INVALID_MFN) ) goto nomem; - pl3t = map_xen_pagetable_new(mfn); + pl3t = map_xen_pagetable(mfn); clear_page(pl3t); l4e_write(&idle_pg_table[l4_table_offset(va)], l4e_from_mfn(mfn, __PAGE_HYPERVISOR_RW)); - UNMAP_XEN_PAGETABLE_NEW(pl3t); + UNMAP_XEN_PAGETABLE(pl3t); } } /* Create user-accessible L2 directory to map the MPT for guests. */ - l3_ro_mpt_mfn = alloc_xen_pagetable_new(); + l3_ro_mpt_mfn = alloc_xen_pagetable(); if ( mfn_eq(l3_ro_mpt_mfn, INVALID_MFN) ) goto nomem; - l3_ro_mpt = map_xen_pagetable_new(l3_ro_mpt_mfn); + l3_ro_mpt = map_xen_pagetable(l3_ro_mpt_mfn); clear_page(l3_ro_mpt); l4e_write(&idle_pg_table[l4_table_offset(RO_MPT_VIRT_START)], l4e_from_mfn(l3_ro_mpt_mfn, __PAGE_HYPERVISOR_RO | _PAGE_USER)); @@ -675,13 +675,13 @@ void __init paging_init(void) * Unmap l2_ro_mpt, which could've been mapped in previous * iteration. */ - unmap_xen_pagetable_new(l2_ro_mpt); + unmap_xen_pagetable(l2_ro_mpt); - l2_ro_mpt_mfn = alloc_xen_pagetable_new(); + l2_ro_mpt_mfn = alloc_xen_pagetable(); if ( mfn_eq(l2_ro_mpt_mfn, INVALID_MFN) ) goto nomem; - l2_ro_mpt = map_xen_pagetable_new(l2_ro_mpt_mfn); + l2_ro_mpt = map_xen_pagetable(l2_ro_mpt_mfn); clear_page(l2_ro_mpt); l3e_write(&l3_ro_mpt[l3_table_offset(va)], l3e_from_mfn(l2_ro_mpt_mfn, @@ -697,8 +697,8 @@ void __init paging_init(void) } #undef CNT #undef MFN - UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); - UNMAP_XEN_PAGETABLE_NEW(l3_ro_mpt); + UNMAP_XEN_PAGETABLE(l2_ro_mpt); + UNMAP_XEN_PAGETABLE(l3_ro_mpt); /* Create user-accessible L2 directory to map the MPT for compat guests. */ BUILD_BUG_ON(l4_table_offset(RDWR_MPT_VIRT_START) != @@ -706,12 +706,12 @@ void __init paging_init(void) l3_ro_mpt_mfn = l4e_get_mfn(idle_pg_table[l4_table_offset( HIRO_COMPAT_MPT_VIRT_START)]); - l3_ro_mpt = map_xen_pagetable_new(l3_ro_mpt_mfn); + l3_ro_mpt = map_xen_pagetable(l3_ro_mpt_mfn); - l2_ro_mpt_mfn = alloc_xen_pagetable_new(); + l2_ro_mpt_mfn = alloc_xen_pagetable(); if ( mfn_eq(l2_ro_mpt_mfn, INVALID_MFN) ) goto nomem; - l2_ro_mpt = map_xen_pagetable_new(l2_ro_mpt_mfn); + l2_ro_mpt = map_xen_pagetable(l2_ro_mpt_mfn); compat_idle_pg_table_l2 = map_domain_page_global(l2_ro_mpt_mfn); clear_page(l2_ro_mpt); l3e_write(&l3_ro_mpt[l3_table_offset(HIRO_COMPAT_MPT_VIRT_START)], @@ -757,8 +757,8 @@ void __init paging_init(void) #undef CNT #undef MFN - UNMAP_XEN_PAGETABLE_NEW(l2_ro_mpt); - UNMAP_XEN_PAGETABLE_NEW(l3_ro_mpt); + UNMAP_XEN_PAGETABLE(l2_ro_mpt); + UNMAP_XEN_PAGETABLE(l3_ro_mpt); machine_to_phys_mapping_valid = 1; @@ -816,10 +816,10 @@ static void cleanup_frame_table(struct mem_hotadd_info *info) while (sva < eva) { - l3t = map_xen_pagetable_new( + l3t = map_xen_pagetable( l4e_get_mfn(idle_pg_table[l4_table_offset(sva)])); l3e = l3t[l3_table_offset(sva)]; - UNMAP_XEN_PAGETABLE_NEW(l3t); + UNMAP_XEN_PAGETABLE(l3t); if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) || (l3e_get_flags(l3e) & _PAGE_PSE) ) { @@ -828,9 +828,9 @@ static void cleanup_frame_table(struct mem_hotadd_info *info) continue; } - l2t = map_xen_pagetable_new(l3e_get_mfn(l3e)); + l2t = map_xen_pagetable(l3e_get_mfn(l3e)); l2e = l2t[l2_table_offset(sva)]; - UNMAP_XEN_PAGETABLE_NEW(l2t); + UNMAP_XEN_PAGETABLE(l2t); ASSERT(l2e_get_flags(l2e) & _PAGE_PRESENT); if ( (l2e_get_flags(l2e) & (_PAGE_PRESENT | _PAGE_PSE)) == @@ -848,10 +848,10 @@ static void cleanup_frame_table(struct mem_hotadd_info *info) #ifndef NDEBUG { - l1_pgentry_t *l1t = map_xen_pagetable_new(l2e_get_mfn(l2e)); + l1_pgentry_t *l1t = map_xen_pagetable(l2e_get_mfn(l2e)); ASSERT(l1e_get_flags(l1t[l1_table_offset(sva)]) & _PAGE_PRESENT); - UNMAP_XEN_PAGETABLE_NEW(l1t); + UNMAP_XEN_PAGETABLE(l1t); } #endif sva = (sva & ~((1UL << PAGE_SHIFT) - 1)) + @@ -942,10 +942,10 @@ void __init subarch_init_memory(void) { n = L2_PAGETABLE_ENTRIES * L1_PAGETABLE_ENTRIES; - l3t = map_xen_pagetable_new( + l3t = map_xen_pagetable( l4e_get_mfn(idle_pg_table[l4_table_offset(v)])); l3e = l3t[l3_table_offset(v)]; - UNMAP_XEN_PAGETABLE_NEW(l3t); + UNMAP_XEN_PAGETABLE(l3t); if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) continue; @@ -953,9 +953,9 @@ void __init subarch_init_memory(void) { n = L1_PAGETABLE_ENTRIES; - l2t = map_xen_pagetable_new(l3e_get_mfn(l3e)); + l2t = map_xen_pagetable(l3e_get_mfn(l3e)); l2e = l2t[l2_table_offset(v)]; - UNMAP_XEN_PAGETABLE_NEW(l2t); + UNMAP_XEN_PAGETABLE(l2t); if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) ) continue; @@ -975,17 +975,17 @@ void __init subarch_init_memory(void) v != RDWR_COMPAT_MPT_VIRT_END; v += 1 << L2_PAGETABLE_SHIFT ) { - l3t = map_xen_pagetable_new( + l3t = map_xen_pagetable( l4e_get_mfn(idle_pg_table[l4_table_offset(v)])); l3e = l3t[l3_table_offset(v)]; - UNMAP_XEN_PAGETABLE_NEW(l3t); + UNMAP_XEN_PAGETABLE(l3t); if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) continue; - l2t = map_xen_pagetable_new(l3e_get_mfn(l3e)); + l2t = map_xen_pagetable(l3e_get_mfn(l3e)); l2e = l2t[l2_table_offset(v)]; - UNMAP_XEN_PAGETABLE_NEW(l2t); + UNMAP_XEN_PAGETABLE(l2t); if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) ) continue; @@ -1036,18 +1036,18 @@ long subarch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) (v < (unsigned long)(machine_to_phys_mapping + max_page)); i++, v += 1UL << L2_PAGETABLE_SHIFT ) { - l3t = map_xen_pagetable_new( + l3t = map_xen_pagetable( l4e_get_mfn(idle_pg_table[l4_table_offset(v)])); l3e = l3t[l3_table_offset(v)]; - UNMAP_XEN_PAGETABLE_NEW(l3t); + UNMAP_XEN_PAGETABLE(l3t); if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) mfn = last_mfn; else if ( !(l3e_get_flags(l3e) & _PAGE_PSE) ) { - l2t = map_xen_pagetable_new(l3e_get_mfn(l3e)); + l2t = map_xen_pagetable(l3e_get_mfn(l3e)); l2e = l2t[l2_table_offset(v)]; - UNMAP_XEN_PAGETABLE_NEW(l2t); + UNMAP_XEN_PAGETABLE(l2t); if ( l2e_get_flags(l2e) & _PAGE_PRESENT ) mfn = l2e_get_pfn(l2e); else diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index f55d6a6d76..d47067c998 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -1443,20 +1443,20 @@ static __init void copy_mapping(l4_pgentry_t *l4, { mfn_t l3t_mfn; - l3t_mfn = alloc_xen_pagetable_new(); + l3t_mfn = alloc_xen_pagetable(); BUG_ON(mfn_eq(l3t_mfn, INVALID_MFN)); - l3dst = map_xen_pagetable_new(l3t_mfn); + l3dst = map_xen_pagetable(l3t_mfn); clear_page(l3dst); l4[l4_table_offset(mfn << PAGE_SHIFT)] = l4e_from_mfn(l3t_mfn, __PAGE_HYPERVISOR); } else - l3dst = map_xen_pagetable_new(l4e_get_mfn(l4e)); - l3src = map_xen_pagetable_new( + l3dst = map_xen_pagetable(l4e_get_mfn(l4e)); + l3src = map_xen_pagetable( l4e_get_mfn(idle_pg_table[l4_table_offset(va)])); l3dst[l3_table_offset(mfn << PAGE_SHIFT)] = l3src[l3_table_offset(va)]; - UNMAP_XEN_PAGETABLE_NEW(l3src); - UNMAP_XEN_PAGETABLE_NEW(l3dst); + UNMAP_XEN_PAGETABLE(l3src); + UNMAP_XEN_PAGETABLE(l3dst); } } @@ -1604,9 +1604,9 @@ void __init efi_init_memory(void) mdesc_ver, efi_memmap); #else /* Set up 1:1 page tables to do runtime calls in "physical" mode. */ - efi_l4_mfn = alloc_xen_pagetable_new(); + efi_l4_mfn = alloc_xen_pagetable(); BUG_ON(mfn_eq(efi_l4_mfn, INVALID_MFN)); - efi_l4_pgtable = map_xen_pagetable_new(efi_l4_mfn); + efi_l4_pgtable = map_xen_pagetable(efi_l4_mfn); clear_page(efi_l4_pgtable); copy_mapping(efi_l4_pgtable, 0, max_page, ram_range_valid); @@ -1641,31 +1641,31 @@ void __init efi_init_memory(void) { mfn_t l3t_mfn; - l3t_mfn = alloc_xen_pagetable_new(); + l3t_mfn = alloc_xen_pagetable(); BUG_ON(mfn_eq(l3t_mfn, INVALID_MFN)); - pl3e = map_xen_pagetable_new(l3t_mfn); + pl3e = map_xen_pagetable(l3t_mfn); clear_page(pl3e); efi_l4_pgtable[l4_table_offset(addr)] = l4e_from_mfn(l3t_mfn, __PAGE_HYPERVISOR); } else - pl3e = map_xen_pagetable_new(l4e_get_mfn(l4e)); + pl3e = map_xen_pagetable(l4e_get_mfn(l4e)); pl3e += l3_table_offset(addr); if ( !(l3e_get_flags(*pl3e) & _PAGE_PRESENT) ) { mfn_t l2t_mfn; - l2t_mfn = alloc_xen_pagetable_new(); + l2t_mfn = alloc_xen_pagetable(); BUG_ON(mfn_eq(l2t_mfn, INVALID_MFN)); - pl2e = map_xen_pagetable_new(l2t_mfn); + pl2e = map_xen_pagetable(l2t_mfn); clear_page(pl2e); *pl3e = l3e_from_mfn(l2t_mfn, __PAGE_HYPERVISOR); } else { BUG_ON(l3e_get_flags(*pl3e) & _PAGE_PSE); - pl2e = map_xen_pagetable_new(l3e_get_mfn(*pl3e)); + pl2e = map_xen_pagetable(l3e_get_mfn(*pl3e)); } pl2e += l2_table_offset(addr); @@ -1673,16 +1673,16 @@ void __init efi_init_memory(void) { mfn_t l1t_mfn; - l1t_mfn = alloc_xen_pagetable_new(); + l1t_mfn = alloc_xen_pagetable(); BUG_ON(mfn_eq(l1t_mfn, INVALID_MFN)); - l1t = map_xen_pagetable_new(l1t_mfn); + l1t = map_xen_pagetable(l1t_mfn); clear_page(l1t); *pl2e = l2e_from_mfn(l1t_mfn, __PAGE_HYPERVISOR); } else { BUG_ON(l2e_get_flags(*pl2e) & _PAGE_PSE); - l1t = map_xen_pagetable_new(l2e_get_mfn(*pl2e)); + l1t = map_xen_pagetable(l2e_get_mfn(*pl2e)); } for ( i = l1_table_offset(addr); i < L1_PAGETABLE_ENTRIES && extra->smfn < extra->emfn; @@ -1695,9 +1695,9 @@ void __init efi_init_memory(void) xfree(extra); } - UNMAP_XEN_PAGETABLE_NEW(l1t); - UNMAP_XEN_PAGETABLE_NEW(pl2e); - UNMAP_XEN_PAGETABLE_NEW(pl3e); + UNMAP_XEN_PAGETABLE(l1t); + UNMAP_XEN_PAGETABLE(pl2e); + UNMAP_XEN_PAGETABLE(pl3e); } /* Insert Xen mappings. */ @@ -1706,7 +1706,7 @@ void __init efi_init_memory(void) efi_l4_pgtable[i] = idle_pg_table[i]; #endif - UNMAP_XEN_PAGETABLE_NEW(efi_l4_pgtable); + UNMAP_XEN_PAGETABLE(efi_l4_pgtable); } #endif diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 4fb79ab8f0..a4b3c9b7af 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -631,15 +631,15 @@ int arch_acquire_resource(struct domain *d, unsigned int type, unsigned int nr_frames, xen_pfn_t mfn_list[]); /* Allocator functions for Xen pagetables. */ -mfn_t alloc_xen_pagetable_new(void); -void *map_xen_pagetable_new(mfn_t mfn); -void unmap_xen_pagetable_new(void *v); -void free_xen_pagetable_new(mfn_t mfn); - -#define UNMAP_XEN_PAGETABLE_NEW(ptr) \ - do { \ - unmap_xen_pagetable_new((ptr)); \ - (ptr) = NULL; \ +mfn_t alloc_xen_pagetable(void); +void *map_xen_pagetable(mfn_t mfn); +void unmap_xen_pagetable(void *v); +void free_xen_pagetable(mfn_t mfn); + +#define UNMAP_XEN_PAGETABLE(ptr) \ + do { \ + unmap_xen_pagetable((ptr)); \ + (ptr) = NULL; \ } while (0) l1_pgentry_t *virt_to_xen_l1e(unsigned long v);