Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2734855pxb; Mon, 25 Apr 2022 00:52:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwF8uDKb+TZkNZyE0tC9CaeRZ3m1Kw91QtF2ESxHMiPYMVWDfcNg5lwvXPl9lLYbj2dS0sI X-Received: by 2002:a17:907:2d21:b0:6f0:7dd:7490 with SMTP id gs33-20020a1709072d2100b006f007dd7490mr14522887ejc.702.1650873168769; Mon, 25 Apr 2022 00:52:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650873168; cv=none; d=google.com; s=arc-20160816; b=F35S/c5vl/HlVlkQTfz8HrH1HNMyEMxRt8ATwJIpwag7+YNTAEwoR8N09EhK8SRQ6L 993COLW+f53KUnpWaQTb0CMd4Meqt99Rgc/iYQKd3gh9CwnmSf9Vk5j37+SGBhzwq64d E3/+IUFxO1AgDH0BtJHQVyvSMvx3QlbVLA9h5cNY5gh+pxn4s1Tw0NKanb1HUG4fG9S0 LUuaexQRW5HZD72dVHND1uN8F1XZuoYOdDg0GoG7fpiYDXqTb2AnGD8HP36iYGmzD82U huBEXfHB0sqJir4vrWinRD5uB0SiXH9CNRQB3Ncetn2eTUzIPVwpar+vvSbXeZ6cg7CO sjhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=OIaruA2rcyqTY8sRh4xqRzqBvl4cTv30hITypVdPT80=; b=K0lD89icT+5KewX8BDhCbnXr+1jnFZgwTwrJ3bLF/qh1h/UA1wg/uaWxl0dvD9BBnx REM082cQ1wpecX32vRkFaqULgeFsTc/5u2mrc3SGbErLZC2/3LR0gEQ9qXPeOVQPn3Yn bBnZAKVwdbzZPe1jMKIuDx+0iXdw9EhDR03XTZX+Ym2ia1mnumoEcEu3vG0uIInJ3wHo H0doFsZ1W0o/KAKE68ZP+U0s1Uw1FWjQDrXq3Lj3QNRHsB1pXa1c49T0MjKms7BHuQSG UDLrc9tcR1un1HX8wiE5MpKQc4n1k1KqRtwOhsC8EygrENtwAwkTmXfhVjGzXEfIscmk 6lEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oF8RXR1S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z20-20020a05640235d400b00425e25ad716si2892919edc.34.2022.04.25.00.52.25; Mon, 25 Apr 2022 00:52:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oF8RXR1S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240726AbiDYEBd (ORCPT + 99 others); Mon, 25 Apr 2022 00:01:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229996AbiDYEBW (ORCPT ); Mon, 25 Apr 2022 00:01:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26E5A35AAC; Sun, 24 Apr 2022 20:58:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3950A60F52; Mon, 25 Apr 2022 03:58:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F4153C385A4; Mon, 25 Apr 2022 03:58:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650859096; bh=Qg2qC4MlVV8ba/9Yso7PQ4kibU52a66r+hx9krqhIq0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oF8RXR1SU9VpaGp2Xxe2qjZ867pLsHYNH4mGXr8ciFPnEO0gwjcYmhWU8+71iZa6A Zb1l/Put2MGXbfsiiRVjVaLm6dYVjCA2uCfd9EFznRmUc74Y1KI6UcNMHJNqhTCbO3 StY27togyW6lLrjN1Agca5+p8VgKMsubGjjGy5gOX0lAsWmDukumP0lysW7ET0Dn2l h2E9ZPg71hza1+dNjMQB5ZHzK3VYs7rVgk0cT2aLyuiV/u90OFg1o6YZ3NwIQVNX46 zgFeGIiLYzMMBQfPhXKn/d8PCOC5tJjqbRb3WPVvzI2koosu7z8mXifSh1wHFriX75 /oXvxzxGgE+Vw== Date: Mon, 25 Apr 2022 06:58:08 +0300 From: Mike Rapoport To: Ard Biesheuvel Cc: Linux Kernel Mailing List , Andrew Morton , Catalin Marinas , Greg Kroah-Hartman , Guillaume Tucker , Mark Brown , Mark-PK Tsai , Mike Rapoport , Russell King , Tony Lindgren , Will Deacon , "kernelci . org bot" , kernelci-results@groups.io, Linux ARM , "# 3.4.x" Subject: Re: [PATCH] arm[64]/memremap: don't abuse pfn_valid() to ensure presence of linear map Message-ID: References: <20220424172044.22220-1-rppt@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 24, 2022 at 11:19:05PM +0200, Ard Biesheuvel wrote: > On Sun, 24 Apr 2022 at 19:22, Mike Rapoport wrote: > > > > From: Mike Rapoport > > > > The semantics of pfn_valid() is to check presence of the memory map for a > > PFN and not whether a PFN is covered by the linear map. The memory map may > > be present for NOMAP memory regions, but they won't be mapped in the linear > > mapping. Accessing such regions via __va() when they are memremap()'ed > > will cause a crash. ... > > diff --git a/kernel/iomem.c b/kernel/iomem.c > > index 62c92e43aa0d..e85bed24c0a9 100644 > > --- a/kernel/iomem.c > > +++ b/kernel/iomem.c > > @@ -33,7 +33,7 @@ static void *try_ram_remap(resource_size_t offset, size_t size, > > unsigned long pfn = PHYS_PFN(offset); > > > > /* In the simple case just return the existing linear address */ > > - if (pfn_valid(pfn) && !PageHighMem(pfn_to_page(pfn)) && > > + if (!PageHighMem(pfn_to_page(pfn)) && > > This looks wrong to me. Calling any of the PageXxx() accessors is only > safe if the PFN is valid, since otherwise, we don't know if the > associated struct page exists. Yeah, you are right, was over-enthusiastic here... > > arch_memremap_can_ram_remap(offset, size, flags)) > > return __va(offset); > > > > > > base-commit: b2d229d4ddb17db541098b83524d901257e93845 > > -- > > 2.28.0 > > -- Sincerely yours, Mike.