From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org,
borntraeger@de.ibm.com, frankja@linux.ibm.com, nrb@linux.ibm.com,
seiden@linux.ibm.com, schlameuss@linux.ibm.com,
gra@linux.ibm.com, david@kernel.org
Subject: [PATCH v2 1/5] KVM: s390: Add some useful mask macros
Date: Wed, 1 Apr 2026 19:39:51 +0200 [thread overview]
Message-ID: <20260401173955.314821-2-imbrenda@linux.ibm.com> (raw)
In-Reply-To: <20260401173955.314821-1-imbrenda@linux.ibm.com>
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
next prev parent reply other threads:[~2026-04-01 17:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-01 17:39 [PATCH v2 0/5] KVM: s390: Enable 4k granularity for memslots Claudio Imbrenda
2026-04-01 17:39 ` Claudio Imbrenda [this message]
2026-04-01 17:39 ` [PATCH v2 2/5] KVM: s390: Add alignment checks for hugepages Claudio Imbrenda
2026-04-01 17:39 ` [PATCH v2 3/5] KVM: s390: Allow 4k granularity for memslots Claudio Imbrenda
2026-04-01 17:39 ` [PATCH v2 4/5] KVM: selftests: Remove 1M alignment requirement for s390 Claudio Imbrenda
2026-04-01 17:39 ` [PATCH v2 5/5] KVM: s390: selftests: enable some common memory-related tests Claudio Imbrenda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260401173955.314821-2-imbrenda@linux.ibm.com \
--to=imbrenda@linux.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=david@kernel.org \
--cc=frankja@linux.ibm.com \
--cc=gra@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=nrb@linux.ibm.com \
--cc=schlameuss@linux.ibm.com \
--cc=seiden@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox