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=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 780D1C4363A for ; Mon, 5 Oct 2020 21:15:37 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0886E2078E for ; Mon, 5 Oct 2020 21:15:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0886E2078E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=invisiblethingslab.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.3085.8933 (Exim 4.92) (envelope-from ) id 1kPXpN-0008E8-U3; Mon, 05 Oct 2020 21:15:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 3085.8933; Mon, 05 Oct 2020 21:15:25 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kPXpN-0008E1-Qz; Mon, 05 Oct 2020 21:15:25 +0000 Received: by outflank-mailman (input) for mailman id 3085; Mon, 05 Oct 2020 21:15:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kPXpM-0008Du-2S for xen-devel@lists.xenproject.org; Mon, 05 Oct 2020 21:15:24 +0000 Received: from wout3-smtp.messagingengine.com (unknown [64.147.123.19]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0adaa178-0210-411b-95f5-ce439d0d8dfb; Mon, 05 Oct 2020 21:15:23 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id B5B19B54; Mon, 5 Oct 2020 17:15:21 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 05 Oct 2020 17:15:22 -0400 Received: from mail-itl (ip5b40aa59.dynamic.kabel-deutschland.de [91.64.170.89]) by mail.messagingengine.com (Postfix) with ESMTPA id 072453280065; Mon, 5 Oct 2020 17:15:19 -0400 (EDT) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kPXpM-0008Du-2S for xen-devel@lists.xenproject.org; Mon, 05 Oct 2020 21:15:24 +0000 X-Inumbo-ID: 0adaa178-0210-411b-95f5-ce439d0d8dfb Received: from wout3-smtp.messagingengine.com (unknown [64.147.123.19]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0adaa178-0210-411b-95f5-ce439d0d8dfb; Mon, 05 Oct 2020 21:15:23 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id B5B19B54; Mon, 5 Oct 2020 17:15:21 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 05 Oct 2020 17:15:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=78gGKA +FpT1gnP+KjIavvYsyqEE7AX9QTMq1801bMgk=; b=I5lNESO7eMv1EfSA91K6eF ch5VD0EmfvLHEwpEV++lUvS8+eU9V5vpZQvNE58O/2uM8wNv87OqcmOoBajTF6L5 W+wVNqCgMaxezPI81rcAiJ0Rs+hR8lhDqGL+Lc7QsnPGTppjGd5zKTHDzVQDhNix YRNU9vQWLN5O8yU1NEY3WlhSVV88BRWJiB69HX5me0CjrAqqy79eN0ovn/izWDqm uh1mVjHglEzC6hga7ntAZXthE0llCnkN03A3Jfrys4+XIJtohvvOaLHt0EZHuLlF WTXxbx7VokfpVhBcBeSAZKvAme7KnEgBPnCszE7MWXrOCQAtN8w0noDQV6AzgJ1Q == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrgedvgdduieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehgtderredttdejnecuhfhrohhmpeforghrvghk ucforghrtgiihihkohifshhkihdqifpkrhgvtghkihcuoehmrghrmhgrrhgvkhesihhnvh hishhisghlvghthhhinhhgshhlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpedtudff feefjeduhffgffelueeugefgvdeltdegfeevtdeugeeuieeltdevfeeuhfenucffohhmrg hinhepphhrohhtrdhssgenucfkphepledurdeigedrudejtddrkeelnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhgrrhhmrghrvghksehinh hvihhsihgslhgvthhhihhnghhslhgrsgdrtghomh X-ME-Proxy: Received: from mail-itl (ip5b40aa59.dynamic.kabel-deutschland.de [91.64.170.89]) by mail.messagingengine.com (Postfix) with ESMTPA id 072453280065; Mon, 5 Oct 2020 17:15:19 -0400 (EDT) Date: Mon, 5 Oct 2020 23:15:17 +0200 From: Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= To: Andrew Cooper Cc: Xen-devel , Jan Beulich , Roger Pau =?utf-8?B?TW9ubsOp?= , Wei Liu Subject: Re: [PATCH] x86/S3: Restore CR4 earlier during resume Message-ID: <20201005211517.GB29479@mail-itl> References: <20201002213650.2197-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="0eh6TmSyL6TZE2Uz" Content-Disposition: inline In-Reply-To: <20201002213650.2197-1-andrew.cooper3@citrix.com> --0eh6TmSyL6TZE2Uz Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH] x86/S3: Restore CR4 earlier during resume On Fri, Oct 02, 2020 at 10:36:50PM +0100, Andrew Cooper wrote: > c/s 4304ff420e5 "x86/S3: Drop {save,restore}_rest_processor_state() > completely" moved CR4 restoration up into C, to account for the fact that= MCE > was explicitly handled later. >=20 > However, time_resume() ends up making an EFI Runtime Service call, and EFI > explodes without OSFXSR, presumably when trying to spill %xmm registers o= nto > the stack. >=20 > Given this codepath, and the potential for other issues of a similar kind= (TLB > flushing vs INVPCID, HVM logic vs VMXE, etc), restore CR4 in asm before > entering C. >=20 > Ignore the previous MCE special case, because its not actually necessary.= The > handler is already suitably configured from before suspend. >=20 > Fixes: 4304ff420e5 ("x86/S3: Drop {save,restore}_rest_processor_state() c= ompletely") > Reported-by: Marek Marczykowski-G=C3=B3recki > Signed-off-by: Andrew Cooper This one doesn't build, wakeup_prot.S misses #include =2E With that fixed: Tested-by: Marek Marczykowski-G=C3=B3recki > --- > CC: Jan Beulich > CC: Roger Pau Monn=C3=A9 > CC: Wei Liu > CC: Marek Marczykowski-G=C3=B3recki >=20 > This is one definite bug fix. It doesn't appear to be the only S3 bug > however. > --- > xen/arch/x86/acpi/power.c | 3 --- > xen/arch/x86/acpi/wakeup_prot.S | 5 +++++ > 2 files changed, 5 insertions(+), 3 deletions(-) >=20 > diff --git a/xen/arch/x86/acpi/power.c b/xen/arch/x86/acpi/power.c > index 4fb1e7a148..7f162a4df9 100644 > --- a/xen/arch/x86/acpi/power.c > +++ b/xen/arch/x86/acpi/power.c > @@ -276,9 +276,6 @@ static int enter_state(u32 state) > =20 > mcheck_init(&boot_cpu_data, false); > =20 > - /* Restore CR4 from cached value, now MCE is set up. */ > - write_cr4(read_cr4()); > - > printk(XENLOG_INFO "Finishing wakeup from ACPI S%d state.\n", state); > =20 > if ( (state =3D=3D ACPI_STATE_S3) && error ) > diff --git a/xen/arch/x86/acpi/wakeup_prot.S b/xen/arch/x86/acpi/wakeup_p= rot.S > index c6b3fcc93d..1ee5551fb5 100644 > --- a/xen/arch/x86/acpi/wakeup_prot.S > +++ b/xen/arch/x86/acpi/wakeup_prot.S > @@ -110,6 +110,11 @@ ENTRY(s3_resume) > =20 > call load_system_tables > =20 > + /* Restore CR4 from the cpuinfo block. */ > + GET_STACK_END(bx) > + mov STACK_CPUINFO_FIELD(cr4)(%rbx), %rax > + mov %rax, %cr4 > + > .Lsuspend_err: > pop %r15 > pop %r14 --=20 Best Regards, Marek Marczykowski-G=C3=B3recki Invisible Things Lab A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? --0eh6TmSyL6TZE2Uz Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEhrpukzGPukRmQqkK24/THMrX1ywFAl97jOQACgkQ24/THMrX 1yxwQAf8Dmth2ZMaDIcy1RZdmJqq+/Zr6s4nHlu0slcjWanu7gIkQt7x4PzLkdGN LDFqmCjlcUh3/dlmZ+gAT9573Gnv6WZKzUGv9SrXS5B1GVBn+Z3zWhk+S5Tf9F5q tlIk0AydKFLFzjlASnwrfO89/ypcBi2A13iMCHgKug1BlK4NGpAtx3smn2ZrvIQP jt70pfwZ0D49lTsKElmjhNEo7GWURtWaWNOEg/n/yhITUcb8Ykk1i43UNQ7y22i5 soWPEAv3cGnSBhPc9a7agODMLV/1smS3i5DluXwlLwWQitwi33fIU8IerjvdASjV ZV4mXQ0SCKGvJ6jJ2dAipFQnpeYrgw== =+E2q -----END PGP SIGNATURE----- --0eh6TmSyL6TZE2Uz--