kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL 0/4] KVM: s390 features and fixes for 4.5 (kvm/next)
@ 2015-12-15 19:23 Christian Borntraeger
  2015-12-15 19:23 ` [GIT PULL 1/4] KVM: s390: use assignment instead of memcpy Christian Borntraeger
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Christian Borntraeger @ 2015-12-15 19:23 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: KVM, linux-s390, Cornelia Huck, Jens Freimann, Alexander Graf,
	Christian Borntraeger

Paolo,

here is the 2nd part of the s390 queue for 4.5

The following changes since commit 460146348518a1c4e810d01baf81847f8c6a1c73:

  Merge tag 'kvm-s390-next-4.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD (2015-12-02 13:50:04 +0100)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git  tags/kvm-s390-next-4.5-2

for you to fetch changes up to 32e6b236d26946eb076d1450bfb8f9978f15d6b9:

  KVM: s390: consider system MHA for guest storage (2015-12-15 17:08:22 +0100)

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

Some small cleanups
- use assignment instead of memcpy
- use %pK for kernel pointers

Changes regarding guest memory size
- Fix an off-by-one error in our guest memory interface (we might
use unnecessarily big page tables, e.g. 3 levels for a 2GB guest
instead of 2 levels)
- We now ask the machine about the max. supported guest address
  and limit accordingly.

----------------------------------------------------------------
Christian Borntraeger (2):
      KVM: s390: use assignment instead of memcpy
      KVM: s390: obey kptr_restrict in traces

Dominik Dingel (1):
      KVM: s390: fix mismatch between user and in-kernel guest limit

Guenther Hutzl (1):
      KVM: s390: consider system MHA for guest storage

 Documentation/virtual/kvm/devices/vm.txt |  3 ++-
 arch/s390/include/asm/kvm_host.h         |  1 +
 arch/s390/include/uapi/asm/kvm.h         |  2 ++
 arch/s390/kvm/kvm-s390.c                 | 44 ++++++++++++++++++++++++--------
 arch/s390/kvm/trace-s390.h               |  6 ++---
 arch/s390/mm/pgtable.c                   |  4 +--
 drivers/s390/char/sclp_early.c           |  8 +++++-
 7 files changed, 50 insertions(+), 18 deletions(-)


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

* [GIT PULL 1/4] KVM: s390: use assignment instead of memcpy
  2015-12-15 19:23 [GIT PULL 0/4] KVM: s390 features and fixes for 4.5 (kvm/next) Christian Borntraeger
@ 2015-12-15 19:23 ` Christian Borntraeger
  2015-12-15 19:23 ` [GIT PULL 2/4] KVM: s390: obey kptr_restrict in traces Christian Borntraeger
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Christian Borntraeger @ 2015-12-15 19:23 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: KVM, linux-s390, Cornelia Huck, Jens Freimann, Alexander Graf,
	Christian Borntraeger

Replace two memcpy with proper assignment.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/kvm/kvm-s390.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 6857262..6dec01d 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -2120,7 +2120,8 @@ static int vcpu_pre_run(struct kvm_vcpu *vcpu)
 	 */
 	kvm_check_async_pf_completion(vcpu);
 
-	memcpy(&vcpu->arch.sie_block->gg14, &vcpu->run->s.regs.gprs[14], 16);
+	vcpu->arch.sie_block->gg14 = vcpu->run->s.regs.gprs[14];
+	vcpu->arch.sie_block->gg15 = vcpu->run->s.regs.gprs[15];
 
 	if (need_resched())
 		schedule();
@@ -2185,7 +2186,8 @@ static int vcpu_post_run(struct kvm_vcpu *vcpu, int exit_reason)
 	if (guestdbg_enabled(vcpu))
 		kvm_s390_restore_guest_per_regs(vcpu);
 
-	memcpy(&vcpu->run->s.regs.gprs[14], &vcpu->arch.sie_block->gg14, 16);
+	vcpu->run->s.regs.gprs[14] = vcpu->arch.sie_block->gg14;
+	vcpu->run->s.regs.gprs[15] = vcpu->arch.sie_block->gg15;
 
 	if (vcpu->arch.sie_block->icptcode > 0) {
 		int rc = kvm_handle_sie_intercept(vcpu);
-- 
2.3.0


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

* [GIT PULL 2/4] KVM: s390: obey kptr_restrict in traces
  2015-12-15 19:23 [GIT PULL 0/4] KVM: s390 features and fixes for 4.5 (kvm/next) Christian Borntraeger
  2015-12-15 19:23 ` [GIT PULL 1/4] KVM: s390: use assignment instead of memcpy Christian Borntraeger
