All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/7] KVM: s390: new guest facilities
@ 2019-04-24 11:56 Christian Borntraeger
  2019-04-24 11:56 ` [PATCH v2 1/7] KVM: s390: add vector enhancements facility 2 to cpumodel Christian Borntraeger
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Christian Borntraeger @ 2019-04-24 11:56 UTC (permalink / raw)
  To: Christian Borntraeger, Janosch Frank
  Cc: KVM, Cornelia Huck, David Hildenbrand, Paolo Bonzini,
	Radim Krčmář,
	Collin Walling, Jason J . Herne

Here is support for new guest cpu facilities.

v1->v2: rework keywrapping patch (now the last one)
	- vsie
	- also check for aes keywrapping
	- add helper functions 

Christian Borntraeger (7):
  KVM: s390: add vector enhancements facility 2 to cpumodel
  KVM: s390: add vector BCD enhancements facility to cpumodel
  KVM: s390: add MSA9 to cpumodel
  KVM: s390: provide query function for instructions returning 32 byte
  KVM: s390: add enhanced sort facilty to cpu model
  KVM: s390: add deflate conversion facilty to cpu model
  KVM: s390: enable MSA9 keywrapping functions depending on cpu model

 Documentation/virtual/kvm/devices/vm.txt |   3 +-
 arch/s390/include/asm/cpacf.h            |   1 +
 arch/s390/include/asm/kvm_host.h         |   1 +
 arch/s390/include/uapi/asm/kvm.h         |   5 +-
 arch/s390/kvm/kvm-s390.c                 | 103 ++++++++++++++++++++++-
 arch/s390/kvm/vsie.c                     |   5 +-
 arch/s390/tools/gen_facilities.c         |   3 +
 tools/arch/s390/include/uapi/asm/kvm.h   |   3 +-
 8 files changed, 119 insertions(+), 5 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 1/7] KVM: s390: add vector enhancements facility 2 to cpumodel
  2019-04-24 11:56 [PATCH v2 0/7] KVM: s390: new guest facilities Christian Borntraeger
@ 2019-04-24 11:56 ` Christian Borntraeger
  2019-04-24 11:56 ` [PATCH v2 2/7] KVM: s390: add vector BCD enhancements facility " Christian Borntraeger
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Christian Borntraeger @ 2019-04-24 11:56 UTC (permalink / raw)
  To: Christian Borntraeger, Janosch Frank
  Cc: KVM, Cornelia Huck, David Hildenbrand, Paolo Bonzini,
	Radim Krčmář,
	Collin Walling, Jason J . Herne

If vector support is enabled, the vector enhancements facility 2
might also be enabled.
We can directly forward this facility to the guest if available
and VX is requested by user space.

Please note that user space can and will have the final decision
on the facility bits for a guests.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
---
 arch/s390/kvm/kvm-s390.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 4638303ba6a8..03ddbe5e62bc 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -657,6 +657,10 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap)
 				set_kvm_facility(kvm->arch.model.fac_mask, 135);
 				set_kvm_facility(kvm->arch.model.fac_list, 135);
 			}
+			if (test_facility(148)) {
+				set_kvm_facility(kvm->arch.model.fac_mask, 148);
+				set_kvm_facility(kvm->arch.model.fac_list, 148);
+			}
 			r = 0;
 		} else
 			r = -EINVAL;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 2/7] KVM: s390: add vector BCD enhancements facility to cpumodel
  2019-04-24 11:56 [PATCH v2 0/7] KVM: s390: new guest facilities Christian Borntraeger
  2019-04-24 11:56 ` [PATCH v2 1/7] KVM: s390: add vector enhancements facility 2 to cpumodel Christian Borntraeger
@ 2019-04-24 11:56 ` Christian Borntraeger
  2019-04-24 11:56 ` [PATCH v2 3/7] KVM: s390: add MSA9 " Christian Borntraeger
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Christian Borntraeger @ 2019-04-24 11:56 UTC (permalink / raw)
  To: Christian Borntraeger, Janosch Frank
  Cc: KVM, Cornelia Huck, David Hildenbrand, Paolo Bonzini,
	Radim Krčmář,
	Collin Walling, Jason J . Herne

If vector support is enabled, the vector BCD enhancements facility
might also be enabled.
We can directly forward this facility to the guest if available
and VX is requested by user space.

Please note that user space can and will have the final decision
on the facility bits for a guests.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
---
 arch/s390/kvm/kvm-s390.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 03ddbe5e62bc..d3f3e63bb164 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -661,6 +661,10 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap)
 				set_kvm_facility(kvm->arch.model.fac_mask, 148);
 				set_kvm_facility(kvm->arch.model.fac_list, 148);
 			}
+			if (test_facility(152)) {
+				set_kvm_facility(kvm->arch.model.fac_mask, 152);
+				set_kvm_facility(kvm->arch.model.fac_list, 152);
+			}
 			r = 0;
 		} else
 			r = -EINVAL;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 3/7] KVM: s390: add MSA9 to cpumodel
  2019-04-24 11:56 [PATCH v2 0/7] KVM: s390: new guest facilities Christian Borntraeger
  2019-04-24 11:56 ` [PATCH v2 1/7] KVM: s390: add vector enhancements facility 2 to cpumodel Christian Borntraeger
  2019-04-24 11:56 ` [PATCH v2 2/7] KVM: s390: add vector BCD enhancements facility " Christian Borntraeger
@ 2019-04-24 11:56 ` Christian Borntraeger
  2019-04-24 11:56 ` [PATCH v2 4/7] KVM: s390: provide query function for instructions returning 32 byte Christian Borntraeger
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Christian Borntraeger @ 2019-04-24 11:56 UTC (permalink / raw)
  To: Christian Borntraeger, Janosch Frank
  Cc: KVM, Cornelia Huck, David Hildenbrand, Paolo Bonzini,
	Radim Krčmář,
	Collin Walling, Jason J . Herne

This enables stfle.155 and adds the subfunctions for KDSA. Bit 155 is
added to the list of facilities that will be enabled when there is no
cpu model involved as MSA9 requires no additional handling from
userspace, e.g. for migration.

