aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-01-12 16:22:12 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-12 16:22:12 -0500
commit1baa5efbeb6eb75de697f7b5931094be33f12005 (patch)
tree30358fcebb950305929306c6654f8a585f1f5500 /arch/x86/include
parentc9bed1cf51011c815d88288b774865d013ca78a8 (diff)
parent45bdbcfdf241149642fb6c25ab0c209d59c371b7 (diff)
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull KVM updates from Paolo Bonzini: "PPC changes will come next week. - s390: Support for runtime instrumentation within guests, support of 248 VCPUs. - ARM: rewrite of the arm64 world switch in C, support for 16-bit VM identifiers. Performance counter virtualization missed the boat. - x86: Support for more Hyper-V features (synthetic interrupt controller), MMU cleanups" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (115 commits) kvm: x86: Fix vmwrite to SECONDARY_VM_EXEC_CONTROL kvm/x86: Hyper-V SynIC timers tracepoints kvm/x86: Hyper-V SynIC tracepoints kvm/x86: Update SynIC timers on guest entry only kvm/x86: Skip SynIC vector check for QEMU side kvm/x86: Hyper-V fix SynIC timer disabling condition kvm/x86: Reorg stimer_expiration() to better control timer restart kvm/x86: Hyper-V unify stimer_start() and stimer_restart() kvm/x86: Drop stimer_stop() function kvm/x86: Hyper-V timers fix incorrect logical operation KVM: move architecture-dependent requests to arch/ KVM: renumber vcpu->request bits KVM: document which architecture uses each request bit KVM: Remove unused KVM_REQ_KICK to save a bit in vcpu->requests kvm: x86: Check kvm_write_guest return value in kvm_write_wall_clock KVM: s390: implement the RI support of guest kvm/s390: drop unpaired smp_mb kvm: x86: fix comment about {mmu,nested_mmu}.gva_to_gpa KVM: x86: MMU: Use clear_page() instead of init_shadow_page_table() arm/arm64: KVM: Detect vGIC presence at runtime ...
Diffstat (limited to 'arch/x86/include')
-rw-r--r--arch/x86/include/asm/kvm_host.h75
-rw-r--r--arch/x86/include/uapi/asm/hyperv.h92
2 files changed, 162 insertions, 5 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 30cfd64295a0..44adbb819041 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -25,6 +25,7 @@
25#include <linux/pvclock_gtod.h> 25#include <linux/pvclock_gtod.h>
26#include <linux/clocksource.h> 26#include <linux/clocksource.h>
27#include <linux/irqbypass.h> 27#include <linux/irqbypass.h>
28#include <linux/hyperv.h>
28 29
29#include <asm/pvclock-abi.h> 30#include <asm/pvclock-abi.h>
30#include <asm/desc.h> 31#include <asm/desc.h>
@@ -45,6 +46,31 @@
45 46
46#define KVM_IRQCHIP_NUM_PINS KVM_IOAPIC_NUM_PINS 47#define KVM_IRQCHIP_NUM_PINS KVM_IOAPIC_NUM_PINS
47 48
49/* x86-specific vcpu->requests bit members */
50#define KVM_REQ_MIGRATE_TIMER 8
51#define KVM_REQ_REPORT_TPR_ACCESS 9
52#define KVM_REQ_TRIPLE_FAULT 10
53#define KVM_REQ_MMU_SYNC 11
54#define KVM_REQ_CLOCK_UPDATE 12
55#define KVM_REQ_DEACTIVATE_FPU 13
56#define KVM_REQ_EVENT 14
57#define KVM_REQ_APF_HALT 15
58#define KVM_REQ_STEAL_UPDATE 16
59#define KVM_REQ_NMI 17
60#define KVM_REQ_PMU 18
61#define KVM_REQ_PMI 19
62#define KVM_REQ_SMI 20
63#define KVM_REQ_MASTERCLOCK_UPDATE 21
64#define KVM_REQ_MCLOCK_INPROGRESS 22
65#define KVM_REQ_SCAN_IOAPIC 23
66#define KVM_REQ_GLOBAL_CLOCK_UPDATE 24
67#define KVM_REQ_APIC_PAGE_RELOAD 25
68#define KVM_REQ_HV_CRASH 26
69#define KVM_REQ_IOAPIC_EOI_EXIT 27
70#define KVM_REQ_HV_RESET 28
71#define KVM_REQ_HV_EXIT 29
72#define KVM_REQ_HV_STIMER 30
73
48#define CR0_RESERVED_BITS \ 74#define CR0_RESERVED_BITS \
49 (~(unsigned long)(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS \ 75 (~(unsigned long)(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS \
50 | X86_CR0_ET | X86_CR0_NE | X86_CR0_WP | X86_CR0_AM \ 76 | X86_CR0_ET | X86_CR0_NE | X86_CR0_WP | X86_CR0_AM \
@@ -213,6 +239,10 @@ union kvm_mmu_page_role {
213 }; 239 };
214}; 240};
215 241
242struct kvm_rmap_head {
243 unsigned long val;
244};
245
216struct kvm_mmu_page { 246struct kvm_mmu_page {
217 struct list_head link; 247 struct list_head link;
218 struct hlist_node hash_link; 248 struct hlist_node hash_link;
@@ -230,7 +260,7 @@ struct kvm_mmu_page {
230 bool unsync; 260 bool unsync;
231 int root_count; /* Currently serving as active root */ 261 int root_count; /* Currently serving as active root */
232 unsigned int unsync_children; 262 unsigned int unsync_children;
233 unsigned long parent_ptes; /* Reverse mapping for parent_pte */ 263 struct kvm_rmap_head parent_ptes; /* rmap pointers to parent sptes */
234 264
235 /* The page is obsolete if mmu_valid_gen != kvm->arch.mmu_valid_gen. */ 265 /* The page is obsolete if mmu_valid_gen != kvm->arch.mmu_valid_gen. */
236 unsigned long mmu_valid_gen; 266 unsigned long mmu_valid_gen;
@@ -374,10 +404,38 @@ struct kvm_mtrr {
374 struct list_head head; 404 struct list_head head;
375}; 405};
376 406
407/* Hyper-V SynIC timer */
408struct kvm_vcpu_hv_stimer {
409 struct hrtimer timer;
410 int index;
411 u64 config;
412 u64 count;
413 u64 exp_time;
414 struct hv_message msg;
415 bool msg_pending;
416};
417
418/* Hyper-V synthetic interrupt controller (SynIC)*/
419struct kvm_vcpu_hv_synic {
420 u64 version;
421 u64 control;
422 u64 msg_page;
423 u64 evt_page;
424 atomic64_t sint[HV_SYNIC_SINT_COUNT];
425 atomic_t sint_to_gsi[HV_SYNIC_SINT_COUNT];
426 DECLARE_BITMAP(auto_eoi_bitmap, 256);
427 DECLARE_BITMAP(vec_bitmap, 256);
428 bool active;
429};
430
377/* Hyper-V per vcpu emulation context */ 431/* Hyper-V per vcpu emulation context */
378struct kvm_vcpu_hv { 432struct kvm_vcpu_hv {
379 u64 hv_vapic; 433 u64 hv_vapic;
380 s64 runtime_offset; 434 s64 runtime_offset;
435 struct kvm_vcpu_hv_synic synic;
436 struct kvm_hyperv_exit exit;
437 struct kvm_vcpu_hv_stimer stimer[HV_SYNIC_STIMER_COUNT];
438 DECLARE_BITMAP(stimer_pending_bitmap, HV_SYNIC_STIMER_COUNT);
381}; 439};
382 440
383struct kvm_vcpu_arch { 441struct kvm_vcpu_arch {
@@ -400,7 +458,8 @@ struct kvm_vcpu_arch {
400 u64 efer; 458 u64 efer;
401 u64 apic_base; 459 u64 apic_base;
402 struct kvm_lapic *apic; /* kernel irqchip context */ 460 struct kvm_lapic *apic; /* kernel irqchip context */
403 u64 eoi_exit_bitmap[4]; 461 bool apicv_active;
462 DECLARE_BITMAP(ioapic_handled_vectors, 256);
404 unsigned long apic_attention; 463 unsigned long apic_attention;
405 int32_t apic_arb_prio; 464 int32_t apic_arb_prio;
406 int mp_state; 465 int mp_state;
@@ -589,7 +648,7 @@ struct kvm_lpage_info {
589}; 648};
590 649
591struct kvm_arch_memory_slot { 650struct kvm_arch_memory_slot {
592 unsigned long *rmap[KVM_NR_PAGE_SIZES]; 651 struct kvm_rmap_head *rmap[KVM_NR_PAGE_SIZES];
593 struct kvm_lpage_info *lpage_info[KVM_NR_PAGE_SIZES - 1]; 652 struct kvm_lpage_info *lpage_info[KVM_NR_PAGE_SIZES - 1];
594}; 653};
595 654
@@ -831,10 +890,11 @@ struct kvm_x86_ops {
831 void (*enable_nmi_window)(struct kvm_vcpu *vcpu); 890 void (*enable_nmi_window)(struct kvm_vcpu *vcpu);
832 void (*enable_irq_window)(struct kvm_vcpu *vcpu); 891 void (*enable_irq_window)(struct kvm_vcpu *vcpu);
833 void (*update_cr8_intercept)(struct kvm_vcpu *vcpu, int tpr, int irr); 892 void (*update_cr8_intercept)(struct kvm_vcpu *vcpu, int tpr, int irr);
834 int (*cpu_uses_apicv)(struct kvm_vcpu *vcpu); 893 bool (*get_enable_apicv)(void);
894 void (*refresh_apicv_exec_ctrl)(struct kvm_vcpu *vcpu);
835 void (*hwapic_irr_update)(struct kvm_vcpu *vcpu, int max_irr); 895 void (*hwapic_irr_update)(struct kvm_vcpu *vcpu, int max_irr);
836 void (*hwapic_isr_update)(struct kvm *kvm, int isr); 896 void (*hwapic_isr_update)(struct kvm *kvm, int isr);
837 void (*load_eoi_exitmap)(struct kvm_vcpu *vcpu); 897 void (*load_eoi_exitmap)(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap);
838 void (*set_virtual_x2apic_mode)(struct kvm_vcpu *vcpu, bool set); 898 void (*set_virtual_x2apic_mode)(struct kvm_vcpu *vcpu, bool set);
839 void (*set_apic_access_page_addr)(struct kvm_vcpu *vcpu, hpa_t hpa); 899 void (*set_apic_access_page_addr)(struct kvm_vcpu *vcpu, hpa_t hpa);
840 void (*deliver_posted_interrupt)(struct kvm_vcpu *vcpu, int vector); 900 void (*deliver_posted_interrupt)(struct kvm_vcpu *vcpu, int vector);
@@ -1086,6 +1146,8 @@ gpa_t kvm_mmu_gva_to_gpa_write(struct kvm_vcpu *vcpu, gva_t gva,
1086gpa_t kvm_mmu_gva_to_gpa_system(struct kvm_vcpu *vcpu, gva_t gva, 1146gpa_t kvm_mmu_gva_to_gpa_system(struct kvm_vcpu *vcpu, gva_t gva,
1087 struct x86_exception *exception); 1147 struct x86_exception *exception);
1088 1148
1149void kvm_vcpu_deactivate_apicv(struct kvm_vcpu *vcpu);
1150
1089int kvm_emulate_hypercall(struct kvm_vcpu *vcpu); 1151int kvm_emulate_hypercall(struct kvm_vcpu *vcpu);
1090 1152
1091int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code, 1153int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code,
@@ -1231,6 +1293,9 @@ u64 kvm_read_l1_tsc(struct kvm_vcpu *vcpu, u64 host_tsc);
1231unsigned long kvm_get_linear_rip(struct kvm_vcpu *vcpu); 1293unsigned long kvm_get_linear_rip(struct kvm_vcpu *vcpu);
1232bool kvm_is_linear_rip(struct kvm_vcpu *vcpu, unsigned long linear_rip); 1294bool kvm_is_linear_rip(struct kvm_vcpu *vcpu, unsigned long linear_rip);
1233 1295
1296void kvm_make_mclock_inprogress_request(struct kvm *kvm);
1297void kvm_make_scan_ioapic_request(struct kvm *kvm);
1298
1234void kvm_arch_async_page_not_present(struct kvm_vcpu *vcpu, 1299void kvm_arch_async_page_not_present(struct kvm_vcpu *vcpu,
1235 struct kvm_async_pf *work); 1300 struct kvm_async_pf *work);
1236void kvm_arch_async_page_present(struct kvm_vcpu *vcpu, 1301void kvm_arch_async_page_present(struct kvm_vcpu *vcpu,
diff --git a/arch/x86/include/uapi/asm/hyperv.h b/arch/x86/include/uapi/asm/hyperv.h
index 040d4083c24f..7956412d09bd 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -269,4 +269,96 @@ typedef struct _HV_REFERENCE_TSC_PAGE {
269#define HV_SYNIC_SINT_AUTO_EOI (1ULL << 17) 269#define HV_SYNIC_SINT_AUTO_EOI (1ULL << 17)
270#define HV_SYNIC_SINT_VECTOR_MASK (0xFF) 270#define HV_SYNIC_SINT_VECTOR_MASK (0xFF)
271 271
272#define HV_SYNIC_STIMER_COUNT (4)
273
274/* Define synthetic interrupt controller message constants. */
275#define HV_MESSAGE_SIZE (256)
276#define HV_MESSAGE_PAYLOAD_BYTE_COUNT (240)
277#define HV_MESSAGE_PAYLOAD_QWORD_COUNT (30)
278
279/* Define hypervisor message types. */
280enum hv_message_type {
281 HVMSG_NONE = 0x00000000,
282
283 /* Memory access messages. */
284 HVMSG_UNMAPPED_GPA = 0x80000000,
285 HVMSG_GPA_INTERCEPT = 0x80000001,
286
287 /* Timer notification messages. */
288 HVMSG_TIMER_EXPIRED = 0x80000010,
289
290 /* Error messages. */
291 HVMSG_INVALID_VP_REGISTER_VALUE = 0x80000020,
292 HVMSG_UNRECOVERABLE_EXCEPTION = 0x80000021,
293 HVMSG_UNSUPPORTED_FEATURE = 0x80000022,
294
295 /* Trace buffer complete messages. */
296 HVMSG_EVENTLOG_BUFFERCOMPLETE = 0x80000040,
297
298 /* Platform-specific processor intercept messages. */
299 HVMSG_X64_IOPORT_INTERCEPT = 0x80010000,
300 HVMSG_X64_MSR_INTERCEPT = 0x80010001,
301 HVMSG_X64_CPUID_INTERCEPT = 0x80010002,
302 HVMSG_X64_EXCEPTION_INTERCEPT = 0x80010003,
303 HVMSG_X64_APIC_EOI = 0x80010004,
304 HVMSG_X64_LEGACY_FP_ERROR = 0x80010005
305};
306
307/* Define synthetic interrupt controller message flags. */
308union hv_message_flags {
309 __u8 asu8;
310 struct {
311 __u8 msg_pending:1;
312 __u8 reserved:7;
313 };
314};
315
316/* Define port identifier type. */
317union hv_port_id {
318 __u32 asu32;
319 struct {
320 __u32 id:24;
321 __u32 reserved:8;
322 } u;
323};
324
325/* Define synthetic interrupt controller message header. */
326struct hv_message_header {
327 __u32 message_type;
328 __u8 payload_size;
329 union hv_message_flags message_flags;
330 __u8 reserved[2];
331 union {
332 __u64 sender;
333 union hv_port_id port;
334 };
335};
336
337/* Define synthetic interrupt controller message format. */
338struct hv_message {
339 struct hv_message_header header;
340 union {
341 __u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
342 } u;
343};
344
345/* Define the synthetic interrupt message page layout. */
346struct hv_message_page {
347 struct hv_message sint_message[HV_SYNIC_SINT_COUNT];
348};
349
350/* Define timer message payload structure. */
351struct hv_timer_message_payload {
352 __u32 timer_index;
353 __u32 reserved;
354 __u64 expiration_time; /* When the timer expired */
355 __u64 delivery_time; /* When the message was delivered */
356};
357
358#define HV_STIMER_ENABLE (1ULL << 0)
359#define HV_STIMER_PERIODIC (1ULL << 1)
360#define HV_STIMER_LAZY (1ULL << 2)
361#define HV_STIMER_AUTOENABLE (1ULL << 3)
362#define HV_STIMER_SINT(config) (__u8)(((config) >> 16) & 0x0F)
363
272#endif 364#endif