mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heiko Carstens <hca@linux.ibm.com>
To: Claudio Imbrenda <imbrenda@linux.ibm.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Sven Schnelle <svens@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/5] s390/mm: Add ptep_ipte() helper
Date: Tue, 24 Nov 2026 14:59:46 +0100	[thread overview]
Message-ID: <20261124135948.1295745-4-hca@linux.ibm.com> (raw)
In-Reply-To: <20261124135948.1295745-1-hca@linux.ibm.com>

Add a common ptep_ipte() helper in order to avoid the
repeated machine_has_tlb_guest() checks.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
 arch/s390/include/asm/pgtable.h | 11 +++++++++++
 arch/s390/kvm/gmap/dat.c        |  5 +----
 arch/s390/mm/pgtable.c          | 10 ++--------
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index 2d5c2ab06de9..378d2db6e6be 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -21,6 +21,7 @@
 #include <linux/atomic.h>
 #include <linux/mmap_lock.h>
 #include <asm/ctlreg.h>
+#include <asm/machine.h>
 #include <asm/bug.h>
 #include <asm/page.h>
 #include <asm/uv.h>
@@ -1156,6 +1157,16 @@ static __always_inline void __ptep_ipte(unsigned long address, pte_t *ptep,
 		: [r1] "a" (pto), [m4] "i" (local) : "memory");
 }
 
+static __always_inline void ptep_ipte(unsigned long address, pte_t *ptep,
+				      unsigned long opt, unsigned long asce,
+				      int local)
+{
+	if (machine_has_tlb_guest())
+		__ptep_ipte(address, ptep, opt, asce, local);
+	else
+		__ptep_ipte(address, ptep, 0, 0, local);
+}
+
 static __always_inline void __ptep_ipte_range(unsigned long address, int nr,
 					      pte_t *ptep, int local)
 {
diff --git a/arch/s390/kvm/gmap/dat.c b/arch/s390/kvm/gmap/dat.c
index 7a25e41a1423..909d665a67a9 100644
--- a/arch/s390/kvm/gmap/dat.c
+++ b/arch/s390/kvm/gmap/dat.c
@@ -173,10 +173,7 @@ union pgste __dat_ptep_xchg(union pte *ptep, union pgste pgste, union pte new, g
 	if (!old.h.i) {
 		unsigned long opts = IPTE_GUEST_ASCE | (pgste.nodat ? IPTE_NODAT : 0);
 
-		if (machine_has_tlb_guest())
-			__ptep_ipte(gfn_to_gpa(gfn), (void *)ptep, opts, asce.val, IPTE_GLOBAL);
-		else
-			__ptep_ipte(gfn_to_gpa(gfn), (void *)ptep, 0, 0, IPTE_GLOBAL);
+		ptep_ipte(gfn_to_gpa(gfn), (void *)ptep, opts, asce.val, IPTE_GLOBAL);
 	}
 
 	if (uses_skeys) {
diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c
index 1aa5fe0b30d8..f6a960f39abf 100644
--- a/arch/s390/mm/pgtable.c
+++ b/arch/s390/mm/pgtable.c
@@ -38,18 +38,12 @@ EXPORT_SYMBOL_GPL(pgprot_writecombine);
 
 static inline void ptep_ipte_local(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
-	if (machine_has_tlb_guest())
-		__ptep_ipte(addr, ptep, IPTE_NODAT | IPTE_GUEST_ASCE, mm->context.asce, IPTE_LOCAL);
-	else
-		__ptep_ipte(addr, ptep, 0, 0, IPTE_LOCAL);
+	ptep_ipte(addr, ptep, IPTE_NODAT | IPTE_GUEST_ASCE, mm->context.asce, IPTE_LOCAL);
 }
 
 static inline void ptep_ipte_global(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
-	if (machine_has_tlb_guest())
-		__ptep_ipte(addr, ptep, IPTE_NODAT | IPTE_GUEST_ASCE, mm->context.asce, IPTE_GLOBAL);
-	else
-		__ptep_ipte(addr, ptep, 0, 0, IPTE_GLOBAL);
+	ptep_ipte(addr, ptep, IPTE_NODAT | IPTE_GUEST_ASCE, mm->context.asce, IPTE_GLOBAL);
 }
 
 static inline pte_t ptep_flush_direct(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
-- 
2.53.0


  parent reply	other threads:[~2026-11-24 13:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 13:59 [PATCH 0/5] s390/mm: Deduplicate machine_has_tlb_guest() usage Heiko Carstens
2026-11-24 13:59 ` [PATCH 1/5] s390/mm: Remove gmap_asce from mm_context_t Heiko Carstens
2026-11-24 13:59 ` [PATCH 2/5] s390/mm: Remove unused nodat parameter from ptep flush helpers Heiko Carstens
2026-11-24 13:59 ` Heiko Carstens [this message]
2026-11-24 13:59 ` [PATCH 4/5] s390/mm: Add pmdp_idte() helper Heiko Carstens
2026-11-24 13:59 ` [PATCH 5/5] s390/mm: Add pudp_idte() helper Heiko Carstens

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=20261124135948.1295745-4-hca@linux.ibm.com \
    --to=hca@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=frankja@linux.ibm.com \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=svens@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

all inboxes | Powered by JetHome®