Please note that a cpu model enabled user space can and will have the
final decision on the facility bits for a guests.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
---
 Documentation/virtual/kvm/devices/vm.txt |  3 ++-
 arch/s390/include/asm/cpacf.h            |  1 +
 arch/s390/include/uapi/asm/kvm.h         |  3 ++-
 arch/s390/kvm/kvm-s390.c                 | 13 +++++++++++++
 arch/s390/tools/gen_facilities.c         |  1 +
 tools/arch/s390/include/uapi/asm/kvm.h   |  3 ++-
 6 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/Documentation/virtual/kvm/devices/vm.txt b/Documentation/virtual/kvm/devices/vm.txt
index 95ca68d663a4..4ffb82b02468 100644
--- a/Documentation/virtual/kvm/devices/vm.txt
+++ b/Documentation/virtual/kvm/devices/vm.txt
@@ -141,7 +141,8 @@ struct kvm_s390_vm_cpu_subfunc {
        u8 pcc[16];           # valid with Message-Security-Assist-Extension 4
        u8 ppno[16];          # valid with Message-Security-Assist-Extension 5
        u8 kma[16];           # valid with Message-Security-Assist-Extension 8
-       u8 reserved[1808];    # reserved for future instructions
+       u8 kdsa[16];          # valid with Message-Security-Assist-Extension 9
+       u8 reserved[1792];    # reserved for future instructions
 };
 
 Parameters: address of a buffer to load the subfunction blocks from.
diff --git a/arch/s390/include/asm/cpacf.h b/arch/s390/include/asm/cpacf.h
index 3cc52e37b4b2..ce2770743cc5 100644
--- a/arch/s390/include/asm/cpacf.h
+++ b/arch/s390/include/asm/cpacf.h
@@ -28,6 +28,7 @@
 #define CPACF_KMCTR		0xb92d		/* MSA4 */
 #define CPACF_PRNO		0xb93c		/* MSA5 */
 #define CPACF_KMA		0xb929		/* MSA8 */
+#define CPACF_KDSA		0xb93a		/* MSA9 */
 
 /*
  * En/decryption modifier bits
diff --git a/arch/s390/include/uapi/asm/kvm.h b/arch/s390/include/uapi/asm/kvm.h
index 16511d97e8dc..09652eabe769 100644
--- a/arch/s390/include/uapi/asm/kvm.h
+++ b/arch/s390/include/uapi/asm/kvm.h
@@ -152,7 +152,8 @@ struct kvm_s390_vm_cpu_subfunc {
 	__u8 pcc[16];		/* with MSA4 */
 	__u8 ppno[16];		/* with MSA5 */
 	__u8 kma[16];		/* with MSA8 */
-	__u8 reserved[1808];
+	__u8 kdsa[16];		/* with MSA9 */
+	__u8 reserved[1792];
 };
 
 /* kvm attributes for crypto */
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index d3f3e63bb164..0dad61ccde3d 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -368,6 +368,10 @@ static void kvm_s390_cpu_feat_init(void)
 		__cpacf_query(CPACF_KMA, (cpacf_mask_t *)
 			      kvm_s390_available_subfunc.kma);
 
+	if (test_facility(155)) /* MSA9 */
+		__cpacf_query(CPACF_KDSA, (cpacf_mask_t *)
+			      kvm_s390_available_subfunc.kdsa);
+
 	if (MACHINE_HAS_ESOP)
 		allow_cpu_feat(KVM_S390_VM_CPU_FEAT_ESOP);
 	/*
@@ -1331,6 +1335,9 @@ static int kvm_s390_set_processor_subfunc(struct kvm *kvm,
 	VM_EVENT(kvm, 3, "SET: guest KMA    subfunc 0x%16.16lx.%16.16lx",
 		 ((unsigned long *) &kvm->arch.model.subfuncs.kma)[0],
 		 ((unsigned long *) &kvm->arch.model.subfuncs.kma)[1]);
+	VM_EVENT(kvm, 3, "SET: guest KDSA   subfunc 0x%16.16lx.%16.16lx",
+		 ((unsigned long *) &kvm->arch.model.subfuncs.kdsa)[0],
+		 ((unsigned long *) &kvm->arch.model.subfuncs.kdsa)[1]);
 
 	return 0;
 }
@@ -1499,6 +1506,9 @@ static int kvm_s390_get_processor_subfunc(struct kvm *kvm,
 	VM_EVENT(kvm, 3, "GET: guest KMA    subfunc 0x%16.16lx.%16.16lx",
 		 ((unsigned long *) &kvm->arch.model.subfuncs.kma)[0],
 		 ((unsigned long *) &kvm->arch.model.subfuncs.kma)[1]);
+	VM_EVENT(kvm, 3, "GET: guest KDSA   subfunc 0x%16.16lx.%16.16lx",
+		 ((unsigned long *) &kvm->arch.model.subfuncs.kdsa)[0],
+		 ((unsigned long *) &kvm->arch.model.subfuncs.kdsa)[1]);
 
 	return 0;
 }
@@ -1554,6 +1564,9 @@ static int kvm_s390_get_machine_subfunc(struct kvm *kvm,
 	VM_EVENT(kvm, 3, "GET: host  KMA    subfunc 0x%16.16lx.%16.16lx",
 		 ((unsigned long *) &kvm_s390_available_subfunc.kma)[0],
 		 ((unsigned long *) &kvm_s390_available_subfunc.kma)[1]);
+	VM_EVENT(kvm, 3, "GET: host  KDSA   subfunc 0x%16.16lx.%16.16lx",
+		 ((unsigned long *) &kvm_s390_available_subfunc.kdsa)[0],
+		 ((unsigned long *) &kvm_s390_available_subfunc.kdsa)[1]);
 
 	return 0;
 }
diff --git a/arch/s390/tools/gen_facilities.c b/arch/s390/tools/gen_facilities.c
index fd788e0f2e5b..e952cb3b75b2 100644
--- a/arch/s390/tools/gen_facilities.c
+++ b/arch/s390/tools/gen_facilities.c
@@ -93,6 +93,7 @@ static struct facility_def facility_defs[] = {
 			131, /* enhanced-SOP 2 and side-effect */
 			139, /* multiple epoch facility */
 			146, /* msa extension 8 */
+			155, /* msa extension 9 */
 			-1  /* END */
 		}
 	},
