aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/lapic.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kvm/lapic.c')
-rw-r--r--arch/x86/kvm/lapic.c193
1 files changed, 87 insertions, 106 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 1a2da0e5a373..bbb5b283ff63 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -59,9 +59,8 @@
59/* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */ 59/* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
60#define apic_debug(fmt, arg...) 60#define apic_debug(fmt, arg...)
61 61
62#define APIC_LVT_NUM 6
63/* 14 is the version for Xeon and Pentium 8.4.8*/ 62/* 14 is the version for Xeon and Pentium 8.4.8*/
64#define APIC_VERSION (0x14UL | ((APIC_LVT_NUM - 1) << 16)) 63#define APIC_VERSION (0x14UL | ((KVM_APIC_LVT_NUM - 1) << 16))
65#define LAPIC_MMIO_LENGTH (1 << 12) 64#define LAPIC_MMIO_LENGTH (1 << 12)
66/* followed define is not in apicdef.h */ 65/* followed define is not in apicdef.h */
67#define APIC_SHORT_MASK 0xc0000 66#define APIC_SHORT_MASK 0xc0000
@@ -73,14 +72,6 @@
73#define APIC_BROADCAST 0xFF 72#define APIC_BROADCAST 0xFF
74#define X2APIC_BROADCAST 0xFFFFFFFFul 73#define X2APIC_BROADCAST 0xFFFFFFFFul
75 74
76#define VEC_POS(v) ((v) & (32 - 1))
77#define REG_POS(v) (((v) >> 5) << 4)
78
79static inline void apic_set_reg(struct kvm_lapic *apic, int reg_off, u32 val)
80{
81 *((u32 *) (apic->regs + reg_off)) = val;
82}
83
84static inline int apic_test_vector(int vec, void *bitmap) 75static inline int apic_test_vector(int vec, void *bitmap)
85{ 76{
86 return test_bit(VEC_POS(vec), (bitmap) + REG_POS(vec)); 77 return test_bit(VEC_POS(vec), (bitmap) + REG_POS(vec));
@@ -94,11 +85,6 @@ bool kvm_apic_pending_eoi(struct kvm_vcpu *vcpu, int vector)
94 apic_test_vector(vector, apic->regs + APIC_IRR); 85 apic_test_vector(vector, apic->regs + APIC_IRR);
95} 86}
96 87
97static inline void apic_set_vector(int vec, void *bitmap)
98{
99 set_bit(VEC_POS(vec), (bitmap) + REG_POS(vec));
100}
101
102static inline void apic_clear_vector(int vec, void *bitmap) 88static inline void apic_clear_vector(int vec, void *bitmap)
103{ 89{
104 clear_bit(VEC_POS(vec), (bitmap) + REG_POS(vec)); 90 clear_bit(VEC_POS(vec), (bitmap) + REG_POS(vec));
@@ -173,7 +159,7 @@ static void recalculate_apic_map(struct kvm *kvm)
173 continue; 159 continue;
174 160
175 aid = kvm_apic_id(apic); 161 aid = kvm_apic_id(apic);
176 ldr = kvm_apic_get_reg(apic, APIC_LDR); 162 ldr = kvm_lapic_get_reg(apic, APIC_LDR);
177 163
178 if (aid < ARRAY_SIZE(new->phys_map)) 164 if (aid < ARRAY_SIZE(new->phys_map))
179 new->phys_map[aid] = apic; 165 new->phys_map[aid] = apic;
@@ -182,7 +168,7 @@ static void recalculate_apic_map(struct kvm *kvm)
182 new->mode |= KVM_APIC_MODE_X2APIC; 168 new->mode |= KVM_APIC_MODE_X2APIC;
183 } else if (ldr) { 169 } else if (ldr) {
184 ldr = GET_APIC_LOGICAL_ID(ldr); 170 ldr = GET_APIC_LOGICAL_ID(ldr);
185 if (kvm_apic_get_reg(apic, APIC_DFR) == APIC_DFR_FLAT) 171 if (kvm_lapic_get_reg(apic, APIC_DFR) == APIC_DFR_FLAT)
186 new->mode |= KVM_APIC_MODE_XAPIC_FLAT; 172 new->mode |= KVM_APIC_MODE_XAPIC_FLAT;
187 else 173 else
188 new->mode |= KVM_APIC_MODE_XAPIC_CLUSTER; 174 new->mode |= KVM_APIC_MODE_XAPIC_CLUSTER;
@@ -212,7 +198,7 @@ static inline void apic_set_spiv(struct kvm_lapic *apic, u32 val)
212{ 198{
213 bool enabled = val & APIC_SPIV_APIC_ENABLED; 199 bool enabled = val & APIC_SPIV_APIC_ENABLED;
214 200
215 apic_set_reg(apic, APIC_SPIV, val); 201 kvm_lapic_set_reg(apic, APIC_SPIV, val);
216 202
217 if (enabled != apic->sw_enabled) { 203 if (enabled != apic->sw_enabled) {
218 apic->sw_enabled = enabled; 204 apic->sw_enabled = enabled;
@@ -226,13 +212,13 @@ static inline void apic_set_spiv(struct kvm_lapic *apic, u32 val)
226 212
227static inline void kvm_apic_set_id(struct kvm_lapic *apic, u8 id) 213static inline void kvm_apic_set_id(struct kvm_lapic *apic, u8 id)
228{ 214{
229 apic_set_reg(apic, APIC_ID, id << 24); 215 kvm_lapic_set_reg(apic, APIC_ID, id << 24);
230 recalculate_apic_map(apic->vcpu->kvm); 216 recalculate_apic_map(apic->vcpu->kvm);
231} 217}
232 218
233static inline void kvm_apic_set_ldr(struct kvm_lapic *apic, u32 id) 219static inline void kvm_apic_set_ldr(struct kvm_lapic *apic, u32 id)
234{ 220{
235 apic_set_reg(apic, APIC_LDR, id); 221 kvm_lapic_set_reg(apic, APIC_LDR, id);
236 recalculate_apic_map(apic->vcpu->kvm); 222 recalculate_apic_map(apic->vcpu->kvm);
237} 223}
238 224
@@ -240,19 +226,19 @@ static inline void kvm_apic_set_x2apic_id(struct kvm_lapic *apic, u8 id)
240{ 226{
241 u32 ldr = ((id >> 4) << 16) | (1 << (id & 0xf)); 227 u32 ldr = ((id >> 4) << 16) | (1 << (id & 0xf));
242 228
243 apic_set_reg(apic, APIC_ID, id << 24); 229 kvm_lapic_set_reg(apic, APIC_ID, id << 24);
244 apic_set_reg(apic, APIC_LDR, ldr); 230 kvm_lapic_set_reg(apic, APIC_LDR, ldr);
245 recalculate_apic_map(apic->vcpu->kvm); 231 recalculate_apic_map(apic->vcpu->kvm);
246} 232}
247 233
248static inline int apic_lvt_enabled(struct kvm_lapic *apic, int lvt_type) 234static inline int apic_lvt_enabled(struct kvm_lapic *apic, int lvt_type)
249{ 235{
250 return !(kvm_apic_get_reg(apic, lvt_type) & APIC_LVT_MASKED); 236 return !(kvm_lapic_get_reg(apic, lvt_type) & APIC_LVT_MASKED);
251} 237}
252 238
253static inline int apic_lvt_vector(struct kvm_lapic *apic, int lvt_type) 239static inline int apic_lvt_vector(struct kvm_lapic *apic, int lvt_type)
254{ 240{
255 return kvm_apic_get_reg(apic, lvt_type) & APIC_VECTOR_MASK; 241 return kvm_lapic_get_reg(apic, lvt_type) & APIC_VECTOR_MASK;
256} 242}
257 243
258static inline int apic_lvtt_oneshot(struct kvm_lapic *apic) 244static inline int apic_lvtt_oneshot(struct kvm_lapic *apic)
@@ -287,10 +273,10 @@ void kvm_apic_set_version(struct kvm_vcpu *vcpu)
287 feat = kvm_find_cpuid_entry(apic->vcpu, 0x1, 0); 273 feat = kvm_find_cpuid_entry(apic->vcpu, 0x1, 0);
288 if (feat && (feat->ecx & (1 << (X86_FEATURE_X2APIC & 31)))) 274 if (feat && (feat->ecx & (1 << (X86_FEATURE_X2APIC & 31))))
289 v |= APIC_LVR_DIRECTED_EOI; 275 v |= APIC_LVR_DIRECTED_EOI;
290 apic_set_reg(apic, APIC_LVR, v); 276 kvm_lapic_set_reg(apic, APIC_LVR, v);
291} 277}
292 278
293static const unsigned int apic_lvt_mask[APIC_LVT_NUM] = { 279static const unsigned int apic_lvt_mask[KVM_APIC_LVT_NUM] = {
294 LVT_MASK , /* part LVTT mask, timer mode mask added at runtime */ 280 LVT_MASK , /* part LVTT mask, timer mode mask added at runtime */
295 LVT_MASK | APIC_MODE_MASK, /* LVTTHMR */ 281 LVT_MASK | APIC_MODE_MASK, /* LVTTHMR */
296 LVT_MASK | APIC_MODE_MASK, /* LVTPC */ 282 LVT_MASK | APIC_MODE_MASK, /* LVTPC */
@@ -349,16 +335,6 @@ void kvm_apic_update_irr(struct kvm_vcpu *vcpu, u32 *pir)
349} 335}
350EXPORT_SYMBOL_GPL(kvm_apic_update_irr); 336EXPORT_SYMBOL_GPL(kvm_apic_update_irr);
351 337
352static inline void apic_set_irr(int vec, struct kvm_lapic *apic)
353{
354 apic_set_vector(vec, apic->regs + APIC_IRR);
355 /*
356 * irr_pending must be true if any interrupt is pending; set it after
357 * APIC_IRR to avoid race with apic_clear_irr
358 */
359 apic->irr_pending = true;
360}
361
362static inline int apic_search_irr(struct kvm_lapic *apic) 338static inline int apic_search_irr(struct kvm_lapic *apic)
363{ 339{
364 return find_highest_vector(apic->regs + APIC_IRR); 340 return find_highest_vector(apic->regs + APIC_IRR);
@@ -416,7 +392,7 @@ static inline void apic_set_isr(int vec, struct kvm_lapic *apic)
416 * just set SVI. 392 * just set SVI.
417 */ 393 */
418 if (unlikely(vcpu->arch.apicv_active)) 394 if (unlikely(vcpu->arch.apicv_active))
419 kvm_x86_ops->hwapic_isr_update(vcpu->kvm, vec); 395 kvm_x86_ops->hwapic_isr_update(vcpu, vec);
420 else { 396 else {
421 ++apic->isr_count; 397 ++apic->isr_count;
422 BUG_ON(apic->isr_count > MAX_APIC_VECTOR); 398 BUG_ON(apic->isr_count > MAX_APIC_VECTOR);
@@ -464,7 +440,7 @@ static inline void apic_clear_isr(int vec, struct kvm_lapic *apic)
464 * and must be left alone. 440 * and must be left alone.
465 */ 441 */
466 if (unlikely(vcpu->arch.apicv_active)) 442 if (unlikely(vcpu->arch.apicv_active))
467 kvm_x86_ops->hwapic_isr_update(vcpu->kvm, 443 kvm_x86_ops->hwapic_isr_update(vcpu,
468 apic_find_highest_isr(apic)); 444 apic_find_highest_isr(apic));
469 else { 445 else {
470 --apic->isr_count; 446 --apic->isr_count;
@@ -549,8 +525,8 @@ static void apic_update_ppr(struct kvm_lapic *apic)
549 u32 tpr, isrv, ppr, old_ppr; 525 u32 tpr, isrv, ppr, old_ppr;
550 int isr; 526 int isr;
551 527
552 old_ppr = kvm_apic_get_reg(apic, APIC_PROCPRI); 528 old_ppr = kvm_lapic_get_reg(apic, APIC_PROCPRI);
553 tpr = kvm_apic_get_reg(apic, APIC_TASKPRI); 529 tpr = kvm_lapic_get_reg(apic, APIC_TASKPRI);
554 isr = apic_find_highest_isr(apic); 530 isr = apic_find_highest_isr(apic);
555 isrv = (isr != -1) ? isr : 0; 531 isrv = (isr != -1) ? isr : 0;
556 532
@@ -563,7 +539,7 @@ static void apic_update_ppr(struct kvm_lapic *apic)
563 apic, ppr, isr, isrv); 539 apic, ppr, isr, isrv);
564 540
565 if (old_ppr != ppr) { 541 if (old_ppr != ppr) {
566 apic_set_reg(apic, APIC_PROCPRI, ppr); 542 kvm_lapic_set_reg(apic, APIC_PROCPRI, ppr);
567 if (ppr < old_ppr) 543 if (ppr < old_ppr)
568 kvm_make_request(KVM_REQ_EVENT, apic->vcpu); 544 kvm_make_request(KVM_REQ_EVENT, apic->vcpu);
569 } 545 }
@@ -571,7 +547,7 @@ static void apic_update_ppr(struct kvm_lapic *apic)
571 547
572static void apic_set_tpr(struct kvm_lapic *apic, u32 tpr) 548static void apic_set_tpr(struct kvm_lapic *apic, u32 tpr)
573{ 549{
574 apic_set_reg(apic, APIC_TASKPRI, tpr); 550 kvm_lapic_set_reg(apic, APIC_TASKPRI, tpr);
575 apic_update_ppr(apic); 551 apic_update_ppr(apic);
576} 552}
577 553
@@ -601,7 +577,7 @@ static bool kvm_apic_match_logical_addr(struct kvm_lapic *apic, u32 mda)
601 if (kvm_apic_broadcast(apic, mda)) 577 if (kvm_apic_broadcast(apic, mda))
602 return true; 578 return true;
603 579
604 logical_id = kvm_apic_get_reg(apic, APIC_LDR); 580 logical_id = kvm_lapic_get_reg(apic, APIC_LDR);
605 581
606 if (apic_x2apic_mode(apic)) 582 if (apic_x2apic_mode(apic))
607 return ((logical_id >> 16) == (mda >> 16)) 583 return ((logical_id >> 16) == (mda >> 16))
@@ -610,7 +586,7 @@ static bool kvm_apic_match_logical_addr(struct kvm_lapic *apic, u32 mda)
610 logical_id = GET_APIC_LOGICAL_ID(logical_id); 586 logical_id = GET_APIC_LOGICAL_ID(logical_id);
611 mda = GET_APIC_DEST_FIELD(mda); 587 mda = GET_APIC_DEST_FIELD(mda);
612 588
613 switch (kvm_apic_get_reg(apic, APIC_DFR)) { 589 switch (kvm_lapic_get_reg(apic, APIC_DFR)) {
614 case APIC_DFR_FLAT: 590 case APIC_DFR_FLAT:
615 return (logical_id & mda) != 0; 591 return (logical_id & mda) != 0;
616 case APIC_DFR_CLUSTER: 592 case APIC_DFR_CLUSTER:
@@ -618,7 +594,7 @@ static bool kvm_apic_match_logical_addr(struct kvm_lapic *apic, u32 mda)
618 && (logical_id & mda & 0xf) != 0; 594 && (logical_id & mda & 0xf) != 0;
619 default: 595 default:
620 apic_debug("Bad DFR vcpu %d: %08x\n", 596 apic_debug("Bad DFR vcpu %d: %08x\n",
621 apic->vcpu->vcpu_id, kvm_apic_get_reg(apic, APIC_DFR)); 597 apic->vcpu->vcpu_id, kvm_lapic_get_reg(apic, APIC_DFR));
622 return false; 598 return false;
623 } 599 }
624} 600}
@@ -668,6 +644,7 @@ bool kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source,
668 return false; 644 return false;
669 } 645 }
670} 646}
647EXPORT_SYMBOL_GPL(kvm_apic_match_dest);
671 648
672int kvm_vector_to_index(u32 vector, u32 dest_vcpus, 649int kvm_vector_to_index(u32 vector, u32 dest_vcpus,
673 const unsigned long *bitmap, u32 bitmap_size) 650 const unsigned long *bitmap, u32 bitmap_size)
@@ -921,7 +898,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
921 898
922 if (apic_test_vector(vector, apic->regs + APIC_TMR) != !!trig_mode) { 899 if (apic_test_vector(vector, apic->regs + APIC_TMR) != !!trig_mode) {
923 if (trig_mode) 900 if (trig_mode)
924 apic_set_vector(vector, apic->regs + APIC_TMR); 901 kvm_lapic_set_vector(vector, apic->regs + APIC_TMR);
925 else 902 else
926 apic_clear_vector(vector, apic->regs + APIC_TMR); 903 apic_clear_vector(vector, apic->regs + APIC_TMR);
927 } 904 }
@@ -929,7 +906,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
929 if (vcpu->arch.apicv_active) 906 if (vcpu->arch.apicv_active)
930 kvm_x86_ops->deliver_posted_interrupt(vcpu, vector); 907 kvm_x86_ops->deliver_posted_interrupt(vcpu, vector);
931 else { 908 else {
932 apic_set_irr(vector, apic); 909 kvm_lapic_set_irr(vector, apic);
933 910
934 kvm_make_request(KVM_REQ_EVENT, vcpu); 911 kvm_make_request(KVM_REQ_EVENT, vcpu);
935 kvm_vcpu_kick(vcpu); 912 kvm_vcpu_kick(vcpu);
@@ -1073,8 +1050,8 @@ EXPORT_SYMBOL_GPL(kvm_apic_set_eoi_accelerated);
1073 1050
1074static void apic_send_ipi(struct kvm_lapic *apic) 1051static void apic_send_ipi(struct kvm_lapic *apic)
1075{ 1052{
1076 u32 icr_low = kvm_apic_get_reg(apic, APIC_ICR); 1053 u32 icr_low = kvm_lapic_get_reg(apic, APIC_ICR);
1077 u32 icr_high = kvm_apic_get_reg(apic, APIC_ICR2); 1054 u32 icr_high = kvm_lapic_get_reg(apic, APIC_ICR2);
1078 struct kvm_lapic_irq irq; 1055 struct kvm_lapic_irq irq;
1079 1056
1080 irq.vector = icr_low & APIC_VECTOR_MASK; 1057 irq.vector = icr_low & APIC_VECTOR_MASK;
@@ -1111,7 +1088,7 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic)
1111 ASSERT(apic != NULL); 1088 ASSERT(apic != NULL);
1112 1089
1113 /* if initial count is 0, current count should also be 0 */ 1090 /* if initial count is 0, current count should also be 0 */
1114 if (kvm_apic_get_reg(apic, APIC_TMICT) == 0 || 1091 if (kvm_lapic_get_reg(apic, APIC_TMICT) == 0 ||
1115 apic->lapic_timer.period == 0) 1092 apic->lapic_timer.period == 0)
1116 return 0; 1093 return 0;
1117 1094
@@ -1168,13 +1145,13 @@ static u32 __apic_read(struct kvm_lapic *apic, unsigned int offset)
1168 break; 1145 break;
1169 case APIC_PROCPRI: 1146 case APIC_PROCPRI:
1170 apic_update_ppr(apic); 1147 apic_update_ppr(apic);
1171 val = kvm_apic_get_reg(apic, offset); 1148 val = kvm_lapic_get_reg(apic, offset);
1172 break; 1149 break;
1173 case APIC_TASKPRI: 1150 case APIC_TASKPRI:
1174 report_tpr_access(apic, false); 1151 report_tpr_access(apic, false);
1175 /* fall thru */ 1152 /* fall thru */
1176 default: 1153 default:
1177 val = kvm_apic_get_reg(apic, offset); 1154 val = kvm_lapic_get_reg(apic, offset);
1178 break; 1155 break;
1179 } 1156 }
1180 1157
@@ -1186,7 +1163,7 @@ static inline struct kvm_lapic *to_lapic(struct kvm_io_device *dev)
1186 return container_of(dev, struct kvm_lapic, dev); 1163 return container_of(dev, struct kvm_lapic, dev);
1187} 1164}
1188 1165
1189static int apic_reg_read(struct kvm_lapic *apic, u32 offset, int len, 1166int kvm_lapic_reg_read(struct kvm_lapic *apic, u32 offset, int len,
1190 void *data) 1167 void *data)
1191{ 1168{
1192 unsigned char alignment = offset & 0xf; 1169 unsigned char alignment = offset & 0xf;
@@ -1223,6 +1200,7 @@ static int apic_reg_read(struct kvm_lapic *apic, u32 offset, int len,
1223 } 1200 }
1224 return 0; 1201 return 0;
1225} 1202}
1203EXPORT_SYMBOL_GPL(kvm_lapic_reg_read);
1226 1204
1227static int apic_mmio_in_range(struct kvm_lapic *apic, gpa_t addr) 1205static int apic_mmio_in_range(struct kvm_lapic *apic, gpa_t addr)
1228{ 1206{
@@ -1240,7 +1218,7 @@ static int apic_mmio_read(struct kvm_vcpu *vcpu, struct kvm_io_device *this,
1240 if (!apic_mmio_in_range(apic, address)) 1218 if (!apic_mmio_in_range(apic, address))
1241 return -EOPNOTSUPP; 1219 return -EOPNOTSUPP;
1242 1220
1243 apic_reg_read(apic, offset, len, data); 1221 kvm_lapic_reg_read(apic, offset, len, data);
1244 1222
1245 return 0; 1223 return 0;
1246} 1224}
@@ -1249,7 +1227,7 @@ static void update_divide_count(struct kvm_lapic *apic)
1249{ 1227{
1250 u32 tmp1, tmp2, tdcr; 1228 u32 tmp1, tmp2, tdcr;
1251 1229
1252 tdcr = kvm_apic_get_reg(apic, APIC_TDCR); 1230 tdcr = kvm_lapic_get_reg(apic, APIC_TDCR);
1253 tmp1 = tdcr & 0xf; 1231 tmp1 = tdcr & 0xf;
1254 tmp2 = ((tmp1 & 0x3) | ((tmp1 & 0x8) >> 1)) + 1; 1232 tmp2 = ((tmp1 & 0x3) | ((tmp1 & 0x8) >> 1)) + 1;
1255 apic->divide_count = 0x1 << (tmp2 & 0x7); 1233 apic->divide_count = 0x1 << (tmp2 & 0x7);
@@ -1260,7 +1238,7 @@ static void update_divide_count(struct kvm_lapic *apic)
1260 1238
1261static void apic_update_lvtt(struct kvm_lapic *apic) 1239static void apic_update_lvtt(struct kvm_lapic *apic)
1262{ 1240{
1263 u32 timer_mode = kvm_apic_get_reg(apic, APIC_LVTT) & 1241 u32 timer_mode = kvm_lapic_get_reg(apic, APIC_LVTT) &
1264 apic->lapic_timer.timer_mode_mask; 1242 apic->lapic_timer.timer_mode_mask;
1265 1243
1266 if (apic->lapic_timer.timer_mode != timer_mode) { 1244 if (apic->lapic_timer.timer_mode != timer_mode) {
@@ -1296,7 +1274,7 @@ static void apic_timer_expired(struct kvm_lapic *apic)
1296static bool lapic_timer_int_injected(struct kvm_vcpu *vcpu) 1274static bool lapic_timer_int_injected(struct kvm_vcpu *vcpu)
1297{ 1275{
1298 struct kvm_lapic *apic = vcpu->arch.apic; 1276 struct kvm_lapic *apic = vcpu->arch.apic;
1299 u32 reg = kvm_apic_get_reg(apic, APIC_LVTT); 1277 u32 reg = kvm_lapic_get_reg(apic, APIC_LVTT);
1300 1278
1301 if (kvm_apic_hw_enabled(apic)) { 1279 if (kvm_apic_hw_enabled(apic)) {
1302 int vec = reg & APIC_VECTOR_MASK; 1280 int vec = reg & APIC_VECTOR_MASK;
@@ -1344,7 +1322,7 @@ static void start_apic_timer(struct kvm_lapic *apic)
1344 if (apic_lvtt_period(apic) || apic_lvtt_oneshot(apic)) { 1322 if (apic_lvtt_period(apic) || apic_lvtt_oneshot(apic)) {
1345 /* lapic timer in oneshot or periodic mode */ 1323 /* lapic timer in oneshot or periodic mode */
1346 now = apic->lapic_timer.timer.base->get_time(); 1324 now = apic->lapic_timer.timer.base->get_time();
1347 apic->lapic_timer.period = (u64)kvm_apic_get_reg(apic, APIC_TMICT) 1325 apic->lapic_timer.period = (u64)kvm_lapic_get_reg(apic, APIC_TMICT)
1348 * APIC_BUS_CYCLE_NS * apic->divide_count; 1326 * APIC_BUS_CYCLE_NS * apic->divide_count;
1349 1327
1350 if (!apic->lapic_timer.period) 1328 if (!apic->lapic_timer.period)
@@ -1376,7 +1354,7 @@ static void start_apic_timer(struct kvm_lapic *apic)
1376 "timer initial count 0x%x, period %lldns, " 1354 "timer initial count 0x%x, period %lldns, "
1377 "expire @ 0x%016" PRIx64 ".\n", __func__, 1355 "expire @ 0x%016" PRIx64 ".\n", __func__,
1378 APIC_BUS_CYCLE_NS, ktime_to_ns(now), 1356 APIC_BUS_CYCLE_NS, ktime_to_ns(now),
1379 kvm_apic_get_reg(apic, APIC_TMICT), 1357 kvm_lapic_get_reg(apic, APIC_TMICT),
1380 apic->lapic_timer.period, 1358 apic->lapic_timer.period,
1381 ktime_to_ns(ktime_add_ns(now, 1359 ktime_to_ns(ktime_add_ns(now,
1382 apic->lapic_timer.period))); 1360 apic->lapic_timer.period)));
@@ -1425,7 +1403,7 @@ static void apic_manage_nmi_watchdog(struct kvm_lapic *apic, u32 lvt0_val)
1425 } 1403 }
1426} 1404}
1427 1405
1428static int apic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val) 1406int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
1429{ 1407{
1430 int ret = 0; 1408 int ret = 0;
1431 1409
@@ -1457,7 +1435,7 @@ static int apic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
1457 1435
1458 case APIC_DFR: 1436 case APIC_DFR:
1459 if (!apic_x2apic_mode(apic)) { 1437 if (!apic_x2apic_mode(apic)) {
1460 apic_set_reg(apic, APIC_DFR, val | 0x0FFFFFFF); 1438 kvm_lapic_set_reg(apic, APIC_DFR, val | 0x0FFFFFFF);
1461 recalculate_apic_map(apic->vcpu->kvm); 1439 recalculate_apic_map(apic->vcpu->kvm);
1462 } else 1440 } else
1463 ret = 1; 1441 ret = 1;
@@ -1465,17 +1443,17 @@ static int apic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
1465 1443
1466 case APIC_SPIV: { 1444 case APIC_SPIV: {
1467 u32 mask = 0x3ff; 1445 u32 mask = 0x3ff;
1468 if (kvm_apic_get_reg(apic, APIC_LVR) & APIC_LVR_DIRECTED_EOI) 1446 if (kvm_lapic_get_reg(apic, APIC_LVR) & APIC_LVR_DIRECTED_EOI)
1469 mask |= APIC_SPIV_DIRECTED_EOI; 1447 mask |= APIC_SPIV_DIRECTED_EOI;
1470 apic_set_spiv(apic, val & mask); 1448 apic_set_spiv(apic, val & mask);
1471 if (!(val & APIC_SPIV_APIC_ENABLED)) { 1449 if (!(val & APIC_SPIV_APIC_ENABLED)) {
1472 int i; 1450 int i;
1473 u32 lvt_val; 1451 u32 lvt_val;
1474 1452
1475 for (i = 0; i < APIC_LVT_NUM; i++) { 1453 for (i = 0; i < KVM_APIC_LVT_NUM; i++) {
1476 lvt_val = kvm_apic_get_reg(apic, 1454 lvt_val = kvm_lapic_get_reg(apic,
1477 APIC_LVTT + 0x10 * i); 1455 APIC_LVTT + 0x10 * i);
1478 apic_set_reg(apic, APIC_LVTT + 0x10 * i, 1456 kvm_lapic_set_reg(apic, APIC_LVTT + 0x10 * i,
1479 lvt_val | APIC_LVT_MASKED); 1457 lvt_val | APIC_LVT_MASKED);
1480 } 1458 }
1481 apic_update_lvtt(apic); 1459 apic_update_lvtt(apic);
@@ -1486,14 +1464,14 @@ static int apic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
1486 } 1464 }
1487 case APIC_ICR: 1465 case APIC_ICR:
1488 /* No delay here, so we always clear the pending bit */ 1466 /* No delay here, so we always clear the pending bit */
1489 apic_set_reg(apic, APIC_ICR, val & ~(1 << 12)); 1467 kvm_lapic_set_reg(apic, APIC_ICR, val & ~(1 << 12));
1490 apic_send_ipi(apic); 1468 apic_send_ipi(apic);
1491 break; 1469 break;
1492 1470
1493 case APIC_ICR2: 1471 case APIC_ICR2:
1494 if (!apic_x2apic_mode(apic)) 1472 if (!apic_x2apic_mode(apic))
1495 val &= 0xff000000; 1473 val &= 0xff000000;
1496 apic_set_reg(apic, APIC_ICR2, val); 1474 kvm_lapic_set_reg(apic, APIC_ICR2, val);
1497 break; 1475 break;
1498 1476
1499 case APIC_LVT0: 1477 case APIC_LVT0:
@@ -1507,7 +1485,7 @@ static int apic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
1507 val |= APIC_LVT_MASKED; 1485 val |= APIC_LVT_MASKED;
1508 1486
1509 val &= apic_lvt_mask[(reg - APIC_LVTT) >> 4]; 1487 val &= apic_lvt_mask[(reg - APIC_LVTT) >> 4];
1510 apic_set_reg(apic, reg, val); 1488 kvm_lapic_set_reg(apic, reg, val);
1511 1489
1512 break; 1490 break;
1513 1491
@@ -1515,7 +1493,7 @@ static int apic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
1515 if (!kvm_apic_sw_enabled(apic)) 1493 if (!kvm_apic_sw_enabled(apic))
1516 val |= APIC_LVT_MASKED; 1494 val |= APIC_LVT_MASKED;
1517 val &= (apic_lvt_mask[0] | apic->lapic_timer.timer_mode_mask); 1495 val &= (apic_lvt_mask[0] | apic->lapic_timer.timer_mode_mask);
1518 apic_set_reg(apic, APIC_LVTT, val); 1496 kvm_lapic_set_reg(apic, APIC_LVTT, val);
1519 apic_update_lvtt(apic); 1497 apic_update_lvtt(apic);
1520 break; 1498 break;
1521 1499
@@ -1524,14 +1502,14 @@ static int apic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
1524 break; 1502 break;
1525 1503
1526 hrtimer_cancel(&apic->lapic_timer.timer); 1504 hrtimer_cancel(&apic->lapic_timer.timer);
1527 apic_set_reg(apic, APIC_TMICT, val); 1505 kvm_lapic_set_reg(apic, APIC_TMICT, val);
1528 start_apic_timer(apic); 1506 start_apic_timer(apic);
1529 break; 1507 break;
1530 1508
1531 case APIC_TDCR: 1509 case APIC_TDCR:
1532 if (val & 4) 1510 if (val & 4)
1533 apic_debug("KVM_WRITE:TDCR %x\n", val); 1511 apic_debug("KVM_WRITE:TDCR %x\n", val);
1534 apic_set_reg(apic, APIC_TDCR, val); 1512 kvm_lapic_set_reg(apic, APIC_TDCR, val);
1535 update_divide_count(apic); 1513 update_divide_count(apic);
1536 break; 1514 break;
1537 1515
@@ -1544,7 +1522,7 @@ static int apic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
1544 1522
1545 case APIC_SELF_IPI: 1523 case APIC_SELF_IPI:
1546 if (apic_x2apic_mode(apic)) { 1524 if (apic_x2apic_mode(apic)) {
1547 apic_reg_write(apic, APIC_ICR, 0x40000 | (val & 0xff)); 1525 kvm_lapic_reg_write(apic, APIC_ICR, 0x40000 | (val & 0xff));
1548 } else 1526 } else
1549 ret = 1; 1527 ret = 1;
1550 break; 1528 break;
@@ -1556,6 +1534,7 @@ static int apic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
1556 apic_debug("Local APIC Write to read-only register %x\n", reg); 1534 apic_debug("Local APIC Write to read-only register %x\n", reg);
1557 return ret; 1535 return ret;
1558} 1536}
1537EXPORT_SYMBOL_GPL(kvm_lapic_reg_write);
1559 1538
1560static int apic_mmio_write(struct kvm_vcpu *vcpu, struct kvm_io_device *this, 1539static int apic_mmio_write(struct kvm_vcpu *vcpu, struct kvm_io_device *this,
1561 gpa_t address, int len, const void *data) 1540 gpa_t address, int len, const void *data)
@@ -1585,14 +1564,14 @@ static int apic_mmio_write(struct kvm_vcpu *vcpu, struct kvm_io_device *this,
1585 apic_debug("%s: offset 0x%x with length 0x%x, and value is " 1564 apic_debug("%s: offset 0x%x with length 0x%x, and value is "
1586 "0x%x\n", __func__, offset, len, val); 1565 "0x%x\n", __func__, offset, len, val);
1587 1566
1588 apic_reg_write(apic, offset & 0xff0, val); 1567 kvm_lapic_reg_write(apic, offset & 0xff0, val);
1589 1568
1590 return 0; 1569 return 0;
1591} 1570}
1592 1571
1593void kvm_lapic_set_eoi(struct kvm_vcpu *vcpu) 1572void kvm_lapic_set_eoi(struct kvm_vcpu *vcpu)
1594{ 1573{
1595 apic_reg_write(vcpu->arch.apic, APIC_EOI, 0); 1574 kvm_lapic_reg_write(vcpu->arch.apic, APIC_EOI, 0);
1596} 1575}
1597EXPORT_SYMBOL_GPL(kvm_lapic_set_eoi); 1576EXPORT_SYMBOL_GPL(kvm_lapic_set_eoi);
1598 1577
@@ -1604,10 +1583,10 @@ void kvm_apic_write_nodecode(struct kvm_vcpu *vcpu, u32 offset)
1604 /* hw has done the conditional check and inst decode */ 1583 /* hw has done the conditional check and inst decode */
1605 offset &= 0xff0; 1584 offset &= 0xff0;
1606 1585
1607 apic_reg_read(vcpu->arch.apic, offset, 4, &val); 1586 kvm_lapic_reg_read(vcpu->arch.apic, offset, 4, &val);
1608 1587
1609 /* TODO: optimize to just emulate side effect w/o one more write */ 1588 /* TODO: optimize to just emulate side effect w/o one more write */
1610 apic_reg_write(vcpu->arch.apic, offset, val); 1589 kvm_lapic_reg_write(vcpu->arch.apic, offset, val);
1611} 1590}
1612EXPORT_SYMBOL_GPL(kvm_apic_write_nodecode); 1591EXPORT_SYMBOL_GPL(kvm_apic_write_nodecode);
1613 1592
@@ -1667,14 +1646,14 @@ void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu, unsigned long cr8)
1667 struct kvm_lapic *apic = vcpu->arch.apic; 1646 struct kvm_lapic *apic = vcpu->arch.apic;
1668 1647
1669 apic_set_tpr(apic, ((cr8 & 0x0f) << 4) 1648 apic_set_tpr(apic, ((cr8 & 0x0f) << 4)
1670 | (kvm_apic_get_reg(apic, APIC_TASKPRI) & 4)); 1649 | (kvm_lapic_get_reg(apic, APIC_TASKPRI) & 4));
1671} 1650}
1672 1651
1673u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu) 1652u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu)
1674{ 1653{
1675 u64 tpr; 1654 u64 tpr;
1676 1655
1677 tpr = (u64) kvm_apic_get_reg(vcpu->arch.apic, APIC_TASKPRI); 1656 tpr = (u64) kvm_lapic_get_reg(vcpu->arch.apic, APIC_TASKPRI);
1678 1657
1679 return (tpr & 0xf0) >> 4; 1658 return (tpr & 0xf0) >> 4;
1680} 1659}
@@ -1740,28 +1719,28 @@ void kvm_lapic_reset(struct kvm_vcpu *vcpu, bool init_event)
1740 kvm_apic_set_id(apic, vcpu->vcpu_id); 1719 kvm_apic_set_id(apic, vcpu->vcpu_id);
1741 kvm_apic_set_version(apic->vcpu); 1720 kvm_apic_set_version(apic->vcpu);
1742 1721
1743 for (i = 0; i < APIC_LVT_NUM; i++) 1722 for (i = 0; i < KVM_APIC_LVT_NUM; i++)
1744 apic_set_reg(apic, APIC_LVTT + 0x10 * i, APIC_LVT_MASKED); 1723 kvm_lapic_set_reg(apic, APIC_LVTT + 0x10 * i, APIC_LVT_MASKED);
1745 apic_update_lvtt(apic); 1724 apic_update_lvtt(apic);
1746 if (kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_LINT0_REENABLED)) 1725 if (kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_LINT0_REENABLED))
1747 apic_set_reg(apic, APIC_LVT0, 1726 kvm_lapic_set_reg(apic, APIC_LVT0,
1748 SET_APIC_DELIVERY_MODE(0, APIC_MODE_EXTINT)); 1727 SET_APIC_DELIVERY_MODE(0, APIC_MODE_EXTINT));
1749 apic_manage_nmi_watchdog(apic, kvm_apic_get_reg(apic, APIC_LVT0)); 1728 apic_manage_nmi_watchdog(apic, kvm_lapic_get_reg(apic, APIC_LVT0));
1750 1729
1751 apic_set_reg(apic, APIC_DFR, 0xffffffffU); 1730 kvm_lapic_set_reg(apic, APIC_DFR, 0xffffffffU);
1752 apic_set_spiv(apic, 0xff); 1731 apic_set_spiv(apic, 0xff);
1753 apic_set_reg(apic, APIC_TASKPRI, 0); 1732 kvm_lapic_set_reg(apic, APIC_TASKPRI, 0);
1754 if (!apic_x2apic_mode(apic)) 1733 if (!apic_x2apic_mode(apic))
1755 kvm_apic_set_ldr(apic, 0); 1734 kvm_apic_set_ldr(apic, 0);
1756 apic_set_reg(apic, APIC_ESR, 0); 1735 kvm_lapic_set_reg(apic, APIC_ESR, 0);
1757 apic_set_reg(apic, APIC_ICR, 0); 1736 kvm_lapic_set_reg(apic, APIC_ICR, 0);
1758 apic_set_reg(apic, APIC_ICR2, 0); 1737 kvm_lapic_set_reg(apic, APIC_ICR2, 0);
1759 apic_set_reg(apic, APIC_TDCR, 0); 1738 kvm_lapic_set_reg(apic, APIC_TDCR, 0);
1760 apic_set_reg(apic, APIC_TMICT, 0); 1739 kvm_lapic_set_reg(apic, APIC_TMICT, 0);
1761 for (i = 0; i < 8; i++) { 1740 for (i = 0; i < 8; i++) {
1762 apic_set_reg(apic, APIC_IRR + 0x10 * i, 0); 1741 kvm_lapic_set_reg(apic, APIC_IRR + 0x10 * i, 0);
1763 apic_set_reg(apic, APIC_ISR + 0x10 * i, 0); 1742 kvm_lapic_set_reg(apic, APIC_ISR + 0x10 * i, 0);
1764 apic_set_reg(apic, APIC_TMR + 0x10 * i, 0); 1743 kvm_lapic_set_reg(apic, APIC_TMR + 0x10 * i, 0);
1765 } 1744 }
1766 apic->irr_pending = vcpu->arch.apicv_active; 1745 apic->irr_pending = vcpu->arch.apicv_active;
1767 apic->isr_count = vcpu->arch.apicv_active ? 1 : 0; 1746 apic->isr_count = vcpu->arch.apicv_active ? 1 : 0;
@@ -1806,7 +1785,7 @@ int apic_has_pending_timer(struct kvm_vcpu *vcpu)
1806 1785
1807int kvm_apic_local_deliver(struct kvm_lapic *apic, int lvt_type) 1786int kvm_apic_local_deliver(struct kvm_lapic *apic, int lvt_type)
1808{ 1787{
1809 u32 reg = kvm_apic_get_reg(apic, lvt_type); 1788 u32 reg = kvm_lapic_get_reg(apic, lvt_type);
1810 int vector, mode, trig_mode; 1789 int vector, mode, trig_mode;
1811 1790
1812 if (kvm_apic_hw_enabled(apic) && !(reg & APIC_LVT_MASKED)) { 1791 if (kvm_apic_hw_enabled(apic) && !(reg & APIC_LVT_MASKED)) {
@@ -1901,14 +1880,14 @@ int kvm_apic_has_interrupt(struct kvm_vcpu *vcpu)
1901 apic_update_ppr(apic); 1880 apic_update_ppr(apic);
1902 highest_irr = apic_find_highest_irr(apic); 1881 highest_irr = apic_find_highest_irr(apic);
1903 if ((highest_irr == -1) || 1882 if ((highest_irr == -1) ||
1904 ((highest_irr & 0xF0) <= kvm_apic_get_reg(apic, APIC_PROCPRI))) 1883 ((highest_irr & 0xF0) <= kvm_lapic_get_reg(apic, APIC_PROCPRI)))
1905 return -1; 1884 return -1;
1906 return highest_irr; 1885 return highest_irr;
1907} 1886}
1908 1887
1909int kvm_apic_accept_pic_intr(struct kvm_vcpu *vcpu) 1888int kvm_apic_accept_pic_intr(struct kvm_vcpu *vcpu)
1910{ 1889{
1911 u32 lvt0 = kvm_apic_get_reg(vcpu->arch.apic, APIC_LVT0); 1890 u32 lvt0 = kvm_lapic_get_reg(vcpu->arch.apic, APIC_LVT0);
1912 int r = 0; 1891 int r = 0;
1913 1892
1914 if (!kvm_apic_hw_enabled(vcpu->arch.apic)) 1893 if (!kvm_apic_hw_enabled(vcpu->arch.apic))
@@ -1974,7 +1953,7 @@ void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu,
1974 apic_update_ppr(apic); 1953 apic_update_ppr(apic);
1975 hrtimer_cancel(&apic->lapic_timer.timer); 1954 hrtimer_cancel(&apic->lapic_timer.timer);
1976 apic_update_lvtt(apic); 1955 apic_update_lvtt(apic);
1977 apic_manage_nmi_watchdog(apic, kvm_apic_get_reg(apic, APIC_LVT0)); 1956 apic_manage_nmi_watchdog(apic, kvm_lapic_get_reg(apic, APIC_LVT0));
1978 update_divide_count(apic); 1957 update_divide_count(apic);
1979 start_apic_timer(apic); 1958 start_apic_timer(apic);
1980 apic->irr_pending = true; 1959 apic->irr_pending = true;
@@ -1982,9 +1961,11 @@ void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu,
1982 1 : count_vectors(apic->regs + APIC_ISR); 1961 1 : count_vectors(apic->regs + APIC_ISR);
1983 apic->highest_isr_cache = -1; 1962 apic->highest_isr_cache = -1;
1984 if (vcpu->arch.apicv_active) { 1963 if (vcpu->arch.apicv_active) {
1964 if (kvm_x86_ops->apicv_post_state_restore)
1965 kvm_x86_ops->apicv_post_state_restore(vcpu);
1985 kvm_x86_ops->hwapic_irr_update(vcpu, 1966 kvm_x86_ops->hwapic_irr_update(vcpu,
1986 apic_find_highest_irr(apic)); 1967 apic_find_highest_irr(apic));
1987 kvm_x86_ops->hwapic_isr_update(vcpu->kvm, 1968 kvm_x86_ops->hwapic_isr_update(vcpu,
1988 apic_find_highest_isr(apic)); 1969 apic_find_highest_isr(apic));
1989 } 1970 }
1990 kvm_make_request(KVM_REQ_EVENT, vcpu); 1971 kvm_make_request(KVM_REQ_EVENT, vcpu);
@@ -2097,7 +2078,7 @@ void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu)
2097 if (!test_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention)) 2078 if (!test_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention))
2098 return; 2079 return;
2099 2080
2100 tpr = kvm_apic_get_reg(apic, APIC_TASKPRI) & 0xff; 2081 tpr = kvm_lapic_get_reg(apic, APIC_TASKPRI) & 0xff;
2101 max_irr = apic_find_highest_irr(apic); 2082 max_irr = apic_find_highest_irr(apic);
2102 if (max_irr < 0) 2083 if (max_irr < 0)
2103 max_irr = 0; 2084 max_irr = 0;
@@ -2139,8 +2120,8 @@ int kvm_x2apic_msr_write(struct kvm_vcpu *vcpu, u32 msr, u64 data)
2139 2120
2140 /* if this is ICR write vector before command */ 2121 /* if this is ICR write vector before command */
2141 if (reg == APIC_ICR) 2122 if (reg == APIC_ICR)
2142 apic_reg_write(apic, APIC_ICR2, (u32)(data >> 32)); 2123 kvm_lapic_reg_write(apic, APIC_ICR2, (u32)(data >> 32));
2143 return apic_reg_write(apic, reg, (u32)data); 2124 return kvm_lapic_reg_write(apic, reg, (u32)data);
2144} 2125}
2145 2126
2146int kvm_x2apic_msr_read(struct kvm_vcpu *vcpu, u32 msr, u64 *data) 2127int kvm_x2apic_msr_read(struct kvm_vcpu *vcpu, u32 msr, u64 *data)
@@ -2157,10 +2138,10 @@ int kvm_x2apic_msr_read(struct kvm_vcpu *vcpu, u32 msr, u64 *data)
2157 return 1; 2138 return 1;
2158 } 2139 }
2159 2140
2160 if (apic_reg_read(apic, reg, 4, &low)) 2141 if (kvm_lapic_reg_read(apic, reg, 4, &low))
2161 return 1; 2142 return 1;
2162 if (reg == APIC_ICR) 2143 if (reg == APIC_ICR)
2163 apic_reg_read(apic, APIC_ICR2, 4, &high); 2144 kvm_lapic_reg_read(apic, APIC_ICR2, 4, &high);
2164 2145
2165 *data = (((u64)high) << 32) | low; 2146 *data = (((u64)high) << 32) | low;
2166 2147
@@ -2176,8 +2157,8 @@ int kvm_hv_vapic_msr_write(struct kvm_vcpu *vcpu, u32 reg, u64 data)
2176 2157
2177 /* if this is ICR write vector before command */ 2158 /* if this is ICR write vector before command */
2178 if (reg == APIC_ICR) 2159 if (reg == APIC_ICR)
2179 apic_reg_write(apic, APIC_ICR2, (u32)(data >> 32)); 2160 kvm_lapic_reg_write(apic, APIC_ICR2, (u32)(data >> 32));
2180 return apic_reg_write(apic, reg, (u32)data); 2161 return kvm_lapic_reg_write(apic, reg, (u32)data);
2181} 2162}
2182 2163
2183int kvm_hv_vapic_msr_read(struct kvm_vcpu *vcpu, u32 reg, u64 *data) 2164int kvm_hv_vapic_msr_read(struct kvm_vcpu *vcpu, u32 reg, u64 *data)
@@ -2188,10 +2169,10 @@ int kvm_hv_vapic_msr_read(struct kvm_vcpu *vcpu, u32 reg, u64 *data)
2188 if (!lapic_in_kernel(vcpu)) 2169 if (!lapic_in_kernel(vcpu))
2189 return 1; 2170 return 1;
2190 2171
2191 if (apic_reg_read(apic, reg, 4, &low)) 2172 if (kvm_lapic_reg_read(apic, reg, 4, &low))
2192 return 1; 2173 return 1;
2193 if (reg == APIC_ICR) 2174 if (reg == APIC_ICR)
2194 apic_reg_read(apic, APIC_ICR2, 4, &high); 2175 kvm_lapic_reg_read(apic, APIC_ICR2, 4, &high);
2195 2176
2196 *data = (((u64)high) << 32) | low; 2177 *data = (((u64)high) << 32) | low;
2197 2178