Skip to contentSkip to conversation

x86: Use "-cpu host" for PCID tests

PATCH In review Sean Christopherson 3 participants 5 messages Feb 4, 2020 – Feb 5, 2020 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: Use "-cpu host" for PCID tests

Use the host CPU model for the PCID tests to allow testing the various combinations of PCID and INVPCID enabled/disabled without having to manually change the kvm-unit-tests command line. I.e. give users the option of changing the command line *OR* running on a (virtual) CPU with or without PCID and/or INVPCID.

---
 x86/unittests.cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
x86/unittests.cfg +1 -1
index aae1523..25f4535 100644
@@ -228,7 +228,7 @@ extra_params = --append "10000000 `date +%s`"
 
 [pcid]
 file = pcid.flat
-extra_params = -cpu qemu64,+pcid
+extra_params = -cpu host
 arch = x86_64
 
 [rdpru]
Signature · 1 line
2.24.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Sean Christopherson

Use the host CPU model for the PCID tests to allow testing the various combinations of PCID and INVPCID enabled/disabled without having to manually change the kvm-unit-tests command line. I.e. give users the option of changing the command line *OR* running on a (virtual) CPU with or without PCID and/or INVPCID.

---
 x86/unittests.cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
x86/unittests.cfg +0 -0
index aae1523..25f4535 100644

x86/unittests.cfg extra_params = --append "10000000 `date +%s`" · line 234

Quoted 8 lines
x86/unittests.cfg +1 -1
@@ -228,7 +228,7 @@ extra_params = --append "10000000 `date +%s`"
 
 [pcid]
 file = pcid.flat
-extra_params = -cpu qemu64,+pcid
+extra_params = -cpu host
 arch = x86_64
 
 [rdpru]

Actually, is there any reason for *not* using '-cpu host' in any of the tests?

Signature · 1 line
Vitaly
#2 lore raw
Quoted 25 lines · Vitaly Kuznetsov
Quoted 23 lines · Sean Christopherson

Use the host CPU model for the PCID tests to allow testing the various combinations of PCID and INVPCID enabled/disabled without having to manually change the kvm-unit-tests command line. I.e. give users the option of changing the command line *OR* running on a (virtual) CPU with or without PCID and/or INVPCID.

---
 x86/unittests.cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
x86/unittests.cfg +1 -1
index aae1523..25f4535 100644
@@ -228,7 +228,7 @@ extra_params = --append "10000000 `date +%s`"
 
 [pcid]
 file = pcid.flat
-extra_params = -cpu qemu64,+pcid
+extra_params = -cpu host
 arch = x86_64
 
Quoted 6 lines

x86/unittests.cfg extra_params = --append "10000000 `date +%s`" · line 234

Quoted 1 line
x86/unittests.cfg +0 -0
 [rdpru]

Actually, is there any reason for *not* using '-cpu host' in any of the tests?

Emulation tests, e.g. for UMIP, will want "-cpu <base>,+<feature>", but I can't think of any reason why <base> shouldn't be host.

maintainer
#3 lore raw
In reply to Sean Christopherson
Quoted 5 lines · Sean Christopherson

Use the host CPU model for the PCID tests to allow testing the various combinations of PCID and INVPCID enabled/disabled without having to manually change the kvm-unit-tests command line. I.e. give users the option of changing the command line *OR* running on a (virtual) CPU with or without PCID and/or INVPCID.

I don't understand. :)

Quoted 11 lines
---
 x86/unittests.cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
x86/unittests.cfg +0 -0
index aae1523..25f4535 100644

x86/unittests.cfg extra_params = --append "10000000 `date +%s`" · line 234

Quoted 8 lines
x86/unittests.cfg +1 -1
@@ -228,7 +228,7 @@ extra_params = --append "10000000 `date +%s`"
 
 [pcid]
 file = pcid.flat
-extra_params = -cpu qemu64,+pcid
+extra_params = -cpu host
 arch = x86_64
 
 [rdpru]

The main reason not to use "-cpu host" is that it is not supported by QEMU TCG (binary translation mode). But there is no reason not to use "-cpu max", which works with TCG and is synonym with "-cpu host" on KVM. :)

Paolo

Paolo

#4 lore raw
Quoted 8 lines · Paolo Bonzini
Quoted 5 lines · Sean Christopherson

Use the host CPU model for the PCID tests to allow testing the various combinations of PCID and INVPCID enabled/disabled without having to manually change the kvm-unit-tests command line. I.e. give users the option of changing the command line *OR* running on a (virtual) CPU with or without PCID and/or INVPCID.

I don't understand. :)

I was trying to test a change in the code that clears INVPCID in guest's CPUID if PCID isn't supported. To do that, I ran the PCID unit test in L1, using L0 Qemu to hide PCID and/or INVPCID from L1 to iterate over the four combinations of PCID and INVPCID being enabled/disabled. But the test in L1 never exercised INVPCID=y because unittest.cfg runs with the test with "-cpu=qemu64,+pcid".

By using qemu64, the only way to test INVPCID=y is to manually run the test a different "-cpu..." command. The idea behind "-cpu=host" is to enable running different combinations of the test in L1 by hiding features from L1 instead of by running the test with different commands.

In other words, if I create an L1 with PCID=y and INVPCID=y, I expect that running the as-configured PCID unit tests would actually test PCID=Y and INVPCID=y.