1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
19using tracegen::TestTraceContainer;
27TEST(AddressingConstrainingTest, EmptyRow)
36TEST(AddressingConstrainingTest, BaseAddressGating)
39 TestTraceContainer
trace({ {
42 { C::execution_sel_bytecode_retrieval_success, 1 },
43 { C::execution_sel_instruction_fetching_success, 1 },
50 { C::execution_sel_op_is_address_0_, 1 },
51 { C::execution_sel_op_is_address_1_, 1 },
52 { C::execution_sel_op_is_address_2_, 1 },
53 { C::execution_sel_op_is_address_3_, 1 },
54 { C::execution_sel_op_is_address_4_, 0 },
55 { C::execution_sel_op_is_address_5_, 0 },
56 { C::execution_sel_op_is_address_6_, 0 },
58 { C::execution_sel_op_is_relative_wire_0_, 1 },
59 { C::execution_sel_op_is_relative_wire_1_, 0 },
60 { C::execution_sel_op_is_relative_wire_2_, 1 },
61 { C::execution_sel_op_is_relative_wire_3_, 0 },
62 { C::execution_sel_op_is_relative_wire_4_, 1 },
63 { C::execution_sel_op_is_relative_wire_5_, 0 },
64 { C::execution_sel_op_is_relative_wire_6_, 0 },
66 { C::execution_sel_op_is_relative_effective_0_, 1 },
67 { C::execution_sel_op_is_relative_effective_1_, 0 },
68 { C::execution_sel_op_is_relative_effective_2_, 1 },
69 { C::execution_sel_op_is_relative_effective_3_, 0 },
70 { C::execution_sel_op_is_relative_effective_4_, 0 },
71 { C::execution_sel_op_is_relative_effective_5_, 0 },
72 { C::execution_sel_op_is_relative_effective_6_, 0 },
74 { C::execution_sel_do_base_check, 0 },
77 "NUM_RELATIVE_INV_CHECK");
80 trace.
set(C::execution_num_relative_operands_inv, 0,
FF(2).invert());
82 "NUM_RELATIVE_INV_CHECK");
85 trace.
set(C::execution_sel_do_base_check, 0, 1);
89TEST(AddressingConstrainingTest, BaseAddressTagIsU32)
92 FF base_address_tag_diff_inv = 0;
94 TestTraceContainer
trace({
96 { C::execution_base_address_tag, base_address_tag },
97 { C::execution_base_address_tag_diff_inv, base_address_tag_diff_inv },
98 { C::execution_sel_base_address_failure, 0 },
101 { C::execution_sel_bytecode_retrieval_success, 1 },
102 { C::execution_sel_instruction_fetching_success, 1 },
103 { C::execution_sel_do_base_check, 1 },
110 trace.
set(C::execution_sel_base_address_failure, 0, 1);
112 "BASE_ADDRESS_CHECK");
117 { C::execution_base_address_tag_diff_inv, 44 },
118 { C::execution_sel_base_address_failure, 0 },
123TEST(AddressingConstrainingTest, BaseAddressTagIsNotU32)
125 FF base_address_tag = 1234567;
127 FF base_address_tag_diff_inv =
FF(base_address_tag - u32_tag).invert();
129 TestTraceContainer
trace({
131 { C::execution_base_address_tag, base_address_tag },
132 { C::execution_base_address_tag_diff_inv, base_address_tag_diff_inv },
133 { C::execution_sel_base_address_failure, 1 },
136 { C::execution_sel_bytecode_retrieval_success, 1 },
137 { C::execution_sel_instruction_fetching_success, 1 },
138 { C::execution_sel_do_base_check, 1 },
145 trace.
set(C::execution_sel_base_address_failure, 0, 0);
147 "BASE_ADDRESS_CHECK");
152 { C::execution_base_address_tag_diff_inv, 0 },
153 { C::execution_sel_base_address_failure, 0 },
156 "BASE_ADDRESS_CHECK");
159TEST(AddressingConstrainingTest, BaseAddressTagNoCheckImpliesNoError)
161 FF base_address_tag = 1234567;
163 FF base_address_tag_diff_inv =
FF(base_address_tag - u32_tag).invert();
165 TestTraceContainer
trace({
167 { C::execution_base_address_tag, base_address_tag },
168 { C::execution_base_address_tag_diff_inv, base_address_tag_diff_inv },
169 { C::execution_sel_base_address_failure, 0 },
172 { C::execution_sel_bytecode_retrieval_success, 1 },
173 { C::execution_sel_instruction_fetching_success, 1 },
174 { C::execution_sel_do_base_check, 0 },
181 trace.
set(C::execution_sel_base_address_failure, 0, 1);
183 "BASE_ADDRESS_CHECK");
190 { C::execution_sel_bytecode_retrieval_success, 0 },
191 { C::execution_sel_instruction_fetching_success, 0 },
193 { C::execution_sel_do_base_check, 1 },
202TEST(AddressingConstrainingTest, RelativeAddressPropagation)
204 FF base_address_val = 100;
206 TestTraceContainer
trace({
208 { C::execution_base_address_val, base_address_val },
209 { C::execution_sel_base_address_failure, 0 },
211 { C::execution_op_0_, 123 },
212 { C::execution_op_1_, 456 },
213 { C::execution_op_2_, 0xFFFFFFFF },
214 { C::execution_op_3_, 101112 },
215 { C::execution_op_4_, 131415 },
216 { C::execution_op_5_, 161718 },
217 { C::execution_op_6_, 192021 },
219 { C::execution_op_after_relative_0_,
FF(123) + base_address_val },
220 { C::execution_op_after_relative_1_, 456 },
221 { C::execution_op_after_relative_2_,
FF(0xFFFFFFFF) + base_address_val },
222 { C::execution_op_after_relative_3_, 101112 },
223 { C::execution_op_after_relative_4_,
FF(131415) + base_address_val },
224 { C::execution_op_after_relative_5_, 161718 },
225 { C::execution_op_after_relative_6_,
FF(192021) + base_address_val },
227 { C::execution_sel_op_is_address_0_, 1 },
228 { C::execution_sel_op_is_address_1_, 1 },
229 { C::execution_sel_op_is_address_2_, 1 },
230 { C::execution_sel_op_is_address_3_, 1 },
231 { C::execution_sel_op_is_address_4_, 1 },
232 { C::execution_sel_op_is_address_5_, 1 },
233 { C::execution_sel_op_is_address_6_, 1 },
235 { C::execution_sel_op_is_relative_effective_0_, 1 },
236 { C::execution_sel_op_is_relative_effective_1_, 0 },
237 { C::execution_sel_op_is_relative_effective_2_, 1 },
238 { C::execution_sel_op_is_relative_effective_3_, 0 },
239 { C::execution_sel_op_is_relative_effective_4_, 1 },
240 { C::execution_sel_op_is_relative_effective_5_, 0 },
241 { C::execution_sel_op_is_relative_effective_6_, 1 },
243 { C::execution_sel_op_is_relative_wire_0_, 1 },
244 { C::execution_sel_op_is_relative_wire_1_, 0 },
245 { C::execution_sel_op_is_relative_wire_2_, 1 },
246 { C::execution_sel_op_is_relative_wire_3_, 0 },
247 { C::execution_sel_op_is_relative_wire_4_, 1 },
248 { C::execution_sel_op_is_relative_wire_5_, 0 },
249 { C::execution_sel_op_is_relative_wire_6_, 1 },
253 check_relation<addressing>(
trace,
265 { C::execution_op_after_relative_0_, 7 },
266 { C::execution_op_after_relative_1_,
FF(456) + base_address_val },
267 { C::execution_op_after_relative_2_, 0xFFFFFFFF },
268 { C::execution_op_after_relative_3_, 7 },
269 { C::execution_op_after_relative_4_, 7 },
270 { C::execution_op_after_relative_5_,
FF(161718) + base_address_val },
271 { C::execution_op_after_relative_6_, 192021 },
274 "RELATIVE_RESOLUTION_0");
276 "RELATIVE_RESOLUTION_1");
278 "RELATIVE_RESOLUTION_2");
280 "RELATIVE_RESOLUTION_3");
282 "RELATIVE_RESOLUTION_4");
284 "RELATIVE_RESOLUTION_5");
286 "RELATIVE_RESOLUTION_6");
289TEST(AddressingConstrainingTest, RelativeAddressPropagationWhenBaseAddressIsInvalid)
291 FF base_address_val = 0x123456789012345ULL;
293 TestTraceContainer
trace({
295 { C::execution_base_address_val, base_address_val },
296 { C::execution_sel_base_address_failure, 1 },
298 { C::execution_op_0_, 123 },
299 { C::execution_op_1_, 456 },
300 { C::execution_op_2_, 0xFFFFFFFF },
301 { C::execution_op_3_, 101112 },
302 { C::execution_op_4_, 131415 },
303 { C::execution_op_5_, 161718 },
304 { C::execution_op_6_, 192021 },
306 { C::execution_op_after_relative_0_, 123 },
307 { C::execution_op_after_relative_1_, 456 },
308 { C::execution_op_after_relative_2_, 0xFFFFFFFF },
309 { C::execution_op_after_relative_3_, 101112 },
310 { C::execution_op_after_relative_4_, 131415 },
311 { C::execution_op_after_relative_5_, 161718 },
312 { C::execution_op_after_relative_6_, 192021 },
314 { C::execution_sel_op_is_address_0_, 1 },
315 { C::execution_sel_op_is_address_1_, 1 },
316 { C::execution_sel_op_is_address_2_, 1 },
317 { C::execution_sel_op_is_address_3_, 1 },
318 { C::execution_sel_op_is_address_4_, 1 },
319 { C::execution_sel_op_is_address_5_, 1 },
320 { C::execution_sel_op_is_address_6_, 1 },
322 { C::execution_sel_op_is_relative_wire_0_, 1 },
323 { C::execution_sel_op_is_relative_wire_1_, 0 },
324 { C::execution_sel_op_is_relative_wire_2_, 1 },
325 { C::execution_sel_op_is_relative_wire_3_, 0 },
326 { C::execution_sel_op_is_relative_wire_4_, 1 },
327 { C::execution_sel_op_is_relative_wire_5_, 0 },
328 { C::execution_sel_op_is_relative_wire_6_, 1 },
330 { C::execution_sel_bytecode_retrieval_success, 1 },
331 { C::execution_sel_instruction_fetching_success, 1 },
335 check_relation<addressing>(
trace,
345 trace.
set(C::execution_op_after_relative_0_, 0,
FF(123) + base_address_val);
347 "RELATIVE_RESOLUTION_0");
350TEST(AddressingConstrainingTest, RelativeOverflowCheck)
352 FF base_address_val = 100;
353 FF two_to_32 =
FF(1ULL << 32);
355 TestTraceContainer
trace({
358 { C::execution_sel_op_is_relative_effective_0_, 1 },
359 { C::execution_sel_op_is_relative_effective_1_, 0 },
360 { C::execution_sel_op_is_relative_effective_2_, 1 },
361 { C::execution_sel_op_is_relative_effective_3_, 0 },
362 { C::execution_sel_op_is_relative_effective_4_, 1 },
363 { C::execution_sel_op_is_relative_effective_5_, 0 },
364 { C::execution_sel_op_is_relative_effective_6_, 1 },
366 { C::execution_op_after_relative_0_,
FF(123) + base_address_val },
367 { C::execution_op_after_relative_1_, 456 },
368 { C::execution_op_after_relative_2_,
FF(0xFFFFFFFF) + base_address_val },
369 { C::execution_op_after_relative_3_, 101112 },
370 { C::execution_op_after_relative_4_,
FF(131415) + base_address_val },
371 { C::execution_op_after_relative_5_, 161718 },
372 { C::execution_op_after_relative_6_,
FF(192021) + base_address_val },
374 { C::execution_sel_relative_overflow_0_, 0 },
375 { C::execution_sel_relative_overflow_1_, 0 },
376 { C::execution_sel_relative_overflow_2_, 1 },
377 { C::execution_sel_relative_overflow_3_, 0 },
378 { C::execution_sel_relative_overflow_4_, 0 },
379 { C::execution_sel_relative_overflow_5_, 0 },
380 { C::execution_sel_relative_overflow_6_, 0 },
382 { C::execution_overflow_range_check_result_0_, two_to_32 - (
FF(123) + base_address_val) - 1 },
383 { C::execution_overflow_range_check_result_1_, 0 },
384 { C::execution_overflow_range_check_result_2_, (
FF(0xFFFFFFFF) + base_address_val) - two_to_32 },
385 { C::execution_overflow_range_check_result_3_, 0 },
386 { C::execution_overflow_range_check_result_4_, two_to_32 - (
FF(131415) + base_address_val) - 1 },
387 { C::execution_overflow_range_check_result_5_, 0 },
388 { C::execution_overflow_range_check_result_6_, two_to_32 - (
FF(192021) + base_address_val) - 1 },
390 { C::execution_two_to_32, two_to_32 },
394 check_relation<addressing>(
trace,
413 { C::execution_sel_relative_overflow_0_, 1 },
414 { C::execution_sel_relative_overflow_1_, 1 },
415 { C::execution_sel_relative_overflow_2_, 0 },
416 { C::execution_sel_relative_overflow_3_, 1 },
417 { C::execution_sel_relative_overflow_4_, 1 },
418 { C::execution_sel_relative_overflow_5_, 1 },
419 { C::execution_sel_relative_overflow_6_, 1 },
422 "RELATIVE_OVERFLOW_RESULT_0");
424 "NOT_RELATIVE_NO_OVERFLOW_1");
426 "RELATIVE_OVERFLOW_RESULT_2");
428 "NOT_RELATIVE_NO_OVERFLOW_3");
430 "RELATIVE_OVERFLOW_RESULT_4");
432 "NOT_RELATIVE_NO_OVERFLOW_5");
434 "RELATIVE_OVERFLOW_RESULT_6");
441TEST(AddressingConstrainingTest, IndirectReconstruction)
443 TestTraceContainer
trace({
445 { C::execution_indirect, 0b11'00'01'00'01'11'01'01 },
446 { C::execution_sel_op_is_indirect_wire_0_, 1 },
447 { C::execution_sel_op_is_relative_wire_0_, 0 },
448 { C::execution_sel_op_is_indirect_wire_1_, 1 },
449 { C::execution_sel_op_is_relative_wire_1_, 0 },
450 { C::execution_sel_op_is_indirect_wire_2_, 1 },
451 { C::execution_sel_op_is_relative_wire_2_, 1 },
452 { C::execution_sel_op_is_indirect_wire_3_, 1 },
453 { C::execution_sel_op_is_relative_wire_3_, 0 },
454 { C::execution_sel_op_is_indirect_wire_4_, 0 },
455 { C::execution_sel_op_is_relative_wire_4_, 0 },
456 { C::execution_sel_op_is_indirect_wire_5_, 1 },
457 { C::execution_sel_op_is_relative_wire_5_, 0 },
458 { C::execution_sel_op_is_indirect_wire_6_, 0 },
459 { C::execution_sel_op_is_relative_wire_6_, 0 },
460 { C::execution_sel_op_is_relative_wire_7_, 1 },
461 { C::execution_sel_op_is_indirect_wire_7_, 1 },
463 { C::execution_sel_bytecode_retrieval_success, 1 },
464 { C::execution_sel_instruction_fetching_success, 1 },
471TEST(AddressingConstrainingTest, IndirectReconstructionZeroWhenAddressingDisabled)
473 TestTraceContainer
trace({
475 { C::execution_indirect, 123456 },
479 { C::execution_sel_bytecode_retrieval_success, 0 },
480 { C::execution_sel_instruction_fetching_success, 0 },
488 C::execution_sel_op_is_indirect_wire_0_, C::execution_sel_op_is_relative_wire_0_,
489 C::execution_sel_op_is_indirect_wire_1_, C::execution_sel_op_is_relative_wire_1_,
490 C::execution_sel_op_is_indirect_wire_2_, C::execution_sel_op_is_relative_wire_2_,
491 C::execution_sel_op_is_indirect_wire_3_, C::execution_sel_op_is_relative_wire_3_,
492 C::execution_sel_op_is_indirect_wire_4_, C::execution_sel_op_is_relative_wire_4_,
493 C::execution_sel_op_is_indirect_wire_5_, C::execution_sel_op_is_relative_wire_5_,
494 C::execution_sel_op_is_indirect_wire_6_, C::execution_sel_op_is_relative_wire_6_,
495 C::execution_sel_op_is_relative_wire_7_, C::execution_sel_op_is_indirect_wire_7_
497 for (
Column sel_on : decomposition_columns) {
499 for (
Column c : decomposition_columns) {
505 "INDIRECT_RECONSTRUCTION");
509TEST(AddressingConstrainingTest, IndirectGating)
511 TestTraceContainer
trace({
515 { C::execution_sel_bytecode_retrieval_success, 1 },
516 { C::execution_sel_instruction_fetching_success, 1 },
518 { C::execution_sel_op_is_indirect_wire_0_, 0 },
519 { C::execution_sel_op_is_indirect_wire_1_, 1 },
520 { C::execution_sel_op_is_indirect_wire_2_, 0 },
521 { C::execution_sel_op_is_indirect_wire_3_, 1 },
522 { C::execution_sel_op_is_indirect_wire_4_, 0 },
523 { C::execution_sel_op_is_indirect_wire_5_, 1 },
524 { C::execution_sel_op_is_indirect_wire_6_, 1 },
526 { C::execution_sel_op_is_address_0_, 1 },
527 { C::execution_sel_op_is_address_1_, 1 },
528 { C::execution_sel_op_is_address_2_, 1 },
529 { C::execution_sel_op_is_address_3_, 1 },
530 { C::execution_sel_op_is_address_4_, 1 },
531 { C::execution_sel_op_is_address_5_, 1 },
532 { C::execution_sel_op_is_address_6_, 0 },
534 { C::execution_sel_relative_overflow_0_, 0 },
535 { C::execution_sel_relative_overflow_1_, 0 },
536 { C::execution_sel_relative_overflow_2_, 1 },
537 { C::execution_sel_relative_overflow_3_, 1 },
538 { C::execution_sel_relative_overflow_4_, 0 },
539 { C::execution_sel_relative_overflow_5_, 0 },
540 { C::execution_sel_relative_overflow_6_, 0 },
542 { C::execution_sel_should_apply_indirection_0_, 0 },
543 { C::execution_sel_should_apply_indirection_1_, 1 },
544 { C::execution_sel_should_apply_indirection_2_, 0 },
545 { C::execution_sel_should_apply_indirection_3_, 0 },
546 { C::execution_sel_should_apply_indirection_4_, 0 },
547 { C::execution_sel_should_apply_indirection_5_, 1 },
548 { C::execution_sel_should_apply_indirection_6_, 0 },
552 check_relation<addressing>(
trace,
565 { C::execution_sel_should_apply_indirection_0_, 1 },
566 { C::execution_sel_should_apply_indirection_1_, 0 },
567 { C::execution_sel_should_apply_indirection_2_, 1 },
568 { C::execution_sel_should_apply_indirection_3_, 1 },
569 { C::execution_sel_should_apply_indirection_4_, 1 },
570 { C::execution_sel_should_apply_indirection_5_, 0 },
571 { C::execution_sel_should_apply_indirection_6_, 1 },
583 trace.
set(C::execution_sel_bytecode_retrieval_success, 0, 0);
584 trace.
set(C::execution_sel_instruction_fetching_success, 0, 0);
594TEST(AddressingConstrainingTest, IndirectGatingIfBaseAddressIsInvalid)
596 TestTraceContainer
trace({
600 { C::execution_sel_bytecode_retrieval_success, 1 },
601 { C::execution_sel_instruction_fetching_success, 1 },
603 { C::execution_sel_base_address_failure, 1 },
605 { C::execution_sel_op_is_indirect_wire_0_, 0 },
606 { C::execution_sel_op_is_indirect_wire_1_, 1 },
607 { C::execution_sel_op_is_indirect_wire_2_, 0 },
608 { C::execution_sel_op_is_indirect_wire_3_, 1 },
609 { C::execution_sel_op_is_indirect_wire_4_, 0 },
610 { C::execution_sel_op_is_indirect_wire_5_, 1 },
611 { C::execution_sel_op_is_indirect_wire_6_, 1 },
613 { C::execution_sel_op_is_address_0_, 1 },
614 { C::execution_sel_op_is_address_1_, 1 },
615 { C::execution_sel_op_is_address_2_, 1 },
616 { C::execution_sel_op_is_address_3_, 1 },
617 { C::execution_sel_op_is_address_4_, 1 },
618 { C::execution_sel_op_is_address_5_, 1 },
619 { C::execution_sel_op_is_address_6_, 0 },
621 { C::execution_sel_relative_overflow_0_, 0 },
622 { C::execution_sel_relative_overflow_1_, 0 },
623 { C::execution_sel_relative_overflow_2_, 1 },
624 { C::execution_sel_relative_overflow_3_, 1 },
625 { C::execution_sel_relative_overflow_4_, 0 },
626 { C::execution_sel_relative_overflow_5_, 0 },
627 { C::execution_sel_relative_overflow_6_, 0 },
629 { C::execution_sel_should_apply_indirection_0_, 0 },
630 { C::execution_sel_should_apply_indirection_1_, 0 },
631 { C::execution_sel_should_apply_indirection_2_, 0 },
632 { C::execution_sel_should_apply_indirection_3_, 0 },
633 { C::execution_sel_should_apply_indirection_4_, 0 },
634 { C::execution_sel_should_apply_indirection_5_, 0 },
635 { C::execution_sel_should_apply_indirection_6_, 0 },
639 check_relation<addressing>(
trace,
652 { C::execution_sel_should_apply_indirection_0_, 1 },
653 { C::execution_sel_should_apply_indirection_1_, 1 },
654 { C::execution_sel_should_apply_indirection_2_, 1 },
655 { C::execution_sel_should_apply_indirection_3_, 1 },
656 { C::execution_sel_should_apply_indirection_4_, 1 },
657 { C::execution_sel_should_apply_indirection_5_, 1 },
658 { C::execution_sel_should_apply_indirection_6_, 1 },
669TEST(AddressingConstrainingTest, IndirectPropagationWhenNoIndirection)
673 TestTraceContainer
trace({
675 { C::execution_sel_should_apply_indirection_0_, 0 },
676 { C::execution_sel_should_apply_indirection_1_, 1 },
677 { C::execution_sel_should_apply_indirection_2_, 0 },
678 { C::execution_sel_should_apply_indirection_3_, 1 },
679 { C::execution_sel_should_apply_indirection_4_, 0 },
680 { C::execution_sel_should_apply_indirection_5_, 1 },
681 { C::execution_sel_should_apply_indirection_6_, 0 },
683 { C::execution_op_after_relative_0_, 123 },
684 { C::execution_op_after_relative_1_, 456 },
685 { C::execution_op_after_relative_2_, 789 },
686 { C::execution_op_after_relative_3_, 101112 },
687 { C::execution_op_after_relative_4_, 131415 },
688 { C::execution_op_after_relative_5_, 161718 },
689 { C::execution_op_after_relative_6_, 192021 },
691 { C::execution_rop_0_, 123 },
692 { C::execution_rop_1_, 99001 },
693 { C::execution_rop_2_, 789 },
694 { C::execution_rop_3_, 99002 },
695 { C::execution_rop_4_, 131415 },
696 { C::execution_rop_5_, 99003 },
697 { C::execution_rop_6_, 192021 },
700 { C::execution_sel_bytecode_retrieval_success, 1 },
701 { C::execution_sel_instruction_fetching_success, 1 },
705 check_relation<addressing>(
trace,
715 trace.
set(C::execution_sel_bytecode_retrieval_success, 0, 0);
716 trace.
set(C::execution_sel_instruction_fetching_success, 0, 0);
717 check_relation<addressing>(
trace,
729 { C::execution_rop_0_, 7 },
730 { C::execution_rop_2_, 7 },
731 { C::execution_rop_4_, 7 },
732 { C::execution_rop_6_, 7 },
735 "INDIRECT_PROPAGATION_0");
737 "INDIRECT_PROPAGATION_2");
739 "INDIRECT_PROPAGATION_4");
741 "INDIRECT_PROPAGATION_6");
744TEST(AddressingConstrainingTest, IndirectPropagationWhenIndirection)
753TEST(AddressingConstrainingTest, FinalCheckNoFailure)
755 constexpr size_t NUM_OPERANDS = 7;
756 FF should_apply_indirection[NUM_OPERANDS] = { 0, 0, 0, 1, 0, 1, 1 };
760 auto get_tag_diff_inv = [&]() {
761 FF batched_tags_diff = 0;
763 for (
size_t i = 0; i < NUM_OPERANDS; ++i) {
765 should_apply_indirection[i] * power_of_2 * (
FF(
static_cast<uint8_t
>(rop_tag[i])) -
FF(
MEM_TAG_U32));
768 return batched_tags_diff != 0 ? batched_tags_diff.invert() : 0;
771 TestTraceContainer
trace({
774 { C::execution_sel_should_apply_indirection_0_, should_apply_indirection[0] },
775 { C::execution_sel_should_apply_indirection_1_, should_apply_indirection[1] },
776 { C::execution_sel_should_apply_indirection_2_, should_apply_indirection[2] },
777 { C::execution_sel_should_apply_indirection_3_, should_apply_indirection[3] },
778 { C::execution_sel_should_apply_indirection_4_, should_apply_indirection[4] },
779 { C::execution_sel_should_apply_indirection_5_, should_apply_indirection[5] },
780 { C::execution_sel_should_apply_indirection_6_, should_apply_indirection[6] },
782 { C::execution_rop_tag_0_,
static_cast<uint8_t
>(rop_tag[0]) },
783 { C::execution_rop_tag_1_,
static_cast<uint8_t
>(rop_tag[1]) },
784 { C::execution_rop_tag_2_,
static_cast<uint8_t
>(rop_tag[2]) },
785 { C::execution_rop_tag_3_,
static_cast<uint8_t
>(rop_tag[3]) },
786 { C::execution_rop_tag_4_,
static_cast<uint8_t
>(rop_tag[4]) },
787 { C::execution_rop_tag_5_,
static_cast<uint8_t
>(rop_tag[5]) },
788 { C::execution_rop_tag_6_,
static_cast<uint8_t
>(rop_tag[6]) },
791 { C::execution_batched_tags_diff_inv, get_tag_diff_inv() },
792 { C::execution_sel_some_final_check_failed, 0 },
799 trace.
set(C::execution_sel_some_final_check_failed, 0, 1);
801 "BATCHED_TAGS_DIFF_CHECK");
804TEST(AddressingConstrainingTest, FinalCheckSingleFailure)
806 constexpr size_t NUM_OPERANDS = 7;
807 FF should_apply_indirection[NUM_OPERANDS] = { 0, 1, 0, 1, 0, 1, 1 };
811 auto get_tag_diff_inv = [&]() {
812 FF batched_tags_diff = 0;
814 for (
size_t i = 0; i < NUM_OPERANDS; ++i) {
816 should_apply_indirection[i] * power_of_2 * (
FF(
static_cast<uint8_t
>(rop_tag[i])) -
FF(
MEM_TAG_U32));
819 return batched_tags_diff != 0 ? batched_tags_diff.invert() : 0;
822 TestTraceContainer
trace({
825 { C::execution_sel_should_apply_indirection_0_, should_apply_indirection[0] },
826 { C::execution_sel_should_apply_indirection_1_, should_apply_indirection[1] },
827 { C::execution_sel_should_apply_indirection_2_, should_apply_indirection[2] },
828 { C::execution_sel_should_apply_indirection_3_, should_apply_indirection[3] },
829 { C::execution_sel_should_apply_indirection_4_, should_apply_indirection[4] },
830 { C::execution_sel_should_apply_indirection_5_, should_apply_indirection[5] },
831 { C::execution_sel_should_apply_indirection_6_, should_apply_indirection[6] },
833 { C::execution_rop_tag_0_,
static_cast<uint8_t
>(rop_tag[0]) },
834 { C::execution_rop_tag_1_,
static_cast<uint8_t
>(rop_tag[1]) },
835 { C::execution_rop_tag_2_,
static_cast<uint8_t
>(rop_tag[2]) },
836 { C::execution_rop_tag_3_,
static_cast<uint8_t
>(rop_tag[3]) },
837 { C::execution_rop_tag_4_,
static_cast<uint8_t
>(rop_tag[4]) },
838 { C::execution_rop_tag_5_,
static_cast<uint8_t
>(rop_tag[5]) },
839 { C::execution_rop_tag_6_,
static_cast<uint8_t
>(rop_tag[6]) },
842 { C::execution_batched_tags_diff_inv, get_tag_diff_inv() },
843 { C::execution_sel_some_final_check_failed, 1 },
850 trace.
set(C::execution_sel_some_final_check_failed, 0, 0);
852 "BATCHED_TAGS_DIFF_CHECK");
853 trace.
set(C::execution_batched_tags_diff_inv, 0, 0);
855 "BATCHED_TAGS_DIFF_CHECK");
858TEST(AddressingConstrainingTest, FinalCheckMultipleFailures)
860 constexpr size_t NUM_OPERANDS = 7;
861 FF should_apply_indirection[NUM_OPERANDS] = { 0, 1, 0, 1, 0, 1, 1 };
865 auto get_tag_diff_inv = [&]() {
866 FF batched_tags_diff = 0;
868 for (
size_t i = 0; i < NUM_OPERANDS; ++i) {
870 should_apply_indirection[i] * power_of_2 * (
FF(
static_cast<uint8_t
>(rop_tag[i])) -
FF(
MEM_TAG_U32));
873 return batched_tags_diff != 0 ? batched_tags_diff.invert() : 0;
876 TestTraceContainer
trace({
879 { C::execution_sel_should_apply_indirection_0_, should_apply_indirection[0] },
880 { C::execution_sel_should_apply_indirection_1_, should_apply_indirection[1] },
881 { C::execution_sel_should_apply_indirection_2_, should_apply_indirection[2] },
882 { C::execution_sel_should_apply_indirection_3_, should_apply_indirection[3] },
883 { C::execution_sel_should_apply_indirection_4_, should_apply_indirection[4] },
884 { C::execution_sel_should_apply_indirection_5_, should_apply_indirection[5] },
885 { C::execution_sel_should_apply_indirection_6_, should_apply_indirection[6] },
887 { C::execution_rop_tag_0_,
static_cast<uint8_t
>(rop_tag[0]) },
888 { C::execution_rop_tag_1_,
static_cast<uint8_t
>(rop_tag[1]) },
889 { C::execution_rop_tag_2_,
static_cast<uint8_t
>(rop_tag[2]) },
890 { C::execution_rop_tag_3_,
static_cast<uint8_t
>(rop_tag[3]) },
891 { C::execution_rop_tag_4_,
static_cast<uint8_t
>(rop_tag[4]) },
892 { C::execution_rop_tag_5_,
static_cast<uint8_t
>(rop_tag[5]) },
893 { C::execution_rop_tag_6_,
static_cast<uint8_t
>(rop_tag[6]) },
896 { C::execution_batched_tags_diff_inv, get_tag_diff_inv() },
897 { C::execution_sel_some_final_check_failed, 1 },
904 trace.
set(C::execution_sel_some_final_check_failed, 0, 0);
906 "BATCHED_TAGS_DIFF_CHECK");
907 trace.
set(C::execution_batched_tags_diff_inv, 0, 0);
909 "BATCHED_TAGS_DIFF_CHECK");
static constexpr size_t SR_NOT_RELATIVE_NO_OVERFLOW_4
static constexpr size_t SR_RELATIVE_RESOLUTION_4
static constexpr size_t SR_RELATIVE_OVERFLOW_RESULT_6
static constexpr size_t SR_INDIRECT_PROPAGATION_4
static constexpr size_t SR_INDIRECT_RECONSTRUCTION
static constexpr size_t SR_BATCHED_TAGS_DIFF_CHECK
static constexpr size_t SR_INDIRECT_PROPAGATION_0
static constexpr size_t SR_INDIRECT_PROPAGATION_2
static constexpr size_t SR_RELATIVE_RESOLUTION_5
static constexpr size_t SR_RELATIVE_OVERFLOW_RESULT_2
static constexpr size_t SR_INDIRECT_GATING_5
static constexpr size_t SR_RELATIVE_RESOLUTION_3
static constexpr size_t SR_BASE_ADDRESS_CHECK
static constexpr size_t SR_INDIRECT_GATING_6
static constexpr size_t SR_RELATIVE_RESOLUTION_2
static constexpr size_t SR_INDIRECT_GATING_0
static constexpr size_t SR_NOT_RELATIVE_NO_OVERFLOW_3
static constexpr size_t SR_INDIRECT_GATING_3
static constexpr size_t SR_INDIRECT_PROPAGATION_6
static constexpr size_t SR_RELATIVE_OVERFLOW_RESULT_3
static constexpr size_t SR_RELATIVE_RESOLUTION_0
static constexpr size_t SR_RELATIVE_RESOLUTION_6
static constexpr size_t SR_INDIRECT_GATING_2
static constexpr size_t SR_INDIRECT_PROPAGATION_5
static constexpr size_t SR_NOT_RELATIVE_NO_OVERFLOW_0
static constexpr size_t SR_INDIRECT_PROPAGATION_1
static constexpr size_t SR_NOT_RELATIVE_NO_OVERFLOW_6
static constexpr size_t SR_INDIRECT_PROPAGATION_3
static constexpr size_t SR_RELATIVE_OVERFLOW_RESULT_4
static constexpr size_t SR_INDIRECT_GATING_4
static constexpr size_t SR_INDIRECT_GATING_1
static constexpr size_t SR_RELATIVE_OVERFLOW_RESULT_0
static constexpr size_t SR_NOT_RELATIVE_NO_OVERFLOW_5
static constexpr size_t SR_NOT_RELATIVE_NO_OVERFLOW_1
static constexpr size_t SR_RELATIVE_OVERFLOW_RESULT_5
static constexpr size_t SR_NOT_RELATIVE_NO_OVERFLOW_2
static constexpr size_t SR_RELATIVE_RESOLUTION_1
static constexpr size_t SR_RELATIVE_OVERFLOW_RESULT_1
static constexpr size_t SR_NUM_RELATIVE_INV_CHECK
void set(Column col, uint32_t row, const FF &value)
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessage)
TEST(TxExecutionConstrainingTest, WriteTreeValue)
TestTraceContainer empty_trace()
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept