LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 03/16] powerpc/64s/exceptions: Change irq reconcile for NMIs from reusing _DAR to RESULT
From: Nicholas Piggin @ 2020-05-08  4:33 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin
In-Reply-To: <20200508043408.886394-1-npiggin@gmail.com>

A spare interrupt stack slot is needed to save irq state when
reconciling NMIs (sreset and decrementer soft-nmi). _DAR is used
for this, but we want to reconcile machine checks as well, which
do use _DAR. Switch to using RESULT instead, as it's used by
system calls.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/exceptions-64s.S | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 3322000316ab..a42b73efb1a9 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -939,13 +939,13 @@ EXC_COMMON_BEGIN(system_reset_common)
 	 * the right thing. We do not want to reconcile because that goes
 	 * through irq tracing which we don't want in NMI.
 	 *
-	 * Save PACAIRQHAPPENED to _DAR (otherwise unused), and set HARD_DIS
+	 * Save PACAIRQHAPPENED to RESULT (otherwise unused), and set HARD_DIS
 	 * as we are running with MSR[EE]=0.
 	 */
 	li	r10,IRQS_ALL_DISABLED
 	stb	r10,PACAIRQSOFTMASK(r13)
 	lbz	r10,PACAIRQHAPPENED(r13)
-	std	r10,_DAR(r1)
+	std	r10,RESULT(r1)
 	ori	r10,r10,PACA_IRQ_HARD_DIS
 	stb	r10,PACAIRQHAPPENED(r13)
 
@@ -966,7 +966,7 @@ EXC_COMMON_BEGIN(system_reset_common)
 	/*
 	 * Restore soft mask settings.
 	 */
-	ld	r10,_DAR(r1)
+	ld	r10,RESULT(r1)
 	stb	r10,PACAIRQHAPPENED(r13)
 	ld	r10,SOFTE(r1)
 	stb	r10,PACAIRQSOFTMASK(r13)
@@ -2743,7 +2743,7 @@ EXC_COMMON_BEGIN(soft_nmi_common)
 	li	r10,IRQS_ALL_DISABLED
 	stb	r10,PACAIRQSOFTMASK(r13)
 	lbz	r10,PACAIRQHAPPENED(r13)
-	std	r10,_DAR(r1)
+	std	r10,RESULT(r1)
 	ori	r10,r10,PACA_IRQ_HARD_DIS
 	stb	r10,PACAIRQHAPPENED(r13)
 
@@ -2757,7 +2757,7 @@ EXC_COMMON_BEGIN(soft_nmi_common)
 	/*
 	 * Restore soft mask settings.
 	 */
-	ld	r10,_DAR(r1)
+	ld	r10,RESULT(r1)
 	stb	r10,PACAIRQHAPPENED(r13)
 	ld	r10,SOFTE(r1)
 	stb	r10,PACAIRQSOFTMASK(r13)
-- 
2.23.0


^ permalink raw reply related

* [PATCH v4 02/16] powerpc/64s/exceptions: Fix in_mce accounting in unrecoverable path
From: Nicholas Piggin @ 2020-05-08  4:33 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Mahesh Salgaonkar, Nicholas Piggin
In-Reply-To: <20200508043408.886394-1-npiggin@gmail.com>

Acked-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/exceptions-64s.S | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index bbf3109c5cba..3322000316ab 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1267,6 +1267,10 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
 	andc	r10,r10,r3
 	mtmsrd	r10
 
+	lhz	r12,PACA_IN_MCE(r13)
+	subi	r12,r12,1
+	sth	r12,PACA_IN_MCE(r13)
+
 	/* Invoke machine_check_exception to print MCE event and panic. */
 	addi	r3,r1,STACK_FRAME_OVERHEAD
 	bl	machine_check_exception
-- 
2.23.0


^ permalink raw reply related

* [PATCH v4 01/16] powerpc/64s/exception: Fix machine check no-loss idle wakeup
From: Nicholas Piggin @ 2020-05-08  4:33 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin
In-Reply-To: <20200508043408.886394-1-npiggin@gmail.com>

The architecture allows for machine check exceptions to cause idle
wakeups which resume at the 0x200 address which has to return via
the idle wakeup code, but the early machine check handler is run
first.

The case of a no state-loss sleep is broken because the early
handler uses non-volatile register r1 , which is needed for the wakeup
protocol, but it is not restored.

Fix this by loading r1 from the MCE exception frame before returning
to the idle wakeup code. Also update the comment which has become
stale since the idle rewrite in C.

Fixes: 10d91611f426d ("powerpc/64s: Reimplement book3s idle code in C")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>

This crash was found and fix confirmed with a machine check injection
test in qemu powernv model (which is not upstream in qemu yet).
---
 arch/powerpc/kernel/exceptions-64s.S | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 728ccb0f560c..bbf3109c5cba 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1224,17 +1224,19 @@ EXC_COMMON_BEGIN(machine_check_idle_common)
 	bl	machine_check_queue_event
 
 	/*
-	 * We have not used any non-volatile GPRs here, and as a rule
-	 * most exception code including machine check does not.
-	 * Therefore PACA_NAPSTATELOST does not need to be set. Idle
-	 * wakeup will restore volatile registers.
+	 * GPR-loss wakeups are relatively straightforward, because the
+	 * idle sleep code has saved all non-volatile registers on its
+	 * own stack, and r1 in PACAR1.
 	 *
-	 * Load the original SRR1 into r3 for pnv_powersave_wakeup_mce.
+	 * For no-loss wakeups the r1 and lr registers used by the
+	 * early machine check handler have to be restored first. r2 is
+	 * the kernel TOC, so no need to restore it.
 	 *
 	 * Then decrement MCE nesting after finishing with the stack.
 	 */
 	ld	r3,_MSR(r1)
 	ld	r4,_LINK(r1)
+	ld	r1,GPR1(r1)
 
 	lhz	r11,PACA_IN_MCE(r13)
 	subi	r11,r11,1
@@ -1243,7 +1245,7 @@ EXC_COMMON_BEGIN(machine_check_idle_common)
 	mtlr	r4
 	rlwinm	r10,r3,47-31,30,31
 	cmpwi	cr1,r10,2
-	bltlr	cr1	/* no state loss, return to idle caller */
+	bltlr	cr1	/* no state loss, return to idle caller with r3=SRR1 */
 	b	idle_return_gpr_loss
 #endif
 
-- 
2.23.0


^ permalink raw reply related

* [PATCH v4 00/16] powerpc: machine check and system reset fixes
From: Nicholas Piggin @ 2020-05-08  4:33 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

Since v3, I fixed a compile error and returned the generic machine check
exception handler to be NMI on 32 and 64e, as caught by Christophe's
review.

Also added the last patch, just found it by looking at the code, a
review for 32s would be good.

Thanks,
Nick

Nicholas Piggin (16):
  powerpc/64s/exception: Fix machine check no-loss idle wakeup
  powerpc/64s/exceptions: Fix in_mce accounting in unrecoverable path
  powerpc/64s/exceptions: Change irq reconcile for NMIs from reusing
    _DAR to RESULT
  powerpc/64s/exceptions: machine check reconcile irq state
  powerpc/pseries/ras: avoid calling rtas_token in NMI paths
  powerpc/pseries/ras: FWNMI_VALID off by one
  powerpc/pseries/ras: fwnmi avoid modifying r3 in error case
  powerpc/pseries/ras: fwnmi sreset should not interlock
  powerpc/pseries: limit machine check stack to 4GB
  powerpc/pseries: machine check use rtas_call_unlocked with args on
    stack
  powerpc/64s: machine check interrupt update NMI accounting
  powerpc: implement ftrace_enabled helper
  powerpc/64s: machine check do not trace real-mode handler
  powerpc/traps: system reset do not trace
  powerpc/traps: make unrecoverable NMIs die instead of panic
  powerpc/traps: Machine check fix RI=0 recoverability check

 arch/powerpc/include/asm/firmware.h    |  1 +
 arch/powerpc/include/asm/ftrace.h      | 14 ++++++
 arch/powerpc/kernel/exceptions-64s.S   | 47 +++++++++++++++-----
 arch/powerpc/kernel/mce.c              | 16 ++++++-
 arch/powerpc/kernel/process.c          |  2 +-
 arch/powerpc/kernel/setup_64.c         | 15 +++++--
 arch/powerpc/kernel/traps.c            | 31 ++++++++++---
 arch/powerpc/platforms/pseries/ras.c   | 60 +++++++++++++++++++-------
 arch/powerpc/platforms/pseries/setup.c | 14 ++++--
 9 files changed, 157 insertions(+), 43 deletions(-)

-- 
2.23.0


^ permalink raw reply

* Re: Fwd: [CRON] Broken: ClangBuiltLinux/continuous-integration#1432 (master - 0aceafc)
From: Michael Ellerman @ 2020-05-08  3:29 UTC (permalink / raw)
  To: Nick Desaulniers; +Cc: linuxppc-dev
In-Reply-To: <CAKwvOdmendjEgurRBAyi4R0rDZRdwfHjddS_pfOQ6761XiiFMA@mail.gmail.com>

Nick Desaulniers <ndesaulniers@google.com> writes:
> Looks like ppc64le powernv_defconfig is suddenly failing the locking
> torture tests, then locks up?
> https://travis-ci.com/github/ClangBuiltLinux/continuous-integration/jobs/329211572#L3111-L3167
> Any recent changes related here in -next?  I believe this is the first
> failure, so I'll report back if we see this again.

Thanks for the report.

There's nothing newly in next-20200507 that seems related.

Odd that it just showed up.

cheers


> ---------- Forwarded message ---------
> From: Travis CI <builds@travis-ci.com>
> Date: Thu, May 7, 2020 at 9:40 AM
> Subject: [CRON] Broken: ClangBuiltLinux/continuous-integration#1432 (master
> - 0aceafc)
> To: <ndesaulniers@google.com>, <natechancellor@gmail.com>
>
>
> ClangBuiltLinux
>
> /
>
> continuous-integration
> <https://travis-ci.com/github/ClangBuiltLinux/continuous-integration?utm_medium=notification&utm_source=email>
>
> [image: branch icon]master
> <https://github.com/ClangBuiltLinux/continuous-integration/tree/master>
> [image: build has failed]
> Build #1432 was broken
> <https://travis-ci.com/github/ClangBuiltLinux/continuous-integration/builds/164415390?utm_medium=notification&utm_source=email>
> [image: arrow to build time]
> [image: clock icon]7 hrs, 0 mins, and 54 secs
>
> [image: Nick Desaulniers avatar]Nick Desaulniers
> 0aceafc CHANGESET →
> <https://github.com/ClangBuiltLinux/continuous-integration/compare/877d002bdcfe6bc5cb0255c3c39192e8175e2c19...0aceafcfcca7c4a095957efae0939a612d755077>
>
> Merge pull request #182 from ClangBuiltLinux/i386
>
> i386
>
> Want to know about upcoming build environment updates?
>
> Would you like to stay up-to-date with the upcoming Travis CI build
> environment updates? We set up a mailing list for you!
> SIGN UP HERE <http://eepurl.com/9OCsP>
>
> [image: book icon]
>
> Documentation <https://docs.travis-ci.com/> about Travis CI
> Have any questions? We're here to help. <support@travis-ci.com>
> Unsubscribe
> <https://travis-ci.com/account/preferences/unsubscribe?repository=6718752&utm_medium=notification&utm_source=email>
> from build emails from the ClangBuiltLinux/continuous-integration
> repository.
> To unsubscribe from *all* build emails, please update your settings
> <https://travis-ci.com/account/preferences/unsubscribe?utm_medium=notification&utm_source=email>.
>
> [image: black and white travis ci logo] <https://travis-ci.com>
>
> Travis CI GmbH, Rigaer Str. 8, 10427 Berlin, Germany | GF/CEO: Randy Jacops
> | Contact: contact@travis-ci.com | Amtsgericht Charlottenburg, Berlin, HRB
> 140133 B | Umsatzsteuer-ID gemäß §27 a Umsatzsteuergesetz: DE282002648
>
>
> -- 
> Thanks,
> ~Nick Desaulniers

^ permalink raw reply

* [PATCH V3 3/3] mm/hugetlb: Define a generic fallback for arch_clear_hugepage_flags()
From: Anshuman Khandual @ 2020-05-08  3:07 UTC (permalink / raw)
  To: linux-mm, akpm
  Cc: Rich Felker, linux-ia64, linux-sh, Catalin Marinas,
	Heiko Carstens, linux-kernel, James E.J. Bottomley,
	Paul Mackerras, H. Peter Anvin, sparclinux, linux-riscv,
	Will Deacon, linux-arch, linux-s390, Yoshinori Sato, Helge Deller,
	x86, Russell King, Christian Borntraeger, Ingo Molnar, Fenghua Yu,
	Vasily Gorbik, Anshuman Khandual, Thomas Bogendoerfer,
	Borislav Petkov, Paul Walmsley, Thomas Gleixner, linux-arm-kernel,
	Tony Luck, linux-parisc, linux-mips, Palmer Dabbelt, linuxppc-dev,
	David S. Miller, Mike Kravetz
In-Reply-To: <1588907271-11920-1-git-send-email-anshuman.khandual@arm.com>

There are multiple similar definitions for arch_clear_hugepage_flags() on
various platforms. Lets just add it's generic fallback definition for
platforms that do not override. This help reduce code duplication.

Cc: Russell King <linux@armlinux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: x86@kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-ia64@vger.kernel.org
Cc: linux-mips@vger.kernel.org
Cc: linux-parisc@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-riscv@lists.infradead.org
Cc: linux-s390@vger.kernel.org
Cc: linux-sh@vger.kernel.org
Cc: sparclinux@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: linux-arch@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 arch/arm/include/asm/hugetlb.h     | 1 +
 arch/arm64/include/asm/hugetlb.h   | 1 +
 arch/ia64/include/asm/hugetlb.h    | 4 ----
 arch/mips/include/asm/hugetlb.h    | 4 ----
 arch/parisc/include/asm/hugetlb.h  | 4 ----
 arch/powerpc/include/asm/hugetlb.h | 4 ----
 arch/riscv/include/asm/hugetlb.h   | 4 ----
 arch/s390/include/asm/hugetlb.h    | 1 +
 arch/sh/include/asm/hugetlb.h      | 1 +
 arch/sparc/include/asm/hugetlb.h   | 4 ----
 arch/x86/include/asm/hugetlb.h     | 4 ----
 include/linux/hugetlb.h            | 5 +++++
 12 files changed, 9 insertions(+), 28 deletions(-)

diff --git a/arch/arm/include/asm/hugetlb.h b/arch/arm/include/asm/hugetlb.h
index 9ecd516d1ff7..d02d6ca88e92 100644
--- a/arch/arm/include/asm/hugetlb.h
+++ b/arch/arm/include/asm/hugetlb.h
@@ -18,5 +18,6 @@ static inline void arch_clear_hugepage_flags(struct page *page)
 {
 	clear_bit(PG_dcache_clean, &page->flags);
 }
+#define arch_clear_hugepage_flags arch_clear_hugepage_flags
 
 #endif /* _ASM_ARM_HUGETLB_H */
diff --git a/arch/arm64/include/asm/hugetlb.h b/arch/arm64/include/asm/hugetlb.h
index 8f58e052697a..94ba0c5bced2 100644
--- a/arch/arm64/include/asm/hugetlb.h
+++ b/arch/arm64/include/asm/hugetlb.h
@@ -21,6 +21,7 @@ static inline void arch_clear_hugepage_flags(struct page *page)
 {
 	clear_bit(PG_dcache_clean, &page->flags);
 }
+#define arch_clear_hugepage_flags arch_clear_hugepage_flags
 
 extern pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
 				struct page *page, int writable);
diff --git a/arch/ia64/include/asm/hugetlb.h b/arch/ia64/include/asm/hugetlb.h
index 6ef50b9a4bdf..7e46ebde8c0c 100644
--- a/arch/ia64/include/asm/hugetlb.h
+++ b/arch/ia64/include/asm/hugetlb.h
@@ -28,10 +28,6 @@ static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
 {
 }
 
-static inline void arch_clear_hugepage_flags(struct page *page)
-{
-}
-
 #include <asm-generic/hugetlb.h>
 
 #endif /* _ASM_IA64_HUGETLB_H */
diff --git a/arch/mips/include/asm/hugetlb.h b/arch/mips/include/asm/hugetlb.h
index 8b201e281f67..10e3be870df7 100644
--- a/arch/mips/include/asm/hugetlb.h
+++ b/arch/mips/include/asm/hugetlb.h
@@ -75,10 +75,6 @@ static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
 	return changed;
 }
 
-static inline void arch_clear_hugepage_flags(struct page *page)
-{
-}
-
 #include <asm-generic/hugetlb.h>
 
 #endif /* __ASM_HUGETLB_H */
diff --git a/arch/parisc/include/asm/hugetlb.h b/arch/parisc/include/asm/hugetlb.h
index 411d9d867baa..a69cf9efb0c1 100644
--- a/arch/parisc/include/asm/hugetlb.h
+++ b/arch/parisc/include/asm/hugetlb.h
@@ -42,10 +42,6 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma,
 					     unsigned long addr, pte_t *ptep,
 					     pte_t pte, int dirty);
 
-static inline void arch_clear_hugepage_flags(struct page *page)
-{
-}
-
 #include <asm-generic/hugetlb.h>
 
 #endif /* _ASM_PARISC64_HUGETLB_H */
diff --git a/arch/powerpc/include/asm/hugetlb.h b/arch/powerpc/include/asm/hugetlb.h
index b167c869d72d..e6dfa63da552 100644
--- a/arch/powerpc/include/asm/hugetlb.h
+++ b/arch/powerpc/include/asm/hugetlb.h
@@ -61,10 +61,6 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma,
 			       unsigned long addr, pte_t *ptep,
 			       pte_t pte, int dirty);
 
-static inline void arch_clear_hugepage_flags(struct page *page)
-{
-}
-
 #include <asm-generic/hugetlb.h>
 
 #else /* ! CONFIG_HUGETLB_PAGE */
diff --git a/arch/riscv/include/asm/hugetlb.h b/arch/riscv/include/asm/hugetlb.h
index 866f6ae6467c..a5c2ca1d1cd8 100644
--- a/arch/riscv/include/asm/hugetlb.h
+++ b/arch/riscv/include/asm/hugetlb.h
@@ -5,8 +5,4 @@
 #include <asm-generic/hugetlb.h>
 #include <asm/page.h>
 
-static inline void arch_clear_hugepage_flags(struct page *page)
-{
-}
-
 #endif /* _ASM_RISCV_HUGETLB_H */
diff --git a/arch/s390/include/asm/hugetlb.h b/arch/s390/include/asm/hugetlb.h
index 7d27ea96ec2f..9ddf4a43a590 100644
--- a/arch/s390/include/asm/hugetlb.h
+++ b/arch/s390/include/asm/hugetlb.h
@@ -39,6 +39,7 @@ static inline void arch_clear_hugepage_flags(struct page *page)
 {
 	clear_bit(PG_arch_1, &page->flags);
 }
+#define arch_clear_hugepage_flags arch_clear_hugepage_flags
 
 static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
 				  pte_t *ptep, unsigned long sz)
diff --git a/arch/sh/include/asm/hugetlb.h b/arch/sh/include/asm/hugetlb.h
index 536ad2cb8aa4..ae4de7b89210 100644
--- a/arch/sh/include/asm/hugetlb.h
+++ b/arch/sh/include/asm/hugetlb.h
@@ -30,6 +30,7 @@ static inline void arch_clear_hugepage_flags(struct page *page)
 {
 	clear_bit(PG_dcache_clean, &page->flags);
 }
+#define arch_clear_hugepage_flags arch_clear_hugepage_flags
 
 #include <asm-generic/hugetlb.h>
 
diff --git a/arch/sparc/include/asm/hugetlb.h b/arch/sparc/include/asm/hugetlb.h
index a056fe1119f5..53838a173f62 100644
--- a/arch/sparc/include/asm/hugetlb.h
+++ b/arch/sparc/include/asm/hugetlb.h
@@ -47,10 +47,6 @@ static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
 	return changed;
 }
 
