linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Axtens <dja@axtens.net>
To: linuxppc-dev@ozlabs.org
Cc: Daniel Axtens <dja@axtens.net>
Subject: [PATCH 4/6] powerpc/kernel: Clean up some sparse warnings
Date: Mon,  4 Jul 2016 17:09:40 +1000	[thread overview]
Message-ID: <1467616182-30886-4-git-send-email-dja@axtens.net> (raw)
In-Reply-To: <1467616182-30886-1-git-send-email-dja@axtens.net>

In hw_breakpoint.c, mark a user NIP as __user before passing it to
__get_user_inatomic.

In process.c, 7b051f665c32 ("powerpc: Use probe_kernel_address in
show_instructions") changed a call from __get_user to
probe_kernel_address. The address space annotations for that are
different: it no longer takes a user pointer, but a kernel pointer:
the new type is simply void *.

(This sounds super dodgy: why is a user pointer now a kernel pointer?
It's not so bad - it was always supposed to be kernel
pointer. __get_user was used on a kernel address to avoid an OOPS
should the address be invalid. probe_kernel_address handles this case,
so there's now no monkeying around with address spaces.)

io.c contains macros for reading and writing from io devices. Sparse
complains about things moving between address spaces. This is what the
functions are designed to do, so tell sparse we know what we're doing
with __force.

Signed-off-by: Daniel Axtens <dja@axtens.net>
---
 arch/powerpc/kernel/hw_breakpoint.c |  2 +-
 arch/powerpc/kernel/io.c            | 16 ++++++++--------
 arch/powerpc/kernel/process.c       |  2 +-
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c
index aec9a1b1d25b..e903a6b96b7f 100644
--- a/arch/powerpc/kernel/hw_breakpoint.c
+++ b/arch/powerpc/kernel/hw_breakpoint.c
@@ -264,7 +264,7 @@ int __kprobes hw_breakpoint_handler(struct die_args *args)
 
 	stepped = 0;
 	instr = 0;
-	if (!__get_user_inatomic(instr, (unsigned int *) regs->nip))
+	if (!__get_user_inatomic(instr, (unsigned int __user *) regs->nip))
 		stepped = emulate_step(regs, instr);
 
 	/*
diff --git a/arch/powerpc/kernel/io.c b/arch/powerpc/kernel/io.c
index 2a2b4aeab80f..3f70b7dccee8 100644
--- a/arch/powerpc/kernel/io.c
+++ b/arch/powerpc/kernel/io.c
@@ -37,7 +37,7 @@ void _insb(const volatile u8 __iomem *port, void *buf, long count)
 		return;
 	asm volatile("sync");
 	do {
-		tmp = *port;
+		tmp = *(u8 __force *)port;
 		eieio();
 		*tbuf++ = tmp;
 	} while (--count != 0);
@@ -47,13 +47,13 @@ EXPORT_SYMBOL(_insb);
 
 void _outsb(volatile u8 __iomem *port, const void *buf, long count)
 {
-	const u8 *tbuf = buf;
+	const u8 __force *tbuf = buf;
 
 	if (unlikely(count <= 0))
 		return;
 	asm volatile("sync");
 	do {
-		*port = *tbuf++;
+		*(volatile u8 __force *)port = *tbuf++;
 	} while (--count != 0);
 	asm volatile("sync");
 }
@@ -68,7 +68,7 @@ void _insw_ns(const volatile u16 __iomem *port, void *buf, long count)
 		return;
 	asm volatile("sync");
 	do {
-		tmp = *port;
+		tmp = *(u16 __force *)port;
 		eieio();
 		*tbuf++ = tmp;
 	} while (--count != 0);
@@ -78,13 +78,13 @@ EXPORT_SYMBOL(_insw_ns);
 
 void _outsw_ns(volatile u16 __iomem *port, const void *buf, long count)
 {
-	const u16 *tbuf = buf;
+	const u16 __force *tbuf = buf;
 
 	if (unlikely(count <= 0))
 		return;
 	asm volatile("sync");
 	do {
-		*port = *tbuf++;
+		*(volatile u16 __force *)port = *tbuf++;
 	} while (--count != 0);
 	asm volatile("sync");
 }
@@ -99,7 +99,7 @@ void _insl_ns(const volatile u32 __iomem *port, void *buf, long count)
 		return;
 	asm volatile("sync");
 	do {
-		tmp = *port;
+		tmp = *(u32 __force *)port;
 		eieio();
 		*tbuf++ = tmp;
 	} while (--count != 0);
@@ -115,7 +115,7 @@ void _outsl_ns(volatile u32 __iomem *port, const void *buf, long count)
 		return;
 	asm volatile("sync");
 	do {
-		*port = *tbuf++;
+		*(volatile u32 __force *)port = *tbuf++;
 	} while (--count != 0);
 	asm volatile("sync");
 }
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index a8cca88e972f..9c775e97558b 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1194,7 +1194,7 @@ static void show_instructions(struct pt_regs *regs)
 #endif
 
 		if (!__kernel_text_address(pc) ||
-		     probe_kernel_address((unsigned int __user *)pc, instr)) {
+		     probe_kernel_address((void *)pc, instr)) {
 			printk(KERN_CONT "XXXXXXXX ");
 		} else {
 			if (regs->nip == pc)
-- 
2.1.4

  parent reply	other threads:[~2016-07-04  7:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-04  7:09 [PATCH 1/6] powerpc/kvm: Clarify __user annotations Daniel Axtens
2016-07-04  7:09 ` [PATCH 2/6] powerpc/kernel: Drop annotation for generic, unannotated function Daniel Axtens
2016-07-04  7:09 ` [PATCH 3/6] powerpc/xics: Fully qualify cast to silence sparse Daniel Axtens
2016-07-04  7:27   ` Andrew Donnellan
2016-07-04  7:46   ` Arnd Bergmann
2016-07-04  7:09 ` Daniel Axtens [this message]
2016-07-04  7:50   ` [PATCH 4/6] powerpc/kernel: Clean up some sparse warnings Arnd Bergmann
2016-07-04  7:09 ` [PATCH 5/6] powerpc/sparse: Pass endianness to sparse Daniel Axtens
2016-07-04  7:32   ` Andrew Donnellan
2016-07-04  7:52   ` Arnd Bergmann
2016-07-04  7:09 ` [PATCH 6/6] powerpc/sparse: Make ppc_md.{halt, restart} __noreturn Daniel Axtens
2016-07-04 10:20   ` kbuild test robot
2016-07-04  7:26 ` [PATCH 1/6] powerpc/kvm: Clarify __user annotations Andrew Donnellan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467616182-30886-4-git-send-email-dja@axtens.net \
    --to=dja@axtens.net \
    --cc=linuxppc-dev@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).