diff options
author | David Hildenbrand <dahi@linux.vnet.ibm.com> | 2016-04-13 04:09:47 -0400 |
---|---|---|
committer | Christian Borntraeger <borntraeger@de.ibm.com> | 2016-06-10 06:07:28 -0400 |
commit | 6164a2e90a5b6c5c32ccfe7a1baff80d603d702d (patch) | |
tree | e228ebab5b999145ff8b018d43a979915c03bcae /arch/s390/kvm | |
parent | fe69eabf8deb85ae8b2958830ea3b2911e332820 (diff) |
KVM: s390: pfmf: fix end address calculation
The current calculation is wrong if absolute != real address. Let's just
calculate the start address for 4k frames upfront. Otherwise, the
calculated end address will be wrong, resulting in wrong memory
location/storage keys getting touched.
To keep low-address protection working (using the effective address),
we have to move the check.
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Diffstat (limited to 'arch/s390/kvm')
-rw-r--r-- | arch/s390/kvm/priv.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c index c6deed782c61..bfba98302ca0 100644 --- a/arch/s390/kvm/priv.c +++ b/arch/s390/kvm/priv.c | |||
@@ -682,8 +682,15 @@ static int handle_pfmf(struct kvm_vcpu *vcpu) | |||
682 | start = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK; | 682 | start = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK; |
683 | start = kvm_s390_logical_to_effective(vcpu, start); | 683 | start = kvm_s390_logical_to_effective(vcpu, start); |
684 | 684 | ||
685 | if (vcpu->run->s.regs.gprs[reg1] & PFMF_CF) { | ||
686 | if (kvm_s390_check_low_addr_prot_real(vcpu, start)) | ||
687 | return kvm_s390_inject_prog_irq(vcpu, &vcpu->arch.pgm); | ||
688 | } | ||
689 | |||
685 | switch (vcpu->run->s.regs.gprs[reg1] & PFMF_FSC) { | 690 | switch (vcpu->run->s.regs.gprs[reg1] & PFMF_FSC) { |
686 | case 0x00000000: | 691 | case 0x00000000: |
692 | /* only 4k frames specify a real address */ | ||
693 | start = kvm_s390_real_to_abs(vcpu, start); | ||
687 | end = (start + (1UL << 12)) & ~((1UL << 12) - 1); | 694 | end = (start + (1UL << 12)) & ~((1UL << 12) - 1); |
688 | break; | 695 | break; |
689 | case 0x00001000: | 696 | case 0x00001000: |
@@ -701,20 +708,11 @@ static int handle_pfmf(struct kvm_vcpu *vcpu) | |||
701 | return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); | 708 | return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); |
702 | } | 709 | } |
703 | 710 | ||
704 | if (vcpu->run->s.regs.gprs[reg1] & PFMF_CF) { | ||
705 | if (kvm_s390_check_low_addr_prot_real(vcpu, start)) | ||
706 | return kvm_s390_inject_prog_irq(vcpu, &vcpu->arch.pgm); | ||
707 | } | ||
708 | |||
709 | while (start < end) { | 711 | while (start < end) { |
710 | unsigned long useraddr, abs_addr; | 712 | unsigned long useraddr; |
711 | 713 | ||
712 | /* Translate guest address to host address */ | 714 | /* Translate guest address to host address */ |
713 | if ((vcpu->run->s.regs.gprs[reg1] & PFMF_FSC) == 0) | 715 | useraddr = gfn_to_hva(vcpu->kvm, gpa_to_gfn(start)); |
714 | abs_addr = kvm_s390_real_to_abs(vcpu, start); | ||
715 | else | ||
716 | abs_addr = start; | ||
717 | useraddr = gfn_to_hva(vcpu->kvm, gpa_to_gfn(abs_addr)); | ||
718 | if (kvm_is_error_hva(useraddr)) | 716 | if (kvm_is_error_hva(useraddr)) |
719 | return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); | 717 | return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); |
720 | 718 | ||