diff --git a/tools/arch/s390/include/uapi/asm/kvm.h b/tools/arch/s390/include/uapi/asm/kvm.h
index 16511d97e8dc..09652eabe769 100644
--- a/tools/arch/s390/include/uapi/asm/kvm.h
+++ b/tools/arch/s390/include/uapi/asm/kvm.h
@@ -152,7 +152,8 @@ struct kvm_s390_vm_cpu_subfunc {
 	__u8 pcc[16];		/* with MSA4 */
 	__u8 ppno[16];		/* with MSA5 */
 	__u8 kma[16];		/* with MSA8 */
-	__u8 reserved[1808];
+	__u8 kdsa[16];		/* with MSA9 */
+	__u8 reserved[1792];
 };
 
 /* kvm attributes for crypto */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 4/7] KVM: s390: provide query function for instructions returning 32 byte
  2019-04-24 11:56 [PATCH v2 0/7] KVM: s390: new guest facilities Christian Borntraeger
                   ` (2 preceding siblings ...)
  2019-04-24 11:56 ` [PATCH v2 3/7] KVM: s390: add MSA9 " Christian Borntraeger
@ 2019-04-24 11:56 ` Christian Borntraeger
  2019-04-24 11:56 ` [PATCH v2 5/7] KVM: s390: add enhanced sort facilty to cpu model Christian Borntraeger
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Christian Borntraeger @ 2019-04-24 11:56 UTC (permalink / raw)
  To: Christian Borntraeger, Janosch Frank
  Cc: KVM, Cornelia Huck, David Hildenbrand, Paolo Bonzini,
	Radim Krčmář,
	Collin Walling, Jason J . Herne

Some of the new features have a 32byte response for the query function.
Provide a new wrapper similar to __cpacf_query. We might want to factor
this out if other users come up, as of today there is none. So let us
keep the function within KVM.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
---
 arch/s390/kvm/kvm-s390.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 0dad61ccde3d..336e591d94eb 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -321,6 +321,19 @@ static inline int plo_test_bit(unsigned char nr)
 	return cc == 0;
 }
 
+static inline void __insn32_query(unsigned int opcode, u8 query[32])
+{
+	register unsigned long r0 asm("0") = 0;	/* query function */
+	register unsigned long r1 asm("1") = (unsigned long) query;
+
+	asm volatile(
+		/* Parameter regs are ignored */
+		"	.insn	rrf,%[opc] << 16,2,4,6,0\n"
+		: "=m" (*query)
+		: "d" (r0), "a" (r1), [opc] "i" (opcode)
+		: "cc");
+}
+
 static void kvm_s390_cpu_feat_init(void)
 {
 	int i;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 5/7] KVM: s390: add enhanced sort facilty to cpu model
  2019-04-24 11:56 [PATCH v2 0/7] KVM: s390: new guest facilities Christian Borntraeger
                   ` (3 preceding siblings ...)
  2019-04-24 11:56 ` [PATCH v2 4/7] KVM: s390: provide query function for instructions returning 32 byte Christian Borntraeger
