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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT 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 C17D6C4363D for ; Fri, 2 Oct 2020 21:37:50 +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 572FA206DC for ; Fri, 2 Oct 2020 21:37:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="Tf0pz0yM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 572FA206DC Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.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.2350.6962 (Exim 4.92) (envelope-from ) id 1kOSjv-0006ZF-PZ; Fri, 02 Oct 2020 21:37:19 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 2350.6962; Fri, 02 Oct 2020 21:37:19 +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 1kOSjv-0006Z8-Ly; Fri, 02 Oct 2020 21:37:19 +0000 Received: by outflank-mailman (input) for mailman id 2350; Fri, 02 Oct 2020 21:37:17 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kOSjt-0006Z0-EF for xen-devel@lists.xenproject.org; Fri, 02 Oct 2020 21:37:17 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e7a44ed0-1738-491c-9f8e-d7a7dc6e6b11; Fri, 02 Oct 2020 21:37:16 +0000 (UTC) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kOSjt-0006Z0-EF for xen-devel@lists.xenproject.org; Fri, 02 Oct 2020 21:37:17 +0000 X-Inumbo-ID: e7a44ed0-1738-491c-9f8e-d7a7dc6e6b11 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e7a44ed0-1738-491c-9f8e-d7a7dc6e6b11; Fri, 02 Oct 2020 21:37:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1601674635; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=9XdDMMC3s8tS4ojhpvzgEXNjfjbFKoUyqBzWSCEDShc=; b=Tf0pz0yMjRWUO8AR2Z8oLJ1xclkWr3yWQyTGYLhyi7J37Tdu8G1YK8lY 3H2qNSQ3xcvHIlyvvyc7vZC/FBwmcFVQ0Fiq9dy2Xkv5Onj6WMa7YIU2m kbX/7+kiJCIfR/mvH92AArqbQeDQxZmW//OTYScA5d3vTl7qjfbTpGZjb A=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: LOKjwRwi/M3m+tachbBjD7pQS5M4HSs1Ov60tAq/bg3etPxr0DT4FvaCy/bxtmMPysh4pxltGS dVmmbnCUIbjNUAEbVYumSPTs7u2FhtZjVy486VgtyuYLJjjbYHykqcZFpBbSR7a3cd9ZOF/36l uZiGr1TS1p804Snkq0VlAOleswvY/oXZ2V4DZYeArv1va0GXe8YQt3MEDCTTtYK/ob/fFIm4wd vrXNGNp6WaiDG2GKuJIk5tlZ0ZiNneJL/qZOAK/hJkTdMOLTRwZDQpzRz/mlc22yAkIEhy6AC2 taw= X-SBRS: None X-MesageID: 28463514 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.77,329,1596513600"; d="scan'208";a="28463514" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Subject: [PATCH] x86/S3: Restore CR4 earlier during resume Date: Fri, 2 Oct 2020 22:36:50 +0100 Message-ID: <20201002213650.2197-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit 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. However, time_resume() ends up making an EFI Runtime Service call, and EFI explodes without OSFXSR, presumably when trying to spill %xmm registers onto the stack. 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. Ignore the previous MCE special case, because its not actually necessary. The handler is already suitably configured from before suspend. Fixes: 4304ff420e5 ("x86/S3: Drop {save,restore}_rest_processor_state() completely") Reported-by: Marek Marczykowski-Górecki Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Roger Pau Monné CC: Wei Liu CC: Marek Marczykowski-Górecki 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(-) 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) mcheck_init(&boot_cpu_data, false); - /* 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); if ( (state == ACPI_STATE_S3) && error ) diff --git a/xen/arch/x86/acpi/wakeup_prot.S b/xen/arch/x86/acpi/wakeup_prot.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) call load_system_tables + /* 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 -- 2.11.0