From: Petr Mladek <pmladek@suse.com>
To: Zack Rusin <zack.rusin@broadcom.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Baoquan He <baoquan.he@linux.dev>,
Mike Rapoport <rppt@kernel.org>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
Pratyush Yadav <pratyush@kernel.org>,
Dave Young <ruirui.yang@linux.dev>,
Borislav Petkov <bp@alien8.de>,
Ajay Kaher <ajay.kaher@broadcom.com>,
Alexey Makhalov <alexey.makhalov@broadcom.com>,
x86@kernel.org, Joel Granados <joel.granados@kernel.org>,
Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
virtualization@lists.linux.dev,
bcm-kernel-feedback-list@broadcom.com,
linux-kernel@vger.kernel.org,
John Ogness <john.ogness@linutronix.de>,
Steven Rostedt <rostedt@goodmis.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Kees Cook <kees@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
Bo Gan <bo.gan@broadcom.com>,
Brennan Lamoreaux <brennan.lamoreaux@broadcom.com>,
kexec@lists.infradead.org, linux-doc@vger.kernel.org,
"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
Maaz Mombasawala <maaz.mombasawala@broadcom.com>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
Stephen Brennan <stephen.s.brennan@oracle.com>,
Michael Kelley <mhklinux@outlook.com>,
Ian Forbes <ian.forbes@broadcom.com>,
Bradley Morgan <brads@mainlining.org>
Subject: Re: [PATCH v4 2/4] x86/vmware: Add a bounded panic log sender
Date: Fri, 20 Nov 2026 10:10:31 +0100 [thread overview]
Message-ID: <awAOhyq48jRfcVWd@pathway> (raw)
In-Reply-To: <7e985e2aea6507a0444addd816d4251f78d048f6.1794980455.git.zack.rusin@broadcom.com>
On Wed 2026-11-18 01:01:49, Zack Rusin wrote:
> A VMware guest may be unable to save its own logs after a crash. Copy
> the newest kernel log records to the host's vmware.log before kdump,
> so they remain available if the capture kernel fails.
>
> Register the sender on the platform panic notifier list and send the
> log through the low-bandwidth register interface. Allocate a fixed
> 8 KiB buffer during early init; 4 KiB can lose useful stack-trace
> context. The callback allocates no memory and emits no printk
> messages. Limit the transfer to the buffer size and make at most three
> attempts, retrying only if a VM checkpoint interrupts the transfer.
>
> Enable logging by default only in guests without memory encryption;
> encrypted guests should send their log to the host only when an
> administrator opts in. The copy is best-effort diagnostics; kdump does
> not depend on it succeeding.
>
> Suggested-by: Michael Kelley <mhklinux@outlook.com>
> Link: https://lore.kernel.org/r/SN6PR02MB41574A11D309A0530C63E0FED4842@SN6PR02MB4157.namprd02.prod.outlook.com
> Link: https://lore.kernel.org/r/20260309235250.2611115-3-alexey.makhalov@broadcom.com
> Co-developed-by: Bo Gan <bo.gan@broadcom.com>
> Signed-off-by: Bo Gan <bo.gan@broadcom.com>
> Co-developed-by: Alexey Makhalov <alexey.makhalov@broadcom.com>
> Signed-off-by: Alexey Makhalov <alexey.makhalov@broadcom.com>
> Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
I made just a quick review of the string manipulation and
kmsg_dump_get_buffer() API use. And it looks good to me:
Reviewed-by: Petr Mladek <pmladek@suse.com>
Note that I am not familiar with the vmware hypercalls so that
I did not check this part.
Some nits below.
> --- a/arch/x86/kernel/cpu/vmware.c
> +++ b/arch/x86/kernel/cpu/vmware.c
> @@ -52,6 +57,23 @@
> +#define VMWARE_LOG_BUF_SIZE SZ_8K
> +#define VMWARE_LOG_ATTEMPTS 3
> +#define VMWARE_LOG_PREFIX "log "
> +#define VMWARE_LOG_PREFIX_LEN (sizeof(VMWARE_LOG_PREFIX) - 1)
[...]
> +static int vmware_log_send_once(const struct vmware_rpc_channel *channel,
> + const char *buffer, size_t length)
> +{
> + u32 info;
> +
> + vmware_hypercall5(VMWARE_CMD_MESSAGE | VMWARE_MSG_SENDSIZE, length,
> + (u32)channel->id << 16, channel->cookie_high,
> + channel->cookie_low, &info);
> + if (!(info & VMWARE_MSG_STATUS_SUCCESS))
> + return info & VMWARE_MSG_STATUS_CPT ? -EAGAIN : -EIO;
> +
> + while (length) {
> + size_t bytes = min_t(size_t, length, sizeof(u32));
> + u32 word = 0;
> +
> + memcpy(&word, buffer, bytes);
> + vmware_hypercall5(VMWARE_CMD_MESSAGE | VMWARE_MSG_SENDPAYLOAD,
> + word, (u32)channel->id << 16,
> + channel->cookie_high, channel->cookie_low,
> + &info);
> + if (!(info & VMWARE_MSG_STATUS_SUCCESS))
> + return info & VMWARE_MSG_STATUS_CPT ? -EAGAIN : -EIO;
> +
> + buffer += bytes;
> + length -= bytes;
> + }
> +
> + return 0;
> +}
[...]
> +static int vmware_panic_log_notify(struct notifier_block *nb,
> + unsigned long action, void *data)
> +{
> + struct kmsg_dump_iter iter;
> + char *buffer = page_address(vmware_panic_page);
> + size_t length = 0;
I would add:
BUILD_BUG_ON(VMWARE_LOG_PREFIX_LEN > VMWARE_LOG_BUF_SIZE);
just to be on the safe side.
> +
> + if (!READ_ONCE(vmware_record_panic_msg))
> + return NOTIFY_DONE;
> +
> + memcpy(buffer, VMWARE_LOG_PREFIX, VMWARE_LOG_PREFIX_LEN);
I would feel more comfortable when the trailing '\0' gets copied as
well, e.g.
strscpy(buffer, VMWARE_LOG_PREFIX);
It is not strictly needed because the length is counted
explicitly, strlen() is not used. Also vmware_log_rpc() does
not send the trailing '\0'.
So, it is a rather a defensive programming. The buffer might be handled
another way in the future, e.g. printed by some debug code, tracing, ...
> + kmsg_dump_rewind(&iter);
> + (void)kmsg_dump_get_buffer(&iter, true,
> + buffer + VMWARE_LOG_PREFIX_LEN,
> + VMWARE_LOG_BUF_SIZE - VMWARE_LOG_PREFIX_LEN,
> + &length);
> + (void)vmware_log_rpc(buffer, length + VMWARE_LOG_PREFIX_LEN);
> +
> + return NOTIFY_DONE;
> +}
Best Regards,
Petr
WARNING: multiple messages have this Message-ID (diff)
From: Petr Mladek <pmladek@suse.com>
To: Zack Rusin <zack.rusin@broadcom.com>
Cc: linux-doc@vger.kernel.org, Kees Cook <kees@kernel.org>,
Dave Hansen <dave.hansen@linux.intel.com>,
Dave Young <ruirui.yang@linux.dev>,
Stephen Brennan <stephen.s.brennan@oracle.com>,
Bo Gan <bo.gan@broadcom.com>, "H. Peter Anvin" <hpa@zytor.com>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
Jonathan Corbet <corbet@lwn.net>,
Brennan Lamoreaux <brennan.lamoreaux@broadcom.com>,
x86@kernel.org, Joel Granados <joel.granados@kernel.org>,
Alexey Makhalov <alexey.makhalov@broadcom.com>,
Ingo Molnar <mingo@redhat.com>,
bcm-kernel-feedback-list@broadcom.com,
Ajay Kaher <ajay.kaher@broadcom.com>,
Bradley Morgan <brads@mainlining.org>,
Baoquan He <baoquan.he@linux.dev>,
John Ogness <john.ogness@linutronix.de>,
virtualization@lists.linux.dev,
Steven Rostedt <rostedt@goodmis.org>,
Maaz Mombasawala <maaz.mombasawala@broadcom.com>,
Borislav Petkov <bp@alien8.de>,
Shuah Khan <skhan@linuxfoundation.org>,
Michael Kelley <mhklinux@outlook.com>,
Pratyush Yadav <pratyush@kernel.org>,
Randy Dunlap <rdunlap@infradead.org>,
kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
Ian Forbes <ian.forbes@broadcom.com>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Thomas Gleixner <tglx@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Mike Rapoport <rppt@kernel.org>
Subject: Re: [PATCH v4 2/4] x86/vmware: Add a bounded panic log sender
Date: Fri, 20 Nov 2026 10:10:31 +0100 [thread overview]
Message-ID: <awAOhyq48jRfcVWd@pathway> (raw)
In-Reply-To: <7e985e2aea6507a0444addd816d4251f78d048f6.1794980455.git.zack.rusin@broadcom.com>
On Wed 2026-11-18 01:01:49, Zack Rusin wrote:
> A VMware guest may be unable to save its own logs after a crash. Copy
> the newest kernel log records to the host's vmware.log before kdump,
> so they remain available if the capture kernel fails.
>
> Register the sender on the platform panic notifier list and send the
> log through the low-bandwidth register interface. Allocate a fixed
> 8 KiB buffer during early init; 4 KiB can lose useful stack-trace
> context. The callback allocates no memory and emits no printk
> messages. Limit the transfer to the buffer size and make at most three
> attempts, retrying only if a VM checkpoint interrupts the transfer.
>
> Enable logging by default only in guests without memory encryption;
> encrypted guests should send their log to the host only when an
> administrator opts in. The copy is best-effort diagnostics; kdump does
> not depend on it succeeding.
>
> Suggested-by: Michael Kelley <mhklinux@outlook.com>
> Link: https://lore.kernel.org/r/SN6PR02MB41574A11D309A0530C63E0FED4842@SN6PR02MB4157.namprd02.prod.outlook.com
> Link: https://lore.kernel.org/r/20260309235250.2611115-3-alexey.makhalov@broadcom.com
> Co-developed-by: Bo Gan <bo.gan@broadcom.com>
> Signed-off-by: Bo Gan <bo.gan@broadcom.com>
> Co-developed-by: Alexey Makhalov <alexey.makhalov@broadcom.com>
> Signed-off-by: Alexey Makhalov <alexey.makhalov@broadcom.com>
> Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
I made just a quick review of the string manipulation and
kmsg_dump_get_buffer() API use. And it looks good to me:
Reviewed-by: Petr Mladek <pmladek@suse.com>
Note that I am not familiar with the vmware hypercalls so that
I did not check this part.
Some nits below.
> --- a/arch/x86/kernel/cpu/vmware.c
> +++ b/arch/x86/kernel/cpu/vmware.c
> @@ -52,6 +57,23 @@
> +#define VMWARE_LOG_BUF_SIZE SZ_8K
> +#define VMWARE_LOG_ATTEMPTS 3
> +#define VMWARE_LOG_PREFIX "log "
> +#define VMWARE_LOG_PREFIX_LEN (sizeof(VMWARE_LOG_PREFIX) - 1)
[...]
> +static int vmware_log_send_once(const struct vmware_rpc_channel *channel,
> + const char *buffer, size_t length)
> +{
> + u32 info;
> +
> + vmware_hypercall5(VMWARE_CMD_MESSAGE | VMWARE_MSG_SENDSIZE, length,
> + (u32)channel->id << 16, channel->cookie_high,
> + channel->cookie_low, &info);
> + if (!(info & VMWARE_MSG_STATUS_SUCCESS))
> + return info & VMWARE_MSG_STATUS_CPT ? -EAGAIN : -EIO;
> +
> + while (length) {
> + size_t bytes = min_t(size_t, length, sizeof(u32));
> + u32 word = 0;
> +
> + memcpy(&word, buffer, bytes);
> + vmware_hypercall5(VMWARE_CMD_MESSAGE | VMWARE_MSG_SENDPAYLOAD,
> + word, (u32)channel->id << 16,
> + channel->cookie_high, channel->cookie_low,
> + &info);
> + if (!(info & VMWARE_MSG_STATUS_SUCCESS))
> + return info & VMWARE_MSG_STATUS_CPT ? -EAGAIN : -EIO;
> +
> + buffer += bytes;
> + length -= bytes;
> + }
> +
> + return 0;
> +}
[...]
> +static int vmware_panic_log_notify(struct notifier_block *nb,
> + unsigned long action, void *data)
> +{
> + struct kmsg_dump_iter iter;
> + char *buffer = page_address(vmware_panic_page);
> + size_t length = 0;
I would add:
BUILD_BUG_ON(VMWARE_LOG_PREFIX_LEN > VMWARE_LOG_BUF_SIZE);
just to be on the safe side.
> +
> + if (!READ_ONCE(vmware_record_panic_msg))
> + return NOTIFY_DONE;
> +
> + memcpy(buffer, VMWARE_LOG_PREFIX, VMWARE_LOG_PREFIX_LEN);
I would feel more comfortable when the trailing '\0' gets copied as
well, e.g.
strscpy(buffer, VMWARE_LOG_PREFIX);
It is not strictly needed because the length is counted
explicitly, strlen() is not used. Also vmware_log_rpc() does
not send the trailing '\0'.
So, it is a rather a defensive programming. The buffer might be handled
another way in the future, e.g. printed by some debug code, tracing, ...
> + kmsg_dump_rewind(&iter);
> + (void)kmsg_dump_get_buffer(&iter, true,
> + buffer + VMWARE_LOG_PREFIX_LEN,
> + VMWARE_LOG_BUF_SIZE - VMWARE_LOG_PREFIX_LEN,
> + &length);
> + (void)vmware_log_rpc(buffer, length + VMWARE_LOG_PREFIX_LEN);
> +
> + return NOTIFY_DONE;
> +}
Best Regards,
Petr
next prev parent reply other threads:[~2026-11-20 9:10 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 6:01 [PATCH v4 0/4] panic, x86/vmware: Preserve crash logs before kdump Zack Rusin
2026-11-18 6:01 ` Zack Rusin
2026-11-18 6:01 ` [PATCH v4 1/4] panic: Add a platform panic notifier list Zack Rusin
2026-11-18 6:01 ` Zack Rusin
2026-11-18 6:16 ` sashiko-bot
2026-11-20 8:36 ` Petr Mladek
2026-11-20 8:36 ` Petr Mladek
2026-11-18 6:01 ` [PATCH v4 2/4] x86/vmware: Add a bounded panic log sender Zack Rusin
2026-11-18 6:01 ` Zack Rusin
2026-11-18 6:18 ` sashiko-bot
2026-11-18 6:18 ` sashiko-bot
2026-11-20 9:10 ` Petr Mladek [this message]
2026-11-20 9:10 ` Petr Mladek
2026-11-18 6:01 ` [PATCH v4 3/4] x86/vmware: Add the vmware_record_panic_msg sysctl Zack Rusin
2026-11-18 6:01 ` Zack Rusin
2026-11-18 6:14 ` sashiko-bot
2026-11-18 6:14 ` sashiko-bot
2026-11-18 6:42 ` Baoquan He
2026-11-18 6:42 ` Baoquan He
2026-11-18 7:02 ` Andrew Morton
2026-11-18 7:02 ` Andrew Morton
2026-11-18 7:51 ` Baoquan He
2026-11-18 7:51 ` Baoquan He
2026-11-18 7:53 ` Bradley Morgan
2026-11-18 7:53 ` Bradley Morgan
2026-11-18 8:09 ` Baoquan He
2026-11-18 8:09 ` Baoquan He
2026-11-19 11:07 ` Pratyush Yadav
2026-11-19 11:07 ` Pratyush Yadav
2026-11-19 15:35 ` Roman Gushchin
2026-11-19 15:35 ` Roman Gushchin
2026-11-18 14:36 ` Steven Rostedt
2026-11-18 14:36 ` Steven Rostedt
2026-11-20 9:19 ` Petr Mladek
2026-11-20 9:19 ` Petr Mladek
2026-11-18 6:01 ` [PATCH v4 4/4] x86/vmware: Report guest crashes after kmsg dumpers Zack Rusin
2026-11-18 6:01 ` Zack Rusin
2026-11-18 6:12 ` sashiko-bot
2026-11-18 6:12 ` sashiko-bot
2026-11-20 10:27 ` Petr Mladek
2026-11-20 10:27 ` Petr Mladek
2026-11-20 16:50 ` Zack Rusin
2026-11-20 16:50 ` Zack Rusin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=awAOhyq48jRfcVWd@pathway \
--to=pmladek@suse.com \
--cc=ajay.kaher@broadcom.com \
--cc=akpm@linux-foundation.org \
--cc=alexey.makhalov@broadcom.com \
--cc=baoquan.he@linux.dev \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bo.gan@broadcom.com \
--cc=bp@alien8.de \
--cc=brads@mainlining.org \
--cc=brennan.lamoreaux@broadcom.com \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=gpiccoli@igalia.com \
--cc=hpa@zytor.com \
--cc=ian.forbes@broadcom.com \
--cc=joel.granados@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=kees@kernel.org \
--cc=kexec@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maaz.mombasawala@broadcom.com \
--cc=mhklinux@outlook.com \
--cc=mingo@redhat.com \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.org \
--cc=rdunlap@infradead.org \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=ruirui.yang@linux.dev \
--cc=senozhatsky@chromium.org \
--cc=skhan@linuxfoundation.org \
--cc=stephen.s.brennan@oracle.com \
--cc=tglx@kernel.org \
--cc=virtualization@lists.linux.dev \
--cc=x86@kernel.org \
--cc=zack.rusin@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.