Skip to content

Commit 7cedb02

Browse files
committed
Merge tag 'x86-urgent-2024-06-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Ingo Molnar: "Miscellaneous fixes: - Fix kexec() crash if call depth tracking is enabled - Fix SMN reads on inaccessible registers on certain AMD systems" * tag 'x86-urgent-2024-06-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/amd_nb: Check for invalid SMN reads x86/kexec: Fix bug with call depth tracking
2 parents 7cec2e1 + c625dab commit 7cedb02

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

arch/x86/kernel/amd_nb.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,14 @@ static int __amd_smn_rw(u16 node, u32 address, u32 *value, bool write)
215215

216216
int amd_smn_read(u16 node, u32 address, u32 *value)
217217
{
218-
return __amd_smn_rw(node, address, value, false);
218+
int err = __amd_smn_rw(node, address, value, false);
219+
220+
if (PCI_POSSIBLE_ERROR(*value)) {
221+
err = -ENODEV;
222+
*value = 0;
223+
}
224+
225+
return err;
219226
}
220227
EXPORT_SYMBOL_GPL(amd_smn_read);
221228

arch/x86/kernel/machine_kexec_64.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,15 @@ void machine_kexec_cleanup(struct kimage *image)
295295
void machine_kexec(struct kimage *image)
296296
{
297297
unsigned long page_list[PAGES_NR];
298-
void *control_page;
298+
unsigned int host_mem_enc_active;
299299
int save_ftrace_enabled;
300+
void *control_page;
301+
302+
/*
303+
* This must be done before load_segments() since if call depth tracking
304+
* is used then GS must be valid to make any function calls.
305+
*/
306+
host_mem_enc_active = cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT);
300307

301308
#ifdef CONFIG_KEXEC_JUMP
302309
if (image->preserve_context)
@@ -358,7 +365,7 @@ void machine_kexec(struct kimage *image)
358365
(unsigned long)page_list,
359366
image->start,
360367
image->preserve_context,
361-
cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT));
368+
host_mem_enc_active);
362369

363370
#ifdef CONFIG_KEXEC_JUMP
364371
if (image->preserve_context)

0 commit comments

Comments
 (0)