Skip to contentSkip to conversation

x86/hyperv: Remove unregister syscore call from Hyper-V cleanup

PATCH Applied Gaurav Kohli 3 participants 3 messages Nov 26, 2022 – Nov 29, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/hyperv: Remove unregister syscore call from Hyper-V cleanup

Hyper-V cleanup code comes under panic path where preemption and irq is already disabled. So calling of unregister_syscore_ops might schedule out the thread even for the case where mutex lock is free. hyperv_cleanup
unregister_syscore_ops
mutex_lock(&syscore_ops_lock)
might_sleep
Here might_sleep might schedule out this thread, where voluntary preemption config is on and this thread will never comes back. And also this was added earlier to maintain the symmetry which is not required as this can comes during crash shutdown path only.

To prevent the same, removing unregister_syscore_ops function call.

---
v2: Update commit message

---
 arch/x86/hyperv/hv_init.c | 2 --
 1 file changed, 2 deletions(-)
arch/x86/hyperv/hv_init.c +0 -2
index f49bc3ec76e6..5ec7badab600 100644
@@ -537,8 +537,6 @@ void hyperv_cleanup(void)
 	union hv_x64_msr_hypercall_contents hypercall_msr;
 	union hv_reference_tsc_msr tsc_msr;
 
-	unregister_syscore_ops(&hv_syscore_ops);
-
 	/* Reset our OS id */
 	wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0);
 	hv_ghcb_msr_write(HV_X64_MSR_GUEST_OS_ID, 0);
Signature · 1 line
2.17.1
Reviewed-by on v2 1/1
#1 lore raw

From: Gaurav Kohli <[email protected]> Sent: Friday, November 25, 2022 10:15 PM

Quoted 36 lines

Hyper-V cleanup code comes under panic path where preemption and irq is already disabled. So calling of unregister_syscore_ops might schedule out the thread even for the case where mutex lock is free. hyperv_cleanup
unregister_syscore_ops
mutex_lock(&syscore_ops_lock)
might_sleep
Here might_sleep might schedule out this thread, where voluntary preemption config is on and this thread will never comes back. And also this was added earlier to maintain the symmetry which is not required as this can comes during crash shutdown path only.

To prevent the same, removing unregister_syscore_ops function call.

---
v2: Update commit message

---
 arch/x86/hyperv/hv_init.c | 2 --
 1 file changed, 2 deletions(-)
arch/x86/hyperv/hv_init.c +0 -3
index f49bc3ec76e6..5ec7badab600 100644
@@ -537,8 +537,6 @@ void hyperv_cleanup(void)
 	union hv_x64_msr_hypercall_contents hypercall_msr;
 	union hv_reference_tsc_msr tsc_msr;
 
-	unregister_syscore_ops(&hv_syscore_ops);
-
 	/* Reset our OS id */
 	wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0);
 	hv_ghcb_msr_write(HV_X64_MSR_GUEST_OS_ID, 0);
--
Quoted 1 line

2.17.1

maintainer Applied
#2 lore raw
Quoted 18 lines · Michael Kelley (LINUX)

From: Gaurav Kohli <[email protected]> Sent: Friday, November 25, 2022 10:15 PM

Quoted 17 lines

Hyper-V cleanup code comes under panic path where preemption and irq is already disabled. So calling of unregister_syscore_ops might schedule out the thread even for the case where mutex lock is free. hyperv_cleanup
unregister_syscore_ops
mutex_lock(&syscore_ops_lock)
might_sleep
Here might_sleep might schedule out this thread, where voluntary preemption config is on and this thread will never comes back. And also this was added earlier to maintain the symmetry which is not required as this can comes during crash shutdown path only.

To prevent the same, removing unregister_syscore_ops function call.

---

[...]

Quoted 3 lines

Applied to hyperv-next. Thanks.