From patchwork Tue May 14 09:00:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 164115 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp2364301ili; Tue, 14 May 2019 02:00:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQ0mPHsfu8xX1VqSMP+7dUMI9eRYmakpspQC/cFjZ1hx4uJz++SbYdJQaFb2LMqVmW1b9W X-Received: by 2002:a17:902:364:: with SMTP id 91mr35883740pld.72.1557824436031; Tue, 14 May 2019 02:00:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557824436; cv=none; d=google.com; s=arc-20160816; b=KjRS6+z9jo2ifOJpXIM6gZDeDqmeUeFant4KxmwFyhiUuqjDSsAGDSHJNNT60ycG2b SbD8tmcc8Wor9nShE3uqNVoyALYvnYW9Ep+mM5HeXx1a4LiTE14gx2KUCLsFUiWl7Ros cylSpAIR4+wrpLfrqUpFolSvUpiowA52/Eg7udA8y163BpmqBNLFvMIvVGKrQHo5/JbV 7h/iLxnY8Z3IOnQnGC6vjjytQUyIffa7DUioyBQ7E+JnuywiJBjGJT78y8Ck/Xz6NjsV xVmum1n8e7RReI0wqQ37Klg33g3lRKvUVuZ5knU59UYJ4HjTgr13xyxwgrNUbgs/m3CY hXDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Oxn8ZWy/d9eOhE/ZHo/3Iao84Hx2qGyQiijGoy+Ys6I=; b=DOqFQef93ZPl81rcDzcUhDJpUGtpCjzhW96T3tpdp6H4+2DIqE64eazoDIM2KnBsLd i6NlOqQhCuZ1dnvn6M9LQGZFxZ+1W9a0nHfU7JiPi3CwoXHqP3d5qFLxMN5ILyFP6XSk FqV/dVLcmeN96JqofbBcbUykrNXDaOzhis6Bx178xzAfhOaa/YxHM0r1mDwkWt4vSWU6 tJ0x+GDRQfY9iphZ1hI6lcRMp8OubWDHFNbDnnXEurpaLNh++0BzXf38CNAcF/X/z4VY vqknbylqR/e/zKR9MoCd3P4RiUnnjNRYLkQzaAl++EKm24chhNBFYUfln4FkVwFpYuRT NonQ== 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 j18si11519809pgm.561.2019.05.14.02.00.35; Tue, 14 May 2019 02:00:36 -0700 (PDT) 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 S1726772AbfENJAe (ORCPT + 30 others); Tue, 14 May 2019 05:00:34 -0400 Received: from foss.arm.com ([217.140.101.70]:52012 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726058AbfENJAe (ORCPT ); Tue, 14 May 2019 05:00:34 -0400 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 B70E915AB; Tue, 14 May 2019 02:00:33 -0700 (PDT) Received: from p8cg001049571a15.arm.com (unknown [10.163.1.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EAEF03F71E; Tue, 14 May 2019 02:00:25 -0700 (PDT) From: Anshuman Khandual To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org, catalin.marinas@arm.com, will.deacon@arm.com Cc: mhocko@suse.com, mgorman@techsingularity.net, james.morse@arm.com, mark.rutland@arm.com, robin.murphy@arm.com, cpandya@codeaurora.org, arunks@codeaurora.org, dan.j.williams@intel.com, osalvador@suse.de, david@redhat.com, cai@lca.pw, logang@deltatee.com, ira.weiny@intel.com Subject: [PATCH V3 3/4] arm64/mm: Inhibit huge-vmap with ptdump Date: Tue, 14 May 2019 14:30:06 +0530 Message-Id: <1557824407-19092-4-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1557824407-19092-1-git-send-email-anshuman.khandual@arm.com> References: <1557824407-19092-1-git-send-email-anshuman.khandual@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Rutland The arm64 ptdump code can race with concurrent modification of the kernel page tables. At the time this was added, this was sound as: * Modifications to leaf entries could result in stale information being logged, but would not result in a functional problem. * Boot time modifications to non-leaf entries (e.g. freeing of initmem) were performed when the ptdump code cannot be invoked. * At runtime, modifications to non-leaf entries only occurred in the vmalloc region, and these were strictly additive, as intermediate entries were never freed. However, since commit: commit 324420bf91f6 ("arm64: add support for ioremap() block mappings") ... it has been possible to create huge mappings in the vmalloc area at runtime, and as part of this existing intermediate levels of table my be removed and freed. It's possible for the ptdump code to race with this, and continue to walk tables which have been freed (and potentially poisoned or reallocated). As a result of this, the ptdump code may dereference bogus addresses, which could be fatal. Since huge-vmap is a TLB and memory optimization, we can disable it when the runtime ptdump code is in use to avoid this problem. Fixes: 324420bf91f60582 ("arm64: add support for ioremap() block mappings") Signed-off-by: Mark Rutland Signed-off-by: Anshuman Khandual Cc: Ard Biesheuvel Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/mm/mmu.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) -- 2.7.4 Acked-by: Ard Biesheuvel diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index ef82312..37a902c 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -955,13 +955,18 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys) int __init arch_ioremap_pud_supported(void) { - /* only 4k granule supports level 1 block mappings */ - return IS_ENABLED(CONFIG_ARM64_4K_PAGES); + /* + * Only 4k granule supports level 1 block mappings. + * SW table walks can't handle removal of intermediate entries. + */ + return IS_ENABLED(CONFIG_ARM64_4K_PAGES) && + !IS_ENABLED(CONFIG_ARM64_PTDUMP_DEBUGFS); } int __init arch_ioremap_pmd_supported(void) { - return 1; + /* See arch_ioremap_pud_supported() */ + return !IS_ENABLED(CONFIG_ARM64_PTDUMP_DEBUGFS); } int pud_set_huge(pud_t *pudp, phys_addr_t phys, pgprot_t prot)