From patchwork Tue May 14 12:31:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 164197 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp2561791ili; Tue, 14 May 2019 05:32:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqysd1vCvh97K4NcIhC8ID5Sf4siL+eZChwN9WftFuhJiw4R63ouL8/i+ylH7vhyRoL5wtYJ X-Received: by 2002:a6b:6f08:: with SMTP id k8mr14761054ioc.104.1557837157325; Tue, 14 May 2019 05:32:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557837157; cv=none; d=google.com; s=arc-20160816; b=AsfXb4yOM0y7l/i9izFc8lIzBCMBGD6JB/LqwmaDb28WL4/IXEbyWhgQC7pfmSPE9U 7Yz6O9ef5yeH1TqkWGEDrL9UMwbzwZDaafW61No2Fyjs2XgWAxuDwITFjCq6bciAcCap 3Tpq1If5dXT3XJvNOs3mAbcEkq2BfI92cEhj+5x7sJ2ineTwXKIZQCwTLXszvQ6DYY6G ebhzD+LZr3zM7wBWUIOCOiE1e9X0473xhJhn8BnpF0hb+1Dqp5VyDETKALaixCfgsgmS vZDdfI4rrpBLg9T6oD9KnwSBUMT+n4XObg8zerYexq5KSaBSveIjwWKSPhN1n6mw+oub cZkA== 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; bh=636CpUsBf7lH75u4OaPdW//ylanrxAd2Ry/1iH7WNaQ=; b=T6563PMaDGVgK+d8Mq32YcvA2MPrnm/tFNt492mKeqpllQc2Nc227u8a4rMFvYKfpa s5vyU3ixi1UYsfFghmF5bkmVTchNWSgMTwjAJ0vby3p/WO62w7M2jJeMLuFkIFP10O7i 9G3SaXOwVYyNQDr9oX3vZtW+dv+I+7qlMG7KGi5TVKgVIpHxKkROCgV0xM6BXy7lIW5P O3IRnZeKbtQtWwf7NXq4z9p5Jg2Fke0iyIe0VhhK9OgyQsVhjGq2CM/wmwjcisk3QbOj CQJRZRx1RyU3mkpioQBr8gZtjIFmeSqCvDnZ29OXOGlPPMyklQPfOblagfnLoa9a5Dha 9nNg== 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 m84si9147090ioa.89.2019.05.14.05.32.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 May 2019 05:32:37 -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 1hQWau-0005O8-91; Tue, 14 May 2019 12:31:44 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hQWat-0005NT-26 for xen-devel@lists.xenproject.org; Tue, 14 May 2019 12:31:43 +0000 X-Inumbo-ID: 3a201512-7644-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 3a201512-7644-11e9-8980-bc764e045a96; Tue, 14 May 2019 12:31:41 +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 80C1315AB; Tue, 14 May 2019 05:31:41 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4CF8D3F71E; Tue, 14 May 2019 05:31:40 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 14 May 2019 13:31:20 +0100 Message-Id: <20190514123125.29086-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190514123125.29086-1-julien.grall@arm.com> References: <20190514123125.29086-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH MM-PART3 v2 07/12] xen/arm: mm: Rework xen_pt_update_entry to avoid use xenmap_operation 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: Oleksandr_Tyshchenko@epam.com, Julien Grall , Stefano Stabellini , Andrii Anisov MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" With the newly introduced flags, it is now possible to know how the page will be updated through the flags. All the use of xenmap_operation are now replaced with the flags. At the same time, validity check are now removed as they are gathered in xen_pt_check_entry(). Signed-off-by: Julien Grall Reviewed-by: Andrii Anisov Reviewed-by: Stefano Stabellini --- Changes in v2: - Fix typo in the commit message - Add Andrii's reviewed-by --- xen/arch/arm/mm.c | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 45a6f9287f..86e1faeeb5 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1067,34 +1067,33 @@ static int xen_pt_update_entry(enum xenmap_operation op, unsigned long addr, if ( !xen_pt_check_entry(*entry, mfn, flags) ) return -EINVAL; - switch ( op ) { - case INSERT: - case RESERVE: - if ( op == RESERVE ) - break; + /* If we are only populating page-table, then we are done. */ + if ( flags & _PAGE_POPULATE ) + return 0; + + /* We are removing the page */ + if ( !(flags & _PAGE_PRESENT) ) + memset(&pte, 0x00, sizeof(pte)); + else + { + /* We are inserting a mapping => Create new pte. */ + if ( !mfn_eq(mfn, INVALID_MFN) ) + { pte = mfn_to_xen_entry(mfn, PAGE_AI_MASK(flags)); - pte.pt.ro = PAGE_RO_MASK(flags); - pte.pt.xn = PAGE_XN_MASK(flags); - BUG_ON(!pte.pt.ro && !pte.pt.xn); + + /* Third level entries set pte.pt.table = 1 */ pte.pt.table = 1; - write_pte(entry, pte); - break; - case MODIFY: - case REMOVE: - if ( op == REMOVE ) - pte.bits = 0; - else - { - pte = *entry; - pte.pt.ro = PAGE_RO_MASK(flags); - pte.pt.xn = PAGE_XN_MASK(flags); - } - write_pte(entry, pte); - break; - default: - BUG(); + } + else /* We are updating the permission => Copy the current pte. */ + pte = *entry; + + /* Set permission */ + pte.pt.ro = PAGE_RO_MASK(flags); + pte.pt.xn = PAGE_XN_MASK(flags); } + write_pte(entry, pte); + return 0; }