Skip to content

Commit 731859d

Browse files
committed
Merge tag 'kvm-s390-next-6.8-1' of https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD
- uvdevice fixed additional data return length - stfle (feature indication) vsie fixes and minor cleanup
2 parents 1362925 + 10f7b1d commit 731859d

6 files changed

Lines changed: 49 additions & 4 deletions

File tree

arch/s390/include/asm/facility.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,10 @@ static inline void stfle(u64 *stfle_fac_list, int size)
111111
preempt_enable();
112112
}
113113

114+
/**
115+
* stfle_size - Actual size of the facility list as specified by stfle
116+
* (number of double words)
117+
*/
118+
unsigned int stfle_size(void);
119+
114120
#endif /* __ASM_FACILITY_H */

arch/s390/include/asm/kvm_host.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ struct s390_io_adapter {
818818

819819
struct kvm_s390_cpu_model {
820820
/* facility mask supported by kvm & hosting machine */
821-
__u64 fac_mask[S390_ARCH_FAC_LIST_SIZE_U64];
821+
__u64 fac_mask[S390_ARCH_FAC_MASK_SIZE_U64];
822822
struct kvm_s390_vm_cpu_subfunc subfuncs;
823823
/* facility list requested by guest (in dma page) */
824824
__u64 *fac_list;

arch/s390/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ obj-y += sysinfo.o lgr.o os_info.o ctlreg.o
4141
obj-y += runtime_instr.o cache.o fpu.o dumpstack.o guarded_storage.o sthyi.o
4242
obj-y += entry.o reipl.o kdebugfs.o alternative.o
4343
obj-y += nospec-branch.o ipl_vmparm.o machine_kexec_reloc.o unwind_bc.o
44-
obj-y += smp.o text_amode31.o stacktrace.o abs_lowcore.o
44+
obj-y += smp.o text_amode31.o stacktrace.o abs_lowcore.o facility.o
4545

4646
extra-y += vmlinux.lds
4747

arch/s390/kernel/facility.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright IBM Corp. 2023
4+
*/
5+
6+
#include <asm/facility.h>
7+
8+
unsigned int stfle_size(void)
9+
{
10+
static unsigned int size;
11+
unsigned int r;
12+
u64 dummy;
13+
14+
r = READ_ONCE(size);
15+
if (!r) {
16+
r = __stfle_asm(&dummy, 1) + 1;
17+
WRITE_ONCE(size, r);
18+
}
19+
return r;
20+
}
21+
EXPORT_SYMBOL(stfle_size);

arch/s390/kvm/vsie.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <asm/nmi.h>
2020
#include <asm/dis.h>
2121
#include <asm/fpu/api.h>
22+
#include <asm/facility.h>
2223
#include "kvm-s390.h"
2324
#include "gaccess.h"
2425

@@ -984,12 +985,26 @@ static void retry_vsie_icpt(struct vsie_page *vsie_page)
984985
static int handle_stfle(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
985986
{
986987
struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
987-
__u32 fac = READ_ONCE(vsie_page->scb_o->fac) & 0x7ffffff8U;
988+
__u32 fac = READ_ONCE(vsie_page->scb_o->fac);
988989

990+
/*
991+
* Alternate-STFLE-Interpretive-Execution facilities are not supported
992+
* -> format-0 flcb
993+
*/
989994
if (fac && test_kvm_facility(vcpu->kvm, 7)) {
990995
retry_vsie_icpt(vsie_page);
996+
/*
997+
* The facility list origin (FLO) is in bits 1 - 28 of the FLD
998+
* so we need to mask here before reading.
999+
*/
1000+
fac = fac & 0x7ffffff8U;
1001+
/*
1002+
* format-0 -> size of nested guest's facility list == guest's size
1003+
* guest's size == host's size, since STFLE is interpretatively executed
1004+
* using a format-0 for the guest, too.
1005+
*/
9911006
if (read_guest_real(vcpu, fac, &vsie_page->fac,
992-
sizeof(vsie_page->fac)))
1007+
stfle_size() * sizeof(u64)))
9931008
return set_validity_icpt(scb_s, 0x1090U);
9941009
scb_s->fac = (__u32)(__u64) &vsie_page->fac;
9951010
}

drivers/s390/char/uvdevice.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ static int uvio_copy_attest_result_to_user(struct uv_cb_attest *uvcb_attest,
109109
struct uvio_attest *uvio_attest)
110110
{
111111
struct uvio_attest __user *user_uvio_attest = (void __user *)uv_ioctl->argument_addr;
112+
u32 __user *user_buf_add_len = (u32 __user *)&user_uvio_attest->add_data_len;
112113
void __user *user_buf_add = (void __user *)uvio_attest->add_data_addr;
113114
void __user *user_buf_meas = (void __user *)uvio_attest->meas_addr;
114115
void __user *user_buf_uid = &user_uvio_attest->config_uid;
@@ -117,6 +118,8 @@ static int uvio_copy_attest_result_to_user(struct uv_cb_attest *uvcb_attest,
117118
return -EFAULT;
118119
if (add_data && copy_to_user(user_buf_add, add_data, uvio_attest->add_data_len))
119120
return -EFAULT;
121+
if (put_user(uvio_attest->add_data_len, user_buf_add_len))
122+
return -EFAULT;
120123
if (copy_to_user(user_buf_uid, uvcb_attest->config_uid, sizeof(uvcb_attest->config_uid)))
121124
return -EFAULT;
122125
return 0;

0 commit comments

Comments
 (0)