Commit 48520187 authored by Radim Krčmář's avatar Radim Krčmář

KVM: x86: save one bit in ctxt->d

Alignments are exclusive, so 5 modes can be expressed in 3 bits.
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent d3fe959f
...@@ -158,9 +158,11 @@ ...@@ -158,9 +158,11 @@
#define Src2GS (OpGS << Src2Shift) #define Src2GS (OpGS << Src2Shift)
#define Src2Mask (OpMask << Src2Shift) #define Src2Mask (OpMask << Src2Shift)
#define Mmx ((u64)1 << 40) /* MMX Vector instruction */ #define Mmx ((u64)1 << 40) /* MMX Vector instruction */
#define AlignMask ((u64)7 << 41)
#define Aligned ((u64)1 << 41) /* Explicitly aligned (e.g. MOVDQA) */ #define Aligned ((u64)1 << 41) /* Explicitly aligned (e.g. MOVDQA) */
#define Unaligned ((u64)1 << 42) /* Explicitly unaligned (e.g. MOVDQU) */ #define Unaligned ((u64)2 << 41) /* Explicitly unaligned (e.g. MOVDQU) */
#define Avx ((u64)1 << 43) /* Advanced Vector Extensions */ #define Avx ((u64)3 << 41) /* Advanced Vector Extensions */
#define Aligned16 ((u64)4 << 41) /* Aligned to 16 byte boundary (e.g. FXSAVE) */
#define Fastop ((u64)1 << 44) /* Use opcode::u.fastop */ #define Fastop ((u64)1 << 44) /* Use opcode::u.fastop */
#define NoWrite ((u64)1 << 45) /* No writeback */ #define NoWrite ((u64)1 << 45) /* No writeback */
#define SrcWrite ((u64)1 << 46) /* Write back src operand */ #define SrcWrite ((u64)1 << 46) /* Write back src operand */
...@@ -171,7 +173,6 @@ ...@@ -171,7 +173,6 @@
#define NearBranch ((u64)1 << 52) /* Near branches */ #define NearBranch ((u64)1 << 52) /* Near branches */
#define No16 ((u64)1 << 53) /* No 16 bit operand */ #define No16 ((u64)1 << 53) /* No 16 bit operand */
#define IncSP ((u64)1 << 54) /* SP is incremented before ModRM calc */ #define IncSP ((u64)1 << 54) /* SP is incremented before ModRM calc */
#define Aligned16 ((u64)1 << 55) /* Aligned to 16 byte boundary (e.g. FXSAVE) */
#define DstXacc (DstAccLo | SrcAccHi | SrcWrite) #define DstXacc (DstAccLo | SrcAccHi | SrcWrite)
...@@ -638,19 +639,21 @@ static void set_segment_selector(struct x86_emulate_ctxt *ctxt, u16 selector, ...@@ -638,19 +639,21 @@ static void set_segment_selector(struct x86_emulate_ctxt *ctxt, u16 selector,
*/ */
static unsigned insn_alignment(struct x86_emulate_ctxt *ctxt, unsigned size) static unsigned insn_alignment(struct x86_emulate_ctxt *ctxt, unsigned size)
{ {
u64 alignment = ctxt->d & AlignMask;
if (likely(size < 16)) if (likely(size < 16))
return 1; return 1;
if (ctxt->d & Aligned) switch (alignment) {
return size; case Unaligned:
else if (ctxt->d & Unaligned) case Avx:
return 1;
else if (ctxt->d & Avx)
return 1; return 1;
else if (ctxt->d & Aligned16) case Aligned16:
return 16; return 16;
else case Aligned:
default:
return size; return size;
}
} }
static __always_inline int __linearize(struct x86_emulate_ctxt *ctxt, static __always_inline int __linearize(struct x86_emulate_ctxt *ctxt,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment