From patchwork Mon Jul 16 17:27:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 142081 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2677792ljj; Mon, 16 Jul 2018 10:29:46 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdCgZjy+x8/aYXL+FI+dpLK5tiPk1MIZ6RRbGxQ0OAscgxmWQof3VTOY71wswQNYKlE6N5k X-Received: by 2002:a24:35c8:: with SMTP id k191-v6mr13181690ita.81.1531762186106; Mon, 16 Jul 2018 10:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531762186; cv=none; d=google.com; s=arc-20160816; b=ybuRaY/mhSUz40mSjaIb4fSDEWQxzRZ/7TCmdCAE0FbnpE74xAevdeR1a+k/oP29bP JKEQjETUB68Vncj7zQ/OriuyK/wBhOLxTyUn/Yz5XomhcX4rSITEO+zM2YU5Ao1aHBrN O9RRB0cFTUQBgIq5vv51yYDJFqx35JemI1qqwrCpd4G2pzmJniH2qbgwaT5S8CcY1gyc G9/ME1WdnMf4ZEc5yMfcLTysCtgCo/C7gkJD+KwUvHQ1MSPY0t2FVdfU/ITZMzEYhHf3 I0Y3ZQqELo0/S4YdqnN382CIaBjsyejATczVXIh+Y8D2x8g6OHoJlK2ZS4Y9SygJlJ43 /K1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from :arc-authentication-results; bh=czJe+kh95aFFHjXNvnM9u2HDL9cTRVYjGSZzs3Vj+3A=; b=BulTaTvGp7wR+excZ7lEzlmobr91ErtIpSSSm4LdfpjnJio65D0LIq0NlAA2hzlkd1 11wbuyKF6xTnQ/QTGszzTXw1U5z6PB89ZU9sCD/hCA2I5zBIWqVwFGmBvhg0TeJS2P7/ JzadPdYmNfNxiUA/S1DzLPdx6AqavseCmCtAMwrLl+5iOqFo5FDAN1qTsq5urwpZ8ehb RvjDJiNQsf1w2HI67jq0zCgdN1zLoI7ydgs3o7ybKbk4MQwuG9718vtpCPf+kFdoYT7H nRFDqWm++gpPgDamq7zdAYltWK7AwzIhBjqHdIOk3BLq3pI6lVt07RA+zQY2KIrAEVoY ZufQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@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.google.com with ESMTPS id l2-v6si7141771jam.126.2018.07.16.10.29.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Jul 2018 10:29:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) 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 1ff7Hc-0006bz-8b; Mon, 16 Jul 2018 17:27:36 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ff7Ha-0006Z5-FI for xen-devel@lists.xenproject.org; Mon, 16 Jul 2018 17:27:34 +0000 X-Inumbo-ID: 8bc22178-891d-11e8-a6a9-d7ebe60f679a Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 8bc22178-891d-11e8-a6a9-d7ebe60f679a; Mon, 16 Jul 2018 17:27:42 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 22B5B1650; Mon, 16 Jul 2018 10:27:33 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 37D463F5B1; Mon, 16 Jul 2018 10:27:32 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 16 Jul 2018 18:27:10 +0100 Message-Id: <20180716172712.20294-14-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180716172712.20294-1-julien.grall@arm.com> References: <20180716172712.20294-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 13/15] xen/arm: p2m: Introduce a new variable removing_mapping in __p2m_set_entry X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Julien Grall , sstabellini@kernel.org, Julien Grall MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This is making the code slightly easier to understand. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/p2m.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 66d58fabd7..e826f57842 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -792,6 +792,8 @@ static int __p2m_set_entry(struct p2m_domain *p2m, unsigned int target = 3 - (page_order / LPAE_SHIFT); lpae_t *entry, *table, orig_pte; int rc; + /* A mapping is removed if the MFN is invalid. */ + bool removing_mapping = mfn_eq(smfn, INVALID_MFN); /* Convenience aliases */ const unsigned int offsets[4] = { @@ -817,9 +819,9 @@ static int __p2m_set_entry(struct p2m_domain *p2m, { /* * Don't try to allocate intermediate page table if the mapping - * is about to be removed (i.e mfn == INVALID_MFN). + * is about to be removed. */ - rc = p2m_next_level(p2m, mfn_eq(smfn, INVALID_MFN), + rc = p2m_next_level(p2m, removing_mapping, level, &table, offsets[level]); if ( rc == GUEST_TABLE_MAP_FAILED ) { @@ -830,7 +832,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m, * when removing a mapping as it may not exist in the * page table. In this case, just ignore it. */ - rc = mfn_eq(smfn, INVALID_MFN) ? 0 : -ENOENT; + rc = removing_mapping ? 0 : -ENOENT; goto out; } else if ( rc != GUEST_TABLE_NORMAL_PAGE ) @@ -925,7 +927,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m, if ( lpae_is_valid(orig_pte) ) p2m_remove_pte(entry, p2m->clean_pte); - if ( mfn_eq(smfn, INVALID_MFN) ) + if ( removing_mapping ) /* Flush can be deferred if the entry is removed */ p2m->need_flush |= !!lpae_is_valid(orig_pte); else