From patchwork Mon Jun 19 16:57:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9796851 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BB3BC600C5 for ; Mon, 19 Jun 2017 17:00:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A29D927F92 for ; Mon, 19 Jun 2017 17:00:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97573281F9; Mon, 19 Jun 2017 17:00:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 47BE427F8F for ; Mon, 19 Jun 2017 17:00:35 +0000 (UTC) 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-0003yk-L0; Mon, 19 Jun 2017 16:58:18 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN00G-0003pe-LC for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:16 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id B9/5E-23755-8A208495; Mon, 19 Jun 2017 16:58:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTXc5k0e kQXOnhcWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmrFk8lOWgi0CFau3nGJpYLzL3cXIxSEksJlR YsO8ycwQzmlGid57h1m6GDk52AQ0Je58/sQEYosISEtc+3yZEcRmFnCQePPxHliNsECUxMyVk 8BsFgFViXu3FoLZvAJWEpt3vmYGsSUE5CV2tV1kBbE5geLf518DmyMkYClx/MkttgmM3AsYGV YxqhenFpWlFula6iUVZaZnlOQmZuboGhoY6+WmFhcnpqfmJCYV6yXn525iBPq3noGBcQfj659 OhxglOZiURHln/XePFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBq8roESkkWJSanlqRlpkDDDSY tAQHj5IIb81voFbe4oLE3OLMdIjUKUZdjhVvd31hEmLJy89LlRLnPQkyQwCkKKM0D24ELOgvM cpKCfMyMjAwCPEUpBblZpagyr9iFOdgVBLm7QK5kiczrwRu0yugI5iAjmA+4wJyREkiQkqqgd Fh8YVWqS0XYzds3n2R1/vKpCcx7Ju+LetX2yh2y+Ss0efLXyPzaorvh32drXGfLXexivfUeM7 cTWa51+e8khbYerdtF2fH/B0/+0xbK3VFBffsrFJKnvOVYVnD04+fFtzK/xzqODWxtbvAiu+u 4NbMP0obZz30LT7DGPEnXiarOWT9wR6jYF4lluKMREMt5qLiRAAyIRdrdQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1497891495!105722322!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 20311 invoked from network); 19 Jun 2017 16:58:15 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-13.tower-31.messagelabs.com with SMTP; 19 Jun 2017 16:58:15 -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 2873D165C; Mon, 19 Jun 2017 09:58:15 -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 7A31C3F41F; Mon, 19 Jun 2017 09:58:14 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:51 +0100 Message-Id: <20170619165753.25049-15-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 14/16] xen/arm: mm: Use lpae_valid and lpae_table 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" X-Virus-Scanned: ClamAV using ClamSMTP This newly introduced lpae_valid and lpae_table helpers will recude the code and make more readable. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Patch added --- xen/arch/arm/mm.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 8d34ae7279..6241c53821 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -991,8 +991,7 @@ static int create_xen_entries(enum xenmap_operation op, for(; addr < addr_end; addr += PAGE_SIZE, mfn = mfn_add(mfn, 1)) { - if ( !xen_second[second_linear_offset(addr)].pt.valid || - !xen_second[second_linear_offset(addr)].pt.table ) + if ( !lpae_table(xen_second[second_linear_offset(addr)]) ) { rc = create_xen_table(&xen_second[second_linear_offset(addr)]); if ( rc < 0 ) { @@ -1001,14 +1000,14 @@ static int create_xen_entries(enum xenmap_operation op, } } - BUG_ON(!xen_second[second_linear_offset(addr)].pt.valid); + BUG_ON(!lpae_valid(xen_second[second_linear_offset(addr)])); third = mfn_to_virt(xen_second[second_linear_offset(addr)].pt.base); switch ( op ) { case INSERT: case RESERVE: - if ( third[third_table_offset(addr)].pt.valid ) + if ( lpae_valid(third[third_table_offset(addr)]) ) { printk("create_xen_entries: trying to replace an existing mapping addr=%lx mfn=%"PRI_mfn"\n", addr, mfn_x(mfn)); @@ -1022,7 +1021,7 @@ static int create_xen_entries(enum xenmap_operation op, break; case MODIFY: case REMOVE: - if ( !third[third_table_offset(addr)].pt.valid ) + if ( !lpae_valid(third[third_table_offset(addr)]) ) { printk("create_xen_entries: trying to %s a non-existing mapping addr=%lx\n", op == REMOVE ? "remove" : "modify", addr);