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=-5.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 DD98CC433DB for ; Thu, 4 Mar 2021 08:18:52 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 73D3C64ED4 for ; Thu, 4 Mar 2021 08:18:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73D3C64ED4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+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=desiato.20200630; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=sH0iQ5YInBluATIu/c2PGUROqaQvY5yoYj4rknouK8o=; b=G377FLCjZWVnmZIn7MG3VKV7D wQR9knmzDHyXkV+O9I8KNEhnTKPRinLvVMfLDRqPBODi2XIHgKz5IJJzmC7i52uLvDARBciFLkStG ZnbpxIcmx8aT+upOnPpauyA7N0VAIJ+JHJyn9T0ju1YwXpcksq8Ix4Rb5epl2vlIp8uDF9I7jGmvZ pmdQOb5qLzMsEk5sDRQgD56N2bZsk4RX7Q93i51HwD5ZIAP7eYhZwpmt1uRAO3YKlqUdm4mraQuyx ASVbKCEY8pi880laUIymbYM4zkapra9GHrq9CBRknff7PE9gn+mmWrxaR59Gki+cjw+q4yePncrdg b2Ls+bG4Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHj9p-0087U4-TZ; Thu, 04 Mar 2021 08:16:30 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHj7e-0087Pr-CV for linux-arm-kernel@desiato.infradead.org; Thu, 04 Mar 2021 08:14:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description; bh=wXmhmZ+FoUv+fepUyqVykFc4BakPLGiKzA7K40lwdt0=; b=Gwr+xmnMNIO9gL/Ak2j1sBZMyl nTJkr9lrXENmKb/sYL5yu1YXE4F9mE7z1FeHN7wP6k3vMIDutn8JE4XSyNCkFcCuXm6a0VMz63WNc b3/yDyHzvAFJaTXi8vxzCtCJUKWHQRn2xtosF5qLKCAS1y34nduwPMjiTLdjA/DQK589bBnNePb6E Oi1M54m+C9X7GvSAF3MJa0ksR+ahDce27U4HoMDfqsEH9EyOVieCHVZBDc0aOzDPoiPgu9u+jdTrv lXmYYoTEjE7OVthPhuP9eRPG00MrvLQSpEIs45zueXycDK5TZcdUB8rUY1xRyls43v9mXb+I8rZNA ZWkkPGhg==; Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHj7W-006CmV-Vr for linux-arm-kernel@lists.infradead.org; Thu, 04 Mar 2021 08:14:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614845641; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wXmhmZ+FoUv+fepUyqVykFc4BakPLGiKzA7K40lwdt0=; b=WndfeIuRDFJgNbMyN01qH7KvsuGev3ystRksFQyFdriUKeqhN9TSOwg3wzF6dypxRAYY/Y KMV9HFYvRvSJHqqDhTO9Ohnc7LEqVJPRc+gIxZRYwhi8n1ub1FT5bfz1NjQFmLhq9XZMxV 5lGdrSMd0trIvESXfJ13I5nclAFZ7Xc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614845643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wXmhmZ+FoUv+fepUyqVykFc4BakPLGiKzA7K40lwdt0=; b=hUJkmjmG8v7dsRwEyzWFj/5bg3aB0E7QAnmVaSk4HGKkODFJQErZdrKQESbMXvj1EbBmZ6 /3DzYqj0Fn6np0a1wajWl61gKkgNhuU/xaiEst4BzZsldH5q9O4Y2fO8kMVx7DNEKeJl+h eRfgcF/o+umgjamBpoweY10bE91I+3E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-383-VkxYFbjIPtSjoldO4VQadA-1; Thu, 04 Mar 2021 03:12:40 -0500 X-MC-Unique: VkxYFbjIPtSjoldO4VQadA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C2B8D804330; Thu, 4 Mar 2021 08:12:37 +0000 (UTC) Received: from [10.36.113.171] (ovpn-113-171.ams2.redhat.com [10.36.113.171]) by smtp.corp.redhat.com (Postfix) with ESMTP id 818242C6F9; Thu, 4 Mar 2021 08:12:32 +0000 (UTC) Subject: Re: [PATCH V2 1/2] arm64/mm: Fix pfn_valid() for ZONE_DEVICE based memory To: Anshuman Khandual , Will Deacon , Catalin Marinas Cc: Mark Rutland , linux-kernel@vger.kernel.org, Mike Rapoport , linux-mm@kvack.org, =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , James Morse , Dan Williams , Robin Murphy , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org References: <20210202123524.GB16868@willie-the-truck> <20210202125152.GC16868@willie-the-truck> <4d8f5156-8628-5531-1485-322ad92aa15c@redhat.com> <0e649f28-4d54-319d-f876-8a93870cda7f@arm.com> <20210205185552.GA23216@willie-the-truck> <20210211115354.GB29894@willie-the-truck> <23e5eb93-a39c-c68e-eac1-c5ccf9036079@arm.com> <20210303190428.GB24035@arm.com> <20210303212406.GB20055@willie-the-truck> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: <9872a864-15b1-12a7-6aac-0e68554bc744@redhat.com> Date: Thu, 4 Mar 2021 09:12:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210304_081410_000454_E3D0DCAA X-CRM114-Status: GOOD ( 24.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 04.03.21 04:31, Anshuman Khandual wrote: > > > On 3/4/21 2:54 AM, Will Deacon wrote: >> On Wed, Mar 03, 2021 at 07:04:33PM +0000, Catalin Marinas wrote: >>> On Thu, Feb 11, 2021 at 01:35:56PM +0100, David Hildenbrand wrote: >>>> On 11.02.21 13:10, Anshuman Khandual wrote: >>>>> On 2/11/21 5:23 PM, Will Deacon wrote: >>>>>> ... and dropped. These patches appear to be responsible for a boot >>>>>> regression reported by CKI: >>>>> >>>>> Ahh, boot regression ? These patches only change the behaviour >>>>> for non boot memory only. >>>>> >>>>>> https://lore.kernel.org/r/cki.8D1CB60FEC.K6NJMEFQPV@redhat.com >>>>> >>>>> Will look into the logs and see if there is something pointing to >>>>> the problem. >>>> >>>> It's strange. One thing I can imagine is a mis-detection of early sections. >>>> However, I don't see that happening: >>>> >>>> In sparse_init_nid(), we: >>>> 1. Initialize the memmap >>>> 2. Set SECTION_IS_EARLY | SECTION_HAS_MEM_MAP via >>>> sparse_init_one_section() >>>> >>>> Only hotplugged sections (DIMMs, dax/kmem) set SECTION_HAS_MEM_MAP without >>>> SECTION_IS_EARLY - which is correct, because these are not early. >>>> >>>> So once we know that we have valid_section() -- SECTION_HAS_MEM_MAP is set >>>> -- early_section() should be correct. >>>> >>>> Even if someone would be doing a pfn_valid() after >>>> memblocks_present()->memory_present() but before >>>> sparse_init_nid(), we should be fine (!valid_section() -> return 0). >>> >>> I couldn't figure out how this could fail with Anshuman's patches. >>> Will's suspicion is that some invalid/null pointer gets dereferenced >>> before being initialised but the only case I see is somewhere in >>> pfn_section_valid() (ms->usage) if valid_section() && !early_section(). >>> >>> Assuming that we do get a valid_section(ms) && !early_section(ms), is >>> there a case where ms->usage is not initialised? I guess races with >>> section_deactivate() are not possible this early. >>> >>> Another situation could be that pfn_valid() returns true when no memory >>> is mapped for that pfn. >> >> The case I wondered about was __pfn_to_section() with a bogus pfn, since >> with patch 2/2 we call that *before* checking that pfn_to_section_nr() is >> sane. > > Right, that is problematic. __pfn_to_section() should not be called without > first validating pfn_to_section_nr(), as it could cause out-of-bound access > on mem_section buffer. Will fix that order but as there is no test scenario > which is definitive for this reported regression, how should we ensure that > it fixes the problem ? Oh, right, I missed that in patch #2. (and when comparing to generic pfn_valid()). I thought bisecting pointed at patch #1, that's why I didn't even have another look at patch #2. Makes sense. -- Thanks, David / dhildenb _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel