Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ccd9e785 authored by Paolo Bonzini's avatar Paolo Bonzini
Browse files

Merge tag 'kvm-s390-next-20150209' of...

Merge tag 'kvm-s390-next-20150209' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD

KVM: s390: fixes and features for kvm/next (3.20)

1. Fixes
- Fix user triggerable endless loop
- reenable LPP facility
- disable KVM compat ioctl on s390 (untested and broken)

2. cpu models for s390
- provide facilities and instruction blocking per VM
- add s390 specific vm attributes for setting values

3. crypto
- toleration patch for z13 support

4. add uuid and long name to /proc/sysinfo (stsi 322)
- patch Acked by Heiko Carstens (touches non-kvm s390 code)
parents f7819512 de8e5d74
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
@@ -38,3 +38,48 @@ Allows userspace to query the actual limit and set a new limit for
the maximum guest memory size. The limit will be rounded up to
2048 MB, 4096 GB, 8192 TB respectively, as this limit is governed by
the number of page table levels.

2. GROUP: KVM_S390_VM_CPU_MODEL
Architectures: s390

2.1. ATTRIBUTE: KVM_S390_VM_CPU_MACHINE (r/o)

Allows user space to retrieve machine and kvm specific cpu related information:

struct kvm_s390_vm_cpu_machine {
       __u64 cpuid;           # CPUID of host
       __u32 ibc;             # IBC level range offered by host
       __u8  pad[4];
       __u64 fac_mask[256];   # set of cpu facilities enabled by KVM
       __u64 fac_list[256];   # set of cpu facilities offered by host
}

Parameters: address of buffer to store the machine related cpu data
            of type struct kvm_s390_vm_cpu_machine*
Returns:    -EFAULT if the given address is not accessible from kernel space
	    -ENOMEM if not enough memory is available to process the ioctl
	    0 in case of success

2.2. ATTRIBUTE: KVM_S390_VM_CPU_PROCESSOR (r/w)

Allows user space to retrieve or request to change cpu related information for a vcpu:

struct kvm_s390_vm_cpu_processor {
       __u64 cpuid;           # CPUID currently (to be) used by this vcpu
       __u16 ibc;             # IBC level currently (to be) used by this vcpu
       __u8  pad[6];
       __u64 fac_list[256];   # set of cpu facilities currently (to be) used
                              # by this vcpu
}

KVM does not enforce or limit the cpu model data in any form. Take the information
retrieved by means of KVM_S390_VM_CPU_MACHINE as hint for reasonable configuration
setups. Instruction interceptions triggered by additionally set facilitiy bits that
are not handled by KVM need to by imlemented in the VM driver code.

Parameters: address of buffer to store/set the processor related cpu
	    data of type struct kvm_s390_vm_cpu_processor*.
Returns:    -EBUSY in case 1 or more vcpus are already activated (only in write case)
	    -EFAULT if the given address is not accessible from kernel space
	    -ENOMEM if not enough memory is available to process the ioctl
	    0 in case of success
