All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Cornelia Huck <cohuck@redhat.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>, KVM <kvm@vger.kernel.org>,
	"Christian Borntraeger" <borntraeger@de.ibm.com>,
	linux-s390 <linux-s390@vger.kernel.org>,
	"Claudio Imbrenda" <imbrenda@linux.vnet.ibm.com>
Subject: [PATCH 11/11] KVM: s390: expose no-DAT to guest and migration support
Date: Mon, 28 Aug 2017 10:07:31 +0200	[thread overview]
Message-ID: <1503907651-65296-5-git-send-email-borntraeger@de.ibm.com> (raw)
In-Reply-To: <1503907651-65296-1-git-send-email-borntraeger@de.ibm.com>

From: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>

The STFLE bit 147 indicates whether the ESSA no-DAT operation code is
valid, the bit is not normally provided to the host; the host is
instead provided with an SCLP bit that indicates whether guests can
support the feature.

This patch:
* enables the STFLE bit in the guest if the corresponding SCLP bit is
  present in the host.
* adds support for migrating the no-DAT bit in the PGSTEs
* fixes the software interpretation of the ESSA instruction that is
  used when migrating, both for the new operation code and for the old
  "set stable", as per specifications.

Signed-off-by: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/include/asm/page-states.h | 2 +-
 arch/s390/kvm/kvm-s390.c            | 8 ++++++--
 arch/s390/kvm/priv.c                | 6 +++++-
 arch/s390/mm/pgtable.c              | 6 +++++-
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/arch/s390/include/asm/page-states.h b/arch/s390/include/asm/page-states.h
index ca21b28..22b0f49 100644
--- a/arch/s390/include/asm/page-states.h
+++ b/arch/s390/include/asm/page-states.h
@@ -15,6 +15,6 @@
 #define ESSA_SET_STABLE_IF_RESIDENT	6
 #define ESSA_SET_STABLE_NODAT		7
 