@ 2019-04-24 11:56 ` Christian Borntraeger
  2019-04-24 11:56 ` [PATCH v2 6/7] KVM: s390: add deflate conversion " Christian Borntraeger
  2019-04-24 11:56 ` [PATCH v2 7/7] KVM: s390: enable MSA9 keywrapping functions depending on " Christian Borntraeger
  6 siblings, 0 replies; 12+ messages in thread
From: Christian Borntraeger @ 2019-04-24 11:56 UTC (permalink / raw)
  To: Christian Borntraeger, Janosch Frank
  Cc: KVM, Cornelia Huck, David Hildenbrand, Paolo Bonzini,
	Radim Krčmář,
	Collin Walling, Jason J . Herne

This enables stfle.150 and adds the subfunctions for SORTL. Bit 150 is
added to the list of facilities that will be enabled when there is no
cpu model involved as sortl requires no additional handling from
userspace, e.g. for migration.

Please note that a cpu model enabled user space can and will have the
final decision on the facility bits for a guests.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
---
 arch/s390/include/uapi/asm/kvm.h |  3 ++-
 arch/s390/kvm/kvm-s390.c         | 20 ++++++++++++++++++++
 arch/s390/tools/gen_facilities.c |  1 +
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/arch/s390/include/uapi/asm/kvm.h b/arch/s390/include/uapi/asm/kvm.h
index 09652eabe769..eba5bac08348 100644
--- a/arch/s390/include/uapi/asm/kvm.h
+++ b/arch/s390/include/uapi/asm/kvm.h
@@ -153,7 +153,8 @@ struct kvm_s390_vm_cpu_subfunc {
 	__u8 ppno[16];		/* with MSA5 */
 	__u8 kma[16];		/* with MSA8 */
 	__u8 kdsa[16];		/* with MSA9 */
-	__u8 reserved[1792];
+	__u8 sortl[32];		/* with STFLE.150 */
+	__u8 reserved[1760];
 };
 
 /* kvm attributes for crypto */
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 336e591d94eb..757f76bba9ea 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -334,6 +334,8 @@ static inline void __insn32_query(unsigned int opcode, u8 query[32])
 		: "cc");
 }
 
+#define INSN_SORTL 0xb938
+
 static void kvm_s390_cpu_feat_init(void)
 {
 	int i;
@@ -385,6 +387,9 @@ static void kvm_s390_cpu_feat_init(void)
 		__cpacf_query(CPACF_KDSA, (cpacf_mask_t *)
 			      kvm_s390_available_subfunc.kdsa);
 
+	if (test_facility(150)) /* SORTL */
+		__insn32_query(INSN_SORTL, kvm_s390_available_subfunc.sortl);
+
 	if (MACHINE_HAS_ESOP)
 		allow_cpu_feat(KVM_S390_VM_CPU_FEAT_ESOP);
 	/*
@@ -1351,6 +1356,11 @@ static int kvm_s390_set_processor_subfunc(struct kvm *kvm,
 	VM_EVENT(kvm, 3, "SET: guest KDSA   subfunc 0x%16.16lx.%16.16lx",
 		 ((unsigned long *) &kvm->arch.model.subfuncs.kdsa)[0],
 		 ((unsigned long *) &kvm->arch.model.subfuncs.kdsa)[1]);
+	VM_EVENT(kvm, 3, "SET: guest SORTL  subfunc 0x%16.16lx.%16.16lx.%16.16lx.%16.16lx",
+		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[0],
+		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[1],
+		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[2],
+		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[3]);
 
 	return 0;
 }
@@ -1522,6 +1532,11 @@ static int kvm_s390_get_processor_subfunc(struct kvm *kvm,
 	VM_EVENT(kvm, 3, "GET: guest KDSA   subfunc 0x%16.16lx.%16.16lx",
 		 ((unsigned long *) &kvm->arch.model.subfuncs.kdsa)[0],
 		 ((unsigned long *) &kvm->arch.model.subfuncs.kdsa)[1]);
+	VM_EVENT(kvm, 3, "GET: guest SORTL  subfunc 0x%16.16lx.%16.16lx.%16.16lx.%16.16lx",
+		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[0],
+		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[1],
+		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[2],
+		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[3]);
 
 	return 0;
 }
@@ -1580,6 +1595,11 @@ static int kvm_s390_get_machine_subfunc(struct kvm *kvm,
 	VM_EVENT(kvm, 3, "GET: host  KDSA   subfunc 0x%16.16lx.%16.16lx",
 		 ((unsigned long *) &kvm_s390_available_subfunc.kdsa)[0],
 		 ((unsigned long *) &kvm_s390_available_subfunc.kdsa)[1]);
+	VM_EVENT(kvm, 3, "GET: host  SORTL  subfunc 0x%16.16lx.%16.16lx.%16.16lx.%16.16lx",
+		 ((unsigned long *) &kvm_s390_available_subfunc.sortl)[0],
+		 ((unsigned long *) &kvm_s390_available_subfunc.sortl)[1],
+		 ((unsigned long *) &kvm_s390_available_subfunc.sortl)[2],
+		 ((unsigned long *) &kvm_s390_available_subfunc.sortl)[3]);
 
 	return 0;
 }
diff --git a/arch/s390/tools/gen_facilities.c b/arch/s390/tools/gen_facilities.c
index e952cb3b75b2..1ec6bed785e8 100644
--- a/arch/s390/tools/gen_facilities.c
+++ b/arch/s390/tools/gen_facilities.c
@@ -93,6 +93,7 @@ static struct facility_def facility_defs[] = {
 			131, /* enhanced-SOP 2 and side-effect */
 			139, /* multiple epoch facility */
 			146, /* msa extension 8 */
+			150, /* enhanced sort */
 			155, /* msa extension 9 */
 			-1  /* END */
 		}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 6/7] KVM: s390: add deflate conversion facilty to cpu model
  2019-04-24 11:56 [PATCH v2 0/7] KVM: s390: new guest facilities Christian Borntraeger
                   ` (4 preceding siblings ...)
  2019-04-24 11:56 ` [PATCH v2 5/7] KVM: s390: add enhanced sort facilty to cpu model Christian Borntraeger
@ 2019-04-24 11:56 ` Christian Borntraeger
  2019-04-24 11:59   ` David Hildenbrand
  2019-04-24 11:56 ` [PATCH v2 7/7] KVM: s390: enable MSA9 keywrapping functions depending on " Christian Borntraeger
  6 siblings, 1 reply; 12+ messages in thread
From: Christian Borntraeger @ 2019-04-24 11:56 UTC (permalink / raw)
  To: Christian Borntraeger, Janosch Frank
  Cc: KVM, Cornelia Huck, David Hildenbrand, Paolo Bonzini,
	Radim Krčmář,
	Collin Walling, Jason J . Herne

This enables stfle.151 and adds the subfunctions for DFLTCC

This enables stfle.151 and adds the subfunctions for DFLTCC. Bit 151 is
added to the list of facilities that will be enabled when there is no
cpu model involved as DFLTCC requires no additional handling from
userspace, e.g. for migration.

Please note that a cpu model enabled user space can and will have the
final decision on the facility bits for a guests.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
---
 arch/s390/include/uapi/asm/kvm.h |  3 ++-
 arch/s390/kvm/kvm-s390.c         | 19 +++++++++++++++++++
 arch/s390/tools/gen_facilities.c |  1 +
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/arch/s390/include/uapi/asm/kvm.h b/arch/s390/include/uapi/asm/kvm.h
index eba5bac08348..47104e5b47fd 100644
--- a/arch/s390/include/uapi/asm/kvm.h
+++ b/arch/s390/include/uapi/asm/kvm.h
@@ -154,7 +154,8 @@ struct kvm_s390_vm_cpu_subfunc {
 	__u8 kma[16];		/* with MSA8 */
 	__u8 kdsa[16];		/* with MSA9 */
 	__u8 sortl[32];		/* with STFLE.150 */
-	__u8 reserved[1760];
+	__u8 dfltcc[32];	/* with STFLE.151 */
+	__u8 reserved[1728];
 };
 
 /* kvm attributes for crypto */
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 757f76bba9ea..38ca8324a91a 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -335,6 +335,7 @@ static inline void __insn32_query(unsigned int opcode, u8 query[32])
 }
 
 #define INSN_SORTL 0xb938