@ 2015-12-15 19:23 ` Christian Borntraeger
  2015-12-15 19:33   ` Kees Cook
  2015-12-15 19:23 ` [GIT PULL 3/4] KVM: s390: fix mismatch between user and in-kernel guest limit Christian Borntraeger
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Christian Borntraeger @ 2015-12-15 19:23 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: KVM, linux-s390, Cornelia Huck, Jens Freimann, Alexander Graf,
	Christian Borntraeger, Kees Cook

The s390dbf and trace events provide a debugfs interface.
If kptr_restrict is active, we should not expose kernel
pointers. We can fence the debugfs output by using %pK
instead of %p.

Cc: Kees Cook <keescook@chromium.org>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/kvm/kvm-s390.c   | 9 +++++----
 arch/s390/kvm/trace-s390.h | 6 +++---
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 6dec01d..c14845c 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -1185,7 +1185,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 	kvm->arch.epoch = 0;
 
 	spin_lock_init(&kvm->arch.start_stop_lock);
-	KVM_EVENT(3, "vm 0x%p created by pid %u", kvm, current->pid);
+	KVM_EVENT(3, "vm 0x%pK created by pid %u", kvm, current->pid);
 
 	return 0;
 out_err:
@@ -1245,7 +1245,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
 		gmap_free(kvm->arch.gmap);
 	kvm_s390_destroy_adapters(kvm);
 	kvm_s390_clear_float_irqs(kvm);
-	KVM_EVENT(3, "vm 0x%p destroyed", kvm);
+	KVM_EVENT(3, "vm 0x%pK destroyed", kvm);
 }
 
 /* Section: vcpu related */
@@ -1349,7 +1349,8 @@ static int sca_switch_to_extended(struct kvm *kvm)
 
 	free_page((unsigned long)old_sca);
 
-	VM_EVENT(kvm, 2, "Switched to ESCA (%p -> %p)", old_sca, kvm->arch.sca);
+	VM_EVENT(kvm, 2, "Switched to ESCA (0x%pK -> 0x%pK)",
+		 old_sca, kvm->arch.sca);
 	return 0;
 }
 
@@ -1624,7 +1625,7 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
 	rc = kvm_vcpu_init(vcpu, kvm, id);
 	if (rc)
 		goto out_free_sie_block;
-	VM_EVENT(kvm, 3, "create cpu %d at %p, sie block at %p", id, vcpu,
+	VM_EVENT(kvm, 3, "create cpu %d at 0x%pK, sie block at 0x%pK", id, vcpu,
 		 vcpu->arch.sie_block);
 	trace_kvm_s390_create_vcpu(id, vcpu, vcpu->arch.sie_block);
 
diff --git a/arch/s390/kvm/trace-s390.h b/arch/s390/kvm/trace-s390.h
index cc1d6c6..396485b 100644
--- a/arch/s390/kvm/trace-s390.h
+++ b/arch/s390/kvm/trace-s390.h
@@ -55,8 +55,8 @@ TRACE_EVENT(kvm_s390_create_vcpu,
 		    __entry->sie_block = sie_block;
 		    ),
 
-	    TP_printk("create cpu %d at %p, sie block at %p", __entry->id,
-		      __entry->vcpu, __entry->sie_block)
+	    TP_printk("create cpu %d at 0x%pK, sie block at 0x%pK",
+		      __entry->id, __entry->vcpu, __entry->sie_block)
 	);
 
 TRACE_EVENT(kvm_s390_destroy_vcpu,
@@ -254,7 +254,7 @@ TRACE_EVENT(kvm_s390_enable_css,
 		    __entry->kvm = kvm;
 		    ),
 
-	    TP_printk("enabling channel I/O support (kvm @ %p)\n",
+	    TP_printk("enabling channel I/O support (kvm @ %pK)\n",
 		      __entry->kvm)
 	);
 
-- 
2.3.0


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

* [GIT PULL 3/4] KVM: s390: fix mismatch between user and in-kernel guest limit
  2015-12-15 19:23 [GIT PULL 0/4] KVM: s390 features and fixes for 4.5 (kvm/next) Christian Borntraeger
  2015-12-15 19:23 ` [GIT PULL 1/4] KVM: s390: use assignment instead of memcpy Christian Borntraeger
  2015-12-15 19:23 ` [GIT PULL 2/4] KVM: s390: obey kptr_restrict in traces Christian Borntraeger
@ 2015-12-15 19:23 ` Christian Borntraeger
  2015-12-15 19:23 ` [GIT PULL 4/4] KVM: s390: consider system MHA for guest storage Christian Borntraeger
  2015-12-16 17:49 ` [GIT PULL 0/4] KVM: s390 features and fixes for 4.5 (kvm/next) Paolo Bonzini
  4 siblings, 0 replies; 7+ messages in thread
