vmx: use C99 bool, not boolean_t

Bhyve's vmm is a self-contained modern component and thus a good
candidate for use of C99 types.

Reviewed by:	jhb, kib, markj, Patrick Mooney
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D21036
This commit is contained in:
Ed Maste 2019-08-01 02:16:48 +00:00
parent a8e111af88
commit 490d56c527
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=350492
10 changed files with 47 additions and 68 deletions

View File

@ -319,12 +319,12 @@ vcpu_reqidle(struct vm_eventinfo *info)
int vcpu_debugged(struct vm *vm, int vcpuid);
/*
* Return 1 if device indicated by bus/slot/func is supposed to be a
* Return true if device indicated by bus/slot/func is supposed to be a
* pci passthrough device.
*
* Return 0 otherwise.
* Return false otherwise.
*/
int vmm_is_pptdev(int bus, int slot, int func);
bool vmm_is_pptdev(int bus, int slot, int func);
void *vm_iommu_domain(struct vm *vm);

View File

@ -1973,20 +1973,20 @@ ept_fault_type(uint64_t ept_qual)
return (fault_type);
}
static boolean_t
static bool
ept_emulation_fault(uint64_t ept_qual)
{
int read, write;
/* EPT fault on an instruction fetch doesn't make sense here */
if (ept_qual & EPT_VIOLATION_INST_FETCH)
return (FALSE);
return (false);
/* EPT fault must be a read fault or a write fault */
read = ept_qual & EPT_VIOLATION_DATA_READ ? 1 : 0;
write = ept_qual & EPT_VIOLATION_DATA_WRITE ? 1 : 0;
if ((read | write) == 0)
return (FALSE);
return (false);
/*
* The EPT violation must have been caused by accessing a
@ -1995,10 +1995,10 @@ ept_emulation_fault(uint64_t ept_qual)
*/
if ((ept_qual & EPT_VIOLATION_GLA_VALID) == 0 ||
(ept_qual & EPT_VIOLATION_XLAT_VALID) == 0) {
return (FALSE);
return (false);
}
return (TRUE);
return (true);
}
static __inline int

View File

@ -45,24 +45,18 @@ __FBSDID("$FreeBSD$");
#include "vmx.h"
#include "vmx_msr.h"
static boolean_t
static bool
vmx_ctl_allows_one_setting(uint64_t msr_val, int bitpos)
{
if (msr_val & (1UL << (bitpos + 32)))
return (TRUE);
else
return (FALSE);
return ((msr_val & (1UL << (bitpos + 32))) != 0);
}
static boolean_t
static bool
vmx_ctl_allows_zero_setting(uint64_t msr_val, int bitpos)
{
if ((msr_val & (1UL << bitpos)) == 0)
return (TRUE);
else
return (FALSE);
return ((msr_val & (1UL << bitpos)) == 0);
}
uint32_t
@ -89,16 +83,13 @@ vmx_set_ctlreg(int ctl_reg, int true_ctl_reg, uint32_t ones_mask,
{
int i;
uint64_t val, trueval;
boolean_t true_ctls_avail, one_allowed, zero_allowed;
bool true_ctls_avail, one_allowed, zero_allowed;
/* We cannot ask the same bit to be set to both '1' and '0' */
if ((ones_mask ^ zeros_mask) != (ones_mask | zeros_mask))
return (EINVAL);
if (rdmsr(MSR_VMX_BASIC) & (1UL << 55))
true_ctls_avail = TRUE;
else
true_ctls_avail = FALSE;
true_ctls_avail = (rdmsr(MSR_VMX_BASIC) & (1UL << 55)) != 0;
val = rdmsr(ctl_reg);
if (true_ctls_avail)

View File

@ -339,7 +339,7 @@ ppt_assigned_devices(struct vm *vm)
return (num);
}
boolean_t
bool
ppt_is_mmio(struct vm *vm, vm_paddr_t gpa)
{
int i;
@ -355,11 +355,11 @@ ppt_is_mmio(struct vm *vm, vm_paddr_t gpa)
if (seg->len == 0)
continue;
if (gpa >= seg->gpa && gpa < seg->gpa + seg->len)
return (TRUE);
return (true);
}
}
return (FALSE);
return (false);
}
static void

View File

