]> git.ipfire.org Git - thirdparty/linux.git/commit
s390/skey: Provide infrastructure for executing with non-default access key
authorHeiko Carstens <hca@linux.ibm.com>
Mon, 16 Jun 2025 15:00:30 +0000 (17:00 +0200)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Sun, 29 Jun 2025 11:12:02 +0000 (13:12 +0200)
commitee417a84d005f90b6c2e572dbad00a25f9fb7660
tree305f359688889edb598fd45b39ffca4ba3f34b69
parent6fe0ea914d73a32b27db9eff5259e59c28633eac
s390/skey: Provide infrastructure for executing with non-default access key

The current assumption is that kernel code is always executed with access
key zero, which means that storage key protection does not apply.

However this assumption is not correct: cmpxchg_user_key() may be executed
with a non-zero key; if then the storage key of the page which belongs to
the cmpxchg_user_key() code contains a key with fetch-protection enabled
the result is a protection exception.

For several performance optimizations storage keys are not initialized on
system boot. To keep these optimizations add infrastructure which allows to
define code ranges within functions which are executed with a non-default
key. When such code is executed such functions must explicitly call
skey_regions_initialize().

This will initialize all storage keys belonging to such code ranges in a
way that no protection exceptions happen when the code is executed with a
non-default access key.

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
arch/s390/include/asm/skey.h [new file with mode: 0644]
arch/s390/kernel/Makefile
arch/s390/kernel/skey.c [new file with mode: 0644]
arch/s390/kernel/vmlinux.lds.S