From patchwork Tue Jun 16 02:58:34 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: 1309937 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 49mCZq2Pw1z9sSt; Tue, 16 Jun 2020 12:58:57 +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 1jl1oK-0000VD-QI; Tue, 16 Jun 2020 02:58:52 +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 1jl1oI-0000Uw-G4 for kernel-team@lists.ubuntu.com; Tue, 16 Jun 2020 02:58:50 +0000 Received: from mail-qk1-f197.google.com ([209.85.222.197]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jl1oI-00063t-4e for kernel-team@lists.ubuntu.com; Tue, 16 Jun 2020 02:58:50 +0000 Received: by mail-qk1-f197.google.com with SMTP id i82so15764906qke.10 for ; Mon, 15 Jun 2020 19:58:50 -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=el3rRmfEl/tRigeqCNcCjvqiPiRxkw99Nt076KvE6g8=; b=kWcZzsZVW5DrhGk8/9mehY6LCLeyjXDstn+7vnp76zPBBXbZXvhaTCGEUBuQ0Z4xQw tKV2dUjen3R0lfgVzmPtkEI850XZcS3N36M+O+HPvs5e42fcn1+sWUwf1DxHDntmo9YD 0XTNJbLiqXTOJa5dKMXM80qIZTr6QmbtxS8dUVIkH4Ntuk131LHNn3xZ3lezdqeZvY9l EsdsorQAk/rIgO6nKmrCBB87Asw5/Qs4exWgNLuZw4EKjOGzYHaJbca4rBE87Cyv9MnW wdRQn4OoOl4IW/3gXW8z6VZ1mkR2kgDA8DD2X3twxjxhXrkK68Ou4tmHW6dO46ZsW/M6 7ZKg== X-Gm-Message-State: AOAM533JbJXHKXf2x9KAjLA2nGmAw63TzlUH0KEuLSmOg7Oj7AfvNj+c 43vYbjXKtNfwfaWslMUb5uso6P091uTpvk+QDTLcKOTqeVYEXRw4Ql/cTnKimNqfU7XuCjAz8PS rU5VM0Q+MMrCfeXO3kPMexH/uo/mza43FT1+GwLLc X-Received: by 2002:ac8:2979:: with SMTP id z54mr19325444qtz.262.1592276328675; Mon, 15 Jun 2020 19:58:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDap41V0MZImXyLnEF67SXkneP+7xQFQyCchN8cycryRjPWewEAy1XWAoX07VqGTpyjkm+fA== X-Received: by 2002:ac8:2979:: with SMTP id z54mr19325418qtz.262.1592276328237; Mon, 15 Jun 2020 19:58:48 -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.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 19:58:47 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [bionic:linux-azure-4.15][PATCH 1/9] Drivers: HV: Send one page worth of kmsg dump over Hyper-V during panic Date: Mon, 15 Jun 2020 23:58:34 -0300 Message-Id: <20200616025842.102415-2-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: Sunil Muthuswamy BugLink: http://bugs.launchpad.net/bugs/1875456 In the VM mode on Hyper-V, currently, when the kernel panics, an error code and few register values are populated in an MSR and the Hypervisor notified. This information is collected on the host. The amount of information currently collected is found to be limited and not very actionable. To gather more actionable data, such as stack trace, the proposal is to write one page worth of kmsg data on an allocated page and the Hypervisor notified of the page address through the MSR. - Sysctl option to control the behavior, with ON by default. Cc: K. Y. Srinivasan Cc: Stephen Hemminger Signed-off-by: Sunil Muthuswamy Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 81b18bce48af3e222ca9eebb3b931f59141b7b49) Signed-off-by: Marcelo Henrique Cerri --- Documentation/sysctl/kernel.txt | 11 +++ arch/x86/hyperv/hv_init.c | 27 +++++++ arch/x86/include/asm/hyperv-tlfs.h | 5 +- arch/x86/include/asm/mshyperv.h | 1 + drivers/hv/vmbus_drv.c | 110 +++++++++++++++++++++++++++++ 5 files changed, 152 insertions(+), 2 deletions(-) diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt index 694968c7523c..85d2d444f70c 100644 --- a/Documentation/sysctl/kernel.txt +++ b/Documentation/sysctl/kernel.txt @@ -38,6 +38,7 @@ show up in /proc/sys/kernel: - hung_task_check_count - hung_task_timeout_secs - hung_task_warnings +- hyperv_record_panic_msg - kexec_load_disabled - kptr_restrict - l2cr [ PPC only ] @@ -360,6 +361,16 @@ This file shows up if CONFIG_DETECT_HUNG_TASK is enabled. ============================================================== +hyperv_record_panic_msg: + +Controls whether the panic kmsg data should be reported to Hyper-V. + +0: do not report panic kmsg data. + +1: report the panic kmsg data. This is the default behavior. + +============================================================== + kexec_load_disabled: A toggle indicating if the kexec_load syscall has been disabled. This diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c index ce3bb175d739..9a5603196e3a 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -459,6 +459,33 @@ void hyperv_report_panic(struct pt_regs *regs, long err) } EXPORT_SYMBOL_GPL(hyperv_report_panic); +/** + * hyperv_report_panic_msg - report panic message to Hyper-V + * @pa: physical address of the panic page containing the message + * @size: size of the message in the page + */ +void hyperv_report_panic_msg(phys_addr_t pa, size_t size) +{ + /* + * P3 to contain the physical address of the panic page & P4 to + * contain the size of the panic data in that page. Rest of the + * registers are no-op when the NOTIFY_MSG flag is set. + */ + wrmsrl(HV_X64_MSR_CRASH_P0, 0); + wrmsrl(HV_X64_MSR_CRASH_P1, 0); + wrmsrl(HV_X64_MSR_CRASH_P2, 0); + wrmsrl(HV_X64_MSR_CRASH_P3, pa); + wrmsrl(HV_X64_MSR_CRASH_P4, size); + + /* + * Let Hyper-V know there is crash data available along with + * the panic message. + */ + wrmsrl(HV_X64_MSR_CRASH_CTL, + (HV_CRASH_CTL_CRASH_NOTIFY | HV_CRASH_CTL_CRASH_NOTIFY_MSG)); +} +EXPORT_SYMBOL_GPL(hyperv_report_panic_msg); + bool hv_is_hyperv_initialized(void) { union hv_x64_msr_hypercall_contents hypercall_msr; diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h index e1e0acb68a61..70cd4c4a0b06 100644 --- a/arch/x86/include/asm/hyperv-tlfs.h +++ b/arch/x86/include/asm/hyperv-tlfs.h @@ -172,9 +172,10 @@ #define HV_X64_ENLIGHTENED_VMCS_RECOMMENDED (1 << 14) /* - * Crash notification flag. + * Crash notification flags. */ -#define HV_CRASH_CTL_CRASH_NOTIFY (1ULL << 63) +#define HV_CRASH_CTL_CRASH_NOTIFY_MSG BIT_ULL(62) +#define HV_CRASH_CTL_CRASH_NOTIFY BIT_ULL(63) /* MSR used to identify the guest OS. */ #define HV_X64_MSR_GUEST_OS_ID 0x40000000 diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h index c3f94968ca06..283aed2d8dfb 100644 --- a/arch/x86/include/asm/mshyperv.h +++ b/arch/x86/include/asm/mshyperv.h @@ -285,6 +285,7 @@ void __init hyperv_init(void); void hyperv_setup_mmu_ops(void); void hyper_alloc_mmu(void); void hyperv_report_panic(struct pt_regs *regs, long err); +void hyperv_report_panic_msg(phys_addr_t pa, size_t size); bool hv_is_hyperv_initialized(void); void hyperv_cleanup(void); diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 6416ea2ad972..f7bf7281e3ea 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -56,6 +56,8 @@ static struct completion probe_event; static int hyperv_cpuhp_online; +static void *hv_panic_page; + static int hyperv_panic_event(struct notifier_block *nb, unsigned long val, void *args) { @@ -1068,6 +1070,75 @@ static void vmbus_isr(void) add_interrupt_randomness(HYPERVISOR_CALLBACK_VECTOR, 0); } +/* + * Boolean to control whether to report panic messages over Hyper-V. + * + * It can be set via /proc/sys/kernel/hyperv/record_panic_msg + */ +static int sysctl_record_panic_msg = 1; + +/* + * Callback from kmsg_dump. Grab as much as possible from the end of the kmsg + * buffer and call into Hyper-V to transfer the data. + */ +static void hv_kmsg_dump(struct kmsg_dumper *dumper, + enum kmsg_dump_reason reason) +{ + size_t bytes_written; + phys_addr_t panic_pa; + + /* We are only interested in panics. */ + if ((reason != KMSG_DUMP_PANIC) || (!sysctl_record_panic_msg)) + return; + + panic_pa = virt_to_phys(hv_panic_page); + + /* + * Write dump contents to the page. No need to synchronize; panic should + * be single-threaded. + */ + if (!kmsg_dump_get_buffer(dumper, true, hv_panic_page, + PAGE_SIZE, &bytes_written)) { + pr_err("Hyper-V: Unable to get kmsg data for panic\n"); + return; + } + + hyperv_report_panic_msg(panic_pa, bytes_written); +} + +static struct kmsg_dumper hv_kmsg_dumper = { + .dump = hv_kmsg_dump, +}; + +static struct ctl_table_header *hv_ctl_table_hdr; +static int zero; +static int one = 1; + +/* + * sysctl option to allow the user to control whether kmsg data should be + * reported to Hyper-V on panic. + */ +static struct ctl_table hv_ctl_table[] = { + { + .procname = "hyperv_record_panic_msg", + .data = &sysctl_record_panic_msg, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = &zero, + .extra2 = &one + }, + {} +}; + +static struct ctl_table hv_root_table[] = { + { + .procname = "kernel", + .mode = 0555, + .child = hv_ctl_table + }, + {} +}; /* * vmbus_bus_init -Main vmbus driver initialization routine. @@ -1115,6 +1186,32 @@ static int vmbus_bus_init(void) * Only register if the crash MSRs are available */ if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) { + u64 hyperv_crash_ctl; + /* + * Sysctl registration is not fatal, since by default + * reporting is enabled. + */ + hv_ctl_table_hdr = register_sysctl_table(hv_root_table); + if (!hv_ctl_table_hdr) + pr_err("Hyper-V: sysctl table register error"); + + /* + * Register for panic kmsg callback only if the right + * capability is supported by the hypervisor. + */ + rdmsrl(HV_X64_MSR_CRASH_CTL, hyperv_crash_ctl); + if (hyperv_crash_ctl & HV_CRASH_CTL_CRASH_NOTIFY_MSG) { + hv_panic_page = (void *)get_zeroed_page(GFP_KERNEL); + if (hv_panic_page) { + ret = kmsg_dump_register(&hv_kmsg_dumper); + if (ret) + pr_err("Hyper-V: kmsg dump register " + "error 0x%x\n", ret); + } else + pr_err("Hyper-V: panic message page memory " + "allocation failed"); + } + register_die_notifier(&hyperv_die_block); atomic_notifier_chain_register(&panic_notifier_list, &hyperv_panic_block); @@ -1131,6 +1228,11 @@ static int vmbus_bus_init(void) hv_remove_vmbus_irq(); bus_unregister(&hv_bus); + free_page((unsigned long)hv_panic_page); + if (!hv_ctl_table_hdr) { + unregister_sysctl_table(hv_ctl_table_hdr); + hv_ctl_table_hdr = NULL; + } return ret; } @@ -1821,10 +1923,18 @@ static void __exit vmbus_exit(void) vmbus_free_channels(); if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) { + kmsg_dump_unregister(&hv_kmsg_dumper); unregister_die_notifier(&hyperv_die_block); atomic_notifier_chain_unregister(&panic_notifier_list, &hyperv_panic_block); } + + free_page((unsigned long)hv_panic_page); + if (!hv_ctl_table_hdr) { + unregister_sysctl_table(hv_ctl_table_hdr); + hv_ctl_table_hdr = NULL; + } + bus_unregister(&hv_bus); cpuhp_remove_state(hyperv_cpuhp_online); From patchwork Tue Jun 16 02:58:35 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: 1309939 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 49mCZq5M5gz9sTD; Tue, 16 Jun 2020 12:58:59 +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 1jl1oN-0000W3-VB; Tue, 16 Jun 2020 02:58:55 +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 1jl1oK-0000V6-22 for kernel-team@lists.ubuntu.com; Tue, 16 Jun 2020 02:58:52 +0000 Received: from mail-qk1-f199.google.com ([209.85.222.199]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jl1oJ-000642-OJ for kernel-team@lists.ubuntu.com; Tue, 16 Jun 2020 02:58:51 +0000 Received: by mail-qk1-f199.google.com with SMTP id w14so15864236qkb.0 for ; Mon, 15 Jun 2020 19:58:51 -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=lI15V5+uhW5XTgKHLs6XTG2fQSXT2PdDf8uOqrYv/Lc=; b=O4T49E1TqygIJdzHc737VWXWHlxqL0KzUjuoS2JMpVRtrWYYWTJRDIk8cBHGshK2gf ZrsXdQbcieTocXa5VVzbzKPoNH2Yi1VocbjYiuOhOVXDWHO6QiChAjwvC8RjU89eNtF0 4sZcl40nlipz3r83RLdX/4isjku3+FO1RnUAqysX6Uu6bMnjrXRnVZm7b+HcdOEZpFgq ilyJwGippkz5paPReY/5tXaKklikitCeYZi9JKZMRHzDjjhlACmwpdPvgzZ2K73riu3B x8b9UVwArMNej+ocK4RiLU1zmdTkeCOeCrqJfjhm0cnw/IPdMKNsNCgUazdjxk9MQqWa sIJA== X-Gm-Message-State: AOAM533kcyoK0dfjDMj9YJt+YYYbCFSj7vjpxtUfqunKuL0JJ6NfOvQU ChkHPIy/46eJcb6qqfG/u2sOQqBjDtydv7bukUkflxe9WbJ8lWpEeIM7nfCmG96DTX25f0PU50t RuiYCEKa/0YEDs3y0/aIjdDhfx3+T3utbhwVtX24o X-Received: by 2002:ad4:528d:: with SMTP id v13mr258504qvr.90.1592276330490; Mon, 15 Jun 2020 19:58:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjvbRF+DnjQjgx2VcpHEwlH8Wc4Fn58YQIHMrE5FamKIY0IawGAXX/kUEhzo83SM+UL/zyWw== X-Received: by 2002:ad4:528d:: with SMTP id v13mr258484qvr.90.1592276330140; Mon, 15 Jun 2020 19:58:50 -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.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 19:58:49 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [bionic:linux-azure-4.15][PATCH 2/9] Drivers: hv: vmus: Fix the check for return value from kmsg get dump buffer Date: Mon, 15 Jun 2020 23:58:35 -0300 Message-Id: <20200616025842.102415-3-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: Sunil Muthuswamy BugLink: http://bugs.launchpad.net/bugs/1875456 The code to support panic control message was checking the return was checking the return value from kmsg_dump_get_buffer as error value, which is not what the routine returns. This fixes it. Fixes: 81b18bce48af ("Drivers: HV: Send one page worth of kmsg dump over Hyper-V during panic") Signed-off-by: Sunil Muthuswamy Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman (cherry picked from commit ddcaf3ca4c3c87b955ad6f57952250030be77791) Signed-off-by: Marcelo Henrique Cerri --- drivers/hv/vmbus_drv.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index f7bf7281e3ea..c83b5c253e30 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -1097,13 +1097,10 @@ static void hv_kmsg_dump(struct kmsg_dumper *dumper, * Write dump contents to the page. No need to synchronize; panic should * be single-threaded. */ - if (!kmsg_dump_get_buffer(dumper, true, hv_panic_page, - PAGE_SIZE, &bytes_written)) { - pr_err("Hyper-V: Unable to get kmsg data for panic\n"); - return; - } - - hyperv_report_panic_msg(panic_pa, bytes_written); + kmsg_dump_get_buffer(dumper, true, hv_panic_page, PAGE_SIZE, + &bytes_written); + if (bytes_written) + hyperv_report_panic_msg(panic_pa, bytes_written); } static struct kmsg_dumper hv_kmsg_dumper = { From patchwork Tue Jun 16 02:58:36 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: 1309940 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 49mCZr4y28z9sRN; Tue, 16 Jun 2020 12:59:00 +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 1jl1oO-0000WW-Gg; Tue, 16 Jun 2020 02:58:56 +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 1jl1oM-0000Vl-0C for kernel-team@lists.ubuntu.com; Tue, 16 Jun 2020 02:58:54 +0000 Received: from mail-qt1-f200.google.com ([209.85.160.200]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jl1oL-000647-Md for kernel-team@lists.ubuntu.com; Tue, 16 Jun 2020 02:58:53 +0000 Received: by mail-qt1-f200.google.com with SMTP id x6so15686483qts.3 for ; Mon, 15 Jun 2020 19:58:53 -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=xi1pLcSc1dHZyZwGCg2NQtxOSbkw/Y0oQoO/FmAJukI=; b=mQ50vDd8D1gUaL8J4yWqZBHo3ExZY/5xz90JWBC0GGXTwyK0kiEbmF1+8Y95QV4c5c 1UuLUYLrtzcQdo122WLGmPlEEuSF6eT+KBC5KJiJ729nTZUda8RDzgSxv0OctyZb/H6+ 5grA+x+gk9rr4rv/iBJsTHqcp0OUBvUMHlJN47dKMjAgauuCxMBcaUFsMw5/sxnGfDmS vI2OYJWT+ucBW+/9sI71ZUZ8odj/zOoPo5GqH/2BTGWb6l33KcMJYKHJd2wue90ES2ig RXqco4CYcstYuDfVWaNZsCrjxwNQfdMmcbdD4seB9gKNE82uWykrn4EzOvh+SAhRbbdv BZfA== X-Gm-Message-State: AOAM530pPcVHV1fgdB8gXm+iYg42Ddv1DqMT1OlBxWO3NTEffB5VX9ss DEdlmMGGUvV+zkTpsextfjEgpIixCrFJeR3rIU+awEOooXk2KKoMF8feFju3Mqy2Mlmcz/Q8UdQ EVYWCqjWBssN0yXvdZHbWJzn5zER2+Kgo7Goff1J3 X-Received: by 2002:aed:27c7:: with SMTP id m7mr19005479qtg.138.1592276332384; Mon, 15 Jun 2020 19:58:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHyev92648hxoiNHvmXSjotsexFjaoBc7kpkhgr4VzMn35za3nVlHyiFr0F3y03eJM3MixkQ== X-Received: by 2002:aed:27c7:: with SMTP id m7mr19005472qtg.138.1592276332107; Mon, 15 Jun 2020 19:58:52 -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.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 19:58:51 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [bionic:linux-azure-4.15][PATCH 3/9] Drivers: hv: vmbus: Fix the issue with freeing up hv_ctl_table_hdr Date: Mon, 15 Jun 2020 23:58:36 -0300 Message-Id: <20200616025842.102415-4-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: Sunil Muthuswamy BugLink: http://bugs.launchpad.net/bugs/1875456 The check to free the Hyper-V control table header was reversed. This fixes it. Fixes: 81b18bce48af ("Drivers: HV: Send one page worth of kmsg dump over Hyper-V during panic") Signed-off-by: Sunil Muthuswamy Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 8afc06dd75c06b9d6e70e4a72fdafbd4cab8d1df) Signed-off-by: Marcelo Henrique Cerri --- drivers/hv/vmbus_drv.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index c83b5c253e30..678576db5273 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -1226,11 +1226,8 @@ static int vmbus_bus_init(void) bus_unregister(&hv_bus); free_page((unsigned long)hv_panic_page); - if (!hv_ctl_table_hdr) { - unregister_sysctl_table(hv_ctl_table_hdr); - hv_ctl_table_hdr = NULL; - } - + unregister_sysctl_table(hv_ctl_table_hdr); + hv_ctl_table_hdr = NULL; return ret; } @@ -1927,11 +1924,8 @@ static void __exit vmbus_exit(void) } free_page((unsigned long)hv_panic_page); - if (!hv_ctl_table_hdr) { - unregister_sysctl_table(hv_ctl_table_hdr); - hv_ctl_table_hdr = NULL; - } - + unregister_sysctl_table(hv_ctl_table_hdr); + hv_ctl_table_hdr = NULL; bus_unregister(&hv_bus); cpuhp_remove_state(hyperv_cpuhp_online); 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(); }; From patchwork Tue Jun 16 02:58:38 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: 1309943 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 49mCb25KRdz9sSd; Tue, 16 Jun 2020 12:59:10 +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 1jl1oX-0000du-Of; Tue, 16 Jun 2020 02:59:05 +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 1jl1oP-0000XW-So for kernel-team@lists.ubuntu.com; Tue, 16 Jun 2020 02:58:57 +0000 Received: from mail-qk1-f197.google.com ([209.85.222.197]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jl1oP-00064I-II for kernel-team@lists.ubuntu.com; Tue, 16 Jun 2020 02:58:57 +0000 Received: by mail-qk1-f197.google.com with SMTP id x68so15852069qkd.1 for ; Mon, 15 Jun 2020 19:58:57 -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=zCLHQqr/77Hj38woIwh6lyM8ino4IigRN+uW8wtexB4=; b=sLJHyFbApIUMuqdJuvlXWKASpvXFjdZKNLd1hKXMgdx1gD0QkZXdHLvL6hpOWtsISb kMFyFAx6tZoOosVPoCqfv+QsuiGhu2bsbtsOlVVQWC4WYHPzyU8MMkM7FrfYq/zcTKa6 4lyAeimctKekbtv5wAJ2EjWCEoITwGboNUc61b0ifSFEKs3DalH4TZhAGlnILwdvuaX7 P/jFtHWmZIjlcNP21Fjiilp8lh2viG8fhskPzMnJCzqw0Bm94hK0TbgJDd91H2l8ONCj +Az/X7BRIpxvLxv8oBOODdheJXaOWz+kU5gNs4xdEhEesRSTrUudfTHW+Zwi0A3m9IwF bvWw== X-Gm-Message-State: AOAM533QF4vFZPDsq+84rRaPUYatORWS3xfPLCQy0QlzZiWDANiPRLNW q882GtVsgw0ohazsfKvEX+umci9O6uRyh7jos76PHZKjUwyGU1zvtz2JOqH/YEbux2JdWybvz+N oxpSQPQm4/dWpwYLAgjuA7zseoydCoVaeQ1rhvMBA X-Received: by 2002:ac8:440b:: with SMTP id j11mr18767008qtn.134.1592276336268; Mon, 15 Jun 2020 19:58:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2ov//UO0/tZll0+a2atzwuCEfm+Z4Kt+ISHalwxz9SRhlhXYRr+2bKVroYjMDMYgOy61x2g== X-Received: by 2002:ac8:440b:: with SMTP id j11mr18766997qtn.134.1592276335967; Mon, 15 Jun 2020 19:58:55 -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.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 19:58:55 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [bionic:linux-azure-4.15][PATCH 5/9] x86/Hyper-V: Free hv_panic_page when fail to register kmsg dump Date: Mon, 15 Jun 2020 23:58:38 -0300 Message-Id: <20200616025842.102415-6-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 If kmsg_dump_register() fails, hv_panic_page will not be used anywhere. So free and reset it. 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-3-Tianyu.Lan@microsoft.com Signed-off-by: Wei Liu (backported from commit 7f11a2cc10a4ae3a70e2c73361f4a9a33503539b) [mc: fixed context] Signed-off-by: Marcelo Henrique Cerri --- drivers/hv/vmbus_drv.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 15a6d43234c5..9b156b476669 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -1204,9 +1204,13 @@ static int vmbus_bus_init(void) hv_panic_page = (void *)get_zeroed_page(GFP_KERNEL); if (hv_panic_page) { ret = kmsg_dump_register(&hv_kmsg_dumper); - if (ret) + if (ret) { pr_err("Hyper-V: kmsg dump register " "error 0x%x\n", ret); + free_page( + (unsigned long)hv_panic_page); + hv_panic_page = NULL; + } } else pr_err("Hyper-V: panic message page memory " "allocation failed"); @@ -1234,7 +1238,6 @@ static int vmbus_bus_init(void) hv_remove_vmbus_irq(); bus_unregister(&hv_bus); - free_page((unsigned long)hv_panic_page); unregister_sysctl_table(hv_ctl_table_hdr); hv_ctl_table_hdr = NULL; return ret; From patchwork Tue Jun 16 02:58:39 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: 1309944 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 49mCb40FRPz9sRN; Tue, 16 Jun 2020 12:59:12 +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 1jl1oZ-0000eb-79; Tue, 16 Jun 2020 02:59:07 +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 1jl1oS-0000YS-2m for kernel-team@lists.ubuntu.com; Tue, 16 Jun 2020 02:59:00 +0000 Received: from mail-qv1-f72.google.com ([209.85.219.72]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jl1oR-00064W-IS for kernel-team@lists.ubuntu.com; Tue, 16 Jun 2020 02:58:59 +0000 Received: by mail-qv1-f72.google.com with SMTP id j4so14542771qvt.20 for ; Mon, 15 Jun 2020 19:58:59 -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=A0ajI3yAdDh762Z0zy1lblc6jfnsqx10GszFdsCW60Q=; b=Uy4rQ0DmWlTpr9ZkrIWwLvbUUb97s0PPyuAo/QXnJmpdfNPzk83RmWBqq0I4D1t1SV K8PPKUxTWMWTaeYeju8T5ecO3mDDtP9SL3T9W263TYUgz2ilFuqrGOyYe0afxjFJ1h5r 7RY7dJftKC9KnCck8xHQAdV+4fgeCC+o8q/sQElcfn2wRI7wkYsx42ZE4PTpFLzAciWg EjkEjGZnX9sQbO7RQVCqWh0R36MvKQmTdM+sH6L3O3oGWmnaty3pXnlrHsfi+oK//Lc3 SDQSJSHmEeqOMltpzIaOKPvphvjfKX7nGggoMmFTFDxxybcC8wZxayWZ6Z/rsITOZ2D/ X7rg== X-Gm-Message-State: AOAM532EyMCgvgN6PzwdCtW3Tc+bCkXAC/67fYNQtw+9O7CGimml1SH5 20sgefgm5PY0ZFLoz2QRScuzdOVBNWqeMt5XMFqMGWhuQfZKA5UxkEwQShgeo6utJ/FNQ8vT/vm eUkGrCEnvzSe7tQ8WxvpF4iuffekIKiX71fP0+tZB X-Received: by 2002:ac8:35d9:: with SMTP id l25mr19501231qtb.374.1592276338237; Mon, 15 Jun 2020 19:58:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmyIS4Xrt8CekxvQCwG3xzwrsuhYA/64ysfSZYFAjunz+gYZN7e0mGp2/IIX7l3a67dtTsNg== X-Received: by 2002:ac8:35d9:: with SMTP id l25mr19501214qtb.374.1592276337943; Mon, 15 Jun 2020 19:58:57 -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.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 19:58:57 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [bionic:linux-azure-4.15][PATCH 6/9] x86/Hyper-V: Trigger crash enlightenment only once during system crash. Date: Mon, 15 Jun 2020 23:58:39 -0300 Message-Id: <20200616025842.102415-7-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 a guest VM panics, Hyper-V should be notified only once via the crash synthetic MSRs. Current Linux code might write these crash MSRs twice during a system panic: 1) hyperv_panic/die_event() calling hyperv_report_panic() 2) hv_kmsg_dump() calling hyperv_report_panic_msg() Fix this by not calling hyperv_report_panic() if a kmsg dump has been successfully registered. The notification will happen later via hyperv_report_panic_msg(). Fixes: 7ed4325a44ea ("Drivers: hv: vmbus: Make panic reporting to be more useful") Reviewed-by: Michael Kelley Signed-off-by: Tianyu Lan Link: https://lore.kernel.org/r/20200406155331.2105-4-Tianyu.Lan@microsoft.com Signed-off-by: Wei Liu (cherry picked from commit 73f26e526f19afb3a06b76b970a76bcac2cafd05) Signed-off-by: Marcelo Henrique Cerri --- drivers/hv/vmbus_drv.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 9b156b476669..1bb303eca970 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -65,7 +65,13 @@ static int hyperv_panic_event(struct notifier_block *nb, unsigned long val, vmbus_initiate_unload(true); - if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) { + /* + * Hyper-V should be notified only once about a panic. If we will be + * doing hyperv_report_panic_msg() later with kmsg data, don't do + * the notification here. + */ + if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE + && !hv_panic_page) { regs = current_pt_regs(); hyperv_report_panic(regs, val); } @@ -78,7 +84,13 @@ static int hyperv_die_event(struct notifier_block *nb, unsigned long val, struct die_args *die = (struct die_args *)args; struct pt_regs *regs = die->regs; - hyperv_report_panic(regs, val); + /* + * Hyper-V should be notified only once about a panic. If we will be + * doing hyperv_report_panic_msg() later with kmsg data, don't do + * the notification here. + */ + if (!hv_panic_page) + hyperv_report_panic(regs, val); return NOTIFY_DONE; } From patchwork Tue Jun 16 02:58:40 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: 1309942 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 49mCZz6Q8Cz9sSc; Tue, 16 Jun 2020 12:59:07 +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 1jl1oW-0000cD-4s; Tue, 16 Jun 2020 02:59:04 +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 1jl1oU-0000b1-7k for kernel-team@lists.ubuntu.com; Tue, 16 Jun 2020 02:59:02 +0000 Received: from mail-qv1-f70.google.com ([209.85.219.70]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jl1oT-000659-TC for kernel-team@lists.ubuntu.com; Tue, 16 Jun 2020 02:59:02 +0000 Received: by mail-qv1-f70.google.com with SMTP id d5so14591398qvo.3 for ; Mon, 15 Jun 2020 19:59:01 -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=JOT/cqqZlr0ZkFChoRnWpy5YZIVTEYo0aTd1A+asnP0=; b=Jcx9CZR9PSDoejLF/p5uxwKeB+sgR8w/LTwwPei3UKNU4nuUFLNfQb8lBc3n5VZgGX PbXSen5QqZ8gjhl8jOciXXo1nSA4RUcHPTMzQcCSPHRoszRTYrnTbItp/4liRB+FEDYu P1iDB5HxCSqBWnm1kLrkHQDrrR3vvHiV3HJsaaVX77KtHGhH6vek8XsZWgQRU2DWeI5s CXvph9u3XBGVrqEBxEF+vJiB/zC/f4MUP6HkiJ0q3t8r8Ui7DbiKeagv0qUvGFnPUfvl OGPd20OZbvGp5EyDxBAmg56qCD1mMTtWvnFQKwulqQ/u2wrIVgrmU9+TVyEy6LjYwUuN tMqQ== X-Gm-Message-State: AOAM531AMt6XKZhlMGQmGqMjY1lY235LnSXPDeMqCTBowke3ug08h4LG JPpjMlmm7TjwQ/zzHO15IKb4HyJ5AhJpgmGxST+29f15y9CuLKI72j2Ju8Bt0ihGCLpK/CH9FZt 6AgVlv6vwzlaxBmzNfR8+I6+qStbxtUfIF2ERnyyc X-Received: by 2002:a37:65cf:: with SMTP id z198mr17483898qkb.133.1592276340279; Mon, 15 Jun 2020 19:59:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9rOGOq91El8zhxydT+o0/bHkOGw/5m2Ma99Q3UYFki12LzGZd5hYsOlF/MiGBdXvt/ef2nQ== X-Received: by 2002:a37:65cf:: with SMTP id z198mr17483887qkb.133.1592276339934; Mon, 15 Jun 2020 19:58:59 -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.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 19:58:59 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [bionic:linux-azure-4.15][PATCH 7/9] x86/Hyper-V: Report crash register data or kmsg before running crash kernel Date: Mon, 15 Jun 2020 23:58:40 -0300 Message-Id: <20200616025842.102415-8-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 We want to notify Hyper-V when a Linux guest VM crash occurs, so there is a record of the crash even when kdump is enabled. But crash_kexec_post_notifiers defaults to "false", so the kdump kernel runs before the notifiers and Hyper-V never gets notified. Fix this by always setting crash_kexec_post_notifiers to be true for Hyper-V VMs. 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-5-Tianyu.Lan@microsoft.com Signed-off-by: Wei Liu (backported from commit a11589563e96bf262767294b89b25a9d44e7303b) [mc: fixed context] Signed-off-by: Marcelo Henrique Cerri --- arch/x86/kernel/cpu/mshyperv.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index a06aeb529eda..7d602805bf0b 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -209,6 +209,16 @@ static void __init ms_hyperv_init_platform(void) x86_platform.calibrate_cpu = hv_get_tsc_khz; } + /* + * Hyper-V expects to get crash register data or kmsg when + * crash enlightment is available and system crashes. Set + * crash_kexec_post_notifiers to be true to make sure that + * calling crash enlightment interface before running kdump + * kernel. + */ + if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) + crash_kexec_post_notifiers = true; + #ifdef CONFIG_X86_LOCAL_APIC if (ms_hyperv.features & HV_X64_ACCESS_FREQUENCY_MSRS && ms_hyperv.misc_features & HV_FEATURE_FREQUENCY_MSRS_AVAILABLE) { From patchwork Tue Jun 16 02:58:41 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: 1309945 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 49mCb61nzyz9sRN; Tue, 16 Jun 2020 12:59:14 +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 1jl1ob-0000gQ-GJ; Tue, 16 Jun 2020 02:59:09 +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 1jl1oW-0000c5-1V for kernel-team@lists.ubuntu.com; Tue, 16 Jun 2020 02:59:04 +0000 Received: from mail-qt1-f197.google.com ([209.85.160.197]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jl1oV-00065R-Fa for kernel-team@lists.ubuntu.com; Tue, 16 Jun 2020 02:59:03 +0000 Received: by mail-qt1-f197.google.com with SMTP id u26so15580630qtj.21 for ; Mon, 15 Jun 2020 19:59:03 -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=SFHbZJUXyR8TKvok5lR3mWyxoPF61Ja4O0kgEgrRIVg=; b=aYYGETY3klhA2EWBb42LUEw96eATuENC02kkn5NU8z9H/6oDiK+Aeim7K3lRWLU1wy u7w0QlwSCpAWHAcS5TRiPFbauVfE1B8YI4wNnwKvs7QY9sQXw6ufTJJqFuySV/wsfV8J 8YNlVMZyhWO2BqAc6ZjkkIkO94IA9d69jN6UzP9m7Mw1lByN4qeLqW4w3PEbaLDRHVec KkqozBtdLqgc8n8MPafEyPSHDsuet5Rvhdw2U5MkIwMu9WT4wDEAdD2p2ha/DQKONtYv vDQSCdYt1KewxGKs64aIGkCFPOjUiFWt36vC2P6/FIcS6EyWq7NvajLb1ZeMDzX14zrC RVBg== X-Gm-Message-State: AOAM531tzGiHj2GfO/xZNbY/yd2YVt42pqswWIghcX9zf9hlDrBF2wx/ Cuft0BK9AydV1BzEeGrwpCis9xHXxpYuZYUuvdH5UHcD/qFZVSWGo4yN47h8YXNMo0A4GmmtNjS eAb7uF/WC85KF7uVKJz0j1BxHc6COZalwcBaVMuBa X-Received: by 2002:ac8:3267:: with SMTP id y36mr19722172qta.241.1592276342177; Mon, 15 Jun 2020 19:59:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpK78kqSiADNfIb4wOo1GWSMQAJrvLHnd6swyMRNfzPx9t/DR1zVqtxkI4mUyf5FvGcze4pA== X-Received: by 2002:ac8:3267:: with SMTP id y36mr19722162qta.241.1592276341885; Mon, 15 Jun 2020 19:59:01 -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.59.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 19:59:01 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [bionic:linux-azure-4.15][PATCH 8/9] x86/Hyper-V: Report crash register data when sysctl_record_panic_msg is not set Date: Mon, 15 Jun 2020 23:58:41 -0300 Message-Id: <20200616025842.102415-9-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 sysctl_record_panic_msg is not set, the panic will not be reported to Hyper-V via hyperv_report_panic_msg(). So the crash should be reported via hyperv_report_panic(). 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-6-Tianyu.Lan@microsoft.com Signed-off-by: Wei Liu (cherry picked from commit 040026df7088c56ccbad28f7042308f67bde63df) Signed-off-by: Marcelo Henrique Cerri --- drivers/hv/vmbus_drv.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 1bb303eca970..e1e93052e60d 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -58,6 +58,18 @@ static int hyperv_cpuhp_online; static void *hv_panic_page; +/* + * Boolean to control whether to report panic messages over Hyper-V. + * + * It can be set via /proc/sys/kernel/hyperv/record_panic_msg + */ +static int sysctl_record_panic_msg = 1; + +static int hyperv_report_reg(void) +{ + return !sysctl_record_panic_msg || !hv_panic_page; +} + static int hyperv_panic_event(struct notifier_block *nb, unsigned long val, void *args) { @@ -71,7 +83,7 @@ static int hyperv_panic_event(struct notifier_block *nb, unsigned long val, * the notification here. */ if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE - && !hv_panic_page) { + && hyperv_report_reg()) { regs = current_pt_regs(); hyperv_report_panic(regs, val); } @@ -89,7 +101,7 @@ static int hyperv_die_event(struct notifier_block *nb, unsigned long val, * doing hyperv_report_panic_msg() later with kmsg data, don't do * the notification here. */ - if (!hv_panic_page) + if (hyperv_report_reg()) hyperv_report_panic(regs, val); return NOTIFY_DONE; } @@ -1085,13 +1097,6 @@ static void vmbus_isr(void) add_interrupt_randomness(HYPERVISOR_CALLBACK_VECTOR, 0); } -/* - * Boolean to control whether to report panic messages over Hyper-V. - * - * It can be set via /proc/sys/kernel/hyperv/record_panic_msg - */ -static int sysctl_record_panic_msg = 1; - /* * Callback from kmsg_dump. Grab as much as possible from the end of the kmsg * buffer and call into Hyper-V to transfer the data. From patchwork Tue Jun 16 02:58:42 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: 1309946 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 49mCb7651Cz9sRN; Tue, 16 Jun 2020 12:59:15 +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 1jl1od-0000j6-8j; Tue, 16 Jun 2020 02:59:11 +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 1jl1oY-0000dz-Pd for kernel-team@lists.ubuntu.com; Tue, 16 Jun 2020 02:59:06 +0000 Received: from mail-qt1-f200.google.com ([209.85.160.200]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jl1oX-00065W-JG for kernel-team@lists.ubuntu.com; Tue, 16 Jun 2020 02:59:05 +0000 Received: by mail-qt1-f200.google.com with SMTP id p9so15681014qtn.5 for ; Mon, 15 Jun 2020 19:59:05 -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=NXTxqjHf7p6VtW1J/fAaqP63fbotBcxtDwyclt4L3xs=; b=HvE/sUDdeAbh5fOIwNwIx1SI2jlQPUIq2oLp9MBpnAnVkjfuY9UgIdf8wkMs+qvsQN Tsx1aVZ73F69V0E60YZOFuKZmFBqtRHTW6GYoRhcX0yC9DOCs0T1dtTJM5mzdvyDXtse FtceP+XnEnsbzm3nfIC4O9lgX0yyeN/iFgga5smtioTt4HbJzqcWprTIXtI4eVa/CvYj Kocz0uea9S8Piv72iQ1Za6VRvSjpi65Uf07dAVT4Q2sOEjma0PyQohWI0Etz+AL76zYj ep/iiAx1zZEGrAqisgU6RY2RLl4me/oH2cKyMFDUI+TUzzp1lttGVXV3CVC42mVSMRD/ HkAg== X-Gm-Message-State: AOAM531WOS2Ae8Hu/6qAAUtjUfgyMXqpfJ5RiIqiyps22NPh2HRMLCTh wW5Frdk/HcdBQ68HagoJMTL3Wmnv/5jr2QAFKXIU4UYzC2VwPleENWxXG9qU29RJ6SAJqJsRj+f FqOtuRAd8SUv3w04FG6Eltv4DKeaXrLFZzwCYDm+D X-Received: by 2002:ad4:56ac:: with SMTP id bd12mr228200qvb.139.1592276344236; Mon, 15 Jun 2020 19:59:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1LXToxO3YFcX1K6OVklz7J3gvBWDzlBuxNVcOANo4ZTOVmF4olXJ2EnnPeIy3smAzaQZbmw== X-Received: by 2002:ad4:56ac:: with SMTP id bd12mr228183qvb.139.1592276343886; Mon, 15 Jun 2020 19:59:03 -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.59.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 19:59:03 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [bionic:linux-azure-4.15][PATCH 9/9] x86/Hyper-V: Report crash data in die() when panic_on_oops is set Date: Mon, 15 Jun 2020 23:58:42 -0300 Message-Id: <20200616025842.102415-10-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 oops happens with panic_on_oops unset, the oops thread is killed by die() and system continues to run. In such case, guest should not report crash register data to host since system still runs. Check panic_on_oops and return directly in hyperv_report_panic() when the function is called in the die() and panic_on_oops is unset. Fix it. Fixes: 7ed4325a44ea ("Drivers: hv: vmbus: Make panic reporting to be more useful") Signed-off-by: Tianyu Lan Reviewed-by: Michael Kelley Link: https://lore.kernel.org/r/20200406155331.2105-7-Tianyu.Lan@microsoft.com Signed-off-by: Wei Liu (backported from commit f3a99e761efa616028b255b4de58e9b5b87c5545) [mc: small context adjustment and mshyperv.h on different location] Signed-off-by: Marcelo Henrique Cerri --- arch/x86/hyperv/hv_init.c | 6 +++++- arch/x86/include/asm/mshyperv.h | 2 +- drivers/hv/vmbus_drv.c | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c index 9a5603196e3a..965f3c9eb82d 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #ifndef PKG_ABI @@ -430,11 +431,14 @@ void hyperv_cleanup(void) } EXPORT_SYMBOL_GPL(hyperv_cleanup); -void hyperv_report_panic(struct pt_regs *regs, long err) +void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die) { static bool panic_reported; u64 guest_id; + if (in_die && !panic_on_oops) + return; + /* * We prefer to report panic on 'die' chain as we have proper * registers to report, but if we miss it (e.g. on BUG()) we need diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h index 283aed2d8dfb..1fbee89cd9ac 100644 --- a/arch/x86/include/asm/mshyperv.h +++ b/arch/x86/include/asm/mshyperv.h @@ -284,7 +284,7 @@ static inline int cpumask_to_vpset(struct hv_vpset *vpset, void __init hyperv_init(void); void hyperv_setup_mmu_ops(void); void hyper_alloc_mmu(void); -void hyperv_report_panic(struct pt_regs *regs, long err); +void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die); void hyperv_report_panic_msg(phys_addr_t pa, size_t size); bool hv_is_hyperv_initialized(void); void hyperv_cleanup(void); diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index e1e93052e60d..0f168f0b1a8f 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "hyperv_vmbus.h" struct vmbus_dynid { @@ -85,7 +86,7 @@ static int hyperv_panic_event(struct notifier_block *nb, unsigned long val, if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE && hyperv_report_reg()) { regs = current_pt_regs(); - hyperv_report_panic(regs, val); + hyperv_report_panic(regs, val, false); } return NOTIFY_DONE; } @@ -102,7 +103,7 @@ static int hyperv_die_event(struct notifier_block *nb, unsigned long val, * the notification here. */ if (hyperv_report_reg()) - hyperv_report_panic(regs, val); + hyperv_report_panic(regs, val, true); return NOTIFY_DONE; }