Skip to content

Commit f3633c2

Browse files
committed
Merge tag 'kvm-s390-next-5.9-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into kvm-next-5.6
KVM: s390: Enhancement for 5.9 - implement diagnose 318
2 parents ff2bd9f + 23a60f8 commit f3633c2

File tree

7 files changed

+23
-11
lines changed

7 files changed

+23
-11
lines changed

arch/s390/include/asm/diag.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,8 @@ struct diag26c_mac_resp {
298298
union diag318_info {
299299
unsigned long val;
300300
struct {
301-
unsigned int cpnc : 8;
302-
unsigned int cpvc_linux : 24;
303-
unsigned char cpvc_distro[3];
304-
unsigned char zero;
301+
unsigned long cpnc : 8;
302+
unsigned long cpvc : 56;
305303
};
306304
};
307305

arch/s390/include/asm/kvm_host.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ struct kvm_s390_sie_block {
260260
__u32 scaol; /* 0x0064 */
261261
__u8 sdf; /* 0x0068 */
262262
__u8 epdx; /* 0x0069 */
263-
__u8 reserved6a[2]; /* 0x006a */
263+
__u8 cpnc; /* 0x006a */
264+
__u8 reserved6b; /* 0x006b */
264265
__u32 todpr; /* 0x006c */
265266
#define GISA_FORMAT1 0x00000001
266267
__u32 gd; /* 0x0070 */
@@ -745,6 +746,7 @@ struct kvm_vcpu_arch {
745746
bool gs_enabled;
746747
bool skey_enabled;
747748
struct kvm_s390_pv_vcpu pv;
749+
union diag318_info diag318_info;
748750
};
749751

750752
struct kvm_vm_stat {

arch/s390/include/uapi/asm/kvm.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,13 @@ struct kvm_guest_debug_arch {
231231
#define KVM_SYNC_GSCB (1UL << 9)
232232
#define KVM_SYNC_BPBC (1UL << 10)
233233
#define KVM_SYNC_ETOKEN (1UL << 11)
234+
#define KVM_SYNC_DIAG318 (1UL << 12)
234235

235236
#define KVM_SYNC_S390_VALID_FIELDS \
236237
(KVM_SYNC_PREFIX | KVM_SYNC_GPRS | KVM_SYNC_ACRS | KVM_SYNC_CRS | \
237238
KVM_SYNC_ARCH0 | KVM_SYNC_PFAULT | KVM_SYNC_VRS | KVM_SYNC_RICCB | \
238-
KVM_SYNC_FPRS | KVM_SYNC_GSCB | KVM_SYNC_BPBC | KVM_SYNC_ETOKEN)
239+
KVM_SYNC_FPRS | KVM_SYNC_GSCB | KVM_SYNC_BPBC | KVM_SYNC_ETOKEN | \
240+
KVM_SYNC_DIAG318)
239241

240242
/* length and alignment of the sdnx as a power of two */
241243
#define SDNXC 8
@@ -264,7 +266,8 @@ struct kvm_sync_regs {
264266
__u8 reserved2 : 7;
265267
__u8 padding1[51]; /* riccb needs to be 64byte aligned */
266268
__u8 riccb[64]; /* runtime instrumentation controls block */
267-
__u8 padding2[192]; /* sdnx needs to be 256byte aligned */
269+
__u64 diag318; /* diagnose 0x318 info */
270+
__u8 padding2[184]; /* sdnx needs to be 256byte aligned */
268271
union {
269272
__u8 sdnx[SDNXL]; /* state description annex */
270273
struct {

arch/s390/kernel/setup.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,8 +1021,7 @@ static void __init setup_control_program_code(void)
10211021
{
10221022
union diag318_info diag318_info = {
10231023
.cpnc = CPNC_LINUX,
1024-
.cpvc_linux = 0,
1025-
.cpvc_distro = {0},
1024+
.cpvc = 0,
10261025
};
10271026

10281027
if (!sclp.has_diag318)

arch/s390/kvm/kvm-s390.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
545545
case KVM_CAP_S390_AIS_MIGRATION:
546546
case KVM_CAP_S390_VCPU_RESETS:
547547
case KVM_CAP_SET_GUEST_DEBUG:
548+
case KVM_CAP_S390_DIAG318:
548549
r = 1;
549550
break;
550551
case KVM_CAP_S390_HPAGE_1M:
@@ -3267,7 +3268,8 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
32673268
KVM_SYNC_ACRS |
32683269
KVM_SYNC_CRS |
32693270
KVM_SYNC_ARCH0 |
3270-
KVM_SYNC_PFAULT;
3271+
KVM_SYNC_PFAULT |
3272+
KVM_SYNC_DIAG318;
32713273
kvm_s390_set_prefix(vcpu, 0);
32723274
if (test_kvm_facility(vcpu->kvm, 64))
32733275
vcpu->run->kvm_valid_regs |= KVM_SYNC_RICCB;
@@ -3562,6 +3564,7 @@ static void kvm_arch_vcpu_ioctl_initial_reset(struct kvm_vcpu *vcpu)
35623564
vcpu->arch.sie_block->pp = 0;
35633565
vcpu->arch.sie_block->fpf &= ~FPF_BPBC;
35643566
vcpu->arch.sie_block->todpr = 0;
3567+
vcpu->arch.sie_block->cpnc = 0;
35653568
}
35663569
}
35673570

@@ -3579,6 +3582,7 @@ static void kvm_arch_vcpu_ioctl_clear_reset(struct kvm_vcpu *vcpu)
35793582

35803583
regs->etoken = 0;
35813584
regs->etoken_extension = 0;
3585+
regs->diag318 = 0;
35823586
}
35833587

35843588
int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
@@ -4195,6 +4199,10 @@ static void sync_regs_fmt2(struct kvm_vcpu *vcpu)
41954199
if (vcpu->arch.pfault_token == KVM_S390_PFAULT_TOKEN_INVALID)
41964200
kvm_clear_async_pf_completion_queue(vcpu);
41974201
}
4202+
if (kvm_run->kvm_dirty_regs & KVM_SYNC_DIAG318) {
4203+
vcpu->arch.diag318_info.val = kvm_run->s.regs.diag318;
4204+
vcpu->arch.sie_block->cpnc = vcpu->arch.diag318_info.cpnc;
4205+
}
41984206
/*
41994207
* If userspace sets the riccb (e.g. after migration) to a valid state,
42004208
* we should enable RI here instead of doing the lazy enablement.
@@ -4300,6 +4308,7 @@ static void store_regs_fmt2(struct kvm_vcpu *vcpu)
43004308
kvm_run->s.regs.pp = vcpu->arch.sie_block->pp;
43014309
kvm_run->s.regs.gbea = vcpu->arch.sie_block->gbea;
43024310
kvm_run->s.regs.bpbc = (vcpu->arch.sie_block->fpf & FPF_BPBC) == FPF_BPBC;
4311+
kvm_run->s.regs.diag318 = vcpu->arch.diag318_info.val;
43034312
if (MACHINE_HAS_GS) {
43044313
__ctl_set_bit(2, 4);
43054314
if (vcpu->arch.gs_enabled)

arch/s390/kvm/vsie.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
548548
scb_s->ecd |= scb_o->ecd & ECD_ETOKENF;
549549

550550
scb_s->hpid = HPID_VSIE;
551+
scb_s->cpnc = scb_o->cpnc;
551552

552553
prepare_ibc(vcpu, vsie_page);
553554
rc = shadow_crycb(vcpu, vsie_page);

include/uapi/linux/kvm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ struct kvm_ppc_resize_hpt {
10341034
#define KVM_CAP_ASYNC_PF_INT 183
10351035
#define KVM_CAP_LAST_CPU 184
10361036
#define KVM_CAP_SMALLER_MAXPHYADDR 185
1037-
1037+
#define KVM_CAP_S390_DIAG318 186
10381038

10391039
#ifdef KVM_CAP_IRQ_ROUTING
10401040

0 commit comments

Comments
 (0)