* [PATCH v4 12/16] powerpc: implement ftrace_enabled helper
From: Nicholas Piggin @ 2020-05-08 4:34 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Nicholas Piggin
In-Reply-To: <20200508043408.886394-1-npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/ftrace.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
index f54a08a2cd70..bc76970b6ee5 100644
--- a/arch/powerpc/include/asm/ftrace.h
+++ b/arch/powerpc/include/asm/ftrace.h
@@ -108,9 +108,23 @@ static inline void this_cpu_enable_ftrace(void)
{
get_paca()->ftrace_enabled = 1;
}
+
+/* Disable ftrace on this CPU if possible (may not be implemented) */
+static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled)
+{
+ get_paca()->ftrace_enabled = ftrace_enabled;
+}
+
+static inline u8 this_cpu_get_ftrace_enabled(void)
+{
+ return get_paca()->ftrace_enabled;
+}
+
#else /* CONFIG_PPC64 */
static inline void this_cpu_disable_ftrace(void) { }
static inline void this_cpu_enable_ftrace(void) { }
+static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { }
+static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; }
#endif /* CONFIG_PPC64 */
#endif /* !__ASSEMBLY__ */
--
2.23.0
^ permalink raw reply related
* [PATCH v4 11/16] powerpc/64s: machine check interrupt update NMI accounting
From: Nicholas Piggin @ 2020-05-08 4:34 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Nicholas Piggin
In-Reply-To: <20200508043408.886394-1-npiggin@gmail.com>
machine_check_early is taken as an NMI, so nmi_enter is used there.
machine_check_exception is no longer taken as an NMI (it's invoked
via irq_work in the case a machine check hits in kernel mode), so
remove the nmi_enter from that case.
In NMI context, hash faults don't try to refill the hash table, which
can lead to crashes accessing non-pinned kernel pages. System reset
still has this potential problem.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/kernel/mce.c | 7 +++++++
arch/powerpc/kernel/process.c | 2 +-
arch/powerpc/kernel/traps.c | 14 +++++++++++++-
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c
index 8077b5fb18a7..be7e3f92a7b5 100644
--- a/arch/powerpc/kernel/mce.c
+++ b/arch/powerpc/kernel/mce.c
@@ -574,6 +574,9 @@ EXPORT_SYMBOL_GPL(machine_check_print_event_info);
long machine_check_early(struct pt_regs *regs)
{
long handled = 0;
+ bool nested = in_nmi();
+ if (!nested)
+ nmi_enter();
hv_nmi_check_nonrecoverable(regs);
@@ -582,6 +585,10 @@ long machine_check_early(struct pt_regs *regs)
*/
if (ppc_md.machine_check_early)
handled = ppc_md.machine_check_early(regs);
+
+ if (!nested)
+ nmi_exit();
+
return handled;
}
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 9c21288f8645..44410dd3029f 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1421,7 +1421,7 @@ void show_regs(struct pt_regs * regs)
pr_cont("DAR: "REG" DSISR: %08lx ", regs->dar, regs->dsisr);
#endif
#ifdef CONFIG_PPC64
- pr_cont("IRQMASK: %lx ", regs->softe);
+ pr_cont("IRQMASK: %lx IN_NMI:%d IN_MCE:%d", regs->softe, (int)get_paca()->in_nmi, (int)get_paca()->in_mce);
#endif
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
if (MSR_TM_ACTIVE(regs->msr))
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 3fca22276bb1..9f6852322e59 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -823,7 +823,19 @@ int machine_check_generic(struct pt_regs *regs)
void machine_check_exception(struct pt_regs *regs)
{
int recover = 0;
- bool nested = in_nmi();
+ bool nested;
+
+ /*
+ * BOOK3S_64 does not call this handler as a non-maskable interrupt
+ * (it uses its own early real-mode handler to handle the MCE proper
+ * and then raises irq_work to call this handler when interrupts are
+ * enabled). Set nested = true for this case, which just makes it avoid
+ * the nmi_enter/exit.
+ */
+ if (IS_ENABLED(CONFIG_PPC_BOOK3S_64) || in_nmi())
+ nested = true;
+ else
+ nested = false;
if (!nested)
nmi_enter();
--
2.23.0
^ permalink raw reply related
* [PATCH v4 10/16] powerpc/pseries: machine check use rtas_call_unlocked with args on stack
From: Nicholas Piggin @ 2020-05-08 4:34 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Nicholas Piggin
In-Reply-To: <20200508043408.886394-1-npiggin@gmail.com>
With the previous patch, machine checks can use rtas_call_unlocked
which avoids the rtas spinlock which would deadlock if a machine
check hits while making an rtas call.
This also avoids the complex rtas error logging which has more rtas calls
and includes kmalloc (which can return memory beyond RMA, which would
also crash).
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/platforms/pseries/ras.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index b2adba59f0ff..ce1665e58d9b 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -468,7 +468,15 @@ static struct rtas_error_log *fwnmi_get_errinfo(struct pt_regs *regs)
*/
static void fwnmi_release_errinfo(void)
{
- int ret = rtas_call(ibm_nmi_interlock_token, 0, 1, NULL);
+ struct rtas_args rtas_args;
+ int ret;
+
+ /*
+ * On pseries, the machine check stack is limited to under 4GB, so
+ * args can be on-stack.
+ */
+ rtas_call_unlocked(&rtas_args, ibm_nmi_interlock_token, 0, 1, NULL);
+ ret = be32_to_cpu(rtas_args.rets[0]);
if (ret != 0)
printk(KERN_ERR "FWNMI: nmi-interlock failed: %d\n", ret);
}
--
2.23.0
^ permalink raw reply related
* [PATCH v4 09/16] powerpc/pseries: limit machine check stack to 4GB
From: Nicholas Piggin @ 2020-05-08 4:34 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Mahesh Salgaonkar, Nicholas Piggin
In-Reply-To: <20200508043408.886394-1-npiggin@gmail.com>
This allows rtas_args to be put on the machine check stack, which
avoids a lot of complications with re-entrancy deadlocks.
Reviewed-by: Christophe Leroy <christophe.leroy@c-s.fr>
Reviewed-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/kernel/setup_64.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 8105010b0e76..bb47555d48a2 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -711,7 +711,7 @@ void __init exc_lvl_early_init(void)
*/
void __init emergency_stack_init(void)
{
- u64 limit;
+ u64 limit, mce_limit;
unsigned int i;
/*
@@ -728,7 +728,16 @@ void __init emergency_stack_init(void)
* initialized in kernel/irq.c. These are initialized here in order
* to have emergency stacks available as early as possible.
*/
- limit = min(ppc64_bolted_size(), ppc64_rma_size);
+ limit = mce_limit = min(ppc64_bolted_size(), ppc64_rma_size);
+
+ /*
+ * Machine check on pseries calls rtas, but can't use the static
+ * rtas_args due to a machine check hitting while the lock is held.
+ * rtas args have to be under 4GB, so the machine check stack is
+ * limited to 4GB so args can be put on stack.
+ */
+ if (firmware_has_feature(FW_FEATURE_LPAR) && mce_limit > SZ_4G)
+ mce_limit = SZ_4G;
for_each_possible_cpu(i) {
paca_ptrs[i]->emergency_sp = alloc_stack(limit, i) + THREAD_SIZE;
@@ -738,7 +747,7 @@ void __init emergency_stack_init(void)
paca_ptrs[i]->nmi_emergency_sp = alloc_stack(limit, i) + THREAD_SIZE;
/* emergency stack for machine check exception handling. */
- paca_ptrs[i]->mc_emergency_sp = alloc_stack(limit, i) + THREAD_SIZE;
+ paca_ptrs[i]->mc_emergency_sp = alloc_stack(mce_limit, i) + THREAD_SIZE;
#endif
}
}
--
2.23.0
^ permalink raw reply related
* [PATCH v4 08/16] powerpc/pseries/ras: fwnmi sreset should not interlock
From: Nicholas Piggin @ 2020-05-08 4:34 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Nicholas Piggin
In-Reply-To: <20200508043408.886394-1-npiggin@gmail.com>
PAPR does not specify that fwnmi sreset should be interlocked, and
PowerVM (and therefore now QEMU) do not require it.
These "ibm,nmi-interlock" calls are ignored by firmware, but there
is a possibility that the sreset could have interrupted a machine
check and release the machine check's interlock too early, corrupting
it if another machine check came in.
This is an extremely rare case, but it should be fixed for clarity
and reducing the code executed in the sreset path. Firmware also
does not provide error information for the sreset case to look at, so
remove that comment.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/platforms/pseries/ras.c | 46 +++++++++++++++++++---------
1 file changed, 32 insertions(+), 14 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index fe14186a8cef..b2adba59f0ff 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -406,6 +406,20 @@ static inline struct rtas_error_log *fwnmi_get_errlog(void)
return (struct rtas_error_log *)local_paca->mce_data_buf;
}
+static unsigned long *fwnmi_get_savep(struct pt_regs *regs)
+{
+ unsigned long savep_ra;
+
+ /* Mask top two bits */
+ savep_ra = regs->gpr[3] & ~(0x3UL << 62);
+ if (!VALID_FWNMI_BUFFER(savep_ra)) {
+ printk(KERN_ERR "FWNMI: corrupt r3 0x%016lx\n", regs->gpr[3]);
+ return NULL;
+ }
+
+ return __va(savep_ra);
+}
+
/*
* Get the error information for errors coming through the
* FWNMI vectors. The pt_regs' r3 will be updated to reflect
@@ -423,20 +437,14 @@ static inline struct rtas_error_log *fwnmi_get_errlog(void)
*/
static struct rtas_error_log *fwnmi_get_errinfo(struct pt_regs *regs)
{
- unsigned long savep_ra;
unsigned long *savep;
struct rtas_error_log *h;
- /* Mask top two bits */
- savep_ra = regs->gpr[3] & ~(0x3UL << 62);
-
- if (!VALID_FWNMI_BUFFER(savep_ra)) {
- printk(KERN_ERR "FWNMI: corrupt r3 0x%016lx\n", regs->gpr[3]);
+ savep = fwnmi_get_savep(regs);
+ if (!savep)
return NULL;
- }
- savep = __va(savep_ra);
- regs->gpr[3] = be64_to_cpu(savep[0]); /* restore original r3 */
+ regs->gpr[3] = be64_to_cpu(savep[0]); /* restore original r3 */
h = (struct rtas_error_log *)&savep[1];
/* Use the per cpu buffer from paca to store rtas error log */
@@ -483,11 +491,21 @@ int pSeries_system_reset_exception(struct pt_regs *regs)
#endif
if (fwnmi_active) {
- struct rtas_error_log *errhdr = fwnmi_get_errinfo(regs);
- if (errhdr) {
- /* XXX Should look at FWNMI information */
- }
- fwnmi_release_errinfo();
+ unsigned long *savep;
+
+ /*
+ * Firmware (PowerVM and KVM) saves r3 to a save area like
+ * machine check, which is not exactly what PAPR (2.9)
+ * suggests but there is no way to detect otherwise, so this
+ * is the interface now.
+ *
+ * System resets do not save any error log or require an
+ * "ibm,nmi-interlock" rtas call to release.
+ */
+
+ savep = fwnmi_get_savep(regs);
+ if (savep)
+ regs->gpr[3] = be64_to_cpu(savep[0]); /* restore original r3 */
}
if (smp_handle_nmi_ipi(regs))
--
2.23.0
^ permalink raw reply related
* [PATCH v4 07/16] powerpc/pseries/ras: fwnmi avoid modifying r3 in error case
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>
If there is some error with the fwnmi save area, r3 has already been
modified which doesn't help with debugging.
Only update r3 when to restore the saved value.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/platforms/pseries/ras.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index a5bd0f747bb1..fe14186a8cef 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -423,18 +423,19 @@ static inline struct rtas_error_log *fwnmi_get_errlog(void)
*/
static struct rtas_error_log *fwnmi_get_errinfo(struct pt_regs *regs)
{
+ unsigned long savep_ra;
unsigned long *savep;
struct rtas_error_log *h;
/* Mask top two bits */
- regs->gpr[3] &= ~(0x3UL << 62);
+ savep_ra = regs->gpr[3] & ~(0x3UL << 62);
- if (!VALID_FWNMI_BUFFER(regs->gpr[3])) {
+ if (!VALID_FWNMI_BUFFER(savep_ra)) {
printk(KERN_ERR "FWNMI: corrupt r3 0x%016lx\n", regs->gpr[3]);
return NULL;
}
- savep = __va(regs->gpr[3]);
+ savep = __va(savep_ra);
regs->gpr[3] = be64_to_cpu(savep[0]); /* restore original r3 */
h = (struct rtas_error_log *)&savep[1];
--
2.23.0
^ permalink raw reply related
* [PATCH v4 06/16] powerpc/pseries/ras: FWNMI_VALID off by one
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>
This was discovered developing qemu fwnmi sreset support. This
off-by-one bug means the last 16 bytes of the rtas area can not
be used for a 16 byte save area.
It's not a serious bug, and QEMU implementation has to retain a
workaround for old kernels, but it's good to tighten it.
Acked-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/platforms/pseries/ras.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index ac92f8687ea3..a5bd0f747bb1 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -395,10 +395,11 @@ static irqreturn_t ras_error_interrupt(int irq, void *dev_id)
/*
* Some versions of FWNMI place the buffer inside the 4kB page starting at
* 0x7000. Other versions place it inside the rtas buffer. We check both.
+ * Minimum size of the buffer is 16 bytes.
*/
#define VALID_FWNMI_BUFFER(A) \
- ((((A) >= 0x7000) && ((A) < 0x7ff0)) || \
- (((A) >= rtas.base) && ((A) < (rtas.base + rtas.size - 16))))
+ ((((A) >= 0x7000) && ((A) <= 0x8000 - 16)) || \
+ (((A) >= rtas.base) && ((A) <= (rtas.base + rtas.size - 16))))
static inline struct rtas_error_log *fwnmi_get_errlog(void)
{
--
2.23.0
^ permalink raw reply related
* [PATCH v4 05/16] powerpc/pseries/ras: avoid calling rtas_token in NMI paths
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>
In the interest of reducing code and possible failures in the
machine check and system reset paths, grab the "ibm,nmi-interlock"
token at init time.
Reviewed-by: Christophe Leroy <christophe.leroy@c-s.fr>
Reviewed-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/include/asm/firmware.h | 1 +
arch/powerpc/platforms/pseries/ras.c | 2 +-
arch/powerpc/platforms/pseries/setup.c | 14 ++++++++++----
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/include/asm/firmware.h b/arch/powerpc/include/asm/firmware.h
index ca33f4ef6cb4..6003c2e533a0 100644
--- a/arch/powerpc/include/asm/firmware.h
+++ b/arch/powerpc/include/asm/firmware.h
@@ -128,6 +128,7 @@ extern void machine_check_fwnmi(void);
/* This is true if we are using the firmware NMI handler (typically LPAR) */
extern int fwnmi_active;
+extern int ibm_nmi_interlock_token;
extern unsigned int __start___fw_ftr_fixup, __stop___fw_ftr_fixup;
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index 1d1da639b8b7..ac92f8687ea3 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -458,7 +458,7 @@ static struct rtas_error_log *fwnmi_get_errinfo(struct pt_regs *regs)
*/
static void fwnmi_release_errinfo(void)
{
- int ret = rtas_call(rtas_token("ibm,nmi-interlock"), 0, 1, NULL);
+ int ret = rtas_call(ibm_nmi_interlock_token, 0, 1, NULL);
if (ret != 0)
printk(KERN_ERR "FWNMI: nmi-interlock failed: %d\n", ret);
}
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 0c8421dd01ab..dd234095ae4f 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -83,6 +83,7 @@ unsigned long CMO_PageSize = (ASM_CONST(1) << IOMMU_PAGE_SHIFT_4K);
EXPORT_SYMBOL(CMO_PageSize);
int fwnmi_active; /* TRUE if an FWNMI handler is present */
+int ibm_nmi_interlock_token;
static void pSeries_show_cpuinfo(struct seq_file *m)
{
@@ -113,9 +114,14 @@ static void __init fwnmi_init(void)
struct slb_entry *slb_ptr;
size_t size;
#endif
+ int ibm_nmi_register_token;
- int ibm_nmi_register = rtas_token("ibm,nmi-register");
- if (ibm_nmi_register == RTAS_UNKNOWN_SERVICE)
+ ibm_nmi_register_token = rtas_token("ibm,nmi-register");
+ if (ibm_nmi_register_token == RTAS_UNKNOWN_SERVICE)
+ return;
+
+ ibm_nmi_interlock_token = rtas_token("ibm,nmi-interlock");
+ if (WARN_ON(ibm_nmi_interlock_token == RTAS_UNKNOWN_SERVICE))
return;
/* If the kernel's not linked at zero we point the firmware at low
@@ -123,8 +129,8 @@ static void __init fwnmi_init(void)
system_reset_addr = __pa(system_reset_fwnmi) - PHYSICAL_START;
machine_check_addr = __pa(machine_check_fwnmi) - PHYSICAL_START;
- if (0 == rtas_call(ibm_nmi_register, 2, 1, NULL, system_reset_addr,
- machine_check_addr))
+ if (0 == rtas_call(ibm_nmi_register_token, 2, 1, NULL,
+ system_reset_addr, machine_check_addr))
fwnmi_active = 1;
/*
--
2.23.0
^ permalink raw reply related
* [PATCH v4 04/16] powerpc/64s/exceptions: machine check reconcile irq state
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>
pseries fwnmi machine check code pops the soft-irq checks in rtas_call
(after the previous patch to remove rtas_token from this call path).
Rather than play whack a mole with these and forever having fragile
code, it seems better to have the early machine check handler perform
the same kind of reconcile as the other NMI interrupts.
WARNING: CPU: 0 PID: 493 at arch/powerpc/kernel/irq.c:343
CPU: 0 PID: 493 Comm: a Tainted: G W
NIP: c00000000001ed2c LR: c000000000042c40 CTR: 0000000000000000
REGS: c0000001fffd38b0 TRAP: 0700 Tainted: G W
MSR: 8000000000021003 <SF,ME,RI,LE> CR: 28000488 XER: 00000000
CFAR: c00000000001ec90 IRQMASK: 0
GPR00: c000000000043820 c0000001fffd3b40 c0000000012ba300 0000000000000000
GPR04: 0000000048000488 0000000000000000 0000000000000000 00000000deadbeef
GPR08: 0000000000000080 0000000000000000 0000000000000000 0000000000001001
GPR12: 0000000000000000 c0000000014a0000 0000000000000000 0000000000000000
GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR24: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR28: 0000000000000000 0000000000000001 c000000001360810 0000000000000000
NIP [c00000000001ed2c] arch_local_irq_restore.part.0+0xac/0x100
LR [c000000000042c40] unlock_rtas+0x30/0x90
Call Trace:
[c0000001fffd3b40] [c000000001360810] 0xc000000001360810 (unreliable)
[c0000001fffd3b60] [c000000000043820] rtas_call+0x1c0/0x280
[c0000001fffd3bb0] [c0000000000dc328] fwnmi_release_errinfo+0x38/0x70
[c0000001fffd3c10] [c0000000000dcd8c] pseries_machine_check_realmode+0x1dc/0x540
[c0000001fffd3cd0] [c00000000003fe04] machine_check_early+0x54/0x70
[c0000001fffd3d00] [c000000000008384] machine_check_early_common+0x134/0x1f0
--- interrupt: 200 at 0x13f1307c8
LR = 0x7fff888b8528
Instruction dump:
60000000 7d2000a6 71298000 41820068 39200002 7d210164 4bffff9c 60000000
60000000 7d2000a6 71298000 4c820020 <0fe00000> 4e800020 60000000 60000000
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/kernel/exceptions-64s.S | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index a42b73efb1a9..072772803b7c 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1116,11 +1116,30 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
li r10,MSR_RI
mtmsrd r10,1
+ /*
+ * Set IRQS_ALL_DISABLED and save PACAIRQHAPPENED (see
+ * system_reset_common)
+ */
+ li r10,IRQS_ALL_DISABLED
+ stb r10,PACAIRQSOFTMASK(r13)
+ lbz r10,PACAIRQHAPPENED(r13)
+ std r10,RESULT(r1)
+ ori r10,r10,PACA_IRQ_HARD_DIS
+ stb r10,PACAIRQHAPPENED(r13)
+
addi r3,r1,STACK_FRAME_OVERHEAD
bl machine_check_early
std r3,RESULT(r1) /* Save result */
ld r12,_MSR(r1)
+ /*
+ * Restore soft mask settings.
+ */
+ ld r10,RESULT(r1)
+ stb r10,PACAIRQHAPPENED(r13)
+ ld r10,SOFTE(r1)
+ stb r10,PACAIRQSOFTMASK(r13)
+
#ifdef CONFIG_PPC_P7_NAP
/*
* Check if thread was in power saving mode. We come here when any
--
2.23.0
^ permalink raw reply related
* [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, ®s, *p->ainsn.insn) == 1) {
> + if (!is_conditional_branch(*(struct ppc_inst *)p->ainsn.insn) &&
> + analyse_instr(&op, ®s,
> + *(struct ppc_inst *)p->ainsn.insn) == 1) {
> emulate_update_regs(®s, &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
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox