From patchwork Thu Nov 4 12:54:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1550893 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=n7CVqtL0; dkim-atps=neutral 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HlNsb1BB0z9sPf for ; Thu, 4 Nov 2021 23:55:29 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1micH0-0004OL-4C; Thu, 04 Nov 2021 12:55:18 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1micGy-0004Ni-EV for kernel-team@lists.ubuntu.com; Thu, 04 Nov 2021 12:55:16 +0000 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 3E7393F1F5 for ; Thu, 4 Nov 2021 12:55:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1636030516; bh=Rubgg3KkhRTKLGh43qvdMdTJOtRlXv1bNw1EoRqbTQ8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n7CVqtL0yQ3qqRN3EVUhgwcTLZZ1Mnt9Z+LMi1P+HEhUocsuOJFomzakXLt/wX7Bo 36MNQ9TF2+5bBr8UH50yW2oqAxIzWfTVsSXa43oaZofSUgCkCtXyge0shIoQ197aHu S7JlfgZrghUjXUGu/wD/lQySmarXhy9wo+csY4hSTjFAF/BlLhbZy7CgfDHAUBk87u LpxJUOtdMNprNzIHpB/krhb6muYuAF3iue6LAOwTo4F3eEODkUNynUAew42OzwNNI/ mWu877SMjJbzZJbcVhWQssUlaP+oLsptiXr36yxb2OjSPaVBL1MKuqApbDqadB63Zg XMY6RayuU4WVw== Received: by mail-pg1-f199.google.com with SMTP id v63-20020a632f42000000b002cc65837088so3693143pgv.1 for ; Thu, 04 Nov 2021 05:55:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rubgg3KkhRTKLGh43qvdMdTJOtRlXv1bNw1EoRqbTQ8=; b=y5hVP6TZ6yBbyyAUf/qsGMfx6ZU+Vqwip6JVooBJaAUycS655ckWUktSwhQ9uLPdrw md0O6F1ClD8s3D5seV7/M+g52Q9lKjVDfLybd8G49wOlWNTICnib4gZQWn3fzz8KhStx UCskAQfcYuufV0FEJu0v33RRve8ynOw+LAdyRxYeslWxSo4Hsv/Tp+3BfBR8tAGuCVAt semM9uSv1fAq9w22YY1YK2x760rbclVrW5UvqQPYDXe5bp0GzLmyZRkHGxLxaKazMH9v NBPxWGjnIxnnDKJhoad/U08SCnEImGKgPzrkabylKaB9n/LFsZwg6y85HhuYV36IIqYu /W7w== X-Gm-Message-State: AOAM531u4PFnF8hIdyZdjNK728ppTE8NXK4KZrahpkk1/28kOnJXD6ND LrtHzFGRsi6ktrCY/eI59XSxotvXurXceqBP8B9y1ES8tK5qEhU3shoc75rR9fNPATotixkJjM6 5BVtzAOhEf18+dRhz5Xe6Qt8qMmBA48pCtnWUtynqdA== X-Received: by 2002:a63:6a49:: with SMTP id f70mr30302753pgc.358.1636030514473; Thu, 04 Nov 2021 05:55:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyt61grUNgdklwZ4JfcUbvYgblbCCEobHWvo8RdJb0d6FEfvBvdc1zHhrX3k+v1bC/YpJ08vw== X-Received: by 2002:a63:6a49:: with SMTP id f70mr30302731pgc.358.1636030514137; Thu, 04 Nov 2021 05:55:14 -0700 (PDT) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id y4sm5283859pfi.178.2021.11.04.05.55.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Nov 2021 05:55:13 -0700 (PDT) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 04/41] Drivers: hv: vmbus: Move hyperv_report_panic_msg to arch neutral code Date: Thu, 4 Nov 2021 06:54:12 -0600 Message-Id: <20211104125449.16540-5-tim.gardner@canonical.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211104125449.16540-1-tim.gardner@canonical.com> References: <20211104125449.16540-1-tim.gardner@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: Michael Kelley BugLink: https://bugs.launchpad.net/bugs/1949770 With the new Hyper-V MSR set function, hyperv_report_panic_msg() can be architecture neutral, so move it out from under arch/x86 and merge into hv_kmsg_dump(). This move also avoids needing a separate implementation under arch/arm64. No functional change. Signed-off-by: Michael Kelley Reviewed-by: Boqun Feng Link: https://lore.kernel.org/r/1614721102-2241-5-git-send-email-mikelley@microsoft.com Signed-off-by: Wei Liu (cherry picked from commit b548a7742791e7818bc2780b2354b9714fd8f8d9) Signed-off-by: Marcelo Henrique Cerri --- arch/x86/hyperv/hv_init.c | 27 --------------------------- drivers/hv/vmbus_drv.c | 24 +++++++++++++++++++----- include/asm-generic/mshyperv.h | 1 - 3 files changed, 19 insertions(+), 33 deletions(-) diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c index 6b65e21a0a24..e145a215e5b1 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -487,33 +487,6 @@ void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die) } 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/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 18b7403999a8..7f61d7b779f3 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -1365,22 +1365,36 @@ 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. */ kmsg_dump_get_buffer(dumper, false, hv_panic_page, HV_HYP_PAGE_SIZE, &bytes_written); - if (bytes_written) - hyperv_report_panic_msg(panic_pa, bytes_written); + if (!bytes_written) + return; + /* + * 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. + */ + hv_set_register(HV_REGISTER_CRASH_P0, 0); + hv_set_register(HV_REGISTER_CRASH_P1, 0); + hv_set_register(HV_REGISTER_CRASH_P2, 0); + hv_set_register(HV_REGISTER_CRASH_P3, virt_to_phys(hv_panic_page)); + hv_set_register(HV_REGISTER_CRASH_P4, bytes_written); + + /* + * Let Hyper-V know there is crash data available along with + * the panic message. + */ + hv_set_register(HV_REGISTER_CRASH_CTL, + (HV_CRASH_CTL_CRASH_NOTIFY | HV_CRASH_CTL_CRASH_NOTIFY_MSG)); } static struct kmsg_dumper hv_kmsg_dumper = { diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h index 10c97a9e4027..6a8072f5845d 100644 --- a/include/asm-generic/mshyperv.h +++ b/include/asm-generic/mshyperv.h @@ -170,7 +170,6 @@ static inline int cpumask_to_vpset(struct hv_vpset *vpset, } 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); bool hv_is_hibernation_supported(void); void hyperv_cleanup(void);