Skip to content

Commit

Permalink
KVM: s390: Fix pfmf and conditional skey emulation
Browse files Browse the repository at this point in the history
We should not return with a lock.
We also have to increase the address when we do page clearing.

Fixes: bd096f6 ("KVM: s390: Add skey emulation fault handling")
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Message-Id: <20180830081355.59234-1-frankja@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
  • Loading branch information
frankjaa authored and borntraeger committed Sep 4, 2018
1 parent 5736184 commit a11bdb1
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions arch/s390/kvm/priv.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,11 @@ static int handle_iske(struct kvm_vcpu *vcpu)
goto retry;
}
}
if (rc)
return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
up_read(&current->mm->mmap_sem);
if (rc == -EFAULT)
return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
if (rc < 0)
return rc;
vcpu->run->s.regs.gprs[reg1] &= ~0xff;
vcpu->run->s.regs.gprs[reg1] |= key;
return 0;
Expand Down Expand Up @@ -324,9 +326,11 @@ static int handle_rrbe(struct kvm_vcpu *vcpu)
goto retry;
}
}
if (rc < 0)
return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
up_read(&current->mm->mmap_sem);
if (rc == -EFAULT)
return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
if (rc < 0)
return rc;
kvm_s390_set_psw_cc(vcpu, rc);
return 0;
}
Expand Down Expand Up @@ -390,12 +394,12 @@ static int handle_sske(struct kvm_vcpu *vcpu)
FAULT_FLAG_WRITE, &unlocked);
rc = !rc ? -EAGAIN : rc;
}
up_read(&current->mm->mmap_sem);
if (rc == -EFAULT)
return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);

up_read(&current->mm->mmap_sem);
if (rc >= 0)
start += PAGE_SIZE;
if (rc < 0)
return rc;
start += PAGE_SIZE;
}

if (m3 & (SSKE_MC | SSKE_MR)) {
Expand Down Expand Up @@ -1002,13 +1006,15 @@ static int handle_pfmf(struct kvm_vcpu *vcpu)
FAULT_FLAG_WRITE, &unlocked);
rc = !rc ? -EAGAIN : rc;
}
up_read(&current->mm->mmap_sem);
if (rc == -EFAULT)
return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);

up_read(&current->mm->mmap_sem);
if (rc >= 0)
start += PAGE_SIZE;
if (rc == -EAGAIN)
continue;
if (rc < 0)
return rc;
}
start += PAGE_SIZE;
}
if (vcpu->run->s.regs.gprs[reg1] & PFMF_FSC) {
if (psw_bits(vcpu->arch.sie_block->gpsw).eaba == PSW_BITS_AMODE_64BIT) {
Expand Down

0 comments on commit a11bdb1

Please sign in to comment.