mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-25 22:05:23 +07:00
56d20861c0
Call Frame Information is used by gdb for back-traces and inserting breakpoints on function return for the "finish" command. This failed when inside __kernel_clock_gettime. More concerning than difficulty debugging is that CFI is also used by stack frame unwinding code to implement exceptions. If you have an app that needs to handle asynchronous exceptions for some reason, and you are unlucky enough to get one inside the VDSO time functions, your app will crash. What's wrong: There is control flow in __kernel_clock_gettime that reaches label 99 without saving lr in r12. CFI info however is interpreted by the unwinder without reference to control flow: It's a simple matter of "Execute all the CFI opcodes up to the current address". That means the unwinder thinks r12 contains the return address at label 99. Disabuse it of that notion by resetting CFI for the return address at label 99. Note that the ".cfi_restore lr" could have gone anywhere from the "mtlr r12" a few instructions earlier to the instruction at label 99. I put the CFI as late as possible, because in general that's best practice (and if possible grouped with other CFI in order to reduce the number of CFI opcodes executed when unwinding). Using r12 as the return address is perfectly fine after the "mtlr r12" since r12 on that code path still contains the return address. __get_datapage also has a CFI error. That function temporarily saves lr in r0, and reflects that fact with ".cfi_register lr,r0". A later use of r0 means the CFI at that point isn't correct, as r0 no longer contains the return address. Fix that too. Signed-off-by: Alan Modra <amodra@gmail.com> Tested-by: Reza Arbab <arbab@linux.ibm.com> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
89 lines
2.1 KiB
ArmAsm
89 lines
2.1 KiB
ArmAsm
/*
|
|
* Access to the shared data page by the vDSO & syscall map
|
|
*
|
|
* Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org), IBM Corp.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the License, or (at your option) any later version.
|
|
*/
|
|
|
|
#include <asm/processor.h>
|
|
#include <asm/ppc_asm.h>
|
|
#include <asm/asm-offsets.h>
|
|
#include <asm/unistd.h>
|
|
#include <asm/vdso.h>
|
|
|
|
.text
|
|
.global __kernel_datapage_offset;
|
|
__kernel_datapage_offset:
|
|
.long 0
|
|
|
|
V_FUNCTION_BEGIN(__get_datapage)
|
|
.cfi_startproc
|
|
/* We don't want that exposed or overridable as we want other objects
|
|
* to be able to bl directly to here
|
|
*/
|
|
.protected __get_datapage
|
|
.hidden __get_datapage
|
|
|
|
mflr r0
|
|
.cfi_register lr,r0
|
|
|
|
bcl 20,31,data_page_branch
|
|
data_page_branch:
|
|
mflr r3
|
|
mtlr r0
|
|
addi r3, r3, __kernel_datapage_offset-data_page_branch
|
|
lwz r0,0(r3)
|
|
.cfi_restore lr
|
|
add r3,r0,r3
|
|
blr
|
|
.cfi_endproc
|
|
V_FUNCTION_END(__get_datapage)
|
|
|
|
/*
|
|
* void *__kernel_get_syscall_map(unsigned int *syscall_count) ;
|
|
*
|
|
* returns a pointer to the syscall map. the map is agnostic to the
|
|
* size of "long", unlike kernel bitops, it stores bits from top to
|
|
* bottom so that memory actually contains a linear bitmap
|
|
* check for syscall N by testing bit (0x80000000 >> (N & 0x1f)) of
|
|
* 32 bits int at N >> 5.
|
|
*/
|
|
V_FUNCTION_BEGIN(__kernel_get_syscall_map)
|
|
.cfi_startproc
|
|
mflr r12
|
|
.cfi_register lr,r12
|
|
mr r4,r3
|
|
bl __get_datapage@local
|
|
mtlr r12
|
|
addi r3,r3,CFG_SYSCALL_MAP32
|
|
cmpli cr0,r4,0
|
|
beqlr
|
|
li r0,NR_syscalls
|
|
stw r0,0(r4)
|
|
crclr cr0*4+so
|
|
blr
|
|
.cfi_endproc
|
|
V_FUNCTION_END(__kernel_get_syscall_map)
|
|
|
|
/*
|
|
* void unsigned long long __kernel_get_tbfreq(void);
|
|
*
|
|
* returns the timebase frequency in HZ
|
|
*/
|
|
V_FUNCTION_BEGIN(__kernel_get_tbfreq)
|
|
.cfi_startproc
|
|
mflr r12
|
|
.cfi_register lr,r12
|
|
bl __get_datapage@local
|
|
lwz r4,(CFG_TB_TICKS_PER_SEC + 4)(r3)
|
|
lwz r3,CFG_TB_TICKS_PER_SEC(r3)
|
|
mtlr r12
|
|
crclr cr0*4+so
|
|
blr
|
|
.cfi_endproc
|
|
V_FUNCTION_END(__kernel_get_tbfreq)
|