Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
1
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
38620fc
Documentation
LICENSES
arch
alpha
arc
arm
arm64
csky
hexagon
loongarch
m68k
microblaze
mips
nios2
openrisc
parisc
powerpc
riscv
s390
sh
sparc
um
x86
boot
coco
configs
crypto
entry
events
hyperv
ia32
include
kernel
kvm
lib
math-emu
mm
net
pci
platform
power
purgatory
ras
realmode
tools
um
video
virt
xen
Kconfig
Makefile
apic.c
debugfs.c
debugfs.h
efi.c
enlighten.c
enlighten_hvm.c
enlighten_pv.c
enlighten_pvh.c
grant-table.c
irq.c
mmu.c
mmu.h
mmu_hvm.c
mmu_pv.c
multicalls.c
multicalls.h
p2m.c
platform-pci-unplug.c
pmu.c
pmu.h
setup.c
smp.c
smp.h
smp_hvm.c
smp_pv.c
spinlock.c
suspend.c
suspend_hvm.c
suspend_pv.c
time.c
trace.c
vga.c
xen-asm.S
xen-head.S
xen-ops.h
.gitignore
Kbuild
Kconfig
Kconfig.assembler
Kconfig.cpu
Kconfig.debug
Makefile
Makefile.postlink
Makefile.um
Makefile_32.cpu
xtensa
.gitignore
Kconfig
block
certs
crypto
drivers
fs
include
init
io_uring
ipc
kernel
lib
mm
net
rust
samples
scripts
security
sound
tools
usr
virt
.clang-format
.cocciconfig
.editorconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
.rustfmt.toml
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
arch
/
x86
/
xen
/
enlighten_pvh.c
Blame
Blame
Latest commit
History
History
142 lines (116 loc) · 3.83 KB
Breadcrumbs
linux
/
arch
/
x86
/
xen
/
enlighten_pvh.c
Top
File metadata and controls
Code
Blame
142 lines (116 loc) · 3.83 KB
Raw
// SPDX-License-Identifier: GPL-2.0 #include <linux/acpi.h> #include <linux/export.h> #include <linux/mm.h> #include <xen/hvc-console.h> #include <asm/io_apic.h> #include <asm/hypervisor.h> #include <asm/e820/api.h> #include <xen/xen.h> #include <asm/xen/interface.h> #include <asm/xen/hypercall.h> #include <xen/interface/memory.h> #include "xen-ops.h" /* * PVH variables. * * The variable xen_pvh needs to live in a data segment since it is used * after startup_{32|64} is invoked, which will clear the .bss segment. */ bool __ro_after_init xen_pvh; EXPORT_SYMBOL_GPL(xen_pvh); void __init xen_pvh_init(struct boot_params *boot_params) { u32 msr; u64 pfn; xen_pvh = 1; xen_domain_type = XEN_HVM_DOMAIN; xen_start_flags = pvh_start_info.flags; msr = cpuid_ebx(xen_cpuid_base() + 2); pfn = __pa(hypercall_page); wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32)); if (xen_initial_domain()) x86_init.oem.arch_setup = xen_add_preferred_consoles; x86_init.oem.banner = xen_banner; xen_efi_init(boot_params); if (xen_initial_domain()) { struct xen_platform_op op = { .cmd = XENPF_get_dom0_console, }; int ret = HYPERVISOR_platform_op(&op); if (ret > 0) xen_init_vga(&op.u.dom0_console, min(ret * sizeof(char), sizeof(op.u.dom0_console)), &boot_params->screen_info); } } void __init mem_map_via_hcall(struct boot_params *boot_params_p) { struct xen_memory_map memmap; int rc; memmap.nr_entries = ARRAY_SIZE(boot_params_p->e820_table); set_xen_guest_handle(memmap.buffer, boot_params_p->e820_table); rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap); if (rc) { xen_raw_printk("XENMEM_memory_map failed (%d)\n", rc); BUG(); } boot_params_p->e820_entries = memmap.nr_entries; } /* * Reserve e820 UNUSABLE regions to inflate the memory balloon. * * On PVH dom0 the host memory map is used, RAM regions available to dom0 are * located as the same place as in the native memory map, but since dom0 gets * less memory than the total amount of host RAM the ranges that can't be * populated are converted from RAM -> UNUSABLE. Use such regions (up to the * ratio signaled in EXTRA_MEM_RATIO) in order to inflate the balloon driver at * boot. Doing so prevents the guest (even if just temporary) from using holes * in the memory map in order to map grants or foreign addresses, and * hopefully limits the risk of a clash with a device MMIO region. Ideally the * hypervisor should notify us which memory ranges are suitable for creating * foreign mappings, but that's not yet implemented. */ void __init xen_reserve_extra_memory(struct boot_params *bootp) { unsigned int i, ram_pages = 0, extra_pages; for (i = 0; i < bootp->e820_entries; i++) { struct boot_e820_entry *e = &bootp->e820_table[i]; if (e->type != E820_TYPE_RAM) continue; ram_pages += PFN_DOWN(e->addr + e->size) - PFN_UP(e->addr); } /* Max amount of extra memory. */ extra_pages = EXTRA_MEM_RATIO * ram_pages; /* * Convert UNUSABLE ranges to RAM and reserve them for foreign mapping * purposes. */ for (i = 0; i < bootp->e820_entries && extra_pages; i++) { struct boot_e820_entry *e = &bootp->e820_table[i]; unsigned long pages; if (e->type != E820_TYPE_UNUSABLE) continue; pages = min(extra_pages, PFN_DOWN(e->addr + e->size) - PFN_UP(e->addr)); if (pages != (PFN_DOWN(e->addr + e->size) - PFN_UP(e->addr))) { struct boot_e820_entry *next; if (bootp->e820_entries == ARRAY_SIZE(bootp->e820_table)) /* No space left to split - skip region. */ continue; /* Split entry. */ next = e + 1; memmove(next, e, (bootp->e820_entries - i) * sizeof(*e)); bootp->e820_entries++; next->addr = PAGE_ALIGN(e->addr) + PFN_PHYS(pages); e->size = next->addr - e->addr; next->size -= e->size; } e->type = E820_TYPE_RAM; extra_pages -= pages; xen_add_extra_mem(PFN_UP(e->addr), pages); } }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
You can’t perform that action at this time.