All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Gaiser <simon@invisiblethingslab.com>
To: xen-devel@lists.xenproject.org
Cc: Simon Gaiser <simon@invisiblethingslab.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Jan Beulich <jbeulich@suse.com>
Subject: [PATCH 2/2] x86: correct ordering of operations during S3 resume
Date: Wed, 11 Apr 2018 22:14:58 +0200	[thread overview]
Message-ID: <20180411201458.26004-2-simon@invisiblethingslab.com> (raw)
In-Reply-To: <20180411201458.26004-1-simon@invisiblethingslab.com>

Microcode loading needs to happen before re-enabling interrupts, in case
only updated microcode allows the use of e.g. the SPEC_{CTRL,CMD} MSRs.
Otoh it doesn't need to happen at all when we didn't suspend in the
first place. It needs to happen before spin_debug_enable() though, as it
acquires a lock and hence would otherwise make
common/spinlock.c:check_lock() unhappy. As microcode loading can be
pretty verbose, also make sure it only runs after console_end_sync().

cpufreq_add_cpu() doesn't need calling on the only "goto enable_cpu"
path, which sits ahead of cpufreq_del_cpu().

Reported-by: Simon Gaiser <simon@invisiblethingslab.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
[Simon: Panic if microcode restore fails]
Signed-off-by: Simon Gaiser <simon@invisiblethingslab.com>
---
 xen/arch/x86/acpi/power.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/acpi/power.c b/xen/arch/x86/acpi/power.c
index 1e4e5680a7..0e00c198db 100644
--- a/xen/arch/x86/acpi/power.c
+++ b/xen/arch/x86/acpi/power.c
@@ -203,6 +203,7 @@ static int enter_state(u32 state)
         printk(XENLOG_ERR "Some devices failed to power down.");
         system_state = SYS_STATE_resume;
         device_power_up(error);
+        console_end_sync();
         error = -EIO;
         goto done;
     }
@@ -243,17 +244,21 @@ static int enter_state(u32 state)
     if ( (state == ACPI_STATE_S3) && error )
         tboot_s3_error(error);
 
+    console_end_sync();
+
+    error = microcode_resume_cpu(0);
+    if (error && error != -ENOENT)
+        panic("Could not restore microcode on boot cpu (%d)", error);
+
  done:
     spin_debug_enable();
     local_irq_restore(flags);
-    console_end_sync();
     acpi_sleep_post(state);
     if ( hvm_cpu_up() )
         BUG();
+    cpufreq_add_cpu(0);
 
  enable_cpu:
-    cpufreq_add_cpu(0);
-    microcode_resume_cpu(0);
     rcu_barrier();
     mtrr_aps_sync_begin();
     enable_nonboot_cpus();
-- 
2.16.2


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-04-11 20:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-11 11:48 Resume from suspend to RAM broken when using early microcode updates Simon Gaiser
2018-04-11 11:51 ` Andrew Cooper
2018-04-11 12:01   ` Simon Gaiser
2018-04-11 12:11     ` Jan Beulich
2018-04-11 12:17       ` Jan Beulich
2018-04-11 12:46         ` Simon Gaiser
2018-04-11 13:45           ` Jan Beulich
2018-04-11 20:14             ` [PATCH 1/2] x86/microcode: Indicate "not found" in rc of microcode_resume_cpu() Simon Gaiser
2018-04-11 20:14               ` Simon Gaiser [this message]
2018-04-11 20:21                 ` [PATCH v2 2/2] x86: correct ordering of operations during S3 resume Simon Gaiser
     [not found]                   ` <5ACE6EA10200005203786DDD@prv1-mh.provo.novell.com>
2018-04-12  7:12                     ` Jan Beulich
2018-04-12  6:56               ` [PATCH 1/2] x86/microcode: Indicate "not found" in rc of microcode_resume_cpu() Jan Beulich
2018-04-11 12:12     ` Resume from suspend to RAM broken when using early microcode updates Andrew Cooper
2018-04-11 14:49       ` Konrad Rzeszutek Wilk
2018-04-11 15:05         ` Andrew Cooper
2018-04-11 15:32           ` Jan Beulich
2018-04-11 12:04   ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180411201458.26004-2-simon@invisiblethingslab.com \
    --to=simon@invisiblethingslab.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.