From patchwork Mon May 20 05:18:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 164567 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp5153246ili; Sun, 19 May 2019 22:19:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFe6v4USzDW/PahL8vlqjSQV1P4T0LN/ekZn5BBlTc/gGvPHdk5zGRtXP0NEjXPCixlp4V X-Received: by 2002:a65:6449:: with SMTP id s9mr71342282pgv.90.1558329541660; Sun, 19 May 2019 22:19:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558329541; cv=none; d=google.com; s=arc-20160816; b=i0pkvdDyW1cshlx0t875MljhhMJtNmOK0BkmhcpcW45TIzoep3zJ54OAQA918aZVFf 1ehwDV8dphWrLCudCbivBqy76Fujv86c+1uJDjR/b3SRnkOGMBO2GX00YELZEZw8WPmh 3M1l6X3nVQpgMn7AjNRQgAeHKhdo43sSZAzeu+BCnUqxUC9ZSRqx+UV8sMxfncsvw9Bp wZO/9UjW2PKsTnVmXnbcqKpp4zDb/l2Ids5gxKD50qtXn1CgpmJgCaSGRIiSgcPYbZ8i +LXCUyxtfbY7/ELZWi/aXdkQW7RmzJfWnXaH7kz/wAfZW/aGIA/qtym12Sfc+AMFD3Lt UVnw== 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=wPXvbk4g+xpCzNUufFCKmYL9KMnQjsRP3igRpf6udEc=; b=fxAR/LInevmdZSzIm8DaqSEC4gnjzQJ+ffmcHnfbqR1Qs/GWT1EFoKWCV6PpOW6p4g dQF5tXksy7bfvix2qY1ovpR4KgHMUX4ddGlgu41qfPxrzwTXR95rlQeGei3iPZWOtFEP xgb6E2DESALeYDim694NQcdZZDIV0UKZnHsWRVQPjdpXvZIUESVkC/XpysFoixNBLunE rGTa2LeIQCMMW/JpwF2hHz9yQJaXhWhkLN/FQUEbzihQLbu4ZHOVoJPeAS5qfRmSD5tU JGPYzwIpn+PWGrEAtI2ipNbU+BbqbPvrJsympM88xb13+U/zg3UbgzmUt/zsZEYUrxrm zDYQ== 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 o6si16912011plh.186.2019.05.19.22.19.01; Sun, 19 May 2019 22:19:01 -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 S1730346AbfETFSr (ORCPT + 30 others); Mon, 20 May 2019 01:18:47 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:37240 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbfETFSo (ORCPT ); Mon, 20 May 2019 01:18:44 -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 7260480D; Sun, 19 May 2019 22:18:44 -0700 (PDT) Received: from p8cg001049571a15.blr.arm.com (p8cg001049571a15.blr.arm.com [10.162.41.132]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 436DD3F5AF; Sun, 19 May 2019 22:18:37 -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: mark.rutland@arm.com, mhocko@suse.com, ira.weiny@intel.com, david@redhat.com, cai@lca.pw, logang@deltatee.com, james.morse@arm.com, cpandya@codeaurora.org, arunks@codeaurora.org, dan.j.williams@intel.com, mgorman@techsingularity.net, osalvador@suse.de, ard.biesheuvel@arm.com Subject: [PATCH V4 2/4] arm64/mm: Inhibit huge-vmap with ptdump Date: Mon, 20 May 2019 10:48:34 +0530 Message-Id: <1558329516-10445-3-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1558329516-10445-1-git-send-email-anshuman.khandual@arm.com> References: <1558329516-10445-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") Acked-by: Ard Biesheuvel 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 diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index a170c63..a1bfc44 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)