drivers/virt/fsl_hypervisor.c
Source file repositories/reference/linux-study-clean/drivers/virt/fsl_hypervisor.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/virt/fsl_hypervisor.c- Extension
.c- Size
- 23598 bytes
- Lines
- 933
- Domain
- Driver Families
- Bucket
- drivers/virt
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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.
- 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/kernel.hlinux/module.hlinux/init.hlinux/types.hlinux/err.hlinux/fs.hlinux/miscdevice.hlinux/mm.hlinux/pagemap.hlinux/slab.hlinux/poll.hlinux/of.hlinux/of_irq.hlinux/reboot.hlinux/uaccess.hlinux/notifier.hlinux/interrupt.hlinux/io.hasm/fsl_hcalls.hlinux/fsl_hypervisor.h
Detected Declarations
struct doorbell_queuestruct doorbell_isrfunction ioctl_restartfunction ioctl_statusfunction ioctl_startfunction ioctl_stopfunction ioctl_memcpyfunction ioctl_doorbellfunction ioctl_dtpropfunction fsl_hv_ioctlfunction fsl_hv_queue_doorbellfunction list_for_each_entryfunction doorbellfunction blocking_notifier_call_chainfunction fsl_hv_state_change_isrfunction fsl_hv_pollfunction fsl_hv_readfunction fsl_hv_openfunction fsl_hv_closefunction fsl_hv_shutdown_isrfunction get_parent_handlefunction fsl_hv_failover_registerfunction fsl_hv_failover_unregisterfunction has_fsl_hypervisorfunction fsl_hypervisor_initfunction for_each_compatible_nodefunction fsl_hypervisor_exitfunction list_for_each_entry_safemodule init fsl_hypervisor_initexport fsl_hv_failover_registerexport fsl_hv_failover_unregister
Annotated Snippet
static const struct file_operations fsl_hv_fops = {
.owner = THIS_MODULE,
.open = fsl_hv_open,
.release = fsl_hv_close,
.poll = fsl_hv_poll,
.read = fsl_hv_read,
.unlocked_ioctl = fsl_hv_ioctl,
.compat_ioctl = compat_ptr_ioctl,
};
static struct miscdevice fsl_hv_misc_dev = {
MISC_DYNAMIC_MINOR,
"fsl-hv",
&fsl_hv_fops
};
static irqreturn_t fsl_hv_shutdown_isr(int irq, void *data)
{
orderly_poweroff(false);
return IRQ_HANDLED;
}
/*
* Returns the handle of the parent of the given node
*
* The handle is the value of the 'hv-handle' property
*/
static int get_parent_handle(struct device_node *np)
{
struct device_node *parent;
const uint32_t *prop;
uint32_t handle;
int len;
parent = of_get_parent(np);
if (!parent)
/* It's not really possible for this to fail */
return -ENODEV;
/*
* The proper name for the handle property is "hv-handle", but some
* older versions of the hypervisor used "reg".
*/
prop = of_get_property(parent, "hv-handle", &len);
if (!prop)
prop = of_get_property(parent, "reg", &len);
if (!prop || (len != sizeof(uint32_t))) {
/* This can happen only if the node is malformed */
of_node_put(parent);
return -ENODEV;
}
handle = be32_to_cpup(prop);
of_node_put(parent);
return handle;
}
/*
* Register a callback for failover events
*
* This function is called by device drivers to register their callback
* functions for fail-over events.
*/
int fsl_hv_failover_register(struct notifier_block *nb)
{
return blocking_notifier_chain_register(&failover_subscribers, nb);
}
EXPORT_SYMBOL(fsl_hv_failover_register);
/*
* Unregister a callback for failover events
*/
int fsl_hv_failover_unregister(struct notifier_block *nb)
{
return blocking_notifier_chain_unregister(&failover_subscribers, nb);
}
EXPORT_SYMBOL(fsl_hv_failover_unregister);
/*
* Return TRUE if we're running under FSL hypervisor
*
* This function checks to see if we're running under the Freescale
* hypervisor, and returns zero if we're not, or non-zero if we are.
*
* First, it checks if MSR[GS]==1, which means we're running under some
* hypervisor. Then it checks if there is a hypervisor node in the device
* tree. Currently, that means there needs to be a node in the root called
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/init.h`, `linux/types.h`, `linux/err.h`, `linux/fs.h`, `linux/miscdevice.h`, `linux/mm.h`.
- Detected declarations: `struct doorbell_queue`, `struct doorbell_isr`, `function ioctl_restart`, `function ioctl_status`, `function ioctl_start`, `function ioctl_stop`, `function ioctl_memcpy`, `function ioctl_doorbell`, `function ioctl_dtprop`, `function fsl_hv_ioctl`.
- Atlas domain: Driver Families / drivers/virt.
- Implementation status: pattern 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.
- 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.