|
189 | 189 | #define X8(x...) X4(x), X4(x)
|
190 | 190 | #define X16(x...) X8(x), X8(x)
|
191 | 191 |
|
192 |
| -#define NR_FASTOP (ilog2(sizeof(ulong)) + 1) |
193 |
| -#define RET_LENGTH (1 + (4 * IS_ENABLED(CONFIG_RETHUNK)) + \ |
194 |
| - IS_ENABLED(CONFIG_SLS)) |
195 |
| -#define FASTOP_LENGTH (ENDBR_INSN_SIZE + 7 + RET_LENGTH) |
196 |
| -#define FASTOP_SIZE (8 << ((FASTOP_LENGTH > 8) & 1) << ((FASTOP_LENGTH > 16) & 1)) |
197 |
| -static_assert(FASTOP_LENGTH <= FASTOP_SIZE); |
198 |
| - |
199 | 192 | struct opcode {
|
200 | 193 | u64 flags;
|
201 | 194 | u8 intercept;
|
@@ -310,9 +303,15 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
|
310 | 303 | * Moreover, they are all exactly FASTOP_SIZE bytes long, so functions for
|
311 | 304 | * different operand sizes can be reached by calculation, rather than a jump
|
312 | 305 | * table (which would be bigger than the code).
|
| 306 | + * |
| 307 | + * The 16 byte alignment, considering 5 bytes for the RET thunk, 3 for ENDBR |
| 308 | + * and 1 for the straight line speculation INT3, leaves 7 bytes for the |
| 309 | + * body of the function. Currently none is larger than 4. |
313 | 310 | */
|
314 | 311 | static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
|
315 | 312 |
|
| 313 | +#define FASTOP_SIZE 16 |
| 314 | + |
316 | 315 | #define __FOP_FUNC(name) \
|
317 | 316 | ".align " __stringify(FASTOP_SIZE) " \n\t" \
|
318 | 317 | ".type " name ", @function \n\t" \
|
@@ -446,9 +445,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
|
446 | 445 | * RET | JMP __x86_return_thunk [1,5 bytes; CONFIG_RETHUNK]
|
447 | 446 | * INT3 [1 byte; CONFIG_SLS]
|
448 | 447 | */
|
449 |
| -#define SETCC_LENGTH (ENDBR_INSN_SIZE + 3 + RET_LENGTH) |
450 |
| -#define SETCC_ALIGN (4 << ((SETCC_LENGTH > 4) & 1) << ((SETCC_LENGTH > 8) & 1)) |
451 |
| -static_assert(SETCC_LENGTH <= SETCC_ALIGN); |
| 448 | +#define SETCC_ALIGN 16 |
452 | 449 |
|
453 | 450 | #define FOP_SETCC(op) \
|
454 | 451 | ".align " __stringify(SETCC_ALIGN) " \n\t" \
|
|
0 commit comments