Skip to contentSkip to conversation

KVM: x86: emulating RDPID failure shall return #UD rather than #GP

PATCH Applied Robert Hoo 3 participants 3 messages Aug 28, 2020 – Sep 23, 2020

Subsystems (3)
lore
Share & tools
lore

Robert Hoo

author
#0 lore raw

Per Intel's SDM, RDPID takes a #UD if it is unsupported, which is more or less what KVM is emulating when MSR_TSC_AUX is not available. In fact, there are no scenarios in which RDPID is supposed to #GP.

Fixes fb6d4d340e (KVM: x86: emulate RDPID)
---
 arch/x86/kvm/emulate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/emulate.c +1 -1
index d0e2825..571cb86 100644
@@ -3594,7 +3594,7 @@ static int em_rdpid(struct x86_emulate_ctxt *ctxt)
 	u64 tsc_aux = 0;
 
 	if (ctxt->ops->get_msr(ctxt, MSR_TSC_AUX, &tsc_aux))
-		return emulate_gp(ctxt, 0);
+		return emulate_ud(ctxt);
 	ctxt->dst.val = tsc_aux;
 	return X86EMUL_CONTINUE;
 }
Signature · 1 line
1.8.3.1
Reviewed-by
#1 lore raw
Quoted 7 lines · Robert Hoo

Per Intel's SDM, RDPID takes a #UD if it is unsupported, which is more or less what KVM is emulating when MSR_TSC_AUX is not available. In fact, there are no scenarios in which RDPID is supposed to #GP.

Fixes fb6d4d340e (KVM: x86: emulate RDPID)
maintainer Applied
#2 lore raw
In reply to Robert Hoo
Quoted 16 lines · Robert Hoo

Per Intel's SDM, RDPID takes a #UD if it is unsupported, which is more or less what KVM is emulating when MSR_TSC_AUX is not available. In fact, there are no scenarios in which RDPID is supposed to #GP.

Fixes fb6d4d340e (KVM: x86: emulate RDPID)
---
 arch/x86/kvm/emulate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/emulate.c +0 -0
index d0e2825..571cb86 100644

arch/x86/kvm/emulate.c static int em_rdpid(struct x86_emulate_ctxt *ctxt) · line 3600

Quoted 8 lines
arch/x86/kvm/emulate.c +1 -1
@@ -3594,7 +3594,7 @@ static int em_rdpid(struct x86_emulate_ctxt *ctxt)
 	u64 tsc_aux = 0;
 
 	if (ctxt->ops->get_msr(ctxt, MSR_TSC_AUX, &tsc_aux))
-		return emulate_gp(ctxt, 0);
+		return emulate_ud(ctxt);
 	ctxt->dst.val = tsc_aux;
 	return X86EMUL_CONTINUE;
 }

Queued, thanks.

Paolo