Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp642635ybz; Wed, 22 Apr 2020 05:21:08 -0700 (PDT) X-Google-Smtp-Source: APiQypIZAKJ9EI8sk/tY28SqqdauU9Ta+0AUJ4WjHo2u7n0IbLEbGuSh9UhIcV0W1ZHGHfAoKcCX X-Received: by 2002:a17:906:4903:: with SMTP id b3mr19730322ejq.80.1587558068495; Wed, 22 Apr 2020 05:21:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587558068; cv=none; d=google.com; s=arc-20160816; b=apBNNX73pZdS99v1+neiAvLaO5Ok50/faWe08d7tQmjtrdHGubOk3LMThMJ0H4Cdqr F+7jOspk42ECtLah6CbiHS++MXbtoIdEXwgIxcDhem2y0z+xyrDB5bNj4mqzmDKbgB/T THNFJ9oqZtnNQ8EE0bF4loSt36OVVEwGboaRhabM99SFSVcQMRrWsOnn2aBNWGTin2kR eLgR3quSUD5daES2J/5bXA6eaddcjveUzXPhUlXs6tt4AKGoPuKmVK7Qy2HruhzWAhhW s9M3VSU6nuJnV0Ym/5/F6py2Y8AcFBal/YYOTMXa7teSvhvrF88+42zJb08SLO3niIf7 d2jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=k2BHT39qQlUuiutad9sctVxQwF5/pm76UI81RqcpuSM=; b=maVVfvlcFtjwp1bjCynvYytpl32lUnaTsG+M87GMEbQVhacfr0iQXzbYdFiNEj6P+q k4HD6PGCydwSkN0qQfNdik793n46sKnSR66rBBZpvG8ciUwYhJGLja4ukYPoGa2q0FEt QpmR/6Ms2+9ClnebJlbQ6D6ALF+eWP09xwO4weLjItX3sNsMG8B4HznKE92srVT+7Cpz F0T5vgQ5d7cg3WvuWQesFKRZ687VIrrPT+Itn7+hZ+ueNWQ8GmKgiA/VHkae6M7MgIwl Z/p4n18ZM7qbTrdtEhD8hP02M2c6qY7+2H0WvVX12M9A5QNgIZ6EjGm/s7FuZoUpnGO9 wugg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VUORTRc6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bd4si3076636edb.607.2020.04.22.05.20.36; Wed, 22 Apr 2020 05:21:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VUORTRc6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729495AbgDVKOR (ORCPT + 99 others); Wed, 22 Apr 2020 06:14:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:48478 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729479AbgDVKOI (ORCPT ); Wed, 22 Apr 2020 06:14:08 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4E89820775; Wed, 22 Apr 2020 10:14:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587550447; bh=86Oq2sZQUjcvGZ9/UwEo1yNRJHuBONwEDrlcqA+shww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VUORTRc6b6KffXEAKbgWZ+oxD1g0qO307uwS7f4yDW3FS2Sh4YQZqnd+g7/rgCyPd yeea/Q6a1Yo1VgYpoRSJcYxbHpghIypAdXGiMZg4r7rR2sJfyJJdpnEgvhrrIHCxvO uwVmIPWpCnxDPF8dbuRYNVsVusRHfGmtib2cDjks= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Kelley , Tianyu Lan , Wei Liu , Sasha Levin Subject: [PATCH 4.19 21/64] x86/Hyper-V: Unload vmbus channel in hv panic callback Date: Wed, 22 Apr 2020 11:57:05 +0200 Message-Id: <20200422095016.907037742@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200422095008.799686511@linuxfoundation.org> References: <20200422095008.799686511@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tianyu Lan [ Upstream commit 74347a99e73ae00b8385f1209aaea193c670f901 ] When kdump is not configured, a Hyper-V VM might still respond to network traffic after a kernel panic when kernel parameter panic=0. The panic CPU goes into an infinite loop with interrupts enabled, and the VMbus driver interrupt handler still works because the VMbus connection is unloaded only in the kdump path. The network responses make the other end of the connection think the VM is still functional even though it has panic'ed, which could affect any failover actions that should be taken. Fix this by unloading the VMbus connection during the panic process. vmbus_initiate_unload() could then be called twice (e.g., by hyperv_panic_event() and hv_crash_handler(), so reset the connection state in vmbus_initiate_unload() to ensure the unload is done only once. Fixes: 81b18bce48af ("Drivers: HV: Send one page worth of kmsg dump over Hyper-V during panic") Reviewed-by: Michael Kelley Signed-off-by: Tianyu Lan Link: https://lore.kernel.org/r/20200406155331.2105-2-Tianyu.Lan@microsoft.com Signed-off-by: Wei Liu Signed-off-by: Sasha Levin --- drivers/hv/channel_mgmt.c | 3 +++ drivers/hv/vmbus_drv.c | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index 16eb9b3f1cb1b..3bf1f9ef8ea25 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -849,6 +849,9 @@ void vmbus_initiate_unload(bool crash) { struct vmbus_channel_message_header hdr; + if (xchg(&vmbus_connection.conn_state, DISCONNECTED) == DISCONNECTED) + return; + /* Pre-Win2012R2 hosts don't support reconnect */ if (vmbus_proto_version < VERSION_WIN8_1) return; diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 9aa18f387a346..5ff7c1708d0e7 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -63,9 +63,12 @@ static int hyperv_panic_event(struct notifier_block *nb, unsigned long val, { struct pt_regs *regs; - regs = current_pt_regs(); + vmbus_initiate_unload(true); - hyperv_report_panic(regs, val); + if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) { + regs = current_pt_regs(); + hyperv_report_panic(regs, val); + } return NOTIFY_DONE; } @@ -1228,10 +1231,16 @@ static int vmbus_bus_init(void) } register_die_notifier(&hyperv_die_block); - atomic_notifier_chain_register(&panic_notifier_list, - &hyperv_panic_block); } + /* + * Always register the panic notifier because we need to unload + * the VMbus channel connection to prevent any VMbus + * activity after the VM panics. + */ + atomic_notifier_chain_register(&panic_notifier_list, + &hyperv_panic_block); + vmbus_request_offers(); return 0; @@ -1875,7 +1884,6 @@ static void hv_kexec_handler(void) { hv_synic_clockevents_cleanup(); vmbus_initiate_unload(false); - vmbus_connection.conn_state = DISCONNECTED; /* Make sure conn_state is set as hv_synic_cleanup checks for it */ mb(); cpuhp_remove_state(hyperv_cpuhp_online); @@ -1890,7 +1898,6 @@ static void hv_crash_handler(struct pt_regs *regs) * doing the cleanup for current CPU only. This should be sufficient * for kdump. */ - vmbus_connection.conn_state = DISCONNECTED; hv_synic_cleanup(smp_processor_id()); hyperv_cleanup(); }; -- 2.20.1