Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1027696yba; Thu, 4 Apr 2019 02:45:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyqssPxxLOAvztMRHimn6nZLy5XGliL6R9hvw6TYsMTZshESpDMAYw07j38u3hlYdLKwrdK X-Received: by 2002:a17:902:868e:: with SMTP id g14mr5348571plo.183.1554371142837; Thu, 04 Apr 2019 02:45:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554371142; cv=none; d=google.com; s=arc-20160816; b=ZnpISNfVeGrJoW/6lM5t4eXNj9fanrapfZ/ELn2fgoQ4vhoeANwnZ5Ge86bFobYI1c Y2bcL5HGl19nE3jn+pZtMzOBG00tMeBEdjHdu42jkJ/L8G+l9eLIbCsLsLMlIJnW7pTu v4BEvRbPuOSBQKqS2gkOINsHwidiZKZCI7saxLHrkqKKiXgdCxl8dOfQPoQcLP5QdMTu Kf5Jo+Jr8Q/pPqbYSz9TTmtcDV2CCNAVohikyPzdhL0eKcOBb0TiDMo8Q7oQns9orNi9 iN+81lPTRn7jsvxApIBkl9TtV0s6P8AivDpAtaWlTB/b+i70rNEjxI3YJcpIvB+scr37 wLXg== 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=nJW7Lra0MRB5nqGjxkuhCvBis9ah7PtWb7u4vFENH1w=; b=GJRMZygg/UxdMm23YrYVhMnbA2bZme14fgYAbVCtn2S+6OkuExZVlrHM8Yqxpb4UKc iJ69gERj3C7dn+U9ycJLu3QRuJvsy+Ha7XOY8QssJlQf95WFNgy6qgao43KPKuKosf0p dxsPmgvf9u4maqZwNK3f7hM9UOMvltq6cNT5hfm4OtQENnijDyNB6vszPOX+1yQ17KdX db8GWS0lWLUCEgdQHW3bBA0ZTWIPeimA2lLx3yzZX27N12x3A17j8p+0KnRrA5NYVMWn VVWR2+lf4oL4FEHMKlxTCWZRVN/rMpRBMoqpoysXgV5AVLoBmwJj6sZwBQIWhaGUq3zU OG2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mVeyGD6l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z4si15361754plk.385.2019.04.04.02.45.27; Thu, 04 Apr 2019 02:45:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mVeyGD6l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729084AbfDDJAb (ORCPT + 99 others); Thu, 4 Apr 2019 05:00:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:37218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731253AbfDDJA3 (ORCPT ); Thu, 4 Apr 2019 05:00:29 -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 51F0421850; Thu, 4 Apr 2019 09:00:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368428; bh=xLa0Tf2HpubeDV/SMX++6z5Q7lZ/pYU5OpIqWG09uRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mVeyGD6lmZVWQ+4e0hrHb+5ap1Wxqa5HoYgx7wNyh36zp+ITvWhYakfCFYbOmkeXS cWY0RY/ejtIxGgL6WerjA/WkFIavpupCRWu7mLTyLkPs/uMz643iTgeG0tH5qctls6 BjL27120r7RPnMtfu+b+8NUyQB0wRnGpKfJ0l6uQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kairui Song , Thomas Gleixner , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Sasha Levin , Borislav Petkov , "H. Peter Anvin" , Vitaly Kuznetsov , Dave Young , devel@linuxdriverproject.org Subject: [PATCH 4.19 021/187] x86/hyperv: Fix kernel panic when kexec on HyperV Date: Thu, 4 Apr 2019 10:45:58 +0200 Message-Id: <20190404084604.080761493@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 179fb36abb097976997f50733d5b122a29158cba ] After commit 68bb7bfb7985 ("X86/Hyper-V: Enable IPI enlightenments"), kexec fails with a kernel panic: kexec_core: Starting new kernel BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 Hardware name: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS Hyper-V UEFI Release v3.0 03/02/2018 RIP: 0010:0xffffc9000001d000 Call Trace: ? __send_ipi_mask+0x1c6/0x2d0 ? hv_send_ipi_mask_allbutself+0x6d/0xb0 ? mp_save_irq+0x70/0x70 ? __ioapic_read_entry+0x32/0x50 ? ioapic_read_entry+0x39/0x50 ? clear_IO_APIC_pin+0xb8/0x110 ? native_stop_other_cpus+0x6e/0x170 ? native_machine_shutdown+0x22/0x40 ? kernel_kexec+0x136/0x156 That happens if hypercall based IPIs are used because the hypercall page is reset very early upon kexec reboot, but kexec sends IPIs to stop CPUs, which invokes the hypercall and dereferences the unusable page. To fix his, reset hv_hypercall_pg to NULL before the page is reset to avoid any misuse, IPI sending will fall back to the non hypercall based method. This only happens on kexec / kdump so just setting the pointer to NULL is good enough. Fixes: 68bb7bfb7985 ("X86/Hyper-V: Enable IPI enlightenments") Signed-off-by: Kairui Song Signed-off-by: Thomas Gleixner Cc: "K. Y. Srinivasan" Cc: Haiyang Zhang Cc: Stephen Hemminger Cc: Sasha Levin Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: Vitaly Kuznetsov Cc: Dave Young Cc: devel@linuxdriverproject.org Link: https://lkml.kernel.org/r/20190306111827.14131-1-kasong@redhat.com Signed-off-by: Sasha Levin --- arch/x86/hyperv/hv_init.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c index 20c876c7c5bf..87abd5145cc9 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -387,6 +387,13 @@ void hyperv_cleanup(void) /* Reset our OS id */ wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0); + /* + * Reset hypercall page reference before reset the page, + * let hypercall operations fail safely rather than + * panic the kernel for using invalid hypercall page + */ + hv_hypercall_pg = NULL; + /* Reset the hypercall page */ hypercall_msr.as_uint64 = 0; wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64); -- 2.19.1