android_kernel_xiaomi_sm8450/drivers/hv
Michael Kelley 8b8c9812c0 Drivers: hv: vmbus: Fix vmbus_wait_for_unload() to scan present CPUs
commit 320805ab61e5f1e2a5729ae266e16bec2904050c upstream.

vmbus_wait_for_unload() may be called in the panic path after other
CPUs are stopped. vmbus_wait_for_unload() currently loops through
online CPUs looking for the UNLOAD response message. But the values of
CONFIG_KEXEC_CORE and crash_kexec_post_notifiers affect the path used
to stop the other CPUs, and in one of the paths the stopped CPUs
are removed from cpu_online_mask. This removal happens in both
x86/x64 and arm64 architectures. In such a case, vmbus_wait_for_unload()
only checks the panic'ing CPU, and misses the UNLOAD response message
except when the panic'ing CPU is CPU 0. vmbus_wait_for_unload()
eventually times out, but only after waiting 100 seconds.

Fix this by looping through *present* CPUs in vmbus_wait_for_unload().
The cpu_present_mask is not modified by stopping the other CPUs in the
panic path, nor should it be.

Also, in a CoCo VM the synic_message_page is not allocated in
hv_synic_alloc(), but is set and cleared in hv_synic_enable_regs()
and hv_synic_disable_regs() such that it is set only when the CPU is
online.  If not all present CPUs are online when vmbus_wait_for_unload()
is called, the synic_message_page might be NULL. Add a check for this.

Fixes: cd95aad557 ("Drivers: hv: vmbus: handle various crash scenarios")
Cc: stable@vger.kernel.org
Reported-by: John Starks <jostarks@microsoft.com>
Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Link: https://lore.kernel.org/r/1684422832-38476-1-git-send-email-mikelley@microsoft.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-06-28 10:28:07 +02:00
..
channel_mgmt.c Drivers: hv: vmbus: Fix vmbus_wait_for_unload() to scan present CPUs 2023-06-28 10:28:07 +02:00
channel.c Drivers: hv: vmbus: Use after free in __vmbus_open() 2021-05-14 09:50:20 +02:00
connection.c Drivers: vmbus: Check for channel allocation before looking up relids 2023-04-20 12:10:21 +02:00
hv_balloon.c hv_balloon: rate-limit "Unhandled message" warning 2022-04-08 14:40:19 +02:00
hv_debugfs.c hv_debugfs: Make hv_debug_root static 2020-04-04 17:47:43 +01:00
hv_fcopy.c hv_utils: Always execute the fcopy and vss callbacks in a tasklet 2020-04-23 13:17:11 +00:00
hv_kvp.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
hv_snapshot.c hv_utils: Always execute the fcopy and vss callbacks in a tasklet 2020-04-23 13:17:11 +00:00
hv_trace_balloon.h hv_balloon: trace post_status 2018-03-06 09:57:17 -08:00
hv_trace.c hv: add SPDX license to trace 2018-03-28 13:24:56 +02:00
hv_trace.h hyperv-next for 5.8 2020-06-03 15:00:05 -07:00
hv_util.c hv_utils: Fix passing zero to 'PTR_ERR' warning 2021-07-14 16:55:57 +02:00
hv_utils_transport.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 280 2019-06-05 17:36:36 +02:00
hv_utils_transport.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 280 2019-06-05 17:36:36 +02:00
hv.c hyperv-fixes for 5.10-rc5 2020-11-16 15:02:33 -08:00
hyperv_vmbus.h hyperv/vmbus: include linux/bitops.h 2021-11-18 14:03:42 +01:00
Kconfig Revert "hv: utils: add PTP_1588_CLOCK to Kconfig to fix build" 2022-04-13 21:01:03 +02:00
Makefile drivers: hv: vmbus: Introduce latency testing 2019-11-21 20:10:44 -05:00
ring_buffer.c video: hyperv_fb: Avoid taking busy spinlock on panic path 2023-01-14 10:16:13 +01:00
vmbus_drv.c Drivers: hv: vmbus: fix possible memory leak in vmbus_device_register() 2022-12-02 17:40:00 +01:00