From patchwork Mon Jun 19 16:57:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105904 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp942588obh; Mon, 19 Jun 2017 10:00:13 -0700 (PDT) X-Received: by 10.36.120.134 with SMTP id p128mr13553037itc.19.1497891612982; Mon, 19 Jun 2017 10:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891612; cv=none; d=google.com; s=arc-20160816; b=cwIVHXNxOwbNrUZpq2MMrWuftSWXVNCd7FyZPa8r0wT0VpEjVWueqIsflwuJO7K9hb HChk6k7oGxjbySWJKe1p+JTTIP4TQ8vrUSKogJf3Epp0GxIxdOtjTx22eUDZZAqbeYCZ 8dm2kcQXLeutq6NNPqWfE839bhpKg8iWGihFhK7EcIxasbio3RrJ1cITeJM/b2XvYhtz B21J1MXvSk7SnV8qUPhVGv6/PofWARTar8ebUI0S5AEbdHEsobYpc20Pf0Y+8gXv6GSD m52EFics4/5oRmxq0/o0gMwcSyUYaAdJT2WC3igQ3AE2v/t4mYXmX0wswGt5cifM3ien VBAQ== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=gdOd23kxgMOMRqLG0ZIC99T/12hy0dM587euPbYyMhc=; b=tC8Q6Ec4dfyxIRT4c1TOqZHeJI3139ESjjmrSzk0cDVPey4vyV15274miveRyjJN/K 2dBg5aiF3zoGw5eegInPxpfALPzfYko+CQ9kSoBeHqQqBqvv1T6Ak3mL3chwwXJcXRYz GQyOHiiSi2mH+ov5g5ABERJmr+FxizPUjCtyHLs8ph+RANuxtLQB6N96hvaKLmGe/ZWA YYhpkf+izOKb+qItpAi6df5nyLl/qr7VDxWKXondTmP7gXPOh9/O6/H/qmjhep1F5+mp ivZdEHdtBqSo1T/09MhnmsdmKBix+R++YDlND/rolod40jHMRzevi0HNE4Jab++01QoD ioOg== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id n138si10977585itn.73.2017.06.19.10.00.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 10:00:12 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN00I-0003zI-S1; Mon, 19 Jun 2017 16:58:18 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN00I-0003wv-0U for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:18 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id 90/3E-02956-9A208495; Mon, 19 Jun 2017 16:58:17 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTXcFk0e kwar5+hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8amY2tZC+5KVjT/3MbawHhBoIuRk0NIYDOj xIG5Xl2MXED2aUaJ39+bWUASbAKaEnc+f2ICsUUEpCWufb7MCGIzCzhIvPl4D6xGWCBSYtr24 +wgNouAqsT9LR/AangFrCSW/X7MDGJLCMhL7Gq7yApicwLFv8+/xgix2FLi+JNbbBMYuRcwMq xi1ChOLSpLLdI1NNdLKspMzyjJTczM0TU0MNPLTS0uTkxPzUlMKtZLzs/dxAj0LwMQ7GC8vTH gEKMkB5OSKO+s/+6RQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4NzF6RAoJFqWmp1akZeYAAw0m LcHBoyTCW/MbqJW3uCAxtzgzHSJ1ilGXY8XbXV+YhFjy8vNSpcR5T4LMEAApyijNgxsBC/pLj LJSwryMQEcJ8RSkFuVmlqDKv2IU52BUEuZ9CjKFJzOvBG7TK6AjmICOYD7jAnJESSJCSqqB0X DOOQ5h0XW3ZesXOzQnulYtjphzp2nOlXVCbg8KLLXSpCQjVDZYHci4nP3Rp/FX0o31iZVyKS3 mPQ85V7qcUc559yBm9c6zGy7pMIRVMS/cuV4xR9Uy5ss62775nyfKm0WuF+cwnjlBWX33ye9h VrGsAWe7lz16PtPx8Fb3SbPrObKyVC54KLEUZyQaajEXFScCAOpHi2B1AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1497891496!103807769!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21722 invoked from network); 19 Jun 2017 16:58:16 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-27.messagelabs.com with SMTP; 19 Jun 2017 16:58:16 -0000 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 178E01684; Mon, 19 Jun 2017 09:58:16 -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 6A71E3F41F; Mon, 19 Jun 2017 09:58:15 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:52 +0100 Message-Id: <20170619165753.25049-16-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619165753.25049-1-julien.grall@arm.com> References: <20170619165753.25049-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 15/16] xen/arm: mm: Introduce temporary variable in create_xen_entries X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" This is improving the code readability and avoid to dereference the table every single time we need to access the entry. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Patch added --- xen/arch/arm/mm.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 6241c53821..657fee0b17 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -986,28 +986,30 @@ static int create_xen_entries(enum xenmap_operation op, { int rc; unsigned long addr = virt, addr_end = addr + nr_mfns * PAGE_SIZE; - lpae_t pte; + lpae_t pte, *entry; lpae_t *third = NULL; for(; addr < addr_end; addr += PAGE_SIZE, mfn = mfn_add(mfn, 1)) { - if ( !lpae_table(xen_second[second_linear_offset(addr)]) ) + entry = &xen_second[second_linear_offset(addr)]; + if ( !lpae_table(*entry) ) { - rc = create_xen_table(&xen_second[second_linear_offset(addr)]); + rc = create_xen_table(entry); if ( rc < 0 ) { printk("create_xen_entries: L2 failed\n"); goto out; } } - BUG_ON(!lpae_valid(xen_second[second_linear_offset(addr)])); + BUG_ON(!lpae_valid(*entry)); - third = mfn_to_virt(xen_second[second_linear_offset(addr)].pt.base); + third = mfn_to_virt(entry->pt.base); + entry = &third[third_table_offset(addr)]; switch ( op ) { case INSERT: case RESERVE: - if ( lpae_valid(third[third_table_offset(addr)]) ) + if ( lpae_valid(*entry) ) { printk("create_xen_entries: trying to replace an existing mapping addr=%lx mfn=%"PRI_mfn"\n", addr, mfn_x(mfn)); @@ -1017,11 +1019,11 @@ static int create_xen_entries(enum xenmap_operation op, break; pte = mfn_to_xen_entry(mfn, ai); pte.pt.table = 1; - write_pte(&third[third_table_offset(addr)], pte); + write_pte(entry, pte); break; case MODIFY: case REMOVE: - if ( !lpae_valid(third[third_table_offset(addr)]) ) + if ( !lpae_valid(*entry) ) { printk("create_xen_entries: trying to %s a non-existing mapping addr=%lx\n", op == REMOVE ? "remove" : "modify", addr); @@ -1031,7 +1033,7 @@ static int create_xen_entries(enum xenmap_operation op, pte.bits = 0; else { - pte = third[third_table_offset(addr)]; + pte = *entry; pte.pt.ro = PTE_RO_MASK(ai); pte.pt.xn = PTE_NX_MASK(ai); if ( !pte.pt.ro && !pte.pt.xn ) @@ -1041,7 +1043,7 @@ static int create_xen_entries(enum xenmap_operation op, return -EINVAL; } } - write_pte(&third[third_table_offset(addr)], pte); + write_pte(entry, pte); break; default: BUG();