All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <andrew.jones@linux.dev>
To: kvm-riscv@lists.infradead.org
Subject: [kvm-unit-tests PATCH] lib/stack: Restrengthen base_address
Date: Wed,  4 Sep 2024 16:51:08 +0200	[thread overview]
Message-ID: <20240904145107.2447876-2-andrew.jones@linux.dev> (raw)

commit a1f2b0e1efd5 ("treewide: lib/stack: Make base_address arch
specific") made base_address() a weak function in order to allow
architectures to override it. Linking for EFI doesn't seem to figure
out the right one to use though [anymore?]. It must have worked at
one point because the commit calls outs EFI as the motivation.
Anyway, just drop the weakness in favor of another HAVE_ define.

Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
---
 lib/riscv/asm/stack.h |  1 +
 lib/riscv/stack.c     |  2 +-
 lib/stack.c           | 10 ++++++----
 lib/stack.h           |  2 +-
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/lib/riscv/asm/stack.h b/lib/riscv/asm/stack.h
index f003ca37c913..708fa4215007 100644
--- a/lib/riscv/asm/stack.h
+++ b/lib/riscv/asm/stack.h
@@ -8,5 +8,6 @@
 
 #define HAVE_ARCH_BACKTRACE_FRAME
 #define HAVE_ARCH_BACKTRACE
+#define HAVE_ARCH_BASE_ADDRESS
 
 #endif
diff --git a/lib/riscv/stack.c b/lib/riscv/stack.c
index 2cd7f012738b..a143c22a570a 100644
--- a/lib/riscv/stack.c
+++ b/lib/riscv/stack.c
@@ -5,7 +5,7 @@
 #ifdef CONFIG_RELOC
 extern char ImageBase, _text, _etext;
 
-bool arch_base_address(const void *rebased_addr, unsigned long *addr)
+bool base_address(const void *rebased_addr, unsigned long *addr)
 {
 	unsigned long ra = (unsigned long)rebased_addr;
 	unsigned long base = (unsigned long)&ImageBase;
diff --git a/lib/stack.c b/lib/stack.c
index 086fec544a81..e1c981085176 100644
--- a/lib/stack.c
+++ b/lib/stack.c
@@ -12,9 +12,10 @@
 #define MAX_DEPTH 20
 
 #ifdef CONFIG_RELOC
+#ifndef HAVE_ARCH_BASE_ADDRESS
 extern char _text, _etext;
 
-bool __attribute__((weak)) arch_base_address(const void *rebased_addr, unsigned long *addr)
+bool base_address(const void *rebased_addr, unsigned long *addr)
 {
 	unsigned long ra = (unsigned long)rebased_addr;
 	unsigned long start = (unsigned long)&_text;
@@ -26,8 +27,9 @@ bool __attribute__((weak)) arch_base_address(const void *rebased_addr, unsigned
 	*addr = ra - start;
 	return true;
 }
+#endif
 #else
-bool __attribute__((weak)) arch_base_address(const void *rebased_addr, unsigned long *addr)
+bool base_address(const void *rebased_addr, unsigned long *addr)
 {
 	*addr = (unsigned long)rebased_addr;
 	return true;
@@ -45,13 +47,13 @@ static void print_stack(const void **return_addrs, int depth,
 	/* @addr indicates a non-return address, as expected by the stack
 	 * pretty printer script. */
 	if (depth > 0 && !top_is_return_address) {
-		if (arch_base_address(return_addrs[0], &addr))
+		if (base_address(return_addrs[0], &addr))
 			printf(" @%lx", addr);
 		i++;
 	}
 
 	for (; i < depth; i++) {
-		if (arch_base_address(return_addrs[i], &addr))
+		if (base_address(return_addrs[i], &addr))
 			printf(" %lx", addr);
 	}
 	printf("\n");
diff --git a/lib/stack.h b/lib/stack.h
index df076d94bf8f..c92112c1744d 100644
--- a/lib/stack.h
+++ b/lib/stack.h
@@ -34,6 +34,6 @@ static inline int backtrace_frame(const void *frame, const void **return_addrs,
 }
 #endif
 
-bool __attribute__((weak)) arch_base_address(const void *rebased_addr, unsigned long *addr);
+bool base_address(const void *rebased_addr, unsigned long *addr);
 
 #endif
-- 
2.46.0



WARNING: multiple messages have this Message-ID (diff)
From: Andrew Jones <andrew.jones@linux.dev>
To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org
Cc: pbonzini@redhat.com, thuth@redhat.com, npiggin@gmail.com,
	atishp@rivosinc.com, cade.richard@berkeley.edu,
	jamestiotio@gmail.com
Subject: [kvm-unit-tests PATCH] lib/stack: Restrengthen base_address
Date: Wed,  4 Sep 2024 16:51:08 +0200	[thread overview]
Message-ID: <20240904145107.2447876-2-andrew.jones@linux.dev> (raw)

commit a1f2b0e1efd5 ("treewide: lib/stack: Make base_address arch
specific") made base_address() a weak function in order to allow
architectures to override it. Linking for EFI doesn't seem to figure
out the right one to use though [anymore?]. It must have worked at
one point because the commit calls outs EFI as the motivation.
Anyway, just drop the weakness in favor of another HAVE_ define.

Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
---
 lib/riscv/asm/stack.h |  1 +
 lib/riscv/stack.c     |  2 +-
 lib/stack.c           | 10 ++++++----
 lib/stack.h           |  2 +-
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/lib/riscv/asm/stack.h b/lib/riscv/asm/stack.h
index f003ca37c913..708fa4215007 100644
--- a/lib/riscv/asm/stack.h
+++ b/lib/riscv/asm/stack.h
@@ -8,5 +8,6 @@
 
 #define HAVE_ARCH_BACKTRACE_FRAME
 #define HAVE_ARCH_BACKTRACE
+#define HAVE_ARCH_BASE_ADDRESS
 
 #endif
diff --git a/lib/riscv/stack.c b/lib/riscv/stack.c
index 2cd7f012738b..a143c22a570a 100644
--- a/lib/riscv/stack.c
+++ b/lib/riscv/stack.c
@@ -5,7 +5,7 @@
 #ifdef CONFIG_RELOC
 extern char ImageBase, _text, _etext;
 
-bool arch_base_address(const void *rebased_addr, unsigned long *addr)
+bool base_address(const void *rebased_addr, unsigned long *addr)
 {
 	unsigned long ra = (unsigned long)rebased_addr;
 	unsigned long base = (unsigned long)&ImageBase;
diff --git a/lib/stack.c b/lib/stack.c
index 086fec544a81..e1c981085176 100644
--- a/lib/stack.c
+++ b/lib/stack.c
@@ -12,9 +12,10 @@
 #define MAX_DEPTH 20
 
 #ifdef CONFIG_RELOC
+#ifndef HAVE_ARCH_BASE_ADDRESS
 extern char _text, _etext;
 
-bool __attribute__((weak)) arch_base_address(const void *rebased_addr, unsigned long *addr)
+bool base_address(const void *rebased_addr, unsigned long *addr)
 {
 	unsigned long ra = (unsigned long)rebased_addr;
 	unsigned long start = (unsigned long)&_text;
@@ -26,8 +27,9 @@ bool __attribute__((weak)) arch_base_address(const void *rebased_addr, unsigned
 	*addr = ra - start;
 	return true;
 }
+#endif
 #else
-bool __attribute__((weak)) arch_base_address(const void *rebased_addr, unsigned long *addr)
+bool base_address(const void *rebased_addr, unsigned long *addr)
 {
 	*addr = (unsigned long)rebased_addr;
 	return true;
@@ -45,13 +47,13 @@ static void print_stack(const void **return_addrs, int depth,
 	/* @addr indicates a non-return address, as expected by the stack
 	 * pretty printer script. */
 	if (depth > 0 && !top_is_return_address) {
-		if (arch_base_address(return_addrs[0], &addr))
+		if (base_address(return_addrs[0], &addr))
 			printf(" @%lx", addr);
 		i++;
 	}
 
 	for (; i < depth; i++) {
-		if (arch_base_address(return_addrs[i], &addr))
+		if (base_address(return_addrs[i], &addr))
 			printf(" %lx", addr);
 	}
 	printf("\n");
diff --git a/lib/stack.h b/lib/stack.h
index df076d94bf8f..c92112c1744d 100644
--- a/lib/stack.h
+++ b/lib/stack.h
@@ -34,6 +34,6 @@ static inline int backtrace_frame(const void *frame, const void **return_addrs,
 }
 #endif
 
-bool __attribute__((weak)) arch_base_address(const void *rebased_addr, unsigned long *addr);
+bool base_address(const void *rebased_addr, unsigned long *addr);
 
 #endif
-- 
2.46.0


             reply	other threads:[~2024-09-04 14:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-04 14:51 Andrew Jones [this message]
2024-09-04 14:51 ` [kvm-unit-tests PATCH] lib/stack: Restrengthen base_address Andrew Jones
2024-09-11  0:55 ` Nicholas Piggin
2024-09-11  0:55   ` Nicholas Piggin
2024-09-11  8:38   ` Andrew Jones
2024-09-11  8:38     ` Andrew Jones

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=20240904145107.2447876-2-andrew.jones@linux.dev \
    --to=andrew.jones@linux.dev \
    --cc=kvm-riscv@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.