diff options
author | David Hildenbrand <dahi@linux.vnet.ibm.com> | 2014-03-18 05:03:26 -0400 |
---|---|---|
committer | Christian Borntraeger <borntraeger@de.ibm.com> | 2014-04-22 07:24:52 -0400 |
commit | bb78c5ec9161561586f8d81d53258b251aab324a (patch) | |
tree | 53f144fdfb89f96995c2e206da5b5554f32aa75a /arch/s390 | |
parent | ffad018cc06ea1e3ada0f613676f97d408817182 (diff) |
KVM: s390: move timer interrupt checks into own functions
This patch moves the checks for enabled timer (clock-comparator) interrupts and pending
timer interrupts into own functions, making the code better readable and easier to
maintain.
The method kvm_cpu_has_pending_timer is filled with life.
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Diffstat (limited to 'arch/s390')
-rw-r--r-- | arch/s390/kvm/interrupt.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c index f331014dd766..0165f1b089ac 100644 --- a/arch/s390/kvm/interrupt.c +++ b/arch/s390/kvm/interrupt.c | |||
@@ -56,6 +56,14 @@ static int psw_interrupts_disabled(struct kvm_vcpu *vcpu) | |||
56 | return 1; | 56 | return 1; |
57 | } | 57 | } |
58 | 58 | ||
59 | static int ckc_interrupts_enabled(struct kvm_vcpu *vcpu) | ||
60 | { | ||
61 | if (psw_extint_disabled(vcpu) || | ||
62 | !(vcpu->arch.sie_block->gcr[0] & 0x800ul)) | ||
63 | return 0; | ||
64 | return 1; | ||
65 | } | ||
66 | |||
59 | static u64 int_word_to_isc_bits(u32 int_word) | 67 | static u64 int_word_to_isc_bits(u32 int_word) |
60 | { | 68 | { |
61 | u8 isc = (int_word & 0x38000000) >> 27; | 69 | u8 isc = (int_word & 0x38000000) >> 27; |
@@ -466,14 +474,10 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu, | |||
466 | } | 474 | } |
467 | } | 475 | } |
468 | 476 | ||
469 | static int __try_deliver_ckc_interrupt(struct kvm_vcpu *vcpu) | 477 | static void deliver_ckc_interrupt(struct kvm_vcpu *vcpu) |
470 | { | 478 | { |
471 | int rc; | 479 | int rc; |
472 | 480 | ||
473 | if (psw_extint_disabled(vcpu)) | ||
474 | return 0; | ||
475 | if (!(vcpu->arch.sie_block->gcr[0] & 0x800ul)) | ||
476 | return 0; | ||
477 | rc = put_guest_lc(vcpu, 0x1004, (u16 __user *)__LC_EXT_INT_CODE); | 481 | rc = put_guest_lc(vcpu, 0x1004, (u16 __user *)__LC_EXT_INT_CODE); |
478 | rc |= write_guest_lc(vcpu, __LC_EXT_OLD_PSW, | 482 | rc |= write_guest_lc(vcpu, __LC_EXT_OLD_PSW, |
479 | &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); | 483 | &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); |
@@ -485,7 +489,6 @@ static int __try_deliver_ckc_interrupt(struct kvm_vcpu *vcpu) | |||
485 | "delivery, killing userspace\n"); | 489 | "delivery, killing userspace\n"); |
486 | do_exit(SIGKILL); | 490 | do_exit(SIGKILL); |
487 | } | 491 | } |
488 | return 1; | ||
489 | } | 492 | } |
490 | 493 | ||
491 | int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu) | 494 | int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu) |
@@ -515,19 +518,20 @@ int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu) | |||
515 | spin_unlock(&fi->lock); | 518 | spin_unlock(&fi->lock); |
516 | } | 519 | } |
517 | 520 | ||
518 | if ((!rc) && (vcpu->arch.sie_block->ckc < | 521 | if (!rc && kvm_cpu_has_pending_timer(vcpu)) |
519 | get_tod_clock_fast() + vcpu->arch.sie_block->epoch)) { | 522 | rc = 1; |
520 | if ((!psw_extint_disabled(vcpu)) && | ||
521 | (vcpu->arch.sie_block->gcr[0] & 0x800ul)) | ||
522 | rc = 1; | ||
523 | } | ||
524 | 523 | ||
525 | return rc; | 524 | return rc; |
526 | } | 525 | } |
527 | 526 | ||
528 | int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu) | 527 | int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu) |
529 | { | 528 | { |
530 | return 0; | 529 | if (!(vcpu->arch.sie_block->ckc < |
530 | get_tod_clock_fast() + vcpu->arch.sie_block->epoch)) | ||
531 | return 0; | ||
532 | if (!ckc_interrupts_enabled(vcpu)) | ||
533 | return 0; | ||
534 | return 1; | ||
531 | } | 535 | } |
532 | 536 | ||
533 | int kvm_s390_handle_wait(struct kvm_vcpu *vcpu) | 537 | int kvm_s390_handle_wait(struct kvm_vcpu *vcpu) |
@@ -550,8 +554,7 @@ int kvm_s390_handle_wait(struct kvm_vcpu *vcpu) | |||
550 | return -EOPNOTSUPP; /* disabled wait */ | 554 | return -EOPNOTSUPP; /* disabled wait */ |
551 | } | 555 | } |
552 | 556 | ||
553 | if (psw_extint_disabled(vcpu) || | 557 | if (!ckc_interrupts_enabled(vcpu)) { |
554 | (!(vcpu->arch.sie_block->gcr[0] & 0x800ul))) { | ||
555 | VCPU_EVENT(vcpu, 3, "%s", "enabled wait w/o timer"); | 558 | VCPU_EVENT(vcpu, 3, "%s", "enabled wait w/o timer"); |
556 | goto no_timer; | 559 | goto no_timer; |
557 | } | 560 | } |
@@ -663,9 +666,8 @@ void kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu) | |||
663 | } while (deliver); | 666 | } while (deliver); |
664 | } | 667 | } |
665 | 668 | ||
666 | if ((vcpu->arch.sie_block->ckc < | 669 | if (kvm_cpu_has_pending_timer(vcpu)) |
667 | get_tod_clock_fast() + vcpu->arch.sie_block->epoch)) | 670 | deliver_ckc_interrupt(vcpu); |
668 | __try_deliver_ckc_interrupt(vcpu); | ||
669 | 671 | ||
670 | if (atomic_read(&fi->active)) { | 672 | if (atomic_read(&fi->active)) { |
671 | do { | 673 | do { |