From: Cornelia Huck <cohuck@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-s390x@nongnu.org, Thomas Huth <thuth@redhat.com>,
Eric Farman <farman@linux.ibm.com>,
Matthew Rosato <mjrosato@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Cornelia Huck <cohuck@redhat.com>
Subject: [PULL v2 01/11] target/s390x/kvm: Simplify the async pfault handling code
Date: Thu, 30 Apr 2026 18:02:57 +0200 [thread overview]
Message-ID: <20260430160307.634093-2-cohuck@redhat.com> (raw)
In-Reply-To: <20260430160307.634093-1-cohuck@redhat.com>
From: Thomas Huth <thuth@redhat.com>
Since commit 126e7f78036 ("kvm: require KVM_CAP_IOEVENTFD and
KVM_CAP_IOEVENTFD_ANY_LENGTH") we require at least kernel v4.4 to
be able to use KVM. KVM_CAP_ASYNC_PF is available in the kernel
since v3.15 and KVM_SYNC_PFAULT is available since kernel v3.18,
so we can assume now that they are available in all supported
kernels. Thus simplify the code a little bit by removing the
checks for these features.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Message-ID: <20260317134531.460141-1-thuth@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
---
target/s390x/kvm/kvm.c | 52 +++++++++---------------------------------
1 file changed, 11 insertions(+), 41 deletions(-)
diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c
index 54d28e37d4dd..133e8c12fd4d 100644
--- a/target/s390x/kvm/kvm.c
+++ b/target/s390x/kvm/kvm.c
@@ -140,7 +140,6 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
KVM_CAP_LAST_INFO
};
-static int cap_async_pf;
static int cap_mem_op;
static int cap_mem_op_extension;
static int cap_s390_irq;
@@ -333,6 +332,7 @@ int kvm_arch_get_default_type(MachineState *ms)
int kvm_arch_init(MachineState *ms, KVMState *s)
{
int required_caps[] = {
+ KVM_CAP_ASYNC_PF,
KVM_CAP_DEVICE_CTRL,
KVM_CAP_SYNC_REGS,
};
@@ -340,7 +340,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
for (int i = 0; i < ARRAY_SIZE(required_caps); i++) {
if (!kvm_check_extension(s, required_caps[i])) {
error_report("KVM is missing capability #%d - "
- "please use kernel 3.15 or newer", required_caps[i]);
+ "please use kernel 4.4 or newer", required_caps[i]);
return -1;
}
}
@@ -354,7 +354,6 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
return -1;
}
- cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF);
cap_mem_op = kvm_check_extension(s, KVM_CAP_S390_MEM_OP);
cap_mem_op_extension = kvm_check_extension(s, KVM_CAP_S390_MEM_OP_EXTENSION);
mem_op_storage_key_support = cap_mem_op_extension > 0;
@@ -466,7 +465,8 @@ static int can_sync_regs(CPUState *cs, int regs)
}
#define KVM_SYNC_REQUIRED_REGS (KVM_SYNC_GPRS | KVM_SYNC_ACRS | \
- KVM_SYNC_CRS | KVM_SYNC_PREFIX)
+ KVM_SYNC_CRS | KVM_SYNC_PREFIX | \
+ KVM_SYNC_PFAULT)
int kvm_arch_put_registers(CPUState *cs, KvmPutState level, Error **errp)
{
@@ -550,25 +550,10 @@ int kvm_arch_put_registers(CPUState *cs, KvmPutState level, Error **errp)
}
/* pfault parameters */
- if (can_sync_regs(cs, KVM_SYNC_PFAULT)) {
- cs->kvm_run->s.regs.pft = env->pfault_token;
- cs->kvm_run->s.regs.pfs = env->pfault_select;
- cs->kvm_run->s.regs.pfc = env->pfault_compare;
- cs->kvm_run->kvm_dirty_regs |= KVM_SYNC_PFAULT;
- } else if (cap_async_pf) {
- r = kvm_set_one_reg(cs, KVM_REG_S390_PFTOKEN, &env->pfault_token);
- if (r < 0) {
- return r;
- }
- r = kvm_set_one_reg(cs, KVM_REG_S390_PFCOMPARE, &env->pfault_compare);
- if (r < 0) {
- return r;
- }
- r = kvm_set_one_reg(cs, KVM_REG_S390_PFSELECT, &env->pfault_select);
- if (r < 0) {
- return r;
- }
- }
+ cs->kvm_run->s.regs.pft = env->pfault_token;
+ cs->kvm_run->s.regs.pfs = env->pfault_select;
+ cs->kvm_run->s.regs.pfc = env->pfault_compare;
+ cs->kvm_run->kvm_dirty_regs |= KVM_SYNC_PFAULT;
if (can_sync_regs(cs, KVM_SYNC_GSCB)) {
memcpy(cs->kvm_run->s.regs.gscb, env->gscb, 32);
@@ -673,24 +658,9 @@ int kvm_arch_get_registers(CPUState *cs, Error **errp)
}
/* pfault parameters */
- if (can_sync_regs(cs, KVM_SYNC_PFAULT)) {
- env->pfault_token = cs->kvm_run->s.regs.pft;
- env->pfault_select = cs->kvm_run->s.regs.pfs;
- env->pfault_compare = cs->kvm_run->s.regs.pfc;
- } else if (cap_async_pf) {
- r = kvm_get_one_reg(cs, KVM_REG_S390_PFTOKEN, &env->pfault_token);
- if (r < 0) {
- return r;
- }
- r = kvm_get_one_reg(cs, KVM_REG_S390_PFCOMPARE, &env->pfault_compare);
- if (r < 0) {
- return r;
- }
- r = kvm_get_one_reg(cs, KVM_REG_S390_PFSELECT, &env->pfault_select);
- if (r < 0) {
- return r;
- }
- }
+ env->pfault_token = cs->kvm_run->s.regs.pft;
+ env->pfault_select = cs->kvm_run->s.regs.pfs;
+ env->pfault_compare = cs->kvm_run->s.regs.pfc;
if (can_sync_regs(cs, KVM_SYNC_DIAG318)) {
env->diag318_info = cs->kvm_run->s.regs.diag318;
--
2.53.0
next prev parent reply other threads:[~2026-04-30 16:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 16:02 [PULL v2 00/11] First batch of s390x updates for 11.1 Cornelia Huck
2026-04-30 16:02 ` Cornelia Huck [this message]
2026-04-30 16:02 ` [PULL v2 02/11] target/s390x: Replace legacy ld/st_phys -> address_space_ld/st (cpu) Cornelia Huck
2026-04-30 16:02 ` [PULL v2 03/11] target/s390x: Replace legacy ld/st_phys -> address_space_ld/st (mmu) Cornelia Huck
2026-04-30 16:03 ` [PULL v2 04/11] target/s390x: Replace legacy ld/st_phys -> address_space_ld/st (tcg) Cornelia Huck
2026-04-30 16:03 ` [PULL v2 05/11] target/s390x: Replace legacy ld/st_phys -> address_space_ld/st (kvm) Cornelia Huck
2026-04-30 16:03 ` [PULL v2 06/11] configs/targets: Restrict the legacy ldst_phys() API on s390x target Cornelia Huck
2026-04-30 16:03 ` [PULL v2 07/11] tests/functional/s390x: Add test for booting from a disk with 4k sectors Cornelia Huck
2026-04-30 16:03 ` [PULL v2 08/11] target/s390x: Prefer MO_128 definition over magic value Cornelia Huck
2026-04-30 16:03 ` [PULL v2 09/11] MAINTAINERS: Update s390 trees Cornelia Huck
2026-04-30 16:03 ` [PULL v2 10/11] hw/s390x/ccw: Disable legacy virtio-pci by default (v11.1+) Cornelia Huck
2026-04-30 16:03 ` [PULL v2 11/11] tests/functional/s390x: Update expected virtio-pci IDs Cornelia Huck
2026-05-02 10:49 ` [PULL v2 00/11] First batch of s390x updates for 11.1 Stefan Hajnoczi
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=20260430160307.634093-2-cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=farman@linux.ibm.com \
--cc=mjrosato@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=thuth@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.