Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390: add 3f program exception handler

Program exception 3f (secure storage violation) can only be detected
when the CPU is running in SIE with a format 4 state description,
e.g. running a protected guest. Because of this and because user
space partly controls the guest memory mapping and can trigger this
exception, we want to send a SIGSEGV to the process running the guest
and not panic the kernel.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Cc: <stable@vger.kernel.org> # 5.7
Fixes: 084ea4d611a3 ("s390/mm: add (non)secure page access exceptions handlers")
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>

authored by

Janosch Frank and committed by
Vasily Gorbik
cd4d3d5f 73ac74c7

+22 -1
+1
arch/s390/kernel/entry.h
··· 26 26 void do_dat_exception(struct pt_regs *regs); 27 27 void do_secure_storage_access(struct pt_regs *regs); 28 28 void do_non_secure_storage_access(struct pt_regs *regs); 29 + void do_secure_storage_violation(struct pt_regs *regs); 29 30 30 31 void addressing_exception(struct pt_regs *regs); 31 32 void data_exception(struct pt_regs *regs);
+1 -1
arch/s390/kernel/pgm_check.S
··· 80 80 PGM_CHECK_DEFAULT /* 3c */ 81 81 PGM_CHECK(do_secure_storage_access) /* 3d */ 82 82 PGM_CHECK(do_non_secure_storage_access) /* 3e */ 83 - PGM_CHECK_DEFAULT /* 3f */ 83 + PGM_CHECK(do_secure_storage_violation) /* 3f */ 84 84 PGM_CHECK(monitor_event_exception) /* 40 */ 85 85 PGM_CHECK_DEFAULT /* 41 */ 86 86 PGM_CHECK_DEFAULT /* 42 */
+20
arch/s390/mm/fault.c
··· 859 859 } 860 860 NOKPROBE_SYMBOL(do_non_secure_storage_access); 861 861 862 + void do_secure_storage_violation(struct pt_regs *regs) 863 + { 864 + /* 865 + * Either KVM messed up the secure guest mapping or the same 866 + * page is mapped into multiple secure guests. 867 + * 868 + * This exception is only triggered when a guest 2 is running 869 + * and can therefore never occur in kernel context. 870 + */ 871 + printk_ratelimited(KERN_WARNING 872 + "Secure storage violation in task: %s, pid %d\n", 873 + current->comm, current->pid); 874 + send_sig(SIGSEGV, current, 0); 875 + } 876 + 862 877 #else 863 878 void do_secure_storage_access(struct pt_regs *regs) 864 879 { ··· 881 866 } 882 867 883 868 void do_non_secure_storage_access(struct pt_regs *regs) 869 + { 870 + default_trap_handler(regs); 871 + } 872 + 873 + void do_secure_storage_violation(struct pt_regs *regs) 884 874 { 885 875 default_trap_handler(regs); 886 876 }