diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-03-16 12:55:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-03-16 12:55:35 -0400 |
commit | 10dc3747661bea9215417b659449bb7b8ed3df2c (patch) | |
tree | d943974b4941203a7db2fabe4896852cf0f16bc4 /drivers/clocksource/arm_arch_timer.c | |
parent | 047486d8e7c2a7e8d75b068b69cb67b47364f5d4 (diff) | |
parent | f958ee745f70b60d0e41927cab2c073104bc70c2 (diff) |
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull KVM updates from Paolo Bonzini:
"One of the largest releases for KVM... Hardly any generic
changes, but lots of architecture-specific updates.
ARM:
- VHE support so that we can run the kernel at EL2 on ARMv8.1 systems
- PMU support for guests
- 32bit world switch rewritten in C
- various optimizations to the vgic save/restore code.
PPC:
- enabled KVM-VFIO integration ("VFIO device")
- optimizations to speed up IPIs between vcpus
- in-kernel handling of IOMMU hypercalls
- support for dynamic DMA windows (DDW).
s390:
- provide the floating point registers via sync regs;
- separated instruction vs. data accesses
- dirty log improvements for huge guests
- bugfixes and documentation improvements.
x86:
- Hyper-V VMBus hypercall userspace exit
- alternative implementation of lowest-priority interrupts using
vector hashing (for better VT-d posted interrupt support)
- fixed guest debugging with nested virtualizations
- improved interrupt tracking in the in-kernel IOAPIC
- generic infrastructure for tracking writes to guest
memory - currently its only use is to speedup the legacy shadow
paging (pre-EPT) case, but in the future it will be used for
virtual GPUs as well
- much cleanup (LAPIC, kvmclock, MMU, PIT), including ubsan fixes"
* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (217 commits)
KVM: x86: remove eager_fpu field of struct kvm_vcpu_arch
KVM: x86: disable MPX if host did not enable MPX XSAVE features
arm64: KVM: vgic-v3: Only wipe LRs on vcpu exit
arm64: KVM: vgic-v3: Reset LRs at boot time
arm64: KVM: vgic-v3: Do not save an LR known to be empty
arm64: KVM: vgic-v3: Save maintenance interrupt state only if required
arm64: KVM: vgic-v3: Avoid accessing ICH registers
KVM: arm/arm64: vgic-v2: Make GICD_SGIR quicker to hit
KVM: arm/arm64: vgic-v2: Only wipe LRs on vcpu exit
KVM: arm/arm64: vgic-v2: Reset LRs at boot time
KVM: arm/arm64: vgic-v2: Do not save an LR known to be empty
KVM: arm/arm64: vgic-v2: Move GICH_ELRSR saving to its own function
KVM: arm/arm64: vgic-v2: Save maintenance interrupt state only if required
KVM: arm/arm64: vgic-v2: Avoid accessing GICH registers
KVM: s390: allocate only one DMA page per VM
KVM: s390: enable STFLE interpretation only if enabled for the guest
KVM: s390: wake up when the VCPU cpu timer expires
KVM: s390: step the VCPU timer while in enabled wait
KVM: s390: protect VCPU cpu timer with a seqcount
KVM: s390: step VCPU cpu timer during kvm_run ioctl
...
Diffstat (limited to 'drivers/clocksource/arm_arch_timer.c')
-rw-r--r-- | drivers/clocksource/arm_arch_timer.c | 96 |
1 files changed, 59 insertions, 37 deletions
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index f0dd9d42bc7b..5152b3898155 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c | |||
@@ -75,7 +75,7 @@ static int arch_timer_ppi[MAX_TIMER_PPI]; | |||
75 | 75 | ||
76 | static struct clock_event_device __percpu *arch_timer_evt; | 76 | static struct clock_event_device __percpu *arch_timer_evt; |
77 | 77 | ||
78 | static bool arch_timer_use_virtual = true; | 78 | static enum ppi_nr arch_timer_uses_ppi = VIRT_PPI; |
79 | static bool arch_timer_c3stop; | 79 | static bool arch_timer_c3stop; |
80 | static bool arch_timer_mem_use_virtual; | 80 | static bool arch_timer_mem_use_virtual; |
81 | 81 | ||
@@ -271,16 +271,22 @@ static void __arch_timer_setup(unsigned type, | |||
271 | clk->name = "arch_sys_timer"; | 271 | clk->name = "arch_sys_timer"; |
272 | clk->rating = 450; | 272 | clk->rating = 450; |
273 | clk->cpumask = cpumask_of(smp_processor_id()); | 273 | clk->cpumask = cpumask_of(smp_processor_id()); |
274 | if (arch_timer_use_virtual) { | 274 | clk->irq = arch_timer_ppi[arch_timer_uses_ppi]; |
275 | clk->irq = arch_timer_ppi[VIRT_PPI]; | 275 | switch (arch_timer_uses_ppi) { |
276 | case VIRT_PPI: | ||
276 | clk->set_state_shutdown = arch_timer_shutdown_virt; | 277 | clk->set_state_shutdown = arch_timer_shutdown_virt; |
277 | clk->set_state_oneshot_stopped = arch_timer_shutdown_virt; | 278 | clk->set_state_oneshot_stopped = arch_timer_shutdown_virt; |
278 | clk->set_next_event = arch_timer_set_next_event_virt; | 279 | clk->set_next_event = arch_timer_set_next_event_virt; |
279 | } else { | 280 | break; |
280 | clk->irq = arch_timer_ppi[PHYS_SECURE_PPI]; | 281 | case PHYS_SECURE_PPI: |
282 | case PHYS_NONSECURE_PPI: | ||
283 | case HYP_PPI: | ||
281 | clk->set_state_shutdown = arch_timer_shutdown_phys; | 284 | clk->set_state_shutdown = arch_timer_shutdown_phys; |
282 | clk->set_state_oneshot_stopped = arch_timer_shutdown_phys; | 285 | clk->set_state_oneshot_stopped = arch_timer_shutdown_phys; |
283 | clk->set_next_event = arch_timer_set_next_event_phys; | 286 | clk->set_next_event = arch_timer_set_next_event_phys; |
287 | break; | ||
288 | default: | ||
289 | BUG(); | ||
284 | } | 290 | } |
285 | } else { | 291 | } else { |
286 | clk->features |= CLOCK_EVT_FEAT_DYNIRQ; | 292 | clk->features |= CLOCK_EVT_FEAT_DYNIRQ; |
@@ -350,17 +356,20 @@ static void arch_counter_set_user_access(void) | |||
350 | arch_timer_set_cntkctl(cntkctl); | 356 | arch_timer_set_cntkctl(cntkctl); |
351 | } | 357 | } |
352 | 358 | ||
359 | static bool arch_timer_has_nonsecure_ppi(void) | ||
360 | { | ||
361 | return (arch_timer_uses_ppi == PHYS_SECURE_PPI && | ||
362 | arch_timer_ppi[PHYS_NONSECURE_PPI]); | ||
363 | } | ||
364 | |||
353 | static int arch_timer_setup(struct clock_event_device *clk) | 365 | static int arch_timer_setup(struct clock_event_device *clk) |
354 | { | 366 | { |
355 | __arch_timer_setup(ARCH_CP15_TIMER, clk); | 367 | __arch_timer_setup(ARCH_CP15_TIMER, clk); |
356 | 368 | ||
357 | if (arch_timer_use_virtual) | 369 | enable_percpu_irq(arch_timer_ppi[arch_timer_uses_ppi], 0); |
358 | enable_percpu_irq(arch_timer_ppi[VIRT_PPI], 0); | 370 | |
359 | else { | 371 | if (arch_timer_has_nonsecure_ppi()) |
360 | enable_percpu_irq(arch_timer_ppi[PHYS_SECURE_PPI], 0); | 372 | enable_percpu_irq(arch_timer_ppi[PHYS_NONSECURE_PPI], 0); |
361 | if (arch_timer_ppi[PHYS_NONSECURE_PPI]) | ||
362 | enable_percpu_irq(arch_timer_ppi[PHYS_NONSECURE_PPI], 0); | ||
363 | } | ||
364 | 373 | ||
365 | arch_counter_set_user_access(); | 374 | arch_counter_set_user_access(); |
366 | if (IS_ENABLED(CONFIG_ARM_ARCH_TIMER_EVTSTREAM)) | 375 | if (IS_ENABLED(CONFIG_ARM_ARCH_TIMER_EVTSTREAM)) |
@@ -402,7 +411,7 @@ static void arch_timer_banner(unsigned type) | |||
402 | (unsigned long)arch_timer_rate / 1000000, | 411 | (unsigned long)arch_timer_rate / 1000000, |
403 | (unsigned long)(arch_timer_rate / 10000) % 100, | 412 | (unsigned long)(arch_timer_rate / 10000) % 100, |
404 | type & ARCH_CP15_TIMER ? | 413 | type & ARCH_CP15_TIMER ? |
405 | arch_timer_use_virtual ? "virt" : "phys" : | 414 | (arch_timer_uses_ppi == VIRT_PPI) ? "virt" : "phys" : |
406 | "", | 415 | "", |
407 | type == (ARCH_CP15_TIMER | ARCH_MEM_TIMER) ? "/" : "", | 416 | type == (ARCH_CP15_TIMER | ARCH_MEM_TIMER) ? "/" : "", |
408 | type & ARCH_MEM_TIMER ? | 417 | type & ARCH_MEM_TIMER ? |
@@ -472,7 +481,7 @@ static void __init arch_counter_register(unsigned type) | |||
472 | 481 | ||
473 | /* Register the CP15 based counter if we have one */ | 482 | /* Register the CP15 based counter if we have one */ |
474 | if (type & ARCH_CP15_TIMER) { | 483 | if (type & ARCH_CP15_TIMER) { |
475 | if (IS_ENABLED(CONFIG_ARM64) || arch_timer_use_virtual) | 484 | if (IS_ENABLED(CONFIG_ARM64) || arch_timer_uses_ppi == VIRT_PPI) |
476 | arch_timer_read_counter = arch_counter_get_cntvct; | 485 | arch_timer_read_counter = arch_counter_get_cntvct; |
477 | else | 486 | else |
478 | arch_timer_read_counter = arch_counter_get_cntpct; | 487 | arch_timer_read_counter = arch_counter_get_cntpct; |
@@ -502,13 +511,9 @@ static void arch_timer_stop(struct clock_event_device *clk) | |||
502 | pr_debug("arch_timer_teardown disable IRQ%d cpu #%d\n", | 511 | pr_debug("arch_timer_teardown disable IRQ%d cpu #%d\n", |
503 | clk->irq, smp_processor_id()); | 512 | clk->irq, smp_processor_id()); |
504 | 513 | ||
505 | if (arch_timer_use_virtual) | 514 | disable_percpu_irq(arch_timer_ppi[arch_timer_uses_ppi]); |
506 | disable_percpu_irq(arch_timer_ppi[VIRT_PPI]); | 515 | if (arch_timer_has_nonsecure_ppi()) |
507 | else { | 516 | disable_percpu_irq(arch_timer_ppi[PHYS_NONSECURE_PPI]); |
508 | disable_percpu_irq(arch_timer_ppi[PHYS_SECURE_PPI]); | ||
509 | if (arch_timer_ppi[PHYS_NONSECURE_PPI]) | ||
510 | disable_percpu_irq(arch_timer_ppi[PHYS_NONSECURE_PPI]); | ||
511 | } | ||
512 | 517 | ||
513 | clk->set_state_shutdown(clk); | 518 | clk->set_state_shutdown(clk); |
514 | } | 519 | } |
@@ -574,12 +579,14 @@ static int __init arch_timer_register(void) | |||
574 | goto out; | 579 | goto out; |
575 | } | 580 | } |
576 | 581 | ||
577 | if (arch_timer_use_virtual) { | 582 | ppi = arch_timer_ppi[arch_timer_uses_ppi]; |
578 | ppi = arch_timer_ppi[VIRT_PPI]; | 583 | switch (arch_timer_uses_ppi) { |
584 | case VIRT_PPI: | ||
579 | err = request_percpu_irq(ppi, arch_timer_handler_virt, | 585 | err = request_percpu_irq(ppi, arch_timer_handler_virt, |
580 | "arch_timer", arch_timer_evt); | 586 | "arch_timer", arch_timer_evt); |
581 | } else { | 587 | break; |
582 | ppi = arch_timer_ppi[PHYS_SECURE_PPI]; | 588 | case PHYS_SECURE_PPI: |
589 | case PHYS_NONSECURE_PPI: | ||
583 | err = request_percpu_irq(ppi, arch_timer_handler_phys, | 590 | err = request_percpu_irq(ppi, arch_timer_handler_phys, |
584 | "arch_timer", arch_timer_evt); | 591 | "arch_timer", arch_timer_evt); |
585 | if (!err && arch_timer_ppi[PHYS_NONSECURE_PPI]) { | 592 | if (!err && arch_timer_ppi[PHYS_NONSECURE_PPI]) { |
@@ -590,6 +597,13 @@ static int __init arch_timer_register(void) | |||
590 | free_percpu_irq(arch_timer_ppi[PHYS_SECURE_PPI], | 597 | free_percpu_irq(arch_timer_ppi[PHYS_SECURE_PPI], |
591 | arch_timer_evt); | 598 | arch_timer_evt); |
592 | } | 599 | } |
600 | break; | ||
601 | case HYP_PPI: | ||
602 | err = request_percpu_irq(ppi, arch_timer_handler_phys, | ||
603 | "arch_timer", arch_timer_evt); | ||
604 | break; | ||
605 | default: | ||
606 | BUG(); | ||
593 | } | 607 | } |
594 | 608 | ||
595 | if (err) { | 609 | if (err) { |
@@ -614,15 +628,10 @@ static int __init arch_timer_register(void) | |||
614 | out_unreg_notify: | 628 | out_unreg_notify: |
615 | unregister_cpu_notifier(&arch_timer_cpu_nb); | 629 | unregister_cpu_notifier(&arch_timer_cpu_nb); |
616 | out_free_irq: | 630 | out_free_irq: |
617 | if (arch_timer_use_virtual) | 631 | free_percpu_irq(arch_timer_ppi[arch_timer_uses_ppi], arch_timer_evt); |
618 | free_percpu_irq(arch_timer_ppi[VIRT_PPI], arch_timer_evt); | 632 | if (arch_timer_has_nonsecure_ppi()) |
619 | else { | 633 | free_percpu_irq(arch_timer_ppi[PHYS_NONSECURE_PPI], |
620 | free_percpu_irq(arch_timer_ppi[PHYS_SECURE_PPI], | ||
621 | arch_timer_evt); | 634 | arch_timer_evt); |
622 | if (arch_timer_ppi[PHYS_NONSECURE_PPI]) | ||
623 | free_percpu_irq(arch_timer_ppi[PHYS_NONSECURE_PPI], | ||
624 | arch_timer_evt); | ||
625 | } | ||
626 | 635 | ||
627 | out_free: | 636 | out_free: |
628 | free_percpu(arch_timer_evt); | 637 | free_percpu(arch_timer_evt); |
@@ -709,12 +718,25 @@ static void __init arch_timer_init(void) | |||
709 | * | 718 | * |
710 | * If no interrupt provided for virtual timer, we'll have to | 719 | * If no interrupt provided for virtual timer, we'll have to |
711 | * stick to the physical timer. It'd better be accessible... | 720 | * stick to the physical timer. It'd better be accessible... |
721 | * | ||
722 | * On ARMv8.1 with VH extensions, the kernel runs in HYP. VHE | ||
723 | * accesses to CNTP_*_EL1 registers are silently redirected to | ||
724 | * their CNTHP_*_EL2 counterparts, and use a different PPI | ||
725 | * number. | ||
712 | */ | 726 | */ |
713 | if (is_hyp_mode_available() || !arch_timer_ppi[VIRT_PPI]) { | 727 | if (is_hyp_mode_available() || !arch_timer_ppi[VIRT_PPI]) { |
714 | arch_timer_use_virtual = false; | 728 | bool has_ppi; |
729 | |||
730 | if (is_kernel_in_hyp_mode()) { | ||
731 | arch_timer_uses_ppi = HYP_PPI; | ||
732 | has_ppi = !!arch_timer_ppi[HYP_PPI]; | ||
733 | } else { | ||
734 | arch_timer_uses_ppi = PHYS_SECURE_PPI; | ||
735 | has_ppi = (!!arch_timer_ppi[PHYS_SECURE_PPI] || | ||
736 | !!arch_timer_ppi[PHYS_NONSECURE_PPI]); | ||
737 | } | ||
715 | 738 | ||
716 | if (!arch_timer_ppi[PHYS_SECURE_PPI] || | 739 | if (!has_ppi) { |
717 | !arch_timer_ppi[PHYS_NONSECURE_PPI]) { | ||
718 | pr_warn("arch_timer: No interrupt available, giving up\n"); | 740 | pr_warn("arch_timer: No interrupt available, giving up\n"); |
719 | return; | 741 | return; |
720 | } | 742 | } |
@@ -747,7 +769,7 @@ static void __init arch_timer_of_init(struct device_node *np) | |||
747 | */ | 769 | */ |
748 | if (IS_ENABLED(CONFIG_ARM) && | 770 | if (IS_ENABLED(CONFIG_ARM) && |
749 | of_property_read_bool(np, "arm,cpu-registers-not-fw-configured")) | 771 | of_property_read_bool(np, "arm,cpu-registers-not-fw-configured")) |
750 | arch_timer_use_virtual = false; | 772 | arch_timer_uses_ppi = PHYS_SECURE_PPI; |
751 | 773 | ||
752 | arch_timer_init(); | 774 | arch_timer_init(); |
753 | } | 775 | } |