xref: /kvmtool/x86/kvm.c (revision 8f46c736eae508f0973d41618db17cced6b5796c)
1af7b0868SMatt Evans #include "kvm/kvm.h"
2af7b0868SMatt Evans #include "kvm/boot-protocol.h"
3af7b0868SMatt Evans #include "kvm/cpufeature.h"
4af7b0868SMatt Evans #include "kvm/interrupt.h"
5af7b0868SMatt Evans #include "kvm/mptable.h"
6af7b0868SMatt Evans #include "kvm/util.h"
70b69bdefSMatt Evans #include "kvm/8250-serial.h"
80b69bdefSMatt Evans #include "kvm/virtio-console.h"
9af7b0868SMatt Evans 
10af7b0868SMatt Evans #include <asm/bootparam.h>
11af7b0868SMatt Evans #include <linux/kvm.h>
1273f00e73SAndre Przywara #include <linux/kernel.h>
13af7b0868SMatt Evans 
14af7b0868SMatt Evans #include <sys/types.h>
15af7b0868SMatt Evans #include <sys/ioctl.h>
16af7b0868SMatt Evans #include <sys/mman.h>
17af7b0868SMatt Evans #include <sys/stat.h>
18af7b0868SMatt Evans #include <stdbool.h>
19af7b0868SMatt Evans #include <stdlib.h>
20af7b0868SMatt Evans #include <string.h>
21af7b0868SMatt Evans #include <unistd.h>
22af7b0868SMatt Evans #include <stdio.h>
23af7b0868SMatt Evans #include <fcntl.h>
24af7b0868SMatt Evans 
25af7b0868SMatt Evans struct kvm_ext kvm_req_ext[] = {
26af7b0868SMatt Evans 	{ DEFINE_KVM_EXT(KVM_CAP_COALESCED_MMIO) },
27af7b0868SMatt Evans 	{ DEFINE_KVM_EXT(KVM_CAP_SET_TSS_ADDR) },
28af7b0868SMatt Evans 	{ DEFINE_KVM_EXT(KVM_CAP_PIT2) },
29af7b0868SMatt Evans 	{ DEFINE_KVM_EXT(KVM_CAP_USER_MEMORY) },
30af7b0868SMatt Evans 	{ DEFINE_KVM_EXT(KVM_CAP_IRQ_ROUTING) },
31af7b0868SMatt Evans 	{ DEFINE_KVM_EXT(KVM_CAP_IRQCHIP) },
32af7b0868SMatt Evans 	{ DEFINE_KVM_EXT(KVM_CAP_HLT) },
33af7b0868SMatt Evans 	{ DEFINE_KVM_EXT(KVM_CAP_IRQ_INJECT_STATUS) },
34af7b0868SMatt Evans 	{ DEFINE_KVM_EXT(KVM_CAP_EXT_CPUID) },
35af7b0868SMatt Evans 	{ 0, 0 }
36af7b0868SMatt Evans };
37af7b0868SMatt Evans 
38af7b0868SMatt Evans bool kvm__arch_cpu_supports_vm(void)
39af7b0868SMatt Evans {
40af7b0868SMatt Evans 	struct cpuid_regs regs;
41af7b0868SMatt Evans 	u32 eax_base;
42af7b0868SMatt Evans 	int feature;
43af7b0868SMatt Evans 
44af7b0868SMatt Evans 	regs	= (struct cpuid_regs) {
45af7b0868SMatt Evans 		.eax		= 0x00,
46af7b0868SMatt Evans 	};
47af7b0868SMatt Evans 	host_cpuid(&regs);
48af7b0868SMatt Evans 
49af7b0868SMatt Evans 	switch (regs.ebx) {
50af7b0868SMatt Evans 	case CPUID_VENDOR_INTEL_1:
51af7b0868SMatt Evans 		eax_base	= 0x00;
52af7b0868SMatt Evans 		feature		= KVM__X86_FEATURE_VMX;
53af7b0868SMatt Evans 		break;
54af7b0868SMatt Evans 
55af7b0868SMatt Evans 	case CPUID_VENDOR_AMD_1:
56af7b0868SMatt Evans 		eax_base	= 0x80000000;
57af7b0868SMatt Evans 		feature		= KVM__X86_FEATURE_SVM;
58af7b0868SMatt Evans 		break;
59af7b0868SMatt Evans 
60af7b0868SMatt Evans 	default:
61af7b0868SMatt Evans 		return false;
62af7b0868SMatt Evans 	}
63af7b0868SMatt Evans 
64af7b0868SMatt Evans 	regs	= (struct cpuid_regs) {
65af7b0868SMatt Evans 		.eax		= eax_base,
66af7b0868SMatt Evans 	};
67af7b0868SMatt Evans 	host_cpuid(&regs);
68af7b0868SMatt Evans 
69af7b0868SMatt Evans 	if (regs.eax < eax_base + 0x01)
70af7b0868SMatt Evans 		return false;
71af7b0868SMatt Evans 
72af7b0868SMatt Evans 	regs	= (struct cpuid_regs) {
73af7b0868SMatt Evans 		.eax		= eax_base + 0x01
74af7b0868SMatt Evans 	};
75af7b0868SMatt Evans 	host_cpuid(&regs);
76af7b0868SMatt Evans 
77af7b0868SMatt Evans 	return regs.ecx & (1 << feature);
78af7b0868SMatt Evans }
79af7b0868SMatt Evans 
80af7b0868SMatt Evans /*
81af7b0868SMatt Evans  * Allocating RAM size bigger than 4GB requires us to leave a gap
82af7b0868SMatt Evans  * in the RAM which is used for PCI MMIO, hotplug, and unconfigured
83af7b0868SMatt Evans  * devices (see documentation of e820_setup_gap() for details).
84af7b0868SMatt Evans  *
85af7b0868SMatt Evans  * If we're required to initialize RAM bigger than 4GB, we will create
86af7b0868SMatt Evans  * a gap between 0xe0000000 and 0x100000000 in the guest virtual mem space.
87af7b0868SMatt Evans  */
88af7b0868SMatt Evans 
89af7b0868SMatt Evans void kvm__init_ram(struct kvm *kvm)
90af7b0868SMatt Evans {
91af7b0868SMatt Evans 	u64	phys_start, phys_size;
92af7b0868SMatt Evans 	void	*host_mem;
93af7b0868SMatt Evans 
94af7b0868SMatt Evans 	if (kvm->ram_size < KVM_32BIT_GAP_START) {
95af7b0868SMatt Evans 		/* Use a single block of RAM for 32bit RAM */
96af7b0868SMatt Evans 
97af7b0868SMatt Evans 		phys_start = 0;
98af7b0868SMatt Evans 		phys_size  = kvm->ram_size;
99af7b0868SMatt Evans 		host_mem   = kvm->ram_start;
100af7b0868SMatt Evans 
101*8f46c736SJean-Philippe Brucker 		kvm__register_ram(kvm, phys_start, phys_size, host_mem);
102af7b0868SMatt Evans 	} else {
103af7b0868SMatt Evans 		/* First RAM range from zero to the PCI gap: */
104af7b0868SMatt Evans 
105af7b0868SMatt Evans 		phys_start = 0;
106af7b0868SMatt Evans 		phys_size  = KVM_32BIT_GAP_START;
107af7b0868SMatt Evans 		host_mem   = kvm->ram_start;
108af7b0868SMatt Evans 
109*8f46c736SJean-Philippe Brucker 		kvm__register_ram(kvm, phys_start, phys_size, host_mem);
110af7b0868SMatt Evans 
111af7b0868SMatt Evans 		/* Second RAM range from 4GB to the end of RAM: */
112af7b0868SMatt Evans 
113f7abc4cdSHongyong Zang 		phys_start = KVM_32BIT_MAX_MEM_SIZE;
114f7abc4cdSHongyong Zang 		phys_size  = kvm->ram_size - phys_start;
115af7b0868SMatt Evans 		host_mem   = kvm->ram_start + phys_start;
116af7b0868SMatt Evans 
117*8f46c736SJean-Philippe Brucker 		kvm__register_ram(kvm, phys_start, phys_size, host_mem);
118af7b0868SMatt Evans 	}
119af7b0868SMatt Evans }
120af7b0868SMatt Evans 
1218e704a7aSMatt Evans /* Arch-specific commandline setup */
1228e704a7aSMatt Evans void kvm__arch_set_cmdline(char *cmdline, bool video)
1238e704a7aSMatt Evans {
1248e704a7aSMatt Evans 	strcpy(cmdline, "noapic noacpi pci=conf1 reboot=k panic=1 i8042.direct=1 "
1258e704a7aSMatt Evans 				"i8042.dumbkbd=1 i8042.nopnp=1");
1263a60be06SSasha Levin 	if (video)
1275857730cSWill Deacon 		strcat(cmdline, " video=vesafb");
1283a60be06SSasha Levin 	else
1295857730cSWill Deacon 		strcat(cmdline, " earlyprintk=serial i8042.noaux=1");
1308e704a7aSMatt Evans }
1318e704a7aSMatt Evans 
132af7b0868SMatt Evans /* Architecture-specific KVM init */
1337eff9f49SWanlong Gao void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)
134af7b0868SMatt Evans {
135af7b0868SMatt Evans 	struct kvm_pit_config pit_config = { .flags = 0, };
136af7b0868SMatt Evans 	int ret;
137af7b0868SMatt Evans 
138af7b0868SMatt Evans 	ret = ioctl(kvm->vm_fd, KVM_SET_TSS_ADDR, 0xfffbd000);
139af7b0868SMatt Evans 	if (ret < 0)
140af7b0868SMatt Evans 		die_perror("KVM_SET_TSS_ADDR ioctl");
141af7b0868SMatt Evans 
142af7b0868SMatt Evans 	ret = ioctl(kvm->vm_fd, KVM_CREATE_PIT2, &pit_config);
143af7b0868SMatt Evans 	if (ret < 0)
144af7b0868SMatt Evans 		die_perror("KVM_CREATE_PIT2 ioctl");
145af7b0868SMatt Evans 
146f7abc4cdSHongyong Zang 	if (ram_size < KVM_32BIT_GAP_START) {
147af7b0868SMatt Evans 		kvm->ram_size = ram_size;
1483ebd8e0bSMichael Ellerman 		kvm->ram_start = mmap_anon_or_hugetlbfs(kvm, hugetlbfs_path, ram_size);
149af7b0868SMatt Evans 	} else {
1503ebd8e0bSMichael Ellerman 		kvm->ram_start = mmap_anon_or_hugetlbfs(kvm, hugetlbfs_path, ram_size + KVM_32BIT_GAP_SIZE);
151f7abc4cdSHongyong Zang 		kvm->ram_size = ram_size + KVM_32BIT_GAP_SIZE;
1523a60be06SSasha Levin 		if (kvm->ram_start != MAP_FAILED)
153af7b0868SMatt Evans 			/*
154af7b0868SMatt Evans 			 * We mprotect the gap (see kvm__init_ram() for details) PROT_NONE so that
155af7b0868SMatt Evans 			 * if we accidently write to it, we will know.
156af7b0868SMatt Evans 			 */
157af7b0868SMatt Evans 			mprotect(kvm->ram_start + KVM_32BIT_GAP_START, KVM_32BIT_GAP_SIZE, PROT_NONE);
158af7b0868SMatt Evans 	}
159af7b0868SMatt Evans 	if (kvm->ram_start == MAP_FAILED)
160af7b0868SMatt Evans 		die("out of memory");
161af7b0868SMatt Evans 
162af7b0868SMatt Evans 	madvise(kvm->ram_start, kvm->ram_size, MADV_MERGEABLE);
163af7b0868SMatt Evans 
164af7b0868SMatt Evans 	ret = ioctl(kvm->vm_fd, KVM_CREATE_IRQCHIP);
165af7b0868SMatt Evans 	if (ret < 0)
166af7b0868SMatt Evans 		die_perror("KVM_CREATE_IRQCHIP ioctl");
167af7b0868SMatt Evans }
168af7b0868SMatt Evans 
169e56e2de7SLai Jiangshan void kvm__arch_delete_ram(struct kvm *kvm)
170e56e2de7SLai Jiangshan {
171e56e2de7SLai Jiangshan 	munmap(kvm->ram_start, kvm->ram_size);
172e56e2de7SLai Jiangshan }
173e56e2de7SLai Jiangshan 
174af7b0868SMatt Evans void kvm__irq_line(struct kvm *kvm, int irq, int level)
175af7b0868SMatt Evans {
176af7b0868SMatt Evans 	struct kvm_irq_level irq_level;
177af7b0868SMatt Evans 
178af7b0868SMatt Evans 	irq_level	= (struct kvm_irq_level) {
179af7b0868SMatt Evans 		{
180af7b0868SMatt Evans 			.irq		= irq,
181af7b0868SMatt Evans 		},
182af7b0868SMatt Evans 		.level		= level,
183af7b0868SMatt Evans 	};
184af7b0868SMatt Evans 
185af7b0868SMatt Evans 	if (ioctl(kvm->vm_fd, KVM_IRQ_LINE, &irq_level) < 0)
186af7b0868SMatt Evans 		die_perror("KVM_IRQ_LINE failed");
187af7b0868SMatt Evans }
188af7b0868SMatt Evans 
189af7b0868SMatt Evans void kvm__irq_trigger(struct kvm *kvm, int irq)
190af7b0868SMatt Evans {
191af7b0868SMatt Evans 	kvm__irq_line(kvm, irq, 1);
192af7b0868SMatt Evans 	kvm__irq_line(kvm, irq, 0);
193af7b0868SMatt Evans }
194af7b0868SMatt Evans 
195af7b0868SMatt Evans #define BOOT_LOADER_SELECTOR	0x1000
196af7b0868SMatt Evans #define BOOT_LOADER_IP		0x0000
197af7b0868SMatt Evans #define BOOT_LOADER_SP		0x8000
198af7b0868SMatt Evans #define BOOT_CMDLINE_OFFSET	0x20000
199af7b0868SMatt Evans 
200af7b0868SMatt Evans #define BOOT_PROTOCOL_REQUIRED	0x206
201af7b0868SMatt Evans #define LOAD_HIGH		0x01
202af7b0868SMatt Evans 
203f412251fSWill Deacon static inline void *guest_real_to_host(struct kvm *kvm, u16 selector, u16 offset)
204f412251fSWill Deacon {
2051cbb2c50SAndre Przywara 	unsigned long flat = ((u32)selector << 4) + offset;
206f412251fSWill Deacon 
207f412251fSWill Deacon 	return guest_flat_to_host(kvm, flat);
208f412251fSWill Deacon }
209f412251fSWill Deacon 
210004f7684SAndre Przywara static bool load_flat_binary(struct kvm *kvm, int fd_kernel)
211af7b0868SMatt Evans {
212af7b0868SMatt Evans 	void *p;
213af7b0868SMatt Evans 
214604dbd63SMatt Evans 	if (lseek(fd_kernel, 0, SEEK_SET) < 0)
215af7b0868SMatt Evans 		die_perror("lseek");
216af7b0868SMatt Evans 
217af7b0868SMatt Evans 	p = guest_real_to_host(kvm, BOOT_LOADER_SELECTOR, BOOT_LOADER_IP);
218af7b0868SMatt Evans 
21973f00e73SAndre Przywara 	if (read_file(fd_kernel, p, kvm->cfg.ram_size) < 0)
22073f00e73SAndre Przywara 		die_perror("read");
221af7b0868SMatt Evans 
22242ac24f9SSasha Levin 	kvm->arch.boot_selector	= BOOT_LOADER_SELECTOR;
22342ac24f9SSasha Levin 	kvm->arch.boot_ip	= BOOT_LOADER_IP;
22442ac24f9SSasha Levin 	kvm->arch.boot_sp	= BOOT_LOADER_SP;
225af7b0868SMatt Evans 
226af7b0868SMatt Evans 	return true;
227af7b0868SMatt Evans }
228af7b0868SMatt Evans 
229af7b0868SMatt Evans static const char *BZIMAGE_MAGIC = "HdrS";
230af7b0868SMatt Evans 
231004f7684SAndre Przywara static bool load_bzimage(struct kvm *kvm, int fd_kernel, int fd_initrd,
232ff7ba6faSWill Deacon 			 const char *kernel_cmdline)
233af7b0868SMatt Evans {
234af7b0868SMatt Evans 	struct boot_params *kern_boot;
235af7b0868SMatt Evans 	struct boot_params boot;
236af7b0868SMatt Evans 	size_t cmdline_size;
23773f00e73SAndre Przywara 	ssize_t file_size;
238af7b0868SMatt Evans 	void *p;
239ff7ba6faSWill Deacon 	u16 vidmode;
240af7b0868SMatt Evans 
241af7b0868SMatt Evans 	/*
242af7b0868SMatt Evans 	 * See Documentation/x86/boot.txt for details no bzImage on-disk and
243af7b0868SMatt Evans 	 * memory layout.
244af7b0868SMatt Evans 	 */
245af7b0868SMatt Evans 
24673f00e73SAndre Przywara 	if (read_in_full(fd_kernel, &boot, sizeof(boot)) != sizeof(boot))
247af7b0868SMatt Evans 		return false;
248af7b0868SMatt Evans 
249af7b0868SMatt Evans 	if (memcmp(&boot.hdr.header, BZIMAGE_MAGIC, strlen(BZIMAGE_MAGIC)))
250af7b0868SMatt Evans 		return false;
251af7b0868SMatt Evans 
252af7b0868SMatt Evans 	if (boot.hdr.version < BOOT_PROTOCOL_REQUIRED)
253af7b0868SMatt Evans 		die("Too old kernel");
254af7b0868SMatt Evans 
255af7b0868SMatt Evans 	if (lseek(fd_kernel, 0, SEEK_SET) < 0)
256af7b0868SMatt Evans 		die_perror("lseek");
257af7b0868SMatt Evans 
258af7b0868SMatt Evans 	if (!boot.hdr.setup_sects)
259af7b0868SMatt Evans 		boot.hdr.setup_sects = BZ_DEFAULT_SETUP_SECTS;
26073f00e73SAndre Przywara 	file_size = (boot.hdr.setup_sects + 1) << 9;
261af7b0868SMatt Evans 	p = guest_real_to_host(kvm, BOOT_LOADER_SELECTOR, BOOT_LOADER_IP);
26273f00e73SAndre Przywara 	if (read_in_full(fd_kernel, p, file_size) != file_size)
26373f00e73SAndre Przywara 		die_perror("kernel setup read");
264af7b0868SMatt Evans 
26573f00e73SAndre Przywara 	/* read actual kernel image (vmlinux.bin) to BZ_KERNEL_START */
266af7b0868SMatt Evans 	p = guest_flat_to_host(kvm, BZ_KERNEL_START);
26773f00e73SAndre Przywara 	file_size = read_file(fd_kernel, p,
26873f00e73SAndre Przywara 			      kvm->cfg.ram_size - BZ_KERNEL_START);
26973f00e73SAndre Przywara 	if (file_size < 0)
27073f00e73SAndre Przywara 		die_perror("kernel read");
271af7b0868SMatt Evans 
272af7b0868SMatt Evans 	p = guest_flat_to_host(kvm, BOOT_CMDLINE_OFFSET);
273af7b0868SMatt Evans 	if (kernel_cmdline) {
274af7b0868SMatt Evans 		cmdline_size = strlen(kernel_cmdline) + 1;
275af7b0868SMatt Evans 		if (cmdline_size > boot.hdr.cmdline_size)
276af7b0868SMatt Evans 			cmdline_size = boot.hdr.cmdline_size;
277af7b0868SMatt Evans 
278af7b0868SMatt Evans 		memset(p, 0, boot.hdr.cmdline_size);
279af7b0868SMatt Evans 		memcpy(p, kernel_cmdline, cmdline_size - 1);
280af7b0868SMatt Evans 	}
281af7b0868SMatt Evans 
282ff7ba6faSWill Deacon 	/* vidmode should be either specified or set by default */
2837bcceb95SPekka Enberg 	if (kvm->cfg.vnc || kvm->cfg.sdl || kvm->cfg.gtk) {
2846ad7171aSAsias He 		if (!kvm->cfg.arch.vidmode)
285ff7ba6faSWill Deacon 			vidmode = 0x312;
2866ad7171aSAsias He 		else
2876ad7171aSAsias He 			vidmode = kvm->cfg.arch.vidmode;
288ff7ba6faSWill Deacon 	} else {
289ff7ba6faSWill Deacon 		vidmode = 0;
290ff7ba6faSWill Deacon 	}
291ff7ba6faSWill Deacon 
292af7b0868SMatt Evans 	kern_boot	= guest_real_to_host(kvm, BOOT_LOADER_SELECTOR, 0x00);
293af7b0868SMatt Evans 
294af7b0868SMatt Evans 	kern_boot->hdr.cmd_line_ptr	= BOOT_CMDLINE_OFFSET;
295af7b0868SMatt Evans 	kern_boot->hdr.type_of_loader	= 0xff;
296af7b0868SMatt Evans 	kern_boot->hdr.heap_end_ptr	= 0xfe00;
297af7b0868SMatt Evans 	kern_boot->hdr.loadflags	|= CAN_USE_HEAP;
298af7b0868SMatt Evans 	kern_boot->hdr.vid_mode		= vidmode;
299af7b0868SMatt Evans 
300af7b0868SMatt Evans 	/*
301af7b0868SMatt Evans 	 * Read initrd image into guest memory
302af7b0868SMatt Evans 	 */
303af7b0868SMatt Evans 	if (fd_initrd >= 0) {
304af7b0868SMatt Evans 		struct stat initrd_stat;
305af7b0868SMatt Evans 		unsigned long addr;
306af7b0868SMatt Evans 
307af7b0868SMatt Evans 		if (fstat(fd_initrd, &initrd_stat))
308af7b0868SMatt Evans 			die_perror("fstat");
309af7b0868SMatt Evans 
310af7b0868SMatt Evans 		addr = boot.hdr.initrd_addr_max & ~0xfffff;
311af7b0868SMatt Evans 		for (;;) {
312af7b0868SMatt Evans 			if (addr < BZ_KERNEL_START)
313af7b0868SMatt Evans 				die("Not enough memory for initrd");
314af7b0868SMatt Evans 			else if (addr < (kvm->ram_size - initrd_stat.st_size))
315af7b0868SMatt Evans 				break;
316af7b0868SMatt Evans 			addr -= 0x100000;
317af7b0868SMatt Evans 		}
318af7b0868SMatt Evans 
319af7b0868SMatt Evans 		p = guest_flat_to_host(kvm, addr);
32073f00e73SAndre Przywara 		if (read_in_full(fd_initrd, p, initrd_stat.st_size) < 0)
321af7b0868SMatt Evans 			die("Failed to read initrd");
322af7b0868SMatt Evans 
323af7b0868SMatt Evans 		kern_boot->hdr.ramdisk_image	= addr;
324af7b0868SMatt Evans 		kern_boot->hdr.ramdisk_size	= initrd_stat.st_size;
325af7b0868SMatt Evans 	}
326af7b0868SMatt Evans 
32742ac24f9SSasha Levin 	kvm->arch.boot_selector = BOOT_LOADER_SELECTOR;
328af7b0868SMatt Evans 	/*
329af7b0868SMatt Evans 	 * The real-mode setup code starts at offset 0x200 of a bzImage. See
330af7b0868SMatt Evans 	 * Documentation/x86/boot.txt for details.
331af7b0868SMatt Evans 	 */
33242ac24f9SSasha Levin 	kvm->arch.boot_ip = BOOT_LOADER_IP + 0x200;
33342ac24f9SSasha Levin 	kvm->arch.boot_sp = BOOT_LOADER_SP;
334af7b0868SMatt Evans 
335af7b0868SMatt Evans 	return true;
336af7b0868SMatt Evans }
337af7b0868SMatt Evans 
338004f7684SAndre Przywara bool kvm__arch_load_kernel_image(struct kvm *kvm, int fd_kernel, int fd_initrd,
339004f7684SAndre Przywara 				 const char *kernel_cmdline)
340004f7684SAndre Przywara {
341004f7684SAndre Przywara 	if (load_bzimage(kvm, fd_kernel, fd_initrd, kernel_cmdline))
342004f7684SAndre Przywara 		return true;
343004f7684SAndre Przywara 	pr_warning("Kernel image is not a bzImage.");
344004f7684SAndre Przywara 	pr_warning("Trying to load it as a flat binary (no cmdline support)");
345004f7684SAndre Przywara 
346004f7684SAndre Przywara 	if (fd_initrd != -1)
347004f7684SAndre Przywara 		pr_warning("Loading initrd with flat binary not supported.");
348004f7684SAndre Przywara 
349004f7684SAndre Przywara 	return load_flat_binary(kvm, fd_kernel);
350004f7684SAndre Przywara }
351004f7684SAndre Przywara 
352af7b0868SMatt Evans /**
353af7b0868SMatt Evans  * kvm__arch_setup_firmware - inject BIOS into guest system memory
354af7b0868SMatt Evans  * @kvm - guest system descriptor
355af7b0868SMatt Evans  *
356af7b0868SMatt Evans  * This function is a main routine where we poke guest memory
357af7b0868SMatt Evans  * and install BIOS there.
358af7b0868SMatt Evans  */
359f7f9d02bSCyrill Gorcunov int kvm__arch_setup_firmware(struct kvm *kvm)
360af7b0868SMatt Evans {
361af7b0868SMatt Evans 	/* standart minimal configuration */
362af7b0868SMatt Evans 	setup_bios(kvm);
363af7b0868SMatt Evans 
364af7b0868SMatt Evans 	/* FIXME: SMP, ACPI and friends here */
365af7b0868SMatt Evans 
3663d34111eSSasha Levin 	return 0;
3671add9f73SSasha Levin }
3681add9f73SSasha Levin 
3691add9f73SSasha Levin int kvm__arch_free_firmware(struct kvm *kvm)
3701add9f73SSasha Levin {
3713d34111eSSasha Levin 	return 0;
372af7b0868SMatt Evans }
3730b69bdefSMatt Evans 
37412c406a8SJonathan Austin void kvm__arch_read_term(struct kvm *kvm)
3750b69bdefSMatt Evans {
376f6b8ccc1SThomas Gleixner 	serial8250__update_consoles(kvm);
3770b69bdefSMatt Evans 	virtio_console__inject_interrupt(kvm);
3780b69bdefSMatt Evans }
379