From patchwork Fri Jun 14 17:51:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 166873 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2351267ilk; Fri, 14 Jun 2019 10:53:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFJwEcsO4Ewu/iSeJ8/5golDI9UikyLZvirzNmTRJj1wF0mCsP4MUdb//v46lD8sZ9ur/k X-Received: by 2002:a02:b798:: with SMTP id f24mr65693943jam.97.1560534812500; Fri, 14 Jun 2019 10:53:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534812; cv=none; d=google.com; s=arc-20160816; b=VQxt/M8fbK2U/sgs+ue3v3L3swC2fO4B1FStR2+8ebstyInmntjZ1kBS5lrJ3tpR8i NF/JTrMo9xYNJZChhW+rLweZxV+F4ayR9Lo0IN3lpSc/aEFIj/PuZd2pxryCQyVEesw1 jP6lQQ2YEPnxbyM+2zXxlPOQfdjgALNBt8pW1BcxB6czP+PMbjlr5hQVGV3OVYkqKFOC x6iaIxSk6iriI2YZ0Xd/wgdwoGeDAaAxPZA3Up4GCR8Z4RhOH2MxINK5BA5C4dR+8v94 U/3SkWfGcll2FE9TfIzAZdvYydGj8owH+pAA3jNIBJGT/309pNBMmJtwTedDHWoVRSOr 7qNw== 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=1kXkSf/vh2dq+0XkIAgAaTpHwRwzHitb95Vu2KlD+Fs=; b=DOeSY6pXPLwIIGqF6J+7qdcUdNf35NsAoCqEP/ed5XGKEkgj/QkKCDdDYZi9GrxCWF JoGzZ/HtA3tcNqilk3iGwqUcH03W7ukxMfJgKSMPWIzC0tIMk2/CQIA1j2TgOU+lckm9 7ZioTP7ecjrwy2vYJL1UDeCvhpqE9soHXxoRA7WJRw268bCj6+f1/JFGS4TmZgoJ/BIs +wwXkCGCQjAQPiZmfC/wIvdTdSbRX7HDsp/AEqgLmhuwHqrMWdCO5d2iF6vpyG7LU2YC TVBTAKPM22+h/VJSDgUOqhW8/e/83WoJfu7GM8OWfqnQpANsdN38s634AaYeblCfV1yh ZRqg== 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 s6si3921720iot.110.2019.06.14.10.53.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jun 2019 10:53:32 -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 1hbqMq-0001oo-0Z; Fri, 14 Jun 2019 17:52:00 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hbqMo-0001nG-6z for xen-devel@lists.xenproject.org; Fri, 14 Jun 2019 17:51:58 +0000 X-Inumbo-ID: 19fa9a05-8ecd-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 19fa9a05-8ecd-11e9-8980-bc764e045a96; Fri, 14 Jun 2019 17:51:56 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 92969367; Fri, 14 Jun 2019 10:51:56 -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 AA3023F718; Fri, 14 Jun 2019 10:51:55 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Fri, 14 Jun 2019 18:51:39 +0100 Message-Id: <20190614175144.20046-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190614175144.20046-1-julien.grall@arm.com> References: <20190614175144.20046-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH MM-PART3 v3 4/9] 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 v3: - Add Stefano's reviewed-by 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 dcf041578b..b2b8bd3dc6 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1047,34 +1047,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; }