aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2023-03-03 14:32:48 +0000
committerMark Johnston <markj@FreeBSD.org>2023-03-03 16:13:22 +0000
commit3f5d875a27318a909f23a2b7463c4b2d963085df (patch)
tree7cec9db1fb470598547b78e3ccbac8e2bb2bcbc7
parentce9f95bd835ec7d3ac6def5a910282509b1413f0 (diff)
downloadsrc-3f5d875a27318a909f23a2b7463c4b2d963085df.tar.gz
src-3f5d875a27318a909f23a2b7463c4b2d963085df.zip
bhyvectl: Address compiler warnings and bump WARNS
Avoid unaligned accesses in cpu_vendor_intel() and address a few other nits. No functional change intended. Reviewed by: corvink, rew, jhb MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D38839
-rw-r--r--usr.sbin/bhyvectl/Makefile2
-rw-r--r--usr.sbin/bhyvectl/bhyvectl.c30
2 files changed, 12 insertions, 20 deletions
diff --git a/usr.sbin/bhyvectl/Makefile b/usr.sbin/bhyvectl/Makefile
index c004d603c8db..5b1c04e8ac88 100644
--- a/usr.sbin/bhyvectl/Makefile
+++ b/usr.sbin/bhyvectl/Makefile
@@ -12,8 +12,6 @@ MAN= bhyvectl.8
LIBADD= vmmapi util
-WARNS?= 3
-
CFLAGS+= -I${SRCTOP}/sys/amd64/vmm
.if ${MK_BHYVE_SNAPSHOT} != "no"
diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c
index 14ab6c7ad33e..cab1e6d72c56 100644
--- a/usr.sbin/bhyvectl/bhyvectl.c
+++ b/usr.sbin/bhyvectl/bhyvectl.c
@@ -294,7 +294,7 @@ static int set_desc_ldtr, get_desc_ldtr;
static int set_cs, set_ds, set_es, set_fs, set_gs, set_ss, set_tr, set_ldtr;
static int get_cs, get_ds, get_es, get_fs, get_gs, get_ss, get_tr, get_ldtr;
static int set_x2apic_state, get_x2apic_state;
-enum x2apic_state x2apic_state;
+static enum x2apic_state x2apic_state;
static int unassign_pptdev, bus, slot, func;
static int run;
static int get_cpu_topology;
@@ -316,7 +316,6 @@ static int get_pinbased_ctls, get_procbased_ctls, get_procbased_ctls2;
static int get_eptp, get_io_bitmap, get_tsc_offset;
static int get_vmcs_entry_interruption_info;
static int get_vmcs_interruptibility;
-uint32_t vmcs_entry_interruption_info;
static int get_vmcs_gpa, get_vmcs_gla;
static int get_exception_bitmap;
static int get_cr0_mask, get_cr0_shadow;
@@ -497,8 +496,8 @@ dump_intel_msr_pm(const char *bitmap, int vcpu)
static int
dump_msr_bitmap(int vcpu, uint64_t addr, bool cpu_intel)
{
+ char *bitmap;
int error, fd, map_size;
- const char *bitmap;
error = -1;
bitmap = MAP_FAILED;
@@ -648,25 +647,20 @@ print_intinfo(const char *banner, uint64_t info)
static bool
cpu_vendor_intel(void)
{
- u_int regs[4];
- char cpu_vendor[13];
+ u_int regs[4], v[3];
do_cpuid(0, regs);
- ((u_int *)&cpu_vendor)[0] = regs[1];
- ((u_int *)&cpu_vendor)[1] = regs[3];
- ((u_int *)&cpu_vendor)[2] = regs[2];
- cpu_vendor[12] = '\0';
+ v[0] = regs[1];
+ v[1] = regs[3];
+ v[2] = regs[2];
- if (strcmp(cpu_vendor, "AuthenticAMD") == 0) {
- return (false);
- } else if (strcmp(cpu_vendor, "HygonGenuine") == 0) {
- return (false);
- } else if (strcmp(cpu_vendor, "GenuineIntel") == 0) {
+ if (memcmp(v, "GenuineIntel", sizeof(v)) == 0)
return (true);
- } else {
- fprintf(stderr, "Unknown cpu vendor \"%s\"\n", cpu_vendor);
- exit(1);
- }
+ if (memcmp(v, "AuthenticAMD", sizeof(v)) == 0 ||
+ memcmp(v, "HygonGenuine", sizeof(v)) == 0)
+ return (false);
+ fprintf(stderr, "Unknown cpu vendor \"%s\"\n", (const char *)v);
+ exit(1);
}
static int