From nobody Mon Feb 9 15:29:52 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=fail; 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=1587737391; cv=none; d=zohomail.com; s=zohoarc; b=hddHcq8XxnJ53hcqqyUFJPmKC22Fce94GxDyha9E7zBnpQZ6iYaQXZ2noEHxmhw0iENuKm3FqFfQXNUk404iIrd4hwxZSb+yVG5Drnf+3qyIa2PboJkOdsf+v/qWSLvnO9Sb7hMk+0Cn6U19WZ5ntdiFS+2/i3cL7BqHo8B1FZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587737391; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=fRkSpuClFodnft3WeIOUG75ZUCmfP/WLuHx0luTOIk0=; b=kU/vj401K2d2hIv+WDkWdvnB7K15RN2xgOLYaxzjr9S7EFI5dgnX55oRS+jNCiL6zxC2BzdLfTbKL1RROuZ/vtLz+8bCk+C6QVwQmUdEUt6KMp9fUYBTTQuz/aSNejj03Ubivt/0nmSFtTu5T/f/A/JZoE3jT+G0O1p3nxqZCNo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1587737391314506.4532881657125; Fri, 24 Apr 2020 07:09:51 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jRz1O-0002yZ-LU; Fri, 24 Apr 2020 14:09:38 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jRz1N-0002xq-Eu for xen-devel@lists.xenproject.org; Fri, 24 Apr 2020 14:09:37 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 37a37e36-8635-11ea-b58d-bc764e2007e4; Fri, 24 Apr 2020 14:09:31 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jRz1H-0001hY-77; Fri, 24 Apr 2020 14:09:31 +0000 Received: from 54-240-197-226.amazon.com ([54.240.197.226] helo=u1bbd043a57dd5a.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1jRz1G-0001fN-Rd; Fri, 24 Apr 2020 14:09:31 +0000 X-Inumbo-ID: 37a37e36-8635-11ea-b58d-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=fRkSpuClFodnft3WeIOUG75ZUCmfP/WLuHx0luTOIk0=; b=UcF2ZDXTxspxFWqMo8u0pUjDco KWijGwEGxYWD5cuD29mhl1j3+gwF7TffeFBF6eB5j529681ajhs1Yz1XXA0sZ6yL7nJsMD1roTDeQ I7qO/kbcb708/ZdcGdKOYRc4yvuM9/lQFfD8S1M26YuiI0rMiVnT4aoPnN0is+F/AuMc=; From: Hongyan Xia To: xen-devel@lists.xenproject.org Subject: [PATCH v6 08/15] x86_64/mm: switch to new APIs in setup_m2p_table Date: Fri, 24 Apr 2020 15:08:59 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , julien@xen.org, Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Wei Liu Also reduce the scope of l2_ro_mpt as it is only used inside the loop, and remove two lines of l2_ro_mpt check which serve no purpose. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- xen/arch/x86/x86_64/mm.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 3cf699d27b..12e9dc6eb2 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -379,13 +379,13 @@ static int setup_m2p_table(struct mem_hotadd_info *in= fo) { unsigned long i, va, smap, emap; unsigned int n; - l2_pgentry_t *l2_ro_mpt =3D NULL; l3_pgentry_t *l3_ro_mpt =3D NULL; int ret =3D 0; =20 ASSERT(l4e_get_flags(idle_pg_table[l4_table_offset(RO_MPT_VIRT_START)]) & _PAGE_PRESENT); - l3_ro_mpt =3D l4e_to_l3e(idle_pg_table[l4_table_offset(RO_MPT_VIRT_STA= RT)]); + l3_ro_mpt =3D map_l3t_from_l4e( + idle_pg_table[l4_table_offset(RO_MPT_VIRT_START)]); =20 smap =3D (info->spfn & (~((1UL << (L2_PAGETABLE_SHIFT - 3)) -1))); emap =3D ((info->epfn + ((1UL << (L2_PAGETABLE_SHIFT - 3)) - 1 )) & @@ -424,6 +424,7 @@ static int setup_m2p_table(struct mem_hotadd_info *info) break; if ( n < CNT ) { + l2_pgentry_t *l2_ro_mpt; mfn_t mfn =3D alloc_hotadd_mfn(info); =20 ret =3D map_pages_to_xen( @@ -440,30 +441,30 @@ static int setup_m2p_table(struct mem_hotadd_info *in= fo) _PAGE_PSE)); if ( l3e_get_flags(l3_ro_mpt[l3_table_offset(va)]) & _PAGE_PRESENT ) - l2_ro_mpt =3D l3e_to_l2e(l3_ro_mpt[l3_table_offset(va)]) + - l2_table_offset(va); + l2_ro_mpt =3D map_l2t_from_l3e(l3_ro_mpt[l3_table_offset(v= a)]); else { - l2_ro_mpt =3D alloc_xen_pagetable(); - if ( !l2_ro_mpt ) + mfn_t l2_ro_mpt_mfn =3D alloc_xen_pagetable_new(); + + if ( mfn_eq(l2_ro_mpt_mfn, INVALID_MFN) ) { ret =3D -ENOMEM; goto error; } =20 + l2_ro_mpt =3D map_domain_page(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= )); - l2_ro_mpt +=3D l2_table_offset(va); + l3e_from_mfn(l2_ro_mpt_mfn, + __PAGE_HYPERVISOR_RO | _PAGE_USER)); } + l2_ro_mpt +=3D l2_table_offset(va); =20 /* NB. Cannot be GLOBAL: guest user mode should not see it. */ l2e_write(l2_ro_mpt, l2e_from_mfn(mfn, /*_PAGE_GLOBAL|*/_PAGE_PSE|_PAGE_USER|_PAGE_PRESENT)); + unmap_domain_page(l2_ro_mpt); } - if ( !((unsigned long)l2_ro_mpt & ~PAGE_MASK) ) - l2_ro_mpt =3D NULL; i +=3D ( 1UL << (L2_PAGETABLE_SHIFT - 3)); } #undef CNT @@ -471,6 +472,7 @@ static int setup_m2p_table(struct mem_hotadd_info *info) =20 ret =3D setup_compat_m2p_table(info); error: + UNMAP_DOMAIN_PAGE(l3_ro_mpt); return ret; } =20 --=20 2.24.1.AMZN