1b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* x86-64 specific core note handling. 2a845f68bf43f90e0670ed6b33154f2aff98ad46bRoland McGrath Copyright (C) 2005, 2007, 2008 Red Hat, Inc. 328ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu Copyright (C) H.J. Lu <hjl.tools@gmail.com>, 2015. 4de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard This file is part of elfutils. 5b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper 6de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard This file is free software; you can redistribute it and/or modify 7de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard it under the terms of either 8b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper 9de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard * the GNU Lesser General Public License as published by the Free 10de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard Software Foundation; either version 3 of the License, or (at 11de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard your option) any later version 12de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard 13de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard or 14de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard 15de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard * the GNU General Public License as published by the Free 16de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard Software Foundation; either version 2 of the License, or (at 17de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard your option) any later version 18de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard 19de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard or both in parallel, as here. 20de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard 21de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard elfutils is distributed in the hope that it will be useful, but 22361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper WITHOUT ANY WARRANTY; without even the implied warranty of 23361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper General Public License for more details. 25361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper 26de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard You should have received copies of the GNU General Public License and 27de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard the GNU Lesser General Public License along with this program. If 28de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard not, see <http://www.gnu.org/licenses/>. */ 29b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper 30b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#ifdef HAVE_CONFIG_H 31b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper# include <config.h> 32b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#endif 33b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper 34b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#include <elf.h> 35b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#include <inttypes.h> 36b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#include <stddef.h> 37b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#include <stdio.h> 38b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#include <sys/time.h> 39b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper 4028ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu#ifndef BITS 4128ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define BITS 64 4228ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define BACKEND x86_64_ 4328ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu#else 4428ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define BITS 32 4528ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define BACKEND x32_ 4628ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu#endif 47cd60ea83050d9fb48c3204005f475df460f433b6Roland McGrath#include "libebl_CPU.h" 48b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper 49b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper 50cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrathstatic const Ebl_Register_Location prstatus_regs[] = 51b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper { 52cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath#define GR(at, n, dwreg) \ 53cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath { .offset = at * 8, .regno = dwreg, .count = n, .bits = 64 } 54cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath#define SR(at, n, dwreg) \ 55cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath { .offset = at * 8, .regno = dwreg, .count = n, .bits = 16, .pad = 6 } 56cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath 57cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath GR (0, 1, 15), /* %r15 */ 58cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath GR (1, 1, 14), /* %r14 */ 59cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath GR (2, 1, 13), /* %r13 */ 60cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath GR (3, 1, 12), /* %r12 */ 61cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath GR (4, 1, 6), /* %rbp */ 62cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath GR (5, 1, 3), /* %rbx */ 63cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath GR (6, 1, 11), /* %r11 */ 64cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath GR (7, 1, 10), /* %r10 */ 65cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath GR (8, 1, 9), /* %r9 */ 66cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath GR (9, 1, 8), /* %r8 */ 67cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath GR (10,1, 0), /* %rax */ 68cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath GR (11,1, 2), /* %rcx */ 69cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath GR (12,1, 1), /* %rdx */ 70cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath GR (13,2, 4), /* %rsi-%rdi */ 71cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath /* 15,1, orig_rax */ 72cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath GR (16,1, 16), /* %rip */ 73cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath SR (17,1, 51), /* %cs */ 74cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath GR (18,1, 49), /* %rFLAGS */ 75cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath GR (19,1, 7), /* %rsp */ 76cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath SR (20,1, 52), /* %ss */ 77cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath GR (21,2, 58), /* %fs.base-%gs.base */ 78cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath SR (23,1, 53), /* %ds */ 79cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath SR (24,1, 50), /* %es */ 80cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath SR (25,2, 54), /* %fs-%gs */ 81cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath 82cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath#undef GR 83cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath#undef SR 84b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper }; 85cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath#define PRSTATUS_REGS_SIZE (27 * 8) 86cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath 8728ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu#if BITS == 32 8828ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define ULONG uint32_t 8928ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define ALIGN_ULONG 4 9028ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define TYPE_ULONG ELF_T_WORD 9128ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define PRPSINFO_UID_T uint16_t 9228ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define ALIGN_PRPSINFO_UID_T 2 9328ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define TYPE_PRPSINFO_UID_T ELF_T_HALF 9428ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define PRPSINFO_GID_T uint16_t 9528ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define ALIGN_PRPSINFO_GID_T 2 9628ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define TYPE_PRPSINFO_GID_T ELF_T_HALF 9728ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu#else 9828ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define ULONG uint64_t 9928ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define ALIGN_ULONG 8 10028ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define TYPE_ULONG ELF_T_XWORD 10128ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define PRPSINFO_UID_T uint32_t 10228ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define ALIGN_PRPSINFO_UID_T 4 10328ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define TYPE_PRPSINFO_UID_T TYPE_UID_T 10428ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define PRPSINFO_GID_T uint32_t 10528ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define ALIGN_PRPSINFO_GID_T 4 10628ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu# define TYPE_PRPSINFO_GID_T TYPE_GID_T 10728ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu#endif 10828ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu#define PR_REG uint64_t 10928ce4e89d34a5cdb6265cf477e535326271f9abeH.J. Lu#define ALIGN_PR_REG 8 110cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath#define PID_T int32_t 111cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath#define UID_T uint32_t 112cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath#define GID_T uint32_t 113cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath#define ALIGN_PID_T 4 114cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath#define ALIGN_UID_T 4 115cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath#define ALIGN_GID_T 4 116cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath#define TYPE_PID_T ELF_T_SWORD 117cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath#define TYPE_UID_T ELF_T_SWORD 118cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath#define TYPE_GID_T ELF_T_SWORD 119cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath 120cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath#define PRSTATUS_REGSET_ITEMS \ 121cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath { \ 122cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath .name = "orig_rax", .type = ELF_T_SXWORD, .format = 'd', \ 123cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath .offset = offsetof (struct EBLHOOK(prstatus), pr_reg) + (8 * 15), \ 124cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath .group = "register" \ 125cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath } 126cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath 127cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrathstatic const Ebl_Register_Location fpregset_regs[] = 128b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper { 129cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath { .offset = 0, .regno = 65, .count = 2, .bits = 16 }, /* fcw-fsw */ 130cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath { .offset = 24, .regno = 64, .count = 1, .bits = 32 }, /* mxcsr */ 131cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath { .offset = 32, .regno = 33, .count = 8, .bits = 80, .pad = 6 }, /* stN */ 132cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath { .offset = 32 + 128, .regno = 17, .count = 16, .bits = 128 }, /* xmm */ 133b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper }; 134cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath#define FPREGSET_SIZE 512 135b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper 136a845f68bf43f90e0670ed6b33154f2aff98ad46bRoland McGrath#define EXTRA_NOTES EXTRA_NOTES_IOPERM 137a845f68bf43f90e0670ed6b33154f2aff98ad46bRoland McGrath 138a845f68bf43f90e0670ed6b33154f2aff98ad46bRoland McGrath#include "x86_corenote.c" 139cb6d865011ad98a8ac2018f072f396a2268739caRoland McGrath#include "linux-core-note.c" 140