linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: X86: Fix the decoding of segment overrides in 64bit mode
@ 2018-03-22  8:34 Wanpeng Li
  2018-03-22 10:07 ` Paolo Bonzini
  0 siblings, 1 reply; 14+ messages in thread
From: Wanpeng Li @ 2018-03-22  8:34 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: Paolo Bonzini, Radim Krčmář

From: Wanpeng Li <wanpengli@tencent.com>

Explicit segment overides other than %fs and %gs are documented as ignored by
both Intel and AMD.

In practice, this means that:

 * Explicit uses of %ss don't actually yield #SS[0] for non-canonical
   memory references.
 * Explicit uses of %{e,c,d}s don't override %rbp/%rsp-based memory references
   to yield #GP[0] for non-canonical memory references.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
---
 arch/x86/kvm/emulate.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index dd88158..5091255 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -5148,8 +5148,10 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len)
 		case 0x2e:	/* CS override */
 		case 0x36:	/* SS override */
 		case 0x3e:	/* DS override */
-			has_seg_override = true;
-			ctxt->seg_override = (ctxt->b >> 3) & 3;
+			if (mode != X86EMUL_MODE_PROT64) {
+				has_seg_override = true;
+				ctxt->seg_override = (ctxt->b >> 3) & 3;
+			}
 			break;
 		case 0x64:	/* FS override */
 		case 0x65:	/* GS override */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-03-26 12:27 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-22  8:34 [PATCH] KVM: X86: Fix the decoding of segment overrides in 64bit mode Wanpeng Li
2018-03-22 10:07 ` Paolo Bonzini
2018-03-22 10:19   ` Andrew Cooper
2018-03-22 10:42     ` Paolo Bonzini
2018-03-22 11:04       ` Andrew Cooper
2018-03-22 11:14         ` Wanpeng Li
2018-03-22 12:38         ` Paolo Bonzini
2018-03-22 13:39           ` Wanpeng Li
2018-03-22 13:53             ` Andrew Cooper
2018-03-23 14:27               ` Wanpeng Li
2018-03-23 14:43                 ` Andrew Cooper
2018-03-23 15:04                 ` Paolo Bonzini
2018-03-26 12:25                   ` Wanpeng Li
2018-03-26 12:27                     ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).