From patchwork Wed Apr 24 16:59:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 162794 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp895723jan; Wed, 24 Apr 2019 10:01:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzLWgRn7UiY2VSOrj+8qv9feG0/UlG1ihOqQElhe8FECIZWy+3Dk4wrsVBvgU1VOXIfyKMj X-Received: by 2002:a81:30d8:: with SMTP id w207mr17661294yww.362.1556125315720; Wed, 24 Apr 2019 10:01:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556125315; cv=none; d=google.com; s=arc-20160816; b=a62PtvMidJlmhPewZ4WoS82W5lsw+1CilrhR+ZpxGSLEJ3lWEtoYped+9mPrU61w5m 8HzELhvWm6Y941m0VHTTJ1KU+K10Yb12DiENVZ6N7USkFH9h3ddBdFqo417UCJtz4T1Q gXnbgSYOJcv0gXqkzmM7slmFYCYHJ+lDXy571Zu+jP4m8bIgu1LA0qQNdtPch5SkjJMT BPCSS8+4K8AaAeJeybSyf9YzzqmUjkgTQEYlLuk7XK7OyO2TC8ZtjlGp0wRFHZ5wWEar xqH2K4YeZtbim0DhtmRMOkqfpOr2FB2P6YPKJS4m/EIqQMG8/yGxN1/RhAvGDvNOOiYk smqA== 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=SXAhvy1mk1PIBcnA6Oz00f9u41NJpRNQO0PISrzh9Ag=; b=Gy+7srTct1xEAJOwU8e47mBUGkYaJsom6arHMveLZAMeYoVfVuVGrim7ScH8oHz34E 46w20yI75ZFOSpxuwh3spqIQYbHtlLv+RlDQdI+rY9mvh4erfmIW9VKz75k+1j1NTLig 0kQURuX7VA8RAJq/j1OgqIIlF1hm6VbdnfkPZVQEsY6qhEMVJYqXQ9oYEARj/wrq86YI XCRHteC1jwPYzy5CpyRXh2K+qQJ9e5kSYOw+Jo6DmF0rR/8QqsTHUOteBsx5m3OBayOO apnBZkkon505gsAz4zQ6fo4jEADii7+liistphiq0c8a5ecD1dgCpidzr8MXUQ41/XCv D2wA== 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 m83si14743307ywm.54.2019.04.24.10.01.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2019 10:01:55 -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 1hJLFp-0007ob-1c; Wed, 24 Apr 2019 17:00:17 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hJLFn-0007o4-OR for xen-devel@lists.xenproject.org; Wed, 24 Apr 2019 17:00:15 +0000 X-Inumbo-ID: 6dc2e40a-66b2-11e9-92d7-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 6dc2e40a-66b2-11e9-92d7-bc764e045a96; Wed, 24 Apr 2019 17:00:14 +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 1DB67EBD; Wed, 24 Apr 2019 10:00:14 -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 028153F557; Wed, 24 Apr 2019 10:00:12 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Wed, 24 Apr 2019 17:59:50 +0100 Message-Id: <20190424165955.23718-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190424165955.23718-1-julien.grall@arm.com> References: <20190424165955.23718-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 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 , sstabellini@kernel.org, Andrii_Anisov@epam.com 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 not 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 --- 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 5eb6f47d74..611ea53992 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1062,34 +1062,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; }