+#define INSN_DFLTCC 0xb939
 
 static void kvm_s390_cpu_feat_init(void)
 {
@@ -390,6 +391,9 @@ static void kvm_s390_cpu_feat_init(void)
 	if (test_facility(150)) /* SORTL */
 		__insn32_query(INSN_SORTL, kvm_s390_available_subfunc.sortl);
 
+	if (test_facility(151)) /* DFLTCC */
+		__insn32_query(INSN_DFLTCC, kvm_s390_available_subfunc.dfltcc);
+
 	if (MACHINE_HAS_ESOP)
 		allow_cpu_feat(KVM_S390_VM_CPU_FEAT_ESOP);
 	/*
@@ -1361,6 +1365,11 @@ static int kvm_s390_set_processor_subfunc(struct kvm *kvm,
 		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[1],
 		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[2],
 		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[3]);
+	VM_EVENT(kvm, 3, "SET: guest DFLTCC subfunc 0x%16.16lx.%16.16lx.%16.16lx.%16.16lx",
+		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[0],
+		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[1],
+		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[2],
+		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[3]);
 
 	return 0;
 }
@@ -1537,6 +1546,11 @@ static int kvm_s390_get_processor_subfunc(struct kvm *kvm,
 		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[1],
 		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[2],
 		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[3]);
+	VM_EVENT(kvm, 3, "GET: guest DFLTCC subfunc 0x%16.16lx.%16.16lx.%16.16lx.%16.16lx",
+		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[0],
+		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[1],
+		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[2],
+		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[3]);
 
 	return 0;
 }
@@ -1600,6 +1614,11 @@ static int kvm_s390_get_machine_subfunc(struct kvm *kvm,
 		 ((unsigned long *) &kvm_s390_available_subfunc.sortl)[1],
 		 ((unsigned long *) &kvm_s390_available_subfunc.sortl)[2],
 		 ((unsigned long *) &kvm_s390_available_subfunc.sortl)[3]);
+	VM_EVENT(kvm, 3, "GET: host  DFLTCC subfunc 0x%16.16lx.%16.16lx.%16.16lx.%16.16lx",
+		 ((unsigned long *) &kvm_s390_available_subfunc.dfltcc)[0],
+		 ((unsigned long *) &kvm_s390_available_subfunc.dfltcc)[1],
+		 ((unsigned long *) &kvm_s390_available_subfunc.dfltcc)[2],
+		 ((unsigned long *) &kvm_s390_available_subfunc.dfltcc)[3]);
 
 	return 0;
 }
diff --git a/arch/s390/tools/gen_facilities.c b/arch/s390/tools/gen_facilities.c
index 1ec6bed785e8..cead9e0dcffb 100644
--- a/arch/s390/tools/gen_facilities.c
+++ b/arch/s390/tools/gen_facilities.c
@@ -94,6 +94,7 @@ static struct facility_def facility_defs[] = {
 			139, /* multiple epoch facility */
 			146, /* msa extension 8 */
 			150, /* enhanced sort */
+			151, /* deflate conversion */
 			155, /* msa extension 9 */
 			-1  /* END */
 		}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 7/7] KVM: s390: enable MSA9 keywrapping functions depending on cpu model
  2019-04-24 11:56 [PATCH v2 0/7] KVM: s390: new guest facilities Christian Borntraeger
                   ` (5 preceding siblings ...)
  2019-04-24 11:56 ` [PATCH v2 6/7] KVM: s390: add deflate conversion " Christian Borntraeger
@ 2019-04-24 11:56 ` Christian Borntraeger
  2019-04-24 12:02   ` David Hildenbrand
  6 siblings, 1 reply; 12+ messages in thread
From: Christian Borntraeger @ 2019-04-24 11:56 UTC (permalink / raw)
  To: Christian Borntraeger, Janosch Frank
  Cc: KVM, Cornelia Huck, David Hildenbrand, Paolo Bonzini,
	Radim Krčmář,
	Collin Walling, Jason J . Herne

Instead of adding a new machine option to disable/enable the keywrapping
options of pckmo (like for AES and DEA) we can now use the CPU model to
decide. As ECC is also wrapped with the AES key we need that to be
enabled.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/include/asm/kvm_host.h |  1 +
 arch/s390/kvm/kvm-s390.c         | 30 +++++++++++++++++++++++++++++-
 arch/s390/kvm/vsie.c             |  5 ++++-
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index c47e22bba87f..e224246ff93c 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -278,6 +278,7 @@ struct kvm_s390_sie_block {
 #define ECD_HOSTREGMGMT	0x20000000
 #define ECD_MEF		0x08000000
 #define ECD_ETOKENF	0x02000000
+#define ECD_ECC		0x00200000
 	__u32	ecd;			/* 0x01c8 */
 	__u8	reserved1cc[18];	/* 0x01cc */
 	__u64	pp;			/* 0x01de */
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 38ca8324a91a..403746fcc16e 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -2890,6 +2890,28 @@ void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
 	vcpu->arch.enabled_gmap = vcpu->arch.gmap;
 }
 
+static bool kvm_has_pckmo_subfunc(struct kvm *kvm, unsigned long nr)
+{
+	if (test_bit_inv(nr, (unsigned long *)&kvm->arch.model.subfuncs.pckmo) &&
+	    test_bit_inv(nr, (unsigned long *)&kvm_s390_available_subfunc.pckmo))
+		return true;
+	return false;
+}
+
+static bool kvm_has_pckmo_ecc(struct kvm *kvm)
+{
+	/*
+	 * Any of the ecc pckmo functions as well as the AES wrapping
+	 * value need to be present to enable ECC wrapping
+	 */
+	return kvm_has_pckmo_subfunc(kvm, 32) ||
+	       kvm_has_pckmo_subfunc(kvm, 33) ||
+	       kvm_has_pckmo_subfunc(kvm, 34) ||
+	       kvm_has_pckmo_subfunc(kvm, 40) ||
+	       kvm_has_pckmo_subfunc(kvm, 41);
+
+}
+
 static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu)
 {
 	/*
@@ -2902,13 +2924,19 @@ static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu)
 	vcpu->arch.sie_block->crycbd = vcpu->kvm->arch.crypto.crycbd;
 	vcpu->arch.sie_block->ecb3 &= ~(ECB3_AES | ECB3_DEA);
 	vcpu->arch.sie_block->eca &= ~ECA_APIE;
+	vcpu->arch.sie_block->ecd &= ~ECD_ECC;
 
 	if (vcpu->kvm->arch.crypto.apie)
 		vcpu->arch.sie_block->eca |= ECA_APIE;
 
 	/* Set up protected key support */
-	if (vcpu->kvm->arch.crypto.aes_kw)
+	if (vcpu->kvm->arch.crypto.aes_kw) {
 		vcpu->arch.sie_block->ecb3 |= ECB3_AES;
+		/* ecc is also wrapped with AES key */
+		if (kvm_has_pckmo_ecc(vcpu->kvm))
+			vcpu->arch.sie_block->ecd |= ECD_ECC;
+	}
+
 	if (vcpu->kvm->arch.crypto.dea_kw)
 		vcpu->arch.sie_block->ecb3 |= ECB3_DEA;
 }
diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
index d62fa148558b..c6983d962abf 100644
--- a/arch/s390/kvm/vsie.c
+++ b/arch/s390/kvm/vsie.c
@@ -288,6 +288,7 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 	const u32 crycb_addr = crycbd_o & 0x7ffffff8U;
 	unsigned long *b1, *b2;
 	u8 ecb3_flags;
+	u32 ecd_flags;
 	int apie_h;
 	int key_msk = test_kvm_facility(vcpu->kvm, 76);
 	int fmt_o = crycbd_o & CRYCB_FORMAT_MASK;
@@ -320,7 +321,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 	/* we may only allow it if enabled for guest 2 */
 	ecb3_flags = scb_o->ecb3 & vcpu->arch.sie_block->ecb3 &
 		     (ECB3_AES | ECB3_DEA);
-	if (!ecb3_flags)
+	ecd_flags = scb_o->ecd & vcpu->arch.sie_block->ecd & ECD_ECC;
+	if (!ecb3_flags && !ecd_flags)
 		goto end;
 
 	/* copy only the wrapping keys */
@@ -329,6 +331,7 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 		return set_validity_icpt(scb_s, 0x0035U);
 
 	scb_s->ecb3 |= ecb3_flags;
+	scb_s->ecd |= ecd_flags;
 
 	/* xor both blocks in one run */
 	b1 = (unsigned long *) vsie_page->crycb.dea_wrapping_key_mask;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 6/7] KVM: s390: add deflate conversion facilty to cpu model
  2019-04-24 11:56 ` [PATCH v2 6/7] KVM: s390: add deflate conversion " Christian Borntraeger
@ 2019-04-24 11:59   ` David Hildenbrand
  2019-04-25  6:24     ` Christian Borntraeger
  0 siblings, 1 reply; 12+ messages in thread
From: David Hildenbrand @ 2019-04-24 11:59 UTC (permalink / raw)
  To: Christian Borntraeger, Janosch Frank
  Cc: KVM, Cornelia Huck, Paolo Bonzini, Radim Krčmář,
	Collin Walling, Jason J . Herne

On 24.04.19 13:56, Christian Borntraeger wrote:
> This enables stfle.151 and adds the subfunctions for DFLTCC
> 

You might want to strip the duplicate sentence here.

> This enables stfle.151 and adds the subfunctions for DFLTCC. Bit 151 is
> added to the list of facilities that will be enabled when there is no
> cpu model involved as DFLTCC requires no additional handling from
> userspace, e.g. for migration.
> 
> Please note that a cpu model enabled user space can and will have the
> final decision on the facility bits for a guests.
> 
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Reviewed-by: Collin Walling <walling@linux.ibm.com>
> Reviewed-by: David Hildenbrand <david@redhat.com>
> ---
>  arch/s390/include/uapi/asm/kvm.h |  3 ++-
>  arch/s390/kvm/kvm-s390.c         | 19 +++++++++++++++++++
>  arch/s390/tools/gen_facilities.c |  1 +
>  3 files changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/s390/include/uapi/asm/kvm.h b/arch/s390/include/uapi/asm/kvm.h
> index eba5bac08348..47104e5b47fd 100644
> --- a/arch/s390/include/uapi/asm/kvm.h
> +++ b/arch/s390/include/uapi/asm/kvm.h
> @@ -154,7 +154,8 @@ struct kvm_s390_vm_cpu_subfunc {
>  	__u8 kma[16];		/* with MSA8 */
>  	__u8 kdsa[16];		/* with MSA9 */
>  	__u8 sortl[32];		/* with STFLE.150 */
> -	__u8 reserved[1760];
> +	__u8 dfltcc[32];	/* with STFLE.151 */
> +	__u8 reserved[1728];
>  };
>  
>  /* kvm attributes for crypto */
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index 757f76bba9ea..38ca8324a91a 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -335,6 +335,7 @@ static inline void __insn32_query(unsigned int opcode, u8 query[32])
>  }
>  
>  #define INSN_SORTL 0xb938
> +#define INSN_DFLTCC 0xb939
>  
>  static void kvm_s390_cpu_feat_init(void)
>  {
> @@ -390,6 +391,9 @@ static void kvm_s390_cpu_feat_init(void)
>  	if (test_facility(150)) /* SORTL */
>  		__insn32_query(INSN_SORTL, kvm_s390_available_subfunc.sortl);
>  
> +	if (test_facility(151)) /* DFLTCC */
> +		__insn32_query(INSN_DFLTCC, kvm_s390_available_subfunc.dfltcc);
> +
>  	if (MACHINE_HAS_ESOP)
>  		allow_cpu_feat(KVM_S390_VM_CPU_FEAT_ESOP);
>  	/*
> @@ -1361,6 +1365,11 @@ static int kvm_s390_set_processor_subfunc(struct kvm *kvm,
>  		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[1],
>  		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[2],
>  		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[3]);
> +	VM_EVENT(kvm, 3, "SET: guest DFLTCC subfunc 0x%16.16lx.%16.16lx.%16.16lx.%16.16lx",
> +		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[0],
> +		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[1],
> +		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[2],
> +		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[3]);
>  
>  	return 0;
>  }
> @@ -1537,6 +1546,11 @@ static int kvm_s390_get_processor_subfunc(struct kvm *kvm,
>  		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[1],
>  		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[2],
>  		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[3]);
> +	VM_EVENT(kvm, 3, "GET: guest DFLTCC subfunc 0x%16.16lx.%16.16lx.%16.16lx.%16.16lx",
> +		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[0],
> +		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[1],
> +		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[2],
> +		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[3]);
>  
>  	return 0;
>  }
> @@ -1600,6 +1614,11 @@ static int kvm_s390_get_machine_subfunc(struct kvm *kvm,
>  		 ((unsigned long *) &kvm_s390_available_subfunc.sortl)[1],
>  		 ((unsigned long *) &kvm_s390_available_subfunc.sortl)[2],
>  		 ((unsigned long *) &kvm_s390_available_subfunc.sortl)[3]);
> +	VM_EVENT(kvm, 3, "GET: host  DFLTCC subfunc 0x%16.16lx.%16.16lx.%16.16lx.%16.16lx",
> +		 ((unsigned long *) &kvm_s390_available_subfunc.dfltcc)[0],
> +		 ((unsigned long *) &kvm_s390_available_subfunc.dfltcc)[1],
> +		 ((unsigned long *) &kvm_s390_available_subfunc.dfltcc)[2],
> +		 ((unsigned long *) &kvm_s390_available_subfunc.dfltcc)[3]);
>  
>  	return 0;
>  }
> diff --git a/arch/s390/tools/gen_facilities.c b/arch/s390/tools/gen_facilities.c
> index 1ec6bed785e8..cead9e0dcffb 100644
> --- a/arch/s390/tools/gen_facilities.c
> +++ b/arch/s390/tools/gen_facilities.c
> @@ -94,6 +94,7 @@ static struct facility_def facility_defs[] = {
>  			139, /* multiple epoch facility */
>  			146, /* msa extension 8 */
>  			150, /* enhanced sort */
> +			151, /* deflate conversion */
>  			155, /* msa extension 9 */
>  			-1  /* END */
>  		}
> 


-- 

Thanks,

David / dhildenb

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 7/7] KVM: s390: enable MSA9 keywrapping functions depending on cpu model
  2019-04-24 11:56 ` [PATCH v2 7/7] KVM: s390: enable MSA9 keywrapping functions depending on " Christian Borntraeger
