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=-10.0 required=3.0 tests=BAYES_00,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 6CEB0C5517A for ; Thu, 5 Nov 2020 18:37:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C470221D46 for ; Thu, 5 Nov 2020 18:37:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C470221D46 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B62226B017B; Thu, 5 Nov 2020 13:37:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B13876B017E; Thu, 5 Nov 2020 13:37:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A02F16B017F; Thu, 5 Nov 2020 13:37:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0211.hostedemail.com [216.40.44.211]) by kanga.kvack.org (Postfix) with ESMTP id 738376B017B for ; Thu, 5 Nov 2020 13:37:08 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 031A11EF1 for ; Thu, 5 Nov 2020 18:37:08 +0000 (UTC) X-FDA: 77451221736.19.lock57_100b968272cc Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id BED6E1AD1B2 for ; Thu, 5 Nov 2020 18:37:07 +0000 (UTC) X-HE-Tag: lock57_100b968272cc X-Filterd-Recvd-Size: 6958 Received: from mail-oi1-f196.google.com (mail-oi1-f196.google.com [209.85.167.196]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Thu, 5 Nov 2020 18:37:07 +0000 (UTC) Received: by mail-oi1-f196.google.com with SMTP id m143so2696263oig.7 for ; Thu, 05 Nov 2020 10:37:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ToiqyHC98V7qJGXGI3S9IRKhf9is/zBp1DfmWd5kGWg=; b=UadTBviPCrjejBeBYCFZjcHR+LXsePgYEYe2BcGYYblbLajfB6J0tIJO170cLI5JFc Xw8n77oqpinswsvJKNRON4iylaqQoWC82Q3efkStQSjhakEaLhy9MSWLvnAjGh35ZP6R bwFf5Q/tKqOjopJ9AM4wSqdLPDDU+J9B9fdG4cN+FhtPJ7j19VH/3wHWj5UXDaa+xyUL Jt91rLzdVctf1rKZ22/uBSV8FXuuVWrRhpmRIGjeut/ghB1Vy65C2nGUNMurGiQhtx9m ROeZI9fmsl3icqpP/McEftpUopgcJ2TVhNrgQpkH8tWeBAzgcyDrrIj3BfgAuIWsa0kU Af/w== X-Gm-Message-State: AOAM531htCwLbTOPpXZEBVKFB0RjnzRrw5Ym5F62QBGqNiwvbFv5bHaV uD0mOMnZ5hzF60yTnIhPEWesR3UC1jGJuUzLjOI= X-Google-Smtp-Source: ABdhPJz4uNPUjtKlZk2wbluSksg5I2qyo5E7gmodreeqAef91jIlkMg3nkaf8gfEYmXNX+S0lBA+9ek4ROeId0nsGqc= X-Received: by 2002:aca:30d7:: with SMTP id w206mr482818oiw.69.1604601426735; Thu, 05 Nov 2020 10:37:06 -0800 (PST) MIME-Version: 1.0 References: <20201103152237.9853-1-vbabka@suse.cz> <20201103152237.9853-4-vbabka@suse.cz> In-Reply-To: <20201103152237.9853-4-vbabka@suse.cz> From: "Rafael J. Wysocki" Date: Thu, 5 Nov 2020 19:36:55 +0100 Message-ID: Subject: Re: [PATCH v2 3/5] kernel/power: allow hibernation with page_poison sanity checking To: Vlastimil Babka Cc: Andrew Morton , Linux Memory Management List , Linux Kernel Mailing List , Alexander Potapenko , Kees Cook , Michal Hocko , David Hildenbrand , Mateusz Nosek , Laura Abbott , "Rafael J. Wysocki" , Len Brown , Pavel Machek , Linux PM Content-Type: text/plain; charset="UTF-8" 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 Tue, Nov 3, 2020 at 4:24 PM Vlastimil Babka wrote: > > Page poisoning used to be incompatible with hibernation, as the state of > poisoned pages was lost after resume, thus enabling CONFIG_HIBERNATION forces > CONFIG_PAGE_POISONING_NO_SANITY. For the same reason, the poisoning with zeroes > variant CONFIG_PAGE_POISONING_ZERO used to disable hibernation. The latter > restriction was removed by commit 1ad1410f632d ("PM / Hibernate: allow > hibernation with PAGE_POISONING_ZERO") and similarly for init_on_free by commit > 18451f9f9e58 ("PM: hibernate: fix crashes with init_on_free=1") by making sure > free pages are cleared after resume. > > We can use the same mechanism to instead poison free pages with PAGE_POISON > after resume. This covers both zero and 0xAA patterns. Thus we can remove the > Kconfig restriction that disables page poison sanity checking when hibernation > is enabled. > > Signed-off-by: Vlastimil Babka > Cc: "Rafael J. Wysocki" > Cc: Len Brown > Cc: Pavel Machek > Cc: Acked-by: Rafael J. Wysocki for the hibernation part and I'm assuming that this patch will be routed through the mm tree. > --- > kernel/power/hibernate.c | 2 +- > kernel/power/power.h | 2 +- > kernel/power/snapshot.c | 14 ++++++++++---- > mm/Kconfig.debug | 1 - > 4 files changed, 12 insertions(+), 7 deletions(-) > > diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c > index 2fc7d509a34f..da0b41914177 100644 > --- a/kernel/power/hibernate.c > +++ b/kernel/power/hibernate.c > @@ -326,7 +326,7 @@ static int create_image(int platform_mode) > > if (!in_suspend) { > events_check_enabled = false; > - clear_free_pages(); > + clear_or_poison_free_pages(); > } > > platform_leave(platform_mode); > diff --git a/kernel/power/power.h b/kernel/power/power.h > index 24f12d534515..778bf431ec02 100644 > --- a/kernel/power/power.h > +++ b/kernel/power/power.h > @@ -106,7 +106,7 @@ extern int create_basic_memory_bitmaps(void); > extern void free_basic_memory_bitmaps(void); > extern int hibernate_preallocate_memory(void); > > -extern void clear_free_pages(void); > +extern void clear_or_poison_free_pages(void); > > /** > * Auxiliary structure used for reading the snapshot image data and > diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c > index 46b1804c1ddf..6b1c84afa891 100644 > --- a/kernel/power/snapshot.c > +++ b/kernel/power/snapshot.c > @@ -1144,7 +1144,7 @@ void free_basic_memory_bitmaps(void) > pr_debug("Basic memory bitmaps freed\n"); > } > > -void clear_free_pages(void) > +void clear_or_poison_free_pages(void) > { > struct memory_bitmap *bm = free_pages_map; > unsigned long pfn; > @@ -1152,12 +1152,18 @@ void clear_free_pages(void) > if (WARN_ON(!(free_pages_map))) > return; > > - if (IS_ENABLED(CONFIG_PAGE_POISONING_ZERO) || want_init_on_free()) { > + if (page_poisoning_enabled() || want_init_on_free()) { > memory_bm_position_reset(bm); > pfn = memory_bm_next_pfn(bm); > while (pfn != BM_END_OF_MAP) { > - if (pfn_valid(pfn)) > - clear_highpage(pfn_to_page(pfn)); > + if (pfn_valid(pfn)) { > + struct page *page = pfn_to_page(pfn); > + if (page_poisoning_enabled_static()) > + kernel_poison_pages(page, 1); > + else if (want_init_on_free()) > + clear_highpage(page); > + > + } > > pfn = memory_bm_next_pfn(bm); > } > diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug > index 864f129f1937..c57786ad5be9 100644 > --- a/mm/Kconfig.debug > +++ b/mm/Kconfig.debug > @@ -64,7 +64,6 @@ config PAGE_OWNER > > config PAGE_POISONING > bool "Poison pages after freeing" > - select PAGE_POISONING_NO_SANITY if HIBERNATION > help > Fill the pages with poison patterns after free_pages() and verify > the patterns before alloc_pages. The filling of the memory helps > -- > 2.29.1 >