All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Jörg Rödel" <joro@8bytes.org>,
	"Andre Przywara" <andre.przywara@arm.com>,
	"kvm ML" <kvm@vger.kernel.org>,
	lkml <linux-kernel@vger.kernel.org>,
	"Tom Lendacky" <thomas.lendacky@amd.com>
Subject: Re: kvm: RDTSCP on AMD
Date: Mon, 10 Dec 2018 21:16:26 +0100	[thread overview]
Message-ID: <20181210201626.GE5482@zn.tnic> (raw)
In-Reply-To: <20181210194725.GM4669@habkost.net>

On Mon, Dec 10, 2018 at 05:47:25PM -0200, Eduardo Habkost wrote:
> On Mon, Dec 10, 2018 at 07:41:53PM +0100, Borislav Petkov wrote:
> > On Mon, Dec 10, 2018 at 04:37:30PM -0200, Eduardo Habkost wrote:
> > > It isn't as simply as reverting commit 33b5e8c03ae7, but we can
> > > surely re-add RDTSCP on pc-*-4.0 and newer.
> > 
> > Sure. If you could only point me to an example how to add that to
> > pc-*-4.0 and newer, I'll gladly cook up a patch and test it.
> 
> Sorry, I forgot to reply to this part.
> 
> See commit 33b5e8c03ae7 for reference.  The differences will be:
> * Instead of removing RDTSCP from builtin_x86_defs, you'll be adding it.
> * Instead of adding rdtscp=on entries to PC_COMPAT_2_4, you'll
>   be adding rdtscp=off entries to PC_COMPAT_3_1.
> 
> PC_COMPAT_3_1 is added by the patch that creates the 4.0
> machine-types.  You can find it on my machine-next branch at:
> 
>   http://github.com/ehabkost/qemu

Thanks for the patient explanation, diff below ontop of your branch.

It is notable to point out that Opteron_G2 - it being family 0xf, model
6 - should not deal with RDTSCP as it doesn't have it.

Although looking at the docs, they say it does but I *have* a K8 laptop
which I just checked and it *doesn't* have RDTSCP in CPUID. So lemme
clarify that aspect first with folks. :)

---
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 9d29c4b1df2a..ebc28e816b04 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -296,6 +296,19 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
 #define PC_COMPAT_3_1 \
     HW_COMPAT_3_1 \
+    {\
+        .driver   = "Opteron_G3" "-" TYPE_X86_CPU,\
+        .property = "rdtscp",\
+        .value    = "off",\
+    },{\
+        .driver   = "Opteron_G4" "-" TYPE_X86_CPU,\
+        .property = "rdtscp",\
+        .value    = "off",\
+    },{\
+        .driver   = "Opteron_G5" "-" TYPE_X86_CPU,\
+        .property = "rdtscp",\
+        .value    = "off",\
+    },
 
 #define PC_COMPAT_3_0 \
     HW_COMPAT_3_0 \
@@ -527,10 +540,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         .driver   = "qemu32" "-" TYPE_X86_CPU,\
         .property = "popcnt",\
         .value    = "on",\
