Skip to content

Commit 10e38fc

Browse files
anadavbonzini
authored andcommitted
KVM: x86: Emulator flag for instruction that only support 16-bit addresses in real mode
Certain instructions, such as monitor and xsave do not support big real mode and cause a #GP exception if any of the accessed bytes effective address are not within [0, 0xffff]. This patch introduces a flag to mark these instructions, including the necassary checks. Signed-off-by: Nadav Amit <namit@cs.technion.ac.il> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 44583cb commit 10e38fc

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎arch/x86/kvm/emulate.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
#define NoMod ((u64)1 << 47) /* Mod field is ignored */
165165
#define Intercept ((u64)1 << 48) /* Has valid intercept field */
166166
#define CheckPerm ((u64)1 << 49) /* Has valid check_perm field */
167+
#define NoBigReal ((u64)1 << 50) /* No big real mode */
167168

168169
#define DstXacc (DstAccLo | SrcAccHi | SrcWrite)
169170

@@ -640,7 +641,12 @@ static int __linearize(struct x86_emulate_ctxt *ctxt,
640641
if (!fetch && (desc.type & 8) && !(desc.type & 2))
641642
goto bad;
642643
lim = desc_limit_scaled(&desc);
643-
if ((desc.type & 8) || !(desc.type & 4)) {
644+
if ((ctxt->mode == X86EMUL_MODE_REAL) && !fetch &&
645+
(ctxt->d & NoBigReal)) {
646+
/* la is between zero and 0xffff */
647+
if (la > 0xffff || (u32)(la + size - 1) > 0xffff)
648+
goto bad;
649+
} else if ((desc.type & 8) || !(desc.type & 4)) {
644650
/* expand-up segment */
645651
if (addr.ea > lim || (u32)(addr.ea + size - 1) > lim)
646652
goto bad;

0 commit comments

Comments
 (0)