| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/08/01 19:40 | flow | patch-triage |
2mArgs:null Results: {
"EnableConfigs": [
"KVM"
],
"FocusSymbols": [
"kvm_arch_vm_ioctl",
"kvm_arch_vcpu_ioctl",
"kvm_arch_vcpu_unlocked_ioctl",
"kvm_arch_commit_memory_region",
"kvm_s390_pv_create_cpu",
"kvm_s390_pv_destroy_cpu",
"kvm_s390_handle_b2",
"kvm_s390_handle_b9",
"kvm_s390_inject_vcpu",
"kvm_s390_faultin_gfn"
],
"Reasoning": "The patch modifies core KVM functionality for the s390 architecture, including handling of memory regions, page faults, virtual CPU creation/destruction, interrupt injection, and specific instruction handlers (RRBE, ESSA). It also adds checks for userspace-controlled VMs (KVM_S390_UCONTROL). These changes are reachable from userspace via standard KVM ioctls and guest execution, and should be fuzzed to ensure they do not introduce regressions, memory leaks, or locking issues.",
"WorthFuzzing": true
} |
| 1/1 | 2026/08/01 19:40 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 853c643249bc530bb01245402735e655699eee96\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Sat Aug 1 19:40:34 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h\nindex eaa34c5bd3c11..edf75b6ad20ce 100644\n--- a/arch/s390/include/asm/kvm_host.h\n+++ b/arch/s390/include/asm/kvm_host.h\n@@ -440,6 +440,7 @@ struct kvm_vcpu_arch {\n \tbool skey_enabled;\n \t/* Indicator if the access registers have been loaded from guest */\n \tbool acrs_loaded;\n+\tbool initialized;\n \tstruct kvm_s390_pv_vcpu pv;\n \tunion diag318_info diag318_info;\n \tstruct kvm_s390_mmu_cache *mc;\ndiff --git a/arch/s390/kvm/dat.c b/arch/s390/kvm/dat.c\nindex ed4259d176295..3f2d6e8902d76 100644\n--- a/arch/s390/kvm/dat.c\n+++ b/arch/s390/kvm/dat.c\n@@ -755,13 +755,15 @@ int dat_cond_set_storage_key(struct kvm_s390_mmu_cache *mmc, union asce asce, gf\n \treturn rc;\n }\n \n-int dat_reset_reference_bit(union asce asce, gfn_t gfn)\n+int dat_reset_reference_bit(union asce asce, gfn_t gfn, union skey *skey)\n {\n \tunion pgste pgste, old;\n \tunion crste *crstep;\n \tunion pte *ptep;\n \tint rc;\n \n+\tskey-\u003eskey = 0;\n+\n \trc = dat_entry_walk(NULL, gfn, asce, DAT_WALK_ANY, TABLE_TYPE_PAGE_TABLE, \u0026crstep, \u0026ptep);\n \tif (rc)\n \t\treturn rc;\n@@ -771,21 +773,23 @@ int dat_reset_reference_bit(union asce asce, gfn_t gfn)\n \n \t\tif (!crste.h.fc || !crste.s.fc1.pr)\n \t\t\treturn 0;\n-\t\treturn page_reset_referenced(large_crste_to_phys(*crstep, gfn));\n+\t\tskey-\u003eskey = page_reset_referenced(large_crste_to_phys(*crstep, gfn)) \u003c\u003c 1;\n+\t\treturn 0;\n \t}\n \told = pgste_get_lock(ptep);\n \tpgste = old;\n \n \tif (!ptep-\u003eh.i) {\n-\t\trc = page_reset_referenced(pte_origin(*ptep));\n-\t\tpgste.hr = rc \u003e\u003e 1;\n+\t\tskey-\u003eskey = page_reset_referenced(pte_origin(*ptep)) \u003c\u003c 1;\n+\t\tpgste.hr = skey-\u003er;\n \t}\n-\trc |= (pgste.gr \u003c\u003c 1) | pgste.gc;\n+\tskey-\u003er |= pgste.gr;\n+\tskey-\u003ec |= pgste.gc;\n \tpgste.gr = 0;\n \n \tdat_update_ptep_sd(old, pgste, ptep);\n \tpgste_set_unlock(ptep, pgste);\n-\treturn rc;\n+\treturn 0;\n }\n \n static long dat_reset_skeys_pte(union pte *ptep, gfn_t gfn, gfn_t next, struct dat_walk *walk)\n@@ -846,6 +850,7 @@ static long _dat_slot_pte(union pte *ptep, gfn_t gfn, gfn_t next, struct dat_wal\n \tstruct slot_priv *p = walk-\u003epriv;\n \tunion crste dummy = { .val = p-\u003etoken };\n \tunion pte new_pte, pte = READ_ONCE(*ptep);\n+\tunion pgste pgste;\n \n \tnew_pte = _PTE_TOK(dummy.tok.type, dummy.tok.par);\n \n@@ -853,7 +858,11 @@ static long _dat_slot_pte(union pte *ptep, gfn_t gfn, gfn_t next, struct dat_wal\n \tif (pte.val == new_pte.val)\n \t\treturn 0;\n \n-\tdat_ptep_xchg(ptep, new_pte, gfn, walk-\u003easce, false);\n+\tpgste = pgste_get_lock(ptep);\n+\tpgste = __dat_ptep_xchg(ptep, pgste, new_pte, gfn, walk-\u003easce, false);\n+\tpgste.cmma_d = 0;\n+\tpgste_set_unlock(ptep, pgste);\n+\n \treturn 0;\n }\n \ndiff --git a/arch/s390/kvm/dat.h b/arch/s390/kvm/dat.h\nindex fad605305e05c..141ee7b9f0191 100644\n--- a/arch/s390/kvm/dat.h\n+++ b/arch/s390/kvm/dat.h\n@@ -537,7 +537,7 @@ int dat_set_storage_key(struct kvm_s390_mmu_cache *mc, union asce asce, gfn_t gf\n \t\t\tunion skey skey, bool nq);\n int dat_cond_set_storage_key(struct kvm_s390_mmu_cache *mmc, union asce asce, gfn_t gfn,\n \t\t\t union skey skey, union skey *oldkey, bool nq, bool mr, bool mc);\n-int dat_reset_reference_bit(union asce asce, gfn_t gfn);\n+int dat_reset_reference_bit(union asce asce, gfn_t gfn, union skey *skey);\n long dat_reset_skeys(union asce asce, gfn_t start);\n \n unsigned long dat_get_ptval(struct page_table *table, struct ptval_param param);\ndiff --git a/arch/s390/kvm/faultin.c b/arch/s390/kvm/faultin.c\nindex fee80047bd94f..3cc45f7f5b2d7 100644\n--- a/arch/s390/kvm/faultin.c\n+++ b/arch/s390/kvm/faultin.c\n@@ -91,9 +91,9 @@ int kvm_s390_faultin_gfn(struct kvm_vcpu *vcpu, struct kvm *kvm, struct guest_fa\n \t\t/* Access outside memory, addressing exception. */\n \t\tif (is_noslot_pfn(f-\u003epfn))\n \t\t\treturn PGM_ADDRESSING;\n-\t\t/* Signal pending: try again. */\n-\t\tif (f-\u003epfn == KVM_PFN_ERR_SIGPENDING)\n-\t\t\treturn -EAGAIN;\n+\t\t/* Fatal signal pending: bail out. */\n+\t\tif (is_sigpending_pfn(f-\u003epfn))\n+\t\t\treturn -EINTR;\n \t\t/* Check if it's read-only memory; don't try to actually handle that case. */\n \t\tif (f-\u003epfn == KVM_PFN_ERR_RO_FAULT)\n \t\t\treturn -EOPNOTSUPP;\ndiff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c\nindex 9e3e6b0d72ad6..9db68e3ac178f 100644\n--- a/arch/s390/kvm/interrupt.c\n+++ b/arch/s390/kvm/interrupt.c\n@@ -45,13 +45,16 @@ static struct kvm_s390_gib *gib;\n static int sca_ext_call_pending(struct kvm_vcpu *vcpu, int *src_id)\n {\n \tstruct esca_block *sca = vcpu-\u003ekvm-\u003earch.sca;\n-\tunion esca_sigp_ctrl sigp_ctrl = sca-\u003ecpu[vcpu-\u003evcpu_id].sigp_ctrl;\n+\tunion esca_sigp_ctrl sigp_ctrl;\n \n \tif (!kvm_s390_test_cpuflags(vcpu, CPUSTAT_ECALL_PEND))\n \t\treturn 0;\n+\tif (kvm_is_ucontrol(vcpu-\u003ekvm))\n+\t\treturn 0;\n \n \tBUG_ON(!kvm_s390_use_sca_entries());\n \n+\tsigp_ctrl = sca-\u003ecpu[vcpu-\u003evcpu_id].sigp_ctrl;\n \tif (src_id)\n \t\t*src_id = sigp_ctrl.scn;\n \n@@ -60,13 +63,16 @@ static int sca_ext_call_pending(struct kvm_vcpu *vcpu, int *src_id)\n \n static int sca_inject_ext_call(struct kvm_vcpu *vcpu, int src_id)\n {\n-\tstruct esca_block *sca = vcpu-\u003ekvm-\u003earch.sca;\n-\tunion esca_sigp_ctrl *sigp_ctrl = \u0026sca-\u003ecpu[vcpu-\u003evcpu_id].sigp_ctrl;\n \tunion esca_sigp_ctrl old_val, new_val = {.scn = src_id, .c = 1};\n+\tstruct esca_block *sca = vcpu-\u003ekvm-\u003earch.sca;\n+\tunion esca_sigp_ctrl *sigp_ctrl;\n \tint expect, rc;\n \n \tBUG_ON(!kvm_s390_use_sca_entries());\n+\tif (KVM_BUG_ON(kvm_is_ucontrol(vcpu-\u003ekvm), vcpu-\u003ekvm))\n+\t\treturn -EINVAL;\n \n+\tsigp_ctrl = \u0026sca-\u003ecpu[vcpu-\u003evcpu_id].sigp_ctrl;\n \told_val = READ_ONCE(*sigp_ctrl);\n \told_val.c = 0;\n \n@@ -84,10 +90,13 @@ static int sca_inject_ext_call(struct kvm_vcpu *vcpu, int src_id)\n static void sca_clear_ext_call(struct kvm_vcpu *vcpu)\n {\n \tstruct esca_block *sca = vcpu-\u003ekvm-\u003earch.sca;\n-\tunion esca_sigp_ctrl *sigp_ctrl = \u0026sca-\u003ecpu[vcpu-\u003evcpu_id].sigp_ctrl;\n+\tunion esca_sigp_ctrl *sigp_ctrl;\n \n-\tif (!kvm_s390_use_sca_entries())\n+\tif (!kvm_s390_use_sca_entries() || !vcpu-\u003earch.initialized || kvm_is_ucontrol(vcpu-\u003ekvm))\n \t\treturn;\n+\n+\t/* Initialize after the above check, to prevent going out of bounds */\n+\tsigp_ctrl = \u0026sca-\u003ecpu[vcpu-\u003evcpu_id].sigp_ctrl;\n \tkvm_s390_clear_cpuflags(vcpu, CPUSTAT_ECALL_PEND);\n \n \tWRITE_ONCE(sigp_ctrl-\u003evalue, 0);\ndiff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c\nindex 150b5dd2170e2..fd8badb0d571c 100644\n--- a/arch/s390/kvm/kvm-s390.c\n+++ b/arch/s390/kvm/kvm-s390.c\n@@ -571,7 +571,7 @@ static int kvm_s390_keyop(struct kvm_s390_mmu_cache *mc, struct kvm *kvm, int op\n \tswitch (op) {\n \tcase KVM_S390_KEYOP_SSKE:\n \t\tr = dat_cond_set_storage_key(mc, asce, gfn, skey, \u0026skey, 0, 0, 0);\n-\t\tif (r \u003e= 0)\n+\t\tif (r == 0 || r == 1)\n \t\t\treturn skey.skey;\n \t\tbreak;\n \tcase KVM_S390_KEYOP_ISKE:\n@@ -580,14 +580,14 @@ static int kvm_s390_keyop(struct kvm_s390_mmu_cache *mc, struct kvm *kvm, int op\n \t\t\treturn skey.skey;\n \t\tbreak;\n \tcase KVM_S390_KEYOP_RRBE:\n-\t\tr = dat_reset_reference_bit(asce, gfn);\n-\t\tif (r \u003e 0)\n-\t\t\treturn r \u003c\u003c 1;\n+\t\tr = dat_reset_reference_bit(asce, gfn, \u0026skey);\n+\t\tif (!r)\n+\t\t\treturn skey.skey;\n \t\tbreak;\n \tdefault:\n \t\treturn -EINVAL;\n \t}\n-\treturn r;\n+\treturn r \u003e 0 ? -EFAULT : r;\n }\n \n /* Section: device related */\n@@ -1219,8 +1219,8 @@ static void kvm_s390_sync_request_broadcast(struct kvm *kvm, int req)\n \n /*\n * Must be called with kvm-\u003esrcu held to avoid races on memslots, and with\n- * kvm-\u003eslots_lock to avoid races with ourselves, kvm_s390_vm_stop_migration(),\n- * and kvm_s390_get_cmma_bits().\n+ * kvm-\u003eslots_arch_lock to avoid races with ourselves,\n+ * kvm_s390_vm_stop_migration(), and kvm_s390_get_cmma_bits().\n */\n static int kvm_s390_vm_start_migration(struct kvm *kvm)\n {\n@@ -1265,7 +1265,7 @@ static int kvm_s390_vm_start_migration(struct kvm *kvm)\n }\n \n /*\n- * Must be called with kvm-\u003eslots_lock to avoid races with ourselves,\n+ * Must be called with kvm-\u003eslots_arch_lock to avoid races with ourselves,\n * kvm_s390_vm_start_migration() and kvm_s390_get_cmma_bits().\n */\n static int kvm_s390_vm_stop_migration(struct kvm *kvm)\n@@ -1300,7 +1300,9 @@ static int kvm_s390_vm_set_migration(struct kvm *kvm,\n {\n \tint res = -ENXIO;\n \n-\tmutex_lock(\u0026kvm-\u003eslots_lock);\n+\tguard(srcu)(\u0026kvm-\u003esrcu);\n+\tguard(mutex)(\u0026kvm-\u003eslots_arch_lock);\n+\n \tswitch (attr-\u003eattr) {\n \tcase KVM_S390_VM_MIGRATION_START:\n \t\tres = kvm_s390_vm_start_migration(kvm);\n@@ -1311,7 +1313,6 @@ static int kvm_s390_vm_set_migration(struct kvm *kvm,\n \tdefault:\n \t\tbreak;\n \t}\n-\tmutex_unlock(\u0026kvm-\u003eslots_lock);\n \n \treturn res;\n }\n@@ -2214,7 +2215,7 @@ static int kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)\n \t}\n \n \tkvfree(keys);\n-\treturn r;\n+\treturn r \u003c= 0 ? r : -EFAULT;\n }\n \n static int kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)\n@@ -2276,7 +2277,7 @@ static int kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)\n \tkvm_s390_free_mmu_cache(mc);\n out:\n \tkvfree(keys);\n-\treturn r;\n+\treturn r \u003c= 0 ? r : -EFAULT;\n }\n \n /*\n@@ -2386,7 +2387,7 @@ static int kvm_s390_set_cmma_bits(struct kvm *kvm,\n \n \tset_bit(GMAP_FLAG_USES_CMM, \u0026kvm-\u003earch.gmap-\u003eflags);\n \n-\treturn r;\n+\treturn r \u003c= 0 ? r : -EFAULT;\n }\n \n /**\n@@ -2934,6 +2935,9 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)\n \tcase KVM_S390_INTERRUPT: {\n \t\tstruct kvm_s390_interrupt s390int;\n \n+\t\tr = -EINVAL;\n+\t\tif (kvm_is_ucontrol(kvm))\n+\t\t\tbreak;\n \t\tr = -EFAULT;\n \t\tif (copy_from_user(\u0026s390int, argp, sizeof(s390int)))\n \t\t\tbreak;\n@@ -2998,9 +3002,8 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)\n \t\tr = -EFAULT;\n \t\tif (copy_from_user(\u0026args, argp, sizeof(args)))\n \t\t\tbreak;\n-\t\tmutex_lock(\u0026kvm-\u003eslots_lock);\n-\t\tr = kvm_s390_get_cmma_bits(kvm, \u0026args);\n-\t\tmutex_unlock(\u0026kvm-\u003eslots_lock);\n+\t\tscoped_guard(mutex, \u0026kvm-\u003eslots_arch_lock)\n+\t\t\tr = kvm_s390_get_cmma_bits(kvm, \u0026args);\n \t\tif (!r) {\n \t\t\tr = copy_to_user(argp, \u0026args, sizeof(args));\n \t\t\tif (r)\n@@ -3014,9 +3017,9 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)\n \t\tr = -EFAULT;\n \t\tif (copy_from_user(\u0026args, argp, sizeof(args)))\n \t\t\tbreak;\n-\t\tmutex_lock(\u0026kvm-\u003eslots_lock);\n+\t\tmutex_lock(\u0026kvm-\u003eslots_arch_lock);\n \t\tr = kvm_s390_set_cmma_bits(kvm, \u0026args);\n-\t\tmutex_unlock(\u0026kvm-\u003eslots_lock);\n+\t\tmutex_unlock(\u0026kvm-\u003eslots_arch_lock);\n \t\tbreak;\n \t}\n \tcase KVM_S390_PV_COMMAND: {\n@@ -3247,7 +3250,8 @@ static void kvm_s390_crypto_init(struct kvm *kvm)\n \n static void sca_dispose(struct kvm *kvm)\n {\n-\tfree_pages_exact(kvm-\u003earch.sca, sizeof(*kvm-\u003earch.sca));\n+\tif (kvm-\u003earch.sca)\n+\t\tfree_pages_exact(kvm-\u003earch.sca, sizeof(*kvm-\u003earch.sca));\n \tkvm-\u003earch.sca = NULL;\n }\n \n@@ -3461,7 +3465,7 @@ static void sca_del_vcpu(struct kvm_vcpu *vcpu)\n {\n \tstruct esca_block *sca = vcpu-\u003ekvm-\u003earch.sca;\n \n-\tif (!kvm_s390_use_sca_entries())\n+\tif (!kvm_s390_use_sca_entries() || !vcpu-\u003earch.initialized)\n \t\treturn;\n \n \tclear_bit_inv(vcpu-\u003evcpu_id, (unsigned long *)sca-\u003emcn);\n@@ -3481,8 +3485,8 @@ static void sca_add_vcpu(struct kvm_vcpu *vcpu)\n \tif (!kvm_s390_use_sca_entries())\n \t\treturn;\n \n+\tWRITE_ONCE(sca-\u003ecpu[vcpu-\u003evcpu_id].sda, virt_to_phys(vcpu-\u003earch.sie_block));\n \tset_bit_inv(vcpu-\u003evcpu_id, (unsigned long *)sca-\u003emcn);\n-\tsca-\u003ecpu[vcpu-\u003evcpu_id].sda = virt_to_phys(vcpu-\u003earch.sie_block);\n }\n \n static int sca_can_add_vcpu(struct kvm *kvm, unsigned int id)\n@@ -3613,6 +3617,9 @@ void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)\n \tif (test_kvm_facility(vcpu-\u003ekvm, 74) || vcpu-\u003ekvm-\u003earch.user_instr0 ||\n \t vcpu-\u003ekvm-\u003earch.user_operexec)\n \t\tvcpu-\u003earch.sie_block-\u003eictl |= ICTL_OPEREXC;\n+\n+\t/* Pairs with smp_load_acquire() in kvm_arch_vcpu_ioctl_run() and kvm_arch_vcpu_ioctl() */\n+\tsmp_store_release(\u0026vcpu-\u003earch.initialized, true);\n }\n \n static bool kvm_has_pckmo_subfunc(struct kvm *kvm, unsigned long nr)\n@@ -3674,7 +3681,8 @@ static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu)\n \n void kvm_s390_vcpu_unsetup_cmma(struct kvm_vcpu *vcpu)\n {\n-\tfree_page((unsigned long)phys_to_virt(vcpu-\u003earch.sie_block-\u003ecbrlo));\n+\tif (vcpu-\u003earch.sie_block-\u003ecbrlo)\n+\t\tfree_page((unsigned long)phys_to_virt(vcpu-\u003earch.sie_block-\u003ecbrlo));\n \tvcpu-\u003earch.sie_block-\u003ecbrlo = 0;\n }\n \n@@ -3792,21 +3800,21 @@ int kvm_arch_vcpu_precreate(struct kvm *kvm, unsigned int id)\n \treturn 0;\n }\n \n+DEFINE_FREE(sie_page, struct sie_page *, if (_T) free_page((unsigned long)(_T)))\n+\n int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)\n {\n-\tstruct sie_page *sie_page;\n+\tstruct kvm_s390_mmu_cache *mc __free(kvm_s390_mmu_cache) = NULL;\n+\tstruct sie_page *sie_page __free(sie_page) = NULL;\n \tint rc;\n \n \tBUILD_BUG_ON(sizeof(struct sie_page) != 4096);\n-\tvcpu-\u003earch.mc = kvm_s390_new_mmu_cache();\n-\tif (!vcpu-\u003earch.mc)\n+\tmc = kvm_s390_new_mmu_cache();\n+\tif (!mc)\n \t\treturn -ENOMEM;\n \tsie_page = (struct sie_page *) get_zeroed_page(GFP_KERNEL_ACCOUNT);\n-\tif (!sie_page) {\n-\t\tkvm_s390_free_mmu_cache(vcpu-\u003earch.mc);\n-\t\tvcpu-\u003earch.mc = NULL;\n+\tif (!sie_page)\n \t\treturn -ENOMEM;\n-\t}\n \n \tvcpu-\u003earch.sie_block = \u0026sie_page-\u003esie_block;\n \tvcpu-\u003earch.sie_block-\u003eitdba = virt_to_phys(\u0026sie_page-\u003eitdb);\n@@ -3848,10 +3856,9 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)\n \t\tvcpu-\u003erun-\u003ekvm_valid_regs |= KVM_SYNC_FPRS;\n \n \tif (kvm_is_ucontrol(vcpu-\u003ekvm)) {\n-\t\trc = -ENOMEM;\n \t\tvcpu-\u003earch.gmap = gmap_new_child(vcpu-\u003ekvm-\u003earch.gmap, -1UL);\n \t\tif (!vcpu-\u003earch.gmap)\n-\t\t\tgoto out_free_sie_block;\n+\t\t\treturn -ENOMEM;\n \t}\n \n \tVM_EVENT(vcpu-\u003ekvm, 3, \"create cpu %d at 0x%p, sie block at 0x%p\",\n@@ -3859,20 +3866,19 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)\n \ttrace_kvm_s390_create_vcpu(vcpu-\u003evcpu_id, vcpu, vcpu-\u003earch.sie_block);\n \n \trc = kvm_s390_vcpu_setup(vcpu);\n-\tif (rc)\n-\t\tgoto out_ucontrol_uninit;\n+\tif (rc) {\n+\t\tif (kvm_is_ucontrol(vcpu-\u003ekvm)) {\n+\t\t\tscoped_guard(spinlock, \u0026vcpu-\u003ekvm-\u003earch.gmap-\u003echildren_lock)\n+\t\t\t\tgmap_remove_child(vcpu-\u003earch.gmap);\n+\t\t\tvcpu-\u003earch.gmap = gmap_put(vcpu-\u003earch.gmap);\n+\t\t}\n+\t\treturn rc;\n+\t}\n \n+\tvcpu-\u003earch.mc = no_free_ptr(mc);\n+\tsie_page = NULL;\n \tkvm_s390_update_topology_change_report(vcpu-\u003ekvm, 1);\n \treturn 0;\n-\n-out_ucontrol_uninit:\n-\tif (kvm_is_ucontrol(vcpu-\u003ekvm)) {\n-\t\tgmap_remove_child(vcpu-\u003earch.gmap);\n-\t\tvcpu-\u003earch.gmap = gmap_put(vcpu-\u003earch.gmap);\n-\t}\n-out_free_sie_block:\n-\tfree_page((unsigned long)(vcpu-\u003earch.sie_block));\n-\treturn rc;\n }\n \n int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)\n@@ -5039,6 +5045,10 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)\n \t kvm_run-\u003ekvm_dirty_regs \u0026 ~KVM_SYNC_S390_VALID_FIELDS)\n \t\treturn -EINVAL;\n \n+\t/* Pairs with smp_store_release() in kvm_arch_vcpu_postcreate() */\n+\tif (!smp_load_acquire(\u0026vcpu-\u003earch.initialized))\n+\t\treturn -EINVAL;\n+\n \tvcpu_load(vcpu);\n \n \tif (guestdbg_exit_pending(vcpu)) {\n@@ -5447,6 +5457,8 @@ long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,\n \t\tstruct kvm_s390_interrupt s390int;\n \t\tstruct kvm_s390_irq s390irq = {};\n \n+\t\tif (kvm_is_ucontrol(vcpu-\u003ekvm))\n+\t\t\treturn -EINVAL;\n \t\tif (copy_from_user(\u0026s390int, argp, sizeof(s390int)))\n \t\t\treturn -EFAULT;\n \t\tif (s390int_to_s390irq(\u0026s390int, \u0026s390irq))\n@@ -5523,6 +5535,10 @@ long kvm_arch_vcpu_ioctl(struct file *filp,\n \tlong r;\n \tu16 rc, rrc;\n \n+\t/* Pairs with smp_store_release() in kvm_arch_vcpu_postcreate() */\n+\tif (!smp_load_acquire(\u0026vcpu-\u003earch.initialized))\n+\t\treturn -EINVAL;\n+\n \tvcpu_load(vcpu);\n \n \tswitch (ioctl) {\n@@ -5794,24 +5810,44 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,\n \treturn 0;\n }\n \n+static long cmma_d_count_pte(union pte *ptep, gfn_t gfn, gfn_t next, struct dat_walk *walk)\n+{\n+\tunion pgste pgste;\n+\n+\tpgste = pgste_get_lock(ptep);\n+\tif (pgste.cmma_d) {\n+\t\tpgste.cmma_d = 0;\n+\t\tatomic64_dec(walk-\u003epriv);\n+\t}\n+\tpgste_set_unlock(ptep, pgste);\n+\treturn 0;\n+}\n+\n void kvm_arch_commit_memory_region(struct kvm *kvm,\n \t\t\t\tstruct kvm_memory_slot *old,\n \t\t\t\tconst struct kvm_memory_slot *new,\n \t\t\t\tenum kvm_mr_change change)\n {\n-\tstruct kvm_s390_mmu_cache *mc = NULL;\n-\tint rc = 0;\n+\tconst struct dat_walk_ops ops = { .pte_entry = cmma_d_count_pte, };\n+\tstruct kvm_s390_mmu_cache *mc __free(kvm_s390_mmu_cache) = NULL;\n+\tint rc = -ENOMEM;\n+\n+\tguard(mutex)(\u0026kvm-\u003eslots_arch_lock);\n \n \tif (change == KVM_MR_FLAGS_ONLY)\n \t\treturn;\n \n \tmc = kvm_s390_new_mmu_cache();\n-\tif (!mc) {\n-\t\trc = -ENOMEM;\n+\tif (!mc)\n \t\tgoto out;\n-\t}\n-\n+retry:\n \tscoped_guard(write_lock, \u0026kvm-\u003emmu_lock) {\n+\t\tif (kvm-\u003earch.migration_mode \u0026\u0026 kvm-\u003earch.use_cmma \u0026\u0026 old) {\n+\t\t\t_dat_walk_gfn_range(old-\u003ebase_gfn, old-\u003ebase_gfn + old-\u003enpages,\n+\t\t\t\t\t kvm-\u003earch.gmap-\u003easce, \u0026ops, DAT_WALK_IGN_HOLES,\n+\t\t\t\t\t \u0026kvm-\u003earch.cmma_dirty_pages);\n+\t\t}\n+\n \t\tswitch (change) {\n \t\tcase KVM_MR_DELETE:\n \t\t\trc = dat_delete_slot(mc, kvm-\u003earch.gmap-\u003easce, old-\u003ebase_gfn, old-\u003enpages);\n@@ -5827,13 +5863,18 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,\n \t\tcase KVM_MR_FLAGS_ONLY:\n \t\t\tbreak;\n \t\tdefault:\n+\t\t\trc = 0;\n \t\t\tWARN(1, \"Unknown KVM MR CHANGE: %d\\n\", change);\n \t\t}\n \t}\n+\tif (rc == -ENOMEM) {\n+\t\trc = kvm_s390_mmu_cache_topup(mc);\n+\t\tif (!rc)\n+\t\t\tgoto retry;\n+\t}\n out:\n \tif (rc)\n \t\tpr_warn(\"failed to commit memory region\\n\");\n-\tkvm_s390_free_mmu_cache(mc);\n \treturn;\n }\n \ndiff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c\nindex ad0ddc433a73c..b1ba24c346efa 100644\n--- a/arch/s390/kvm/priv.c\n+++ b/arch/s390/kvm/priv.c\n@@ -289,6 +289,7 @@ static int handle_iske(struct kvm_vcpu *vcpu)\n static int handle_rrbe(struct kvm_vcpu *vcpu)\n {\n \tunsigned long gaddr;\n+\tunion skey skey;\n \tint reg1, reg2;\n \tint rc;\n \n@@ -307,12 +308,12 @@ static int handle_rrbe(struct kvm_vcpu *vcpu)\n \tgaddr = kvm_s390_logical_to_effective(vcpu, gaddr);\n \tgaddr = kvm_s390_real_to_abs(vcpu, gaddr);\n \tscoped_guard(read_lock, \u0026vcpu-\u003ekvm-\u003emmu_lock)\n-\t\trc = dat_reset_reference_bit(vcpu-\u003earch.gmap-\u003easce, gpa_to_gfn(gaddr));\n+\t\trc = dat_reset_reference_bit(vcpu-\u003earch.gmap-\u003easce, gpa_to_gfn(gaddr), \u0026skey);\n \tif (rc \u003e 0)\n \t\treturn kvm_s390_inject_program_int(vcpu, rc);\n \tif (rc \u003c 0)\n \t\treturn rc;\n-\tkvm_s390_set_psw_cc(vcpu, rc);\n+\tkvm_s390_set_psw_cc(vcpu, (skey.skey \u003e\u003e 1) \u0026 3);\n \treturn 0;\n }\n \n@@ -1260,8 +1261,9 @@ static int handle_essa(struct kvm_vcpu *vcpu)\n \t\t/* Retry the ESSA instruction */\n \t\tkvm_s390_retry_instr(vcpu);\n \t} else {\n-\t\tscoped_guard(read_lock, \u0026vcpu-\u003ekvm-\u003emmu_lock)\n-\t\t\ti = __do_essa(vcpu, orc);\n+\t\tscoped_guard(mutex, \u0026vcpu-\u003ekvm-\u003eslots_arch_lock)\n+\t\t\tscoped_guard(read_lock, \u0026vcpu-\u003ekvm-\u003emmu_lock)\n+\t\t\t\ti = __do_essa(vcpu, orc);\n \t\tif (i \u003c 0)\n \t\t\treturn i;\n \t\t/* Account for the possible extra cbrl entry */\ndiff --git a/arch/s390/kvm/pv.c b/arch/s390/kvm/pv.c\nindex 1beacc841ca85..b02e0159d3cd2 100644\n--- a/arch/s390/kvm/pv.c\n+++ b/arch/s390/kvm/pv.c\n@@ -244,6 +244,24 @@ static void kvm_s390_clear_pv_state(struct kvm *kvm)\n \tkvm-\u003earch.pv.stor_var = NULL;\n }\n \n+static void kvm_s390_pv_dispose_cpu(struct kvm_vcpu *vcpu, bool free_stor_base)\n+{\n+\tif (free_stor_base)\n+\t\tfree_pages(vcpu-\u003earch.pv.stor_base, get_order(uv_info.guest_cpu_stor_len));\n+\tfree_page((unsigned long)sida_addr(vcpu-\u003earch.sie_block));\n+\tvcpu-\u003earch.sie_block-\u003epv_handle_cpu = 0;\n+\tvcpu-\u003earch.sie_block-\u003epv_handle_config = 0;\n+\tmemset(\u0026vcpu-\u003earch.pv, 0, sizeof(vcpu-\u003earch.pv));\n+\tvcpu-\u003earch.sie_block-\u003esdf = 0;\n+\t/*\n+\t * The sidad field (for sdf == 2) is now the gbea field (for sdf == 0).\n+\t * Use the reset value of gbea to avoid leaking the kernel pointer of\n+\t * the just freed sida.\n+\t */\n+\tvcpu-\u003earch.sie_block-\u003egbea = 1;\n+\tkvm_make_request(KVM_REQ_TLB_FLUSH, vcpu);\n+}\n+\n int kvm_s390_pv_destroy_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc)\n {\n \tint cc;\n@@ -258,24 +276,9 @@ int kvm_s390_pv_destroy_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc)\n \tWARN_ONCE(cc, \"protvirt destroy cpu failed rc %x rrc %x\", *rc, *rrc);\n \n \t/* Intended memory leak for something that should never happen. */\n-\tif (!cc)\n-\t\tfree_pages(vcpu-\u003earch.pv.stor_base,\n-\t\t\t get_order(uv_info.guest_cpu_stor_len));\n-\n-\tfree_page((unsigned long)sida_addr(vcpu-\u003earch.sie_block));\n-\tvcpu-\u003earch.sie_block-\u003epv_handle_cpu = 0;\n-\tvcpu-\u003earch.sie_block-\u003epv_handle_config = 0;\n-\tmemset(\u0026vcpu-\u003earch.pv, 0, sizeof(vcpu-\u003earch.pv));\n-\tvcpu-\u003earch.sie_block-\u003esdf = 0;\n-\t/*\n-\t * The sidad field (for sdf == 2) is now the gbea field (for sdf == 0).\n-\t * Use the reset value of gbea to avoid leaking the kernel pointer of\n-\t * the just freed sida.\n-\t */\n-\tvcpu-\u003earch.sie_block-\u003egbea = 1;\n-\tkvm_make_request(KVM_REQ_TLB_FLUSH, vcpu);\n+\tkvm_s390_pv_dispose_cpu(vcpu, !cc);\n \n-\treturn cc ? EIO : 0;\n+\treturn cc ? -EIO : 0;\n }\n \n int kvm_s390_pv_create_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc)\n@@ -319,9 +322,7 @@ int kvm_s390_pv_create_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc)\n \t\t uvcb.header.rrc);\n \n \tif (cc) {\n-\t\tu16 dummy;\n-\n-\t\tkvm_s390_pv_destroy_cpu(vcpu, \u0026dummy, \u0026dummy);\n+\t\tkvm_s390_pv_dispose_cpu(vcpu, true);\n \t\treturn -EIO;\n \t}\n \n@@ -809,7 +810,7 @@ static int unpack_one(struct kvm *kvm, unsigned long addr, u64 tweak,\n \t\t\treturn -EAGAIN;\n \t}\n \n-\tif (ret \u0026\u0026 ret != -EAGAIN)\n+\tif (ret \u0026\u0026 ret != -EAGAIN \u0026\u0026 ret != -EINTR)\n \t\tKVM_UV_EVENT(kvm, 3, \"PROTVIRT VM UNPACK: failed addr %llx with rc %x rrc %x\",\n \t\t\t uvcb.gaddr, *rc, *rrc);\n \treturn ret;\n"
} |
| 2/1 | 2026/08/01 19:40 | agent | patch-evaluator |
2mModel:best-expensive Args: null Results: {
"EnableConfigs": [
"KVM"
],
"FocusSymbols": [
"kvm_arch_vm_ioctl",
"kvm_arch_vcpu_ioctl",
"kvm_arch_vcpu_unlocked_ioctl",
"kvm_arch_commit_memory_region",
"kvm_s390_pv_create_cpu",
"kvm_s390_pv_destroy_cpu",
"kvm_s390_handle_b2",
"kvm_s390_handle_b9",
"kvm_s390_inject_vcpu",
"kvm_s390_faultin_gfn"
],
"Reasoning": "The patch modifies core KVM functionality for the s390 architecture, including handling of memory regions, page faults, virtual CPU creation/destruction, interrupt injection, and specific instruction handlers (RRBE, ESSA). It also adds checks for userspace-controlled VMs (KVM_S390_UCONTROL). These changes are reachable from userspace via standard KVM ioctls and guest execution, and should be fuzzed to ensure they do not introduce regressions, memory leaks, or locking issues.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer. Your job is to review a provided patch series and determine if it makes functional changes to the kernel that should be fuzzed. IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively use your code access tools to examine the actual source code and confirm any assumptions. Return WorthFuzzing=false if the patch only contains: - Modifications to Documentation/, Kconfig files, or code comments. - Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints. - Changes to numeric constants or macros that do not functionally alter execution flow. - Code paths that are impossible to reach in virtualized environments like GCE or QEMU, even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim). - Code in vendor-specific PCIe switch, SmartNIC, or GPU drivers (e.g., mlxsw, pds_core, qed, ionic, amdgpu) that require physical PCIe hardware cards not emulated in standard QEMU. - Driver .remove, .shutdown, or pci_unregister_driver teardown callbacks (e.g., igb_remove) that are executed only during PCI hot-unplug or sysfs driver unbind operations. If it modifies reachable core kernel logic, drivers, or architectures, use your code search tools to verify the code can be executed, then return WorthFuzzing=true. When returning WorthFuzzing=true, you MUST ALSO: 1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols. Avoid listing generic hot-path functions to prevent skewed test distributions. Prefer non-static, non-inlined API entrypoint functions over internal static helper functions (which are inlined by the compiler and do not have distinct symbol addresses). 2. Identify any specific CONFIG_ options required to properly test this new/modified feature. Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions. Also check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed for Kbuild to compile the code statically into vmlinux. List them in the EnableConfigs output array, and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4"). Prefer calling several tools at the same time to save round-trips. Use set-results tool to provide results of the analysis. It must be called exactly once before the final reply. Ignore results of this tool. Prompt: For your convenience, here is the diff of the changes:
commit 853c643249bc530bb01245402735e655699eee96
Author: syz-cluster <triage@syzkaller.com>
Date: Sat Aug 1 19:40:34 2026 +0000
syz-cluster: applied patch under review
diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index eaa34c5bd3c11..edf75b6ad20ce 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -440,6 +440,7 @@ struct kvm_vcpu_arch {
bool skey_enabled;
/* Indicator if the access registers have been loaded from guest */
bool acrs_loaded;
+ bool initialized;
struct kvm_s390_pv_vcpu pv;
union diag318_info diag318_info;
struct kvm_s390_mmu_cache *mc;
diff --git a/arch/s390/kvm/dat.c b/arch/s390/kvm/dat.c
index ed4259d176295..3f2d6e8902d76 100644
--- a/arch/s390/kvm/dat.c
+++ b/arch/s390/kvm/dat.c
@@ -755,13 +755,15 @@ int dat_cond_set_storage_key(struct kvm_s390_mmu_cache *mmc, union asce asce, gf
return rc;
}
-int dat_reset_reference_bit(union asce asce, gfn_t gfn)
+int dat_reset_reference_bit(union asce asce, gfn_t gfn, union skey *skey)
{
union pgste pgste, old;
union crste *crstep;
union pte *ptep;
int rc;
+ skey->skey = 0;
+
rc = dat_entry_walk(NULL, gfn, asce, DAT_WALK_ANY, TABLE_TYPE_PAGE_TABLE, &crstep, &ptep);
if (rc)
return rc;
@@ -771,21 +773,23 @@ int dat_reset_reference_bit(union asce asce, gfn_t gfn)
if (!crste.h.fc || !crste.s.fc1.pr)
return 0;
- return page_reset_referenced(large_crste_to_phys(*crstep, gfn));
+ skey->skey = page_reset_referenced(large_crste_to_phys(*crstep, gfn)) << 1;
+ return 0;
}
old = pgste_get_lock(ptep);
pgste = old;
if (!ptep->h.i) {
- rc = page_reset_referenced(pte_origin(*ptep));
- pgste.hr = rc >> 1;
+ skey->skey = page_reset_referenced(pte_origin(*ptep)) << 1;
+ pgste.hr = skey->r;
}
- rc |= (pgste.gr << 1) | pgste.gc;
+ skey->r |= pgste.gr;
+ skey->c |= pgste.gc;
pgste.gr = 0;
dat_update_ptep_sd(old, pgste, ptep);
pgste_set_unlock(ptep, pgste);
- return rc;
+ return 0;
}
static long dat_reset_skeys_pte(union pte *ptep, gfn_t gfn, gfn_t next, struct dat_walk *walk)
@@ -846,6 +850,7 @@ static long _dat_slot_pte(union pte *ptep, gfn_t gfn, gfn_t next, struct dat_wal
struct slot_priv *p = walk->priv;
union crste dummy = { .val = p->token };
union pte new_pte, pte = READ_ONCE(*ptep);
+ union pgste pgste;
new_pte = _PTE_TOK(dummy.tok.type, dummy.tok.par);
@@ -853,7 +858,11 @@ static long _dat_slot_pte(union pte *ptep, gfn_t gfn, gfn_t next, struct dat_wal
if (pte.val == new_pte.val)
return 0;
- dat_ptep_xchg(ptep, new_pte, gfn, walk->asce, false);
+ pgste = pgste_get_lock(ptep);
+ pgste = __dat_ptep_xchg(ptep, pgste, new_pte, gfn, walk->asce, false);
+ pgste.cmma_d = 0;
+ pgste_set_unlock(ptep, pgste);
+
return 0;
}
diff --git a/arch/s390/kvm/dat.h b/arch/s390/kvm/dat.h
index fad605305e05c..141ee7b9f0191 100644
--- a/arch/s390/kvm/dat.h
+++ b/arch/s390/kvm/dat.h
@@ -537,7 +537,7 @@ int dat_set_storage_key(struct kvm_s390_mmu_cache *mc, union asce asce, gfn_t gf
union skey skey, bool nq);
int dat_cond_set_storage_key(struct kvm_s390_mmu_cache *mmc, union asce asce, gfn_t gfn,
union skey skey, union skey *oldkey, bool nq, bool mr, bool mc);
-int dat_reset_reference_bit(union asce asce, gfn_t gfn);
+int dat_reset_reference_bit(union asce asce, gfn_t gfn, union skey *skey);
long dat_reset_skeys(union asce asce, gfn_t start);
unsigned long dat_get_ptval(struct page_table *table, struct ptval_param param);
diff --git a/arch/s390/kvm/faultin.c b/arch/s390/kvm/faultin.c
index fee80047bd94f..3cc45f7f5b2d7 100644
--- a/arch/s390/kvm/faultin.c
+++ b/arch/s390/kvm/faultin.c
@@ -91,9 +91,9 @@ int kvm_s390_faultin_gfn(struct kvm_vcpu *vcpu, struct kvm *kvm, struct guest_fa
/* Access outside memory, addressing exception. */
if (is_noslot_pfn(f->pfn))
return PGM_ADDRESSING;
- /* Signal pending: try again. */
- if (f->pfn == KVM_PFN_ERR_SIGPENDING)
- return -EAGAIN;
+ /* Fatal signal pending: bail out. */
+ if (is_sigpending_pfn(f->pfn))
+ return -EINTR;
/* Check if it's read-only memory; don't try to actually handle that case. */
if (f->pfn == KVM_PFN_ERR_RO_FAULT)
return -EOPNOTSUPP;
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index 9e3e6b0d72ad6..9db68e3ac178f 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -45,13 +45,16 @@ static struct kvm_s390_gib *gib;
static int sca_ext_call_pending(struct kvm_vcpu *vcpu, int *src_id)
{
struct esca_block *sca = vcpu->kvm->arch.sca;
- union esca_sigp_ctrl sigp_ctrl = sca->cpu[vcpu->vcpu_id].sigp_ctrl;
+ union esca_sigp_ctrl sigp_ctrl;
if (!kvm_s390_test_cpuflags(vcpu, CPUSTAT_ECALL_PEND))
return 0;
+ if (kvm_is_ucontrol(vcpu->kvm))
+ return 0;
BUG_ON(!kvm_s390_use_sca_entries());
+ sigp_ctrl = sca->cpu[vcpu->vcpu_id].sigp_ctrl;
if (src_id)
*src_id = sigp_ctrl.scn;
@@ -60,13 +63,16 @@ static int sca_ext_call_pending(struct kvm_vcpu *vcpu, int *src_id)
static int sca_inject_ext_call(struct kvm_vcpu *vcpu, int src_id)
{
- struct esca_block *sca = vcpu->kvm->arch.sca;
- union esca_sigp_ctrl *sigp_ctrl = &sca->cpu[vcpu->vcpu_id].sigp_ctrl;
union esca_sigp_ctrl old_val, new_val = {.scn = src_id, .c = 1};
+ struct esca_block *sca = vcpu->kvm->arch.sca;
+ union esca_sigp_ctrl *sigp_ctrl;
int expect, rc;
BUG_ON(!kvm_s390_use_sca_entries());
+ if (KVM_BUG_ON(kvm_is_ucontrol(vcpu->kvm), vcpu->kvm))
+ return -EINVAL;
+ sigp_ctrl = &sca->cpu[vcpu->vcpu_id].sigp_ctrl;
old_val = READ_ONCE(*sigp_ctrl);
old_val.c = 0;
@@ -84,10 +90,13 @@ static int sca_inject_ext_call(struct kvm_vcpu *vcpu, int src_id)
static void sca_clear_ext_call(struct kvm_vcpu *vcpu)
{
struct esca_block *sca = vcpu->kvm->arch.sca;
- union esca_sigp_ctrl *sigp_ctrl = &sca->cpu[vcpu->vcpu_id].sigp_ctrl;
+ union esca_sigp_ctrl *sigp_ctrl;
- if (!kvm_s390_use_sca_entries())
+ if (!kvm_s390_use_sca_entries() || !vcpu->arch.initialized || kvm_is_ucontrol(vcpu->kvm))
return;
+
+ /* Initialize after the above check, to prevent going out of bounds */
+ sigp_ctrl = &sca->cpu[vcpu->vcpu_id].sigp_ctrl;
kvm_s390_clear_cpuflags(vcpu, CPUSTAT_ECALL_PEND);
WRITE_ONCE(sigp_ctrl->value, 0);
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 150b5dd2170e2..fd8badb0d571c 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -571,7 +571,7 @@ static int kvm_s390_keyop(struct kvm_s390_mmu_cache *mc, struct kvm *kvm, int op
switch (op) {
case KVM_S390_KEYOP_SSKE:
r = dat_cond_set_storage_key(mc, asce, gfn, skey, &skey, 0, 0, 0);
- if (r >= 0)
+ if (r == 0 || r == 1)
return skey.skey;
break;
case KVM_S390_KEYOP_ISKE:
@@ -580,14 +580,14 @@ static int kvm_s390_keyop(struct kvm_s390_mmu_cache *mc, struct kvm *kvm, int op
return skey.skey;
break;
case KVM_S390_KEYOP_RRBE:
- r = dat_reset_reference_bit(asce, gfn);
- if (r > 0)
- return r << 1;
+ r = dat_reset_reference_bit(asce, gfn, &skey);
+ if (!r)
+ return skey.skey;
break;
default:
return -EINVAL;
}
- return r;
+ return r > 0 ? -EFAULT : r;
}
/* Section: device related */
@@ -1219,8 +1219,8 @@ static void kvm_s390_sync_request_broadcast(struct kvm *kvm, int req)
/*
* Must be called with kvm->srcu held to avoid races on memslots, and with
- * kvm->slots_lock to avoid races with ourselves, kvm_s390_vm_stop_migration(),
- * and kvm_s390_get_cmma_bits().
+ * kvm->slots_arch_lock to avoid races with ourselves,
+ * kvm_s390_vm_stop_migration(), and kvm_s390_get_cmma_bits().
*/
static int kvm_s390_vm_start_migration(struct kvm *kvm)
{
@@ -1265,7 +1265,7 @@ static int kvm_s390_vm_start_migration(struct kvm *kvm)
}
/*
- * Must be called with kvm->slots_lock to avoid races with ourselves,
+ * Must be called with kvm->slots_arch_lock to avoid races with ourselves,
* kvm_s390_vm_start_migration() and kvm_s390_get_cmma_bits().
*/
static int kvm_s390_vm_stop_migration(struct kvm *kvm)
@@ -1300,7 +1300,9 @@ static int kvm_s390_vm_set_migration(struct kvm *kvm,
{
int res = -ENXIO;
- mutex_lock(&kvm->slots_lock);
+ guard(srcu)(&kvm->srcu);
+ guard(mutex)(&kvm->slots_arch_lock);
+
switch (attr->attr) {
case KVM_S390_VM_MIGRATION_START:
res = kvm_s390_vm_start_migration(kvm);
@@ -1311,7 +1313,6 @@ static int kvm_s390_vm_set_migration(struct kvm *kvm,
default:
break;
}
- mutex_unlock(&kvm->slots_lock);
return res;
}
@@ -2214,7 +2215,7 @@ static int kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
}
kvfree(keys);
- return r;
+ return r <= 0 ? r : -EFAULT;
}
static int kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
@@ -2276,7 +2277,7 @@ static int kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
kvm_s390_free_mmu_cache(mc);
out:
kvfree(keys);
- return r;
+ return r <= 0 ? r : -EFAULT;
}
/*
@@ -2386,7 +2387,7 @@ static int kvm_s390_set_cmma_bits(struct kvm *kvm,
set_bit(GMAP_FLAG_USES_CMM, &kvm->arch.gmap->flags);
- return r;
+ return r <= 0 ? r : -EFAULT;
}
/**
@@ -2934,6 +2935,9 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
case KVM_S390_INTERRUPT: {
struct kvm_s390_interrupt s390int;
+ r = -EINVAL;
+ if (kvm_is_ucontrol(kvm))
+ break;
r = -EFAULT;
if (copy_from_user(&s390int, argp, sizeof(s390int)))
break;
@@ -2998,9 +3002,8 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
r = -EFAULT;
if (copy_from_user(&args, argp, sizeof(args)))
break;
- mutex_lock(&kvm->slots_lock);
- r = kvm_s390_get_cmma_bits(kvm, &args);
- mutex_unlock(&kvm->slots_lock);
+ scoped_guard(mutex, &kvm->slots_arch_lock)
+ r = kvm_s390_get_cmma_bits(kvm, &args);
if (!r) {
r = copy_to_user(argp, &args, sizeof(args));
if (r)
@@ -3014,9 +3017,9 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
r = -EFAULT;
if (copy_from_user(&args, argp, sizeof(args)))
break;
- mutex_lock(&kvm->slots_lock);
+ mutex_lock(&kvm->slots_arch_lock);
r = kvm_s390_set_cmma_bits(kvm, &args);
- mutex_unlock(&kvm->slots_lock);
+ mutex_unlock(&kvm->slots_arch_lock);
break;
}
case KVM_S390_PV_COMMAND: {
@@ -3247,7 +3250,8 @@ static void kvm_s390_crypto_init(struct kvm *kvm)
static void sca_dispose(struct kvm *kvm)
{
- free_pages_exact(kvm->arch.sca, sizeof(*kvm->arch.sca));
+ if (kvm->arch.sca)
+ free_pages_exact(kvm->arch.sca, sizeof(*kvm->arch.sca));
kvm->arch.sca = NULL;
}
@@ -3461,7 +3465,7 @@ static void sca_del_vcpu(struct kvm_vcpu *vcpu)
{
struct esca_block *sca = vcpu->kvm->arch.sca;
- if (!kvm_s390_use_sca_entries())
+ if (!kvm_s390_use_sca_entries() || !vcpu->arch.initialized)
return;
clear_bit_inv(vcpu->vcpu_id, (unsigned long *)sca->mcn);
@@ -3481,8 +3485,8 @@ static void sca_add_vcpu(struct kvm_vcpu *vcpu)
if (!kvm_s390_use_sca_entries())
return;
+ WRITE_ONCE(sca->cpu[vcpu->vcpu_id].sda, virt_to_phys(vcpu->arch.sie_block));
set_bit_inv(vcpu->vcpu_id, (unsigned long *)sca->mcn);
- sca->cpu[vcpu->vcpu_id].sda = virt_to_phys(vcpu->arch.sie_block);
}
static int sca_can_add_vcpu(struct kvm *kvm, unsigned int id)
@@ -3613,6 +3617,9 @@ void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
if (test_kvm_facility(vcpu->kvm, 74) || vcpu->kvm->arch.user_instr0 ||
vcpu->kvm->arch.user_operexec)
vcpu->arch.sie_block->ictl |= ICTL_OPEREXC;
+
+ /* Pairs with smp_load_acquire() in kvm_arch_vcpu_ioctl_run() and kvm_arch_vcpu_ioctl() */
+ smp_store_release(&vcpu->arch.initialized, true);
}
static bool kvm_has_pckmo_subfunc(struct kvm *kvm, unsigned long nr)
@@ -3674,7 +3681,8 @@ static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu)
void kvm_s390_vcpu_unsetup_cmma(struct kvm_vcpu *vcpu)
{
- free_page((unsigned long)phys_to_virt(vcpu->arch.sie_block->cbrlo));
+ if (vcpu->arch.sie_block->cbrlo)
+ free_page((unsigned long)phys_to_virt(vcpu->arch.sie_block->cbrlo));
vcpu->arch.sie_block->cbrlo = 0;
}
@@ -3792,21 +3800,21 @@ int kvm_arch_vcpu_precreate(struct kvm *kvm, unsigned int id)
return 0;
}
+DEFINE_FREE(sie_page, struct sie_page *, if (_T) free_page((unsigned long)(_T)))
+
int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
{
- struct sie_page *sie_page;
+ struct kvm_s390_mmu_cache *mc __free(kvm_s390_mmu_cache) = NULL;
+ struct sie_page *sie_page __free(sie_page) = NULL;
int rc;
BUILD_BUG_ON(sizeof(struct sie_page) != 4096);
- vcpu->arch.mc = kvm_s390_new_mmu_cache();
- if (!vcpu->arch.mc)
+ mc = kvm_s390_new_mmu_cache();
+ if (!mc)
return -ENOMEM;
sie_page = (struct sie_page *) get_zeroed_page(GFP_KERNEL_ACCOUNT);
- if (!sie_page) {
- kvm_s390_free_mmu_cache(vcpu->arch.mc);
- vcpu->arch.mc = NULL;
+ if (!sie_page)
return -ENOMEM;
- }
vcpu->arch.sie_block = &sie_page->sie_block;
vcpu->arch.sie_block->itdba = virt_to_phys(&sie_page->itdb);
@@ -3848,10 +3856,9 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
vcpu->run->kvm_valid_regs |= KVM_SYNC_FPRS;
if (kvm_is_ucontrol(vcpu->kvm)) {
- rc = -ENOMEM;
vcpu->arch.gmap = gmap_new_child(vcpu->kvm->arch.gmap, -1UL);
if (!vcpu->arch.gmap)
- goto out_free_sie_block;
+ return -ENOMEM;
}
VM_EVENT(vcpu->kvm, 3, "create cpu %d at 0x%p, sie block at 0x%p",
@@ -3859,20 +3866,19 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
trace_kvm_s390_create_vcpu(vcpu->vcpu_id, vcpu, vcpu->arch.sie_block);
rc = kvm_s390_vcpu_setup(vcpu);
- if (rc)
- goto out_ucontrol_uninit;
+ if (rc) {
+ if (kvm_is_ucontrol(vcpu->kvm)) {
+ scoped_guard(spinlock, &vcpu->kvm->arch.gmap->children_lock)
+ gmap_remove_child(vcpu->arch.gmap);
+ vcpu->arch.gmap = gmap_put(vcpu->arch.gmap);
+ }
+ return rc;
+ }
+ vcpu->arch.mc = no_free_ptr(mc);
+ sie_page = NULL;
kvm_s390_update_topology_change_report(vcpu->kvm, 1);
return 0;
-
-out_ucontrol_uninit:
- if (kvm_is_ucontrol(vcpu->kvm)) {
- gmap_remove_child(vcpu->arch.gmap);
- vcpu->arch.gmap = gmap_put(vcpu->arch.gmap);
- }
-out_free_sie_block:
- free_page((unsigned long)(vcpu->arch.sie_block));
- return rc;
}
int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
@@ -5039,6 +5045,10 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
kvm_run->kvm_dirty_regs & ~KVM_SYNC_S390_VALID_FIELDS)
return -EINVAL;
+ /* Pairs with smp_store_release() in kvm_arch_vcpu_postcreate() */
+ if (!smp_load_acquire(&vcpu->arch.initialized))
+ return -EINVAL;
+
vcpu_load(vcpu);
if (guestdbg_exit_pending(vcpu)) {
@@ -5447,6 +5457,8 @@ long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,
struct kvm_s390_interrupt s390int;
struct kvm_s390_irq s390irq = {};
+ if (kvm_is_ucontrol(vcpu->kvm))
+ return -EINVAL;
if (copy_from_user(&s390int, argp, sizeof(s390int)))
return -EFAULT;
if (s390int_to_s390irq(&s390int, &s390irq))
@@ -5523,6 +5535,10 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
long r;
u16 rc, rrc;
+ /* Pairs with smp_store_release() in kvm_arch_vcpu_postcreate() */
+ if (!smp_load_acquire(&vcpu->arch.initialized))
+ return -EINVAL;
+
vcpu_load(vcpu);
switch (ioctl) {
@@ -5794,24 +5810,44 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
return 0;
}
+static long cmma_d_count_pte(union pte *ptep, gfn_t gfn, gfn_t next, struct dat_walk *walk)
+{
+ union pgste pgste;
+
+ pgste = pgste_get_lock(ptep);
+ if (pgste.cmma_d) {
+ pgste.cmma_d = 0;
+ atomic64_dec(walk->priv);
+ }
+ pgste_set_unlock(ptep, pgste);
+ return 0;
+}
+
void kvm_arch_commit_memory_region(struct kvm *kvm,
struct kvm_memory_slot *old,
const struct kvm_memory_slot *new,
enum kvm_mr_change change)
{
- struct kvm_s390_mmu_cache *mc = NULL;
- int rc = 0;
+ const struct dat_walk_ops ops = { .pte_entry = cmma_d_count_pte, };
+ struct kvm_s390_mmu_cache *mc __free(kvm_s390_mmu_cache) = NULL;
+ int rc = -ENOMEM;
+
+ guard(mutex)(&kvm->slots_arch_lock);
if (change == KVM_MR_FLAGS_ONLY)
return;
mc = kvm_s390_new_mmu_cache();
- if (!mc) {
- rc = -ENOMEM;
+ if (!mc)
goto out;
- }
-
+retry:
scoped_guard(write_lock, &kvm->mmu_lock) {
+ if (kvm->arch.migration_mode && kvm->arch.use_cmma && old) {
+ _dat_walk_gfn_range(old->base_gfn, old->base_gfn + old->npages,
+ kvm->arch.gmap->asce, &ops, DAT_WALK_IGN_HOLES,
+ &kvm->arch.cmma_dirty_pages);
+ }
+
switch (change) {
case KVM_MR_DELETE:
rc = dat_delete_slot(mc, kvm->arch.gmap->asce, old->base_gfn, old->npages);
@@ -5827,13 +5863,18 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
case KVM_MR_FLAGS_ONLY:
break;
default:
+ rc = 0;
WARN(1, "Unknown KVM MR CHANGE: %d\n", change);
}
}
+ if (rc == -ENOMEM) {
+ rc = kvm_s390_mmu_cache_topup(mc);
+ if (!rc)
+ goto retry;
+ }
out:
if (rc)
pr_warn("failed to commit memory region\n");
- kvm_s390_free_mmu_cache(mc);
return;
}
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index ad0ddc433a73c..b1ba24c346efa 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -289,6 +289,7 @@ static int handle_iske(struct kvm_vcpu *vcpu)
static int handle_rrbe(struct kvm_vcpu *vcpu)
{
unsigned long gaddr;
+ union skey skey;
int reg1, reg2;
int rc;
@@ -307,12 +308,12 @@ static int handle_rrbe(struct kvm_vcpu *vcpu)
gaddr = kvm_s390_logical_to_effective(vcpu, gaddr);
gaddr = kvm_s390_real_to_abs(vcpu, gaddr);
scoped_guard(read_lock, &vcpu->kvm->mmu_lock)
- rc = dat_reset_reference_bit(vcpu->arch.gmap->asce, gpa_to_gfn(gaddr));
+ rc = dat_reset_reference_bit(vcpu->arch.gmap->asce, gpa_to_gfn(gaddr), &skey);
if (rc > 0)
return kvm_s390_inject_program_int(vcpu, rc);
if (rc < 0)
return rc;
- kvm_s390_set_psw_cc(vcpu, rc);
+ kvm_s390_set_psw_cc(vcpu, (skey.skey >> 1) & 3);
return 0;
}
@@ -1260,8 +1261,9 @@ static int handle_essa(struct kvm_vcpu *vcpu)
/* Retry the ESSA instruction */
kvm_s390_retry_instr(vcpu);
} else {
- scoped_guard(read_lock, &vcpu->kvm->mmu_lock)
- i = __do_essa(vcpu, orc);
+ scoped_guard(mutex, &vcpu->kvm->slots_arch_lock)
+ scoped_guard(read_lock, &vcpu->kvm->mmu_lock)
+ i = __do_essa(vcpu, orc);
if (i < 0)
return i;
/* Account for the possible extra cbrl entry */
diff --git a/arch/s390/kvm/pv.c b/arch/s390/kvm/pv.c
index 1beacc841ca85..b02e0159d3cd2 100644
--- a/arch/s390/kvm/pv.c
+++ b/arch/s390/kvm/pv.c
@@ -244,6 +244,24 @@ static void kvm_s390_clear_pv_state(struct kvm *kvm)
kvm->arch.pv.stor_var = NULL;
}
+static void kvm_s390_pv_dispose_cpu(struct kvm_vcpu *vcpu, bool free_stor_base)
+{
+ if (free_stor_base)
+ free_pages(vcpu->arch.pv.stor_base, get_order(uv_info.guest_cpu_stor_len));
+ free_page((unsigned long)sida_addr(vcpu->arch.sie_block));
+ vcpu->arch.sie_block->pv_handle_cpu = 0;
+ vcpu->arch.sie_block->pv_handle_config = 0;
+ memset(&vcpu->arch.pv, 0, sizeof(vcpu->arch.pv));
+ vcpu->arch.sie_block->sdf = 0;
+ /*
+ * The sidad field (for sdf == 2) is now the gbea field (for sdf == 0).
+ * Use the reset value of gbea to avoid leaking the kernel pointer of
+ * the just freed sida.
+ */
+ vcpu->arch.sie_block->gbea = 1;
+ kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu);
+}
+
int kvm_s390_pv_destroy_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc)
{
int cc;
@@ -258,24 +276,9 @@ int kvm_s390_pv_destroy_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc)
WARN_ONCE(cc, "protvirt destroy cpu failed rc %x rrc %x", *rc, *rrc);
/* Intended memory leak for something that should never happen. */
- if (!cc)
- free_pages(vcpu->arch.pv.stor_base,
- get_order(uv_info.guest_cpu_stor_len));
-
- free_page((unsigned long)sida_addr(vcpu->arch.sie_block));
- vcpu->arch.sie_block->pv_handle_cpu = 0;
- vcpu->arch.sie_block->pv_handle_config = 0;
- memset(&vcpu->arch.pv, 0, sizeof(vcpu->arch.pv));
- vcpu->arch.sie_block->sdf = 0;
- /*
- * The sidad field (for sdf == 2) is now the gbea field (for sdf == 0).
- * Use the reset value of gbea to avoid leaking the kernel pointer of
- * the just freed sida.
- */
- vcpu->arch.sie_block->gbea = 1;
- kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu);
+ kvm_s390_pv_dispose_cpu(vcpu, !cc);
- return cc ? EIO : 0;
+ return cc ? -EIO : 0;
}
int kvm_s390_pv_create_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc)
@@ -319,9 +322,7 @@ int kvm_s390_pv_create_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc)
uvcb.header.rrc);
if (cc) {
- u16 dummy;
-
- kvm_s390_pv_destroy_cpu(vcpu, &dummy, &dummy);
+ kvm_s390_pv_dispose_cpu(vcpu, true);
return -EIO;
}
@@ -809,7 +810,7 @@ static int unpack_one(struct kvm *kvm, unsigned long addr, u64 tweak,
return -EAGAIN;
}
- if (ret && ret != -EAGAIN)
+ if (ret && ret != -EAGAIN && ret != -EINTR)
KVM_UV_EVENT(kvm, 3, "PROTVIRT VM UNPACK: failed addr %llx with rc %x rrc %x",
uvcb.gaddr, *rc, *rrc);
return ret;
|
| 3/2 | 2026/08/01 19:40 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 11971 output: 35 thoughts: 954 Thoughts: **Analyzing the S390 KVM Patch Series** Okay, so I've got this patch series modifying the `arch/s390/kvm/` directory. This is KVM code, specifically for the s390 architecture, which immediately tells me this is interesting. I see changes in core functions like `dat_reset_reference_bit`, `sca_ext_call_pending`, `kvm_s390_keyop`, and a bunch more, all dealing with VM setup, control, and memory management. Since this is KVM on s390, it's pretty clear that these functions are exposed to userspace through KVM ioctls. Now, the important question: Can this be fuzzed? The prompt mentions scenarios where code paths are unreachable in virtualized environments like QEMU and GCE, in which case we return `WorthFuzzing=false`. But hang on… s390 KVM *does* require an actual s390x host for the KVM part, doesn't it? QEMU can emulate s390x, and Syzkaller supports s390x. But, does Syzkaller run on s390x? Yes! Yes, it does. Therefore, these KVM ioctls are reachable. So, unless the fuzzing environment is x86_64, then it would be reachable. The prompt specifically asks about KVM for s390x. It is reachable! In a Syzkaller environment it would be, since Syzkaller runs on s390x. So, given that Syzkaller is capable of fuzzing s390x, I'm going to return `WorthFuzzing=true`. This is core KVM logic for s390, so it's a good target. Let's quickly scan the code changes. I see that the `dat_reset_reference_bit` signature has changed. We've got `kvm_s390_faultin_gfn` now handling `is_sigpending_pfn`. There are added `kvm_is_ucontrol(vcpu->kvm)` checks in functions related to external calls, and `kvm_s390_vm_set_migration` is using a different lock now. I'm seeing checks for the `vcpu->arch.initialized` flag in `kvm_arch_vcpu_ioctl_run` and `kvm_arch_vcpu_ioctl`. `kvm_arch_commit_memory_region` is also using new locks and free operations. I'm seeing fixes for memory leaks in `kvm_arch_vcpu_create`, which is always a good thing. I'd say my focus symbols from the diff are: `kvm_arch_vcpu_ioctl_run`, `kvm_arch_vcpu_ioctl`, `kvm_arch_vm_ioctl`, `kvm_s390_vm_set_migration`, `kvm_arch_commit_memory_region`, `kvm_s390_pv_create_cpu`, and `kvm_s390_pv_destroy_cpu`. Finally, I need to make sure the right Kconfig options are enabled. `CONFIG_KVM` is definitely needed. I'll quickly check `arch/s390/kvm/Kconfig` to be absolutely sure, but I'm pretty confident we're good to go. |
| 4/2 | 2026/08/01 19:40 | tool | grepper |
0mArgs:{
"Expression": "config KVM",
"PathPrefix": "arch/s390/kvm/Kconfig"
}Results: {
"Output": "arch/s390/kvm/Kconfig=17=if VIRTUALIZATION\narch/s390/kvm/Kconfig-18-\narch/s390/kvm/Kconfig:19:config KVM\narch/s390/kvm/Kconfig-20-\tdef_tristate y\n--\narch/s390/kvm/Kconfig-46-\narch/s390/kvm/Kconfig:47:config KVM_S390_UCONTROL\narch/s390/kvm/Kconfig-48-\tbool \"Userspace controlled virtual machines\"\n"
} |
| 5/2 | 2026/08/01 19:40 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 13888 output: 34 thoughts: 103 Thoughts: **Analyzing KVM and S390 Ucontrol in this Patch** Okay, so looking at this patch, my initial thoughts are that `CONFIG_KVM` and `CONFIG_KVM_S390_UCONTROL` are definitely going to be relevant here. The first step is to figure out if `KVM_S390_UCONTROL` is *actually* being utilized in this patch's functionality. I see a reference to `kvm_is_ucontrol(vcpu->kvm)`. Right, so that's the key. Now I need to look up where that function is defined. I'll need to check `arch/s390/include/asm/kvm_host.h` to get the full picture of what `kvm_is_ucontrol` is doing and what its implications are. |
| 6/2 | 2026/08/01 19:40 | tool | grepper |
0mArgs:{
"Expression": "kvm_is_ucontrol",
"PathPrefix": "arch/s390/"
}Results: {
"Output": "arch/s390/kvm/gmap.c=89=static void gmap_add_child(struct gmap *parent, struct gmap *child)\n--\narch/s390/kvm/gmap.c-112-\narch/s390/kvm/gmap.c:113:\tif (kvm_is_ucontrol(parent-\u003ekvm))\narch/s390/kvm/gmap.c-114-\t\tclear_bit(GMAP_FLAG_OWNS_PAGETABLES, \u0026child-\u003eflags);\n--\narch/s390/kvm/intercept.c=613=int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu)\n--\narch/s390/kvm/intercept.c-616-\narch/s390/kvm/intercept.c:617:\tif (kvm_is_ucontrol(vcpu-\u003ekvm))\narch/s390/kvm/intercept.c-618-\t\treturn -EOPNOTSUPP;\n--\narch/s390/kvm/interrupt.c=45=static int sca_ext_call_pending(struct kvm_vcpu *vcpu, int *src_id)\n--\narch/s390/kvm/interrupt.c-51-\t\treturn 0;\narch/s390/kvm/interrupt.c:52:\tif (kvm_is_ucontrol(vcpu-\u003ekvm))\narch/s390/kvm/interrupt.c-53-\t\treturn 0;\n--\narch/s390/kvm/interrupt.c=64=static int sca_inject_ext_call(struct kvm_vcpu *vcpu, int src_id)\n--\narch/s390/kvm/interrupt.c-71-\tBUG_ON(!kvm_s390_use_sca_entries());\narch/s390/kvm/interrupt.c:72:\tif (KVM_BUG_ON(kvm_is_ucontrol(vcpu-\u003ekvm), vcpu-\u003ekvm))\narch/s390/kvm/interrupt.c-73-\t\treturn -EINVAL;\n--\narch/s390/kvm/interrupt.c=90=static void sca_clear_ext_call(struct kvm_vcpu *vcpu)\n--\narch/s390/kvm/interrupt.c-94-\narch/s390/kvm/interrupt.c:95:\tif (!kvm_s390_use_sca_entries() || !vcpu-\u003earch.initialized || kvm_is_ucontrol(vcpu-\u003ekvm))\narch/s390/kvm/interrupt.c-96-\t\treturn;\n--\narch/s390/kvm/interrupt.c=2818=static int flic_set_attr(struct kvm_device *dev, struct kvm_device_attr *attr)\n--\narch/s390/kvm/interrupt.c-2831-\tcase KVM_DEV_FLIC_APF_ENABLE:\narch/s390/kvm/interrupt.c:2832:\t\tif (kvm_is_ucontrol(dev-\u003ekvm))\narch/s390/kvm/interrupt.c-2833-\t\t\treturn -EINVAL;\n--\narch/s390/kvm/interrupt.c-2836-\tcase KVM_DEV_FLIC_APF_DISABLE_WAIT:\narch/s390/kvm/interrupt.c:2837:\t\tif (kvm_is_ucontrol(dev-\u003ekvm))\narch/s390/kvm/interrupt.c-2838-\t\t\treturn -EINVAL;\n--\narch/s390/kvm/interrupt.c=3121=int kvm_set_routing_entry(struct kvm *kvm,\n--\narch/s390/kvm/interrupt.c-3130-\tcase KVM_IRQ_ROUTING_S390_ADAPTER:\narch/s390/kvm/interrupt.c:3131:\t\tif (kvm_is_ucontrol(kvm))\narch/s390/kvm/interrupt.c-3132-\t\t\treturn -EINVAL;\n--\narch/s390/kvm/kvm-s390.c=602=int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)\n--\narch/s390/kvm/kvm-s390.c-645-\t\tr = 0;\narch/s390/kvm/kvm-s390.c:646:\t\tif (hpage \u0026\u0026 !(kvm \u0026\u0026 kvm_is_ucontrol(kvm)))\narch/s390/kvm/kvm-s390.c-647-\t\t\tr = 1;\n--\narch/s390/kvm/kvm-s390.c-650-\t\tr = 0;\narch/s390/kvm/kvm-s390.c:651:\t\tif (hpage_2g \u0026\u0026 !(kvm \u0026\u0026 kvm_is_ucontrol(kvm)))\narch/s390/kvm/kvm-s390.c-652-\t\t\tr = 1;\n--\narch/s390/kvm/kvm-s390.c=746=int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,\n--\narch/s390/kvm/kvm-s390.c-753-\narch/s390/kvm/kvm-s390.c:754:\tif (kvm_is_ucontrol(kvm))\narch/s390/kvm/kvm-s390.c-755-\t\treturn -EINVAL;\n--\narch/s390/kvm/kvm-s390.c=788=int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap)\n--\narch/s390/kvm/kvm-s390.c-892-\t\t\tr = -EBUSY;\narch/s390/kvm/kvm-s390.c:893:\t\telse if (!hpage || kvm-\u003earch.use_cmma || kvm_is_ucontrol(kvm))\narch/s390/kvm/kvm-s390.c-894-\t\t\tr = -EINVAL;\n--\narch/s390/kvm/kvm-s390.c-913-\t\t\tr = -EBUSY;\narch/s390/kvm/kvm-s390.c:914:\t\t} else if (!hpage_2g || kvm-\u003earch.use_cmma || kvm_is_ucontrol(kvm)) {\narch/s390/kvm/kvm-s390.c-915-\t\t\tr = -EINVAL;\n--\narch/s390/kvm/kvm-s390.c=993=static int kvm_s390_set_mem_control(struct kvm *kvm, struct kvm_device_attr *attr)\n--\narch/s390/kvm/kvm-s390.c-1040-\narch/s390/kvm/kvm-s390.c:1041:\t\tif (kvm_is_ucontrol(kvm))\narch/s390/kvm/kvm-s390.c-1042-\t\t\treturn -EINVAL;\n--\narch/s390/kvm/kvm-s390.c=2926=int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)\n--\narch/s390/kvm/kvm-s390.c-2938-\t\tr = -EINVAL;\narch/s390/kvm/kvm-s390.c:2939:\t\tif (kvm_is_ucontrol(kvm))\narch/s390/kvm/kvm-s390.c-2940-\t\t\tbreak;\n--\narch/s390/kvm/kvm-s390.c=3405=void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu)\n--\narch/s390/kvm/kvm-s390.c-3412-\tkvm_clear_async_pf_completion_queue(vcpu);\narch/s390/kvm/kvm-s390.c:3413:\tif (!kvm_is_ucontrol(vcpu-\u003ekvm))\narch/s390/kvm/kvm-s390.c-3414-\t\tsca_del_vcpu(vcpu);\n--\narch/s390/kvm/kvm-s390.c-3416-\narch/s390/kvm/kvm-s390.c:3417:\tif (kvm_is_ucontrol(vcpu-\u003ekvm)) {\narch/s390/kvm/kvm-s390.c-3418-\t\tscoped_guard(spinlock, \u0026vcpu-\u003ekvm-\u003earch.gmap-\u003echildren_lock)\n--\narch/s390/kvm/kvm-s390.c=3605=void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)\n--\narch/s390/kvm/kvm-s390.c-3612-\tmutex_unlock(\u0026vcpu-\u003ekvm-\u003elock);\narch/s390/kvm/kvm-s390.c:3613:\tif (!kvm_is_ucontrol(vcpu-\u003ekvm)) {\narch/s390/kvm/kvm-s390.c-3614-\t\tvcpu-\u003earch.gmap = vcpu-\u003ekvm-\u003earch.gmap;\n--\narch/s390/kvm/kvm-s390.c=3709=static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)\n--\narch/s390/kvm/kvm-s390.c-3733-\t\tvcpu-\u003earch.sie_block-\u003eecb |= ECB_TE;\narch/s390/kvm/kvm-s390.c:3734:\tif (!kvm_is_ucontrol(vcpu-\u003ekvm))\narch/s390/kvm/kvm-s390.c-3735-\t\tvcpu-\u003earch.sie_block-\u003eecb |= ECB_SPECI;\n--\narch/s390/kvm/kvm-s390.c=3796=int kvm_arch_vcpu_precreate(struct kvm *kvm, unsigned int id)\narch/s390/kvm/kvm-s390.c-3797-{\narch/s390/kvm/kvm-s390.c:3798:\tif (!kvm_is_ucontrol(kvm) \u0026\u0026 !sca_can_add_vcpu(kvm, id))\narch/s390/kvm/kvm-s390.c-3799-\t\treturn -EINVAL;\n--\narch/s390/kvm/kvm-s390.c=3805=int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)\n--\narch/s390/kvm/kvm-s390.c-3857-\narch/s390/kvm/kvm-s390.c:3858:\tif (kvm_is_ucontrol(vcpu-\u003ekvm)) {\narch/s390/kvm/kvm-s390.c-3859-\t\tvcpu-\u003earch.gmap = gmap_new_child(vcpu-\u003ekvm-\u003earch.gmap, -1UL);\n--\narch/s390/kvm/kvm-s390.c-3869-\tif (rc) {\narch/s390/kvm/kvm-s390.c:3870:\t\tif (kvm_is_ucontrol(vcpu-\u003ekvm)) {\narch/s390/kvm/kvm-s390.c-3871-\t\t\tscoped_guard(spinlock, \u0026vcpu-\u003ekvm-\u003earch.gmap-\u003echildren_lock)\n--\narch/s390/kvm/kvm-s390.c=4323=static int vcpu_ucontrol_translate(struct kvm_vcpu *vcpu, gpa_t *gaddr)\n--\narch/s390/kvm/kvm-s390.c-4326-\narch/s390/kvm/kvm-s390.c:4327:\tif (kvm_is_ucontrol(vcpu-\u003ekvm)) {\narch/s390/kvm/kvm-s390.c-4328-\t\trc = gmap_ucas_translate(vcpu-\u003earch.mc, vcpu-\u003earch.gmap, gaddr);\n--\narch/s390/kvm/kvm-s390.c=4557=static int vcpu_pre_run(struct kvm_vcpu *vcpu)\n--\narch/s390/kvm/kvm-s390.c-4570-\narch/s390/kvm/kvm-s390.c:4571:\tif (!kvm_is_ucontrol(vcpu-\u003ekvm)) {\narch/s390/kvm/kvm-s390.c-4572-\t\trc = kvm_s390_deliver_pending_interrupts(vcpu);\n--\narch/s390/kvm/kvm-s390.c=5440=long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,\n--\narch/s390/kvm/kvm-s390.c-5459-\narch/s390/kvm/kvm-s390.c:5460:\t\tif (kvm_is_ucontrol(vcpu-\u003ekvm))\narch/s390/kvm/kvm-s390.c-5461-\t\t\treturn -EINVAL;\n--\narch/s390/kvm/kvm-s390.c=5529=long kvm_arch_vcpu_ioctl(struct file *filp,\n--\narch/s390/kvm/kvm-s390.c-5613-\t\tr = -EINVAL;\narch/s390/kvm/kvm-s390.c:5614:\t\tif (!kvm_is_ucontrol(vcpu-\u003ekvm))\narch/s390/kvm/kvm-s390.c-5615-\t\t\tbreak;\n--\narch/s390/kvm/kvm-s390.c-5631-\t\tr = -EINVAL;\narch/s390/kvm/kvm-s390.c:5632:\t\tif (!kvm_is_ucontrol(vcpu-\u003ekvm))\narch/s390/kvm/kvm-s390.c-5633-\t\t\tbreak;\n--\narch/s390/kvm/kvm-s390.c=5748=vm_fault_t kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)\n--\narch/s390/kvm/kvm-s390.c-5751-\tif ((vmf-\u003epgoff == KVM_S390_SIE_PAGE_OFFSET)\narch/s390/kvm/kvm-s390.c:5752:\t\t \u0026\u0026 (kvm_is_ucontrol(vcpu-\u003ekvm))) {\narch/s390/kvm/kvm-s390.c-5753-\t\tvmf-\u003epage = virt_to_page(vcpu-\u003earch.sie_block);\n--\narch/s390/kvm/kvm-s390.c=5767=int kvm_arch_prepare_memory_region(struct kvm *kvm,\n--\narch/s390/kvm/kvm-s390.c-5771-{\narch/s390/kvm/kvm-s390.c:5772:\tif (kvm_is_ucontrol(kvm) \u0026\u0026 new \u0026\u0026 new-\u003eid \u003c KVM_USER_MEM_SLOTS)\narch/s390/kvm/kvm-s390.c-5773-\t\treturn -EINVAL;\n--\narch/s390/kvm/kvm-s390.c=5901=long kvm_arch_vcpu_pre_fault_memory(struct kvm_vcpu *vcpu, struct kvm_pre_fault_memory *range)\n--\narch/s390/kvm/kvm-s390.c-5906-\narch/s390/kvm/kvm-s390.c:5907:\tif (kvm_is_ucontrol(vcpu-\u003ekvm))\narch/s390/kvm/kvm-s390.c-5908-\t\treturn -EINVAL;\n--\narch/s390/kvm/kvm-s390.h=111=static inline int is_vcpu_idle(struct kvm_vcpu *vcpu)\n--\narch/s390/kvm/kvm-s390.h-115-\narch/s390/kvm/kvm-s390.h:116:static inline int kvm_is_ucontrol(struct kvm *kvm)\narch/s390/kvm/kvm-s390.h-117-{\n"
} |
| 7/2 | 2026/08/01 19:40 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 18911 output: 43 thoughts: 52 Thoughts: Here's my thought process, summarized as you requested: **Investigating the KVM_S390_UCONTROL Configuration Option** Okay, so `KVM_S390_UCONTROL`, right, that's definitely a valid config option. Now, let's figure out its dependencies. It's time to dig into the source code to understand how it's used and what it relies on. I'll need to check the Kconfig file for the s390 architecture, specifically `arch/s390/kvm/Kconfig`. That's where I'll find the relevant configuration logic and any potential prerequisites that need to be in place for `KVM_S390_UCONTROL` to be enabled. This is the first step in understanding the implications of enabling or disabling this feature in a KVM environment on s390 hardware. Let's see what the Kconfig file reveals. |
| 8/2 | 2026/08/01 19:40 | tool | grepper |
0mArgs:{
"Expression": "config KVM_S390_UCONTROL",
"PathPrefix": "arch/s390/kvm/Kconfig"
}Results: {
"Output": "arch/s390/kvm/Kconfig=19=config KVM\n--\narch/s390/kvm/Kconfig-46-\narch/s390/kvm/Kconfig:47:config KVM_S390_UCONTROL\narch/s390/kvm/Kconfig-48-\tbool \"Userspace controlled virtual machines\"\n"
} |
| 9/2 | 2026/08/01 19:40 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 19312 output: 39 thoughts: 24 Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience: **Analyzing the KVM Kconfig for s390 Architecture** Alright, let's dive into the `arch/s390/kvm/Kconfig` file, specifically around line 47. I'm focusing on this area because... well, I suspect there's something interesting or possibly problematic there. My initial guess, given the context, is that we're likely looking at some conditional compilation or a feature flag related to KVM support on s390. Perhaps it's dealing with a new hardware feature, or an optimization. I'll be keeping an eye out for dependencies on other config options, especially those related to processor features or specific hypervisor implementations. I need to understand what this Kconfig entry *enables* or *disables* in order to see if it's impacting a current project, or for what it may relate for future design concerns. I'll need to remember the architectural specifics of s390 and how KVM integrates on that architecture to fully grasp the rationale behind that particular configuration option. I also want to assess the impact of the current config option to future designs. |
| 10/2 | 2026/08/01 19:40 | tool | read-file |
0mArgs:{
"File": "arch/s390/kvm/Kconfig",
"FirstLine": 30,
"LineCount": 30
}Results: {
"Contents": " 30:\t\tselect KVM_VFIO\n 31:\t\tselect VIRT_XFER_TO_GUEST_WORK\n 32:\t\tselect KVM_MMU_LOCKLESS_AGING\n 33:\t\tselect KVM_GENERIC_PRE_FAULT_MEMORY\n 34:\t\thelp\n 35:\t\t Support hosting paravirtualized guest machines using the SIE\n 36:\t\t virtualization capability on the mainframe. This should work\n 37:\t\t on any 64bit machine.\n 38:\t\n 39:\t\t This module provides access to the hardware capabilities through\n 40:\t\t a character device node named /dev/kvm.\n 41:\t\n 42:\t\t To compile this as a module, choose M here: the module\n 43:\t\t will be called kvm.\n 44:\t\n 45:\t\t If unsure, say N.\n 46:\t\n 47:\tconfig KVM_S390_UCONTROL\n 48:\t\tbool \"Userspace controlled virtual machines\"\n 49:\t\tdepends on KVM\n 50:\t\thelp\n 51:\t\t Allow CAP_SYS_ADMIN users to create KVM virtual machines that are\n 52:\t\t controlled by userspace.\n 53:\t\n 54:\t\t If unsure, say N.\n 55:\t\n 56:\tendif # VIRTUALIZATION\n"
} |
| 11/2 | 2026/08/01 19:40 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 19989 output: 43 thoughts: 85 Thoughts: Okay, let's break this down. **KVM Configuration Deep Dive** Alright, so I'm focusing on the KVM configuration. My initial thought is that `KVM` and `KVM_S390_UCONTROL` are the key configs involved here. Wait a second, *`KVM` itself is a tristate*. That's good; it means it’s inherently enabled or disabled based on other criteria, so as long as those are met `KVM` is not the problem and can be considered active. Now, are there any *other* related configs I need to consider? I need to make sure I haven't missed a crucial setting somewhere else. Let's delve into the code to confirm my assumptions and make sure all relevant configurations are addressed. I'll take a look at `arch/s390/kvm/pv.c` and specifically focus on the `kvm_s390_pv_create_cpu` function. That seems like a prime spot to look for dependencies or conditional logic that might be relevant to the configuration setup. I'm hoping to get a clearer picture of how these configs interact and if there's any implicit dependency that I'm overlooking. |
| 12/2 | 2026/08/01 19:40 | tool | grepper |
0mArgs:{
"Expression": "kvm_s390_pv_create_cpu",
"PathPrefix": "arch/s390/kvm/"
}Results: {
"Output": "arch/s390/kvm/kvm-s390.c=2447=static int kvm_s390_cpus_to_pv(struct kvm *kvm, u16 *rc, u16 *rrc)\n--\narch/s390/kvm/kvm-s390.c-2460-\t\tmutex_lock(\u0026vcpu-\u003emutex);\narch/s390/kvm/kvm-s390.c:2461:\t\tr = kvm_s390_pv_create_cpu(vcpu, rc, rrc);\narch/s390/kvm/kvm-s390.c-2462-\t\tmutex_unlock(\u0026vcpu-\u003emutex);\n--\narch/s390/kvm/kvm-s390.c=3709=static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)\n--\narch/s390/kvm/kvm-s390.c-3786-\tif (kvm_s390_pv_is_protected(vcpu-\u003ekvm)) {\narch/s390/kvm/kvm-s390.c:3787:\t\trc = kvm_s390_pv_create_cpu(vcpu, \u0026uvrc, \u0026uvrrc);\narch/s390/kvm/kvm-s390.c-3788-\t\tif (rc)\n--\narch/s390/kvm/kvm-s390.h=305=int kvm_s390_pv_destroy_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc);\narch/s390/kvm/kvm-s390.h:306:int kvm_s390_pv_create_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc);\narch/s390/kvm/kvm-s390.h-307-int kvm_s390_pv_set_aside(struct kvm *kvm, u16 *rc, u16 *rrc);\n--\narch/s390/kvm/pv.c=265=int kvm_s390_pv_destroy_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc)\n--\narch/s390/kvm/pv.c-283-\narch/s390/kvm/pv.c:284:int kvm_s390_pv_create_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc)\narch/s390/kvm/pv.c-285-{\n"
} |
| 13/2 | 2026/08/01 19:41 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 21114 output: 34 thoughts: 26 Thoughts: Here's a summary of my thought process: **Investigating Conditional Compilation of `pv.c`** Okay, so I'm wondering about `pv.c` and whether it's compiled conditionally. My first instinct is to dig into the `Makefile` within the architecture-specific kernel directory. Specifically, I'm thinking the `arch/s390/kvm/Makefile` file is where the build process for KVM on s390 is defined. That's the logical place to start looking for any conditional compilation flags or rules related to this particular source file. Time to open that up and see what's what. |
| 14/2 | 2026/08/01 19:41 | tool | grepper |
0mArgs:{
"Expression": "pv\\.o",
"PathPrefix": "arch/s390/kvm/Makefile"
}Results: {
"Output": "arch/s390/kvm/Makefile=10=kvm-y += kvm-s390.o intercept.o interrupt.o priv.o sigp.o\narch/s390/kvm/Makefile:11:kvm-y += diag.o gaccess.o guestdbg.o vsie.o pv.o\narch/s390/kvm/Makefile-12-kvm-y += dat.o gmap.o faultin.o\n"
} |
| 15/2 | 2026/08/01 19:41 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 21437 output: 40 thoughts: 333 Thoughts: **Analyzing KVM-S390 Compilation and Key Symbols** Okay, so I'm thinking about the KVM-S390 code and how it's compiled. Right now, it looks like `pv.o`, `dat.c`, `faultin.c`, `interrupt.c`, `kvm-s390.c`, and `priv.c` are always compiled when `KVM` is enabled. That's a good starting point. I need to keep that in mind. My attention then moves to the relevant configuration symbols. I need to understand which ones are key here, so I'm noting these down as potential areas of investigation: `KVM` and `KVM_S390_UCONTROL`. I'm going to quickly review the key symbols associated with the code. Let's see... I've identified: `kvm_arch_vcpu_ioctl_run`, `kvm_arch_vcpu_ioctl`, `kvm_arch_vm_ioctl`, `kvm_s390_vm_set_migration`, `kvm_arch_commit_memory_region`, `kvm_s390_pv_create_cpu`, `kvm_s390_pv_destroy_cpu`, `dat_reset_reference_bit`, `handle_rrbe`, and `handle_essa`. Hold on, I see a connection here! `dat_reset_reference_bit` is called from `handle_rrbe` and `kvm_s390_keyop`. `handle_rrbe` is definitely an instruction handler, which is interesting. Now, I need to understand the relationship with `kvm_s390_keyop`. Is it called from `kvm_s390_guest_skey_op`? I should probably check that, or something very similar. That's the next logical step. |
| 16/2 | 2026/08/01 19:41 | tool | grepper |
0mArgs:{
"Expression": "kvm_s390_keyop",
"PathPrefix": "arch/s390/kvm/"
}Results: {
"Output": "arch/s390/kvm/kvm-s390.c=550=static void __kvm_s390_exit(void)\n--\narch/s390/kvm/kvm-s390.c-561-\narch/s390/kvm/kvm-s390.c:562:static int kvm_s390_keyop(struct kvm_s390_mmu_cache *mc, struct kvm *kvm, int op,\narch/s390/kvm/kvm-s390.c-563-\t\t\t unsigned long addr, union skey skey)\n--\narch/s390/kvm/kvm-s390.c=2926=int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)\n--\narch/s390/kvm/kvm-s390.c-3061-\t\tstruct kvm_s390_mmu_cache *mc;\narch/s390/kvm/kvm-s390.c:3062:\t\tstruct kvm_s390_keyop kop;\narch/s390/kvm/kvm-s390.c-3063-\t\tunion skey skey;\n--\narch/s390/kvm/kvm-s390.c-3074-\narch/s390/kvm/kvm-s390.c:3075:\t\tr = kvm_s390_keyop(mc, kvm, kop.operation, kop.guest_addr, skey);\narch/s390/kvm/kvm-s390.c-3076-\t\tkvm_s390_free_mmu_cache(mc);\n"
} |
| 17/2 | 2026/08/01 19:41 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 22708 output: 48 thoughts: 145 Thoughts: **Investigating the KVM_S390_KEYOP Mystery** Okay, so I see that `kvm_s390_keyop` is being called from `kvm_arch_vm_ioctl`, specifically when handling `KVM_S390_KEYOP`. My spidey-sense is tingling – `KVM_S390_KEYOP` doesn't sound familiar, and that's not good. It's not a standard ioctl. Let's dig deeper. Ah, right, `kvm_s390_keyop` is a *static* function. That's a clue. Hmm, could this be a typo? Perhaps the intended ioctl is `KVM_S390_ZPCI_OP`? No, wait, that doesn't seem right. `KVM_S390_KEYOP` still doesn't exist, I need to check `kvm_arch_vm_ioctl` again, around line 3075 to see what's happening. |
| 18/2 | 2026/08/01 19:41 | tool | read-file |
0mArgs:{
"File": "arch/s390/kvm/kvm-s390.c",
"FirstLine": 3050,
"LineCount": 30
}Results: {
"Contents": "3050:\t\t}\n3051:\t\tcase KVM_S390_MEM_OP: {\n3052:\t\t\tstruct kvm_s390_mem_op mem_op;\n3053:\t\n3054:\t\t\tif (copy_from_user(\u0026mem_op, argp, sizeof(mem_op)) == 0)\n3055:\t\t\t\tr = kvm_s390_vm_mem_op(kvm, \u0026mem_op);\n3056:\t\t\telse\n3057:\t\t\t\tr = -EFAULT;\n3058:\t\t\tbreak;\n3059:\t\t}\n3060:\t\tcase KVM_S390_KEYOP: {\n3061:\t\t\tstruct kvm_s390_mmu_cache *mc;\n3062:\t\t\tstruct kvm_s390_keyop kop;\n3063:\t\t\tunion skey skey;\n3064:\t\n3065:\t\t\tif (copy_from_user(\u0026kop, argp, sizeof(kop))) {\n3066:\t\t\t\tr = -EFAULT;\n3067:\t\t\t\tbreak;\n3068:\t\t\t}\n3069:\t\t\tskey.skey = kop.key;\n3070:\t\n3071:\t\t\tmc = kvm_s390_new_mmu_cache();\n3072:\t\t\tif (!mc)\n3073:\t\t\t\treturn -ENOMEM;\n3074:\t\n3075:\t\t\tr = kvm_s390_keyop(mc, kvm, kop.operation, kop.guest_addr, skey);\n3076:\t\t\tkvm_s390_free_mmu_cache(mc);\n3077:\t\t\tif (r \u003c 0)\n3078:\t\t\t\tbreak;\n3079:\t\n"
} |
| 19/2 | 2026/08/01 19:41 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 23613 output: 43 thoughts: 388 Thoughts: **My Analysis of KVM_S390_KEYOP and Associated Functions** Okay, so `KVM_S390_KEYOP` is indeed an ioctl, as I suspected. Now, I need to identify the relevant functions to focus on. Let's see... I've got: * `kvm_arch_vm_ioctl` * `kvm_arch_vcpu_ioctl` * `kvm_arch_vcpu_ioctl_run` * `kvm_s390_vm_set_migration` * `kvm_arch_commit_memory_region` * `kvm_s390_pv_create_cpu` * `kvm_s390_pv_destroy_cpu` * `handle_rrbe` * `handle_essa` Wait a minute, the prompt *specifically* warns against focusing on generic hot-path functions to avoid biasing the test distribution. That means I need to avoid `kvm_arch_vcpu_ioctl_run`. It's a key function in KVM, but it's *very* frequently called. Now, what about `kvm_arch_vcpu_ioctl` and `kvm_arch_vm_ioctl`? Hmm, they're more generic, but they're the entry points for ioctls that have been modified. They're probably worth looking at. Ah, and `kvm_s390_vm_set_migration`. Now where is that called from? I thought it might be something like `kvm_vm_ioctl_set_extension`, but I don't think that's right... Is it from `kvm_arch_vm_ioctl` via `KVM_S390_VM_MIGRATION_START`? No, wait... it's `kvm_s390_vm_set_migration` that calls it. And what's calling *that*? Is it `kvm_s390_set_mem_control`, or something similar? I should probably double-check the call chain for `kvm_s390_vm_set_migration` to make sure I understand its context. |
| 20/2 | 2026/08/01 19:41 | tool | grepper |
0mArgs:{
"Expression": "kvm_s390_vm_set_migration",
"PathPrefix": "arch/s390/kvm/"
}Results: {
"Output": "arch/s390/kvm/kvm-s390.c=1271=static int kvm_s390_vm_stop_migration(struct kvm *kvm)\n--\narch/s390/kvm/kvm-s390.c-1297-\narch/s390/kvm/kvm-s390.c:1298:static int kvm_s390_vm_set_migration(struct kvm *kvm,\narch/s390/kvm/kvm-s390.c-1299-\t\t\t\t struct kvm_device_attr *attr)\n--\narch/s390/kvm/kvm-s390.c=2044=static int kvm_s390_vm_set_attr(struct kvm *kvm, struct kvm_device_attr *attr)\n--\narch/s390/kvm/kvm-s390.c-2061-\tcase KVM_S390_VM_MIGRATION:\narch/s390/kvm/kvm-s390.c:2062:\t\tret = kvm_s390_vm_set_migration(kvm, attr);\narch/s390/kvm/kvm-s390.c-2063-\t\tbreak;\n"
} |
| 21/2 | 2026/08/01 19:41 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 24901 output: 37 thoughts: 565 Thoughts: **Identifying Key KVM/s390 Entry Points** Okay, let's see. My primary goal here is to identify the most significant entry points into the KVM/s390 architecture. I'm focusing on non-static, non-inlined functions as the preferred candidates, since those represent well-defined API boundaries. So, *`kvm_s390_vm_set_migration`* is triggered by *`kvm_s390_vm_set_attr`*, which itself is a consequence of *`KVM_SET_DEVICE_ATTR`* from the VM. That definitely seems like a strong point of focus. It's a nice, clean call chain to represent. I've got that one. Now, what about the CMMA bits functions? *`kvm_s390_get_cmma_bits`* and *`kvm_s390_set_cmma_bits`* are called via *`kvm_arch_vm_ioctl`*, in response to the *`KVM_S390_GET_CMMA_BITS`* and *`KVM_S390_SET_CMMA_BITS`* ioctls, respectively. I think I'll add *`kvm_arch_vm_ioctl`* as a focus symbol, since those are how the user interacts with them. I like *`kvm_s390_pv_create_cpu`* and *`kvm_s390_pv_destroy_cpu`*. These seem like good entry points related to CPU lifecycle management, so I'll add those. Next, I need to consider `handle_rrbe` and `handle_essa`. These are instruction handlers for RRBE and ESSA instructions, respectively. I need to be careful with them, since they are static. But, given their role in instruction handling, I'm going to check. Okay, let's step back and consider the instruction handlers. They *are* called internally when the guest executes specific instructions. Should they be included? Now, the instructions indicate a preference for non-static, non-inlined API entrypoints. That helps focus my attention on interfaces which are more likely to be stable API. I see that `kvm_s390_keyop` is static, but is called from `kvm_arch_vm_ioctl`. I want to avoid adding static or inlined functions. Given the guidance to avoid static functions where possible, I am going to try to include `kvm_arch_vm_ioctl` in the list, instead. Reviewing what I know so far, the most appropriate focus symbols should be: - `kvm_arch_vm_ioctl` - `kvm_arch_vcpu_ioctl` - `kvm_arch_commit_memory_region` - `kvm_s390_pv_create_cpu` - `kvm_s390_pv_destroy_cpu` I will add these to my list. |
| 22/2 | 2026/08/01 19:41 | tool | grepper |
0mArgs:{
"Expression": "handle_rrbe",
"PathPrefix": "arch/s390/kvm/priv.c"
}Results: {
"Output": "arch/s390/kvm/priv.c=257=static int handle_iske(struct kvm_vcpu *vcpu)\n--\narch/s390/kvm/priv.c-288-\narch/s390/kvm/priv.c:289:static int handle_rrbe(struct kvm_vcpu *vcpu)\narch/s390/kvm/priv.c-290-{\n--\narch/s390/kvm/priv.c=959=int kvm_s390_handle_b2(struct kvm_vcpu *vcpu)\n--\narch/s390/kvm/priv.c-979-\tcase 0x2a:\narch/s390/kvm/priv.c:980:\t\treturn handle_rrbe(vcpu);\narch/s390/kvm/priv.c-981-\tcase 0x2b:\n"
} |
| 23/2 | 2026/08/01 19:41 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 26433 output: 36 thoughts: 122 Thoughts: **Analyzing KVM/s390 Handler Functions** Okay, so I'm looking at these functions, `kvm_s390_handle_b2` and `kvm_s390_handle_b9`, and I'm guessing they're called from those switch statements within the KVM/s390 code. The fact that they're probably not inlined makes sense, given they're pretty hefty and get called from a large switch, which suggests a performance-focused design. Just to be thorough, I'll add `kvm_s390_handle_b2` and `kvm_s390_handle_b9` to ensure that it has covered everything. Wait, hang on... `kvm_s390_handle_b2` is non-static, which is interesting. I'll need to dig into `handle_essa` to see why it's structured this way, what other implications this design choice has, and what the overall impact is. |
| 24/2 | 2026/08/01 19:41 | tool | grepper |
0mArgs:{
"Expression": "handle_essa",
"PathPrefix": "arch/s390/kvm/priv.c"
}Results: {
"Output": "arch/s390/kvm/priv.c=1191=static void _essa_clear_cbrl(struct kvm_vcpu *vcpu, unsigned long *cbrl, int len)\n--\narch/s390/kvm/priv.c-1216-\narch/s390/kvm/priv.c:1217:static int handle_essa(struct kvm_vcpu *vcpu)\narch/s390/kvm/priv.c-1218-{\n--\narch/s390/kvm/priv.c=1284=int kvm_s390_handle_b9(struct kvm_vcpu *vcpu)\n--\narch/s390/kvm/priv.c-1293-\tcase 0xab:\narch/s390/kvm/priv.c:1294:\t\treturn handle_essa(vcpu);\narch/s390/kvm/priv.c-1295-\tcase 0xaf:\n"
} |
| 25/2 | 2026/08/01 19:41 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 27087 output: 44 thoughts: 82 Thoughts: Here's my thought process, as if I were considering this code: **Analyzing `kvm_s390_handle_b9` and Related Functions** Okay, I see that `kvm_s390_handle_b9` *isn't* declared as static. Good, that's what I expected. Now, I should probably understand how this function interacts with the other components in the S390 KVM implementation. I should check `kvm_s390_get_cmma_bits` and `kvm_s390_set_cmma_bits` next to see if there are any interesting interactions. I know they're probably defined within `kvm-s390.c`, but I need to quickly confirm whether they're declared as `static`. That might provide some useful information about their intended scope and usage. I'll take a quick look at the file. |
| 26/2 | 2026/08/01 19:41 | tool | grepper |
0mArgs:{
"Expression": "kvm_s390_get_cmma_bits",
"PathPrefix": "arch/s390/kvm/"
}Results: {
"Output": "arch/s390/kvm/kvm-s390.c=1211=static void kvm_s390_sync_request_broadcast(struct kvm *kvm, int req)\n--\narch/s390/kvm/kvm-s390.c-1222- * kvm-\u003eslots_arch_lock to avoid races with ourselves,\narch/s390/kvm/kvm-s390.c:1223: * kvm_s390_vm_stop_migration(), and kvm_s390_get_cmma_bits().\narch/s390/kvm/kvm-s390.c-1224- */\narch/s390/kvm/kvm-s390.c=1225=static int kvm_s390_vm_start_migration(struct kvm *kvm)\n--\narch/s390/kvm/kvm-s390.c-1268- * Must be called with kvm-\u003eslots_arch_lock to avoid races with ourselves,\narch/s390/kvm/kvm-s390.c:1269: * kvm_s390_vm_start_migration() and kvm_s390_get_cmma_bits().\narch/s390/kvm/kvm-s390.c-1270- */\n--\narch/s390/kvm/kvm-s390.c=2221=static int kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)\n--\narch/s390/kvm/kvm-s390.c-2290- */\narch/s390/kvm/kvm-s390.c:2291:static int kvm_s390_get_cmma_bits(struct kvm *kvm,\narch/s390/kvm/kvm-s390.c-2292-\t\t\t\t struct kvm_s390_cmma_log *args)\n--\narch/s390/kvm/kvm-s390.c=2926=int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)\n--\narch/s390/kvm/kvm-s390.c-3005-\t\tscoped_guard(mutex, \u0026kvm-\u003eslots_arch_lock)\narch/s390/kvm/kvm-s390.c:3006:\t\t\tr = kvm_s390_get_cmma_bits(kvm, \u0026args);\narch/s390/kvm/kvm-s390.c-3007-\t\tif (!r) {\n"
} |
| 27/2 | 2026/08/01 19:41 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 28154 output: 40 thoughts: 86 Thoughts: Okay, let's see, my thinking goes like this: **Addressing Static Function Calls in KVM/s390 Architecture** Alright, so I'm looking at `kvm_s390_get_cmma_bits`. The first thing that jumps out is that it's static. That's not ideal for what I'm trying to achieve. I think I'll use `kvm_arch_vm_ioctl` instead; that seems like a more appropriate entry point. Now, moving on, I need to address the other static functions in `interrupt.c`: `sca_ext_call_pending`, `sca_inject_ext_call`, and `sca_clear_ext_call`. They're *also* static, which means I can't just call them directly. I need to understand their context. I'll need to figure out where those functions are actually *being* called from within the codebase. Time to start digging for call sites. |
| 28/2 | 2026/08/01 19:41 | tool | grepper |
0mArgs:{
"Expression": "sca_inject_ext_call",
"PathPrefix": "arch/s390/kvm/interrupt.c"
}Results: {
"Output": "arch/s390/kvm/interrupt.c=45=static int sca_ext_call_pending(struct kvm_vcpu *vcpu, int *src_id)\n--\narch/s390/kvm/interrupt.c-63-\narch/s390/kvm/interrupt.c:64:static int sca_inject_ext_call(struct kvm_vcpu *vcpu, int src_id)\narch/s390/kvm/interrupt.c-65-{\n--\narch/s390/kvm/interrupt.c=1507=static int __inject_extcall(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)\n--\narch/s390/kvm/interrupt.c-1523-\tif (kvm_s390_use_sca_entries() \u0026\u0026 !kvm_s390_pv_cpu_get_handle(vcpu))\narch/s390/kvm/interrupt.c:1524:\t\treturn sca_inject_ext_call(vcpu, src_id);\narch/s390/kvm/interrupt.c-1525-\n"
} |
| 29/2 | 2026/08/01 19:41 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 28805 output: 38 thoughts: 25 Thoughts: Here's my take on the thought process, summarized as you requested: **Deconstructing `__inject_extcall`** Okay, so `__inject_extcall` is a static function. That immediately tells me it's likely internal to a specific compilation unit and probably not exported for general use. My next step is obvious: I need to trace its usage. I'm going to find all the places in the codebase where `__inject_extcall` is actually *called*. Understanding its call sites will give me crucial context about its purpose, the data it's operating on, and how it fits into the broader architecture. This is where the real work begins. |
| 30/2 | 2026/08/01 19:41 | tool | grepper |
0mArgs:{
"Expression": "__inject_extcall",
"PathPrefix": "arch/s390/kvm/interrupt.c"
}Results: {
"Output": "arch/s390/kvm/interrupt.c=1490=static int __inject_pfault_init(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)\n--\narch/s390/kvm/interrupt.c-1506-\narch/s390/kvm/interrupt.c:1507:static int __inject_extcall(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)\narch/s390/kvm/interrupt.c-1508-{\n--\narch/s390/kvm/interrupt.c=2105=static int do_inject_vcpu(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)\n--\narch/s390/kvm/interrupt.c-2128-\tcase KVM_S390_INT_EXTERNAL_CALL:\narch/s390/kvm/interrupt.c:2129:\t\trc = __inject_extcall(vcpu, irq);\narch/s390/kvm/interrupt.c-2130-\t\tbreak;\n"
} |
| 31/2 | 2026/08/01 19:41 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 29324 output: 39 thoughts: 27 Thoughts: Okay, here's my take on those thoughts, framed as an expert's internal monologue: **Investigating the `do_inject_vcpu` Function** Right, `do_inject_vcpu`. That's a static function, which means its scope is limited to the current compilation unit. That immediately piques my interest. Static functions can sometimes be tricky to trace, especially in a large codebase, because you need to know exactly where it *is* used. So, the first thing I need to do is identify all the call sites for `do_inject_vcpu`. Understanding its callers is absolutely critical for figuring out its purpose and, potentially, any issues that might be present. Let's see where this one pops up. A quick search should give me the answer. |
| 32/2 | 2026/08/01 19:41 | tool | grepper |
0mArgs:{
"Expression": "do_inject_vcpu",
"PathPrefix": "arch/s390/kvm/interrupt.c"
}Results: {
"Output": "arch/s390/kvm/interrupt.c=2095=void kvm_s390_clear_stop_irq(struct kvm_vcpu *vcpu)\n--\narch/s390/kvm/interrupt.c-2104-\narch/s390/kvm/interrupt.c:2105:static int do_inject_vcpu(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)\narch/s390/kvm/interrupt.c-2106-{\n--\narch/s390/kvm/interrupt.c=2150=int kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)\n--\narch/s390/kvm/interrupt.c-2155-\tspin_lock(\u0026li-\u003elock);\narch/s390/kvm/interrupt.c:2156:\trc = do_inject_vcpu(vcpu, irq);\narch/s390/kvm/interrupt.c-2157-\tspin_unlock(\u0026li-\u003elock);\n--\narch/s390/kvm/interrupt.c=3169=int kvm_s390_set_irq_state(struct kvm_vcpu *vcpu, void __user *irqstate, int len)\n--\narch/s390/kvm/interrupt.c-3195-\tfor (n = 0; n \u003c len / sizeof(*buf); n++) {\narch/s390/kvm/interrupt.c:3196:\t\tr = do_inject_vcpu(vcpu, \u0026buf[n]);\narch/s390/kvm/interrupt.c-3197-\t\tif (r)\n"
} |
| 33/2 | 2026/08/01 19:41 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 30030 output: 43 thoughts: 299 Thoughts: **My Initial Focus for Exploration** Okay, so I'm thinking about how to best navigate this code. I notice `kvm_s390_inject_vcpu` and `kvm_s390_set_irq_state` aren't static, which immediately makes them interesting entry points. `kvm_s390_inject_vcpu` in particular looks like a promising focus symbol. Let's see... I'll check out `kvm_arch_vcpu_ioctl` and `kvm_arch_vm_ioctl`; those are usually good spots to start digging. Right, let's assemble a list of focus symbols, a set of key functions that can provide an overview of the subsystem: - `kvm_arch_vm_ioctl` - `kvm_arch_vcpu_ioctl` - `kvm_arch_commit_memory_region` - `kvm_s390_pv_create_cpu` - `kvm_s390_pv_destroy_cpu` - `kvm_s390_handle_b2` - `kvm_s390_handle_b9` - `kvm_s390_inject_vcpu` Ah, here's a wrinkle. `kvm_s390_vm_set_migration` is static. That's not ideal, but it's called from `kvm_s390_vm_set_attr`. Okay, I can use that then, `kvm_s390_vm_set_attr` is the path. I'll take a look at that one. |
| 34/2 | 2026/08/01 19:41 | tool | grepper |
0mArgs:{
"Expression": "kvm_s390_vm_set_attr",
"PathPrefix": "arch/s390/kvm/"
}Results: {
"Output": "arch/s390/kvm/kvm-s390.c=2031=static int kvm_s390_get_topo_change_indication(struct kvm *kvm,\n--\narch/s390/kvm/kvm-s390.c-2043-\narch/s390/kvm/kvm-s390.c:2044:static int kvm_s390_vm_set_attr(struct kvm *kvm, struct kvm_device_attr *attr)\narch/s390/kvm/kvm-s390.c-2045-{\n--\narch/s390/kvm/kvm-s390.c=2926=int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)\n--\narch/s390/kvm/kvm-s390.c-2961-\t\t\tbreak;\narch/s390/kvm/kvm-s390.c:2962:\t\tr = kvm_s390_vm_set_attr(kvm, \u0026attr);\narch/s390/kvm/kvm-s390.c-2963-\t\tbreak;\n"
} |
| 35/2 | 2026/08/01 19:41 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 31091 output: 43 thoughts: 61 Thoughts: Here's my summary, as though I'm thinking through this process: **Analyzing the KVM Code Path** Okay, so I'm looking at this code and trying to understand its behavior. The first thing I notice is that it's static. That immediately tells me it has a limited scope, likely internal to a specific function or file. And the call site is `kvm_arch_vm_ioctl`. That suggests that `kvm_arch_vm_ioctl` is the primary entry point or controlling function for this bit of code. So, the scope is neatly contained within the broader `kvm_arch_vm_ioctl` context. Now, let's switch gears and check out `kvm_s390_faultin_gfn`. Aha! This one is *not* static, which opens up more possibilities for its usage. This means it could be called from various locations within the KVM code. This non-static nature warrants further investigation to trace all possible execution paths. |
| 36/2 | 2026/08/01 19:42 | tool | grepper |
0mArgs:{
"Expression": "kvm_s390_faultin_gfn",
"PathPrefix": "arch/s390/kvm/"
}Results: {
"Output": "arch/s390/kvm/faultin.c=15=bool kvm_arch_setup_async_pf(struct kvm_vcpu *vcpu);\n--\narch/s390/kvm/faultin.c-17-/*\narch/s390/kvm/faultin.c:18: * kvm_s390_faultin_gfn() - handle a dat fault.\narch/s390/kvm/faultin.c-19- * @vcpu: The vCPU whose gmap is to be fixed up, or NULL if operating on the VM.\n--\narch/s390/kvm/faultin.c-32- */\narch/s390/kvm/faultin.c:33:int kvm_s390_faultin_gfn(struct kvm_vcpu *vcpu, struct kvm *kvm, struct guest_fault *f)\narch/s390/kvm/faultin.c-34-{\n--\narch/s390/kvm/faultin.h-15-\narch/s390/kvm/faultin.h:16:int kvm_s390_faultin_gfn(struct kvm_vcpu *vcpu, struct kvm *kvm, struct guest_fault *f);\narch/s390/kvm/faultin.h-17-int kvm_s390_get_guest_page(struct kvm *kvm, struct guest_fault *f, gfn_t gfn, bool w);\narch/s390/kvm/faultin.h-18-\narch/s390/kvm/faultin.h:19:static inline int kvm_s390_faultin_gfn_simple(struct kvm_vcpu *vcpu, struct kvm *kvm,\narch/s390/kvm/faultin.h-20-\t\t\t\t\t gfn_t gfn, bool wr)\n--\narch/s390/kvm/faultin.h-23-\narch/s390/kvm/faultin.h:24:\treturn kvm_s390_faultin_gfn(vcpu, kvm, \u0026f);\narch/s390/kvm/faultin.h-25-}\n--\narch/s390/kvm/gaccess.c=882=static int access_guest_page_with_key_gpa(struct kvm *kvm, enum gacc_mode mode, gpa_t gpa,\n--\narch/s390/kvm/gaccess.c-902-\narch/s390/kvm/gaccess.c:903:\trc = kvm_s390_faultin_gfn(NULL, kvm, \u0026fault);\narch/s390/kvm/gaccess.c-904-\tif (rc)\n--\narch/s390/kvm/gaccess.c=1137=int cmpxchg_guest_abs_with_key(struct kvm *kvm, gpa_t gpa, int len, union kvm_s390_quad *old,\n--\narch/s390/kvm/gaccess.c-1159-\narch/s390/kvm/gaccess.c:1160:\trc = kvm_s390_faultin_gfn(NULL, kvm, \u0026fault);\narch/s390/kvm/gaccess.c-1161-\tif (rc)\n--\narch/s390/kvm/intercept.c=359=static int handle_mvpg_pei(struct kvm_vcpu *vcpu)\n--\narch/s390/kvm/intercept.c-372-\tdo {\narch/s390/kvm/intercept.c:373:\t\trc = kvm_s390_faultin_gfn_simple(vcpu, NULL, gpa_to_gfn(srcaddr), false);\narch/s390/kvm/intercept.c-374-\t} while (rc == -EAGAIN);\n--\narch/s390/kvm/intercept.c-384-\tdo {\narch/s390/kvm/intercept.c:385:\t\trc = kvm_s390_faultin_gfn_simple(vcpu, NULL, gpa_to_gfn(dstaddr), true);\narch/s390/kvm/intercept.c-386-\t} while (rc == -EAGAIN);\n--\narch/s390/kvm/kvm-s390.c=4339=static int kvm_s390_fixup_prefix(struct kvm_vcpu *vcpu)\n--\narch/s390/kvm/kvm-s390.c-4348-\narch/s390/kvm/kvm-s390.c:4349:\trc = kvm_s390_faultin_gfn_simple(vcpu, NULL, gfn, true);\narch/s390/kvm/kvm-s390.c-4350-\tif (rc)\narch/s390/kvm/kvm-s390.c-4351-\t\treturn rc;\narch/s390/kvm/kvm-s390.c:4352:\trc = kvm_s390_faultin_gfn_simple(vcpu, NULL, gfn + 1, true);\narch/s390/kvm/kvm-s390.c-4353-\tif (rc)\n--\narch/s390/kvm/kvm-s390.c=4640=static int vcpu_dat_fault_handler(struct kvm_vcpu *vcpu, gpa_t gaddr, bool wr)\n--\narch/s390/kvm/kvm-s390.c-4651-\narch/s390/kvm/kvm-s390.c:4652:\trc = kvm_s390_faultin_gfn(vcpu, NULL, \u0026f);\narch/s390/kvm/kvm-s390.c-4653-\tif (rc \u003c= 0)\n--\narch/s390/kvm/kvm-s390.c=5529=long kvm_arch_vcpu_ioctl(struct file *filp,\n--\narch/s390/kvm/kvm-s390.c-5650-\narch/s390/kvm/kvm-s390.c:5651:\t\t\tr = kvm_s390_faultin_gfn_simple(vcpu, NULL, gpa_to_gfn(gaddr), false);\narch/s390/kvm/kvm-s390.c-5652-\t\t\tif (r == PGM_ADDRESSING)\n--\narch/s390/kvm/kvm-s390.c=5901=long kvm_arch_vcpu_pre_fault_memory(struct kvm_vcpu *vcpu, struct kvm_pre_fault_memory *range)\n--\narch/s390/kvm/kvm-s390.c-5909-\narch/s390/kvm/kvm-s390.c:5910:\trc = kvm_s390_faultin_gfn(vcpu, NULL, \u0026f);\narch/s390/kvm/kvm-s390.c-5911-\tif (rc == PGM_ADDRESSING)\n--\narch/s390/kvm/pv.c=147=int kvm_s390_pv_make_secure(struct kvm *kvm, unsigned long gaddr, void *uvcb)\n--\narch/s390/kvm/pv.c-162-\tscoped_guard(mutex, \u0026kvm-\u003earch.pv.import_lock) {\narch/s390/kvm/pv.c:163:\t\trc = kvm_s390_faultin_gfn(NULL, kvm, \u0026f);\narch/s390/kvm/pv.c-164-\n--\narch/s390/kvm/pv.c=791=static int unpack_one(struct kvm *kvm, unsigned long addr, u64 tweak,\n--\narch/s390/kvm/pv.c-807-\tif (ret == -ENXIO) {\narch/s390/kvm/pv.c:808:\t\tret = kvm_s390_faultin_gfn_simple(NULL, kvm, gpa_to_gfn(addr), true);\narch/s390/kvm/pv.c-809-\t\tif (!ret)\n"
} |
| 37/2 | 2026/08/01 19:42 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 33688 output: 42 thoughts: 1976 Thoughts: **KVM/s390 Code Review and Fuzzing Strategy** Okay, so I've been digging into these KVM/s390 changes, and my initial thoughts are that they are pretty solid. `kvm_s390_faultin_gfn` is a good starting point for a deeper dive, as it's called from quite a few places, like `kvm_arch_vcpu_ioctl` and `kvm_arch_vcpu_pre_fault_memory`. I started with a list of focus symbols, but I've narrowed it down: * `kvm_arch_vm_ioctl` * `kvm_arch_vcpu_ioctl` * `kvm_arch_vcpu_unlocked_ioctl` * `kvm_arch_commit_memory_region` * `kvm_s390_pv_create_cpu` * `kvm_s390_pv_destroy_cpu` * `kvm_s390_handle_b2` * `kvm_s390_handle_b9` * `kvm_s390_inject_vcpu` * `kvm_s390_faultin_gfn` I realized `kvm_s390_handle_b2` and `kvm_s390_handle_b9` are instruction handlers, called from `kvm_handle_sie_intercept`, which is called from `kvm_arch_vcpu_ioctl_run`. So, I'll focus on them. I then looked at `kvm_s390_vm_set_migration`. I can use `kvm_s390_vm_set_attr` or just `kvm_arch_vm_ioctl` since it is static. `kvm_arch_vm_ioctl` seems fine. For configuration, I noted `KVM` and `KVM_S390_UCONTROL`. I should probably check that `KVM_S390_UCONTROL` depends on `KVM`. I don't see any other s390-specific configs in the `Kconfig`. Now, reviewing the changes, there are several key areas: * **`dat_reset_reference_bit`:** Its signature changed to include `union skey *skey`. It's called from `handle_rrbe` and `kvm_s390_keyop`, where `handle_rrbe` is called from `kvm_s390_handle_b2` and `kvm_s390_keyop` is called from `kvm_arch_vm_ioctl`. * **`kvm_s390_faultin_gfn`:** The change in `kvm_s390_faultin_gfn` now returns `-EINTR` instead of `-EAGAIN` when a fatal signal is pending. This is worth checking in detail. * **`sca_ext_call_pending`, `sca_inject_ext_call`, `sca_clear_ext_call`:** Added `kvm_is_ucontrol(vcpu->kvm)` checks. Called from `kvm_s390_inject_vcpu` and `kvm_s390_clear_stop_irq`. * **`kvm_s390_vm_set_migration`:** Uses `srcu` and `slots_arch_lock`. Reachable through `kvm_arch_vm_ioctl` via `kvm_s390_vm_set_attr`. * **`kvm_arch_vm_ioctl`:** Added `kvm_is_ucontrol(kvm)` checks for the `KVM_S390_INTERRUPT` case. * **`kvm_arch_vcpu_postcreate`:** Implements `smp_store_release(&vcpu->arch.initialized, true)` * **`kvm_arch_vcpu_create`:** Refactored for memory leak fixes. * **`kvm_arch_vcpu_ioctl_run`:** Checks for `smp_load_acquire(&vcpu->arch.initialized)` before running. * **`kvm_arch_vcpu_unlocked_ioctl`:** Added `kvm_is_ucontrol(vcpu->kvm)` checks. * **`kvm_arch_vcpu_ioctl`:** Same |
| 38/2 | 2026/08/01 19:42 | tool | grepper |
0mArgs:{
"Expression": "kvm_arch_vcpu_unlocked_ioctl",
"PathPrefix": "arch/s390/kvm/"
}Results: {
"Output": "arch/s390/kvm/kvm-s390.c=5415=static long kvm_s390_vcpu_memsida_op(struct kvm_vcpu *vcpu,\n--\narch/s390/kvm/kvm-s390.c-5439-\narch/s390/kvm/kvm-s390.c:5440:long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,\narch/s390/kvm/kvm-s390.c-5441-\t\t\t\t unsigned long arg)\n"
} |
| 39/2 | 2026/08/01 19:42 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 36909 output: 32 thoughts: 156 Thoughts: **Tracing the Function Call Path** Okay, so I'm looking at `kvm_arch_vcpu_unlocked_ioctl`. Yes, that's definitely a function within `kvm-s390.c`. Now, the important question is how it's being invoked. Is it directly called from `kvm_vcpu_ioctl`? No, no, no. `kvm_vcpu_ioctl` is in `kvm_main.c` under `virt/kvm`, I should know this. *That* function calls `kvm_arch_vcpu_ioctl` instead. But is `kvm_arch_vcpu_unlocked_ioctl` called from there? I need to double-check this. I'll quickly look in `kvm_main.c` or perhaps `kvm_host.h` for the precise call chain. Need to verify that relationship now. |
| 40/2 | 2026/08/01 19:42 | tool | grepper |
0mArgs:{
"Expression": "kvm_arch_vcpu_unlocked_ioctl",
"PathPrefix": ""
}Results: {
"Output": "arch/arm64/kvm/arm.c=1824=long kvm_arch_vcpu_ioctl(struct file *filp,\n--\narch/arm64/kvm/arm.c-1958-\narch/arm64/kvm/arm.c:1959:long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,\narch/arm64/kvm/arm.c-1960-\t\t\t\t unsigned long arg)\n--\narch/loongarch/kvm/vcpu.c=1460=int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq)\n--\narch/loongarch/kvm/vcpu.c-1484-\narch/loongarch/kvm/vcpu.c:1485:long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,\narch/loongarch/kvm/vcpu.c-1486-\t\t\t\t unsigned long arg)\n--\narch/mips/kvm/mips.c=871=static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,\n--\narch/mips/kvm/mips.c-897-\narch/mips/kvm/mips.c:898:long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,\narch/mips/kvm/mips.c-899-\t\t\t\t unsigned long arg)\n--\narch/powerpc/kvm/powerpc.c=2019=int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,\n--\narch/powerpc/kvm/powerpc.c-2024-\narch/powerpc/kvm/powerpc.c:2025:long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,\narch/powerpc/kvm/powerpc.c-2026-\t\t\t\t unsigned long arg)\n--\narch/riscv/kvm/vcpu.c=244=vm_fault_t kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)\n--\narch/riscv/kvm/vcpu.c-248-\narch/riscv/kvm/vcpu.c:249:long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,\narch/riscv/kvm/vcpu.c-250-\t\t\t\t unsigned long arg)\n--\narch/s390/kvm/kvm-s390.c=5415=static long kvm_s390_vcpu_memsida_op(struct kvm_vcpu *vcpu,\n--\narch/s390/kvm/kvm-s390.c-5439-\narch/s390/kvm/kvm-s390.c:5440:long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,\narch/s390/kvm/kvm-s390.c-5441-\t\t\t\t unsigned long arg)\n--\narch/x86/kvm/x86.c=7199=static int kvm_vm_ioctl_set_clock(struct kvm *kvm, void __user *argp)\n--\narch/x86/kvm/x86.c-7244-\narch/x86/kvm/x86.c:7245:long kvm_arch_vcpu_unlocked_ioctl(struct file *filp, unsigned int ioctl,\narch/x86/kvm/x86.c-7246-\t\t\t\t unsigned long arg)\n--\ninclude/linux/kvm_host.h=1572=long kvm_arch_vcpu_ioctl(struct file *filp,\ninclude/linux/kvm_host.h-1573-\t\t\t unsigned int ioctl, unsigned long arg);\ninclude/linux/kvm_host.h:1574:long kvm_arch_vcpu_unlocked_ioctl(struct file *filp,\ninclude/linux/kvm_host.h-1575-\t\t\t\t unsigned int ioctl, unsigned long arg);\n--\nvirt/kvm/kvm_main.c=4406=static long kvm_vcpu_ioctl(struct file *filp,\n--\nvirt/kvm/kvm_main.c-4433-\t */\nvirt/kvm/kvm_main.c:4434:\tr = kvm_arch_vcpu_unlocked_ioctl(filp, ioctl, arg);\nvirt/kvm/kvm_main.c-4435-\tif (r != -ENOIOCTLCMD)\n"
} |
| 41/2 | 2026/08/01 19:42 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 38558 output: 296 thoughts: 769 Thoughts: **My Analysis of KVM/s390 Architecture Changes** Okay, let's break this down systematically. First, I'm noting that `kvm_arch_vcpu_unlocked_ioctl` is called from `kvm_vcpu_ioctl` *before* `kvm_arch_vcpu_ioctl`. Standard KVM flow, so I'll definitely include it in the focus symbols. Now, let's double-check `kvm_s390_pv_create_cpu` and `kvm_s390_pv_destroy_cpu`. These are critical, as they're non-static and are called from `kvm_arch_vcpu_ioctl` via `KVM_S390_PV_COMMAND`. Definitely including them. From a configuration perspective, it's clear that KVM itself and `KVM_S390_UCONTROL` are relevant. So my initial focus symbols are: `kvm_arch_vm_ioctl`, `kvm_arch_vcpu_ioctl`, `kvm_arch_vcpu_unlocked_ioctl`, `kvm_arch_commit_memory_region`, `kvm_s390_pv_create_cpu`, `kvm_s390_pv_destroy_cpu`, `kvm_s390_handle_b2`, `kvm_s390_handle_b9`, `kvm_s390_inject_vcpu`, and `kvm_s390_faultin_gfn`. Wait, `kvm_s390_pv_create_cpu` is defined in `pv.c`. I need to ensure that it's always included during compilation. No other configuration is required for `pv.c`. I will double check `arch/s390/kvm/Makefile` just to be sure... yep, it's always compiled in. Now, for `KVM_S390_UCONTROL`. I should double-check that this option is defined as well. Okay, yes, `KVM_S390_UCONTROL` is indeed a configuration option, so I need to make sure to fuzz the cases where this is enabled. Let's make sure there aren't any other related configs, nope, just that one. In summary, the patch modifies core KVM functionality specific to the s390 architecture. This includes changes that directly impact memory regions, page faults, CPU lifecycle management (creation/destruction), interrupt injection, and handling of specific instructions (RRBE, ESSA). Importantly, the addition of `KVM_S390_UCONTROL` indicates the handling of user-space controlled VMs. These changes are all reachable from userspace through standard KVM ioctls and guest execution paths. Therefore, they all warrant fuzzing to identify and prevent potential regressions, memory leaks, or locking issues. The patch is definitely worth fuzzing. |
| 42/2 | 2026/08/01 19:42 | tool | set-results |
0mError:the following configs do not exist in the kernel tree: KVM_S390_UCONTROL Args: {
"EnableConfigs": [
"KVM",
"KVM_S390_UCONTROL"
],
"FocusSymbols": [
"kvm_arch_vm_ioctl",
"kvm_arch_vcpu_ioctl",
"kvm_arch_vcpu_unlocked_ioctl",
"kvm_arch_commit_memory_region",
"kvm_s390_pv_create_cpu",
"kvm_s390_pv_destroy_cpu",
"kvm_s390_handle_b2",
"kvm_s390_handle_b9",
"kvm_s390_inject_vcpu",
"kvm_s390_faultin_gfn"
],
"Reasoning": "The patch modifies core KVM functionality for the s390 architecture, including handling of memory regions, page faults, virtual CPU creation/destruction, interrupt injection, and specific instruction handlers (RRBE, ESSA). It also adds checks for userspace-controlled VMs (KVM_S390_UCONTROL). These changes are reachable from userspace via standard KVM ioctls and guest execution, and should be fuzzed to ensure they do not introduce regressions, memory leaks, or locking issues.",
"WorthFuzzing": true
}Results: {
"error": "the following configs do not exist in the kernel tree: KVM_S390_UCONTROL"
} |
| 43/2 | 2026/08/01 19:42 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 40302 output: 43 thoughts: 42 Thoughts: Okay, let me think this through. **Investigating the Absence of `KVM_S390_UCONTROL`** Hmm, this is strange. I was certain I was seeing something about `KVM_S390_UCONTROL` somewhere, but now it seems to be eluding me. The kernel documentation I was reviewing suggested its existence, but the build environment is throwing an error. A discrepancy like this is usually a symptom of a misconfiguration or potentially some outdated documentation. The first thing I'll do is double check the source. Let's delve back into `arch/s390/kvm/Kconfig` and make absolutely sure I'm not missing something obvious, or perhaps misinterpreting a conditional statement. It's a fundamental part of the architecure, so I may be missing something, it can't be that it doesn't exist, can it? I will methodically search for it. |
| 44/2 | 2026/08/01 19:42 | tool | grepper |
0mArgs:{
"Expression": "config KVM_S390_UCONTROL",
"PathPrefix": "arch/s390/kvm/Kconfig"
}Results: {
"Output": "arch/s390/kvm/Kconfig=19=config KVM\n--\narch/s390/kvm/Kconfig-46-\narch/s390/kvm/Kconfig:47:config KVM_S390_UCONTROL\narch/s390/kvm/Kconfig-48-\tbool \"Userspace controlled virtual machines\"\n"
} |
| 45/2 | 2026/08/01 19:42 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 40693 output: 283 thoughts: 170 Thoughts: **Navigating the Kconfig Labyrinth** Okay, hold on a second. I was certain I'd seen `KVM_S390_UCONTROL` somewhere… and there it is, right in `arch/s390/kvm/Kconfig`. That's strange, I wonder why `set-results` flagged it as non-existent? Hmm, maybe the tool is defaulting to checking against the x86_64 defconfig or some other architecture? That would explain it. Right, this is an s390-specific config. The tool probably doesn't see it because it's not part of the mainline architecture it's checking against. I'll need to adjust my strategy. I think the simplest solution is just to use the `KVM` option. If the tool complains about `KVM_S390_UCONTROL`, I'll omit it entirely or just provide `KVM` which should enable everything I need. Let me double-check that the config name is correct, just to be sure... Yep, confirmed: `config KVM_S390_UCONTROL`. Okay, I'm confident now. I'll just provide `KVM` for now. |
| 46/2 | 2026/08/01 19:43 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"KVM"
],
"FocusSymbols": [
"kvm_arch_vm_ioctl",
"kvm_arch_vcpu_ioctl",
"kvm_arch_vcpu_unlocked_ioctl",
"kvm_arch_commit_memory_region",
"kvm_s390_pv_create_cpu",
"kvm_s390_pv_destroy_cpu",
"kvm_s390_handle_b2",
"kvm_s390_handle_b9",
"kvm_s390_inject_vcpu",
"kvm_s390_faultin_gfn"
],
"Reasoning": "The patch modifies core KVM functionality for the s390 architecture, including handling of memory regions, page faults, virtual CPU creation/destruction, interrupt injection, and specific instruction handlers (RRBE, ESSA). It also adds checks for userspace-controlled VMs (KVM_S390_UCONTROL). These changes are reachable from userspace via standard KVM ioctls and guest execution, and should be fuzzed to ensure they do not introduce regressions, memory leaks, or locking issues.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"KVM"
],
"FocusSymbols": [
"kvm_arch_vm_ioctl",
"kvm_arch_vcpu_ioctl",
"kvm_arch_vcpu_unlocked_ioctl",
"kvm_arch_commit_memory_region",
"kvm_s390_pv_create_cpu",
"kvm_s390_pv_destroy_cpu",
"kvm_s390_handle_b2",
"kvm_s390_handle_b9",
"kvm_s390_inject_vcpu",
"kvm_s390_faultin_gfn"
],
"Reasoning": "The patch modifies core KVM functionality for the s390 architecture, including handling of memory regions, page faults, virtual CPU creation/destruction, interrupt injection, and specific instruction handlers (RRBE, ESSA). It also adds checks for userspace-controlled VMs (KVM_S390_UCONTROL). These changes are reachable from userspace via standard KVM ioctls and guest execution, and should be fuzzed to ensure they do not introduce regressions, memory leaks, or locking issues.",
"WorthFuzzing": true
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|