forked from illumos/illumos-gate
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BHYVE: OS-6740 bhyve vtd leaks mapping resources
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Reviewed by: Patrick Mooney <patrick.mooney@joyent.com> Approved by: Patrick Mooney <patrick.mooney@joyent.com>
- Loading branch information
1 parent
2c1e306
commit bc5debe
Showing
5 changed files
with
160 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -262,6 +262,7 @@ VMM_OBJS += vmm.o \ | |
vmx.o \ | ||
vmx_support.o \ | ||
vtd.o \ | ||
vtd_sol.o \ | ||
svm.o \ | ||
svm_msr.o \ | ||
npt.o \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* This file and its contents are supplied under the terms of the | ||
* Common Development and Distribution License ("CDDL"), version 1.0. | ||
* You may only use this file in accordance with the terms of version | ||
* 1.0 of the CDDL. | ||
* | ||
* A full copy of the text of the CDDL should have accompanied this | ||
* source. A copy of the CDDL is also available via the Internet at | ||
* http://www.illumos.org/license/CDDL. | ||
*/ | ||
|
||
/* | ||
* Copyright 2018 Joyent, Inc. | ||
*/ | ||
|
||
#include <sys/sunndi.h> | ||
#include <contrib/dev/acpica/include/acpi.h> | ||
|
||
dev_info_t * | ||
vtd_get_dip(ACPI_DMAR_HARDWARE_UNIT *drhd, int unit) | ||
{ | ||
dev_info_t *dip; | ||
struct ddi_parent_private_data *pdptr; | ||
struct regspec reg; | ||
int circ; | ||
|
||
/* | ||
* Try to find an existing devinfo node for this vtd unit. | ||
*/ | ||
ndi_devi_enter(ddi_root_node(), &circ); | ||
dip = ddi_find_devinfo("vtd", unit, 0); | ||
ndi_devi_exit(ddi_root_node(), circ); | ||
|
||
if (dip != NULL) | ||
return (dip); | ||
|
||
/* | ||
* None found, construct a devinfo node for this vtd unit. | ||
*/ | ||
dip = ddi_add_child(ddi_root_node(), "vtd", | ||
DEVI_SID_NODEID, unit); | ||
|
||
reg.regspec_bustype = 0; | ||
reg.regspec_addr = drhd->Address; | ||
reg.regspec_size = PAGE_SIZE; | ||
|
||
/* | ||
* update the reg properties | ||
* | ||
* reg property will be used for register | ||
* set access | ||
* | ||
* refer to the bus_map of root nexus driver | ||
* I/O or memory mapping: | ||
* | ||
* <bustype=0, addr=x, len=x>: memory | ||
* <bustype=1, addr=x, len=x>: i/o | ||
* <bustype>1, addr=0, len=x>: x86-compatibility i/o | ||
*/ | ||
(void) ndi_prop_update_int_array(DDI_DEV_T_NONE, | ||
dip, "reg", (int *)®, | ||
sizeof (struct regspec) / sizeof (int)); | ||
|
||
/* | ||
* This is an artificially constructed dev_info, and we | ||
* need to set a few more things to be able to use it | ||
* for ddi_dma_alloc_handle/free_handle. | ||
*/ | ||
ddi_set_driver(dip, ddi_get_driver(ddi_root_node())); | ||
DEVI(dip)->devi_bus_dma_allochdl = | ||
DEVI(ddi_get_driver((ddi_root_node()))); | ||
|
||
pdptr = kmem_zalloc(sizeof (struct ddi_parent_private_data) | ||
+ sizeof (struct regspec), KM_SLEEP); | ||
pdptr->par_nreg = 1; | ||
pdptr->par_reg = (struct regspec *)(pdptr + 1); | ||
pdptr->par_reg->regspec_bustype = 0; | ||
pdptr->par_reg->regspec_addr = drhd->Address; | ||
pdptr->par_reg->regspec_size = PAGE_SIZE; | ||
ddi_set_parent_data(dip, pdptr); | ||
|
||
return (dip); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -497,6 +497,7 @@ vmm_mod_unload() | |
{ | ||
int error; | ||
|
||
iommu_cleanup(); | ||
error = VMM_CLEANUP(); | ||
if (error) | ||
return (error); | ||
|