am b67ff7e3: am 734f0d64: Merge "Fix signal mask save/restore for arm64."

* commit 'b67ff7e37eac39bdbc06478a545b507462fdcee9':
  Fix signal mask save/restore for arm64.
This commit is contained in:
Elliott Hughes 2014-12-09 14:41:04 +00:00 committed by Android Git Automerger
commit 2660970708
2 changed files with 20 additions and 25 deletions

View File

@ -32,7 +32,6 @@
*/ */
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
#include <machine/setjmp.h>
// According to the ARM AAPCS document, we only need to save // According to the ARM AAPCS document, we only need to save
// the following registers: // the following registers:

View File

@ -28,9 +28,6 @@
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
// _JBLEN is the size of a jmp_buf in longs(64bit on AArch64).
#define _JBLEN 32
// According to AARCH64 PCS document we need to save the following // According to AARCH64 PCS document we need to save the following
// registers: // registers:
// //
@ -40,32 +37,30 @@
// NOTE: All the registers saved here will have 64bit vales (except FPSR). // NOTE: All the registers saved here will have 64bit vales (except FPSR).
// AAPCS mandates that the higher part of q registers do not need to // AAPCS mandates that the higher part of q registers do not need to
// be saved by the callee. // be saved by the callee.
//
// The structure of jmp_buf for AArch64: // The structure of jmp_buf for AArch64:
// //
// NOTE: _JBLEN is the size of jmp_buf in longs(64bit on AArch64)! The table // NOTE: _JBLEN is the size of jmp_buf in longs(64bit on AArch64)! The table
// below computes the offsets in words(32bit). // below computes the offsets in words(32bit).
// //
// word name description // word name description
// 0 magic magic number // -------------------------------------------------------------------------
// 1 sigmask signal mask (not used with _setjmp / _longjmp) // 0-1 sigmask signal mask (not used with _setjmp / _longjmp)
// 2 core_base base of core registers (x19-x30, sp) // 2 core_base base of core registers (x19-x30, sp)
// 28 float_base base of float registers (d8-d15) // 28 float_base base of float registers (d8-d15)
// 44 reserved reserved entries (room to grow) // 44 magic magic number
// 45- reserved reserved entries (room to grow)
// 64 // 64
// //
//
// NOTE: The instructions that load/store core/vfp registers expect 8-byte // NOTE: The instructions that load/store core/vfp registers expect 8-byte
// alignment. Contrary to the previous setjmp header for ARM we do not // alignment. Contrary to the previous setjmp header for ARM we do not
// need to save status/control registers for VFP (it is not a // need to save status/control registers for VFP (it is not a
// requirement for setjmp). // requirement for setjmp).
//
#define _JB_MAGIC 0 #define _JB_SIGMASK 0
#define _JB_SIGMASK (_JB_MAGIC+1) #define _JB_CORE_BASE (_JB_SIGMASK + 2)
#define _JB_CORE_BASE (_JB_SIGMASK+1)
#define _JB_FLOAT_BASE (_JB_CORE_BASE + (31-19+1)*2) #define _JB_FLOAT_BASE (_JB_CORE_BASE + (31-19+1)*2)
#define _JB_MAGIC (_JB_FLOAT_BASE + 16*2)
.L_setjmp_magic_signal_mask_n: .word 0x53657200 .L_setjmp_magic_signal_mask_n: .word 0x53657200
.L_setjmp_magic_signal_mask_y: .word 0x53657201 .L_setjmp_magic_signal_mask_y: .word 0x53657201
@ -86,16 +81,14 @@ ENTRY(sigsetjmp)
ldr w9, .L_setjmp_magic_signal_mask_n ldr w9, .L_setjmp_magic_signal_mask_n
cbz w1, 1f cbz w1, 1f
// Get current signal mask. // Save current signal mask.
stp x0, x30, [sp, #-16]! stp x0, x30, [sp, #-16]!
mov x0, xzr // The 'how' argument is ignored if new_mask is NULL.
bl sigblock mov x1, #0 // NULL.
mov w1, w0 add x2, x0, #(_JB_SIGMASK * 4) // old_mask.
bl sigprocmask
ldp x0, x30, [sp], #16 ldp x0, x30, [sp], #16
// Save signal mask.
str w1, [x0, #(_JB_SIGMASK * 4)]
ldr w9, .L_setjmp_magic_signal_mask_y ldr w9, .L_setjmp_magic_signal_mask_y
1: 1:
@ -135,11 +128,14 @@ ENTRY(siglongjmp)
// Restore signal mask. // Restore signal mask.
stp x0, x30, [sp, #-16]! stp x0, x30, [sp, #-16]!
mov x19, x1 mov x19, x1 // Save 'value'.
ldr w0, [x0, #(_JB_SIGMASK * 4)] mov x2, x0
bl sigsetmask mov x0, #2 // SIG_SETMASK
add x1, x2, #(_JB_SIGMASK * 4) // new_mask.
mov x2, #0 // NULL.
bl sigprocmask
mov x1, x19 // Restore 'value'.
ldp x0, x30, [sp], #16 ldp x0, x30, [sp], #16
mov x1, x19
1: 1:
// Restore core registers. // Restore core registers.