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>
This commit is contained in:
parent
fe69eabf8d
commit
6164a2e90a
|
@ -682,8 +682,15 @@ static int handle_pfmf(struct kvm_vcpu *vcpu)
|
|||
start = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK;
|
||||
start = kvm_s390_logical_to_effective(vcpu, start);
|
||||
|
||||
if (vcpu->run->s.regs.gprs[reg1] & PFMF_CF) {
|
||||
if (kvm_s390_check_low_addr_prot_real(vcpu, start))
|
||||
return kvm_s390_inject_prog_irq(vcpu, &vcpu->arch.pgm);
|
||||
}
|
||||
|
||||
switch (vcpu->run->s.regs.gprs[reg1] & PFMF_FSC) {
|
||||
case 0x00000000:
|
||||
/* only 4k frames specify a real address */
|
||||
start = kvm_s390_real_to_abs(vcpu, start);
|
||||
end = (start + (1UL << 12)) & ~((1UL << 12) - 1);
|
||||
break;
|
||||
case 0x00001000:
|
||||
|
@ -701,20 +708,11 @@ static int handle_pfmf(struct kvm_vcpu *vcpu)
|
|||
return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
|
||||
}
|
||||
|
||||
if (vcpu->run->s.regs.gprs[reg1] & PFMF_CF) {
|
||||
if (kvm_s390_check_low_addr_prot_real(vcpu, start))
|
||||
return kvm_s390_inject_prog_irq(vcpu, &vcpu->arch.pgm);
|
||||
}
|
||||
|
||||
while (start < end) {
|
||||
unsigned long useraddr, abs_addr;
|
||||
unsigned long useraddr;
|
||||
|
||||
/* Translate guest address to host address */
|
||||
if ((vcpu->run->s.regs.gprs[reg1] & PFMF_FSC) == 0)
|
||||
abs_addr = kvm_s390_real_to_abs(vcpu, start);
|
||||
else
|
||||
abs_addr = start;
|
||||
useraddr = gfn_to_hva(vcpu->kvm, gpa_to_gfn(abs_addr));
|
||||
useraddr = gfn_to_hva(vcpu->kvm, gpa_to_gfn(start));
|
||||
if (kvm_is_error_hva(useraddr))
|
||||
return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
|
||||
|
||||
|
|
Loading…
Reference in New Issue