Skip to content

Commit c756ad0

Browse files
committed
Merge tag 'kvm-s390-20140721' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into kvm-next
Bugfixes -------- - add IPTE to trace event decoder - document and advertise KVM_CAP_S390_IRQCHIP Cleanups -------- - Reuse kvm_vcpu_block for s390 - Get rid of tasklet for wakup processing
2 parents 6f43ed0 + e59d120 commit c756ad0

7 files changed

Lines changed: 82 additions & 104 deletions

File tree

‎Documentation/virtual/kvm/api.txt‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2934,15 +2934,18 @@ The fields in each entry are defined as follows:
29342934
6. Capabilities that can be enabled
29352935
-----------------------------------
29362936

2937-
There are certain capabilities that change the behavior of the virtual CPU when
2938-
enabled. To enable them, please see section 4.37. Below you can find a list of
2939-
capabilities and what their effect on the vCPU is when enabling them.
2937+
There are certain capabilities that change the behavior of the virtual CPU or
2938+
the virtual machine when enabled. To enable them, please see section 4.37.
2939+
Below you can find a list of capabilities and what their effect on the vCPU or
2940+
the virtual machine is when enabling them.
29402941

29412942
The following information is provided along with the description:
29422943

29432944
Architectures: which instruction set architectures provide this ioctl.
29442945
x86 includes both i386 and x86_64.
29452946

2947+
Target: whether this is a per-vcpu or per-vm capability.
2948+
29462949
Parameters: what parameters are accepted by the capability.
29472950

29482951
Returns: the return value. General error numbers (EBADF, ENOMEM, EINVAL)
@@ -2952,6 +2955,7 @@ The following information is provided along with the description:
29522955
6.1 KVM_CAP_PPC_OSI
29532956

29542957
Architectures: ppc
2958+
Target: vcpu
29552959
Parameters: none
29562960
Returns: 0 on success; -1 on error
29572961

@@ -2966,6 +2970,7 @@ When this capability is enabled, KVM_EXIT_OSI can occur.
29662970
6.2 KVM_CAP_PPC_PAPR
29672971

29682972
Architectures: ppc
2973+
Target: vcpu
29692974
Parameters: none
29702975
Returns: 0 on success; -1 on error
29712976

@@ -2985,6 +2990,7 @@ When this capability is enabled, KVM_EXIT_PAPR_HCALL can occur.
29852990
6.3 KVM_CAP_SW_TLB
29862991

29872992
Architectures: ppc
2993+
Target: vcpu
29882994
Parameters: args[0] is the address of a struct kvm_config_tlb
29892995
Returns: 0 on success; -1 on error
29902996

@@ -3027,6 +3033,7 @@ For mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV:
30273033
6.4 KVM_CAP_S390_CSS_SUPPORT
30283034

30293035
Architectures: s390
3036+
Target: vcpu
30303037
Parameters: none
30313038
Returns: 0 on success; -1 on error
30323039

@@ -3038,9 +3045,13 @@ handled in-kernel, while the other I/O instructions are passed to userspace.
30383045
When this capability is enabled, KVM_EXIT_S390_TSCH will occur on TEST
30393046
SUBCHANNEL intercepts.
30403047

3048+
Note that even though this capability is enabled per-vcpu, the complete
3049+
virtual machine is affected.
3050+
30413051
6.5 KVM_CAP_PPC_EPR
30423052

30433053
Architectures: ppc
3054+
Target: vcpu
30443055
Parameters: args[0] defines whether the proxy facility is active
30453056
Returns: 0 on success; -1 on error
30463057

@@ -3066,7 +3077,17 @@ This capability connects the vcpu to an in-kernel MPIC device.
30663077
6.7 KVM_CAP_IRQ_XICS
30673078

30683079
Architectures: ppc
3080+
Target: vcpu
30693081
Parameters: args[0] is the XICS device fd
30703082
args[1] is the XICS CPU number (server ID) for this vcpu
30713083

30723084
This capability connects the vcpu to an in-kernel XICS device.
3085+
3086+
6.8 KVM_CAP_S390_IRQCHIP
3087+
3088+
Architectures: s390
3089+
Target: vm
3090+
Parameters: none
3091+
3092+
This capability enables the in-kernel irqchip for s390. Please refer to
3093+
"4.24 KVM_CREATE_IRQCHIP" for details.

