s390/mm: add debug user asce support

Verify on exit to user space that always
- the primary ASCE (cr1) is set to kernel ASCE
- the secondary ASCE (cr7) is set to user ASCE

If this is not the case: panic since something went terribly wrong.

Reviewed-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
This commit is contained in:
Heiko Carstens
2020-11-16 08:06:41 +01:00
parent 0290c9e328
commit 062e527956
5 changed files with 35 additions and 0 deletions

View File

@@ -16,6 +16,22 @@
#include <asm/mmu_context.h>
#include <asm/facility.h>
#ifdef CONFIG_DEBUG_USER_ASCE
void debug_user_asce(void)
{
unsigned long cr1, cr7;
__ctl_store(cr1, 1, 1);
__ctl_store(cr7, 7, 7);
if (cr1 == S390_lowcore.kernel_asce && cr7 == S390_lowcore.user_asce)
return;
panic("incorrect ASCE on kernel exit\n"
"cr1: %016lx cr7: %016lx\n"
"kernel: %016llx user: %016llx\n",
cr1, cr7, S390_lowcore.kernel_asce, S390_lowcore.user_asce);
}
#endif /*CONFIG_DEBUG_USER_ASCE */
#ifndef CONFIG_HAVE_MARCH_Z10_FEATURES
static DEFINE_STATIC_KEY_FALSE(have_mvcos);