KVM: s390: New features for 7.2
Subsystems (5)
Claudio Imbrenda
maintainerCiao Paolo,
Here are some new features for 7.2 for KVM/s390:
* KVM_PRE_FAULT_MEMORY support
* Support for 2G hugepages
* Support for the ASTFLEIE 2 facility
* kvm_arch_set_irq_inatomic Fast Inject
* Fix potential leak of uninitialized bytes
The following changes since commit 7fd2df204f342fc17d1a0bfcd474b24232fb0f32:
Linux 7.1-rc2 (2026-05-03 14:21:25 -0700)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git tags/kvm-s390-next-7.2-1
for you to fetch changes up to a868b30492c59f398359b7891293bbde8d126a51:
KVM: s390: Introducing kvm_arch_set_irq_inatomic fast inject (2026-06-15 14:18:37 +0200)
----------------------------------------------------------------
KVM: s390: New features for 7.2
New features for 7.2 for KVM/s390:
* KVM_PRE_FAULT_MEMORY support
* Support for 2G hugepages
* Support for the ASTFLEIE 2 facility
* kvm_arch_set_irq_inatomic Fast Inject
* Fix potential leak of uninitialized bytes
----------------------------------------------------------------
Christian Borntraeger (1):
KVM: s390: Initialize KVM_S390_GET_CMMA_BITS memory
Claudio Imbrenda (9):
KVM: s390: Track page size in struct guest_fault
KVM: s390: Implement KVM_PRE_FAULT_MEMORY
KVM: s390: Update KVM_PRE_FAULT_MEMORY API documentation
KVM: selftests: Fix pre_fault_memory_test to run on s390
KVM: selftests: Enable pre_fault_memory_test for s390
KVM: s390: Add module parameter to fence 2G hugepages
KVM: s390: Add capability to support 2G hugepages
KVM: s390: Allow for 2G hugepages
KVM: s390: Document the KVM_CAP_S390_HPAGE_2G capability
Douglas Freimuth (3):
KVM: s390: Add map/unmap ioctl and clean mappings post-guest
KVM: s390: Enable adapter_indicators_set to use mapped pages
KVM: s390: Introducing kvm_arch_set_irq_inatomic fast inject
Nina Schoetterl-Glausch (4):
KVM: s390: Minor refactor of base/ext facility lists s390/sclp: Detect ASTFLEIE 2 facility
KVM: s390: vsie: Refactor handle_stfle
KVM: s390: vsie: Implement ASTFLEIE facility 2
Documentation/virt/kvm/api.rst | 20 +- arch/s390/include/asm/kvm_host.h | 23 +- arch/s390/include/asm/sclp.h | 1 + arch/s390/include/uapi/asm/kvm.h | 1 + arch/s390/kvm/Kconfig | 1 + arch/s390/kvm/dat.h | 1 + arch/s390/kvm/gmap.c | 26 +- arch/s390/kvm/intercept.c | 5 +- arch/s390/kvm/interrupt.c | 559 ++++++++++++++++----- arch/s390/kvm/kvm-s390.c | 161 ++++-- arch/s390/kvm/kvm-s390.h | 5 +- arch/s390/kvm/pv.c | 5 +- arch/s390/kvm/vsie.c | 85 +++- drivers/s390/char/sclp_early.c | 4 +- include/uapi/linux/kvm.h | 1 + tools/testing/selftests/kvm/Makefile.kvm | 1 + .../testing/selftests/kvm/pre_fault_memory_test.c | 7 +- 17 files changed, 727 insertions(+), 179 deletions(-)
Claudio Imbrenda
maintainer[GIT PULL v1 02/17] KVM: s390: Implement KVM_PRE_FAULT_MEMORY
Implement and enable the KVM_PRE_FAULT_MEMORY ioctl for s390.
Faulted-in pages will be marked as accessed, unlike x86, otherwise they will trigger a minor fault when accessed. Avoiding such faults is one of the points of KVM_PRE_FAULT_MEMORY.
Message-ID: <[email protected]>
--- arch/s390/kvm/Kconfig | 1 + arch/s390/kvm/kvm-s390.c | 45 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)
arch/s390/kvm/Kconfig +1 -0
@@ -30,6 +30,7 @@ config KVM select KVM_VFIO select VIRT_XFER_TO_GUEST_WORK select KVM_MMU_LOCKLESS_AGING + select KVM_GENERIC_PRE_FAULT_MEMORY help Support hosting paravirtualized guest machines using the SIE virtualization capability on the mainframe. This should work
arch/s390/kvm/kvm-s390.c +45 -0
57 lines not on this page · raw message
Signature · 1 line
2.54.0
Claudio Imbrenda
maintainer[GIT PULL v1 01/17] KVM: s390: Track page size in struct guest_fault
In reply to Claudio ImbrendaUntil now, the members of struct guest_fault are always accessed while holding the required locks, and thus the ptep and crstep pointers can be dereferenced safely.
There will be some new cases where callers of kvm_s390_faultin_gfn() need to know the size of the page used to solve the fault, at which point no locks are held anymore, and dereferencing the crstep field is not possible.
Introduce a new crste_region3 flag for struct guest_fault to indicate whether the crstep used to solve the fault was a region 3 entry with FC=1 (large pud).
This allows to disambiguate all three possible scenarios:
* If ptep is not NULL, the fault was solved with a pte.
* If ptep is NULL and crste_region3 is 0, a segment entry with FC=1 (large pmd) was used.
* If ptep is NULL and crste_region3 is 1, a region 3 entry with FC=1 (large pud) was used.
Message-ID: <[email protected]>
--- arch/s390/kvm/dat.h | 1 + arch/s390/kvm/gmap.c | 2 ++ 2 files changed, 3 insertions(+)
arch/s390/kvm/dat.h +1 -0
@@ -500,6 +500,7 @@ struct guest_fault {bool write_attempt;/* Write access attempted */ bool attempt_pfault;/* Attempt a pfault first */ bool valid;/* This entry contains valid data */ +bool crste_region3;/* Whether crstep refers to a region3 entry */ void (*callback)(struct guest_fault *f);void *priv; };
arch/s390/kvm/gmap.c +2 -0
@@ -531,6 +531,7 @@ static int gmap_handle_minor_crste_fault(struct gmap *gmap, struct guest_fault * f->pfn =PHYS_PFN (large_crste_to_phys (oldcrste, f->gfn)); f->writable = oldcrste.s.fc1.w; + f->crste_region3 =is_pud (oldcrste);/* Appropriate permissions already (race with another handler), nothing to do. */ if (!oldcrste.h.i && !(f->write_attempt && oldcrste.h.p))return 0 ;
@@ -690,6 +691,7 @@ static int _gmap_link(struct kvm_s390_mmu_cache *mc, struct gmap *gmap, int leveif (oldval.val !=_CRSTE_EMPTY (oldval.h.tt).val &&crste_origin_large (oldval) !=crste_origin_large (newval))return -EAGAIN ; + f->crste_region3 =is_pud (newval); }while (!gmap_crstep_xchg_atomic (gmap, f->crstep, oldval, newval, f->gfn));if (f->callback) f->callback (f);
Signature · 1 line
2.54.0
Claudio Imbrenda
maintainer[GIT PULL v1 03/17] KVM: s390: Update KVM_PRE_FAULT_MEMORY API documentation
In reply to Claudio ImbrendaUpdate the API documentation for KVM_PRE_FAULT_MEMORY to account for its s390 implementation.
Message-ID: <[email protected]>
--- Documentation/virt/kvm/api.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/virt/kvm/api.rst +3 -2
@@ -6471,7 +6471,8 @@ Errors: ========== =============================================================== EINVAL The specified `gpa` and `size` were invalid (e.g. not - page aligned, causes an overflow, or size is zero). + page aligned, causes an overflow, or size is zero), or the VM + is UCONTROL (s390). ENOENT The specified `gpa` is outside defined memslots. EINTR An unmasked signal is pending and no page was processed. EFAULT The parameter address was invalid.
@@ -6494,7 +6495,7 @@ Errors: KVM_PRE_FAULT_MEMORY populates KVM's stage-2 page tables used to map memory for the current vCPU state. KVM maps memory as if the vCPU generated a stage-2 read page fault, e.g. faults in memory as needed, but doesn't break -CoW. However, KVM does not mark any newly created stage-2 PTE as Accessed. +CoW. On x86, KVM does not mark any newly created stage-2 PTE as Accessed. In the case of confidential VM types where there is an initial set up of private guest memory before the guest is 'finalized'/measured, this ioctl
Signature · 1 line
2.54.0
Claudio Imbrenda
maintainer[GIT PULL v1 04/17] KVM: selftests: Fix pre_fault_memory_test to run on s390
In reply to Claudio ImbrendaAdd a missing #include <ucall_common.h> which is needed and otherwise not included on s390.
Remove the assertion vcpu->run->exit_reason == KVM_EXIT_IO since it is x86-specific and redundant anyway.
Message-ID: <[email protected]>
--- tools/testing/selftests/kvm/pre_fault_memory_test.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
tools/testing/selftests/kvm/pre_fault_memory_test.c +1 -6
@@ -11,6 +11,7 @@#include <kvm_util.h> #include <processor.h> #include <pthread.h> +#include <ucall_common.h> /* Arbitrarily chosen values */ #define TEST_SIZE (SZ_2M + PAGE_SIZE)
@@ -167,7 +168,6 @@ static void __test_pre_fault_memory(unsigned long vm_type, bool private) .type = vm_type, };struct kvm_vcpu *vcpu; -struct kvm_run *run;struct kvm_vm *vm;struct ucall uc;
@@ -193,11 +193,6 @@ static void __test_pre_fault_memory(unsigned long vm_type, bool private)vcpu_args_set (vcpu,1 , gva);vcpu_run (vcpu); - run = vcpu->run; -TEST_ASSERT (run->exit_reason ==KVM_EXIT_IO , -"Wanted KVM_EXIT_IO, got exit reason: %u (%s)" , - run->exit_reason,exit_reason_str (run->exit_reason)); -switch (get_ucall (vcpu, &uc)) {case UCALL_ABORT :REPORT_GUEST_ASSERT (uc);
Signature · 1 line
2.54.0
Claudio Imbrenda
maintainer[GIT PULL v1 05/17] KVM: selftests: Enable pre_fault_memory_test for s390
In reply to Claudio ImbrendaEnable the pre_fault_memory_test to run on s390.
Message-ID: <[email protected]>
--- tools/testing/selftests/kvm/Makefile.kvm | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/kvm/Makefile.kvm +1 -0
@@ -210,6 +210,7 @@ TEST_GEN_PROGS_s390 += s390/keyop TEST_GEN_PROGS_s390 += rseq_test TEST_GEN_PROGS_s390 += s390/irq_routing TEST_GEN_PROGS_s390 += mmu_stress_test +TEST_GEN_PROGS_s390 += pre_fault_memory_test TEST_GEN_PROGS_riscv = $(TEST_GEN_PROGS_COMMON) TEST_GEN_PROGS_riscv += riscv/sbi_pmu_test
Signature · 1 line
2.54.0
Claudio Imbrenda
maintainer[GIT PULL v1 06/17] KVM: s390: Add module parameter to fence 2G hugepages
In reply to Claudio ImbrendaAdd the hpage_2g module parameter to KVM to allow enabling or disabling 2G hugepages in KVM.
If hpage_2g is enabled but hpage is not enabled, print a message and disable hpage_2g.
Opportunistically fix the comment for the hpage module parameter.
Message-ID: <[email protected]>
--- arch/s390/kvm/kvm-s390.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/s390/kvm/kvm-s390.c +11 -1
@@ -204,11 +204,16 @@ static int nested;module_param (nested, int,S_IRUGO );MODULE_PARM_DESC (nested,"Nested virtualization support" ); -/* allow 1m huge page guest backing, if !nested */ +/* allow 1m huge page guest backing */ static int hpage;module_param (hpage, int,0444 );MODULE_PARM_DESC (hpage,"1m huge page backing support" ); +/* allow 2g huge page guest backing */ +static int hpage_2g; +module_param (hpage_2g, int,0444 ); +MODULE_PARM_DESC (hpage_2g,"2g huge page backing support" ); +/* maximum percentage of steal time for polling. >100 is treated like 100 */ static u8 halt_poll_max_steal =10 ;module_param (halt_poll_max_steal, byte,0644 );
@@ -5842,6 +5847,11 @@ static int __init kvm_s390_init(void)return -ENODEV ; } +if (hpage_2g && !hpage) { + hpage_2g =0 ; +pr_info ("Disabling 2G hugepage support, since 1M hugepage support is not enabled.\n" ); + } +for (i =0 ; i <16 ; i++) kvm_s390_fac_base[i] |= stfle_fac_list[i] &nonhyp_mask (i);
Signature · 1 line
2.54.0
Claudio Imbrenda
maintainer[GIT PULL v1 09/17] KVM: s390: Document the KVM_CAP_S390_HPAGE_2G capability
In reply to Claudio ImbrendaDocument the KVM_CAP_S390_HPAGE_2G capability, which behaves very similarly to the existing KVM_CAP_S390_HPAGE_1M.
Message-ID: <[email protected]>
--- Documentation/virt/kvm/api.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
Documentation/virt/kvm/api.rst +15 -0
@@ -8905,6 +8905,21 @@ helpful if user space wants to emulate instructions which are not This capability can be enabled dynamically even if VCPUs were already created and are running. +7.47 KVM_CAP_S390_HPAGE_2G +-------------------------- + +:Architectures: s390 +:Parameters: none +:Returns: 0 on success; -EINVAL if hpage_2g module parameter was not set, + cmma is enabled, or the VM has the KVM_VM_S390_UCONTROL + flag set; -EBUSY if vCPUs were already created for the VM. + +With this capability the KVM support for memory backing with 2g pages +through hugetlbfs can be enabled for a VM. After the capability is +enabled, cmma can't be enabled anymore and pfmfi and the storage key +interpretation are disabled. If cmma has already been enabled or the +hpage_2g module parameter is not set to 1, -EINVAL is returned. + 8. Other capabilities. ======================
Signature · 1 line
2.54.0
Claudio Imbrenda
maintainer[GIT PULL v1 07/17] KVM: s390: Add capability to support 2G hugepages
In reply to Claudio ImbrendaAdd KVM_CAP_S390_HPAGE_2G to signal to userspace that 2G hugepages may be used to back the guest; restrictions apply similar to 1M hugepages.
Enable the (for now still ignored) GMAP_FLAG_ALLOW_HPAGE_2G flag for the guest gmap, and propagate / disable it as necessary.
Message-ID: <[email protected]>
--- arch/s390/kvm/gmap.c | 5 +++++ arch/s390/kvm/kvm-s390.c | 26 ++++++++++++++++++++++++++ arch/s390/kvm/pv.c | 5 ++++- include/uapi/linux/kvm.h | 1 + 4 files changed, 36 insertions(+), 1 deletion(-)
arch/s390/kvm/gmap.c +5 -0
@@ -105,6 +105,11 @@ static void gmap_add_child(struct gmap *parent, struct gmap *child)else clear_bit (GMAP_FLAG_ALLOW_HPAGE_1M , &child->flags); +if (test_bit (GMAP_FLAG_ALLOW_HPAGE_2G , &parent->flags)) +set_bit (GMAP_FLAG_ALLOW_HPAGE_2G , &child->flags); +else +clear_bit (GMAP_FLAG_ALLOW_HPAGE_2G , &child->flags); +if (kvm_is_ucontrol (parent->kvm))clear_bit (GMAP_FLAG_OWNS_PAGETABLES , &child->flags);list_add (&child->list, &parent->children);
arch/s390/kvm/kvm-s390.c +26 -0
@@ -646,6 +646,11 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)if (hpage && !(kvm &&kvm_is_ucontrol (kvm))) r =1 ;break ; +case KVM_CAP_S390_HPAGE_2G : + r =0 ; +if (hpage_2g && !(kvm &&kvm_is_ucontrol (kvm))) + r =1 ; +break ;case KVM_CAP_S390_MEM_OP : r =MEM_OP_MAX_SIZE ;break ;
@@ -902,6 +907,27 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap)VM_EVENT (kvm,3 ,"ENABLE: CAP_S390_HPAGE %s" , r ?"(not available)" :"(success)" );break ; +case KVM_CAP_S390_HPAGE_2G : +mutex_lock (&kvm->lock); +if (kvm->created_vcpus) { + r = -EBUSY ; + }else if (!hpage_2g || kvm->arch.use_cmma ||kvm_is_ucontrol (kvm)) { + r = -EINVAL ; + }else { + r =0 ; +set_bit (GMAP_FLAG_ALLOW_HPAGE_2G , &kvm->arch.gmap->flags); +/* +* We might have to create fake 4k page +* tables. To avoid that the hardware works on +* stale PGSTEs, we emulate these instructions. +*/ + kvm->arch.use_skf =0 ; + kvm->arch.use_pfmfi =0 ; + } +mutex_unlock (&kvm->lock); +VM_EVENT (kvm,3 ,"ENABLE: CAP_S390_HPAGE_2G %s" , + r ?"(not available)" :"(success)" ); +break ;case KVM_CAP_S390_USER_STSI :VM_EVENT (kvm,3 ,"%s" ,"ENABLE: CAP_S390_USER_STSI" ); kvm->arch.user_stsi =1 ;
arch/s390/kvm/pv.c +4 -1
@@ -721,7 +721,10 @@ int kvm_s390_pv_init_vm(struct kvm *kvm, u16 *rc, u16 *rrc) uvcb.flags.ap_allow_instr = kvm->arch.model.uv_feat_guest.ap; uvcb.flags.ap_instr_intr = kvm->arch.model.uv_feat_guest.ap_intr; -clear_bit (GMAP_FLAG_ALLOW_HPAGE_1M , &kvm->arch.gmap->flags); + scoped_guard(write_lock, &kvm->mmu_lock) { +clear_bit (GMAP_FLAG_ALLOW_HPAGE_1M , &kvm->arch.gmap->flags); +clear_bit (GMAP_FLAG_ALLOW_HPAGE_2G , &kvm->arch.gmap->flags); + }gmap_split_huge_pages (kvm->arch.gmap); cc =uv_call_sched (0 , (u64)&uvcb);
include/uapi/linux/kvm.h +1 -0
@@ -996,6 +996,7 @@ struct kvm_enable_cap {#define KVM_CAP_S390_USER_OPEREXEC 246#define KVM_CAP_S390_KEYOP 247#define KVM_CAP_S390_VSIE_ESAMODE 248 +#define KVM_CAP_S390_HPAGE_2G 249struct kvm_irq_routing_irqchip {__u32 irqchip;
Signature · 1 line
2.54.0
Claudio Imbrenda
maintainer[GIT PULL v1 08/17] KVM: s390: Allow for 2G hugepages
In reply to Claudio ImbrendaChange gmap_2g_allowed() to perform the necessary checks to allow for 2G hugepages to be used, instead of returning false. The GMAP_FLAG_ALLOW_HPAGE_2G gmap flag is now taken into account.
Also add appropriate kerneldoc comments.
Message-ID: <[email protected]>
--- arch/s390/kvm/gmap.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
arch/s390/kvm/gmap.c +18 -1
@@ -624,10 +624,27 @@ int gmap_try_fixup_minor(struct gmap *gmap, struct guest_fault *fault)return rc; } +/** +* gmap_2g_allowed() - Check whether a 2G hugepage is allowed. +* @gmap: The gmap of the guest. +* @f: Describes the fault that is being resolved. +* @slot: The memslot the faulting address belongs to. +* +* The function checks whether the GMAP_FLAG_ALLOW_HPAGE_2G flag is set for +* @gmap, whether the offset of the address in the 2G virtual frame is the +* same as the offset in the physical 2G frame, and finally whether the whole +* 2G page would fit in the given memslot. +* +* Return: true if a 2G hugepage is allowed to back the faulting address, false +* otherwise. +*/ static inline bool gmap_2g_allowed (struct gmap *gmap,struct guest_fault *f,struct kvm_memory_slot *slot) { -return false; +return test_bit (GMAP_FLAG_ALLOW_HPAGE_2G , &gmap->flags) && + !((f->gfn ^ f->pfn) & ~_REGION3_FR_MASK) && + slot->base_gfn <=ALIGN_DOWN (f->gfn, _PAGES_PER_REGION3) && + slot->base_gfn + slot->npages >=ALIGN (f->gfn +1 , _PAGES_PER_REGION3); }/**
Signature · 1 line
2.54.0
Claudio Imbrenda
maintainer[GIT PULL v1 10/17] KVM: s390: Initialize KVM_S390_GET_CMMA_BITS memory
In reply to Claudio ImbrendaFrom: Christian Borntraeger <[email protected]>
kvm_s390_get_cmma_bits() allocates its output buffer with vmalloc(), which does not zero the returned pages:
values = vmalloc(args->count);
In the non-peek (migration) path, dat_get_cmma() reports a byte count spanning from the first to the last dirty page, but __dat_get_cmma_pte() writes values[gfn - start] only for pages whose CMMA dirty bit is set. The walk uses DAT_WALK_IGN_HOLES, so clean and unmapped pages that lie between two dirty pages within the reported span are visited but never store their byte. Those gaps (up to KVM_S390_MAX_BIT_DISTANCE pages each) stay uninitialized yet fall inside [0, count) and are copied out by copy_to_user(), disclosing stale kernel memory to user space.
Before the switch to the new gmap implementation the buffer was fully populated for every gfn in the span, so no uninitialized bytes were exposed; the dirty-only walk introduced the leak.
Use vzalloc() so the gaps read back as zero.
Message-ID: <[email protected]>
--- arch/s390/kvm/kvm-s390.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kvm/kvm-s390.c +1 -1
@@ -2263,7 +2263,7 @@ static int kvm_s390_get_cmma_bits(struct kvm *kvm,return 0 ; } - values =vmalloc (args->count); + values =vzalloc (args->count);if (!values)return -ENOMEM ;
Signature · 1 line
2.54.0
Claudio Imbrenda
maintainer[GIT PULL v1 11/17] KVM: s390: Minor refactor of base/ext facility lists
In reply to Claudio ImbrendaFrom: Nina Schoetterl-Glausch <[email protected]>
Directly use the size of the arrays instead of going through the indirection of kvm_s390_fac_size().
Don't use magic number for the number of entries in the non hypervisor managed facility bit mask list.
Make the constraint of that number on kvm_s390_fac_base obvious. Get rid of implicit double anding of stfle_fac_list.
Message-ID: <[email protected]>
--- arch/s390/kvm/kvm-s390.c | 44 +++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 25 deletions(-)
arch/s390/kvm/kvm-s390.c +19 -25
@@ -237,33 +237,25 @@ static int async_destroy = 1;module_param (async_destroy, int,0444 );MODULE_PARM_DESC (async_destroy,"Asynchronous destroy for protected guests" ); -/* -* For now we handle at most 16 double words as this is what the s390 base -* kernel handles and stores in the prefix page. If we ever need to go beyond -* this, this requires changes to code, but the external uapi can stay. -*/ -#define SIZE_INTERNAL 16 - +#define HMFAI_DWORDS 16/* * Base feature mask that defines default mask for facilities. Consists of the * defines in FACILITIES_KVM and the non-hypervisor managed bits. */ -static unsigned long kvm_s390_fac_base[SIZE_INTERNAL ] = {FACILITIES_KVM }; +static unsigned long kvm_s390_fac_base[HMFAI_DWORDS ] = {FACILITIES_KVM }; +static_assert (ARRAY_SIZE (((long []){FACILITIES_KVM })) <=HMFAI_DWORDS ); +static_assert (ARRAY_SIZE (kvm_s390_fac_base) <=S390_ARCH_FAC_MASK_SIZE_U64 ); +static_assert (ARRAY_SIZE (kvm_s390_fac_base) <=S390_ARCH_FAC_LIST_SIZE_U64 ); +static_assert (ARRAY_SIZE (kvm_s390_fac_base) <=ARRAY_SIZE (stfle_fac_list)); +/* * Extended feature mask. Consists of the defines in FACILITIES_KVM_CPUMODEL * and defines the facilities that can be enabled via a cpu model. */ -static unsigned long kvm_s390_fac_ext[SIZE_INTERNAL ] = {FACILITIES_KVM_CPUMODEL }; - -static unsigned long kvm_s390_fac_size (void ) -{ -BUILD_BUG_ON (SIZE_INTERNAL >S390_ARCH_FAC_MASK_SIZE_U64 ); -BUILD_BUG_ON (SIZE_INTERNAL >S390_ARCH_FAC_LIST_SIZE_U64 ); -BUILD_BUG_ON (SIZE_INTERNAL *sizeof (unsigned long ) > -sizeof (stfle_fac_list)); - -return SIZE_INTERNAL ; -} +static const unsigned long kvm_s390_fac_ext[] = {FACILITIES_KVM_CPUMODEL }; +static_assert (ARRAY_SIZE (kvm_s390_fac_ext) <=S390_ARCH_FAC_MASK_SIZE_U64 ); +static_assert (ARRAY_SIZE (kvm_s390_fac_ext) <=S390_ARCH_FAC_LIST_SIZE_U64 ); +static_assert (ARRAY_SIZE (kvm_s390_fac_ext) <=ARRAY_SIZE (stfle_fac_list));/* available cpu features supported by kvm */ static DECLARE_BITMAP(kvm_s390_available_cpu_feat, KVM_S390_VM_CPU_FEAT_NR_BITS);
@@ -3249,13 +3241,16 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) kvm->arch.sie_page2->kvm = kvm; kvm->arch.model.fac_list = kvm->arch.sie_page2->fac_list; -for (i =0 ; i <kvm_s390_fac_size (); i++) { +for (i =0 ; i <ARRAY_SIZE (kvm_s390_fac_base); i++) { kvm->arch.model.fac_mask[i] = stfle_fac_list[i] & - (kvm_s390_fac_base[i] | - kvm_s390_fac_ext[i]); + kvm_s390_fac_base[i]; kvm->arch.model.fac_list[i] = stfle_fac_list[i] & kvm_s390_fac_base[i]; } +for (i =0 ; i <ARRAY_SIZE (kvm_s390_fac_ext); i++) { + kvm->arch.model.fac_mask[i] |= stfle_fac_list[i] & + kvm_s390_fac_ext[i]; + } kvm->arch.model.subfuncs = kvm_s390_available_subfunc;/* we are always in czam mode - even on pre z14 machines */
@@ -5878,9 +5873,8 @@ static int __init kvm_s390_init(void)pr_info ("Disabling 2G hugepage support, since 1M hugepage support is not enabled.\n" ); } -for (i =0 ; i <16 ; i++) - kvm_s390_fac_base[i] |= - stfle_fac_list[i] &nonhyp_mask (i); +for (i =0 ; i <HMFAI_DWORDS ; i++) + kvm_s390_fac_base[i] |=nonhyp_mask (i); r =__kvm_s390_init ();if (r)
Signature · 1 line
2.54.0
Claudio Imbrenda
maintainer[GIT PULL v1 12/17] s390/sclp: Detect ASTFLEIE 2 facility
In reply to Claudio ImbrendaFrom: Nina Schoetterl-Glausch <[email protected]>
Detect alternate STFLE interpretive execution facility 2.
Message-ID: <[email protected]>
--- arch/s390/include/asm/sclp.h | 1 + drivers/s390/char/sclp_early.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)
arch/s390/include/asm/sclp.h +1 -0
@@ -104,6 +104,7 @@ struct sclp_info { unsigned char has_aisii : 1; unsigned char has_aeni : 1; unsigned char has_aisi : 1; + unsigned char has_astfleie2 : 1;unsigned int ibc;unsigned int mtid;unsigned int mtid_cp;
drivers/s390/char/sclp_early.c +3 -1
@@ -61,8 +61,10 @@ static void __init sclp_early_facilities_detect(void) sclp.has_sipl = !!(sccb->cbl &0x4000 ); sclp.has_sipl_eckd = !!(sccb->cbl &0x2000 ); } -if (sccb->cpuoff >139 ) +if (sccb->cpuoff >139 ) { sclp.has_diag324 = !!(sccb->byte_139 &0x80 ); + sclp.has_astfleie2 = !!(sccb->byte_139 &0x40 ); + } sclp.rnmax = sccb->rnmax ? sccb->rnmax : sccb->rnmax2; sclp.rzm = sccb->rnsize ? sccb->rnsize : sccb->rnsize2; sclp.rzm <<=20 ;
Signature · 1 line
2.54.0
Claudio Imbrenda
maintainer[GIT PULL v1 13/17] KVM: s390: vsie: Refactor handle_stfle
In reply to Claudio ImbrendaFrom: Nina Schoetterl-Glausch <[email protected]>
Use switch case in anticipation of handling format-1 and format-2 facility list designations in the future.
As the alternate STFLE facilities are not enabled, only case 0 is possible.
No functional change intended.
Message-ID: <[email protected]>
--- arch/s390/include/uapi/asm/kvm.h | 1 + arch/s390/kvm/vsie.c | 53 ++++++++++++++++++++++---------- 2 files changed, 38 insertions(+), 16 deletions(-)
arch/s390/include/uapi/asm/kvm.h +1 -0
@@ -444,6 +444,7 @@ struct kvm_s390_vm_cpu_machine {#define KVM_S390_VM_CPU_FEAT_PFMFI 11#define KVM_S390_VM_CPU_FEAT_SIGPIF 12#define KVM_S390_VM_CPU_FEAT_KSS 13 +#define KVM_S390_VM_CPU_FEAT_ASTFLEIE2 14struct kvm_s390_vm_cpu_feat {__u64 feat[16 ]; };
arch/s390/kvm/vsie.c +37 -16
84 lines not on this page · raw message
Signature · 1 line
2.54.0
Claudio Imbrenda
maintainer[GIT PULL v1 14/17] KVM: s390: vsie: Implement ASTFLEIE facility 2
In reply to Claudio ImbrendaFrom: Nina Schoetterl-Glausch <[email protected]>
Implement shadowing of format-2 facility list when running in VSIE.
ASTFLEIE2 is available since IBM z16.
To function G1 has to run this KVM code and G1 and G2 have to run QEMU with ASTFLEIE2 support.
Message-ID: <[email protected]>
--- arch/s390/include/asm/kvm_host.h | 12 +++++++++++ arch/s390/kvm/kvm-s390.c | 2 ++ arch/s390/kvm/vsie.c | 34 ++++++++++++++++++++++++++++---- 3 files changed, 44 insertions(+), 4 deletions(-)
arch/s390/include/asm/kvm_host.h +12 -0
@@ -504,6 +504,18 @@ struct kvm_s390_cpu_model {struct kvm_s390_vm_cpu_uv_feat uv_feat_guest; }; +#define S390_ARCH_FAC_FORMAT_2 2 +struct kvm_s390_flcb2 { +union { +struct { +u8 reserved0[7 ]; +u8 length; + }; +u64 header_val; + }; +u64 facilities[S390_ARCH_FAC_LIST_SIZE_U64 ]; +}; +typedef int (*crypto_hook )(struct kvm_vcpu *vcpu);struct kvm_s390_crypto {
arch/s390/kvm/kvm-s390.c +2 -0
@@ -465,6 +465,8 @@ static void __init kvm_s390_cpu_feat_init(void)allow_cpu_feat (KVM_S390_VM_CPU_FEAT_IBS );if (sclp.has_kss)allow_cpu_feat (KVM_S390_VM_CPU_FEAT_KSS ); +if (sclp.has_astfleie2) +allow_cpu_feat (KVM_S390_VM_CPU_FEAT_ASTFLEIE2 );/* * KVM_S390_VM_CPU_FEAT_SKEY: Wrong shadow of PTE.I bits will make * all skey handling functions read/set the skey from the PGSTE
arch/s390/kvm/vsie.c +30 -4
@@ -65,9 +65,9 @@ struct vsie_page {gpa_t scb_gpa;/* 0x0258 */ /* the shadow gmap in use by the vsie_page */ struct gmap_cache gmap_cache;/* 0x0260 */ -__u8 reserved[0x0700 -0x0278 ];/* 0x0278 */ -struct kvm_s390_crypto_cb crycb;/* 0x0700 */ -__u8 fac[S390_ARCH_FAC_LIST_SIZE_BYTE ];/* 0x0800 */ +__u8 reserved[0x06f8 -0x0278 ];/* 0x0278 */ +struct kvm_s390_crypto_cb crycb;/* 0x06f8 */ +__u8 fac[8 +S390_ARCH_FAC_LIST_SIZE_BYTE ];/* 0x07f8 */ };static_assert (sizeof (struct vsie_page ) ==PAGE_SIZE );
@@ -1020,6 +1020,28 @@ static int handle_stfle_0(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page,return 0 ; } +static int handle_stfle_2 (struct kvm_vcpu *vcpu,struct vsie_page *vsie_page,u32 fac_list_origin) +{ +struct kvm_s390_flcb2 *flcb_s = (struct kvm_s390_flcb2 *)vsie_page->fac; +struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s; +u64 len; + +if (read_guest_real (vcpu, fac_list_origin, &len,sizeof (len))) +return set_validity_icpt (scb_s,0x1090U ); + +/* discard reserved bits */ + len = (len &U8_MAX ); + flcb_s->header_val = len; + len +=1 ; + +if (read_guest_real (vcpu, fac_list_origin + offsetof(struct kvm_s390_flcb2 , facilities), + &flcb_s->facilities, len *sizeof (u64))) +return set_validity_icpt (scb_s,0x1090U ); + + scb_s->fac = (u32 )virt_to_phys (&vsie_page->fac) |S390_ARCH_FAC_FORMAT_2 ; +return 0 ; +} +/* * Try to shadow + enable the guest 2 provided facility list. * Retry instruction execution if enabled for and provided by guest 2.
@@ -1034,6 +1056,8 @@ static int handle_stfle(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)int format_mask, format;u32 origin; +/* assert no overflow with maximum len */ +BUILD_BUG_ON (sizeof (vsie_page->fac) < ((S390_ARCH_FAC_LIST_SIZE_U64 +1 ) *sizeof (u64)));BUILD_BUG_ON (!IS_ALIGNED (offsetof(struct vsie_page , fac),8 ));if (fac &&test_kvm_facility (vcpu->kvm,7 )) {
@@ -1049,9 +1073,11 @@ static int handle_stfle(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)case 0 :return handle_stfle_0 (vcpu, vsie_page, origin);case 1 : +return set_validity_icpt (&vsie_page->scb_s,0x1330U );case 2 : +return handle_stfle_2 (vcpu, vsie_page, origin);case 3 : -unreachable (); +return set_validity_icpt (&vsie_page->scb_s,0x1330U ); } }return 0 ;
Signature · 1 line
2.54.0
Claudio Imbrenda
maintainer[GIT PULL v1 15/17] KVM: s390: Add map/unmap ioctl and clean mappings post-guest
In reply to Claudio ImbrendaFrom: Douglas Freimuth <[email protected]>
s390 needs map/unmap ioctls, which map the adapter set indicator pages, so the pages can be accessed when interrupts are disabled. The mappings are cleaned up when the guest is removed. pin_user_pages_remote is used for both the ioctl as well as the pin-on-demand logic in adapter_indicators_set().
Map/Unmap ioctls are fenced in order to avoid the longterm pinning in Secure Execution environments. In Secure Execution environments the path of execution available before this patch is followed.
Statistical counters to count map/unmap functions for adapter indicator pages are added. The counters can be used to analyze map/unmap functions in non-Secure Execution environments and similarly can be used to analyze Secure Execution environments where the counters will not be incremented as the adapter indicator pages are not mapped.
Message-ID: <[email protected]>
--- arch/s390/include/asm/kvm_host.h | 5 + arch/s390/kvm/interrupt.c | 227 +++++++++++++++++++++++++------ arch/s390/kvm/kvm-s390.c | 3 + arch/s390/kvm/kvm-s390.h | 2 + 4 files changed, 194 insertions(+), 43 deletions(-)
arch/s390/include/asm/kvm_host.h +5 -0
@@ -448,6 +448,8 @@ struct kvm_vcpu_arch {struct kvm_vm_stat {struct kvm_vm_stat_generic generic;u64 inject_io; +u64 io_390_adapter_map; +u64 io_390_adapter_unmap;u64 inject_float_mchk;u64 inject_pfault_done;u64 inject_service_signal;
@@ -479,6 +481,9 @@ struct s390_io_adapter {bool masked;bool swap;bool suppressible; +spinlock_t maps_lock; +struct list_head maps; +unsigned int nr_maps; };#define MAX_S390_IO_ADAPTERS ((MAX_ISC + 1) * 8)
arch/s390/kvm/interrupt.c +184 -43
288 lines not on this page · raw message
arch/s390/kvm/kvm-s390.c +3 -0
@@ -68,6 +68,8 @@const struct kvm_stats_desc kvm_vm_stats_desc[] = {KVM_GENERIC_VM_STATS (),STATS_DESC_COUNTER (VM , inject_io), +STATS_DESC_COUNTER (VM , io_390_adapter_map), +STATS_DESC_COUNTER (VM , io_390_adapter_unmap),STATS_DESC_COUNTER (VM , inject_float_mchk),STATS_DESC_COUNTER (VM , inject_pfault_done),STATS_DESC_COUNTER (VM , inject_service_signal),
@@ -2539,6 +2541,7 @@ static int kvm_s390_handle_pv(struct kvm *kvm, struct kvm_pv_cmd *cmd)if (kvm_s390_pv_is_protected (kvm))break ; +kvm_s390_unmap_all_adapters (kvm);mmap_write_lock (kvm->mm);/* * Disable creation of new THPs. Existing THPs can stay, they
arch/s390/kvm/kvm-s390.h +2 -0
@@ -560,6 +560,8 @@ void kvm_s390_gisa_disable(struct kvm *kvm);void kvm_s390_gisa_enable (struct kvm *kvm);int __init kvm_s390_gib_init (u8 nisc);void kvm_s390_gib_destroy (void ); +void kvm_s390_unmap_all_adapters (struct kvm *kvm); +/* implemented in guestdbg.c */ void kvm_s390_backup_guest_per_regs (struct kvm_vcpu *vcpu);
Signature · 1 line
2.54.0
Claudio Imbrenda
maintainer[GIT PULL v1 16/17] KVM: s390: Enable adapter_indicators_set to use mapped pages
In reply to Claudio ImbrendaFrom: Douglas Freimuth <[email protected]>
The s390 adapter_indicators_set function can now be optimized to use long-term mapped pages when available so that work can be processed on a fast path when interrupts are disabled.
If adapter indicator pages are not mapped then local mapping is done on a slow path as it is prior to this patch. For example, Secure Execution environments will take the local mapping path as it does prior to this patch.
Message-ID: <[email protected]>
--- arch/s390/kvm/interrupt.c | 87 ++++++++++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 24 deletions(-)
arch/s390/kvm/interrupt.c +63 -24
@@ -2892,41 +2892,80 @@ static unsigned long get_ind_bit(__u64 addr, unsigned long bit_nr, bool swap)return swap ? (bit ^ (BITS_PER_LONG -1 )) : bit; } +static struct s390_map_info *get_map_info (struct s390_io_adapter *adapter, +u64 addr) +{ +struct s390_map_info *map; + +if (!adapter) +return NULL ; + +list_for_each_entry (map, &adapter->maps, list) { +if (map->addr == addr) +return map; + } +return NULL ; +} +static int adapter_indicators_set (struct kvm *kvm,struct s390_io_adapter *adapter,struct kvm_s390_adapter_int *adapter_int) {unsigned long bit;int summary_set, idx; -struct page *ind_page, *summary_page; +struct s390_map_info *ind_info, *summary_info;void *map; +struct page *ind_page, *summary_page; +unsigned long flags; - ind_page =pin_map_page (kvm, adapter_int->ind_addr,0 ); -if (!ind_page) -return -1 ; - summary_page =pin_map_page (kvm, adapter_int->summary_addr,0 ); -if (!summary_page) { + ind_page =NULL ; + +spin_lock_irqsave (&adapter->maps_lock, flags); + ind_info =get_map_info (adapter, adapter_int->ind_addr); +if (!ind_info) { +spin_unlock_irqrestore (&adapter->maps_lock, flags); + ind_page =pin_map_page (kvm, adapter_int->ind_addr,0 ); +if (!ind_page) +return -1 ; + idx =srcu_read_lock (&kvm->srcu); + map =page_address (ind_page); + bit =get_ind_bit (adapter_int->ind_addr, + adapter_int->ind_offset, adapter->swap); +set_bit (bit, map); +mark_page_dirty (kvm, adapter_int->ind_gaddr >>PAGE_SHIFT ); +set_page_dirty_lock (ind_page); +srcu_read_unlock (&kvm->srcu, idx);unpin_user_page (ind_page); -return -1 ; + }else { + map =page_address (ind_info->page); + bit =get_ind_bit (ind_info->addr, adapter_int->ind_offset, adapter->swap); +set_bit (bit, map); +spin_unlock_irqrestore (&adapter->maps_lock, flags); + } +spin_lock_irqsave (&adapter->maps_lock, flags); + summary_info =get_map_info (adapter, adapter_int->summary_addr); +if (!summary_info) { +spin_unlock_irqrestore (&adapter->maps_lock, flags); + summary_page =pin_map_page (kvm, adapter_int->summary_addr,0 ); +if (WARN_ON_ONCE (!summary_page)) +return -1 ; + idx =srcu_read_lock (&kvm->srcu); + map =page_address (summary_page); + bit =get_ind_bit (adapter_int->summary_addr, + adapter_int->summary_offset, adapter->swap); + summary_set =test_and_set_bit (bit, map); +mark_page_dirty (kvm, adapter_int->summary_gaddr >>PAGE_SHIFT ); +set_page_dirty_lock (summary_page); +srcu_read_unlock (&kvm->srcu, idx); +unpin_user_page (summary_page); + }else { + map =page_address (summary_info->page); + bit =get_ind_bit (summary_info->addr, adapter_int->summary_offset, + adapter->swap); + summary_set =test_and_set_bit (bit, map); +spin_unlock_irqrestore (&adapter->maps_lock, flags); } - idx =srcu_read_lock (&kvm->srcu); - map =page_address (ind_page); - bit =get_ind_bit (adapter_int->ind_addr, - adapter_int->ind_offset, adapter->swap); -set_bit (bit, map); -mark_page_dirty (kvm, adapter_int->ind_gaddr >>PAGE_SHIFT ); -set_page_dirty_lock (ind_page); - map =page_address (summary_page); - bit =get_ind_bit (adapter_int->summary_addr, - adapter_int->summary_offset, adapter->swap); - summary_set =test_and_set_bit (bit, map); -mark_page_dirty (kvm, adapter_int->summary_gaddr >>PAGE_SHIFT ); -set_page_dirty_lock (summary_page); -srcu_read_unlock (&kvm->srcu, idx); - -unpin_user_page (ind_page); -unpin_user_page (summary_page);return summary_set ?0 :1 ; }
Signature · 1 line
2.54.0
Claudio Imbrenda
maintainer[GIT PULL v1 17/17] KVM: s390: Introducing kvm_arch_set_irq_inatomic fast inject
In reply to Claudio ImbrendaFrom: Douglas Freimuth <[email protected]>
s390 needs a fast path for irq injection, and along those lines we introduce kvm_arch_set_irq_inatomic. Instead of placing all interrupts on the global work queue as it does today, this patch provides a fast path for irq injection.
The inatomic fast path cannot lose control since it is running with interrupts disabled. This meant making the following changes that exist on the slow path today. First, the adapter_indicators page needs to be mapped since it is accessed with interrupts disabled, so we added map/unmap functions. Second, access to shared resources between the fast and slow paths needed to be changed from mutex and semaphores to spin_lock's. Finally, the memory allocation on the slow path utilizes GFP_KERNEL_ACCOUNT but we had to implement the fast path with GFP_ATOMIC allocation. Each of these enhancements were required to prevent blocking on the fast inject path.
Fencing of Fast Inject in Secure Execution environments is enabled in the patch series by not mapping adapter indicator pages. In Secure Execution environments the path of execution available before this patch is followed.
Statistical counters have been added to enable analysis of irq injection on the fast path and slow path including io_390_inatomic, io_flic_inject_airq, io_set_adapter_int and io_390_inatomic_no_inject. The no inject counter captures adapter masked, coalesced and suppressed interrupts.
Message-ID: <[email protected]>
--- arch/s390/include/asm/kvm_host.h | 6 +- arch/s390/kvm/intercept.c | 5 +- arch/s390/kvm/interrupt.c | 265 ++++++++++++++++++++++++------- arch/s390/kvm/kvm-s390.c | 27 +++- arch/s390/kvm/kvm-s390.h | 3 +- 5 files changed, 241 insertions(+), 65 deletions(-)
arch/s390/include/asm/kvm_host.h +5 -1
@@ -359,7 +359,7 @@ struct kvm_s390_float_interrupt {struct kvm_s390_mchk_info mchk;struct kvm_s390_ext_info srv_signal;int last_sleep_cpu; -struct mutex ais_lock; +spinlock_t ais_lock;u8 simm;u8 nimm; };
@@ -450,6 +450,10 @@ struct kvm_vm_stat {u64 inject_io;u64 io_390_adapter_map;u64 io_390_adapter_unmap; +u64 io_390_inatomic; +u64 io_flic_inject_airq; +u64 io_set_adapter_int; +u64 io_390_inatomic_no_inject;u64 inject_float_mchk;u64 inject_pfault_done;u64 inject_service_signal;
arch/s390/kvm/intercept.c +3 -2
@@ -517,8 +517,9 @@ static int handle_pv_spx(struct kvm_vcpu *vcpu)static int handle_pv_sclp (struct kvm_vcpu *vcpu) {struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int; +unsigned long flags; -spin_lock (&fi->lock); +spin_lock_irqsave (&fi->lock, flags);/* * 2 cases: * a: an sccb answering interrupt was already pending or in flight.
@@ -534,7 +535,7 @@ static int handle_pv_sclp(struct kvm_vcpu *vcpu) fi->srv_signal.ext_params |=0x43000 ;set_bit (IRQ_PEND_EXT_SERVICE , &fi->pending_irqs);clear_bit (IRQ_PEND_EXT_SERVICE , &fi->masked_irqs); -spin_unlock (&fi->lock); +spin_unlock_irqrestore (&fi->lock, flags);return 0 ; }
arch/s390/kvm/interrupt.c +208 -57
589 lines not on this page · raw message
arch/s390/kvm/kvm-s390.c +23 -4
@@ -70,6 +70,10 @@ const struct kvm_stats_desc kvm_vm_stats_desc[] = {STATS_DESC_COUNTER (VM , inject_io),STATS_DESC_COUNTER (VM , io_390_adapter_map),STATS_DESC_COUNTER (VM , io_390_adapter_unmap), +STATS_DESC_COUNTER (VM , io_390_inatomic), +STATS_DESC_COUNTER (VM , io_flic_inject_airq), +STATS_DESC_COUNTER (VM , io_set_adapter_int), +STATS_DESC_COUNTER (VM , io_390_inatomic_no_inject),STATS_DESC_COUNTER (VM , inject_float_mchk),STATS_DESC_COUNTER (VM , inject_pfault_done), STATS_DESC_COUNTER(VM, inject_service_signal),
@@ -2877,6 +2881,7 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)void __user *argp = (void __user *)arg;struct kvm_device_attr attr;int r; +struct kvm_s390_interrupt_info *inti;switch (ioctl) {case KVM_S390_INTERRUPT : {
@@ -2885,7 +2890,12 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) r = -EFAULT ;if (copy_from_user (&s390int, argp,sizeof (s390int)))break ; - r =kvm_s390_inject_vm (kvm, &s390int); + inti =kzalloc_obj (*inti,GFP_KERNEL_ACCOUNT ); +if (!inti) +return -ENOMEM ; + r =kvm_s390_inject_vm (kvm, &s390int, inti); +if (r) +kfree (inti);break ; }case KVM_CREATE_IRQCHIP : {
@@ -3286,7 +3296,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)mutex_unlock (&kvm->lock); } -mutex_init (&kvm->arch.float_int.ais_lock); +spin_lock_init (&kvm->arch.float_int.ais_lock);spin_lock_init (&kvm->arch.float_int.lock);for (i =0 ; i <FIRQ_LIST_COUNT ; i++)INIT_LIST_HEAD (&kvm->arch.float_int.lists[i]);
@@ -4408,19 +4418,28 @@ int kvm_s390_try_set_tod_clock(struct kvm *kvm, const struct kvm_s390_vm_tod_clo }static void __kvm_inject_pfault_token (struct kvm_vcpu *vcpu,bool start_token, -unsigned long token) +unsigned long token) {struct kvm_s390_interrupt inti;struct kvm_s390_irq irq; +struct kvm_s390_interrupt_info *inti_mem =NULL ; +int ret =0 ;if (start_token) { irq.u.ext.ext_params2 = token; irq.type =KVM_S390_INT_PFAULT_INIT ;WARN_ON_ONCE (kvm_s390_inject_vcpu (vcpu, &irq)); }else { + inti_mem =kzalloc_obj (*inti_mem,GFP_KERNEL_ACCOUNT ); +if (WARN_ON_ONCE (!inti_mem)) +return ; + inti.type =KVM_S390_INT_PFAULT_DONE ; inti.parm64 = token; -WARN_ON_ONCE (kvm_s390_inject_vm (vcpu->kvm, &inti)); + ret =kvm_s390_inject_vm (vcpu->kvm, &inti, inti_mem); +if (ret) +kfree (inti_mem); +WARN_ON_ONCE (ret); } }
arch/s390/kvm/kvm-s390.h +2 -1
@@ -376,7 +376,8 @@ int __must_check kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu);void kvm_s390_clear_local_irqs (struct kvm_vcpu *vcpu);void kvm_s390_clear_float_irqs (struct kvm *kvm);int __must_check kvm_s390_inject_vm (struct kvm *kvm, -struct kvm_s390_interrupt *s390int); +struct kvm_s390_interrupt *s390int, +struct kvm_s390_interrupt_info *inti);int __must_check kvm_s390_inject_vcpu (struct kvm_vcpu *vcpu,struct kvm_s390_irq *irq); static inline int kvm_s390_inject_prog_irq(struct kvm_vcpu *vcpu,
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [GIT PULL v1 09/17] KVM: s390: Document the KVM_CAP_S390_HPAGE_2G capability
In reply to Claudio ImbrendaThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing mutual exclusivity check between KVM_CAP_S390_HPAGE_2G and KVM_S390_VM_MEM_ENABLE_CMMA allows conflicting features, leading to silent loss of CMMA state. --
commit d788facb209d12a096219ba2f554a3019dcb380e
Author: Claudio Imbrenda <[email protected]>
KVM: s390: Document the KVM_CAP_S390_HPAGE_2G capability
Document the KVM_CAP_S390_HPAGE_2G capability, which behaves very similarly to the existing KVM_CAP_S390_HPAGE_1M.
Quoted 4 lines
Documentation/virt/kvm/api.rst +0
-0
[ ... ]
Quoted 6 lines
Documentation/virt/kvm/api.rst +2
-0@@ -8905,6 +8905,21 @@ helpful if user space wants to emulate instructions which are not This capability can be enabled dynamically even if VCPUs were already created and are running. +7.47 KVM_CAP_S390_HPAGE_2G +--------------------------
Documentation/virt/kvm/api.rst helpful if user space wants to emulate instructions which are not · line 8919
Quoted 10 lines
Documentation/virt/kvm/api.rst +10
-0+ +:Architectures: s390 +:Parameters: none +:Returns: 0 on success; -EINVAL if hpage_2g module parameter was not set, + cmma is enabled, or the VM has the KVM_VM_S390_UCONTROL + flag set; -EBUSY if vCPUs were already created for the VM. + +With this capability the KVM support for memory backing with 2g pages +through hugetlbfs can be enabled for a VM. After the capability is +enabled, cmma can't be enabled anymore and pfmfi and the storage key
[Severity: High]
This is a pre-existing issue, but does the implementation actually enforce this restriction when enabling CMMA?
Looking at arch/s390/kvm/kvm-s390.c:kvm_s390_set_mem_control(), when KVM_S390_VM_MEM_ENABLE_CMMA is called:
else {
kvm->arch.use_cmma = 1;
/* Not compatible with cmma. */
kvm->arch.use_pfmfi = 0;
ret = 0;
}It appears it sets kvm->arch.use_cmma = 1 without verifying if GMAP_FLAG_ALLOW_HPAGE_2G (or 1M) has already been enabled in the gmap flags. If userspace enables the 2G hugepage capability first and subsequently calls the KVM_S390_VM_MEM_ENABLE_CMMA ioctl, could this allow conflicting features?
When both are enabled, the MMU table walker (_dat_walk_gfn_range) skips over huge pages during CMMA operations, which might lead to CMMA state for hugepages being silently lost. Could this cause guest memory corruption or incorrect functional behavior during live migration?
Quoted 6 lines
Documentation/virt/kvm/api.rst +3
-0+interpretation are disabled. If cmma has already been enabled or the +hpage_2g module parameter is not set to 1, -EINVAL is returned. + 8. Other capabilities. ======================
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
[email protected]
AI reviewRe: [GIT PULL v1 07/17] KVM: s390: Add capability to support 2G hugepages
In reply to Claudio ImbrendaThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Userspace can simultaneously enable both CMMA and huge pages (1M and 2G), bypassing mutual exclusivity, because KVM_S390_VM_MEM_ENABLE_CMMA does not check if huge pages are already enabled. --
commit 98eba733f54412a163121c369883f11ed5ca35db
Author: Claudio Imbrenda <[email protected]>
KVM: s390: Add capability to support 2G hugepages
This commit adds the KVM_CAP_S390_HPAGE_2G capability to signal to userspace that 2G hugepages may be used to back the guest. It also implements the necessary gmap flag enablement and propagation for the new hugepage size.
Quoted 4 lines
arch/s390/kvm/kvm-s390.c +0
-0
[ ... ]
arch/s390/kvm/kvm-s390.c int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap) · line 914
Quoted 9 lines
arch/s390/kvm/kvm-s390.c +5
-0@@ -902,6 +907,27 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap)VM_EVENT (kvm,3 ,"ENABLE: CAP_S390_HPAGE %s" , r ?"(not available)" :"(success)" );break ; +case KVM_CAP_S390_HPAGE_2G : +mutex_lock (&kvm->lock); +if (kvm->created_vcpus) { + r = -EBUSY ; + }else if (!hpage_2g || kvm->arch.use_cmma ||kvm_is_ucontrol (kvm)) {
[Severity: High]
This is a pre-existing issue, but could userspace bypass this mutual exclusivity check between CMMA and huge pages?
When enabling huge pages via KVM_CAP_S390_HPAGE_1M or KVM_CAP_S390_HPAGE_2G, KVM correctly rejects the operation if kvm->arch.use_cmma is already set.
However, if userspace enables huge pages first, and then enables CMMA, kvm_s390_set_mem_control() does not appear to verify if huge pages are already active:
arch/s390/kvm/kvm-s390.c:kvm_s390_set_mem_control() {
...
case KVM_S390_VM_MEM_ENABLE_CMMA:
...
mutex_lock(&kvm->lock);
if (kvm->created_vcpus)
ret = -EBUSY;
else {
kvm->arch.use_cmma = 1;
/* Not compatible with cmma. */
kvm->arch.use_pfmfi = 0;
ret = 0;
}
mutex_unlock(&kvm->lock);
...
}Does this sequence allow the guest to run with both kvm->arch.use_cmma and GMAP_FLAG_ALLOW_HPAGE_2G (or 1M) enabled simultaneously?
If so, and the guest executes the ESSA instruction on a huge page, would this lead to KVM entering an infinite intercept loop that stalls the vCPU, or cause undefined hardware behavior if migration mode is inactive?
Quoted 13 lines
arch/s390/kvm/kvm-s390.c +13
-0+ r = -EINVAL ; + }else { + r =0 ; +set_bit (GMAP_FLAG_ALLOW_HPAGE_2G , &kvm->arch.gmap->flags); +/* +* We might have to create fake 4k page +* tables. To avoid that the hardware works on +* stale PGSTEs, we emulate these instructions. +*/ + kvm->arch.use_skf =0 ; + kvm->arch.use_pfmfi =0 ; + } +mutex_unlock (&kvm->lock);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
[email protected]
AI reviewRe: [GIT PULL v1 10/17] KVM: s390: Initialize KVM_S390_GET_CMMA_BITS memory
In reply to Claudio ImbrendaThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] In dat_peek_cmma(), if the provided start guest frame number (GFN) is out of bounds, _dat_walk_gfn_range() immediately returns -EFAULT without executing any callbacks. Consequently, state.end remains 0. The function then computes *count = state.end - start, which underflows into a large unsigned integer. This underflow bypasses the error check and causes kvm_s390_get_cmma_bits() to perform a massive out-of-bounds read and copy kernel memory to userspace. --
commit d8e920ce2bbd8785a01a3239ce6dc856e44c18b4
Author: Christian Borntraeger <[email protected]>
KVM: s390: Initialize KVM_S390_GET_CMMA_BITS memory
This commit changes the output buffer allocation in kvm_s390_get_cmma_bits() from vmalloc to vzalloc. This prevents unmapped or clean pages from exposing uninitialized kernel memory to userspace during migration.
Message-ID: <[email protected]>
arch/s390/kvm/kvm-s390.c static int kvm_s390_get_cmma_bits(struct kvm *kvm, · line 2287
Quoted 10 lines
arch/s390/kvm/kvm-s390.c +1
-1@@ -2284,7 +2284,7 @@ static int kvm_s390_get_cmma_bits(struct kvm *kvm,return 0 ; } - values =vmalloc (args->count); + values =vzalloc (args->count);
[Severity: Critical]
This is a pre-existing issue, but does the error handling in the peek path allow an underflow of args->count that leads to an out-of-bounds read later?
If an out-of-bounds start_gfn is passed, dat_peek_cmma() calls _dat_walk_gfn_range() which returns -EFAULT immediately, leaving state.end at 0:
arch/s390/kvm/dat.c:dat_peek_cmma() {
...
rc = _dat_walk_gfn_range(start, start + *count, asce, &ops, DAT_WALK_DEFAULT, &state);
*count = state.end - start;
/* Return success if at least one value was saved, otherwise an error. */
return (rc == -EFAULT && *count > 0) ? 0 : rc;
}If start is greater than 0 and state.end is 0, *count will underflow to a large unsigned integer. Because this underflowed *count is greater than 0, dat_peek_cmma() masks the -EFAULT and incorrectly returns 0 for success.
When execution continues in kvm_s390_get_cmma_bits(), this underflowed args->count is passed directly to copy_to_user():
if (copy_to_user((void __user *)args->values, values, args->count)) ret = -EFAULT;
Can this allow a user to craft a start_gfn that triggers this underflow and copies memory beyond the vzalloc buffer to userspace?
Quoted 3 lines
arch/s390/kvm/kvm-s390.c +0
-0if (!values)return -ENOMEM ;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
[email protected]
AI reviewRe: [GIT PULL v1 16/17] KVM: s390: Enable adapter_indicators_set to use mapped pages
In reply to Claudio ImbrendaThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] Missing KVM dirty page tracking in fast path for mapped adapter indicators breaks live migration.…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Missing KVM dirty page tracking in fast path for mapped adapter indicators breaks live migration.
- [High] Atomicity violation when pinning the summary page fails leaves the guest hardware state inconsistent.
- [High] Host-side denial of service vulnerability via unprivileged userspace-reachable WARN_ON_ONCE. --
commit 65f7550eaa09f7cd9feb26fff5319f4be6fecb0c
Author: Douglas Freimuth <[email protected]>
KVM: s390: Enable adapter_indicators_set to use mapped pages
This patch optimizes the s390 adapter_indicators_set function to use long-term mapped pages when available. If pages are mapped, it processes the interrupt on a fast path; otherwise, it falls back to the slow path pinning.
Message-ID: <[email protected]>
Quoted 4 lines
arch/s390/kvm/interrupt.c +0
-0
[ ... ]
Quoted 1 line
arch/s390/kvm/interrupt.c +0
-0@@ -2892,41 +2892,80 @@ static unsigned long get_ind_bit(__u64 addr, unsigned long bit_nr, bool swap)
[ ... ]
Quoted 32 lines
static int adapter_indicators_set(struct kvm *kvm,
arch/s390/kvm/interrupt.c +18
-6struct s390_io_adapter *adapter, struct kvm_s390_adapter_int *adapter_int) { unsigned long bit;int summary_set, idx; -struct page *ind_page, *summary_page; +struct s390_map_info *ind_info, *summary_info;void *map; +struct page *ind_page, *summary_page; +unsigned long flags; - ind_page =pin_map_page (kvm, adapter_int->ind_addr,0 ); -if (!ind_page) -return -1 ; - summary_page =pin_map_page (kvm, adapter_int->summary_addr,0 ); -if (!summary_page) { + ind_page =NULL ; + +spin_lock_irqsave (&adapter->maps_lock, flags); + ind_info =get_map_info (adapter, adapter_int->ind_addr); +if (!ind_info) { +spin_unlock_irqrestore (&adapter->maps_lock, flags); + ind_page =pin_map_page (kvm, adapter_int->ind_addr,0 ); +if (!ind_page) +return -1 ; + idx =srcu_read_lock (&kvm->srcu); + map =page_address (ind_page); + bit =get_ind_bit (adapter_int->ind_addr, + adapter_int->ind_offset, adapter->swap); +set_bit (bit, map); +mark_page_dirty (kvm, adapter_int->ind_gaddr >>PAGE_SHIFT );
arch/s390/kvm/interrupt.c static unsigned long get_ind_bit(__u64 addr, unsigned long bit_nr, bool swap) · line 2944
Quoted 10 lines
arch/s390/kvm/interrupt.c +8
-1+set_page_dirty_lock (ind_page); +srcu_read_unlock (&kvm->srcu, idx);unpin_user_page (ind_page); -return -1 ; + }else { + map =page_address (ind_info->page); + bit =get_ind_bit (ind_info->addr, adapter_int->ind_offset, adapter->swap); +set_bit (bit, map); +spin_unlock_irqrestore (&adapter->maps_lock, flags); + }
[Severity: High]
When updating the mapped indicator page in this fast path branch, does this skip calling mark_page_dirty() and set_page_dirty_lock()? Could skipping the dirty page logging cause the destination VM to resume with stale memory state during live migration?
arch/s390/kvm/interrupt.c static unsigned long get_ind_bit(__u64 addr, unsigned long bit_nr, bool swap) · line 2950
Quoted 6 lines
arch/s390/kvm/interrupt.c +6
-0+spin_lock_irqsave (&adapter->maps_lock, flags); + summary_info =get_map_info (adapter, adapter_int->summary_addr); +if (!summary_info) { +spin_unlock_irqrestore (&adapter->maps_lock, flags); + summary_page =pin_map_page (kvm, adapter_int->summary_addr,0 ); +if (WARN_ON_ONCE (!summary_page))
[Severity: High]
Since summary_addr is provided by userspace, can an invalid address intentionally trigger this WARN_ON_ONCE()? Should this return an error instead of asserting to avoid spamming the host kernel log?
arch/s390/kvm/interrupt.c
Quoted 1 line
arch/s390/kvm/interrupt.c +1
-0+return -1 ;
[Severity: High]
If pin_map_page() fails for the summary page and returns -1 here, does this leave the indicator bit already set in guest memory without its corresponding summary bit? The original code pinned both pages before modifying memory.
Quoted 6 lines
arch/s390/kvm/interrupt.c +6
-0+ idx =srcu_read_lock (&kvm->srcu); + map =page_address (summary_page); + bit =get_ind_bit (adapter_int->summary_addr, + adapter_int->summary_offset, adapter->swap); + summary_set =test_and_set_bit (bit, map); +mark_page_dirty (kvm, adapter_int->summary_gaddr >>PAGE_SHIFT );
arch/s390/kvm/interrupt.c static unsigned long get_ind_bit(__u64 addr, unsigned long bit_nr, bool swap) · line 2967
Quoted 10 lines
arch/s390/kvm/interrupt.c +9
-0+set_page_dirty_lock (summary_page); +srcu_read_unlock (&kvm->srcu, idx); +unpin_user_page (summary_page); + }else { + map =page_address (summary_info->page); + bit =get_ind_bit (summary_info->addr, adapter_int->summary_offset, + adapter->swap); + summary_set =test_and_set_bit (bit, map); +spin_unlock_irqrestore (&adapter->maps_lock, flags); }
[Severity: High]
Similar to the indicator fast path, does this skip calling mark_page_dirty() when updating the summary bit?
Quoted 20 lines
arch/s390/kvm/interrupt.c +0
-17- idx =srcu_read_lock (&kvm->srcu); - map =page_address (ind_page); - bit =get_ind_bit (adapter_int->ind_addr, - adapter_int->ind_offset, adapter->swap); -set_bit (bit, map); -mark_page_dirty (kvm, adapter_int->ind_gaddr >>PAGE_SHIFT ); -set_page_dirty_lock (ind_page); - map =page_address (summary_page); - bit =get_ind_bit (adapter_int->summary_addr, - adapter_int->summary_offset, adapter->swap); - summary_set =test_and_set_bit (bit, map); -mark_page_dirty (kvm, adapter_int->summary_gaddr >>PAGE_SHIFT ); -set_page_dirty_lock (summary_page); -srcu_read_unlock (&kvm->srcu, idx); - -unpin_user_page (ind_page); -unpin_user_page (summary_page);return summary_set ?0 :1 ; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=16
[email protected]
AI reviewRe: [GIT PULL v1 15/17] KVM: s390: Add map/unmap ioctl and clean mappings post-guest
In reply to Claudio ImbrendaThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The newly added `!addr` check in `kvm_s390_adapter_map` and `kvm_s390_adapter_unmap` incorrectly…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The newly added !addr check in kvm_s390_adapter_map and kvm_s390_adapter_unmap incorrectly rejects GPA 0. --
commit a3f46a9fac83fcdf67e052053b6923a848a2c796
Author: Douglas Freimuth <[email protected]>
KVM: s390: Add map/unmap ioctl and clean mappings post-guest
This commit adds map and unmap ioctls for s390 adapter set indicator pages. It introduces lifecycle tracking for mapped pages using pin_user_pages_remote and adds statistics counters to track map and unmap requests.
Message-ID: <[email protected]>
Quoted 3 lines
arch/s390/kvm/interrupt.c +0
-0
[ ... ]
arch/s390/kvm/interrupt.c int kvm_s390_mask_adapter(struct kvm *kvm, unsigned int id, bool masked) · line 2496
Quoted 10 lines
arch/s390/kvm/interrupt.c +10
-0+static int kvm_s390_adapter_map (struct kvm *kvm,unsigned int id,__u64 addr) +{ +struct s390_io_adapter *adapter =get_io_adapter (kvm, id); +struct s390_map_info *map; +unsigned long flags; +__u64 host_addr; +int ret, idx; + +if (!adapter || !addr) +return -EINVAL ;
[Severity: Low]
Does this address check incorrectly reject mapping guest physical address 0?
The ioctl argument addr represents a guest physical address. In the s390 architecture, guest physical address 0 points to the Prefix Save Area, which is a valid memory location. Treating an address of 0 as an invalid mapping request rejects a legitimate architectural address.
Quoted 2 lines
arch/s390/kvm/interrupt.c +2
-0+ + map =kzalloc_obj (*map,GFP_KERNEL_ACCOUNT );
[ ... ]
arch/s390/kvm/interrupt.c int kvm_s390_mask_adapter(struct kvm *kvm, unsigned int id, bool masked) · line 2545
Quoted 11 lines
arch/s390/kvm/interrupt.c +11
-0+static int kvm_s390_adapter_unmap (struct kvm *kvm,unsigned int id,__u64 addr) +{ +struct s390_io_adapter *adapter =get_io_adapter (kvm, id); +struct s390_map_info *map, *tmp, *map_to_free; +struct page *map_page_to_put =NULL ; +u64 map_addr_to_mark =0 ; +unsigned long flags; +int found =0 , idx; + +if (!adapter || !addr) +return -EINVAL ;
[Severity: Low]
Similarly here, should this unmap function allow guest physical address 0?
Quoted 2 lines
arch/s390/kvm/interrupt.c +2
-0+ +spin_lock_irqsave (&adapter->maps_lock, flags);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=15
[email protected]
AI reviewRe: [GIT PULL v1 17/17] KVM: s390: Introducing kvm_arch_set_irq_inatomic fast inject
In reply to Claudio ImbrendaThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Guest-reachable WARN_ON_ONCE during memory allocation failure in __kvm_inject_pfault_token
- [High] Preexisting guest-triggerable WARN_ON_ONCE on interrupt queue full
--
commit 4b098d22649d526ad54d46d65ab883c23baf1ae2
Author: Douglas Freimuth <[email protected]>
KVM: s390: Introducing kvm_arch_set_irq_inatomic fast inject
This commit introduces a fast path for irq injection to prevent blocking on the global work queue. It also converts shared resources between the fast and slow paths to spinlocks and adds statistical counters for analysis.
Message-ID: <[email protected]>
Quoted 4 lines
arch/s390/kvm/kvm-s390.c +0
-0
[ ... ]
Quoted 10 lines
arch/s390/kvm/kvm-s390.c +2
-1@@ -4429,19 +4439,28 @@ int kvm_s390_try_set_tod_clock(struct kvm *kvm, const struct kvm_s390_vm_tod_clo }static void __kvm_inject_pfault_token (struct kvm_vcpu *vcpu,bool start_token, -unsigned long token) +unsigned long token) {struct kvm_s390_interrupt inti;struct kvm_s390_irq irq; +struct kvm_s390_interrupt_info *inti_mem =NULL ;
arch/s390/kvm/kvm-s390.c int kvm_s390_try_set_tod_clock(struct kvm *kvm, const struct kvm_s390_vm_tod_clo · line 4456
Quoted 10 lines
arch/s390/kvm/kvm-s390.c +4
-0+int ret =0 ;if (start_token) { irq.u.ext.ext_params2 = token; irq.type =KVM_S390_INT_PFAULT_INIT ;WARN_ON_ONCE (kvm_s390_inject_vcpu (vcpu, &irq)); }else { + inti_mem =kzalloc_obj (*inti_mem,GFP_KERNEL_ACCOUNT ); +if (WARN_ON_ONCE (!inti_mem)) +return ;
[Severity: High]
This isn't a bug introduced by this patch, but does this guest-reachable assertion pose a denial of service risk? Under host memory pressure, this allocation can fail. Since a guest can trigger async page faults (and thus host memory allocations) by accessing swapped-out memory, an unprivileged guest could exhaust memory limits to force this allocation to fail. This would intentionally hit the WARN_ON_ONCE, potentially crashing the host if panic_on_warn is enabled.
arch/s390/kvm/kvm-s390.c int kvm_s390_try_set_tod_clock(struct kvm *kvm, const struct kvm_s390_vm_tod_clo · line 4442
Quoted 8 lines
arch/s390/kvm/kvm-s390.c +5
-1+ inti.type =KVM_S390_INT_PFAULT_DONE ; inti.parm64 = token; -WARN_ON_ONCE (kvm_s390_inject_vm (vcpu->kvm, &inti)); + ret =kvm_s390_inject_vm (vcpu->kvm, &inti, inti_mem); +if (ret) +kfree (inti_mem); +WARN_ON_ONCE (ret);
[Severity: High]
This is a pre-existing issue, but could this assertion also be driven by a malicious guest? A guest can trigger up to ASYNC_PF_PER_VCPU * KVM_MAX_VCPUS async page faults by continuously accessing unmapped pages and intentionally masking floating interrupts.
This would cause the host's floating interrupt list to hit its maximum capacity limit, causing kvm_s390_inject_vm() to return -EBUSY and triggering this WARN_ON_ONCE. Could this be converted to a pr_warn_once() or similar to avoid host denial of service?
Quoted 2 lines
arch/s390/kvm/kvm-s390.c +0
-0} }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=17