LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] kvm: fix wrong exception emulation in check_rdtsc
@ 2021-08-18 3:36 Hou Wenlong
2021-08-18 21:07 ` Jim Mattson
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Hou Wenlong @ 2021-08-18 3:36 UTC (permalink / raw)
To: kvm
Cc: Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
Jim Mattson, Joerg Roedel, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, x86, H. Peter Anvin, Avi Kivity, linux-kernel
According to Intel's SDM Vol2 and AMD's APM Vol3, when
CR4.TSD is set, use rdtsc/rdtscp instruction above privilege
level 0 should trigger a #GP.
Fixes: d7eb82030699e ("KVM: SVM: Add intercept checks for remaining group7 instructions")
Signed-off-by: Hou Wenlong <houwenlong93@linux.alibaba.com>
---
arch/x86/kvm/emulate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 2837110e66ed..c589ac832265 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -4206,7 +4206,7 @@ static int check_rdtsc(struct x86_emulate_ctxt *ctxt)
u64 cr4 = ctxt->ops->get_cr(ctxt, 4);
if (cr4 & X86_CR4_TSD && ctxt->ops->cpl(ctxt))
- return emulate_ud(ctxt);
+ return emulate_gp(ctxt, 0);
return X86EMUL_CONTINUE;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] kvm: fix wrong exception emulation in check_rdtsc
2021-08-18 3:36 [PATCH] kvm: fix wrong exception emulation in check_rdtsc Hou Wenlong
@ 2021-08-18 21:07 ` Jim Mattson
2021-08-18 21:43 ` Sean Christopherson
2021-09-21 18:00 ` Paolo Bonzini
2 siblings, 0 replies; 4+ messages in thread
From: Jim Mattson @ 2021-08-18 21:07 UTC (permalink / raw)
To: Hou Wenlong
Cc: kvm, Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov,
Wanpeng Li, Joerg Roedel, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, x86, H. Peter Anvin, Avi Kivity, linux-kernel
On Tue, Aug 17, 2021 at 8:36 PM Hou Wenlong
<houwenlong93@linux.alibaba.com> wrote:
>
> According to Intel's SDM Vol2 and AMD's APM Vol3, when
> CR4.TSD is set, use rdtsc/rdtscp instruction above privilege
> level 0 should trigger a #GP.
>
> Fixes: d7eb82030699e ("KVM: SVM: Add intercept checks for remaining group7 instructions")
> Signed-off-by: Hou Wenlong <houwenlong93@linux.alibaba.com>
Reviewed-by: Jim Mattson <jmattson@google.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] kvm: fix wrong exception emulation in check_rdtsc
2021-08-18 3:36 [PATCH] kvm: fix wrong exception emulation in check_rdtsc Hou Wenlong
2021-08-18 21:07 ` Jim Mattson
@ 2021-08-18 21:43 ` Sean Christopherson
2021-09-21 18:00 ` Paolo Bonzini
2 siblings, 0 replies; 4+ messages in thread
From: Sean Christopherson @ 2021-08-18 21:43 UTC (permalink / raw)
To: Hou Wenlong
Cc: kvm, Paolo Bonzini, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
Joerg Roedel, Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, Avi Kivity, linux-kernel
On Wed, Aug 18, 2021, Hou Wenlong wrote:
> According to Intel's SDM Vol2 and AMD's APM Vol3, when
> CR4.TSD is set, use rdtsc/rdtscp instruction above privilege
> level 0 should trigger a #GP.
>
> Fixes: d7eb82030699e ("KVM: SVM: Add intercept checks for remaining group7 instructions")
> Signed-off-by: Hou Wenlong <houwenlong93@linux.alibaba.com>
> ---
> arch/x86/kvm/emulate.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 2837110e66ed..c589ac832265 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -4206,7 +4206,7 @@ static int check_rdtsc(struct x86_emulate_ctxt *ctxt)
> u64 cr4 = ctxt->ops->get_cr(ctxt, 4);
>
> if (cr4 & X86_CR4_TSD && ctxt->ops->cpl(ctxt))
> - return emulate_ud(ctxt);
> + return emulate_gp(ctxt, 0);
Heh, I was having some serious deja vu, but the fix I was thinking of was
for em_rdpid, and that was changing #GP -> #UD (commit a9e2e0ae6860).
Reviewed-by: Sean Christopherson <seanjc@google.com>
> return X86EMUL_CONTINUE;
> }
> --
> 2.31.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] kvm: fix wrong exception emulation in check_rdtsc
2021-08-18 3:36 [PATCH] kvm: fix wrong exception emulation in check_rdtsc Hou Wenlong
2021-08-18 21:07 ` Jim Mattson
2021-08-18 21:43 ` Sean Christopherson
@ 2021-09-21 18:00 ` Paolo Bonzini
2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2021-09-21 18:00 UTC (permalink / raw)
To: Hou Wenlong, kvm
Cc: Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
Joerg Roedel, Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, Avi Kivity, linux-kernel
On 18/08/21 05:36, Hou Wenlong wrote:
> According to Intel's SDM Vol2 and AMD's APM Vol3, when
> CR4.TSD is set, use rdtsc/rdtscp instruction above privilege
> level 0 should trigger a #GP.
>
> Fixes: d7eb82030699e ("KVM: SVM: Add intercept checks for remaining group7 instructions")
> Signed-off-by: Hou Wenlong <houwenlong93@linux.alibaba.com>
> ---
> arch/x86/kvm/emulate.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 2837110e66ed..c589ac832265 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -4206,7 +4206,7 @@ static int check_rdtsc(struct x86_emulate_ctxt *ctxt)
> u64 cr4 = ctxt->ops->get_cr(ctxt, 4);
>
> if (cr4 & X86_CR4_TSD && ctxt->ops->cpl(ctxt))
> - return emulate_ud(ctxt);
> + return emulate_gp(ctxt, 0);
>
> return X86EMUL_CONTINUE;
> }
>
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-21 18:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-18 3:36 [PATCH] kvm: fix wrong exception emulation in check_rdtsc Hou Wenlong
2021-08-18 21:07 ` Jim Mattson
2021-08-18 21:43 ` Sean Christopherson
2021-09-21 18:00 ` 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).