+26 −1
Original line number Diff line number Diff line
@@ -89,7 +89,8 @@ struct kvm_s390_sie_block {
	atomic_t cpuflags;		/* 0x0000 */
	__u32 : 1;			/* 0x0004 */
	__u32 prefix : 18;
	__u32 : 13;
	__u32 : 1;
	__u32 ibc : 12;
	__u8	reserved08[4];		/* 0x0008 */
#define PROG_IN_SIE (1<<0)
	__u32	prog0c;			/* 0x000c */
@@ -163,6 +164,7 @@ struct kvm_s390_sie_block {
	__u64	tecmc;			/* 0x00e8 */
	__u8	reservedf0[12];		/* 0x00f0 */
#define CRYCB_FORMAT1 0x00000001
#define CRYCB_FORMAT2 0x00000003
	__u32	crycbd;			/* 0x00fc */
	__u64	gcr[16];		/* 0x0100 */
	__u64	gbea;			/* 0x0180 */
@@ -505,6 +507,27 @@ struct s390_io_adapter {
#define MAX_S390_IO_ADAPTERS ((MAX_ISC + 1) * 8)
#define MAX_S390_ADAPTER_MAPS 256

/* maximum size of facilities and facility mask is 2k bytes */
#define S390_ARCH_FAC_LIST_SIZE_BYTE (1<<11)
#define S390_ARCH_FAC_LIST_SIZE_U64 \
	(S390_ARCH_FAC_LIST_SIZE_BYTE / sizeof(u64))
#define S390_ARCH_FAC_MASK_SIZE_BYTE S390_ARCH_FAC_LIST_SIZE_BYTE
#define S390_ARCH_FAC_MASK_SIZE_U64 \
	(S390_ARCH_FAC_MASK_SIZE_BYTE / sizeof(u64))

struct s390_model_fac {
	/* facilities used in SIE context */
	__u64 sie[S390_ARCH_FAC_LIST_SIZE_U64];
	/* subset enabled by kvm */
	__u64 kvm[S390_ARCH_FAC_LIST_SIZE_U64];
};

struct kvm_s390_cpu_model {
	struct s390_model_fac *fac;
	struct cpuid cpu_id;
	unsigned short ibc;
};

struct kvm_s390_crypto {
	struct kvm_s390_crypto_cb *crycb;
	__u32 crycbd;
@@ -516,6 +539,7 @@ struct kvm_s390_crypto_cb {
	__u8    reserved00[72];                 /* 0x0000 */
	__u8    dea_wrapping_key_mask[24];      /* 0x0048 */
	__u8    aes_wrapping_key_mask[32];      /* 0x0060 */
	__u8    reserved80[128];                /* 0x0080 */
};

struct kvm_arch{
@@ -534,6 +558,7 @@ struct kvm_arch{
	int ipte_lock_count;
	struct mutex ipte_mutex;
	spinlock_t start_stop_lock;
	struct kvm_s390_cpu_model model;
	struct kvm_s390_crypto crypto;
	u64 epoch;
};
+7 −3
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#define __ASM_S390_SYSINFO_H

#include <asm/bitsperlong.h>
#include <linux/uuid.h>

struct sysinfo_1_1_1 {
	unsigned char p:1;
@@ -112,10 +113,13 @@ struct sysinfo_3_2_2 {
		char name[8];
		unsigned int caf;
		char cpi[16];
		char reserved_1[24];

		char reserved_1[3];
		char ext_name_encoding;
		unsigned int reserved_2;
		uuid_be uuid;
	} vm[8];
	char reserved_544[3552];
	char reserved_3[1504];
	char ext_names[8][256];
};

extern int topology_max_mnest;
+21 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ struct kvm_s390_io_adapter_req {
#define KVM_S390_VM_MEM_CTRL		0
#define KVM_S390_VM_TOD			1
#define KVM_S390_VM_CRYPTO		2
#define KVM_S390_VM_CPU_MODEL		3

/* kvm attributes for mem_ctrl */
#define KVM_S390_VM_MEM_ENABLE_CMMA	0
@@ -69,6 +70,26 @@ struct kvm_s390_io_adapter_req {
#define KVM_S390_VM_TOD_LOW		0
#define KVM_S390_VM_TOD_HIGH		1

/* kvm attributes for KVM_S390_VM_CPU_MODEL */
/* processor related attributes are r/w */
#define KVM_S390_VM_CPU_PROCESSOR	0
struct kvm_s390_vm_cpu_processor {
	__u64 cpuid;
	__u16 ibc;
	__u8  pad[6];
	__u64 fac_list[256];
};

/* machine related attributes are r/o */
#define KVM_S390_VM_CPU_MACHINE		1
struct kvm_s390_vm_cpu_machine {
	__u64 cpuid;
	__u32 ibc;
	__u8  pad[4];
	__u64 fac_mask[256];
	__u64 fac_list[256];
};

/* kvm attributes for crypto */
#define KVM_S390_VM_CRYPTO_ENABLE_AES_KW	0
#define KVM_S390_VM_CRYPTO_ENABLE_DEA_KW	1
+29 −0
Original line number Diff line number Diff line
@@ -196,6 +196,33 @@ static void stsi_2_2_2(struct seq_file *m, struct sysinfo_2_2_2 *info)
	seq_printf(m, "LPAR CPUs Shared:     %d\n", info->cpus_shared);
}

static void print_ext_name(struct seq_file *m, int lvl,
			   struct sysinfo_3_2_2 *info)
{
	if (info->vm[lvl].ext_name_encoding == 0)
		return;
	if (info->ext_names[lvl][0] == 0)
		return;
	switch (info->vm[lvl].ext_name_encoding) {
	case 1: /* EBCDIC */
		EBCASC(info->ext_names[lvl], sizeof(info->ext_names[lvl]));
		break;
	case 2:	/* UTF-8 */
		break;
	default:
		return;
	}
	seq_printf(m, "VM%02d Extended Name:   %-.256s\n", lvl,
		   info->ext_names[lvl]);
}

static void print_uuid(struct seq_file *m, int i, struct sysinfo_3_2_2 *info)
{
	if (!memcmp(&info->vm[i].uuid, &NULL_UUID_BE, sizeof(uuid_be)))
		return;
	seq_printf(m, "VM%02d UUID:            %pUb\n", i, &info->vm[i].uuid);
}

static void stsi_3_2_2(struct seq_file *m, struct sysinfo_3_2_2 *info)
{
	int i;
@@ -213,6 +240,8 @@ static void stsi_3_2_2(struct seq_file *m, struct sysinfo_3_2_2 *info)
		seq_printf(m, "VM%02d CPUs Configured: %d\n", i, info->vm[i].cpus_configured);
		seq_printf(m, "VM%02d CPUs Standby:    %d\n", i, info->vm[i].cpus_standby);
		seq_printf(m, "VM%02d CPUs Reserved:   %d\n", i, info->vm[i].cpus_reserved);
		print_ext_name(m, i, info);
		print_uuid(m, i, info);
	}
}

Loading