2 * TPR optimization for 32-bit Windows guests (XP and Server 2003)
4 * Copyright (C) 2007-2008 Qumranet Technologies
5 * Copyright (C) 2012 Jan Kiszka, Siemens AG
7 * This work is licensed under the terms of the GNU GPL version 2, or
8 * (at your option) any later version. See the COPYING file in the
11 #include "sysemu/sysemu.h"
12 #include "sysemu/cpus.h"
13 #include "sysemu/kvm.h"
14 #include "hw/i386/apic_internal.h"
16 #define VAPIC_IO_PORT 0x7e
18 #define VAPIC_CPU_SHIFT 7
20 #define ROM_BLOCK_SIZE 512
21 #define ROM_BLOCK_MASK (~(ROM_BLOCK_SIZE - 1))
23 typedef enum VAPICMode
{
29 typedef struct VAPICHandlers
{
33 uint32_t get_tpr_stack
;
34 } QEMU_PACKED VAPICHandlers
;
36 typedef struct GuestROMState
{
44 uint32_t real_tpr_addr
;
47 } QEMU_PACKED GuestROMState
;
49 typedef struct VAPICROMState
{
54 uint32_t rom_state_paddr
;
55 uint32_t rom_state_vaddr
;
57 uint32_t real_tpr_addr
;
58 GuestROMState rom_state
;
60 bool rom_mapped_writable
;
63 #define TYPE_VAPIC "kvmvapic"
64 #define VAPIC(obj) OBJECT_CHECK(VAPICROMState, (obj), TYPE_VAPIC)
66 #define TPR_INSTR_ABS_MODRM 0x1
67 #define TPR_INSTR_MATCH_MODRM_REG 0x2
69 typedef struct TPRInstruction
{
78 /* must be sorted by length, shortest first */
79 static const TPRInstruction tpr_instr
[] = {
80 { /* mov abs to eax */
82 .access
= TPR_ACCESS_READ
,
86 { /* mov eax to abs */
88 .access
= TPR_ACCESS_WRITE
,
92 { /* mov r32 to r/m32 */
94 .flags
= TPR_INSTR_ABS_MODRM
,
95 .access
= TPR_ACCESS_WRITE
,
99 { /* mov r/m32 to r32 */
101 .flags
= TPR_INSTR_ABS_MODRM
,
102 .access
= TPR_ACCESS_READ
,
109 .flags
= TPR_INSTR_ABS_MODRM
| TPR_INSTR_MATCH_MODRM_REG
,
110 .access
= TPR_ACCESS_READ
,
114 { /* mov imm32, r/m32 (c7/0) */
117 .flags
= TPR_INSTR_ABS_MODRM
| TPR_INSTR_MATCH_MODRM_REG
,
118 .access
= TPR_ACCESS_WRITE
,
124 static void read_guest_rom_state(VAPICROMState
*s
)
126 cpu_physical_memory_rw(s
->rom_state_paddr
, (void *)&s
->rom_state
,
127 sizeof(GuestROMState
), 0);
130 static void write_guest_rom_state(VAPICROMState
*s
)
132 cpu_physical_memory_rw(s
->rom_state_paddr
, (void *)&s
->rom_state
,
133 sizeof(GuestROMState
), 1);
136 static void update_guest_rom_state(VAPICROMState
*s
)
138 read_guest_rom_state(s
);
140 s
->rom_state
.real_tpr_addr
= cpu_to_le32(s
->real_tpr_addr
);
141 s
->rom_state
.vcpu_shift
= cpu_to_le32(VAPIC_CPU_SHIFT
);
143 write_guest_rom_state(s
);
146 static int find_real_tpr_addr(VAPICROMState
*s
, CPUX86State
*env
)
151 if (s
->state
== VAPIC_ACTIVE
) {
155 * If there is no prior TPR access instruction we could analyze (which is
156 * the case after resume from hibernation), we need to scan the possible
157 * virtual address space for the APIC mapping.
159 for (addr
= 0xfffff000; addr
>= 0x80000000; addr
-= TARGET_PAGE_SIZE
) {
160 paddr
= cpu_get_phys_page_debug(env
, addr
);
161 if (paddr
!= APIC_DEFAULT_ADDRESS
) {
164 s
->real_tpr_addr
= addr
+ 0x80;
165 update_guest_rom_state(s
);
171 static uint8_t modrm_reg(uint8_t modrm
)
173 return (modrm
>> 3) & 7;
176 static bool is_abs_modrm(uint8_t modrm
)
178 return (modrm
& 0xc7) == 0x05;
181 static bool opcode_matches(uint8_t *opcode
, const TPRInstruction
*instr
)
183 return opcode
[0] == instr
->opcode
&&
184 (!(instr
->flags
& TPR_INSTR_ABS_MODRM
) || is_abs_modrm(opcode
[1])) &&
185 (!(instr
->flags
& TPR_INSTR_MATCH_MODRM_REG
) ||
186 modrm_reg(opcode
[1]) == instr
->modrm_reg
);
189 static int evaluate_tpr_instruction(VAPICROMState
*s
, CPUX86State
*env
,
190 target_ulong
*pip
, TPRAccess access
)
192 const TPRInstruction
*instr
;
193 target_ulong ip
= *pip
;
195 uint32_t real_tpr_addr
;
198 if ((ip
& 0xf0000000ULL
) != 0x80000000ULL
&&
199 (ip
& 0xf0000000ULL
) != 0xe0000000ULL
) {
204 * Early Windows 2003 SMP initialization contains a
208 * instruction that is patched by TPR optimization. The problem is that
209 * RSP, used by the patched instruction, is zero, so the guest gets a
210 * double fault and dies.
212 if (env
->regs
[R_ESP
] == 0) {
216 if (kvm_enabled() && !kvm_irqchip_in_kernel()) {
218 * KVM without kernel-based TPR access reporting will pass an IP that
219 * points after the accessing instruction. So we need to look backward
220 * to find the reason.
222 for (i
= 0; i
< ARRAY_SIZE(tpr_instr
); i
++) {
223 instr
= &tpr_instr
[i
];
224 if (instr
->access
!= access
) {
227 if (cpu_memory_rw_debug(env
, ip
- instr
->length
, opcode
,
228 sizeof(opcode
), 0) < 0) {
231 if (opcode_matches(opcode
, instr
)) {
238 if (cpu_memory_rw_debug(env
, ip
, opcode
, sizeof(opcode
), 0) < 0) {
241 for (i
= 0; i
< ARRAY_SIZE(tpr_instr
); i
++) {
242 instr
= &tpr_instr
[i
];
243 if (opcode_matches(opcode
, instr
)) {
252 * Grab the virtual TPR address from the instruction
253 * and update the cached values.
255 if (cpu_memory_rw_debug(env
, ip
+ instr
->addr_offset
,
256 (void *)&real_tpr_addr
,
257 sizeof(real_tpr_addr
), 0) < 0) {
260 real_tpr_addr
= le32_to_cpu(real_tpr_addr
);
261 if ((real_tpr_addr
& 0xfff) != 0x80) {
264 s
->real_tpr_addr
= real_tpr_addr
;
265 update_guest_rom_state(s
);
271 static int update_rom_mapping(VAPICROMState
*s
, CPUX86State
*env
, target_ulong ip
)
274 uint32_t rom_state_vaddr
;
275 uint32_t pos
, patch
, offset
;
277 /* nothing to do if already activated */
278 if (s
->state
== VAPIC_ACTIVE
) {
282 /* bail out if ROM init code was not executed (missing ROM?) */
283 if (s
->state
== VAPIC_INACTIVE
) {
287 /* find out virtual address of the ROM */
288 rom_state_vaddr
= s
->rom_state_paddr
+ (ip
& 0xf0000000);
289 paddr
= cpu_get_phys_page_debug(env
, rom_state_vaddr
);
293 paddr
+= rom_state_vaddr
& ~TARGET_PAGE_MASK
;
294 if (paddr
!= s
->rom_state_paddr
) {
297 read_guest_rom_state(s
);
298 if (memcmp(s
->rom_state
.signature
, "kvm aPiC", 8) != 0) {
301 s
->rom_state_vaddr
= rom_state_vaddr
;
303 /* fixup addresses in ROM if needed */
304 if (rom_state_vaddr
== le32_to_cpu(s
->rom_state
.vaddr
)) {
307 for (pos
= le32_to_cpu(s
->rom_state
.fixup_start
);
308 pos
< le32_to_cpu(s
->rom_state
.fixup_end
);
310 cpu_physical_memory_rw(paddr
+ pos
- s
->rom_state
.vaddr
,
311 (void *)&offset
, sizeof(offset
), 0);
312 offset
= le32_to_cpu(offset
);
313 cpu_physical_memory_rw(paddr
+ offset
, (void *)&patch
,
315 patch
= le32_to_cpu(patch
);
316 patch
+= rom_state_vaddr
- le32_to_cpu(s
->rom_state
.vaddr
);
317 patch
= cpu_to_le32(patch
);
318 cpu_physical_memory_rw(paddr
+ offset
, (void *)&patch
,
321 read_guest_rom_state(s
);
322 s
->vapic_paddr
= paddr
+ le32_to_cpu(s
->rom_state
.vapic_vaddr
) -
323 le32_to_cpu(s
->rom_state
.vaddr
);
329 * Tries to read the unique processor number from the Kernel Processor Control
330 * Region (KPCR) of 32-bit Windows XP and Server 2003. Returns -1 if the KPCR
331 * cannot be accessed or is considered invalid. This also ensures that we are
332 * not patching the wrong guest.
334 static int get_kpcr_number(CPUX86State
*env
)
343 if (cpu_memory_rw_debug(env
, env
->segs
[R_FS
].base
,
344 (void *)&kpcr
, sizeof(kpcr
), 0) < 0 ||
345 kpcr
.self
!= env
->segs
[R_FS
].base
) {
351 static int vapic_enable(VAPICROMState
*s
, CPUX86State
*env
)
353 int cpu_number
= get_kpcr_number(env
);
355 static const uint8_t enabled
= 1;
357 if (cpu_number
< 0) {
360 vapic_paddr
= s
->vapic_paddr
+
361 (((hwaddr
)cpu_number
) << VAPIC_CPU_SHIFT
);
362 cpu_physical_memory_rw(vapic_paddr
+ offsetof(VAPICState
, enabled
),
363 (void *)&enabled
, sizeof(enabled
), 1);
364 apic_enable_vapic(env
->apic_state
, vapic_paddr
);
366 s
->state
= VAPIC_ACTIVE
;
371 static void patch_byte(CPUX86State
*env
, target_ulong addr
, uint8_t byte
)
373 cpu_memory_rw_debug(env
, addr
, &byte
, 1, 1);
376 static void patch_call(VAPICROMState
*s
, CPUX86State
*env
, target_ulong ip
,
381 offset
= cpu_to_le32(target
- ip
- 5);
382 patch_byte(env
, ip
, 0xe8); /* call near */
383 cpu_memory_rw_debug(env
, ip
+ 1, (void *)&offset
, sizeof(offset
), 1);
386 static void patch_instruction(VAPICROMState
*s
, X86CPU
*cpu
, target_ulong ip
)
388 CPUState
*cs
= CPU(cpu
);
389 CPUX86State
*env
= &cpu
->env
;
390 VAPICHandlers
*handlers
;
393 target_ulong current_pc
= 0;
394 target_ulong current_cs_base
= 0;
395 int current_flags
= 0;
398 handlers
= &s
->rom_state
.up
;
400 handlers
= &s
->rom_state
.mp
;
403 if (!kvm_enabled()) {
404 cpu_restore_state(env
, env
->mem_io_pc
);
405 cpu_get_tb_cpu_state(env
, ¤t_pc
, ¤t_cs_base
,
411 cpu_memory_rw_debug(env
, ip
, opcode
, sizeof(opcode
), 0);
414 case 0x89: /* mov r32 to r/m32 */
415 patch_byte(env
, ip
, 0x50 + modrm_reg(opcode
[1])); /* push reg */
416 patch_call(s
, env
, ip
+ 1, handlers
->set_tpr
);
418 case 0x8b: /* mov r/m32 to r32 */
419 patch_byte(env
, ip
, 0x90);
420 patch_call(s
, env
, ip
+ 1, handlers
->get_tpr
[modrm_reg(opcode
[1])]);
422 case 0xa1: /* mov abs to eax */
423 patch_call(s
, env
, ip
, handlers
->get_tpr
[0]);
425 case 0xa3: /* mov eax to abs */
426 patch_call(s
, env
, ip
, handlers
->set_tpr_eax
);
428 case 0xc7: /* mov imm32, r/m32 (c7/0) */
429 patch_byte(env
, ip
, 0x68); /* push imm32 */
430 cpu_memory_rw_debug(env
, ip
+ 6, (void *)&imm32
, sizeof(imm32
), 0);
431 cpu_memory_rw_debug(env
, ip
+ 1, (void *)&imm32
, sizeof(imm32
), 1);
432 patch_call(s
, env
, ip
+ 5, handlers
->set_tpr
);
434 case 0xff: /* push r/m32 */
435 patch_byte(env
, ip
, 0x50); /* push eax */
436 patch_call(s
, env
, ip
+ 1, handlers
->get_tpr_stack
);
444 if (!kvm_enabled()) {
445 cs
->current_tb
= NULL
;
446 tb_gen_code(env
, current_pc
, current_cs_base
, current_flags
, 1);
447 cpu_resume_from_signal(env
, NULL
);
451 void vapic_report_tpr_access(DeviceState
*dev
, CPUState
*cs
, target_ulong ip
,
454 VAPICROMState
*s
= DO_UPCAST(VAPICROMState
, busdev
.qdev
, dev
);
455 X86CPU
*cpu
= X86_CPU(cs
);
456 CPUX86State
*env
= &cpu
->env
;
458 cpu_synchronize_state(env
);
460 if (evaluate_tpr_instruction(s
, env
, &ip
, access
) < 0) {
461 if (s
->state
== VAPIC_ACTIVE
) {
462 vapic_enable(s
, env
);
466 if (update_rom_mapping(s
, env
, ip
) < 0) {
469 if (vapic_enable(s
, env
) < 0) {
472 patch_instruction(s
, cpu
, ip
);
475 typedef struct VAPICEnableTPRReporting
{
478 } VAPICEnableTPRReporting
;
480 static void vapic_do_enable_tpr_reporting(void *data
)
482 VAPICEnableTPRReporting
*info
= data
;
484 apic_enable_tpr_access_reporting(info
->apic
, info
->enable
);
487 static void vapic_enable_tpr_reporting(bool enable
)
489 VAPICEnableTPRReporting info
= {
495 for (env
= first_cpu
; env
!= NULL
; env
= env
->next_cpu
) {
496 cpu
= x86_env_get_cpu(env
);
497 info
.apic
= env
->apic_state
;
498 run_on_cpu(CPU(cpu
), vapic_do_enable_tpr_reporting
, &info
);
502 static void vapic_reset(DeviceState
*dev
)
504 VAPICROMState
*s
= DO_UPCAST(VAPICROMState
, busdev
.qdev
, dev
);
506 if (s
->state
== VAPIC_ACTIVE
) {
507 s
->state
= VAPIC_STANDBY
;
509 vapic_enable_tpr_reporting(false);
513 * Set the IRQ polling hypercalls to the supported variant:
514 * - vmcall if using KVM in-kernel irqchip
515 * - 32-bit VAPIC port write otherwise
517 static int patch_hypercalls(VAPICROMState
*s
)
519 hwaddr rom_paddr
= s
->rom_state_paddr
& ROM_BLOCK_MASK
;
520 static const uint8_t vmcall_pattern
[] = { /* vmcall */
521 0xb8, 0x1, 0, 0, 0, 0xf, 0x1, 0xc1
523 static const uint8_t outl_pattern
[] = { /* nop; outl %eax,0x7e */
524 0xb8, 0x1, 0, 0, 0, 0x90, 0xe7, 0x7e
526 uint8_t alternates
[2];
527 const uint8_t *pattern
;
528 const uint8_t *patch
;
533 rom
= g_malloc(s
->rom_size
);
534 cpu_physical_memory_rw(rom_paddr
, rom
, s
->rom_size
, 0);
536 for (pos
= 0; pos
< s
->rom_size
- sizeof(vmcall_pattern
); pos
++) {
537 if (kvm_irqchip_in_kernel()) {
538 pattern
= outl_pattern
;
539 alternates
[0] = outl_pattern
[7];
540 alternates
[1] = outl_pattern
[7];
541 patch
= &vmcall_pattern
[5];
543 pattern
= vmcall_pattern
;
544 alternates
[0] = vmcall_pattern
[7];
545 alternates
[1] = 0xd9; /* AMD's VMMCALL */
546 patch
= &outl_pattern
[5];
548 if (memcmp(rom
+ pos
, pattern
, 7) == 0 &&
549 (rom
[pos
+ 7] == alternates
[0] || rom
[pos
+ 7] == alternates
[1])) {
550 cpu_physical_memory_rw(rom_paddr
+ pos
+ 5, (uint8_t *)patch
,
553 * Don't flush the tb here. Under ordinary conditions, the patched
554 * calls are miles away from the current IP. Under malicious
555 * conditions, the guest could trick us to crash.
562 if (patches
!= 0 && patches
!= 2) {
570 * For TCG mode or the time KVM honors read-only memory regions, we need to
571 * enable write access to the option ROM so that variables can be updated by
574 static void vapic_map_rom_writable(VAPICROMState
*s
)
576 hwaddr rom_paddr
= s
->rom_state_paddr
& ROM_BLOCK_MASK
;
577 MemoryRegionSection section
;
582 as
= sysbus_address_space(&s
->busdev
);
584 if (s
->rom_mapped_writable
) {
585 memory_region_del_subregion(as
, &s
->rom
);
586 memory_region_destroy(&s
->rom
);
589 /* grab RAM memory region (region @rom_paddr may still be pc.rom) */
590 section
= memory_region_find(as
, 0, 1);
592 /* read ROM size from RAM region */
593 ram
= memory_region_get_ram_ptr(section
.mr
);
594 rom_size
= ram
[rom_paddr
+ 2] * ROM_BLOCK_SIZE
;
595 s
->rom_size
= rom_size
;
597 /* We need to round to avoid creating subpages
598 * from which we cannot run code. */
599 rom_size
+= rom_paddr
& ~TARGET_PAGE_MASK
;
600 rom_paddr
&= TARGET_PAGE_MASK
;
601 rom_size
= TARGET_PAGE_ALIGN(rom_size
);
603 memory_region_init_alias(&s
->rom
, "kvmvapic-rom", section
.mr
, rom_paddr
,
605 memory_region_add_subregion_overlap(as
, rom_paddr
, &s
->rom
, 1000);
606 s
->rom_mapped_writable
= true;
609 static int vapic_prepare(VAPICROMState
*s
)
611 vapic_map_rom_writable(s
);
613 if (patch_hypercalls(s
) < 0) {
617 vapic_enable_tpr_reporting(true);
622 static void vapic_write(void *opaque
, hwaddr addr
, uint64_t data
,
625 CPUX86State
*env
= cpu_single_env
;
627 VAPICROMState
*s
= opaque
;
629 cpu_synchronize_state(env
);
632 * The VAPIC supports two PIO-based hypercalls, both via port 0x7E.
633 * o 16-bit write access:
634 * Reports the option ROM initialization to the hypervisor. Written
635 * value is the offset of the state structure in the ROM.
636 * o 8-bit write access:
637 * Reactivates the VAPIC after a guest hibernation, i.e. after the
638 * option ROM content has been re-initialized by a guest power cycle.
639 * o 32-bit write access:
640 * Poll for pending IRQs, considering the current VAPIC state.
644 if (s
->state
== VAPIC_INACTIVE
) {
645 rom_paddr
= (env
->segs
[R_CS
].base
+ env
->eip
) & ROM_BLOCK_MASK
;
646 s
->rom_state_paddr
= rom_paddr
+ data
;
648 s
->state
= VAPIC_STANDBY
;
650 if (vapic_prepare(s
) < 0) {
651 s
->state
= VAPIC_INACTIVE
;
658 * Disable triggering instruction in ROM by writing a NOP.
660 * We cannot do this in TCG mode as the reported IP is not
664 patch_byte(env
, env
->eip
- 2, 0x66);
665 patch_byte(env
, env
->eip
- 1, 0x90);
669 if (s
->state
== VAPIC_ACTIVE
) {
672 if (update_rom_mapping(s
, env
, env
->eip
) < 0) {
675 if (find_real_tpr_addr(s
, env
) < 0) {
678 vapic_enable(s
, env
);
682 if (!kvm_irqchip_in_kernel()) {
683 apic_poll_irq(env
->apic_state
);
689 static const MemoryRegionOps vapic_ops
= {
690 .write
= vapic_write
,
691 .endianness
= DEVICE_NATIVE_ENDIAN
,
694 static int vapic_init(SysBusDevice
*dev
)
696 VAPICROMState
*s
= VAPIC(dev
);
698 memory_region_init_io(&s
->io
, &vapic_ops
, s
, "kvmvapic", 2);
699 sysbus_add_io(dev
, VAPIC_IO_PORT
, &s
->io
);
700 sysbus_init_ioports(dev
, VAPIC_IO_PORT
, 2);
702 option_rom
[nb_option_roms
].name
= "kvmvapic.bin";
703 option_rom
[nb_option_roms
].bootindex
= -1;
709 static void do_vapic_enable(void *data
)
711 VAPICROMState
*s
= data
;
713 vapic_enable(s
, first_cpu
);
716 static int vapic_post_load(void *opaque
, int version_id
)
718 VAPICROMState
*s
= opaque
;
722 * The old implementation of qemu-kvm did not provide the state
723 * VAPIC_STANDBY. Reconstruct it.
725 if (s
->state
== VAPIC_INACTIVE
&& s
->rom_state_paddr
!= 0) {
726 s
->state
= VAPIC_STANDBY
;
729 if (s
->state
!= VAPIC_INACTIVE
) {
730 if (vapic_prepare(s
) < 0) {
734 if (s
->state
== VAPIC_ACTIVE
) {
736 run_on_cpu(ENV_GET_CPU(first_cpu
), do_vapic_enable
, s
);
738 zero
= g_malloc0(s
->rom_state
.vapic_size
);
739 cpu_physical_memory_rw(s
->vapic_paddr
, zero
,
740 s
->rom_state
.vapic_size
, 1);
748 static const VMStateDescription vmstate_handlers
= {
749 .name
= "kvmvapic-handlers",
751 .minimum_version_id
= 1,
752 .minimum_version_id_old
= 1,
753 .fields
= (VMStateField
[]) {
754 VMSTATE_UINT32(set_tpr
, VAPICHandlers
),
755 VMSTATE_UINT32(set_tpr_eax
, VAPICHandlers
),
756 VMSTATE_UINT32_ARRAY(get_tpr
, VAPICHandlers
, 8),
757 VMSTATE_UINT32(get_tpr_stack
, VAPICHandlers
),
758 VMSTATE_END_OF_LIST()
762 static const VMStateDescription vmstate_guest_rom
= {
763 .name
= "kvmvapic-guest-rom",
765 .minimum_version_id
= 1,
766 .minimum_version_id_old
= 1,
767 .fields
= (VMStateField
[]) {
768 VMSTATE_UNUSED(8), /* signature */
769 VMSTATE_UINT32(vaddr
, GuestROMState
),
770 VMSTATE_UINT32(fixup_start
, GuestROMState
),
771 VMSTATE_UINT32(fixup_end
, GuestROMState
),
772 VMSTATE_UINT32(vapic_vaddr
, GuestROMState
),
773 VMSTATE_UINT32(vapic_size
, GuestROMState
),
774 VMSTATE_UINT32(vcpu_shift
, GuestROMState
),
775 VMSTATE_UINT32(real_tpr_addr
, GuestROMState
),
776 VMSTATE_STRUCT(up
, GuestROMState
, 0, vmstate_handlers
, VAPICHandlers
),
777 VMSTATE_STRUCT(mp
, GuestROMState
, 0, vmstate_handlers
, VAPICHandlers
),
778 VMSTATE_END_OF_LIST()
782 static const VMStateDescription vmstate_vapic
= {
783 .name
= "kvm-tpr-opt", /* compatible with qemu-kvm VAPIC */
785 .minimum_version_id
= 1,
786 .minimum_version_id_old
= 1,
787 .post_load
= vapic_post_load
,
788 .fields
= (VMStateField
[]) {
789 VMSTATE_STRUCT(rom_state
, VAPICROMState
, 0, vmstate_guest_rom
,
791 VMSTATE_UINT32(state
, VAPICROMState
),
792 VMSTATE_UINT32(real_tpr_addr
, VAPICROMState
),
793 VMSTATE_UINT32(rom_state_vaddr
, VAPICROMState
),
794 VMSTATE_UINT32(vapic_paddr
, VAPICROMState
),
795 VMSTATE_UINT32(rom_state_paddr
, VAPICROMState
),
796 VMSTATE_END_OF_LIST()
800 static void vapic_class_init(ObjectClass
*klass
, void *data
)
802 SysBusDeviceClass
*sc
= SYS_BUS_DEVICE_CLASS(klass
);
803 DeviceClass
*dc
= DEVICE_CLASS(klass
);
806 dc
->reset
= vapic_reset
;
807 dc
->vmsd
= &vmstate_vapic
;
808 sc
->init
= vapic_init
;
811 static const TypeInfo vapic_type
= {
813 .parent
= TYPE_SYS_BUS_DEVICE
,
814 .instance_size
= sizeof(VAPICROMState
),
815 .class_init
= vapic_class_init
,
818 static void vapic_register(void)
820 type_register_static(&vapic_type
);
823 type_init(vapic_register
);