|
171 | 171 | #define NearBranch ((u64)1 << 52) /* Near branches */ |
172 | 172 | #define No16 ((u64)1 << 53) /* No 16 bit operand */ |
173 | 173 | #define IncSP ((u64)1 << 54) /* SP is incremented before ModRM calc */ |
| 174 | +#define Aligned16 ((u64)1 << 55) /* Aligned to 16 byte boundary (e.g. FXSAVE) */ |
174 | 175 |
|
175 | 176 | #define DstXacc (DstAccLo | SrcAccHi | SrcWrite) |
176 | 177 |
|
@@ -632,21 +633,24 @@ static void set_segment_selector(struct x86_emulate_ctxt *ctxt, u16 selector, |
632 | 633 | * depending on whether they're AVX encoded or not. |
633 | 634 | * |
634 | 635 | * Also included is CMPXCHG16B which is not a vector instruction, yet it is |
635 | | - * subject to the same check. |
| 636 | + * subject to the same check. FXSAVE and FXRSTOR are checked here too as their |
| 637 | + * 512 bytes of data must be aligned to a 16 byte boundary. |
636 | 638 | */ |
637 | | -static bool insn_aligned(struct x86_emulate_ctxt *ctxt, unsigned size) |
| 639 | +static unsigned insn_alignment(struct x86_emulate_ctxt *ctxt, unsigned size) |
638 | 640 | { |
639 | 641 | if (likely(size < 16)) |
640 | | - return false; |
| 642 | + return 1; |
641 | 643 |
|
642 | 644 | if (ctxt->d & Aligned) |
643 | | - return true; |
| 645 | + return size; |
644 | 646 | else if (ctxt->d & Unaligned) |
645 | | - return false; |
| 647 | + return 1; |
646 | 648 | else if (ctxt->d & Avx) |
647 | | - return false; |
| 649 | + return 1; |
| 650 | + else if (ctxt->d & Aligned16) |
| 651 | + return 16; |
648 | 652 | else |
649 | | - return true; |
| 653 | + return size; |
650 | 654 | } |
651 | 655 |
|
652 | 656 | static __always_inline int __linearize(struct x86_emulate_ctxt *ctxt, |
@@ -704,7 +708,7 @@ static __always_inline int __linearize(struct x86_emulate_ctxt *ctxt, |
704 | 708 | } |
705 | 709 | break; |
706 | 710 | } |
707 | | - if (insn_aligned(ctxt, size) && ((la & (size - 1)) != 0)) |
| 711 | + if (la & (insn_alignment(ctxt, size) - 1)) |
708 | 712 | return emulate_gp(ctxt, 0); |
709 | 713 | return X86EMUL_CONTINUE; |
710 | 714 | bad: |
|
0 commit comments