hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/hv/channel_mgmt.c
....@@ -765,11 +765,22 @@
765765 if (completion_done(&vmbus_connection.unload_event))
766766 goto completed;
767767
768
- for_each_online_cpu(cpu) {
768
+ for_each_present_cpu(cpu) {
769769 struct hv_per_cpu_context *hv_cpu
770770 = per_cpu_ptr(hv_context.cpu_context, cpu);
771771
772
+ /*
773
+ * In a CoCo VM the synic_message_page is not allocated
774
+ * in hv_synic_alloc(). Instead it is set/cleared in
775
+ * hv_synic_enable_regs() and hv_synic_disable_regs()
776
+ * such that it is set only when the CPU is online. If
777
+ * not all present CPUs are online, the message page
778
+ * might be NULL, so skip such CPUs.
779
+ */
772780 page_addr = hv_cpu->synic_message_page;
781
+ if (!page_addr)
782
+ continue;
783
+
773784 msg = (struct hv_message *)page_addr
774785 + VMBUS_MESSAGE_SINT;
775786
....@@ -803,11 +814,14 @@
803814 * maybe-pending messages on all CPUs to be able to receive new
804815 * messages after we reconnect.
805816 */
806
- for_each_online_cpu(cpu) {
817
+ for_each_present_cpu(cpu) {
807818 struct hv_per_cpu_context *hv_cpu
808819 = per_cpu_ptr(hv_context.cpu_context, cpu);
809820
810821 page_addr = hv_cpu->synic_message_page;
822
+ if (!page_addr)
823
+ continue;
824
+
811825 msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT;
812826 msg->header.message_type = HVMSG_NONE;
813827 }