From nobody Mon Feb 9 11:07:16 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=1587737382; cv=none; d=zohomail.com; s=zohoarc; b=apa3BrEw5Xz0AxUXrQ7mTWSN4u/GFxNdAn3AWt5bsXQ4rHG4eIICzdy2nKvo1K36Fs/rQ6eIjyFiI9xitGhi71nBEScA+R86J5FUj+t8wpsDsajXQwgd8vGtehldGhc7GA8MUFYyDiYlUAr4gnb/a3s6PmviLJERk8ASSTM9Huo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587737382; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=wuKSH+etKo7Jo0+ZezG3H1XK7TumB7Bc+ci7lGz0PLk=; b=E7f4LIVjQSHSm3tdSfqx/8VF8j6sYgL5hliSeaW7qvr+Xy3KNZvTur5MdVJ2maNt/wSkhYQZsES2IZKqhWMKMhytz9RcPLdw6G0BAzhWKDUkMYOAoH8i1UUN2tH4Je595kxrBMWUptmt0lEh8aCn1HNm8qXrRjLD41igKuk8nKg= 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 1587737382651976.1714805629302; Fri, 24 Apr 2020 07:09:42 -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 1jRz1B-0002pp-2D; Fri, 24 Apr 2020 14:09:25 +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.92) (envelope-from ) id 1jRz1A-0002pb-LJ for xen-devel@lists.xenproject.org; Fri, 24 Apr 2020 14:09:24 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 310015c6-8635-11ea-94b0-12813bfff9fa; Fri, 24 Apr 2020 14:09:20 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jRz15-0001gC-Uk; Fri, 24 Apr 2020 14:09:19 +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 1jRz15-0001fN-Iw; Fri, 24 Apr 2020 14:09:19 +0000 X-Inumbo-ID: 310015c6-8635-11ea-94b0-12813bfff9fa 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=wuKSH+etKo7Jo0+ZezG3H1XK7TumB7Bc+ci7lGz0PLk=; b=bNL3GNbndE1LgY8gb7b+rytX5a CZqOmiD5+qjoarwPnP/ejsBi+JEsFbuD+biyMOifNBtKcx4NNw8eV9tJN6Svhw+1Ygk2H2DIkM4y4 OfL1z4WErTBNxP4vd6kXpJ/tU8NrWFClBVYpWX85EGxVFiD9I/4abtRckdK8yyHG6Gms=; From: Hongyan Xia To: xen-devel@lists.xenproject.org Subject: [PATCH v6 01/15] x86/mm: map_pages_to_xen would better have one exit path Date: Fri, 24 Apr 2020 15:08:52 +0100 Message-Id: <65a239b5c283890f83d2e637dbb6d01a673e586b.1587735799.git.hongyxia@amazon.com> 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 We will soon rewrite the function to handle dynamically mapping and unmapping of page tables. Since dynamic mappings may map and unmap pages in different iterations of the while loop, we need to lift pl3e out of the loop. No functional change. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- Changed since v4: - drop the end_of_loop goto label. Changed since v3: - remove asserts on rc since rc never gets changed to anything else. - reword commit message. --- xen/arch/x86/mm.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 355c50ff91..0d7f1f1265 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5073,9 +5073,11 @@ int map_pages_to_xen( unsigned int flags) { bool locking =3D system_state > SYS_STATE_boot; + l3_pgentry_t *pl3e, ol3e; l2_pgentry_t *pl2e, ol2e; l1_pgentry_t *pl1e, ol1e; unsigned int i; + int rc =3D -ENOMEM; =20 #define flush_flags(oldf) do { \ unsigned int o_ =3D (oldf); \ @@ -5093,10 +5095,11 @@ int map_pages_to_xen( =20 while ( nr_mfns !=3D 0 ) { - l3_pgentry_t ol3e, *pl3e =3D virt_to_xen_l3e(virt); + pl3e =3D virt_to_xen_l3e(virt); =20 if ( !pl3e ) - return -ENOMEM; + goto out; + ol3e =3D *pl3e; =20 if ( cpu_has_page1gb && @@ -5186,7 +5189,7 @@ int map_pages_to_xen( =20 l2t =3D alloc_xen_pagetable(); if ( l2t =3D=3D NULL ) - return -ENOMEM; + goto out; =20 for ( i =3D 0; i < L2_PAGETABLE_ENTRIES; i++ ) l2e_write(l2t + i, @@ -5215,7 +5218,7 @@ int map_pages_to_xen( =20 pl2e =3D virt_to_xen_l2e(virt); if ( !pl2e ) - return -ENOMEM; + goto out; =20 if ( ((((virt >> PAGE_SHIFT) | mfn_x(mfn)) & ((1u << PAGETABLE_ORDER) - 1)) =3D=3D 0) && @@ -5259,7 +5262,7 @@ int map_pages_to_xen( { pl1e =3D virt_to_xen_l1e(virt); if ( pl1e =3D=3D NULL ) - return -ENOMEM; + goto out; } else if ( l2e_get_flags(*pl2e) & _PAGE_PSE ) { @@ -5287,7 +5290,7 @@ int map_pages_to_xen( =20 l1t =3D alloc_xen_pagetable(); if ( l1t =3D=3D NULL ) - return -ENOMEM; + goto out; =20 for ( i =3D 0; i < L1_PAGETABLE_ENTRIES; i++ ) l1e_write(&l1t[i], @@ -5433,7 +5436,10 @@ int map_pages_to_xen( =20 #undef flush_flags =20 - return 0; + rc =3D 0; + + out: + return rc; } =20 int populate_pt_range(unsigned long virt, unsigned long nr_mfns) --=20 2.24.1.AMZN