2 # Local APIC acceleration for Windows XP and related guests
4 # Copyright 2011 Red Hat, Inc. and/or its affiliates
6 # Author: Avi Kivity <avi@redhat.com>
8 # This work is licensed under the terms of the GNU GPL, version 2, or (at your
9 # option) any later version. See the COPYING file in the top-level directory.
12 #include "optionrom.h"
16 # clear vapic area: firmware load using rep insb may cause
17 # stale tpr/isr/irr data to corrupt the vapic area.
22 mov $vapic_size/2, %cx
28 # announce presence to the hypervisor
40 .long 777b + \delta - vapic_base
58 .long vapic_base ; fixup
59 .long fixup_start ; fixup
60 .long fixup_end ; fixup
68 .long up_set_tpr ; fixup
69 .long up_set_tpr_eax ; fixup
70 .long up_get_tpr_eax ; fixup
71 .long up_get_tpr_ecx ; fixup
72 .long up_get_tpr_edx ; fixup
73 .long up_get_tpr_ebx ; fixup
74 .long 0 /* esp. won't work. */
75 .long up_get_tpr_ebp ; fixup
76 .long up_get_tpr_esi ; fixup
77 .long up_get_tpr_edi ; fixup
78 .long up_get_tpr_stack ; fixup
79 .long mp_set_tpr ; fixup
80 .long mp_set_tpr_eax ; fixup
81 .long mp_get_tpr_eax ; fixup
82 .long mp_get_tpr_ecx ; fixup
83 .long mp_get_tpr_edx ; fixup
84 .long mp_get_tpr_ebx ; fixup
85 .long 0 /* esp. won't work. */
86 .long mp_get_tpr_ebp ; fixup
87 .long mp_get_tpr_esi ; fixup
88 .long mp_get_tpr_edi ; fixup
89 .long mp_get_tpr_stack ; fixup
92 .byte 0x0f, 0x01, 0xc1
95 kvm_hypercall_vapic_poll_irq = 1
107 fs/movzbl pcr_cpu, %eax
109 mov vcpu_shift, %ecx ; fixup
111 testb $1, vapic+4(%eax) ; fixup delta=-5
113 movzbl vapic(%eax), %eax ; fixup
121 mov real_tpr, %eax ; fixup
181 fs/movzbl pcr_cpu, %edx
183 mov vcpu_shift, %ecx ; fixup
186 testb $1, vapic+4(%edx) ; fixup delta=-5
189 mov vapic(%edx), %eax ; fixup
194 /* %ebx = new vapic (%bl = tpr, %bh = isr, %b3 = irr) */
196 lock cmpxchg %ebx, vapic(%edx) ; fixup
197 jnz mp_set_tpr_failed
207 /* now: %bl = irr, %bh = ppr */
209 ja mp_set_tpr_poll_irq
220 mov $kvm_hypercall_vapic_poll_irq, %eax
226 mov real_tpr, %eax ; fixup
232 movzbl vapic, %eax ; fixup
237 movzbl vapic, %ebx ; fixup
242 movzbl vapic, %ecx ; fixup
247 movzbl vapic, %edx ; fixup
252 movzbl vapic, %esi ; fixup
257 movzbl vapic, %edi ; fixup
262 movzbl vapic, %ebp ; fixup
267 movzbl vapic, %eax ; fixup
283 mov vapic, %eax ; fixup
288 /* %ebx = new vapic (%bl = tpr, %bh = isr, %b3 = irr) */
290 lock cmpxchg %ebx, vapic ; fixup
291 jnz up_set_tpr_failed
301 /* now: %bl = irr, %bh = ppr */
303 ja up_set_tpr_poll_irq
312 mov $kvm_hypercall_vapic_poll_irq, %eax
322 * per-vcpu records of size 2^vcpu shift.
324 * byte 1: highest in-service interrupt (isr) (r/o); bits 3:0 are zero
326 * byte 3: highest pending interrupt (irr) (r/o)