svn commit: r351753 - in stable/11/sys/amd64: include vmm vmm/intel vmm/io
Ed Maste
emaste at FreeBSD.org
Tue Sep 3 16:23:49 UTC 2019
Author: emaste
Date: Tue Sep 3 16:23:46 2019
New Revision: 351753
URL: https://svnweb.freebsd.org/changeset/base/351753
Log:
MFC r350492: 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.
Sponsored by: The FreeBSD Foundation
Modified:
stable/11/sys/amd64/include/vmm.h
stable/11/sys/amd64/vmm/intel/vmx.c
stable/11/sys/amd64/vmm/intel/vmx_msr.c
stable/11/sys/amd64/vmm/io/ppt.c
stable/11/sys/amd64/vmm/io/ppt.h
stable/11/sys/amd64/vmm/vmm.c
stable/11/sys/amd64/vmm/vmm_lapic.c
stable/11/sys/amd64/vmm/vmm_lapic.h
stable/11/sys/amd64/vmm/vmm_util.c
stable/11/sys/amd64/vmm/vmm_util.h
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/amd64/include/vmm.h
==============================================================================
--- stable/11/sys/amd64/include/vmm.h Tue Sep 3 16:20:04 2019 (r351752)
+++ stable/11/sys/amd64/include/vmm.h Tue Sep 3 16:23:46 2019 (r351753)
@@ -290,12 +290,12 @@ vcpu_reqidle(struct vm_eventinfo *info)
}
/*
- * 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);
Modified: stable/11/sys/amd64/vmm/intel/vmx.c
==============================================================================
--- stable/11/sys/amd64/vmm/intel/vmx.c Tue Sep 3 16:20:04 2019 (r351752)
+++ stable/11/sys/amd64/vmm/intel/vmx.c Tue Sep 3 16:23:46 2019 (r351753)
@@ -1971,20 +1971,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
@@ -1993,10 +1993,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
Modified: stable/11/sys/amd64/vmm/intel/vmx_msr.c
==============================================================================
--- stable/11/sys/amd64/vmm/intel/vmx_msr.c Tue Sep 3 16:20:04 2019 (r351752)
+++ stable/11/sys/amd64/vmm/intel/vmx_msr.c Tue Sep 3 16:23:46 2019 (r351753)
@@ -43,24 +43,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
@@ -87,16 +81,13 @@ vmx_set_ctlreg(int ctl_reg, int true_ctl_reg, uint32_t
{
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)
Modified: stable/11/sys/amd64/vmm/io/ppt.c
==============================================================================
--- stable/11/sys/amd64/vmm/io/ppt.c Tue Sep 3 16:20:04 2019 (r351752)
+++ stable/11/sys/amd64/vmm/io/ppt.c Tue Sep 3 16:23:46 2019 (r351753)
@@ -337,7 +337,7 @@ ppt_assigned_devices(struct vm *vm)
return (num);
}
-boolean_t
+bool
ppt_is_mmio(struct vm *vm, vm_paddr_t gpa)
{
int i;
@@ -353,11 +353,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
Modified: stable/11/sys/amd64/vmm/io/ppt.h
==============================================================================
--- stable/11/sys/amd64/vmm/io/ppt.h Tue Sep 3 16:20:04 2019 (r351752)
+++ stable/11/sys/amd64/vmm/io/ppt.h Tue Sep 3 16:23:46 2019 (r351753)
@@ -37,7 +37,7 @@ int ppt_setup_msi(struct vm *vm, int vcpu, int bus, in
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
Modified: stable/11/sys/amd64/vmm/vmm.c
==============================================================================
--- stable/11/sys/amd64/vmm/vmm.c Tue Sep 3 16:20:04 2019 (r351752)
+++ stable/11/sys/amd64/vmm/vmm.c Tue Sep 3 16:23:46 2019 (r351753)
@@ -842,7 +842,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;
@@ -905,8 +905,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)
@@ -1038,20 +1038,20 @@ vm_set_register(struct vm *vm, int vcpuid, int reg, ui
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)
{
@@ -1064,9 +1064,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);
}
}
@@ -2214,12 +2214,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
@@ -2233,7 +2233,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') {
@@ -2242,7 +2242,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;
}
Modified: stable/11/sys/amd64/vmm/vmm_lapic.c
==============================================================================
--- stable/11/sys/amd64/vmm/vmm_lapic.c Tue Sep 3 16:20:04 2019 (r351752)
+++ stable/11/sys/amd64/vmm/vmm_lapic.c Tue Sep 3 16:23:46 2019 (r351753)
@@ -135,13 +135,10 @@ lapic_intr_msi(struct vm *vm, uint64_t addr, uint64_t
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
@@ -151,14 +148,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
Modified: stable/11/sys/amd64/vmm/vmm_lapic.h
==============================================================================
--- stable/11/sys/amd64/vmm/vmm_lapic.h Tue Sep 3 16:20:04 2019 (r351752)
+++ stable/11/sys/amd64/vmm/vmm_lapic.h Tue Sep 3 16:23:46 2019 (r351753)
@@ -31,7 +31,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,
Modified: stable/11/sys/amd64/vmm/vmm_util.c
==============================================================================
--- stable/11/sys/amd64/vmm/vmm_util.c Tue Sep 3 16:20:04 2019 (r351752)
+++ stable/11/sys/amd64/vmm/vmm_util.c Tue Sep 3 16:23:46 2019 (r351753)
@@ -36,26 +36,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];
@@ -68,9 +62,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>
Modified: stable/11/sys/amd64/vmm/vmm_util.h
==============================================================================
--- stable/11/sys/amd64/vmm/vmm_util.h Tue Sep 3 16:20:04 2019 (r351752)
+++ stable/11/sys/amd64/vmm/vmm_util.h Tue Sep 3 16:23:46 2019 (r351753)
@@ -31,9 +31,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);
More information about the svn-src-stable
mailing list