Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1309308pxu; Mon, 23 Nov 2020 17:59:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJyklasdpIzddfxax6PMxceEHlEbVc0P0ln9Ctnz+wrJcmvIPW8bnG7yNTMm3F3sPyVv8r5B X-Received: by 2002:a17:906:304c:: with SMTP id d12mr2176308ejd.84.1606183160795; Mon, 23 Nov 2020 17:59:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606183160; cv=none; d=google.com; s=arc-20160816; b=zh7zqupANiUQaWqL4u9klQFkE8wS1DdOchDmj00AomEZx+JbM1K5xu94STNh79rzB+ EOQTSGXz2AV5PBNaqpmNBh6dH+Aljz87PevJHG6/oSPNWx80/4/R7MeMoeUlBU3aeiDv O6q/sY/5PGPIynsysVaApgGhYoWuRzsOlSG6EnYMqDSPDcZL6D3IPefOhv1DvzMu44j5 SjV+9NUEMhl2NJyfhWnGTor+hl/qgoXgSPzgDFBdQetVuCrytAqssviPu2FPdA4s+D2G HQdPYLOolUFOeTjH9tuoLpEO3L/ZXQQzxGr/amXrcueIW0g3qM0scM/WSJWY3AKR0DvX 2Z4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ndeOTawCS38OvfAPBo98N71bRiZEcuqHco80XxmkAV4=; b=QMB2ZnFNeTXENh1aTEPj+Hr1R1/Ema0Ieo/OUOkG0aFQjquNoFb1smvHdQoe4TaX1a EK96tBN1Jvqrgmp/1ddgRWkkXgkYJuwkthPfrsL7NRdTN2XzSMPpMPtNE0yt5U9/97YT /51HiJismgPfyWVZsf+NIjWtK8hOSrttOqN6s/ghwpQO4d71/wx7KQI9y8/MbYRC5qYy FWtkN9kRIFQ8iprHv2jobq4D+dY/gxeiGRxFbKJ/tXUZgYYiDizvaapovX1dfSelcr/P V97AdtBAhRUi9YmRJX4Xf8cHjV6OjcHja3W4iic4dDw9Alc3ksVGSjlANuyftvJXBDsG 50IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xDAJLKaA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gb20si1817278ejc.685.2020.11.23.17.58.57; Mon, 23 Nov 2020 17:59:20 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=xDAJLKaA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732460AbgKWMkX (ORCPT + 99 others); Mon, 23 Nov 2020 07:40:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:53086 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732443AbgKWMkV (ORCPT ); Mon, 23 Nov 2020 07:40:21 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 73A5820732; Mon, 23 Nov 2020 12:40:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606135220; bh=ragVKkuKwArePznIzij19t/oV3to1Njynt3ssOVGQvE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xDAJLKaA6doXSEredBRJcVvw6V8bC8K7LL1xsTyPubXUUi3/sICGzfx5uym+jgktH jdD9lu1ad/qH/DeYv+zzujxkT5VvJrWiwSFxZgw8GpBXbEAtQb+RT6i8PoSpXQuoQL CuctAbLsalZRtu5TsRbMKoRCLOaGVfDPuT9Bjlkw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Co , "Andrea Parri (Microsoft)" , Wei Liu Subject: [PATCH 5.4 148/158] Drivers: hv: vmbus: Allow cleanup of VMBUS_CONNECT_CPU if disconnected Date: Mon, 23 Nov 2020 13:22:56 +0100 Message-Id: <20201123121827.071521109@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121819.943135899@linuxfoundation.org> References: <20201123121819.943135899@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chris Co commit 92e4dc8b05663d6539b1b8375f3b1cf7b204cfe9 upstream. When invoking kexec() on a Linux guest running on a Hyper-V host, the kernel panics. RIP: 0010:cpuhp_issue_call+0x137/0x140 Call Trace: __cpuhp_remove_state_cpuslocked+0x99/0x100 __cpuhp_remove_state+0x1c/0x30 hv_kexec_handler+0x23/0x30 [hv_vmbus] hv_machine_shutdown+0x1e/0x30 machine_shutdown+0x10/0x20 kernel_kexec+0x6d/0x96 __do_sys_reboot+0x1ef/0x230 __x64_sys_reboot+0x1d/0x20 do_syscall_64+0x6b/0x3d8 entry_SYSCALL_64_after_hwframe+0x44/0xa9 This was due to hv_synic_cleanup() callback returning -EBUSY to cpuhp_issue_call() when tearing down the VMBUS_CONNECT_CPU, even if the vmbus_connection.conn_state = DISCONNECTED. hv_synic_cleanup() should succeed in the case where vmbus_connection.conn_state is DISCONNECTED. Fix is to add an extra condition to test for vmbus_connection.conn_state == CONNECTED on the VMBUS_CONNECT_CPU and only return early if true. This way the kexec() path can still shut everything down while preserving the initial behavior of preventing CPU offlining on the VMBUS_CONNECT_CPU while the VM is running. Fixes: 8a857c55420f29 ("Drivers: hv: vmbus: Always handle the VMBus messages on CPU0") Signed-off-by: Chris Co Reviewed-by: Andrea Parri (Microsoft) Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20201110190118.15596-1-chrco@linux.microsoft.com Signed-off-by: Wei Liu Signed-off-by: Greg Kroah-Hartman --- drivers/hv/hv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -251,9 +251,13 @@ int hv_synic_cleanup(unsigned int cpu) /* * Hyper-V does not provide a way to change the connect CPU once - * it is set; we must prevent the connect CPU from going offline. + * it is set; we must prevent the connect CPU from going offline + * while the VM is running normally. But in the panic or kexec() + * path where the vmbus is already disconnected, the CPU must be + * allowed to shut down. */ - if (cpu == VMBUS_CONNECT_CPU) + if (cpu == VMBUS_CONNECT_CPU && + vmbus_connection.conn_state == CONNECTED) return -EBUSY; /*