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"
15 #include "hw/sysbus.h"
17 #define VAPIC_IO_PORT 0x7e
19 #define VAPIC_CPU_SHIFT 7
21 #define ROM_BLOCK_SIZE 512
22 #define ROM_BLOCK_MASK (~(ROM_BLOCK_SIZE - 1))
24 typedef enum VAPICMode
{
30 typedef struct VAPICHandlers
{
34 uint32_t get_tpr_stack
;
35 } QEMU_PACKED VAPICHandlers
;
37 typedef struct GuestROMState
{
45 uint32_t real_tpr_addr
;
48 } QEMU_PACKED GuestROMState
;
50 typedef struct VAPICROMState
{
55 uint32_t rom_state_paddr
;
56 uint32_t rom_state_vaddr
;
58 uint32_t real_tpr_addr
;
59 GuestROMState rom_state
;
61 bool rom_mapped_writable
;
64 #define TYPE_VAPIC "kvmvapic"
65 #define VAPIC(obj) OBJECT_CHECK(VAPICROMState, (obj), TYPE_VAPIC)
67 #define TPR_INSTR_ABS_MODRM 0x1
68 #define TPR_INSTR_MATCH_MODRM_REG 0x2
70 typedef struct TPRInstruction
{
79 /* must be sorted by length, shortest first */
80 static const TPRInstruction tpr_instr
[] = {
81 { /* mov abs to eax */
83 .access
= TPR_ACCESS_READ
,
87 { /* mov eax to abs */
89 .access
= TPR_ACCESS_WRITE
,
93 { /* mov r32 to r/m32 */
95 .flags
= TPR_INSTR_ABS_MODRM
,
96 .access
= TPR_ACCESS_WRITE
,
100 { /* mov r/m32 to r32 */
102 .flags
= TPR_INSTR_ABS_MODRM
,
103 .access
= TPR_ACCESS_READ
,
110 .flags
= TPR_INSTR_ABS_MODRM
| TPR_INSTR_MATCH_MODRM_REG
,
111 .access
= TPR_ACCESS_READ
,
115 { /* mov imm32, r/m32 (c7/0) */
118 .flags
= TPR_INSTR_ABS_MODRM
| TPR_INSTR_MATCH_MODRM_REG
,
119 .access
= TPR_ACCESS_WRITE
,
125 static void read_guest_rom_state(VAPICROMState
*s
)
127 cpu_physical_memory_rw(s
->rom_state_paddr
, (void *)&s
->rom_state
,
128 sizeof(GuestROMState
), 0);
131 static void write_guest_rom_state(VAPICROMState
*s
)
133 cpu_physical_memory_rw(s
->rom_state_paddr
, (void *)&s
->rom_state
,
134 sizeof(GuestROMState
), 1);
137 static void update_guest_rom_state(VAPICROMState
*s
)
139 read_guest_rom_state(s
);
141 s
->rom_state
.real_tpr_addr
= cpu_to_le32(s
->real_tpr_addr
);
142 s
->rom_state
.vcpu_shift
= cpu_to_le32(VAPIC_CPU_SHIFT
);
144 write_guest_rom_state(s
);
147 static int find_real_tpr_addr(VAPICROMState
*s
, CPUX86State
*env
)
152 if (s
->state
== VAPIC_ACTIVE
) {
156 * If there is no prior TPR access instruction we could analyze (which is
157 * the case after resume from hibernation), we need to scan the possible
158 * virtual address space for the APIC mapping.
160 for (addr
= 0xfffff000; addr
>= 0x80000000; addr
-= TARGET_PAGE_SIZE
) {
161 paddr
= cpu_get_phys_page_debug(env
, addr
);
162 if (paddr
!= APIC_DEFAULT_ADDRESS
) {
165 s
->real_tpr_addr
= addr
+ 0x80;
166 update_guest_rom_state(s
);
172 static uint8_t modrm_reg(uint8_t modrm
)
174 return (modrm
>> 3) & 7;
177 static bool is_abs_modrm(uint8_t modrm
)
179 return (modrm
& 0xc7) == 0x05;
182 static bool opcode_matches(uint8_t *opcode
, const TPRInstruction
*instr
)
184 return opcode
[0] == instr
->opcode
&&
185 (!(instr
->flags
& TPR_INSTR_ABS_MODRM
) || is_abs_modrm(opcode
[1])) &&
186 (!(instr
->flags
& TPR_INSTR_MATCH_MODRM_REG
) ||
187 modrm_reg(opcode
[1]) == instr
->modrm_reg
);
190 static int evaluate_tpr_instruction(VAPICROMState
*s
, CPUX86State
*env
,
191 target_ulong
*pip
, TPRAccess access
)
193 const TPRInstruction
*instr
;
194 target_ulong ip
= *pip
;
196 uint32_t real_tpr_addr
;
199 if ((ip
& 0xf0000000ULL
) != 0x80000000ULL
&&
200 (ip
& 0xf0000000ULL
) != 0xe0000000ULL
) {
205 * Early Windows 2003 SMP initialization contains a
209 * instruction that is patched by TPR optimization. The problem is that
210 * RSP, used by the patched instruction, is zero, so the guest gets a
211 * double fault and dies.
213 if (env
->regs
[R_ESP
] == 0) {
217 if (kvm_enabled() && !kvm_irqchip_in_kernel()) {
219 * KVM without kernel-based TPR access reporting will pass an IP that
220 * points after the accessing instruction. So we need to look backward
221 * to find the reason.
223 for (i
= 0; i
< ARRAY_SIZE(tpr_instr
); i
++) {
224 instr
= &tpr_instr
[i
];
225 if (instr
->access
!= access
) {
228 if (cpu_memory_rw_debug(env
, ip
- instr
->length
, opcode
,
229 sizeof(opcode
), 0) < 0) {
232 if (opcode_matches(opcode
, instr
)) {
239 if (cpu_memory_rw_debug(env
, ip
, opcode
, sizeof(opcode
), 0) < 0) {
242 for (i
= 0; i
< ARRAY_SIZE(tpr_instr
); i
++) {
243 instr
= &tpr_instr
[i
];
244 if (opcode_matches(opcode
, instr
)) {
253 * Grab the virtual TPR address from the instruction
254 * and update the cached values.
256 if (cpu_memory_rw_debug(env
, ip
+ instr
->addr_offset
,
257 (void *)&real_tpr_addr
,
258 sizeof(real_tpr_addr
), 0) < 0) {
261 real_tpr_addr
= le32_to_cpu(real_tpr_addr
);
262 if ((real_tpr_addr
& 0xfff) != 0x80) {
265 s
->real_tpr_addr
= real_tpr_addr
;
266 update_guest_rom_state(s
);
272 static int update_rom_mapping(VAPICROMState
*s
, CPUX86State
*env
, target_ulong ip
)
275 uint32_t rom_state_vaddr
;
276 uint32_t pos
, patch
, offset
;
278 /* nothing to do if already activated */
279 if (s
->state
== VAPIC_ACTIVE
) {
283 /* bail out if ROM init code was not executed (missing ROM?) */
284 if (s
->state
== VAPIC_INACTIVE
) {
288 /* find out virtual address of the ROM */
289 rom_state_vaddr
= s
->rom_state_paddr
+ (ip
& 0xf0000000);
290 paddr
= cpu_get_phys_page_debug(env
, rom_state_vaddr
);
294 paddr
+= rom_state_vaddr
& ~TARGET_PAGE_MASK
;
295 if (paddr
!= s
->rom_state_paddr
) {
298 read_guest_rom_state(s
);
299 if (memcmp(s
->rom_state
.signature
, "kvm aPiC", 8) != 0) {
302 s
->rom_state_vaddr
= rom_state_vaddr
;
304 /* fixup addresses in ROM if needed */
305 if (rom_state_vaddr
== le32_to_cpu(s
->rom_state
.vaddr
)) {
308 for (pos
= le32_to_cpu(s
->rom_state
.fixup_start
);
309 pos
< le32_to_cpu(s
->rom_state
.fixup_end
);
311 cpu_physical_memory_rw(paddr
+ pos
- s
->rom_state
.vaddr
,
312 (void *)&offset
, sizeof(offset
), 0);
313 offset
= le32_to_cpu(offset
);
314 cpu_physical_memory_rw(paddr
+ offset
, (void *)&patch
,
316 patch
= le32_to_cpu(patch
);
317 patch
+= rom_state_vaddr
- le32_to_cpu(s
->rom_state
.vaddr
);
318 patch
= cpu_to_le32(patch
);
319 cpu_physical_memory_rw(paddr
+ offset
, (void *)&patch
,
322 read_guest_rom_state(s
);
323 s
->vapic_paddr
= paddr
+ le32_to_cpu(s
->rom_state
.vapic_vaddr
) -
324 le32_to_cpu(s
->rom_state
.vaddr
);
330 * Tries to read the unique processor number from the Kernel Processor Control
331 * Region (KPCR) of 32-bit Windows XP and Server 2003. Returns -1 if the KPCR
332 * cannot be accessed or is considered invalid. This also ensures that we are
333 * not patching the wrong guest.
335 static int get_kpcr_number(CPUX86State
*env
)
344 if (cpu_memory_rw_debug(env
, env
->segs
[R_FS
].base
,
345 (void *)&kpcr
, sizeof(kpcr
), 0) < 0 ||
346 kpcr
.self
!= env
->segs
[R_FS
].base
) {
352 static int vapic_enable(VAPICROMState
*s
, CPUX86State
*env
)
354 int cpu_number
= get_kpcr_number(env
);
356 static const uint8_t enabled
= 1;
358 if (cpu_number
< 0) {
361 vapic_paddr
= s
->vapic_paddr
+
362 (((hwaddr
)cpu_number
) << VAPIC_CPU_SHIFT
);
363 cpu_physical_memory_rw(vapic_paddr
+ offsetof(VAPICState
, enabled
),
364 (void *)&enabled
, sizeof(enabled
), 1);
365 apic_enable_vapic(env
->apic_state
, vapic_paddr
);
367 s
->state
= VAPIC_ACTIVE
;
372 static void patch_byte(CPUX86State
*env
, target_ulong addr
, uint8_t byte
)
374 cpu_memory_rw_debug(env
, addr
, &byte
, 1, 1);
377 static void patch_call(VAPICROMState
*s
, CPUX86State
*env
, target_ulong ip
,
382 offset
= cpu_to_le32(target
- ip
- 5);
383 patch_byte(env
, ip
, 0xe8); /* call near */
384 cpu_memory_rw_debug(env
, ip
+ 1, (void *)&offset
, sizeof(offset
), 1);
387 static void patch_instruction(VAPICROMState
*s
, X86CPU
*cpu
, target_ulong ip
)
389 CPUState
*cs
= CPU(cpu
);
390 CPUX86State
*env
= &cpu
->env
;
391 VAPICHandlers
*handlers
;
394 target_ulong current_pc
= 0;
395 target_ulong current_cs_base
= 0;
396 int current_flags
= 0;
399 handlers
= &s
->rom_state
.up
;
401 handlers
= &s
->rom_state
.mp
;
404 if (!kvm_enabled()) {
405 cpu_restore_state(env
, env
->mem_io_pc
);
406 cpu_get_tb_cpu_state(env
, ¤t_pc
, ¤t_cs_base
,
412 cpu_memory_rw_debug(env
, ip
, opcode
, sizeof(opcode
), 0);
415 case 0x89: /* mov r32 to r/m32 */
416 patch_byte(env
, ip
, 0x50 + modrm_reg(opcode
[1])); /* push reg */
417 patch_call(s
, env
, ip
+ 1, handlers
->set_tpr
);
419 case 0x8b: /* mov r/m32 to r32 */
420 patch_byte(env
, ip
, 0x90);
421 patch_call(s
, env
, ip
+ 1, handlers
->get_tpr
[modrm_reg(opcode
[1])]);
423 case 0xa1: /* mov abs to eax */
424 patch_call(s
, env
, ip
, handlers
->get_tpr
[0]);
426 case 0xa3: /* mov eax to abs */
427 patch_call(s
, env
, ip
, handlers
->set_tpr_eax
);
429 case 0xc7: /* mov imm32, r/m32 (c7/0) */
430 patch_byte(env
, ip
, 0x68); /* push imm32 */
431 cpu_memory_rw_debug(env
, ip
+ 6, (void *)&imm32
, sizeof(imm32
), 0);
432 cpu_memory_rw_debug(env
, ip
+ 1, (void *)&imm32
, sizeof(imm32
), 1);
433 patch_call(s
, env
, ip
+ 5, handlers
->set_tpr
);
435 case 0xff: /* push r/m32 */
436 patch_byte(env
, ip
, 0x50); /* push eax */
437 patch_call(s
, env
, ip
+ 1, handlers
->get_tpr_stack
);
445 if (!kvm_enabled()) {
446 cs
->current_tb
= NULL
;
447 tb_gen_code(env
, current_pc
, current_cs_base
, current_flags
, 1);
448 cpu_resume_from_signal(env
, NULL
);
452 void vapic_report_tpr_access(DeviceState
*dev
, CPUState
*cs
, target_ulong ip
,
455 VAPICROMState
*s
= DO_UPCAST(VAPICROMState
, busdev
.qdev
, dev
);
456 X86CPU
*cpu
= X86_CPU(cs
);
457 CPUX86State
*env
= &cpu
->env
;
459 cpu_synchronize_state(cs
);
461 if (evaluate_tpr_instruction(s
, env
, &ip
, access
) < 0) {
462 if (s
->state
== VAPIC_ACTIVE
) {
463 vapic_enable(s
, env
);
467 if (update_rom_mapping(s
, env
, ip
) < 0) {
470 if (vapic_enable(s
, env
) < 0) {
473 patch_instruction(s
, cpu
, ip
);
476 typedef struct VAPICEnableTPRReporting
{
479 } VAPICEnableTPRReporting
;
481 static void vapic_do_enable_tpr_reporting(void *data
)
483 VAPICEnableTPRReporting
*info
= data
;
485 apic_enable_tpr_access_reporting(info
->apic
, info
->enable
);
488 static void vapic_enable_tpr_reporting(bool enable
)
490 VAPICEnableTPRReporting info
= {
496 for (env
= first_cpu
; env
!= NULL
; env
= env
->next_cpu
) {
497 cpu
= x86_env_get_cpu(env
);
498 info
.apic
= env
->apic_state
;
499 run_on_cpu(CPU(cpu
), vapic_do_enable_tpr_reporting
, &info
);
503 static void vapic_reset(DeviceState
*dev
)
505 VAPICROMState
*s
= DO_UPCAST(VAPICROMState
, busdev
.qdev
, dev
);
507 if (s
->state
== VAPIC_ACTIVE
) {
508 s
->state
= VAPIC_STANDBY
;
510 vapic_enable_tpr_reporting(false);
514 * Set the IRQ polling hypercalls to the supported variant:
515 * - vmcall if using KVM in-kernel irqchip
516 * - 32-bit VAPIC port write otherwise
518 static int patch_hypercalls(VAPICROMState
*s
)
520 hwaddr rom_paddr
= s
->rom_state_paddr
& ROM_BLOCK_MASK
;
521 static const uint8_t vmcall_pattern
[] = { /* vmcall */
522 0xb8, 0x1, 0, 0, 0, 0xf, 0x1, 0xc1
524 static const uint8_t outl_pattern
[] = { /* nop; outl %eax,0x7e */
525 0xb8, 0x1, 0, 0, 0, 0x90, 0xe7, 0x7e
527 uint8_t alternates
[2];
528 const uint8_t *pattern
;
529 const uint8_t *patch
;
534 rom
= g_malloc(s
->rom_size
);
535 cpu_physical_memory_rw(rom_paddr
, rom
, s
->rom_size
, 0);
537 for (pos
= 0; pos
< s
->rom_size
- sizeof(vmcall_pattern
); pos
++) {
538 if (kvm_irqchip_in_kernel()) {
539 pattern
= outl_pattern
;
540 alternates
[0] = outl_pattern
[7];
541 alternates
[1] = outl_pattern
[7];
542 patch
= &vmcall_pattern
[5];
544 pattern
= vmcall_pattern
;
545 alternates
[0] = vmcall_pattern
[7];
546 alternates
[1] = 0xd9; /* AMD's VMMCALL */
547 patch
= &outl_pattern
[5];
549 if (memcmp(rom
+ pos
, pattern
, 7) == 0 &&
550 (rom
[pos
+ 7] == alternates
[0] || rom
[pos
+ 7] == alternates
[1])) {
551 cpu_physical_memory_rw(rom_paddr
+ pos
+ 5, (uint8_t *)patch
,
554 * Don't flush the tb here. Under ordinary conditions, the patched
555 * calls are miles away from the current IP. Under malicious
556 * conditions, the guest could trick us to crash.
563 if (patches
!= 0 && patches
!= 2) {
571 * For TCG mode or the time KVM honors read-only memory regions, we need to
572 * enable write access to the option ROM so that variables can be updated by
575 static void vapic_map_rom_writable(VAPICROMState
*s
)
577 hwaddr rom_paddr
= s
->rom_state_paddr
& ROM_BLOCK_MASK
;
578 MemoryRegionSection section
;
583 as
= sysbus_address_space(&s
->busdev
);
585 if (s
->rom_mapped_writable
) {
586 memory_region_del_subregion(as
, &s
->rom
);
587 memory_region_destroy(&s
->rom
);
590 /* grab RAM memory region (region @rom_paddr may still be pc.rom) */
591 section
= memory_region_find(as
, 0, 1);
593 /* read ROM size from RAM region */
594 ram
= memory_region_get_ram_ptr(section
.mr
);
595 rom_size
= ram
[rom_paddr
+ 2] * ROM_BLOCK_SIZE
;
596 s
->rom_size
= rom_size
;
598 /* We need to round to avoid creating subpages
599 * from which we cannot run code. */
600 rom_size
+= rom_paddr
& ~TARGET_PAGE_MASK
;
601 rom_paddr
&= TARGET_PAGE_MASK
;
602 rom_size
= TARGET_PAGE_ALIGN(rom_size
);
604 memory_region_init_alias(&s
->rom
, "kvmvapic-rom", section
.mr
, rom_paddr
,
606 memory_region_add_subregion_overlap(as
, rom_paddr
, &s
->rom
, 1000);
607 s
->rom_mapped_writable
= true;
610 static int vapic_prepare(VAPICROMState
*s
)
612 vapic_map_rom_writable(s
);
614 if (patch_hypercalls(s
) < 0) {
618 vapic_enable_tpr_reporting(true);
623 static void vapic_write(void *opaque
, hwaddr addr
, uint64_t data
,
626 CPUX86State
*env
= cpu_single_env
;
628 VAPICROMState
*s
= opaque
;
630 cpu_synchronize_state(CPU(x86_env_get_cpu(env
)));
633 * The VAPIC supports two PIO-based hypercalls, both via port 0x7E.
634 * o 16-bit write access:
635 * Reports the option ROM initialization to the hypervisor. Written
636 * value is the offset of the state structure in the ROM.
637 * o 8-bit write access:
638 * Reactivates the VAPIC after a guest hibernation, i.e. after the
639 * option ROM content has been re-initialized by a guest power cycle.
640 * o 32-bit write access:
641 * Poll for pending IRQs, considering the current VAPIC state.
645 if (s
->state
== VAPIC_INACTIVE
) {
646 rom_paddr
= (env
->segs
[R_CS
].base
+ env
->eip
) & ROM_BLOCK_MASK
;
647 s
->rom_state_paddr
= rom_paddr
+ data
;
649 s
->state
= VAPIC_STANDBY
;
651 if (vapic_prepare(s
) < 0) {
652 s
->state
= VAPIC_INACTIVE
;
659 * Disable triggering instruction in ROM by writing a NOP.
661 * We cannot do this in TCG mode as the reported IP is not
665 patch_byte(env
, env
->eip
- 2, 0x66);
666 patch_byte(env
, env
->eip
- 1, 0x90);
670 if (s
->state
== VAPIC_ACTIVE
) {
673 if (update_rom_mapping(s
, env
, env
->eip
) < 0) {
676 if (find_real_tpr_addr(s
, env
) < 0) {
679 vapic_enable(s
, env
);
683 if (!kvm_irqchip_in_kernel()) {
684 apic_poll_irq(env
->apic_state
);
690 static uint64_t vapic_read(void *opaque
, hwaddr addr
, unsigned size
)
695 static const MemoryRegionOps vapic_ops
= {
696 .write
= vapic_write
,
698 .endianness
= DEVICE_NATIVE_ENDIAN
,
701 static int vapic_init(SysBusDevice
*dev
)
703 VAPICROMState
*s
= VAPIC(dev
);
705 memory_region_init_io(&s
->io
, &vapic_ops
, s
, "kvmvapic", 2);
706 sysbus_add_io(dev
, VAPIC_IO_PORT
, &s
->io
);
707 sysbus_init_ioports(dev
, VAPIC_IO_PORT
, 2);
709 option_rom
[nb_option_roms
].name
= "kvmvapic.bin";
710 option_rom
[nb_option_roms
].bootindex
= -1;
716 static void do_vapic_enable(void *data
)
718 VAPICROMState
*s
= data
;
720 vapic_enable(s
, first_cpu
);
723 static int vapic_post_load(void *opaque
, int version_id
)
725 VAPICROMState
*s
= opaque
;
729 * The old implementation of qemu-kvm did not provide the state
730 * VAPIC_STANDBY. Reconstruct it.
732 if (s
->state
== VAPIC_INACTIVE
&& s
->rom_state_paddr
!= 0) {
733 s
->state
= VAPIC_STANDBY
;
736 if (s
->state
!= VAPIC_INACTIVE
) {
737 if (vapic_prepare(s
) < 0) {
741 if (s
->state
== VAPIC_ACTIVE
) {
743 run_on_cpu(ENV_GET_CPU(first_cpu
), do_vapic_enable
, s
);
745 zero
= g_malloc0(s
->rom_state
.vapic_size
);
746 cpu_physical_memory_rw(s
->vapic_paddr
, zero
,
747 s
->rom_state
.vapic_size
, 1);
755 static const VMStateDescription vmstate_handlers
= {
756 .name
= "kvmvapic-handlers",
758 .minimum_version_id
= 1,
759 .minimum_version_id_old
= 1,
760 .fields
= (VMStateField
[]) {
761 VMSTATE_UINT32(set_tpr
, VAPICHandlers
),
762 VMSTATE_UINT32(set_tpr_eax
, VAPICHandlers
),
763 VMSTATE_UINT32_ARRAY(get_tpr
, VAPICHandlers
, 8),
764 VMSTATE_UINT32(get_tpr_stack
, VAPICHandlers
),
765 VMSTATE_END_OF_LIST()
769 static const VMStateDescription vmstate_guest_rom
= {
770 .name
= "kvmvapic-guest-rom",
772 .minimum_version_id
= 1,
773 .minimum_version_id_old
= 1,
774 .fields
= (VMStateField
[]) {
775 VMSTATE_UNUSED(8), /* signature */
776 VMSTATE_UINT32(vaddr
, GuestROMState
),
777 VMSTATE_UINT32(fixup_start
, GuestROMState
),
778 VMSTATE_UINT32(fixup_end
, GuestROMState
),
779 VMSTATE_UINT32(vapic_vaddr
, GuestROMState
),
780 VMSTATE_UINT32(vapic_size
, GuestROMState
),
781 VMSTATE_UINT32(vcpu_shift
, GuestROMState
),
782 VMSTATE_UINT32(real_tpr_addr
, GuestROMState
),
783 VMSTATE_STRUCT(up
, GuestROMState
, 0, vmstate_handlers
, VAPICHandlers
),
784 VMSTATE_STRUCT(mp
, GuestROMState
, 0, vmstate_handlers
, VAPICHandlers
),
785 VMSTATE_END_OF_LIST()
789 static const VMStateDescription vmstate_vapic
= {
790 .name
= "kvm-tpr-opt", /* compatible with qemu-kvm VAPIC */
792 .minimum_version_id
= 1,
793 .minimum_version_id_old
= 1,
794 .post_load
= vapic_post_load
,
795 .fields
= (VMStateField
[]) {
796 VMSTATE_STRUCT(rom_state
, VAPICROMState
, 0, vmstate_guest_rom
,
798 VMSTATE_UINT32(state
, VAPICROMState
),
799 VMSTATE_UINT32(real_tpr_addr
, VAPICROMState
),
800 VMSTATE_UINT32(rom_state_vaddr
, VAPICROMState
),
801 VMSTATE_UINT32(vapic_paddr
, VAPICROMState
),
802 VMSTATE_UINT32(rom_state_paddr
, VAPICROMState
),
803 VMSTATE_END_OF_LIST()
807 static void vapic_class_init(ObjectClass
*klass
, void *data
)
809 SysBusDeviceClass
*sc
= SYS_BUS_DEVICE_CLASS(klass
);
810 DeviceClass
*dc
= DEVICE_CLASS(klass
);
813 dc
->reset
= vapic_reset
;
814 dc
->vmsd
= &vmstate_vapic
;
815 sc
->init
= vapic_init
;
818 static const TypeInfo vapic_type
= {
820 .parent
= TYPE_SYS_BUS_DEVICE
,
821 .instance_size
= sizeof(VAPICROMState
),
822 .class_init
= vapic_class_init
,
825 static void vapic_register(void)
827 type_register_static(&vapic_type
);
830 type_init(vapic_register
);