From patchwork Thu May 12 11:48:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 9079611 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C98B09FF69 for ; Thu, 12 May 2016 11:51:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 05578201FA for ; Thu, 12 May 2016 11:51:27 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 41D2420219 for ; Thu, 12 May 2016 11:51:25 +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 1b0p79-0004Vr-TQ; Thu, 12 May 2016 11:49:11 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0p79-0004Vl-IN for xen-devel@lists.xen.org; Thu, 12 May 2016 11:49:11 +0000 Received: from [193.109.254.147] by server-5.bemta-14.messagelabs.com id CE/69-03971-6BD64375; Thu, 12 May 2016 11:49:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrMIsWRWlGSWpSXmKPExsVyMfTAYd1tuSb hBnO28Fss+biYxYHR4+ju30wBjFGsmXlJ+RUJrBnPnx9lLGgXqDjY0M7WwLiCt4uRi0NIYCKj RPvK1awgDovASxaJOY3bmEAcCYF+VolPiw4BZTiBnBiJde1nGLsYOYDsaom5H/xAwkICKhJzN /UwQkzqYZJombGaHSTBJqAmceT9TEYQW0TAW2Lnh25mEJtZQFJi6vGvTCC2sICbxOnt+1hAbB YBVYmL6+eA2bwCLhKnPh6B2isnMeV+OxPIXk4BV4mHv1RBTCGgkusXaicwCixgZFjFqF6cWlS WWqRrppdUlJmeUZKbmJmja2hoopebWlycmJ6ak5hUrJecn7uJERhUDECwg/HvBOdDjJIcTEqi vLkmJuFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHjVc4BygkWp6akVaZk5wPCGSUtw8CiJ8GqBp HmLCxJzizPTIVKnGI05tvy+tpaJY9vUe2uZhFjy8vNSpcR5X2YDlQqAlGaU5sENgsXdJUZZKW FeRqDThHgKUotyM0tQ5V8xinMwKgnzSoIs5MnMK4Hb9wroFCagU6qvG4GcUpKIkJJqYGRyjLq ZzhgvulO0znL9lOmbFmeczo08t73TT6iiryBeJTGsWWKCtE2r2s207umXde5dF/GbfnhdCLPh nzmrXV2Fnid6P2Nl3Z77W/NEj++71z/Zd7nc+xqTuCr+zWm9T+WFG/ftVJaMK7ggWBWsxbh60 0vr4N+rMz9c4r/nn2ywL49h+tcAGyWW4oxEQy3mouJEAECVW3y2AgAA X-Env-Sender: van.freenix@gmail.com X-Msg-Ref: server-12.tower-27.messagelabs.com!1463053748!41121233!1 X-Originating-IP: [209.85.192.195] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28110 invoked from network); 12 May 2016 11:49:09 -0000 Received: from mail-pf0-f195.google.com (HELO mail-pf0-f195.google.com) (209.85.192.195) by server-12.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 12 May 2016 11:49:09 -0000 Received: by mail-pf0-f195.google.com with SMTP id 145so6245786pfz.1 for ; Thu, 12 May 2016 04:49:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mGTTP+v31QSFIdqNuu19qWZDWLVHG5rsVhIZoTalui4=; b=GLzJMdBIoPXkJCAXzvWXr55bMHA1oonkNz/bjus2k/9IqIZeLF3D4iclDjoKUvK/+o 8uioEJD/oiuWsxu8iihbKIcI+YvMoGogpTt6Hcp6Mk7OjStCRKRwEn1nxtnfuefUvZqj k9ic5Ng3fpav7dIl1qkYhbAcf8l8Bv38K5pr6Lc45v8h0MIBk2vLKUUwvtLUGlU1fHsU T32f3lUE4XTa00JZMue8Ixojrriu9EhvpyrkwDJImtbT6MJV8BfoeOAfcdOYrrQRdlVf FOShURip54i8bMemaYfYCTCwYV0EYmUhBP8FqOXD8XtkrVp9N+OYdY4DaaIjPpGQLIzG vOdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mGTTP+v31QSFIdqNuu19qWZDWLVHG5rsVhIZoTalui4=; b=BDkU9Twkb7OUvAS+S+E3wz2y02/7RX71t/5HJcZHGDxDssgA7b0WBy9ZZAa1GScRWE hdPLtyQa3qz0TaIWKP6fEc2ziNHRcckVrnnTd3Q62YTlsxUiagDtyhiL5P3bNraSHCUl TBf9+7iuRGmAM2cI9msVOMahi2VT9gY1KJ3xHWZz7PKRzbmnbxlPTnTuz1jk1vNmN3FC t3YcxgsQIZuFKjiAfeYXj0KlktVLHLBVX+MC8iHEV4i7RWpvXc9oUPGta7GOtYldo+tz qY35nzNYzmgAIOEJg/kDqbxIWGlgRl88Gh9wxnmjVdlwO9U/hEUG3Njd2qDzVntjFPIy FkrA== X-Gm-Message-State: AOPr4FWEkTmH8eYtEkSbkKaXntCkLUDUWWOXCDncBPy3jx6HcCPkerMj93NsOyn265LMBw== X-Received: by 10.98.46.130 with SMTP id u124mr12817865pfu.134.1463053748168; Thu, 12 May 2016 04:49:08 -0700 (PDT) Received: from linux-7smt.suse (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id d186sm19351064pfa.45.2016.05.12.04.49.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 May 2016 04:49:07 -0700 (PDT) From: Peng Fan To: xen-devel@lists.xen.org, julien.grall@arm.com, sstabellini@kernel.org Date: Thu, 12 May 2016 19:48:48 +0800 Message-Id: <1463053728-3624-2-git-send-email-van.freenix@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1463053728-3624-1-git-send-email-van.freenix@gmail.com> References: <1463053728-3624-1-git-send-email-van.freenix@gmail.com> Cc: van.freenix@gmail.com Subject: [Xen-devel] [PATCH V3 2/2] xen/arm: mm: clean up code in setup_pagetables 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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The base of address for the relocated xen needs to be mapped at the same virtual address (BOOT_RELOC_VIRT_START) in both the boot and runtime page tables. So we can merge the two pieces of code into on code block Also no need to use write_pte when mapping BOOT_RELOC_VIRT_START in xen_second, because CPU0 is using boot page tables. Signed-off-by: Peng Fan Cc: Stefano Stabellini Cc: Julien Grall Reviewed-by: Julien Grall --- V3: Refine the commit log. V2: Follow Julien's comments: split the V1 patch into two patches, this patch is the code movement part. xen/arch/arm/mm.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index addd699..0a4f845 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -443,11 +443,6 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) lpae_t pte, *p; int i; - /* Map the destination in the boot misc area. */ - dest_va = BOOT_RELOC_VIRT_START; - pte = mfn_to_xen_entry(xen_paddr >> PAGE_SHIFT, WRITEALLOC); - write_pte(xen_second + second_table_offset(dest_va), pte); - /* Calculate virt-to-phys offset for the new location */ phys_offset = xen_paddr - (unsigned long) _start; @@ -494,9 +489,12 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) pte = boot_second[second_table_offset(BOOT_FDT_VIRT_START)]; xen_second[second_table_offset(BOOT_FDT_VIRT_START)] = pte; - /* Map the destination in the boot misc area. */ + /* ... Boot Misc area for xen relocation */ dest_va = BOOT_RELOC_VIRT_START; pte = mfn_to_xen_entry(xen_paddr >> PAGE_SHIFT, WRITEALLOC); + /* Map the destination in xen_second. */ + xen_second[second_table_offset(dest_va)] = pte; + /* Map the destination in boot_second. */ write_pte(boot_second + second_table_offset(dest_va), pte); flush_xen_data_tlb_range_va_local(dest_va, SECOND_SIZE); #ifdef CONFIG_ARM_64