From patchwork Tue Apr 6 11:05:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongyan Xia X-Patchwork-Id: 12184873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52F74C433ED for ; Tue, 6 Apr 2021 11:06:41 +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 1CAC360FF0 for ; Tue, 6 Apr 2021 11:06:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CAC360FF0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.105808.202452 (Exim 4.92) (envelope-from ) id 1lTjXW-0004dy-Br; Tue, 06 Apr 2021 11:06:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 105808.202452; Tue, 06 Apr 2021 11:06:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTjXW-0004dl-61; Tue, 06 Apr 2021 11:06:34 +0000 Received: by outflank-mailman (input) for mailman id 105808; Tue, 06 Apr 2021 11:06:33 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTjXU-0004bL-TE for xen-devel@lists.xenproject.org; Tue, 06 Apr 2021 11:06:32 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTjXU-00053k-OF; Tue, 06 Apr 2021 11:06:32 +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 1lTjXU-0002qD-7v; Tue, 06 Apr 2021 11:06:32 +0000 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=WyOLTWy30UAQ1i+d+4Gv5h1nt743T4iqL5WX21fKHJs=; b=F rbB/vL/o0AwCfSeS1ZtEsipXn5nqwQTNJcXuBgbzqVmr1GKCYDdjW2yvZjW7WAnMjjOrKDI8Uh0a8 swwf7Tff+tN0aS2yZbNrnH+60UGjC7JW5VdKYHEyawpeI6oJ+W6Uy+k428Z0GbXZKYTUNni7e8ckI V247oIHt5qEaWkUc=; From: Hongyan Xia To: xen-devel@lists.xenproject.org Cc: jgrall@amazon.com, Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu Subject: [PATCH v9 09/13] x86/smpboot: add exit path for clone_mapping() Date: Tue, 6 Apr 2021 12:05:57 +0100 Message-Id: <1277cb7cb71edbb03a13f9db8fe07810e68c7248.1617706782.git.hongyxia@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: From: Wei Liu We will soon need to clean up page table mappings in the exit path. No functional change. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia Acked-by: Jan Beulich --- Changed in v7: - edit commit message. - begin with rc = 0 and set it to -ENOMEM ahead of if(). --- xen/arch/x86/smpboot.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 82c1012e892f..e90c4dfa8a88 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -696,6 +696,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) l3_pgentry_t *pl3e; l2_pgentry_t *pl2e; l1_pgentry_t *pl1e; + int rc = 0; /* * Sanity check 'linear'. We only allow cloning from the Xen virtual @@ -736,7 +737,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) pl1e = l2e_to_l1e(*pl2e) + l1_table_offset(linear); flags = l1e_get_flags(*pl1e); if ( !(flags & _PAGE_PRESENT) ) - return 0; + goto out; pfn = l1e_get_pfn(*pl1e); } } @@ -744,8 +745,9 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) if ( !(root_get_flags(rpt[root_table_offset(linear)]) & _PAGE_PRESENT) ) { pl3e = alloc_xen_pagetable(); + rc = -ENOMEM; if ( !pl3e ) - return -ENOMEM; + goto out; clear_page(pl3e); l4e_write(&rpt[root_table_offset(linear)], l4e_from_paddr(__pa(pl3e), __PAGE_HYPERVISOR)); @@ -758,8 +760,9 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) if ( !(l3e_get_flags(*pl3e) & _PAGE_PRESENT) ) { pl2e = alloc_xen_pagetable(); + rc = -ENOMEM; if ( !pl2e ) - return -ENOMEM; + goto out; clear_page(pl2e); l3e_write(pl3e, l3e_from_paddr(__pa(pl2e), __PAGE_HYPERVISOR)); } @@ -774,8 +777,9 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) ) { pl1e = alloc_xen_pagetable(); + rc = -ENOMEM; if ( !pl1e ) - return -ENOMEM; + goto out; clear_page(pl1e); l2e_write(pl2e, l2e_from_paddr(__pa(pl1e), __PAGE_HYPERVISOR)); } @@ -796,7 +800,9 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt) else l1e_write(pl1e, l1e_from_pfn(pfn, flags)); - return 0; + rc = 0; + out: + return rc; } DEFINE_PER_CPU(root_pgentry_t *, root_pgt);