From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727895AbgKCLIS (ORCPT ); Tue, 3 Nov 2020 06:08:18 -0500 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 636F1C061A47 for ; Tue, 3 Nov 2020 03:08:18 -0800 (PST) Received: by mail-lf1-x144.google.com with SMTP id k14so6418046lfg.7 for ; Tue, 03 Nov 2020 03:08:18 -0800 (PST) Date: Tue, 3 Nov 2020 14:08:16 +0300 From: "Kirill A. Shutemov" Subject: Re: [PATCH v3 2/4] PM: hibernate: make direct map manipulations more explicit Message-ID: <20201103110816.t6a3ebtgcm7mfogy@box> References: <20201101170815.9795-1-rppt@kernel.org> <20201101170815.9795-3-rppt@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201101170815.9795-3-rppt@kernel.org> List-ID: To: Mike Rapoport Cc: Andrew Morton , Albert Ou , Andy Lutomirski , Benjamin Herrenschmidt , Borislav Petkov , Catalin Marinas , Christian Borntraeger , Christoph Lameter , "David S. Miller" , Dave Hansen , David Hildenbrand , David Rientjes , "Edgecombe, Rick P" , "H. Peter Anvin" , Heiko Carstens , Ingo Molnar , Joonsoo Kim , Len Brown , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , Paul Mackerras , Paul Walmsley , Pavel Machek , Pekka Enberg , Peter Zijlstra , "Rafael J. Wysocki" , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pm@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, x86@kernel.org, "Rafael J . Wysocki" On Sun, Nov 01, 2020 at 07:08:13PM +0200, Mike Rapoport wrote: > diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c > index 46b1804c1ddf..054c8cce4236 100644 > --- a/kernel/power/snapshot.c > +++ b/kernel/power/snapshot.c > @@ -76,6 +76,32 @@ static inline void hibernate_restore_protect_page(void *page_address) {} > static inline void hibernate_restore_unprotect_page(void *page_address) {} > #endif /* CONFIG_STRICT_KERNEL_RWX && CONFIG_ARCH_HAS_SET_MEMORY */ > > +static inline void hibernate_map_page(struct page *page, int enable) > +{ > + if (IS_ENABLED(CONFIG_ARCH_HAS_SET_DIRECT_MAP)) { > + unsigned long addr = (unsigned long)page_address(page); > + int ret; > + > + /* > + * This should not fail because remapping a page here means > + * that we only update protection bits in an existing PTE. > + * It is still worth to have WARN_ON() here if something > + * changes and this will no longer be the case. > + */ > + if (enable) > + ret = set_direct_map_default_noflush(page); > + else > + ret = set_direct_map_invalid_noflush(page); > + > + if (WARN_ON(ret)) _ONCE? > + return; > + > + flush_tlb_kernel_range(addr, addr + PAGE_SIZE); > + } else { > + debug_pagealloc_map_pages(page, 1, enable); > + } > +} > + > static int swsusp_page_is_free(struct page *); > static void swsusp_set_page_forbidden(struct page *); > static void swsusp_unset_page_forbidden(struct page *); -- Kirill A. Shutemov