From patchwork Wed May 11 07:59:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 9065701 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 78403BF29F for ; Wed, 11 May 2016 08:02:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9DBC620142 for ; Wed, 11 May 2016 08:02:33 +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 B34DB2010B for ; Wed, 11 May 2016 08:02:32 +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 1b0P4B-0006D2-8n; Wed, 11 May 2016 08:00:23 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b0P4A-0006Cw-AY for xen-devel@lists.xen.org; Wed, 11 May 2016 08:00:22 +0000 Received: from [193.109.254.147] by server-2.bemta-14.messagelabs.com id 5D/79-03279-596E2375; Wed, 11 May 2016 08:00:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmkeJIrShJLcpLzFFi42K5GHrHRXfKM6N wgynnrCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oyuKbkFzUIVJ/60MDUwzubvYuTiEBKYwCix vmcvE4jDInCJReLJ9CXsII6EwDsWiQf79zB2MXICOTESF5bOZ4GwyyV6Lx5kBbGFBFQk5m7qY YSwO5gk2tcJgthsAmoSR97PBIuLCHhL7PzQzQxiMwtISkw9/pUJxBYWMJfo+/KVDcRmEVCVeP GmB2gmBwevgKvEmUWaEKvkJKbcb2eawMi3gJFhFaN6cWpRWWqRroVeUlFmekZJbmJmjq6hoYl ebmpxcWJ6ak5iUrFecn7uJkZgkDAAwQ7GjZOcDzFKcjApifKWtRuFC/El5adUZiQWZ8QXleak Fh9ilOHgUJLgXf4UKCdYlJqeWpGWmQMMV5i0BAePkghvA0iat7ggMbc4Mx0idYrRmGPL72trm Ti2Tb23lkmIJS8/L1VKnLcCpFQApDSjNA9uECyOLjHKSgnzMgKdJsRTkFqUm1mCKv+KUZyDUU mYNwNkCk9mXgncvldApzABnVJ9HeyUkkSElFQD47Y57/TLfYwvRT711eI46p0jHncg0KMjrt+ OXdu8pPbVpM4HtW0vhD8ly950WHhx8e4wv/Plcyfqq16ZUhH/Q/lP4sLVZ9aejYudKp+wN9Vv RidvzqWHrxtiPb83mIhr33w0a4tWvr2/+zTbvomzlZ+e1Uq7d26m0avUcuOS6Nc1qQZvkg12K 7EUZyQaajEXFScCADlkyy+eAgAA X-Env-Sender: van.freenix@gmail.com X-Msg-Ref: server-13.tower-27.messagelabs.com!1462953619!40799877!1 X-Originating-IP: [209.85.220.68] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 63215 invoked from network); 11 May 2016 08:00:20 -0000 Received: from mail-pa0-f68.google.com (HELO mail-pa0-f68.google.com) (209.85.220.68) by server-13.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 11 May 2016 08:00:20 -0000 Received: by mail-pa0-f68.google.com with SMTP id gh9so3040704pac.0 for ; Wed, 11 May 2016 01:00:20 -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; bh=aKGuMwmEIgAD2cwoC434BEdkX0L2eUyg8cPma0hg4kA=; b=L1zSOl5i6aJoB8k5dw/ToUsGGhdNcCXel7rOEYXh0HhSHZrSkhZfsYbwYMP4bSfPvQ G6oPGZNVD0rRoN0MiN9riEyXsrI8D36VegVLxTijPGEsVGg/5Vbk9lI20Kjs83cfviAN NrzwiZLdvddcT9dwybxdyWhtwkhjciav0YX6Pt6ICOLITy/8KBwQDOhbuodcc/sjQnti Wn+EzAV2KHMVav68HflkHDX1iKpY/pIogaziuFb7yvW/Ej72Bu5SYlU1Hs5s/Z/tAtch Nw79PuAf4T6ll/Wa+kOxW83m7wbfebA1hGRaN4ImGSiZfynStoYhCMZBQEbaJlJw5BiO dXtg== 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; bh=aKGuMwmEIgAD2cwoC434BEdkX0L2eUyg8cPma0hg4kA=; b=OwQGsRPxI6jk8z9607uMbR8o3KZroOUBGwmMhJ8K+yY19cNJjlWKvkoIgqMgakFE4+ PZzC4hzlk8Wwhv3TIum9caVDOaa2xiUZQEVM4hhbUyTdNyEIb1ZoEUS7+V83wtMgvmrP T9rNiMzQDp+dlM3px9QBs0rCL1Ewei0MNSLnfUZkYASgVuDuc11jQiYM0iQgQe1gz8E1 T5lB1k1P7d++S2oxA2TCB0iIOQ1P9Xp7XtrANjGBQXO1oGMWisxh/5dajz5QiaVl3+/l OSe3yFwTXaIlvAiK019cT4nYT+XdtP5BEGV6sc0CEDccGRsI2oKgMdI76PEJyWGm7JB5 +YQA== X-Gm-Message-State: AOPr4FUB0NHW2CQKnA8t98cwFK4CFgv3Xsk0WRpxWWhv88t0SbeEQ8aJmHYwFjE9naUq+A== X-Received: by 10.66.63.98 with SMTP id f2mr2693704pas.123.1462953618817; Wed, 11 May 2016 01:00:18 -0700 (PDT) Received: from linux-7smt.suse (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id 5sm9753325pfi.91.2016.05.11.01.00.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 May 2016 01:00:18 -0700 (PDT) From: Peng Fan To: xen-devel@lists.xen.org, julien.grall@arm.com, sstabellini@kernel.org Date: Wed, 11 May 2016 15:59:58 +0800 Message-Id: <1462953598-20802-1-git-send-email-van.freenix@gmail.com> X-Mailer: git-send-email 2.6.2 Cc: van.freenix@gmail.com Subject: [Xen-devel] [PATCH] xen/arm: mm: optimize 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 Before relocating xen to high address, need to build the mapping BOOT_RELOC_VIRT_START to xen_paddr into boot_pgtable and xen_pgtable. In setup_pagetables, relocate_xen will switch the root page table from boot_pgtable to xen_pgtable/cpu0_pgtable. Before relocate_xen: If touching xen_pgtable, no need to flush_xen_data_tlb_range_va_local. We only need to flush tlb when touch boot_pgtable. And no need to use write_pte for xen_pgtable, we can simply use "xen_second[second_table_offset(dest_va)] = pte;" Also move the piece code near DTB/Fixmap/XEN_VIRT_START to be more easier to understand. Signed-off-by: Peng Fan Cc: Stefano Stabellini Cc: Julien Grall --- There is no function change in this patch, I just think there is no need to use flush_xen_data_tlb_range_va_local and write_pte at that point. And I tested this patch on AArch64. xen/arch/arm/mm.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 94ea054..bebd82f 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -443,12 +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); - flush_xen_data_tlb_range_va_local(dest_va, SECOND_SIZE); - /* Calculate virt-to-phys offset for the new location */ phys_offset = xen_paddr - (unsigned long) _start; @@ -498,6 +492,11 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) /* Map the destination in the boot misc area. */ dest_va = BOOT_RELOC_VIRT_START; pte = mfn_to_xen_entry(xen_paddr >> PAGE_SHIFT, WRITEALLOC); + xen_second[second_table_offset(dest_va)] = pte; + + /* 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(boot_second + second_table_offset(dest_va), pte); flush_xen_data_tlb_range_va_local(dest_va, SECOND_SIZE); #ifdef CONFIG_ARM_64