From: Eric Farman <farman@linux.ibm.com>
To: Christian Borntraeger <borntraeger@linux.ibm.com>,
Hendrik Brueckner <brueckner@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
David Hildenbrand <david@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
kvm@vger.kernel.org, linux-s390@vger.kernel.org,
Eric Farman <farman@linux.ibm.com>
Subject: [PATCH v1 3/4] KVM: s390: vsie: Accommodate ESA prefix pages
Date: Wed, 1 Apr 2026 04:09:14 +0200 [thread overview]
Message-ID: <20260401020915.1339228-4-farman@linux.ibm.com> (raw)
In-Reply-To: <20260401020915.1339228-1-farman@linux.ibm.com>
The prefix page address occupies a different number
of bits for z/Architecture versus ESA mode. Adjust the
definition to cover both, and permit an ESA mode
address within the nested codepath.
Signed-off-by: Eric Farman <farman@linux.ibm.com>
---
arch/s390/include/asm/kvm_host_types.h | 3 +--
arch/s390/kvm/kvm-s390.h | 5 ++++-
arch/s390/kvm/vsie.c | 7 ++++++-
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/arch/s390/include/asm/kvm_host_types.h b/arch/s390/include/asm/kvm_host_types.h
index 1394d3fb648f..3f50942bdfe6 100644
--- a/arch/s390/include/asm/kvm_host_types.h
+++ b/arch/s390/include/asm/kvm_host_types.h
@@ -137,8 +137,7 @@ struct mcck_volatile_info {
struct kvm_s390_sie_block {
atomic_t cpuflags; /* 0x0000 */
__u32 : 1; /* 0x0004 */
- __u32 prefix : 18;
- __u32 : 1;
+ __u32 prefix : 19;
__u32 ibc : 12;
__u8 reserved08[4]; /* 0x0008 */
#define PROG_IN_SIE (1<<0)
diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
index bf1d7798c1af..c0ad8effe3d0 100644
--- a/arch/s390/kvm/kvm-s390.h
+++ b/arch/s390/kvm/kvm-s390.h
@@ -122,7 +122,9 @@ static inline int kvm_is_ucontrol(struct kvm *kvm)
#endif
}
-#define GUEST_PREFIX_SHIFT 13
+#define GUEST_PREFIX_SHIFT 12
+#define GUEST_PREFIX_ZARCH 0x7fffe
+#define GUEST_PREFIX_ESA 0x7ffff
static inline u32 kvm_s390_get_prefix(struct kvm_vcpu *vcpu)
{
return vcpu->arch.sie_block->prefix << GUEST_PREFIX_SHIFT;
@@ -133,6 +135,7 @@ static inline void kvm_s390_set_prefix(struct kvm_vcpu *vcpu, u32 prefix)
VCPU_EVENT(vcpu, 3, "set prefix of cpu %03u to 0x%x", vcpu->vcpu_id,
prefix);
vcpu->arch.sie_block->prefix = prefix >> GUEST_PREFIX_SHIFT;
+ vcpu->arch.sie_block->prefix &= GUEST_PREFIX_ZARCH;
kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu);
kvm_make_request(KVM_REQ_REFRESH_GUEST_PREFIX, vcpu);
}
diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
index 584fc7803632..e45378a01731 100644
--- a/arch/s390/kvm/vsie.c
+++ b/arch/s390/kvm/vsie.c
@@ -479,7 +479,7 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
/* READ_ONCE does not work on bitfields - use a temporary variable */
const uint32_t __new_prefix = scb_o->prefix;
- const uint32_t new_prefix = READ_ONCE(__new_prefix);
+ uint32_t new_prefix = READ_ONCE(__new_prefix);
const bool wants_tx = READ_ONCE(scb_o->ecb) & ECB_TE;
bool had_tx = scb_s->ecb & ECB_TE;
unsigned long new_mso = 0;
@@ -527,6 +527,11 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
scb_s->icpua = scb_o->icpua;
+ if (!(atomic_read(&scb_s->cpuflags) & CPUSTAT_ZARCH))
+ new_prefix &= GUEST_PREFIX_ESA;
+ else
+ new_prefix &= GUEST_PREFIX_ZARCH;
+
if (!(atomic_read(&scb_s->cpuflags) & CPUSTAT_SM))
new_mso = READ_ONCE(scb_o->mso) & 0xfffffffffff00000UL;
/* if the hva of the prefix changes, we have to remap the prefix */
--
2.51.0
next prev parent reply other threads:[~2026-04-01 2:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-01 2:09 [PATCH v1 0/4] KVM: s390: Permit ESA mode guests in VSIE Eric Farman
2026-04-01 2:09 ` [PATCH v1 1/4] KVM: s390: vsie: Allow non-zarch guests Eric Farman
2026-04-01 11:25 ` Janosch Frank
2026-04-01 13:31 ` Eric Farman
2026-04-01 2:09 ` [PATCH v1 2/4] KVM: s390: vsie: Disable some bits when in ESA mode Eric Farman
2026-04-01 12:58 ` Christian Borntraeger
2026-04-01 13:46 ` Eric Farman
2026-04-01 14:50 ` Janosch Frank
2026-04-01 2:09 ` Eric Farman [this message]
2026-04-01 11:45 ` [PATCH v1 3/4] KVM: s390: vsie: Accommodate ESA prefix pages Janosch Frank
2026-04-01 13:44 ` Eric Farman
2026-04-01 2:09 ` [PATCH v1 4/4] KVM: s390: Add KVM capability for ESA mode guests Eric Farman
2026-04-01 11:52 ` Janosch Frank
2026-04-01 6:40 ` [PATCH v1 0/4] KVM: s390: Permit ESA mode guests in VSIE Christoph Hellwig
2026-04-01 10:00 ` Janosch Frank
2026-04-06 5:37 ` Christoph Hellwig
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=20260401020915.1339228-4-farman@linux.ibm.com \
--to=farman@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=brueckner@linux.ibm.com \
--cc=corbet@lwn.net \
--cc=david@kernel.org \
--cc=frankja@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=skhan@linuxfoundation.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox