Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromtorvalds/linux

Commitf23d74f

Browse files
tlendackyKAGA-KOKO
authored andcommitted
x86/mm: Rework wbinvd, hlt operation in stop_this_cpu()
Some issues have been reported with the for loop in stop_this_cpu() thatissues the 'wbinvd; hlt' sequence. Reverting this sequence to halt()has been shown to resolve the issue.However, the wbinvd is needed when running with SME. The reason for thewbinvd is to prevent cache flush races between encrypted and non-encryptedentries that have the same physical address. This can occur whenkexec'ing from memory encryption active to inactive or vice-versa. Theimportant thing is to not have outside of kernel text memory references(such as stack usage), so the usage of the native_*() functions is neededsince these expand as inline asm sequences. So instead of reverting thechange, rework the sequence.Move the wbinvd instruction outside of the for loop as native_wbinvd()and make its execution conditional on X86_FEATURE_SME. In the for loop,change the asm 'wbinvd; hlt' sequence back to a halt sequence but usethe native_halt() call.Fixes:bba4ed0 ("x86/mm, kexec: Allow kexec to be used with SME")Reported-by: Dave Young <dyoung@redhat.com>Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>Signed-off-by: Thomas Gleixner <tglx@linutronix.de>Tested-by: Dave Young <dyoung@redhat.com>Cc: Juergen Gross <jgross@suse.com>Cc: Tony Luck <tony.luck@intel.com>Cc: Yu Chen <yu.c.chen@intel.com>Cc: Baoquan He <bhe@redhat.com>Cc: Linus Torvalds <torvalds@linux-foundation.org>Cc: kexec@lists.infradead.orgCc: ebiederm@redhat.comCc: Borislav Petkov <bp@alien8.de>Cc: Rui Zhang <rui.zhang@intel.com>Cc: Arjan van de Ven <arjan@linux.intel.com>Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>Cc: Dan Williams <dan.j.williams@intel.com>Cc: stable@vger.kernel.orgLink:https://lkml.kernel.org/r/20180117234141.21184.44067.stgit@tlendack-t1.amdoffice.net
1 parent1d966eb commitf23d74f

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

‎arch/x86/kernel/process.c‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -380,19 +380,24 @@ void stop_this_cpu(void *dummy)
380380
disable_local_APIC();
381381
mcheck_cpu_clear(this_cpu_ptr(&cpu_info));
382382

383+
/*
384+
* Use wbinvd on processors that support SME. This provides support
385+
* for performing a successful kexec when going from SME inactive
386+
* to SME active (or vice-versa). The cache must be cleared so that
387+
* if there are entries with the same physical address, both with and
388+
* without the encryption bit, they don't race each other when flushed
389+
* and potentially end up with the wrong entry being committed to
390+
* memory.
391+
*/
392+
if (boot_cpu_has(X86_FEATURE_SME))
393+
native_wbinvd();
383394
for (;;) {
384395
/*
385-
* Use wbinvd followed by hlt to stop the processor. This
386-
* provides support for kexec on a processor that supports
387-
* SME. With kexec, going from SME inactive to SME active
388-
* requires clearing cache entries so that addresses without
389-
* the encryption bit set don't corrupt the same physical
390-
* address that has the encryption bit set when caches are
391-
* flushed. To achieve this a wbinvd is performed followed by
392-
* a hlt. Even if the processor is not in the kexec/SME
393-
* scenario this only adds a wbinvd to a halting processor.
396+
* Use native_halt() so that memory contents don't change
397+
* (stack usage and variables) after possibly issuing the
398+
* native_wbinvd() above.
394399
*/
395-
asmvolatile("wbinvd; hlt" : : :"memory");
400+
native_halt();
396401
}
397402
}
398403

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp