Skip to content

Commit 14058f7

Browse files
Saurabh Sengarliuw
authored andcommitted
x86/hyperv: Remove hv_vtl_early_init initcall
There has been cases reported where HYPERV_VTL_MODE is enabled by mistake, on a non Hyper-V platforms. This causes the hv_vtl_early_init function to be called in an non Hyper-V/VTL platforms which results the memory corruption. Remove the early_initcall for hv_vtl_early_init and call it at the end of hyperv_init to make sure it is never called in a non Hyper-V platform by mistake. Reported-by: Mathias Krause <[email protected]> Closes: https://lore.kernel.org/lkml/[email protected]/ Signed-off-by: Saurabh Sengar <[email protected]> Acked-by: Mathias Krause <[email protected]> Signed-off-by: Wei Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent f2a55d0 commit 14058f7

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

arch/x86/hyperv/hv_init.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,9 @@ void __init hyperv_init(void)
610610
/* Find the VTL */
611611
ms_hyperv.vtl = get_vtl();
612612

613+
if (ms_hyperv.vtl > 0) /* non default VTL */
614+
hv_vtl_early_init();
615+
613616
return;
614617

615618
clean_guest_os_id:

arch/x86/hyperv/hv_vtl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static int hv_vtl_wakeup_secondary_cpu(int apicid, unsigned long start_eip)
215215
return hv_vtl_bringup_vcpu(vp_id, start_eip);
216216
}
217217

218-
static int __init hv_vtl_early_init(void)
218+
int __init hv_vtl_early_init(void)
219219
{
220220
/*
221221
* `boot_cpu_has` returns the runtime feature support,
@@ -230,4 +230,3 @@ static int __init hv_vtl_early_init(void)
230230

231231
return 0;
232232
}
233-
early_initcall(hv_vtl_early_init);

arch/x86/include/asm/mshyperv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,10 @@ static inline u64 hv_get_non_nested_register(unsigned int reg) { return 0; }
340340

341341
#ifdef CONFIG_HYPERV_VTL_MODE
342342
void __init hv_vtl_init_platform(void);
343+
int __init hv_vtl_early_init(void);
343344
#else
344345
static inline void __init hv_vtl_init_platform(void) {}
346+
static inline int __init hv_vtl_early_init(void) { return 0; }
345347
#endif
346348

347349
#include <asm-generic/mshyperv.h>

0 commit comments

Comments
 (0)