Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress unimplemented MSR related warnings #1611

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions usr.sbin/bhyve/amd64/bhyverun_machdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ bhyve_init_config(void)
set_config_bool("acpi_tables_in_memory", true);
set_config_value("memory.size", "256M");
set_config_bool("x86.strictmsr", true);
set_config_bool("x86.verbosemsr", true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can actually default it to false, only developers probably care and for users it is just annoying spam.

set_config_value("lpc.fwcfg", "bhyve");
}

Expand All @@ -74,7 +75,7 @@ bhyve_usage(int code)
progname = getprogname();

fprintf(stderr,
"Usage: %s [-aCDeHhPSuWwxY]\n"
"Usage: %s [-aCDeHhPqSuWwxY]\n"
" %*s [-c [[cpus=]numcpus][,sockets=n][,cores=n][,threads=n]]\n"
" %*s [-G port] [-k config_file] [-l lpc] [-m mem] [-o var=value]\n"
" %*s [-p vcpu:hostcpu] [-r file] [-s pci] [-U uuid] vmname\n"
Expand All @@ -96,6 +97,7 @@ bhyve_usage(int code)
#ifdef BHYVE_SNAPSHOT
" -r: path to checkpoint file\n"
#endif
" -q: disable verbose MSR print out\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably not add a new top-level option as there are already several, and -q is pretty generic. I think having it just settable via '-o' is fine.

" -S: guest memory cannot be swapped\n"
" -s: <slot,driver,configinfo> PCI slot config\n"
" -U: UUID\n"
Expand All @@ -116,9 +118,9 @@ bhyve_optparse(int argc, char **argv)
int c;

#ifdef BHYVE_SNAPSHOT
optstr = "aehuwxACDHIPSWYk:f:o:p:G:c:s:m:l:K:U:r:";
optstr = "aehuwxACDHIPqSWYk:f:o:p:G:c:s:m:l:K:U:r:";
#else
optstr = "aehuwxACDHIPSWYk:f:o:p:G:c:s:m:l:K:U:";
optstr = "aehuwxACDHIPqSWYk:f:o:p:G:c:s:m:l:K:U:";
#endif
while ((c = getopt(argc, argv, optstr)) != -1) {
switch (c) {
Expand Down Expand Up @@ -224,6 +226,9 @@ bhyve_optparse(int argc, char **argv)
case 'U':
set_config_value("uuid", optarg);
break;
case 'q':
set_config_value("x86.verbosemsr", false);
break;
case 'w':
set_config_bool("x86.strictmsr", false);
break;
Expand Down
12 changes: 8 additions & 4 deletions usr.sbin/bhyve/amd64/vmexit.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ vmexit_rdmsr(struct vmctx *ctx __unused, struct vcpu *vcpu,
val = 0;
error = emulate_rdmsr(vcpu, vme->u.msr.code, &val);
if (error != 0) {
EPRINTLN("rdmsr to register %#x on vcpu %d",
vme->u.msr.code, vcpu_id(vcpu));
if (get_config_bool("x86.strictmsr") || get_config_bool("x86.verbosemsr")) {
EPRINTLN("rdmsr to register %#x on vcpu %d",
vme->u.msr.code, vcpu_id(vcpu));
}
if (get_config_bool("x86.strictmsr")) {
vm_inject_gp(vcpu);
return (VMEXIT_CONTINUE);
Expand Down Expand Up @@ -137,8 +139,10 @@ vmexit_wrmsr(struct vmctx *ctx __unused, struct vcpu *vcpu,

error = emulate_wrmsr(vcpu, vme->u.msr.code, vme->u.msr.wval);
if (error != 0) {
EPRINTLN("wrmsr to register %#x(%#lx) on vcpu %d",
vme->u.msr.code, vme->u.msr.wval, vcpu_id(vcpu));
if (get_config_bool("x86.strictmsr") || get_config_bool("x86.verbosemsr")) {
EPRINTLN("wrmsr to register %#x(%#lx) on vcpu %d",
vme->u.msr.code, vme->u.msr.wval, vcpu_id(vcpu));
}
if (get_config_bool("x86.strictmsr")) {
vm_inject_gp(vcpu);
return (VMEXIT_CONTINUE);
Expand Down
9 changes: 8 additions & 1 deletion usr.sbin/bhyve/bhyve.8
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
.Nd "run a guest operating system inside a virtual machine"
.Sh SYNOPSIS
.Nm
.Op Fl aCDeHhPSuWwxY
.Op Fl aCDeHhPqSuWwxY
.Oo
.Sm off
.Fl c\~
Expand Down Expand Up @@ -295,6 +295,13 @@ To map a 4 vCPU guest to host CPUs 12-15:
.Bd -literal
-p 0:12 -p 1:13 -p 2:14 -p 3:15
.Ed
.It Fl q
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't do -q, we should still document this in bhyve_config.5 which describes all the config nodes.

Disable verbose MSR (Model-Specific Register) print out.
When this option is enabled, bhyve will suppress messages related to reading
from (rdmsr) and writing to (wrmsr) MSRs on virtual CPUs.
This can be useful for reducing log verbosity and preventing the VM console
from being spammed with informational messages, particularly in environments
where such messages are not needed for diagnostic purposes.
.It Fl r Ar file
Resume a guest from a snapshot.
The guest memory contents are restored from
Expand Down