s390/kvm: mask extra bits from program interrupt code
Claudio Imbrenda
maintainerPATCH 1/1 s390/kvm: mask extra bits from program interrupt code
The program interrupt code has some extra bits that are sometimes set by hardware for various reasons; those bits should be ignored when the program interrupt number is needed for interrupt handling.
--- arch/s390/kvm/kvm-s390.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kvm/kvm-s390.c +1 -1
@@ -4737,7 +4737,7 @@ static int vcpu_post_run_handle_fault(struct kvm_vcpu *vcpu)if (kvm_s390_cur_gmap_fault_is_write ()) flags =FAULT_FLAG_WRITE ; -switch (current->thread.gmap_int_code) { +switch (current->thread.gmap_int_code &PGM_INT_CODE_MASK ) {case 0 : vcpu->stat.exit_null++;break ;
Signature · 1 line
2.47.0
Heiko Carstens
maintainerQuoted 16 lines · Claudio Imbrenda
The program interrupt code has some extra bits that are sometimes set by hardware for various reasons; those bits should be ignored when the program interrupt number is needed for interrupt handling.
Fixes ce2b276ebe51 ("s390/mm/fault: Handle guest-related program interrupts in KVM")Reported-by Christian Borntraeger <[email protected]>Signed-off-by Claudio Imbrenda <[email protected]>--- arch/s390/kvm/kvm-s390.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/s390/kvm/kvm-s390.c +0
-0
arch/s390/kvm/kvm-s390.c static int vcpu_post_run_handle_fault(struct kvm_vcpu *vcpu) · line 4740
Quoted 5 lines
arch/s390/kvm/kvm-s390.c +1
-1@@ -4737,7 +4737,7 @@ static int vcpu_post_run_handle_fault(struct kvm_vcpu *vcpu)if (kvm_s390_cur_gmap_fault_is_write ()) flags =FAULT_FLAG_WRITE ; -switch (current->thread.gmap_int_code) { +switch (current->thread.gmap_int_code &PGM_INT_CODE_MASK ) {
Can you give an example? When reviewing your patch I was aware of this, but actually thought we do want to know when this happens, since the kernel did something which causes such bits to be set; e.g. single stepping with PER on the sie instruction. If that happens then such program interruptions should not be passed for kvm handling, since that would indicate a host kernel bug (the sie instruction is not allowed to be single stepped).
Or in other words: this should never happen. Of course I might have missed something; so when could this happen where this is not a bug and the bits should be ignored?
Claudio Imbrenda
maintainerQuoted 30 lines · On Thu, 31 Oct 2024 13:38:15 +0100 Heiko Carstens <[email protected]> wrote:
Quoted 16 lines · Claudio Imbrenda
The program interrupt code has some extra bits that are sometimes set by hardware for various reasons; those bits should be ignored when the program interrupt number is needed for interrupt handling.
Fixes ce2b276ebe51 ("s390/mm/fault: Handle guest-related program interrupts in KVM")Reported-by Christian Borntraeger <[email protected]>Signed-off-by Claudio Imbrenda <[email protected]>--- arch/s390/kvm/kvm-s390.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/s390/kvm/kvm-s390.c +0
-0arch/s390/kvm/kvm-s390.c static int vcpu_post_run_handle_fault(struct kvm_vcpu *vcpu) · line 4740
Quoted 5 lines
arch/s390/kvm/kvm-s390.c +1
-1@@ -4737,7 +4737,7 @@ static int vcpu_post_run_handle_fault(struct kvm_vcpu *vcpu)if (kvm_s390_cur_gmap_fault_is_write ()) flags =FAULT_FLAG_WRITE ; -switch (current->thread.gmap_int_code) { +switch (current->thread.gmap_int_code &PGM_INT_CODE_MASK ) {Can you give an example? When reviewing your patch I was aware of this, but actually thought we do want to know when this happens, since the kernel did something which causes such bits to be set; e.g. single stepping with PER on the sie instruction. If that happens then such program interruptions should not be passed for kvm handling, since that would indicate a host kernel bug (the sie instruction is not allowed to be single stepped).
Quoted 3 lines
Or in other words: this should never happen. Of course I might have missed something; so when could this happen where this is not a bug and the bits should be ignored?
in some cases some guest indication bits might be set when a host exception happens.
I was also unaware of those and found out the hard way.
Quoted 20 lines · Claudio Imbrenda
Quoted 18 lines · On Thu, 31 Oct 2024 13:38:15 +0100 Heiko Carstens <[email protected]> wrote:
arch/s390/kvm/kvm-s390.c static int vcpu_post_run_handle_fault(struct kvm_vcpu *vcpu) · line 4740
Quoted 10 lines
arch/s390/kvm/kvm-s390.c +1
-1@@ -4737,7 +4737,7 @@ static int vcpu_post_run_handle_fault(struct kvm_vcpu *vcpu)if (kvm_s390_cur_gmap_fault_is_write ()) flags =FAULT_FLAG_WRITE ; -switch (current->thread.gmap_int_code) { +switch (current->thread.gmap_int_code &PGM_INT_CODE_MASK ) {Can you give an example? When reviewing your patch I was aware of this, but actually thought we do want to know when this happens, since the kernel did something which causes such bits to be set; e.g. single stepping with PER on the sie instruction. If that happens then such program interruptions should not be passed for kvm handling, since that would indicate a host kernel bug (the sie instruction is not allowed to be single stepped).
Quoted 8 lines
Quoted 3 lines
Or in other words: this should never happen. Of course I might have missed something; so when could this happen where this is not a bug and the bits should be ignored?
in some cases some guest indication bits might be set when a host exception happens.
I was also unaware of those and found out the hard way.
Thanks for explaining. Chances are that we need another patch to address this for the vsie code as well (handle_fault()). But that would be another patch.
Applied, thanks!
Am 31.10.24 um 13:03 schrieb Claudio Imbrenda:
Quoted 7 lines
The program interrupt code has some extra bits that are sometimes set by hardware for various reasons; those bits should be ignored when the program interrupt number is needed for interrupt handling.
Fixes ce2b276ebe51 ("s390/mm/fault: Handle guest-related program interrupts in KVM")Reported-by Christian Borntraeger <[email protected]>Signed-off-by Claudio Imbrenda <[email protected]>
seems to fix my issue:
Quoted 17 lines
--- arch/s390/kvm/kvm-s390.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/s390/kvm/kvm-s390.c +1
-1@@ -4737,7 +4737,7 @@ static int vcpu_post_run_handle_fault(struct kvm_vcpu *vcpu)if (kvm_s390_cur_gmap_fault_is_write ()) flags =FAULT_FLAG_WRITE ; -switch (current->thread.gmap_int_code) { +switch (current->thread.gmap_int_code &PGM_INT_CODE_MASK ) {case 0 : vcpu->stat.exit_null++;break ;