-static inline void arch_clear_hugepage_flags(struct page *page)
-{
-}
-
 #define __HAVE_ARCH_HUGETLB_FREE_PGD_RANGE
 void hugetlb_free_pgd_range(struct mmu_gather *tlb, unsigned long addr,
 			    unsigned long end, unsigned long floor,
diff --git a/arch/x86/include/asm/hugetlb.h b/arch/x86/include/asm/hugetlb.h
index cc98f79074d0..1721b1aadeb1 100644
--- a/arch/x86/include/asm/hugetlb.h
+++ b/arch/x86/include/asm/hugetlb.h
@@ -7,8 +7,4 @@
 
 #define hugepages_supported() boot_cpu_has(X86_FEATURE_PSE)
 
-static inline void arch_clear_hugepage_flags(struct page *page)
-{
-}
-
 #endif /* _ASM_X86_HUGETLB_H */
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index c01c0c6f7fd4..04bc794becfc 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -600,6 +600,11 @@ static inline int is_hugepage_only_range(struct mm_struct *mm,
 #define is_hugepage_only_range is_hugepage_only_range
 #endif
 
+#ifndef arch_clear_hugepage_flags
+static inline void arch_clear_hugepage_flags(struct page *page) { }
+#define arch_clear_hugepage_flags arch_clear_hugepage_flags
+#endif
+
 #ifndef arch_make_huge_pte
 static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
 				       struct page *page, int writable)
-- 
2.20.1


^ permalink raw reply related

* [PATCH V3 2/3] mm/hugetlb: Define a generic fallback for is_hugepage_only_range()
From: Anshuman Khandual @ 2020-05-08  3:07 UTC (permalink / raw)
  To: linux-mm, akpm
  Cc: Rich Felker, linux-ia64, linux-sh, Catalin Marinas,
	Heiko Carstens, linux-kernel, James E.J. Bottomley,
	Paul Mackerras, H. Peter Anvin, sparclinux, linux-riscv,
	Will Deacon, linux-arch, linux-s390, Yoshinori Sato, Helge Deller,
	x86, Russell King, Christian Borntraeger, Ingo Molnar, Fenghua Yu,
	Vasily Gorbik, Anshuman Khandual, Thomas Bogendoerfer,
	Borislav Petkov, Paul Walmsley, Thomas Gleixner, linux-arm-kernel,
	Tony Luck, linux-parisc, linux-mips, Palmer Dabbelt, linuxppc-dev,
	David S. Miller, Mike Kravetz
In-Reply-To: <1588907271-11920-1-git-send-email-anshuman.khandual@arm.com>

There are multiple similar definitions for is_hugepage_only_range() on
various platforms. Lets just add it's generic fallback definition for
platforms that do not override. This help reduce code duplication.

Cc: Russell King <linux@armlinux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: x86@kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-ia64@vger.kernel.org
Cc: linux-mips@vger.kernel.org
Cc: linux-parisc@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-riscv@lists.infradead.org
Cc: linux-s390@vger.kernel.org
Cc: linux-sh@vger.kernel.org
Cc: sparclinux@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: linux-arch@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 arch/arm/include/asm/hugetlb.h     | 6 ------
 arch/arm64/include/asm/hugetlb.h   | 6 ------
 arch/ia64/include/asm/hugetlb.h    | 1 +
 arch/mips/include/asm/hugetlb.h    | 7 -------
 arch/parisc/include/asm/hugetlb.h  | 6 ------
 arch/powerpc/include/asm/hugetlb.h | 1 +
 arch/riscv/include/asm/hugetlb.h   | 6 ------
 arch/s390/include/asm/hugetlb.h    | 7 -------
 arch/sh/include/asm/hugetlb.h      | 6 ------
 arch/sparc/include/asm/hugetlb.h   | 6 ------
 arch/x86/include/asm/hugetlb.h     | 6 ------
 include/linux/hugetlb.h            | 9 +++++++++
 12 files changed, 11 insertions(+), 56 deletions(-)

diff --git a/arch/arm/include/asm/hugetlb.h b/arch/arm/include/asm/hugetlb.h
index 318dcf5921ab..9ecd516d1ff7 100644
--- a/arch/arm/include/asm/hugetlb.h
+++ b/arch/arm/include/asm/hugetlb.h
@@ -14,12 +14,6 @@
 #include <asm/hugetlb-3level.h>
 #include <asm-generic/hugetlb.h>
 
-static inline int is_hugepage_only_range(struct mm_struct *mm,
-					 unsigned long addr, unsigned long len)
-{
-	return 0;
-}
-
 static inline void arch_clear_hugepage_flags(struct page *page)
 {
 	clear_bit(PG_dcache_clean, &page->flags);
diff --git a/arch/arm64/include/asm/hugetlb.h b/arch/arm64/include/asm/hugetlb.h
index b88878ddc88b..8f58e052697a 100644
--- a/arch/arm64/include/asm/hugetlb.h
+++ b/arch/arm64/include/asm/hugetlb.h
@@ -17,12 +17,6 @@
 extern bool arch_hugetlb_migration_supported(struct hstate *h);
 #endif
 
-static inline int is_hugepage_only_range(struct mm_struct *mm,
-					 unsigned long addr, unsigned long len)
-{
-	return 0;
-}
-
 static inline void arch_clear_hugepage_flags(struct page *page)
 {
 	clear_bit(PG_dcache_clean, &page->flags);
diff --git a/arch/ia64/include/asm/hugetlb.h b/arch/ia64/include/asm/hugetlb.h
index 36cc0396b214..6ef50b9a4bdf 100644
--- a/arch/ia64/include/asm/hugetlb.h
+++ b/arch/ia64/include/asm/hugetlb.h
@@ -20,6 +20,7 @@ static inline int is_hugepage_only_range(struct mm_struct *mm,
 	return (REGION_NUMBER(addr) == RGN_HPAGE ||
 		REGION_NUMBER((addr)+(len)-1) == RGN_HPAGE);
 }
+#define is_hugepage_only_range is_hugepage_only_range
 
 #define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH
 static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
diff --git a/arch/mips/include/asm/hugetlb.h b/arch/mips/include/asm/hugetlb.h
index 425bb6fc3bda..8b201e281f67 100644
--- a/arch/mips/include/asm/hugetlb.h
+++ b/arch/mips/include/asm/hugetlb.h
@@ -11,13 +11,6 @@
 
 #include <asm/page.h>
 
-static inline int is_hugepage_only_range(struct mm_struct *mm,
-					 unsigned long addr,
-					 unsigned long len)
-{
-	return 0;
-}
-
 #define __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE
 static inline int prepare_hugepage_range(struct file *file,
 					 unsigned long addr,
diff --git a/arch/parisc/include/asm/hugetlb.h b/arch/parisc/include/asm/hugetlb.h
index 7cb595dcb7d7..411d9d867baa 100644
--- a/arch/parisc/include/asm/hugetlb.h
+++ b/arch/parisc/include/asm/hugetlb.h
@@ -12,12 +12,6 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
 pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
 			      pte_t *ptep);
 
-static inline int is_hugepage_only_range(struct mm_struct *mm,
-					 unsigned long addr,
-					 unsigned long len) {
-	return 0;
-}
-
 /*
  * If the arch doesn't supply something else, assume that hugepage
  * size aligned regions are ok without further preparation.
diff --git a/arch/powerpc/include/asm/hugetlb.h b/arch/powerpc/include/asm/hugetlb.h
index bd6504c28c2f..b167c869d72d 100644
--- a/arch/powerpc/include/asm/hugetlb.h
+++ b/arch/powerpc/include/asm/hugetlb.h
@@ -30,6 +30,7 @@ static inline int is_hugepage_only_range(struct mm_struct *mm,
 		return slice_is_hugepage_only_range(mm, addr, len);
 	return 0;
 }
+#define is_hugepage_only_range is_hugepage_only_range
 
 #define __HAVE_ARCH_HUGETLB_FREE_PGD_RANGE
 void hugetlb_free_pgd_range(struct mmu_gather *tlb, unsigned long addr,
diff --git a/arch/riscv/include/asm/hugetlb.h b/arch/riscv/include/asm/hugetlb.h
index 728a5db66597..866f6ae6467c 100644
--- a/arch/riscv/include/asm/hugetlb.h
+++ b/arch/riscv/include/asm/hugetlb.h
@@ -5,12 +5,6 @@
 #include <asm-generic/hugetlb.h>
 #include <asm/page.h>
 
-static inline int is_hugepage_only_range(struct mm_struct *mm,
-					 unsigned long addr,
-					 unsigned long len) {
-	return 0;
-}
-
 static inline void arch_clear_hugepage_flags(struct page *page)
 {
 }
diff --git a/arch/s390/include/asm/hugetlb.h b/arch/s390/include/asm/hugetlb.h
index de8f0bf5f238..7d27ea96ec2f 100644
--- a/arch/s390/include/asm/hugetlb.h
+++ b/arch/s390/include/asm/hugetlb.h
@@ -21,13 +21,6 @@ pte_t huge_ptep_get(pte_t *ptep);
 pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
 			      unsigned long addr, pte_t *ptep);
 
-static inline bool is_hugepage_only_range(struct mm_struct *mm,
-					  unsigned long addr,
-					  unsigned long len)
-{
-	return false;
-}
-
 /*
  * If the arch doesn't supply something else, assume that hugepage
  * size aligned regions are ok without further preparation.
diff --git a/arch/sh/include/asm/hugetlb.h b/arch/sh/include/asm/hugetlb.h
index 6f025fe18146..536ad2cb8aa4 100644
--- a/arch/sh/include/asm/hugetlb.h
+++ b/arch/sh/include/asm/hugetlb.h
@@ -5,12 +5,6 @@
 #include <asm/cacheflush.h>
 #include <asm/page.h>
 
-static inline int is_hugepage_only_range(struct mm_struct *mm,
-					 unsigned long addr,
-					 unsigned long len) {
-	return 0;
-}
-
 /*
  * If the arch doesn't supply something else, assume that hugepage
  * size aligned regions are ok without further preparation.
diff --git a/arch/sparc/include/asm/hugetlb.h b/arch/sparc/include/asm/hugetlb.h
index 3963f80d1cb3..a056fe1119f5 100644
--- a/arch/sparc/include/asm/hugetlb.h
+++ b/arch/sparc/include/asm/hugetlb.h
@@ -20,12 +20,6 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
 pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
 			      pte_t *ptep);
 
-static inline int is_hugepage_only_range(struct mm_struct *mm,
-					 unsigned long addr,
-					 unsigned long len) {
-	return 0;
-}
-
 #define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH
 static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
 					 unsigned long addr, pte_t *ptep)
diff --git a/arch/x86/include/asm/hugetlb.h b/arch/x86/include/asm/hugetlb.h
index f65cfb48cfdd..cc98f79074d0 100644
--- a/arch/x86/include/asm/hugetlb.h
+++ b/arch/x86/include/asm/hugetlb.h
@@ -7,12 +7,6 @@
 
 #define hugepages_supported() boot_cpu_has(X86_FEATURE_PSE)
 
-static inline int is_hugepage_only_range(struct mm_struct *mm,
-					 unsigned long addr,
-					 unsigned long len) {
-	return 0;
-}
-
 static inline void arch_clear_hugepage_flags(struct page *page)
 {
 }
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 43a1cef8f0f1..c01c0c6f7fd4 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -591,6 +591,15 @@ static inline unsigned int blocks_per_huge_page(struct hstate *h)
 
 #include <asm/hugetlb.h>
 
+#ifndef is_hugepage_only_range
+static inline int is_hugepage_only_range(struct mm_struct *mm,
+					unsigned long addr, unsigned long len)
+{
+	return 0;
+}
+#define is_hugepage_only_range is_hugepage_only_range
+#endif
+
 #ifndef arch_make_huge_pte
 static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
 				       struct page *page, int writable)
-- 
2.20.1


^ permalink raw reply related

* [PATCH V3 0/3] mm/hugetlb: Add some new generic fallbacks
From: Anshuman Khandual @ 2020-05-08  3:07 UTC (permalink / raw)
  To: linux-mm, akpm
  Cc: Rich Felker, linux-ia64, linux-sh, Catalin Marinas,
	Heiko Carstens, linux-kernel, James E.J. Bottomley,
	Paul Mackerras, H. Peter Anvin, sparclinux, linux-riscv,
	Will Deacon, linux-arch, linux-s390, Yoshinori Sato, Helge Deller,
	x86, Russell King, Christian Borntraeger, Ingo Molnar, Fenghua Yu,
	Vasily Gorbik, Anshuman Khandual, Thomas Bogendoerfer,
	Borislav Petkov, Paul Walmsley, Thomas Gleixner, linux-arm-kernel,
	Tony Luck, linux-parisc, linux-mips, Palmer Dabbelt, linuxppc-dev,
	David S. Miller, Mike Kravetz

This series adds the following new generic fallbacks. Before that it drops
__HAVE_ARCH_HUGE_PTEP_GET from arm64 platform.

1. is_hugepage_only_range()
2. arch_clear_hugepage_flags()

This has been boot tested on arm64 and x86 platforms but built tested on
some more platforms including the changed ones here. This series applies
on v5.7-rc4. After this arm (32 bit) remains the sole platform defining
it's own huge_ptep_get() via __HAVE_ARCH_HUGE_PTEP_GET.

Changes in V3:

- Added READ_ONCE() in generic huge_ptep_get() per Will

Changes in V2: (https://patchwork.kernel.org/project/linux-mm/list/?series=282947)

- Adopted "#ifndef func" method (adding a single symbol to namespace) per Andrew
- Updated the commit messages in [PATCH 2/3] and [PATCH 3/3] as required

Changes in V1: (https://patchwork.kernel.org/project/linux-mm/list/?series=270677)

Cc: Russell King <linux@armlinux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: x86@kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-ia64@vger.kernel.org
Cc: linux-mips@vger.kernel.org
Cc: linux-parisc@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-riscv@lists.infradead.org
Cc: linux-s390@vger.kernel.org
Cc: linux-sh@vger.kernel.org
Cc: sparclinux@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: linux-arch@vger.kernel.org
Cc: linux-kernel@vger.kernel.org

Anshuman Khandual (3):
  arm64/mm: Drop __HAVE_ARCH_HUGE_PTEP_GET
  mm/hugetlb: Define a generic fallback for is_hugepage_only_range()
  mm/hugetlb: Define a generic fallback for arch_clear_hugepage_flags()

 arch/arm/include/asm/hugetlb.h     |  7 +------
 arch/arm64/include/asm/hugetlb.h   | 13 +------------
 arch/ia64/include/asm/hugetlb.h    |  5 +----
 arch/mips/include/asm/hugetlb.h    | 11 -----------
 arch/parisc/include/asm/hugetlb.h  | 10 ----------
 arch/powerpc/include/asm/hugetlb.h |  5 +----
 arch/riscv/include/asm/hugetlb.h   | 10 ----------
 arch/s390/include/asm/hugetlb.h    |  8 +-------
 arch/sh/include/asm/hugetlb.h      |  7 +------
 arch/sparc/include/asm/hugetlb.h   | 10 ----------
 arch/x86/include/asm/hugetlb.h     | 10 ----------
 include/asm-generic/hugetlb.h      |  2 +-
 include/linux/hugetlb.h            | 14 ++++++++++++++
 13 files changed, 21 insertions(+), 91 deletions(-)

-- 
2.20.1


^ permalink raw reply

* Re: [PATCH v8 22/30] powerpc: Define new SRR1 bits for a future ISA version
From: Jordan Niethe @ 2020-05-08  2:26 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Alistair Popple, Nicholas Piggin, Balamuruhan S, naveen.n.rao,
	Daniel Axtens
In-Reply-To: <20200506034050.24806-23-jniethe5@gmail.com>

Hi mpe,
Could you please take some changes for the commit message.
In the patch title
s/a future ISA version/ISA v3.1/

On Wed, May 6, 2020 at 1:47 PM Jordan Niethe <jniethe5@gmail.com> wrote:
>
> Add the BOUNDARY SRR1 bit definition for when the cause of an alignment
> exception is a prefixed instruction that crosses a 64-byte boundary.
> Add the PREFIXED SRR1 bit definition for exceptions caused by prefixed
> instructions.
>
> Bit 35 of SRR1 is called SRR1_ISI_N_OR_G. This name comes from it being
> used to indicate that an ISI was due to the access being no-exec or
> guarded. A future ISA version adds another purpose. It is also set if

s/A future ISA version/ISA v3.1/

> there is an access in a cache-inhibited location for prefixed
> instruction.  Rename from SRR1_ISI_N_OR_G to SRR1_ISI_N_G_OR_CIP.
>
> Reviewed-by: Alistair Popple <alistair@popple.id.au>
> Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
> ---
> v2: Combined all the commits concerning SRR1 bits.
> ---

^ permalink raw reply

* Re: [PATCH v8 11/30] powerpc: Use a datatype for instructions
From: Jordan Niethe @ 2020-05-08  2:15 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Alistair Popple, Nicholas Piggin, Balamuruhan S, naveen.n.rao,
	Daniel Axtens
In-Reply-To: <20200506034050.24806-12-jniethe5@gmail.com>

Hi mpe,
On Wed, May 6, 2020 at 1:45 PM Jordan Niethe <jniethe5@gmail.com> wrote:
>
> Currently unsigned ints are used to represent instructions on powerpc.
> This has worked well as instructions have always been 4 byte words.
> However, a future ISA version will introduce some changes to

s/a future ISA version will introduce/ISA v3.1 introduces/

> instructions that mean this scheme will no longer work as well. This
> change is Prefixed Instructions. A prefixed instruction is made up of a
> word prefix followed by a word suffix to make an 8 byte double word
> instruction. No matter the endianness of the system the prefix always
> comes first. Prefixed instructions are only planned for powerpc64.
>
> Introduce a ppc_inst type to represent both prefixed and word
> instructions on powerpc64 while keeping it possible to exclusively have
> word instructions on powerpc32.
>
> Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
> ---

^ permalink raw reply

* Re: [PATCH 1/3] powerpc/va: Add a __va() variant that doesn't do input validation
From: kbuild test robot @ 2020-05-08  1:52 UTC (permalink / raw)
  To: Aneesh Kumar K.V, linuxppc-dev, mpe; +Cc: kbuild-all
In-Reply-To: <20200507142316.265457-1-aneesh.kumar@linux.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 6677 bytes --]

Hi "Aneesh,

I love your patch! Perhaps something to improve:

[auto build test WARNING on powerpc/next]
[also build test WARNING on v5.7-rc4 next-20200507]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Aneesh-Kumar-K-V/powerpc-va-Add-a-__va-variant-that-doesn-t-do-input-validation/20200508-042829
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-allyesconfig (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day GCC_VERSION=9.3.0 make.cross ARCH=powerpc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   arch/powerpc/platforms/powernv/opal-core.c: In function 'read_opalcore':
>> arch/powerpc/platforms/powernv/opal-core.c:199:20: warning: passing argument 1 of '__va' makes integer from pointer without a cast [-Wint-conversion]
     199 |    memcpy(to, __va(addr), tsz);
         |                    ^~~~
         |                    |
         |                    void *
   In file included from arch/powerpc/include/asm/mmu.h:132,
                    from arch/powerpc/include/asm/lppaca.h:47,
                    from arch/powerpc/include/asm/paca.h:17,
                    from arch/powerpc/include/asm/current.h:13,
                    from include/linux/thread_info.h:21,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/powerpc/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:51,
                    from include/linux/mmzone.h:8,
                    from include/linux/gfp.h:6,
                    from include/linux/mm.h:10,
                    from include/linux/memblock.h:13,
                    from arch/powerpc/platforms/powernv/opal-core.c:11:
   arch/powerpc/include/asm/page.h:229:38: note: expected 'phys_addr_t' {aka 'long long unsigned int'} but argument is of type 'void *'
     229 | static inline void *__va(phys_addr_t addr)
         |                          ~~~~~~~~~~~~^~~~

vim +/__va +199 arch/powerpc/platforms/powernv/opal-core.c

6f713d18144ce86 Hari Bathini 2019-09-11  156  
6f713d18144ce86 Hari Bathini 2019-09-11  157  /*
6f713d18144ce86 Hari Bathini 2019-09-11  158   * Read from the ELF header and then the crash dump.
6f713d18144ce86 Hari Bathini 2019-09-11  159   * Returns number of bytes read on success, -errno on failure.
6f713d18144ce86 Hari Bathini 2019-09-11  160   */
6f713d18144ce86 Hari Bathini 2019-09-11  161  static ssize_t read_opalcore(struct file *file, struct kobject *kobj,
6f713d18144ce86 Hari Bathini 2019-09-11  162  			     struct bin_attribute *bin_attr, char *to,
6f713d18144ce86 Hari Bathini 2019-09-11  163  			     loff_t pos, size_t count)
6f713d18144ce86 Hari Bathini 2019-09-11  164  {
6f713d18144ce86 Hari Bathini 2019-09-11  165  	struct opalcore *m;
6f713d18144ce86 Hari Bathini 2019-09-11  166  	ssize_t tsz, avail;
6f713d18144ce86 Hari Bathini 2019-09-11  167  	loff_t tpos = pos;
6f713d18144ce86 Hari Bathini 2019-09-11  168  
6f713d18144ce86 Hari Bathini 2019-09-11  169  	if (pos >= oc_conf->opalcore_size)
6f713d18144ce86 Hari Bathini 2019-09-11  170  		return 0;
6f713d18144ce86 Hari Bathini 2019-09-11  171  
6f713d18144ce86 Hari Bathini 2019-09-11  172  	/* Adjust count if it goes beyond opalcore size */
6f713d18144ce86 Hari Bathini 2019-09-11  173  	avail = oc_conf->opalcore_size - pos;
6f713d18144ce86 Hari Bathini 2019-09-11  174  	if (count > avail)
6f713d18144ce86 Hari Bathini 2019-09-11  175  		count = avail;
6f713d18144ce86 Hari Bathini 2019-09-11  176  
6f713d18144ce86 Hari Bathini 2019-09-11  177  	if (count == 0)
6f713d18144ce86 Hari Bathini 2019-09-11  178  		return 0;
6f713d18144ce86 Hari Bathini 2019-09-11  179  
6f713d18144ce86 Hari Bathini 2019-09-11  180  	/* Read ELF core header and/or PT_NOTE segment */
6f713d18144ce86 Hari Bathini 2019-09-11  181  	if (tpos < oc_conf->opalcorebuf_sz) {
6f713d18144ce86 Hari Bathini 2019-09-11  182  		tsz = min_t(size_t, oc_conf->opalcorebuf_sz - tpos, count);
6f713d18144ce86 Hari Bathini 2019-09-11  183  		memcpy(to, oc_conf->opalcorebuf + tpos, tsz);
6f713d18144ce86 Hari Bathini 2019-09-11  184  		to += tsz;
6f713d18144ce86 Hari Bathini 2019-09-11  185  		tpos += tsz;
6f713d18144ce86 Hari Bathini 2019-09-11  186  		count -= tsz;
6f713d18144ce86 Hari Bathini 2019-09-11  187  	}
6f713d18144ce86 Hari Bathini 2019-09-11  188  
6f713d18144ce86 Hari Bathini 2019-09-11  189  	list_for_each_entry(m, &opalcore_list, list) {
6f713d18144ce86 Hari Bathini 2019-09-11  190  		/* nothing more to read here */
6f713d18144ce86 Hari Bathini 2019-09-11  191  		if (count == 0)
6f713d18144ce86 Hari Bathini 2019-09-11  192  			break;
6f713d18144ce86 Hari Bathini 2019-09-11  193  
6f713d18144ce86 Hari Bathini 2019-09-11  194  		if (tpos < m->offset + m->size) {
6f713d18144ce86 Hari Bathini 2019-09-11  195  			void *addr;
6f713d18144ce86 Hari Bathini 2019-09-11  196  
6f713d18144ce86 Hari Bathini 2019-09-11  197  			tsz = min_t(size_t, m->offset + m->size - tpos, count);
6f713d18144ce86 Hari Bathini 2019-09-11  198  			addr = (void *)(m->paddr + tpos - m->offset);
6f713d18144ce86 Hari Bathini 2019-09-11 @199  			memcpy(to, __va(addr), tsz);
6f713d18144ce86 Hari Bathini 2019-09-11  200  			to += tsz;
6f713d18144ce86 Hari Bathini 2019-09-11  201  			tpos += tsz;
6f713d18144ce86 Hari Bathini 2019-09-11  202  			count -= tsz;
6f713d18144ce86 Hari Bathini 2019-09-11  203  		}
6f713d18144ce86 Hari Bathini 2019-09-11  204  	}
6f713d18144ce86 Hari Bathini 2019-09-11  205  
6f713d18144ce86 Hari Bathini 2019-09-11  206  	return (tpos - pos);
6f713d18144ce86 Hari Bathini 2019-09-11  207  }
6f713d18144ce86 Hari Bathini 2019-09-11  208  

:::::: The code at line 199 was first introduced by commit
:::::: 6f713d18144ce86c9f01cdf64222d6339e26129e powerpc/opalcore: export /sys/firmware/opal/core for analysing opal crashes

:::::: TO: Hari Bathini <hbathini@linux.vnet.ibm.com>
:::::: CC: Michael Ellerman <mpe@ellerman.id.au>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 66039 bytes --]

^ permalink raw reply

* Re: [PATCH v8 11/30] powerpc: Use a datatype for instructions
From: Jordan Niethe @ 2020-05-08  1:51 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Alistair Popple, Nicholas Piggin, Balamuruhan S, naveen.n.rao,
	Daniel Axtens
In-Reply-To: <20200506034050.24806-12-jniethe5@gmail.com>

On Wed, May 6, 2020 at 1:45 PM Jordan Niethe <jniethe5@gmail.com> wrote:
>
> Currently unsigned ints are used to represent instructions on powerpc.
> This has worked well as instructions have always been 4 byte words.
> However, a future ISA version will introduce some changes to
> instructions that mean this scheme will no longer work as well. This
> change is Prefixed Instructions. A prefixed instruction is made up of a
> word prefix followed by a word suffix to make an 8 byte double word
> instruction. No matter the endianness of the system the prefix always
> comes first. Prefixed instructions are only planned for powerpc64.
>
> Introduce a ppc_inst type to represent both prefixed and word
> instructions on powerpc64 while keeping it possible to exclusively have
> word instructions on powerpc32.
>
> Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
> ---
> v4: New to series
> v5: Add to epapr_paravirt.c, kgdb.c
> v6: - setup_32.c: machine_init(): Use type
>     - feature-fixups.c: do_final_fixups(): Use type
>     - optprobes.c: arch_prepare_optimized_kprobe(): change a void * to
>       struct ppc_inst *
>     - fault.c: store_updates_sp(): Use type
>     - Change ppc_inst_equal() implementation from memcpy()
> v7: - Fix compilation issue in early_init_dt_scan_epapr() and
>       do_patch_instruction() with CONFIG_STRICT_KERNEL_RWX
> v8: - style
>     - Use in crash_dump.c, mpc86xx_smp.c, smp.c
> ---
>  arch/powerpc/include/asm/code-patching.h  | 32 ++++-----
>  arch/powerpc/include/asm/inst.h           | 18 +++--
>  arch/powerpc/include/asm/sstep.h          |  5 +-
>  arch/powerpc/include/asm/uprobes.h        |  5 +-
>  arch/powerpc/kernel/align.c               |  4 +-
>  arch/powerpc/kernel/crash_dump.c          |  2 +-
>  arch/powerpc/kernel/epapr_paravirt.c      |  6 +-
>  arch/powerpc/kernel/hw_breakpoint.c       |  4 +-
>  arch/powerpc/kernel/jump_label.c          |  2 +-
>  arch/powerpc/kernel/kgdb.c                |  4 +-
>  arch/powerpc/kernel/kprobes.c             |  8 +--
>  arch/powerpc/kernel/mce_power.c           |  5 +-
>  arch/powerpc/kernel/optprobes.c           | 64 +++++++++--------
>  arch/powerpc/kernel/setup_32.c            |  4 +-
>  arch/powerpc/kernel/trace/ftrace.c        | 83 ++++++++++++-----------
>  arch/powerpc/kernel/vecemu.c              |  5 +-
>  arch/powerpc/lib/code-patching.c          | 76 ++++++++++-----------
>  arch/powerpc/lib/feature-fixups.c         | 60 ++++++++--------
>  arch/powerpc/lib/sstep.c                  |  4 +-
>  arch/powerpc/lib/test_emulate_step.c      |  9 +--
>  arch/powerpc/mm/fault.c                   |  4 +-
>  arch/powerpc/perf/core-book3s.c           |  4 +-
>  arch/powerpc/platforms/86xx/mpc86xx_smp.c |  4 +-
>  arch/powerpc/platforms/powermac/smp.c     |  4 +-
>  arch/powerpc/xmon/xmon.c                  | 22 +++---
>  arch/powerpc/xmon/xmon_bpts.h             |  6 +-
>  26 files changed, 233 insertions(+), 211 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/code-patching.h b/arch/powerpc/include/asm/code-patching.h
> index 48e021957ee5..eacc9102c251 100644
> --- a/arch/powerpc/include/asm/code-patching.h
> +++ b/arch/powerpc/include/asm/code-patching.h
> @@ -23,33 +23,33 @@
>  #define BRANCH_ABSOLUTE        0x2
>
>  bool is_offset_in_branch_range(long offset);
> -int create_branch(unsigned int *instr, const unsigned int *addr,
> +int create_branch(struct ppc_inst *instr, const struct ppc_inst *addr,
>                   unsigned long target, int flags);
> -int create_cond_branch(unsigned int *instr, const unsigned int *addr,
> +int create_cond_branch(struct ppc_inst *instr, const struct ppc_inst *addr,
>                        unsigned long target, int flags);
> -int patch_branch(unsigned int *addr, unsigned long target, int flags);
> -int patch_instruction(unsigned int *addr, unsigned int instr);
> -int raw_patch_instruction(unsigned int *addr, unsigned int instr);
> +int patch_branch(struct ppc_inst *addr, unsigned long target, int flags);
> +int patch_instruction(struct ppc_inst *addr, struct ppc_inst instr);
> +int raw_patch_instruction(struct ppc_inst *addr, struct ppc_inst instr);
>
>  static inline unsigned long patch_site_addr(s32 *site)
>  {
>         return (unsigned long)site + *site;
>  }
>
> -static inline int patch_instruction_site(s32 *site, unsigned int instr)
> +static inline int patch_instruction_site(s32 *site, struct ppc_inst instr)
>  {
> -       return patch_instruction((unsigned int *)patch_site_addr(site), instr);
> +       return patch_instruction((struct ppc_inst *)patch_site_addr(site), instr);
>  }
>
>  static inline int patch_branch_site(s32 *site, unsigned long target, int flags)
>  {
> -       return patch_branch((unsigned int *)patch_site_addr(site), target, flags);
> +       return patch_branch((struct ppc_inst *)patch_site_addr(site), target, flags);
>  }
>
>  static inline int modify_instruction(unsigned int *addr, unsigned int clr,
>                                      unsigned int set)
>  {
> -       return patch_instruction(addr, ppc_inst((*addr & ~clr) | set));
> +       return patch_instruction((struct ppc_inst *)addr, ppc_inst((*addr & ~clr) | set));
>  }
>
>  static inline int modify_instruction_site(s32 *site, unsigned int clr, unsigned int set)
> @@ -57,13 +57,13 @@ static inline int modify_instruction_site(s32 *site, unsigned int clr, unsigned
>         return modify_instruction((unsigned int *)patch_site_addr(site), clr, set);
>  }
>
> -int instr_is_relative_branch(unsigned int instr);
> -int instr_is_relative_link_branch(unsigned int instr);
> -int instr_is_branch_to_addr(const unsigned int *instr, unsigned long addr);
> -unsigned long branch_target(const unsigned int *instr);
> -int translate_branch(unsigned int *instr, const unsigned int *dest,
> -                    const unsigned int *src);
> -extern bool is_conditional_branch(unsigned int instr);
> +int instr_is_relative_branch(struct ppc_inst instr);
> +int instr_is_relative_link_branch(struct ppc_inst instr);
> +int instr_is_branch_to_addr(const struct ppc_inst *instr, unsigned long addr);
> +unsigned long branch_target(const struct ppc_inst *instr);
> +int translate_branch(struct ppc_inst *instr, const struct ppc_inst *dest,
> +                    const struct ppc_inst *src);
> +extern bool is_conditional_branch(struct ppc_inst instr);
>  #ifdef CONFIG_PPC_BOOK3E_64
>  void __patch_exception(int exc, unsigned long addr);
>  #define patch_exception(exc, name) do { \
> diff --git a/arch/powerpc/include/asm/inst.h b/arch/powerpc/include/asm/inst.h
> index 0c5dc539160a..19d8bb7a1c2b 100644
> --- a/arch/powerpc/include/asm/inst.h
> +++ b/arch/powerpc/include/asm/inst.h
> @@ -6,26 +6,30 @@
>   * Instruction data type for POWER
>   */
>
> -#define ppc_inst(x) (x)
> +struct ppc_inst {
> +       u32 val;
> +} __packed;
>
> -static inline u32 ppc_inst_val(u32 x)
> +#define ppc_inst(x) ((struct ppc_inst){ .val = x })
> +
> +static inline u32 ppc_inst_val(struct ppc_inst x)
>  {
> -       return x;
> +       return x.val;
>  }
>
> -static inline int ppc_inst_primary_opcode(u32 x)
> +static inline int ppc_inst_primary_opcode(struct ppc_inst x)
>  {
>         return ppc_inst_val(x) >> 26;
>  }
>
> -static inline u32 ppc_inst_swab(u32 x)
> +static inline struct ppc_inst ppc_inst_swab(struct ppc_inst x)
>  {
>         return ppc_inst(swab32(ppc_inst_val(x)));
>  }
>
> -static inline bool ppc_inst_equal(u32 x, u32 y)
> +static inline bool ppc_inst_equal(struct ppc_inst x, struct ppc_inst y)
>  {
> -       return x == y;
> +       return ppc_inst_val(x) == ppc_inst_val(y);
>  }
>
>  #endif /* _ASM_INST_H */
> diff --git a/arch/powerpc/include/asm/sstep.h b/arch/powerpc/include/asm/sstep.h
> index 26d729562fe2..c3ce903ac488 100644
> --- a/arch/powerpc/include/asm/sstep.h
> +++ b/arch/powerpc/include/asm/sstep.h
> @@ -2,6 +2,7 @@
>  /*
>   * Copyright (C) 2004 Paul Mackerras <paulus@au.ibm.com>, IBM
>   */
> +#include <asm/inst.h>
>
>  struct pt_regs;
>
> @@ -132,7 +133,7 @@ union vsx_reg {
>   * otherwise.
>   */
>  extern int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
> -                        unsigned int instr);
> +                        struct ppc_inst instr);
>
>  /*
>   * Emulate an instruction that can be executed just by updating
> @@ -149,7 +150,7 @@ void emulate_update_regs(struct pt_regs *reg, struct instruction_op *op);
>   * 0 if it could not be emulated, or -1 for an instruction that
>   * should not be emulated (rfid, mtmsrd clearing MSR_RI, etc.).
>   */
> -extern int emulate_step(struct pt_regs *regs, unsigned int instr);
> +extern int emulate_step(struct pt_regs *regs, struct ppc_inst instr);
>
>  /*
>   * Emulate a load or store instruction by reading/writing the
> diff --git a/arch/powerpc/include/asm/uprobes.h b/arch/powerpc/include/asm/uprobes.h
> index 2bbdf27d09b5..7e3b329ba2d3 100644
> --- a/arch/powerpc/include/asm/uprobes.h
> +++ b/arch/powerpc/include/asm/uprobes.h
> @@ -11,6 +11,7 @@
>
>  #include <linux/notifier.h>
>  #include <asm/probes.h>
> +#include <asm/inst.h>
>
>  typedef ppc_opcode_t uprobe_opcode_t;
>
> @@ -23,8 +24,8 @@ typedef ppc_opcode_t uprobe_opcode_t;
>
>  struct arch_uprobe {
>         union {
> -               u32     insn;
> -               u32     ixol;
> +               struct ppc_inst insn;
> +               struct ppc_inst ixol;
>         };
>  };
>
> diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c
> index a63216da8cf1..9e66e6c62354 100644
> --- a/arch/powerpc/kernel/align.c
> +++ b/arch/powerpc/kernel/align.c
> @@ -294,7 +294,7 @@ static int emulate_spe(struct pt_regs *regs, unsigned int reg,
>
>  int fix_alignment(struct pt_regs *regs)
>  {
> -       unsigned int instr;
> +       struct ppc_inst instr;
>         struct instruction_op op;
>         int r, type;
>
> @@ -304,7 +304,7 @@ int fix_alignment(struct pt_regs *regs)
>          */
>         CHECK_FULL_REGS(regs);
>
> -       if (unlikely(__get_user(instr, (unsigned int __user *)regs->nip)))
> +       if (unlikely(__get_user(instr.val, (unsigned int __user *)regs->nip)))
>                 return -EFAULT;
>         if ((regs->msr & MSR_LE) != (MSR_KERNEL & MSR_LE)) {
>                 /* We don't handle PPC little-endian any more... */
> diff --git a/arch/powerpc/kernel/crash_dump.c b/arch/powerpc/kernel/crash_dump.c
> index 78e556b131db..72bafb47e757 100644
> --- a/arch/powerpc/kernel/crash_dump.c
> +++ b/arch/powerpc/kernel/crash_dump.c
> @@ -35,7 +35,7 @@ void __init reserve_kdump_trampoline(void)
>
>  static void __init create_trampoline(unsigned long addr)
>  {
> -       unsigned int *p = (unsigned int *)addr;
> +       struct ppc_inst *p = (struct ppc_inst *)addr;
>
>         /* The maximum range of a single instruction branch, is the current
>          * instruction's address + (32 MB - 4) bytes. For the trampoline we
> diff --git a/arch/powerpc/kernel/epapr_paravirt.c b/arch/powerpc/kernel/epapr_paravirt.c
> index e8eb72a65572..2ed14d4a47f5 100644
> --- a/arch/powerpc/kernel/epapr_paravirt.c
> +++ b/arch/powerpc/kernel/epapr_paravirt.c
> @@ -37,10 +37,10 @@ static int __init early_init_dt_scan_epapr(unsigned long node,
>                 return -1;
>
>         for (i = 0; i < (len / 4); i++) {
> -               u32 inst = ppc_inst(be32_to_cpu(insts[i]));
> -               patch_instruction(epapr_hypercall_start + i, inst);
> +               struct ppc_inst inst = ppc_inst(be32_to_cpu(insts[i]));
> +               patch_instruction((struct ppc_inst *)(epapr_hypercall_start + i), inst);
>  #if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
> -               patch_instruction(epapr_ev_idle_start + i, inst);
> +               patch_instruction((struct ppc_inst *)(epapr_ev_idle_start + i), inst);
>  #endif
>         }
>
> diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c
> index 46e09ac8b84a..2db9a7ac7bcb 100644
> --- a/arch/powerpc/kernel/hw_breakpoint.c
> +++ b/arch/powerpc/kernel/hw_breakpoint.c
> @@ -244,12 +244,12 @@ dar_range_overlaps(unsigned long dar, int size, struct arch_hw_breakpoint *info)
>  static bool stepping_handler(struct pt_regs *regs, struct perf_event *bp,
>                              struct arch_hw_breakpoint *info)
>  {
> -       unsigned int instr = ppc_inst(0);
> +       struct ppc_inst instr = ppc_inst(0);
>         int ret, type, size;
>         struct instruction_op op;
>         unsigned long addr = info->address;
>
> -       if (__get_user_inatomic(instr, (unsigned int *)regs->nip))
> +       if (__get_user_inatomic(instr.val, (unsigned int *)regs->nip))
>                 goto fail;
>
>         ret = analyse_instr(&op, regs, instr);
> diff --git a/arch/powerpc/kernel/jump_label.c b/arch/powerpc/kernel/jump_label.c
> index daa4afce7ec8..144858027fa3 100644
> --- a/arch/powerpc/kernel/jump_label.c
> +++ b/arch/powerpc/kernel/jump_label.c
> @@ -11,7 +11,7 @@
>  void arch_jump_label_transform(struct jump_entry *entry,
>                                enum jump_label_type type)
>  {
> -       u32 *addr = (u32 *)(unsigned long)entry->code;
> +       struct ppc_inst *addr = (struct ppc_inst *)(unsigned long)entry->code;
>
>         if (type == JUMP_LABEL_JMP)
>                 patch_branch(addr, entry->target, 0);
> diff --git a/arch/powerpc/kernel/kgdb.c b/arch/powerpc/kernel/kgdb.c
> index a6b38a19133f..652b2852bea3 100644
> --- a/arch/powerpc/kernel/kgdb.c
> +++ b/arch/powerpc/kernel/kgdb.c
> @@ -419,7 +419,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
>  {
>         int err;
>         unsigned int instr;
> -       unsigned int *addr = (unsigned int *)bpt->bpt_addr;
> +       struct ppc_inst *addr = (struct ppc_inst *)bpt->bpt_addr;
>
>         err = probe_kernel_address(addr, instr);
>         if (err)
> @@ -438,7 +438,7 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
>  {
>         int err;
>         unsigned int instr = *(unsigned int *)bpt->saved_instr;
> -       unsigned int *addr = (unsigned int *)bpt->bpt_addr;
> +       struct ppc_inst *addr = (struct ppc_inst *)bpt->bpt_addr;
>
>         err = patch_instruction(addr, ppc_inst(instr));
>         if (err)
> diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
> index 92fa3070d905..a08ae5803622 100644
> --- a/arch/powerpc/kernel/kprobes.c
> +++ b/arch/powerpc/kernel/kprobes.c
> @@ -106,7 +106,7 @@ kprobe_opcode_t *kprobe_lookup_name(const char *name, unsigned int offset)
>  int arch_prepare_kprobe(struct kprobe *p)
>  {
>         int ret = 0;
> -       kprobe_opcode_t insn = *p->addr;
> +       struct ppc_inst insn = *(struct ppc_inst *)p->addr;
>
>         if ((unsigned long)p->addr & 0x03) {
>                 printk("Attempt to register kprobe at an unaligned address\n");
> @@ -139,13 +139,13 @@ NOKPROBE_SYMBOL(arch_prepare_kprobe);
>
>  void arch_arm_kprobe(struct kprobe *p)
>  {
> -       patch_instruction(p->addr, ppc_inst(BREAKPOINT_INSTRUCTION));
> +       patch_instruction((struct ppc_inst *)p->addr, ppc_inst(BREAKPOINT_INSTRUCTION));
>  }
>  NOKPROBE_SYMBOL(arch_arm_kprobe);
>
>  void arch_disarm_kprobe(struct kprobe *p)
>  {
> -       patch_instruction(p->addr, ppc_inst(p->opcode));
> +       patch_instruction((struct ppc_inst *)p->addr, ppc_inst(p->opcode));
>  }
>  NOKPROBE_SYMBOL(arch_disarm_kprobe);
>
> @@ -217,7 +217,7 @@ NOKPROBE_SYMBOL(arch_prepare_kretprobe);
>  static int try_to_emulate(struct kprobe *p, struct pt_regs *regs)
>  {
>         int ret;
> -       unsigned int insn = *p->ainsn.insn;
> +       struct ppc_inst insn = *(struct ppc_inst *)p->ainsn.insn;
>
>         /* regs->nip is also adjusted if emulate_step returns 1 */
>         ret = emulate_step(regs, insn);
> diff --git a/arch/powerpc/kernel/mce_power.c b/arch/powerpc/kernel/mce_power.c
> index 067b094bfeff..cd23218c60bb 100644
> --- a/arch/powerpc/kernel/mce_power.c
> +++ b/arch/powerpc/kernel/mce_power.c
> @@ -20,6 +20,7 @@
>  #include <asm/sstep.h>
>  #include <asm/exception-64s.h>
>  #include <asm/extable.h>
> +#include <asm/inst.h>
>
>  /*
>   * Convert an address related to an mm to a PFN. NOTE: we are in real
> @@ -365,7 +366,7 @@ static int mce_find_instr_ea_and_phys(struct pt_regs *regs, uint64_t *addr,
>          * in real-mode is tricky and can lead to recursive
>          * faults
>          */
> -       int instr;
> +       struct ppc_inst instr;
>         unsigned long pfn, instr_addr;
>         struct instruction_op op;
>         struct pt_regs tmp = *regs;
> @@ -373,7 +374,7 @@ static int mce_find_instr_ea_and_phys(struct pt_regs *regs, uint64_t *addr,
>         pfn = addr_to_pfn(regs, regs->nip);
>         if (pfn != ULONG_MAX) {
>                 instr_addr = (pfn << PAGE_SHIFT) + (regs->nip & ~PAGE_MASK);
> -               instr = *(unsigned int *)(instr_addr);
> +               instr = *(struct ppc_inst *)(instr_addr);
>                 if (!analyse_instr(&op, &tmp, instr)) {
>                         pfn = addr_to_pfn(regs, op.ea);
>                         *addr = op.ea;
> diff --git a/arch/powerpc/kernel/optprobes.c b/arch/powerpc/kernel/optprobes.c
> index 44006c4ca4f1..5a71fef71c22 100644
> --- a/arch/powerpc/kernel/optprobes.c
> +++ b/arch/powerpc/kernel/optprobes.c
> @@ -100,8 +100,9 @@ static unsigned long can_optimize(struct kprobe *p)
>          * Ensure that the instruction is not a conditional branch,
>          * and that can be emulated.
>          */
> -       if (!is_conditional_branch(*p->ainsn.insn) &&
> -                       analyse_instr(&op, &regs, *p->ainsn.insn) == 1) {
> +       if (!is_conditional_branch(*(struct ppc_inst *)p->ainsn.insn) &&
> +           analyse_instr(&op, &regs,
> +                         *(struct ppc_inst *)p->ainsn.insn) == 1) {
>                 emulate_update_regs(&regs, &op);
>                 nip = regs.nip;
>         }
> @@ -148,13 +149,15 @@ void arch_remove_optimized_kprobe(struct optimized_kprobe *op)
>  void patch_imm32_load_insns(unsigned int val, kprobe_opcode_t *addr)
>  {
>         /* addis r4,0,(insn)@h */
> -       patch_instruction(addr, ppc_inst(PPC_INST_ADDIS | ___PPC_RT(4) |
> -                         ((val >> 16) & 0xffff)));
> +       patch_instruction((struct ppc_inst *)addr,
> +                         ppc_inst(PPC_INST_ADDIS | ___PPC_RT(4) |
> +                                  ((val >> 16) & 0xffff)));
>         addr++;
>
>         /* ori r4,r4,(insn)@l */
> -       patch_instruction(addr, ppc_inst(PPC_INST_ORI | ___PPC_RA(4) |
> -                         ___PPC_RS(4) | (val & 0xffff)));
> +       patch_instruction((struct ppc_inst *)addr,
> +                         ppc_inst(PPC_INST_ORI | ___PPC_RA(4) |
> +                                  ___PPC_RS(4) | (val & 0xffff)));
>  }
>
>  /*
> @@ -164,34 +167,39 @@ void patch_imm32_load_insns(unsigned int val, kprobe_opcode_t *addr)
>  void patch_imm64_load_insns(unsigned long val, kprobe_opcode_t *addr)
>  {
>         /* lis r3,(op)@highest */
> -       patch_instruction(addr, ppc_inst(PPC_INST_ADDIS | ___PPC_RT(3) |
> -                         ((val >> 48) & 0xffff)));
> +       patch_instruction((struct ppc_inst *)addr,
> +                         ppc_inst(PPC_INST_ADDIS | ___PPC_RT(3) |
> +                                  ((val >> 48) & 0xffff)));
>         addr++;
>
>         /* ori r3,r3,(op)@higher */
> -       patch_instruction(addr, ppc_inst(PPC_INST_ORI | ___PPC_RA(3) |
> -                         ___PPC_RS(3) | ((val >> 32) & 0xffff)));
> +       patch_instruction((struct ppc_inst *)addr,
> +                         ppc_inst(PPC_INST_ORI | ___PPC_RA(3) |
> +                                  ___PPC_RS(3) | ((val >> 32) & 0xffff)));
>         addr++;
>
>         /* rldicr r3,r3,32,31 */
> -       patch_instruction(addr, ppc_inst(PPC_INST_RLDICR | ___PPC_RA(3) |
> -                         ___PPC_RS(3) | __PPC_SH64(32) | __PPC_ME64(31)));
> +       patch_instruction((struct ppc_inst *)addr,
> +                         ppc_inst(PPC_INST_RLDICR | ___PPC_RA(3) |
> +                                  ___PPC_RS(3) | __PPC_SH64(32) | __PPC_ME64(31)));
>         addr++;
>
>         /* oris r3,r3,(op)@h */
> -       patch_instruction(addr, ppc_inst(PPC_INST_ORIS | ___PPC_RA(3) |
> -                         ___PPC_RS(3) | ((val >> 16) & 0xffff)));
> +       patch_instruction((struct ppc_inst *)addr,
> +                         ppc_inst(PPC_INST_ORIS | ___PPC_RA(3) |
> +                                  ___PPC_RS(3) | ((val >> 16) & 0xffff)));
>         addr++;
>
>         /* ori r3,r3,(op)@l */
> -       patch_instruction(addr, ppc_inst(PPC_INST_ORI | ___PPC_RA(3) |
> -                         ___PPC_RS(3) | (val & 0xffff)));
> +       patch_instruction((struct ppc_inst *)addr,
> +                         ppc_inst(PPC_INST_ORI | ___PPC_RA(3) |
> +                                  ___PPC_RS(3) | (val & 0xffff)));
>  }
>
>  int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *p)
>  {
> -       kprobe_opcode_t *buff, branch_op_callback, branch_emulate_step;
> -       kprobe_opcode_t *op_callback_addr, *emulate_step_addr;
> +       struct ppc_inst branch_op_callback, branch_emulate_step;
> +       kprobe_opcode_t *op_callback_addr, *emulate_step_addr, *buff;
>         long b_offset;
>         unsigned long nip, size;
>         int rc, i;
> @@ -231,7 +239,7 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *p)
>         size = (TMPL_END_IDX * sizeof(kprobe_opcode_t)) / sizeof(int);
>         pr_devel("Copying template to %p, size %lu\n", buff, size);
>         for (i = 0; i < size; i++) {
> -               rc = patch_instruction(buff + i,
> +               rc = patch_instruction((struct ppc_inst *)(buff + i),
>                                        ppc_inst(*(optprobe_template_entry + i)));
>                 if (rc < 0)
>                         goto error;
> @@ -254,20 +262,22 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *p)
>         }
>
>         rc = create_branch(&branch_op_callback,
> -                          (unsigned int *)buff + TMPL_CALL_HDLR_IDX,
> +                          (struct ppc_inst *)(buff + TMPL_CALL_HDLR_IDX),
>                            (unsigned long)op_callback_addr,
>                            BRANCH_SET_LINK);
>
>         rc |= create_branch(&branch_emulate_step,
> -                           (unsigned int *)buff + TMPL_EMULATE_IDX,
> +                           (struct ppc_inst *)(buff + TMPL_EMULATE_IDX),
>                             (unsigned long)emulate_step_addr,
>                             BRANCH_SET_LINK);
>
>         if (rc)
>                 goto error;
>
> -       patch_instruction(buff + TMPL_CALL_HDLR_IDX, branch_op_callback);
> -       patch_instruction(buff + TMPL_EMULATE_IDX, branch_emulate_step);
> +       patch_instruction((struct ppc_inst *)(buff + TMPL_CALL_HDLR_IDX),
> +                         branch_op_callback);
> +       patch_instruction((struct ppc_inst *)(buff + TMPL_EMULATE_IDX),
> +                         branch_emulate_step);
>
>         /*
>          * 3. load instruction to be emulated into relevant register, and
> @@ -277,7 +287,7 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *p)
>         /*
>          * 4. branch back from trampoline
>          */
> -       patch_branch(buff + TMPL_RET_IDX, (unsigned long)nip, 0);
> +       patch_branch((struct ppc_inst *)(buff + TMPL_RET_IDX), (unsigned long)nip, 0);
>
>         flush_icache_range((unsigned long)buff,
>                            (unsigned long)(&buff[TMPL_END_IDX]));
> @@ -309,7 +319,7 @@ int arch_check_optimized_kprobe(struct optimized_kprobe *op)
>
>  void arch_optimize_kprobes(struct list_head *oplist)
>  {
> -       unsigned int instr;
> +       struct ppc_inst instr;
>         struct optimized_kprobe *op;
>         struct optimized_kprobe *tmp;
>
> @@ -321,9 +331,9 @@ void arch_optimize_kprobes(struct list_head *oplist)
>                 memcpy(op->optinsn.copied_insn, op->kp.addr,
>                                                RELATIVEJUMP_SIZE);
>                 create_branch(&instr,
> -                             (unsigned int *)op->kp.addr,
> +                             (struct ppc_inst *)op->kp.addr,
>                               (unsigned long)op->optinsn.insn, 0);
> -               patch_instruction(op->kp.addr, instr);
> +               patch_instruction((struct ppc_inst *)op->kp.addr, instr);
>                 list_del_init(&op->list);
>         }
>  }
> diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
> index 0536e4aed330..15f0a7c84944 100644
> --- a/arch/powerpc/kernel/setup_32.c
> +++ b/arch/powerpc/kernel/setup_32.c
> @@ -74,8 +74,8 @@ EXPORT_SYMBOL(DMA_MODE_WRITE);
>   */
>  notrace void __init machine_init(u64 dt_ptr)
>  {
> -       unsigned int *addr = (unsigned int *)patch_site_addr(&patch__memset_nocache);
> -       unsigned int insn;
> +       struct ppc_inst *addr = (struct ppc_inst *)patch_site_addr(&patch__memset_nocache);
> +       struct ppc_inst insn;
>
>         /* Configure static keys first, now that we're relocated. */
>         setup_feature_keys();
> diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c
> index cbb19af4a72a..3117ed675735 100644
> --- a/arch/powerpc/kernel/trace/ftrace.c
> +++ b/arch/powerpc/kernel/trace/ftrace.c
> @@ -41,23 +41,23 @@
>  #define        NUM_FTRACE_TRAMPS       8
>  static unsigned long ftrace_tramps[NUM_FTRACE_TRAMPS];
>
> -static unsigned int
> +static struct ppc_inst
>  ftrace_call_replace(unsigned long ip, unsigned long addr, int link)
>  {
> -       unsigned int op;
> +       struct ppc_inst op;
>
>         addr = ppc_function_entry((void *)addr);
>
>         /* if (link) set op to 'bl' else 'b' */
> -       create_branch(&op, (unsigned int *)ip, addr, link ? 1 : 0);
> +       create_branch(&op, (struct ppc_inst *)ip, addr, link ? 1 : 0);
>
>         return op;
>  }
>
>  static int
> -ftrace_modify_code(unsigned long ip, unsigned int old, unsigned int new)
> +ftrace_modify_code(unsigned long ip, struct ppc_inst old, struct ppc_inst new)
>  {
> -       unsigned int replaced;
> +       struct ppc_inst replaced;
>
>         /*
>          * Note:
> @@ -79,7 +79,7 @@ ftrace_modify_code(unsigned long ip, unsigned int old, unsigned int new)
>         }
>
>         /* replace the text with the new text */
> -       if (patch_instruction((unsigned int *)ip, new))
> +       if (patch_instruction((struct ppc_inst *)ip, new))
>                 return -EPERM;
>
>         return 0;
> @@ -90,24 +90,24 @@ ftrace_modify_code(unsigned long ip, unsigned int old, unsigned int new)
>   */
>  static int test_24bit_addr(unsigned long ip, unsigned long addr)
>  {
> -       unsigned int op;
> +       struct ppc_inst op;
>         addr = ppc_function_entry((void *)addr);
>
>         /* use the create_branch to verify that this offset can be branched */
> -       return create_branch(&op, (unsigned int *)ip, addr, 0) == 0;
> +       return create_branch(&op, (struct ppc_inst *)ip, addr, 0) == 0;
>  }
>
> -static int is_bl_op(unsigned int op)
> +static int is_bl_op(struct ppc_inst op)
>  {
>         return (ppc_inst_val(op) & 0xfc000003) == 0x48000001;
>  }
>
> -static int is_b_op(unsigned int op)
> +static int is_b_op(struct ppc_inst op)
>  {
>         return (ppc_inst_val(op) & 0xfc000003) == 0x48000000;
>  }
>
> -static unsigned long find_bl_target(unsigned long ip, unsigned int op)
> +static unsigned long find_bl_target(unsigned long ip, struct ppc_inst op)
>  {
>         int offset;
>
> @@ -127,7 +127,7 @@ __ftrace_make_nop(struct module *mod,
>  {
>         unsigned long entry, ptr, tramp;
>         unsigned long ip = rec->ip;
> -       unsigned int op, pop;
> +       struct ppc_inst op, pop;
>
>         /* read where this goes */
>         if (probe_kernel_read(&op, (void *)ip, sizeof(int))) {
> @@ -208,7 +208,7 @@ __ftrace_make_nop(struct module *mod,
>         }
>  #endif /* CONFIG_MPROFILE_KERNEL */
>
> -       if (patch_instruction((unsigned int *)ip, pop)) {
> +       if (patch_instruction((struct ppc_inst *)ip, pop)) {
>                 pr_err("Patching NOP failed.\n");
>                 return -EPERM;
>         }
> @@ -221,7 +221,7 @@ static int
>  __ftrace_make_nop(struct module *mod,
>                   struct dyn_ftrace *rec, unsigned long addr)
>  {
> -       unsigned int op;
> +       struct ppc_inst op;
>         unsigned int jmp[4];
>         unsigned long ip = rec->ip;
>         unsigned long tramp;
> @@ -280,7 +280,7 @@ __ftrace_make_nop(struct module *mod,
>
>         op = ppc_inst(PPC_INST_NOP);
>
> -       if (patch_instruction((unsigned int *)ip, op))
> +       if (patch_instruction((struct ppc_inst *)ip, op))
>                 return -EPERM;
>
>         return 0;
> @@ -291,7 +291,7 @@ __ftrace_make_nop(struct module *mod,
>  static unsigned long find_ftrace_tramp(unsigned long ip)
>  {
>         int i;
> -       unsigned int instr;
> +       struct ppc_inst instr;
>
>         /*
>          * We have the compiler generated long_branch tramps at the end
> @@ -328,9 +328,10 @@ static int add_ftrace_tramp(unsigned long tramp)
>   */
>  static int setup_mcount_compiler_tramp(unsigned long tramp)
>  {
> -       int i, op;
> +       int i;
> +       struct ppc_inst op;
>         unsigned long ptr;
> -       unsigned int instr;
> +       struct ppc_inst instr;
>         static unsigned long ftrace_plt_tramps[NUM_FTRACE_TRAMPS];
>
>         /* Is this a known long jump tramp? */
> @@ -379,7 +380,7 @@ static int setup_mcount_compiler_tramp(unsigned long tramp)
>                 return -1;
>         }
>
> -       if (patch_branch((unsigned int *)tramp, ptr, 0)) {
> +       if (patch_branch((struct ppc_inst *)tramp, ptr, 0)) {
>                 pr_debug("REL24 out of range!\n");
>                 return -1;
>         }
> @@ -395,7 +396,7 @@ static int setup_mcount_compiler_tramp(unsigned long tramp)
>  static int __ftrace_make_nop_kernel(struct dyn_ftrace *rec, unsigned long addr)
>  {
>         unsigned long tramp, ip = rec->ip;
> -       unsigned int op;
> +       struct ppc_inst op;
>
>         /* Read where this goes */
>         if (probe_kernel_read(&op, (void *)ip, sizeof(int))) {
> @@ -423,7 +424,7 @@ static int __ftrace_make_nop_kernel(struct dyn_ftrace *rec, unsigned long addr)
>                 }
>         }
>
> -       if (patch_instruction((unsigned int *)ip, ppc_inst(PPC_INST_NOP))) {
> +       if (patch_instruction((struct ppc_inst *)ip, ppc_inst(PPC_INST_NOP))) {
>                 pr_err("Patching NOP failed.\n");
>                 return -EPERM;
>         }
> @@ -435,7 +436,7 @@ int ftrace_make_nop(struct module *mod,
>                     struct dyn_ftrace *rec, unsigned long addr)
>  {
>         unsigned long ip = rec->ip;
> -       unsigned int old, new;
> +       struct ppc_inst old, new;
>
>         /*
>          * If the calling address is more that 24 bits away,
> @@ -488,7 +489,7 @@ int ftrace_make_nop(struct module *mod,
>   */
>  #ifndef CONFIG_MPROFILE_KERNEL
>  static int
> -expected_nop_sequence(void *ip, unsigned int op0, unsigned int op1)
> +expected_nop_sequence(void *ip, struct ppc_inst op0, struct ppc_inst op1)
>  {
>         /*
>          * We expect to see:
> @@ -506,7 +507,7 @@ expected_nop_sequence(void *ip, unsigned int op0, unsigned int op1)
>  }
>  #else
>  static int
> -expected_nop_sequence(void *ip, unsigned int op0, unsigned int op1)
> +expected_nop_sequence(void *ip, struct ppc_inst op0, struct ppc_inst op1)
>  {
>         /* look for patched "NOP" on ppc64 with -mprofile-kernel */
>         if (!ppc_inst_equal(op0, ppc_inst(PPC_INST_NOP)))
> @@ -518,8 +519,8 @@ expected_nop_sequence(void *ip, unsigned int op0, unsigned int op1)
>  static int
>  __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
>  {
> -       unsigned int op[2];
> -       unsigned int instr;
> +       struct ppc_inst op[2];
> +       struct ppc_inst instr;
>         void *ip = (void *)rec->ip;
>         unsigned long entry, ptr, tramp;
>         struct module *mod = rec->arch.mod;
> @@ -584,7 +585,7 @@ static int
>  __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
>  {
>         int err;
> -       unsigned int op;
> +       struct ppc_inst op;
>         unsigned long ip = rec->ip;
>
>         /* read where this goes */
> @@ -604,7 +605,7 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
>         }
>
>         /* create the branch to the trampoline */
> -       err = create_branch(&op, (unsigned int *)ip,
> +       err = create_branch(&op, (struct ppc_inst *)ip,
>                             rec->arch.mod->arch.tramp, BRANCH_SET_LINK);
>         if (err) {
>                 pr_err("REL24 out of range!\n");
> @@ -613,7 +614,7 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
>
>         pr_devel("write to %lx\n", rec->ip);
>
> -       if (patch_instruction((unsigned int *)ip, op))
> +       if (patch_instruction((struct ppc_inst *)ip, op))
>                 return -EPERM;
>
>         return 0;
> @@ -623,7 +624,7 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
>
>  static int __ftrace_make_call_kernel(struct dyn_ftrace *rec, unsigned long addr)
>  {
> -       unsigned int op;
> +       struct ppc_inst op;
>         void *ip = (void *)rec->ip;
>         unsigned long tramp, entry, ptr;
>
> @@ -671,7 +672,7 @@ static int __ftrace_make_call_kernel(struct dyn_ftrace *rec, unsigned long addr)
>  int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
>  {
>         unsigned long ip = rec->ip;
> -       unsigned int old, new;
> +       struct ppc_inst old, new;
>
>         /*
>          * If the calling address is more that 24 bits away,
> @@ -710,7 +711,7 @@ static int
>  __ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
>                                         unsigned long addr)
>  {
> -       unsigned int op;
> +       struct ppc_inst op;
>         unsigned long ip = rec->ip;
>         unsigned long entry, ptr, tramp;
>         struct module *mod = rec->arch.mod;
> @@ -758,7 +759,7 @@ __ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
>         /* The new target may be within range */
>         if (test_24bit_addr(ip, addr)) {
>                 /* within range */
> -               if (patch_branch((unsigned int *)ip, addr, BRANCH_SET_LINK)) {
> +               if (patch_branch((struct ppc_inst *)ip, addr, BRANCH_SET_LINK)) {
>                         pr_err("REL24 out of range!\n");
>                         return -EINVAL;
>                 }
> @@ -786,12 +787,12 @@ __ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
>         }
>
>         /* Ensure branch is within 24 bits */
> -       if (create_branch(&op, (unsigned int *)ip, tramp, BRANCH_SET_LINK)) {
> +       if (create_branch(&op, (struct ppc_inst *)ip, tramp, BRANCH_SET_LINK)) {
>                 pr_err("Branch out of range\n");
>                 return -EINVAL;
>         }
>
> -       if (patch_branch((unsigned int *)ip, tramp, BRANCH_SET_LINK)) {
> +       if (patch_branch((struct ppc_inst *)ip, tramp, BRANCH_SET_LINK)) {
>                 pr_err("REL24 out of range!\n");
>                 return -EINVAL;
>         }
> @@ -804,7 +805,7 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
>                         unsigned long addr)
>  {
>         unsigned long ip = rec->ip;
> -       unsigned int old, new;
> +       struct ppc_inst old, new;
>
>         /*
>          * If the calling address is more that 24 bits away,
> @@ -844,10 +845,10 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
>  int ftrace_update_ftrace_func(ftrace_func_t func)
>  {
>         unsigned long ip = (unsigned long)(&ftrace_call);
> -       unsigned int old, new;
> +       struct ppc_inst old, new;
>         int ret;
>
> -       old = *(unsigned int *)&ftrace_call;
> +       old = *(struct ppc_inst *)&ftrace_call;
>         new = ftrace_call_replace(ip, (unsigned long)func, 1);
>         ret = ftrace_modify_code(ip, old, new);
>
> @@ -855,7 +856,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
>         /* Also update the regs callback function */
>         if (!ret) {
>                 ip = (unsigned long)(&ftrace_regs_call);
> -               old = *(unsigned int *)&ftrace_regs_call;
> +               old = *(struct ppc_inst *)&ftrace_regs_call;
>                 new = ftrace_call_replace(ip, (unsigned long)func, 1);
>                 ret = ftrace_modify_code(ip, old, new);
>         }
> @@ -929,7 +930,7 @@ int ftrace_enable_ftrace_graph_caller(void)
>         unsigned long ip = (unsigned long)(&ftrace_graph_call);
>         unsigned long addr = (unsigned long)(&ftrace_graph_caller);
>         unsigned long stub = (unsigned long)(&ftrace_graph_stub);
> -       unsigned int old, new;
> +       struct ppc_inst old, new;
>
>         old = ftrace_call_replace(ip, stub, 0);
>         new = ftrace_call_replace(ip, addr, 0);
> @@ -942,7 +943,7 @@ int ftrace_disable_ftrace_graph_caller(void)
>         unsigned long ip = (unsigned long)(&ftrace_graph_call);
>         unsigned long addr = (unsigned long)(&ftrace_graph_caller);
>         unsigned long stub = (unsigned long)(&ftrace_graph_stub);
> -       unsigned int old, new;
> +       struct ppc_inst old, new;
>
>         old = ftrace_call_replace(ip, addr, 0);
>         new = ftrace_call_replace(ip, stub, 0);
> diff --git a/arch/powerpc/kernel/vecemu.c b/arch/powerpc/kernel/vecemu.c
> index a544590b90e5..3dd70eeb10c5 100644
> --- a/arch/powerpc/kernel/vecemu.c
> +++ b/arch/powerpc/kernel/vecemu.c
> @@ -261,11 +261,12 @@ static unsigned int rfin(unsigned int x)
>
>  int emulate_altivec(struct pt_regs *regs)
>  {
> -       unsigned int instr, i, word;
> +       struct ppc_inst instr;
> +       unsigned int i, word;
>         unsigned int va, vb, vc, vd;
>         vector128 *vrs;
>
> -       if (get_user(instr, (unsigned int __user *) regs->nip))
> +       if (get_user(instr.val, (unsigned int __user *)regs->nip))
>                 return -EFAULT;
>
>         word = ppc_inst_val(instr);
> diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
> index d298bb16936e..1dff9d9d6645 100644
> --- a/arch/powerpc/lib/code-patching.c
> +++ b/arch/powerpc/lib/code-patching.c
> @@ -19,12 +19,12 @@
>  #include <asm/setup.h>
>  #include <asm/inst.h>
>
> -static int __patch_instruction(unsigned int *exec_addr, unsigned int instr,
> -                              unsigned int *patch_addr)
> +static int __patch_instruction(struct ppc_inst *exec_addr, struct ppc_inst instr,
> +                              struct ppc_inst *patch_addr)
>  {
>         int err = 0;
>
> -       __put_user_asm(instr, patch_addr, err, "stw");
> +       __put_user_asm(ppc_inst_val(instr), patch_addr, err, "stw");
>         if (err)
>                 return err;
>
> @@ -34,7 +34,7 @@ static int __patch_instruction(unsigned int *exec_addr, unsigned int instr,
>         return 0;
>  }
>
> -int raw_patch_instruction(unsigned int *addr, unsigned int instr)
> +int raw_patch_instruction(struct ppc_inst *addr, struct ppc_inst instr)
>  {
>         return __patch_instruction(addr, instr, addr);
>  }
> @@ -137,10 +137,10 @@ static inline int unmap_patch_area(unsigned long addr)
>         return 0;
>  }
>
> -static int do_patch_instruction(unsigned int *addr, unsigned int instr)
> +static int do_patch_instruction(struct ppc_inst *addr, struct ppc_inst instr)
>  {
>         int err;
> -       unsigned int *patch_addr = NULL;
> +       struct ppc_inst *patch_addr = NULL;
>         unsigned long flags;
>         unsigned long text_poke_addr;
>         unsigned long kaddr = (unsigned long)addr;
> @@ -161,8 +161,7 @@ static int do_patch_instruction(unsigned int *addr, unsigned int instr)
>                 goto out;
>         }
>
> -       patch_addr = (unsigned int *)(text_poke_addr) +
> -                       ((kaddr & ~PAGE_MASK) / sizeof(unsigned int));
> +       patch_addr = (struct ppc_inst *)(text_poke_addr + (kaddr & ~PAGE_MASK));
>
>         __patch_instruction(addr, instr, patch_addr);
>
> @@ -177,14 +176,14 @@ static int do_patch_instruction(unsigned int *addr, unsigned int instr)
>  }
>  #else /* !CONFIG_STRICT_KERNEL_RWX */
>
> -static int do_patch_instruction(unsigned int *addr, unsigned int instr)
> +static int do_patch_instruction(struct ppc_inst *addr, struct ppc_inst instr)
>  {
>         return raw_patch_instruction(addr, instr);
>  }
>
>  #endif /* CONFIG_STRICT_KERNEL_RWX */
>
> -int patch_instruction(unsigned int *addr, unsigned int instr)
> +int patch_instruction(struct ppc_inst *addr, struct ppc_inst instr)
>  {
>         /* Make sure we aren't patching a freed init section */
>         if (init_mem_is_free && init_section_contains(addr, 4)) {
> @@ -195,9 +194,9 @@ int patch_instruction(unsigned int *addr, unsigned int instr)
>  }
>  NOKPROBE_SYMBOL(patch_instruction);
>
> -int patch_branch(unsigned int *addr, unsigned long target, int flags)
> +int patch_branch(struct ppc_inst *addr, unsigned long target, int flags)
>  {
> -       unsigned int instr;
> +       struct ppc_inst instr;
>
>         create_branch(&instr, addr, target, flags);
>         return patch_instruction(addr, instr);
> @@ -229,7 +228,7 @@ bool is_offset_in_branch_range(long offset)
>   * Helper to check if a given instruction is a conditional branch
>   * Derived from the conditional checks in analyse_instr()
>   */
> -bool is_conditional_branch(unsigned int instr)
> +bool is_conditional_branch(struct ppc_inst instr)
>  {
>         unsigned int opcode = ppc_inst_primary_opcode(instr);
>
> @@ -247,13 +246,13 @@ bool is_conditional_branch(unsigned int instr)
>  }
>  NOKPROBE_SYMBOL(is_conditional_branch);
>
> -int create_branch(unsigned int *instr,
> -                 const unsigned int *addr,
> +int create_branch(struct ppc_inst *instr,
> +                 const struct ppc_inst *addr,
>                   unsigned long target, int flags)
>  {
>         long offset;
>
> -       *instr = 0;
> +       *instr = ppc_inst(0);
>         offset = target;
>         if (! (flags & BRANCH_ABSOLUTE))
>                 offset = offset - (unsigned long)addr;
> @@ -263,12 +262,12 @@ int create_branch(unsigned int *instr,
>                 return 1;
>
>         /* Mask out the flags and target, so they don't step on each other. */
> -       *instr = 0x48000000 | (flags & 0x3) | (offset & 0x03FFFFFC);
> +       *instr = ppc_inst(0x48000000 | (flags & 0x3) | (offset & 0x03FFFFFC));
>
>         return 0;
>  }
>
> -int create_cond_branch(unsigned int *instr, const unsigned int *addr,
> +int create_cond_branch(struct ppc_inst *instr, const struct ppc_inst *addr,
>                        unsigned long target, int flags)
>  {
>         long offset;
> @@ -282,27 +281,27 @@ int create_cond_branch(unsigned int *instr, const unsigned int *addr,
>                 return 1;
>
>         /* Mask out the flags and target, so they don't step on each other. */
> -       *instr = 0x40000000 | (flags & 0x3FF0003) | (offset & 0xFFFC);
> +       *instr = ppc_inst(0x40000000 | (flags & 0x3FF0003) | (offset & 0xFFFC));
>
>         return 0;
>  }
>
> -static unsigned int branch_opcode(unsigned int instr)
> +static unsigned int branch_opcode(struct ppc_inst instr)
>  {
>         return ppc_inst_primary_opcode(instr) & 0x3F;
>  }
>
> -static int instr_is_branch_iform(unsigned int instr)
> +static int instr_is_branch_iform(struct ppc_inst instr)
>  {
>         return branch_opcode(instr) == 18;
>  }
>
> -static int instr_is_branch_bform(unsigned int instr)
> +static int instr_is_branch_bform(struct ppc_inst instr)
>  {
>         return branch_opcode(instr) == 16;
>  }
>
> -int instr_is_relative_branch(unsigned int instr)
> +int instr_is_relative_branch(struct ppc_inst instr)
>  {
>         if (ppc_inst_val(instr) & BRANCH_ABSOLUTE)
>                 return 0;
> @@ -310,12 +309,12 @@ int instr_is_relative_branch(unsigned int instr)
>         return instr_is_branch_iform(instr) || instr_is_branch_bform(instr);
>  }
>
> -int instr_is_relative_link_branch(unsigned int instr)
> +int instr_is_relative_link_branch(struct ppc_inst instr)
>  {
>         return instr_is_relative_branch(instr) && (ppc_inst_val(instr) & BRANCH_SET_LINK);
>  }
>
> -static unsigned long branch_iform_target(const unsigned int *instr)
> +static unsigned long branch_iform_target(const struct ppc_inst *instr)
>  {
>         signed long imm;
>
> @@ -331,7 +330,7 @@ static unsigned long branch_iform_target(const unsigned int *instr)
>         return (unsigned long)imm;
>  }
>
> -static unsigned long branch_bform_target(const unsigned int *instr)
> +static unsigned long branch_bform_target(const struct ppc_inst *instr)
>  {
>         signed long imm;
>
> @@ -347,7 +346,7 @@ static unsigned long branch_bform_target(const unsigned int *instr)
>         return (unsigned long)imm;
>  }
>
> -unsigned long branch_target(const unsigned int *instr)
> +unsigned long branch_target(const struct ppc_inst *instr)
>  {
>         if (instr_is_branch_iform(*instr))
>                 return branch_iform_target(instr);
> @@ -357,7 +356,7 @@ unsigned long branch_target(const unsigned int *instr)
>         return 0;
>  }
>
> -int instr_is_branch_to_addr(const unsigned int *instr, unsigned long addr)
> +int instr_is_branch_to_addr(const struct ppc_inst *instr, unsigned long addr)
>  {
>         if (instr_is_branch_iform(*instr) || instr_is_branch_bform(*instr))
>                 return branch_target(instr) == addr;
> @@ -365,8 +364,8 @@ int instr_is_branch_to_addr(const unsigned int *instr, unsigned long addr)
>         return 0;
>  }
>
> -int translate_branch(unsigned int *instr, const unsigned int *dest,
> -                    const unsigned int *src)
> +int translate_branch(struct ppc_inst *instr, const struct ppc_inst *dest,
> +                    const struct ppc_inst *src)
>  {
>         unsigned long target;
>
> @@ -392,7 +391,7 @@ void __patch_exception(int exc, unsigned long addr)
>          * instruction of the exception, not the first one
>          */
>
> -       patch_branch(ibase + (exc / 4) + 1, addr, 0);
> +       patch_branch((struct ppc_inst *)(ibase + (exc / 4) + 1), addr, 0);
>  }
>  #endif
>
> @@ -409,7 +408,7 @@ static void __init test_trampoline(void)
>  static void __init test_branch_iform(void)
>  {
>         int err;
> -       unsigned int instr;
> +       struct ppc_inst instr;
>         unsigned long addr;
>
>         addr = (unsigned long)&instr;
> @@ -484,12 +483,12 @@ static void __init test_branch_iform(void)
>
>  static void __init test_create_function_call(void)
>  {
> -       unsigned int *iptr;
> +       struct ppc_inst *iptr;
>         unsigned long dest;
> -       unsigned int instr;
> +       struct ppc_inst instr;
>
>         /* Check we can create a function call */
> -       iptr = (unsigned int *)ppc_function_entry(test_trampoline);
> +       iptr = (struct ppc_inst *)ppc_function_entry(test_trampoline);
>         dest = ppc_function_entry(test_create_function_call);
>         create_branch(&instr, iptr, dest, BRANCH_SET_LINK);
>         patch_instruction(iptr, instr);
> @@ -500,7 +499,8 @@ static void __init test_branch_bform(void)
>  {
>         int err;
>         unsigned long addr;
> -       unsigned int *iptr, instr, flags;
> +       struct ppc_inst *iptr, instr;
> +       unsigned int flags;
>
>         iptr = &instr;
>         addr = (unsigned long)iptr;
> @@ -570,8 +570,8 @@ static void __init test_branch_bform(void)
>  static void __init test_translate_branch(void)
>  {
>         unsigned long addr;
> -       unsigned int *p, *q;
> -       unsigned int instr;
> +       struct ppc_inst *p, *q;
> +       struct ppc_inst instr;
>         void *buf;
>
>         buf = vmalloc(PAGE_ALIGN(0x2000000 + 1));
> diff --git a/arch/powerpc/lib/feature-fixups.c b/arch/powerpc/lib/feature-fixups.c
> index 6e7479b8887a..fb6e8e8abf4e 100644
> --- a/arch/powerpc/lib/feature-fixups.c
> +++ b/arch/powerpc/lib/feature-fixups.c
> @@ -32,26 +32,26 @@ struct fixup_entry {
>         long            alt_end_off;
>  };
>
> -static unsigned int *calc_addr(struct fixup_entry *fcur, long offset)
> +static struct ppc_inst *calc_addr(struct fixup_entry *fcur, long offset)
>  {
>         /*
>          * We store the offset to the code as a negative offset from
>          * the start of the alt_entry, to support the VDSO. This
>          * routine converts that back into an actual address.
>          */
> -       return (unsigned int *)((unsigned long)fcur + offset);
> +       return (struct ppc_inst *)((unsigned long)fcur + offset);
>  }
>
> -static int patch_alt_instruction(unsigned int *src, unsigned int *dest,
> -                                unsigned int *alt_start, unsigned int *alt_end)
> +static int patch_alt_instruction(struct ppc_inst *src, struct ppc_inst *dest,
> +                                struct ppc_inst *alt_start, struct ppc_inst *alt_end)
>  {
>         int err;
> -       unsigned int instr;
> +       struct ppc_inst instr;
>
>         instr = *src;
>
>         if (instr_is_relative_branch(*src)) {
> -               unsigned int *target = (unsigned int *)branch_target(src);
> +               struct ppc_inst *target = (struct ppc_inst *)branch_target(src);
>
>                 /* Branch within the section doesn't need translating */
>                 if (target < alt_start || target > alt_end) {
> @@ -68,7 +68,7 @@ static int patch_alt_instruction(unsigned int *src, unsigned int *dest,
>
>  static int patch_feature_section(unsigned long value, struct fixup_entry *fcur)
>  {
> -       unsigned int *start, *end, *alt_start, *alt_end, *src, *dest;
> +       struct ppc_inst *start, *end, *alt_start, *alt_end, *src, *dest;
>
>         start = calc_addr(fcur, fcur->start_off);
>         end = calc_addr(fcur, fcur->end_off);
> @@ -147,15 +147,17 @@ static void do_stf_entry_barrier_fixups(enum stf_barrier_type types)
>
>                 pr_devel("patching dest %lx\n", (unsigned long)dest);
>
> -               patch_instruction(dest, ppc_inst(instrs[0]));
> +               patch_instruction((struct ppc_inst *)dest, ppc_inst(instrs[0]));
>
>                 if (types & STF_BARRIER_FALLBACK)
> -                       patch_branch(dest + 1, (unsigned long)&stf_barrier_fallback,
> +                       patch_branch((struct ppc_inst *)(dest + 1),
> +                                    (unsigned long)&stf_barrier_fallback,
>                                      BRANCH_SET_LINK);
>                 else
> -                       patch_instruction(dest + 1, ppc_inst(instrs[1]));
> +                       patch_instruction((struct ppc_inst *)(dest + 1),
> +                                         ppc_inst(instrs[1]));
>
> -               patch_instruction(dest + 2, ppc_inst(instrs[2]));
> +               patch_instruction((struct ppc_inst *)(dest + 2), ppc_inst(instrs[2]));
>         }
>
>         printk(KERN_DEBUG "stf-barrier: patched %d entry locations (%s barrier)\n", i,
> @@ -208,12 +210,12 @@ static void do_stf_exit_barrier_fixups(enum stf_barrier_type types)
>
>                 pr_devel("patching dest %lx\n", (unsigned long)dest);
>
> -               patch_instruction(dest, ppc_inst(instrs[0]));
> -               patch_instruction(dest + 1, ppc_inst(instrs[1]));
> -               patch_instruction(dest + 2, ppc_inst(instrs[2]));
> -               patch_instruction(dest + 3, ppc_inst(instrs[3]));
> -               patch_instruction(dest + 4, ppc_inst(instrs[4]));
> -               patch_instruction(dest + 5, ppc_inst(instrs[5]));
> +               patch_instruction((struct ppc_inst *)dest, ppc_inst(instrs[0]));
> +               patch_instruction((struct ppc_inst *)(dest + 1), ppc_inst(instrs[1]));
> +               patch_instruction((struct ppc_inst *)(dest + 2), ppc_inst(instrs[2]));
> +               patch_instruction((struct ppc_inst *)(dest + 3), ppc_inst(instrs[3]));
> +               patch_instruction((struct ppc_inst *)(dest + 4), ppc_inst(instrs[4]));
> +               patch_instruction((struct ppc_inst *)(dest + 5), ppc_inst(instrs[5]));
>         }
>         printk(KERN_DEBUG "stf-barrier: patched %d exit locations (%s barrier)\n", i,
>                 (types == STF_BARRIER_NONE)                  ? "no" :
> @@ -261,9 +263,9 @@ void do_rfi_flush_fixups(enum l1d_flush_type types)
>
>                 pr_devel("patching dest %lx\n", (unsigned long)dest);
>
> -               patch_instruction(dest, ppc_inst(instrs[0]));
> -               patch_instruction(dest + 1, ppc_inst(instrs[1]));
> -               patch_instruction(dest + 2, ppc_inst(instrs[2]));
> +               patch_instruction((struct ppc_inst *)dest, ppc_inst(instrs[0]));
> +               patch_instruction((struct ppc_inst *)(dest + 1), ppc_inst(instrs[1]));
> +               patch_instruction((struct ppc_inst *)(dest + 2), ppc_inst(instrs[2]));
>         }
>
>         printk(KERN_DEBUG "rfi-flush: patched %d locations (%s flush)\n", i,
> @@ -296,7 +298,7 @@ void do_barrier_nospec_fixups_range(bool enable, void *fixup_start, void *fixup_
>                 dest = (void *)start + *start;
>
>                 pr_devel("patching dest %lx\n", (unsigned long)dest);
> -               patch_instruction(dest, ppc_inst(instr));
> +               patch_instruction((struct ppc_inst *)dest, ppc_inst(instr));
>         }
>
>         printk(KERN_DEBUG "barrier-nospec: patched %d locations\n", i);
> @@ -339,8 +341,8 @@ void do_barrier_nospec_fixups_range(bool enable, void *fixup_start, void *fixup_
>                 dest = (void *)start + *start;
>
>                 pr_devel("patching dest %lx\n", (unsigned long)dest);
> -               patch_instruction(dest, ppc_inst(instr[0]));
> -               patch_instruction(dest + 1, ppc_inst(instr[1]));
> +               patch_instruction((struct ppc_inst *)dest, ppc_inst(instr[0]));
> +               patch_instruction((struct ppc_inst *)(dest + 1), ppc_inst(instr[1]));
>         }
>
>         printk(KERN_DEBUG "barrier-nospec: patched %d locations\n", i);
> @@ -373,7 +375,7 @@ void do_btb_flush_fixups(void)
>  void do_lwsync_fixups(unsigned long value, void *fixup_start, void *fixup_end)
>  {
>         long *start, *end;
> -       unsigned int *dest;
> +       struct ppc_inst *dest;
>
>         if (!(value & CPU_FTR_LWSYNC))
>                 return ;
> @@ -390,18 +392,18 @@ void do_lwsync_fixups(unsigned long value, void *fixup_start, void *fixup_end)
>  static void do_final_fixups(void)
>  {
>  #if defined(CONFIG_PPC64) && defined(CONFIG_RELOCATABLE)
> -       int *src, *dest;
> +       struct ppc_inst *src, *dest;
>         unsigned long length;
>
>         if (PHYSICAL_START == 0)
>                 return;
>
> -       src = (int *)(KERNELBASE + PHYSICAL_START);
> -       dest = (int *)KERNELBASE;
> -       length = (__end_interrupts - _stext) / sizeof(int);
> +       src = (struct ppc_inst *)(KERNELBASE + PHYSICAL_START);
> +       dest = (struct ppc_inst *)KERNELBASE;
> +       length = (__end_interrupts - _stext) / sizeof(struct ppc_inst);
>
>         while (length--) {
> -               raw_patch_instruction(dest, ppc_inst(*src));
> +               raw_patch_instruction(dest, *src);
>                 src++;
>                 dest++;
>         }
> diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
> index 7f7be154da7e..95a56bb1ba3f 100644
> --- a/arch/powerpc/lib/sstep.c
> +++ b/arch/powerpc/lib/sstep.c
> @@ -1163,7 +1163,7 @@ static nokprobe_inline int trap_compare(long v1, long v2)
>   * otherwise.
>   */
>  int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
> -                 unsigned int instr)
> +                 struct ppc_inst instr)
>  {
>         unsigned int opcode, ra, rb, rc, rd, spr, u;
>         unsigned long int imm;
> @@ -3103,7 +3103,7 @@ NOKPROBE_SYMBOL(emulate_loadstore);
>   * or -1 if the instruction is one that should not be stepped,
>   * such as an rfid, or a mtmsrd that would clear MSR_RI.
>   */
> -int emulate_step(struct pt_regs *regs, unsigned int instr)
> +int emulate_step(struct pt_regs *regs, struct ppc_inst instr)
>  {
>         struct instruction_op op;
>         int r, err, type;
> diff --git a/arch/powerpc/lib/test_emulate_step.c b/arch/powerpc/lib/test_emulate_step.c
> index b928b21feac1..46af80279ebc 100644
> --- a/arch/powerpc/lib/test_emulate_step.c
> +++ b/arch/powerpc/lib/test_emulate_step.c
> @@ -462,7 +462,7 @@ struct compute_test {
>         struct {
>                 char *descr;
>                 unsigned long flags;
> -               unsigned int instr;
> +               struct ppc_inst instr;
>                 struct pt_regs regs;
>         } subtests[MAX_SUBTESTS + 1];
>  };
> @@ -843,7 +843,7 @@ static struct compute_test compute_tests[] = {
>  };
>
>  static int __init emulate_compute_instr(struct pt_regs *regs,
> -                                       unsigned int instr)
> +                                       struct ppc_inst instr)
>  {
>         struct instruction_op op;
>
> @@ -861,7 +861,7 @@ static int __init emulate_compute_instr(struct pt_regs *regs,
>  }
>
>  static int __init execute_compute_instr(struct pt_regs *regs,
> -                                       unsigned int instr)
> +                                       struct ppc_inst instr)
>  {
>         extern int exec_instr(struct pt_regs *regs);
>         extern s32 patch__exec_instr;
> @@ -892,7 +892,8 @@ static void __init run_tests_compute(void)
>         unsigned long flags;
>         struct compute_test *test;
>         struct pt_regs *regs, exp, got;
> -       unsigned int i, j, k, instr;
> +       unsigned int i, j, k;
> +       struct ppc_inst instr;
>         bool ignore_gpr, ignore_xer, ignore_ccr, passed;
>
>         for (i = 0; i < ARRAY_SIZE(compute_tests); i++) {
> diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
> index 0e7e145d5cad..4a50f125ec18 100644
> --- a/arch/powerpc/mm/fault.c
> +++ b/arch/powerpc/mm/fault.c
> @@ -47,7 +47,7 @@
>   * Check whether the instruction inst is a store using
>   * an update addressing form which will update r1.
>   */
> -static bool store_updates_sp(unsigned int inst)
> +static bool store_updates_sp(struct ppc_inst inst)
>  {
>         /* check for 1 in the rA field */
>         if (((ppc_inst_val(inst) >> 16) & 0x1f) != 1)
> @@ -279,7 +279,7 @@ static bool bad_stack_expansion(struct pt_regs *regs, unsigned long address,
>
>                 if ((flags & FAULT_FLAG_WRITE) && (flags & FAULT_FLAG_USER) &&
>                     access_ok(nip, sizeof(*nip))) {
> -                       unsigned int inst;
> +                       struct ppc_inst inst;
>
>                         if (!probe_user_read(&inst, nip, sizeof(inst)))
>                                 return !store_updates_sp(inst);
> diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
> index 3dcfecf858f3..13b9dd5e4a76 100644
> --- a/arch/powerpc/perf/core-book3s.c
> +++ b/arch/powerpc/perf/core-book3s.c
> @@ -421,14 +421,14 @@ static __u64 power_pmu_bhrb_to(u64 addr)
>                 if (probe_kernel_read(&instr, (void *)addr, sizeof(instr)))
>                         return 0;
>
> -               return branch_target(&instr);
> +               return branch_target((struct ppc_inst *)&instr);
>         }
>
>         /* Userspace: need copy instruction here then translate it */
>         if (probe_user_read(&instr, (unsigned int __user *)addr, sizeof(instr)))
>                 return 0;
>
> -       target = branch_target(&instr);
> +       target = branch_target((struct ppc_inst *)&instr);
>         if ((!target) || (instr & BRANCH_ABSOLUTE))
>                 return target;
>
> diff --git a/arch/powerpc/platforms/86xx/mpc86xx_smp.c b/arch/powerpc/platforms/86xx/mpc86xx_smp.c
> index 31540ebf1e29..dba3aa73c062 100644
> --- a/arch/powerpc/platforms/86xx/mpc86xx_smp.c
> +++ b/arch/powerpc/platforms/86xx/mpc86xx_smp.c
> @@ -73,7 +73,7 @@ smp_86xx_kick_cpu(int nr)
>
>         /* Setup fake reset vector to call __secondary_start_mpc86xx. */
>         target = (unsigned long) __secondary_start_mpc86xx;
> -       patch_branch(vector, target, BRANCH_SET_LINK);
> +       patch_branch((struct ppc_inst *)vector, target, BRANCH_SET_LINK);
>
>         /* Kick that CPU */
>         smp_86xx_release_core(nr);
> @@ -83,7 +83,7 @@ smp_86xx_kick_cpu(int nr)
>                 mdelay(1);
>
>         /* Restore the exception vector */
> -       patch_instruction(vector, ppc_inst(save_vector));
> +       patch_instruction((struct ppc_inst *)vector, ppc_inst(save_vector));
>
>         local_irq_restore(flags);
>
> diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
> index 44a00990af9d..9969c07035b6 100644
> --- a/arch/powerpc/platforms/powermac/smp.c
> +++ b/arch/powerpc/platforms/powermac/smp.c
> @@ -814,7 +814,7 @@ static int smp_core99_kick_cpu(int nr)
>          *   b __secondary_start_pmac_0 + nr*8
>          */
>         target = (unsigned long) __secondary_start_pmac_0 + nr * 8;
> -       patch_branch(vector, target, BRANCH_SET_LINK);
> +       patch_branch((struct ppc_inst *)vector, target, BRANCH_SET_LINK);
>
>         /* Put some life in our friend */
>         pmac_call_feature(PMAC_FTR_RESET_CPU, NULL, nr, 0);
> @@ -827,7 +827,7 @@ static int smp_core99_kick_cpu(int nr)
>         mdelay(1);
>
>         /* Restore our exception vector */
> -       patch_instruction(vector, ppc_inst(save_vector));
> +       patch_instruction((struct ppc_inst *)vector, ppc_inst(save_vector));
>
>         local_irq_restore(flags);
>         if (ppc_md.progress) ppc_md.progress("smp_core99_kick_cpu done", 0x347);
> diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
> index 2e8ed8cdcf28..e0132d6d24d0 100644
> --- a/arch/powerpc/xmon/xmon.c
> +++ b/arch/powerpc/xmon/xmon.c
> @@ -100,7 +100,7 @@ static long *xmon_fault_jmp[NR_CPUS];
>  /* Breakpoint stuff */
>  struct bpt {
>         unsigned long   address;
> -       unsigned int    *instr;
> +       struct ppc_inst *instr;
>         atomic_t        ref_count;
>         int             enabled;
>         unsigned long   pad;
> @@ -876,8 +876,8 @@ static struct bpt *new_breakpoint(unsigned long a)
>         for (bp = bpts; bp < &bpts[NBPTS]; ++bp) {
>                 if (!bp->enabled && atomic_read(&bp->ref_count) == 0) {
>                         bp->address = a;
> -                       bp->instr = bpt_table + ((bp - bpts) * BPT_WORDS);
> -                       patch_instruction(bp->instr + 1, bpinstr);
> +                       bp->instr = (void *)(bpt_table + ((bp - bpts) * BPT_WORDS));
> +                       patch_instruction(bp->instr + 1, ppc_inst(bpinstr));
>                         return bp;
>                 }
>         }
> @@ -889,7 +889,7 @@ static struct bpt *new_breakpoint(unsigned long a)
>  static void insert_bpts(void)
>  {
>         int i;
> -       unsigned int instr;
> +       struct ppc_inst instr;
>         struct bpt *bp;
>
>         bp = bpts;
> @@ -911,8 +911,8 @@ static void insert_bpts(void)
>                 patch_instruction(bp->instr, instr);
>                 if (bp->enabled & BP_CIABR)
>                         continue;
> -               if (patch_instruction((unsigned int *)bp->address,
> -                                                       bpinstr) != 0) {
> +               if (patch_instruction((struct ppc_inst *)bp->address,
> +                                     ppc_inst(bpinstr)) != 0) {
>                         printf("Couldn't write instruction at %lx, "
>                                "disabling breakpoint there\n", bp->address);
>                         bp->enabled &= ~BP_TRAP;
> @@ -940,7 +940,7 @@ static void remove_bpts(void)
>  {
>         int i;
>         struct bpt *bp;
> -       unsigned instr;
> +       struct ppc_inst instr;
>
>         bp = bpts;
>         for (i = 0; i < NBPTS; ++i, ++bp) {
> @@ -949,7 +949,7 @@ static void remove_bpts(void)
>                 if (mread(bp->address, &instr, 4) == 4
>                     && ppc_inst_equal(instr, ppc_inst(bpinstr))
>                     && patch_instruction(
> -                       (unsigned int *)bp->address, bp->instr[0]) != 0)
> +                       (struct ppc_inst *)bp->address, bp->instr[0]) != 0)
>                         printf("Couldn't remove breakpoint at %lx\n",
>                                bp->address);
>         }
> @@ -1156,7 +1156,7 @@ static int do_step(struct pt_regs *regs)
>   */
>  static int do_step(struct pt_regs *regs)
>  {
> -       unsigned int instr;
> +       struct ppc_inst instr;
>         int stepped;
>
>         force_enable_xmon();
> @@ -1322,7 +1322,7 @@ csum(void)
>   */
>  static long check_bp_loc(unsigned long addr)
>  {
> -       unsigned int instr;
> +       struct ppc_inst instr;
>
>         addr &= ~3;
>         if (!is_kernel_addr(addr)) {
> @@ -2848,7 +2848,7 @@ generic_inst_dump(unsigned long adr, long count, int praddr,
>  {
>         int nr, dotted;
>         unsigned long first_adr;
> -       unsigned int inst, last_inst = ppc_inst(0);
> +       struct ppc_inst inst, last_inst = ppc_inst(0);
>         unsigned char val[4];
>
>         dotted = 0;
> diff --git a/arch/powerpc/xmon/xmon_bpts.h b/arch/powerpc/xmon/xmon_bpts.h
> index b7e94375db86..57e6fb03de48 100644
> --- a/arch/powerpc/xmon/xmon_bpts.h
> +++ b/arch/powerpc/xmon/xmon_bpts.h
> @@ -4,11 +4,11 @@
>
>  #define NBPTS  256
>  #ifndef __ASSEMBLY__
> -#define BPT_SIZE       (sizeof(unsigned int) * 2)
> -#define BPT_WORDS      (BPT_SIZE / sizeof(unsigned int))
> +#include <asm/inst.h>
> +#define BPT_SIZE       (sizeof(struct ppc_inst) * 2)
> +#define BPT_WORDS      (BPT_SIZE / sizeof(struct ppc_inst))
>
>  extern unsigned int bpt_table[NBPTS * BPT_WORDS];
> -
>  #endif /* __ASSEMBLY__ */
>
>  #endif /* XMON_BPTS_H */
> --
> 2.17.1
>

Hi mpe,
Could you add this fixup.
--- a/arch/powerpc/lib/feature-fixups.c
+++ b/arch/powerpc/lib/feature-fixups.c
@@ -356,7 +356,7 @@ static void patch_btb_flush_section(long *curr)
        end = (void *)curr + *(curr + 1);
        for (; start < end; start++) {
                pr_devel("patching dest %lx\n", (unsigned long)start);
-               patch_instruction(start, ppc_inst(PPC_INST_NOP));
+               patch_instruction((struct ppc_inst *)start,
ppc_inst(PPC_INST_NOP));
        }
 }

^ permalink raw reply

* [PATCH V3.1] kmap: Consolidate kmap_prot definitions
From: ira.weiny @ 2020-05-07 22:52 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton
  Cc: Peter Zijlstra, Dave Hansen, dri-devel, James E.J. Bottomley,
	Max Filippov, Paul Mackerras, H. Peter Anvin, sparclinux,
	Ira Weiny, Dan Williams, Helge Deller, x86, linux-csky,
	Christoph Hellwig, Christoph Hellwig, Ingo Molnar, linux-snps-arc,
	linux-xtensa, Borislav Petkov, Al Viro, Andy Lutomirski,
	Thomas Gleixner, linux-arm-kernel, Chris Zankel,
	Thomas Bogendoerfer, linux-parisc, linux-mips, Christian Koenig,
	linuxppc-dev, David S. Miller
In-Reply-To: <20200507150004.1423069-16-ira.weiny@intel.com>

From: Ira Weiny <ira.weiny@intel.com>

Most architectures define kmap_prot to be PAGE_KERNEL.

Let sparc and xtensa define there own and define PAGE_KERNEL as the
default if not overridden.

Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>

---
Changes from V3:
	Fix semicolon in macro

Changes from V2:
	New Patch for this series
---
 arch/arc/include/asm/highmem.h        | 3 ---
 arch/arm/include/asm/highmem.h        | 2 --
 arch/csky/include/asm/highmem.h       | 2 --
 arch/microblaze/include/asm/highmem.h | 1 -
 arch/mips/include/asm/highmem.h       | 2 --
 arch/nds32/include/asm/highmem.h      | 1 -
 arch/powerpc/include/asm/highmem.h    | 1 -
 arch/sparc/include/asm/highmem.h      | 3 ++-
 arch/sparc/mm/highmem.c               | 4 ----
 arch/x86/include/asm/fixmap.h         | 1 -
 include/linux/highmem.h               | 4 ++++
 11 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/arch/arc/include/asm/highmem.h b/arch/arc/include/asm/highmem.h
index 70900a73bfc8..6e5eafb3afdd 100644
--- a/arch/arc/include/asm/highmem.h
+++ b/arch/arc/include/asm/highmem.h
@@ -25,9 +25,6 @@
 #define PKMAP_ADDR(nr)		(PKMAP_BASE + ((nr) << PAGE_SHIFT))
 #define PKMAP_NR(virt)		(((virt) - PKMAP_BASE) >> PAGE_SHIFT)
 
-#define kmap_prot		PAGE_KERNEL
-
-
 #include <asm/cacheflush.h>
 
 extern void kmap_init(void);
diff --git a/arch/arm/include/asm/highmem.h b/arch/arm/include/asm/highmem.h
index b0d4bd8dc3c1..31811be38d78 100644
--- a/arch/arm/include/asm/highmem.h
+++ b/arch/arm/include/asm/highmem.h
@@ -10,8 +10,6 @@
 #define PKMAP_NR(virt)		(((virt) - PKMAP_BASE) >> PAGE_SHIFT)
 #define PKMAP_ADDR(nr)		(PKMAP_BASE + ((nr) << PAGE_SHIFT))
 
-#define kmap_prot		PAGE_KERNEL
-
 #define flush_cache_kmaps() \
 	do { \
 		if (cache_is_vivt()) \
diff --git a/arch/csky/include/asm/highmem.h b/arch/csky/include/asm/highmem.h
index ea2f3f39174d..14645e3d5cd5 100644
--- a/arch/csky/include/asm/highmem.h
+++ b/arch/csky/include/asm/highmem.h
@@ -38,8 +38,6 @@ extern void *kmap_atomic_pfn(unsigned long pfn);
 
 extern void kmap_init(void);
 
-#define kmap_prot PAGE_KERNEL
-
 #endif /* __KERNEL__ */
 
 #endif /* __ASM_CSKY_HIGHMEM_H */
diff --git a/arch/microblaze/include/asm/highmem.h b/arch/microblaze/include/asm/highmem.h
index d7c55cfd27bd..284ca8fb54c1 100644
--- a/arch/microblaze/include/asm/highmem.h
+++ b/arch/microblaze/include/asm/highmem.h
@@ -25,7 +25,6 @@
 #include <linux/uaccess.h>
 #include <asm/fixmap.h>
 
-#define kmap_prot		PAGE_KERNEL
 extern pte_t *kmap_pte;
 extern pte_t *pkmap_page_table;
 
diff --git a/arch/mips/include/asm/highmem.h b/arch/mips/include/asm/highmem.h
index 76dec0bd4f59..f1f788b57166 100644
--- a/arch/mips/include/asm/highmem.h
+++ b/arch/mips/include/asm/highmem.h
@@ -54,8 +54,6 @@ extern void *kmap_atomic_pfn(unsigned long pfn);
 
 extern void kmap_init(void);
 
-#define kmap_prot PAGE_KERNEL
-
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_HIGHMEM_H */
diff --git a/arch/nds32/include/asm/highmem.h b/arch/nds32/include/asm/highmem.h
index a48a6536d41a..5717647d14d1 100644
--- a/arch/nds32/include/asm/highmem.h
+++ b/arch/nds32/include/asm/highmem.h
@@ -32,7 +32,6 @@
 #define LAST_PKMAP_MASK		(LAST_PKMAP - 1)
 #define PKMAP_NR(virt)		(((virt) - (PKMAP_BASE)) >> PAGE_SHIFT)
 #define PKMAP_ADDR(nr)		(PKMAP_BASE + ((nr) << PAGE_SHIFT))
-#define kmap_prot		PAGE_KERNEL
 
 static inline void flush_cache_kmaps(void)
 {
diff --git a/arch/powerpc/include/asm/highmem.h b/arch/powerpc/include/asm/highmem.h
index 8d8ee3fcd800..104026f7d6bc 100644
--- a/arch/powerpc/include/asm/highmem.h
+++ b/arch/powerpc/include/asm/highmem.h
@@ -29,7 +29,6 @@
 #include <asm/page.h>
 #include <asm/fixmap.h>
 
-#define kmap_prot		PAGE_KERNEL
 extern pte_t *kmap_pte;
 extern pte_t *pkmap_page_table;
 
diff --git a/arch/sparc/include/asm/highmem.h b/arch/sparc/include/asm/highmem.h
index f4babe67cb5d..ddb03c04f1f3 100644
--- a/arch/sparc/include/asm/highmem.h
+++ b/arch/sparc/include/asm/highmem.h
@@ -25,11 +25,12 @@
 #include <asm/vaddrs.h>
 #include <asm/kmap_types.h>
 #include <asm/pgtable.h>
+#include <asm/pgtsrmmu.h>
 
 /* declarations for highmem.c */
 extern unsigned long highstart_pfn, highend_pfn;
 
-extern pgprot_t kmap_prot;
+#define kmap_prot __pgprot(SRMMU_ET_PTE | SRMMU_PRIV | SRMMU_CACHE)
 extern pte_t *pkmap_page_table;
 
 void kmap_init(void) __init;
diff --git a/arch/sparc/mm/highmem.c b/arch/sparc/mm/highmem.c
index 414f578d1e57..d237d902f9c3 100644
--- a/arch/sparc/mm/highmem.c
+++ b/arch/sparc/mm/highmem.c
@@ -32,9 +32,6 @@
 #include <asm/pgalloc.h>
 #include <asm/vaddrs.h>
 
-pgprot_t kmap_prot;
-EXPORT_SYMBOL(kmap_prot);
-
 static pte_t *kmap_pte;
 
 void __init kmap_init(void)
@@ -51,7 +48,6 @@ void __init kmap_init(void)
 
         /* cache the first kmap pte */
         kmap_pte = pte_offset_kernel(dir, address);
-        kmap_prot = __pgprot(SRMMU_ET_PTE | SRMMU_PRIV | SRMMU_CACHE);
 }
 
 void *kmap_atomic_high_prot(struct page *page, pgprot_t prot)
diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
index 28183ee3cc42..b9527a54db99 100644
--- a/arch/x86/include/asm/fixmap.h
+++ b/arch/x86/include/asm/fixmap.h
@@ -152,7 +152,6 @@ extern void reserve_top_address(unsigned long reserve);
 extern int fixmaps_set;
 
 extern pte_t *kmap_pte;
-#define kmap_prot PAGE_KERNEL
 extern pte_t *pkmap_page_table;
 
 void __native_set_fixmap(enum fixed_addresses idx, pte_t pte);
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index cc0c3904e501..bf470c16cecb 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -40,6 +40,10 @@ extern void kunmap_atomic_high(void *kvaddr);
 static inline void kmap_flush_tlb(unsigned long addr) { }
 #endif
 
+#ifndef kmap_prot
+#define kmap_prot PAGE_KERNEL
+#endif
+
 void *kmap_high(struct page *page);
 static inline void *kmap(struct page *page)
 {
-- 
2.25.1


^ permalink raw reply related

* Re: [PATCH V3 15/15] kmap: Consolidate kmap_prot definitions
From: Ira Weiny @ 2020-05-07 22:51 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Peter Zijlstra, Dave Hansen, dri-devel, linux-mips,
	James E.J. Bottomley, Max Filippov, Paul Mackerras,
	H. Peter Anvin, sparclinux, Dan Williams, Helge Deller, x86,
	linux-csky, Christoph Hellwig, Christoph Hellwig, Ingo Molnar,
	linux-snps-arc, linux-xtensa, Borislav Petkov, Al Viro,
	Andy Lutomirski, Thomas Gleixner, linux-arm-kernel, Chris Zankel,
	Thomas Bogendoerfer, linux-parisc, linux-kernel, Christian Koenig,
	linuxppc-dev, David S. Miller
In-Reply-To: <20200507135307.4ba10d99c611f17beab31751@linux-foundation.org>

On Thu, May 07, 2020 at 01:53:07PM -0700, Andrew Morton wrote:
> On Thu,  7 May 2020 08:00:03 -0700 ira.weiny@intel.com wrote:
> 
> > From: Ira Weiny <ira.weiny@intel.com>
> > 
> > Most architectures define kmap_prot to be PAGE_KERNEL.
> > 
> > Let sparc and xtensa define there own and define PAGE_KERNEL as the
> > default if not overridden.
> > 
> 
> checkpatch considered useful ;)

Yes sorry...  V3.1 on it's way...

Ira

> 
> 
> From: Andrew Morton <akpm@linux-foundation.org>
> Subject: kmap-consolidate-kmap_prot-definitions-checkpatch-fixes
> 
> WARNING: macros should not use a trailing semicolon
> #134: FILE: arch/sparc/include/asm/highmem.h:33:
> +#define kmap_prot __pgprot(SRMMU_ET_PTE | SRMMU_PRIV | SRMMU_CACHE);
> 
> total: 0 errors, 1 warnings, 100 lines checked
> 
> NOTE: For some of the reported defects, checkpatch may be able to
>       mechanically convert to the typical style using --fix or --fix-inplace.
> 
> ./patches/kmap-consolidate-kmap_prot-definitions.patch has style problems, please review.
> 
> NOTE: If any of the errors are false positives, please report
>       them to the maintainer, see CHECKPATCH in MAINTAINERS.
> 
> Please run checkpatch prior to sending patches
> 
> Cc: Ira Weiny <ira.weiny@intel.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  arch/sparc/include/asm/highmem.h |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- a/arch/sparc/include/asm/highmem.h~kmap-consolidate-kmap_prot-definitions-checkpatch-fixes
> +++ a/arch/sparc/include/asm/highmem.h
> @@ -30,7 +30,7 @@
>  /* declarations for highmem.c */
>  extern unsigned long highstart_pfn, highend_pfn;
>  
> -#define kmap_prot __pgprot(SRMMU_ET_PTE | SRMMU_PRIV | SRMMU_CACHE);
> +#define kmap_prot __pgprot(SRMMU_ET_PTE | SRMMU_PRIV | SRMMU_CACHE)
>  extern pte_t *pkmap_page_table;
>  
>  void kmap_init(void) __init;
> _
> 

^ permalink raw reply

* Re: [PATCH V3 13/15] parisc/kmap: Remove duplicate kmap code
From: Ira Weiny @ 2020-05-07 22:50 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Peter Zijlstra, Dave Hansen, dri-devel, linux-mips,
	James E.J. Bottomley, Max Filippov, Paul Mackerras,
	H. Peter Anvin, sparclinux, Thomas Gleixner, Helge Deller, x86,
	linux-csky, Christoph Hellwig, Ingo Molnar, linux-snps-arc,
	linux-xtensa, Borislav Petkov, Al Viro, Andy Lutomirski,
	Dan Williams, linux-arm-kernel, Chris Zankel, Thomas Bogendoerfer,
	linux-parisc, linux-kernel, Christian Koenig, linuxppc-dev,
	David S. Miller
In-Reply-To: <20200507135258.f430182578c0d63b7488916e@linux-foundation.org>

On Thu, May 07, 2020 at 01:52:58PM -0700, Andrew Morton wrote:
> On Thu,  7 May 2020 08:00:01 -0700 ira.weiny@intel.com wrote:
> 
> > parisc reimplements the kmap calls except to flush it's dcache.  This is
> > arguably an abuse of kmap but regardless it is messy and confusing.
> > 
> > Remove the duplicate code and have parisc define
> > ARCH_HAS_FLUSH_ON_KUNMAP for a kunmap_flush_on_unmap() architecture
> > specific call to flush the cache.
> 
> checkpatch says:
> 
> ERROR: #define of 'ARCH_HAS_FLUSH_ON_KUNMAP' is wrong - use Kconfig variables or standard guards instead
> #69: FILE: arch/parisc/include/asm/cacheflush.h:103:
> +#define ARCH_HAS_FLUSH_ON_KUNMAP
> 
> which is fair enough, I guess.  More conventional would be
> 
> arch/parisc/include/asm/cacheflush.h:
> 
> static inline void kunmap_flush_on_unmap(void *addr)
> {
> 	...
> }
> #define kunmap_flush_on_unmap kunmap_flush_on_unmap
> 
> 
> include/linux/highmem.h:
> 
> #ifndef kunmap_flush_on_unmap
> static inline void kunmap_flush_on_unmap(void *addr)
> {
> }
> #define kunmap_flush_on_unmap kunmap_flush_on_unmap
> #endif
> 
> 
> static inline void kunmap_atomic_high(void *addr)
> {
> 	/* Mostly nothing to do in the CONFIG_HIGHMEM=n case as kunmap_atomic()
> 	 * handles re-enabling faults + preemption */
> 	kunmap_flush_on_unmap(addr);
> }
> 
> 
> but I don't really think it's worth bothering changing it.	
> 
> (Ditto patch 3/15)

Yes I was following the pattern already there.

I'll fix up the last patch now.
Ira


^ permalink raw reply

* [PATCH] powerpc/mm: Replace zero-length array with flexible-array
From: Gustavo A. R. Silva @ 2020-05-07 18:57 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Paul Mackerras, linuxppc-dev, linux-kernel

The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

sizeof(flexible-array-member) triggers a warning because flexible array
members have incomplete type[1]. There are some instances of code in
which the sizeof operator is being incorrectly/erroneously applied to
zero-length arrays and the result is zero. Such instances may be hiding
some bugs. So, this work (flexible-array member conversions) will also
help to get completely rid of those sorts of issues.

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 arch/powerpc/mm/hugetlbpage.c                   |    2 +-
 tools/testing/selftests/powerpc/pmu/ebb/trace.h |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index 33b3461d91e8..d06efb946c7d 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -253,7 +253,7 @@ int __init alloc_bootmem_huge_page(struct hstate *h)
 struct hugepd_freelist {
 	struct rcu_head	rcu;
 	unsigned int index;
-	void *ptes[0];
+	void *ptes[];
 };
 
 static DEFINE_PER_CPU(struct hugepd_freelist *, hugepd_freelist_cur);
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/trace.h b/tools/testing/selftests/powerpc/pmu/ebb/trace.h
index 7c0fb5d2bdb1..da2a3be5441f 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/trace.h
+++ b/tools/testing/selftests/powerpc/pmu/ebb/trace.h
@@ -18,7 +18,7 @@ struct trace_entry
 {
 	u8 type;
 	u8 length;
-	u8 data[0];
+	u8 data[];
 };
 
 struct trace_buffer
@@ -26,7 +26,7 @@ struct trace_buffer
 	u64  size;
 	bool overflow;
 	void *tail;
-	u8   data[0];
+	u8   data[];
 };
 
 struct trace_buffer *trace_buffer_allocate(u64 size);
-- 
2.26.2



^ permalink raw reply related

* [PATCH] powerpc: Replace zero-length array with flexible-array
From: Gustavo A. R. Silva @ 2020-05-07 18:57 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, linux-kernel

The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

sizeof(flexible-array-member) triggers a warning because flexible array
members have incomplete type[1]. There are some instances of code in
which the sizeof operator is being incorrectly/erroneously applied to
zero-length arrays and the result is zero. Such instances may be hiding
some bugs. So, this work (flexible-array member conversions) will also
help to get completely rid of those sorts of issues.

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 arch/powerpc/platforms/powermac/nvram.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powermac/nvram.c b/arch/powerpc/platforms/powermac/nvram.c
index dc7a5bae8f1c..853ccc4480e2 100644
--- a/arch/powerpc/platforms/powermac/nvram.c
+++ b/arch/powerpc/platforms/powermac/nvram.c
@@ -55,7 +55,7 @@ struct chrp_header {
   u8		cksum;
   u16		len;
   char          name[12];
-  u8		data[0];
+  u8		data[];
 };
 
 struct core99_header {


^ permalink raw reply related

* [PATCH] treewide: Replace zero-length array with flexible-array
From: Gustavo A. R. Silva @ 2020-05-07 18:53 UTC (permalink / raw)
  To: Li Yang; +Cc: linuxppc-dev, linux-kernel, linux-arm-kernel

The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

sizeof(flexible-array-member) triggers a warning because flexible array
members have incomplete type[1]. There are some instances of code in
which the sizeof operator is being incorrectly/erroneously applied to
zero-length arrays and the result is zero. Such instances may be hiding
some bugs. So, this work (flexible-array member conversions) will also
help to get completely rid of those sorts of issues.

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 include/linux/fsl/bestcomm/bestcomm.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/fsl/bestcomm/bestcomm.h b/include/linux/fsl/bestcomm/bestcomm.h
index a0e2e6b19b57..154e541ce57e 100644
--- a/include/linux/fsl/bestcomm/bestcomm.h
+++ b/include/linux/fsl/bestcomm/bestcomm.h
@@ -27,7 +27,7 @@
  */
 struct bcom_bd {
 	u32	status;
-	u32	data[0];	/* variable payload size */
+	u32	data[];	/* variable payload size */
 };
 
 /* ======================================================================== */


^ permalink raw reply related

* Fwd: [CRON] Broken: ClangBuiltLinux/continuous-integration#1432 (master - 0aceafc)
From: Nick Desaulniers @ 2020-05-07 17:18 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev
In-Reply-To: <5eb43a0c8d43d_13fb5db924ca0104770@travis-pro-tasks-6cc9887df6-4zmjd.mail>

[-- Attachment #1: Type: text/plain, Size: 2486 bytes --]

Looks like ppc64le powernv_defconfig is suddenly failing the locking
torture tests, then locks up?
https://travis-ci.com/github/ClangBuiltLinux/continuous-integration/jobs/329211572#L3111-L3167
Any recent changes related here in -next?  I believe this is the first
failure, so I'll report back if we see this again.

---------- Forwarded message ---------
From: Travis CI <builds@travis-ci.com>
Date: Thu, May 7, 2020 at 9:40 AM
Subject: [CRON] Broken: ClangBuiltLinux/continuous-integration#1432 (master
- 0aceafc)
To: <ndesaulniers@google.com>, <natechancellor@gmail.com>


ClangBuiltLinux

/

continuous-integration
<https://travis-ci.com/github/ClangBuiltLinux/continuous-integration?utm_medium=notification&utm_source=email>

[image: branch icon]master
<https://github.com/ClangBuiltLinux/continuous-integration/tree/master>
[image: build has failed]
Build #1432 was broken
<https://travis-ci.com/github/ClangBuiltLinux/continuous-integration/builds/164415390?utm_medium=notification&utm_source=email>
[image: arrow to build time]
[image: clock icon]7 hrs, 0 mins, and 54 secs

[image: Nick Desaulniers avatar]Nick Desaulniers
0aceafc CHANGESET →
<https://github.com/ClangBuiltLinux/continuous-integration/compare/877d002bdcfe6bc5cb0255c3c39192e8175e2c19...0aceafcfcca7c4a095957efae0939a612d755077>

Merge pull request #182 from ClangBuiltLinux/i386

i386

Want to know about upcoming build environment updates?

Would you like to stay up-to-date with the upcoming Travis CI build
environment updates? We set up a mailing list for you!
SIGN UP HERE <http://eepurl.com/9OCsP>

[image: book icon]

Documentation <https://docs.travis-ci.com/> about Travis CI
Have any questions? We're here to help. <support@travis-ci.com>
Unsubscribe
<https://travis-ci.com/account/preferences/unsubscribe?repository=6718752&utm_medium=notification&utm_source=email>
from build emails from the ClangBuiltLinux/continuous-integration
repository.
To unsubscribe from *all* build emails, please update your settings
<https://travis-ci.com/account/preferences/unsubscribe?utm_medium=notification&utm_source=email>.

[image: black and white travis ci logo] <https://travis-ci.com>

Travis CI GmbH, Rigaer Str. 8, 10427 Berlin, Germany | GF/CEO: Randy Jacops
| Contact: contact@travis-ci.com | Amtsgericht Charlottenburg, Berlin, HRB
140133 B | Umsatzsteuer-ID gemäß §27 a Umsatzsteuergesetz: DE282002648


-- 
Thanks,
~Nick Desaulniers

[-- Attachment #2: Type: text/html, Size: 14499 bytes --]

^ permalink raw reply

* Re: [PATCH net 11/16] net: ethernet: marvell: mvneta: fix fixed-link phydev leaks
From: Naresh Kamboju @ 2020-05-07 22:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Johan Hovold
  Cc: Andrew Lunn, lkft-triage, Frank Rowand, Sasha Levin,
	Florian Fainelli,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Grygorii Strashko, Rob Herring, linux-mediatek, Lars Persson,
	Matthias Brugger, linux-omap, Thomas Petazzoni, Fugang Duan,
	Sergei Shtylyov, Netdev, open list, linux- stable,
	linux-renesas-soc, nios2-dev, linuxppc-dev, David S. Miller
In-Reply-To: <20200507111312.GA1497799@kroah.com>

On Thu, 7 May 2020 at 16:43, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
<trim>
> > >
> > > Greg, 3f65047c853a ("of_mdio: add helper to deregister fixed-link
> > > PHYs") needs to be backported as well for these.
> > >
> > > Original series can be found here:
> > >
> > >     https://lkml.kernel.org/r/1480357509-28074-1-git-send-email-johan@kernel.org
> >
> > Ah, thanks for that, I thought I dropped all of the ones that caused
> > build errors, but missed the above one.  I'll go take the whole series
> > instead.
>
> This should now all be fixed up, thanks.

While building kernel Image for arm architecture on stable-rc 4.4 branch
the following build error found.

of_mdio: add helper to deregister fixed-link PHYs
commit 3f65047c853a2a5abcd8ac1984af3452b5df4ada upstream.

Add helper to deregister fixed-link PHYs registered using
of_phy_register_fixed_link().

Convert the two drivers that care to deregister their fixed-link PHYs to
use the new helper, but note that most drivers currently fail to do so.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
[only take helper function for 4.4.y - gregkh]

 # make -sk KBUILD_BUILD_USER=TuxBuild -C/linux -j16 ARCH=arm
CROSS_COMPILE=arm-linux-gnueabihf- HOSTCC=gcc CC="sccache
arm-linux-gnueabihf-gcc" O=build zImage
70 #
71 ../drivers/of/of_mdio.c: In function ‘of_phy_deregister_fixed_link’:
72 ../drivers/of/of_mdio.c:379:2: error: implicit declaration of
function ‘fixed_phy_unregister’; did you mean ‘fixed_phy_register’?
[-Werror=implicit-function-declaration]
73  379 | fixed_phy_unregister(phydev);
74  | ^~~~~~~~~~~~~~~~~~~~
75  | fixed_phy_register
76 ../drivers/of/of_mdio.c:381:22: error: ‘struct phy_device’ has no
member named ‘mdio’; did you mean ‘mdix’?
77  381 | put_device(&phydev->mdio.dev); /* of_phy_find_device() */
78  | ^~~~
79  | mdix

>
> greg k-h

^ permalink raw reply

* [PATCH 3/5] powerpc/mpc85xx: Add Cyrus Power-off and reset
From: Darren Stevens @ 2020-05-07 21:13 UTC (permalink / raw)
  To: linuxppc-dev, oss; +Cc: chzigotzky

The Cyrus board has GPIO connected power-off and reset, add device tree
nodes describing them.

Signed-off-by: Darren Stevens <darren@stevens-zone.net>

---

 arch/powerpc/boot/dts/fsl/cyrus_p5020.dts | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/powerpc/boot/dts/fsl/cyrus_p5020.dts
b/arch/powerpc/boot/dts/fsl/cyrus_p5020.dts index bdf0405..f0548fe
100644 --- a/arch/powerpc/boot/dts/fsl/cyrus_p5020.dts
+++ b/arch/powerpc/boot/dts/fsl/cyrus_p5020.dts
@@ -73,6 +73,16 @@
 			};
 		};
 
+		gpio-poweroff {
+			compatible = "gpio-poweroff";
+			gpios = <&gpio0 3 1>;
+		};
+
+		gpio-restart {
+			compatible = "gpio-restart";
+			gpios = <&gpio0 2 1>;
+		};
+
 		fman@400000 {
 			mdio@e1120 {
 				phy3: ethernet-phy@3 {

^ permalink raw reply

* [PATCH 5/5] powerpc/mpc85xx: Add Cyrus P5040 device tree source
From: Darren Stevens @ 2020-05-07 21:30 UTC (permalink / raw)
  To: linuxppc-dev, oss; +Cc: chzigotzky

The Cyrus P5040 does not currently have a dts file in Linux, Add one.

Signed-off-by: Darren Stevens <darren@stevens-zone.net>
Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>

---
 arch/powerpc/boot/dts/fsl/cyrus_p5040.dts | 235 ++++++++++++++++++++++++++++++
 1 file changed, 235 insertions(+)

diff --git a/arch/powerpc/boot/dts/fsl/cyrus_p5040.dts b/arch/powerpc/boot/dts/fsl/cyrus_p5040.dts
new file mode 100644
index 0000000..596ee19
--- /dev/null
+++ b/arch/powerpc/boot/dts/fsl/cyrus_p5040.dts
@@ -0,0 +1,235 @@
+/*
+ * Cyrus 5040 Device Tree Source, based on p5040ds.dts
+ *
+ * Copyright 2020 Darren Stevens
+ *
+ * p5040ds.dts Copyright 2012 - 2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Freescale Semiconductor nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * This software is provided by Freescale Semiconductor "as is" and any
+ * express or implied warranties, including, but not limited to, the implied
+ * warranties of merchantability and fitness for a particular purpose are
+ * disclaimed. In no event shall Freescale Semiconductor be liable for any
+ * direct, indirect, incidental, special, exemplary, or consequential damages
+ * (including, but not limited to, procurement of substitute goods or services;
+ * loss of use, data, or profits; or business interruption) however caused and
+ * on any theory of liability, whether in contract, strict liability, or tort
+ * (including negligence or otherwise) arising in any way out of the use of this
+ * software, even if advised of the possibility of such damage.
+ */
+
+/include/ "p5040si-pre.dtsi"
+
+/ {
+	model = "varisys,CYRUS5040";
+	compatible = "varisys,CYRUS";
+	#address-cells = <2>;
+	#size-cells = <2>;
+	interrupt-parent = <&mpic>;
+
+	aliases{
+		ethernet0 = &enet4;
+		ethernet1 = &enet10;
+	};
+
+	memory {
+		device_type = "memory";
+	};
+
+	reserved-memory {
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;
+
+		bman_fbpr: bman-fbpr {
+			size = <0 0x1000000>;
+			alignment = <0 0x1000000>;
+		};
+		qman_fqd: qman-fqd {
+			size = <0 0x400000>;
+			alignment = <0 0x400000>;
+		};
+		qman_pfdr: qman-pfdr {
+			size = <0 0x2000000>;
+			alignment = <0 0x2000000>;
+		};
+	};
+
+	dcsr: dcsr@f00000000 {
+		ranges = <0x00000000 0xf 0x00000000 0x01008000>;
+	};
+
+	bportals: bman-portals@ff4000000 {
+		ranges = <0x0 0xf 0xf4000000 0x200000>;
+	};
+
+	qportals: qman-portals@ff4200000 {
+		ranges = <0x0 0xf 0xf4200000 0x200000>;
+	};
+
+	soc: soc@ffe000000 {
+		ranges = <0x00000000 0xf 0xfe000000 0x1000000>;
+		reg = <0xf 0xfe000000 0 0x00001000>;
+		spi@110000 {
+		};
+
+		i2c@118100 {
+		};
+
+		i2c@119100 {
+			rtc@6f {
+				compatible = "microchip,mcp7941x";
+				reg = <0x6f>;
+			};
+		};
+
+		gpio-poweroff {
+			compatible = "gpio-poweroff";
+			gpios = <&gpio0 3 1>;
+		};
+
+		gpio-restart {
+			compatible = "gpio-restart";
+			gpios = <&gpio0 2 1>;
+		};
+
+		leds {
+			compatible = "gpio-leds";
+			hdd {
+				label = "Disk activity";
+				gpios = <&gpio0 5 0>;
+				linux,default-trigger = "disk-activity";
+			};
+		};
+
+		fman@400000 {
+			mdio@e1120 {
+				phy3: ethernet-phy@3 {
+					reg = <0x3>;
+				};
+
+				phy7: ethernet-phy@7 {
+					reg = <0x7>;
+				};
+			};
+
+			ethernet@e0000 {
+				status = "disabled";
+			};
+
+			ethernet@e2000 {
+				status = "disabled";
+			};
+
+			ethernet@e4000 {
+				status = "disabled";
+			};
+
+			ethernet@e6000 {
+				status = "disabled";
+			};
+
+			ethernet@e8000 {
+				phy-handle = <&phy3>;
+				phy-connection-type = "rgmii";
+			};
+
+		};
+
+		fman@500000 {
+			ethernet@e0000 {
+				status = "disabled";
+			};
+
+			ethernet@e2000 {
+				status = "disabled";
+			};
+
+			ethernet@e4000 {
+				status = "disabled";
+			};
+
+			ethernet@e6000 {
+				status = "disabled";
+			};
+
+			ethernet@e8000 {
+				phy-handle = <&phy7>;
+				phy-connection-type = "rgmii";
+			};
+
+		};
+
+	};
+
+	lbc: localbus@ffe124000 {
+		reg = <0xf 0xfe124000 0 0x1000>;
+		ranges = <0 0 0xf 0xe8000000 0x08000000
+			  2 0 0xf 0xffa00000 0x00040000
+			  3 0 0xf 0xffdf0000 0x00008000>;
+
+	};
+
+	pci0: pcie@ffe200000 {
+		reg = <0xf 0xfe200000 0 0x1000>;
+		ranges = <0x02000000 0 0xe0000000 0xc 0x00000000 0x0 0x20000000
+			  0x01000000 0 0x00000000 0xf 0xf8000000 0x0 0x00010000>;
+		pcie@0 {
+			ranges = <0x02000000 0 0xe0000000
+				  0x02000000 0 0xe0000000
+				  0 0x20000000
+
+				  0x01000000 0 0x00000000
+				  0x01000000 0 0x00000000
+				  0 0x00010000>;
+		};
+	};
+
+	pci1: pcie@ffe201000 {
+		reg = <0xf 0xfe201000 0 0x1000>;
+		ranges = <0x02000000 0x0 0xe0000000 0xc 0x20000000 0x0 0x20000000
+			  0x01000000 0x0 0x00000000 0xf 0xf8010000 0x0 0x00010000>;
+		pcie@0 {
+			ranges = <0x02000000 0 0xe0000000
+				  0x02000000 0 0xe0000000
+				  0 0x20000000
+
+				  0x01000000 0 0x00000000
+				  0x01000000 0 0x00000000
+				  0 0x00010000>;
+		};
+	};
+
+	pci2: pcie@ffe202000 {
+		reg = <0xf 0xfe202000 0 0x1000>;
+		ranges = <0x02000000 0 0xe0000000 0xc 0x40000000 0 0x20000000
+			  0x01000000 0 0x00000000 0xf 0xf8020000 0 0x00010000>;
+		pcie@0 {
+			ranges = <0x02000000 0 0xe0000000
+				  0x02000000 0 0xe0000000
+				  0 0x20000000
+
+				  0x01000000 0 0x00000000
+				  0x01000000 0 0x00000000
+				  0 0x00010000>;
+		};
+	};
+};
+
+/include/ "p5040si-post.dtsi"

^ permalink raw reply related

* [PATCH 1/5] powerpc/mpc85xx: Define ethernet port aliases in board dts file
From: Darren Stevens @ 2020-05-07 21:12 UTC (permalink / raw)
  To: linuxppc-dev, oss; +Cc: chzigotzky

in patch da414bb923d9 (Add FSL Qoriq DPAA FMan support to the SoC
device tree(s)) we added aliases for all ethernet ports, and linked
them to specific hardware devices, but we put them in the pre.dtsi
include file meaning any board wishing to use this file is stuck with
this port layout, even if it don't match the boards hardware. The Cyrus
5020 and 5040 boards are examples, they are based on the p5020 ref
design, but only have 2 ethernet ports.
Fix the problem by moving the ethernet aliases to the boards dts file
where we define the phy aliases.

Signed-off-by: Darren Stevens <darren@stevens-zone.net>

---

Only patched the p5020ds and p5040ds as they are the boards I work
with. Others may need looking at.

 arch/powerpc/boot/dts/fsl/p5020ds.dts      |  7 +++++++
 arch/powerpc/boot/dts/fsl/p5020si-pre.dtsi |  6 ------
 arch/powerpc/boot/dts/fsl/p5040ds.dts      | 13 +++++++++++++
 arch/powerpc/boot/dts/fsl/p5040si-pre.dtsi | 12 ------------
 4 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/arch/powerpc/boot/dts/fsl/p5020ds.dts
b/arch/powerpc/boot/dts/fsl/p5020ds.dts index b24adf9..cdf0559 100644
--- a/arch/powerpc/boot/dts/fsl/p5020ds.dts
+++ b/arch/powerpc/boot/dts/fsl/p5020ds.dts
@@ -53,6 +53,13 @@
 		emi1_rgmii = &hydra_mdio_rgmii;
 		emi1_sgmii = &hydra_mdio_sgmii;
 		emi2_xgmii = &hydra_mdio_xgmii;
+
+		ethernet0 = &enet0;
+		ethernet1 = &enet1;
+		ethernet2 = &enet2;
+		ethernet3 = &enet3;
+		ethernet4 = &enet4;
+		ethernet5 = &enet5;
 	};
 
 	memory {
diff --git a/arch/powerpc/boot/dts/fsl/p5020si-pre.dtsi
b/arch/powerpc/boot/dts/fsl/p5020si-pre.dtsi index 2d74ea8..8bc7a75
100644 --- a/arch/powerpc/boot/dts/fsl/p5020si-pre.dtsi
+++ b/arch/powerpc/boot/dts/fsl/p5020si-pre.dtsi
@@ -81,12 +81,6 @@
 		raideng_jr3 = &raideng_jr3;
 
 		fman0 = &fman0;
-		ethernet0 = &enet0;
-		ethernet1 = &enet1;
-		ethernet2 = &enet2;
-		ethernet3 = &enet3;
-		ethernet4 = &enet4;
-		ethernet5 = &enet5;
 	};
 
 	cpus {
diff --git a/arch/powerpc/boot/dts/fsl/p5040ds.dts
b/arch/powerpc/boot/dts/fsl/p5040ds.dts index 30850b3..bffbba5 100644
--- a/arch/powerpc/boot/dts/fsl/p5040ds.dts
+++ b/arch/powerpc/boot/dts/fsl/p5040ds.dts
@@ -65,6 +65,19 @@
 		hydra_sg_slot6 = &hydra_sg_slot6;
 		hydra_xg_slot1 = &hydra_xg_slot1;
 		hydra_xg_slot2 = &hydra_xg_slot2;
+
+		ethernet0 = &enet0;
+		ethernet1 = &enet1;
+		ethernet2 = &enet2;
+		ethernet3 = &enet3;
+		ethernet4 = &enet4;
+		ethernet5 = &enet5;
+		ethernet6 = &enet6;
+		ethernet7 = &enet7;
+		ethernet8 = &enet8;
+		ethernet9 = &enet9;
+		ethernet10 = &enet10;
+		ethernet11 = &enet11;
 	};
 
 	memory {
diff --git a/arch/powerpc/boot/dts/fsl/p5040si-pre.dtsi
b/arch/powerpc/boot/dts/fsl/p5040si-pre.dtsi index ed89dbb..bc4e0bc
100644 --- a/arch/powerpc/boot/dts/fsl/p5040si-pre.dtsi
+++ b/arch/powerpc/boot/dts/fsl/p5040si-pre.dtsi
@@ -81,18 +81,6 @@
 
 		fman0 = &fman0;
 		fman1 = &fman1;
-		ethernet0 = &enet0;
-		ethernet1 = &enet1;
-		ethernet2 = &enet2;
-		ethernet3 = &enet3;
-		ethernet4 = &enet4;
-		ethernet5 = &enet5;
-		ethernet6 = &enet6;
-		ethernet7 = &enet7;
-		ethernet8 = &enet8;
-		ethernet9 = &enet9;
-		ethernet10 = &enet10;
-		ethernet11 = &enet11;
 	};
 
 	cpus {

^ permalink raw reply

* [PATCH 4/5] powerpc/mpc85xx: Add Cyrus HDD LED
From: Darren Stevens @ 2020-05-07 21:15 UTC (permalink / raw)
  To: linuxppc-dev, oss; +Cc: chzigotzky

The Cyrus board has its HDD LED connected to a GPIO pin. Add a device
tree entry for this.

Signed-off-By: Darren Stevens <darren@stevens-zone.net>

---
 arch/powerpc/boot/dts/fsl/cyrus_p5020.dts | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/powerpc/boot/dts/fsl/cyrus_p5020.dts
b/arch/powerpc/boot/dts/fsl/cyrus_p5020.dts index f0548fe..74c100f
100644 --- a/arch/powerpc/boot/dts/fsl/cyrus_p5020.dts
+++ b/arch/powerpc/boot/dts/fsl/cyrus_p5020.dts
@@ -83,6 +83,16 @@
 			gpios = <&gpio0 2 1>;
 		};
 
+		leds {
+			compatible = "gpio-leds";
+
+			hdd {
+				label = "Disk Activity";
+				gpios = <&gpio0 5 0>;
+				linux,default-trigger =
"disk-activity";
+			};
+		};
+
 		fman@400000 {
 			mdio@e1120 {
 				phy3: ethernet-phy@3 {

^ permalink raw reply

* [PATCH 2/5] powerpc/mpc85xx: Activate Cyrus P5020 ethernet
From: Darren Stevens @ 2020-05-07 21:13 UTC (permalink / raw)
  To: linuxppc-dev, oss; +Cc: chzigotzky

The Cyrus P5020 board has 2 ethernet ports, add the required device tree
entries.

Signed-off-by: Darren Stevens <darren@stevens-zone.net>

---

 arch/powerpc/boot/dts/fsl/cyrus_p5020.dts | 39
 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)

diff --git a/arch/powerpc/boot/dts/fsl/cyrus_p5020.dts
b/arch/powerpc/boot/dts/fsl/cyrus_p5020.dts index 40ba060..bdf0405
100644 --- a/arch/powerpc/boot/dts/fsl/cyrus_p5020.dts
+++ b/arch/powerpc/boot/dts/fsl/cyrus_p5020.dts
@@ -17,6 +17,11 @@
 	#size-cells = <2>;
 	interrupt-parent = <&mpic>;
 
+	aliases {
+		ethernet0 = &enet3;
+		ethernet1 = &enet4;
+	};
+
 	memory {
 		device_type = "memory";
 	};
@@ -67,6 +72,40 @@
 				reg = <0x6f>;
 			};
 		};
+
+		fman@400000 {
+			mdio@e1120 {
+				phy3: ethernet-phy@3 {
+					reg = <0x3>;
+				};
+
+				phy7: ethernet-phy@7 {
+					reg = <0x7>;
+				};
+			};
+
+			ethernet@e0000 {
+				status = "disabled";
+			};
+
+			ethernet@e2000 {
+				status = "disabled";
+			};
+
+			ethernet@e4000 {
+				status = "disabled";
+			};
+
+			ethernet@e6000 {
+				phy-handle = <&phy3>;
+				phy-connection-type = "rgmii";
+			};
+
+			ethernet@e8000 {
+				phy-handle = <&phy7>;
+				phy-connection-type = "rgmii";
+			};
+		};
 	};
 
 	rio: rapidio@ffe0c0000 {

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox