Files
cubelinux-kernel/arch/s390/kernel/skey.c
T
Greg Kroah-Hartman 598cf27219 Linux 6.19.3
Link: https://lore.kernel.org/r/20260217200002.683975158@linuxfoundation.org
Tested-by: Florian Fainelli <florian.fainelli@broadcom.com>
Tested-by: Takeshi Ogasawara <takeshi.ogasawara@futuring-girl.com>
Tested-by: Peter Schneider <pschneider1968@googlemail.com>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: Salvatore Bonaccorso <carnil@debian.org>
Tested-by: Brett A C Sheffield <bacs@librecast.net>
Tested-by: Mark Brown <broonie@kernel.org>
Tested-by: Luna Jernberg <droidbittin@gmail.com>
Tested-by: Ronald Warsow <rwarsow@gmx.de>
Tested-by: Justin M. Forbes <jforbes@fedoraproject.org>
Tested-by: Ron Economos <re@w6rz.net>
Tested-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-02-19 16:33:27 +01:00

49 lines
1.0 KiB
C

// SPDX-License-Identifier: GPL-2.0
#include <asm/rwonce.h>
#include <asm/page.h>
#include <asm/skey.h>
int skey_regions_initialized;
static inline unsigned long load_real_address(unsigned long address)
{
unsigned long real;
asm volatile(
" lra %[real],0(%[address])"
: [real] "=d" (real)
: [address] "a" (address)
: "cc");
return real;
}
/*
* Initialize storage keys of registered memory regions with the
* default key. This is useful for code which is executed with a
* non-default access key.
*/
void __skey_regions_initialize(void)
{
unsigned long address, real;
struct skey_region *r, *end;
r = __skey_region_start;
end = __skey_region_end;
while (r < end) {
address = r->start & PAGE_MASK;
do {
real = load_real_address(address);
page_set_storage_key(real, PAGE_DEFAULT_KEY, 1);
address += PAGE_SIZE;
} while (address < r->end);
r++;
}
/*
* Make sure storage keys are initialized before
* skey_regions_initialized is changed.
*/
barrier();
WRITE_ONCE(skey_regions_initialized, 1);
}