x86 queue, 2018-12-11
The following changes since commit 32a1a94dd324d33578dca1dc96d7896a0244d768:
Update version for v3.1.0 release (2018-12-11 17:18:37 +0000)
are available in the Git repository at:
git://github.com/ehabkost/qemu.git tags/x86-next-pull-request
for you to fetch changes up to 0e8916582991b9fd0b94850a8444b8b80d0a0955:
i386: Add "stibp" flag name (2018-12-11 18:50:48 -0200)
----------------------------------------------------------------
x86 queue, 2018-12-11
* New CPU features: MOVDIRI, MOVDIR64B (Liu Jingqi); STIBP (Eduardo Habkost)
* Fix clang build warning (Peter Maydell)
----------------------------------------------------------------
Eduardo Habkost (1):
i386: Add "stibp" flag name
Liu Jingqi (2):
x86/cpu: Enable MOVDIRI cpu feature
x86/cpu: Enable MOVDIR64B cpu feature
Peter Maydell (1):
target/i386/kvm.c: Don't mark cpuid_data as QEMU_PACKED
target/i386/cpu.h | 2 ++ target/i386/cpu.c | 6 +++--- target/i386/kvm.c | 10 +++++++++- 3 files changed, 14 insertions(+), 4 deletions(-)
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
[PULL 1/4] x86/cpu: Enable MOVDIRI cpu feature
From: Liu Jingqi <[email protected]>
MOVDIRI moves doubleword or quadword from register to memory through direct store which is implemented by using write combining (WC) for writing data directly into memory without caching the data.
The bit definition:
CPUID.(EAX=7,ECX=0):ECX[bit 27] MOVDIRI
The release document ref below link:
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf
Message-Id: <[email protected]>
--- target/i386/cpu.h | 1 + target/i386/cpu.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
target/i386/cpu.h +1 -0
@@ -687,6 +687,7 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_ECX_LA57 (1U << 16)#define CPUID_7_0_ECX_RDPID (1U << 22)#define CPUID_7_0_ECX_CLDEMOTE (1U << 25)/* CLDEMOTE Instruction */ +#define CPUID_7_0_ECX_MOVDIRI (1U << 27)/* MOVDIRI Instruction */ #define CPUID_7_0_EDX_AVX512_4VNNIW (1U << 2)/* AVX512 Neural Network Instructions */ #define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3)/* AVX512 Multiply Accumulation Single Precision */
target/i386/cpu.c +1 -1
@@ -1023,7 +1023,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {"avx512bitalg" ,NULL ,"avx512-vpopcntdq" ,NULL ,"la57" ,NULL ,NULL ,NULL ,NULL ,NULL ,"rdpid" ,NULL , -NULL ,"cldemote" ,NULL ,NULL , +NULL ,"cldemote" ,NULL ,"movdiri" , NULL, NULL, NULL, NULL, }, .cpuid = {
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
[PULL 2/4] x86/cpu: Enable MOVDIR64B cpu feature
In reply to Eduardo HabkostFrom: Liu Jingqi <[email protected]>
MOVDIR64B moves 64-bytes as direct-store with 64-bytes write atomicity. Direct store is implemented by using write combining (WC) for writing data directly into memory without caching the data.
The bit definition:
CPUID.(EAX=7,ECX=0):ECX[bit 28] MOVDIR64B
The release document ref below link:
https://software.intel.com/sites/default/files/managed/c5/15/\
architecture-instruction-set-extensions-programming-reference.pdf
Message-Id: <[email protected]>
--- target/i386/cpu.h | 1 + target/i386/cpu.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
target/i386/cpu.h +1 -0
@@ -688,6 +688,7 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_ECX_RDPID (1U << 22)#define CPUID_7_0_ECX_CLDEMOTE (1U << 25)/* CLDEMOTE Instruction */ #define CPUID_7_0_ECX_MOVDIRI (1U << 27)/* MOVDIRI Instruction */ +#define CPUID_7_0_ECX_MOVDIR64B (1U << 28)/* MOVDIR64B Instruction */ #define CPUID_7_0_EDX_AVX512_4VNNIW (1U << 2)/* AVX512 Neural Network Instructions */ #define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3)/* AVX512 Multiply Accumulation Single Precision */
target/i386/cpu.c +1 -1
@@ -1024,7 +1024,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {"la57" ,NULL ,NULL ,NULL ,NULL ,NULL ,"rdpid" ,NULL ,NULL ,"cldemote" ,NULL ,"movdiri" , - NULL, NULL, NULL, NULL, + "movdir64b", NULL, NULL, NULL, }, .cpuid = { .eax = 7,
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
[PULL 3/4] target/i386/kvm.c: Don't mark cpuid_data as QEMU_PACKED
In reply to Eduardo HabkostFrom: Peter Maydell <[email protected]>
clang complains about taking the address of a packed member of a struct:
target/i386/kvm.c:1245:27: warning: taking address of packed member 'cpuid' of class or structure '' may result in an unaligned pointer value [-Waddress-of-packed-member]
c = cpuid_find_entry(&cpuid_data.cpuid, 1, 0);
^~~~~~~~~~~~~~~~
target/i386/kvm.c:1297:31: warning: taking address of packed member 'cpuid' of class or structure '' may result in an unaligned pointer value [-Waddress-of-packed-member]
c = cpuid_find_entry(&cpuid_data.cpuid, kvm_base, 0);
^~~~~~~~~~~~~~~~The kernel's definitions of struct kvm_cpuid2 and struct kvm_cpuid_entry2 are carefully set up with padding fields so that there is no between-struct padding anyway, so the QEMU_PACKED annotation is unnecessary and might result in the compiler generating worse code. Drop it, and instead assert at build time that there is no stray padding.
Message-Id: <[email protected]>
--- target/i386/kvm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
target/i386/kvm.c +9 -1
@@ -864,7 +864,15 @@ int kvm_arch_init_vcpu(CPUState *cs)struct {struct kvm_cpuid2 cpuid;struct kvm_cpuid_entry2 entries[KVM_MAX_CPUID_ENTRIES ]; - } QEMU_PACKED cpuid_data; + } cpuid_data; +/* +* The kernel defines these structs with padding fields so there +* should be no extra padding in our cpuid_data struct. +*/ +QEMU_BUILD_BUG_ON (sizeof (cpuid_data) != +sizeof (struct kvm_cpuid2 ) + +sizeof (struct kvm_cpuid_entry2 ) *KVM_MAX_CPUID_ENTRIES ); +X86CPU *cpu =X86_CPU (cs);CPUX86State *env = &cpu->env;uint32_t limit, i, j, cpuid_i;
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
[PULL 4/4] i386: Add "stibp" flag name
In reply to Eduardo HabkostThe STIBP flag may be supported by the host KVM module, so QEMU can allow it to be configured manually, and it can be exposed to guests when using "-cpu host".
No additional migration code is required because the whole contents of spec_ctrl is already migrated in the "cpu/spec_ctrl" section.
Corresponding KVM patch was submitted at:
https://lore.kernel.org/lkml/[email protected]/
Message-Id: <[email protected]>
--- target/i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/cpu.c +1 -1
@@ -1042,7 +1042,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,"pconfig" ,NULL ,NULL ,NULL ,NULL ,NULL , -NULL ,NULL ,"spec-ctrl" ,NULL , +NULL ,NULL ,"spec-ctrl" ,"stibp" , NULL, "arch-capabilities", NULL, "ssbd", }, .cpuid = {
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
Re: [PULL 4/4] i386: Add "stibp" flag name
Quoted 23 lines · Eduardo Habkost
The STIBP flag may be supported by the host KVM module, so QEMU can allow it to be configured manually, and it can be exposed to guests when using "-cpu host".
No additional migration code is required because the whole contents of
spec_ctrlis already migrated in the "cpu/spec_ctrl" section.Corresponding KVM patch was submitted at:
https://lore.kernel.org/lkml/[email protected]/Signed-off-by Eduardo Habkost <[email protected]>Message-Id: <[email protected]>
Signed-off-by Eduardo Habkost <[email protected]>--- target/i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/i386/cpu.c +0
-0
target/i386/cpu.c static FeatureWordInfo feature_word_info[FEATURE_WORDS] = { · line 1045
Quoted 5 lines
target/i386/cpu.c +1
-1@@ -1042,7 +1042,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,"pconfig" ,NULL ,NULL ,NULL ,NULL ,NULL , - NULL, NULL, "spec-ctrl", NULL, + NULL, NULL, "spec-ctrl", "stibp",
I guess I missed this earlier. Is there a corresponding patch for the AMD STIBP bit (CPUID 0x80000008_EBX[15]) that is in KVM?
Thanks,
Tom
Quoted 4 lines
target/i386/cpu.c +0
-0NULL, "arch-capabilities", NULL, "ssbd", }, .cpuid = {
Re: [PULL 4/4] i386: Add "stibp" flag name
Quoted 19 lines · Thomas
Quoted 18 lines · Eduardo Habkost
The STIBP flag may be supported by the host KVM module, so QEMU can allow it to be configured manually, and it can be exposed to guests when using "-cpu host".
No additional migration code is required because the whole contents of
spec_ctrlis already migrated in the "cpu/spec_ctrl" section.Corresponding KVM patch was submitted at:
https://lore.kernel.org/lkml/[email protected]/Signed-off-by Eduardo Habkost <[email protected]>Message-Id: <[email protected]>
Signed-off-by Eduardo Habkost <[email protected]>--- target/i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines
target/i386/cpu.c static FeatureWordInfo feature_word_info[FEATURE_WORDS] = { · line 1045
Quoted 10 lines
target/i386/cpu.c +1
-1@@ -1042,7 +1042,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,"pconfig" ,NULL ,NULL ,NULL ,NULL ,NULL , - NULL, NULL, "spec-ctrl", NULL, + NULL, NULL, "spec-ctrl", "stibp",I guess I missed this earlier. Is there a corresponding patch for the AMD STIBP bit (CPUID 0x80000008_EBX[15]) that is in KVM?
This Intel STIBP patch is one that many distros have carried downstream since the flaw came to light.
I've not seen any equiv patch for AMD STIBP bit, in either QMEU or libvirt, so guess that's a gap that needs filling.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PULL 4/4] i386: Add "stibp" flag name
Quoted 34 lines · Daniel P. Berrangé
Quoted 19 lines · Thomas
Quoted 18 lines · Eduardo Habkost
The STIBP flag may be supported by the host KVM module, so QEMU can allow it to be configured manually, and it can be exposed to guests when using "-cpu host".
No additional migration code is required because the whole contents of
spec_ctrlis already migrated in the "cpu/spec_ctrl" section.Corresponding KVM patch was submitted at:
https://lore.kernel.org/lkml/[email protected]/Signed-off-by Eduardo Habkost <[email protected]>Message-Id: <[email protected]>
Signed-off-by Eduardo Habkost <[email protected]>--- target/i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 13 lines
target/i386/cpu.c static FeatureWordInfo feature_word_info[FEATURE_WORDS] = { · line 1045
Quoted 10 lines
target/i386/cpu.c +1
-1@@ -1042,7 +1042,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,"pconfig" ,NULL ,NULL ,NULL ,NULL ,NULL , - NULL, NULL, "spec-ctrl", NULL, + NULL, NULL, "spec-ctrl", "stibp",I guess I missed this earlier. Is there a corresponding patch for the AMD STIBP bit (CPUID 0x80000008_EBX[15]) that is in KVM?
Quoted 5 lines
This Intel STIBP patch is one that many distros have carried downstream since the flaw came to light.
I've not seen any equiv patch for AMD STIBP bit, in either QMEU or libvirt, so guess that's a gap that needs filling.
I can submit a "amd-stibp" patch for completeness, although I doubt many people will actually use the flag.
Signature · 1 line
Eduardo
Peter Maydell
AppliedQuoted 13 lines · Eduardo Habkost
The following changes since commit
32a1a94dd324d33578dca1dc96d7896a0244d768:Update version for v3.1.0 release (2018-12-11 17:18:37 +0000)
are available in the Git repository at:
git://github.com/ehabkost/qemu.gittags/x86-next-pull-requestfor you to fetch changes up to
0e8916582991b9fd0b94850a8444b8b80d0a0955:i386: Add "stibp" flag name (2018-12-11 18:50:48 -0200)
Quoted 8 lines
----------------------------------------------------------------
x86 queue, 2018-12-11* New CPU features: MOVDIRI, MOVDIR64B (Liu Jingqi); STIBP (Eduardo Habkost)
* Fix clang build warning (Peter Maydell)----------------------------------------------------------------
Applied, thanks.
-- PMM