mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joan Bruguera <joanbrugueram@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: Wake-up from suspend to RAM broken under `retbleed=stuff`
Date: Mon,  9 Jan 2023 04:05:31 +0000	[thread overview]
Message-ID: <20230109040531.7888-1-joanbrugueram@gmail.com> (raw)
In-Reply-To: <20230108030748.158120-1-joanbrugueram@gmail.com>

This fixes wakeup for me on both QEMU and real HW
(just a proof of concept, don't merge)

diff --git a/arch/x86/kernel/callthunks.c b/arch/x86/kernel/callthunks.c
index ffea98f9064b..8704bcc0ce32 100644
--- a/arch/x86/kernel/callthunks.c
+++ b/arch/x86/kernel/callthunks.c
@@ -7,6 +7,7 @@
 #include <linux/memory.h>
 #include <linux/moduleloader.h>
 #include <linux/static_call.h>
+#include <linux/suspend.h>
 
 #include <asm/alternative.h>
 #include <asm/asm-offsets.h>
@@ -150,6 +151,10 @@ static bool skip_addr(void *dest)
 	if (dest >= (void *)hypercall_page &&
 	    dest < (void*)hypercall_page + PAGE_SIZE)
 		return true;
+#endif
+#ifdef CONFIG_PM_SLEEP
+	if (dest == restore_processor_state)
+		return true;
 #endif
 	return false;
 }
diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
index 236447ee9beb..e667894936f7 100644
--- a/arch/x86/power/cpu.c
+++ b/arch/x86/power/cpu.c
@@ -281,6 +281,9 @@ static void notrace __restore_processor_state(struct saved_context *ctxt)
 /* Needed by apm.c */
 void notrace restore_processor_state(void)
 {
+	/* Restore GS before calling anything to avoid crash on call depth accounting */
+	native_wrmsrl(MSR_GS_BASE, saved_context.kernelmode_gs_base);
+
 	__restore_processor_state(&saved_context);
 }
 #ifdef CONFIG_X86_32

  parent reply	other threads:[~2023-01-09  4:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-08  3:07 Joan Bruguera
2023-01-08 11:33 ` Borislav Petkov
2023-01-08 17:11   ` Joan Bruguera
2023-01-08 21:27     ` Borislav Petkov
2023-01-08 22:27       ` Joan Bruguera
2023-01-09  4:05 ` Joan Bruguera [this message]
2023-01-11 11:20   ` Peter Zijlstra
2023-01-11 11:39     ` Andrew Cooper
2023-01-11 11:45       ` Jan Beulich
2023-01-11 22:06         ` Andrew Cooper
2023-01-11 11:52     ` Juergen Gross
2023-01-11 12:59       ` Peter Zijlstra
2023-01-11 17:56     ` Rafael J. Wysocki

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=20230109040531.7888-1-joanbrugueram@gmail.com \
    --to=joanbrugueram@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®