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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6368AC76196 for ; Mon, 3 Apr 2023 15:29:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC8DC900002; Mon, 3 Apr 2023 11:29:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C2AC66B0078; Mon, 3 Apr 2023 11:29:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA44F900002; Mon, 3 Apr 2023 11:29:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 980286B0075 for ; Mon, 3 Apr 2023 11:29:03 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4AB7C160C6A for ; Mon, 3 Apr 2023 15:29:03 +0000 (UTC) X-FDA: 80640462966.12.980EC2D Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) by imf17.hostedemail.com (Postfix) with ESMTP id 42D2A40013 for ; Mon, 3 Apr 2023 15:29:00 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf17.hostedemail.com: domain of tanurelinux@gmail.com designates 209.85.160.51 as permitted sender) smtp.mailfrom=tanurelinux@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680535740; h=from:from:sender:reply-to: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=AfXSjA7q7dvjRoKzxnHZQeB6zpJL1qkef91cGmYxqmc=; b=08HzXYOcS5Du/v7hYGz3EwBMgjk8UTKQvVpIh48SyuNtoS0l00C7y8qmaK25PtD4Suw/SZ OLCv+HkORcnWA4kaq8y1FKMxWcMVdWmk8oDgc/l5DDJUfUSxIefi+sotxg4s/vsKdpvt3g PZz6ubG8sPMmdYnTud03lMx/gh/AHjk= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf17.hostedemail.com: domain of tanurelinux@gmail.com designates 209.85.160.51 as permitted sender) smtp.mailfrom=tanurelinux@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680535740; a=rsa-sha256; cv=none; b=ypNsvUE36TID/vytrfkMgfnwNnXv/cVkw6NEObXwyuewhzAzCoz//yzYag9JqiOaYXwZlH poz8MvceIP2ftSK1pQeAW+vSzdYxQkOB5KEfh27sRKuV6oFfJlWqkvVQj5LZ/N7fK1Lk32 3zO2ijVDwiur/Uvr5Lzon+HGJK8umBU= Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-17683b570b8so31132467fac.13 for ; Mon, 03 Apr 2023 08:28:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680535739; h=content-transfer-encoding:cc:to:subject:message-id:date:from :reply-to:in-reply-to:references:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=AfXSjA7q7dvjRoKzxnHZQeB6zpJL1qkef91cGmYxqmc=; b=K6T1YYrLtHRec1Il8MefHhCN48nSKP1Tye87qjbCk6DnPNnri8FvvZ4UStB1NoijyM JfW7qM1J3jMID/zhFEIokyXxfk8+ZytzIoWFqhrBSqepuGCyzS405kCRN+HScLtGtIk9 peMkJ66lQdEKnBksemLkf6rx/ao+p6rfpv3i+NOaL6AM+B25KBRr54bGS19KZjrWQarf XWwh64IePNWNoIxNsUGgTuOjdb8oYHOAzd8xnnJc4BVxqbnh6pgLXAzjq2DBcx6sEu/6 TIB+aMxWx+22U7rTZbBXpQn+B+BfbhucBBpd0Aob2NWv1ZBv7xSxujI41WZffpcHeqQS FjRw== X-Gm-Message-State: AAQBX9fzD6pzXVtB91AVxjHKfJrl23SfcJ7EQMMYOWA0JQbh27eoYcFN 7EFxpoGXNgMUsazFV3HWuvc0gKa79H10hlwi X-Google-Smtp-Source: AKy350b6rANNKExIp0h9e9inV+1ODpu2f25KycqzaCSxgSDyAmTJCuQYBIXuI46LkFhDuaChEi6KOg== X-Received: by 2002:a05:6871:5cd:b0:17f:8da0:ce51 with SMTP id v13-20020a05687105cd00b0017f8da0ce51mr13739880oan.13.1680535739251; Mon, 03 Apr 2023 08:28:59 -0700 (PDT) Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com. [209.85.210.46]) by smtp.gmail.com with ESMTPSA id kw17-20020a056870ac1100b001802d3e181fsm3640102oab.14.2023.04.03.08.28.53 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Apr 2023 08:28:55 -0700 (PDT) Received: by mail-ot1-f46.google.com with SMTP id d22-20020a9d5e16000000b0069b5252ced7so15807003oti.13 for ; Mon, 03 Apr 2023 08:28:53 -0700 (PDT) X-Received: by 2002:a9d:65d1:0:b0:69f:1418:7a8f with SMTP id z17-20020a9d65d1000000b0069f14187a8fmr11995072oth.3.1680535733526; Mon, 03 Apr 2023 08:28:53 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Reply-To: tanure@linux.com From: Lucas Tanure Date: Mon, 3 Apr 2023 16:28:42 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Kernel Panic - V6.2 - Reseved memory issue To: Bagas Sanjaya , Mike Rapoport , Andrew Morton , linux-mm@kvack.org Cc: kernelnewbies , Rob Herring , Frank Rowand , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content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cto6Qxl10sy4DyqD66ifeEW0rgA8cY03PkBQua2u0vefV6GHY haF9DysM n9sR5zj5kRy2iSEzaN0DJsJ6Uin9QjURknZX1OgJMYoEbw/JvFZUJ4Ey20f6WUChlldFjNoqf4gpecjwrgX34eFx2JyOzoeHtr/ApSxjxY+8zv654GVbGNEvO1afnaT95bCayhrsDlCPkVS9lZPtV5MjU3Je+IXld2y9HvN9heakXftMX9KEHu57sRU/FJ6H0Omj00U8/RKTESFg3PuFiCUAS5vYorL5ZhIpGgj2G3bEgVa+mlrxyyBbFTwcAN5dmVzO4ZAhnSRTMrxwL2T1mwaXIecglxfBhHh915sWiYLJ9e39cWoXJR2KAo5Z2bAF9VMSboa37W/UIPQ0+RVoqs/PJ4HSHy/9cjoKBBWz7N0x8YiMyTFJi9o6jueDkf79WlK4iSN8tsB1yhaOpW86biv8GyyL3kvA+ljpqr7yDMsZ0yqQdq+9q/fYeIWa3OdhlMeS+i/qoPFG29TKGHRMA4QPOp8sSNDoDPw1KBFiXc+eSKzCNlaXrf0wqGWjJNobM9geumgixuXay3pUCgfKed9uEUxn2M3E0RbmdKjmqHMkKkGIUYrdh7mOkX9TILhSYGCP8iIfuwvTNDNKbUQt/Y9B7USsXjAWlVxaLgi8YKjNvs47YCIGlLJfOoA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Apr 3, 2023 at 12:29=E2=80=AFPM Lucas Tanure wro= te: > > On Sun, Apr 2, 2023 at 1:55=E2=80=AFPM Bagas Sanjaya wrote: > > > > On Sun, Apr 02, 2023 at 09:10:36AM +0100, Lucas Tanure wrote: > > > Log: > > > > > > [ 9.792966] SError Interrupt on CPU3, code 0x00000000bf000000 -- SErr= or > > > [ 9.792980] CPU: 3 PID: 3471 Comm: kded5 Tainted: G C 6.2.0 #1 > > > [ 9.792985] Hardware name: Khadas VIM3 (DT) > > > [ 9.792987] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTY= PE=3D--) > > > [ 9.792991] pc : kmem_cache_free_bulk.part.98+0x1f0/0x528 > > > [ 9.793004] lr : kmem_cache_free_bulk.part.98+0x2f8/0x528 > > > [ 9.793008] sp : ffff80000a2eb7f0 > > > [ 9.793009] x29: ffff80000a2eb7f0 x28: ffff00001f358518 x27: ffff0000= 00008800 > > > [ 9.793016] x26: ffff00000262b300 x25: ffff00000262b300 x24: 00000000= 00000001 > > > [ 9.793019] x23: ffff00000262b000 x22: 0000000000000000 x21: ffff0000= 1f358538 > > > [ 9.793022] x20: fffffc0000098ac0 x19: 0000000000000004 x18: 00000000= 00000040 > > > [ 9.793025] x17: 0000000000000018 x16: 00000000000007f8 x15: 00000000= 00000003 > > > [ 9.793028] x14: 0000000000000006 x13: ffff800008e48550 x12: 0000ffff= 9dc91fff > > > [ 9.793031] x11: 0000000000000004 x10: 0000000000000001 x9 : ffff0000= 07e93680 > > > [ 9.793035] x8 : 0000000000000020 x7 : ffff000001d2b100 x6 : 00000000= 00000007 > > > [ 9.793037] x5 : 0000000000000020 x4 : ffff000000008800 x3 : 00000000= 00000001 > > > [ 9.793040] x2 : 0000000000000007 x1 : 0000000000000000 x0 : ffff0000= 1f358540 > > > [ 9.793045] Kernel panic - not syncing: Asynchronous SError Interrupt > > > > > > This doesn't happen with downstream Khadas 6.2 kernel, and that's > > > because the downstream kernel removed this from > > > early_init_dt_reserve_memory (drivers/of/fdt.c): > > > > > > /* > > > * If the memory is already reserved (by another region), we > > > * should not allow it to be marked nomap, but don't worry > > > * if the region isn't memory as it won't be mapped. > > > */ > > > if (memblock_overlaps_region(&memblock.memory, base, size) && > > > memblock_is_region_reserved(base, size)) > > > return -EBUSY; > > > > > > > What commit on downstream kernel that fix the issue? > Here: > https://github.com/khadas/linux/commit/2cb57b1071bf69f615fedc999b7ecacf2c= de7228 > > Can you reproduce > > on mainline with above conditional removed? > No, without that code mainline works fine. > > > Alternatively, can > > you post the downstream fix here? > Same https://github.com/khadas/linux/commit/2cb57b1071bf69f615fedc999b7ec= acf2cde7228 > > > > > Also, can you find last working commit on mainline? If so, this is > > regression. > That is difficult as 5.13.0 has the line: > OF: fdt: Reserved memory: failed to reserve memory for node > 'secmon@5000000': base 0x0000000005000000, size 3 MiB > But doesn't crash. It could be that no process used that address so no cr= ash. > > > > > Thanks. > > > > -- > > An old man doll... just what I always wanted! - Clara Hi, I git bisect point it out commit that even reverting it would trigger the p= anic. So this is a memory corruption problem that a simple git bisect will not find the correct offending commit. I managed to understand a little more about the issue: 1 ) early_init_fdt_scan_reserved_mem is executed first, reserves [0x0000000005000000-0x00000000052fffff] but doesn't mark as no-map. 2 ) early_init_dt_reserve_memory tries to mark that region as nomap, but it is already reserved and memblock_overlaps_region and memblock_is_region_reserved return true, so it fails to mark as nomap. 3 ) kernel uses that memory and crashes I think we have two options here: 1) Allow early_init_dt_reserve_memory mark nomap memory that is already res= erved 2) Make early_init_fdt_scan_reserved_mem reserve with the flag nomap if necessary. I don't know if that's possible. Question MM guys, Mike Rapoport and Andrew Morton: - Is it possible to make early_init_fdt_scan_reserved_mem reserve memory with flags? - It ok for early_init_fdt_scan_reserved_mem to mark regions already reserved as nomap? Thanks Lucas