From patchwork Mon Sep 30 10:32: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: 11166441 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 C907213BD for ; Mon, 30 Sep 2019 10:36:35 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A5B6620679 for ; Mon, 30 Sep 2019 10:36:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="X3PWWhyI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5B6620679 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 1iEt1t-0000N1-LX; Mon, 30 Sep 2019 10:35:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt1r-0000JU-UL for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:35:43 +0000 X-Inumbo-ID: f64b5590-e36d-11e9-bf31-bc764e2007e4 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id f64b5590-e36d-11e9-bf31-bc764e2007e4; Mon, 30 Sep 2019 10:35:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839704; x=1601375704; h=from:to:cc:subject:date:message-id:mime-version; bh=KdH3mX2MKz0JF2vtBu/NmunaypPJDd19n8FmiQuhJGg=; b=X3PWWhyIt9vW9havUbjgZp2ytC/3rpi5HUGG/j82vkjo+ZO4w88UFWo8 USwG4Ig+Y+QdZyBdx3kArc7A3HR2Y7ShwzrOl6liAnig1WD3hwfcRxyL8 udNk+vuhvmaHgQ1rvBdeQ4zH0CNVKmReoultHkr/xsMXPuhKlHQJp6brF g=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="838005459" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1e-57e1d233.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 30 Sep 2019 10:34:03 +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 B005414173B; Mon, 30 Sep 2019 10:33:49 +0000 (UTC) Received: from EX13D15UEE004.ant.amazon.com (10.43.62.241) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:49 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D15UEE004.ant.amazon.com (10.43.62.241) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:33:48 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:33:48 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:32:52 +0100 Message-ID: X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 00/55] Switch to domheap for Xen PTEs X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This series is mostly Wei's effort to switch from xenheap to domheap for Xen page tables. In addition, I have also merged several bug fixes from my "Remove direct map from Xen" series [1]. As the title suggests, this series switches from xenheap to domheap for Xen PTEs. This is needed to achieve the ultimate goal of removing the always-mapped direct map from Xen. To work without an always-mapped direct map, Xen PTE manipulations themselves must not rely on it. Unfortunately, PTE APIs currently use the xenheap that does not work without the direct map. By switching to domheap APIs, it is much easier for us to break the reliance on the direct map later on, not only for PTEs but for all other memory allocations as well. I have broken down the direct map removal series into two. This series is the first batch. The patches change the life cycle of Xen PTEs from alloc-free to alloc-map-unmap-free, which means PTEs must be explicitly mapped and unmapped. This also makes sense to be the first batch from a stability PoV, since this is just an API change and the direct map has not been actually removed. Further, the map and unmap in the release build use the direct map as a fast path, so there is also no performance degredation in a release build. I have tested both debug and release build on bare-metal and nested virtualisation. I am able to run PV and HVM guests and XTF tests without crashes so far on x86. I am able to build on AArch64. This series is at https://xenbits.xen.org/git-http/people/hx242/xen.git, xen_pte_map branch. --- Changed since v1: - squash some commits - merge bug fixes into this first batch - rebase against latest master [1]: https://lists.xenproject.org/archives/html/xen-devel/2019-09/msg02647.html Wei Liu (55): x86/mm: defer clearing page in virt_to_xen_lXe x86: move some xen mm function declarations x86: introduce a new set of APIs to manage Xen page tables x86/mm: introduce l{1,2}t local variables to map_pages_to_xen x86/mm: introduce l{1,2}t local variables to modify_xen_mappings x86/mm: map_pages_to_xen should have one exit path x86/mm: add an end_of_loop label in map_pages_to_xen x86/mm: make sure there is one exit path for modify_xen_mappings x86/mm: add an end_of_loop label in modify_xen_mappings x86/mm: change pl2e to l2t in virt_to_xen_l2e x86/mm: change pl1e to l1t in virt_to_xen_l1e x86/mm: change pl3e to l3t in virt_to_xen_l3e x86/mm: rewrite virt_to_xen_l3e x86/mm: rewrite xen_to_virt_l2e x86/mm: rewrite virt_to_xen_l1e x86/mm: switch to new APIs in map_pages_to_xen x86/mm: drop lXe_to_lYe invocations in map_pages_to_xen x86/mm: switch to new APIs in modify_xen_mappings x86/mm: drop lXe_to_lYe invocations from modify_xen_mappings x86/mm: switch to new APIs in arch_init_memory x86_64/mm: introduce pl2e in paging_init x86_64/mm: switch to new APIs in paging_init x86_64/mm: drop l4e_to_l3e invocation from paging_init x86_64/mm.c: remove code that serves no purpose in setup_m2p_table x86_64/mm: introduce pl2e in setup_m2p_table x86_64/mm: switch to new APIs in setup_m2p_table x86_64/mm: drop lXe_to_lYe invocations from setup_m2p_table efi: use new page table APIs in copy_mapping efi: avoid using global variable in copy_mapping efi: use new page table APIs in efi_init_memory efi: add emacs block to boot.c efi: switch EFI L4 table to use new APIs x86/smpboot: add emacs block x86/smpboot: clone_mapping should have one exit path x86/smpboot: switch pl3e to use new APIs in clone_mapping x86/smpboot: switch pl2e to use new APIs in clone_mapping x86/smpboot: switch pl1e to use new APIs in clone_mapping x86/smpboot: drop lXe_to_lYe invocations from cleanup_cpu_root_pgt x86: switch root_pgt to mfn_t and use new APIs x86/shim: map and unmap page tables in replace_va_mapping x86_64/mm: map and unmap page tables in m2p_mapped x86_64/mm: map and unmap page tables in share_hotadd_m2p_table x86_64/mm: map and unmap page tables in destroy_compat_m2p_mapping x86_64/mm: map and unmap page tables in destroy_m2p_mapping x86_64/mm: map and unmap page tables in setup_compat_m2p_table x86_64/mm: map and unmap page tables in cleanup_frame_table x86_64/mm: map and unmap page tables in subarch_init_memory x86_64/mm: map and unmap page tables in subarch_memory_op x86/smpboot: remove lXe_to_lYe in cleanup_cpu_root_pgt x86/pv: properly map and unmap page tables in mark_pv_pt_pages_rdonly x86/pv: properly map and unmap page table in dom0_construct_pv x86: remove lXe_to_lYe in __start_xen x86/mm: drop old page table APIs x86: switch to use domheap page for page tables x86/mm: drop _new suffix for page table APIs xen/arch/x86/domain.c | 15 +- xen/arch/x86/domain_page.c | 12 +- xen/arch/x86/efi/runtime.h | 12 +- xen/arch/x86/mm.c | 482 ++++++++++++++++++++++---------- xen/arch/x86/pv/dom0_build.c | 41 ++- xen/arch/x86/pv/domain.c | 2 +- xen/arch/x86/pv/shim.c | 20 +- xen/arch/x86/setup.c | 10 +- xen/arch/x86/smpboot.c | 171 +++++++---- xen/arch/x86/x86_64/mm.c | 267 +++++++++++++----- xen/common/efi/boot.c | 84 ++++-- xen/common/efi/efi.h | 3 +- xen/common/efi/runtime.c | 8 +- xen/include/asm-x86/mm.h | 16 ++ xen/include/asm-x86/page.h | 10 - xen/include/asm-x86/processor.h | 2 +- 16 files changed, 819 insertions(+), 336 deletions(-)