diff options
author | Nina Schoetterl-Glausch <nsg@linux.ibm.com> | 2023-12-19 15:08:51 +0100 |
---|---|---|
committer | Janosch Frank <frankja@linux.ibm.com> | 2023-12-23 10:41:09 +0100 |
commit | 682dbf430d27bc0e23d8d6921116b4f77f5dc9c6 (patch) | |
tree | 7d15afcec67aafd2fd7027251e61c14c032adddf /arch/s390/kernel/facility.c | |
parent | KVM: s390: vsie: Fix STFLE interpretive execution identification (diff) | |
download | linux-682dbf430d27bc0e23d8d6921116b4f77f5dc9c6.tar.xz linux-682dbf430d27bc0e23d8d6921116b4f77f5dc9c6.zip |
KVM: s390: vsie: Fix length of facility list shadowed
The length of the facility list accessed when interpretively executing
STFLE is the same as the hosts facility list (in case of format-0)
The memory following the facility list doesn't need to be accessible.
The current VSIE implementation accesses a fixed length that exceeds the
guest/host facility list length and can therefore wrongly inject a
validity intercept.
Instead, find out the host facility list length by running STFLE and
copy only as much as necessary when shadowing.
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Link: https://lore.kernel.org/r/20231219140854.1042599-3-nsg@linux.ibm.com
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Message-ID: <20231219140854.1042599-3-nsg@linux.ibm.com>
Diffstat (limited to 'arch/s390/kernel/facility.c')
-rw-r--r-- | arch/s390/kernel/facility.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/arch/s390/kernel/facility.c b/arch/s390/kernel/facility.c new file mode 100644 index 000000000000..f02127219a27 --- /dev/null +++ b/arch/s390/kernel/facility.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright IBM Corp. 2023 + */ + +#include <asm/facility.h> + +unsigned int stfle_size(void) +{ + static unsigned int size; + unsigned int r; + u64 dummy; + + r = READ_ONCE(size); + if (!r) { + r = __stfle_asm(&dummy, 1) + 1; + WRITE_ONCE(size, r); + } + return r; +} +EXPORT_SYMBOL(stfle_size); |