From: Julien Thierry <jthierry@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: jpoimboe@redhat.com, peterz@infradead.org, mbenes@suse.cz,
raphael.gault@arm.com, benh@kernel.crashing.org,
Julien Thierry <jthierry@redhat.com>
Subject: [PATCH v3 10/10] objtool: Decode unwind hint register depending on architecture
Date: Fri, 4 Sep 2020 16:30:28 +0100 [thread overview]
Message-ID: <20200904153028.32676-11-jthierry@redhat.com> (raw)
In-Reply-To: <20200904153028.32676-1-jthierry@redhat.com>
The set of registers that can be included in an unwind hint and their
encoding will depend on the architecture. Have arch specific code to
decode that register.
Signed-off-by: Julien Thierry <jthierry@redhat.com>
---
tools/objtool/arch.h | 2 ++
tools/objtool/arch/x86/decode.c | 37 +++++++++++++++++++++++++++++++++
tools/objtool/check.c | 27 +-----------------------
3 files changed, 40 insertions(+), 26 deletions(-)
diff --git a/tools/objtool/arch.h b/tools/objtool/arch.h
index b18c5f61d42d..4a84c3081b8e 100644
--- a/tools/objtool/arch.h
+++ b/tools/objtool/arch.h
@@ -88,4 +88,6 @@ unsigned long arch_dest_reloc_offset(int addend);
const char *arch_nop_insn(int len);
+int arch_decode_hint_reg(struct instruction *insn, u8 sp_reg);
+
#endif /* _ARCH_H */
diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
index 1967370440b3..cde9c36e40ae 100644
--- a/tools/objtool/arch/x86/decode.c
+++ b/tools/objtool/arch/x86/decode.c
@@ -15,6 +15,7 @@
#include "../../elf.h"
#include "../../arch.h"
#include "../../warn.h"
+#include <asm/orc_types.h>
static unsigned char op_to_cfi_reg[][2] = {
{CFI_AX, CFI_R8},
@@ -583,3 +584,39 @@ const char *arch_nop_insn(int len)
return nops[len-1];
}
+
+int arch_decode_hint_reg(struct instruction *insn, u8 sp_reg)
+{
+ struct cfi_reg *cfa = &insn->cfi.cfa;
+
+ switch (sp_reg) {
+ case ORC_REG_UNDEFINED:
+ cfa->base = CFI_UNDEFINED;
+ break;
+ case ORC_REG_SP:
+ cfa->base = CFI_SP;
+ break;
+ case ORC_REG_BP:
+ cfa->base = CFI_BP;
+ break;
+ case ORC_REG_SP_INDIRECT:
+ cfa->base = CFI_SP_INDIRECT;
+ break;
+ case ORC_REG_R10:
+ cfa->base = CFI_R10;
+ break;
+ case ORC_REG_R13:
+ cfa->base = CFI_R13;
+ break;
+ case ORC_REG_DI:
+ cfa->base = CFI_DI;
+ break;
+ case ORC_REG_DX:
+ cfa->base = CFI_DX;
+ break;
+ default:
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 60e23c8f93e0..8630a2d5e68c 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1261,32 +1261,7 @@ static int read_unwind_hints(struct objtool_file *file)
insn->hint = true;
- switch (hint->sp_reg) {
- case ORC_REG_UNDEFINED:
- cfa->base = CFI_UNDEFINED;
- break;
- case ORC_REG_SP:
- cfa->base = CFI_SP;
- break;
- case ORC_REG_BP:
- cfa->base = CFI_BP;
- break;
- case ORC_REG_SP_INDIRECT:
- cfa->base = CFI_SP_INDIRECT;
- break;
- case ORC_REG_R10:
- cfa->base = CFI_R10;
- break;
- case ORC_REG_R13:
- cfa->base = CFI_R13;
- break;
- case ORC_REG_DI:
- cfa->base = CFI_DI;
- break;
- case ORC_REG_DX:
- cfa->base = CFI_DX;
- break;
- default:
+ if (arch_decode_hint_reg(insn, hint->sp_reg)) {
WARN_FUNC("unsupported unwind_hint sp base reg %d",
insn->sec, insn->offset, hint->sp_reg);
return -1;
--
2.21.3
next prev parent reply other threads:[~2020-09-04 15:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-04 15:30 [PATCH v3 00/10] Make check implementation arch agnostic Julien Thierry
2020-09-04 15:30 ` [PATCH v3 01/10] objtool: Group headers to check in a single list Julien Thierry
2020-09-04 15:30 ` [PATCH v3 02/10] objtool: Make sync-check consider the target architecture Julien Thierry
2020-09-04 18:22 ` Josh Poimboeuf
2020-09-04 15:30 ` [PATCH v3 03/10] objtool: Move macros describing structures to arch-dependent code Julien Thierry
2020-09-04 15:30 ` [PATCH v3 04/10] objtool: Abstract alternative special case handling Julien Thierry
2020-09-04 15:30 ` [PATCH v3 05/10] objtool: Make relocation in alternative handling arch dependent Julien Thierry
2020-09-04 15:30 ` [PATCH v3 06/10] objtool: Refactor switch-tables code to support other architectures Julien Thierry
2020-09-04 15:30 ` [PATCH v3 07/10] headers: Rename frame.h Julien Thierry
2020-09-04 15:30 ` [PATCH v3 08/10] objtool: Only include valid definitions depending on source file type Julien Thierry
2020-09-04 15:30 ` [PATCH v3 09/10] objtool: Make unwind hints definitions available to other architectures Julien Thierry
2020-09-04 18:49 ` Josh Poimboeuf
2020-09-04 15:30 ` Julien Thierry [this message]
2020-09-04 18:55 ` [PATCH v3 00/10] Make check implementation arch agnostic Josh Poimboeuf
2020-09-08 13:24 ` [PATCH] objtool: Fix sync-check.sh bashisms Julien Thierry
2020-09-11 10:43 ` [PATCH v3 00/10] Make check implementation arch agnostic Miroslav Benes
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=20200904153028.32676-11-jthierry@redhat.com \
--to=jthierry@redhat.com \
--cc=benh@kernel.crashing.org \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=peterz@infradead.org \
--cc=raphael.gault@arm.com \
/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).