@ 2019-04-24 12:02   ` David Hildenbrand
  2019-04-25  6:27     ` Christian Borntraeger
  0 siblings, 1 reply; 12+ messages in thread
From: David Hildenbrand @ 2019-04-24 12:02 UTC (permalink / raw)
  To: Christian Borntraeger, Janosch Frank
  Cc: KVM, Cornelia Huck, Paolo Bonzini, Radim Krčmář,
	Collin Walling, Jason J . Herne

On 24.04.19 13:56, Christian Borntraeger wrote:
> Instead of adding a new machine option to disable/enable the keywrapping
> options of pckmo (like for AES and DEA) we can now use the CPU model to
> decide. As ECC is also wrapped with the AES key we need that to be
> enabled.
> 
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
>  arch/s390/include/asm/kvm_host.h |  1 +
>  arch/s390/kvm/kvm-s390.c         | 30 +++++++++++++++++++++++++++++-
>  arch/s390/kvm/vsie.c             |  5 ++++-
>  3 files changed, 34 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
> index c47e22bba87f..e224246ff93c 100644
> --- a/arch/s390/include/asm/kvm_host.h
> +++ b/arch/s390/include/asm/kvm_host.h
> @@ -278,6 +278,7 @@ struct kvm_s390_sie_block {
>  #define ECD_HOSTREGMGMT	0x20000000
>  #define ECD_MEF		0x08000000
>  #define ECD_ETOKENF	0x02000000
> +#define ECD_ECC		0x00200000
>  	__u32	ecd;			/* 0x01c8 */
>  	__u8	reserved1cc[18];	/* 0x01cc */
>  	__u64	pp;			/* 0x01de */
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index 38ca8324a91a..403746fcc16e 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -2890,6 +2890,28 @@ void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
>  	vcpu->arch.enabled_gmap = vcpu->arch.gmap;
>  }
>  
> +static bool kvm_has_pckmo_subfunc(struct kvm *kvm, unsigned long nr)
> +{
> +	if (test_bit_inv(nr, (unsigned long *)&kvm->arch.model.subfuncs.pckmo) &&
> +	    test_bit_inv(nr, (unsigned long *)&kvm_s390_available_subfunc.pckmo))
> +		return true;
> +	return false;
> +}
> +
> +static bool kvm_has_pckmo_ecc(struct kvm *kvm)
> +{
> +	/*
> +	 * Any of the ecc pckmo functions as well as the AES wrapping
> +	 * value need to be present to enable ECC wrapping
> +	 */

The comment is slightly confusing as aes is checked by the caller. I
would have expected the check here. Not sure if splitting up handling,
rephrasing the comment or simply leaving it as is is better.

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 

Thanks,

David / dhildenb

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 6/7] KVM: s390: add deflate conversion facilty to cpu model
  2019-04-24 11:59   ` David Hildenbrand
@ 2019-04-25  6:24     ` Christian Borntraeger
  0 siblings, 0 replies; 12+ messages in thread
From: Christian Borntraeger @ 2019-04-25  6:24 UTC (permalink / raw)
  To: David Hildenbrand, Janosch Frank
  Cc: KVM, Cornelia Huck, Paolo Bonzini, Radim Krčmář,
	Collin Walling, Jason J . Herne



On 24.04.19 13:59, David Hildenbrand wrote:
> On 24.04.19 13:56, Christian Borntraeger wrote:
>> This enables stfle.151 and adds the subfunctions for DFLTCC
>>
> 
> You might want to strip the duplicate sentence here.

