1 /* 2 * Copyright (c) 2015-2020, Intel Corporation 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * * Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. 9 * * Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * * Neither the name of Intel Corporation nor the names of its contributors 13 * may be used to endorse or promote products derived from this software 14 * without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** \file 30 * \brief Rose data structures to do with role programs. 31 */ 32 33 #ifndef ROSE_ROSE_PROGRAM_H 34 #define ROSE_ROSE_PROGRAM_H 35 36 #include "som/som_operation.h" 37 #include "rose_internal.h" 38 #include "ue2common.h" 39 #include "util/simd_types.h" 40 41 /** \brief Minimum alignment for each instruction in memory. */ 42 #define ROSE_INSTR_MIN_ALIGN 8U 43 44 /** \brief Role program instruction opcodes. */ 45 enum RoseInstructionCode { 46 ROSE_INSTR_END, //!< End of program. 47 ROSE_INSTR_ANCHORED_DELAY, //!< Delay until after anchored matcher. 48 ROSE_INSTR_CHECK_LIT_EARLY, //!< Skip matches before floating min offset. 49 ROSE_INSTR_CHECK_GROUPS, //!< Check that literal groups are on. 50 ROSE_INSTR_CHECK_ONLY_EOD, //!< Role matches only at EOD. 51 ROSE_INSTR_CHECK_BOUNDS, //!< Bounds on distance from offset 0. 52 ROSE_INSTR_CHECK_NOT_HANDLED, //!< Test & set role in "handled". 53 ROSE_INSTR_CHECK_SINGLE_LOOKAROUND, //!< Single lookaround check. 54 ROSE_INSTR_CHECK_LOOKAROUND, //!< Lookaround check. 55 ROSE_INSTR_CHECK_MASK, //!< 8-bytes mask check. 56 ROSE_INSTR_CHECK_MASK_32, //!< 32-bytes and/cmp/neg mask check. 57 ROSE_INSTR_CHECK_BYTE, //!< Single Byte check. 58 ROSE_INSTR_CHECK_SHUFTI_16x8, //!< Check 16-byte data by 8-bucket shufti. 59 ROSE_INSTR_CHECK_SHUFTI_32x8, //!< Check 32-byte data by 8-bucket shufti. 60 ROSE_INSTR_CHECK_SHUFTI_16x16, //!< Check 16-byte data by 16-bucket shufti. 61 ROSE_INSTR_CHECK_SHUFTI_32x16, //!< Check 32-byte data by 16-bucket shufti. 62 ROSE_INSTR_CHECK_INFIX, //!< Infix engine must be in accept state. 63 ROSE_INSTR_CHECK_PREFIX, //!< Prefix engine must be in accept state. 64 ROSE_INSTR_PUSH_DELAYED, //!< Push delayed literal matches. 65 ROSE_INSTR_DUMMY_NOP, //!< NOP. Should not exist in build programs. 66 ROSE_INSTR_CATCH_UP, //!< Catch up engines, anchored matches. 67 ROSE_INSTR_CATCH_UP_MPV, //!< Catch up the MPV. 68 ROSE_INSTR_SOM_ADJUST, //!< Set SOM from a distance to EOM. 69 ROSE_INSTR_SOM_LEFTFIX, //!< Acquire SOM from a leftfix engine. 70 ROSE_INSTR_SOM_FROM_REPORT, //!< Acquire SOM from a som_operation. 71 ROSE_INSTR_SOM_ZERO, //!< Set SOM to zero. 72 ROSE_INSTR_TRIGGER_INFIX, //!< Trigger an infix engine. 73 ROSE_INSTR_TRIGGER_SUFFIX, //!< Trigger a suffix engine. 74 ROSE_INSTR_DEDUPE, //!< Run deduplication for report. 75 ROSE_INSTR_DEDUPE_SOM, //!< Run deduplication for SOM report. 76 ROSE_INSTR_REPORT_CHAIN, //!< Fire a chained report (MPV). 77 ROSE_INSTR_REPORT_SOM_INT, //!< Manipulate SOM only. 78 ROSE_INSTR_REPORT_SOM_AWARE, //!< Manipulate SOM from SOM-aware source. 79 80 /** \brief Fire a report. */ 81 ROSE_INSTR_REPORT, 82 83 /** \brief Fire an exhaustible report. */ 84 ROSE_INSTR_REPORT_EXHAUST, 85 86 /** \brief Fire a SOM report. */ 87 ROSE_INSTR_REPORT_SOM, 88 89 /** \brief Fire an exhaustible SOM report. */ 90 ROSE_INSTR_REPORT_SOM_EXHAUST, 91 92 /** \brief Super-instruction combining DEDUPE and REPORT. */ 93 ROSE_INSTR_DEDUPE_AND_REPORT, 94 95 /** 96 * \brief Fire a report and stop program execution. This is a 97 * specialisation intended for short, frequently-executed programs. 98 */ 99 ROSE_INSTR_FINAL_REPORT, 100 101 ROSE_INSTR_CHECK_EXHAUSTED, //!< Check if an ekey has already been set. 102 ROSE_INSTR_CHECK_MIN_LENGTH, //!< Check (EOM - SOM) against min length. 103 ROSE_INSTR_SET_STATE, //!< Switch a state index on. 104 ROSE_INSTR_SET_GROUPS, //!< Set some literal group bits. 105 ROSE_INSTR_SQUASH_GROUPS, //!< Conditionally turn off some groups. 106 ROSE_INSTR_CHECK_STATE, //!< Test a single bit in the state multibit. 107 ROSE_INSTR_SPARSE_ITER_BEGIN, //!< Begin running a sparse iter over states. 108 ROSE_INSTR_SPARSE_ITER_NEXT, //!< Continue running sparse iter over states. 109 ROSE_INSTR_SPARSE_ITER_ANY, //!< Test for any bit in the sparse iterator. 110 111 /** \brief Check outfixes and suffixes for EOD and fire reports if so. */ 112 ROSE_INSTR_ENGINES_EOD, 113 114 /** \brief Catch up and check active suffixes for EOD and fire reports if 115 * so. */ 116 ROSE_INSTR_SUFFIXES_EOD, 117 118 /** \brief Run the EOD-anchored HWLM literal matcher. */ 119 ROSE_INSTR_MATCHER_EOD, 120 121 /** 122 * \brief Confirm a case-sensitive literal at the current offset. In 123 * streaming mode, this makes use of the long literal table. 124 */ 125 ROSE_INSTR_CHECK_LONG_LIT, 126 127 /** 128 * \brief Confirm a case-insensitive literal at the current offset. In 129 * streaming mode, this makes use of the long literal table. 130 */ 131 ROSE_INSTR_CHECK_LONG_LIT_NOCASE, 132 133 /** 134 * \brief Confirm a case-sensitive "medium length" literal at the current 135 * offset. In streaming mode, this will check history if needed. 136 */ 137 ROSE_INSTR_CHECK_MED_LIT, 138 139 /** 140 * \brief Confirm a case-insensitive "medium length" literal at the current 141 * offset. In streaming mode, this will check history if needed. 142 */ 143 ROSE_INSTR_CHECK_MED_LIT_NOCASE, 144 145 /** 146 * \brief Clear the "work done" flag used by the SQUASH_GROUPS instruction. 147 */ 148 ROSE_INSTR_CLEAR_WORK_DONE, 149 150 /** \brief Check lookaround if it has multiple paths. */ 151 ROSE_INSTR_MULTIPATH_LOOKAROUND, 152 153 /** 154 * \brief Use shufti to check lookaround with multiple paths. The total 155 * length of the paths is 16 bytes at most and shufti has 8 buckets. 156 * All paths can be at most 16 bytes long. 157 */ 158 ROSE_INSTR_CHECK_MULTIPATH_SHUFTI_16x8, 159 160 /** 161 * \brief Use shufti to check lookaround with multiple paths. The total 162 * length of the paths is 32 bytes at most and shufti has 8 buckets. 163 * All paths can be at most 16 bytes long. 164 */ 165 ROSE_INSTR_CHECK_MULTIPATH_SHUFTI_32x8, 166 167 /** 168 * \brief Use shufti to check lookaround with multiple paths. The total 169 * length of the paths is 32 bytes at most and shufti has 16 buckets. 170 * All paths can be at most 16 bytes long. 171 */ 172 ROSE_INSTR_CHECK_MULTIPATH_SHUFTI_32x16, 173 174 /** 175 * \brief Use shufti to check multiple paths lookaround. The total 176 * length of the paths is 64 bytes at most and shufti has 8 buckets. 177 * All paths can be at most 16 bytes long. 178 */ 179 ROSE_INSTR_CHECK_MULTIPATH_SHUFTI_64, 180 181 /** 182 * \brief Jump to the program of included literal. 183 */ 184 ROSE_INSTR_INCLUDED_JUMP, 185 186 /** 187 * \brief Set matching status of a sub-expression. 188 */ 189 ROSE_INSTR_SET_LOGICAL, 190 191 /** 192 * \brief Set combination status pending checking. 193 */ 194 ROSE_INSTR_SET_COMBINATION, 195 196 /** 197 * \brief Check if compliant with any logical constraints. 198 */ 199 ROSE_INSTR_FLUSH_COMBINATION, 200 201 /** \brief Mark as exhausted instead of report while quiet. */ 202 ROSE_INSTR_SET_EXHAUST, 203 204 /** 205 * \brief Calculate any combination's logical value if none of its 206 * sub-expression matches until EOD, then check if compliant with any 207 * logical constraints. 208 */ 209 ROSE_INSTR_LAST_FLUSH_COMBINATION, 210 211 ROSE_INSTR_CHECK_SHUFTI_64x8, //!< Check 64-byte data by 8-bucket shufti. 212 ROSE_INSTR_CHECK_SHUFTI_64x16, //!< Check 64-byte data by 16-bucket shufti. 213 ROSE_INSTR_CHECK_MASK_64, //!< 64-bytes and/cmp/neg mask check. 214 215 LAST_ROSE_INSTRUCTION = ROSE_INSTR_CHECK_MASK_64 //!< Sentinel. 216 }; 217 218 struct ROSE_STRUCT_END { 219 u8 code; //!< From enum RoseInstructionCode. 220 }; 221 222 struct ROSE_STRUCT_ANCHORED_DELAY { 223 u8 code; //!< From enum RoseInstructionCode. 224 rose_group groups; //!< Bitmask. 225 u32 anch_id; //!< Program to restart after the delay. 226 u32 done_jump; //!< Jump forward this many bytes if we have to delay. 227 }; 228 229 struct ROSE_STRUCT_CHECK_LIT_EARLY { 230 u8 code; //!< From enum RoseInstructionCode. 231 u32 min_offset; //!< Minimum offset for this literal. 232 u32 fail_jump; //!< Jump forward this many bytes on failure. 233 }; 234 235 /** Note: check failure will halt program. */ 236 struct ROSE_STRUCT_CHECK_GROUPS { 237 u8 code; //!< From enum RoseInstructionCode. 238 rose_group groups; //!< Bitmask. 239 }; 240 241 struct ROSE_STRUCT_CHECK_ONLY_EOD { 242 u8 code; //!< From enum RoseInstructionCode. 243 u32 fail_jump; //!< Jump forward this many bytes on failure. 244 }; 245 246 struct ROSE_STRUCT_CHECK_BOUNDS { 247 u8 code; //!< From enum RoseInstructionCode. 248 u64a min_bound; //!< Min distance from zero. 249 u64a max_bound; //!< Max distance from zero. 250 u32 fail_jump; //!< Jump forward this many bytes on failure. 251 }; 252 253 struct ROSE_STRUCT_CHECK_NOT_HANDLED { 254 u8 code; //!< From enum RoseInstructionCode. 255 u32 key; //!< Key in the "handled_roles" fatbit in scratch. 256 u32 fail_jump; //!< Jump forward this many bytes if we have seen key before. 257 }; 258 259 struct ROSE_STRUCT_CHECK_SINGLE_LOOKAROUND { 260 u8 code; //!< From enum RoseInstructionCode. 261 s8 offset; //!< The offset of the byte to examine. 262 u32 reach_index; //!< Index for lookaround reach bitvectors. 263 u32 fail_jump; //!< Jump forward this many bytes on failure. 264 }; 265 266 struct ROSE_STRUCT_CHECK_LOOKAROUND { 267 u8 code; //!< From enum RoseInstructionCode. 268 u32 look_index; //!< Offset in bytecode of lookaround offset list. 269 u32 reach_index; //!< Offset in bytecode of lookaround reach bitvectors. 270 u32 count; //!< The count of lookaround entries in one instruction. 271 u32 fail_jump; //!< Jump forward this many bytes on failure. 272 }; 273 274 struct ROSE_STRUCT_CHECK_MASK { 275 u8 code; //!< From enum roseInstructionCode. 276 u64a and_mask; //!< 8-byte and mask. 277 u64a cmp_mask; //!< 8-byte cmp mask. 278 u64a neg_mask; //!< 8-byte negation mask. 279 s32 offset; //!< Relative offset of the first byte. 280 u32 fail_jump; //!< Jump forward this many bytes on failure. 281 }; 282 283 struct ROSE_STRUCT_CHECK_MASK_32 { 284 u8 code; //!< From enum RoseInstructionCode. 285 u8 and_mask[32]; //!< 32-byte and mask. 286 u8 cmp_mask[32]; //!< 32-byte cmp mask. 287 u32 neg_mask; //!< negation mask with 32 bits. 288 s32 offset; //!< Relative offset of the first byte. 289 u32 fail_jump; //!< Jump forward this many bytes on failure. 290 }; 291 292 struct ROSE_STRUCT_CHECK_MASK_64 { 293 u8 code; //!< From enum RoseInstructionCode. 294 u8 and_mask[64]; //!< 64-byte and mask. 295 u8 cmp_mask[64]; //!< 64-byte cmp mask. 296 u64a neg_mask; //!< negation mask with 32 bits. 297 s32 offset; //!< Relative offset of the first byte. 298 u32 fail_jump; //!< Jump forward this many bytes on failure. 299 }; 300 301 struct ROSE_STRUCT_CHECK_BYTE { 302 u8 code; //!< From enum RoseInstructionCode. 303 u8 and_mask; //!< 8-bits and mask. 304 u8 cmp_mask; //!< 8-bits cmp mask. 305 u8 negation; //!< Flag about negation. 306 s32 offset; //!< The relative offset. 307 u32 fail_jump; //!< Jump forward this many bytes on failure. 308 }; 309 310 // Since m128 and m256 could be missaligned in the bytecode, 311 // we'll use u8[16] and u8[32] instead in all rose_check_shufti structures. 312 struct ROSE_STRUCT_CHECK_SHUFTI_16x8 { 313 u8 code; //!< From enum RoseInstructionCode. 314 u8 nib_mask[32]; //!< High 16 and low 16 bits nibble mask in shufti. 315 u8 bucket_select_mask[16]; //!< Mask for bucket assigning. 316 u32 neg_mask; //!< Negation mask in low 16 bits. 317 s32 offset; //!< Relative offset of the first byte. 318 u32 fail_jump; //!< Jump forward this many bytes on failure. 319 }; 320 321 struct ROSE_STRUCT_CHECK_SHUFTI_32x8 { 322 u8 code; //!< From enum RoseInstructionCode. 323 u8 hi_mask[16]; //!< High nibble mask in shufti. 324 u8 lo_mask[16]; //!< Low nibble mask in shufti. 325 u8 bucket_select_mask[32]; //!< Mask for bucket assigning. 326 u32 neg_mask; //!< 32 bits negation mask. 327 s32 offset; //!< Relative offset of the first byte. 328 u32 fail_jump; //!< Jump forward this many bytes on failure. 329 }; 330 331 struct ROSE_STRUCT_CHECK_SHUFTI_16x16 { 332 u8 code; //!< From enum RoseInstructionCode. 333 u8 hi_mask[32]; //!< High nibble mask in shufti. 334 u8 lo_mask[32]; //!< Low nibble mask in shufti. 335 u8 bucket_select_mask[32]; //!< Mask for bucket assigning. 336 u32 neg_mask; //!< Negation mask in low 16 bits. 337 s32 offset; //!< Relative offset of the first byte. 338 u32 fail_jump; //!< Jump forward this many bytes on failure. 339 }; 340 341 struct ROSE_STRUCT_CHECK_SHUFTI_32x16 { 342 u8 code; //!< From enum RoseInstructionCode. 343 u8 hi_mask[32]; //!< High nibble mask in shufti. 344 u8 lo_mask[32]; //!< Low nibble mask in shufti. 345 u8 bucket_select_mask_hi[32]; //!< Bucket mask for high 8 buckets. 346 u8 bucket_select_mask_lo[32]; //!< Bucket mask for low 8 buckets. 347 u32 neg_mask; //!< 32 bits negation mask. 348 s32 offset; //!< Relative offset of the first byte. 349 u32 fail_jump; //!< Jump forward this many bytes on failure. 350 }; 351 352 struct ROSE_STRUCT_CHECK_SHUFTI_64x8 { 353 u8 code; //!< From enum RoseInstructionCode. 354 u8 hi_mask[64]; //!< High nibble mask in shufti. 355 u8 lo_mask[64]; //!< Low nibble mask in shufti. 356 u8 bucket_select_mask[64]; //!< Mask for bucket assigning. 357 u64a neg_mask; //!< 64 bits negation mask. 358 s32 offset; //!< Relative offset of the first byte. 359 u32 fail_jump; //!< Jump forward this many bytes on failure. 360 }; 361 362 struct ROSE_STRUCT_CHECK_SHUFTI_64x16 { 363 u8 code; //!< From enum RoseInstructionCode. 364 u8 hi_mask_1[64]; //!< 4 copies of 0-15 High nibble mask. 365 u8 hi_mask_2[64]; //!< 4 copies of 16-32 High nibble mask. 366 u8 lo_mask_1[64]; //!< 4 copies of 0-15 Low nibble mask. 367 u8 lo_mask_2[64]; //!< 4 copies of 16-32 Low nibble mask. 368 u8 bucket_select_mask_hi[64]; //!< Bucket mask for high 8 buckets. 369 u8 bucket_select_mask_lo[64]; //!< Bucket mask for low 8 buckets. 370 u64a neg_mask; //!< 64 bits negation mask. 371 s32 offset; //!< Relative offset of the first byte. 372 u32 fail_jump; //!< Jump forward this many bytes on failure. 373 }; 374 375 struct ROSE_STRUCT_CHECK_INFIX { 376 u8 code; //!< From enum RoseInstructionCode. 377 u32 queue; //!< Queue of leftfix to check. 378 u32 lag; //!< Lag of leftfix for this case. 379 ReportID report; //!< ReportID of leftfix to check. 380 u32 fail_jump; //!< Jump forward this many bytes on failure. 381 }; 382 383 struct ROSE_STRUCT_CHECK_PREFIX { 384 u8 code; //!< From enum RoseInstructionCode. 385 u32 queue; //!< Queue of leftfix to check. 386 u32 lag; //!< Lag of leftfix for this case. 387 ReportID report; //!< ReportID of leftfix to check. 388 u32 fail_jump; //!< Jump forward this many bytes on failure. 389 }; 390 391 struct ROSE_STRUCT_PUSH_DELAYED { 392 u8 code; //!< From enum RoseInstructionCode. 393 u8 delay; // Number of bytes to delay. 394 u32 index; // Delay literal index (relative to first delay lit). 395 }; 396 397 struct ROSE_STRUCT_DUMMY_NOP { 398 u8 code; //!< From enum RoseInstructionCode. 399 }; 400 401 struct ROSE_STRUCT_CATCH_UP { 402 u8 code; //!< From enum RoseInstructionCode. 403 }; 404 405 struct ROSE_STRUCT_CATCH_UP_MPV { 406 u8 code; //!< From enum RoseInstructionCode. 407 }; 408 409 struct ROSE_STRUCT_SOM_ADJUST { 410 u8 code; //!< From enum RoseInstructionCode. 411 u32 distance; //!< Distance to EOM. 412 }; 413 414 struct ROSE_STRUCT_SOM_LEFTFIX { 415 u8 code; //!< From enum RoseInstructionCode. 416 u32 queue; //!< Queue index of leftfix providing SOM. 417 u32 lag; //!< Lag of leftfix for this case. 418 }; 419 420 struct ROSE_STRUCT_SOM_FROM_REPORT { 421 u8 code; //!< From enum RoseInstructionCode. 422 struct som_operation som; 423 }; 424 425 struct ROSE_STRUCT_SOM_ZERO { 426 u8 code; //!< From enum RoseInstructionCode. 427 }; 428 429 struct ROSE_STRUCT_TRIGGER_INFIX { 430 u8 code; //!< From enum RoseInstructionCode. 431 u8 cancel; //!< Cancels previous top event. 432 u32 queue; //!< Queue index of infix. 433 u32 event; //!< Queue event, from MQE_*. 434 }; 435 436 struct ROSE_STRUCT_TRIGGER_SUFFIX { 437 u8 code; //!< From enum RoseInstructionCode. 438 u32 queue; //!< Queue index of suffix. 439 u32 event; //!< Queue event, from MQE_*. 440 }; 441 442 struct ROSE_STRUCT_DEDUPE { 443 u8 code; //!< From enum RoseInstructionCode. 444 u8 quash_som; //!< Force SOM to zero for this report. 445 u32 dkey; //!< Dedupe key. 446 s32 offset_adjust; //!< Offset adjustment to apply to end offset. 447 u32 fail_jump; //!< Jump forward this many bytes on failure. 448 }; 449 450 struct ROSE_STRUCT_DEDUPE_SOM { 451 u8 code; //!< From enum RoseInstructionCode. 452 u8 quash_som; //!< Force SOM to zero for this report. 453 u32 dkey; //!< Dedupe key. 454 s32 offset_adjust; //!< Offset adjustment to apply to end offset. 455 u32 fail_jump; //!< Jump forward this many bytes on failure. 456 }; 457 458 struct ROSE_STRUCT_REPORT_CHAIN { 459 u8 code; //!< From enum RoseInstructionCode. 460 u32 event; //!< Queue event, from MQE_*. Must be a top. 461 462 /** 463 * \brief Number of bytes behind us that we are allowed to squash 464 * identical top events on the queue. 465 */ 466 u64a top_squash_distance; 467 }; 468 469 struct ROSE_STRUCT_REPORT_SOM_INT { 470 u8 code; //!< From enum RoseInstructionCode. 471 struct som_operation som; 472 }; 473 474 struct ROSE_STRUCT_REPORT_SOM_AWARE { 475 u8 code; //!< From enum RoseInstructionCode. 476 struct som_operation som; 477 }; 478 479 struct ROSE_STRUCT_REPORT { 480 u8 code; //!< From enum RoseInstructionCode. 481 ReportID onmatch; //!< Report ID to deliver to user. 482 s32 offset_adjust; //!< Offset adjustment to apply to end offset. 483 }; 484 485 struct ROSE_STRUCT_REPORT_EXHAUST { 486 u8 code; //!< From enum RoseInstructionCode. 487 ReportID onmatch; //!< Report ID to deliver to user. 488 s32 offset_adjust; //!< Offset adjustment to apply to end offset. 489 u32 ekey; //!< Exhaustion key. 490 }; 491 492 struct ROSE_STRUCT_REPORT_SOM { 493 u8 code; //!< From enum RoseInstructionCode. 494 ReportID onmatch; //!< Report ID to deliver to user. 495 s32 offset_adjust; //!< Offset adjustment to apply to end offset. 496 }; 497 498 struct ROSE_STRUCT_REPORT_SOM_EXHAUST { 499 u8 code; //!< From enum RoseInstructionCode. 500 ReportID onmatch; //!< Report ID to deliver to user. 501 s32 offset_adjust; //!< Offset adjustment to apply to end offset. 502 u32 ekey; //!< Exhaustion key. 503 }; 504 505 struct ROSE_STRUCT_DEDUPE_AND_REPORT { 506 u8 code; //!< From enum RoseInstructionCode. 507 u8 quash_som; //!< Force SOM to zero for this report. 508 u32 dkey; //!< Dedupe key. 509 ReportID onmatch; //!< Report ID to deliver to user. 510 s32 offset_adjust; //!< Offset adjustment to apply to end offset. 511 u32 fail_jump; //!< Jump forward this many bytes on failure. 512 }; 513 514 struct ROSE_STRUCT_FINAL_REPORT { 515 u8 code; //!< From enum RoseInstructionCode. 516 ReportID onmatch; //!< Report ID to deliver to user. 517 s32 offset_adjust; //!< Offset adjustment to apply to end offset. 518 }; 519 520 struct ROSE_STRUCT_CHECK_EXHAUSTED { 521 u8 code; //!< From enum RoseInstructionCode. 522 u32 ekey; //!< Exhaustion key to check. 523 u32 fail_jump; //!< Jump forward this many bytes on failure. 524 }; 525 526 struct ROSE_STRUCT_CHECK_MIN_LENGTH { 527 u8 code; //!< From enum RoseInstructionCode. 528 s32 end_adj; //!< Offset adjustment to add to EOM first. 529 u64a min_length; //!< Minimum distance from SOM to EOM. 530 u32 fail_jump; //!< Jump forward this many bytes on failure. 531 }; 532 533 struct ROSE_STRUCT_SET_STATE { 534 u8 code; //!< From enum RoseInstructionCode. 535 u32 index; //!< State index in multibit. 536 }; 537 538 struct ROSE_STRUCT_SET_GROUPS { 539 u8 code; //!< From enum RoseInstructionCode. 540 rose_group groups; //!< Bitmask to OR into groups. 541 }; 542 543 struct ROSE_STRUCT_SQUASH_GROUPS { 544 u8 code; //!< From enum RoseInstructionCode. 545 rose_group groups; //!< Bitmask to AND into groups. 546 }; 547 548 struct ROSE_STRUCT_CHECK_STATE { 549 u8 code; //!< From enum RoseInstructionCode. 550 u32 index; //!< State index in the role multibit. 551 u32 fail_jump; //!< Jump forward this many bytes on failure. 552 }; 553 554 /** 555 * Note that the offsets in the jump table are always relative to the start of 556 * the program, not the current instruction. 557 */ 558 struct ROSE_STRUCT_SPARSE_ITER_BEGIN { 559 u8 code; //!< From enum RoseInstructionCode. 560 u32 iter_offset; //!< Offset of mmbit_sparse_iter structure. 561 u32 jump_table; //!< Offset of jump table indexed by sparse iterator. 562 u32 fail_jump; //!< Jump forward this many bytes on failure. 563 }; 564 565 /** 566 * Note that the offsets in the jump table are always relative to the start of 567 * the program, not the current instruction. 568 */ 569 struct ROSE_STRUCT_SPARSE_ITER_NEXT { 570 u8 code; //!< From enum RoseInstructionCode. 571 u32 iter_offset; //!< Offset of mmbit_sparse_iter structure. 572 u32 jump_table; //!< Offset of jump table indexed by sparse iterator. 573 u32 state; // Current state index. 574 u32 fail_jump; //!< Jump forward this many bytes on failure. 575 }; 576 577 struct ROSE_STRUCT_SPARSE_ITER_ANY { 578 u8 code; //!< From enum RoseInstructionCode. 579 u32 iter_offset; //!< Offset of mmbit_sparse_iter structure. 580 u32 fail_jump; //!< Jump forward this many bytes on failure. 581 }; 582 583 struct ROSE_STRUCT_ENGINES_EOD { 584 u8 code; //!< From enum RoseInstructionCode. 585 u32 iter_offset; //!< Offset of mmbit_sparse_iter structure. 586 }; 587 588 struct ROSE_STRUCT_SUFFIXES_EOD { 589 u8 code; //!< From enum RoseInstructionCode. 590 }; 591 592 struct ROSE_STRUCT_MATCHER_EOD { 593 u8 code; //!< From enum RoseInstructionCode. 594 }; 595 596 struct ROSE_STRUCT_CHECK_LONG_LIT { 597 u8 code; //!< From enum RoseInstructionCode. 598 u32 lit_offset; //!< Offset of literal string. 599 u32 lit_length; //!< Length of literal string. 600 u32 fail_jump; //!< Jump forward this many bytes on failure. 601 }; 602 603 struct ROSE_STRUCT_CHECK_LONG_LIT_NOCASE { 604 u8 code; //!< From enum RoseInstructionCode. 605 u32 lit_offset; //!< Offset of literal string. 606 u32 lit_length; //!< Length of literal string. 607 u32 fail_jump; //!< Jump forward this many bytes on failure. 608 }; 609 610 struct ROSE_STRUCT_CHECK_MED_LIT { 611 u8 code; //!< From enum RoseInstructionCode. 612 u32 lit_offset; //!< Offset of literal string. 613 u32 lit_length; //!< Length of literal string. 614 u32 fail_jump; //!< Jump forward this many bytes on failure. 615 }; 616 617 struct ROSE_STRUCT_CHECK_MED_LIT_NOCASE { 618 u8 code; //!< From enum RoseInstructionCode. 619 u32 lit_offset; //!< Offset of literal string. 620 u32 lit_length; //!< Length of literal string. 621 u32 fail_jump; //!< Jump forward this many bytes on failure. 622 }; 623 624 struct ROSE_STRUCT_CLEAR_WORK_DONE { 625 u8 code; //!< From enum RoseInstructionCode. 626 }; 627 628 struct ROSE_STRUCT_MULTIPATH_LOOKAROUND { 629 u8 code; //!< From enum RoseInstructionCode. 630 u32 look_index; //!< Offset in bytecode of lookaround offset list. 631 u32 reach_index; //!< Offset in bytecode of lookaround reach bitvectors. 632 u32 count; //!< The lookaround byte numbers for each path. 633 s32 last_start; //!< The latest start offset among 8 paths. 634 u8 start_mask[MULTIPATH_MAX_LEN]; /*!< Used to initialize path if left-most 635 * data is missed. */ 636 u32 fail_jump; //!< Jump forward this many bytes on failure. 637 }; 638 639 struct ROSE_STRUCT_CHECK_MULTIPATH_SHUFTI_16x8 { 640 u8 code; //!< From enum RoseInstructionCode. 641 u8 nib_mask[2 * sizeof(m128)]; //!< High and low nibble mask in shufti. 642 u8 bucket_select_mask[sizeof(m128)]; //!< Mask for bucket assigning. 643 u8 data_select_mask[sizeof(m128)]; //!< Shuffle mask for data ordering. 644 u32 hi_bits_mask; //!< High-bits used in multi-path validation. 645 u32 lo_bits_mask; //!< Low-bits used in multi-path validation. 646 u32 neg_mask; //!< 64 bits negation mask. 647 s32 base_offset; //!< Relative offset of the first byte. 648 s32 last_start; //!< The latest start offset among 8 paths. 649 u32 fail_jump; //!< Jump forward this many bytes on failure. 650 }; 651 652 struct ROSE_STRUCT_CHECK_MULTIPATH_SHUFTI_32x8 { 653 u8 code; //!< From enum RoseInstructionCode. 654 u8 hi_mask[sizeof(m128)]; //!< High nibble mask in shufti. 655 u8 lo_mask[sizeof(m128)]; //!< Low nibble mask in shufti. 656 u8 bucket_select_mask[sizeof(m256)]; //!< Mask for bucket assigning. 657 u8 data_select_mask[sizeof(m256)]; //!< Shuffle mask for data ordering. 658 u32 hi_bits_mask; //!< High-bits used in multi-path validation. 659 u32 lo_bits_mask; //!< Low-bits used in multi-path validation. 660 u32 neg_mask; //!< 64 bits negation mask. 661 s32 base_offset; //!< Relative offset of the first byte. 662 s32 last_start; //!< The latest start offset among 8 paths. 663 u32 fail_jump; //!< Jump forward this many bytes on failure. 664 }; 665 666 struct ROSE_STRUCT_CHECK_MULTIPATH_SHUFTI_32x16 { 667 u8 code; //!< From enum RoseInstructionCode. 668 u8 hi_mask[sizeof(m256)]; //!< High nibble mask in shufti. 669 u8 lo_mask[sizeof(m256)]; //!< Low nibble mask in shufti. 670 u8 bucket_select_mask_hi[sizeof(m256)]; //!< Mask for bucket assigning. 671 u8 bucket_select_mask_lo[sizeof(m256)]; //!< Mask for bucket assigning. 672 u8 data_select_mask[sizeof(m256)]; //!< Shuffle mask for data ordering. 673 u32 hi_bits_mask; //!< High-bits used in multi-path validation. 674 u32 lo_bits_mask; //!< Low-bits used in multi-path validation. 675 u32 neg_mask; //!< 64 bits negation mask. 676 s32 base_offset; //!< Relative offset of the first byte. 677 s32 last_start; //!< The latest start offset among 8 paths. 678 u32 fail_jump; //!< Jump forward this many bytes on failure. 679 }; 680 681 struct ROSE_STRUCT_CHECK_MULTIPATH_SHUFTI_64 { 682 u8 code; //!< From enum RoseInstructionCode. 683 u8 hi_mask[sizeof(m128)]; //!< High nibble mask in shufti. 684 u8 lo_mask[sizeof(m128)]; //!< Low nibble mask in shufti. 685 u8 bucket_select_mask[2 * sizeof(m256)]; //!< Mask for bucket assigning. 686 u8 data_select_mask[2 * sizeof(m256)]; //!< Shuffle mask for data ordering. 687 u64a hi_bits_mask; //!< High-bits used in multi-path validation. 688 u64a lo_bits_mask; //!< Low-bits used in multi-path validation. 689 u64a neg_mask; //!< 64 bits negation mask. 690 s32 base_offset; //!< Relative offset of the first byte. 691 s32 last_start; //!< The latest start offset among 8 paths. 692 u32 fail_jump; //!< Jump forward this many bytes on failure. 693 }; 694 695 struct ROSE_STRUCT_INCLUDED_JUMP { 696 u8 code; //!< From enum RoseInstructionCode. 697 u8 squash; //!< FDR confirm squash mask for included literal. 698 u32 child_offset; //!< Program offset of included literal. 699 }; 700 701 struct ROSE_STRUCT_SET_LOGICAL { 702 u8 code; //!< From enum RoseInstructionCode. 703 u32 lkey; //!< Logical key to set. 704 s32 offset_adjust; //!< offsetAdjust from struct Report triggers the flush. 705 }; 706 707 struct ROSE_STRUCT_SET_COMBINATION { 708 u8 code; //!< From enum RoseInstructionCode. 709 u32 ckey; //!< Combination key to set. 710 }; 711 712 struct ROSE_STRUCT_FLUSH_COMBINATION { 713 u8 code; //!< From enum RoseInstructionCode. 714 }; 715 716 struct ROSE_STRUCT_SET_EXHAUST { 717 u8 code; //!< From enum RoseInstructionCode. 718 u32 ekey; //!< Exhaustion key. 719 }; 720 721 struct ROSE_STRUCT_LAST_FLUSH_COMBINATION { 722 u8 code; //!< From enum RoseInstructionCode. 723 }; 724 #endif // ROSE_ROSE_PROGRAM_H 725