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
This commit is contained in:
Mark Johnston 2023-03-03 09:32:48 -05:00
parent ce9f95bd83
commit 3f5d875a27
2 changed files with 12 additions and 20 deletions

View File

@ -12,8 +12,6 @@ MAN= bhyvectl.8
LIBADD= vmmapi util
WARNS?= 3
CFLAGS+= -I${SRCTOP}/sys/amd64/vmm
.if ${MK_BHYVE_SNAPSHOT} != "no"

View File

@ -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