linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@denx.de>
To: Roman Kiryanov <rkir@google.com>
Cc: Pavel Machek <pavel@denx.de>, Borislav Petkov <bp@alien8.de>,
	rjw@rjwysocki.net, Thomas Gleixner <tglx@linutronix.de>,
	mingo@redhat.com, x86@kernel.org, linux-pm@vger.kernel.org,
	Greg KH <gregkh@linuxfoundation.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Alistair Delva <adelva@google.com>,
	Haitao Shan <hshan@google.com>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] arch: x86: power: cpu: init %gs before __restore_processor_state (clang)
Date: Sun, 4 Oct 2020 11:59:43 +0200	[thread overview]
Message-ID: <20201004095942.GD1104@bug> (raw)
In-Reply-To: <CAOGAQepVWwMvA_m_kZpwQ4UN+ziR+=w2auiL1euFyuGvyCU7SQ@mail.gmail.com>

Hi!

> > > > > I believe the kernel makes a questionable assumption on how clang
> > > > > uses registers (gs will not be used if stack protection is disabled).
> > > > > Both kernel and clang behaves unfortunate here.
> > > >
> > > > If the kernel is at fault here and this same thing happens with GCC,
> > > > sure, but this is a clang-specific fix.
> > >
> > > This is fair. Unfortunately I am not an x86 asm expert. I expect the proper
> > > fix should land into arch/x86/kernel/acpi/wakeup_64.S to init %gs
> > > (maybe some more registers) before "jmp restore_processor_state".
> >
> > That would certainly be nicer / more acceptable solution than patch
> > being proposed here.
> >
> > Code was written with assumption compiler random C code would not use
> > %gs. If that's no longer true, fixing it in wakeup_64.S _with comments
> > explaining what goes on_ might be solution.
> 
> I looked and restore_processor_state is referenced in several places,
> so changing
> wakeup_64.S is not enough. Is moving the beginning of restore_processor_state
> to an .S file ok? I see restore_processor_state initializes CR registers first,
> do you know if there is a reason to do so (can I init segment
> registers before CR ones)?

Yes, moving to .S file should be okay.

CR first... makes sense to me, they really select how segment registers will be
interpretted, etc. If it will work the other way... not sure.

I'd keep existing code if I were you. This is tricky to debug.

									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

  reply	other threads:[~2020-10-04  9:59 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-15 17:26 [PATCH] arch: x86: power: cpu: init %gs before __restore_processor_state (clang) rkir
2020-09-15 17:46 ` Borislav Petkov
2020-09-15 17:57   ` Roman Kiryanov
2020-09-15 18:27     ` Borislav Petkov
2020-09-15 18:36       ` Roman Kiryanov
2020-09-15 18:52         ` Borislav Petkov
2020-09-15 18:55           ` Roman Kiryanov
2020-09-18 22:25         ` Pavel Machek
2020-09-21 23:28           ` Roman Kiryanov
2020-10-04  9:59             ` Pavel Machek [this message]
2020-09-15 18:00   ` Nick Desaulniers
2020-09-15 18:25     ` Borislav Petkov
2020-09-15 19:51       ` Nick Desaulniers
2020-09-15 20:20         ` Borislav Petkov
2020-09-15 21:49           ` Nick Desaulniers
2020-09-16  9:23             ` Borislav Petkov
2020-09-19 16:48             ` Pavel Machek
2020-09-16  8:17         ` peterz
2020-09-15 20:44     ` Arvind Sankar
2020-09-15 22:17 ` Pavel Machek
2020-09-15 22:21   ` Nick Desaulniers
2020-09-18 22:20     ` Pavel Machek
2020-09-15 23:13   ` Roman Kiryanov

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=20201004095942.GD1104@bug \
    --to=pavel@denx.de \
    --cc=adelva@google.com \
    --cc=bp@alien8.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=hshan@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=ndesaulniers@google.com \
    --cc=rjw@rjwysocki.net \
    --cc=rkir@google.com \
    --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;
as well as URLs for NNTP newsgroup(s).