Received: by 10.223.185.116 with SMTP id b49csp1021110wrg; Wed, 21 Feb 2018 10:42:05 -0800 (PST) X-Google-Smtp-Source: AH8x226Gt0K1uYFr5CUQCHN9gGOn8hhzd6D9KVfJNoPI5DKRiH9j2a2vD32OaMr+/8rD3IKKKGfP X-Received: by 10.99.97.86 with SMTP id v83mr3434413pgb.138.1519238525737; Wed, 21 Feb 2018 10:42:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519238525; cv=none; d=google.com; s=arc-20160816; b=0Vp1WCVYcO4tjINPXLYvXOOrQANqjKYOM/NAxWfDHbuPuFOxo44EPaXx8n/OcRXOs5 od/K8lQDJTdWdnay3KnCGlbXfhCJYK7MQXf5Aiw0b4RC8/N4kFRirlNYtBuR/fr5fgC3 fDjSkOvuzay2WCh3Fw+JiY6+Ce1vtbXXOkx5uQzjGE8mrWlfDDJIz42Zrck7ZfZ6Hgk/ goTKLryzb38y+JZOORFmuk9WxaaUVo6J/V0x2uWpojPQqDRSrlcP5oSpVbIfR3gSGuo3 pZ2nBM4NzGI981jpfr6QU24xKVQfqLGMtmRvLMhePv11J786IOryHely/HngVf+mVyiN 3M6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Q6LGJFeJpK4n2UpScrE/oxJn7np4o1a732IF6DKv+/g=; b=SAluaZNiBb4UmuX+mbNs3V/sADSXgKwvmWvMqJA1wh1bAX4Tfrn1eZHzMRXrC+UHEw ePYIqAKPFyqshoLXvvaKq6DPdqDaVT4/PHxUaks42ZRENHAh5GJx9rbKCXwcbe4/KUEZ cP3b/LAD15o9cyn5gcnlByqu5YUGfsmM5RuPM4uI9ymZgEtRWyeqQyOviQcyBc7uuE+G tArEHYF81LzKtffjuHS5S89Rdtot6srw0WUdzqTP4RQhZPo+CSBC8NOzwv6IikewMSX7 Y2SauIuQhELo7qgP3O1N+el4R4Ihzx08sseGqefewVITHikIdOcP+TMvgmJMLLYZpB5f CD3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b65si7021293pgc.70.2018.02.21.10.41.51; Wed, 21 Feb 2018 10:42:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936640AbeBUNXm (ORCPT + 99 others); Wed, 21 Feb 2018 08:23:42 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:44968 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933524AbeBUNLa (ORCPT ); Wed, 21 Feb 2018 08:11:30 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 433AF89C; Wed, 21 Feb 2018 13:11:29 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Will Deacon , Catalin Marinas Subject: [PATCH 4.15 128/163] arm64: proc: Set PTE_NG for table entries to avoid traversing them twice Date: Wed, 21 Feb 2018 13:49:17 +0100 Message-Id: <20180221124537.197753532@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124529.931834518@linuxfoundation.org> References: <20180221124529.931834518@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Will Deacon commit 2ce77f6d8a9ae9ce6d80397d88bdceb84a2004cd upstream. When KASAN is enabled, the swapper page table contains many identical mappings of the zero page, which can lead to a stall during boot whilst the G -> nG code continually walks the same page table entries looking for global mappings. This patch sets the nG bit (bit 11, which is IGNORED) in table entries after processing the subtree so we can easily skip them if we see them a second time. Tested-by: Mark Rutland Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas Signed-off-by: Greg Kroah-Hartman --- arch/arm64/mm/proc.S | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) --- a/arch/arm64/mm/proc.S +++ b/arch/arm64/mm/proc.S @@ -189,7 +189,8 @@ ENDPROC(idmap_cpu_replace_ttbr1) dc cvac, cur_\()\type\()p // Ensure any existing dirty dmb sy // lines are written back before ldr \type, [cur_\()\type\()p] // loading the entry - tbz \type, #0, next_\()\type // Skip invalid entries + tbz \type, #0, skip_\()\type // Skip invalid and + tbnz \type, #11, skip_\()\type // non-global entries .endm .macro __idmap_kpti_put_pgtable_ent_ng, type @@ -249,8 +250,9 @@ ENTRY(idmap_kpti_install_ng_mappings) add end_pgdp, cur_pgdp, #(PTRS_PER_PGD * 8) do_pgd: __idmap_kpti_get_pgtable_ent pgd tbnz pgd, #1, walk_puds - __idmap_kpti_put_pgtable_ent_ng pgd next_pgd: + __idmap_kpti_put_pgtable_ent_ng pgd +skip_pgd: add cur_pgdp, cur_pgdp, #8 cmp cur_pgdp, end_pgdp b.ne do_pgd @@ -278,8 +280,9 @@ walk_puds: add end_pudp, cur_pudp, #(PTRS_PER_PUD * 8) do_pud: __idmap_kpti_get_pgtable_ent pud tbnz pud, #1, walk_pmds - __idmap_kpti_put_pgtable_ent_ng pud next_pud: + __idmap_kpti_put_pgtable_ent_ng pud +skip_pud: add cur_pudp, cur_pudp, 8 cmp cur_pudp, end_pudp b.ne do_pud @@ -298,8 +301,9 @@ walk_pmds: add end_pmdp, cur_pmdp, #(PTRS_PER_PMD * 8) do_pmd: __idmap_kpti_get_pgtable_ent pmd tbnz pmd, #1, walk_ptes - __idmap_kpti_put_pgtable_ent_ng pmd next_pmd: + __idmap_kpti_put_pgtable_ent_ng pmd +skip_pmd: add cur_pmdp, cur_pmdp, #8 cmp cur_pmdp, end_pmdp b.ne do_pmd @@ -317,7 +321,7 @@ walk_ptes: add end_ptep, cur_ptep, #(PTRS_PER_PTE * 8) do_pte: __idmap_kpti_get_pgtable_ent pte __idmap_kpti_put_pgtable_ent_ng pte -next_pte: +skip_pte: add cur_ptep, cur_ptep, #8 cmp cur_ptep, end_ptep b.ne do_pte