Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 34eeaf37 authored by Martin Schwidefsky's avatar Martin Schwidefsky
Browse files

s390/mm: merge local / non-local IPTE helper



Merge the __ptep_ipte and __ptep_ipte_local functions into a single
__ptep_ipte function with an additional parameter. The __pte_ipte_range
function is still extra as the while loops makes it hard to merge.

Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 44b6cc81
Loading
Loading
Loading
Loading
+13 −17
Original line number Diff line number Diff line
@@ -874,35 +874,31 @@ static inline pte_t pte_mkhuge(pte_t pte)
}
#endif

static inline void __ptep_ipte(unsigned long address, pte_t *ptep)
{
	unsigned long pto = (unsigned long) ptep;

	/* Invalidation + global TLB flush for the pte */
	asm volatile(
		"	ipte	%2,%3"
		: "=m" (*ptep) : "m" (*ptep), "a" (pto), "a" (address));
}
#define IPTE_GLOBAL	0
#define	IPTE_LOCAL	1

static inline void __ptep_ipte_local(unsigned long address, pte_t *ptep)
static inline void __ptep_ipte(unsigned long address, pte_t *ptep, int local)
{
	unsigned long pto = (unsigned long) ptep;

	/* Invalidation + local TLB flush for the pte */
	/* Invalidation + TLB flush for the pte */
	asm volatile(
		"	.insn rrf,0xb2210000,%2,%3,0,1"
		: "=m" (*ptep) : "m" (*ptep), "a" (pto), "a" (address));
		"       .insn rrf,0xb2210000,%[r1],%[r2],0,%[m4]"
		: "+m" (*ptep) : [r1] "a" (pto), [r2] "a" (address),
		  [m4] "i" (local));
}

static inline void __ptep_ipte_range(unsigned long address, int nr, pte_t *ptep)
static inline void __ptep_ipte_range(unsigned long address, int nr,
				     pte_t *ptep, int local)
{
	unsigned long pto = (unsigned long) ptep;

	/* Invalidate a range of ptes + global TLB flush of the ptes */
	/* Invalidate a range of ptes + TLB flush of the ptes */
	do {
		asm volatile(
			"	.insn rrf,0xb2210000,%2,%0,%1,0"
			: "+a" (address), "+a" (nr) : "a" (pto) : "memory");
			"       .insn rrf,0xb2210000,%[r1],%[r2],%[r3],%[m4]"
			: [r2] "+a" (address), [r3] "+a" (nr)
			: [r1] "a" (pto), [m4] "i" (local) : "memory");
	} while (nr != 255);
}

+2 −2
Original line number Diff line number Diff line
@@ -309,11 +309,11 @@ static void ipte_range(pte_t *pte, unsigned long address, int nr)
	int i;

	if (test_facility(13)) {
		__ptep_ipte_range(address, nr - 1, pte);
		__ptep_ipte_range(address, nr - 1, pte, IPTE_GLOBAL);
		return;
	}
	for (i = 0; i < nr; i++) {
		__ptep_ipte(address, pte);
		__ptep_ipte(address, pte, IPTE_GLOBAL);
		address += PAGE_SIZE;
		pte++;
	}
+4 −4
Original line number Diff line number Diff line
@@ -35,9 +35,9 @@ static inline pte_t ptep_flush_direct(struct mm_struct *mm,
	atomic_inc(&mm->context.flush_count);
	if (MACHINE_HAS_TLB_LC &&
	    cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id())))
		__ptep_ipte_local(addr, ptep);
		__ptep_ipte(addr, ptep, IPTE_LOCAL);
	else
		__ptep_ipte(addr, ptep);
		__ptep_ipte(addr, ptep, IPTE_GLOBAL);
	atomic_dec(&mm->context.flush_count);
	return old;
}
@@ -56,7 +56,7 @@ static inline pte_t ptep_flush_lazy(struct mm_struct *mm,
		pte_val(*ptep) |= _PAGE_INVALID;
		mm->context.flush_mm = 1;
	} else
		__ptep_ipte(addr, ptep);
		__ptep_ipte(addr, ptep, IPTE_GLOBAL);
	atomic_dec(&mm->context.flush_count);
	return old;
}
@@ -620,7 +620,7 @@ bool test_and_clear_guest_dirty(struct mm_struct *mm, unsigned long addr)
	pte = *ptep;
	if (dirty && (pte_val(pte) & _PAGE_PRESENT)) {
		pgste = pgste_pte_notify(mm, addr, ptep, pgste);
		__ptep_ipte(addr, ptep);
		__ptep_ipte(addr, ptep, IPTE_GLOBAL);
		if (MACHINE_HAS_ESOP || !(pte_val(pte) & _PAGE_WRITE))
			pte_val(pte) |= _PAGE_PROTECT;
		else