From patchwork Tue Feb 20 11:40:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 128869 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4539502ljc; Tue, 20 Feb 2018 03:40:11 -0800 (PST) X-Google-Smtp-Source: AH8x2258FdUvscOFPEUtjjFr8X7j/xgbt9YnQLEXzcMbvhjmzCDJ3jC7owjhPyp6DKIXLaMb6bfR X-Received: by 10.98.141.65 with SMTP id z62mr3105434pfd.129.1519126810915; Tue, 20 Feb 2018 03:40:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519126810; cv=none; d=google.com; s=arc-20160816; b=k9r2f2ePx9lltvBgqcCs9FmA/njFGv9zxhc4oOmRf/+WxA35TWF6uxkkPIaOnsr1fF UsX0js5BndMjfkYRkZim+HW9zfG8rhMjdF4BaUrW/rNGJvNEhQscxCl5ZiEEqFGBVBgF oLvE2+DqZP4R6OCEEwI3zREDnRYPgl18qhtwk/kcuY/3j2b3V9BzZunPveMWtdHNuQ9i V5urOZ6JD3WAo6tLzwZOY+1wvBq3z+OWgUtXdTQrv4/c4ZvJMOAfr9p91Sm5j9isEBzc dQ3EErN/bTKPrZCtTLOlM72WBy7fIlLPpr1PvY5XUZG/pzkz+sNLIoTNL3E+tLMWOY+R tznA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=iOrtfM2tr2uEwnlmTeLdNhwRr4fQz3i3STKAOqj4qQM=; b=wkW8wsVn5wrJCJeQKiHXbue/yOwYerjk02gzPQP4Cu+Lp9KHeGJuMn42QuatDiIkRY JeYZrlWu760sjI0J+bFvvHC/7lNTBguXp+jCupf3RU/asKVKGSEaIyC91hZWcTJqigo8 lRIFn2ijYhVtcaVGFNmTmSQsazeuK4/cbdz2ieBuo/JbkFFbceluDZd3mrqI0tH0zBYZ MCvNaWX/fnEwId960e+XeLmEG9uNRVS8wT6t+iZCVDcFvKPLCu9vnnu2Uht1i3NtuY2Z mGseFGGVRAj/KFH+DGwMcP1EWHCQX8yi5Y1KbrNS6D9bf58GRSb47q7Ak+yOZMYozpq2 6bAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 f10-v6si8900355plm.169.2018.02.20.03.40.10; Tue, 20 Feb 2018 03:40:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751459AbeBTLkJ (ORCPT + 10 others); Tue, 20 Feb 2018 06:40:09 -0500 Received: from foss.arm.com ([217.140.101.70]:41734 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751402AbeBTLkJ (ORCPT ); Tue, 20 Feb 2018 06:40:09 -0500 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 DF7F31596; Tue, 20 Feb 2018 03:40:08 -0800 (PST) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AFF823F318; Tue, 20 Feb 2018 03:40:08 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 3AE4E1AE5429; Tue, 20 Feb 2018 11:40:08 +0000 (GMT) From: Will Deacon To: gregkh@linuxfoundation.org Cc: Will Deacon , , Catalin Marinas Subject: [PATCH] arm64: proc: Set PTE_NG for table entries to avoid traversing them twice Date: Tue, 20 Feb 2018 11:40:06 +0000 Message-Id: <1519126806-16595-1-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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. Cc: # 4.14+ Tested-by: Mark Rutland Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas --- arch/arm64/mm/proc.S | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) -- 2.1.4 diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S index 71baed7e592a..c0af47617299 100644 --- a/arch/arm64/mm/proc.S +++ b/arch/arm64/mm/proc.S @@ -205,7 +205,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 @@ -265,8 +266,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 @@ -294,8 +296,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 @@ -314,8 +317,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 @@ -333,7 +337,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