mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Chang S. Bae" <chang.seok.bae@intel.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Adamos Ttofari <attofari@amazon.de>
Cc: <abusse@amazon.de>, <dwmw@amazon.co.uk>, <hborghor@amazon.de>,
	<sironi@amazon.de>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>, <x86@kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>, Kyle Huey <me@kylehuey.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] fpu: xstate: Keep xfd_state always in-sync with IA32_XFD MSR
Date: Fri, 12 May 2023 10:46:15 -0700	[thread overview]
Message-ID: <ec7b8f81-98ea-539c-c1b9-abf103e45b30@intel.com> (raw)
In-Reply-To: <877cted6pl.ffs@tglx>

On 5/11/2023 12:11 PM, Thomas Gleixner wrote:
> On Thu, May 11 2023 at 15:28, Adamos Ttofari wrote:
> 
>> @@ -915,7 +921,7 @@ void fpu__resume_cpu(void)
>>   	}
>>   
>>   	if (fpu_state_size_dynamic())
>> -		wrmsrl(MSR_IA32_XFD, current->thread.fpu.fpstate->xfd);
>> +		xfd_update_state(&init_fpstate);

xfd_update_state() here is not a right choice as Thomas pointed out 
multiple times.

> On suspend per CPU xfd_state == current->thread.fpu.fpstate->xfd so it's
> correct to restore the exact state which was active _before_ suspend.
> xfd_state can't be out of sync in that case, no?

Indeed! But, looking around the code, writing 'xfd_state' here appears 
to be consistent and logical I suppose.

Every time writing the MSR in the kernel (except for the init), the 
value is saved in 'xfd_state'. So we don't do it on the sleep path. 
Then, on the wake-up path, perhaps it makes sense to restore the context 
with the saved.

Thanks,
Chang

  reply	other threads:[~2023-05-12 17:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-11 15:28 Adamos Ttofari
2023-05-11 17:59 ` Dave Hansen
2023-05-11 19:11 ` Thomas Gleixner
2023-05-12 17:46   ` Chang S. Bae [this message]
2023-05-12 11:38 ` [PATCH v2] x86: fpu: Keep xfd_state always in sync with MSR_IA32_XFD Adamos Ttofari
2023-05-12 12:52   ` Thomas Gleixner
2023-05-19 11:23     ` [PATCH v3] " Adamos Ttofari
2023-05-19 15:03       ` Thomas Gleixner
2023-05-19 22:21       ` Chang S. Bae
2023-06-03 15:24         ` [PATCH] selftests/x86/amx: Add a CPU hotplug test Chang S. Bae
2024-03-22 23:04       ` [PATCH v4] x86/fpu: Keep xfd_state always in sync with MSR_IA32_XFD Chang S. Bae
2024-03-24  3:15         ` [tip: x86/urgent] x86/fpu: Keep xfd_state " tip-bot2 for Adamos Ttofari
2023-05-16 21:35   ` [PATCH v2] x86: fpu: Keep xfd_state always " Chang S. Bae

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=ec7b8f81-98ea-539c-c1b9-abf103e45b30@intel.com \
    --to=chang.seok.bae@intel.com \
    --cc=abusse@amazon.de \
    --cc=andrew.cooper3@citrix.com \
    --cc=attofari@amazon.de \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dwmw@amazon.co.uk \
    --cc=hborghor@amazon.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@kylehuey.com \
    --cc=mingo@redhat.com \
    --cc=sironi@amazon.de \
    --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®