From: Ard Biesheuvel <ardb@kernel.org>
Use RIP-relative accesses and 32-bit offsets for .tracedata, to avoid
the need for relocation fixups at boot time.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/x86/include/asm/pm-trace.h | 4 ++--
drivers/base/power/trace.c | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/x86/include/asm/pm-trace.h b/arch/x86/include/asm/pm-trace.h
index bfa32aa428e5..123faf978473 100644
--- a/arch/x86/include/asm/pm-trace.h
+++ b/arch/x86/include/asm/pm-trace.h
@@ -8,10 +8,10 @@
do { \
if (pm_trace_enabled) { \
const void *tracedata; \
- asm volatile(_ASM_MOV " $1f,%0\n" \
+ asm volatile("lea " _ASM_RIP(1f) ", %0\n" \
".section .tracedata,\"a\"\n" \
"1:\t.word %c1\n\t" \
- _ASM_PTR " %c2\n" \
+ ".long %c2 - .\n" \
".previous" \
:"=r" (tracedata) \
: "i" (__LINE__), "i" (__FILE__)); \
diff --git a/drivers/base/power/trace.c b/drivers/base/power/trace.c
index cd6e559648b2..686a0276ccfc 100644
--- a/drivers/base/power/trace.c
+++ b/drivers/base/power/trace.c
@@ -167,7 +167,7 @@ EXPORT_SYMBOL(set_trace_device);
void generate_pm_trace(const void *tracedata, unsigned int user)
{
unsigned short lineno = *(unsigned short *)tracedata;
- const char *file = *(const char **)(tracedata + 2);
+ const char *file = offset_to_ptr((int *)(tracedata + 2));
unsigned int user_hash_value, file_hash_value;
if (!x86_platform.legacy.rtc)
@@ -187,9 +187,9 @@ static int show_file_hash(unsigned int value)
match = 0;
for (tracedata = __tracedata_start ; tracedata < __tracedata_end ;
- tracedata += 2 + sizeof(unsigned long)) {
+ tracedata += 2 + sizeof(int)) {
unsigned short lineno = *(unsigned short *)tracedata;
- const char *file = *(const char **)(tracedata + 2);
+ const char *file = offset_to_ptr((int *)(tracedata + 2));
unsigned int hash = hash_string(lineno, file, FILEHASH);
if (hash != value)
continue;
--
2.46.0.792.g87dc391469-goog