Commit 3497447f authored by Paul Mundt's avatar Paul Mundt

sh: unwinder: Fix up usage of unaligned accessors.

This was using internal symbols for unaligned accesses, bypassing the
exposed interface for variable sized safe accesses. This converts all of
the __get_unaligned_cpuXX() users over to get_unaligned() directly,
relying on the cast to select the proper internal routine.

Additionally, the __put_unaligned_cpuXX() case is superfluous given that
the destination address is aligned in all of the current cases, so just
drop that outright.

Furthermore, this switches to the asm/unaligned.h header instead of the
asm-generic version, which was silently bypassing the SH-4A optimized
unaligned ops.
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent cafb0dda
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <asm/dwarf.h> #include <asm/dwarf.h>
#include <asm/unwinder.h> #include <asm/unwinder.h>
#include <asm/sections.h> #include <asm/sections.h>
#include <asm-generic/unaligned.h> #include <asm/unaligned.h>
#include <asm/dwarf.h> #include <asm/dwarf.h>
#include <asm/stacktrace.h> #include <asm/stacktrace.h>
...@@ -87,11 +87,9 @@ static void dwarf_frame_alloc_regs(struct dwarf_frame *frame, ...@@ -87,11 +87,9 @@ static void dwarf_frame_alloc_regs(struct dwarf_frame *frame,
* from @src and writing to @dst, because they can be arbitrarily * from @src and writing to @dst, because they can be arbitrarily
* aligned. Return 'n' - the number of bytes read. * aligned. Return 'n' - the number of bytes read.
*/ */
static inline int dwarf_read_addr(void *src, void *dst) static inline int dwarf_read_addr(unsigned long *src, unsigned long *dst)
{ {
u32 val = __get_unaligned_cpu32(src); *dst = get_unaligned(src);
__put_unaligned_cpu32(val, dst);
return sizeof(unsigned long *); return sizeof(unsigned long *);
} }
...@@ -207,7 +205,7 @@ static int dwarf_read_encoded_value(char *addr, unsigned long *val, ...@@ -207,7 +205,7 @@ static int dwarf_read_encoded_value(char *addr, unsigned long *val,
case DW_EH_PE_sdata4: case DW_EH_PE_sdata4:
case DW_EH_PE_udata4: case DW_EH_PE_udata4:
count += 4; count += 4;
decoded_addr += __get_unaligned_cpu32(addr); decoded_addr += get_unaligned((u32 *)addr);
__raw_writel(decoded_addr, val); __raw_writel(decoded_addr, val);
break; break;
default: default:
...@@ -232,7 +230,7 @@ static inline int dwarf_entry_len(char *addr, unsigned long *len) ...@@ -232,7 +230,7 @@ static inline int dwarf_entry_len(char *addr, unsigned long *len)
u32 initial_len; u32 initial_len;
int count; int count;
initial_len = __get_unaligned_cpu32(addr); initial_len = get_unaligned((u32 *)addr);
count = 4; count = 4;
/* /*
...@@ -247,7 +245,7 @@ static inline int dwarf_entry_len(char *addr, unsigned long *len) ...@@ -247,7 +245,7 @@ static inline int dwarf_entry_len(char *addr, unsigned long *len)
* compulsory 32-bit length field. * compulsory 32-bit length field.
*/ */
if (initial_len == DW_EXT_DWARF64) { if (initial_len == DW_EXT_DWARF64) {
*len = __get_unaligned_cpu64(addr + 4); *len = get_unaligned((u64 *)addr + 4);
count = 12; count = 12;
} else { } else {
printk(KERN_WARNING "Unknown DWARF extension\n"); printk(KERN_WARNING "Unknown DWARF extension\n");
...@@ -392,12 +390,12 @@ static int dwarf_cfa_execute_insns(unsigned char *insn_start, ...@@ -392,12 +390,12 @@ static int dwarf_cfa_execute_insns(unsigned char *insn_start,
frame->pc += delta * cie->code_alignment_factor; frame->pc += delta * cie->code_alignment_factor;
break; break;
case DW_CFA_advance_loc2: case DW_CFA_advance_loc2:
delta = __get_unaligned_cpu16(current_insn); delta = get_unaligned((u16 *)current_insn);
current_insn += 2; current_insn += 2;
frame->pc += delta * cie->code_alignment_factor; frame->pc += delta * cie->code_alignment_factor;
break; break;
case DW_CFA_advance_loc4: case DW_CFA_advance_loc4:
delta = __get_unaligned_cpu32(current_insn); delta = get_unaligned((u32 *)current_insn);
current_insn += 4; current_insn += 4;
frame->pc += delta * cie->code_alignment_factor; frame->pc += delta * cie->code_alignment_factor;
break; break;
...@@ -841,7 +839,7 @@ void dwarf_unwinder_init(void) ...@@ -841,7 +839,7 @@ void dwarf_unwinder_init(void)
/* initial length does not include itself */ /* initial length does not include itself */
end = p + len; end = p + len;
entry_type = __get_unaligned_cpu32(p); entry_type = get_unaligned((u32 *)p);
p += 4; p += 4;
if (entry_type == DW_EH_FRAME_CIE) { if (entry_type == DW_EH_FRAME_CIE) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment