blob: 1bacc60f5c294f20fb57c80803b9de4ab851eb68 [file] [log] [blame]
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00001/* x86-64 specific core note handling.
Roland McGratha845f682008-12-03 03:41:58 +00002 Copyright (C) 2005, 2007, 2008 Red Hat, Inc.
H.J. Lu28ce4e82015-03-12 14:51:42 -07003 Copyright (C) H.J. Lu <hjl.tools@gmail.com>, 2015.
Mark Wielaardde2ed972012-06-05 17:15:16 +02004 This file is part of elfutils.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00005
Mark Wielaardde2ed972012-06-05 17:15:16 +02006 This file is free software; you can redistribute it and/or modify
7 it under the terms of either
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00008
Mark Wielaardde2ed972012-06-05 17:15:16 +02009 * the GNU Lesser General Public License as published by the Free
10 Software Foundation; either version 3 of the License, or (at
11 your option) any later version
12
13 or
14
15 * the GNU General Public License as published by the Free
16 Software Foundation; either version 2 of the License, or (at
17 your option) any later version
18
19 or both in parallel, as here.
20
21 elfutils is distributed in the hope that it will be useful, but
Ulrich Drepper361df7d2006-04-04 21:38:57 +000022 WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 General Public License for more details.
25
Mark Wielaardde2ed972012-06-05 17:15:16 +020026 You should have received copies of the GNU General Public License and
27 the GNU Lesser General Public License along with this program. If
28 not, see <http://www.gnu.org/licenses/>. */
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000029
30#ifdef HAVE_CONFIG_H
31# include <config.h>
32#endif
33
34#include <elf.h>
35#include <inttypes.h>
36#include <stddef.h>
37#include <stdio.h>
38#include <sys/time.h>
39
H.J. Lu28ce4e82015-03-12 14:51:42 -070040#ifndef BITS
41# define BITS 64
42# define BACKEND x86_64_
43#else
44# define BITS 32
45# define BACKEND x32_
46#endif
Roland McGrathcd60ea82005-11-16 01:57:40 +000047#include "libebl_CPU.h"
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000048
49
Roland McGrathcb6d8652007-08-23 08:10:54 +000050static const Ebl_Register_Location prstatus_regs[] =
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000051 {
Roland McGrathcb6d8652007-08-23 08:10:54 +000052#define GR(at, n, dwreg) \
53 { .offset = at * 8, .regno = dwreg, .count = n, .bits = 64 }
54#define SR(at, n, dwreg) \
55 { .offset = at * 8, .regno = dwreg, .count = n, .bits = 16, .pad = 6 }
56
57 GR (0, 1, 15), /* %r15 */
58 GR (1, 1, 14), /* %r14 */
59 GR (2, 1, 13), /* %r13 */
60 GR (3, 1, 12), /* %r12 */
61 GR (4, 1, 6), /* %rbp */
62 GR (5, 1, 3), /* %rbx */
63 GR (6, 1, 11), /* %r11 */
64 GR (7, 1, 10), /* %r10 */
65 GR (8, 1, 9), /* %r9 */
66 GR (9, 1, 8), /* %r8 */
67 GR (10,1, 0), /* %rax */
68 GR (11,1, 2), /* %rcx */
69 GR (12,1, 1), /* %rdx */
70 GR (13,2, 4), /* %rsi-%rdi */
71 /* 15,1, orig_rax */
72 GR (16,1, 16), /* %rip */
73 SR (17,1, 51), /* %cs */
74 GR (18,1, 49), /* %rFLAGS */
75 GR (19,1, 7), /* %rsp */
76 SR (20,1, 52), /* %ss */
77 GR (21,2, 58), /* %fs.base-%gs.base */
78 SR (23,1, 53), /* %ds */
79 SR (24,1, 50), /* %es */
80 SR (25,2, 54), /* %fs-%gs */
81
82#undef GR
83#undef SR
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000084 };
Roland McGrathcb6d8652007-08-23 08:10:54 +000085#define PRSTATUS_REGS_SIZE (27 * 8)
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000086
H.J. Lu28ce4e82015-03-12 14:51:42 -070087#if BITS == 32
88# define ULONG uint32_t
89# define ALIGN_ULONG 4
90# define TYPE_ULONG ELF_T_WORD
91# define PRPSINFO_UID_T uint16_t
92# define ALIGN_PRPSINFO_UID_T 2
93# define TYPE_PRPSINFO_UID_T ELF_T_HALF
94# define PRPSINFO_GID_T uint16_t
95# define ALIGN_PRPSINFO_GID_T 2
96# define TYPE_PRPSINFO_GID_T ELF_T_HALF
97#else
98# define ULONG uint64_t
99# define ALIGN_ULONG 8
100# define TYPE_ULONG ELF_T_XWORD
101# define PRPSINFO_UID_T uint32_t
102# define ALIGN_PRPSINFO_UID_T 4
103# define TYPE_PRPSINFO_UID_T TYPE_UID_T
104# define PRPSINFO_GID_T uint32_t
105# define ALIGN_PRPSINFO_GID_T 4
106# define TYPE_PRPSINFO_GID_T TYPE_GID_T
107#endif
108#define PR_REG uint64_t
109#define ALIGN_PR_REG 8
Roland McGrathcb6d8652007-08-23 08:10:54 +0000110#define PID_T int32_t
111#define UID_T uint32_t
112#define GID_T uint32_t
Roland McGrathcb6d8652007-08-23 08:10:54 +0000113#define ALIGN_PID_T 4
114#define ALIGN_UID_T 4
115#define ALIGN_GID_T 4
Roland McGrathcb6d8652007-08-23 08:10:54 +0000116#define TYPE_PID_T ELF_T_SWORD
117#define TYPE_UID_T ELF_T_SWORD
118#define TYPE_GID_T ELF_T_SWORD
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000119
Roland McGrathcb6d8652007-08-23 08:10:54 +0000120#define PRSTATUS_REGSET_ITEMS \
121 { \
122 .name = "orig_rax", .type = ELF_T_SXWORD, .format = 'd', \
123 .offset = offsetof (struct EBLHOOK(prstatus), pr_reg) + (8 * 15), \
124 .group = "register" \
125 }
126
127static const Ebl_Register_Location fpregset_regs[] =
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000128 {
Roland McGrathcb6d8652007-08-23 08:10:54 +0000129 { .offset = 0, .regno = 65, .count = 2, .bits = 16 }, /* fcw-fsw */
130 { .offset = 24, .regno = 64, .count = 1, .bits = 32 }, /* mxcsr */
131 { .offset = 32, .regno = 33, .count = 8, .bits = 80, .pad = 6 }, /* stN */
132 { .offset = 32 + 128, .regno = 17, .count = 16, .bits = 128 }, /* xmm */
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000133 };
Roland McGrathcb6d8652007-08-23 08:10:54 +0000134#define FPREGSET_SIZE 512
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000135
Roland McGratha845f682008-12-03 03:41:58 +0000136#define EXTRA_NOTES EXTRA_NOTES_IOPERM
137
138#include "x86_corenote.c"
Roland McGrathcb6d8652007-08-23 08:10:54 +0000139#include "linux-core-note.c"