From nobody Wed May 8 06:38:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1601674677; cv=none; d=zohomail.com; s=zohoarc; b=U5eIh2+SWHegHwqu04ls7WJj0XltBW3ApHIDWPWUuXt/03atuhuJ8Z/JcRCjrfHqFSj1TcgTsm1H8iRAKasN9BkI5IUTX/c9zJXFT1ilrRAZowHjWGK6GOhYJGKTodj4DxuLgMOSS9UCNoFZkBHx0tb1lXj5uwaqh4RtpkaZUIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601674677; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=zuzl112/oEH8uTzFRTWQkyiBhQLH3f1Jz8JhxYuIsFA=; b=naaP0dnaxtXQ1EQFAid7XXaOVnQvQNDEUHQ3kybZ9FSG0xVHC2TCS9FajYdQDmiS4hdTJlHjIJvhx2OG9QNY5uqYW7xoF2qunMw01dCNm68sWF20/wKgHuy5RI0uP+ud1xm2+rNYCCujiv4jwrxjZ0HoSLRfkx/drYNgBIM/ibU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 160167467786755.87438027757605; Fri, 2 Oct 2020 14:37:57 -0700 (PDT) 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 Received: by outflank-mailman (output) from mailman id 2350.6962; Fri, 02 Oct 2020 21:37:19 +0000 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 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) X-Outflank-Mailman: Message body and most headers restored to incoming version 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" X-Inumbo-ID: e7a44ed0-1738-491c-9f8e-d7a7dc6e6b11 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: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) c/s 4304ff420e5 "x86/S3: Drop {save,restore}_rest_processor_state() completely" moved CR4 restoration up into C, to account for the fact that M= CE 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() com= pletely") Reported-by: Marek Marczykowski-G=C3=B3recki Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich 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 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) =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_pro= t.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 2.11.0