Message ID | 20230424113846.46382-1-tanure@linux.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2681932vqo; Mon, 24 Apr 2023 04:49:45 -0700 (PDT) X-Google-Smtp-Source: AKy350YqQI+0sC+FK+3mVVba+XgNgRJeAGpj5hzHjziL8EiZgj6BSoI7Zq681ekRO1A5kc12Zdt8 X-Received: by 2002:a17:90a:ac18:b0:249:6086:a301 with SMTP id o24-20020a17090aac1800b002496086a301mr13535804pjq.27.1682336984969; Mon, 24 Apr 2023 04:49:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682336984; cv=none; d=google.com; s=arc-20160816; b=idSZLLKspdpr4mUs09Jyue5q8pTUKlCaI18ZPp3/yHrvPM6uHBVigPDvDe1okz28ZH 99vj1Y08mCPIFiFQc6Cs4WnwXAKzKgK2BY7OeSm1pqn0hYcugGdVWKFwML1QI4/wAfhG WoxbW0fzl98cm6aqJ/iXqigdYQrgI5beFc4KH7osgkKWhJDOlDQjmV/QPlspTm/YRpss f5L2f5hBGP99/04eJYWOfOD11VM+Ntx4wpX0gCU0lD6nN3XK0mOF2QYP9Rjvj5DQNRZf Tx7YESncHVyGFlHXnsxxjnH8gHfD6x9+teIRza2LBMcGwVJc2B1gVouFQOw8iTjsjlTM Iz9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Eglyz+j/occX8WNkEpcLNlY9OWqv/i1uyY+qtuXKrx0=; b=XDtXgrcuVhf/YnqNFkQ7pMt/o2WyJx/sJk6DMErZ18iliRNG2YXr6NkT8wlDfPAZ5K THLI2aUoYqdLaxA2Oos43OfPjxMPM4I1Pd/04Ee5VOTCfOBWCfXXWtQKcQpH8pRJ/Grp MrZJIsgBjFMjbNuRuvzUrzoLvhgPMnM+ZNZXHnLhLqx3sIGjb2aug5w688FYQzRsg9pq ueVR4U+FR/kRJAp0jASZLtqdENZKwwYIE5iIgDasNiv8zVJhI7vsSyYEQRfhduLhLl08 EXT/17Np79ieIN+nQUTaUS+tKn+bhVSolxMrTa4d0e2j4tFo0uTAf+bvIgu6p3BPbgxp 5h1Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lr10-20020a17090b4b8a00b00246ba136cc1si11930254pjb.137.2023.04.24.04.49.29; Mon, 24 Apr 2023 04:49:44 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231214AbjDXLix (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Mon, 24 Apr 2023 07:38:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229547AbjDXLiw (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 24 Apr 2023 07:38:52 -0400 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 932A23A8C; Mon, 24 Apr 2023 04:38:50 -0700 (PDT) Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-3f1957e80a2so74187505e9.1; Mon, 24 Apr 2023 04:38:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682336329; x=1684928329; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Eglyz+j/occX8WNkEpcLNlY9OWqv/i1uyY+qtuXKrx0=; b=h1oc6OkSzXaUIiu8xVLaoIH/i5VQBCmXcQ3cLNvvdXasTBCJo8bwrQR6con5vXUJco 9WBW1obzz6gy3S/jjTzNtm9NlAvxU8KUljaCl8XijtgznI55E6Wq8fVVQJMQQ8XYvXkU j9XGZ73PTdXoqHPPT4CiujN9ZHCNwxapF8WcD9LSr6B8MbyHJGjnSPyRravILLdIypQY hxMfe1qe1LMBhY+UOOtRTrhDnbw8fefehWEuXbo18oTj8uNkyT5NDxO+WeTuulbT2E29 Gbrd3Hc405ZNQPJwWUfqc471MvlDNmnfJGLULe4ZtQrUXwtpTiugUnKbXc9VEc8vg3I/ b2og== X-Gm-Message-State: AAQBX9cWNefnz+qarmb/1pDl2wIgHW/UPCtp8BdLNgI50CYQUnkE+uV+ IWhiq0Ih9Y/y25OlTEKEkeU= X-Received: by 2002:a5d:414c:0:b0:2fa:d00d:cab8 with SMTP id c12-20020a5d414c000000b002fad00dcab8mr9478626wrq.18.1682336328944; Mon, 24 Apr 2023 04:38:48 -0700 (PDT) Received: from ryzen.lan (cpc87451-finc19-2-0-cust61.4-2.cable.virginm.net. [82.11.51.62]) by smtp.gmail.com with ESMTPSA id e18-20020adffc52000000b002efacde3fc7sm10570820wrs.35.2023.04.24.04.38.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Apr 2023 04:38:48 -0700 (PDT) From: Lucas Tanure <tanure@linux.com> To: Rob Herring <robh+dt@kernel.org>, Frank Rowand <frowand.list@gmail.com>, Mike Rapoport <rppt@kernel.org>, Andrew Morton <akpm@linux-foundation.org> Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, jbrunet@baylibre.com, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, martin.blumenstingl@googlemail.com, narmstrong@baylibre.com, stefan@agner.ch, Lucas Tanure <tanure@linux.com> Subject: [PATCH v4] of: fdt: Scan /memreserve/ last Date: Mon, 24 Apr 2023 12:38:46 +0100 Message-Id: <20230424113846.46382-1-tanure@linux.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764058186464325266?= X-GMAIL-MSGID: =?utf-8?q?1764058186464325266?= |
Series |
[v4] of: fdt: Scan /memreserve/ last
|
|
Commit Message
Lucas Tanure
April 24, 2023, 11:38 a.m. UTC
Change the scanning /memreserve/ and /reserved-memory node order to fix
Kernel panic on Khadas Vim3 Board.
If /memreserve/ goes first, the memory is reserved, but nomap can't be
applied to the region. So the memory won't be used by Linux, but it is
still present in the linear map as normal memory, which allows
speculation. Legitimate access to adjacent pages will cause the CPU
to end up prefetching into them leading to Kernel panic.
So /reserved-memory node should go first, as it has a more updated
description of the memory regions and can apply flags, like nomap.
Signed-off-by: Lucas Tanure <tanure@linux.com>i
---
Previous Threads:
#regzbot link: https://lore.kernel.org/linux-arm-kernel/40ca11f84b7cdbfb9ad2ddd480cb204a@agner.ch/#regzbot
#regzbot link: https://lore.kernel.org/all/CAJX_Q+1Tjc+-TjZ6JW9X0NxEdFe=82a9626yL63j7uVD4LpxEA@mail.gmail.com/
V1: https://lore.kernel.org/all/20230406151429.524591-1-tanure@linux.com/
v2: https://lore.kernel.org/all/20230410120017.41664-1-tanure@linux.com/
v3: https://lore.kernel.org/linux-mm/20230412224620.8909-1-tanure@linux.com/T/
Change from V3:
- Drop cover letter
- Add more information into the patch
Change from V2:
- Remove region overlap and reserved checks
Change from V1:
- Instead of allowing to mark nomap a region already reserved, give
precedence to /reserved-memory node scan.
---
drivers/of/fdt.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Comments
On Mon, 24 Apr 2023 12:38:46 +0100, Lucas Tanure wrote: > Change the scanning /memreserve/ and /reserved-memory node order to fix > Kernel panic on Khadas Vim3 Board. > > If /memreserve/ goes first, the memory is reserved, but nomap can't be > applied to the region. So the memory won't be used by Linux, but it is > still present in the linear map as normal memory, which allows > speculation. Legitimate access to adjacent pages will cause the CPU > to end up prefetching into them leading to Kernel panic. > > So /reserved-memory node should go first, as it has a more updated > description of the memory regions and can apply flags, like nomap. > > Signed-off-by: Lucas Tanure <tanure@linux.com>i > --- > Previous Threads: > #regzbot link: https://lore.kernel.org/linux-arm-kernel/40ca11f84b7cdbfb9ad2ddd480cb204a@agner.ch/#regzbot > #regzbot link: https://lore.kernel.org/all/CAJX_Q+1Tjc+-TjZ6JW9X0NxEdFe=82a9626yL63j7uVD4LpxEA@mail.gmail.com/ Note that this should have been a 'Link:' entry in the commit message for regzbot. I added it. > > V1: https://lore.kernel.org/all/20230406151429.524591-1-tanure@linux.com/ > v2: https://lore.kernel.org/all/20230410120017.41664-1-tanure@linux.com/ > v3: https://lore.kernel.org/linux-mm/20230412224620.8909-1-tanure@linux.com/T/ > > Change from V3: > - Drop cover letter > - Add more information into the patch > > Change from V2: > - Remove region overlap and reserved checks > > Change from V1: > - Instead of allowing to mark nomap a region already reserved, give > precedence to /reserved-memory node scan. > --- > drivers/of/fdt.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > Applied, thanks! Going to let this sit in linux-next for a bit. I also didn't tag for stable kernels. I want it to get some exposure in mainline at least for a few -rc releases rather than getting backported right away. Please help ensure that happens if you see stable review emails. I'm going to be offline most of the next month. Rob
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index d14735a81301..bf502ba8da95 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -635,6 +635,9 @@ void __init early_init_fdt_scan_reserved_mem(void) if (!initial_boot_params) return; + fdt_scan_reserved_mem(); + fdt_reserve_elfcorehdr(); + /* Process header /memreserve/ fields */ for (n = 0; ; n++) { fdt_get_mem_rsv(initial_boot_params, n, &base, &size); @@ -643,8 +646,6 @@ void __init early_init_fdt_scan_reserved_mem(void) memblock_reserve(base, size); } - fdt_scan_reserved_mem(); - fdt_reserve_elfcorehdr(); fdt_init_reserved_mem(); }