* [PATCH] powerpc/misc: get rid of add_reloc_offset()
@ 2018-04-17 7:56 Christophe Leroy
2018-04-17 9:30 ` Paul Mackerras
0 siblings, 1 reply; 2+ messages in thread
From: Christophe Leroy @ 2018-04-17 7:56 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linux-kernel, linuxppc-dev
add_reloc_offset() is almost redundant with reloc_offset()
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/setup.h | 3 +--
arch/powerpc/kernel/misc.S | 16 ----------------
arch/powerpc/kernel/prom_init_check.sh | 2 +-
3 files changed, 2 insertions(+), 19 deletions(-)
diff --git a/arch/powerpc/include/asm/setup.h b/arch/powerpc/include/asm/setup.h
index 27fa52ed6d00..115e0896ffa7 100644
--- a/arch/powerpc/include/asm/setup.h
+++ b/arch/powerpc/include/asm/setup.h
@@ -17,10 +17,9 @@ extern void note_scsi_host(struct device_node *, void *);
/* Used in very early kernel initialization. */
extern unsigned long reloc_offset(void);
-extern unsigned long add_reloc_offset(unsigned long);
extern void reloc_got2(unsigned long);
-#define PTRRELOC(x) ((typeof(x)) add_reloc_offset((unsigned long)(x)))
+#define PTRRELOC(x) ((typeof(x)) ((unsigned long)(x) + reloc_offset()))
void check_for_initrd(void);
void mem_topology_setup(void);
diff --git a/arch/powerpc/kernel/misc.S b/arch/powerpc/kernel/misc.S
index 384357cb8bc0..2711b10ebdb3 100644
--- a/arch/powerpc/kernel/misc.S
+++ b/arch/powerpc/kernel/misc.S
@@ -39,22 +39,6 @@ _GLOBAL(reloc_offset)
.align 3
2: PPC_LONG 1b
-/*
- * add_reloc_offset(x) returns x + reloc_offset().
- */
-_GLOBAL(add_reloc_offset)
- mflr r0
- bl 1f
-1: mflr r5
- PPC_LL r4,(2f-1b)(r5)
- subf r5,r4,r5
- add r3,r3,r5
- mtlr r0
- blr
-
- .align 3
-2: PPC_LONG 1b
-
_GLOBAL(setjmp)
mflr r0
PPC_STL r0,0(r3)
diff --git a/arch/powerpc/kernel/prom_init_check.sh b/arch/powerpc/kernel/prom_init_check.sh
index acb6b9226352..ee9f63186b72 100644
--- a/arch/powerpc/kernel/prom_init_check.sh
+++ b/arch/powerpc/kernel/prom_init_check.sh
@@ -16,7 +16,7 @@
# If you really need to reference something from prom_init.o add
# it to the list below:
-WHITELIST="add_reloc_offset __bss_start __bss_stop copy_and_flush
+WHITELIST="__bss_start __bss_stop copy_and_flush
_end enter_prom memcpy memset reloc_offset __secondary_hold
__secondary_hold_acknowledge __secondary_hold_spinloop __start
strcmp strcpy strlcpy strlen strncmp strstr kstrtobool logo_linux_clut224
--
2.13.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] powerpc/misc: get rid of add_reloc_offset()
2018-04-17 7:56 [PATCH] powerpc/misc: get rid of add_reloc_offset() Christophe Leroy
@ 2018-04-17 9:30 ` Paul Mackerras
0 siblings, 0 replies; 2+ messages in thread
From: Paul Mackerras @ 2018-04-17 9:30 UTC (permalink / raw)
To: Christophe Leroy
Cc: Benjamin Herrenschmidt, Michael Ellerman, linux-kernel,
linuxppc-dev
On Tue, Apr 17, 2018 at 09:56:24AM +0200, Christophe Leroy wrote:
> add_reloc_offset() is almost redundant with reloc_offset()
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> arch/powerpc/include/asm/setup.h | 3 +--
> arch/powerpc/kernel/misc.S | 16 ----------------
> arch/powerpc/kernel/prom_init_check.sh | 2 +-
> 3 files changed, 2 insertions(+), 19 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/setup.h b/arch/powerpc/include/asm/setup.h
> index 27fa52ed6d00..115e0896ffa7 100644
> --- a/arch/powerpc/include/asm/setup.h
> +++ b/arch/powerpc/include/asm/setup.h
> @@ -17,10 +17,9 @@ extern void note_scsi_host(struct device_node *, void *);
>
> /* Used in very early kernel initialization. */
> extern unsigned long reloc_offset(void);
> -extern unsigned long add_reloc_offset(unsigned long);
> extern void reloc_got2(unsigned long);
>
> -#define PTRRELOC(x) ((typeof(x)) add_reloc_offset((unsigned long)(x)))
> +#define PTRRELOC(x) ((typeof(x)) ((unsigned long)(x) + reloc_offset()))
NAK. This is how it used to be, and we changed it in order to prevent
gcc from making incorrect assumptions. If you use the form with the
explicit addition, and x is the address of an array, gcc will assume
that the result is within the bounds of the array (apparently the C
standard says it can do that) and potentially generate incorrect
code. I recall that we had an actual case where gcc was generating
incorrect code, though I don't recall the details, as this was some
time before 2002.
Paul.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-04-17 9:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-17 7:56 [PATCH] powerpc/misc: get rid of add_reloc_offset() Christophe Leroy
2018-04-17 9:30 ` Paul Mackerras
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).