KVM: s390: fix ESSA addressing exception injection in migration mode
v2 cover KVM: s390: fix ESSA addressing exception injection in migration mode
ESSA emulation in migration mode silently dropped addressing exceptions when the guest page-table walk failed, so the guest never received the expected PGM_ADDRESSING interrupt during live migration.
Patch 1 fixes dat_perform_essa() to return PGM_ADDRESSING on a walk failure, and __do_essa() to inject the program interrupt when it sees that return value.
Patch 2 adds a regression test integrated into the existing cmma_test selftest.
Changes since v1:
- dat_perform_essa() now returns +PGM_ADDRESSING instead of -PGM_ADDRESSING; kvm_s390_inject_program_int() takes an unsigned u16 so passing -5 would have wrapped to 0xFFFB and injected a bogus PIC. __do_essa() comparison and inject call updated accordingly. The kernel-doc return-value entry is corrected to %PGM_ADDRESSING.
- Selftest: pgm_handler_c() now reads the actual PIC from lowcore (__LC_PGM_INT_CODE) instead of hard-coding PGM_ADDRESSING, so the test would have caught the sign error above had it been in v1.
- Selftest: virt_map(vm, 0, 0, 1) added so the DAT-on guest can access the lowcore to read the PIC.
- Selftest: PGM_ADDRESSING, __LC_PGM_INT_CODE and __LC_PGM_NEW_PSW constants moved to the shared s390/processor.h header.
- Selftest: SIGALRM/alarm() timeout wrapper removed.
Gautam Gala (2):
KVM: s390: fix ESSA addressing exception injection in migration mode
KVM: s390: selftests: add ESSA migration mode PGM_ADDRESSING
regression test
arch/s390/kvm/gmap/dat.c | 5 +- arch/s390/kvm/s390/priv.c | 2 + .../selftests/kvm/include/s390/processor.h | 7 ++ tools/testing/selftests/kvm/s390/cmma_test.c | 69 +++++++++++++++++++ 4 files changed, 82 insertions(+), 1 deletion(-)
Signature · 1 line
2.55.0
PATCH v2 1/2 KVM: s390: fix ESSA addressing exception injection in migration mode
__do_essa() treated any negative return from dat_perform_essa() as the normal "no CBRL entry appended" case and returned 0, so a page-table walk failure silently dropped the addressing exception.
Return -PGM_ADDRESSING on a walk failure and inject the program interrupt in __do_essa() for the -PGM_ADDRESSING return value.
DAT_WALK_ANY is required in the dat_entry_walk() call so that a GFN backed by a large page (segment or region entry) does not return an
error: the walk stops early but succeeds, leaving ptep as NULL, which is already handled by the existing "set exception state, return -1" path. Without DAT_WALK_ANY such addresses would fall through to the new error path and incorrectly inject PGM_ADDRESSING.
--- arch/s390/kvm/gmap/dat.c | 5 ++++- arch/s390/kvm/s390/priv.c | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-)
arch/s390/kvm/gmap/dat.c +4 -1
@@ -1084,6 +1084,7 @@ int dat_set_prefix_notif_bit(union asce asce, gfn_t gfn)* * %1 if the page state has been altered and the page is to be added to the CBRL * * %0 if the page state has been altered, but the page is not to be added to the CBRL * * %-1 if the page state has not been altered and the page is not to be added to the CBRL +* * %PGM_ADDRESSING if the guest page-table walk failed */ int dat_perform_essa (union asce asce,gfn_t gfn,int orc,union essa_state *state,bool *dirty) {
@@ -1092,7 +1093,9 @@ int dat_perform_essa(union asce asce, gfn_t gfn, int orc, union essa_state *statunion pte *ptep;int res =0 ; -if (dat_entry_walk (NULL , gfn, asce,0 ,TABLE_TYPE_PAGE_TABLE , &crstep, &ptep)) { +if (dat_entry_walk (NULL , gfn, asce,DAT_WALK_ANY ,TABLE_TYPE_PAGE_TABLE , &crstep, &ptep)) +return PGM_ADDRESSING ; +if (!ptep) { *state = (union essa_state ) { .exception =1 };return -1 ; }
arch/s390/kvm/s390/priv.c +2 -0
@@ -1168,6 +1168,8 @@ static inline int __do_essa(struct kvm_vcpu *vcpu, const int orc) entries = (vcpu->arch.sie_block->cbrlo & ~PAGE_MASK ) >>3 ; nappended =dat_perform_essa (vcpu->arch.gmap->asce, gfn, orc, &state, &dirtied); +if (nappended ==PGM_ADDRESSING ) +return kvm_s390_inject_program_int (vcpu,PGM_ADDRESSING ); vcpu->run->s.regs.gprs[r1] = state.val;if (nappended <0 )return 0 ;
Signature · 1 line
2.55.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 14 lines
__do_essa()treated any negative return fromdat_perform_essa()as the normal "no CBRL entry appended" case and returned 0, so a page-table walk failure silently dropped the addressing exception.Return -PGM_ADDRESSING on a walk failure and inject the program interrupt in
__do_essa()for the -PGM_ADDRESSING return value.
DAT_WALK_ANYis required in thedat_entry_walk()call so that a GFN backed by a large page (segment or region entry) does not return an
error: the walk stops early but succeeds, leaving ptep as NULL, which is already handled by the existing "set exception state, return -1" path. WithoutDAT_WALK_ANYsuch addresses would fall through to the new error path and incorrectly injectPGM_ADDRESSING.
Quoted 5 lines
Fixes e38c884df921 ("KVM: s390: Switch to new gmap")Reported-by Christian Borntraeger <[email protected]>Suggested-by Claudio Imbrenda <[email protected]>Signed-off-by Gautam Gala <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v2 2/2 KVM: s390: selftests: add ESSA migration mode PGM_ADDRESSING regression test
In reply to Gautam GalaRegression test for the bug where ESSA emulation in migration mode silently dropped addressing exceptions instead of injecting PGM_ADDRESSING into the guest.
The test is integrated into cmma_test alongside the existing CMMA migration tests.
--- .../selftests/kvm/include/s390/processor.h | 7 ++ tools/testing/selftests/kvm/s390/cmma_test.c | 69 +++++++++++++++++++ 2 files changed, 76 insertions(+)
tools/testing/selftests/kvm/include/s390/processor.h +7 -0
@@ -26,6 +26,13 @@#define PAGE_SIZE BIT_ULL(PAGE_SHIFT)#define PAGE_MASK (~(PAGE_SIZE - 1)) +/* Program interruption codes */ +#define PGM_ADDRESSING 0x05 + +/* Lowcore offsets */ +#define __LC_PGM_INT_CODE 0x8e +#define __LC_PGM_NEW_PSW 0x1d0 +/* Is there a portable way to do this? */ static inline void cpu_relax (void ) {
tools/testing/selftests/kvm/s390/cmma_test.c +69 -0
87 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 2/2] KVM: s390: selftests: add ESSA migration mode PGM_ADDRESSING regression test
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines
Regression test for the bug where ESSA emulation in migration mode silently dropped addressing exceptions instead of injecting
PGM_ADDRESSINGinto the guest.The test is integrated into
cmma_testalongside the existing CMMA migration tests.Signed-off-by Gautam Gala <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Quoted 10 lines · On Thu, 15 Oct 2026 12:48:20 +0200 Gautam Gala <[email protected]> wrote:
ESSA emulation in migration mode silently dropped addressing exceptions when the guest page-table walk failed, so the guest never received the expected
PGM_ADDRESSINGinterrupt during live migration.Patch 1 fixes
dat_perform_essa()to returnPGM_ADDRESSINGon a walk failure, and__do_essa()to inject the program interrupt when it sees that return value.Patch 2 adds a regression test integrated into the existing
cmma_testselftest.
Whole series:
Quoted 27 lines
Changes since v1:
-dat_perform_essa()now returns +PGM_ADDRESSING instead of -PGM_ADDRESSING;kvm_s390_inject_program_int()takes an unsigned u16 so passing -5 would have wrapped to0xFFFBand injected a bogus PIC.__do_essa()comparison and inject call updated accordingly. The kernel-doc return-value entry is corrected to %PGM_ADDRESSING.
- Selftest:pgm_handler_c()now reads the actual PIC from lowcore (__LC_PGM_INT_CODE) instead of hard-codingPGM_ADDRESSING, so the test would have caught the sign error above had it been in v1.
- Selftest:virt_map(vm, 0, 0, 1)added so the DAT-on guest can access the lowcore to read the PIC.
- Selftest:PGM_ADDRESSING,__LC_PGM_INT_CODEand__LC_PGM_NEW_PSWconstants moved to the shareds390/processor.hheader.
- Selftest: SIGALRM/alarm() timeout wrapper removed.Gautam Gala (2):
KVM: s390: fix ESSA addressing exception injection in migration mode
KVM: s390: selftests: add ESSA migration modePGM_ADDRESSING
regression testarch/s390/kvm/gmap/dat.c | 5 +- arch/s390/kvm/s390/priv.c | 2 + .../selftests/kvm/include/s390/processor.h | 7 ++ tools/testing/selftests/kvm/s390/cmma_test.c | 69 +++++++++++++++++++ 4 files changed, 82 insertions(+), 1 deletion(-)
Am 15.10.26 um 12:48 schrieb Gautam Gala:
Quoted 31 lines
ESSA emulation in migration mode silently dropped addressing exceptions when the guest page-table walk failed, so the guest never received the expected
PGM_ADDRESSINGinterrupt during live migration.Patch 1 fixes
dat_perform_essa()to returnPGM_ADDRESSINGon a walk failure, and__do_essa()to inject the program interrupt when it sees that return value.Patch 2 adds a regression test integrated into the existing
cmma_testselftest.Changes since v1:
-dat_perform_essa()now returns +PGM_ADDRESSING instead of -PGM_ADDRESSING;kvm_s390_inject_program_int()takes an unsigned u16 so passing -5 would have wrapped to0xFFFBand injected a bogus PIC.__do_essa()comparison and inject call updated accordingly. The kernel-doc return-value entry is corrected to %PGM_ADDRESSING.
- Selftest:pgm_handler_c()now reads the actual PIC from lowcore (__LC_PGM_INT_CODE) instead of hard-codingPGM_ADDRESSING, so the test would have caught the sign error above had it been in v1.
- Selftest:virt_map(vm, 0, 0, 1)added so the DAT-on guest can access the lowcore to read the PIC.
- Selftest:PGM_ADDRESSING,__LC_PGM_INT_CODEand__LC_PGM_NEW_PSWconstants moved to the shareds390/processor.hheader.
- Selftest: SIGALRM/alarm() timeout wrapper removed.Gautam Gala (2):
KVM: s390: fix ESSA addressing exception injection in migration mode
KVM: s390: selftests: add ESSA migration modePGM_ADDRESSING
regression test
Quoted 6 lines
arch/s390/kvm/gmap/dat.c | 5 +- arch/s390/kvm/s390/priv.c | 2 + .../selftests/kvm/include/s390/processor.h | 7 ++ tools/testing/selftests/kvm/s390/cmma_test.c | 69 +++++++++++++++++++ 4 files changed, 82 insertions(+), 1 deletion(-)
Thanks, applied.