From patchwork Tue Jun 16 02:58:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1309941 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49mCZv36t1z9sSd; Tue, 16 Jun 2020 12:59:03 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jl1oR-0000Y7-JY; Tue, 16 Jun 2020 02:58:59 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jl1oN-0000W1-Uo for kernel-team@lists.ubuntu.com; Tue, 16 Jun 2020 02:58:55 +0000 Received: from mail-qt1-f199.google.com ([209.85.160.199]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jl1oN-00064B-KE for kernel-team@lists.ubuntu.com; Tue, 16 Jun 2020 02:58:55 +0000 Received: by mail-qt1-f199.google.com with SMTP id d2so15676239qtw.4 for ; Mon, 15 Jun 2020 19:58:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nYSQFyvxebclWe7c+JcZc1/OBgWzCqiZUjPuOrJnnsw=; b=WAuAvKb9dJd6VMft996vWfReTfGNaLYziEMIfSxjdErf26uV6VfHedQSgc+di9i4rY ybHQ163Onn1Wu7VrH6ccBd30lQQheIUBlnPL6iugI3BSmBnWHGOWNHEFgUCFCcw+3lsh Qh0mpBFzO5IoLXB3+gbv+A8vUVAZOb7q9A6ZQ1WW7IztJRtzWrbzq5Z+nxAql2onLyJS Acanl/t/njrFDBt4SlAq20GfEW5/5cjRt1PGf4P7YbL7/9umHyXg+58izcT9R2bvbe9P UiPHHXGvaui4dcEqjJ97f6VYnK6Rb9D8f/t/yoZbpE/DjavD6pilvMRskSIIg/DfwEIZ Bodg== X-Gm-Message-State: AOAM533HF7/Wzro85YoClU08to2jZwtrVRAF8YIu49oF7lzC2QjE5Fsd 9Zwf4/tYGqkOp7fHZjzqIHwoMYSwjpRLpzYSudzU9rEkH8WuCAEvt2ZecTZT4GGL8bPSzhf0CvD DqyG/CwU+wNvMigi/FAmsK9Peggl+aQy0gecNAEAX X-Received: by 2002:a0c:efcf:: with SMTP id a15mr251650qvt.108.1592276334337; Mon, 15 Jun 2020 19:58:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSH4lrjXoz9PwBx3/VPHVd9EwJlnbQfaZdUffBvHMkJ7ScsjxIDmyo1K3o/MVBw/nK9t1sKg== X-Received: by 2002:a0c:efcf:: with SMTP id a15mr251627qvt.108.1592276333990; Mon, 15 Jun 2020 19:58:53 -0700 (PDT) Received: from gallifrey.lan ([2804:14c:4e6:18:74d9:26:da92:f043]) by smtp.gmail.com with ESMTPSA id i14sm12397109qkl.105.2020.06.15.19.58.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 19:58:53 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [bionic:linux-azure-4.15][PATCH 4/9] x86/Hyper-V: Unload vmbus channel in hv panic callback Date: Mon, 15 Jun 2020 23:58:37 -0300 Message-Id: <20200616025842.102415-5-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200616025842.102415-1-marcelo.cerri@canonical.com> References: <20200616025842.102415-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Tianyu Lan BugLink: http://bugs.launchpad.net/bugs/1875456 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 (backported from commit 74347a99e73ae00b8385f1209aaea193c670f901) [mc: fixed context and skipped vmbus_bus_suspend()] Signed-off-by: Marcelo Henrique Cerri --- 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 06a6a01c0b31..d7ccd62848c8 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -844,6 +844,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 678576db5273..15a6d43234c5 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; } @@ -1210,10 +1213,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; @@ -1840,7 +1849,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); @@ -1855,7 +1863,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(); };