arch/riscv/kernel/vdso.c
Source file repositories/reference/linux-study-clean/arch/riscv/kernel/vdso.c
File Facts
- System
- Linux kernel
- Corpus path
arch/riscv/kernel/vdso.c- Extension
.c- Size
- 4344 bytes
- Lines
- 188
- Domain
- Architecture Layer
- Bucket
- arch/riscv
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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/elf.hlinux/mm.hlinux/slab.hlinux/binfmts.hlinux/err.hasm/page.hasm/vdso.hlinux/vdso_datastore.hvdso/datapage.hvdso/vsyscall.h
Detected Declarations
struct __vdso_infofunction vdso_mremapfunction __vdso_initfunction vdso_initfunction __setup_additional_pagesfunction compat_arch_setup_additional_pagesfunction arch_setup_additional_pages
Annotated Snippet
struct __vdso_info {
const char *name;
const char *vdso_code_start;
const char *vdso_code_end;
unsigned long vdso_pages;
/* Code Mapping */
struct vm_special_mapping *cm;
};
static struct __vdso_info vdso_info;
#ifdef CONFIG_COMPAT
static struct __vdso_info compat_vdso_info;
#endif
static int vdso_mremap(const struct vm_special_mapping *sm,
struct vm_area_struct *new_vma)
{
current->mm->context.vdso = (void *)new_vma->vm_start;
return 0;
}
static void __init __vdso_init(struct __vdso_info *vdso_info)
{
unsigned int i;
struct page **vdso_pagelist;
unsigned long pfn;
if (memcmp(vdso_info->vdso_code_start, "\177ELF", 4))
panic("vDSO is not a valid ELF object!\n");
vdso_info->vdso_pages = (
vdso_info->vdso_code_end -
vdso_info->vdso_code_start) >>
PAGE_SHIFT;
vdso_pagelist = kzalloc_objs(struct page *, vdso_info->vdso_pages);
if (vdso_pagelist == NULL)
panic("vDSO kcalloc failed!\n");
/* Grab the vDSO code pages. */
pfn = sym_to_pfn(vdso_info->vdso_code_start);
for (i = 0; i < vdso_info->vdso_pages; i++)
vdso_pagelist[i] = pfn_to_page(pfn + i);
vdso_info->cm->pages = vdso_pagelist;
}
static struct vm_special_mapping rv_vdso_map __ro_after_init = {
.name = "[vdso]",
.mremap = vdso_mremap,
};
static struct __vdso_info vdso_info __ro_after_init = {
.name = "vdso",
.vdso_code_start = vdso_start,
.vdso_code_end = vdso_end,
.cm = &rv_vdso_map,
};
#ifdef CONFIG_COMPAT
static struct vm_special_mapping rv_compat_vdso_map __ro_after_init = {
.name = "[vdso]",
.mremap = vdso_mremap,
};
static struct __vdso_info compat_vdso_info __ro_after_init = {
.name = "compat_vdso",
.vdso_code_start = compat_vdso_start,
.vdso_code_end = compat_vdso_end,
.cm = &rv_compat_vdso_map,
};
#endif
static int __init vdso_init(void)
{
/* Hart implements zimop, expose cfi compiled vdso */
if (IS_ENABLED(CONFIG_RISCV_USER_CFI) &&
riscv_has_extension_unlikely(RISCV_ISA_EXT_ZIMOP)) {
vdso_info.vdso_code_start = vdso_cfi_start;
vdso_info.vdso_code_end = vdso_cfi_end;
}
__vdso_init(&vdso_info);
#ifdef CONFIG_COMPAT
__vdso_init(&compat_vdso_info);
#endif
return 0;
Annotation
- Immediate include surface: `linux/elf.h`, `linux/mm.h`, `linux/slab.h`, `linux/binfmts.h`, `linux/err.h`, `asm/page.h`, `asm/vdso.h`, `linux/vdso_datastore.h`.
- Detected declarations: `struct __vdso_info`, `function vdso_mremap`, `function __vdso_init`, `function vdso_init`, `function __setup_additional_pages`, `function compat_arch_setup_additional_pages`, `function arch_setup_additional_pages`.
- Atlas domain: Architecture Layer / arch/riscv.
- Implementation status: source 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.