From patchwork Wed Dec 4 17:10:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11273329 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 538F317EF for ; Wed, 4 Dec 2019 17:12:50 +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 3026A2084B for ; Wed, 4 Dec 2019 17:12:50 +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="cg3OcqFC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3026A2084B 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 1icYBc-0003h0-AN; Wed, 04 Dec 2019 17:11:36 +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 1icYBa-0003gA-RH for xen-devel@lists.xenproject.org; Wed, 04 Dec 2019 17:11:34 +0000 X-Inumbo-ID: 1aa4d154-16b9-11ea-8206-12813bfff9fa Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 1aa4d154-16b9-11ea-8206-12813bfff9fa; Wed, 04 Dec 2019 17:11:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1575479486; x=1607015486; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=P0ze9j9IMl8twsXynPSvX0GZYqiXEm239vamHZAscSo=; b=cg3OcqFCkQjkbCRrjc8kd+hmQzGtA79yDgJ6UCXOt/ixjXyG0MNYdLwt NznlT7EREdYzNsJFGrQoeErEv6/skB3/wYvurYEZU5lqM6d8deqQlwW07 iBM/OWS+F3rb1KSb3xp//pNxZtAV6HK4R9xUGPPCAt8TPL1G4WvYzNRXT M=; IronPort-SDR: 1Nz4LTFn846Tn8mIjjejWVr72kc95/aZ0rreMuHFvlSfp/3k6hFZ19K0danzydJEsTSeBLwqds omCkGm9kWQ+A== X-IronPort-AV: E=Sophos;i="5.69,277,1571702400"; d="scan'208";a="13005505" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2b-81e76b79.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 04 Dec 2019 17:11:21 +0000 Received: from EX13MTAUWA001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan3.pdx.amazon.com [10.170.41.166]) by email-inbound-relay-2b-81e76b79.us-west-2.amazon.com (Postfix) with ESMTPS id 6BC74A2209; Wed, 4 Dec 2019 17:11:21 +0000 (UTC) Received: from EX13D24UWA004.ant.amazon.com (10.43.160.233) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 4 Dec 2019 17:11:10 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D24UWA004.ant.amazon.com (10.43.160.233) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 4 Dec 2019 17:11:10 +0000 Received: from u60d575063b1f53.ant.amazon.com (10.125.106.64) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Wed, 4 Dec 2019 17:11:09 +0000 From: Hongyan Xia To: Date: Wed, 4 Dec 2019 17:10:57 +0000 Message-ID: <3057ce64c73e8e48c91b89192c8a8b43196bb1ce.1575477921.git.hongyxia@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v4 5/9] x86/mm: map_pages_to_xen would better have one exit path 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: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu We will soon rewrite the function to handle dynamically mapping and unmapping of page tables. No functional change. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia --- 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 303bc35549..f7464c2103 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5187,9 +5187,11 @@ int map_pages_to_xen( unsigned int flags) { bool locking = 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 = -ENOMEM; #define flush_flags(oldf) do { \ unsigned int o_ = (oldf); \ @@ -5207,10 +5209,11 @@ int map_pages_to_xen( while ( nr_mfns != 0 ) { - l3_pgentry_t ol3e, *pl3e = virt_to_xen_l3e(virt); + pl3e = virt_to_xen_l3e(virt); if ( !pl3e ) - return -ENOMEM; + goto out; + ol3e = *pl3e; if ( cpu_has_page1gb && @@ -5302,7 +5305,7 @@ int map_pages_to_xen( l2t = alloc_xen_pagetable(); if ( l2t == NULL ) - return -ENOMEM; + goto out; for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) l2e_write(l2t + i, @@ -5331,7 +5334,7 @@ int map_pages_to_xen( pl2e = virt_to_xen_l2e(virt); if ( !pl2e ) - return -ENOMEM; + goto out; if ( ((((virt >> PAGE_SHIFT) | mfn_x(mfn)) & ((1u << PAGETABLE_ORDER) - 1)) == 0) && @@ -5376,7 +5379,7 @@ int map_pages_to_xen( { pl1e = virt_to_xen_l1e(virt); if ( pl1e == NULL ) - return -ENOMEM; + goto out; } else if ( l2e_get_flags(*pl2e) & _PAGE_PSE ) { @@ -5404,7 +5407,7 @@ int map_pages_to_xen( l1t = alloc_xen_pagetable(); if ( l1t == NULL ) - return -ENOMEM; + goto out; for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) l1e_write(&l1t[i], @@ -5550,7 +5553,10 @@ int map_pages_to_xen( #undef flush_flags - return 0; + rc = 0; + + out: + return rc; } int populate_pt_range(unsigned long virt, unsigned long nr_mfns)