@ -39,7 +39,7 @@ int ppt_setup_msi(struct vm *vm, int vcpu, int bus, int slot, int func,
int ppt_setup_msix(struct vm *vm, int vcpu, int bus, int slot, int func,
int idx, uint64_t addr, uint64_t msg, uint32_t vector_control);
int ppt_assigned_devices(struct vm *vm);
boolean_t ppt_is_mmio(struct vm *vm, vm_paddr_t gpa);
bool ppt_is_mmio(struct vm *vm, vm_paddr_t gpa);
/*
* Returns the number of devices sequestered by the ppt driver for assignment

View File

@ -847,7 +847,7 @@ vmm_sysmem_maxaddr(struct vm *vm)
}
static void
vm_iommu_modify(struct vm *vm, boolean_t map)
vm_iommu_modify(struct vm *vm, bool map)
{
int i, sz;
vm_paddr_t gpa, hpa;
@ -910,8 +910,8 @@ vm_iommu_modify(struct vm *vm, boolean_t map)
iommu_invalidate_tlb(vm->iommu);
}
#define vm_iommu_unmap(vm) vm_iommu_modify((vm), FALSE)
#define vm_iommu_map(vm) vm_iommu_modify((vm), TRUE)
#define vm_iommu_unmap(vm) vm_iommu_modify((vm), false)
#define vm_iommu_map(vm) vm_iommu_modify((vm), true)
int
vm_unassign_pptdev(struct vm *vm, int bus, int slot, int func)
@ -1043,20 +1043,20 @@ vm_set_register(struct vm *vm, int vcpuid, int reg, uint64_t val)
return (0);
}
static boolean_t
static bool
is_descriptor_table(int reg)
{
switch (reg) {
case VM_REG_GUEST_IDTR:
case VM_REG_GUEST_GDTR:
return (TRUE);
return (true);
default:
return (FALSE);
return (false);
}
}
static boolean_t
static bool
is_segment_register(int reg)
{
@ -1069,9 +1069,9 @@ is_segment_register(int reg)
case VM_REG_GUEST_GS:
case VM_REG_GUEST_TR:
case VM_REG_GUEST_LDTR:
return (TRUE);
return (true);
default:
return (FALSE);
return (false);
}
}
@ -2233,12 +2233,12 @@ vm_hpet(struct vm *vm)
return (vm->vhpet);
}
boolean_t
bool
vmm_is_pptdev(int bus, int slot, int func)
{
int found, i, n;
int b, s, f;
int b, f, i, n, s;
char *val, *cp, *cp2;
bool found;
/*
* XXX
@ -2252,7 +2252,7 @@ vmm_is_pptdev(int bus, int slot, int func)
const char *names[] = { "pptdevs", "pptdevs2", "pptdevs3", NULL };
/* set pptdevs="1/2/3 4/5/6 7/8/9 10/11/12" */
found = 0;
found = false;
for (i = 0; names[i] != NULL && !found; i++) {
cp = val = kern_getenv(names[i]);
while (cp != NULL && *cp != '\0') {
@ -2261,7 +2261,7 @@ vmm_is_pptdev(int bus, int slot, int func)
n = sscanf(cp, "%d/%d/%d", &b, &s, &f);
if (n == 3 && bus == b && slot == s && func == f) {
found = 1;
found = true;
break;
}

View File

@ -137,13 +137,10 @@ lapic_intr_msi(struct vm *vm, uint64_t addr, uint64_t msg)
return (0);
}
static boolean_t
static bool
x2apic_msr(u_int msr)
{
if (msr >= 0x800 && msr <= 0xBFF)
return (TRUE);
else
return (FALSE);
return (msr >= 0x800 && msr <= 0xBFF);
}
static u_int
@ -153,14 +150,11 @@ x2apic_msr_to_regoff(u_int msr)
return ((msr - 0x800) << 4);
}
boolean_t
bool
lapic_msr(u_int msr)
{
if (x2apic_msr(msr) || (msr == MSR_APICBASE))
return (TRUE);
else
return (FALSE);
return (x2apic_msr(msr) || msr == MSR_APICBASE);
}
int

View File

@ -33,7 +33,7 @@
struct vm;
boolean_t lapic_msr(u_int num);
bool lapic_msr(u_int num);
int lapic_rdmsr(struct vm *vm, int cpu, u_int msr, uint64_t *rval,
bool *retu);
int lapic_wrmsr(struct vm *vm, int cpu, u_int msr, uint64_t wval,

View File

@ -38,26 +38,20 @@ __FBSDID("$FreeBSD$");
#include "vmm_util.h"
boolean_t
bool
vmm_is_intel(void)
{
if (strcmp(cpu_vendor, "GenuineIntel") == 0)
return (TRUE);
else
return (FALSE);
return (strcmp(cpu_vendor, "GenuineIntel") == 0);
}
boolean_t
bool
vmm_is_amd(void)
{
if (strcmp(cpu_vendor, "AuthenticAMD") == 0)
return (TRUE);
else
return (FALSE);
return (strcmp(cpu_vendor, "AuthenticAMD") == 0);
}
boolean_t
bool
vmm_supports_1G_pages(void)
{
unsigned int regs[4];
@ -70,9 +64,9 @@ vmm_supports_1G_pages(void)
if (cpu_exthigh >= 0x80000001) {
do_cpuid(0x80000001, regs);
if (regs[3] & (1 << 26))
return (TRUE);
return (true);
}
return (FALSE);
return (false);
}
#include <sys/proc.h>

View File

@ -33,9 +33,9 @@
struct trapframe;
boolean_t vmm_is_intel(void);
boolean_t vmm_is_amd(void);
boolean_t vmm_supports_1G_pages(void);
bool vmm_is_intel(void);
bool vmm_is_amd(void);
bool vmm_supports_1G_pages(void);
void dump_trapframe(struct trapframe *tf);