Commit 58cdf5eb authored by Heiko Carstens's avatar Heiko Carstens Committed by Martin Schwidefsky

KVM: s390: use new mm defines instead of magic values

Acked-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: default avatarJanosch Frank <frankja@linux.vnet.ibm.com>
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent f1c1174f
...@@ -27,7 +27,7 @@ static int diag_release_pages(struct kvm_vcpu *vcpu) ...@@ -27,7 +27,7 @@ static int diag_release_pages(struct kvm_vcpu *vcpu)
unsigned long prefix = kvm_s390_get_prefix(vcpu); unsigned long prefix = kvm_s390_get_prefix(vcpu);
start = vcpu->run->s.regs.gprs[(vcpu->arch.sie_block->ipa & 0xf0) >> 4]; start = vcpu->run->s.regs.gprs[(vcpu->arch.sie_block->ipa & 0xf0) >> 4];
end = vcpu->run->s.regs.gprs[vcpu->arch.sie_block->ipa & 0xf] + 4096; end = vcpu->run->s.regs.gprs[vcpu->arch.sie_block->ipa & 0xf] + PAGE_SIZE;
vcpu->stat.diagnose_10++; vcpu->stat.diagnose_10++;
if (start & ~PAGE_MASK || end & ~PAGE_MASK || start >= end if (start & ~PAGE_MASK || end & ~PAGE_MASK || start >= end
...@@ -51,9 +51,9 @@ static int diag_release_pages(struct kvm_vcpu *vcpu) ...@@ -51,9 +51,9 @@ static int diag_release_pages(struct kvm_vcpu *vcpu)
*/ */
gmap_discard(vcpu->arch.gmap, start, prefix); gmap_discard(vcpu->arch.gmap, start, prefix);
if (start <= prefix) if (start <= prefix)
gmap_discard(vcpu->arch.gmap, 0, 4096); gmap_discard(vcpu->arch.gmap, 0, PAGE_SIZE);
if (end > prefix + 4096) if (end > prefix + PAGE_SIZE)
gmap_discard(vcpu->arch.gmap, 4096, 8192); gmap_discard(vcpu->arch.gmap, PAGE_SIZE, 2 * PAGE_SIZE);
gmap_discard(vcpu->arch.gmap, prefix + 2 * PAGE_SIZE, end); gmap_discard(vcpu->arch.gmap, prefix + 2 * PAGE_SIZE, end);
} }
return 0; return 0;
......
...@@ -629,7 +629,7 @@ static unsigned long guest_translate(struct kvm_vcpu *vcpu, unsigned long gva, ...@@ -629,7 +629,7 @@ static unsigned long guest_translate(struct kvm_vcpu *vcpu, unsigned long gva,
iep = ctlreg0.iep && test_kvm_facility(vcpu->kvm, 130); iep = ctlreg0.iep && test_kvm_facility(vcpu->kvm, 130);
if (asce.r) if (asce.r)
goto real_address; goto real_address;
ptr = asce.origin * 4096; ptr = asce.origin * PAGE_SIZE;
switch (asce.dt) { switch (asce.dt) {
case ASCE_TYPE_REGION1: case ASCE_TYPE_REGION1:
if (vaddr.rfx01 > asce.tl) if (vaddr.rfx01 > asce.tl)
...@@ -674,7 +674,7 @@ static unsigned long guest_translate(struct kvm_vcpu *vcpu, unsigned long gva, ...@@ -674,7 +674,7 @@ static unsigned long guest_translate(struct kvm_vcpu *vcpu, unsigned long gva,
return PGM_REGION_SECOND_TRANS; return PGM_REGION_SECOND_TRANS;
if (edat1) if (edat1)
dat_protection |= rfte.p; dat_protection |= rfte.p;
ptr = rfte.rto * 4096 + vaddr.rsx * 8; ptr = rfte.rto * PAGE_SIZE + vaddr.rsx * 8;
} }
/* fallthrough */ /* fallthrough */
case ASCE_TYPE_REGION2: { case ASCE_TYPE_REGION2: {
...@@ -692,7 +692,7 @@ static unsigned long guest_translate(struct kvm_vcpu *vcpu, unsigned long gva, ...@@ -692,7 +692,7 @@ static unsigned long guest_translate(struct kvm_vcpu *vcpu, unsigned long gva,
return PGM_REGION_THIRD_TRANS; return PGM_REGION_THIRD_TRANS;
if (edat1) if (edat1)
dat_protection |= rste.p; dat_protection |= rste.p;
ptr = rste.rto * 4096 + vaddr.rtx * 8; ptr = rste.rto * PAGE_SIZE + vaddr.rtx * 8;
} }
/* fallthrough */ /* fallthrough */
case ASCE_TYPE_REGION3: { case ASCE_TYPE_REGION3: {
...@@ -720,7 +720,7 @@ static unsigned long guest_translate(struct kvm_vcpu *vcpu, unsigned long gva, ...@@ -720,7 +720,7 @@ static unsigned long guest_translate(struct kvm_vcpu *vcpu, unsigned long gva,
return PGM_SEGMENT_TRANSLATION; return PGM_SEGMENT_TRANSLATION;
if (edat1) if (edat1)
dat_protection |= rtte.fc0.p; dat_protection |= rtte.fc0.p;
ptr = rtte.fc0.sto * 4096 + vaddr.sx * 8; ptr = rtte.fc0.sto * PAGE_SIZE + vaddr.sx * 8;
} }
/* fallthrough */ /* fallthrough */
case ASCE_TYPE_SEGMENT: { case ASCE_TYPE_SEGMENT: {
...@@ -743,7 +743,7 @@ static unsigned long guest_translate(struct kvm_vcpu *vcpu, unsigned long gva, ...@@ -743,7 +743,7 @@ static unsigned long guest_translate(struct kvm_vcpu *vcpu, unsigned long gva,
goto absolute_address; goto absolute_address;
} }
dat_protection |= ste.fc0.p; dat_protection |= ste.fc0.p;
ptr = ste.fc0.pto * 2048 + vaddr.px * 8; ptr = ste.fc0.pto * (PAGE_SIZE / 2) + vaddr.px * 8;
} }
} }
if (kvm_is_error_gpa(vcpu->kvm, ptr)) if (kvm_is_error_gpa(vcpu->kvm, ptr))
...@@ -993,7 +993,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr, ...@@ -993,7 +993,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
parent = sg->parent; parent = sg->parent;
vaddr.addr = saddr; vaddr.addr = saddr;
asce.val = sg->orig_asce; asce.val = sg->orig_asce;
ptr = asce.origin * 4096; ptr = asce.origin * PAGE_SIZE;
if (asce.r) { if (asce.r) {
*fake = 1; *fake = 1;
ptr = 0; ptr = 0;
...@@ -1029,7 +1029,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr, ...@@ -1029,7 +1029,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
union region1_table_entry rfte; union region1_table_entry rfte;
if (*fake) { if (*fake) {
ptr += (unsigned long) vaddr.rfx << 53; ptr += vaddr.rfx * _REGION1_SIZE;
rfte.val = ptr; rfte.val = ptr;
goto shadow_r2t; goto shadow_r2t;
} }
...@@ -1044,7 +1044,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr, ...@@ -1044,7 +1044,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
return PGM_REGION_SECOND_TRANS; return PGM_REGION_SECOND_TRANS;
if (sg->edat_level >= 1) if (sg->edat_level >= 1)
*dat_protection |= rfte.p; *dat_protection |= rfte.p;
ptr = rfte.rto << 12UL; ptr = rfte.rto * PAGE_SIZE;
shadow_r2t: shadow_r2t:
rc = gmap_shadow_r2t(sg, saddr, rfte.val, *fake); rc = gmap_shadow_r2t(sg, saddr, rfte.val, *fake);
if (rc) if (rc)
...@@ -1055,7 +1055,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr, ...@@ -1055,7 +1055,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
union region2_table_entry rste; union region2_table_entry rste;
if (*fake) { if (*fake) {
ptr += (unsigned long) vaddr.rsx << 42; ptr += vaddr.rsx * _REGION2_SIZE;
rste.val = ptr; rste.val = ptr;
goto shadow_r3t; goto shadow_r3t;
} }
...@@ -1070,7 +1070,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr, ...@@ -1070,7 +1070,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
return PGM_REGION_THIRD_TRANS; return PGM_REGION_THIRD_TRANS;
if (sg->edat_level >= 1) if (sg->edat_level >= 1)
*dat_protection |= rste.p; *dat_protection |= rste.p;
ptr = rste.rto << 12UL; ptr = rste.rto * PAGE_SIZE;
shadow_r3t: shadow_r3t:
rste.p |= *dat_protection; rste.p |= *dat_protection;
rc = gmap_shadow_r3t(sg, saddr, rste.val, *fake); rc = gmap_shadow_r3t(sg, saddr, rste.val, *fake);
...@@ -1082,7 +1082,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr, ...@@ -1082,7 +1082,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
union region3_table_entry rtte; union region3_table_entry rtte;
if (*fake) { if (*fake) {
ptr += (unsigned long) vaddr.rtx << 31; ptr += vaddr.rtx * _REGION3_SIZE;
rtte.val = ptr; rtte.val = ptr;
goto shadow_sgt; goto shadow_sgt;
} }
...@@ -1098,7 +1098,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr, ...@@ -1098,7 +1098,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
if (rtte.fc && sg->edat_level >= 2) { if (rtte.fc && sg->edat_level >= 2) {
*dat_protection |= rtte.fc0.p; *dat_protection |= rtte.fc0.p;
*fake = 1; *fake = 1;
ptr = rtte.fc1.rfaa << 31UL; ptr = rtte.fc1.rfaa * _REGION3_SIZE;
rtte.val = ptr; rtte.val = ptr;
goto shadow_sgt; goto shadow_sgt;
} }
...@@ -1106,7 +1106,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr, ...@@ -1106,7 +1106,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
return PGM_SEGMENT_TRANSLATION; return PGM_SEGMENT_TRANSLATION;
if (sg->edat_level >= 1) if (sg->edat_level >= 1)
*dat_protection |= rtte.fc0.p; *dat_protection |= rtte.fc0.p;
ptr = rtte.fc0.sto << 12UL; ptr = rtte.fc0.sto * PAGE_SIZE;
shadow_sgt: shadow_sgt:
rtte.fc0.p |= *dat_protection; rtte.fc0.p |= *dat_protection;
rc = gmap_shadow_sgt(sg, saddr, rtte.val, *fake); rc = gmap_shadow_sgt(sg, saddr, rtte.val, *fake);
...@@ -1118,7 +1118,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr, ...@@ -1118,7 +1118,7 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
union segment_table_entry ste; union segment_table_entry ste;
if (*fake) { if (*fake) {
ptr += (unsigned long) vaddr.sx << 20; ptr += vaddr.sx * _SEGMENT_SIZE;
ste.val = ptr; ste.val = ptr;
goto shadow_pgt; goto shadow_pgt;
} }
...@@ -1134,11 +1134,11 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr, ...@@ -1134,11 +1134,11 @@ static int kvm_s390_shadow_tables(struct gmap *sg, unsigned long saddr,
*dat_protection |= ste.fc0.p; *dat_protection |= ste.fc0.p;
if (ste.fc && sg->edat_level >= 1) { if (ste.fc && sg->edat_level >= 1) {
*fake = 1; *fake = 1;
ptr = ste.fc1.sfaa << 20UL; ptr = ste.fc1.sfaa * _SEGMENT_SIZE;
ste.val = ptr; ste.val = ptr;
goto shadow_pgt; goto shadow_pgt;
} }
ptr = ste.fc0.pto << 11UL; ptr = ste.fc0.pto * (PAGE_SIZE / 2);
shadow_pgt: shadow_pgt:
ste.fc0.p |= *dat_protection; ste.fc0.p |= *dat_protection;
rc = gmap_shadow_pgt(sg, saddr, ste.val, *fake); rc = gmap_shadow_pgt(sg, saddr, ste.val, *fake);
...@@ -1187,8 +1187,7 @@ int kvm_s390_shadow_fault(struct kvm_vcpu *vcpu, struct gmap *sg, ...@@ -1187,8 +1187,7 @@ int kvm_s390_shadow_fault(struct kvm_vcpu *vcpu, struct gmap *sg,
vaddr.addr = saddr; vaddr.addr = saddr;
if (fake) { if (fake) {
/* offset in 1MB guest memory block */ pte.val = pgt + vaddr.px * PAGE_SIZE;
pte.val = pgt + ((unsigned long) vaddr.px << 12UL);
goto shadow_page; goto shadow_page;
} }
if (!rc) if (!rc)
......
...@@ -329,7 +329,7 @@ static int handle_sske(struct kvm_vcpu *vcpu) ...@@ -329,7 +329,7 @@ static int handle_sske(struct kvm_vcpu *vcpu)
start = kvm_s390_logical_to_effective(vcpu, start); start = kvm_s390_logical_to_effective(vcpu, start);
if (m3 & SSKE_MB) { if (m3 & SSKE_MB) {
/* start already designates an absolute address */ /* start already designates an absolute address */
end = (start + (1UL << 20)) & ~((1UL << 20) - 1); end = (start + _SEGMENT_SIZE) & ~(_SEGMENT_SIZE - 1);
} else { } else {
start = kvm_s390_real_to_abs(vcpu, start); start = kvm_s390_real_to_abs(vcpu, start);
end = start + PAGE_SIZE; end = start + PAGE_SIZE;
...@@ -893,10 +893,10 @@ static int handle_pfmf(struct kvm_vcpu *vcpu) ...@@ -893,10 +893,10 @@ static int handle_pfmf(struct kvm_vcpu *vcpu)
case 0x00000000: case 0x00000000:
/* only 4k frames specify a real address */ /* only 4k frames specify a real address */
start = kvm_s390_real_to_abs(vcpu, start); start = kvm_s390_real_to_abs(vcpu, start);
end = (start + (1UL << 12)) & ~((1UL << 12) - 1); end = (start + PAGE_SIZE) & ~(PAGE_SIZE - 1);
break; break;
case 0x00001000: case 0x00001000:
end = (start + (1UL << 20)) & ~((1UL << 20) - 1); end = (start + _SEGMENT_SIZE) & ~(_SEGMENT_SIZE - 1);
break; break;
case 0x00002000: case 0x00002000:
/* only support 2G frame size if EDAT2 is available and we are /* only support 2G frame size if EDAT2 is available and we are
...@@ -904,7 +904,7 @@ static int handle_pfmf(struct kvm_vcpu *vcpu) ...@@ -904,7 +904,7 @@ static int handle_pfmf(struct kvm_vcpu *vcpu)
if (!test_kvm_facility(vcpu->kvm, 78) || if (!test_kvm_facility(vcpu->kvm, 78) ||
psw_bits(vcpu->arch.sie_block->gpsw).eaba == PSW_BITS_AMODE_24BIT) psw_bits(vcpu->arch.sie_block->gpsw).eaba == PSW_BITS_AMODE_24BIT)
return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
end = (start + (1UL << 31)) & ~((1UL << 31) - 1); end = (start + _REGION3_SIZE) & ~(_REGION3_SIZE - 1);
break; break;
default: default:
return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
......
...@@ -1069,7 +1069,7 @@ int kvm_s390_handle_vsie(struct kvm_vcpu *vcpu) ...@@ -1069,7 +1069,7 @@ int kvm_s390_handle_vsie(struct kvm_vcpu *vcpu)
if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
BUILD_BUG_ON(sizeof(struct vsie_page) != 4096); BUILD_BUG_ON(sizeof(struct vsie_page) != PAGE_SIZE);
scb_addr = kvm_s390_get_base_disp_s(vcpu, NULL); scb_addr = kvm_s390_get_base_disp_s(vcpu, NULL);
/* 512 byte alignment */ /* 512 byte alignment */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment