From patchwork Thu Sep 26 09:45: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: 11162081 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 5486513B1 for ; Thu, 26 Sep 2019 09:49:24 +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 23578222C4 for ; Thu, 26 Sep 2019 09:49:24 +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="QxtzOIPw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 23578222C4 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 1iDQNd-0004AT-Qc; Thu, 26 Sep 2019 09:48:09 +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 1iDQNc-00049A-B8 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:08 +0000 X-Inumbo-ID: bd9b7079-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id bd9b7079-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48: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=1569491288; x=1601027288; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=dzdF87SizyQOXNy95CNVyj6xRv19mPnErY+Ua4/etgQ=; b=QxtzOIPwyS19O/2NCHjPysKb3smqueOVRlVY7hF/SYrYHPivpg2fbzj7 jkjD/dckg67CGdAwbWSSdDEBh96OL1gCPFqE/LjMVhCTTgzXNl+QWQFNA nDQNP+l4R+khll/UC9w9AyYD6NRW9xZcHmEBxeJAHe0XROZoKMIpHWclU Y=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836988546" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1a-821c648d.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 26 Sep 2019 09:47:08 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1a-821c648d.us-east-1.amazon.com (Postfix) with ESMTPS id BA090A238B; Thu, 26 Sep 2019 09:46:55 +0000 (UTC) Received: from EX13D13UWA001.ant.amazon.com (10.43.160.136) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:46:55 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D13UWA001.ant.amazon.com (10.43.160.136) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:46:54 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:46:53 +0000 From: To: Date: Thu, 26 Sep 2019 10:45: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] [RFC PATCH 01/84] x86/mm: defer clearing page in virt_to_xen_lXe 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Defer the call to clear_page to the point when we're sure the page is going to become a page table. This is a minor optimisation. No functional change. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 99816fc67c..e90c8a63a6 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4879,13 +4879,13 @@ static l3_pgentry_t *virt_to_xen_l3e(unsigned long v) if ( !pl3e ) return NULL; - clear_page(pl3e); 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); + clear_page(pl3e); l4e_write(pl4e, l4e); efi_update_l4_pgtable(l4_table_offset(v), l4e); pl3e = NULL; @@ -4914,11 +4914,11 @@ static l2_pgentry_t *virt_to_xen_l2e(unsigned long v) if ( !pl2e ) return NULL; - clear_page(pl2e); 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; } @@ -4947,11 +4947,11 @@ l1_pgentry_t *virt_to_xen_l1e(unsigned long v) if ( !pl1e ) return NULL; - clear_page(pl1e); 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; } From patchwork Thu Sep 26 09:45: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: 11162119 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 CA48013BD for ; Thu, 26 Sep 2019 09:50:13 +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 A5AEA222C0 for ; Thu, 26 Sep 2019 09:50:13 +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="vZs6ypAm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5AEA222C0 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 1iDQOt-0006FR-Nd; Thu, 26 Sep 2019 09:49:27 +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 1iDQOr-0006BS-U9 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:25 +0000 X-Inumbo-ID: dac3b55d-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id dac3b55d-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491336; x=1601027336; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=5Q2XE0XvYzUty69qqRlTGEEguqCrML7ftDS0JmcjKEo=; b=vZs6ypAmKaV/ssztcrieLjCkc8w+9mUfpHTEB7hibcWeWNwew7xIIc+Q Nn/rJpCBQVrBZnOg7o7C4tWpbqc5W7cxvwA38N1h09EAyp3/HLH2UV7jE FAZ2aQPawwDlW7F3irz1rFOv842xRlT9Hfo5GxUqXk12F0qm7AGYjWby6 M=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="704637159" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1d-37fd6b3d.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 26 Sep 2019 09:47:14 +0000 Received: from EX13MTAUWA001.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 AADD6281FDE; Thu, 26 Sep 2019 09:46:57 +0000 (UTC) Received: from EX13D19UWA001.ant.amazon.com (10.43.160.169) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:46:57 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D19UWA001.ant.amazon.com (10.43.160.169) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:46:56 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:46:55 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:25 +0100 Message-ID: <70b327fb33bf4e53ce98ad547589170fa93c62fe.1569489002.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] [RFC PATCH 02/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:45: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: 11162103 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 4253C13B1 for ; Thu, 26 Sep 2019 09:50: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 1E416222C3 for ; Thu, 26 Sep 2019 09:50: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="tXrbE+QD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E416222C3 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 1iDQOi-0005sc-Po; Thu, 26 Sep 2019 09:49: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 1iDQOh-0005qU-R1 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:15 +0000 X-Inumbo-ID: dac3b55c-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id dac3b55c-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491336; x=1601027336; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=RDCbfQZPMBLWD5HES/JB4RFQjNpnLWAPbAQJ3Nba6J0=; b=tXrbE+QDk6+rlhuu2rp3pO84eM5X5nYgtoSEXY2mMZjTWtWfa3gYda90 9wcwFx5LABGccl3iwC2Y5ktiD09WVZrK5iJsow3FRMBev6cM1vrA+reEE PDwNGZe9Hsz8zomsH/OD3uJNOIVvRC20wPPnOAMbZV5sHaohaKTTVsWll U=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="704637160" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1a-821c648d.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 26 Sep 2019 09:47:16 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1a-821c648d.us-east-1.amazon.com (Postfix) with ESMTPS id 9F2E0A2397; Thu, 26 Sep 2019 09:46:59 +0000 (UTC) Received: from EX13D32UWA004.ant.amazon.com (10.43.160.193) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:46:59 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D32UWA004.ant.amazon.com (10.43.160.193) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:46:58 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:46:57 +0000 From: To: Date: Thu, 26 Sep 2019 10:45: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] [RFC PATCH 03/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:45: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: 11162049 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 882A5924 for ; Thu, 26 Sep 2019 09:48: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 5841B222C0 for ; Thu, 26 Sep 2019 09:48: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="IazlgGnw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5841B222C0 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 1iDQMd-0003cX-8n; Thu, 26 Sep 2019 09:47:07 +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 1iDQMb-0003bg-JP for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:47:05 +0000 X-Inumbo-ID: 98f1bd54-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id 98f1bd54-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:47: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=1569491224; x=1601027224; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=IwBygj+RhjB/roSYIAno5ZW1vZEaPnrSx3ay7bN2WgM=; b=IazlgGnw7nOwXEWfUhNyLxqwrBlLENHgv6ZMLvVsLvyfGpwHp5ZKzHpn Eew8Stb2YZk/EFr+Osdl3NTntwhtLlrUs1aAhRhZ4ur5+gZiP+beOMgSj +Zir9iRasy0o+Cg5nZr1+4xRZ/wjVOV4rR6MtqGsCB86JZES28VhbDyh5 U=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="753353976" 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; 26 Sep 2019 09:47:03 +0000 Received: from EX13MTAUWA001.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 7092F141773; Thu, 26 Sep 2019 09:47:01 +0000 (UTC) Received: from EX13D13UWA001.ant.amazon.com (10.43.160.136) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:01 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D13UWA001.ant.amazon.com (10.43.160.136) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:00 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:46:59 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:27 +0100 Message-ID: <57342866b36c4c5184a4e378f1993e985c6c3115.1569489002.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] [RFC PATCH 04/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:45: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: 11162051 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 B140113B1 for ; Thu, 26 Sep 2019 09:48: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 8D2B6222C3 for ; Thu, 26 Sep 2019 09:48: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="cIxMP0I9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D2B6222C3 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 1iDQMs-0003f0-Nc; Thu, 26 Sep 2019 09:47: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 1iDQMs-0003es-Bk for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:47:22 +0000 X-Inumbo-ID: a308f41a-e042-11e9-bf31-bc764e2007e4 Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id a308f41a-e042-11e9-bf31-bc764e2007e4; Thu, 26 Sep 2019 09:47:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491241; x=1601027241; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=ylxx4KY9/y4YFgv7nP3EOYtykrPz1aPjA0nz6rqmeOA=; b=cIxMP0I9O6KH+tTu30YsBHhPK5WwVO7jyv5CgUsZ1pklnU5tDJRl5YV9 W1JCCKXu0RhHaHQ6lOzUfi1sFpCAsPQjsWMcpylm8T+eBC6b1k6uaK1Xl 25uh0hL3TpiCja07XiL136JfSg7rHjGkNaI/Wd14pUh+ICO5oLvU8zddV E=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="753354010" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1d-474bcd9f.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 26 Sep 2019 09:47:21 +0000 Received: from EX13MTAUWA001.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 BD8ACA26EE; Thu, 26 Sep 2019 09:47:19 +0000 (UTC) Received: from EX13D20UWA001.ant.amazon.com (10.43.160.34) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:03 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D20UWA001.ant.amazon.com (10.43.160.34) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:02 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:01 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:28 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [RFC PATCH 05/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:45: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: 11162115 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 8732713B1 for ; Thu, 26 Sep 2019 09:50: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 5C628222C4 for ; Thu, 26 Sep 2019 09:50: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="XRlRg22Q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C628222C4 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 1iDQOr-0006B5-Lv; Thu, 26 Sep 2019 09:49: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 1iDQOp-00065f-59 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:23 +0000 X-Inumbo-ID: e8691dfa-e042-11e9-97fb-bc764e2007e4 Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id e8691dfa-e042-11e9-97fb-bc764e2007e4; Thu, 26 Sep 2019 09:49: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=1569491359; x=1601027359; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=kpUuXZAvzGVSonE9aOxyMJVulSwYJnIv2Ma6gLcbPBA=; b=XRlRg22QFcrH58CdfCf8nUE4XmZBWrUhOIOrOKh3neVPuJC1TxqD3FmS Irrkjlmj8YMHUX38sE/7cAnmqyCMaNX0ESSM4/vCzq7B5TNJlL2cHKffu ZphS7jGuUZJQtKb0IGmokExfck2xr80RnIGR7rKAWaXI7Z1xPx4MVfs9u Q=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="704637215" 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; 26 Sep 2019 09:47:41 +0000 Received: from EX13MTAUWA001.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 51664A190A; Thu, 26 Sep 2019 09:47:24 +0000 (UTC) Received: from EX13D15UWA001.ant.amazon.com (10.43.160.152) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:05 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D15UWA001.ant.amazon.com (10.43.160.152) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:04 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:03 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:29 +0100 Message-ID: <857b41c9da828de697d4b85f81f98aec6c4dd666.1569489002.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] [RFC PATCH 06/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:45: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: 11162053 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 66C5B13B1 for ; Thu, 26 Sep 2019 09:48:53 +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 41D58222C0 for ; Thu, 26 Sep 2019 09:48:53 +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="CXu4Em4v" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 41D58222C0 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 1iDQN6-0003hs-1P; Thu, 26 Sep 2019 09:47: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 1iDQN4-0003he-T9 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:47:34 +0000 X-Inumbo-ID: aa7267b8-e042-11e9-bf31-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id aa7267b8-e042-11e9-bf31-bc764e2007e4; Thu, 26 Sep 2019 09:47:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491254; x=1601027254; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=5eAgOpLk7B+gyLwhtLD5m88hf+aaR83vnf4le+j06Qo=; b=CXu4Em4vWkCaFuLr6J1ndS7L6Ax5NLBEyENjphnEbaMOTdzQsvfiPicW B48ZPbdNrwqrcKFPUtTAzXVkGZf7GLSgmnCzbgjCEItzwx4xf72TIH52m wo3X3W2fW8jWKb2Glw0L2c/XpgFEYOYtOdaDcKsoblSD9midUTbrQQQrJ w=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="423750353" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-16acd5e0.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 26 Sep 2019 09:47:31 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-16acd5e0.us-east-1.amazon.com (Postfix) with ESMTPS id B2E93A288E; Thu, 26 Sep 2019 09:47:29 +0000 (UTC) Received: from EX13D13UWA003.ant.amazon.com (10.43.160.181) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:07 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D13UWA003.ant.amazon.com (10.43.160.181) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:06 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:05 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:30 +0100 Message-ID: <72df1b211d891a052d509d46d8f8241a6ea0ca5e.1569489002.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] [RFC PATCH 07/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:45: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: 11162055 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 D16A613B1 for ; Thu, 26 Sep 2019 09:48:58 +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 AD269222C0 for ; Thu, 26 Sep 2019 09:48:58 +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="o8YFuwEZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD269222C0 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 1iDQNC-0003jt-CK; Thu, 26 Sep 2019 09:47: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 1iDQNA-0003jH-Ld for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:47:40 +0000 X-Inumbo-ID: addfbb1d-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id addfbb1d-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:47: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=1569491260; x=1601027260; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Mauyqd924PdT/m+H441U/gI5RxdAY067bvDgJxjGF/A=; b=o8YFuwEZOU0dKjpazJlMlMas92ZT8eD3/Ce4d4Cj4ZRzkwye9u9O3zWu QYdmqn6Pos5tuwjp5PbM7y+rQOVZ3aAZ3YygF5c23Xrq2yJWJ4PgFABSB 9sa6l9myW0VSzRhRx/Hd9yyoroHsKKeNjEKYhz5ryM5CPldYo43nzKEyu E=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="423750365" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-807d4a99.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 26 Sep 2019 09:47:39 +0000 Received: from EX13MTAUWA001.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 E3DECA1F34; Thu, 26 Sep 2019 09:47:37 +0000 (UTC) Received: from EX13P01UWA003.ant.amazon.com (10.43.160.197) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:08 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13P01UWA003.ant.amazon.com (10.43.160.197) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:08 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:07 +0000 From: To: Date: Thu, 26 Sep 2019 10:45: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] [RFC PATCH 08/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:45: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: 11162107 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 C85C013BD for ; Thu, 26 Sep 2019 09:50:06 +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 A4E03222C0 for ; Thu, 26 Sep 2019 09:50:06 +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="G8ovb6z/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4E03222C0 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 1iDQOE-00052Q-S2; Thu, 26 Sep 2019 09:48:46 +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 1iDQOD-00050b-Qg for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:45 +0000 X-Inumbo-ID: d3402a68-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id d3402a68-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48: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=1569491324; x=1601027324; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=swDCRUW0LzPuFtPbYgjWPDHeLL7krWJ7Ji5Wu5oJhuE=; b=G8ovb6z/lCDMk6fSCtHj3t3IzZU2Qz4L1jdQdp57eWvJbXhQfHAkyJZw IvvnY55tdaVQnYibH4/dnkjZnRWtUcdYPqTPXGCqXJ8+/TsMiIrDCVErv 5B6JIx6OBzdCGDe6EWrpVlI8UbhIObPuGTd754BudMw7qru1s5l4xfRrf s=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836988696" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1e-a70de69e.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 26 Sep 2019 09:47:51 +0000 Received: from EX13MTAUWA001.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 82EBBA2376; Thu, 26 Sep 2019 09:47:39 +0000 (UTC) Received: from EX13D06UWA003.ant.amazon.com (10.43.160.13) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:10 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D06UWA003.ant.amazon.com (10.43.160.13) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:10 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:08 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:32 +0100 Message-ID: <75febda9a3f5b8263df37cc09e8a1bda409d48b9.1569489002.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] [RFC PATCH 09/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:45: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: 11162145 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 B793613BD for ; Thu, 26 Sep 2019 09:50: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 93A52222C0 for ; Thu, 26 Sep 2019 09:50: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="mg4OCw6X" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93A52222C0 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 1iDQPA-0006oH-L9; Thu, 26 Sep 2019 09:49:44 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iDQP9-0006ku-59 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:43 +0000 X-Inumbo-ID: f1597b94-e042-11e9-b588-bc764e2007e4 Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id f1597b94-e042-11e9-b588-bc764e2007e4; Thu, 26 Sep 2019 09:49: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=1569491374; x=1601027374; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=iM0pBRhHPqSu1d/F9uL8ZRB9EnCqA5i0SQPBpzKDfcA=; b=mg4OCw6XPvRdMU/LNsiFEKyriJaVIpWUWNTcMesE60Kw08V+p7A/92Qy AZWIbRFB/oXecaebpM9Cn5lg9YrB7fCClwBzTL/x1BlYvJdmHWmGlV0kv 4XXSk21zZ4zdLqO6Ksdd7yGgwjIIMwmNIXnK7jDOuuGmHsUKiOM78nabd 4=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="704637261" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1e-a70de69e.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 26 Sep 2019 09:48:00 +0000 Received: from EX13MTAUWA001.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 34C6BA2443; Thu, 26 Sep 2019 09:47:44 +0000 (UTC) Received: from EX13D18UWA003.ant.amazon.com (10.43.160.238) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:12 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D18UWA003.ant.amazon.com (10.43.160.238) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:12 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:10 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:33 +0100 Message-ID: <78ad85ad08e14a59d7e6aa59b5aeac0bfa7bf82a.1569489002.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] [RFC PATCH 10/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:45: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: 11162127 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 9954F13B1 for ; Thu, 26 Sep 2019 09:50: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 756BF222C4 for ; Thu, 26 Sep 2019 09:50: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="UOIg+PrI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 756BF222C4 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 1iDQOT-0005Os-4i; Thu, 26 Sep 2019 09:49:01 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iDQOR-0005Mo-QS for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:59 +0000 X-Inumbo-ID: dc80e46e-e042-11e9-8628-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id dc80e46e-e042-11e9-8628-bc764e2007e4; Thu, 26 Sep 2019 09:48: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=1569491339; x=1601027339; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=IWvv3JFE8UC9wDGna0qJ6XB0bPktobco6eb0qHMgbxc=; b=UOIg+PrIjjbRfK28IvkxC8avQRlYRZkfwzUo+oQZohXhh3ghGBq+HTSk 8v2rUh/HFF3FLJBcCK0vdhi7vUnHWXExtS1Gaxpp9893042kXXZTngx5A UiGe6sHMZ9UIElkfEZZLJePeNtJaFBSn5F1LxU476TUa7XJL+PqdTueTP U=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836988727" 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; 26 Sep 2019 09:47:57 +0000 Received: from EX13MTAUWA001.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 2DE26A2684; Thu, 26 Sep 2019 09:47:46 +0000 (UTC) Received: from EX13D03UWA001.ant.amazon.com (10.43.160.141) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:14 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D03UWA001.ant.amazon.com (10.43.160.141) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:13 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:12 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:34 +0100 Message-ID: <17912d14fabfdcce9b309028fc9a0a8dbf5a5f32.1569489002.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] [RFC PATCH 11/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:45: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: 11162069 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 3D61D1709 for ; Thu, 26 Sep 2019 09:49:13 +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 1895F222C0 for ; Thu, 26 Sep 2019 09:49:13 +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="QXB3ierz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1895F222C0 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 1iDQNM-0003nQ-NC; Thu, 26 Sep 2019 09:47:52 +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 1iDQNK-0003mj-Ie for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:47:50 +0000 X-Inumbo-ID: b3c657de-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id b3c657de-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:47: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=1569491270; x=1601027270; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=JByvjWRTQDqIZJNIb36YOya7+MZMs5J4FP69RDCf1ls=; b=QXB3ierzAEe9F1JxbjerYBuoSamr3bydVn6vRW/o01umdmlx/Wlg7rF/ hlUwrMwVJEKwqVv44LMkXKZ8qIsV2WU1+RKMBX8mgJb4adhGmKJw/DiU4 cBg/BMc8J9a3wfYn2jJFgRSjqMzHUsjJVVGKCyFoWK0miVJUO0pmdejSx k=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="417788087" 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; 26 Sep 2019 09:47:47 +0000 Received: from EX13MTAUWA001.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 63283A2455; Thu, 26 Sep 2019 09:47:47 +0000 (UTC) Received: from EX13D07UWA004.ant.amazon.com (10.43.160.32) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:16 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D07UWA004.ant.amazon.com (10.43.160.32) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:15 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:14 +0000 From: To: Date: Thu, 26 Sep 2019 10:45: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] [RFC PATCH 12/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:45: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: 11162101 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 BAD4013B1 for ; Thu, 26 Sep 2019 09:49: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 94C25222C0 for ; Thu, 26 Sep 2019 09:49: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="K3ImUR0U" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94C25222C0 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 1iDQOb-0005f0-RO; Thu, 26 Sep 2019 09:49: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 1iDQOa-0005be-3Z for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:08 +0000 X-Inumbo-ID: dd5dbc9a-e042-11e9-bf31-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id dd5dbc9a-e042-11e9-bf31-bc764e2007e4; Thu, 26 Sep 2019 09:49:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491341; x=1601027341; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Py9hgP70m9HBUfBEhr08s8H5V3T2TLC0UE4W9w9lg6s=; b=K3ImUR0Ulonl23S/SMPdSoSQE12JqVyCNx9dLcC+GPwVOgWjaesBYeo+ 2xrJRwMUUeUvJrFOIMLuBpLNwWWPSPxVbvsJf5phf2zM0pn+fuk9IFR7j vKan9jCkrxBltvLH+2pzlC8GTmf6MCL/Zf87EcYu89AHSmMpnHPIrLsye E=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836988740" 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; 26 Sep 2019 09:48:02 +0000 Received: from EX13MTAUWA001.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 011A0A2A48; Thu, 26 Sep 2019 09:47:49 +0000 (UTC) Received: from EX13D23UWA001.ant.amazon.com (10.43.160.68) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:18 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D23UWA001.ant.amazon.com (10.43.160.68) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:17 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:16 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:36 +0100 Message-ID: <0f7cf39cee6b4a2ca4ddec25d264a5e55313886b.1569489002.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] [RFC PATCH 13/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:45: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: 11162067 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 C077213B1 for ; Thu, 26 Sep 2019 09:49: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 9C6DA222C0 for ; Thu, 26 Sep 2019 09:49: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="c4VjpE2F" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C6DA222C0 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 1iDQNP-0003qj-JJ; Thu, 26 Sep 2019 09:47:55 +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 1iDQNO-0003om-F5 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:47:54 +0000 X-Inumbo-ID: b57367e9-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id b57367e9-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:47: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=1569491273; x=1601027273; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=hTkmNlwsOjF0Hl2l2Hvic+lIfqYsmmXAm8fsLU5GbNQ=; b=c4VjpE2Fr6RVuJfmSRwtaEdNqnqV6WXjwVThXASF74BTVkkG+8j140jI 4T2cVgYTXrUWVpPGruXLSJS9KTc/0Y2eH+bH7DKPuFYPahaE0CwsW7q6w sG5FcRLCLPE6gzb7OlDBUcQ7mx7Xg/jO5M290ZEjuLuz6Pi/CIZj5QYs+ 4=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="423750415" 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-6002.iad6.amazon.com with ESMTP; 26 Sep 2019 09:47:53 +0000 Received: from EX13MTAUWA001.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 3AA862421A1; Thu, 26 Sep 2019 09:47:50 +0000 (UTC) Received: from EX13D31UWA003.ant.amazon.com (10.43.160.130) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:20 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D31UWA003.ant.amazon.com (10.43.160.130) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:19 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:18 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:37 +0100 Message-ID: <022d5088caa43d0eaf35f55630e0b66987b4fdea.1569489002.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] [RFC PATCH 14/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:45: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: 11162057 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 91F4013BD for ; Thu, 26 Sep 2019 09:49:07 +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 6E2E5222C0 for ; Thu, 26 Sep 2019 09:49:07 +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="Ww6PM7bE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E2E5222C0 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 1iDQNO-0003oL-1D; Thu, 26 Sep 2019 09:47:54 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iDQNN-0003o3-EL for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:47:53 +0000 X-Inumbo-ID: b5aaa212-e042-11e9-bf31-bc764e2007e4 Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id b5aaa212-e042-11e9-bf31-bc764e2007e4; Thu, 26 Sep 2019 09:47: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=1569491273; x=1601027273; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=oJedWuo8zlV2fAKG2dDdFVDd+2/P/qJmMMw67NRF0oI=; b=Ww6PM7bEkppWgztyfWRFRoOCEMAwB+ZCjNgGfzVZfSfbZFAimfTqM6fP FsFgQGMwbWFPVzdo5OR+WECu1/bS1kXyL9AmP+zYVXkjUHl0c0UHss1Eu NSml3nWmKo6Y3HoV2fMf+Z2swnHJm+Sl09AJYXXgLdQ7S7rhC2Pu6W00Y 4=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="753354102" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1d-f273de60.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 26 Sep 2019 09:47:52 +0000 Received: from EX13MTAUWA001.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 0D42BA22AC; Thu, 26 Sep 2019 09:47:51 +0000 (UTC) Received: from EX13D01UWA002.ant.amazon.com (10.43.160.74) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:22 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13d01UWA002.ant.amazon.com (10.43.160.74) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:20 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:20 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:38 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [RFC PATCH 15/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:45: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: 11162177 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 69A821709 for ; Thu, 26 Sep 2019 09:51:10 +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 45BE52053B for ; Thu, 26 Sep 2019 09:51:10 +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="D1GDVH79" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 45BE52053B 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 1iDQPl-0008MN-Tx; Thu, 26 Sep 2019 09:50: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 1iDQPk-0008Ho-Rm for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:20 +0000 X-Inumbo-ID: f595e512-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id f595e512-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:49:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491381; x=1601027381; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=zyosdYVmojrSWgJKr5OykIUlrK5LiuGCbfn1NO0sGF8=; b=D1GDVH79KEVlgcWrqKDNhvKDINUXe4Vo0uJswrQNanPpprXg2KEMVJE4 pnXJbcbXAZXhahuIFZHHRQXJWNZQu1DzBfof2vT5CV00C5/xbuih7WbkF 8E217wOcpRntdgAPywAzyHENJPdbKOpZsq4NL9VVrxl/X1Q/fFoAx3VZh M=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="704637294" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1d-98acfc19.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 26 Sep 2019 09:48:09 +0000 Received: from EX13MTAUWA001.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 897CDA18F2; Thu, 26 Sep 2019 09:47:51 +0000 (UTC) Received: from EX13D15UWA001.ant.amazon.com (10.43.160.152) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:23 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D15UWA001.ant.amazon.com (10.43.160.152) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:23 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:22 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:39 +0100 Message-ID: <5d71a079f647c913dc6cdfe30ce62c8728f37fc4.1569489002.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] [RFC PATCH 16/84] 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 , Wei Liu , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 --- xen/arch/x86/mm.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index f7fd0e6bad..0616666221 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 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 ) + 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(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)); + l3e_write_atomic(pl3e, l3e_from_mfn(mfn, __PAGE_HYPERVISOR)); + UNMAP_XEN_PAGETABLE_NEW(l2t); l2t = NULL; } 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(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 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 ) + 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, @@ -5337,15 +5346,19 @@ 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(mfn, __PAGE_HYPERVISOR)); + UNMAP_XEN_PAGETABLE_NEW(l1t); l1t = NULL; } 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(mfn); + } } pl1e = l2e_to_l1e(*pl2e) + l1_table_offset(virt); From patchwork Thu Sep 26 09:45: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: 11162071 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 3AB241709 for ; Thu, 26 Sep 2019 09:49: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 17243222C0 for ; Thu, 26 Sep 2019 09:49: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="Jj/r/P3a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17243222C0 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 1iDQNR-0003tL-VL; Thu, 26 Sep 2019 09:47:57 +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 1iDQNP-0003qn-Ow for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:47:55 +0000 X-Inumbo-ID: b5ac42df-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id b5ac42df-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:47: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=1569491273; x=1601027273; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=NzzwvERroAI+I7zkH8dvAghyc38Cq8FDW8eCIR3M3OY=; b=Jj/r/P3awWb7BtysKBUP7791LweCd85ru4U4DTxcoTjgg3KScVWUppND 5CjFj9dMM3UwSJ01fTA5PfMFL7sbxAdKa+lGymMSrdhQrGuzd4/a8uv39 L6bq+bCk7SUS1cI7IX8YZXaC//tMdAzJ8CkMeYASIYpWQ6u9RO7ANFZWc Q=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="417788121" 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-6001.iad6.amazon.com with ESMTP; 26 Sep 2019 09:47:53 +0000 Received: from EX13MTAUWA001.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 04F0824111A; Thu, 26 Sep 2019 09:47:52 +0000 (UTC) Received: from EX13D31UWA002.ant.amazon.com (10.43.160.82) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:25 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D31UWA002.ant.amazon.com (10.43.160.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:25 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:23 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:40 +0100 Message-ID: <754cbac796a3e4326e2ad6b103d85dbbc3f51ae2.1569489002.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] [RFC PATCH 17/84] xxx fixup: avoid shadowing mfn 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu --- xen/arch/x86/mm.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 0616666221..267e4ceef5 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5185,7 +5185,7 @@ int map_pages_to_xen( unsigned int flush_flags = FLUSH_TLB | FLUSH_ORDER(2 * PAGETABLE_ORDER); l2_pgentry_t *l2t; - mfn_t mfn; + mfn_t l2t_mfn; /* Skip this PTE if there is no change. */ if ( ((l3e_get_pfn(ol3e) & ~(L2_PAGETABLE_ENTRIES * @@ -5207,14 +5207,14 @@ int map_pages_to_xen( goto end_of_loop; } - mfn = alloc_xen_pagetable_new(); - if ( mfn_eq(mfn, INVALID_MFN) ) + l2t_mfn = alloc_xen_pagetable_new(); + if ( mfn_eq(l2t_mfn, INVALID_MFN) ) { ASSERT(rc == -ENOMEM); goto out; } - l2t = map_xen_pagetable_new(mfn); + l2t = map_xen_pagetable_new(l2t_mfn); for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) l2e_write(l2t + i, @@ -5230,7 +5230,8 @@ 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(mfn, __PAGE_HYPERVISOR)); + l3e_write_atomic(pl3e, + l3e_from_mfn(l2t_mfn, __PAGE_HYPERVISOR)); UNMAP_XEN_PAGETABLE_NEW(l2t); l2t = NULL; } @@ -5240,7 +5241,7 @@ int map_pages_to_xen( if ( l2t ) { UNMAP_XEN_PAGETABLE_NEW(l2t); - free_xen_pagetable_new(mfn); + free_xen_pagetable_new(l2t_mfn); } } @@ -5304,7 +5305,7 @@ int map_pages_to_xen( unsigned int flush_flags = FLUSH_TLB | FLUSH_ORDER(PAGETABLE_ORDER); l1_pgentry_t *l1t; - mfn_t mfn; + mfn_t l1t_mfn; /* Skip this PTE if there is no change. */ if ( (((l2e_get_pfn(*pl2e) & ~(L1_PAGETABLE_ENTRIES - 1)) + @@ -5324,14 +5325,14 @@ int map_pages_to_xen( goto check_l3; } - mfn = alloc_xen_pagetable_new(); - if ( mfn_eq(mfn, INVALID_MFN) ) + l1t_mfn = alloc_xen_pagetable_new(); + if ( mfn_eq(l1t_mfn, INVALID_MFN) ) { ASSERT(rc == -ENOMEM); goto out; } - l1t = map_xen_pagetable_new(mfn); + l1t = map_xen_pagetable_new(l1t_mfn); for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) l1e_write(&l1t[i], @@ -5346,7 +5347,7 @@ 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(mfn, + l2e_write_atomic(pl2e, l2e_from_mfn(l1t_mfn, __PAGE_HYPERVISOR)); UNMAP_XEN_PAGETABLE_NEW(l1t); l1t = NULL; @@ -5357,7 +5358,7 @@ int map_pages_to_xen( if ( l1t ) { UNMAP_XEN_PAGETABLE_NEW(l1t); - free_xen_pagetable_new(mfn); + free_xen_pagetable_new(l1t_mfn); } } From patchwork Thu Sep 26 09:45: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: 11162077 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 2C0B913BD for ; Thu, 26 Sep 2019 09:49:18 +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 08662222C0 for ; Thu, 26 Sep 2019 09:49:18 +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="FF0d+H7G" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08662222C0 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 1iDQNZ-00043J-47; Thu, 26 Sep 2019 09:48: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 1iDQNX-00040s-EB for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:03 +0000 X-Inumbo-ID: b81891da-e042-11e9-8628-bc764e2007e4 Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id b81891da-e042-11e9-8628-bc764e2007e4; Thu, 26 Sep 2019 09:47: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=1569491277; x=1601027277; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=6giu/6ArwPKfshJRzAHbKeKdI/4RdevVJDy7m7l1cF4=; b=FF0d+H7Gjwrcd6rO6yoXQUgIDUH530so10zF8Y1J1VVB3+B42pgVyKIN kToPnD9kNIJKF7Voe3JKSm2CMxvM5HLxTRPaLuYjnyXFgU3JZORiJ5Ybx CXPblCmQm/KAaGBTNrWR4jwkFyfRpkeYGqcZHLyIEgUrOWIxJ/mDzAKEI E=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="787535042" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-715bee71.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 26 Sep 2019 09:47:56 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-715bee71.us-east-1.amazon.com (Postfix) with ESMTPS id 39F51A2A65; Thu, 26 Sep 2019 09:47:54 +0000 (UTC) Received: from EX13P01UWA004.ant.amazon.com (10.43.160.127) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:27 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13P01UWA004.ant.amazon.com (10.43.160.127) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:26 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:25 +0000 From: To: Date: Thu, 26 Sep 2019 10:45: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] [RFC PATCH 18/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 267e4ceef5..2333e93151 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); } } @@ -5274,12 +5278,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); } } @@ -5293,12 +5299,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 ) { @@ -5362,9 +5370,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); @@ -5385,6 +5395,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); @@ -5408,12 +5419,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, @@ -5423,7 +5437,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); @@ -5439,6 +5453,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); @@ -5456,7 +5471,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++ ) @@ -5464,6 +5481,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, @@ -5473,7 +5491,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 Thu Sep 26 09:45: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: 11162063 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 0DD3C13BD for ; Thu, 26 Sep 2019 09:49: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 DC0FD222C0 for ; Thu, 26 Sep 2019 09:49: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="J7l9g6S+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC0FD222C0 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 1iDQNT-0003vC-Am; Thu, 26 Sep 2019 09:47: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 1iDQNS-0003uK-EI for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:47:58 +0000 X-Inumbo-ID: b7f1abba-e042-11e9-8628-bc764e2007e4 Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id b7f1abba-e042-11e9-8628-bc764e2007e4; Thu, 26 Sep 2019 09:47: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=1569491276; x=1601027276; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=lQwIe7eKispWsJ7EczXrD1I5UIckpRGulgQiuOZp20I=; b=J7l9g6S+FotjpNsKzCBdZfO3IntN56LzDX6VE/xFNtKkuA8qkGUCk/Tv Ortyw36acrKOlldCH4kF9Nh2RGdbKPvGIC4KHN8BZbevpNHpHh5F3bUPr PeTL+O8hjgivEwwymnwWjOlyY/zFNOVOszoUSaNkRaJxOm1RspZnMifC2 Q=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="787535039" 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; 26 Sep 2019 09:47:55 +0000 Received: from EX13MTAUWA001.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 33545240B39; Thu, 26 Sep 2019 09:47:55 +0000 (UTC) Received: from EX13D04UWA004.ant.amazon.com (10.43.160.234) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:29 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D04UWA004.ant.amazon.com (10.43.160.234) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:28 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:27 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:42 +0100 Message-ID: <6ace3d28ba0345b6de6ce53a14288dfacee31e2f.1569489002.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] [RFC PATCH 19/84] 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 , Wei Liu , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 --- xen/arch/x86/mm.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 2333e93151..d2b873a958 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5564,6 +5564,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 && @@ -5580,13 +5581,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) + @@ -5597,14 +5600,17 @@ 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)); + l3e_write_atomic(pl3e, l3e_from_mfn(mfn, __PAGE_HYPERVISOR)); + UNMAP_XEN_PAGETABLE_NEW(l2t); l2t = NULL; } if ( locking ) spin_unlock(&map_pgdir_lock); if ( l2t ) - free_xen_pagetable(l2t); + { + UNMAP_XEN_PAGETABLE_NEW(l2t); + free_xen_pagetable_new(mfn); + } } /* @@ -5639,15 +5645,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, @@ -5657,14 +5666,18 @@ 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)); + UNMAP_XEN_PAGETABLE_NEW(l1t); l1t = NULL; } 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 Thu Sep 26 09:45: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: 11162185 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 4196E13B1 for ; Thu, 26 Sep 2019 09:51: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 1DA6F222C0 for ; Thu, 26 Sep 2019 09:51: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="J8alHDso" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DA6F222C0 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 1iDQPx-0000X5-0S; Thu, 26 Sep 2019 09:50:33 +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 1iDQPu-0000P9-TY for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:30 +0000 X-Inumbo-ID: f9054c1a-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id f9054c1a-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:49: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=1569491386; x=1601027386; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=QwdLf2vuXnKxrJh4UAeimBQsZDNeQYlG52mojdSJMGU=; b=J8alHDsoOoeZTf7P5MURnzgOkfkobTvquT5FNHYETRcwXl050mrl2Zqb cdBhao61zRPcygSkeBs9qDp6hU83zk22Z776nKkcDBhedK+gX+upDcVjc 6ZxQsw1JRGH4w9yyeSC0Sq+n1YYZPSTRMfT/u7MOUUSkCQxucinciDndj s=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="704637300" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1d-38ae4ad2.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 26 Sep 2019 09:48:17 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-38ae4ad2.us-east-1.amazon.com (Postfix) with ESMTPS id 0336AA25D8; Thu, 26 Sep 2019 09:47:56 +0000 (UTC) Received: from EX13D27UWA001.ant.amazon.com (10.43.160.19) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:31 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D27UWA001.ant.amazon.com (10.43.160.19) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:30 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:29 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:43 +0100 Message-ID: <202306c7c9d00ec33c46ebad857063ee10df8495.1569489002.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] [RFC PATCH 20/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 d2b873a958..a9361b859a 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5534,8 +5534,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; @@ -5617,7 +5616,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) ) { @@ -5682,14 +5682,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) ) @@ -5700,6 +5702,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; /* @@ -5729,10 +5732,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. */ @@ -5740,7 +5745,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); @@ -5771,11 +5776,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. */ @@ -5783,12 +5791,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); } @@ -5798,6 +5807,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 Thu Sep 26 09:45: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: 11162073 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 1106E13BD for ; Thu, 26 Sep 2019 09:49: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 E19C0222C0 for ; Thu, 26 Sep 2019 09:49:15 +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="Lqkcp5sL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E19C0222C0 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 1iDQNV-0003yb-Lw; Thu, 26 Sep 2019 09:48: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 1iDQNU-0003xM-Ma for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:00 +0000 X-Inumbo-ID: b89c2ef1-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id b89c2ef1-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:47:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491278; x=1601027278; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=LWFx3gZXlXyggl/OgrfKOJDKrGBkC4PTLu0JOK+Lpsc=; b=Lqkcp5sLQ8+1uvtDlVsN9BPTxRyj2r/rntgTnK0K6UuSK8S3s1+9P+wQ l3/Bxnf8/HVi2WmLq/kHkgFyTlfi4Cg5BbEef8eDaC7AaGKYlPDRK3kB2 7RUwwKAjG/4PLyWdRhNrd67JkyWXH5PzIVOoKWiWvCMHItiE6ElF5IN3h s=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="417788142" 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-6001.iad6.amazon.com with ESMTP; 26 Sep 2019 09:47:58 +0000 Received: from EX13MTAUWA001.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 98786A2A41; Thu, 26 Sep 2019 09:47:57 +0000 (UTC) Received: from EX13D19UWA004.ant.amazon.com (10.43.160.102) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:33 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D19UWA004.ant.amazon.com (10.43.160.102) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:32 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:31 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:44 +0100 Message-ID: <818f17997f90b464bbe620ead9f35bab3844375c.1569489002.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] [RFC PATCH 21/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 a9361b859a..59dba05ba8 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 Thu Sep 26 09:45: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: 11162165 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 AF8AF13B1 for ; Thu, 26 Sep 2019 09:50: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 8A8BA2053B for ; Thu, 26 Sep 2019 09:50: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="BBpmuyU5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A8BA2053B 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 1iDQPY-0007jQ-IO; Thu, 26 Sep 2019 09:50:08 +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 1iDQPV-0007bg-Uu for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:06 +0000 X-Inumbo-ID: e155b872-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id e155b872-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:49: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=1569491348; x=1601027348; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=/Z9WKLMpqFRozBiJpqcif/gsXhYneDnuhvjAsJE3mek=; b=BBpmuyU5UGdyjJ84ldmSigYNQrCeCSCRH+HWfusYDR7QdIvdAM3PyF3q KJVV/k3OqlWSptXOCru3VQiAMgsUscaCwhGzBEWa2bWfQhcx4eMRSrg0D e5xafaJDNY3ipYOVEXgr8S6Q5LZCLTbZYgZ5iLOsyS+Q627NdA7t0ovGO E=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836988784" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1e-a70de69e.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 26 Sep 2019 09:48:12 +0000 Received: from EX13MTAUWA001.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 91941A0380; Thu, 26 Sep 2019 09:48:00 +0000 (UTC) Received: from EX13D18UWA002.ant.amazon.com (10.43.160.199) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:35 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D18UWA002.ant.amazon.com (10.43.160.199) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:34 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:33 +0000 From: To: Date: Thu, 26 Sep 2019 10:45: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] [RFC PATCH 22/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:45: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: 11162085 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 C40641800 for ; Thu, 26 Sep 2019 09:49:24 +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 A0108222C3 for ; Thu, 26 Sep 2019 09:49:24 +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="H9U2ldhL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A0108222C3 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 1iDQNg-0004Cr-6x; Thu, 26 Sep 2019 09:48:12 +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 1iDQNe-0004BR-NM for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:10 +0000 X-Inumbo-ID: beb48b16-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id beb48b16-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48: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=1569491288; x=1601027288; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=CIjRhdRTYTYikd5jkOOGCDn8bq3qlMiDUTtyFuW+4HU=; b=H9U2ldhLv/liDpyyZRyi57+yXbFtxtVJLP89Tf9ejIwkwUJJ5n3o8D8K Avx6oZb8+qvXtpcoX5Yt/U3kw0RHujHVoO+t95wTLTf11kHvu1wlhJ8ox l45ec7hqC1hlj9fvYYMpfXo1WUNPZNB2UofB0QQf1PYjvqWGufgYNkMc1 4=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="753354136" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1d-474bcd9f.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 26 Sep 2019 09:48:08 +0000 Received: from EX13MTAUWA001.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 9F94AA26E6; Thu, 26 Sep 2019 09:48:05 +0000 (UTC) Received: from EX13D03UWA004.ant.amazon.com (10.43.160.250) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:36 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D03UWA004.ant.amazon.com (10.43.160.250) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:36 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:35 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:46 +0100 Message-ID: <535848a7f55c3418ba44791d91e86e4b5016a5f7.1569489002.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] [RFC PATCH 23/84] 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 , Wei Liu , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 | 48 ++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index ac5e366e5b..a9c2b5ca54 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; + l2_ro_mpt = map_xen_pagetable_new(l2_ro_mpt_mfn); compat_idle_pg_table_l2 = l2_ro_mpt; 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 Thu Sep 26 09:45: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: 11162125 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 DACE41709 for ; Thu, 26 Sep 2019 09:50:15 +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 B6BA8222C0 for ; Thu, 26 Sep 2019 09:50:15 +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="hjGDIHYB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B6BA8222C0 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 1iDQOv-0006Iq-BR; Thu, 26 Sep 2019 09:49: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 1iDQOu-0006GJ-65 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:28 +0000 X-Inumbo-ID: eb644908-e042-11e9-97fb-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id eb644908-e042-11e9-97fb-bc764e2007e4; Thu, 26 Sep 2019 09:49: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=1569491367; x=1601027367; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=2UYyndybd/u2L8eu6I/OvdFYJWjbmvXRD7Ecm6dmF+Q=; b=hjGDIHYB8E3OtG7sWZj7V1ZhWTIZB7M1voLM/fnZ59AkrJl5ow1412Ao Go9ZSBjRVtdHFzES3By6C/Da9PMl2F/zkSr/WrYn/XiyrErXGcZ/LGxEF VqydEayO62uHa37NhfRC5RilLJsKxpTqk2heJQJZH9ZgEAUi75k/lWxmz s=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836988813" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1d-74cf8b49.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 26 Sep 2019 09:48:20 +0000 Received: from EX13MTAUWA001.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 4402DC1333; Thu, 26 Sep 2019 09:48:09 +0000 (UTC) Received: from EX13P01UWA003.ant.amazon.com (10.43.160.197) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:38 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13P01UWA003.ant.amazon.com (10.43.160.197) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:38 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:37 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:47 +0100 Message-ID: <24536847bce6e0d42440990abaa617e80fe08af8.1569489002.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] [RFC PATCH 24/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 a9c2b5ca54..945ae123a6 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 Thu Sep 26 09:45:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11162087 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 C302513BD for ; Thu, 26 Sep 2019 09:49: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 9EF93222C0 for ; Thu, 26 Sep 2019 09:49: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="Ni+VbyLh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9EF93222C0 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 1iDQNj-0004Fy-KJ; Thu, 26 Sep 2019 09:48: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 1iDQNi-0004FJ-On for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:14 +0000 X-Inumbo-ID: c25651d2-e042-11e9-b588-bc764e2007e4 Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id c25651d2-e042-11e9-b588-bc764e2007e4; Thu, 26 Sep 2019 09:48: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=1569491294; x=1601027294; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=vtHVGWpmxN+XKXUpX4r1cfArkAPoliqMZ/3sDWi6CkU=; b=Ni+VbyLhhJkEkuCRJv+9OPqbNqPSiUdgpxnmacxwQVIy8yVnilFDNfzQ 4gnR4uMJmLJST3dZyzb+VnQmAByayTsQFzGqx0e0PwMysr9mXavVxl7+H pBcTS5bOh7M9nII64xNm6iNZup0xgwK4is3uo5y5TiWD77EcSX7/4CDyD c=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="787535086" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-16acd5e0.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 26 Sep 2019 09:48:13 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-16acd5e0.us-east-1.amazon.com (Postfix) with ESMTPS id BF1FDA2D8F; Thu, 26 Sep 2019 09:48:11 +0000 (UTC) Received: from EX13D31UWA001.ant.amazon.com (10.43.160.57) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:40 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D31UWA001.ant.amazon.com (10.43.160.57) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:40 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:38 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:48 +0100 Message-ID: <3217dbfb7b277abc7de77067f38a2948cd1532cc.1569489002.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] [RFC PATCH 25/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 945ae123a6..9b39b2ffcb 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 Thu Sep 26 09:45:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11162095 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 3A91313BD for ; Thu, 26 Sep 2019 09:49: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 1692F222C0 for ; Thu, 26 Sep 2019 09:49: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="JauuXSAR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1692F222C0 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 1iDQNl-0004HW-0t; Thu, 26 Sep 2019 09:48:17 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iDQNj-0004Fe-8c for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:15 +0000 X-Inumbo-ID: c28b26aa-e042-11e9-b588-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id c28b26aa-e042-11e9-b588-bc764e2007e4; Thu, 26 Sep 2019 09:48: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=1569491294; x=1601027294; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=4lutyPBW4XA50f+CKZlHwiI8jX/ew/mq524Sw3Qgbi4=; b=JauuXSAR5+FSiwqYlIlKu2o8Npib/XRmIFbbP/BZhmNJtDgZmgL0bCkW wEkRclOiyLfYfaLsnOe48Sj62y9S4kRSeFslzYMGWaX+ybZB04xRfpWA2 JglUyuUmoUFduOVERf/yTsbHoUmnsxXSDyhCiG0x1fliDUvB4NsHRXOk0 w=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="423750478" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-67b371d8.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 26 Sep 2019 09:48:14 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1a-67b371d8.us-east-1.amazon.com (Postfix) with ESMTPS id 9E1AFA1DD9; Thu, 26 Sep 2019 09:48:12 +0000 (UTC) Received: from EX13D19UWA001.ant.amazon.com (10.43.160.169) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:42 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D19UWA001.ant.amazon.com (10.43.160.169) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:42 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:40 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:49 +0100 Message-ID: <99a473287b586b084d092170f885a6bda8ebaa6b.1569489002.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] [RFC PATCH 26/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 9b39b2ffcb..d01b8f7c17 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 Thu Sep 26 09:45:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11162141 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 B694213B1 for ; Thu, 26 Sep 2019 09:50: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 9219B222C0 for ; Thu, 26 Sep 2019 09:50: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="BuS/LxPQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9219B222C0 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 1iDQP1-0006US-4f; Thu, 26 Sep 2019 09:49: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 1iDQOz-0006QQ-4m for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:33 +0000 X-Inumbo-ID: ee4d4188-e042-11e9-97fb-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id ee4d4188-e042-11e9-97fb-bc764e2007e4; Thu, 26 Sep 2019 09:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491369; x=1601027369; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=VLg8J96hE0TekqiR90JQhSSRAIe4sbPYqHBK92uWVGE=; b=BuS/LxPQM/Z+rX/a0r3/vAfioBjG07Y/QvlngMOhnXx6K5SSnd5sZkAy 4gXXtsrLLJT6N6EIuw21GVfBa59H7FgLatz0GhE3dvhlpqz/2zrjVV4Tb J/CMy9CfOYIUQLmb2mDZGFiPqVoL7DZFszrJQ+5NQlQwkpMfkjmp/vb7h I=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836988826" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1d-98acfc19.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 26 Sep 2019 09:48:24 +0000 Received: from EX13MTAUWA001.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 9A94AA31AD; Thu, 26 Sep 2019 09:48:13 +0000 (UTC) Received: from EX13D10UWA001.ant.amazon.com (10.43.160.216) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:44 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D10UWA001.ant.amazon.com (10.43.160.216) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:44 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:42 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:50 +0100 Message-ID: <5c25bb98b74ccd09a48b421c636dc1d383c20150.1569489002.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] [RFC PATCH 27/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 d01b8f7c17..e05a3a445a 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 Thu Sep 26 09:45:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11162091 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 EF02F13B1 for ; Thu, 26 Sep 2019 09:49: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 CB299222C0 for ; Thu, 26 Sep 2019 09:49: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="dfGZsKlN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB299222C0 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 1iDQNm-0004JT-ER; Thu, 26 Sep 2019 09:48:18 +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 1iDQNl-0004IE-Ku for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:17 +0000 X-Inumbo-ID: c3e9b570-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id c3e9b570-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48: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=1569491297; x=1601027297; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=KJ14P5Bqi4tyVqx7vQ0u6JsMrbSbQzectx0LeeuTkRc=; b=dfGZsKlNCN8VC9qv4pVFguSg3cv+ipnPwWtpRkF2pgM2AZTRfa95uZss k3S2RBReUS5WRdFFNfWCt2RGmJTjxt3tXrZrvmWXsCi2imdCMUkH96NIg bUI5hvNY/PbaiLchMjzX5vcfd/H9xV++nZrXNgAcTxrCtwYBG/cJcTRHS E=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="417788184" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-67b371d8.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 26 Sep 2019 09:48:16 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1a-67b371d8.us-east-1.amazon.com (Postfix) with ESMTPS id E4DC2A194F; Thu, 26 Sep 2019 09:48:14 +0000 (UTC) Received: from EX13D31UWA002.ant.amazon.com (10.43.160.82) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:46 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D31UWA002.ant.amazon.com (10.43.160.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:45 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:44 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:51 +0100 Message-ID: <8d8a44d0526bcc08d290c14bfd127be6860ce2e4.1569489002.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] [RFC PATCH 28/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 e05a3a445a..9163f08de9 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 Thu Sep 26 09:45:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11162059 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 8710A13BD for ; Thu, 26 Sep 2019 09:49:08 +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 632BA222C3 for ; Thu, 26 Sep 2019 09:49: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="PgwIX4cZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 632BA222C3 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 1iDQNo-0004MT-QN; Thu, 26 Sep 2019 09:48: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 1iDQNn-0004L8-PK for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:19 +0000 X-Inumbo-ID: c4226992-e042-11e9-b588-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id c4226992-e042-11e9-b588-bc764e2007e4; Thu, 26 Sep 2019 09:48: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=1569491297; x=1601027297; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=WWxC8CaECvf3fPLUIHiBL4xp/pGS6BRlh6hTeTHWnrE=; b=PgwIX4cZh0M+Lr8gZrgR5yyd2xERooyApf9qDmzHMWstIM6go208ibSx RLOfoX2DZ2lHiwpjvCeolXNjshfNPaKqCwE4EiTOKBJsdVBrtiPrxmoE+ FNqXJT92uLNLi7KA/J6UPqrIDZVUR4nqQynpBQJeppfa1N2//E/FGRnmE g=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="423750482" 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-6002.iad6.amazon.com with ESMTP; 26 Sep 2019 09:48:17 +0000 Received: from EX13MTAUWA001.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 6FCD8A2688; Thu, 26 Sep 2019 09:48:16 +0000 (UTC) Received: from EX13d09UWA004.ant.amazon.com (10.43.160.158) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:47 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13d09UWA004.ant.amazon.com (10.43.160.158) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:47 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:46 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:52 +0100 Message-ID: <7df76e609e1f67834bc2ffc1a63f67681b11050d.1569489002.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] [RFC PATCH 29/84] 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: Wei Liu , 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 Thu Sep 26 09:45:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11162121 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 E2E3813B1 for ; Thu, 26 Sep 2019 09:50: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 BF5F9222C0 for ; Thu, 26 Sep 2019 09:50: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="X4XxJfbY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF5F9222C0 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 1iDQOW-0005UW-C7; Thu, 26 Sep 2019 09:49: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 1iDQOV-0005SD-49 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:03 +0000 X-Inumbo-ID: dd4f1e92-e042-11e9-8628-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id dd4f1e92-e042-11e9-8628-bc764e2007e4; Thu, 26 Sep 2019 09:48: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=1569491340; x=1601027340; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=3nNvQG1v8uYo6cTIKpiw9dRaihrielmfxq5scEhNceU=; b=X4XxJfbYjWbj0UuvetiLCUNOyydqQqm4ZGx6G8v7ufNiCXt+5gOdJeUa hv2yvr9kS09TS8nq5l4gYFv2ZM+wQ5Ggd96SZ0uErHAf7T/EOPpH9nZCt rx5X2Hq0Akm2EarQHYrK6zbi2c1DdTl9U8zbQhTkA/CV2sSHhubL/dXCf 8=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836988835" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1a-715bee71.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 26 Sep 2019 09:48:27 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-715bee71.us-east-1.amazon.com (Postfix) with ESMTPS id E26B6A18A8; Thu, 26 Sep 2019 09:48:16 +0000 (UTC) Received: from EX13D19UWA003.ant.amazon.com (10.43.160.170) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:49 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D19UWA003.ant.amazon.com (10.43.160.170) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:48 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:47 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:53 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [RFC PATCH 30/84] 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: Wei Liu , 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 Thu Sep 26 09:45: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: 11162061 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 E8E3413B1 for ; Thu, 26 Sep 2019 09:49: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 C3745222C0 for ; Thu, 26 Sep 2019 09:49:09 +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="jf/soolw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C3745222C0 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 1iDQNq-0004Ow-GU; Thu, 26 Sep 2019 09:48:22 +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 1iDQNo-0004MF-NK for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:20 +0000 X-Inumbo-ID: c3e9b571-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id c3e9b571-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48: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=1569491298; x=1601027298; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=0SYqLn0J8g22MwTPI4ly2IZPEB0g/6dxXq86B5UES/I=; b=jf/soolwuAgNTsw5aikDpAlJY9ctmpkZ2yBPtINWXR0PEZ4W/BPu7vLE Ldkh5nbwezsOzSKl0IbyN9hJrZGlzMflvaCMGNG9nzcLLhmKuPif5xp78 SbI/JLMlnOlfPl6BGolyKN9t+Dswu0lBwqyjFSuTVVE2l/g+8omXREVai 4=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="417788190" 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-6001.iad6.amazon.com with ESMTP; 26 Sep 2019 09:48:18 +0000 Received: from EX13MTAUWA001.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 D09F9A04EB; Thu, 26 Sep 2019 09:48:17 +0000 (UTC) Received: from EX13D03UWA002.ant.amazon.com (10.43.160.144) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:50 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D03UWA002.ant.amazon.com (10.43.160.144) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:49 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:49 +0000 From: To: Date: Thu, 26 Sep 2019 10:45: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] [RFC PATCH 31/84] 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: Wei Liu , 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 Thu Sep 26 09:45: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: 11162093 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 9D67A13B1 for ; Thu, 26 Sep 2019 09:49: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 7947A222C0 for ; Thu, 26 Sep 2019 09:49: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="jv25eFn8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7947A222C0 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 1iDQNu-0004UA-2C; Thu, 26 Sep 2019 09:48:26 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iDQNs-0004SP-Oh for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:24 +0000 X-Inumbo-ID: c647f764-e042-11e9-b588-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id c647f764-e042-11e9-b588-bc764e2007e4; Thu, 26 Sep 2019 09:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491300; x=1601027300; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=EkbSE2k+c0yDqIG045tLdYR7PyZYrRga2vnlZteckMc=; b=jv25eFn8Fxb2XCpYVPbhesTmlaHlr6x7tK/s48blF4/h9wITp4YgZGr6 tSBta6O2jS0U7jOn9aoR56lBXT5A++1dL+rEOJPePyF7lquW4BtyX4CkK iPiLN+CuXwa9QfezvzDmPJoK8cwTEZ5VaJLcU83zCjHUzDOQCD4i8Bfkl 8=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="423750490" 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-6002.iad6.amazon.com with ESMTP; 26 Sep 2019 09:48:20 +0000 Received: from EX13MTAUWA001.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 A310DA1C4E; Thu, 26 Sep 2019 09:48:18 +0000 (UTC) Received: from EX13D12UWA001.ant.amazon.com (10.43.160.163) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:51 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D12UWA001.ant.amazon.com (10.43.160.163) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:51 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:50 +0000 From: To: Date: Thu, 26 Sep 2019 10:45: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] [RFC PATCH 32/84] 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: Wei Liu , 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 Thu Sep 26 09:45: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: 11162079 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 C707F13BD for ; Thu, 26 Sep 2019 09:49:22 +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 A1C48222C0 for ; Thu, 26 Sep 2019 09:49:22 +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="IlM/KF4q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A1C48222C0 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 1iDQO0-0004eB-EV; Thu, 26 Sep 2019 09:48:32 +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 1iDQNy-0004bU-O5 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:30 +0000 X-Inumbo-ID: c6a914e0-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id c6a914e0-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491301; x=1601027301; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=HOlQh5k1oNPRVyL9EqE56c5arborDHenMa3MWF/9pfs=; b=IlM/KF4qOHtiHobdIhoy4X9IQKrT7Z/OOlTfJ6iGL3z10hBx4FYvTdTs 6dvfDM/kb539B7sKCllwfWiawVSFIPMfU+QULXjtvj9A4X9gVWYxyhJFB Zhv0+joeWcrUveDuNYEo6EEG1TZbRZbnoF3uOFQ+hkLb+BE1fjn55D5BK M=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="787535108" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-38ae4ad2.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 26 Sep 2019 09:48:21 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-38ae4ad2.us-east-1.amazon.com (Postfix) with ESMTPS id 53C5DA299F; Thu, 26 Sep 2019 09:48:19 +0000 (UTC) Received: from EX13D18UWA004.ant.amazon.com (10.43.160.45) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:53 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D18UWA004.ant.amazon.com (10.43.160.45) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:52 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:51 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:56 +0100 Message-ID: <8f0acf3643328ce680cb9aac0eccb7d724fd1b40.1569489002.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] [RFC PATCH 33/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:45: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: 11162065 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 37D881709 for ; Thu, 26 Sep 2019 09:49: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 13B07222C0 for ; Thu, 26 Sep 2019 09:49: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="l6S6ciKA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 13B07222C0 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 1iDQNv-0004WG-Er; Thu, 26 Sep 2019 09:48:27 +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 1iDQNt-0004TY-NQ for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:25 +0000 X-Inumbo-ID: c6a914e1-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id c6a914e1-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491301; x=1601027301; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=L46FocjdSdsTHOhvGjL/s9F2JXilCIgVAbX2/WEoSrg=; b=l6S6ciKAvs5Ty7NFdV99AfDHOCQpGAfqtz6N+62dflFO6ArxlFtof5kj RTHAZGDq68jvmmbazitUtaDCnFpAXmF9lDdvpxOWGRIrlD4apeU88CPCa 5n5WoGf97yDxYlTItMoavg0A1o+vf9rR6CjJYpjvshPe04MNRNOAvgi/o s=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="787535109" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-303d0b0e.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 26 Sep 2019 09:48:21 +0000 Received: from EX13MTAUWA001.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 A5441A26C6; Thu, 26 Sep 2019 09:48:19 +0000 (UTC) Received: from EX13D27UWA003.ant.amazon.com (10.43.160.56) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:55 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D27UWA003.ant.amazon.com (10.43.160.56) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:55 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:53 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:57 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [RFC PATCH 34/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 911416c1e1..b086063486 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -1380,3 +1380,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 Thu Sep 26 09:45: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: 11162189 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 DCFBB1709 for ; Thu, 26 Sep 2019 09:51: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 B91642053B for ; Thu, 26 Sep 2019 09:51: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="fLTRkgCN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B91642053B 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 1iDQQ3-0000kR-56; Thu, 26 Sep 2019 09:50: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 1iDQPz-0000dJ-UW for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:35 +0000 X-Inumbo-ID: 02dd51f6-e043-11e9-964c-12813bfff9fa Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id 02dd51f6-e043-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:50:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491403; x=1601027403; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=D3xhAXkkAyvkgXZaKgSRCepjVtWQLUGgeMXG4FaK6oI=; b=fLTRkgCNwvdUjR/kP+LeZOF2PftRFieGzX1lhwqYacDAJnvDH5DMSd47 m8fxeZ2MgXVkqnb7TvxU3mQVOYEc3EFKKAL4JpePRgtxUCC2IjonaDUiN PU3t5K7DgiJ4fIXuSCDyfqMA6mrYtQ/7k07lkUuB9y+kDG+dE8VBohsb+ 0=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="704637337" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1a-715bee71.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 26 Sep 2019 09:48:40 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-715bee71.us-east-1.amazon.com (Postfix) with ESMTPS id 3ED53A016A; Thu, 26 Sep 2019 09:48:20 +0000 (UTC) Received: from EX13d09UWA001.ant.amazon.com (10.43.160.247) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:57 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13d09UWA001.ant.amazon.com (10.43.160.247) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:56 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:55 +0000 From: To: Date: Thu, 26 Sep 2019 10:45: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] [RFC PATCH 35/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 b086063486..8bee0c41e3 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -669,6 +669,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 @@ -676,11 +677,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); @@ -709,7 +716,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); } } @@ -718,7 +728,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)); @@ -732,7 +745,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)); } @@ -748,7 +764,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)); } @@ -769,7 +788,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 Thu Sep 26 09:45: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: 11162099 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 EE2C613BD for ; Thu, 26 Sep 2019 09:49: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 C9544222C0 for ; Thu, 26 Sep 2019 09:49: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="G6wiJEl2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9544222C0 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 1iDQO5-0004oS-VS; Thu, 26 Sep 2019 09:48:37 +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 1iDQO3-0004jX-O5 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:35 +0000 X-Inumbo-ID: c7c32be1-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id c7c32be1-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491303; x=1601027303; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=9WigQ+PC2MhUNlwYiu/8I0IxPqzWO1pANTCorurPBOE=; b=G6wiJEl2UzbjOKCWl+hdBYo3kbtrVGlyPYGEeNo6BdINAEfIUwStIQ6q H38ChkMGztp0nCQqRTZJ4rEiazb14aiqcPZU2nI6d6WKe112RFflKGK0G gltnvQXm/enklp1VDSLn7b6P8zNXmn7kzB1u7Of0lmF79T29RQdsFpsSg I=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="417788203" 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-6001.iad6.amazon.com with ESMTP; 26 Sep 2019 09:48:23 +0000 Received: from EX13MTAUWA001.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 6EEAAA2229; Thu, 26 Sep 2019 09:48:21 +0000 (UTC) Received: from EX13D18UWA002.ant.amazon.com (10.43.160.199) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:59 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D18UWA002.ant.amazon.com (10.43.160.199) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:47:58 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:57 +0000 From: To: Date: Thu, 26 Sep 2019 10:45:59 +0100 Message-ID: <0f1379a676f2cd6676b950bdae66b9a81df34fe0.1569489002.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] [RFC PATCH 36/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 8bee0c41e3..f970b1bd69 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 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; @@ -689,8 +689,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); @@ -724,20 +725,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); @@ -790,6 +797,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) rc = 0; out: + UNMAP_XEN_PAGETABLE_NEW(pl3e); return rc; } From patchwork Thu Sep 26 09:46: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: 11162075 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 E901C13B1 for ; Thu, 26 Sep 2019 09:49: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 C56D2222C0 for ; Thu, 26 Sep 2019 09:49: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="LIQ7c9qv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C56D2222C0 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 1iDQNz-0004bw-0M; Thu, 26 Sep 2019 09:48:31 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iDQNx-0004Zp-PX for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:29 +0000 X-Inumbo-ID: c7c17eda-e042-11e9-b588-bc764e2007e4 Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id c7c17eda-e042-11e9-b588-bc764e2007e4; Thu, 26 Sep 2019 09:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491303; x=1601027303; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=WpXJh4cxTqcmeqRGheLyKYvfYSmoTSzMIwmkSSiwZqI=; b=LIQ7c9qvbvciFsYufoBDgS64GQnYHBqjqp9yAj5rOwrf9NKlErtgk+9o zCg7TtezTA5jzbJEmutjLVVvlvDHinD3Of6blAQhwrcAupwUBb/mtGwB5 JkZ7DW9NLVejLXrQ2pdqBjuzZ5MxGabtCQjrKKRdxtNCsKnxOJbi6iDit I=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="753354161" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1e-17c49630.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 26 Sep 2019 09:48:23 +0000 Received: from EX13MTAUWA001.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 0FC04A04EB; Thu, 26 Sep 2019 09:48:22 +0000 (UTC) Received: from EX13D29UWA003.ant.amazon.com (10.43.160.253) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:01 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D29UWA003.ant.amazon.com (10.43.160.253) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:00 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:47:59 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:00 +0100 Message-ID: <3a5608ac405a3a3c6b0241199ddf5434d422a14b.1569489002.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] [RFC PATCH 37/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 f970b1bd69..d3651fb99a 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -667,7 +667,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; @@ -703,7 +703,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 ) @@ -725,6 +726,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) ) @@ -750,19 +752,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); @@ -797,6 +802,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 Thu Sep 26 09:46: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: 11162083 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 706E11709 for ; Thu, 26 Sep 2019 09:49:24 +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 4D014222C0 for ; Thu, 26 Sep 2019 09:49:24 +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="R6nypKWm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D014222C0 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 1iDQO4-0004k9-1V; Thu, 26 Sep 2019 09:48: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 1iDQO2-0004i7-P3 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:34 +0000 X-Inumbo-ID: cb99bbc6-e042-11e9-b588-bc764e2007e4 Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id cb99bbc6-e042-11e9-b588-bc764e2007e4; Thu, 26 Sep 2019 09:48:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491309; x=1601027309; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=XhYOIXufiZD9zZ7TLNj+y8Go4KtY9z8YI6yVoMYhfI8=; b=R6nypKWmFX3Uj4P+IpMNlDjN3Ap2HmwOUw1cKOYCiHbVAvZq62Vmh8nL 6PiGhgOnT1dcaOMhV8dzH8p8Jw2cCdSBAoq8Fe89cdMjdvZPvKmBPUtf7 3n3zh13WjFYhmg8KE5hjl3ruJ5N4h52G+7hx7fQcsQt6KwUw1UONVrOvR 8=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="787535127" 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-4101.iad4.amazon.com with ESMTP; 26 Sep 2019 09:48:29 +0000 Received: from EX13MTAUWA001.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 CF372A25D2; Thu, 26 Sep 2019 09:48:27 +0000 (UTC) Received: from EX13D27UWA002.ant.amazon.com (10.43.160.30) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:03 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D27UWA002.ant.amazon.com (10.43.160.30) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:02 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:01 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:01 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [RFC PATCH 38/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 d3651fb99a..daf734d095 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -668,7 +668,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; /* @@ -715,7 +715,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) ) { @@ -726,6 +727,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); @@ -774,19 +776,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); @@ -802,6 +807,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 Thu Sep 26 09:46: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: 11162089 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 B879E13B1 for ; Thu, 26 Sep 2019 09:49: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 94259222C0 for ; Thu, 26 Sep 2019 09:49: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="REN/rmjE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94259222C0 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 1iDQOB-0004x0-Dr; Thu, 26 Sep 2019 09:48:43 +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 1iDQO9-0004ur-Vq for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:42 +0000 X-Inumbo-ID: d2908950-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id d2908950-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491321; x=1601027321; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=9mWYNHZmtuPB9zVPJuoVpk2F+cc/wi/n5qjrC2/v5/g=; b=REN/rmjEqThlHQHVVW1FaEPSq9z7dGasdcoP9EkXRnRCiDv43Ng3F05o j6Fta56fmkE1s35vDkHG0egM5wdo0geIyDi9OYAh6TatcsLdSHGeOM4DN hMczg5LrK/XDunmsg92Uvthmx1+iNaymSBZ9APlsRnZ1DoQLLptPDbIr4 g=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="787535151" 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; 26 Sep 2019 09:48:41 +0000 Received: from EX13MTAUWA001.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 7F008242082; Thu, 26 Sep 2019 09:48:39 +0000 (UTC) Received: from EX13d09UWA004.ant.amazon.com (10.43.160.158) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:05 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13d09UWA004.ant.amazon.com (10.43.160.158) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:04 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:03 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:02 +0100 Message-ID: <4d89fb167f229e84026702595558a0aa24fc00c1.1569489002.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] [RFC PATCH 39/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 daf734d095..b67432933d 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -893,23 +893,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 ) { @@ -917,13 +921,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 Thu Sep 26 09:46: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: 11162097 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 28E6B13BD for ; Thu, 26 Sep 2019 09:49: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 04CD2222C0 for ; Thu, 26 Sep 2019 09:49: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="M3mIjdod" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04CD2222C0 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 1iDQOJ-00058w-CA; Thu, 26 Sep 2019 09:48: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 1iDQOI-00058A-Oj for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:50 +0000 X-Inumbo-ID: d4a05875-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id d4a05875-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48: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=1569491326; x=1601027326; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=oSh+TFhg7s/HzxQHWUccbH8nzVnoxH50O9hYc8duEPM=; b=M3mIjdodhMKLJ1uVHp4S7cEwrpZ0ayy6YHklIk+WrBWupxVpPZlFXxho SPp0Ayeg7/olu+sV+SNhpAgWJmCIrhoMhlBSL71tWLZ0BoaRUYSKSkeAi Kl1rdE6eU4WLe8rvU/NM55yDO+eurRfrZQQ3dZGSvJbgRpImKOaKCLCFY M=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="753354226" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1d-74cf8b49.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 26 Sep 2019 09:48:46 +0000 Received: from EX13MTAUWA001.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 5033BC1336; Thu, 26 Sep 2019 09:48:44 +0000 (UTC) Received: from EX13D19UWA003.ant.amazon.com (10.43.160.170) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:06 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D19UWA003.ant.amazon.com (10.43.160.170) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:06 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:05 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:03 +0100 Message-ID: <895e7b00d76f84e78e2fb86538b12c0cb6c70b52.1569489002.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] [RFC PATCH 40/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 4b0ad5e15d..a11b05ea5a 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 59dba05ba8..302423a11f 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 b67432933d..f09563ab34 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -813,7 +813,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; @@ -821,19 +821,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)]; @@ -850,7 +858,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)]; } @@ -875,19 +883,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 ) @@ -932,7 +945,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 ) @@ -1136,7 +1150,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 3660238ca8..f571191cdb 100644 --- a/xen/include/asm-x86/processor.h +++ b/xen/include/asm-x86/processor.h @@ -465,7 +465,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 Thu Sep 26 09:46: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: 11162161 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 E6D8D13B1 for ; Thu, 26 Sep 2019 09:50:53 +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 C2166222C0 for ; Thu, 26 Sep 2019 09:50:53 +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="WP6mRyjY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C2166222C0 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 1iDQPV-0007ZL-2g; Thu, 26 Sep 2019 09:50: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 1iDQPT-0007TK-IH for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:03 +0000 X-Inumbo-ID: 01f906c2-e043-11e9-b588-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 01f906c2-e043-11e9-b588-bc764e2007e4; Thu, 26 Sep 2019 09:50: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=1569491402; x=1601027402; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=3SN61TJ04n0xBCYnr1+TtV3siYlmPBFZgsnjGBXinLs=; b=WP6mRyjY2GiytIQERe7mP/MS9yL3oLc1rcTQsx0KYM+MT37UhRVWSP67 VVGHLqzDXk4SKsq3MdsPFBePrTkAEvNHVhxI+dBP9010zuHmmMhS2zBtY dI6zKqRFa+Bqkk0T0s4Pfj/Z930gDAtu2BDcLae5HjT/3eVgmGlOjbAeF g=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836988949" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1d-2c665b5d.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 26 Sep 2019 09:48:59 +0000 Received: from EX13MTAUWA001.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 838ADA25D2; Thu, 26 Sep 2019 09:48:46 +0000 (UTC) Received: from EX13D06UWA003.ant.amazon.com (10.43.160.13) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:08 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D06UWA003.ant.amazon.com (10.43.160.13) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:08 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:07 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:04 +0100 Message-ID: <10ca381404695513eb89c2b5b155005439333bcf.1569489002.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] [RFC PATCH 41/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:46: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: 11162137 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 EF1D31709 for ; Thu, 26 Sep 2019 09:50: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 CACD8222C0 for ; Thu, 26 Sep 2019 09:50: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="bAcBM3f7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CACD8222C0 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 1iDQOP-0005J8-KL; Thu, 26 Sep 2019 09:48:57 +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 1iDQON-0005Fd-P8 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:55 +0000 X-Inumbo-ID: d7a31700-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id d7a31700-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48: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=1569491330; x=1601027330; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=kEqJEZp9xHiKHGinEbupzGCKej+WQIrDevTGdejpDDc=; b=bAcBM3f7HJ3H9Zos8Lcm41LZSKMj0UH/r0yhvcLYkpX1EDmOl6Y3gpBw RIhXDKAUeCExr92ny0KyJOiRRdoNr5QuMRGhGSlomYauncqFkcfGqhR0o DzQWiLRsmLkzPPta4IqC52NbRFFii36j9HzUnQjtiEcgMrVl28au2rGCQ w=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="423750579" 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; 26 Sep 2019 09:48:49 +0000 Received: from EX13MTAUWA001.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 EBB38A2102; Thu, 26 Sep 2019 09:48:47 +0000 (UTC) Received: from EX13d09UWA004.ant.amazon.com (10.43.160.158) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:10 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13d09UWA004.ant.amazon.com (10.43.160.158) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:10 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:08 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:05 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [RFC PATCH 42/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 9163f08de9..36dfac11a3 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 Thu Sep 26 09:46: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: 11162113 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 76F3913B1 for ; Thu, 26 Sep 2019 09:50: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 529D7222C0 for ; Thu, 26 Sep 2019 09:50: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="VjadGMPh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 529D7222C0 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 1iDQOM-0005E1-RF; Thu, 26 Sep 2019 09:48:54 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iDQOL-0005BO-2w for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:53 +0000 X-Inumbo-ID: d9309ee4-e042-11e9-8628-bc764e2007e4 Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id d9309ee4-e042-11e9-8628-bc764e2007e4; Thu, 26 Sep 2019 09:48: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=1569491332; x=1601027332; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=RcEhJ5JylrFM/vWvy+r87bDbpUfrF7kIJMA2aE7t3nw=; b=VjadGMPhxOx9t5WD/2pZnOB/991tYib/AXea9fgsFVtj1NUkbzoeUtUs ZGgePn7VQF8fiClbttpHQM5wkI4GDTROqywz/5w2YaQU743yU/LVS1LCy Wjcz03YOqHqnbFr/33uTPIyvsRqDP0Qm/d4DcH0/2+QOezQsmBe6ddPOW o=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="787535189" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-97fdccfd.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 26 Sep 2019 09:48:52 +0000 Received: from EX13MTAUWA001.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 8D0D2A1DAE; Thu, 26 Sep 2019 09:48:50 +0000 (UTC) Received: from EX13D31UWA002.ant.amazon.com (10.43.160.82) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:12 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D31UWA002.ant.amazon.com (10.43.160.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:11 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:10 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:06 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [RFC PATCH 43/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 36dfac11a3..3b2b136b49 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 Thu Sep 26 09:46: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: 11162167 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 A5DB513BD for ; Thu, 26 Sep 2019 09:50:59 +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 818772053B for ; Thu, 26 Sep 2019 09:50: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="uc5ZuajN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 818772053B 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 1iDQPa-0007oq-GV; Thu, 26 Sep 2019 09:50: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 1iDQPY-0007jK-Ie for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:08 +0000 X-Inumbo-ID: 051809a2-e043-11e9-b588-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 051809a2-e043-11e9-b588-bc764e2007e4; Thu, 26 Sep 2019 09:50:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491407; x=1601027407; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=/N+3BiC33vzQF6ohI6LMcU0gxzw4E3xPn2zu9preNjo=; b=uc5ZuajNOESt5XN8VmeokTnEEXgfzsoLoyUellFlGn/R+z69hiuXLQWF 6S5iql8DSvukoQLdTDXy1PlZ8CUB1kW7Cly4fJvKIudnO0pZAGYb6nlpz AxSqu0bhCkNtpKg+18Q4BVoaGPdeW7Fr0GbnwZqDkBd3iPlT2DSSKe0FB E=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836988975" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1a-715bee71.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 26 Sep 2019 09:49:04 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-715bee71.us-east-1.amazon.com (Postfix) with ESMTPS id DB16AA036A; Thu, 26 Sep 2019 09:48:50 +0000 (UTC) Received: from EX13D10UWA002.ant.amazon.com (10.43.160.228) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:14 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D10UWA002.ant.amazon.com (10.43.160.228) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:13 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:12 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:07 +0100 Message-ID: <915a683ca67a6379017e2cbbfc4157080111aa47.1569489002.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] [RFC PATCH 44/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 3b2b136b49..f4779f5c0a 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 Thu Sep 26 09:46: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: 11162131 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 647A313BD for ; Thu, 26 Sep 2019 09:50:19 +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 40753222C0 for ; Thu, 26 Sep 2019 09:50:19 +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="EQ9MNjRm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 40753222C0 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 1iDQOZ-0005bQ-VQ; Thu, 26 Sep 2019 09:49:07 +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 1iDQOX-0005XC-RC for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:05 +0000 X-Inumbo-ID: d9482f15-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id d9482f15-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48: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=1569491333; x=1601027333; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=40Gpd8bmwREwV1srXIw1S2hAqM0HjChiGnaArUmq3b8=; b=EQ9MNjRmx7qoAFGwFvXHQMSWjuVaadFrtBP+lD059Yz+5toZ20gKSHWG GPmyD3VtFbIjRYQwNi3S0AtAJQG8sfBEEBDMnNzoe46sYxsxK5HHQ6+Jo 5CiBEDIrEah8gt8Zb+Hek1lOGXRC/f53Y1pm+GEj/7zW6zBTuvCTiuC1y 8=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="423750595" 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; 26 Sep 2019 09:48:53 +0000 Received: from EX13MTAUWA001.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 19B83A29F6; Thu, 26 Sep 2019 09:48:51 +0000 (UTC) Received: from EX13D23UWA003.ant.amazon.com (10.43.160.194) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:16 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D23UWA003.ant.amazon.com (10.43.160.194) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:15 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:14 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:08 +0100 Message-ID: <9d7c7e7eae4f88fb732780da7486a0bee32097a2.1569489002.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] [RFC PATCH 45/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 f4779f5c0a..642fead4f6 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 Thu Sep 26 09:46: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: 11162123 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 A786413BD for ; Thu, 26 Sep 2019 09:50:15 +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 83DC1222C0 for ; Thu, 26 Sep 2019 09:50:15 +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="Z4wFJftE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83DC1222C0 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 1iDQOU-0005RK-Ls; Thu, 26 Sep 2019 09:49:02 +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 1iDQOS-0005OE-P8 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:00 +0000 X-Inumbo-ID: d9482f14-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id d9482f14-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48: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=1569491332; x=1601027332; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=+RHBcW6KCppwDFXfLm4Jpwg6xCNrwVVorBBy++8X8SQ=; b=Z4wFJftEKvrE47qackHDZv8LvqM3lcYuc8J/O7qgfbptVN7Q9yl8S2IG E5O7CUroyvsjEc8l+xwOrU15Zp/TEzY0uziQv19zVkhwgmI4XlNHkT6hv 8Qc6NmjEnHbuwTQPntMdpZI3Vmc9sQuxctssvBdYmmCfvux+4YzywHIbA U=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="423750593" 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; 26 Sep 2019 09:48:52 +0000 Received: from EX13MTAUWA001.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 656A0A2AF7; Thu, 26 Sep 2019 09:48:52 +0000 (UTC) Received: from EX13D06UWA003.ant.amazon.com (10.43.160.13) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:18 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D06UWA003.ant.amazon.com (10.43.160.13) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:17 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:16 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:09 +0100 Message-ID: <50b69940bfef5c9102d234f557b0e8bc228cc6a5.1569489002.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] [RFC PATCH 46/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 642fead4f6..0fac71356b 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 Thu Sep 26 09:46: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: 11162139 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 4001813BD for ; Thu, 26 Sep 2019 09:50: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 1BD9B222C0 for ; Thu, 26 Sep 2019 09:50: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="jjjI688C" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BD9B222C0 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 1iDQOd-0005iK-G9; Thu, 26 Sep 2019 09:49:11 +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 1iDQOc-0005gr-PC for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:10 +0000 X-Inumbo-ID: da9f1e5e-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id da9f1e5e-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48: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=1569491335; x=1601027335; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=g3nBDFD3rOj2j8Dpfaejkhy+nfkyUfS2Tj2b5j5iSC8=; b=jjjI688CVQKTlsax/ieFOGsHYCl/4YQgypOe6ClWTKgwzlTkLYpu42GO iM9moHaW4j6wSvABMQbDgm31Qm/AMBNDPclbCCiQ2NJC+fJfdhxwL93Xy Tcone1nLXJvVLVP9U2EIT5QKLiNathmtHdiCP+BwRDNUtU8UIKHAdFrPC U=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="417788324" 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-6001.iad6.amazon.com with ESMTP; 26 Sep 2019 09:48:55 +0000 Received: from EX13MTAUWA001.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 0D523A2A39; Thu, 26 Sep 2019 09:48:53 +0000 (UTC) Received: from EX13D18UWA004.ant.amazon.com (10.43.160.45) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:20 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D18UWA004.ant.amazon.com (10.43.160.45) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:19 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:18 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:10 +0100 Message-ID: <1616300d2e376baba872b00809c500cba64787ae.1569489002.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] [RFC PATCH 47/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 0fac71356b..bbdf1ee47c 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 Thu Sep 26 09:46: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: 11162171 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 58BB813B1 for ; Thu, 26 Sep 2019 09:51:04 +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 33E4F2053B for ; Thu, 26 Sep 2019 09:51:04 +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="rNgJ0hCY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 33E4F2053B 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 1iDQPg-00083k-SU; Thu, 26 Sep 2019 09:50:16 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iDQPd-0007wx-KN for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:13 +0000 X-Inumbo-ID: 052d25d0-e043-11e9-bf31-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 052d25d0-e043-11e9-bf31-bc764e2007e4; Thu, 26 Sep 2019 09:50: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=1569491407; x=1601027407; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=uPaFBKCI+WAJGgUixMIOEyzRi5v+2ZaD+PavNIUChg4=; b=rNgJ0hCYOHxdQE9TXa4Ii+8F7GvXu4UzD5mUoE/gtSx/WdfcCYec0aZt lbRDWb4LHYXsEAw/XWFlExve4+LKx3JiPKlQFk2PSdRUIGjuByEpO+wPT 4fqnKwBU8sUujxi8GNvhCpl3Bk23ayShNkpbBbMVTkWUUi13JH2g96PAh 8=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836988992" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1a-67b371d8.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 26 Sep 2019 09:49:07 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1a-67b371d8.us-east-1.amazon.com (Postfix) with ESMTPS id D8A4FA1C46; Thu, 26 Sep 2019 09:48:53 +0000 (UTC) Received: from EX13D04UWA001.ant.amazon.com (10.43.160.47) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:21 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D04UWA001.ant.amazon.com (10.43.160.47) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:21 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:20 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:11 +0100 Message-ID: <931bc9eed0fa7f6fa9ca81f4c7c8c436d18b6819.1569489002.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] [RFC PATCH 48/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 bbdf1ee47c..7483f8f23d 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 Thu Sep 26 09:46: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: 11162129 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 8BDD513BD for ; Thu, 26 Sep 2019 09:50: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 66C0F222C0 for ; Thu, 26 Sep 2019 09:50: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="V7ktIUtZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 66C0F222C0 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 1iDQOy-0006OM-4g; Thu, 26 Sep 2019 09:49:32 +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 1iDQOw-0006Ln-Pl for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:30 +0000 X-Inumbo-ID: da9f1e5f-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id da9f1e5f-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491336; x=1601027336; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=dsrNjN6yPWr+vJW/UTJ4O8vlGArBVD6ggCYMslFwKW8=; b=V7ktIUtZYSzOgjVZhGYV4bqUnP1h2SvID6uHWHgXFTfreM3Y7ijh8JU8 au4KlgckyOlG9gTd6+g+cgab+VcXiDBTE/GqB7uRn7jLKttXDPaKTVwXK 0FRdBfyVyX+4Z7cLdV2QRbj/Pou98U4gm3o7kniRNZjbU3i3Wn8vaeikZ A=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="417788331" 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-6001.iad6.amazon.com with ESMTP; 26 Sep 2019 09:48:56 +0000 Received: from EX13MTAUWA001.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 8D188A2684; Thu, 26 Sep 2019 09:48:54 +0000 (UTC) Received: from EX13D20UWA001.ant.amazon.com (10.43.160.34) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:23 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D20UWA001.ant.amazon.com (10.43.160.34) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:23 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:22 +0000 From: To: Date: Thu, 26 Sep 2019 10:46: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] [RFC PATCH 49/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 7483f8f23d..6f37bc4c15 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 Thu Sep 26 09:46: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: 11162111 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 91B5113BD for ; Thu, 26 Sep 2019 09:50: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 6C7A0222C0 for ; Thu, 26 Sep 2019 09:50:09 +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="DwUA6MnX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C7A0222C0 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 1iDQOo-00064l-OU; Thu, 26 Sep 2019 09:49:22 +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 1iDQOm-00060m-Pt for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:20 +0000 X-Inumbo-ID: db477202-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id db477202-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491336; x=1601027336; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=85eRksdJi5K0oVMyeH7P/wmA8MP87rAHYUSXiEfwFHk=; b=DwUA6MnXScC/Y1y/2+QhySpT5me9TJh7s4Xkh7BMWxInNvzQmFOqEhuL qnhXCo5aQ3hq/FtCwfQGU2r2YJdAe/vVUPSq19j60kLi5CTZPFs2XZtfu /B2F5QWCC6pjvNDaV/Db+4To2SgewqE0sWgZPKrpWchhe63ZcWjKYliyV E=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="423750612" 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; 26 Sep 2019 09:48:55 +0000 Received: from EX13MTAUWA001.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 A4E2DA2102; Thu, 26 Sep 2019 09:48:55 +0000 (UTC) Received: from EX13D03UWA004.ant.amazon.com (10.43.160.250) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:25 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D03UWA004.ant.amazon.com (10.43.160.250) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:25 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:23 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:13 +0100 Message-ID: <89715b3932df742de4f14474358eaeeb5db2c841.1569489002.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] [RFC PATCH 50/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 f09563ab34..d657ac0108 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -951,11 +951,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 Thu Sep 26 09:46: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: 11162143 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 EEA6B13BD for ; Thu, 26 Sep 2019 09:50: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 CA243222C4 for ; Thu, 26 Sep 2019 09:50: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="fghuVl+r" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA243222C4 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 1iDQP4-0006bj-Gu; Thu, 26 Sep 2019 09:49:38 +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 1iDQP1-0006W3-Rh for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:35 +0000 X-Inumbo-ID: db477203-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id db477203-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:48: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=1569491337; x=1601027337; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=f3D8sT4nLjfsYF+QuArXbr8SObtyun4SFrgHXutwP0A=; b=fghuVl+rtwyFFW84VkmtvF5pM52okdWq3XcbA0+B58Qw04i+tvQ97iFe XSC63MjVHYXXjEZdGRB50TzIQCPMfEro6Goy6RzXRl8T9QNNq8ojeq9FZ HDj0TVMaFTVHTbXLlBbmXeJmmWjAUUDUcTB0y4PtteOofxLvGPv582NPQ A=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="423750615" 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; 26 Sep 2019 09:48:56 +0000 Received: from EX13MTAUWA001.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 8A07DA2991; Thu, 26 Sep 2019 09:48:56 +0000 (UTC) Received: from EX13D10UWA004.ant.amazon.com (10.43.160.64) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:27 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D10UWA004.ant.amazon.com (10.43.160.64) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:26 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:25 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:14 +0100 Message-ID: <144c16e0cb37d5fde3eb48b2eaad1bbd7022108f.1569489002.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] [RFC PATCH 51/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:46: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: 11162179 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 DDDE313B1 for ; Thu, 26 Sep 2019 09:51: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 BA6C92053B for ; Thu, 26 Sep 2019 09:51: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="ZY/XPyj0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BA6C92053B 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 1iDQPo-0008UV-NU; Thu, 26 Sep 2019 09:50:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iDQPn-0008Qf-Ka for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:23 +0000 X-Inumbo-ID: 07d8e59e-e043-11e9-bf31-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 07d8e59e-e043-11e9-bf31-bc764e2007e4; Thu, 26 Sep 2019 09:50: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=1569491412; x=1601027412; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=asXLxl/75rRuYGnWov8wrMv8pQpcv+qWDkmA7y7z49A=; b=ZY/XPyj0r5fQVD0e+idXQCGZJj/kibu/zgBf/v51jSP++9j/C0Pa8+N9 Zehp7q9L7sS+LVmRjJMoWjhr2RU/ZYNamkdkLSIW4NGzrL5uRTKgmUlqx mjTyztFIq9gbmSLLZwzJ6ho08zIszXtP5+VMS1+3JK4vVTsKaUMTedzr4 k=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836989007" 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; 26 Sep 2019 09:49:10 +0000 Received: from EX13MTAUWA001.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 89D91A04EB; Thu, 26 Sep 2019 09:48:57 +0000 (UTC) Received: from EX13D32UWA001.ant.amazon.com (10.43.160.4) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:29 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D32UWA001.ant.amazon.com (10.43.160.4) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:28 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:27 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:15 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [RFC PATCH 52/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 Thu Sep 26 09:46: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: 11162151 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 34B0B13B1 for ; Thu, 26 Sep 2019 09:50: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 108C0222C0 for ; Thu, 26 Sep 2019 09:50:33 +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="ojz5PpuG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 108C0222C0 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 1iDQPD-0006uD-Ii; Thu, 26 Sep 2019 09:49: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 1iDQPB-0006qk-UV for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:45 +0000 X-Inumbo-ID: de1c7900-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id de1c7900-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:49: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=1569491340; x=1601027340; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Wby/mGwNUuZMxWF138zkmrPdE1eRR8bcGajq5qTxSXc=; b=ojz5PpuGRvxVFs9oILFlpn54wH3wrQe5nl4jxS0Bx51meoAHfuq1TASw ns/aJTqJl80UEKlctCrvfqoHmhCd0q3lss7jNNI5KwwYVrtGl9NJByfuS QrhTad5tFKjauoSBuXAMazUOxqm04xp/a3KbM9g7jajIUf1rx1SAW9fMc 4=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="423750630" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-97fdccfd.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 26 Sep 2019 09:49:00 +0000 Received: from EX13MTAUWA001.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 DDA02A1F03; Thu, 26 Sep 2019 09:48:58 +0000 (UTC) Received: from EX13D24UWA004.ant.amazon.com (10.43.160.233) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:31 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D24UWA004.ant.amazon.com (10.43.160.233) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:30 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:29 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:16 +0100 Message-ID: <32ae1461fb4177b1586bb7e735da6d58bbee5462.1569489002.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] [RFC PATCH 53/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 27981adc0b..1c90559288 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 Thu Sep 26 09:46: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: 11162149 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 DDBF61800 for ; Thu, 26 Sep 2019 09:50: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 BA561222C0 for ; Thu, 26 Sep 2019 09:50: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="L3BrHHSJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BA561222C0 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 1iDQP8-0006jy-JG; Thu, 26 Sep 2019 09:49: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 1iDQP6-0006gg-QV for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:40 +0000 X-Inumbo-ID: dd4b39b4-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id dd4b39b4-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:49:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491340; x=1601027340; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=W9PzwUfjSXRL4r6oD5FHM2BfgE+AdiBZBwN49R8r3mM=; b=L3BrHHSJri84FOybN41H3Nb4hFyganCynfTebEJZLzXzOvbxDbuHzGGO eCCBtycat0ak9GfoJkUMZ89rdo/RLegkfy6xc7fHRzjpirmgfwA68p2Ya PWdQbkCj14wpnFwyurpghYAvC6WPzR+Rz4YyLYMm6nDd/dT+p7aiy1MdR k=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="753354289" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1e-17c49630.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 26 Sep 2019 09:49:00 +0000 Received: from EX13MTAUWA001.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 2F7D0A2A39; Thu, 26 Sep 2019 09:49:00 +0000 (UTC) Received: from EX13D18UWA004.ant.amazon.com (10.43.160.45) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:33 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D18UWA004.ant.amazon.com (10.43.160.45) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:32 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:31 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:17 +0100 Message-ID: <4295599137290de85e7964b7a2dd7311a5d52ff3.1569489002.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] [RFC PATCH 54/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 302423a11f..d594b61702 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 Thu Sep 26 09:46: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: 11162155 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 18C381709 for ; Thu, 26 Sep 2019 09:50: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 E8B87222C0 for ; Thu, 26 Sep 2019 09:50: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="eOeIXmhL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E8B87222C0 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 1iDQPH-00071t-BR; Thu, 26 Sep 2019 09:49: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 1iDQPG-00070h-Ql for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:50 +0000 X-Inumbo-ID: de1c7901-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id de1c7901-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:49:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491342; x=1601027342; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=vgKhVC0ZR1gCJMfDli481PKJCVnBgEwbjfDPwtj0rqo=; b=eOeIXmhLLiPnkaeisxolZ5CP+pav75PghdMtmOeZzmBt+HeVeRNAq8No jnTgGM9W5zUHNwGMxc1vpRjmlfhDecDZJdrd1Rc3+5qIo3SfZqAjRHnJl 4i5xHpzCnWM5zpwdqRx7U+gAziix3UoFK34YZRM76JczucCIR/hZh48NJ g=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="753354297" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1e-17c49630.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 26 Sep 2019 09:49:02 +0000 Received: from EX13MTAUWA001.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 0FC15A2A42; Thu, 26 Sep 2019 09:49:02 +0000 (UTC) Received: from EX13d09UWA004.ant.amazon.com (10.43.160.158) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:35 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13d09UWA004.ant.amazon.com (10.43.160.158) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:34 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:33 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:18 +0100 Message-ID: <872c9d77a7ada6183a23c0e776d0975d07da873e.1569489002.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] [RFC PATCH 55/84] 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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 d594b61702..8e33c8f4fe 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 Thu Sep 26 09:46: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: 11162163 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 A3A1E13BD for ; Thu, 26 Sep 2019 09:50: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 6671F2053B for ; Thu, 26 Sep 2019 09:50: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="H9XpqcXv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6671F2053B 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 1iDQPN-0007F4-Om; Thu, 26 Sep 2019 09:49:57 +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 1iDQPL-0007BU-V1 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:56 +0000 X-Inumbo-ID: dfc72af2-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id dfc72af2-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:49:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491343; x=1601027343; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=SACdUBbbExS2N8tVnCoyvdJrMIaNKqA8nFeqqiztjxw=; b=H9XpqcXvRMU2WdWuQHXLy7tdwgiz7IxJUSnxIp7gmI6v7L/gdIq8E06W /b3FAdwt4JLx4c9kCbzD2YdQoJAL2EGqh5g6BvI51KaMySl+6pyplU7Ds k5S2j2aUOXU2OF8YnUBuTS1CS1k6IKwXzTJ9zDlPzGOg6+E0hbVJPWbMN U=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="753354302" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1e-17c49630.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 26 Sep 2019 09:49:03 +0000 Received: from EX13MTAUWA001.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 39407A2A4A; Thu, 26 Sep 2019 09:49:03 +0000 (UTC) Received: from EX13D27UWA003.ant.amazon.com (10.43.160.56) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:37 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D27UWA003.ant.amazon.com (10.43.160.56) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:36 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:35 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:19 +0100 Message-ID: <28a37c34184073178dfc096729179b44b06baa1c.1569489002.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] [RFC PATCH 56/84] 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 , Wei Liu , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?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/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 a11b05ea5a..75e89b81bf 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 8e33c8f4fe..b2b2edbed1 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,7 +5224,7 @@ 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); l2t = NULL; } if ( locking ) @@ -5232,8 +5232,8 @@ int map_pages_to_xen( 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); } } @@ -5268,12 +5268,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); } } @@ -5294,7 +5294,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 ) { @@ -5321,14 +5321,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], @@ -5345,7 +5345,7 @@ 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); l1t = NULL; } if ( locking ) @@ -5353,16 +5353,16 @@ int map_pages_to_xen( 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); @@ -5408,14 +5408,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, @@ -5425,7 +5425,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); @@ -5460,7 +5460,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); @@ -5469,7 +5469,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, @@ -5479,15 +5479,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 @@ -5495,9 +5495,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; } @@ -5568,14 +5568,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, @@ -5588,15 +5588,15 @@ 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); l2t = NULL; } 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); } } @@ -5604,7 +5604,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) ) @@ -5636,14 +5636,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], @@ -5656,15 +5656,15 @@ 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); l1t = NULL; } 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); } } } @@ -5678,7 +5678,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. */ @@ -5690,7 +5690,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; /* @@ -5721,11 +5721,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. */ @@ -5733,7 +5733,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); @@ -5767,11 +5767,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. */ @@ -5779,14 +5779,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); @@ -5795,8 +5795,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 1c90559288..e964c032f6 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 d657ac0108..53f9173f37 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -689,7 +689,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); @@ -703,7 +703,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); @@ -715,7 +715,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) ) @@ -727,13 +727,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) ) { @@ -741,20 +741,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) ) { @@ -762,21 +762,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) ) { @@ -784,14 +784,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); @@ -807,9 +807,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; } @@ -832,14 +832,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; @@ -884,7 +884,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; } @@ -900,7 +900,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 ) @@ -913,7 +913,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 ) { @@ -926,7 +926,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 ) { @@ -934,34 +934,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 6f37bc4c15..37e8d59e5d 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 = l2_ro_mpt; 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); From patchwork Thu Sep 26 09:46: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: 11162105 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 509EC13B1 for ; Thu, 26 Sep 2019 09:50:06 +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 2C9F8222C0 for ; Thu, 26 Sep 2019 09:50:06 +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="WcOdG9xQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C9F8222C0 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 1iDQOh-0005pF-5d; Thu, 26 Sep 2019 09:49: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 1iDQOf-0005lY-4d for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:13 +0000 X-Inumbo-ID: e14891cc-e042-11e9-bf31-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id e14891cc-e042-11e9-bf31-bc764e2007e4; Thu, 26 Sep 2019 09:49:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491346; x=1601027346; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=s4mefAb4N0ny9YTycU16/nUjrF+aqb1Mt3BdhB6r1z8=; b=WcOdG9xQamKv8wIdB9Z1hRPoMnth/HFK8f1H8VAf4LMJ3gWkO/J19E9L 9dZAJu2Xs8xD91VGnOhnNBSfG8+73+2x2pyAUc4NkU5QpmpjXC9oiuTry L85Ruigkt+N5QZiX2az/aUhO5BI61J2D5VprPg341UQUKNa26wXADMWV9 g=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="423750636" 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-6002.iad6.amazon.com with ESMTP; 26 Sep 2019 09:49:06 +0000 Received: from EX13MTAUWA001.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 3A17FA2685; Thu, 26 Sep 2019 09:49:04 +0000 (UTC) Received: from EX13D19UWA003.ant.amazon.com (10.43.160.170) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:39 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D19UWA003.ant.amazon.com (10.43.160.170) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:38 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:37 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:20 +0100 Message-ID: <4401db4cb6eafd307444ecbc6340c6e39c446418.1569489002.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] [RFC PATCH 57/84] x86: add Persistent Map (PMAP) infrastructure 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu The basic idea is like Persistent Kernel Map (PKMAP) in linux. We pre-populate all the relevant page tables before system is fully set up. It is needed to bootstrap map domain page infrastructure -- we need some way to map pages to set up per-cpu region without a direct map. In order to keep the number of entries minimal, this infrastructure can only be used by one CPU at a time. Signed-off-by: Wei Liu --- xen/arch/x86/Makefile | 1 + xen/arch/x86/pmap.c | 82 ++++++++++++++++++++++++++++++++++++ xen/include/asm-x86/fixmap.h | 3 ++ xen/include/asm-x86/pmap.h | 12 ++++++ 4 files changed, 98 insertions(+) create mode 100644 xen/arch/x86/pmap.c create mode 100644 xen/include/asm-x86/pmap.h diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 2443fd2cc5..7508219686 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -55,6 +55,7 @@ obj-y += pci.o obj-y += percpu.o obj-y += physdev.o x86_64/physdev.o obj-y += platform_hypercall.o x86_64/platform_hypercall.o +obj-y += pmap.o obj-y += psr.o obj-y += setup.o obj-y += shutdown.o diff --git a/xen/arch/x86/pmap.c b/xen/arch/x86/pmap.c new file mode 100644 index 0000000000..4ae16b0212 --- /dev/null +++ b/xen/arch/x86/pmap.c @@ -0,0 +1,82 @@ +#include +#include +#include + +#include +#include + +/* + * Simple mapping infrastructure to map / unmap pages in fixed map. + * This is used to set up percpu page table for mapcache, which is + * used by map domain page infrastructure. + * + * There is a restriction that only one CPU can use this + * infrastructure at a time. So this infrastructure _should not_ be + * used anywhere else other than the stated purpose above. + */ + +static DEFINE_SPINLOCK(lock); +/* Bitmap to track which slot is used */ +static unsigned long inuse; + +void pmap_lock(void) +{ + spin_lock(&lock); +} + +void pmap_unlock(void) +{ + spin_unlock(&lock); +} + +void *pmap_map(struct page_info *page) +{ + unsigned int idx; + void *linear = NULL; + enum fixed_addresses slot; + + ASSERT(!in_irq()); + ASSERT(spin_is_locked(&lock)); + + idx = find_first_zero_bit(&inuse, NUM_FIX_PMAP); + if ( idx == NUM_FIX_PMAP ) + panic("Out of PMAP slots\n"); + + __set_bit(idx, &inuse); + + slot = idx + FIX_PMAP_BEGIN; + ASSERT(slot >= FIX_PMAP_BEGIN && slot <= FIX_PMAP_END); + + set_fixmap(slot, mfn_x(page_to_mfn(page))); + linear = (void *)__fix_to_virt(slot); + + return linear; +} + +void pmap_unmap(void *p) +{ + unsigned int idx; + enum fixed_addresses slot = __virt_to_fix((unsigned long)p); + + ASSERT(!in_irq()); + ASSERT(slot >= FIX_PMAP_BEGIN && slot <= FIX_PMAP_END); + ASSERT(spin_is_locked(&lock)); + + idx = slot - FIX_PMAP_BEGIN; + __clear_bit(idx, &inuse); + clear_fixmap(slot); +} + +static void __maybe_unused build_assertions(void) +{ + BUILD_BUG_ON(sizeof(inuse) * BITS_PER_LONG < NUM_FIX_PMAP); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/asm-x86/fixmap.h b/xen/include/asm-x86/fixmap.h index 9fb2f47946..85885f8950 100644 --- a/xen/include/asm-x86/fixmap.h +++ b/xen/include/asm-x86/fixmap.h @@ -23,6 +23,7 @@ #include #include #include +#include #include /* @@ -48,6 +49,8 @@ enum fixed_addresses { FIX_XEN_SHARED_INFO, #endif /* CONFIG_XEN_GUEST */ /* Everything else should go further down. */ + FIX_PMAP_BEGIN, + FIX_PMAP_END = FIX_PMAP_BEGIN + NUM_FIX_PMAP - 1, FIX_APIC_BASE, FIX_IO_APIC_BASE_0, FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1, diff --git a/xen/include/asm-x86/pmap.h b/xen/include/asm-x86/pmap.h new file mode 100644 index 0000000000..42cd4c7793 --- /dev/null +++ b/xen/include/asm-x86/pmap.h @@ -0,0 +1,12 @@ +#ifndef __X86_PMAP_H__ +#define __X86_PMAP_H__ + +/* Large enough for mapping 5 levels of page tables */ +#define NUM_FIX_PMAP 5 + +void pmap_lock(void); +void pmap_unlock(void); +void *pmap_map(struct page_info *page); +void pmap_unmap(void *p); + +#endif /* __X86_PMAP_H__ */ From patchwork Thu Sep 26 09:46: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: 11162205 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 5883913B1 for ; Thu, 26 Sep 2019 09:51: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 343E42053B for ; Thu, 26 Sep 2019 09:51: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="GsCDE9PX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 343E42053B 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 1iDQQW-0001rs-Sr; Thu, 26 Sep 2019 09:51:08 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iDQQU-0001m1-Km for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:51:06 +0000 X-Inumbo-ID: 281807f4-e043-11e9-97fb-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 281807f4-e043-11e9-97fb-bc764e2007e4; Thu, 26 Sep 2019 09:51: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=1569491466; x=1601027466; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=X8ubSK1Ujw0hZSx2rdKIH6pGHqgEunpSnXJ2Y0lhEZQ=; b=GsCDE9PXBN60aq5YDqcXE2F+dih1jpNFl9BgNMLj5egOe/9ZHAhEQ3yH CvaHvSZSm/mSFGt7dNkW7LnG3V5I1shiV16RKJ4Ky43jMna4P1qtY7bhh lKwwEQRD6cZhFTskuSpsLfeKlSvLiN/hOFFewOvK7vJ5MIvm0MLR0sK2b U=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836988951" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1e-97fdccfd.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 26 Sep 2019 09:48: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-97fdccfd.us-east-1.amazon.com (Postfix) with ESMTPS id F1265A1D5D; Thu, 26 Sep 2019 09:48:44 +0000 (UTC) Received: from EX13D28EUC004.ant.amazon.com (10.43.164.80) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:44 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUC004.ant.amazon.com (10.43.164.80) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:43 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:39 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:21 +0100 Message-ID: <6d79e6301ff15af71b21c64d10760abb9775b626.1569489002.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] [RFC PATCH 58/84] x86/mm: fix leaks in map_xen_pagetable. 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: Stefano Stabellini , Wei Liu , Hongyan Xia , George Dunlap , Andrew Cooper , Konrad Rzeszutek Wilk , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Volodymyr Babchuk , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Not unmapping pages after map_xen_pagetable can leak the virtual address space over time. Also this fix makes vmap_to_mfn non-trivial to be a macro. There might be better options but move it into vmap.c for now. Signed-off-by: Hongyan Xia --- xen/arch/x86/mm.c | 5 +---- xen/common/vmap.c | 13 +++++++++++++ xen/include/asm-arm/mm.h | 2 -- xen/include/asm-x86/page.h | 2 -- xen/include/xen/vmap.h | 3 +++ 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index b2b2edbed1..145c5ab47c 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5160,6 +5160,7 @@ int map_pages_to_xen( !(l2e_get_flags(ol2e) & _PAGE_PSE) ) free_xen_pagetable(l2e_get_mfn(ol2e)); } + UNMAP_XEN_PAGETABLE(l2t); free_xen_pagetable(l2t_mfn); } } @@ -5225,7 +5226,6 @@ int map_pages_to_xen( l3e_write_atomic(pl3e, l3e_from_mfn(l2t_mfn, __PAGE_HYPERVISOR)); UNMAP_XEN_PAGETABLE(l2t); - l2t = NULL; } if ( locking ) spin_unlock(&map_pgdir_lock); @@ -5346,7 +5346,6 @@ int map_pages_to_xen( l2e_write_atomic(pl2e, l2e_from_mfn(l1t_mfn, __PAGE_HYPERVISOR)); UNMAP_XEN_PAGETABLE(l1t); - l1t = NULL; } if ( locking ) spin_unlock(&map_pgdir_lock); @@ -5589,7 +5588,6 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf) { l3e_write_atomic(pl3e, l3e_from_mfn(mfn, __PAGE_HYPERVISOR)); UNMAP_XEN_PAGETABLE(l2t); - l2t = NULL; } if ( locking ) spin_unlock(&map_pgdir_lock); @@ -5657,7 +5655,6 @@ 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(l1t); - l1t = NULL; } if ( locking ) spin_unlock(&map_pgdir_lock); diff --git a/xen/common/vmap.c b/xen/common/vmap.c index faebc1ddf1..fcdb8495c8 100644 --- a/xen/common/vmap.c +++ b/xen/common/vmap.c @@ -19,6 +19,19 @@ static unsigned int __read_mostly vm_end[VMAP_REGION_NR]; /* lowest known clear bit in the bitmap */ static unsigned int vm_low[VMAP_REGION_NR]; +mfn_t vmap_to_mfn(void *va) +{ + l1_pgentry_t *pl1e = virt_to_xen_l1e((unsigned long)(va)); + mfn_t ret = _mfn(l1e_get_pfn(*pl1e)); + unmap_xen_pagetable(pl1e); + return ret; +} + +struct page_info *vmap_to_page(void *va) +{ + return mfn_to_page(vmap_to_mfn(va)); +} + void __init vm_init_type(enum vmap_region type, void *start, void *end) { unsigned int i, nr; diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index 262d92f18d..1b53429255 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -231,8 +231,6 @@ static inline void __iomem *ioremap_wc(paddr_t start, size_t len) #define gaddr_to_gfn(ga) _gfn(paddr_to_pfn(ga)) #define mfn_to_maddr(mfn) pfn_to_paddr(mfn_x(mfn)) #define maddr_to_mfn(ma) _mfn(paddr_to_pfn(ma)) -#define vmap_to_mfn(va) maddr_to_mfn(virt_to_maddr((vaddr_t)va)) -#define vmap_to_page(va) mfn_to_page(vmap_to_mfn(va)) /* Page-align address and convert to frame number format */ #define paddr_to_pfn_aligned(paddr) paddr_to_pfn(PAGE_ALIGN(paddr)) diff --git a/xen/include/asm-x86/page.h b/xen/include/asm-x86/page.h index 906ec701a3..191de86bff 100644 --- a/xen/include/asm-x86/page.h +++ b/xen/include/asm-x86/page.h @@ -266,8 +266,6 @@ void copy_page_sse2(void *, const void *); #define pfn_to_paddr(pfn) __pfn_to_paddr(pfn) #define paddr_to_pfn(pa) __paddr_to_pfn(pa) #define paddr_to_pdx(pa) pfn_to_pdx(paddr_to_pfn(pa)) -#define vmap_to_mfn(va) _mfn(l1e_get_pfn(*virt_to_xen_l1e((unsigned long)(va)))) -#define vmap_to_page(va) mfn_to_page(vmap_to_mfn(va)) #endif /* !defined(__ASSEMBLY__) */ diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h index 369560e620..3d69727a9d 100644 --- a/xen/include/xen/vmap.h +++ b/xen/include/xen/vmap.h @@ -23,6 +23,9 @@ void *vmalloc_xen(size_t size); void *vzalloc(size_t size); void vfree(void *va); +mfn_t vmap_to_mfn(void *va); +struct page_info *vmap_to_page(void *va); + void __iomem *ioremap(paddr_t, size_t); static inline void iounmap(void __iomem *va) From patchwork Thu Sep 26 09:46: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: 11162175 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 E941213BD for ; Thu, 26 Sep 2019 09:51: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 C542B2053B for ; Thu, 26 Sep 2019 09:51:09 +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="vASdipTh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C542B2053B 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 1iDQPl-0008K5-54; Thu, 26 Sep 2019 09:50:21 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iDQPi-00087i-RO for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:18 +0000 X-Inumbo-ID: 07ae05f4-e043-11e9-8628-bc764e2007e4 Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id 07ae05f4-e043-11e9-8628-bc764e2007e4; Thu, 26 Sep 2019 09:50: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=1569491411; x=1601027411; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=8z0oYlQF1Bg6k3+OWJ/LtkFIqff1rqs7pLf37Fuu1Ss=; b=vASdipThD4YWNSFvq4Ra9zVfSFI8d9kXB/Fl/E/ZFYn9nUJbXDKDTPmw Kp9RftGRIlx8PdEpwk6DIqE8XvJ5OxuyZCasFNwfaD+YjV59WhoqY/9Dn xwX2wJn2eKF2FoJx2O27GLLO3bHGmztjrAjh/qTc91OpnuDxgTxEoWtB3 s=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="704637411" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1a-af6a10df.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 26 Sep 2019 09:49: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-1a-af6a10df.us-east-1.amazon.com (Postfix) with ESMTPS id 9E60EA2616; Thu, 26 Sep 2019 09:48:48 +0000 (UTC) Received: from EX13D28EUB004.ant.amazon.com (10.43.166.176) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:48 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUB004.ant.amazon.com (10.43.166.176) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:46 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:44 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:22 +0100 Message-ID: <3dba7fe6e3a9be5f41d02d41bc4ec6dbb1ba734c.1569489002.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] [RFC PATCH 59/84] x86/pmap: break the loop in pmap 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 , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Wei Liu , Jan Beulich , Hongyan Xia Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Modify the pmap PTEs directly. Using set/clear_fixmap() may result in invocation loops. Signed-off-by: Hongyan Xia --- xen/arch/x86/pmap.c | 11 ++++++++--- xen/include/asm-x86/pmap.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/pmap.c b/xen/arch/x86/pmap.c index 4ae16b0212..93104d0b86 100644 --- a/xen/arch/x86/pmap.c +++ b/xen/arch/x86/pmap.c @@ -29,11 +29,12 @@ void pmap_unlock(void) spin_unlock(&lock); } -void *pmap_map(struct page_info *page) +void *pmap_map(mfn_t mfn) { unsigned int idx; void *linear = NULL; enum fixed_addresses slot; + l1_pgentry_t *pl1e; ASSERT(!in_irq()); ASSERT(spin_is_locked(&lock)); @@ -47,7 +48,8 @@ void *pmap_map(struct page_info *page) slot = idx + FIX_PMAP_BEGIN; ASSERT(slot >= FIX_PMAP_BEGIN && slot <= FIX_PMAP_END); - set_fixmap(slot, mfn_x(page_to_mfn(page))); + pl1e = &l1_fixmap[L1_PAGETABLE_ENTRIES - 1 - slot]; + l1e_write_atomic(pl1e, l1e_from_mfn(mfn, PAGE_HYPERVISOR)); linear = (void *)__fix_to_virt(slot); return linear; @@ -56,6 +58,7 @@ void *pmap_map(struct page_info *page) void pmap_unmap(void *p) { unsigned int idx; + l1_pgentry_t *pl1e; enum fixed_addresses slot = __virt_to_fix((unsigned long)p); ASSERT(!in_irq()); @@ -64,7 +67,9 @@ void pmap_unmap(void *p) idx = slot - FIX_PMAP_BEGIN; __clear_bit(idx, &inuse); - clear_fixmap(slot); + + pl1e = &l1_fixmap[L1_PAGETABLE_ENTRIES - 1 - slot]; + l1e_write_atomic(pl1e, l1e_from_mfn(_mfn(0), 0)); } static void __maybe_unused build_assertions(void) diff --git a/xen/include/asm-x86/pmap.h b/xen/include/asm-x86/pmap.h index 42cd4c7793..feab1e9170 100644 --- a/xen/include/asm-x86/pmap.h +++ b/xen/include/asm-x86/pmap.h @@ -6,7 +6,7 @@ void pmap_lock(void); void pmap_unlock(void); -void *pmap_map(struct page_info *page); +void *pmap_map(mfn_t mfn); void pmap_unmap(void *p); #endif /* __X86_PMAP_H__ */ From patchwork Thu Sep 26 09:46: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: 11162117 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 710051709 for ; Thu, 26 Sep 2019 09:50:13 +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 4CCC4222C0 for ; Thu, 26 Sep 2019 09:50:13 +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="K7q9PWZE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4CCC4222C0 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 1iDQON-0005Ff-O1; Thu, 26 Sep 2019 09:48: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 1iDQOM-0005D5-6h for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:48:54 +0000 X-Inumbo-ID: d9e130ce-e042-11e9-8628-bc764e2007e4 Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id d9e130ce-e042-11e9-8628-bc764e2007e4; Thu, 26 Sep 2019 09:48: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=1569491333; x=1601027333; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=1aordIdIJbykTsdjQxOL5oa92i7bkfOlz+OB+WQS6D8=; b=K7q9PWZExsV8Wk5W2u9d0H/fSuvhRVMkHR8EuiLrurYnUx2Os1xXhX82 yp5dksK4X0SAKJ12QMBj/67e6mBDeTxpxFhkQRM+jmyb1Jb5YjdRECqrV N4LnHc3+1k+AlfuvKgeLRhwXUdZljD63UlDtKeUhmRFaDkkOtb4cJB6iR 8=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="787535196" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-af6a10df.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 26 Sep 2019 09:48: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-1a-af6a10df.us-east-1.amazon.com (Postfix) with ESMTPS id 48ED2A23EF; Thu, 26 Sep 2019 09:48:52 +0000 (UTC) Received: from EX13D28EUB001.ant.amazon.com (10.43.166.50) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:51 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUB001.ant.amazon.com (10.43.166.50) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:50 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:47 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:23 +0100 Message-ID: <4b8e2d635bedc8a51281cac0eb93b6761c1eec5c.1569489002.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] [RFC PATCH 60/84] x86/domain_page: use PMAP when d/vcache is not ready. 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 , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Wei Liu , Jan Beulich , Hongyan Xia Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Also fix a place where unmap_domain_page should only be conditionally used. Signed-off-by: Hongyan Xia --- xen/arch/x86/domain_page.c | 27 ++++++++++++++++++++++++--- xen/arch/x86/mm.c | 3 ++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c index 9ea74b456c..bece9d8cd0 100644 --- a/xen/arch/x86/domain_page.c +++ b/xen/arch/x86/domain_page.c @@ -17,6 +17,8 @@ #include #include #include +#include +#include static DEFINE_PER_CPU(struct vcpu *, override); @@ -83,12 +85,26 @@ void *map_domain_page(mfn_t mfn) v = mapcache_current_vcpu(); if ( !v || !is_pv_vcpu(v) ) - return mfn_to_virt(mfn_x(mfn)); + { + void *ret; + pmap_lock(); + ret = pmap_map(mfn); + pmap_unlock(); + flush_tlb_one_local(ret); + return ret; + } dcache = &v->domain->arch.pv.mapcache; vcache = &v->arch.pv.mapcache; if ( !dcache->inuse ) - return mfn_to_virt(mfn_x(mfn)); + { + void *ret; + pmap_lock(); + ret = pmap_map(mfn); + pmap_unlock(); + flush_tlb_one_local(ret); + return ret; + } perfc_incr(map_domain_page_count); @@ -181,8 +197,13 @@ void unmap_domain_page(const void *ptr) unsigned long va = (unsigned long)ptr, mfn, flags; struct vcpu_maphash_entry *hashent; - if ( va >= DIRECTMAP_VIRT_START ) + if ( va >= FIXADDR_START && va < FIXADDR_TOP ) + { + pmap_lock(); + pmap_unmap((void *)ptr); + pmap_unlock(); return; + } ASSERT(va >= MAPCACHE_VIRT_START && va < MAPCACHE_VIRT_END); diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 145c5ab47c..9619182f52 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5949,7 +5949,8 @@ int create_perdomain_mapping(struct domain *d, unsigned long va, if ( rc || !nr || !l1_table_offset(va) ) { /* Note that this is a no-op for the alloc_xenheap_page() case. */ - unmap_domain_page(l1tab); + if( (unsigned long)l1tab < DIRECTMAP_VIRT_START ) + unmap_domain_page(l1tab); l1tab = NULL; } } From patchwork Thu Sep 26 09:46: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: 11162169 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 CEC5813BD for ; Thu, 26 Sep 2019 09:51: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 AAEE92053B for ; Thu, 26 Sep 2019 09:51: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="Gjkv1i/+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AAEE92053B 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 1iDQPd-0007x7-Lt; Thu, 26 Sep 2019 09:50:13 +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 1iDQPa-0007qF-Sx for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:10 +0000 X-Inumbo-ID: e716710a-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id e716710a-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:49:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491356; x=1601027356; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=USV90sFuRrX8EANWvawhUHi+KMNPnW4terwRZ7si4HI=; b=Gjkv1i/+5PmE1knZTajvVtAwQtc4VUyLgoxNqQxWg5pFZYXgkZNoaxLz NBulUidE41eCZevH7Xe9nUiDS/01ynao0Lqb+RPYxeqmM/IaQM1sBUEgs xwtbsNe57ThXtuHR177cX/AaNPomso9FvoqdcE2Drbgw/ettH5SCQBBbN 8=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="753354334" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1a-807d4a99.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 26 Sep 2019 09:49:15 +0000 Received: from EX13MTAUWA001.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 B57ACA2AC9; Thu, 26 Sep 2019 09:49:13 +0000 (UTC) Received: from EX13D27UWA003.ant.amazon.com (10.43.160.56) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:53 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D27UWA003.ant.amazon.com (10.43.160.56) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:53 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:51 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:24 +0100 Message-ID: <4e79e54d7052964e8ddbd7fde381b4198eb992b0.1569489002.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] [RFC PATCH 61/84] x86: lift domain mapcache to arch_domain 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu It is going to be needed by HVM as well, because we want even HVM domain to have a per-domain mapcache. No functional change. Signed-off-by: Wei Liu --- xen/arch/x86/domain.c | 4 ++-- xen/arch/x86/domain_page.c | 10 ++++------ xen/include/asm-x86/domain.h | 6 +++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 75e89b81bf..083b413a70 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -617,6 +617,8 @@ int arch_domain_create(struct domain *d, psr_domain_init(d); + mapcache_domain_init(d); + if ( is_hvm_domain(d) ) { if ( (rc = hvm_domain_initialise(d)) != 0 ) @@ -624,8 +626,6 @@ int arch_domain_create(struct domain *d, } else if ( is_pv_domain(d) ) { - mapcache_domain_init(d); - if ( (rc = pv_domain_initialise(d)) != 0 ) goto fail; } diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c index bece9d8cd0..9a1cc5bb40 100644 --- a/xen/arch/x86/domain_page.c +++ b/xen/arch/x86/domain_page.c @@ -94,7 +94,7 @@ void *map_domain_page(mfn_t mfn) return ret; } - dcache = &v->domain->arch.pv.mapcache; + dcache = &v->domain->arch.mapcache; vcache = &v->arch.pv.mapcache; if ( !dcache->inuse ) { @@ -210,7 +210,7 @@ void unmap_domain_page(const void *ptr) v = mapcache_current_vcpu(); ASSERT(v && is_pv_vcpu(v)); - dcache = &v->domain->arch.pv.mapcache; + dcache = &v->domain->arch.mapcache; ASSERT(dcache->inuse); idx = PFN_DOWN(va - MAPCACHE_VIRT_START); @@ -254,11 +254,9 @@ void unmap_domain_page(const void *ptr) int mapcache_domain_init(struct domain *d) { - struct mapcache_domain *dcache = &d->arch.pv.mapcache; + struct mapcache_domain *dcache = &d->arch.mapcache; unsigned int bitmap_pages; - ASSERT(is_pv_domain(d)); - #ifdef NDEBUG if ( !mem_hotplug && max_page <= PFN_DOWN(__pa(HYPERVISOR_VIRT_END - 1)) ) return 0; @@ -282,7 +280,7 @@ int mapcache_domain_init(struct domain *d) int mapcache_vcpu_init(struct vcpu *v) { struct domain *d = v->domain; - struct mapcache_domain *dcache = &d->arch.pv.mapcache; + struct mapcache_domain *dcache = &d->arch.mapcache; unsigned long i; unsigned int ents = d->max_vcpus * MAPCACHE_VCPU_ENTRIES; unsigned int nr = PFN_UP(BITS_TO_LONGS(ents) * sizeof(long)); diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index 7cebfa4fb9..2c7b4df34c 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -260,9 +260,6 @@ struct pv_domain /* Mitigate L1TF with shadow/crashing? */ bool check_l1tf; - /* map_domain_page() mapping cache. */ - struct mapcache_domain mapcache; - struct cpuidmasks *cpuidmasks; }; @@ -295,6 +292,9 @@ struct arch_domain uint32_t pci_cf8; uint8_t cmos_idx; + /* map_domain_page() mapping cache. */ + struct mapcache_domain mapcache; + union { struct pv_domain pv; struct hvm_domain hvm; From patchwork Thu Sep 26 09:46: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: 11162109 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 977C613BD for ; Thu, 26 Sep 2019 09:50:07 +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 73B0E222C0 for ; Thu, 26 Sep 2019 09:50:07 +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="ugJvlZ6E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73B0E222C0 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 1iDQOm-00060H-HP; Thu, 26 Sep 2019 09:49: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 1iDQOk-0005vK-41 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:18 +0000 X-Inumbo-ID: e755c544-e042-11e9-97fb-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id e755c544-e042-11e9-97fb-bc764e2007e4; Thu, 26 Sep 2019 09:49:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491356; x=1601027356; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=woXLRl6C1H1ZD3v5zYbS0cYBVVy/4R3dJrCGF/ESWkY=; b=ugJvlZ6EuXVhhAWDtN/EuXcAmRplAtOgGsacwFL7gPuaOwdsKJmVWyJS TXemw4/Wsf2sljpNr30c+uL+We2LBzMJN2O2CXo2T7guihA6vnV0CWide LUHm3W30q6Ne3bHYbPxxs8huVHi7MFtXKzafhEUH6euuyf8UsHeuNcbk4 g=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="423750674" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-27fb8269.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 26 Sep 2019 09:49:16 +0000 Received: from EX13MTAUWA001.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 61566A1D79; Thu, 26 Sep 2019 09:49:14 +0000 (UTC) Received: from EX13d09UWA003.ant.amazon.com (10.43.160.227) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:55 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13d09UWA003.ant.amazon.com (10.43.160.227) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:55 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:53 +0000 From: To: Date: Thu, 26 Sep 2019 10:46: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] [RFC PATCH 62/84] x86: lift vcpu mapcache to arch_vcpu 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu It is going to be needed by HVM as well, because we want even HVM vcpu to have a per-vcpu mapcache. No functional change. Signed-off-by: Wei Liu --- xen/arch/x86/domain_page.c | 8 ++++---- xen/include/asm-x86/domain.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c index 9a1cc5bb40..348ea9ebf3 100644 --- a/xen/arch/x86/domain_page.c +++ b/xen/arch/x86/domain_page.c @@ -95,7 +95,7 @@ void *map_domain_page(mfn_t mfn) } dcache = &v->domain->arch.mapcache; - vcache = &v->arch.pv.mapcache; + vcache = &v->arch.mapcache; if ( !dcache->inuse ) { void *ret; @@ -215,7 +215,7 @@ void unmap_domain_page(const void *ptr) idx = PFN_DOWN(va - MAPCACHE_VIRT_START); mfn = l1e_get_pfn(MAPCACHE_L1ENT(idx)); - hashent = &v->arch.pv.mapcache.hash[MAPHASH_HASHFN(mfn)]; + hashent = &v->arch.mapcache.hash[MAPHASH_HASHFN(mfn)]; local_irq_save(flags); @@ -285,7 +285,7 @@ int mapcache_vcpu_init(struct vcpu *v) unsigned int ents = d->max_vcpus * MAPCACHE_VCPU_ENTRIES; unsigned int nr = PFN_UP(BITS_TO_LONGS(ents) * sizeof(long)); - if ( !is_pv_vcpu(v) || !dcache->inuse ) + if ( !dcache->inuse ) return 0; if ( ents > dcache->entries ) @@ -312,7 +312,7 @@ int mapcache_vcpu_init(struct vcpu *v) BUILD_BUG_ON(MAPHASHENT_NOTINUSE < MAPCACHE_ENTRIES); for ( i = 0; i < MAPHASH_ENTRIES; i++ ) { - struct vcpu_maphash_entry *hashent = &v->arch.pv.mapcache.hash[i]; + struct vcpu_maphash_entry *hashent = &v->arch.mapcache.hash[i]; hashent->mfn = ~0UL; /* never valid to map */ hashent->idx = MAPHASHENT_NOTINUSE; diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index 2c7b4df34c..48a40946da 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -477,9 +477,6 @@ struct arch_domain struct pv_vcpu { - /* map_domain_page() mapping cache. */ - struct mapcache_vcpu mapcache; - struct trap_info *trap_ctxt; unsigned long gdt_frames[FIRST_RESERVED_GDT_PAGE]; @@ -560,6 +557,9 @@ struct arch_vcpu struct vpmu_struct vpmu; + /* map_domain_page() mapping cache. */ + struct mapcache_vcpu mapcache; + /* Virtual Machine Extensions */ union { struct pv_vcpu pv; From patchwork Thu Sep 26 09:46: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: 11162183 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 C137813BD for ; Thu, 26 Sep 2019 09:51:18 +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 9D9492053B for ; Thu, 26 Sep 2019 09:51:18 +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="mX0FNO1u" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D9492053B 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 1iDQPu-0000NP-7S; Thu, 26 Sep 2019 09:50: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 1iDQPs-0000HY-K2 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:28 +0000 X-Inumbo-ID: 0ad4a922-e043-11e9-bf31-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 0ad4a922-e043-11e9-bf31-bc764e2007e4; Thu, 26 Sep 2019 09:50:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491416; x=1601027416; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Ay+KC3Ona01czWU1vcgcrNwN1I58Svev1gy8xA0gHpM=; b=mX0FNO1uIxplkp5Mvielk3X0xVrBfa5TSl/vBxYqKQzWAmGSPfZWK7ex mkPOVr3chswuuN/JdXRqXmzSfayIAzEp/KflE+6lABfoSvoHTQgzpV2Zi Uuk/mZ+YTcqpQ+UM+RwYJ3jP1pxDexAvSLvZKsLpBC4NWoznoRXF++6XI I=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836989061" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1d-2c665b5d.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 26 Sep 2019 09:49:27 +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 9982BA25C7; Thu, 26 Sep 2019 09:49:15 +0000 (UTC) Received: from EX13D28EUB002.ant.amazon.com (10.43.166.97) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:59 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUB002.ant.amazon.com (10.43.166.97) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:58 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:55 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:26 +0100 Message-ID: <340534a15e206136a9573e0af57fd74565dbaeff.1569489002.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] [RFC PATCH 63/84] x86/domain_page: mapcache is no longer tied to 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 , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Wei Liu , Jan Beulich , Hongyan Xia Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Signed-off-by: Hongyan Xia --- xen/arch/x86/domain_page.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c index 348ea9ebf3..4a3995ccef 100644 --- a/xen/arch/x86/domain_page.c +++ b/xen/arch/x86/domain_page.c @@ -84,7 +84,7 @@ void *map_domain_page(mfn_t mfn) #endif v = mapcache_current_vcpu(); - if ( !v || !is_pv_vcpu(v) ) + if ( !v ) { void *ret; pmap_lock(); @@ -208,7 +208,7 @@ void unmap_domain_page(const void *ptr) ASSERT(va >= MAPCACHE_VIRT_START && va < MAPCACHE_VIRT_END); v = mapcache_current_vcpu(); - ASSERT(v && is_pv_vcpu(v)); + ASSERT(v); dcache = &v->domain->arch.mapcache; ASSERT(dcache->inuse); From patchwork Thu Sep 26 09:46: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: 11162173 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 0C94513B1 for ; Thu, 26 Sep 2019 09:51:06 +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 DD4F2222C0 for ; Thu, 26 Sep 2019 09:51: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="a24FeU50" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD4F2222C0 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 1iDQPh-00085b-TP; Thu, 26 Sep 2019 09:50:17 +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 1iDQPf-00081e-RK for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:15 +0000 X-Inumbo-ID: eb9d974f-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id eb9d974f-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:49:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491363; x=1601027363; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=13mM5dRGLSEYhfnX5pNRRWDPwuo7bv2jjXzInhU8Nh0=; b=a24FeU50khJGpV/1l4vjgYHfMVfpNyb3sVH7fbdZHa+sBsa4dahYW8Wo ECv3usDrUeBNazbg2O5Cb5QofgXTRFEmu1+LQ/OlIHKt6KOC411PY6P8v IHIFAutNHE48d52GHdSXfrkShBg7wEd4Wx+ETq7g06YHEGSyExRjq7clE o=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="423750699" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-57e1d233.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 26 Sep 2019 09:49:23 +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 497AC141773; Thu, 26 Sep 2019 09:49:21 +0000 (UTC) Received: from EX13D28EUB003.ant.amazon.com (10.43.166.124) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:03 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUB003.ant.amazon.com (10.43.166.124) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:02 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:59 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:27 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [RFC PATCH 64/84] mapcache: initialise the mapcache even for the idle domain. 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: Wei Liu , Hongyan Xia , George Dunlap , Andrew Cooper , Dario Faggioli , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia In situations like in irqs or domain creation, PMAP cannot be used or the mapcache of that domain is simply not ready. We need to have a mapcache in the idle domain to map pages to deal with these. After this patch, map_domain_page() completely gets rid of the direct map. The assertions ensure mappings only happen within PMAP or MAPCACHE regions. As a result, map_xen_pagetable() gets rid of the direct map as well. Signed-off-by: Hongyan Xia --- xen/arch/x86/mm.c | 3 +++ xen/common/schedule.c | 1 + 2 files changed, 4 insertions(+) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 9619182f52..f30b5b3951 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5858,6 +5858,9 @@ int create_perdomain_mapping(struct domain *d, unsigned long va, l3tab = __map_domain_page(pg); clear_page(l3tab); d->arch.perdomain_l3_pg = pg; + if ( is_idle_domain(d) ) + idle_pg_table[l4_table_offset(PERDOMAIN_VIRT_START)] = + l4e_from_page(pg, __PAGE_HYPERVISOR_RW); if ( !nr ) { unmap_domain_page(l3tab); diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 7b71581756..e687be33a3 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1814,6 +1814,7 @@ void __init scheduler_init(void) BUG_ON(nr_cpu_ids > ARRAY_SIZE(idle_vcpu)); idle_domain->vcpu = idle_vcpu; idle_domain->max_vcpus = nr_cpu_ids; + mapcache_domain_init(idle_domain); if ( vcpu_create(idle_domain, 0, 0) == NULL ) BUG(); this_cpu(schedule_data).sched_priv = sched_alloc_pdata(&ops, 0); From patchwork Thu Sep 26 09:46: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: 11162193 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 019C513B1 for ; Thu, 26 Sep 2019 09:51: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 D2657222C2 for ; Thu, 26 Sep 2019 09:51:33 +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="kFbCHezO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2657222C2 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 1iDQQ8-0000vk-7O; Thu, 26 Sep 2019 09:50: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 1iDQQ4-0000oS-T7 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:40 +0000 X-Inumbo-ID: 125132ce-e043-11e9-964c-12813bfff9fa Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 125132ce-e043-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:50: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=1569491429; x=1601027429; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=EQfXGAiYAwwkWDZDwPbXdH4ATyLi8r4fPivSmtdu1wY=; b=kFbCHezOU+E9LWbAVyIkhb/jcQgGodPKsRs1PcGdp3gm0r+Vqoz74XXJ m92y2VtSEyiz5BivMowVzePaqfGzt8/H8tunF7HlDdJNCzcoygRn8LCfz m9/dxE9SsSQAtwbrBGgGVxzjOCeq7FFqDxHC1NvokUv1B7/9azBp9kU1L 4=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836989102" 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; 26 Sep 2019 09:49: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-62350142.us-east-1.amazon.com (Postfix) with ESMTPS id 58834A1F10; Thu, 26 Sep 2019 09:49:27 +0000 (UTC) Received: from EX13D28EUB004.ant.amazon.com (10.43.166.176) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:07 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUB004.ant.amazon.com (10.43.166.176) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:06 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:49:03 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:28 +0100 Message-ID: <0aa271bfe3670f7058128c728d392faa69418a49.1569489002.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] [RFC PATCH 65/84] x86: fix some wrong assumptions on direct map. Increase PMAP slots to 8. 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 , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Wei Liu , Jan Beulich , Hongyan Xia Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Signed-off-by: Hongyan Xia --- xen/arch/x86/domain_page.c | 8 -------- xen/arch/x86/x86_64/mm.c | 3 ++- xen/include/asm-x86/pmap.h | 4 ++-- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c index 4a3995ccef..f4f53a2a33 100644 --- a/xen/arch/x86/domain_page.c +++ b/xen/arch/x86/domain_page.c @@ -328,11 +328,6 @@ void *map_domain_page_global(mfn_t mfn) system_state < SYS_STATE_active) || local_irq_is_enabled())); -#ifdef NDEBUG - if ( mfn_x(mfn) <= PFN_DOWN(__pa(HYPERVISOR_VIRT_END - 1)) ) - return mfn_to_virt(mfn_x(mfn)); -#endif - return vmap(&mfn, 1); } @@ -340,9 +335,6 @@ void unmap_domain_page_global(const void *ptr) { unsigned long va = (unsigned long)ptr; - if ( va >= DIRECTMAP_VIRT_START ) - return; - ASSERT(va >= VMAP_VIRT_START && va < VMAP_VIRT_END); vunmap(ptr); diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 37e8d59e5d..40f29f8ddc 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -712,7 +712,8 @@ void __init paging_init(void) if ( mfn_eq(l2_ro_mpt_mfn, INVALID_MFN) ) goto nomem; l2_ro_mpt = map_xen_pagetable(l2_ro_mpt_mfn); - compat_idle_pg_table_l2 = l2_ro_mpt; + /* compat_idle_pg_table_l2 is used globally. */ + 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_mfn(l2_ro_mpt_mfn, __PAGE_HYPERVISOR_RO)); diff --git a/xen/include/asm-x86/pmap.h b/xen/include/asm-x86/pmap.h index feab1e9170..34d4f2bb38 100644 --- a/xen/include/asm-x86/pmap.h +++ b/xen/include/asm-x86/pmap.h @@ -1,8 +1,8 @@ #ifndef __X86_PMAP_H__ #define __X86_PMAP_H__ -/* Large enough for mapping 5 levels of page tables */ -#define NUM_FIX_PMAP 5 +/* Large enough for mapping 5 levels of page tables with some headroom */ +#define NUM_FIX_PMAP 8 void pmap_lock(void); void pmap_unlock(void); From patchwork Thu Sep 26 09:46: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: 11162207 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 7ABC413B1 for ; Thu, 26 Sep 2019 09:52: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 569C62053B for ; Thu, 26 Sep 2019 09:52: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="HUU4o5hF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 569C62053B 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 1iDQQq-0002RG-VO; Thu, 26 Sep 2019 09:51:28 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iDQQp-0002PE-O7 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:51:27 +0000 X-Inumbo-ID: 34eaf996-e043-11e9-bf31-bc764e2007e4 Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id 34eaf996-e043-11e9-bf31-bc764e2007e4; Thu, 26 Sep 2019 09:51: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=1569491487; x=1601027487; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=/5cplFV3IuulIGMdnfMNZOlzQqBhLt/T+9k7NrC7Kbc=; b=HUU4o5hFZCWFlux2zkb1RCv4xPCUSmRY/2fIpdN8QKYVKDEwc+4MH45/ Dd4KGktNe/gUx4Do8IL2ExCg4aIF5Goc38BYVFn+NFzvM7VRIjekiMAXL 5PysJy0+Zq0tyCCkuTdaFYVDHG5USEipLYJ9Yl8WtbX+yQaUYXJfmCMl0 s=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="704637550" 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; 26 Sep 2019 09:49:52 +0000 Received: from EX13MTAUWA001.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 DCD59A2A41; Thu, 26 Sep 2019 09:49:36 +0000 (UTC) Received: from EX13D23UWA003.ant.amazon.com (10.43.160.194) by EX13MTAUWA001.ant.amazon.com (10.43.160.118) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:09 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D23UWA003.ant.amazon.com (10.43.160.194) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:08 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:49:07 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:29 +0100 Message-ID: <1dac8f90c57bdb8e62a4fbf0b419b31d2202b48f.1569489002.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] [RFC PATCH 66/84] x86/pv: domheap pages should be mapped while relocating initrd 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 , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Xen shouldn't use domheap page as if they were xenheap pages. Map and unmap pages accordingly. Signed-off-by: Wei Liu --- xen/arch/x86/pv/dom0_build.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 02d7f1c27c..15b3ca2191 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -523,18 +523,32 @@ int __init dom0_construct_pv(struct domain *d, if ( d->arch.physaddr_bitsize && ((mfn + count - 1) >> (d->arch.physaddr_bitsize - PAGE_SHIFT)) ) { + unsigned int nr_pages; + unsigned int len = initrd_len; + struct page_info *pg; + order = get_order_from_pages(count); page = alloc_domheap_pages(d, order, MEMF_no_scrub); if ( !page ) panic("Not enough RAM for domain 0 initrd\n"); + + nr_pages = 1UL << order; for ( count = -count; order--; ) if ( count & (1UL << order) ) { free_domheap_pages(page, order); page += 1UL << order; + nr_pages -= 1UL << order; } - memcpy(page_to_virt(page), mfn_to_virt(initrd->mod_start), - initrd_len); + + for ( pg = page, i = 0; i < nr_pages; i++, len -= PAGE_SIZE, pg++ ) + { + void *p = __map_domain_page(pg); + memcpy(p, mfn_to_virt(initrd->mod_start) + i * PAGE_SIZE, + len > PAGE_SIZE ? PAGE_SIZE : len); + unmap_domain_page(p); + } + mpt_alloc = (paddr_t)initrd->mod_start << PAGE_SHIFT; init_domheap_pages(mpt_alloc, mpt_alloc + PAGE_ALIGN(initrd_len)); From patchwork Thu Sep 26 09:46: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: 11162147 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 AFF4F13B1 for ; Thu, 26 Sep 2019 09:50: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 8C651222C7 for ; Thu, 26 Sep 2019 09:50: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="qh2b7jYX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C651222C7 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 1iDQP5-0006e3-L3; Thu, 26 Sep 2019 09:49: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 1iDQP4-0006aw-4F for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:38 +0000 X-Inumbo-ID: f18dd65a-e042-11e9-b588-bc764e2007e4 Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id f18dd65a-e042-11e9-b588-bc764e2007e4; Thu, 26 Sep 2019 09:49: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=1569491373; x=1601027373; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=WA7fvNw77v8vAj8/L23G6+zYdl9FPU4M3xrqGinNO78=; b=qh2b7jYXk90YDovH2i8bYyn7z89UTQRFeaeFgclZqwHJTExLGlvg90xi ZhzloTIgBwDVNp37XLJfxJMYKd99bMb1WUE5jRF9m1+N0Xe8zAwqmAgtp DQTSadQBT+0yzjj/Yg/b9qPGeW7x1mpdeSUD4Dho4Hik8mbpWySRmhFTY k=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="417788427" 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; 26 Sep 2019 09:49:33 +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 476ABA32D9; Thu, 26 Sep 2019 09:49:33 +0000 (UTC) Received: from EX13D28EUC004.ant.amazon.com (10.43.164.80) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:13 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUC004.ant.amazon.com (10.43.164.80) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:11 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:49:09 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:30 +0100 Message-ID: <10c0b97f3f378af07012628afc685905af43148f.1569489002.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] [RFC PATCH 67/84] x86/domain_page: remove direct map code and initialise idle mapcache. 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 , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Wei Liu , Jan Beulich , Hongyan Xia Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia These are found in the NDEBUG build. Signed-off-by: Hongyan Xia --- xen/arch/x86/domain_page.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c index f4f53a2a33..f606677ae6 100644 --- a/xen/arch/x86/domain_page.c +++ b/xen/arch/x86/domain_page.c @@ -78,11 +78,6 @@ void *map_domain_page(mfn_t mfn) struct mapcache_vcpu *vcache; struct vcpu_maphash_entry *hashent; -#ifdef NDEBUG - if ( mfn_x(mfn) <= PFN_DOWN(__pa(HYPERVISOR_VIRT_END - 1)) ) - return mfn_to_virt(mfn_x(mfn)); -#endif - v = mapcache_current_vcpu(); if ( !v ) { @@ -257,11 +252,6 @@ int mapcache_domain_init(struct domain *d) struct mapcache_domain *dcache = &d->arch.mapcache; unsigned int bitmap_pages; -#ifdef NDEBUG - if ( !mem_hotplug && max_page <= PFN_DOWN(__pa(HYPERVISOR_VIRT_END - 1)) ) - return 0; -#endif - BUILD_BUG_ON(MAPCACHE_VIRT_END + PAGE_SIZE * (3 + 2 * PFN_UP(BITS_TO_LONGS(MAPCACHE_ENTRIES) * sizeof(long))) > MAPCACHE_VIRT_START + (PERDOMAIN_SLOT_MBYTES << 20)); From patchwork Thu Sep 26 09:46: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: 11162217 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 CF32413B1 for ; Thu, 26 Sep 2019 09:52: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 AA1DB2053B for ; Thu, 26 Sep 2019 09:52: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="klB5hPvP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA1DB2053B 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 1iDQRP-0003Cy-L9; Thu, 26 Sep 2019 09:52:03 +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 1iDQRP-0003C3-0u for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:52:03 +0000 X-Inumbo-ID: 49a35e3d-e043-11e9-964d-12813bfff9fa Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id 49a35e3d-e043-11e9-964d-12813bfff9fa; Thu, 26 Sep 2019 09:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491522; x=1601027522; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=0ZRTMVyTxhD3UAeSMOjD2jf6Xx+XUFYSwEDGxF69GA4=; b=klB5hPvPOZyF0u6evgDbtwEM+jan6klo47etBMPz5hJAi/hGWTOv8lTt nvlnUstQZEQTAaj6MVHvtfsTxqEY7f8bz/wShi8aHiONpExUj0PXJS5HQ GHCrE1CxYMCewjoSSLSYfIJHSjFaz7LfU0FgR8yloQ5Wk+4+DCHGC84S8 Q=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="704637566" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1e-62350142.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 26 Sep 2019 09:49: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 75CDEA21D2; Thu, 26 Sep 2019 09:49:38 +0000 (UTC) Received: from EX13D28EUB003.ant.amazon.com (10.43.166.124) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:17 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUB003.ant.amazon.com (10.43.166.124) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:16 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:49:13 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:31 +0100 Message-ID: <30e7ab0c4eff006d752ecd004cd1f0130ef52536.1569489002.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] [RFC PATCH 68/84] page_alloc: actually do the mapping and unmapping on xenheap. 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: Stefano Stabellini , Wei Liu , Hongyan Xia , George Dunlap , Andrew Cooper , Konrad Rzeszutek Wilk , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Signed-off-by: Hongyan Xia --- xen/common/page_alloc.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 7cb1bd368b..4ec6299ba8 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2143,6 +2143,7 @@ void init_xenheap_pages(paddr_t ps, paddr_t pe) void *alloc_xenheap_pages(unsigned int order, unsigned int memflags) { struct page_info *pg; + void *ret; ASSERT(!in_irq()); @@ -2151,7 +2152,10 @@ void *alloc_xenheap_pages(unsigned int order, unsigned int memflags) if ( unlikely(pg == NULL) ) return NULL; - memguard_unguard_range(page_to_virt(pg), 1 << (order + PAGE_SHIFT)); + ret = page_to_virt(pg); + memguard_unguard_range(ret, 1 << (order + PAGE_SHIFT)); + map_pages_to_xen((unsigned long)ret, page_to_mfn(pg), + 1UL << order, PAGE_HYPERVISOR); return page_to_virt(pg); } @@ -2165,6 +2169,8 @@ void free_xenheap_pages(void *v, unsigned int order) return; memguard_guard_range(v, 1 << (order + PAGE_SHIFT)); + ASSERT((unsigned long)v >= DIRECTMAP_VIRT_START); + map_pages_to_xen((unsigned long)v, INVALID_MFN, 1UL << order, _PAGE_NONE); free_heap_pages(virt_to_page(v), order, false); } @@ -2189,6 +2195,7 @@ void *alloc_xenheap_pages(unsigned int order, unsigned int memflags) { struct page_info *pg; unsigned int i; + void *ret; ASSERT(!in_irq()); @@ -2204,7 +2211,11 @@ void *alloc_xenheap_pages(unsigned int order, unsigned int memflags) for ( i = 0; i < (1u << order); i++ ) pg[i].count_info |= PGC_xen_heap; - return page_to_virt(pg); + ret = page_to_virt(pg); + map_pages_to_xen((unsigned long)ret, page_to_mfn(pg), + 1UL << order, PAGE_HYPERVISOR); + + return ret; } void free_xenheap_pages(void *v, unsigned int order) @@ -2222,6 +2233,9 @@ void free_xenheap_pages(void *v, unsigned int order) for ( i = 0; i < (1u << order); i++ ) pg[i].count_info &= ~PGC_xen_heap; + ASSERT((unsigned long)v >= DIRECTMAP_VIRT_START); + map_pages_to_xen((unsigned long)v, INVALID_MFN, 1UL << order, _PAGE_NONE); + free_heap_pages(pg, order, true); } From patchwork Thu Sep 26 09:46: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: 11162213 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 4F11513B1 for ; Thu, 26 Sep 2019 09:52: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 2B6392053B for ; Thu, 26 Sep 2019 09:52: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="ZNXcGJTg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B6392053B 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 1iDQR8-0002q3-N5; Thu, 26 Sep 2019 09:51:46 +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 1iDQR7-0002nx-Bn for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:51:45 +0000 X-Inumbo-ID: 3d71c8d9-e043-11e9-964d-12813bfff9fa Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 3d71c8d9-e043-11e9-964d-12813bfff9fa; Thu, 26 Sep 2019 09:51:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491502; x=1601027502; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=gUmQxE1/9r+oWcjOQYQcyyS1mWBwuNCjdmshVcZJotg=; b=ZNXcGJTg5oQelB9faY9mTIi6pA/ByJUR6Q5opV9f48GUtZRxtzEsIlwn i/nh7Fjgo58xNbPCmveCHIlgP8r8bWMn+U6GmwgE/pMn4YEooTw7ZXdcm jeVrKOD7XvZ6zK2EIT/AVJt5YcNUj14sDg7Zk4uSWkTlpBpFTvD7TwNRg k=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836989166" 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; 26 Sep 2019 09:49:54 +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 B9086A26A7; Thu, 26 Sep 2019 09:49:41 +0000 (UTC) Received: from EX13D28EUB004.ant.amazon.com (10.43.166.176) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:22 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUB004.ant.amazon.com (10.43.166.176) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:21 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:49:17 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:32 +0100 Message-ID: <71e585138508d7d46c5349f72e1dfd3df8f2b595.1569489002.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] [RFC PATCH 69/84] page_alloc: comments on (un)mapping pages in xenheap allocations. 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: Stefano Stabellini , Wei Liu , Hongyan Xia , George Dunlap , Andrew Cooper , Konrad Rzeszutek Wilk , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Signed-off-by: Hongyan Xia --- xen/common/page_alloc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 4ec6299ba8..a00db4c0d9 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2212,6 +2212,10 @@ void *alloc_xenheap_pages(unsigned int order, unsigned int memflags) pg[i].count_info |= PGC_xen_heap; ret = page_to_virt(pg); + /* + * The direct map is not always mapped now. We need to populate the direct + * map region on demand for security. + */ map_pages_to_xen((unsigned long)ret, page_to_mfn(pg), 1UL << order, PAGE_HYPERVISOR); @@ -2234,6 +2238,7 @@ void free_xenheap_pages(void *v, unsigned int order) pg[i].count_info &= ~PGC_xen_heap; ASSERT((unsigned long)v >= DIRECTMAP_VIRT_START); + /* Tear down the 1:1 mapping in this region for memory safety. */ map_pages_to_xen((unsigned long)v, INVALID_MFN, 1UL << order, _PAGE_NONE); free_heap_pages(pg, order, true); From patchwork Thu Sep 26 09:46: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: 11162181 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 216FD13BD for ; Thu, 26 Sep 2019 09:51: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 EEB122053B for ; Thu, 26 Sep 2019 09:51: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="AWEzgS8I" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EEB122053B 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 1iDQPs-0000GC-2X; Thu, 26 Sep 2019 09:50:28 +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 1iDQPp-00006R-Sr for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:25 +0000 X-Inumbo-ID: f84ce850-e042-11e9-964c-12813bfff9fa Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id f84ce850-e042-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:49: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=1569491384; x=1601027384; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=kyWBa7Itj+eCyTqGw+czzYikdfFYsEt5DZcfNy6zJ2Q=; b=AWEzgS8IDoTb4R98eM780ttDPfhcj38VkuHVtzKBPYo92B2F2zHotgLx aOEsok0lsrgVXhL22eB1XXMG03GvNZWbFMEfyP6qDNoGFQFDG//ptI13W WO5ZIvXidC01yg5x0J0XiIjfJgrvbJ3FBa0f/DJTh/DRwbmrSzqNgWgIw s=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="753354397" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1a-821c648d.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 26 Sep 2019 09:49:44 +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-821c648d.us-east-1.amazon.com (Postfix) with ESMTPS id 537BFA236A; Thu, 26 Sep 2019 09:49:43 +0000 (UTC) Received: from EX13D28EUB001.ant.amazon.com (10.43.166.50) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:26 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUB001.ant.amazon.com (10.43.166.50) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:25 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:49:22 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:33 +0100 Message-ID: <42c22c45411e5953097478899c1f9c1b147f39f7.1569489002.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] [RFC PATCH 70/84] x86/smpboot: use xenheap pages for rpts in smpboot. 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 , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Wei Liu , Jan Beulich , Hongyan Xia Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia This is because a lot of code assumes that the rpt is in the direct map region which is always mapped. Switching to domheap is non-trivial, so use xenheap for now, which means a bit less security. Signed-off-by: Hongyan Xia --- xen/arch/x86/smpboot.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 53f9173f37..7034c699d6 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -832,14 +832,20 @@ static int setup_cpu_root_pgt(unsigned int cpu) goto out; } - rpt_mfn = alloc_xen_pagetable(); - if ( mfn_eq(rpt_mfn, INVALID_MFN) ) + /* + * Unfortunately, some code (especially in assembly) assumes the rpt is in + * the DIRECTMAP region and is always mapped. Making all of them adapt to + * the new page table APIs is non-trivial. For now, make it always mapped + * on the xenheap. + */ + rpt = alloc_xenheap_page(); + if ( !rpt ) { rc = -ENOMEM; goto out; } - rpt = map_xen_pagetable(rpt_mfn); + rpt_mfn = _mfn(virt_to_mfn(rpt)); clear_page(rpt); per_cpu(root_pgt_mfn, cpu) = rpt_mfn; @@ -884,7 +890,6 @@ static int setup_cpu_root_pgt(unsigned int cpu) rc = clone_mapping((void *)per_cpu(stubs.addr, cpu), rpt); out: - UNMAP_XEN_PAGETABLE(rpt); return rc; } @@ -900,7 +905,7 @@ static void cleanup_cpu_root_pgt(unsigned int cpu) per_cpu(root_pgt_mfn, cpu) = INVALID_MFN; - rpt = map_xen_pagetable(rpt_mfn); + rpt = mfn_to_virt(mfn_x(rpt_mfn)); for ( r = root_table_offset(DIRECTMAP_VIRT_START); r < root_table_offset(HYPERVISOR_VIRT_END); ++r ) @@ -945,8 +950,8 @@ static void cleanup_cpu_root_pgt(unsigned int cpu) free_xen_pagetable(l3t_mfn); } - UNMAP_XEN_PAGETABLE(rpt); - free_xen_pagetable(rpt_mfn); + /* Unlike other levels, the root level is a xenheap page. */ + free_xenheap_page(rpt); /* Also zap the stub mapping for this CPU. */ if ( stub_linear ) From patchwork Thu Sep 26 09:46: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: 11162157 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 25C9C13BD for ; Thu, 26 Sep 2019 09:50: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 00250222C0 for ; Thu, 26 Sep 2019 09:50:46 +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="HqJAy0lr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 00250222C0 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 1iDQPJ-00076l-Op; Thu, 26 Sep 2019 09:49:53 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iDQPH-000733-Ud for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:51 +0000 X-Inumbo-ID: fc110368-e042-11e9-97fb-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id fc110368-e042-11e9-97fb-bc764e2007e4; Thu, 26 Sep 2019 09:49: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=1569491391; x=1601027391; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=BGeUL/mcPd5wEv8IOXu2uKjLO1fDkSD+qYwjUV4qteY=; b=HqJAy0lrGaegXSfls0093bWeJpmcath64yRBreeMaLbkuuekiuw5Do8a kz+LXDjbc9zoiIJsRc/vKfP/8i/C6qakYC1iLyEyBEfWzwJ9qCvBssYGr qDtG2aXulInpvK3kJTAZlePrBDl8ddRvld6HU2A8aSuqerVPu26UHNx6N A=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="423750777" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-715bee71.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 26 Sep 2019 09:49: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-1a-715bee71.us-east-1.amazon.com (Postfix) with ESMTPS id AF268A236F; Thu, 26 Sep 2019 09:49:47 +0000 (UTC) Received: from EX13D28EUC002.ant.amazon.com (10.43.164.254) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:31 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUC002.ant.amazon.com (10.43.164.254) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:30 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:49:26 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:34 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [RFC PATCH 71/84] x86/setup: start tearing down the direct map. 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: Stefano Stabellini , Wei Liu , Hongyan Xia , George Dunlap , Andrew Cooper , Konrad Rzeszutek Wilk , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Signed-off-by: Hongyan Xia --- xen/arch/x86/setup.c | 4 ++-- xen/common/page_alloc.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index e964c032f6..3dc2fad987 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1367,7 +1367,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) if ( map_e < end ) { - map_pages_to_xen((unsigned long)__va(map_e), maddr_to_mfn(map_e), + map_pages_to_xen((unsigned long)__va(map_e), INVALID_MFN, PFN_DOWN(end - map_e), PAGE_HYPERVISOR); init_boot_pages(map_e, end); map_e = end; @@ -1382,7 +1382,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) } if ( s < map_s ) { - map_pages_to_xen((unsigned long)__va(s), maddr_to_mfn(s), + map_pages_to_xen((unsigned long)__va(s), INVALID_MFN, PFN_DOWN(map_s - s), PAGE_HYPERVISOR); init_boot_pages(s, map_s); } diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index a00db4c0d9..deeeac065c 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2157,7 +2157,7 @@ void *alloc_xenheap_pages(unsigned int order, unsigned int memflags) map_pages_to_xen((unsigned long)ret, page_to_mfn(pg), 1UL << order, PAGE_HYPERVISOR); - return page_to_virt(pg); + return ret; } From patchwork Thu Sep 26 09:46: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: 11162153 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 B229B13B1 for ; Thu, 26 Sep 2019 09:50: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 8DCB5222C6 for ; Thu, 26 Sep 2019 09:50: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="iKzwo0Uh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DCB5222C6 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 1iDQPK-00078w-Qw; Thu, 26 Sep 2019 09:49:54 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iDQPJ-00075X-59 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:49:53 +0000 X-Inumbo-ID: fcd3d69a-e042-11e9-97fb-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by localhost (Halon) with ESMTPS id fcd3d69a-e042-11e9-97fb-bc764e2007e4; Thu, 26 Sep 2019 09:49: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=1569491392; x=1601027392; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=hLhaqBqKlhsYdBQLmVKD140d9/Kwf8o4PkFJCGHBtN4=; b=iKzwo0UhQ7J1u2IhnJXXBYLBin2GNjjhjBAeAtELD6ufWbP8d2AZ2ZBf Ycs6/QpskEEIonYM1c7pIckscnzaiNChGvxZgjHUxrrPhhkyCPdGPszCH dFOlC4zHJFae+lGJYUoEYThgitjEIq0Ust8jsPDgAmSJyj3rfptufwdMv Y=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="423750784" 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; 26 Sep 2019 09:49: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-1e-62350142.us-east-1.amazon.com (Postfix) with ESMTPS id 0F489A1EF3; Thu, 26 Sep 2019 09:49:52 +0000 (UTC) Received: from EX13D28EUB001.ant.amazon.com (10.43.166.50) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:34 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUB001.ant.amazon.com (10.43.166.50) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:33 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:49:30 +0000 From: To: Date: Thu, 26 Sep 2019 10:46: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] [RFC PATCH 72/84] acpi: don't assume an always-mapped direct map in acpi allocations. 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 , Hongyan Xia Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Signed-off-by: Hongyan Xia --- xen/drivers/acpi/osl.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c index 4c8bb7839e..dbf62325f3 100644 --- a/xen/drivers/acpi/osl.c +++ b/xen/drivers/acpi/osl.c @@ -216,14 +216,25 @@ acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width) void *__init acpi_os_alloc_memory(size_t sz) { - void *ptr; - - if (system_state == SYS_STATE_early_boot) - return mfn_to_virt(mfn_x(alloc_boot_pages(PFN_UP(sz), 1))); - - ptr = xmalloc_bytes(sz); - ASSERT(!ptr || is_xmalloc_memory(ptr)); - return ptr; + void *ptr; + unsigned long nr_pfns = PFN_UP(sz); + mfn_t mfn; + + if (system_state == SYS_STATE_early_boot) + { + mfn = alloc_boot_pages(nr_pfns, 1); + ptr = mfn_to_virt(mfn_x(mfn)); + /* + * Direct map is garbage now, fill the actual mapping. Safe to do so + * now because map_pages got rid of the direct map even in early boot. + */ + map_pages_to_xen((unsigned long)ptr, mfn, nr_pfns, PAGE_HYPERVISOR); + return ptr; + } + + ptr = xmalloc_bytes(sz); + ASSERT(!ptr || is_xmalloc_memory(ptr)); + return ptr; } void *__init acpi_os_zalloc_memory(size_t sz) @@ -241,8 +252,14 @@ void *__init acpi_os_zalloc_memory(size_t sz) void __init acpi_os_free_memory(void *ptr) { - if (is_xmalloc_memory(ptr)) - xfree(ptr); - else if (ptr && system_state == SYS_STATE_early_boot) - init_boot_pages(__pa(ptr), __pa(ptr) + PAGE_SIZE); + mfn_t mfn; + if (is_xmalloc_memory(ptr)) + xfree(ptr); + else if (ptr && system_state == SYS_STATE_early_boot) + { + init_boot_pages(__pa(ptr), __pa(ptr) + PAGE_SIZE); + /* Also unmap in the 1:1 region for security. */ + mfn = _mfn(virt_to_mfn(ptr)); + map_pages_to_xen((unsigned long)ptr, mfn, 1, _PAGE_NONE); + } } From patchwork Thu Sep 26 09:46: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: 11162219 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 54A9C13BD for ; Thu, 26 Sep 2019 09:52:59 +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 3019A2053B for ; Thu, 26 Sep 2019 09:52: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="vAcER24b" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3019A2053B 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 1iDQRY-0003NE-0i; Thu, 26 Sep 2019 09:52:12 +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 1iDQRW-0003LS-Ic for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:52:10 +0000 X-Inumbo-ID: 4dbf6b6e-e043-11e9-964d-12813bfff9fa Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 4dbf6b6e-e043-11e9-964d-12813bfff9fa; Thu, 26 Sep 2019 09:52: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=1569491529; x=1601027529; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=M4xZGI3sG3gLLgUNWWpn0VT0zlxORA27r6JiOSmnYMw=; b=vAcER24bNxWGPjW5stUr3nOfyK9GZNiyW/cGbJLopdCe4UUVanHWawcB /sD7/w38horWqfMuIzsIIHGAbNP5O3/4SpOzHIe8Yr0qidHvKg6sjhlct AGYp79+Ng4ytndq63X8G2mkti0MnFSDjyP1bPa8H6zEpq1smwLinTzGG0 0=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836989235" 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; 26 Sep 2019 09:50: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-1a-807d4a99.us-east-1.amazon.com (Postfix) with ESMTPS id E64E4A02B6; Thu, 26 Sep 2019 09:49:55 +0000 (UTC) Received: from EX13D28EUC002.ant.amazon.com (10.43.164.254) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:39 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUC002.ant.amazon.com (10.43.164.254) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:38 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:49:34 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:36 +0100 Message-ID: <8f017ae92757547e7b3492357d305045cffb5650.1569489002.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] [RFC PATCH 73/84] x86/mm: Move vmap_to_mfn() to mm.c and rename to virt_to_mfn_walk(). 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: Stefano Stabellini , Wei Liu , Hongyan Xia , George Dunlap , Andrew Cooper , Konrad Rzeszutek Wilk , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Obviously, vmap_to_mfn is a generic mechanism to walk the page table to find the mfn, not vmap specific. Also the difference from virt_to_mfn() is that it actually walks the page table instead of relying on a direct map. Signed-off-by: Hongyan Xia --- xen/arch/x86/mm.c | 13 +++++++++++++ xen/common/vmap.c | 15 +-------------- xen/include/asm-x86/mm.h | 2 ++ xen/include/xen/vmap.h | 3 --- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index f30b5b3951..ab760ecc1f 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5056,6 +5056,19 @@ l1_pgentry_t *virt_to_xen_l1e(unsigned long v) return pl1e; } +unsigned long virt_to_mfn_walk(void *va) +{ + l1_pgentry_t *pl1e = virt_to_xen_l1e((unsigned long)(va)); + unsigned long ret = l1e_get_pfn(*pl1e); + unmap_xen_pagetable(pl1e); + return ret; +} + +struct page_info *virt_to_page_walk(void *va) +{ + return mfn_to_page(_mfn(virt_to_mfn_walk(va))); +} + /* Convert to from superpage-mapping flags for map_pages_to_xen(). */ #define l1f_to_lNf(f) (((f) & _PAGE_PRESENT) ? ((f) | _PAGE_PSE) : (f)) #define lNf_to_l1f(f) (((f) & _PAGE_PRESENT) ? ((f) & ~_PAGE_PSE) : (f)) diff --git a/xen/common/vmap.c b/xen/common/vmap.c index fcdb8495c8..4323c6811f 100644 --- a/xen/common/vmap.c +++ b/xen/common/vmap.c @@ -19,19 +19,6 @@ static unsigned int __read_mostly vm_end[VMAP_REGION_NR]; /* lowest known clear bit in the bitmap */ static unsigned int vm_low[VMAP_REGION_NR]; -mfn_t vmap_to_mfn(void *va) -{ - l1_pgentry_t *pl1e = virt_to_xen_l1e((unsigned long)(va)); - mfn_t ret = _mfn(l1e_get_pfn(*pl1e)); - unmap_xen_pagetable(pl1e); - return ret; -} - -struct page_info *vmap_to_page(void *va) -{ - return mfn_to_page(vmap_to_mfn(va)); -} - void __init vm_init_type(enum vmap_region type, void *start, void *end) { unsigned int i, nr; @@ -332,7 +319,7 @@ void vfree(void *va) for ( i = 0; i < pages; i++ ) { - struct page_info *page = vmap_to_page(va + i * PAGE_SIZE); + struct page_info *page = virt_to_page_walk(va + i * PAGE_SIZE); ASSERT(page); page_list_add(page, &pg_list); diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index a4b3c9b7af..76ba56bdc3 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -643,6 +643,8 @@ void free_xen_pagetable(mfn_t mfn); } while (0) l1_pgentry_t *virt_to_xen_l1e(unsigned long v); +unsigned long virt_to_mfn_walk(void *va); +struct page_info *virt_to_page_walk(void *va); DECLARE_PER_CPU(mfn_t, root_pgt_mfn); diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h index 3d69727a9d..369560e620 100644 --- a/xen/include/xen/vmap.h +++ b/xen/include/xen/vmap.h @@ -23,9 +23,6 @@ void *vmalloc_xen(size_t size); void *vzalloc(size_t size); void vfree(void *va); -mfn_t vmap_to_mfn(void *va); -struct page_info *vmap_to_page(void *va); - void __iomem *ioremap(paddr_t, size_t); static inline void iounmap(void __iomem *va) From patchwork Thu Sep 26 09:46: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: 11162209 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 931B313BD for ; Thu, 26 Sep 2019 09:52: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 6F7F32053B for ; Thu, 26 Sep 2019 09:52: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="Hs1wRF/u" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F7F32053B 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 1iDQQy-0002bW-EV; Thu, 26 Sep 2019 09:51: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 1iDQQx-0002Zp-9V for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:51:35 +0000 X-Inumbo-ID: 38c5d266-e043-11e9-964d-12813bfff9fa Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id 38c5d266-e043-11e9-964d-12813bfff9fa; Thu, 26 Sep 2019 09:51: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=1569491494; x=1601027494; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=qEGCuo73XxRhiEqecnqitQbCBG76FFtj6v0UyuE/UME=; b=Hs1wRF/uUVt2FDKbhqQhV+5vGn6Wi/mxK5BePhX7cSZqyPY4t/gLjZPt Afa6ziTyDfxBxnZlGg76LvQw9fi1T0bM7bMbvCRTmy6Vj7bqdIRsVuZbB AUXKuO1lc3w87gGaXDdG1jRP8Js4B8AIkDeESf5+rE/hWtPJQM2LVP7HE Q=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="704637637" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1d-74cf8b49.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 26 Sep 2019 09:50:17 +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 F15DBC1332; Thu, 26 Sep 2019 09:49:58 +0000 (UTC) Received: from EX13D28EUC003.ant.amazon.com (10.43.164.43) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:42 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUC003.ant.amazon.com (10.43.164.43) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:41 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:49:38 +0000 From: To: Date: Thu, 26 Sep 2019 10:46: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] [RFC PATCH 74/84] x86/pv: refactor how building dom0 in PV handles domheap 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 , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Wei Liu , Jan Beulich , Hongyan Xia Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Building a PV dom0 is allocating from the domheap but uses it like the xenheap. This is clearly wrong. Fix. Signed-off-by: Hongyan Xia --- xen/arch/x86/pv/dom0_build.c | 40 ++++++++++++++++++++++++++---------- xen/include/asm-x86/mm.h | 1 + 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 15b3ca2191..0ec30988b8 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -623,7 +623,10 @@ int __init dom0_construct_pv(struct domain *d, if ( !is_pv_32bit_domain(d) ) { maddr_to_page(mpt_alloc)->u.inuse.type_info = PGT_l4_page_table; - l4start = l4tab = __va(mpt_alloc); mpt_alloc += PAGE_SIZE; + l4start = l4tab = __va(mpt_alloc); + map_pages_to_xen((unsigned long)l4start, maddr_to_mfn(mpt_alloc), 1, + PAGE_HYPERVISOR); + mpt_alloc += PAGE_SIZE; clear_page(l4tab); init_xen_l4_slots(l4tab, _mfn(virt_to_mfn(l4start)), d, INVALID_MFN, true); @@ -633,9 +636,12 @@ int __init dom0_construct_pv(struct domain *d, { /* Monitor table already created by switch_compat(). */ l4start = l4tab = __va(pagetable_get_paddr(v->arch.guest_table)); + map_pages_to_xen((unsigned long)l4start, + pagetable_get_mfn(v->arch.guest_table), 1, PAGE_HYPERVISOR); /* See public/xen.h on why the following is needed. */ maddr_to_page(mpt_alloc)->u.inuse.type_info = PGT_l3_page_table; - l3start = __va(mpt_alloc); mpt_alloc += PAGE_SIZE; + l3start = map_xen_pagetable(maddr_to_mfn(mpt_alloc)); + mpt_alloc += PAGE_SIZE; } l4tab += l4_table_offset(v_start); @@ -645,14 +651,18 @@ int __init dom0_construct_pv(struct domain *d, if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) ) { maddr_to_page(mpt_alloc)->u.inuse.type_info = PGT_l1_page_table; - l1start = l1tab = __va(mpt_alloc); mpt_alloc += PAGE_SIZE; + UNMAP_XEN_PAGETABLE(l1start); + l1start = l1tab = map_xen_pagetable(maddr_to_mfn(mpt_alloc)); + mpt_alloc += PAGE_SIZE; clear_page(l1tab); if ( count == 0 ) l1tab += l1_table_offset(v_start); if ( !((unsigned long)l2tab & (PAGE_SIZE-1)) ) { maddr_to_page(mpt_alloc)->u.inuse.type_info = PGT_l2_page_table; - l2start = l2tab = __va(mpt_alloc); mpt_alloc += PAGE_SIZE; + UNMAP_XEN_PAGETABLE(l2start); + l2start = l2tab = map_xen_pagetable(maddr_to_mfn(mpt_alloc)); + mpt_alloc += PAGE_SIZE; clear_page(l2tab); if ( count == 0 ) l2tab += l2_table_offset(v_start); @@ -662,19 +672,21 @@ int __init dom0_construct_pv(struct domain *d, { maddr_to_page(mpt_alloc)->u.inuse.type_info = PGT_l3_page_table; - l3start = __va(mpt_alloc); mpt_alloc += PAGE_SIZE; + UNMAP_XEN_PAGETABLE(l3start); + l3start = map_xen_pagetable(maddr_to_mfn(mpt_alloc)); + mpt_alloc += PAGE_SIZE; } l3tab = l3start; clear_page(l3tab); if ( count == 0 ) l3tab += l3_table_offset(v_start); - *l4tab = l4e_from_paddr(__pa(l3start), L4_PROT); + *l4tab = l4e_from_paddr(virt_to_maddr_walk(l3start), L4_PROT); l4tab++; } - *l3tab = l3e_from_paddr(__pa(l2start), L3_PROT); + *l3tab = l3e_from_paddr(virt_to_maddr_walk(l2start), L3_PROT); l3tab++; } - *l2tab = l2e_from_paddr(__pa(l1start), L2_PROT); + *l2tab = l2e_from_paddr(virt_to_maddr_walk(l1start), L2_PROT); l2tab++; } if ( count < initrd_pfn || count >= initrd_pfn + PFN_UP(initrd_len) ) @@ -701,9 +713,11 @@ int __init dom0_construct_pv(struct domain *d, if ( !l3e_get_intpte(*l3tab) ) { maddr_to_page(mpt_alloc)->u.inuse.type_info = PGT_l2_page_table; - l2tab = __va(mpt_alloc); mpt_alloc += PAGE_SIZE; - clear_page(l2tab); - *l3tab = l3e_from_paddr(__pa(l2tab), L3_PROT); + UNMAP_XEN_PAGETABLE(l2start); + l2start = map_xen_pagetable(maddr_to_mfn(mpt_alloc)); + mpt_alloc += PAGE_SIZE; + clear_page(l2start); + *l3tab = l3e_from_paddr(virt_to_maddr_walk(l2start), L3_PROT); } if ( i == 3 ) l3e_get_page(*l3tab)->u.inuse.type_info |= PGT_pae_xen_l2; @@ -714,6 +728,10 @@ int __init dom0_construct_pv(struct domain *d, UNMAP_XEN_PAGETABLE(l2t); } + UNMAP_XEN_PAGETABLE(l1start); + UNMAP_XEN_PAGETABLE(l2start); + UNMAP_XEN_PAGETABLE(l3start); + /* Pages that are part of page tables must be read only. */ mark_pv_pt_pages_rdonly(d, l4start, vpt_start, nr_pt_pages); diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 76ba56bdc3..e5819cbfdf 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -645,6 +645,7 @@ void free_xen_pagetable(mfn_t mfn); l1_pgentry_t *virt_to_xen_l1e(unsigned long v); unsigned long virt_to_mfn_walk(void *va); struct page_info *virt_to_page_walk(void *va); +#define virt_to_maddr_walk(va) mfn_to_maddr(_mfn(virt_to_mfn_walk(va))) DECLARE_PER_CPU(mfn_t, root_pgt_mfn); From patchwork Thu Sep 26 09:46: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: 11162211 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 1B8A713BD for ; Thu, 26 Sep 2019 09:52: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 EC49D2053B for ; Thu, 26 Sep 2019 09:52: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="d1+vRJUv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC49D2053B 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 1iDQR4-0002jr-9p; Thu, 26 Sep 2019 09:51: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 1iDQR2-0002hC-A7 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:51:40 +0000 X-Inumbo-ID: 39ff7e7a-e043-11e9-964d-12813bfff9fa Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id 39ff7e7a-e043-11e9-964d-12813bfff9fa; Thu, 26 Sep 2019 09:51: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=1569491495; x=1601027495; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=FLP1Pjfg7I76yn1/Mf5e4V7h1NEQgm8sbRL2xI1/ZvQ=; b=d1+vRJUv8eHaKuLH+hiGppEJxXTGaZTRWijRZxBKQznM0NVJp06jrdNq UHZPARY0kZhRFDQsVJrSBnzGE+Ey44KOA8zwA82UXd2DE6k4qrrvqn7ym PX1bfazfDTNd8m8HTK/5GpCzx8Y6LYvut9v/opHWJbjGyHatMp5SySgWS w=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="704637634" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1a-715bee71.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 26 Sep 2019 09:50:16 +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-715bee71.us-east-1.amazon.com (Postfix) with ESMTPS id 8A8E4A2343; Thu, 26 Sep 2019 09:50:01 +0000 (UTC) Received: from EX13D28EUB003.ant.amazon.com (10.43.166.124) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:46 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUB003.ant.amazon.com (10.43.166.124) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:45 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:49:42 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:38 +0100 Message-ID: <5e135be6b8754ddfa24560eec8c5d1254dba34ae.1569489002.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] [RFC PATCH 75/84] x86/mm: handle PSE early termination cases in virt_to_mfn_walk(). 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 , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Wei Liu , Jan Beulich , Hongyan Xia Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Signed-off-by: Hongyan Xia --- xen/arch/x86/mm.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index ab760ecc1f..39ba9f9bf4 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5058,8 +5058,40 @@ l1_pgentry_t *virt_to_xen_l1e(unsigned long v) unsigned long virt_to_mfn_walk(void *va) { - l1_pgentry_t *pl1e = virt_to_xen_l1e((unsigned long)(va)); - unsigned long ret = l1e_get_pfn(*pl1e); + unsigned long ret; + l3_pgentry_t *pl3e; + l2_pgentry_t *pl2e; + l1_pgentry_t *pl1e; + + /* + * FIXME: This is rather unoptimised, because e.g. virt_to_xen_l2e + * recomputes virt_to_xen_l3e again. Clearly one can keep the result and + * carry on. + */ + + pl3e = virt_to_xen_l3e((unsigned long)(va)); + BUG_ON(!(l3e_get_flags(*pl3e) & _PAGE_PRESENT)); + if ( l3e_get_flags(*pl3e) & _PAGE_PSE ) + { + ret = l3e_get_pfn(*pl3e); + ret |= (((unsigned long)va & ((1UL << L3_PAGETABLE_SHIFT)-1)) >> PAGE_SHIFT); + unmap_xen_pagetable(pl3e); + return ret; + } + + pl2e = virt_to_xen_l2e((unsigned long)(va)); + BUG_ON(!(l2e_get_flags(*pl2e) & _PAGE_PRESENT)); + if ( l2e_get_flags(*pl2e) & _PAGE_PSE ) + { + ret = l2e_get_pfn(*pl2e); + ret |= (((unsigned long)va & ((1UL << L2_PAGETABLE_SHIFT)-1)) >> PAGE_SHIFT); + unmap_xen_pagetable(pl2e); + return ret; + } + + pl1e = virt_to_xen_l1e((unsigned long)(va)); + BUG_ON(!(l1e_get_flags(*pl1e) & _PAGE_PRESENT)); + ret = l1e_get_pfn(*pl1e); unmap_xen_pagetable(pl1e); return ret; } From patchwork Thu Sep 26 09:46: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: 11162187 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 4FE3C1709 for ; Thu, 26 Sep 2019 09:51: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 2C638222C2 for ; Thu, 26 Sep 2019 09:51: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="aLxpylX5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C638222C2 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 1iDQPz-0000bb-2F; Thu, 26 Sep 2019 09:50: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 1iDQPx-0000YU-Ls for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:33 +0000 X-Inumbo-ID: 0c89a4b6-e043-11e9-b588-bc764e2007e4 Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id 0c89a4b6-e043-11e9-b588-bc764e2007e4; Thu, 26 Sep 2019 09:50: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=1569491418; x=1601027418; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=h8UJCEQDp86ZrC/JZ2cINLB5PckAhlkYWAg3GFXzyuA=; b=aLxpylX5bw6w+FNLTz7QwOxMqwZe8oYr3xtL/029Z/7qMooNZJMII7WG ehKxC8+DvKs+DC5PDvOf4Kg+y+Z3P7zeqIoQIWvIM2esqloITMGppMaDe re72KNPLru1mqlk0ggDWkVfVPg6henfQUeHFPPjwoLxzSD3vh4BLB233w 4=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="753354483" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1d-98acfc19.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 26 Sep 2019 09:50: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-1d-98acfc19.us-east-1.amazon.com (Postfix) with ESMTPS id 47922A1F9D; Thu, 26 Sep 2019 09:50:17 +0000 (UTC) Received: from EX13D28EUB004.ant.amazon.com (10.43.166.176) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:50 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUB004.ant.amazon.com (10.43.166.176) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:49 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:49:46 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:39 +0100 Message-ID: <50268efd2bd6bdf4e1508218e7f1ec9b8776ea72.1569489002.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] [RFC PATCH 76/84] x86/setup: also clear the permission bits in the dummy 1:1 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 , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Wei Liu , Jan Beulich , Hongyan Xia Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Signed-off-by: Hongyan Xia --- xen/arch/x86/setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 3dc2fad987..9015e3b723 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1368,7 +1368,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) if ( map_e < end ) { map_pages_to_xen((unsigned long)__va(map_e), INVALID_MFN, - PFN_DOWN(end - map_e), PAGE_HYPERVISOR); + PFN_DOWN(end - map_e), _PAGE_NONE); init_boot_pages(map_e, end); map_e = end; } @@ -1383,7 +1383,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) if ( s < map_s ) { map_pages_to_xen((unsigned long)__va(s), INVALID_MFN, - PFN_DOWN(map_s - s), PAGE_HYPERVISOR); + PFN_DOWN(map_s - s), _PAGE_NONE); init_boot_pages(s, map_s); } } From patchwork Thu Sep 26 09:46: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: 11162191 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 0990813BD for ; Thu, 26 Sep 2019 09:51: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 D9F832053B for ; Thu, 26 Sep 2019 09:51: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="NDAiXiSK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D9F832053B 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 1iDQQ5-0000qI-Mq; Thu, 26 Sep 2019 09:50: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 1iDQQ2-0000jT-LP for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:38 +0000 X-Inumbo-ID: 0e7fd56a-e043-11e9-b588-bc764e2007e4 Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id 0e7fd56a-e043-11e9-b588-bc764e2007e4; Thu, 26 Sep 2019 09:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491422; x=1601027422; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=+1jLygSDyv4GFQENO5qpV0Y2nFg1v//DHVeDCSUFn/g=; b=NDAiXiSKfqZTaxKhvvItUUqMB+IQIPWe80Mu1q1v7CsMQEyU/cp35Neb C8tMCcH6B5frX7M0j89HFshFN5Az/OwQBPgVFdCJXwIwXAI9Q+IkpS8fB 0kZwGh1APQqNXZbtlkh+Nk0cjFNdYaPfiCOkMIBc02hlIAdAEsqKku2r4 4=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="753354491" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1a-af6a10df.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 26 Sep 2019 09:50:22 +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 8FB9BA0702; Thu, 26 Sep 2019 09:50:20 +0000 (UTC) Received: from EX13D28EUC003.ant.amazon.com (10.43.164.43) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:54 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUC003.ant.amazon.com (10.43.164.43) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:52 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:49:50 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:40 +0100 Message-ID: <450fcebd6ad4cbf0b078070149b9287260bdc0a3.1569489002.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] [RFC PATCH 77/84] x86: properly (un)map pages in restore_all_guests. 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 , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Wei Liu , Jan Beulich , Hongyan Xia Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Before, it assumed both cr3 could be accessed via a direct map. This is no longer true. Also, this means we can remove a xenheap mapping hack we introduced earlier when building the cr3 of dom0. Signed-off-by: Hongyan Xia --- xen/arch/x86/pv/dom0_build.c | 11 +++++------ xen/arch/x86/x86_64/entry.S | 32 +++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 0ec30988b8..202edcaa17 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -623,9 +623,7 @@ int __init dom0_construct_pv(struct domain *d, if ( !is_pv_32bit_domain(d) ) { maddr_to_page(mpt_alloc)->u.inuse.type_info = PGT_l4_page_table; - l4start = l4tab = __va(mpt_alloc); - map_pages_to_xen((unsigned long)l4start, maddr_to_mfn(mpt_alloc), 1, - PAGE_HYPERVISOR); + l4start = l4tab = map_xen_pagetable(maddr_to_mfn(mpt_alloc)); mpt_alloc += PAGE_SIZE; clear_page(l4tab); init_xen_l4_slots(l4tab, _mfn(virt_to_mfn(l4start)), @@ -635,9 +633,8 @@ int __init dom0_construct_pv(struct domain *d, else { /* Monitor table already created by switch_compat(). */ - l4start = l4tab = __va(pagetable_get_paddr(v->arch.guest_table)); - map_pages_to_xen((unsigned long)l4start, - pagetable_get_mfn(v->arch.guest_table), 1, PAGE_HYPERVISOR); + l4start = l4tab = + map_xen_pagetable(pagetable_get_mfn(v->arch.guest_table)); /* See public/xen.h on why the following is needed. */ maddr_to_page(mpt_alloc)->u.inuse.type_info = PGT_l3_page_table; l3start = map_xen_pagetable(maddr_to_mfn(mpt_alloc)); @@ -907,6 +904,8 @@ int __init dom0_construct_pv(struct domain *d, pv_shim_setup_dom(d, l4start, v_start, vxenstore_start, vconsole_start, vphysmap_start, si); + UNMAP_XEN_PAGETABLE(l4start); + if ( is_pv_32bit_domain(d) ) xlat_start_info(si, pv_shim ? XLAT_start_info_console_domU : XLAT_start_info_console_dom0); diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S index 11385857fa..8ca9a8e0ea 100644 --- a/xen/arch/x86/x86_64/entry.S +++ b/xen/arch/x86/x86_64/entry.S @@ -150,11 +150,27 @@ restore_all_guest: je .Lrag_copy_done movb $0, STACK_CPUINFO_FIELD(root_pgt_changed)(%rdx) movabs $PADDR_MASK & PAGE_MASK, %rsi - movabs $DIRECTMAP_VIRT_START, %rcx and %rsi, %rdi and %r9, %rsi - add %rcx, %rdi - add %rcx, %rsi + + /* Without a direct map, we have to map pages first before copying. */ + /* FIXME: optimisations may be needed. */ + pushq %r9 + pushq %rdx + pushq %rax + pushq %rsi + shr $PAGE_SHIFT, %rdi + callq map_xen_pagetable + popq %rdi + pushq %rax + shr $PAGE_SHIFT, %rdi + callq map_xen_pagetable + mov %rax, %rsi + mov 0(%rsp), %rdi + + /* %rsi and %rdi are on top the stack for unmapping. */ + pushq %rsi + mov $ROOT_PAGETABLE_FIRST_XEN_SLOT, %ecx mov root_table_offset(SH_LINEAR_PT_VIRT_START)*8(%rsi), %r8 mov %r8, root_table_offset(SH_LINEAR_PT_VIRT_START)*8(%rdi) @@ -166,6 +182,16 @@ restore_all_guest: sub $(ROOT_PAGETABLE_FIRST_XEN_SLOT - \ ROOT_PAGETABLE_LAST_XEN_SLOT - 1) * 8, %rdi rep movsq + + /* Unmap the two pages. */ + popq %rdi + callq unmap_xen_pagetable + popq %rdi + callq unmap_xen_pagetable + popq %rax + popq %rdx + popq %r9 + .Lrag_copy_done: mov %r9, STACK_CPUINFO_FIELD(xen_cr3)(%rdx) movb $1, STACK_CPUINFO_FIELD(use_pv_cr3)(%rdx) From patchwork Thu Sep 26 09:46: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: 11162215 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 C708713BD for ; Thu, 26 Sep 2019 09:52: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 A2CE8222C0 for ; Thu, 26 Sep 2019 09:52: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="PjKzf6xX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2CE8222C0 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 1iDQRE-0002yD-5J; Thu, 26 Sep 2019 09:51:52 +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 1iDQRC-0002ve-EE for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:51:50 +0000 X-Inumbo-ID: 4202aa34-e043-11e9-964d-12813bfff9fa Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id 4202aa34-e043-11e9-964d-12813bfff9fa; Thu, 26 Sep 2019 09:51:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491509; x=1601027509; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=ekZ3PcHMk4uKY0DEmsTYP5mEVLITbkETFNx6DlWLxjQ=; b=PjKzf6xXRJUcIM0AiOLpftMiYvvlVf+qFZNnPFgZ19LehZRb5kGEHmU7 5E8GXzF7PhydhDHXok+4zFDDhyr2kwvQ+JkUCk1DTKl7apX7mwqsCq+Dn rGFx5tQwxOqRkFm7ry8Q+M8Qh2bk1WwXW2Hpu2AejeOZjAuT60mAw32v6 M=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="704637681" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1d-38ae4ad2.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 26 Sep 2019 09:50: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-38ae4ad2.us-east-1.amazon.com (Postfix) with ESMTPS id C1A52A2840; Thu, 26 Sep 2019 09:50:21 +0000 (UTC) Received: from EX13D28EUB002.ant.amazon.com (10.43.166.97) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:57 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUB002.ant.amazon.com (10.43.166.97) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:56 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:49:53 +0000 From: To: Date: Thu, 26 Sep 2019 10:46: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] [RFC PATCH 78/84] Revert "x86/smpboot: use xenheap pages for rpts in smpboot." 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 , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Wei Liu , Jan Beulich , Hongyan Xia Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia We have properly handled (un)mapping of pages in restore_all_guests. This hack is no longer required. Signed-off-by: Hongyan Xia --- xen/arch/x86/smpboot.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 7034c699d6..53f9173f37 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -832,20 +832,14 @@ static int setup_cpu_root_pgt(unsigned int cpu) goto out; } - /* - * Unfortunately, some code (especially in assembly) assumes the rpt is in - * the DIRECTMAP region and is always mapped. Making all of them adapt to - * the new page table APIs is non-trivial. For now, make it always mapped - * on the xenheap. - */ - rpt = alloc_xenheap_page(); - if ( !rpt ) + rpt_mfn = alloc_xen_pagetable(); + if ( mfn_eq(rpt_mfn, INVALID_MFN) ) { rc = -ENOMEM; goto out; } - rpt_mfn = _mfn(virt_to_mfn(rpt)); + rpt = map_xen_pagetable(rpt_mfn); clear_page(rpt); per_cpu(root_pgt_mfn, cpu) = rpt_mfn; @@ -890,6 +884,7 @@ static int setup_cpu_root_pgt(unsigned int cpu) rc = clone_mapping((void *)per_cpu(stubs.addr, cpu), rpt); out: + UNMAP_XEN_PAGETABLE(rpt); return rc; } @@ -905,7 +900,7 @@ static void cleanup_cpu_root_pgt(unsigned int cpu) per_cpu(root_pgt_mfn, cpu) = INVALID_MFN; - rpt = mfn_to_virt(mfn_x(rpt_mfn)); + rpt = map_xen_pagetable(rpt_mfn); for ( r = root_table_offset(DIRECTMAP_VIRT_START); r < root_table_offset(HYPERVISOR_VIRT_END); ++r ) @@ -950,8 +945,8 @@ static void cleanup_cpu_root_pgt(unsigned int cpu) free_xen_pagetable(l3t_mfn); } - /* Unlike other levels, the root level is a xenheap page. */ - free_xenheap_page(rpt); + UNMAP_XEN_PAGETABLE(rpt); + free_xen_pagetable(rpt_mfn); /* Also zap the stub mapping for this CPU. */ if ( stub_linear ) From patchwork Thu Sep 26 09:46: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: 11162221 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 8AB7F13BD for ; Thu, 26 Sep 2019 09:53: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 656BA2053B for ; Thu, 26 Sep 2019 09:53: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="uycXVr/Q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 656BA2053B 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 1iDQS5-0003kY-FM; Thu, 26 Sep 2019 09:52: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 1iDQS3-0003jd-Sy for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:52:43 +0000 X-Inumbo-ID: 620e9839-e043-11e9-964d-12813bfff9fa Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 620e9839-e043-11e9-964d-12813bfff9fa; Thu, 26 Sep 2019 09:52: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=1569491563; x=1601027563; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=rYvzmeotaaJgW6qlOTM/rr72px2cLcmGMqr3gdxHDvU=; b=uycXVr/QfYo1UOG2ruuinl3Xr3UAUuktbEzYHZPu+4mYe+C7s+3s54gx Eq7SIiWAqBU1guKumgzS5gr96j2YarbK4Pm74BokYgam9KqSKHU7pISsH OFaGc0/lLg2H9QT7v1KZOQg/ZvoKaHFg6hzBYtwefadngnyWthjKA/ydE Q=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836989337" 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; 26 Sep 2019 09:50:42 +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 D3A90A26C9; Thu, 26 Sep 2019 09:50:26 +0000 (UTC) Received: from EX13D28EUC001.ant.amazon.com (10.43.164.4) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:50:02 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUC001.ant.amazon.com (10.43.164.4) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:50:01 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:49:57 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:42 +0100 Message-ID: <96f10f9693fdc795152a7f24c6df65f7f345b0f4.1569489002.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] [RFC PATCH 79/84] Don't assume bootmem_region_list is mapped. Also fix a double unmap bug. 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: Stefano Stabellini , Wei Liu , Hongyan Xia , George Dunlap , Andrew Cooper , Konrad Rzeszutek Wilk , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Signed-off-by: Hongyan Xia --- xen/arch/x86/pv/dom0_build.c | 2 +- xen/common/page_alloc.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 202edcaa17..1555a61b84 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -236,7 +236,7 @@ static __init void setup_pv_physmap(struct domain *d, unsigned long pgtbl_pfn, if ( pl3e ) unmap_domain_page(pl3e); - unmap_domain_page(l4start); + //unmap_domain_page(l4start); } static struct page_info * __init alloc_chunk(struct domain *d, diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index deeeac065c..6acc1c78a4 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -247,6 +247,7 @@ mfn_t first_valid_mfn = INVALID_MFN_INITIALIZER; static struct bootmem_region { unsigned long s, e; /* MFNs @s through @e-1 inclusive are free */ } *__initdata bootmem_region_list; +struct page_info *bootmem_region_list_pg; static unsigned int __initdata nr_bootmem_regions; struct scrub_region { @@ -264,7 +265,11 @@ static void __init bootmem_region_add(unsigned long s, unsigned long e) unsigned int i; if ( (bootmem_region_list == NULL) && (s < e) ) - bootmem_region_list = mfn_to_virt(s++); + { + bootmem_region_list_pg = mfn_to_page(_mfn(s)); + bootmem_region_list = map_domain_page(_mfn(s)); + s++; + } if ( s >= e ) return; @@ -1869,7 +1874,10 @@ void __init end_boot_allocator(void) init_heap_pages(mfn_to_page(_mfn(r->s)), r->e - r->s); } nr_bootmem_regions = 0; - init_heap_pages(virt_to_page(bootmem_region_list), 1); + init_heap_pages(bootmem_region_list_pg, 1); + /* Remember to discard the mapping for bootmem_region_list. */ + unmap_domain_page(bootmem_region_list); + flush_tlb_one_local(bootmem_region_list); if ( !dma_bitsize && (num_online_nodes() > 1) ) dma_bitsize = arch_get_dma_bitsize(); From patchwork Thu Sep 26 09:46: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: 11162195 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 EF66813BD for ; Thu, 26 Sep 2019 09:51: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 CB97E2053B for ; Thu, 26 Sep 2019 09:51: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="Obc0RyPS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB97E2053B 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 1iDQQE-0001AD-Pb; Thu, 26 Sep 2019 09:50:50 +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 1iDQQ9-0000ze-W6 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:46 +0000 X-Inumbo-ID: 1a310348-e043-11e9-964c-12813bfff9fa Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id 1a310348-e043-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491441; x=1601027441; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=+D3aSBpu/9jGRBhfqGVbSAXhO++vMOcqH3ZAlDGs2+w=; b=Obc0RyPSQiQCt90QNpGKb4SiiHDxtsGCHs/MiiKZxIHlT/wYqvOgwQWc L37aFnrcZbldDwMh9SFALjwSPDRxJgRRzE6D/auectgdcftJRO900yStT SVzzr+rsEa13P869bYlBf0gqFANgLv98sYPV7dpZ+nmERvsE8cVc12dNo Y=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="787535493" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-67b371d8.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 26 Sep 2019 09:50: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-1a-67b371d8.us-east-1.amazon.com (Postfix) with ESMTPS id 2B4CDA05FE; Thu, 26 Sep 2019 09:50:40 +0000 (UTC) Received: from EX13D28EUC003.ant.amazon.com (10.43.164.43) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:50:06 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUC003.ant.amazon.com (10.43.164.43) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:50:04 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:50:02 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:43 +0100 Message-ID: <969374c5a1c62eabb329694092d551b04d77b8be.1569489002.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] [RFC PATCH 80/84] x86/setup: Install dummy 1:1 mappings for all mem passed to allocators. 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 , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Wei Liu , Jan Beulich , Hongyan Xia Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia This means we no longer have an always-mapped direct map now. Signed-off-by: Hongyan Xia --- xen/arch/x86/setup.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 9015e3b723..e6a3f1e0a1 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -240,7 +240,9 @@ void __init discard_initial_images(void) uint64_t start = (uint64_t)initial_images[i].mod_start << PAGE_SHIFT; init_domheap_pages(start, - start + PAGE_ALIGN(initial_images[i].mod_end)); + start + PAGE_ALIGN(initial_images[i].mod_end)); + map_pages_to_xen((unsigned long)__va(start), INVALID_MFN, + PFN_DOWN(PAGE_ALIGN(initial_images[i].mod_end)), _PAGE_NONE); } nr_initial_images = 0; @@ -1346,6 +1348,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) /* Pass mapped memory to allocator /before/ creating new mappings. */ init_boot_pages(s, min(map_s, e)); + map_pages_to_xen((unsigned long)__va(s), INVALID_MFN, + PFN_DOWN(min(map_s, e) - s), _PAGE_NONE); s = map_s; if ( s < map_e ) { @@ -1354,6 +1358,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) map_s = (s + mask) & ~mask; map_e &= ~mask; init_boot_pages(map_s, map_e); + map_pages_to_xen((unsigned long)__va(map_s), INVALID_MFN, + PFN_DOWN(map_e - map_s), _PAGE_NONE); } if ( map_s > map_e ) @@ -1367,9 +1373,9 @@ void __init noreturn __start_xen(unsigned long mbi_p) if ( map_e < end ) { + init_boot_pages(map_e, end); map_pages_to_xen((unsigned long)__va(map_e), INVALID_MFN, PFN_DOWN(end - map_e), _PAGE_NONE); - init_boot_pages(map_e, end); map_e = end; } } @@ -1382,9 +1388,9 @@ void __init noreturn __start_xen(unsigned long mbi_p) } if ( s < map_s ) { + init_boot_pages(s, map_s); map_pages_to_xen((unsigned long)__va(s), INVALID_MFN, PFN_DOWN(map_s - s), _PAGE_NONE); - init_boot_pages(s, map_s); } } @@ -1506,6 +1512,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) if ( PFN_DOWN(s) <= limit ) s = pfn_to_paddr(limit + 1); init_domheap_pages(s, e); + map_pages_to_xen((unsigned long)__va(s), INVALID_MFN, + PFN_DOWN(e - s), _PAGE_NONE); } } else From patchwork Thu Sep 26 09:46: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: 11162197 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 B220213BD for ; Thu, 26 Sep 2019 09:51:44 +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 8DFA82053B for ; Thu, 26 Sep 2019 09:51:44 +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="kApuKHNq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DFA82053B 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 1iDQQJ-0001Kp-Em; Thu, 26 Sep 2019 09:50:55 +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 1iDQQE-0001Aw-VB for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:50 +0000 X-Inumbo-ID: 1eec13be-e043-11e9-964c-12813bfff9fa Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id 1eec13be-e043-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:50:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491449; x=1601027449; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=kXHcgiUvuLHbcZv8fnxbRiyV9RFWhHe9YC9kc1lD21c=; b=kApuKHNqTXBAwCu7gg1waklXLZqp18XaTQIAKv11IwlkUZyr8blE0GO9 faja+14OE2cxq1OcOlCucfdrlZ6UmYwNnUDevV96AxprAUGB9ux30GrMq jdjg49tYtpIR3Er+BcPMItkmGJqGek3356kFOMUUuGCPlLCQ0/rIqIYds s=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="787535511" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-27fb8269.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 26 Sep 2019 09:50:49 +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 1A89BA1D79; Thu, 26 Sep 2019 09:50:48 +0000 (UTC) Received: from EX13D28EUB003.ant.amazon.com (10.43.166.124) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:50:10 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUB003.ant.amazon.com (10.43.166.124) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:50:08 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:50:06 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:44 +0100 Message-ID: <08be36e125433c438191fa17bbdaed5b50088530.1569489002.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] [RFC PATCH 81/84] x86/mm: optimise and properly unmap pages in virt_to_mfn_walk(). 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 , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Wei Liu , Jan Beulich , Hongyan Xia Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia This also resolves a mapcache overflow bug. Signed-off-by: Hongyan Xia --- xen/arch/x86/mm.c | 57 +++++++++++++++++++++++++--------------- xen/include/asm-x86/mm.h | 3 ++- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 39ba9f9bf4..f3c9042ba6 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5056,42 +5056,57 @@ l1_pgentry_t *virt_to_xen_l1e(unsigned long v) return pl1e; } +/* + * Unlike virt_to_mfn() which just translates between the direct map and the + * mfn, this version actually walks the page table to find the mfn of any + * virtual address, as long as it is mapped. If not, INVALID_MFN is returned. + */ unsigned long virt_to_mfn_walk(void *va) { unsigned long ret; - l3_pgentry_t *pl3e; - l2_pgentry_t *pl2e; - l1_pgentry_t *pl1e; - - /* - * FIXME: This is rather unoptimised, because e.g. virt_to_xen_l2e - * recomputes virt_to_xen_l3e again. Clearly one can keep the result and - * carry on. - */ + unsigned long v = (unsigned long)va; + l3_pgentry_t *pl3e = NULL; + l2_pgentry_t *pl2e = NULL; + l1_pgentry_t *pl1e = NULL; - pl3e = virt_to_xen_l3e((unsigned long)(va)); - BUG_ON(!(l3e_get_flags(*pl3e) & _PAGE_PRESENT)); + pl3e = virt_to_xen_l3e(v); + if ( !pl3e || !(l3e_get_flags(*pl3e) & _PAGE_PRESENT) ) + { + ret = mfn_x(INVALID_MFN); + goto out; + } if ( l3e_get_flags(*pl3e) & _PAGE_PSE ) { ret = l3e_get_pfn(*pl3e); - ret |= (((unsigned long)va & ((1UL << L3_PAGETABLE_SHIFT)-1)) >> PAGE_SHIFT); - unmap_xen_pagetable(pl3e); - return ret; + ret |= ((v & ((1UL << L3_PAGETABLE_SHIFT)-1)) >> PAGE_SHIFT); + goto out; } - pl2e = virt_to_xen_l2e((unsigned long)(va)); - BUG_ON(!(l2e_get_flags(*pl2e) & _PAGE_PRESENT)); + pl2e = (l2_pgentry_t *)map_xen_pagetable(l3e_get_mfn(*pl3e)) + + l2_table_offset(v); + if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) ) + { + ret = mfn_x(INVALID_MFN); + goto out; + } if ( l2e_get_flags(*pl2e) & _PAGE_PSE ) { ret = l2e_get_pfn(*pl2e); - ret |= (((unsigned long)va & ((1UL << L2_PAGETABLE_SHIFT)-1)) >> PAGE_SHIFT); - unmap_xen_pagetable(pl2e); - return ret; + ret |= ((v & ((1UL << L2_PAGETABLE_SHIFT)-1)) >> PAGE_SHIFT); + goto out; } - pl1e = virt_to_xen_l1e((unsigned long)(va)); - BUG_ON(!(l1e_get_flags(*pl1e) & _PAGE_PRESENT)); + pl1e = (l1_pgentry_t *)map_xen_pagetable(l2e_get_mfn(*pl2e)) + + l1_table_offset(v); + if ( !(l1e_get_flags(*pl1e) & _PAGE_PRESENT) ) + { + ret = mfn_x(INVALID_MFN); + goto out; + } ret = l1e_get_pfn(*pl1e); +out: + unmap_xen_pagetable(pl3e); + unmap_xen_pagetable(pl2e); unmap_xen_pagetable(pl1e); return ret; } diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index e5819cbfdf..411737207f 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -645,7 +645,8 @@ void free_xen_pagetable(mfn_t mfn); l1_pgentry_t *virt_to_xen_l1e(unsigned long v); unsigned long virt_to_mfn_walk(void *va); struct page_info *virt_to_page_walk(void *va); -#define virt_to_maddr_walk(va) mfn_to_maddr(_mfn(virt_to_mfn_walk(va))) +#define virt_to_maddr_walk(va) (mfn_to_maddr(_mfn(virt_to_mfn_walk(va))) | \ + ((unsigned long)va & (PAGE_SIZE - 1))) DECLARE_PER_CPU(mfn_t, root_pgt_mfn); From patchwork Thu Sep 26 09:46: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: 11162199 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 447DF13B1 for ; Thu, 26 Sep 2019 09:51: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 207B52053B for ; Thu, 26 Sep 2019 09:51: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="Ua3MS6ur" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 207B52053B 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 1iDQQM-0001Rn-JE; Thu, 26 Sep 2019 09:50:58 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iDQQJ-0001Ka-6l for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:55 +0000 X-Inumbo-ID: 21d1bdcc-e043-11e9-bf31-bc764e2007e4 Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by localhost (Halon) with ESMTPS id 21d1bdcc-e043-11e9-bf31-bc764e2007e4; Thu, 26 Sep 2019 09:50: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=1569491454; x=1601027454; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=EWA3h2guB9NBCcDuy07jNu66y3K3A4xPKuQuLcY6GoU=; b=Ua3MS6urZubWVLuZ4eHMMSV5RNLAxVW7lnBU3N3Ya89EcIXg0eT99Zxp 7g9Bslv81/3sCzk0OHiL6J5DKOjLTXEBt7LY96bebP5nBcLDeAZ/GepV9 z+qdjH21Bjg0OvJ4qWTljkrLkEJtG9qLLMK7Aoo/XFXvh74dKjYmoJL6A 4=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="417788627" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-97fdccfd.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 26 Sep 2019 09:50: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-97fdccfd.us-east-1.amazon.com (Postfix) with ESMTPS id CEFD3A1E17; Thu, 26 Sep 2019 09:50:52 +0000 (UTC) Received: from EX13D28EUB004.ant.amazon.com (10.43.166.176) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:50:13 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUB004.ant.amazon.com (10.43.166.176) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:50:12 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:50:09 +0000 From: To: Date: Thu, 26 Sep 2019 10:46: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] [RFC PATCH 82/84] x86: deduplicate code a bit and fix an unmapping bug. 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 , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Wei Liu , Jan Beulich , Hongyan Xia Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Signed-off-by: Hongyan Xia --- xen/arch/x86/domain_page.c | 28 +++++++++++----------------- xen/arch/x86/pv/dom0_build.c | 2 +- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c index f606677ae6..782dd0650c 100644 --- a/xen/arch/x86/domain_page.c +++ b/xen/arch/x86/domain_page.c @@ -77,29 +77,16 @@ void *map_domain_page(mfn_t mfn) struct mapcache_domain *dcache; struct mapcache_vcpu *vcache; struct vcpu_maphash_entry *hashent; + void *ret; v = mapcache_current_vcpu(); if ( !v ) - { - void *ret; - pmap_lock(); - ret = pmap_map(mfn); - pmap_unlock(); - flush_tlb_one_local(ret); - return ret; - } + goto pmap; dcache = &v->domain->arch.mapcache; vcache = &v->arch.mapcache; if ( !dcache->inuse ) - { - void *ret; - pmap_lock(); - ret = pmap_map(mfn); - pmap_unlock(); - flush_tlb_one_local(ret); - return ret; - } + goto pmap; perfc_incr(map_domain_page_count); @@ -179,9 +166,16 @@ void *map_domain_page(mfn_t mfn) l1e_write(&MAPCACHE_L1ENT(idx), l1e_from_mfn(mfn, __PAGE_HYPERVISOR_RW)); - out: +out: local_irq_restore(flags); return (void *)MAPCACHE_VIRT_START + pfn_to_paddr(idx); + +pmap: + pmap_lock(); + ret = pmap_map(mfn); + pmap_unlock(); + flush_tlb_one_local(ret); + return ret; } void unmap_domain_page(const void *ptr) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 1555a61b84..202edcaa17 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -236,7 +236,7 @@ static __init void setup_pv_physmap(struct domain *d, unsigned long pgtbl_pfn, if ( pl3e ) unmap_domain_page(pl3e); - //unmap_domain_page(l4start); + unmap_domain_page(l4start); } static struct page_info * __init alloc_chunk(struct domain *d, From patchwork Thu Sep 26 09:46: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: 11162203 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 5F1351709 for ; Thu, 26 Sep 2019 09:51: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 3B4D8222C2 for ; Thu, 26 Sep 2019 09:51: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="qF96qfJD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B4D8222C2 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 1iDQQQ-0001Zp-1g; Thu, 26 Sep 2019 09:51:02 +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 1iDQQL-0001PD-89 for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:57 +0000 X-Inumbo-ID: 2330c38e-e043-11e9-964c-12813bfff9fa Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by localhost (Halon) with ESMTPS id 2330c38e-e043-11e9-964c-12813bfff9fa; Thu, 26 Sep 2019 09:50:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491456; x=1601027456; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=LDyYzg3DfaKc88izlDhVAvNjYE+nmpb1QGtOx4rbMSo=; b=qF96qfJDRqXBVLsGGGM3wjJkN+crY7W0hSndoOcyn62xPf8PVR49pqYC Wkv/ebd9eKFsSv38T/Ko5BbxlGyR2ODCW+c8p1fURJC1j6nHswWfJnKz0 47vVQsEYehnV/1VRjbQfihsO5nCqxV8GU+vGpUkzqliMWu8+bxPhy/Iyc 8=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="753354562" 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; 26 Sep 2019 09:50: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-57e1d233.us-east-1.amazon.com (Postfix) with ESMTPS id 7F35A1417B8; Thu, 26 Sep 2019 09:50:54 +0000 (UTC) Received: from EX13D28EUB002.ant.amazon.com (10.43.166.97) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:50:17 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUB002.ant.amazon.com (10.43.166.97) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:50:16 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:50:13 +0000 From: To: Date: Thu, 26 Sep 2019 10:46: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] [RFC PATCH 83/84] x86/pmap: rewrite logic for locking. 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 , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Wei Liu , Jan Beulich , Hongyan Xia Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Due to the limited PMAP entries, another pCPU is allowed to use PMAP only when the current pCPU has unmapped all mappings. Signed-off-by: Hongyan Xia --- xen/arch/x86/domain_page.c | 4 ---- xen/arch/x86/pmap.c | 48 ++++++++++++++++++++++++++++++++------ xen/include/asm-x86/pmap.h | 2 -- 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c index 782dd0650c..189ca41a1d 100644 --- a/xen/arch/x86/domain_page.c +++ b/xen/arch/x86/domain_page.c @@ -171,9 +171,7 @@ out: return (void *)MAPCACHE_VIRT_START + pfn_to_paddr(idx); pmap: - pmap_lock(); ret = pmap_map(mfn); - pmap_unlock(); flush_tlb_one_local(ret); return ret; } @@ -188,9 +186,7 @@ void unmap_domain_page(const void *ptr) if ( va >= FIXADDR_START && va < FIXADDR_TOP ) { - pmap_lock(); pmap_unmap((void *)ptr); - pmap_unlock(); return; } diff --git a/xen/arch/x86/pmap.c b/xen/arch/x86/pmap.c index 93104d0b86..af7438cbe4 100644 --- a/xen/arch/x86/pmap.c +++ b/xen/arch/x86/pmap.c @@ -15,18 +15,44 @@ * used anywhere else other than the stated purpose above. */ -static DEFINE_SPINLOCK(lock); +static DEFINE_SPINLOCK(lock_cpu); /* Bitmap to track which slot is used */ static unsigned long inuse; -void pmap_lock(void) +static unsigned int lock_cpu_id = ~0; +static unsigned int lock_count; + +/* + * Only one pCPU is allowed to use PMAP entries. Another pCPU can use PMAP only + * when the current pCPU has unmapped all entries. + */ +static void pmap_cpu_up(void) { - spin_lock(&lock); + int ret = -1; + unsigned int cpu_id = smp_processor_id(); + + do + { + while ( cpu_id != lock_cpu_id && lock_count != 0 ) + ; + spin_lock(&lock_cpu); + if ( cpu_id == lock_cpu_id || lock_count == 0 ) + { + lock_cpu_id = cpu_id; + lock_count++; + ret = 0; + } + spin_unlock(&lock_cpu); + } while ( ret == -1 ); } -void pmap_unlock(void) +static void pmap_cpu_down(void) { - spin_unlock(&lock); + spin_lock(&lock_cpu); + ASSERT(smp_processor_id() == lock_cpu_id); + ASSERT(lock_count); + lock_count--; + spin_unlock(&lock_cpu); } void *pmap_map(mfn_t mfn) @@ -37,7 +63,13 @@ void *pmap_map(mfn_t mfn) l1_pgentry_t *pl1e; ASSERT(!in_irq()); - ASSERT(spin_is_locked(&lock)); + + /* + * This semaphore-like locking means only one pCPU is allowed, which also + * suggests PMAP should only be used to bootstrap other structures. Any + * general purpose use of PMAP is a mistake. + */ + pmap_cpu_up(); idx = find_first_zero_bit(&inuse, NUM_FIX_PMAP); if ( idx == NUM_FIX_PMAP ) @@ -63,13 +95,15 @@ void pmap_unmap(void *p) ASSERT(!in_irq()); ASSERT(slot >= FIX_PMAP_BEGIN && slot <= FIX_PMAP_END); - ASSERT(spin_is_locked(&lock)); + idx = slot - FIX_PMAP_BEGIN; __clear_bit(idx, &inuse); pl1e = &l1_fixmap[L1_PAGETABLE_ENTRIES - 1 - slot]; l1e_write_atomic(pl1e, l1e_from_mfn(_mfn(0), 0)); + + pmap_cpu_down(); } static void __maybe_unused build_assertions(void) diff --git a/xen/include/asm-x86/pmap.h b/xen/include/asm-x86/pmap.h index 34d4f2bb38..790cd71fb3 100644 --- a/xen/include/asm-x86/pmap.h +++ b/xen/include/asm-x86/pmap.h @@ -4,8 +4,6 @@ /* Large enough for mapping 5 levels of page tables with some headroom */ #define NUM_FIX_PMAP 8 -void pmap_lock(void); -void pmap_unlock(void); void *pmap_map(mfn_t mfn); void pmap_unmap(void *p); From patchwork Thu Sep 26 09:46: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: 11162201 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 3910513BD for ; Thu, 26 Sep 2019 09:51: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 156EA2053B for ; Thu, 26 Sep 2019 09:51: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="Gb4eppG2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 156EA2053B 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 1iDQQS-0001gQ-OW; Thu, 26 Sep 2019 09:51: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 1iDQQO-0001Vk-5l for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:51:00 +0000 X-Inumbo-ID: 23a6c3cc-e043-11e9-97fb-bc764e2007e4 Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id 23a6c3cc-e043-11e9-97fb-bc764e2007e4; Thu, 26 Sep 2019 09:50: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=1569491457; x=1601027457; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=JbDOP4ipVKzLlTXBw9nd78xyznvahBG8mPjM9/COwUA=; b=Gb4eppG2zeC0o1d3WOHz54wimZdF/H2XbcSnaEZbPgriUndE2fced5Mm 8BIBwbAe6M0OBquEFB6OeZyoLov5wr4X2pzrdiYGqEAYJljxAcWJdubUH lBGpvZdtzlJffBMtAa5LeXMwgAf6CIeTuKKwKCZVVhFcsPry9QTRlleFf g=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="787535548" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-821c648d.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 26 Sep 2019 09:50: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-1a-821c648d.us-east-1.amazon.com (Postfix) with ESMTPS id 07D24A1E66; Thu, 26 Sep 2019 09:50:55 +0000 (UTC) Received: from EX13D28EUC001.ant.amazon.com (10.43.164.4) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:50:21 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUC001.ant.amazon.com (10.43.164.4) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:50:19 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:50:17 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:47 +0100 Message-ID: <19981ca60bdd61b305946e51fa4ec4e66e2a9408.1569489002.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] [RFC PATCH 84/84] x86/pv: fix a couple of direct map assumptions in dom0 building. 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 , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Wei Liu , Jan Beulich , Hongyan Xia Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Signed-off-by: Hongyan Xia --- xen/arch/x86/pv/dom0_build.c | 7 ++++--- xen/include/asm-x86/processor.h | 2 -- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 202edcaa17..98dcc18d21 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -626,9 +626,10 @@ int __init dom0_construct_pv(struct domain *d, l4start = l4tab = map_xen_pagetable(maddr_to_mfn(mpt_alloc)); mpt_alloc += PAGE_SIZE; clear_page(l4tab); - init_xen_l4_slots(l4tab, _mfn(virt_to_mfn(l4start)), - d, INVALID_MFN, true); - v->arch.guest_table = pagetable_from_paddr(__pa(l4start)); + init_xen_l4_slots(l4tab, _mfn(virt_to_mfn_walk(l4start)), d, + INVALID_MFN, true); + v->arch.guest_table = + pagetable_from_mfn(_mfn(virt_to_mfn_walk(l4start))); } else { diff --git a/xen/include/asm-x86/processor.h b/xen/include/asm-x86/processor.h index f571191cdb..7e8d010d07 100644 --- a/xen/include/asm-x86/processor.h +++ b/xen/include/asm-x86/processor.h @@ -465,8 +465,6 @@ 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(struct tss_struct, init_tss); - extern void write_ptbase(struct vcpu *v); /* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */