From nobody Mon Feb 9 16:20:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1617707205; cv=none; d=zohomail.com; s=zohoarc; b=gvrAqMbnkZID0lTzMUZEjyZQq4RFFEgH8esPKPXO+91+YSs1LHG/EtX8lkjn9pi4eleVRs2jKUdDW6hxNbwYqc2UyTqQmoM2AqC1LTw7NNQLMfWxNZ5j8cCYG1BOBZUzAmBEkAE0WR+pNcbzxiAG24bglV64VtVgBG27U6/j3Wc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617707205; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=LFpwvb91UZUoU14PzilixiyXhwhbK+Ssko2aEV8OspU=; b=WEfw14Bqh1LTy8pj8azUToLAWpDjXJ5iH0yujdxughHdu+KK6QowowskZ/vI30xuS3BsczCXDDo+azLSdOPbWyJZpCKTqXCWqjOhV2TmHSYTBJp7BZnXTL2sklACo/E9/GizO4cs9HUC5YLRqvU0CgZ+AvNR+TlM4z9aQQ1pFDw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1617707205109455.47095267986504; Tue, 6 Apr 2021 04:06:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.105805.202428 (Exim 4.92) (envelope-from ) id 1lTjXS-0004Uz-F3; Tue, 06 Apr 2021 11:06:30 +0000 Received: by outflank-mailman (output) from mailman id 105805.202428; Tue, 06 Apr 2021 11:06:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTjXS-0004Ul-9u; Tue, 06 Apr 2021 11:06:30 +0000 Received: by outflank-mailman (input) for mailman id 105805; Tue, 06 Apr 2021 11:06:28 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTjXQ-0004RG-LP for xen-devel@lists.xenproject.org; Tue, 06 Apr 2021 11:06:28 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTjXQ-00053V-FM; Tue, 06 Apr 2021 11:06:28 +0000 Received: from 54-240-197-238.amazon.com ([54.240.197.238] 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 1lTjXQ-0002qD-35; Tue, 06 Apr 2021 11:06:28 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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=LFpwvb91UZUoU14PzilixiyXhwhbK+Ssko2aEV8OspU=; b=d tCkrh5Em0heROtY5F1o8msjHHMg4VJGceKwrKAfMdczs1c89z/qDBPzgak9d8od/844cCrLIfAx6C yGHve5ntFf3TfLz2dVb8jxEjowz0XkqOTXHh3rSPHzH5vzMV+ywXpvmBr2652xRGQB9gOdFd62I9M FSbtyBrcttub7geE=; From: Hongyan Xia To: xen-devel@lists.xenproject.org Cc: jgrall@amazon.com, Jan Beulich Subject: [PATCH v9 07/13] efi: use new page table APIs in copy_mapping Date: Tue, 6 Apr 2021 12:05:55 +0100 Message-Id: <7acd46b563df7c684342a467de1b703be1366a74.1617706782.git.hongyxia@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia Reviewed-by: Jan Beulich --- Changed in v8: - remove redundant commit message. - unmap l3src based on va instead of mfn. - re-structure if condition around l3dst. Changed in v7: - hoist l3 variables out of the loop to avoid repetitive mappings. --- xen/common/efi/boot.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 63e289ab8506..64b319d0013b 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -1439,29 +1440,42 @@ static __init void copy_mapping(unsigned long mfn, = unsigned long end, unsigned long emfn)) { unsigned long next; + l3_pgentry_t *l3src =3D NULL, *l3dst =3D NULL; =20 for ( ; mfn < end; mfn =3D next ) { l4_pgentry_t l4e =3D efi_l4_pgtable[l4_table_offset(mfn << PAGE_SH= IFT)]; - l3_pgentry_t *l3src, *l3dst; unsigned long va =3D (unsigned long)mfn_to_virt(mfn); =20 + if ( !(mfn & ((1UL << (L4_PAGETABLE_SHIFT - PAGE_SHIFT)) - 1)) ) + UNMAP_DOMAIN_PAGE(l3dst); + if ( !(va & ((1UL << L4_PAGETABLE_SHIFT) - 1)) ) + UNMAP_DOMAIN_PAGE(l3src); next =3D mfn + (1UL << (L3_PAGETABLE_SHIFT - PAGE_SHIFT)); if ( !is_valid(mfn, min(next, end)) ) continue; - if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) ) + + if ( l3dst ) + /* nothing */; + else if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) ) { - l3dst =3D alloc_xen_pagetable(); + mfn_t l3mfn; + + l3dst =3D alloc_map_clear_xen_pt(&l3mfn); BUG_ON(!l3dst); - clear_page(l3dst); efi_l4_pgtable[l4_table_offset(mfn << PAGE_SHIFT)] =3D - l4e_from_paddr(virt_to_maddr(l3dst), __PAGE_HYPERVISOR); + l4e_from_mfn(l3mfn, __PAGE_HYPERVISOR); } else - l3dst =3D l4e_to_l3e(l4e); - l3src =3D l4e_to_l3e(idle_pg_table[l4_table_offset(va)]); + l3dst =3D map_l3t_from_l4e(l4e); + + if ( !l3src ) + l3src =3D map_l3t_from_l4e(idle_pg_table[l4_table_offset(va)]); l3dst[l3_table_offset(mfn << PAGE_SHIFT)] =3D l3src[l3_table_offse= t(va)]; } + + unmap_domain_page(l3src); + unmap_domain_page(l3dst); } =20 static bool __init ram_range_valid(unsigned long smfn, unsigned long emfn) --=20 2.23.3