‎arch/s390/include/asm/kvm_host.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ struct kvm_s390_local_interrupt {
305305
struct list_head list;
306306
atomic_t active;
307307
struct kvm_s390_float_interrupt *float_int;
308-
int timer_due; /* event indicator for waitqueue below */
309308
wait_queue_head_t *wq;
310309
atomic_t *cpuflags;
311310
unsigned int action_bits;
@@ -367,7 +366,6 @@ struct kvm_vcpu_arch {
367366
s390_fp_regs guest_fpregs;
368367
struct kvm_s390_local_interrupt local_int;
369368
struct hrtimer ckc_timer;
370-
struct tasklet_struct tasklet;
371369
struct kvm_s390_pgm_info pgm;
372370
union {
373371
struct cpuid cpu_id;

‎arch/s390/include/uapi/asm/sie.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
exit_code_ipa0(0xB2, 0x17, "STETR"), \
109109
exit_code_ipa0(0xB2, 0x18, "PC"), \
110110
exit_code_ipa0(0xB2, 0x20, "SERVC"), \
111+
exit_code_ipa0(0xB2, 0x21, "IPTE"), \
111112
exit_code_ipa0(0xB2, 0x28, "PT"), \
112113
exit_code_ipa0(0xB2, 0x29, "ISKE"), \
113114
exit_code_ipa0(0xB2, 0x2a, "RRBE"), \

‎arch/s390/kvm/interrupt.c‎

Lines changed: 32 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -544,13 +544,13 @@ int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu)
544544
int rc = 0;
545545

546546
if (atomic_read(&li->active)) {
547-
spin_lock_bh(&li->lock);
547+
spin_lock(&li->lock);
548548
list_for_each_entry(inti, &li->list, list)
549549
if (__interrupt_is_deliverable(vcpu, inti)) {
550550
rc = 1;
551551
break;
552552
}
553-
spin_unlock_bh(&li->lock);
553+
spin_unlock(&li->lock);
554554
}
555555

556556
if ((!rc) && atomic_read(&fi->active)) {
@@ -585,88 +585,56 @@ int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu)
585585
int kvm_s390_handle_wait(struct kvm_vcpu *vcpu)
586586
{
587587
u64 now, sltime;
588-
DECLARE_WAITQUEUE(wait, current);
589588

590589
vcpu->stat.exit_wait_state++;
591-
if (kvm_cpu_has_interrupt(vcpu))
592-
return 0;
593590

594-
__set_cpu_idle(vcpu);
595-
spin_lock_bh(&vcpu->arch.local_int.lock);
596-
vcpu->arch.local_int.timer_due = 0;
597-
spin_unlock_bh(&vcpu->arch.local_int.lock);
591+
/* fast path */
592+
if (kvm_cpu_has_pending_timer(vcpu) || kvm_arch_vcpu_runnable(vcpu))
593+
return 0;
598594

599595
if (psw_interrupts_disabled(vcpu)) {
600596
VCPU_EVENT(vcpu, 3, "%s", "disabled wait");
601-
__unset_cpu_idle(vcpu);
602597
return -EOPNOTSUPP; /* disabled wait */
603598
}
604599

600+
__set_cpu_idle(vcpu);
605601
if (!ckc_interrupts_enabled(vcpu)) {
606602
VCPU_EVENT(vcpu, 3, "%s", "enabled wait w/o timer");
607603
goto no_timer;
608604
}
609605

610606
now = get_tod_clock_fast() + vcpu->arch.sie_block->epoch;
611-
if (vcpu->arch.sie_block->ckc < now) {
612-
__unset_cpu_idle(vcpu);
613-
return 0;
614-
}
615-
616607
sltime = tod_to_ns(vcpu->arch.sie_block->ckc - now);
617-
618608
hrtimer_start(&vcpu->arch.ckc_timer, ktime_set (0, sltime) , HRTIMER_MODE_REL);
619609
VCPU_EVENT(vcpu, 5, "enabled wait via clock comparator: %llx ns", sltime);
620610
no_timer:
621611
srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
622-
spin_lock(&vcpu->arch.local_int.float_int->lock);
623-
spin_lock_bh(&vcpu->arch.local_int.lock);
624-
add_wait_queue(&vcpu->wq, &wait);
625-
while (list_empty(&vcpu->arch.local_int.list) &&
626-
list_empty(&vcpu->arch.local_int.float_int->list) &&
627-
(!vcpu->arch.local_int.timer_due) &&
628-
!signal_pending(current) &&
629-
!kvm_s390_si_ext_call_pending(vcpu)) {
630-
set_current_state(TASK_INTERRUPTIBLE);
631-
spin_unlock_bh(&vcpu->arch.local_int.lock);
632-
spin_unlock(&vcpu->arch.local_int.float_int->lock);
633-
schedule();
634-
spin_lock(&vcpu->arch.local_int.float_int->lock);
635-
spin_lock_bh(&vcpu->arch.local_int.lock);
636-
}
612+
kvm_vcpu_block(vcpu);
637613
__unset_cpu_idle(vcpu);
638-
__set_current_state(TASK_RUNNING);
639-
remove_wait_queue(&vcpu->wq, &wait);
640-
spin_unlock_bh(&vcpu->arch.local_int.lock);
641-
spin_unlock(&vcpu->arch.local_int.float_int->lock);
642614
vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
643615

644616
hrtimer_try_to_cancel(&vcpu->arch.ckc_timer);
645617
return 0;
646618
}
647619

648-
void kvm_s390_tasklet(unsigned long parm)
620+
void kvm_s390_vcpu_wakeup(struct kvm_vcpu *vcpu)
649621
{
650-
struct kvm_vcpu *vcpu = (struct kvm_vcpu *) parm;
651-
652-
spin_lock(&vcpu->arch.local_int.lock);
653-
vcpu->arch.local_int.timer_due = 1;
654-
if (waitqueue_active(&vcpu->wq))
622+
if (waitqueue_active(&vcpu->wq)) {
623+
/*
624+
* The vcpu gave up the cpu voluntarily, mark it as a good
625+
* yield-candidate.
626+
*/
627+
vcpu->preempted = true;
655628
wake_up_interruptible(&vcpu->wq);
656-
spin_unlock(&vcpu->arch.local_int.lock);
629+
}
657630
}
658631

659-
/*
660-
* low level hrtimer wake routine. Because this runs in hardirq context
661-
* we schedule a tasklet to do the real work.
662-
*/
663632
enum hrtimer_restart kvm_s390_idle_wakeup(struct hrtimer *timer)
664633
{
665634
struct kvm_vcpu *vcpu;
666635

667636
vcpu = container_of(timer, struct kvm_vcpu, arch.ckc_timer);
668-
vcpu->preempted = true;
669-
tasklet_schedule(&vcpu->arch.tasklet);
637+
kvm_s390_vcpu_wakeup(vcpu);
670638

671639
return HRTIMER_NORESTART;
672640
}
@@ -676,13 +644,13 @@ void kvm_s390_clear_local_irqs(struct kvm_vcpu *vcpu)
676644
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
677645
struct kvm_s390_interrupt_info *n, *inti = NULL;
678646

679-
spin_lock_bh(&li->lock);
647+
spin_lock(&li->lock);
680648
list_for_each_entry_safe(inti, n, &li->list, list) {
681649
list_del(&inti->list);
682650
kfree(inti);
683651
}
684652
atomic_set(&li->active, 0);
685-
spin_unlock_bh(&li->lock);
653+
spin_unlock(&li->lock);
686654

687655
/* clear pending external calls set by sigp interpretation facility */
688656
atomic_clear_mask(CPUSTAT_ECALL_PEND, &vcpu->arch.sie_block->cpuflags);
@@ -701,7 +669,7 @@ void kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu)
701669
if (atomic_read(&li->active)) {
702670
do {
703671
deliver = 0;
704-
spin_lock_bh(&li->lock);
672+
spin_lock(&li->lock);
705673
list_for_each_entry_safe(inti, n, &li->list, list) {
706674
if (__interrupt_is_deliverable(vcpu, inti)) {
707675
list_del(&inti->list);
@@ -712,7 +680,7 @@ void kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu)
712680
}
713681
if (list_empty(&li->list))
714682
atomic_set(&li->active, 0);
715-
spin_unlock_bh(&li->lock);
683+
spin_unlock(&li->lock);
716684
if (deliver) {
717685
__do_deliver_interrupt(vcpu, inti);
718686
kfree(inti);
@@ -758,7 +726,7 @@ void kvm_s390_deliver_pending_machine_checks(struct kvm_vcpu *vcpu)
758726
if (atomic_read(&li->active)) {
759727
do {
760728
deliver = 0;
761-
spin_lock_bh(&li->lock);
729+
spin_lock(&li->lock);
762730
list_for_each_entry_safe(inti, n, &li->list, list) {
763731
if ((inti->type == KVM_S390_MCHK) &&
764732
__interrupt_is_deliverable(vcpu, inti)) {
@@ -770,7 +738,7 @@ void kvm_s390_deliver_pending_machine_checks(struct kvm_vcpu *vcpu)
770738
}
771739
if (list_empty(&li->list))
772740
atomic_set(&li->active, 0);
773-
spin_unlock_bh(&li->lock);
741+
spin_unlock(&li->lock);
774742
if (deliver) {
775743
__do_deliver_interrupt(vcpu, inti);
776744
kfree(inti);
@@ -817,11 +785,11 @@ int kvm_s390_inject_program_int(struct kvm_vcpu *vcpu, u16 code)
817785

818786
VCPU_EVENT(vcpu, 3, "inject: program check %d (from kernel)", code);
819787
trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, inti->type, code, 0, 1);
820-
spin_lock_bh(&li->lock);
788+
spin_lock(&li->lock);
821789
list_add(&inti->list, &li->list);
822790
atomic_set(&li->active, 1);
823791
BUG_ON(waitqueue_active(li->wq));
824-
spin_unlock_bh(&li->lock);
792+
spin_unlock(&li->lock);
825793
return 0;
826794
}
827795

@@ -842,11 +810,11 @@ int kvm_s390_inject_prog_irq(struct kvm_vcpu *vcpu,
842810

843811
inti->type = KVM_S390_PROGRAM_INT;
844812
memcpy(&inti->pgm, pgm_info, sizeof(inti->pgm));
845-
spin_lock_bh(&li->lock);
813+
spin_lock(&li->lock);
846814
list_add(&inti->list, &li->list);
847815
atomic_set(&li->active, 1);
848816
BUG_ON(waitqueue_active(li->wq));
849-
spin_unlock_bh(&li->lock);
817+
spin_unlock(&li->lock);
850818
return 0;
851819
}
852820

@@ -934,12 +902,10 @@ static int __inject_vm(struct kvm *kvm, struct kvm_s390_interrupt_info *inti)
934902
}
935903
dst_vcpu = kvm_get_vcpu(kvm, sigcpu);
936904
li = &dst_vcpu->arch.local_int;
937-
spin_lock_bh(&li->lock);
905+
spin_lock(&li->lock);
938906
atomic_set_mask(CPUSTAT_EXT_INT, li->cpuflags);
939-
if (waitqueue_active(li->wq))
940-
wake_up_interruptible(li->wq);
941-
kvm_get_vcpu(kvm, sigcpu)->preempted = true;
942-
spin_unlock_bh(&li->lock);
907+
spin_unlock(&li->lock);
908+
kvm_s390_vcpu_wakeup(kvm_get_vcpu(kvm, sigcpu));
943909
unlock_fi:
944910
spin_unlock(&fi->lock);
945911
mutex_unlock(&kvm->lock);
@@ -1081,7 +1047,7 @@ int kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu,
10811047

10821048
mutex_lock(&vcpu->kvm->lock);
10831049
li = &vcpu->arch.local_int;
1084-
spin_lock_bh(&li->lock);
1050+
spin_lock(&li->lock);
10851051
if (inti->type == KVM_S390_PROGRAM_INT)
10861052
list_add(&inti->list, &li->list);
10871053
else
@@ -1090,11 +1056,9 @@ int kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu,
10901056
if (inti->type == KVM_S390_SIGP_STOP)
10911057
li->action_bits |= ACTION_STOP_ON_STOP;
10921058
atomic_set_mask(CPUSTAT_EXT_INT, li->cpuflags);
1093-
if (waitqueue_active(&vcpu->wq))
1094-
wake_up_interruptible(&vcpu->wq);
1095-
vcpu->preempted = true;
1096-
spin_unlock_bh(&li->lock);
1059+
spin_unlock(&li->lock);
10971060
mutex_unlock(&vcpu->kvm->lock);
1061+
kvm_s390_vcpu_wakeup(vcpu);
10981062
return 0;
10991063
}
11001064

0 commit comments

Comments
 (0)