From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54D77C43462 for ; Wed, 21 Apr 2021 14:36:36 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E7A2C6144D for ; Wed, 21 Apr 2021 14:36:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7A2C6144D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.114739.218713 (Exim 4.92) (envelope-from ) id 1lZDxn-0004xp-C7; Wed, 21 Apr 2021 14:36:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 114739.218713; Wed, 21 Apr 2021 14:36:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZDxn-0004xc-14; Wed, 21 Apr 2021 14:36:23 +0000 Received: by outflank-mailman (input) for mailman id 114739; Wed, 21 Apr 2021 14:36:21 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZDxl-0004wM-3L for xen-devel@lists.xenproject.org; Wed, 21 Apr 2021 14:36:21 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZDxk-0001QT-Oz; Wed, 21 Apr 2021 14:36:20 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ua82172827c7b5a.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lZDeC-00045m-Pg; Wed, 21 Apr 2021 14:16:09 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=References:In-Reply-To:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From; bh=BZ5P7bdDeDjJxLx3W7/LuN05q0NJBaBDMv0rirzWg8Q=; b=l oHU+3s/3SgK7e4ZTv+KriClHfxqTmGV5trfX1Fmj3t5QwA0qiJw52j4yZ/TcifKEuGnj1zMeRzCRW 9oiJ0F3NIFI0man0SmB3h+gDakIlhyV8dfNpbpSDKJxKS31oP72hO4pn95gK2LFa7dy6meGK+FgEZ Aj4tEmeawliZ8Hm8=; From: Hongyan Xia To: xen-devel@lists.xenproject.org Cc: jgrall@amazon.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v10 11/13] x86/mm: drop old page table APIs Date: Wed, 21 Apr 2021 15:15:39 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: From: Hongyan Xia Two sets of old APIs, alloc/free_xen_pagetable() and lXe_to_lYe(), are now dropped to avoid the dependency on direct map. There are two special cases which still have not been re-written into the new APIs, thus need special treatment: rpt in smpboot.c cannot use ephemeral mappings yet. The problem is that rpt is read and written in context switch code, but the mapping infrastructure is NOT context-switch-safe, meaning we cannot map rpt in one domain and unmap in another. Before the mapping infrastructure supports context switches, rpt has to be globally mapped. Also, lXe_to_lYe() during Xen image relocation cannot be converted into map/unmap pairs. We cannot hold on to mappings while the mapping infrastructure is being relocated! It is enough to remove the direct map in the second e820 pass, so we still use the direct map (<4GiB) in Xen relocation (which is during the first e820 pass). Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia Reviewed-by: Jan Beulich --- xen/arch/x86/mm.c | 14 -------------- xen/arch/x86/setup.c | 4 ++-- xen/arch/x86/smpboot.c | 4 ++-- xen/include/asm-x86/mm.h | 2 -- xen/include/asm-x86/page.h | 5 ----- 5 files changed, 4 insertions(+), 25 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 832e654294b4..bf86ba3729aa 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4891,20 +4891,6 @@ int mmcfg_intercept_write( return X86EMUL_OKAY; } -void *alloc_xen_pagetable(void) -{ - mfn_t mfn = alloc_xen_pagetable_new(); - - return mfn_eq(mfn, INVALID_MFN) ? NULL : mfn_to_virt(mfn_x(mfn)); -} - -void free_xen_pagetable(void *v) -{ - mfn_t mfn = v ? virt_to_mfn(v) : INVALID_MFN; - - free_xen_pagetable_new(mfn); -} - /* * For these PTE APIs, the caller must follow the alloc-map-unmap-free * lifecycle, which means explicitly mapping the PTE pages before accessing diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index a6658d976937..f2dff2ae6a64 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1247,7 +1247,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) continue; *pl4e = l4e_from_intpte(l4e_get_intpte(*pl4e) + xen_phys_start); - pl3e = l4e_to_l3e(*pl4e); + pl3e = __va(l4e_get_paddr(*pl4e)); for ( j = 0; j < L3_PAGETABLE_ENTRIES; j++, pl3e++ ) { /* Not present, 1GB mapping, or already relocated? */ @@ -1257,7 +1257,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 = __va(l3e_get_paddr(*pl3e)); for ( k = 0; k < L2_PAGETABLE_ENTRIES; k++, pl2e++ ) { /* Not present, PSE, or already relocated? */ diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 765cf3396051..ad878d8aebca 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -830,7 +830,7 @@ static int setup_cpu_root_pgt(unsigned int cpu) if ( !opt_xpti_hwdom && !opt_xpti_domu ) return 0; - rpt = alloc_xen_pagetable(); + rpt = alloc_xenheap_page(); if ( !rpt ) return -ENOMEM; @@ -933,7 +933,7 @@ static void cleanup_cpu_root_pgt(unsigned int cpu) free_xen_pagetable_new(l3mfn); } - free_xen_pagetable(rpt); + free_xenheap_page(rpt); /* Also zap the stub mapping for this CPU. */ if ( stub_linear ) diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 111754675cbf..0a72fa7a26c3 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -573,8 +573,6 @@ int vcpu_destroy_pagetables(struct vcpu *); void *do_page_walk(struct vcpu *v, unsigned long addr); /* Allocator functions for Xen pagetables. */ -void *alloc_xen_pagetable(void); -void free_xen_pagetable(void *v); mfn_t alloc_xen_pagetable_new(void); void free_xen_pagetable_new(mfn_t mfn); void *alloc_mapped_pagetable(mfn_t *pmfn); diff --git a/xen/include/asm-x86/page.h b/xen/include/asm-x86/page.h index 4c7f2cb70c69..1d080cffbe84 100644 --- a/xen/include/asm-x86/page.h +++ b/xen/include/asm-x86/page.h @@ -180,11 +180,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)) -- 2.23.4