-#define ESSA_MAX	ESSA_SET_STABLE_IF_RESIDENT
+#define ESSA_MAX	ESSA_SET_STABLE_NODAT
 
 #endif
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index e65b763..84c069a 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -1574,7 +1574,7 @@ static int kvm_s390_get_cmma_bits(struct kvm *kvm,
 		if (r < 0)
 			pgstev = 0;
 		/* save the value */
-		res[i++] = (pgstev >> 24) & 0x3;
+		res[i++] = (pgstev >> 24) & 0x43;
 		/*
 		 * if the next bit is too far away, stop.
 		 * if we reached the previous "next", find the next one
@@ -1652,7 +1652,7 @@ static int kvm_s390_set_cmma_bits(struct kvm *kvm,
 
 		pgstev = bits[i];
 		pgstev = pgstev << 24;
-		mask &= _PGSTE_GPS_USAGE_MASK;
+		mask &= _PGSTE_GPS_USAGE_MASK | _PGSTE_GPS_NODAT;
 		set_pgste_bits(kvm->mm, hva, mask, pgstev);
 	}
 	srcu_read_unlock(&kvm->srcu, srcu_idx);
@@ -1929,6 +1929,10 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 
 	set_kvm_facility(kvm->arch.model.fac_mask, 74);
 	set_kvm_facility(kvm->arch.model.fac_list, 74);
+	if (MACHINE_HAS_TLB_GUEST) {
+		set_kvm_facility(kvm->arch.model.fac_mask, 147);
+		set_kvm_facility(kvm->arch.model.fac_list, 147);
+	}
 
 	kvm->arch.model.cpuid = kvm_s390_get_initial_cpuid();
 	kvm->arch.model.ibc = sclp.ibc & 0x0fff;
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index 8a1dac7..91dc4a8 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -988,6 +988,8 @@ static inline int do_essa(struct kvm_vcpu *vcpu, const int orc)
 		if (pgstev & _PGSTE_GPS_ZERO)
 			res |= 1;
 	}
+	if (pgstev & _PGSTE_GPS_NODAT)
+		res |= 0x20;
 	vcpu->run->s.regs.gprs[r1] = res;
 	/*
 	 * It is possible that all the normal 511 slots were full, in which case
@@ -1027,7 +1029,9 @@ static int handle_essa(struct kvm_vcpu *vcpu)
 		return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
 	/* Check for invalid operation request code */
 	orc = (vcpu->arch.sie_block->ipb & 0xf0000000) >> 28;
-	if (orc > ESSA_MAX)
+	/* ORCs 0-6 are always valid */
+	if (orc > (test_kvm_facility(vcpu->kvm, 147) ? ESSA_SET_STABLE_NODAT
+						: ESSA_SET_STABLE_IF_RESIDENT))
 		return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
 
 	if (likely(!vcpu->kvm->arch.migration_state)) {
diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c
index 8d018c7..459716d 100644
--- a/arch/s390/mm/pgtable.c
+++ b/arch/s390/mm/pgtable.c
@@ -919,7 +919,7 @@ int pgste_perform_essa(struct mm_struct *mm, unsigned long hva, int orc,
 	case ESSA_GET_STATE:
 		break;
 	case ESSA_SET_STABLE:
-		pgstev &= ~_PGSTE_GPS_USAGE_MASK;
+		pgstev &= ~(_PGSTE_GPS_USAGE_MASK | _PGSTE_GPS_NODAT);
 		pgstev |= _PGSTE_GPS_USAGE_STABLE;
 		break;
 	case ESSA_SET_UNUSED:
@@ -965,6 +965,10 @@ int pgste_perform_essa(struct mm_struct *mm, unsigned long hva, int orc,
 			pgstev |= _PGSTE_GPS_USAGE_STABLE;
 		}
 		break;
+	case ESSA_SET_STABLE_NODAT:
+		pgstev &= ~_PGSTE_GPS_USAGE_MASK;
+		pgstev |= _PGSTE_GPS_USAGE_STABLE | _PGSTE_GPS_NODAT;
+		break;
 	default:
 		/* we should never get here! */
 		break;
-- 
2.7.4

  parent reply	other threads:[~2017-08-28  8:07 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28  8:07 [PATCH 00/11] KVM: s390: Fixes and features for 4.14 Christian Borntraeger
2017-08-28  8:07 ` [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode Christian Borntraeger
2017-08-28  9:07   ` Cornelia Huck
2017-08-28  9:11     ` Christian Borntraeger
2017-08-28  9:14       ` Christian Borntraeger
2017-08-28 11:33       ` Cornelia Huck
2017-08-28 11:35   ` Cornelia Huck
2017-08-28 14:06   ` David Hildenbrand
2017-08-28 14:24     ` Christian Borntraeger
2017-08-28 14:38       ` David Hildenbrand
2017-08-28 14:42         ` Christian Borntraeger
2017-08-28 19:27   ` David Hildenbrand
2017-08-28 19:35     ` Christian Borntraeger
2017-08-28 19:38       ` Christian Borntraeger
2017-08-28 19:42         ` David Hildenbrand
2017-08-29  7:18           ` Christian Borntraeger
2017-08-29 12:08             ` David Hildenbrand
2017-08-29 12:21               ` Christian Borntraeger
2017-08-29 12:24                 ` David Hildenbrand
2017-08-29 14:31                 ` [PATCH] KVM: s390: we are always in czam mode David Hildenbrand
2017-08-29 14:40                   ` Cornelia Huck
2017-08-29 14:48                   ` Christian Borntraeger
2017-08-28 19:41       ` [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode David Hildenbrand
2017-08-28  8:07 ` [PATCH 06/11] KVM: s390: Multiple Epoch Facility support Christian Borntraeger
2017-08-28 11:21   ` Cornelia Huck
2017-08-28 11:36     ` Christian Borntraeger
2017-08-28 11:45       ` Cornelia Huck
2017-08-29 12:24   ` David Hildenbrand
2017-08-29 12:46     ` Christian Borntraeger
2017-08-29 12:54       ` David Hildenbrand
2017-08-29 12:59       ` Christian Borntraeger
2017-08-28  8:07 ` [PATCH 10/11] KVM: s390: sthyi: remove invalid guest write access Christian Borntraeger
2017-08-28 11:39   ` Cornelia Huck
2017-08-28  8:07 ` Christian Borntraeger [this message]
2017-08-28 12:12   ` [PATCH 11/11] KVM: s390: expose no-DAT to guest and migration support Cornelia Huck
2017-08-28 12:17 ` [PATCH 00/11] KVM: s390: Fixes and features for 4.14 Cornelia Huck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1503907651-65296-5-git-send-email-borntraeger@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=imbrenda@linux.vnet.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.