drivers/xen/mem-reservation.c
Source file repositories/reference/linux-study-clean/drivers/xen/mem-reservation.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/xen/mem-reservation.c- Extension
.c- Size
- 3141 bytes
- Lines
- 116
- Domain
- Driver Families
- Bucket
- drivers/xen
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
asm/xen/hypercall.hxen/interface/memory.hxen/mem-reservation.hlinux/moduleparam.h
Detected Declarations
function __xenmem_reservation_va_mapping_updatefunction __xenmem_reservation_va_mapping_resetfunction xenmem_reservation_increasefunction xenmem_reservation_decreaseexport __xenmem_reservation_va_mapping_updateexport __xenmem_reservation_va_mapping_resetexport xenmem_reservation_increaseexport xenmem_reservation_decrease
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/******************************************************************************
* Xen memory reservation utilities.
*
* Copyright (c) 2003, B Dragovic
* Copyright (c) 2003-2004, M Williamson, K Fraser
* Copyright (c) 2005 Dan M. Smith, IBM Corporation
* Copyright (c) 2010 Daniel Kiper
* Copyright (c) 2018 Oleksandr Andrushchenko, EPAM Systems Inc.
*/
#include <asm/xen/hypercall.h>
#include <xen/interface/memory.h>
#include <xen/mem-reservation.h>
#include <linux/moduleparam.h>
bool __read_mostly xen_scrub_pages = IS_ENABLED(CONFIG_XEN_SCRUB_PAGES_DEFAULT);
core_param(xen_scrub_pages, xen_scrub_pages, bool, 0);
/*
* Use one extent per PAGE_SIZE to avoid to break down the page into
* multiple frame.
*/
#define EXTENT_ORDER (fls(XEN_PFN_PER_PAGE) - 1)
#ifdef CONFIG_XEN_HAVE_PVMMU
void __xenmem_reservation_va_mapping_update(unsigned long count,
struct page **pages,
xen_pfn_t *frames)
{
int i;
for (i = 0; i < count; i++) {
struct page *page = pages[i];
unsigned long pfn = page_to_pfn(page);
int ret;
BUG_ON(!page);
/*
* We don't support PV MMU when Linux and Xen is using
* different page granularity.
*/
BUILD_BUG_ON(XEN_PAGE_SIZE != PAGE_SIZE);
set_phys_to_machine(pfn, frames[i]);
ret = HYPERVISOR_update_va_mapping(
(unsigned long)__va(pfn << PAGE_SHIFT),
mfn_pte(frames[i], PAGE_KERNEL), 0);
BUG_ON(ret);
}
}
EXPORT_SYMBOL_GPL(__xenmem_reservation_va_mapping_update);
void __xenmem_reservation_va_mapping_reset(unsigned long count,
struct page **pages)
{
int i;
for (i = 0; i < count; i++) {
struct page *page = pages[i];
unsigned long pfn = page_to_pfn(page);
int ret;
/*
* We don't support PV MMU when Linux and Xen are using
* different page granularity.
*/
BUILD_BUG_ON(XEN_PAGE_SIZE != PAGE_SIZE);
ret = HYPERVISOR_update_va_mapping(
(unsigned long)__va(pfn << PAGE_SHIFT),
__pte_ma(0), 0);
BUG_ON(ret);
__set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
}
}
EXPORT_SYMBOL_GPL(__xenmem_reservation_va_mapping_reset);
#endif /* CONFIG_XEN_HAVE_PVMMU */
/* @frames is an array of PFNs */
int xenmem_reservation_increase(int count, xen_pfn_t *frames)
{
struct xen_memory_reservation reservation = {
.address_bits = 0,
.extent_order = EXTENT_ORDER,
Annotation
- Immediate include surface: `asm/xen/hypercall.h`, `xen/interface/memory.h`, `xen/mem-reservation.h`, `linux/moduleparam.h`.
- Detected declarations: `function __xenmem_reservation_va_mapping_update`, `function __xenmem_reservation_va_mapping_reset`, `function xenmem_reservation_increase`, `function xenmem_reservation_decrease`, `export __xenmem_reservation_va_mapping_update`, `export __xenmem_reservation_va_mapping_reset`, `export xenmem_reservation_increase`, `export xenmem_reservation_decrease`.
- Atlas domain: Driver Families / drivers/xen.
- Implementation status: integration implementation candidate.
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.