Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4480160ybx; Mon, 4 Nov 2019 14:07:47 -0800 (PST) X-Google-Smtp-Source: APXvYqwRmhUXs78K2Cz9NkAEG81KnK7sjweD6vtvmcNExKwcs3RMufsYkQnzfFkdVkiYWJYK5t8o X-Received: by 2002:a50:c30d:: with SMTP id a13mr28935731edb.177.1572905267666; Mon, 04 Nov 2019 14:07:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572905267; cv=none; d=google.com; s=arc-20160816; b=eDNeUF96lWxNhK33o1y2LVNRZjwc3GKWgCAWzd37NXcwZU6I73uy94VS6693wjLkYD iZKQ7Oib+YXRmBV9q9oF/tqyE3SwA2QxpN/WmNO+ANSY22rUGVHMG1pXIG78W6ru7mv7 +YXUdGMDr2wuU+irPfMnyIUhOBUjZ5bmBg8t8hzLWa/mwvZdB6xyqGim7KkYHL8yoy3h FeGlFnUtA90sIbTQT3yGMx0sQxkND2DWUEGJw8r4aJHp7O0LZ5bsbr0tLSWZuRYGiIgU Dpj0zPSWzBOx/ALnVWwV02S0gqwD8OQUF9B/g2TX6xAhGTWEfuz+VmVeg5fkEep4pFfY hxHQ== 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=mGGppzQKX1aCcT9TLMbFh5XHwyNAnzexVLfaCembbXE=; b=I2imZ2ZlLlzEq0a+LmY2cQ6l9zj/yf5KaEf88LQBnLUjoRctXUUlEz1/e1mJFVWJDo l7/Q3NhqG0FKkWcK9mObGvk0LdP+0dc0XbmgghZCASmdIgHzDzPFvIu0Kt81LEjLqZSy HLycTXIq/X0fAGLu/9OiCi58q+B+KVLe8PyCz4i2sDYxD4D0UtUQqEUMcH5r22h+ywJ9 ZeLTsCBWba7mQzZULWilSfuve8gEMl9EpHK2ht/+84oQgljwLetVJ6hd9cXDUOXb9YX7 3fcsyNozjlx4b9r3guNsy4zGg/4K+kt/lq2wyBd+xCU2MRGBqQUT2NsXmB4npc/WvCJ3 TNaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yGqmuEwN; 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 b18si7435079eda.307.2019.11.04.14.07.17; Mon, 04 Nov 2019 14:07:47 -0800 (PST) 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=yGqmuEwN; 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 S2389274AbfKDWGY (ORCPT + 99 others); Mon, 4 Nov 2019 17:06:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:38164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389932AbfKDWGW (ORCPT ); Mon, 4 Nov 2019 17:06:22 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (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 B30E720650; Mon, 4 Nov 2019 22:06:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572905181; bh=QhHN1i/apWtfsJxZ56V2XWINw49Kv7/OXH9TlRgBoH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yGqmuEwNgA7ycpxESvUgH528/wv7aWhJhZfvESFyjqgwvI4NmhgaeWYbgI4SUgP/b goNoefgSxSN8wD2LApo9tygZeCQcYJCyh5zOL4T1wOD8OXN+DA+J72McezK8v0bQgA xFh9ypR7myMavomUdr+gtRf2nXi3LYU6sXV50FRU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Dingwall , Boris Ostrovsky , Juergen Gross , Sasha Levin Subject: [PATCH 5.3 057/163] x86/xen: Return from panic notifier Date: Mon, 4 Nov 2019 22:44:07 +0100 Message-Id: <20191104212144.235807229@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212140.046021995@linuxfoundation.org> References: <20191104212140.046021995@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: Boris Ostrovsky [ Upstream commit c6875f3aacf2a5a913205accddabf0bfb75cac76 ] Currently execution of panic() continues until Xen's panic notifier (xen_panic_event()) is called at which point we make a hypercall that never returns. This means that any notifier that is supposed to be called later as well as significant part of panic() code (such as pstore writes from kmsg_dump()) is never executed. There is no reason for xen_panic_event() to be this last point in execution since panic()'s emergency_restart() will call into xen_emergency_restart() from where we can perform our hypercall. Nevertheless, we will provide xen_legacy_crash boot option that will preserve original behavior during crash. This option could be used, for example, if running kernel dumper (which happens after panic notifiers) is undesirable. Reported-by: James Dingwall Signed-off-by: Boris Ostrovsky Reviewed-by: Juergen Gross Signed-off-by: Sasha Levin --- .../admin-guide/kernel-parameters.txt | 4 +++ arch/x86/xen/enlighten.c | 28 +++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 4c1971960afa3..5ea005c9e2d60 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5267,6 +5267,10 @@ the unplug protocol never -- do not unplug even if version check succeeds + xen_legacy_crash [X86,XEN] + Crash from Xen panic notifier, without executing late + panic() code such as dumping handler. + xen_nopvspin [X86,XEN] Disables the ticketlock slowpath using Xen PV optimizations. diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 750f46ad018a0..205b1176084f5 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -269,19 +269,41 @@ void xen_reboot(int reason) BUG(); } +static int reboot_reason = SHUTDOWN_reboot; +static bool xen_legacy_crash; void xen_emergency_restart(void) { - xen_reboot(SHUTDOWN_reboot); + xen_reboot(reboot_reason); } static int xen_panic_event(struct notifier_block *this, unsigned long event, void *ptr) { - if (!kexec_crash_loaded()) - xen_reboot(SHUTDOWN_crash); + if (!kexec_crash_loaded()) { + if (xen_legacy_crash) + xen_reboot(SHUTDOWN_crash); + + reboot_reason = SHUTDOWN_crash; + + /* + * If panic_timeout==0 then we are supposed to wait forever. + * However, to preserve original dom0 behavior we have to drop + * into hypervisor. (domU behavior is controlled by its + * config file) + */ + if (panic_timeout == 0) + panic_timeout = -1; + } return NOTIFY_DONE; } +static int __init parse_xen_legacy_crash(char *arg) +{ + xen_legacy_crash = true; + return 0; +} +early_param("xen_legacy_crash", parse_xen_legacy_crash); + static struct notifier_block xen_panic_block = { .notifier_call = xen_panic_event, .priority = INT_MIN -- 2.20.1