* [PATCH v3 1/6] KVM: s390: Add some useful mask macros
2026-04-02 15:01 [PATCH v3 0/6] KVM: s390: Enable 4k granularity for memslots Claudio Imbrenda
@ 2026-04-02 15:01 ` Claudio Imbrenda
2026-04-07 12:13 ` Steffen Eiden
2026-04-02 15:01 ` [PATCH v3 2/6] KVM: s390: Add alignment checks for hugepages Claudio Imbrenda
` (4 subsequent siblings)
5 siblings, 1 reply; 17+ messages in thread
From: Claudio Imbrenda @ 2026-04-02 15:01 UTC (permalink / raw)
To: linux-kernel
Cc: kvm, linux-s390, borntraeger, frankja, nrb, seiden, schlameuss,
gra, david
Add _{SEGMENT,REGION3}_FR_MASK, similar to _{SEGMENT,REGION3}_MASK, but
working on gfn/pfn instead of addresses. Use them in gaccess.c instead
of using the normal masks plus gpa_to_gfn().
Also add _PAGES_PER_{SEGMENT,REGION3} to make future code more readable.
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
arch/s390/kvm/dat.h | 5 +++++
arch/s390/kvm/gaccess.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/s390/kvm/dat.h b/arch/s390/kvm/dat.h
index 123e11dcd70d..809cd7a8adb7 100644
--- a/arch/s390/kvm/dat.h
+++ b/arch/s390/kvm/dat.h
@@ -104,6 +104,11 @@ union pte {
} tok;
};
+#define _SEGMENT_FR_MASK (_SEGMENT_MASK >> PAGE_SHIFT)
+#define _REGION3_FR_MASK (_REGION3_MASK >> PAGE_SHIFT)
+#define _PAGES_PER_SEGMENT _PAGE_ENTRIES
+#define _PAGES_PER_REGION3 (_PAGES_PER_SEGMENT * _CRST_ENTRIES)
+
/* Soft dirty, needed as macro for atomic operations on ptes */
#define _PAGE_SD 0x002
diff --git a/arch/s390/kvm/gaccess.c b/arch/s390/kvm/gaccess.c
index 4630b2a067ea..a2ad11e2bf61 100644
--- a/arch/s390/kvm/gaccess.c
+++ b/arch/s390/kvm/gaccess.c
@@ -1461,7 +1461,7 @@ static int _do_shadow_crste(struct gmap *sg, gpa_t raddr, union crste *host, uni
lockdep_assert_held(&sg->kvm->mmu_lock);
lockdep_assert_held(&sg->parent->children_lock);
- gfn = f->gfn & gpa_to_gfn(is_pmd(*table) ? _SEGMENT_MASK : _REGION3_MASK);
+ gfn = f->gfn & (is_pmd(*table) ? _SEGMENT_FR_MASK : _REGION3_FR_MASK);
scoped_guard(spinlock, &sg->host_to_rmap_lock)
rc = gmap_insert_rmap(sg, gfn, gpa_to_gfn(raddr), host->h.tt);
if (rc)
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH v3 1/6] KVM: s390: Add some useful mask macros
2026-04-02 15:01 ` [PATCH v3 1/6] KVM: s390: Add some useful mask macros Claudio Imbrenda
@ 2026-04-07 12:13 ` Steffen Eiden
0 siblings, 0 replies; 17+ messages in thread
From: Steffen Eiden @ 2026-04-07 12:13 UTC (permalink / raw)
To: Claudio Imbrenda
Cc: linux-kernel, kvm, linux-s390, borntraeger, frankja, nrb,
schlameuss, gra, david
On Thu, Apr 02, 2026 at 05:01:30PM +0200, Claudio Imbrenda wrote:
> Add _{SEGMENT,REGION3}_FR_MASK, similar to _{SEGMENT,REGION3}_MASK, but
> working on gfn/pfn instead of addresses. Use them in gaccess.c instead
> of using the normal masks plus gpa_to_gfn().
>
> Also add _PAGES_PER_{SEGMENT,REGION3} to make future code more readable.
>
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v3 2/6] KVM: s390: Add alignment checks for hugepages
2026-04-02 15:01 [PATCH v3 0/6] KVM: s390: Enable 4k granularity for memslots Claudio Imbrenda
2026-04-02 15:01 ` [PATCH v3 1/6] KVM: s390: Add some useful mask macros Claudio Imbrenda
@ 2026-04-02 15:01 ` Claudio Imbrenda
2026-04-07 12:30 ` Steffen Eiden
2026-04-02 15:01 ` [PATCH v3 3/6] KVM: s390: Allow 4k granularity for memslots Claudio Imbrenda
` (3 subsequent siblings)
5 siblings, 1 reply; 17+ messages in thread
From: Claudio Imbrenda @ 2026-04-02 15:01 UTC (permalink / raw)
To: linux-kernel
Cc: kvm, linux-s390, borntraeger, frankja, nrb, seiden, schlameuss,
gra, david
When backing a guest page with a large page, check that the alignment
of the guest page matches the alignment of the host physical page
backing it within the large page.
Also check that the memslot is large enough to fit the large page.
Those checks are currently not needed, because memslots are guaranteed
to be 1m-aligned, but this will change.
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
arch/s390/kvm/faultin.c | 2 +-
arch/s390/kvm/gmap.c | 32 ++++++++++++++++++++++++++------
arch/s390/kvm/gmap.h | 3 ++-
3 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/arch/s390/kvm/faultin.c b/arch/s390/kvm/faultin.c
index e37cd18200f5..ddf0ca71f374 100644
--- a/arch/s390/kvm/faultin.c
+++ b/arch/s390/kvm/faultin.c
@@ -109,7 +109,7 @@ int kvm_s390_faultin_gfn(struct kvm_vcpu *vcpu, struct kvm *kvm, struct guest_fa
scoped_guard(read_lock, &kvm->mmu_lock) {
if (!mmu_invalidate_retry_gfn(kvm, inv_seq, f->gfn)) {
f->valid = true;
- rc = gmap_link(mc, kvm->arch.gmap, f);
+ rc = gmap_link(mc, kvm->arch.gmap, f, slot);
kvm_release_faultin_page(kvm, f->page, !!rc, f->write_attempt);
f->page = NULL;
}
diff --git a/arch/s390/kvm/gmap.c b/arch/s390/kvm/gmap.c
index ef0c6ebfdde2..e3c1b070a11d 100644
--- a/arch/s390/kvm/gmap.c
+++ b/arch/s390/kvm/gmap.c
@@ -613,17 +613,37 @@ int gmap_try_fixup_minor(struct gmap *gmap, struct guest_fault *fault)
return rc;
}
-static inline bool gmap_2g_allowed(struct gmap *gmap, gfn_t gfn)
+static inline bool gmap_2g_allowed(struct gmap *gmap, struct guest_fault *f,
+ struct kvm_memory_slot *slot)
{
return false;
}
-static inline bool gmap_1m_allowed(struct gmap *gmap, gfn_t gfn)
+/**
+ * gmap_1m_allowed() - Check whether a 1M 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_1M flag is set for
+ * @gmap, whether the offset of the address in the 1M virtual frame is the
+ * same as the offset in the physical 1M frame, and finally whether the whole
+ * 1M page would fit in the given memslot.
+ *
+ * Return: true if a 1M hugepage is allowed to back the faulting address, false
+ * otherwise.
+ */
+static inline bool gmap_1m_allowed(struct gmap *gmap, struct guest_fault *f,
+ struct kvm_memory_slot *slot)
{
- return test_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &gmap->flags);
+ return test_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &gmap->flags) &&
+ !((f->gfn ^ f->pfn) & ~_SEGMENT_FR_MASK) &&
+ slot->base_gfn <= ALIGN_DOWN(f->gfn, _PAGES_PER_SEGMENT) &&
+ slot->base_gfn + slot->npages >= ALIGN(f->gfn + 1, _PAGES_PER_SEGMENT);
}
-int gmap_link(struct kvm_s390_mmu_cache *mc, struct gmap *gmap, struct guest_fault *f)
+int gmap_link(struct kvm_s390_mmu_cache *mc, struct gmap *gmap, struct guest_fault *f,
+ struct kvm_memory_slot *slot)
{
unsigned int order;
int rc, level;
@@ -633,9 +653,9 @@ int gmap_link(struct kvm_s390_mmu_cache *mc, struct gmap *gmap, struct guest_fau
level = TABLE_TYPE_PAGE_TABLE;
if (f->page) {
order = folio_order(page_folio(f->page));
- if (order >= get_order(_REGION3_SIZE) && gmap_2g_allowed(gmap, f->gfn))
+ if (order >= get_order(_REGION3_SIZE) && gmap_2g_allowed(gmap, f, slot))
level = TABLE_TYPE_REGION3;
- else if (order >= get_order(_SEGMENT_SIZE) && gmap_1m_allowed(gmap, f->gfn))
+ else if (order >= get_order(_SEGMENT_SIZE) && gmap_1m_allowed(gmap, f, slot))
level = TABLE_TYPE_SEGMENT;
}
rc = dat_link(mc, gmap->asce, level, uses_skeys(gmap), f);
diff --git a/arch/s390/kvm/gmap.h b/arch/s390/kvm/gmap.h
index ccb5cd751e31..a2f74587ddbf 100644
--- a/arch/s390/kvm/gmap.h
+++ b/arch/s390/kvm/gmap.h
@@ -90,7 +90,8 @@ struct gmap *gmap_new(struct kvm *kvm, gfn_t limit);
struct gmap *gmap_new_child(struct gmap *parent, gfn_t limit);
void gmap_remove_child(struct gmap *child);
void gmap_dispose(struct gmap *gmap);
-int gmap_link(struct kvm_s390_mmu_cache *mc, struct gmap *gmap, struct guest_fault *fault);
+int gmap_link(struct kvm_s390_mmu_cache *mc, struct gmap *gmap, struct guest_fault *fault,
+ struct kvm_memory_slot *slot);
void gmap_sync_dirty_log(struct gmap *gmap, gfn_t start, gfn_t end);
int gmap_set_limit(struct gmap *gmap, gfn_t limit);
int gmap_ucas_translate(struct kvm_s390_mmu_cache *mc, struct gmap *gmap, gpa_t *gaddr);
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH v3 2/6] KVM: s390: Add alignment checks for hugepages
2026-04-02 15:01 ` [PATCH v3 2/6] KVM: s390: Add alignment checks for hugepages Claudio Imbrenda
@ 2026-04-07 12:30 ` Steffen Eiden
0 siblings, 0 replies; 17+ messages in thread
From: Steffen Eiden @ 2026-04-07 12:30 UTC (permalink / raw)
To: Claudio Imbrenda
Cc: linux-kernel, kvm, linux-s390, borntraeger, frankja, nrb,
schlameuss, gra, david
On Thu, Apr 02, 2026 at 05:01:31PM +0200, Claudio Imbrenda wrote:
> When backing a guest page with a large page, check that the alignment
> of the guest page matches the alignment of the host physical page
> backing it within the large page.
>
> Also check that the memslot is large enough to fit the large page.
>
> Those checks are currently not needed, because memslots are guaranteed
> to be 1m-aligned, but this will change.
>
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v3 3/6] KVM: s390: Allow 4k granularity for memslots
2026-04-02 15:01 [PATCH v3 0/6] KVM: s390: Enable 4k granularity for memslots Claudio Imbrenda
2026-04-02 15:01 ` [PATCH v3 1/6] KVM: s390: Add some useful mask macros Claudio Imbrenda
2026-04-02 15:01 ` [PATCH v3 2/6] KVM: s390: Add alignment checks for hugepages Claudio Imbrenda
@ 2026-04-02 15:01 ` Claudio Imbrenda
2026-04-07 12:33 ` Steffen Eiden
2026-04-02 15:01 ` [PATCH v3 4/6] KVM: selftests: Remove 1M alignment requirement for s390 Claudio Imbrenda
` (2 subsequent siblings)
5 siblings, 1 reply; 17+ messages in thread
From: Claudio Imbrenda @ 2026-04-02 15:01 UTC (permalink / raw)
To: linux-kernel
Cc: kvm, linux-s390, borntraeger, frankja, nrb, seiden, schlameuss,
gra, david
Until now memslots on s390 needed to have 1M granularity and be 1M
aligned. Since the new gmap code can handle memslots with 4k
granularity and alignment, remove the restrictions.
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>
---
arch/s390/kvm/kvm-s390.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index bc7d6fa66eaf..be2a721e2574 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -5636,8 +5636,6 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
struct kvm_memory_slot *new,
enum kvm_mr_change change)
{
- gpa_t size;
-
if (kvm_is_ucontrol(kvm) && new->id < KVM_USER_MEM_SLOTS)
return -EINVAL;
@@ -5647,20 +5645,14 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
if (change != KVM_MR_DELETE && change != KVM_MR_FLAGS_ONLY) {
/*
- * A few sanity checks. We can have memory slots which have to be
- * located/ended at a segment boundary (1MB). The memory in userland is
- * ok to be fragmented into various different vmas. It is okay to mmap()
- * and munmap() stuff in this slot after doing this call at any time
+ * A few sanity checks. The memory in userland is ok to be
+ * fragmented into various different vmas. It is okay to mmap()
+ * and munmap() stuff in this slot after doing this call at any
+ * time.
*/
-
- if (new->userspace_addr & 0xffffful)
+ if (new->userspace_addr & ~PAGE_MASK)
return -EINVAL;
-
- size = new->npages * PAGE_SIZE;
- if (size & 0xffffful)
- return -EINVAL;
-
- if ((new->base_gfn * PAGE_SIZE) + size > kvm->arch.mem_limit)
+ if ((new->base_gfn + new->npages) * PAGE_SIZE > kvm->arch.mem_limit)
return -EINVAL;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH v3 3/6] KVM: s390: Allow 4k granularity for memslots
2026-04-02 15:01 ` [PATCH v3 3/6] KVM: s390: Allow 4k granularity for memslots Claudio Imbrenda
@ 2026-04-07 12:33 ` Steffen Eiden
0 siblings, 0 replies; 17+ messages in thread
From: Steffen Eiden @ 2026-04-07 12:33 UTC (permalink / raw)
To: Claudio Imbrenda
Cc: linux-kernel, kvm, linux-s390, borntraeger, frankja, nrb,
schlameuss, gra, david
On Thu, Apr 02, 2026 at 05:01:32PM +0200, Claudio Imbrenda wrote:
> Until now memslots on s390 needed to have 1M granularity and be 1M
> aligned. Since the new gmap code can handle memslots with 4k
> granularity and alignment, remove the restrictions.
>
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v3 4/6] KVM: selftests: Remove 1M alignment requirement for s390
2026-04-02 15:01 [PATCH v3 0/6] KVM: s390: Enable 4k granularity for memslots Claudio Imbrenda
` (2 preceding siblings ...)
2026-04-02 15:01 ` [PATCH v3 3/6] KVM: s390: Allow 4k granularity for memslots Claudio Imbrenda
@ 2026-04-02 15:01 ` Claudio Imbrenda
2026-04-07 12:44 ` Steffen Eiden
2026-04-02 15:01 ` [PATCH v3 5/6] KVM: s390: selftests: enable some common memory-related tests Claudio Imbrenda
2026-04-02 15:01 ` [PATCH v3 6/6] KVM: s390: ucontrol: Fix memslot handling Claudio Imbrenda
5 siblings, 1 reply; 17+ messages in thread
From: Claudio Imbrenda @ 2026-04-02 15:01 UTC (permalink / raw)
To: linux-kernel
Cc: kvm, linux-s390, borntraeger, frankja, nrb, seiden, schlameuss,
gra, david
Remove the 1M memslot alignment requirement for s390, since it is not
needed anymore.
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
tools/testing/selftests/kvm/dirty_log_test.c | 3 ---
tools/testing/selftests/kvm/include/kvm_util.h | 4 ----
tools/testing/selftests/kvm/kvm_page_table_test.c | 3 ---
tools/testing/selftests/kvm/lib/kvm_util.c | 9 +--------
tools/testing/selftests/kvm/lib/memstress.c | 4 ----
tools/testing/selftests/kvm/pre_fault_memory_test.c | 4 ----
tools/testing/selftests/kvm/set_memory_region_test.c | 9 +--------
7 files changed, 2 insertions(+), 34 deletions(-)
diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c
index d58a641b0e6a..7627b328f18a 100644
--- a/tools/testing/selftests/kvm/dirty_log_test.c
+++ b/tools/testing/selftests/kvm/dirty_log_test.c
@@ -641,9 +641,6 @@ static void run_test(enum vm_guest_mode mode, void *arg)
}
#ifdef __s390x__
- /* Align to 1M (segment size) */
- guest_test_phys_mem = align_down(guest_test_phys_mem, 1 << 20);
-
/*
* The workaround in guest_code() to write all pages prior to the first
* iteration isn't compatible with the dirty ring, as the dirty ring
diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h
index 8b39cb919f4f..f861242b4ae8 100644
--- a/tools/testing/selftests/kvm/include/kvm_util.h
+++ b/tools/testing/selftests/kvm/include/kvm_util.h
@@ -1127,10 +1127,6 @@ vm_adjust_num_guest_pages(enum vm_guest_mode mode, unsigned int num_guest_pages)
{
unsigned int n;
n = vm_num_guest_pages(mode, vm_num_host_pages(mode, num_guest_pages));
-#ifdef __s390x__
- /* s390 requires 1M aligned guest sizes */
- n = (n + 255) & ~255;
-#endif
return n;
}
diff --git a/tools/testing/selftests/kvm/kvm_page_table_test.c b/tools/testing/selftests/kvm/kvm_page_table_test.c
index dd8b12f626d3..c60a24a92829 100644
--- a/tools/testing/selftests/kvm/kvm_page_table_test.c
+++ b/tools/testing/selftests/kvm/kvm_page_table_test.c
@@ -261,9 +261,6 @@ static struct kvm_vm *pre_init_before_test(enum vm_guest_mode mode, void *arg)
guest_page_size;
else
guest_test_phys_mem = p->phys_offset;
-#ifdef __s390x__
- alignment = max(0x100000UL, alignment);
-#endif
guest_test_phys_mem = align_down(guest_test_phys_mem, alignment);
/* Set up the shared data structure test_args */
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index 1959bf556e88..f5e076591c64 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -985,7 +985,7 @@ void vm_mem_add(struct kvm_vm *vm, enum vm_mem_backing_src_type src_type,
struct userspace_mem_region *region;
size_t backing_src_pagesz = get_backing_src_pagesz(src_type);
size_t mem_size = npages * vm->page_size;
- size_t alignment;
+ size_t alignment = 1;
TEST_REQUIRE_SET_USER_MEMORY_REGION2();
@@ -1039,13 +1039,6 @@ void vm_mem_add(struct kvm_vm *vm, enum vm_mem_backing_src_type src_type,
TEST_ASSERT(region != NULL, "Insufficient Memory");
region->mmap_size = mem_size;
-#ifdef __s390x__
- /* On s390x, the host address must be aligned to 1M (due to PGSTEs) */
- alignment = 0x100000;
-#else
- alignment = 1;
-#endif
-
/*
* When using THP mmap is not guaranteed to returned a hugepage aligned
* address so we have to pad the mmap. Padding is not needed for HugeTLB
diff --git a/tools/testing/selftests/kvm/lib/memstress.c b/tools/testing/selftests/kvm/lib/memstress.c
index 557c0a0a5658..1ea735d66e15 100644
--- a/tools/testing/selftests/kvm/lib/memstress.c
+++ b/tools/testing/selftests/kvm/lib/memstress.c
@@ -196,10 +196,6 @@ struct kvm_vm *memstress_create_vm(enum vm_guest_mode mode, int nr_vcpus,
args->gpa = (region_end_gfn - guest_num_pages - 1) * args->guest_page_size;
args->gpa = align_down(args->gpa, backing_src_pagesz);
-#ifdef __s390x__
- /* Align to 1M (segment size) */
- args->gpa = align_down(args->gpa, 1 << 20);
-#endif
args->size = guest_num_pages * args->guest_page_size;
pr_info("guest physical test memory: [0x%lx, 0x%lx)\n",
args->gpa, args->gpa + args->size);
diff --git a/tools/testing/selftests/kvm/pre_fault_memory_test.c b/tools/testing/selftests/kvm/pre_fault_memory_test.c
index 93e603d91311..f3de0386ba7b 100644
--- a/tools/testing/selftests/kvm/pre_fault_memory_test.c
+++ b/tools/testing/selftests/kvm/pre_fault_memory_test.c
@@ -175,11 +175,7 @@ static void __test_pre_fault_memory(unsigned long vm_type, bool private)
alignment = guest_page_size = vm_guest_mode_params[VM_MODE_DEFAULT].page_size;
gpa = (vm->max_gfn - TEST_NPAGES) * guest_page_size;
-#ifdef __s390x__
- alignment = max(0x100000UL, guest_page_size);
-#else
alignment = SZ_2M;
-#endif
gpa = align_down(gpa, alignment);
gva = gpa & ((1ULL << (vm->va_bits - 1)) - 1);
diff --git a/tools/testing/selftests/kvm/set_memory_region_test.c b/tools/testing/selftests/kvm/set_memory_region_test.c
index 7fe427ff9b38..a398dc3a8c4b 100644
--- a/tools/testing/selftests/kvm/set_memory_region_test.c
+++ b/tools/testing/selftests/kvm/set_memory_region_test.c
@@ -413,14 +413,7 @@ static void test_add_max_memory_regions(void)
uint32_t max_mem_slots;
uint32_t slot;
void *mem, *mem_aligned, *mem_extra;
- size_t alignment;
-
-#ifdef __s390x__
- /* On s390x, the host address must be aligned to 1M (due to PGSTEs) */
- alignment = 0x100000;
-#else
- alignment = 1;
-#endif
+ size_t alignment = 1;
max_mem_slots = kvm_check_cap(KVM_CAP_NR_MEMSLOTS);
TEST_ASSERT(max_mem_slots > 0,
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH v3 4/6] KVM: selftests: Remove 1M alignment requirement for s390
2026-04-02 15:01 ` [PATCH v3 4/6] KVM: selftests: Remove 1M alignment requirement for s390 Claudio Imbrenda
@ 2026-04-07 12:44 ` Steffen Eiden
0 siblings, 0 replies; 17+ messages in thread
From: Steffen Eiden @ 2026-04-07 12:44 UTC (permalink / raw)
To: Claudio Imbrenda
Cc: linux-kernel, kvm, linux-s390, borntraeger, frankja, nrb,
schlameuss, gra, david
On Thu, Apr 02, 2026 at 05:01:33PM +0200, Claudio Imbrenda wrote:
> Remove the 1M memslot alignment requirement for s390, since it is not
> needed anymore.
>
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
You may want to add a testcase that deliberately wants to create a non-1M
aligned memslot.
Steffen
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v3 5/6] KVM: s390: selftests: enable some common memory-related tests
2026-04-02 15:01 [PATCH v3 0/6] KVM: s390: Enable 4k granularity for memslots Claudio Imbrenda
` (3 preceding siblings ...)
2026-04-02 15:01 ` [PATCH v3 4/6] KVM: selftests: Remove 1M alignment requirement for s390 Claudio Imbrenda
@ 2026-04-02 15:01 ` Claudio Imbrenda
2026-04-07 12:47 ` Steffen Eiden
2026-04-07 15:19 ` Steffen Eiden
2026-04-02 15:01 ` [PATCH v3 6/6] KVM: s390: ucontrol: Fix memslot handling Claudio Imbrenda
5 siblings, 2 replies; 17+ messages in thread
From: Claudio Imbrenda @ 2026-04-02 15:01 UTC (permalink / raw)
To: linux-kernel
Cc: kvm, linux-s390, borntraeger, frankja, nrb, seiden, schlameuss,
gra, david
Enable the following tests on s390:
* memslot_modification_stress_test
* memslot_perf_test
* mmu_stress_test
Since the first two tests are now supported on all architectures, move
them into TEST_GEN_PROGS_COMMON and out of the indiviual architectures.
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
tools/testing/selftests/kvm/Makefile.kvm | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm
index fdec90e85467..057f17d6b896 100644
--- a/tools/testing/selftests/kvm/Makefile.kvm
+++ b/tools/testing/selftests/kvm/Makefile.kvm
@@ -64,6 +64,8 @@ TEST_GEN_PROGS_COMMON += kvm_binary_stats_test
TEST_GEN_PROGS_COMMON += kvm_create_max_vcpus
TEST_GEN_PROGS_COMMON += kvm_page_table_test
TEST_GEN_PROGS_COMMON += set_memory_region_test
+TEST_GEN_PROGS_COMMON += memslot_modification_stress_test
+TEST_GEN_PROGS_COMMON += memslot_perf_test
# Compiled test targets
TEST_GEN_PROGS_x86 = $(TEST_GEN_PROGS_COMMON)
@@ -147,8 +149,6 @@ TEST_GEN_PROGS_x86 += coalesced_io_test
TEST_GEN_PROGS_x86 += dirty_log_perf_test
TEST_GEN_PROGS_x86 += guest_memfd_test
TEST_GEN_PROGS_x86 += hardware_disable_test
-TEST_GEN_PROGS_x86 += memslot_modification_stress_test
-TEST_GEN_PROGS_x86 += memslot_perf_test
TEST_GEN_PROGS_x86 += mmu_stress_test
TEST_GEN_PROGS_x86 += rseq_test
TEST_GEN_PROGS_x86 += steal_time
@@ -186,8 +186,6 @@ TEST_GEN_PROGS_arm64 += coalesced_io_test
TEST_GEN_PROGS_arm64 += dirty_log_perf_test
TEST_GEN_PROGS_arm64 += get-reg-list
TEST_GEN_PROGS_arm64 += guest_memfd_test
-TEST_GEN_PROGS_arm64 += memslot_modification_stress_test
-TEST_GEN_PROGS_arm64 += memslot_perf_test
TEST_GEN_PROGS_arm64 += mmu_stress_test
TEST_GEN_PROGS_arm64 += rseq_test
TEST_GEN_PROGS_arm64 += steal_time
@@ -205,6 +203,7 @@ TEST_GEN_PROGS_s390 += s390/ucontrol_test
TEST_GEN_PROGS_s390 += s390/user_operexec
TEST_GEN_PROGS_s390 += s390/keyop
TEST_GEN_PROGS_s390 += rseq_test
+TEST_GEN_PROGS_s390 += mmu_stress_test
TEST_GEN_PROGS_riscv = $(TEST_GEN_PROGS_COMMON)
TEST_GEN_PROGS_riscv += riscv/sbi_pmu_test
@@ -214,8 +213,6 @@ TEST_GEN_PROGS_riscv += arch_timer
TEST_GEN_PROGS_riscv += coalesced_io_test
TEST_GEN_PROGS_riscv += dirty_log_perf_test
TEST_GEN_PROGS_riscv += get-reg-list
-TEST_GEN_PROGS_riscv += memslot_modification_stress_test
-TEST_GEN_PROGS_riscv += memslot_perf_test
TEST_GEN_PROGS_riscv += mmu_stress_test
TEST_GEN_PROGS_riscv += rseq_test
TEST_GEN_PROGS_riscv += steal_time
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH v3 5/6] KVM: s390: selftests: enable some common memory-related tests
2026-04-02 15:01 ` [PATCH v3 5/6] KVM: s390: selftests: enable some common memory-related tests Claudio Imbrenda
@ 2026-04-07 12:47 ` Steffen Eiden
2026-04-07 13:04 ` Claudio Imbrenda
2026-04-07 15:19 ` Steffen Eiden
1 sibling, 1 reply; 17+ messages in thread
From: Steffen Eiden @ 2026-04-07 12:47 UTC (permalink / raw)
To: Claudio Imbrenda
Cc: linux-kernel, kvm, linux-s390, borntraeger, frankja, nrb,
schlameuss, gra, david
On Thu, Apr 02, 2026 at 05:01:34PM +0200, Claudio Imbrenda wrote:
> Enable the following tests on s390:
> * memslot_modification_stress_test
> * memslot_perf_test
> * mmu_stress_test
>
> Since the first two tests are now supported on all architectures, move
> them into TEST_GEN_PROGS_COMMON and out of the indiviual architectures.
>
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> ---
> tools/testing/selftests/kvm/Makefile.kvm | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm
> index fdec90e85467..057f17d6b896 100644
> --- a/tools/testing/selftests/kvm/Makefile.kvm
> +++ b/tools/testing/selftests/kvm/Makefile.kvm
> @@ -64,6 +64,8 @@ TEST_GEN_PROGS_COMMON += kvm_binary_stats_test
> TEST_GEN_PROGS_COMMON += kvm_create_max_vcpus
> TEST_GEN_PROGS_COMMON += kvm_page_table_test
> TEST_GEN_PROGS_COMMON += set_memory_region_test
> +TEST_GEN_PROGS_COMMON += memslot_modification_stress_test
> +TEST_GEN_PROGS_COMMON += memslot_perf_test
>
> # Compiled test targets
> TEST_GEN_PROGS_x86 = $(TEST_GEN_PROGS_COMMON)
> @@ -147,8 +149,6 @@ TEST_GEN_PROGS_x86 += coalesced_io_test
> TEST_GEN_PROGS_x86 += dirty_log_perf_test
> TEST_GEN_PROGS_x86 += guest_memfd_test
> TEST_GEN_PROGS_x86 += hardware_disable_test
> -TEST_GEN_PROGS_x86 += memslot_modification_stress_test
> -TEST_GEN_PROGS_x86 += memslot_perf_test
> TEST_GEN_PROGS_x86 += mmu_stress_test
> TEST_GEN_PROGS_x86 += rseq_test
> TEST_GEN_PROGS_x86 += steal_time
> @@ -186,8 +186,6 @@ TEST_GEN_PROGS_arm64 += coalesced_io_test
> TEST_GEN_PROGS_arm64 += dirty_log_memslot_perf_testperf_test
> TEST_GEN_PROGS_arm64 += get-reg-list
> TEST_GEN_PROGS_arm64 += guest_memfd_test
> -TEST_GEN_PROGS_arm64 += memslot_modification_stress_test
> -TEST_GEN_PROGS_arm64 += memslot_perf_test
> TEST_GEN_PROGS_arm64 += mmu_stress_test
> TEST_GEN_PROGS_arm64 += rseq_test
> TEST_GEN_PROGS_arm64 += steal_time
> @@ -205,6 +203,7 @@ TEST_GEN_PROGS_s390 += s390/ucontrol_test
> TEST_GEN_PROGS_s390 += s390/user_operexec
> TEST_GEN_PROGS_s390 += s390/keyop
> TEST_GEN_PROGS_s390 += rseq_test
> +TEST_GEN_PROGS_s390 += mmu_stress_test
>
> TEST_GEN_PROGS_riscv = $(TEST_GEN_PROGS_COMMON)
> TEST_GEN_PROGS_riscv += riscv/sbi_pmu_test
> @@ -214,8 +213,6 @@ TEST_GEN_PROGS_riscv += arch_timer
> TEST_GEN_PROGS_riscv += coalesced_io_test
> TEST_GEN_PROGS_riscv += dirty_log_perf_test
> TEST_GEN_PROGS_riscv += get-reg-list
> -TEST_GEN_PROGS_riscv += memslot_modification_stress_test
> -TEST_GEN_PROGS_riscv += memslot_perf_test
> TEST_GEN_PROGS_riscv += mmu_stress_test
> TEST_GEN_PROGS_riscv += rseq_test
> TEST_GEN_PROGS_riscv += steal_time
> --
I think you missed removing the loongarch targets.
Steffen
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 5/6] KVM: s390: selftests: enable some common memory-related tests
2026-04-07 12:47 ` Steffen Eiden
@ 2026-04-07 13:04 ` Claudio Imbrenda
2026-04-07 13:41 ` Steffen Eiden
0 siblings, 1 reply; 17+ messages in thread
From: Claudio Imbrenda @ 2026-04-07 13:04 UTC (permalink / raw)
To: Steffen Eiden
Cc: linux-kernel, kvm, linux-s390, borntraeger, frankja, nrb,
schlameuss, gra, david
On Tue, 7 Apr 2026 14:47:52 +0200
Steffen Eiden <seiden@linux.ibm.com> wrote:
> On Thu, Apr 02, 2026 at 05:01:34PM +0200, Claudio Imbrenda wrote:
> > Enable the following tests on s390:
> > * memslot_modification_stress_test
> > * memslot_perf_test
> > * mmu_stress_test
> >
> > Since the first two tests are now supported on all architectures, move
> > them into TEST_GEN_PROGS_COMMON and out of the indiviual architectures.
> >
> > Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> > ---
> > tools/testing/selftests/kvm/Makefile.kvm | 9 +++------
> > 1 file changed, 3 insertions(+), 6 deletions(-)
> >
> > diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm
> > index fdec90e85467..057f17d6b896 100644
> > --- a/tools/testing/selftests/kvm/Makefile.kvm
> > +++ b/tools/testing/selftests/kvm/Makefile.kvm
> > @@ -64,6 +64,8 @@ TEST_GEN_PROGS_COMMON += kvm_binary_stats_test
> > TEST_GEN_PROGS_COMMON += kvm_create_max_vcpus
> > TEST_GEN_PROGS_COMMON += kvm_page_table_test
> > TEST_GEN_PROGS_COMMON += set_memory_region_test
> > +TEST_GEN_PROGS_COMMON += memslot_modification_stress_test
> > +TEST_GEN_PROGS_COMMON += memslot_perf_test
[...]
> > TEST_GEN_PROGS_riscv = $(TEST_GEN_PROGS_COMMON)
> > TEST_GEN_PROGS_riscv += riscv/sbi_pmu_test
> > @@ -214,8 +213,6 @@ TEST_GEN_PROGS_riscv += arch_timer
> > TEST_GEN_PROGS_riscv += coalesced_io_test
> > TEST_GEN_PROGS_riscv += dirty_log_perf_test
> > TEST_GEN_PROGS_riscv += get-reg-list
> > -TEST_GEN_PROGS_riscv += memslot_modification_stress_test
> > -TEST_GEN_PROGS_riscv += memslot_perf_test
> > TEST_GEN_PROGS_riscv += mmu_stress_test
> > TEST_GEN_PROGS_riscv += rseq_test
> > TEST_GEN_PROGS_riscv += steal_time
> > --
>
> I think you missed removing the loongarch targets.
no, loongarch does *not* include TEST_GEN_PROGS_COMMON, so if I
remove them, they're gone
>
> Steffen
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 5/6] KVM: s390: selftests: enable some common memory-related tests
2026-04-07 13:04 ` Claudio Imbrenda
@ 2026-04-07 13:41 ` Steffen Eiden
0 siblings, 0 replies; 17+ messages in thread
From: Steffen Eiden @ 2026-04-07 13:41 UTC (permalink / raw)
To: Claudio Imbrenda
Cc: linux-kernel, kvm, linux-s390, borntraeger, frankja, nrb,
schlameuss, gra, david
On Tue, Apr 07, 2026 at 03:04:38PM +0200, Claudio Imbrenda wrote:
> On Tue, 7 Apr 2026 14:47:52 +0200
> Steffen Eiden <seiden@linux.ibm.com> wrote:
>
> > On Thu, Apr 02, 2026 at 05:01:34PM +0200, Claudio Imbrenda wrote:
> > > Enable the following tests on s390:
> > > * memslot_modification_stress_test
> > > * memslot_perf_test
> > > * mmu_stress_test
> > >
> > > Since the first two tests are now supported on all architectures, move
> > > them into TEST_GEN_PROGS_COMMON and out of the indiviual architectures.
> > >
> > > Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> > > ---
> > > tools/testing/selftests/kvm/Makefile.kvm | 9 +++------
> > > 1 file changed, 3 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm
> > > index fdec90e85467..057f17d6b896 100644
> > > --- a/tools/testing/selftests/kvm/Makefile.kvm
> > > +++ b/tools/testing/selftests/kvm/Makefile.kvm
> > > @@ -64,6 +64,8 @@ TEST_GEN_PROGS_COMMON += kvm_binary_stats_test
> > > TEST_GEN_PROGS_COMMON += kvm_create_max_vcpus
> > > TEST_GEN_PROGS_COMMON += kvm_page_table_test
> > > TEST_GEN_PROGS_COMMON += set_memory_region_test
> > > +TEST_GEN_PROGS_COMMON += memslot_modification_stress_test
> > > +TEST_GEN_PROGS_COMMON += memslot_perf_test
>
> [...]
>
> > > TEST_GEN_PROGS_riscv = $(TEST_GEN_PROGS_COMMON)
> > > TEST_GEN_PROGS_riscv += riscv/sbi_pmu_test
> > > @@ -214,8 +213,6 @@ TEST_GEN_PROGS_riscv += arch_timer
> > > TEST_GEN_PROGS_riscv += coalesced_io_test
> > > TEST_GEN_PROGS_riscv += dirty_log_perf_test
> > > TEST_GEN_PROGS_riscv += get-reg-list
> > > -TEST_GEN_PROGS_riscv += memslot_modification_stress_test
> > > -TEST_GEN_PROGS_riscv += memslot_perf_test
> > > TEST_GEN_PROGS_riscv += mmu_stress_test
> > > TEST_GEN_PROGS_riscv += rseq_test
> > > TEST_GEN_PROGS_riscv += steal_time
> > > --
> >
> > I think you missed removing the loongarch targets.
>
> no, loongarch does *not* include TEST_GEN_PROGS_COMMON, so if I
> remove them, they're gone
Ok, my bad. I just did a quick grep for the test names to look for missing
removals. I missed that little detail.
>
> >
> > Steffen
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 5/6] KVM: s390: selftests: enable some common memory-related tests
2026-04-02 15:01 ` [PATCH v3 5/6] KVM: s390: selftests: enable some common memory-related tests Claudio Imbrenda
2026-04-07 12:47 ` Steffen Eiden
@ 2026-04-07 15:19 ` Steffen Eiden
1 sibling, 0 replies; 17+ messages in thread
From: Steffen Eiden @ 2026-04-07 15:19 UTC (permalink / raw)
To: Claudio Imbrenda
Cc: linux-kernel, kvm, linux-s390, borntraeger, frankja, nrb,
schlameuss, gra, david
On Thu, Apr 02, 2026 at 05:01:34PM +0200, Claudio Imbrenda wrote:
> Enable the following tests on s390:
> * memslot_modification_stress_test
> * memslot_perf_test
> * mmu_stress_test
>
> Since the first two tests are now supported on all architectures, move
> them into TEST_GEN_PROGS_COMMON and out of the indiviual architectures.
>
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v3 6/6] KVM: s390: ucontrol: Fix memslot handling
2026-04-02 15:01 [PATCH v3 0/6] KVM: s390: Enable 4k granularity for memslots Claudio Imbrenda
` (4 preceding siblings ...)
2026-04-02 15:01 ` [PATCH v3 5/6] KVM: s390: selftests: enable some common memory-related tests Claudio Imbrenda
@ 2026-04-02 15:01 ` Claudio Imbrenda
2026-04-07 12:55 ` Steffen Eiden
5 siblings, 1 reply; 17+ messages in thread
From: Claudio Imbrenda @ 2026-04-02 15:01 UTC (permalink / raw)
To: linux-kernel
Cc: kvm, linux-s390, borntraeger, frankja, nrb, seiden, schlameuss,
gra, david
Fix memslots handling for UCONTROL guests. Attempts to delete user
memslots will fail, as they should, without the risk of a NULL pointer
dereference.
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
arch/s390/kvm/kvm-s390.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index be2a721e2574..435c3a1b74f8 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -5636,7 +5636,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
struct kvm_memory_slot *new,
enum kvm_mr_change change)
{
- if (kvm_is_ucontrol(kvm) && new->id < KVM_USER_MEM_SLOTS)
+ if (kvm_is_ucontrol(kvm) && new && new->id < KVM_USER_MEM_SLOTS)
return -EINVAL;
/* When we are protected, we should not change the memory slots */
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH v3 6/6] KVM: s390: ucontrol: Fix memslot handling
2026-04-02 15:01 ` [PATCH v3 6/6] KVM: s390: ucontrol: Fix memslot handling Claudio Imbrenda
@ 2026-04-07 12:55 ` Steffen Eiden
2026-04-07 13:05 ` Claudio Imbrenda
0 siblings, 1 reply; 17+ messages in thread
From: Steffen Eiden @ 2026-04-07 12:55 UTC (permalink / raw)
To: Claudio Imbrenda
Cc: linux-kernel, kvm, linux-s390, borntraeger, frankja, nrb,
schlameuss, gra, david
On Thu, Apr 02, 2026 at 05:01:35PM +0200, Claudio Imbrenda wrote:
> Fix memslots handling for UCONTROL guests. Attempts to delete user
> memslots will fail, as they should, without the risk of a NULL pointer
> dereference.
>
You may want to spend a fixes tag:
Fixes: 413c98f24c63 ("KVM: s390: fake memslot for ucontrol VMs")
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Steffen
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH v3 6/6] KVM: s390: ucontrol: Fix memslot handling
2026-04-07 12:55 ` Steffen Eiden
@ 2026-04-07 13:05 ` Claudio Imbrenda
0 siblings, 0 replies; 17+ messages in thread
From: Claudio Imbrenda @ 2026-04-07 13:05 UTC (permalink / raw)
To: Steffen Eiden
Cc: linux-kernel, kvm, linux-s390, borntraeger, frankja, nrb,
schlameuss, gra, david
On Tue, 7 Apr 2026 14:55:35 +0200
Steffen Eiden <seiden@linux.ibm.com> wrote:
> On Thu, Apr 02, 2026 at 05:01:35PM +0200, Claudio Imbrenda wrote:
> > Fix memslots handling for UCONTROL guests. Attempts to delete user
> > memslots will fail, as they should, without the risk of a NULL pointer
> > dereference.
> >
>
> You may want to spend a fixes tag:
>
> Fixes: 413c98f24c63 ("KVM: s390: fake memslot for ucontrol VMs")
indeed, I will fix it when picking, thanks
>
> > Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
>
> Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
>
> Steffen
^ permalink raw reply [flat|nested] 17+ messages in thread