From: Christian Borntraeger @ 2015-12-15 19:23 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: KVM, linux-s390, Cornelia Huck, Jens Freimann, Alexander Graf,
	Dominik Dingel, Christian Borntraeger

From: Dominik Dingel <dingel@linux.vnet.ibm.com>

While the userspace interface requests the maximum size the gmap code
expects to get a maximum address.

This error resulted in bigger page tables than necessary for some guest
sizes, e.g. a 2GB guest used 3 levels instead of 2.

At the same time we introduce KVM_S390_NO_MEM_LIMIT, which allows in a
bright future that a guest spans the complete 64 bit address space.

We also switch to TASK_MAX_SIZE for the initial memory size, this is a
cosmetic change as the previous size also resulted in a 4 level pagetable
creation.

Reported-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 Documentation/virtual/kvm/devices/vm.txt |  3 ++-
 arch/s390/include/asm/kvm_host.h         |  1 +
 arch/s390/include/uapi/asm/kvm.h         |  2 ++
 arch/s390/kvm/kvm-s390.c                 | 25 ++++++++++++++++++++-----
 arch/s390/mm/pgtable.c                   |  4 ++--
 5 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/Documentation/virtual/kvm/devices/vm.txt b/Documentation/virtual/kvm/devices/vm.txt
index 2d09d1e..f083a16 100644
--- a/Documentation/virtual/kvm/devices/vm.txt
+++ b/Documentation/virtual/kvm/devices/vm.txt
@@ -37,7 +37,8 @@ Returns: -EFAULT if the given address is not accessible
 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.
+the number of page table levels. In the case that there is no limit we will set
+the limit to KVM_S390_NO_MEM_LIMIT (U64_MAX).
 
 2. GROUP: KVM_S390_VM_CPU_MODEL
 Architectures: s390
diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index 12e9291..c831441 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -627,6 +627,7 @@ struct kvm_arch{
 	struct kvm_s390_float_interrupt float_int;
 	struct kvm_device *flic;
 	struct gmap *gmap;
+	unsigned long mem_limit;
 	int css_support;
 	int use_irqchip;
 	int use_cmma;
diff --git a/arch/s390/include/uapi/asm/kvm.h b/arch/s390/include/uapi/asm/kvm.h
index ef1a5fc..d2aea31 100644
--- a/arch/s390/include/uapi/asm/kvm.h
+++ b/arch/s390/include/uapi/asm/kvm.h
@@ -66,6 +66,8 @@ struct kvm_s390_io_adapter_req {
 #define KVM_S390_VM_MEM_CLR_CMMA	1
 #define KVM_S390_VM_MEM_LIMIT_SIZE	2
 
+#define KVM_S390_NO_MEM_LIMIT		U64_MAX
+
 /* kvm attributes for KVM_S390_VM_TOD */
 #define KVM_S390_VM_TOD_LOW		0
 #define KVM_S390_VM_TOD_HIGH		1
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index c14845c..8aa5e55 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -378,8 +378,8 @@ static int kvm_s390_get_mem_control(struct kvm *kvm, struct kvm_device_attr *att
 	case KVM_S390_VM_MEM_LIMIT_SIZE:
 		ret = 0;
 		VM_EVENT(kvm, 3, "QUERY: max guest memory: %lu bytes",
-			 kvm->arch.gmap->asce_end);
-		if (put_user(kvm->arch.gmap->asce_end, (u64 __user *)attr->addr))
+			 kvm->arch.mem_limit);
+		if (put_user(kvm->arch.mem_limit, (u64 __user *)attr->addr))
 			ret = -EFAULT;
 		break;
 	default:
@@ -431,9 +431,17 @@ static int kvm_s390_set_mem_control(struct kvm *kvm, struct kvm_device_attr *att
 		if (get_user(new_limit, (u64 __user *)attr->addr))
 			return -EFAULT;
 
-		if (new_limit > kvm->arch.gmap->asce_end)
+		if (kvm->arch.mem_limit != KVM_S390_NO_MEM_LIMIT &&
+		    new_limit > kvm->arch.mem_limit)
 			return -E2BIG;
 
+		if (!new_limit)
+			return -EINVAL;
+
+		/* gmap_alloc takes last usable address */
+		if (new_limit != KVM_S390_NO_MEM_LIMIT)
+			new_limit -= 1;
+
 		ret = -EBUSY;
 		mutex_lock(&kvm->lock);
 		if (atomic_read(&kvm->online_vcpus) == 0) {
@@ -450,7 +458,9 @@ static int kvm_s390_set_mem_control(struct kvm *kvm, struct kvm_device_attr *att
 			}
 		}
 		mutex_unlock(&kvm->lock);
-		VM_EVENT(kvm, 3, "SET: max guest memory: %lu bytes", new_limit);
+		VM_EVENT(kvm, 3, "SET: max guest address: %lu", new_limit);
+		VM_EVENT(kvm, 3, "New guest asce: 0x%pK",
+			 (void *) kvm->arch.gmap->asce);
 		break;
 	}
 	default:
@@ -1172,8 +1182,10 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 
 	if (type & KVM_VM_S390_UCONTROL) {
 		kvm->arch.gmap = NULL;
+		kvm->arch.mem_limit = KVM_S390_NO_MEM_LIMIT;
 	} else {
-		kvm->arch.gmap = gmap_alloc(current->mm, (1UL << 44) - 1);
+		kvm->arch.mem_limit = TASK_MAX_SIZE;
+		kvm->arch.gmap = gmap_alloc(current->mm, kvm->arch.mem_limit - 1);
 		if (!kvm->arch.gmap)
 			goto out_err;
 		kvm->arch.gmap->private = kvm;
@@ -2829,6 +2841,9 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
 	if (mem->memory_size & 0xffffful)
 		return -EINVAL;
 
+	if (mem->guest_phys_addr + mem->memory_size > kvm->arch.mem_limit)
+		return -EINVAL;
+
 	return 0;
 }
 
diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c
index 54ef3bc..63b0398 100644
--- a/arch/s390/mm/pgtable.c
+++ b/arch/s390/mm/pgtable.c
@@ -133,7 +133,7 @@ void crst_table_downgrade(struct mm_struct *mm, unsigned long limit)
 /**
  * gmap_alloc - allocate a guest address space
  * @mm: pointer to the parent mm_struct
- * @limit: maximum size of the gmap address space
+ * @limit: maximum address of the gmap address space
  *
  * Returns a guest address space structure.
  */
@@ -402,7 +402,7 @@ int gmap_map_segment(struct gmap *gmap, unsigned long from,
 	if ((from | to | len) & (PMD_SIZE - 1))
 		return -EINVAL;
 	if (len == 0 || from + len < from || to + len < to ||
-	    from + len > TASK_MAX_SIZE || to + len > gmap->asce_end)
+	    from + len - 1 > TASK_MAX_SIZE || to + len - 1 > gmap->asce_end)
 		return -EINVAL;
 
 	flush = 0;
-- 
2.3.0


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

* [GIT PULL 4/4] KVM: s390: consider system MHA for guest storage
  2015-12-15 19:23 [GIT PULL 0/4] KVM: s390 features and fixes for 4.5 (kvm/next) Christian Borntraeger
                   ` (2 preceding siblings ...)
  2015-12-15 19:23 ` [GIT PULL 3/4] KVM: s390: fix mismatch between user and in-kernel guest limit Christian Borntraeger
@ 2015-12-15 19:23 ` Christian Borntraeger
  2015-12-16 17:49 ` [GIT PULL 0/4] KVM: s390 features and fixes for 4.5 (kvm/next) Paolo Bonzini
  4 siblings, 0 replies; 7+ messages in thread
From: Christian Borntraeger @ 2015-12-15 19:23 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: KVM, linux-s390, Cornelia Huck, Jens Freimann, Alexander Graf,
	Guenther Hutzl, Dominik Dingel, Christian Borntraeger

From: Guenther Hutzl <hutzl@linux.vnet.ibm.com>

Verify that the guest maximum storage address is below the MHA (maximum
host address) value allowed on the host.

Acked-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Guenther Hutzl <hutzl@linux.vnet.ibm.com>
Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
[adopt to match recent limit,size changes]

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/kvm/kvm-s390.c       | 6 +++++-
 drivers/s390/char/sclp_early.c | 8 +++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 8aa5e55..940e9ff 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -1184,7 +1184,11 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 		kvm->arch.gmap = NULL;
 		kvm->arch.mem_limit = KVM_S390_NO_MEM_LIMIT;
 	} else {
-		kvm->arch.mem_limit = TASK_MAX_SIZE;
+		if (sclp.hamax == U64_MAX)
+			kvm->arch.mem_limit = TASK_MAX_SIZE;
+		else
+			kvm->arch.mem_limit = min_t(unsigned long, TASK_MAX_SIZE,
+						    sclp.hamax + 1);
 		kvm->arch.gmap = gmap_alloc(current->mm, kvm->arch.mem_limit - 1);
 		if (!kvm->arch.gmap)
 			goto out_err;
diff --git a/drivers/s390/char/sclp_early.c b/drivers/s390/char/sclp_early.c
index e0a1f4e..6804354 100644
--- a/drivers/s390/char/sclp_early.c
+++ b/drivers/s390/char/sclp_early.c
@@ -40,7 +40,8 @@ struct read_info_sccb {
 	u8	fac85;			/* 85 */
 	u8	_pad_86[91 - 86];	/* 86-90 */
 	u8	flags;			/* 91 */
-	u8	_pad_92[100 - 92];	/* 92-99 */
+	u8	_pad_92[99 - 92];	/* 92-98 */
+	u8	hamaxpow;		/* 99 */
 	u32	rnsize2;		/* 100-103 */
 	u64	rnmax2;			/* 104-111 */
 	u8	_pad_112[116 - 112];	/* 112-115 */
@@ -120,6 +121,11 @@ static void __init sclp_facilities_detect(struct read_info_sccb *sccb)
 	sclp.rzm <<= 20;
 	sclp.ibc = sccb->ibc;
 
+	if (sccb->hamaxpow && sccb->hamaxpow < 64)
+		sclp.hamax = (1UL << sccb->hamaxpow) - 1;
+	else
+		sclp.hamax = U64_MAX;
+
 	if (!sccb->hcpua) {
 		if (MACHINE_IS_VM)
 			sclp.max_cores = 64;
-- 
2.3.0


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

* Re: [GIT PULL 2/4] KVM: s390: obey kptr_restrict in traces
  2015-12-15 19:23 ` [GIT PULL 2/4] KVM: s390: obey kptr_restrict in traces Christian Borntraeger
@ 2015-12-15 19:33   ` Kees Cook
  0 siblings, 0 replies; 7+ messages in thread
From: Kees Cook @ 2015-12-15 19:33 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: Paolo Bonzini, KVM, linux-s390, Cornelia Huck, Jens Freimann,
	Alexander Graf

On Tue, Dec 15, 2015 at 11:23 AM, Christian Borntraeger
<borntraeger@de.ibm.com> wrote:
> The s390dbf and trace events provide a debugfs interface.
> If kptr_restrict is active, we should not expose kernel
> pointers. We can fence the debugfs output by using %pK
> instead of %p.
>
> Cc: Kees Cook <keescook@chromium.org>
> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>

Nice catch, thanks!

Acked-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  arch/s390/kvm/kvm-s390.c   | 9 +++++----
>  arch/s390/kvm/trace-s390.h | 6 +++---
>  2 files changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index 6dec01d..c14845c 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -1185,7 +1185,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
>         kvm->arch.epoch = 0;
>
>         spin_lock_init(&kvm->arch.start_stop_lock);
> -       KVM_EVENT(3, "vm 0x%p created by pid %u", kvm, current->pid);
> +       KVM_EVENT(3, "vm 0x%pK created by pid %u", kvm, current->pid);
>
>         return 0;
>  out_err:
> @@ -1245,7 +1245,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
>                 gmap_free(kvm->arch.gmap);
>         kvm_s390_destroy_adapters(kvm);
>         kvm_s390_clear_float_irqs(kvm);
> -       KVM_EVENT(3, "vm 0x%p destroyed", kvm);
> +       KVM_EVENT(3, "vm 0x%pK destroyed", kvm);
>  }
>
>  /* Section: vcpu related */
> @@ -1349,7 +1349,8 @@ static int sca_switch_to_extended(struct kvm *kvm)
>
>         free_page((unsigned long)old_sca);
>
> -       VM_EVENT(kvm, 2, "Switched to ESCA (%p -> %p)", old_sca, kvm->arch.sca);
> +       VM_EVENT(kvm, 2, "Switched to ESCA (0x%pK -> 0x%pK)",
> +                old_sca, kvm->arch.sca);
>         return 0;
>  }
>
> @@ -1624,7 +1625,7 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
>         rc = kvm_vcpu_init(vcpu, kvm, id);
>         if (rc)
>                 goto out_free_sie_block;
> -       VM_EVENT(kvm, 3, "create cpu %d at %p, sie block at %p", id, vcpu,
> +       VM_EVENT(kvm, 3, "create cpu %d at 0x%pK, sie block at 0x%pK", id, vcpu,
>                  vcpu->arch.sie_block);
>         trace_kvm_s390_create_vcpu(id, vcpu, vcpu->arch.sie_block);
>
> diff --git a/arch/s390/kvm/trace-s390.h b/arch/s390/kvm/trace-s390.h
> index cc1d6c6..396485b 100644
> --- a/arch/s390/kvm/trace-s390.h
> +++ b/arch/s390/kvm/trace-s390.h
> @@ -55,8 +55,8 @@ TRACE_EVENT(kvm_s390_create_vcpu,
>                     __entry->sie_block = sie_block;
>                     ),
>
> -           TP_printk("create cpu %d at %p, sie block at %p", __entry->id,
> -                     __entry->vcpu, __entry->sie_block)
> +           TP_printk("create cpu %d at 0x%pK, sie block at 0x%pK",
> +                     __entry->id, __entry->vcpu, __entry->sie_block)
>         );
>
>  TRACE_EVENT(kvm_s390_destroy_vcpu,
> @@ -254,7 +254,7 @@ TRACE_EVENT(kvm_s390_enable_css,
>                     __entry->kvm = kvm;
>                     ),
>
> -           TP_printk("enabling channel I/O support (kvm @ %p)\n",
> +           TP_printk("enabling channel I/O support (kvm @ %pK)\n",
>                       __entry->kvm)
>         );
>
> --
> 2.3.0
>



-- 
Kees Cook
Chrome OS & Brillo Security

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

* Re: [GIT PULL 0/4] KVM: s390 features and fixes for 4.5 (kvm/next)
  2015-12-15 19:23 [GIT PULL 0/4] KVM: s390 features and fixes for 4.5 (kvm/next) Christian Borntraeger
                   ` (3 preceding siblings ...)
  2015-12-15 19:23 ` [GIT PULL 4/4] KVM: s390: consider system MHA for guest storage Christian Borntraeger
@ 2015-12-16 17:49 ` Paolo Bonzini
  4 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2015-12-16 17:49 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: KVM, linux-s390, Cornelia Huck, Jens Freimann, Alexander Graf



On 15/12/2015 20:23, Christian Borntraeger wrote:
> Paolo,
> 
> here is the 2nd part of the s390 queue for 4.5
> 
> The following changes since commit 460146348518a1c4e810d01baf81847f8c6a1c73:
> 
>   Merge tag 'kvm-s390-next-4.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD (2015-12-02 13:50:04 +0100)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git  tags/kvm-s390-next-4.5-2
> 
> for you to fetch changes up to 32e6b236d26946eb076d1450bfb8f9978f15d6b9:
> 
>   KVM: s390: consider system MHA for guest storage (2015-12-15 17:08:22 +0100)
> 
> ----------------------------------------------------------------
> KVM: s390 features and fixes for 4.5 (kvm/next)
> 
> Some small cleanups
> - use assignment instead of memcpy
> - use %pK for kernel pointers
> 
> Changes regarding guest memory size
> - Fix an off-by-one error in our guest memory interface (we might
> use unnecessarily big page tables, e.g. 3 levels for a 2GB guest
> instead of 2 levels)
> - We now ask the machine about the max. supported guest address
>   and limit accordingly.
> 
> ----------------------------------------------------------------
> Christian Borntraeger (2):
>       KVM: s390: use assignment instead of memcpy
>       KVM: s390: obey kptr_restrict in traces
> 
> Dominik Dingel (1):
>       KVM: s390: fix mismatch between user and in-kernel guest limit
> 
> Guenther Hutzl (1):
>       KVM: s390: consider system MHA for guest storage
> 
>  Documentation/virtual/kvm/devices/vm.txt |  3 ++-
>  arch/s390/include/asm/kvm_host.h         |  1 +
>  arch/s390/include/uapi/asm/kvm.h         |  2 ++
>  arch/s390/kvm/kvm-s390.c                 | 44 ++++++++++++++++++++++++--------
>  arch/s390/kvm/trace-s390.h               |  6 ++---
>  arch/s390/mm/pgtable.c                   |  4 +--
>  drivers/s390/char/sclp_early.c           |  8 +++++-
>  7 files changed, 50 insertions(+), 18 deletions(-)
> 

Pulled (but not pushed yet), thanks.

Paolo

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

end of thread, other threads:[~2015-12-16 17:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-15 19:23 [GIT PULL 0/4] KVM: s390 features and fixes for 4.5 (kvm/next) Christian Borntraeger
2015-12-15 19:23 ` [GIT PULL 1/4] KVM: s390: use assignment instead of memcpy Christian Borntraeger
2015-12-15 19:23 ` [GIT PULL 2/4] KVM: s390: obey kptr_restrict in traces Christian Borntraeger
2015-12-15 19:33   ` Kees Cook
2015-12-15 19:23 ` [GIT PULL 3/4] KVM: s390: fix mismatch between user and in-kernel guest limit Christian Borntraeger
2015-12-15 19:23 ` [GIT PULL 4/4] KVM: s390: consider system MHA for guest storage Christian Borntraeger
2015-12-16 17:49 ` [GIT PULL 0/4] KVM: s390 features and fixes for 4.5 (kvm/next) Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).