Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/vmm/vmm.c
Show First 20 Lines • Show All 841 Lines • ▼ Show 20 Lines | if (sysmem_mapping(vm, mm)) { | ||||
if (maxaddr < mm->gpa + mm->len) | if (maxaddr < mm->gpa + mm->len) | ||||
maxaddr = mm->gpa + mm->len; | maxaddr = mm->gpa + mm->len; | ||||
} | } | ||||
} | } | ||||
return (maxaddr); | return (maxaddr); | ||||
} | } | ||||
static void | static void | ||||
vm_iommu_modify(struct vm *vm, boolean_t map) | vm_iommu_modify(struct vm *vm, bool map) | ||||
{ | { | ||||
int i, sz; | int i, sz; | ||||
vm_paddr_t gpa, hpa; | vm_paddr_t gpa, hpa; | ||||
struct mem_map *mm; | struct mem_map *mm; | ||||
void *vp, *cookie, *host_domain; | void *vp, *cookie, *host_domain; | ||||
sz = PAGE_SIZE; | sz = PAGE_SIZE; | ||||
host_domain = iommu_host_domain(); | host_domain = iommu_host_domain(); | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | vm_iommu_modify(struct vm *vm, bool map) | ||||
* from which pages were removed. | * from which pages were removed. | ||||
*/ | */ | ||||
if (map) | if (map) | ||||
iommu_invalidate_tlb(host_domain); | iommu_invalidate_tlb(host_domain); | ||||
else | else | ||||
iommu_invalidate_tlb(vm->iommu); | iommu_invalidate_tlb(vm->iommu); | ||||
} | } | ||||
#define vm_iommu_unmap(vm) vm_iommu_modify((vm), FALSE) | #define vm_iommu_unmap(vm) vm_iommu_modify((vm), false) | ||||
#define vm_iommu_map(vm) vm_iommu_modify((vm), TRUE) | #define vm_iommu_map(vm) vm_iommu_modify((vm), true) | ||||
int | int | ||||
vm_unassign_pptdev(struct vm *vm, int bus, int slot, int func) | vm_unassign_pptdev(struct vm *vm, int bus, int slot, int func) | ||||
{ | { | ||||
int error; | int error; | ||||
error = ppt_unassign_device(vm, bus, slot, func); | error = ppt_unassign_device(vm, bus, slot, func); | ||||
if (error) | if (error) | ||||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | vm_set_register(struct vm *vm, int vcpuid, int reg, uint64_t val) | ||||
/* Set 'nextrip' to match the value of %rip */ | /* Set 'nextrip' to match the value of %rip */ | ||||
VCPU_CTR1(vm, vcpuid, "Setting nextrip to %#lx", val); | VCPU_CTR1(vm, vcpuid, "Setting nextrip to %#lx", val); | ||||
vcpu = &vm->vcpu[vcpuid]; | vcpu = &vm->vcpu[vcpuid]; | ||||
vcpu->nextrip = val; | vcpu->nextrip = val; | ||||
return (0); | return (0); | ||||
} | } | ||||
static boolean_t | static bool | ||||
is_descriptor_table(int reg) | is_descriptor_table(int reg) | ||||
{ | { | ||||
switch (reg) { | switch (reg) { | ||||
case VM_REG_GUEST_IDTR: | case VM_REG_GUEST_IDTR: | ||||
case VM_REG_GUEST_GDTR: | case VM_REG_GUEST_GDTR: | ||||
return (TRUE); | return (true); | ||||
default: | default: | ||||
return (FALSE); | return (false); | ||||
} | } | ||||
} | } | ||||
static boolean_t | static bool | ||||
is_segment_register(int reg) | is_segment_register(int reg) | ||||
{ | { | ||||
switch (reg) { | switch (reg) { | ||||
case VM_REG_GUEST_ES: | case VM_REG_GUEST_ES: | ||||
case VM_REG_GUEST_CS: | case VM_REG_GUEST_CS: | ||||
case VM_REG_GUEST_SS: | case VM_REG_GUEST_SS: | ||||
case VM_REG_GUEST_DS: | case VM_REG_GUEST_DS: | ||||
case VM_REG_GUEST_FS: | case VM_REG_GUEST_FS: | ||||
case VM_REG_GUEST_GS: | case VM_REG_GUEST_GS: | ||||
case VM_REG_GUEST_TR: | case VM_REG_GUEST_TR: | ||||
case VM_REG_GUEST_LDTR: | case VM_REG_GUEST_LDTR: | ||||
return (TRUE); | return (true); | ||||
default: | default: | ||||
return (FALSE); | return (false); | ||||
} | } | ||||
} | } | ||||
int | int | ||||
vm_get_seg_desc(struct vm *vm, int vcpu, int reg, | vm_get_seg_desc(struct vm *vm, int vcpu, int reg, | ||||
struct seg_desc *desc) | struct seg_desc *desc) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 1,145 Lines • ▼ Show 20 Lines | |||||
struct vhpet * | struct vhpet * | ||||
vm_hpet(struct vm *vm) | vm_hpet(struct vm *vm) | ||||
{ | { | ||||
return (vm->vhpet); | return (vm->vhpet); | ||||
} | } | ||||
boolean_t | bool | ||||
vmm_is_pptdev(int bus, int slot, int func) | vmm_is_pptdev(int bus, int slot, int func) | ||||
{ | { | ||||
int found, i, n; | int b, f, i, n, s; | ||||
kib: bool found | |||||
int b, s, f; | |||||
char *val, *cp, *cp2; | char *val, *cp, *cp2; | ||||
bool found; | |||||
/* | /* | ||||
* XXX | * XXX | ||||
* The length of an environment variable is limited to 128 bytes which | * The length of an environment variable is limited to 128 bytes which | ||||
* puts an upper limit on the number of passthru devices that may be | * puts an upper limit on the number of passthru devices that may be | ||||
* specified using a single environment variable. | * specified using a single environment variable. | ||||
* | * | ||||
* Work around this by scanning multiple environment variable | * Work around this by scanning multiple environment variable | ||||
* names instead of a single one - yuck! | * names instead of a single one - yuck! | ||||
*/ | */ | ||||
const char *names[] = { "pptdevs", "pptdevs2", "pptdevs3", NULL }; | const char *names[] = { "pptdevs", "pptdevs2", "pptdevs3", NULL }; | ||||
/* set pptdevs="1/2/3 4/5/6 7/8/9 10/11/12" */ | /* 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++) { | for (i = 0; names[i] != NULL && !found; i++) { | ||||
cp = val = kern_getenv(names[i]); | cp = val = kern_getenv(names[i]); | ||||
while (cp != NULL && *cp != '\0') { | while (cp != NULL && *cp != '\0') { | ||||
if ((cp2 = strchr(cp, ' ')) != NULL) | if ((cp2 = strchr(cp, ' ')) != NULL) | ||||
*cp2 = '\0'; | *cp2 = '\0'; | ||||
n = sscanf(cp, "%d/%d/%d", &b, &s, &f); | n = sscanf(cp, "%d/%d/%d", &b, &s, &f); | ||||
if (n == 3 && bus == b && slot == s && func == f) { | if (n == 3 && bus == b && slot == s && func == f) { | ||||
found = 1; | found = true; | ||||
break; | break; | ||||
} | } | ||||
if (cp2 != NULL) | if (cp2 != NULL) | ||||
*cp2++ = ' '; | *cp2++ = ' '; | ||||
cp = cp2; | cp = cp2; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 447 Lines • Show Last 20 Lines |
bool found