Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/trusted/validator_arm/baseline_classes.cc

Issue 11569019: Fix uses in ARM table media_instructions. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 #include "native_client/src/trusted/validator_arm/baseline_classes.h" 7 #include "native_client/src/trusted/validator_arm/baseline_classes.h"
8 8
9 #include <assert.h> 9 #include <assert.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 181
182 RegisterList Unary1RegisterImmediateOpPc::defs(Instruction i) const { 182 RegisterList Unary1RegisterImmediateOpPc::defs(Instruction i) const {
183 return RegisterList(d.reg(i)); 183 return RegisterList(d.reg(i));
184 } 184 }
185 185
186 RegisterList Unary1RegisterImmediateOpPc::uses(Instruction i) const { 186 RegisterList Unary1RegisterImmediateOpPc::uses(Instruction i) const {
187 UNREFERENCED_PARAMETER(i); 187 UNREFERENCED_PARAMETER(i);
188 return RegisterList(Register::Pc()); 188 return RegisterList(Register::Pc());
189 } 189 }
190 190
191 // Unary1RegisterBitRangeMsbGeLsb
192 SafetyLevel Unary1RegisterBitRangeMsbGeLsb::safety(Instruction i) const {
193 if (d.reg(i).Equals(Register::Pc()) ||
194 msb.value(i) < lsb.value(i))
195 return UNPREDICTABLE;
196
197 // Note: We would restrict out PC as well for Rd in NaCl, but no need
198 // since the ARM restriction doesn't allow it anyway.
199 return MAY_BE_SAFE;
200 }
201
202 RegisterList Unary1RegisterBitRangeMsbGeLsb::defs(Instruction i) const {
203 return RegisterList(d.reg(i));
204 }
205
206 RegisterList Unary1RegisterBitRangeMsbGeLsb::uses(Instruction i) const {
207 return RegisterList(d.reg(i));
208 }
209
191 // Binary2RegisterBitRangeMsbGeLsb 210 // Binary2RegisterBitRangeMsbGeLsb
192 SafetyLevel Binary2RegisterBitRangeMsbGeLsb::safety(Instruction i) const { 211 SafetyLevel Binary2RegisterBitRangeMsbGeLsb::safety(Instruction i) const {
193 return (d.reg(i).Equals(Register::Pc()) || 212 return (d.reg(i).Equals(Register::Pc()) ||
194 (msb.value(i) < lsb.value(i))) 213 (msb.value(i) < lsb.value(i)))
195 ? UNPREDICTABLE 214 ? UNPREDICTABLE
196 : MAY_BE_SAFE; 215 : MAY_BE_SAFE;
197 } 216 }
198 217
199 RegisterList Binary2RegisterBitRangeMsbGeLsb::defs(Instruction i) const { 218 RegisterList Binary2RegisterBitRangeMsbGeLsb::defs(Instruction i) const {
200 return RegisterList(d.reg(i)); 219 return RegisterList(d.reg(i));
201 } 220 }
202 221
222 RegisterList Binary2RegisterBitRangeMsbGeLsb::uses(Instruction i) const {
223 return RegisterList(n.reg(i)).Add(d.reg(i));
224 }
225
203 // Binary2RegisterBitRangeNotRnIsPcBitfieldExtract 226 // Binary2RegisterBitRangeNotRnIsPcBitfieldExtract
204 SafetyLevel Binary2RegisterBitRangeNotRnIsPcBitfieldExtract 227 SafetyLevel Binary2RegisterBitRangeNotRnIsPcBitfieldExtract
205 ::safety(Instruction i) const { 228 ::safety(Instruction i) const {
206 return (RegisterList(d.reg(i)).Add(n.reg(i)).Contains(Register::Pc()) || 229 return (RegisterList(d.reg(i)).Add(n.reg(i)).Contains(Register::Pc()) ||
207 (lsb.value(i) + widthm1.value(i) > 31)) 230 (lsb.value(i) + widthm1.value(i) > 31))
208 ? UNPREDICTABLE 231 ? UNPREDICTABLE
209 : MAY_BE_SAFE; 232 : MAY_BE_SAFE;
210 } 233 }
211 234
212 RegisterList Binary2RegisterBitRangeNotRnIsPcBitfieldExtract 235 RegisterList Binary2RegisterBitRangeNotRnIsPcBitfieldExtract
213 ::defs(Instruction i) const { 236 ::defs(Instruction i) const {
214 return RegisterList(d.reg(i)); 237 return RegisterList(d.reg(i));
215 } 238 }
216 239
240 RegisterList Binary2RegisterBitRangeNotRnIsPcBitfieldExtract
241 ::uses(Instruction i) const {
242 return RegisterList(n.reg(i));
243 }
244
217 // Binary2RegisterImmediateOp 245 // Binary2RegisterImmediateOp
218 SafetyLevel Binary2RegisterImmediateOp::safety(Instruction i) const { 246 SafetyLevel Binary2RegisterImmediateOp::safety(Instruction i) const {
219 if (d.reg(i).Equals(Register::Pc())) { 247 if (d.reg(i).Equals(Register::Pc())) {
220 if (conditions.is_updated(i)) return DECODER_ERROR; 248 if (conditions.is_updated(i)) return DECODER_ERROR;
221 // NaCl Constraint. 249 // NaCl Constraint.
222 return FORBIDDEN_OPERANDS; 250 return FORBIDDEN_OPERANDS;
223 } 251 }
224 return MAY_BE_SAFE; 252 return MAY_BE_SAFE;
225 } 253 }
226 254
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } 368 }
341 369
342 // Binary3RegisterOpAltA 370 // Binary3RegisterOpAltA
343 SafetyLevel Binary3RegisterOpAltA::safety(Instruction i) const { 371 SafetyLevel Binary3RegisterOpAltA::safety(Instruction i) const {
344 // Unsafe if any register contains PC (ARM restriction). 372 // Unsafe if any register contains PC (ARM restriction).
345 if (RegisterList(d.reg(i)).Add(m.reg(i)).Add(n.reg(i)). 373 if (RegisterList(d.reg(i)).Add(m.reg(i)).Add(n.reg(i)).
346 Contains(Register::Pc())) { 374 Contains(Register::Pc())) {
347 return UNPREDICTABLE; 375 return UNPREDICTABLE;
348 } 376 }
349 377
378 // TODO(karl): This doesn't apply to all uses in rows in armv7.table.
379 // However, it doesn't really matter since we only accept version 7.
350 if ((ArchVersion() < 6) && m.reg(i).Equals(n.reg(i))) return UNPREDICTABLE; 380 if ((ArchVersion() < 6) && m.reg(i).Equals(n.reg(i))) return UNPREDICTABLE;
351 381
352 // Note: We would restrict out PC as well for Rd in NaCl, but no need 382 // Note: We would restrict out PC as well for Rd in NaCl, but no need
353 // since the ARM restriction doesn't allow it anyway. 383 // since the ARM restriction doesn't allow it anyway.
354 return MAY_BE_SAFE; 384 return MAY_BE_SAFE;
355 } 385 }
356 386
357 RegisterList Binary3RegisterOpAltA::defs(Instruction i) const { 387 RegisterList Binary3RegisterOpAltA::defs(Instruction i) const {
358 return RegisterList(d.reg(i)).Add(conditions.conds_if_updated(i)); 388 return RegisterList(d.reg(i)).Add(conditions.conds_if_updated(i));
359 } 389 }
(...skipping 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 } 2160 }
2131 2161
2132 // InstructionBarrier 2162 // InstructionBarrier
2133 SafetyLevel InstructionBarrier::safety(Instruction i) const { 2163 SafetyLevel InstructionBarrier::safety(Instruction i) const {
2134 if (option.value(i) != 0xF) 2164 if (option.value(i) != 0xF)
2135 return FORBIDDEN_OPERANDS; 2165 return FORBIDDEN_OPERANDS;
2136 return UncondDecoder::safety(i); 2166 return UncondDecoder::safety(i);
2137 } 2167 }
2138 2168
2139 } // namespace nacl_arm_dec 2169 } // namespace nacl_arm_dec
OLDNEW
« no previous file with comments | « src/trusted/validator_arm/baseline_classes.h ('k') | src/trusted/validator_arm/gen/arm32_decode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698