Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp641405yba; Mon, 1 Apr 2019 13:40:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqx59h5VF60isxXDBIHMkPb4dgQ+8uyTRGTzabqotj9/4oQq+70HjD/JwdNuAB2iky5p/0tw X-Received: by 2002:a17:902:bd92:: with SMTP id q18mr16846979pls.136.1554151213899; Mon, 01 Apr 2019 13:40:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554151213; cv=none; d=google.com; s=arc-20160816; b=XgljQT/e/DGsMtaqUJwxSnzEX1eK7huOyPFCFXXMiHjuXIb9hfbzyqTjCITd4+6xck woDfITD7E/ElAjdOT/GFxR4hXOLW2p5W5uxIG/CLZain80wdQv+RsaMfi4VqWC4yh1Zu 68SLGszZ/tcZq0Qd+JyuFiKH+6XgOPUa4Y3idUOtaUfdWhQDiqowhtPVU5g4qZZ/b0s6 TRctzlNOvzGonrdzhndmrmjKojDs5VU94R0Zb1KnoZr2h4lve2GvxfC30HoAEvJ2+XtC Shcx0qS66ND4yKO3/PuLJKaMALvV+IZMPL1XdLNdp8kc9vqQasATyeODqbfrwaUx5Lq5 UYZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=cN0pgeRrdk24YjRml24XEGb+P2aR7axI9oYvgn6KFu4=; b=y8kxx/QtOgOF4yj0dg/shy25X0OPzNipreJf4w6/eO78LbXSf+7L46+hcaK2ie8V6n l3SzWliTaFA3Iq9gjjeDqNP4AoX97Wzu6Y/nYUXTgy9nUtu5oEJQtGonKaDptUSNYITI NjWO8OQIcbJLRCvKE3SQ9CYiYTW3KjJH0snb8+sVI6/VU7jh6x3tsfaAhHfzAymhxmuc Gvw5fJCewjpsQnc83oEbF/j/OQqLGS1QLw1e6cXehdzcY7D600YbQPTZrVhfQ4jaluMi Nfax0VN5iu0qiSWBUXRKGTNxK7nWZWGQ0bC7WBka5BCnEDHPjgrXfM+bc8uCbSGVAkUC KZVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3si9780042pla.399.2019.04.01.13.39.57; Mon, 01 Apr 2019 13:40:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726924AbfDAUjV (ORCPT + 99 others); Mon, 1 Apr 2019 16:39:21 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:49934 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725878AbfDAUjU (ORCPT ); Mon, 1 Apr 2019 16:39:20 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 91A83808A7; Mon, 1 Apr 2019 22:39:08 +0200 (CEST) Date: Mon, 1 Apr 2019 22:39:18 +0200 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, James Morse , "Rafael J. Wysocki" , Catalin Marinas , Will Deacon , Sasha Levin Subject: Re: [PATCH 4.4 078/131] PM / Hibernate: Call flush_icache_range() on pages restored in-place Message-ID: <20190401203918.GA26671@amd> References: <20190401170051.645954551@linuxfoundation.org> <20190401170058.681712612@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7JfCtLOvnd9MIVvH" Content-Disposition: inline In-Reply-To: <20190401170058.681712612@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --7JfCtLOvnd9MIVvH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon 2019-04-01 19:02:28, Greg Kroah-Hartman wrote: > 4.4-stable review patch. If anyone has any objections, please let me kno= w. >=20 > ------------------ >=20 > [ Upstream commit f6cf0545ec697ddc278b7457b7d0c0d86a2ea88e ] >=20 > Some architectures require code written to memory as if it were data to be > 'cleaned' from any data caches before the processor can fetch them as new > instructions. >=20 > During resume from hibernate, the snapshot code copies some pages directl= y, > meaning these architectures do not get a chance to perform their cache > maintenance. Modify the read and decompress code to call > flush_icache_range() on all pages that are restored, so that the restored > in-place pages are guaranteed to be executable on these architectures. >=20 > Signed-off-by: James Morse > Acked-by: Pavel Machek > Acked-by: Rafael J. Wysocki > Acked-by: Catalin Marinas > [will: make clean_pages_on_* static and remove initialisers] > Signed-off-by: Will Deacon > Signed-off-by: Sasha Levin I don't think this is suitable for stable. Catalin: Are there platforms that a) need this and b) support hibernation in 4.4.X? Thanks Pavel > @@ -36,6 +36,14 @@ > =20 > #define HIBERNATE_SIG "S1SUSPEND" > =20 > +/* > + * When reading an {un,}compressed image, we may restore pages in place, > + * in which case some architectures need these pages cleaning before they > + * can be executed. We don't know which pages these may be, so clean the= lot. > + */ > +static bool clean_pages_on_read; > +static bool clean_pages_on_decompress; > + > /* > * The swap map is a data structure used for keeping track of each page > * written to a swap partition. It consists of many swap_map_page > @@ -241,6 +249,9 @@ static void hib_end_io(struct bio *bio) > =20 > if (bio_data_dir(bio) =3D=3D WRITE) > put_page(page); > + else if (clean_pages_on_read) > + flush_icache_range((unsigned long)page_address(page), > + (unsigned long)page_address(page) + PAGE_SIZE); > =20 > if (bio->bi_error && !hb->error) > hb->error =3D bio->bi_error; > @@ -1049,6 +1060,7 @@ static int load_image(struct swap_map_handle *handl= e, > =20 > hib_init_batch(&hb); > =20 > + clean_pages_on_read =3D true; > printk(KERN_INFO "PM: Loading image data pages (%u pages)...\n", > nr_to_read); > m =3D nr_to_read / 10; > @@ -1124,6 +1136,10 @@ static int lzo_decompress_threadfn(void *data) > d->unc_len =3D LZO_UNC_SIZE; > d->ret =3D lzo1x_decompress_safe(d->cmp + LZO_HEADER, d->cmp_len, > d->unc, &d->unc_len); > + if (clean_pages_on_decompress) > + flush_icache_range((unsigned long)d->unc, > + (unsigned long)d->unc + d->unc_len); > + > atomic_set(&d->stop, 1); > wake_up(&d->done); > } > @@ -1189,6 +1205,8 @@ static int load_image_lzo(struct swap_map_handle *h= andle, > } > memset(crc, 0, offsetof(struct crc_data, go)); > =20 > + clean_pages_on_decompress =3D true; > + > /* > * Start the decompression threads. > */ --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --7JfCtLOvnd9MIVvH Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlyidvYACgkQMOfwapXb+vKE7ACfcdklTuz+ZcPICFYEK3GEvntW RFwAoMRfcRBZtzz1IZM5ob3r9ZjfESip =yiNi -----END PGP SIGNATURE----- --7JfCtLOvnd9MIVvH--