From patchwork Mon Nov 23 15:51:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 57166 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1515579lbb; Mon, 23 Nov 2015 07:54:04 -0800 (PST) X-Received: by 10.98.86.10 with SMTP id k10mr16854092pfb.85.1448294044005; Mon, 23 Nov 2015 07:54:04 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id fx1si20764191pbb.159.2015.11.23.07.54.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2015 07:54:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a0tPL-0001Oc-SF; Mon, 23 Nov 2015 15:51:59 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a0tPI-0001KR-VO for linux-arm-kernel@lists.infradead.org; Mon, 23 Nov 2015 15:51:57 +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 786CB49; Mon, 23 Nov 2015 07:51:19 -0800 (PST) Received: from e104818-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1953E3F51B; Mon, 23 Nov 2015 07:51:34 -0800 (PST) Date: Mon, 23 Nov 2015 15:51:32 +0000 From: Catalin Marinas To: Mark Rutland Subject: Re: [PATCH] [PATCH] arm64: Boot failure on m400 with new cont PTEs Message-ID: <20151123155132.GC32300@e104818-lin.cambridge.arm.com> References: <1447858999-26665-1-git-send-email-jeremy.linton@arm.com> <20151118152044.GD10644@leverpostej> <564CA29A.9050905@arm.com> <20151118162932.GA13355@leverpostej> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20151118162932.GA13355@leverpostej> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151123_075157_116244_A2E65431 X-CRM114-Status: GOOD ( 15.11 ) X-Spam-Score: -7.5 (-------) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-7.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.101.70 listed in list.dnswl.org] -0.6 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lauraa@codeaurora.org, ard.biesheuvel@linaro.org, jlinton@redhat.com, suzuki.poulose@arm.com, will.deacon@arm.com, Jeremy Linton , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org On Wed, Nov 18, 2015 at 04:29:32PM +0000, Mark Rutland wrote: > FWIW, Will had a patch [1] for detecting PTE level break-before-make > violations. I gave this a go on Juno with v4.4-rc1, and saw an issue in > the EFI virtmap code that I'm currently investigating. [...] > [1] https://git.kernel.org/cgit/linux/kernel/git/will/linux.git/commit/?h=aarch64/devel&id=372f39220ad35fa39a75419f2221ffeb6ffd78d3 I thought about adding a check for when we change from contiguous to non-contiguous or vice-versa, on top of Will's patch: --------------8<-------------------- --------------8<-------------------- Jeremy, can you give this fixup_init() patch a try, see whether it makes any difference (it's just a temporary hack which may prevent us from reverting the PTE_CONT patches until we have a better solution). Anyway, I think we should merge Will's patch since it's a handy debug tool. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index defbfde43a43..70e02e3b1a78 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -240,6 +240,10 @@ static inline void set_pte(pte_t *ptep, pte_t pte) if (WARN_ON((old & PTE_ATTRINDX_MASK) != (new & PTE_ATTRINDX_MASK))) goto pte_bad; + /* Changing contiguity may lead to a TLB conflict */ + if (WARN_ON((old & PTE_CONT) != (new & PTE_CONT))) + goto pte_bad; + /* Change of OA is only an issue if one mapping is writable */ if (!(old & new & PTE_RDONLY) && WARN_ON(pte_pfn(*ptep) != pte_pfn(pte))) --------------8<-------------------- But it doesn't look nice afterwards. It's the fixup_init() trying to re-write the entries and we start changing the PTE_CONT bit: Call trace: [] __create_mapping.isra.5+0x360/0x530 [] fixup_init+0x64/0x80 [] free_initmem+0xc/0x38 [] kernel_init+0x20/0xe0 [] ret_from_fork+0x10/0x40 What I don't get is why we have fixup_init() even when !CONFIG_DEBUG_RODATA. It probably breaks the initial mapping just to get a non-executable init section. However, the other sections are left executable when this config option is disabled. The patch below fixes the warnings above: --------------8<-------------------- diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index abb66f84d4ac..e0f82e1a1c09 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -482,9 +482,11 @@ void mark_rodata_ro(void) void fixup_init(void) { +#ifdef CONFIG_DEBUG_RODATA create_mapping_late(__pa(__init_begin), (unsigned long)__init_begin, (unsigned long)__init_end - (unsigned long)__init_begin, PAGE_KERNEL); +#endif } /*