Fixed and pushed. Thanks for all the feedback. 
> 
>> This enables stfle.151 and adds the subfunctions for DFLTCC. Bit 151 is
>> added to the list of facilities that will be enabled when there is no
>> cpu model involved as DFLTCC requires no additional handling from
>> userspace, e.g. for migration.
>>
>> Please note that a cpu model enabled user space can and will have the
>> final decision on the facility bits for a guests.
>>
>> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
>> Reviewed-by: Collin Walling <walling@linux.ibm.com>
>> Reviewed-by: David Hildenbrand <david@redhat.com>
>> ---
>>  arch/s390/include/uapi/asm/kvm.h |  3 ++-
>>  arch/s390/kvm/kvm-s390.c         | 19 +++++++++++++++++++
>>  arch/s390/tools/gen_facilities.c |  1 +
>>  3 files changed, 22 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/s390/include/uapi/asm/kvm.h b/arch/s390/include/uapi/asm/kvm.h
>> index eba5bac08348..47104e5b47fd 100644
>> --- a/arch/s390/include/uapi/asm/kvm.h
>> +++ b/arch/s390/include/uapi/asm/kvm.h
>> @@ -154,7 +154,8 @@ struct kvm_s390_vm_cpu_subfunc {
>>  	__u8 kma[16];		/* with MSA8 */
>>  	__u8 kdsa[16];		/* with MSA9 */
>>  	__u8 sortl[32];		/* with STFLE.150 */
>> -	__u8 reserved[1760];
>> +	__u8 dfltcc[32];	/* with STFLE.151 */
>> +	__u8 reserved[1728];
>>  };
>>  
>>  /* kvm attributes for crypto */
>> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
>> index 757f76bba9ea..38ca8324a91a 100644
>> --- a/arch/s390/kvm/kvm-s390.c
>> +++ b/arch/s390/kvm/kvm-s390.c
>> @@ -335,6 +335,7 @@ static inline void __insn32_query(unsigned int opcode, u8 query[32])
>>  }
>>  
>>  #define INSN_SORTL 0xb938
>> +#define INSN_DFLTCC 0xb939
>>  
>>  static void kvm_s390_cpu_feat_init(void)
>>  {
>> @@ -390,6 +391,9 @@ static void kvm_s390_cpu_feat_init(void)
>>  	if (test_facility(150)) /* SORTL */
>>  		__insn32_query(INSN_SORTL, kvm_s390_available_subfunc.sortl);
>>  
>> +	if (test_facility(151)) /* DFLTCC */
>> +		__insn32_query(INSN_DFLTCC, kvm_s390_available_subfunc.dfltcc);
>> +
>>  	if (MACHINE_HAS_ESOP)
>>  		allow_cpu_feat(KVM_S390_VM_CPU_FEAT_ESOP);
>>  	/*
>> @@ -1361,6 +1365,11 @@ static int kvm_s390_set_processor_subfunc(struct kvm *kvm,
>>  		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[1],
>>  		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[2],
>>  		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[3]);
>> +	VM_EVENT(kvm, 3, "SET: guest DFLTCC subfunc 0x%16.16lx.%16.16lx.%16.16lx.%16.16lx",
>> +		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[0],
>> +		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[1],
>> +		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[2],
>> +		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[3]);
>>  
>>  	return 0;
>>  }
>> @@ -1537,6 +1546,11 @@ static int kvm_s390_get_processor_subfunc(struct kvm *kvm,
>>  		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[1],
>>  		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[2],
>>  		 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[3]);
>> +	VM_EVENT(kvm, 3, "GET: guest DFLTCC subfunc 0x%16.16lx.%16.16lx.%16.16lx.%16.16lx",
>> +		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[0],
>> +		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[1],
>> +		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[2],
>> +		 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[3]);
>>  
>>  	return 0;
>>  }
>> @@ -1600,6 +1614,11 @@ static int kvm_s390_get_machine_subfunc(struct kvm *kvm,
>>  		 ((unsigned long *) &kvm_s390_available_subfunc.sortl)[1],
>>  		 ((unsigned long *) &kvm_s390_available_subfunc.sortl)[2],
>>  		 ((unsigned long *) &kvm_s390_available_subfunc.sortl)[3]);
>> +	VM_EVENT(kvm, 3, "GET: host  DFLTCC subfunc 0x%16.16lx.%16.16lx.%16.16lx.%16.16lx",
>> +		 ((unsigned long *) &kvm_s390_available_subfunc.dfltcc)[0],
>> +		 ((unsigned long *) &kvm_s390_available_subfunc.dfltcc)[1],
>> +		 ((unsigned long *) &kvm_s390_available_subfunc.dfltcc)[2],
>> +		 ((unsigned long *) &kvm_s390_available_subfunc.dfltcc)[3]);
>>  
>>  	return 0;
>>  }
>> diff --git a/arch/s390/tools/gen_facilities.c b/arch/s390/tools/gen_facilities.c
>> index 1ec6bed785e8..cead9e0dcffb 100644
>> --- a/arch/s390/tools/gen_facilities.c
>> +++ b/arch/s390/tools/gen_facilities.c
>> @@ -94,6 +94,7 @@ static struct facility_def facility_defs[] = {
>>  			139, /* multiple epoch facility */
>>  			146, /* msa extension 8 */
>>  			150, /* enhanced sort */
>> +			151, /* deflate conversion */
>>  			155, /* msa extension 9 */
>>  			-1  /* END */
>>  		}
>>
> 
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 7/7] KVM: s390: enable MSA9 keywrapping functions depending on cpu model
  2019-04-24 12:02   ` David Hildenbrand
@ 2019-04-25  6:27     ` Christian Borntraeger
  0 siblings, 0 replies; 12+ messages in thread
From: Christian Borntraeger @ 2019-04-25  6:27 UTC (permalink / raw)
  To: David Hildenbrand, Janosch Frank
  Cc: KVM, Cornelia Huck, Paolo Bonzini, Radim Krčmář,
	Collin Walling, Jason J . Herne

On 24.04.19 14:02, David Hildenbrand wrote:
>> +	/*
>> +	 * Any of the ecc pckmo functions as well as the AES wrapping
>> +	 * value need to be present to enable ECC wrapping
>> +	 */
> The comment is slightly confusing as aes is checked by the caller. I
> would have expected the check here. Not sure if splitting up handling,
> rephrasing the comment or simply leaving it as is is better.

Agreed. I removed the AES part from this comment.


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-04-25  6:27 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 11:56 [PATCH v2 0/7] KVM: s390: new guest facilities Christian Borntraeger
2019-04-24 11:56 ` [PATCH v2 1/7] KVM: s390: add vector enhancements facility 2 to cpumodel Christian Borntraeger
2019-04-24 11:56 ` [PATCH v2 2/7] KVM: s390: add vector BCD enhancements facility " Christian Borntraeger
2019-04-24 11:56 ` [PATCH v2 3/7] KVM: s390: add MSA9 " Christian Borntraeger
2019-04-24 11:56 ` [PATCH v2 4/7] KVM: s390: provide query function for instructions returning 32 byte Christian Borntraeger
2019-04-24 11:56 ` [PATCH v2 5/7] KVM: s390: add enhanced sort facilty to cpu model Christian Borntraeger
2019-04-24 11:56 ` [PATCH v2 6/7] KVM: s390: add deflate conversion " Christian Borntraeger
2019-04-24 11:59   ` David Hildenbrand
2019-04-25  6:24     ` Christian Borntraeger
2019-04-24 11:56 ` [PATCH v2 7/7] KVM: s390: enable MSA9 keywrapping functions depending on " Christian Borntraeger
2019-04-24 12:02   ` David Hildenbrand
2019-04-25  6:27     ` Christian Borntraeger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.