Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2021903rwd; Wed, 17 May 2023 04:51:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4SKoOETM9ahALjOYM4TwrgdNd+KCTIpR4gW0TZj4Vfcic2o25dGOZtLGXN2r2AYRtq2WNP X-Received: by 2002:a17:90a:1f4b:b0:252:7cc4:a556 with SMTP id y11-20020a17090a1f4b00b002527cc4a556mr22483268pjy.39.1684324297126; Wed, 17 May 2023 04:51:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684324297; cv=none; d=google.com; s=arc-20160816; b=MBSoOSfN9j1gUFAJVBRfp222YO6BSYSziO3GrU9Uar59/SLg5tsiErBjSezk0uVJVQ qrn9c4yLxfFoEN3iZUt3qo6kxafVsSk0yN2G1czRmZ1WTQjcUiYDrUermOdJxgXJ9JhX MgDfPtHUaJLeWpibewBrRquARjh6sXUmloV5FMGvRGizxBYEi4mQgKYqee25FnTZMyCm XwjZYmcufigjPeql80HgOExZFwWEmM6fxLn2rP/ZHSCl2zGsjF6VF/LFo9muz9nD70Nx j5cjRpbx0uIBKPP0+0siJzRZz+S5K1iTMQkf07sf6BXxYAbyUm/NmuA02/Y/26XMI0V/ StDg== 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=+/jxmtVM5F0H9lZRoZLuT8QkT0M+ZqwNLppD3u34qEM=; b=Z5pVSYUixqQlzQkJkIxhY1oHj5Rwi89VmPg9S++hAZkBQ3uVLZXp3yGaRhRaWsMm+7 BsS1reA46tmoM1PVx2oF9l4sTrkC+oH6HErzHIkWwpbCLT0dT6mJ1GeqXZv081f6Cn7d QunYldtoOXJpZKLpjqkHc0S37ngiFziazzUT8s9I+CvctNRDM87hBYdnAOfjYvaakpzg b5yJ4bFs6kjQ9pJk/RNQxaCPaCTq8ZtcpYEaqme8Du7tI7U7pvathxwymHmtbiarlW4i J6Ok0QUeyuEY8Fvt/ORljKvr4iKme9GccmbSBVfJu9BC0R/ifOKJYjNhe7P+/TH8OOFS QH5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=AdXZR13x; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bs184-20020a6328c1000000b0052c3f0ae398si20006425pgb.158.2023.05.17.04.51.22; Wed, 17 May 2023 04:51:37 -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=@microchip.com header.s=mchp header.b=AdXZR13x; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231264AbjEQL2I (ORCPT + 99 others); Wed, 17 May 2023 07:28:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231190AbjEQL2G (ORCPT ); Wed, 17 May 2023 07:28:06 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7370830F6 for ; Wed, 17 May 2023 04:28:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1684322886; x=1715858886; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=USREqE8lRmbgXvnU/8dLwkbI7tqJwD1a8ZDS5Hs3u8I=; b=AdXZR13xDjplgXzxzsvkytI82nNuOK9LtLFkoge26ylBmHXhKZXphyY2 l98SGGY/prYKluWeiRiHYOV1IOLBLAaZcyvT4Ih36rSbIS9/J5UK4OWqC MxIYwWf9V5Fgkw14o726+VttAcI0sciV4gdFSpKf++SSINSqRHiRMGGOo 3dYt5az+wLlSXgwesK4Y8NP49/7cIaMZraKYRV4hiPRokMnXyBZ9Q6/AJ meyLP78oUpuDhEytlV+NnFMCJHKdrYZDkqoyGc7lUTSSWo7ONdYc8U17M kABSmCWyEZnduQyRt5aPBIOp//dgJeIx2hCYnhocrQXbcs5QxFg4W2yO2 A==; X-IronPort-AV: E=Sophos;i="5.99,281,1677567600"; d="asc'?scan'208";a="214265850" X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 May 2023 04:27:55 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 17 May 2023 04:27:53 -0700 Received: from wendy (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21 via Frontend Transport; Wed, 17 May 2023 04:27:51 -0700 Date: Wed, 17 May 2023 12:27:30 +0100 From: Conor Dooley To: Alexandre Ghiti CC: Song Shuai , , Andrew Jones , , , , , , Paul Walmsley , Guo Ren , , Subject: Re: Bug report: kernel paniced when system hibernates Message-ID: <20230517-preacher-primer-f41020b3376a@wendy> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6w54c5FuSo5Xd9WG" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 --6w54c5FuSo5Xd9WG Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hey Alex, On Wed, May 17, 2023 at 10:58:02AM +0200, Alexandre Ghiti wrote: > On Tue, May 16, 2023 at 1:12=E2=80=AFPM Alexandre Ghiti wrote: > > On Tue, May 16, 2023 at 11:24=E2=80=AFAM Song Shuai wrote: > > I actually removed this flag a few years ago, and I have to admit that > > I need to check if that's necessary: the goal of commit 3335068f8721 > > ("riscv: Use PUD/P4D/PGD pages for the linear mapping") is to expose > > the "right" start of DRAM so that we can align virtual and physical > > addresses on a 1GB boundary. > > > > So I have to check if a nomap region is actually added as a > > memblock.memory.regions[] or not: if yes, that's perfect, let's add > > the nomap attributes to the PMP regions, otherwise, I don't think that > > is a good solution. >=20 > So here is the current linear mapping without nomap in openSBI: >=20 > ---[ Linear mapping ]--- > 0xff60000000000000-0xff60000000200000 0x0000000080000000 2M > PMD D A G . . W R V > 0xff60000000200000-0xff60000000e00000 0x0000000080200000 12M > PMD D A G . . . R V >=20 > And below the linear mapping with nomap in openSBI: >=20 > ---[ Linear mapping ]--- > 0xff60000000080000-0xff60000000200000 0x0000000080080000 1536K > PTE D A G . . W R V > 0xff60000000200000-0xff60000000e00000 0x0000000080200000 12M > PMD D A G . . . R V >=20 > So adding nomap does not misalign virtual and physical addresses, it > prevents the usage of 1GB page for this area though, so that's a > solution, we just lose this 1GB page here. >=20 > But even though that may be the fix, I think we also need to fix that > in the kernel as it would break compatibility with certain versions of > openSBI *if* we fix openSBI...So here are a few solutions: >=20 > 1. we can mark all "mmode_resv" nodes in the device tree as nomap, > before the linear mapping is established (IIUC, those nodes are added > by openSBI to advertise PMP regions) > -> This amounts to the same fix as opensbi and we lose the 1GB hugepa= ge. AFAIU, losing the 1 GB hugepage is a regression, which would make this not an option, right? > 2. we can tweak pfn_is_nosave function to *not* save pfn corresponding > to PMP regions > -> We don't lose the 1GB hugepage \o/ > 3. we can use register_nosave_region() to not save the "mmode_resv" > regions (x86 does that > https://elixir.bootlin.com/linux/v6.4-rc1/source/arch/x86/kernel/e820.c#L= 753) > -> We don't lose the 1GB hugepage \o/ > 4. Given JeeHeng pointer to > https://elixir.bootlin.com/linux/v6.4-rc1/source/kernel/power/snapshot.c#= L1340, > we can mark those pages as non-readable and make the hibernation > process not save those pages > -> Very late-in-the-day idea, not sure what it's worth, we also > lose the 1GB hugepage... Ditto here re: introducing another regression. > To me, the best solution is 3 as it would prepare for other similar > issues later, it is similar to x86 and it allows us to keep 1GB > hugepages. >=20 > I have been thinking, and to me nomap does not provide anything since > the kernel should not address this memory range, so if it does, we > must fix the kernel. >=20 > Let me know what you all think, I'll be preparing a PoC of 3 in the meant= ime! #3 would probably get my vote too. It seems like you could use it dynamically if there was to be a future other provider of "mmode_resv" regions, rather than doing something location-specific. We should probably document these opensbi reserved memory nodes though in a dt-binding or w/e if we are going to be relying on them to not crash! Thanks for working on this, Conor. --6w54c5FuSo5Xd9WG Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZGS6IgAKCRB4tDGHoIJi 0qsIAQCtlGg/uMm4zz/vWITkgyLV+LGXakABee0MyRtoPfADJgEAhWfiM9TB46v4 4k0/ko1bu+Hxn6d2KvY+53/VT6P1DQk= =YttE -----END PGP SIGNATURE----- --6w54c5FuSo5Xd9WG--