aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Freimann <jfrei@linux.vnet.ibm.com>2014-07-23 10:36:06 -0400
committerChristian Borntraeger <borntraeger@de.ibm.com>2014-08-25 08:35:29 -0400
commit8a2ef71b0bd0060c7095fd2043992b78e23735c4 (patch)
treeae0bcfcb49f2549d342196895da9349c5a776b34
parent44c6ca3d1b9c16cb715c21ec15670d27a8950822 (diff)
KVM: s390: factor out get_ilc() function
Let's make this a reusable function. Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com> Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
-rw-r--r--arch/s390/kvm/interrupt.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index 6c9428e71fdd..71bf7e749cf7 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -206,11 +206,30 @@ static void __set_intercept_indicator(struct kvm_vcpu *vcpu,
206 } 206 }
207} 207}
208 208
209static u16 get_ilc(struct kvm_vcpu *vcpu)
210{
211 const unsigned short table[] = { 2, 4, 4, 6 };
212
213 switch (vcpu->arch.sie_block->icptcode) {
214 case ICPT_INST:
215 case ICPT_INSTPROGI:
216 case ICPT_OPEREXC:
217 case ICPT_PARTEXEC:
218 case ICPT_IOINST:
219 /* last instruction only stored for these icptcodes */
220 return table[vcpu->arch.sie_block->ipa >> 14];
221 case ICPT_PROGI:
222 return vcpu->arch.sie_block->pgmilc;
223 default:
224 return 0;
225 }
226}
227
209static int __deliver_prog_irq(struct kvm_vcpu *vcpu, 228static int __deliver_prog_irq(struct kvm_vcpu *vcpu,
210 struct kvm_s390_pgm_info *pgm_info) 229 struct kvm_s390_pgm_info *pgm_info)
211{ 230{
212 const unsigned short table[] = { 2, 4, 4, 6 };
213 int rc = 0; 231 int rc = 0;
232 u16 ilc = get_ilc(vcpu);
214 233
215 switch (pgm_info->code & ~PGM_PER) { 234 switch (pgm_info->code & ~PGM_PER) {
216 case PGM_AFX_TRANSLATION: 235 case PGM_AFX_TRANSLATION:
@@ -277,25 +296,7 @@ static int __deliver_prog_irq(struct kvm_vcpu *vcpu,
277 (u8 *) __LC_PER_ACCESS_ID); 296 (u8 *) __LC_PER_ACCESS_ID);
278 } 297 }
279 298
280 switch (vcpu->arch.sie_block->icptcode) { 299 rc |= put_guest_lc(vcpu, ilc, (u16 *) __LC_PGM_ILC);
281 case ICPT_INST:
282 case ICPT_INSTPROGI:
283 case ICPT_OPEREXC:
284 case ICPT_PARTEXEC:
285 case ICPT_IOINST:
286 /* last instruction only stored for these icptcodes */
287 rc |= put_guest_lc(vcpu, table[vcpu->arch.sie_block->ipa >> 14],
288 (u16 *) __LC_PGM_ILC);
289 break;
290 case ICPT_PROGI:
291 rc |= put_guest_lc(vcpu, vcpu->arch.sie_block->pgmilc,
292 (u16 *) __LC_PGM_ILC);
293 break;
294 default:
295 rc |= put_guest_lc(vcpu, 0,
296 (u16 *) __LC_PGM_ILC);
297 }
298
299 rc |= put_guest_lc(vcpu, pgm_info->code, 300 rc |= put_guest_lc(vcpu, pgm_info->code,
300 (u16 *)__LC_PGM_INT_CODE); 301 (u16 *)__LC_PGM_INT_CODE);
301 rc |= write_guest_lc(vcpu, __LC_PGM_OLD_PSW, 302 rc |= write_guest_lc(vcpu, __LC_PGM_OLD_PSW,