drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vmwgfx/vmwgfx_msg.c- Extension
.c- Size
- 30543 bytes
- Lines
- 1138
- Domain
- Driver Families
- Bucket
- drivers/gpu
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/objtool.hlinux/kernel.hlinux/module.hlinux/slab.hlinux/cc_platform.hasm/hypervisor.hdrm/drm_ioctl.hvmwgfx_drv.hvmwgfx_msg_x86.hvmwgfx_msg_arm64.hvmwgfx_mksstat.h
Detected Declarations
struct rpc_channelenum rpc_msg_typefunction vmw_open_channelfunction vmw_close_channelfunction vmw_port_hb_outfunction vmw_port_hb_infunction vmw_send_msgfunction vmw_recv_msgfunction vmw_host_get_guestinfofunction vmw_host_printffunction vmw_msg_ioctlfunction reset_ppn_arrayfunction hypervisor_ppn_reset_allfunction hypervisor_ppn_addfunction hypervisor_ppn_removefunction mksstat_init_kern_idfunction vmw_mksstat_get_kern_slotfunction vmw_mksstat_cleanup_descriptorfunction vmw_mksstat_remove_allfunction vmw_mksstat_reset_ioctlfunction vmw_mksstat_add_ioctlfunction vmw_mksstat_remove_ioctlfunction vmw_disable_backdoor
Annotated Snippet
struct rpc_channel {
u16 channel_id;
u32 cookie_high;
u32 cookie_low;
};
#if IS_ENABLED(CONFIG_DRM_VMWGFX_MKSSTATS)
/* Kernel mksGuestStats counter names and desciptions; same order as enum mksstat_kern_stats_t */
static const char* const mksstat_kern_name_desc[MKSSTAT_KERN_COUNT][2] =
{
{ "vmw_execbuf_ioctl", "vmw_execbuf_ioctl" },
{ "vmw_cotable_resize", "vmw_cotable_resize" },
};
#endif
/**
* vmw_open_channel
*
* @channel: RPC channel
* @protocol:
*
* Returns: 0 on success
*/
static int vmw_open_channel(struct rpc_channel *channel, unsigned int protocol)
{
u32 ecx, edx, esi, edi;
vmware_hypercall6(VMW_PORT_CMD_OPEN_CHANNEL,
(protocol | GUESTMSG_FLAG_COOKIE), 0,
&ecx, &edx, &esi, &edi);
if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0)
return -EINVAL;
channel->channel_id = HIGH_WORD(edx);
channel->cookie_high = esi;
channel->cookie_low = edi;
return 0;
}
/**
* vmw_close_channel
*
* @channel: RPC channel
*
* Returns: 0 on success
*/
static int vmw_close_channel(struct rpc_channel *channel)
{
u32 ecx;
vmware_hypercall5(VMW_PORT_CMD_CLOSE_CHANNEL,
0, channel->channel_id << 16,
channel->cookie_high,
channel->cookie_low,
&ecx);
if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0)
return -EINVAL;
return 0;
}
/**
* vmw_port_hb_out - Send the message payload either through the
* high-bandwidth port if available, or through the backdoor otherwise.
* @channel: The rpc channel.
* @msg: NULL-terminated message.
* @hb: Whether the high-bandwidth port is available.
*
* Return: The port status.
*/
static unsigned long vmw_port_hb_out(struct rpc_channel *channel,
const char *msg, bool hb)
{
u32 ebx, ecx;
unsigned long msg_len = strlen(msg);
/* HB port can't access encrypted memory. */
if (hb && !cc_platform_has(CC_ATTR_MEM_ENCRYPT)) {
vmware_hypercall_hb_out(
(MESSAGE_STATUS_SUCCESS << 16) | VMW_PORT_CMD_HB_MSG,
msg_len,
channel->channel_id << 16,
(uintptr_t) msg, channel->cookie_low,
channel->cookie_high,
&ebx);
Annotation
- Immediate include surface: `linux/objtool.h`, `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/cc_platform.h`, `asm/hypervisor.h`, `drm/drm_ioctl.h`, `vmwgfx_drv.h`.
- Detected declarations: `struct rpc_channel`, `enum rpc_msg_type`, `function vmw_open_channel`, `function vmw_close_channel`, `function vmw_port_hb_out`, `function vmw_port_hb_in`, `function vmw_send_msg`, `function vmw_recv_msg`, `function vmw_host_get_guestinfo`, `function vmw_host_printf`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.