diff options
author | Juro Bystricky <juro.bystricky@intel.com> | 2018-03-01 10:32:43 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-03-14 07:55:54 -0700 |
commit | 1d3634423ccc69e06587ca7d06a2408d652df151 (patch) | |
tree | 0ee7ba98aeb83f057553c4889266793570409c37 /meta/recipes-devtools/gcc/gcc-6.4/backport/0001-i386-Move-struct-ix86_frame-to-machine_function.patch | |
parent | 12b68d0fc72d7ced68ef9b181adcb844457d94be (diff) | |
download | poky-1d3634423ccc69e06587ca7d06a2408d652df151.tar.gz |
gcc6: Backport few more patches
Backported series of patches from https://github.com/hjl-tools/gcc.git
branch /hjl/indirect/gcc-6-branch/master which contains
an IA patch series for security related issues
(From OE-Core rev: 155936a8e5d29d26ef80333920a056f7c3211657)
Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-6.4/backport/0001-i386-Move-struct-ix86_frame-to-machine_function.patch')
-rw-r--r-- | meta/recipes-devtools/gcc/gcc-6.4/backport/0001-i386-Move-struct-ix86_frame-to-machine_function.patch | 247 |
1 files changed, 247 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-6.4/backport/0001-i386-Move-struct-ix86_frame-to-machine_function.patch b/meta/recipes-devtools/gcc/gcc-6.4/backport/0001-i386-Move-struct-ix86_frame-to-machine_function.patch new file mode 100644 index 0000000000..00b0ffd156 --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc-6.4/backport/0001-i386-Move-struct-ix86_frame-to-machine_function.patch | |||
@@ -0,0 +1,247 @@ | |||
1 | From c2c7775c5587dc59b6756162d390d89d60971a16 Mon Sep 17 00:00:00 2001 | ||
2 | From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4> | ||
3 | Date: Mon, 15 Jan 2018 11:27:24 +0000 | ||
4 | Subject: [PATCH 01/12] i386: Move struct ix86_frame to machine_function | ||
5 | |||
6 | Make ix86_frame available to i386 code generation. This is needed to | ||
7 | backport the patch set of -mindirect-branch= to mitigate variant #2 of | ||
8 | the speculative execution vulnerabilities on x86 processors identified | ||
9 | by CVE-2017-5715, aka Spectre. | ||
10 | |||
11 | Backport from mainline | ||
12 | 2017-06-01 Bernd Edlinger <bernd.edlinger@hotmail.de> | ||
13 | |||
14 | * config/i386/i386.c (ix86_frame): Moved to ... | ||
15 | * config/i386/i386.h (ix86_frame): Here. | ||
16 | (machine_function): Add frame. | ||
17 | * config/i386/i386.c (ix86_compute_frame_layout): Repace the | ||
18 | frame argument with &cfun->machine->frame. | ||
19 | (ix86_can_use_return_insn_p): Don't pass &frame to | ||
20 | ix86_compute_frame_layout. Copy frame from cfun->machine->frame. | ||
21 | (ix86_can_eliminate): Likewise. | ||
22 | (ix86_expand_prologue): Likewise. | ||
23 | (ix86_expand_epilogue): Likewise. | ||
24 | (ix86_expand_split_stack_prologue): Likewise. | ||
25 | |||
26 | |||
27 | Upstream-Status: Pending | ||
28 | |||
29 | Signed-off-by: Juro Bystricky <juro.bystricky@intel.com> | ||
30 | |||
31 | --- | ||
32 | gcc/config/i386/i386.c | 68 ++++++++++---------------------------------------- | ||
33 | gcc/config/i386/i386.h | 53 ++++++++++++++++++++++++++++++++++++++- | ||
34 | 2 files changed, 65 insertions(+), 56 deletions(-) | ||
35 | |||
36 | diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c | ||
37 | index 8b5faac..a1ff32b 100644 | ||
38 | --- a/gcc/config/i386/i386.c | ||
39 | +++ b/gcc/config/i386/i386.c | ||
40 | @@ -2434,53 +2434,6 @@ struct GTY(()) stack_local_entry { | ||
41 | struct stack_local_entry *next; | ||
42 | }; | ||
43 | |||
44 | -/* Structure describing stack frame layout. | ||
45 | - Stack grows downward: | ||
46 | - | ||
47 | - [arguments] | ||
48 | - <- ARG_POINTER | ||
49 | - saved pc | ||
50 | - | ||
51 | - saved static chain if ix86_static_chain_on_stack | ||
52 | - | ||
53 | - saved frame pointer if frame_pointer_needed | ||
54 | - <- HARD_FRAME_POINTER | ||
55 | - [saved regs] | ||
56 | - <- regs_save_offset | ||
57 | - [padding0] | ||
58 | - | ||
59 | - [saved SSE regs] | ||
60 | - <- sse_regs_save_offset | ||
61 | - [padding1] | | ||
62 | - | <- FRAME_POINTER | ||
63 | - [va_arg registers] | | ||
64 | - | | ||
65 | - [frame] | | ||
66 | - | | ||
67 | - [padding2] | = to_allocate | ||
68 | - <- STACK_POINTER | ||
69 | - */ | ||
70 | -struct ix86_frame | ||
71 | -{ | ||
72 | - int nsseregs; | ||
73 | - int nregs; | ||
74 | - int va_arg_size; | ||
75 | - int red_zone_size; | ||
76 | - int outgoing_arguments_size; | ||
77 | - | ||
78 | - /* The offsets relative to ARG_POINTER. */ | ||
79 | - HOST_WIDE_INT frame_pointer_offset; | ||
80 | - HOST_WIDE_INT hard_frame_pointer_offset; | ||
81 | - HOST_WIDE_INT stack_pointer_offset; | ||
82 | - HOST_WIDE_INT hfp_save_offset; | ||
83 | - HOST_WIDE_INT reg_save_offset; | ||
84 | - HOST_WIDE_INT sse_reg_save_offset; | ||
85 | - | ||
86 | - /* When save_regs_using_mov is set, emit prologue using | ||
87 | - move instead of push instructions. */ | ||
88 | - bool save_regs_using_mov; | ||
89 | -}; | ||
90 | - | ||
91 | /* Which cpu are we scheduling for. */ | ||
92 | enum attr_cpu ix86_schedule; | ||
93 | |||
94 | @@ -2572,7 +2525,7 @@ static unsigned int ix86_function_arg_boundary (machine_mode, | ||
95 | const_tree); | ||
96 | static rtx ix86_static_chain (const_tree, bool); | ||
97 | static int ix86_function_regparm (const_tree, const_tree); | ||
98 | -static void ix86_compute_frame_layout (struct ix86_frame *); | ||
99 | +static void ix86_compute_frame_layout (void); | ||
100 | static bool ix86_expand_vector_init_one_nonzero (bool, machine_mode, | ||
101 | rtx, rtx, int); | ||
102 | static void ix86_add_new_builtins (HOST_WIDE_INT); | ||
103 | @@ -10944,7 +10897,8 @@ ix86_can_use_return_insn_p (void) | ||
104 | if (crtl->args.pops_args && crtl->args.size >= 32768) | ||
105 | return 0; | ||
106 | |||
107 | - ix86_compute_frame_layout (&frame); | ||
108 | + ix86_compute_frame_layout (); | ||
109 | + frame = cfun->machine->frame; | ||
110 | return (frame.stack_pointer_offset == UNITS_PER_WORD | ||
111 | && (frame.nregs + frame.nsseregs) == 0); | ||
112 | } | ||
113 | @@ -11355,8 +11309,8 @@ ix86_can_eliminate (const int from, const int to) | ||
114 | HOST_WIDE_INT | ||
115 | ix86_initial_elimination_offset (int from, int to) | ||
116 | { | ||
117 | - struct ix86_frame frame; | ||
118 | - ix86_compute_frame_layout (&frame); | ||
119 | + ix86_compute_frame_layout (); | ||
120 | + struct ix86_frame frame = cfun->machine->frame; | ||
121 | |||
122 | if (from == ARG_POINTER_REGNUM && to == HARD_FRAME_POINTER_REGNUM) | ||
123 | return frame.hard_frame_pointer_offset; | ||
124 | @@ -11395,8 +11349,9 @@ ix86_builtin_setjmp_frame_value (void) | ||
125 | /* Fill structure ix86_frame about frame of currently computed function. */ | ||
126 | |||
127 | static void | ||
128 | -ix86_compute_frame_layout (struct ix86_frame *frame) | ||
129 | +ix86_compute_frame_layout (void) | ||
130 | { | ||
131 | + struct ix86_frame *frame = &cfun->machine->frame; | ||
132 | unsigned HOST_WIDE_INT stack_alignment_needed; | ||
133 | HOST_WIDE_INT offset; | ||
134 | unsigned HOST_WIDE_INT preferred_alignment; | ||
135 | @@ -12702,7 +12657,8 @@ ix86_expand_prologue (void) | ||
136 | m->fs.sp_offset = INCOMING_FRAME_SP_OFFSET; | ||
137 | m->fs.sp_valid = true; | ||
138 | |||
139 | - ix86_compute_frame_layout (&frame); | ||
140 | + ix86_compute_frame_layout (); | ||
141 | + frame = m->frame; | ||
142 | |||
143 | if (!TARGET_64BIT && ix86_function_ms_hook_prologue (current_function_decl)) | ||
144 | { | ||
145 | @@ -13379,7 +13335,8 @@ ix86_expand_epilogue (int style) | ||
146 | bool using_drap; | ||
147 | |||
148 | ix86_finalize_stack_realign_flags (); | ||
149 | - ix86_compute_frame_layout (&frame); | ||
150 | + ix86_compute_frame_layout (); | ||
151 | + frame = m->frame; | ||
152 | |||
153 | m->fs.sp_valid = (!frame_pointer_needed | ||
154 | || (crtl->sp_is_unchanging | ||
155 | @@ -13876,7 +13833,8 @@ ix86_expand_split_stack_prologue (void) | ||
156 | gcc_assert (flag_split_stack && reload_completed); | ||
157 | |||
158 | ix86_finalize_stack_realign_flags (); | ||
159 | - ix86_compute_frame_layout (&frame); | ||
160 | + ix86_compute_frame_layout (); | ||
161 | + frame = cfun->machine->frame; | ||
162 | allocate = frame.stack_pointer_offset - INCOMING_FRAME_SP_OFFSET; | ||
163 | |||
164 | /* This is the label we will branch to if we have enough stack | ||
165 | diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h | ||
166 | index 8113f83..5414416 100644 | ||
167 | --- a/gcc/config/i386/i386.h | ||
168 | +++ b/gcc/config/i386/i386.h | ||
169 | @@ -2427,9 +2427,56 @@ enum avx_u128_state | ||
170 | |||
171 | #define FASTCALL_PREFIX '@' | ||
172 | |||
173 | +#ifndef USED_FOR_TARGET | ||
174 | +/* Structure describing stack frame layout. | ||
175 | + Stack grows downward: | ||
176 | + | ||
177 | + [arguments] | ||
178 | + <- ARG_POINTER | ||
179 | + saved pc | ||
180 | + | ||
181 | + saved static chain if ix86_static_chain_on_stack | ||
182 | + | ||
183 | + saved frame pointer if frame_pointer_needed | ||
184 | + <- HARD_FRAME_POINTER | ||
185 | + [saved regs] | ||
186 | + <- regs_save_offset | ||
187 | + [padding0] | ||
188 | + | ||
189 | + [saved SSE regs] | ||
190 | + <- sse_regs_save_offset | ||
191 | + [padding1] | | ||
192 | + | <- FRAME_POINTER | ||
193 | + [va_arg registers] | | ||
194 | + | | ||
195 | + [frame] | | ||
196 | + | | ||
197 | + [padding2] | = to_allocate | ||
198 | + <- STACK_POINTER | ||
199 | + */ | ||
200 | +struct GTY(()) ix86_frame | ||
201 | +{ | ||
202 | + int nsseregs; | ||
203 | + int nregs; | ||
204 | + int va_arg_size; | ||
205 | + int red_zone_size; | ||
206 | + int outgoing_arguments_size; | ||
207 | + | ||
208 | + /* The offsets relative to ARG_POINTER. */ | ||
209 | + HOST_WIDE_INT frame_pointer_offset; | ||
210 | + HOST_WIDE_INT hard_frame_pointer_offset; | ||
211 | + HOST_WIDE_INT stack_pointer_offset; | ||
212 | + HOST_WIDE_INT hfp_save_offset; | ||
213 | + HOST_WIDE_INT reg_save_offset; | ||
214 | + HOST_WIDE_INT sse_reg_save_offset; | ||
215 | + | ||
216 | + /* When save_regs_using_mov is set, emit prologue using | ||
217 | + move instead of push instructions. */ | ||
218 | + bool save_regs_using_mov; | ||
219 | +}; | ||
220 | + | ||
221 | /* Machine specific frame tracking during prologue/epilogue generation. */ | ||
222 | |||
223 | -#ifndef USED_FOR_TARGET | ||
224 | struct GTY(()) machine_frame_state | ||
225 | { | ||
226 | /* This pair tracks the currently active CFA as reg+offset. When reg | ||
227 | @@ -2475,6 +2522,9 @@ struct GTY(()) machine_function { | ||
228 | int varargs_fpr_size; | ||
229 | int optimize_mode_switching[MAX_386_ENTITIES]; | ||
230 | |||
231 | + /* Cached initial frame layout for the current function. */ | ||
232 | + struct ix86_frame frame; | ||
233 | + | ||
234 | /* Number of saved registers USE_FAST_PROLOGUE_EPILOGUE | ||
235 | has been computed for. */ | ||
236 | int use_fast_prologue_epilogue_nregs; | ||
237 | @@ -2554,6 +2604,7 @@ struct GTY(()) machine_function { | ||
238 | #define ix86_current_function_calls_tls_descriptor \ | ||
239 | (ix86_tls_descriptor_calls_expanded_in_cfun && df_regs_ever_live_p (SP_REG)) | ||
240 | #define ix86_static_chain_on_stack (cfun->machine->static_chain_on_stack) | ||
241 | +#define ix86_red_zone_size (cfun->machine->frame.red_zone_size) | ||
242 | |||
243 | /* Control behavior of x86_file_start. */ | ||
244 | #define X86_FILE_START_VERSION_DIRECTIVE false | ||
245 | -- | ||
246 | 2.7.4 | ||
247 | |||