From patchwork Mon Sep 30 10:33:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11166383 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3FE2C13BD for ; Mon, 30 Sep 2019 10:35:38 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1BF8C216F4 for ; Mon, 30 Sep 2019 10:35:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="R5aBm6pF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BF8C216F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt11-0007N7-QX; Mon, 30 Sep 2019 10:34:51 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEt0z-0007Ka-RN for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 10:34:49 +0000 X-Inumbo-ID: ecde9abc-e36d-11e9-96cd-12813bfff9fa Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by localhost (Halon) with ESMTPS id ecde9abc-e36d-11e9-96cd-12813bfff9fa; Mon, 30 Sep 2019 10:34:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569839687; x=1601375687; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=3nNvQG1v8uYo6cTIKpiw9dRaihrielmfxq5scEhNceU=; b=R5aBm6pFiCth9Kx2KlDdmHLrjQQ7FVQT8EPnXXwP+5RVQcggoukn3kl7 RaNTQj0cp9L3jn0SEk96hMiP+yY3S11UJQzAmFsSWmtzpVscc99E+ni9V VIt+PlN1n4WS/S+zVXOKs4idKJiLnnVkiJ5mZJLAR1OLmnXY3yLuwhkQt 0=; X-IronPort-AV: E=Sophos;i="5.64,565,1559520000"; d="scan'208";a="788414695" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-c7c08562.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 30 Sep 2019 10:34:47 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1e-c7c08562.us-east-1.amazon.com (Postfix) with ESMTPS id 271E9244235; Mon, 30 Sep 2019 10:34:47 +0000 (UTC) Received: from EX13D15UEE002.ant.amazon.com (10.43.62.80) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:18 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D15UEE002.ant.amazon.com (10.43.62.80) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 10:34:17 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.78) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 10:34:17 +0000 From: Hongyan Xia To: Date: Mon, 30 Sep 2019 11:33:21 +0100 Message-ID: <75bdd5c41f19bd435bb708f3e3297c89e37bcbf1.1569833766.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2 29/55] efi: avoid using global variable in copy_mapping X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu We will soon switch efi_l4_table to use ephemeral mapping. Make copy_mapping take a pointer to the mapping instead of using the global variable. No functional change intended. Signed-off-by: Wei Liu --- xen/common/efi/boot.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 62b5944e61..64a287690a 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -1423,7 +1423,8 @@ static int __init parse_efi_param(const char *s) custom_param("efi", parse_efi_param); #ifndef USE_SET_VIRTUAL_ADDRESS_MAP -static __init void copy_mapping(unsigned long mfn, unsigned long end, +static __init void copy_mapping(l4_pgentry_t *l4, + unsigned long mfn, unsigned long end, bool (*is_valid)(unsigned long smfn, unsigned long emfn)) { @@ -1431,7 +1432,7 @@ static __init void copy_mapping(unsigned long mfn, unsigned long end, for ( ; mfn < end; mfn = next ) { - l4_pgentry_t l4e = efi_l4_pgtable[l4_table_offset(mfn << PAGE_SHIFT)]; + l4_pgentry_t l4e = l4[l4_table_offset(mfn << PAGE_SHIFT)]; l3_pgentry_t *l3src, *l3dst; unsigned long va = (unsigned long)mfn_to_virt(mfn); @@ -1446,7 +1447,7 @@ static __init void copy_mapping(unsigned long mfn, unsigned long end, BUG_ON(mfn_eq(l3t_mfn, INVALID_MFN)); l3dst = map_xen_pagetable_new(l3t_mfn); clear_page(l3dst); - efi_l4_pgtable[l4_table_offset(mfn << PAGE_SHIFT)] = + l4[l4_table_offset(mfn << PAGE_SHIFT)] = l4e_from_mfn(l3t_mfn, __PAGE_HYPERVISOR); } else @@ -1606,7 +1607,7 @@ void __init efi_init_memory(void) BUG_ON(!efi_l4_pgtable); clear_page(efi_l4_pgtable); - copy_mapping(0, max_page, ram_range_valid); + copy_mapping(efi_l4_pgtable, 0, max_page, ram_range_valid); /* Insert non-RAM runtime mappings inside the direct map. */ for ( i = 0; i < efi_memmap_size; i += efi_mdesc_size ) @@ -1619,7 +1620,7 @@ void __init efi_init_memory(void) desc->Type == EfiBootServicesData))) && desc->VirtualStart != INVALID_VIRTUAL_ADDRESS && desc->VirtualStart != desc->PhysicalStart ) - copy_mapping(PFN_DOWN(desc->PhysicalStart), + copy_mapping(efi_l4_pgtable, PFN_DOWN(desc->PhysicalStart), PFN_UP(desc->PhysicalStart + (desc->NumberOfPages << EFI_PAGE_SHIFT)), rt_range_valid);