Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752044AbdLJWUx (ORCPT ); Sun, 10 Dec 2017 17:20:53 -0500 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:54924 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751268AbdLJWUw (ORCPT ); Sun, 10 Dec 2017 17:20:52 -0500 Date: Sun, 10 Dec 2017 23:20:50 +0100 From: Pavel Machek To: Andy Lutomirski Cc: Linus Torvalds , Zhang Rui , Andrew Lutomirski , Thomas Gleixner , Jarkko Nikula , "Rafael J. Wysocki" , Linux Kernel Mailing List , the arch/x86 maintainers Subject: Re: [PATCH] Fix resume on x86-32 machines Message-ID: <20171210222049.GA6587@amd> References: <20171209103325.GA13867@amd> <20171209220110.GA11496@amd> <20171210162305.GA10159@amd> <20171210185638.GA10363@amd> <20171210213804.GA4660@amd> <76028A95-1CE1-49AA-9929-9C15FFC520EB@amacapital.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="pWyiEgJYm5f9v55/" Content-Disposition: inline In-Reply-To: <76028A95-1CE1-49AA-9929-9C15FFC520EB@amacapital.net> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3469 Lines: 115 --pWyiEgJYm5f9v55/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun 2017-12-10 13:58:23, Andy Lutomirski wrote: > > On Dec 10, 2017, at 1:38 PM, Pavel Machek wrote: > >=20 > >=20 > > After 4.15-rc2, suspend stopped working on Thinkpad X60. 5b06bbc > > (unintentionally?) reordered stuff with respect to > > fix_processor_context() on 32-bit and 64-bit. We undo that change on > > 32-bit. > >=20 >=20 > Can you explain what was wrong with the reordering? Your patch certainly= *looks* incorrect. >=20 No, I can't, sorry. > I'm guessing that the real issue is that 32-bit needs %fs restored > early for TLS. Maybe. I can test patches... I don't think it would be good idea to revert 5b06bbcfc2c621da3009da8decb7511500c293ed, but since it introduced regression in -rc2, I believe we should fix the regression now, and then we can try to provide cleaner solution. As Linus noted, the code is quite "interesting". Pavel >=20 > > While we are at it, fix a comment. > >=20 > > Signed-off-by: Pavel Machek > > Fixes: 5b06bbcfc2c621da3009da8decb7511500c293ed > >=20 > > diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c > > index 5191de1..af7b613 100644 > > --- a/arch/x86/power/cpu.c > > +++ b/arch/x86/power/cpu.c > > @@ -216,8 +216,8 @@ static void notrace __restore_processor_state(struc= t saved_context *ctxt) > > write_cr0(ctxt->cr0); > >=20 > > /* > > - * now restore the descriptor tables to their proper values > > - * ltr is done i fix_processor_context(). > > + * Now restore the descriptor tables to their proper values > > + * ltr is done in fix_processor_context(). > > */ > > #ifdef CONFIG_X86_32 > > load_idt(&ctxt->idt); > > @@ -235,13 +235,11 @@ static void notrace __restore_processor_state(str= uct saved_context *ctxt) > > wrmsrl(MSR_GS_BASE, ctxt->gs_base); > > #endif > >=20 > > - fix_processor_context(); > > - > > +#ifdef CONFIG_X86_32 > > /* > > - * Restore segment registers. This happens after restoring the GDT > > - * and LDT, which happen in fix_processor_context(). > > + * Restore segment registers. > > */ > > -#ifdef CONFIG_X86_32 > > + > > loadsegment(es, ctxt->es); > > loadsegment(fs, ctxt->fs); > > loadsegment(gs, ctxt->gs); > > @@ -252,8 +250,17 @@ static void notrace __restore_processor_state(stru= ct saved_context *ctxt) > > */ > > if (boot_cpu_has(X86_FEATURE_SEP)) > > enable_sep_cpu(); > > + > > + fix_processor_context(); > > #else > > /* CONFIG_X86_64 */ > > + /* > > + * Restore segment registers. This happens after restoring the GDT > > + * and LDT, which happen in fix_processor_context(). > > + */ > > + =20 > > + fix_processor_context(); > > + > > asm volatile ("movw %0, %%ds" :: "r" (ctxt->ds)); > > asm volatile ("movw %0, %%es" :: "r" (ctxt->es)); > > asm volatile ("movw %0, %%fs" :: "r" (ctxt->fs)); > >=20 --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --pWyiEgJYm5f9v55/ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlots0EACgkQMOfwapXb+vKbjQCdFmYYV+WWe9/hl4QWWtqgI7kG lQkAoK0fazyiOR+JTWDQ/ApCIAbafaUB =2rRs -----END PGP SIGNATURE----- --pWyiEgJYm5f9v55/--