From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4F42C04AB4 for ; Thu, 16 May 2019 08:38:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 95C3C205C9 for ; Thu, 16 May 2019 08:38:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="aKw+gMpd"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="sXvJHWWE"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="uV8PXLrE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 95C3C205C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=H6HiUToEclViJ5piYXqTncUZTQGb2ZLJOoL1mxrAT9Y=; b=aKw+gMpdtI+cdW 1eezPmJ6HohskoIhjhMNlYyN683fkw6W18kKkf4GXLbVmgdu1S0tuCLRfklyW87Zc8y0cVshvzX6q WqsZgMLLocPb28YzPnSOG5ZlDXzkuYl2BeM1TGavdZz2+ApQS55B9LLZgWSM1WfW+gl5CvZxDKkR3 VgizaqSfqJuDyy7uyRuIVVbO/jB9Vkk3xwzLiHE9mkijsAdM/oPadFKsTxksjoGOcyJwgoDLLvOe+ 5emBxECwsM1H1rqGe8yJHnLh217SKKqY2IKDrTOzCmJkm0Z8gAaEe8iY1E0HRxOzTeiHZjF4Cqat5 dXANSomKVDjogNrmCeFA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hRBuE-0003oQ-2t; Thu, 16 May 2019 08:38:26 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hRBuB-0003nA-H7 for linux-arm-kernel@bombadil.infradead.org; Thu, 16 May 2019 08:38:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Cc:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=C9JP0N9BOAKIKjnOKpvcauJRP2dUC/WHKbmpM2CzhnA=; b=sXvJHWWEII4o0dyBWsnFWLo65 Hl1+IGnxSMpPfg2Fm5gPO9sHEdecwPGy0uZoTO6jk1K2D5ixCkGtVNkvkScJRKkjcNX7RjvNNB2UQ cdu8IdEE35jyQYD3LdvHjSpfc1KwnRiBzTBK4TOJ/8Zjj4YIzDE2l6T0aqe/0ChDHnDDT7K3ni9Ia xsHymaC0eGCZHaOpgX4A4HKn6FEG8EAqYVpnL2Sd9lE4TT+1/Qy5iKzJvXToU5BXItGauUiR8ySLG 7X7px95c0oBTWqFrWOSwDhYgYRpz2C62kuEh8Punwg7L8BNBqjPx5ewMEwUruce3cVDH/wynP+EUQ RL0YTchSg==; Received: from mail-io1-xd44.google.com ([2607:f8b0:4864:20::d44]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hRBu6-0005ib-7j for linux-arm-kernel@lists.infradead.org; Thu, 16 May 2019 08:38:20 +0000 Received: by mail-io1-xd44.google.com with SMTP id q21so1873671iog.13 for ; Thu, 16 May 2019 01:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=C9JP0N9BOAKIKjnOKpvcauJRP2dUC/WHKbmpM2CzhnA=; b=uV8PXLrENhbYzJPMQg/GfuwTr2zlOMTnJo7nzJg05BO+KHWDwr3Gy/uxNWLBv7Kuka 3NDIIOKcKiFBUsBMdUv3lHNHNwPeoXQ4FSdn4trrpXJVg+2yNarpb7yJgEUStTZLx+cS tidwhMPRDkWJAGrARxSxyE5gTccNzRGsFHOUjYS/90QUDPVTdo2humon+At1R42bVUJa FpcI/JbBOOXWBxyNW4GgunCPAUvgiQZHC5Z03vjL6j5oRIaVciSzG9MPfy6a69cLUnqH SaElm0KDWl3NEjcWzlORIUr2lLJSzpvzLtJHRrUcDk1dR1h7SC8acTT2bETRMCfSIP9W 0ztA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=C9JP0N9BOAKIKjnOKpvcauJRP2dUC/WHKbmpM2CzhnA=; b=PMOVShqJ6M4E/n5a3C5ZKzJrwAQkllvE8wyxr72/L6eB+A/EeJAqHCrVaP5ImWLOTu sfQXYxT/QWBDRKoGIqmas2kdGVk4XEknw0LOWHNGWFs7UdOUAHe2SO8sgnMKQzmH8siF eV1v4BaV7lJSs8MGDWh5+vOWvwznjbDHIZeuWqIei1eDWkL6lnLKw2nZxWb9zYDQFFDt bY+gsVg8eUhFSN/JwdzYGaBgrDopGByw6X2SfWo1RfqreKGFdOpXFQSd0jpy6ecuLL/P xJ6naz4ue9P/WR7ORwjYNpXgH19bbWc6qhMiEdun1RLSom+dVfPgSzhRnAVtH55Fk1V6 J21A== X-Gm-Message-State: APjAAAWdpyY7HGLgWLFeoC6xFg1GrOVErSk3iipHpDqfDwcYZcrhySI7 RsFM0MQrzcImte+gDjNG2+Is30Y/85su2p9zlGm6Uw== X-Google-Smtp-Source: APXvYqz9CmbRJ3iRRK2v6t05hYLre9i2on+joX41dk5hh0qgy7FoEcnsqERuE7gSKNj6gb2SeUu1Zka4+ya1Zbn+dDo= X-Received: by 2002:a5d:93da:: with SMTP id j26mr26590152ioo.170.1557995895704; Thu, 16 May 2019 01:38:15 -0700 (PDT) MIME-Version: 1.0 References: <1557824407-19092-1-git-send-email-anshuman.khandual@arm.com> <1557824407-19092-4-git-send-email-anshuman.khandual@arm.com> In-Reply-To: <1557824407-19092-4-git-send-email-anshuman.khandual@arm.com> From: Ard Biesheuvel Date: Thu, 16 May 2019 10:38:03 +0200 Message-ID: Subject: Re: [PATCH V3 3/4] arm64/mm: Inhibit huge-vmap with ptdump To: Anshuman Khandual X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190516_093818_399522_E03636A8 X-CRM114-Status: GOOD ( 34.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Michal Hocko , Mel Gorman , david@redhat.com, Catalin Marinas , Will Deacon , Linux Kernel Mailing List , Logan Gunthorpe , arunks@codeaurora.org, Qian Cai , cpandya@codeaurora.org, James Morse , Andrew Morton , osalvador@suse.de, ira.weiny@intel.com, "Williams, Dan J" , linux-arm-kernel , Robin Murphy Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 14 May 2019 at 11:00, Anshuman Khandual wrote: > > 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. > The reason I added this originally is so that we don't trigger a warning when unmapping vmappings that use 2 MB block mappings, which happens when we free the kernel's .init segment. The ability to create such mappings is indeed an optimization that the kernel mapping code does not rely on. > 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 Acked-by: Ard Biesheuvel > --- > arch/arm64/mm/mmu.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > 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) > -- > 2.7.4 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel