arch/x86/xen/enlighten_pvh.c

Source file repositories/reference/linux-study-clean/arch/x86/xen/enlighten_pvh.c

File Facts

System
Linux kernel
Corpus path
arch/x86/xen/enlighten_pvh.c
Extension
.c
Size
5067 bytes
Lines
186
Domain
Architecture Layer
Bucket
arch/x86
Inferred role
Architecture Layer: exported/initcall integration point
Status
integration 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.

Dependency Surface

Detected Declarations

Annotated Snippet

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);
	}
}

static void __init pvh_arch_setup(void)
{
	pvh_reserve_extra_memory();

	if (xen_initial_domain()) {
		xen_add_preferred_consoles();

		/*
		 * Disable usage of CPU idle and frequency drivers: when
		 * running as hardware domain the exposed native ACPI tables
		 * causes idle and/or frequency drivers to attach and
		 * malfunction.  It's Xen the entity that controls the idle and
		 * frequency states.
		 *
		 * For unprivileged domains the exposed ACPI tables are
		 * fabricated and don't contain such data.
		 */
		disable_cpuidle();
		disable_cpufreq();
		WARN_ON(xen_set_default_idle());
	}
}

void __init xen_pvh_init(struct boot_params *boot_params)
{
	xen_pvh = 1;
	xen_domain_type = XEN_HVM_DOMAIN;
	xen_start_flags = pvh_start_info.flags;

	x86_init.oem.arch_setup = pvh_arch_setup;
	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;
}

Annotation

Implementation Notes