drivers/virt/vboxguest/vboxguest_core.c
Source file repositories/reference/linux-study-clean/drivers/virt/vboxguest/vboxguest_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/virt/vboxguest/vboxguest_core.c- Extension
.c- Size
- 50295 bytes
- Lines
- 1854
- Domain
- Driver Families
- Bucket
- drivers/virt
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/io.hlinux/mm.hlinux/sched.hlinux/sizes.hlinux/slab.hlinux/vbox_err.hlinux/vbox_utils.hlinux/vmalloc.hvboxguest_core.hvboxguest_version.h
Detected Declarations
function Copyrightfunction vbg_guest_mappings_exitfunction vbg_report_guest_infofunction vbg_report_driver_statusfunction vbg_balloon_inflatefunction vbg_balloon_deflatefunction vbg_balloon_workfunction vbg_heartbeat_timerfunction vbg_heartbeat_host_configfunction vbg_heartbeat_initfunction vbg_heartbeat_exitfunction vbg_track_bit_usagefunction thefunction vbg_set_session_event_filterfunction vbg_reset_host_capabilitiesfunction vbg_set_host_capabilitiesfunction vbg_acquire_session_capabilitiesfunction vbg_set_session_capabilitiesfunction vbg_query_host_versionfunction memoryfunction vbg_core_exitfunction vbg_core_close_sessionfunction vbg_ioctl_chkfunction vbg_ioctl_driver_version_infofunction vbg_get_allowed_event_mask_for_sessionfunction vbg_wait_event_condfunction vbg_consume_events_lockedfunction vbg_ioctl_wait_for_eventsfunction vbg_ioctl_interrupt_all_wait_eventsfunction vbg_req_allowedfunction vbg_ioctl_vmmrequestfunction vbg_ioctl_hgcm_connectfunction vbg_ioctl_hgcm_disconnectfunction vbg_param_validfunction vbg_ioctl_hgcm_callfunction vbg_ioctl_logfunction vbg_ioctl_change_filter_maskfunction vbg_ioctl_acquire_guest_capabilitiesfunction vbg_ioctl_change_guest_capabilitiesfunction vbg_ioctl_check_balloonfunction vbg_ioctl_write_core_dumpfunction vbg_core_ioctlfunction vbg_core_set_mouse_statusfunction vbg_core_isr
Annotated Snippet
if (rc >= 0) {
gdev->guest_mappings = guest_mappings[i];
break;
}
}
/* Free vmap's from failed attempts. */
while (--i >= 0)
vunmap(guest_mappings[i]);
/* On failure free the dummy-page backing the vmap */
if (!gdev->guest_mappings) {
__free_page(gdev->guest_mappings_dummy_page);
gdev->guest_mappings_dummy_page = NULL;
}
out:
vbg_req_free(req, sizeof(*req));
kfree(pages);
}
/**
* vbg_guest_mappings_exit - Undo what vbg_guest_mappings_init did.
*
* @gdev: The Guest extension device.
*/
static void vbg_guest_mappings_exit(struct vbg_dev *gdev)
{
struct vmmdev_hypervisorinfo *req;
int rc;
if (!gdev->guest_mappings)
return;
/*
* Tell the host that we're going to free the memory we reserved for
* it, the free it up. (Leak the memory if anything goes wrong here.)
*/
req = vbg_req_alloc(sizeof(*req), VMMDEVREQ_SET_HYPERVISOR_INFO,
VBG_KERNEL_REQUEST);
if (!req)
return;
req->hypervisor_start = 0;
req->hypervisor_size = 0;
rc = vbg_req_perform(gdev, req);
vbg_req_free(req, sizeof(*req));
if (rc < 0) {
vbg_err("%s error: %d\n", __func__, rc);
return;
}
vunmap(gdev->guest_mappings);
gdev->guest_mappings = NULL;
__free_page(gdev->guest_mappings_dummy_page);
gdev->guest_mappings_dummy_page = NULL;
}
/**
* vbg_report_guest_info - Report the guest information to the host.
* @gdev: The Guest extension device.
*
* Return: %0 or negative errno value.
*/
static int vbg_report_guest_info(struct vbg_dev *gdev)
{
/*
* Allocate and fill in the two guest info reports.
*/
struct vmmdev_guest_info *req1 = NULL;
struct vmmdev_guest_info2 *req2 = NULL;
int rc, ret = -ENOMEM;
req1 = vbg_req_alloc(sizeof(*req1), VMMDEVREQ_REPORT_GUEST_INFO,
VBG_KERNEL_REQUEST);
req2 = vbg_req_alloc(sizeof(*req2), VMMDEVREQ_REPORT_GUEST_INFO2,
VBG_KERNEL_REQUEST);
if (!req1 || !req2)
goto out_free;
req1->interface_version = VMMDEV_VERSION;
req1->os_type = VMMDEV_OSTYPE_LINUX26;
#if __BITS_PER_LONG == 64
req1->os_type |= VMMDEV_OSTYPE_X64;
#endif
Annotation
- Immediate include surface: `linux/device.h`, `linux/io.h`, `linux/mm.h`, `linux/sched.h`, `linux/sizes.h`, `linux/slab.h`, `linux/vbox_err.h`, `linux/vbox_utils.h`.
- Detected declarations: `function Copyright`, `function vbg_guest_mappings_exit`, `function vbg_report_guest_info`, `function vbg_report_driver_status`, `function vbg_balloon_inflate`, `function vbg_balloon_deflate`, `function vbg_balloon_work`, `function vbg_heartbeat_timer`, `function vbg_heartbeat_host_config`, `function vbg_heartbeat_init`.
- Atlas domain: Driver Families / drivers/virt.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.