-    },{\
-        .driver   = "Opteron_G2" "-" TYPE_X86_CPU,\
-        .property = "rdtscp",\
-        .value    = "on",\
     },{\
         .driver   = "Opteron_G3" "-" TYPE_X86_CPU,\
         .property = "rdtscp",\
diff --git a/qemu-doc.texi b/qemu-doc.texi
index f7ad1dfe4b69..913b2ef68d54 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -37,6 +37,7 @@
 * QEMU System emulator for non PC targets::
 * QEMU Guest Agent::
 * QEMU User space emulator::
+* System requirements::
 * Implementation notes::
 * Deprecated features::
 * Supported build platforms::
@@ -2813,6 +2814,13 @@ Act as if the host page size was 'pagesize' bytes
 Run the emulation in single step mode.
 @end table
 
+@node System requirements
+@chapter System requirements
+
+@section KVM kernel module
+
+On x86_64 hosts, the default set of CPU features enabled by the KVM accelerator
+require the host to be running Linux v4.5 or newer.
 
 @include qemu-tech.texi
 
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index f81d35e1f914..a7def11b27cd 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -2706,7 +2706,6 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_DE | CPUID_FP87,
         .features[FEAT_1_ECX] =
             CPUID_EXT_CX16 | CPUID_EXT_SSE3,
-        /* Missing: CPUID_EXT2_RDTSCP */
         .features[FEAT_8000_0001_EDX] =
             CPUID_EXT2_LM | CPUID_EXT2_NX | CPUID_EXT2_SYSCALL,
         .features[FEAT_8000_0001_ECX] =
@@ -2730,9 +2729,9 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .features[FEAT_1_ECX] =
             CPUID_EXT_POPCNT | CPUID_EXT_CX16 | CPUID_EXT_MONITOR |
             CPUID_EXT_SSE3,
-        /* Missing: CPUID_EXT2_RDTSCP */
         .features[FEAT_8000_0001_EDX] =
-            CPUID_EXT2_LM | CPUID_EXT2_NX | CPUID_EXT2_SYSCALL,
+            CPUID_EXT2_LM | CPUID_EXT2_NX | CPUID_EXT2_SYSCALL |
+            CPUID_EXT2_RDTSCP,
         .features[FEAT_8000_0001_ECX] =
             CPUID_EXT3_MISALIGNSSE | CPUID_EXT3_SSE4A |
             CPUID_EXT3_ABM | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM,
@@ -2757,10 +2756,9 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_EXT_POPCNT | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 |
             CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | CPUID_EXT_PCLMULQDQ |
             CPUID_EXT_SSE3,
-        /* Missing: CPUID_EXT2_RDTSCP */
         .features[FEAT_8000_0001_EDX] =
             CPUID_EXT2_LM | CPUID_EXT2_PDPE1GB | CPUID_EXT2_NX |
-            CPUID_EXT2_SYSCALL,
+            CPUID_EXT2_SYSCALL | CPUID_EXT2_RDTSCP,
         .features[FEAT_8000_0001_ECX] =
             CPUID_EXT3_FMA4 | CPUID_EXT3_XOP |
             CPUID_EXT3_3DNOWPREFETCH | CPUID_EXT3_MISALIGNSSE |
@@ -2788,10 +2786,9 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_EXT_AES | CPUID_EXT_POPCNT | CPUID_EXT_SSE42 |
             CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_FMA |
             CPUID_EXT_SSSE3 | CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3,
-        /* Missing: CPUID_EXT2_RDTSCP */
         .features[FEAT_8000_0001_EDX] =
             CPUID_EXT2_LM | CPUID_EXT2_PDPE1GB | CPUID_EXT2_NX |
-            CPUID_EXT2_SYSCALL,
+            CPUID_EXT2_SYSCALL | CPUID_EXT2_RDTSCP,
         .features[FEAT_8000_0001_ECX] =
             CPUID_EXT3_TBM | CPUID_EXT3_FMA4 | CPUID_EXT3_XOP |
             CPUID_EXT3_3DNOWPREFETCH | CPUID_EXT3_MISALIGNSSE |

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

  reply	other threads:[~2018-12-10 20:16 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-10 18:13 kvm: RDTSCP on AMD Borislav Petkov
2018-12-10 18:37 ` Eduardo Habkost
2018-12-10 18:41   ` Borislav Petkov
2018-12-10 19:06     ` Eduardo Habkost
2018-12-10 19:42       ` Borislav Petkov
2018-12-10 20:08         ` Eduardo Habkost
2018-12-10 20:39           ` Borislav Petkov
2018-12-11 10:38           ` Daniel P. Berrangé
2018-12-11 11:55             ` Eduardo Habkost
2018-12-11 14:35               ` Daniel P. Berrangé
2018-12-11 15:23               ` Paolo Bonzini
2018-12-11 15:30                 ` Daniel P. Berrangé
2018-12-11 16:14                   ` [PATCH] target-i386: Reenable RDTSCP support on Opteron_G[345] CPU models Borislav Petkov
2018-12-11 16:14                     ` [Qemu-devel] " Borislav Petkov
2018-12-12 19:52                     ` Eduardo Habkost
2018-12-12 19:52                       ` [Qemu-devel] " Eduardo Habkost
2018-12-12 20:08                       ` [PATCH -v2] target-i386: Reenable RDTSCP support on Opteron_G[345] CPU models " Borislav Petkov
2018-12-12 20:08                         ` [Qemu-devel] " Borislav Petkov
2018-12-20 12:10                         ` Eduardo Habkost
2018-12-20 12:10                           ` [Qemu-devel] " Eduardo Habkost
2018-12-10 19:47     ` kvm: RDTSCP on AMD Eduardo Habkost
2018-12-10 20:16       ` Borislav Petkov [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-07-06 12:44 Borislav Petkov
2016-07-06 13:01 ` Paolo Bonzini
2016-07-06 17:34   ` Eduardo Habkost
2016-07-06 21:27     ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181210201626.GE5482@zn.tnic \
    --to=bp@alien8.de \
    --cc=andre.przywara@arm.com \
    --cc=ehabkost@redhat.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=thomas.lendacky@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.