QEMU changes for 7.0 soft freeze
The following changes since commit 99c53410bc9d50e556f565b0960673cccb566452:
Merge remote-tracking branch 'remotes/thuth-gitlab/tags/pull-request-2022-02-28' into staging (2022-03-01 13:25:54 +0000)
are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to d722beb6ac1d457bfa3d7dd5bce7bcea5ea45540:
gitlab-ci: do not run tests with address sanitizer (2022-03-08 12:34:12 +0100)
----------------------------------------------------------------
* whpx fixes in preparation for GDB support (Ivan)
* VSS header fixes (Marc-André)
* 5-level EPT support (Vitaly)
* AMX support (Jing Liu & Yang Zhong)
* Bundle changes to MSI routes (Longpeng)
* More precise emulation of #SS (Gareth)
* Disable ASAN testing
----------------------------------------------------------------
Gareth Webb (1):
target/i386: Throw a #SS when loading a non-canonical IST
Ivan Shcherbakov (2):
whpx: Fixed reporting of the CPU context to GDB for 64-bit
whpx: Fixed incorrect CR8/TPR synchronization
Jing Liu (5):
x86: Fix the 64-byte boundary enumeration for extended state
x86: Add AMX XTILECFG and XTILEDATA components
x86: Add XFD faulting bit for state components
x86: Add AMX CPUIDs enumeration
x86: add support for KVM_CAP_XSAVE2 and AMX state migration
Longpeng (Mike) (2):
kvm-irqchip: introduce new API to support route change kvm/msi: do explicit commit when adding msi routes
Marc-André Lureau (3):
meson: fix generic location of vss headers qga/vss-win32: check old VSS SDK headers qga/vss: update informative message about MinGW
Maxim Levitsky (1):
KVM: SVM: always set MSR_AMD64_TSC_RATIO to default value
Paolo Bonzini (4):
update meson-buildoptions.sh
target/i386: only include bits in pg_mode if they are not ignored
linux-headers: include missing changes from 5.17
gitlab-ci: do not run tests with address sanitizer
Vitaly Kuznetsov (2):
vmxcap: Add 5-level EPT bit
i386: Add Icelake-Server-v6 CPU model with 5-level EPT support
Yang Zhong (1):
x86: Grant AMX permission for guest
Zeng Guang (1):
x86: Support XFD and AMX xsave data migration
.gitlab-ci.d/buildtest.yml | 2 - accel/kvm/kvm-all.c | 7 +- accel/stubs/kvm-stub.c | 2 +- hw/misc/ivshmem.c | 5 +- hw/vfio/pci.c | 5 +- hw/virtio/virtio-pci.c | 4 +- include/sysemu/kvm.h | 23 ++++++- linux-headers/asm-x86/kvm.h | 3 + linux-headers/linux/kvm.h | 4 ++ meson.build | 5 +- qga/meson.build | 2 +- qga/vss-win32/install.cpp | 4 ++ qga/vss-win32/provider.cpp | 4 ++ qga/vss-win32/vss-common.h | 3 +- scripts/kvm/vmxcap | 1 + scripts/meson-buildoptions.sh | 2 +- target/i386/cpu.c | 84 +++++++++++++++++++++-- target/i386/cpu.h | 43 +++++++++++- target/i386/kvm/kvm-cpu.c | 11 +-- target/i386/kvm/kvm.c | 125 ++++++++++++++++++++++++++++++----- target/i386/kvm/kvm_i386.h | 1 + target/i386/machine.c | 46 +++++++++++++ target/i386/tcg/seg_helper.c | 49 +++++++++++++- target/i386/tcg/sysemu/excp_helper.c | 40 +---------- target/i386/whpx/whpx-all.c | 30 ++++++++- target/i386/xsave_helper.c | 28 ++++++++ 26 files changed, 449 insertions(+), 84 deletions(-)
Signature · 1 line
2.35.1
[PULL 01/22] whpx: Fixed reporting of the CPU context to GDB for 64-bit
From: Ivan Shcherbakov <[email protected]>
Make sure that pausing the VM while in 64-bit mode will set the HF_CS64_MASK flag in env->hflags (see x86_update_hflags() in target/i386/cpu.c).
Without it, the code in gdbstub.c would only use the 32-bit register values when debugging 64-bit targets, making debugging effectively impossible.
Message-Id: <[email protected]>
--- target/i386/whpx/whpx-all.c | 2 ++ 1 file changed, 2 insertions(+)
target/i386/whpx/whpx-all.c +2 -0
@@ -604,6 +604,8 @@ static void whpx_get_registers(CPUState *cpu)whpx_apic_get (x86_cpu->apic_state); } +x86_update_hflags (env); +return ; }
Signature · 1 line
2.35.1
[PULL 06/22] qga/vss: update informative message about MinGW
In reply to Paolo BonziniFrom: Marc-André Lureau <[email protected]>
The headers are now all available in MinGW master branch. (commit 13390dbbf885f and earlier) aiming for 10.0.
Message-Id: <[email protected]>
--- qga/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qga/meson.build +1 -1
@@ -15,7 +15,7 @@ have_qga_vss = get_option('qga_vss') \ If your Visual Studio installation doesn't have the VSS headers, Please download and install Microsoft VSS SDK: http://www.microsoft.com/en-us/download/details.aspx?id=23490 - On POSIX-systems, MinGW doesn't yet provide working headers. + On POSIX-systems, MinGW should provide headers in >=10.0 releases. you can extract the SDK headers by: $ scripts/extract-vsssdk-headers setup.exe The headers are extracted in the directory 'inc/win2003'.
Signature · 1 line
2.35.1
[PULL 05/22] qga/vss-win32: check old VSS SDK headers
In reply to Paolo BonziniFrom: Marc-André Lureau <[email protected]>
The VssCoordinator & VssAdmin interfaces have been moved to vsadmin.h in the Windows SDK.
Message-Id: <[email protected]>
--- meson.build | 3 +++ qga/vss-win32/install.cpp | 4 ++++ qga/vss-win32/provider.cpp | 4 ++++ qga/vss-win32/vss-common.h | 3 ++- 4 files changed, 13 insertions(+), 1 deletion(-)
meson.build +3 -0
@@ -1933,12 +1933,15 @@ config_host_data.set('CONFIG_AF_VSOCK', cc.compiles(gnu_source_prefix + ''' }''')) have_vss = false +have_vss_sdk = false # old xp/2003 SDK if targetos == 'windows' and link_language == 'cpp' have_vss = cxx.compiles(''' #define __MIDL_user_allocate_free_DEFINED__ #include <vss.h> int main(void) { return VSS_CTX_BACKUP; }''') + have_vss_sdk = cxx.has_header('vscoordint.h') endif +config_host_data.set('HAVE_VSS_SDK', have_vss_sdk) have_ntddscsi = false if targetos == 'windows'
qga/vss-win32/install.cpp +4 -0
@@ -13,7 +13,11 @@ #include "qemu/osdep.h" #include "vss-common.h" +#ifdef HAVE_VSS_SDK #include <vscoordint.h> +#else +#include <vsadmin.h> +#endif #include "install.h" #include <wbemidl.h> #include <comdef.h>
qga/vss-win32/provider.cpp +4 -0
@@ -12,7 +12,11 @@ #include "qemu/osdep.h" #include "vss-common.h" +#ifdef HAVE_VSS_SDK #include <vscoordint.h> +#else +#include <vsadmin.h> +#endif #include <vsprov.h> #define VSS_TIMEOUT_MSEC (60*1000)
qga/vss-win32/vss-common.h +2 -1
@@ -64,12 +64,13 @@ const CLSID CLSID_QGAVSSProvider = { 0x6e6a3492, 0x8d4d, 0x440c,const TCHAR g_szClsid[] =TEXT ("{6E6A3492-8D4D-440C-9619-5E5D0CC31CA8}" );const TCHAR g_szProgid[] =TEXT ("QGAVSSProvider" ); +#ifdef HAVE_VSS_SDK /* Enums undefined in VSS SDK 7.2 but defined in newer Windows SDK */ enum __VSS_VOLUME_SNAPSHOT_ATTRIBUTES {VSS_VOLSNAP_ATTR_NO_AUTORECOVERY =0x00000002 ,VSS_VOLSNAP_ATTR_TXF_RECOVERY =0x02000000 }; - +#endif /* COM pointer utility; call ->Release() when it goes out of scope */ template <class T>
Signature · 1 line
2.35.1
[PULL 17/22] x86: Add AMX CPUIDs enumeration
In reply to Paolo BonziniFrom: Jing Liu <[email protected]>
Add AMX primary feature bits XFD and AMX_TILE to enumerate the CPU's AMX capability. Meanwhile, add AMX TILE and TMUL CPUID leaf and subleaves which exist when AMX TILE is present to provide the maximum capability of TILE and TMUL.
Message-Id: <[email protected]>
--- target/i386/cpu.c | 55 ++++++++++++++++++++++++++++++++++++++++--- target/i386/kvm/kvm.c | 4 +++- 2 files changed, 55 insertions(+), 4 deletions(-)
target/i386/cpu.c +52 -3
@@ -575,6 +575,18 @@ static CPUCacheInfo legacy_l3_cache = {#define INTEL_PT_CYCLE_BITMAP 0x1fff/* Support 0,2^(0~11) */ #define INTEL_PT_PSB_BITMAP (0x003f << 16)/* Support 2K,4K,8K,16K,32K,64K */ +/* CPUID Leaf 0x1D constants: */ +#define INTEL_AMX_TILE_MAX_SUBLEAF 0x1 +#define INTEL_AMX_TOTAL_TILE_BYTES 0x2000 +#define INTEL_AMX_BYTES_PER_TILE 0x400 +#define INTEL_AMX_BYTES_PER_ROW 0x40 +#define INTEL_AMX_TILE_MAX_NAMES 0x8 +#define INTEL_AMX_TILE_MAX_ROWS 0x10 + +/* CPUID Leaf 0x1E constants: */ +#define INTEL_AMX_TMUL_MAX_K 0x10 +#define INTEL_AMX_TMUL_MAX_N 0x40 +void x86_cpu_vendor_words2str (char *dst,uint32_t vendor1,uint32_t vendor2,uint32_t vendor3) {
@@ -844,8 +856,8 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = {"avx512-vp2intersect" ,NULL ,"md-clear" ,NULL ,NULL ,NULL ,"serialize" ,NULL ,"tsx-ldtrk" ,NULL ,NULL /* pconfig */ ,NULL , -NULL ,NULL ,NULL ,"avx512-fp16" , -NULL ,NULL ,"spec-ctrl" ,"stibp" , +NULL ,NULL ,"amx-bf16" ,"avx512-fp16" , +"amx-tile" ,"amx-int8" ,"spec-ctrl" ,"stibp" , NULL, "arch-capabilities", "core-capability", "ssbd", }, .cpuid = {
@@ -910,7 +922,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = { .type = CPUID_FEATURE_WORD, .feat_names = {"xsaveopt" ,"xsavec" ,"xgetbv1" ,"xsaves" , -NULL ,NULL ,NULL ,NULL , +"xfd" ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL , NULL, NULL, NULL, NULL,
@@ -5586,6 +5598,43 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, }break ; } +case 0x1D : { +/* AMX TILE */ + *eax =0 ; + *ebx =0 ; + *ecx =0 ; + *edx =0 ; +if (!(env->features[FEAT_7_0_EDX ] &CPUID_7_0_EDX_AMX_TILE )) { +break ; + } + +if (count ==0 ) { +/* Highest numbered palette subleaf */ + *eax =INTEL_AMX_TILE_MAX_SUBLEAF ; + }else if (count ==1 ) { + *eax =INTEL_AMX_TOTAL_TILE_BYTES | + (INTEL_AMX_BYTES_PER_TILE <<16 ); + *ebx =INTEL_AMX_BYTES_PER_ROW | (INTEL_AMX_TILE_MAX_NAMES <<16 ); + *ecx =INTEL_AMX_TILE_MAX_ROWS ; + } +break ; + } +case 0x1E : { +/* AMX TMUL */ + *eax =0 ; + *ebx =0 ; + *ecx =0 ; + *edx =0 ; +if (!(env->features[FEAT_7_0_EDX ] &CPUID_7_0_EDX_AMX_TILE )) { +break ; + } + +if (count ==0 ) { +/* Highest numbered palette subleaf */ + *ebx =INTEL_AMX_TMUL_MAX_K | (INTEL_AMX_TMUL_MAX_N <<8 ); + } +break ; + }case 0x40000000 :/* * CPUID code in kvm_arch_init_vcpu() ignores stuff
target/i386/kvm/kvm.c +3 -1
@@ -1780,7 +1780,9 @@ int kvm_arch_init_vcpu(CPUState *cs) c = &cpuid_data.entries[cpuid_i++]; }break ; -case 0x14 : { +case 0x14 : +case 0x1d : +case 0x1e : {uint32_t times; c->function = i;
Signature · 1 line
2.35.1
[PULL 02/22] whpx: Fixed incorrect CR8/TPR synchronization
In reply to Paolo BonziniFrom: Ivan Shcherbakov <[email protected]>
This fixes the following error triggered when stopping and resuming a 64-bit Linux kernel via gdb:
qemu-system-x86_64.exe: WHPX: Failed to set virtual processor context, hr=c0350005
The previous logic for synchronizing the values did not take into account that the lower 4 bits of the CR8 register, containing the priority level, mapped to bits 7:4 of the APIC.TPR register (see section 10.8.6.1 of Volume 3 of Intel 64 and IA-32 Architectures Software Developer's Manual). The caused WHvSetVirtualProcessorRegisters() to fail with an error, effectively preventing GDB from changing the guest context.
Message-Id: <[email protected]>
--- target/i386/whpx/whpx-all.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
target/i386/whpx/whpx-all.c +27 -1
@@ -256,6 +256,21 @@ static int whpx_set_tsc(CPUState *cpu)return 0 ; } +/* +* The CR8 register in the CPU is mapped to the TPR register of the APIC, +* however, they use a slightly different encoding. Specifically: +* +* APIC.TPR[bits 7:4] = CR8[bits 3:0] +* +* This mechanism is described in section 10.8.6.1 of Volume 3 of Intel 64 +* and IA-32 Architectures Software Developer's Manual. +*/ + +static uint64_t whpx_apic_tpr_to_cr8 (uint64_t tpr) +{ +return tpr >>4 ; +} +static void whpx_set_registers (CPUState *cpu,int level) {struct whpx_state *whpx = &whpx_global;
@@ -284,7 +299,7 @@ static void whpx_set_registers(CPUState *cpu, int level) v86 = (env->eflags &VM_MASK ); r86 = !(env->cr[0 ] &CR0_PE_MASK ); - vcpu->tpr =cpu_get_apic_tpr (x86_cpu->apic_state); + vcpu->tpr =whpx_apic_tpr_to_cr8 (cpu_get_apic_tpr (x86_cpu->apic_state)); vcpu->apic_base =cpu_get_apic_base (x86_cpu->apic_state); idx =0 ;
@@ -475,6 +490,17 @@ static void whpx_get_registers(CPUState *cpu) hr); } +if (whpx_apic_in_platform ()) { +/* +* Fetch the TPR value from the emulated APIC. It may get overwritten +* below with the value from CR8 returned by +* WHvGetVirtualProcessorRegisters(). +*/ +whpx_apic_get (x86_cpu->apic_state); + vcpu->tpr =whpx_apic_tpr_to_cr8 ( +cpu_get_apic_tpr (x86_cpu->apic_state)); + } + idx =0 ;/* Indexes for first 16 registers match between HV and QEMU definitions */
Signature · 1 line
2.35.1
[PULL 07/22] update meson-buildoptions.sh
In reply to Paolo Bonzini--- scripts/meson-buildoptions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/meson-buildoptions.sh +1 -1
@@ -20,7 +20,6 @@ meson_options_help() { printf "%s\n" ' --enable-malloc=CHOICE choose memory allocator to use [system] (choices:' printf "%s\n" ' jemalloc/system/tcmalloc)' printf "%s\n" ' --enable-profiler profiler support' - printf "%s\n" ' --enable-qga-vss build QGA VSS support' printf "%s\n" ' --enable-qom-cast-debug cast debugging support' printf "%s\n" ' --enable-rng-none dummy RNG, avoid using /dev/(u)random and' printf "%s\n" ' getrandom()'
@@ -97,6 +96,7 @@ meson_options_help() { printf "%s\n" ' parallels parallels image format support' printf "%s\n" ' qcow1 qcow1 image format support' printf "%s\n" ' qed qed image format support' + printf "%s\n" ' qga-vss build QGA VSS support (broken with MinGW)' printf "%s\n" ' rbd Ceph block device driver' printf "%s\n" ' replication replication support' printf "%s\n" ' sdl SDL user interface'
Signature · 1 line
2.35.1
[PULL 08/22] kvm-irqchip: introduce new API to support route change
In reply to Paolo BonziniFrom: "Longpeng(Mike)" <[email protected]>
Paolo suggested adding the new API to support route changes [1]. We should invoke kvm_irqchip_begin_route_changes() before changing the routes, increasing the KVMRouteChange.changes if the routes are changed, and commit the changes at last.
[1] https://lists.gnu.org/archive/html/qemu-devel/2021-11/msg02898.html
Message-Id: <[email protected]>
--- include/sysemu/kvm.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
include/sysemu/kvm.h +19 -0
@@ -224,6 +224,11 @@ DECLARE_INSTANCE_CHECKER(KVMState, KVM_STATE,extern KVMState *kvm_state;typedef struct Notifier Notifier ; +typedef struct KVMRouteChange { +KVMState *s; +int changes; +}KVMRouteChange ; +/* external API */ bool kvm_has_free_slot (MachineState *ms);
@@ -494,6 +499,20 @@ int kvm_irqchip_add_msi_route(KVMState *s, int vector, PCIDevice *dev);int kvm_irqchip_update_msi_route (KVMState *s,int virq,MSIMessage msg,PCIDevice *dev);void kvm_irqchip_commit_routes (KVMState *s); + +static inline KVMRouteChange kvm_irqchip_begin_route_changes (KVMState *s) +{ +return (KVMRouteChange ) { .s = s, .changes =0 }; +} + +static inline void kvm_irqchip_commit_route_changes (KVMRouteChange *c) +{ +if (c->changes) { +kvm_irqchip_commit_routes (c->s); + c->changes =0 ; + } +} +void kvm_irqchip_release_virq (KVMState *s,int virq);int kvm_irqchip_add_adapter_route (KVMState *s,AdapterInfo *adapter);
Signature · 1 line
2.35.1
[PULL 03/22] vmxcap: Add 5-level EPT bit
In reply to Paolo BonziniFrom: Vitaly Kuznetsov <[email protected]>
5-level EPT is present in Icelake Server CPUs and is supported by QEMU ('vmx-page-walk-5').
Message-Id: <[email protected]>
--- scripts/kvm/vmxcap | 1 + 1 file changed, 1 insertion(+)
scripts/kvm/vmxcap +1 -0
@@ -249,6 +249,7 @@ controls = [ bits = { 0: 'Execute-only EPT translations', 6: 'Page-walk length 4', + 7: 'Page-walk length 5', 8: 'Paging-structure memory type UC', 14: 'Paging-structure memory type WB', 16: '2MB EPT pages',
Signature · 1 line
2.35.1
[PULL 18/22] x86: add support for KVM_CAP_XSAVE2 and AMX state migration
In reply to Paolo BonziniFrom: Jing Liu <[email protected]>
When dynamic xfeatures (e.g. AMX) are used by the guest, the xsave area would be larger than 4KB. KVM_GET_XSAVE2 and KVM_SET_XSAVE under KVM_CAP_XSAVE2 works with a xsave buffer larger than 4KB. Always use the new ioctls under KVM_CAP_XSAVE2 when KVM supports it.
Message-Id: <[email protected]>
--- target/i386/cpu.h | 4 ++++ target/i386/kvm/kvm.c | 42 ++++++++++++++++++++++++-------------- target/i386/xsave_helper.c | 28 +++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 15 deletions(-)
target/i386/cpu.h +4 -0
@@ -1527,6 +1527,10 @@ typedef struct CPUX86State {uint64_t opmask_regs[NB_OPMASK_REGS ];YMMReg zmmh_regs[CPU_NB_REGS ];ZMMReg hi16_zmm_regs[CPU_NB_REGS ]; +#ifdef TARGET_X86_64 +uint8_t xtilecfg[64 ]; +uint8_t xtiledata[8192 ]; +#endif /* sysenter registers */ uint32_t sysenter_cs;
target/i386/kvm/kvm.c +27 -15
77 lines not on this page · raw message
target/i386/xsave_helper.c +28 -0
@@ -126,6 +126,20 @@ void x86_cpu_xsave_all_areas(X86CPU *cpu, void *buf, uint32_t buflen) memcpy(pkru, &env->pkru, sizeof(env->pkru)); } + + e = &x86_ext_save_areas[XSTATE_XTILE_CFG_BIT ]; +if (e->size && e->offset) { +XSaveXTILECFG *tilecfg = buf + e->offset; + +memcpy (tilecfg, &env->xtilecfg,sizeof (env->xtilecfg)); + } + + e = &x86_ext_save_areas[XSTATE_XTILE_DATA_BIT ]; +if (e->size && e->offset && buflen >= e->size + e->offset) { +XSaveXTILEDATA *tiledata = buf + e->offset; + +memcpy (tiledata, &env->xtiledata,sizeof (env->xtiledata)); + }#endif }
@@ -247,5 +261,19 @@ void x86_cpu_xrstor_all_areas(X86CPU *cpu, const void *buf, uint32_t buflen) pkru = buf + e->offset; memcpy(&env->pkru, pkru, sizeof(env->pkru)); } + + e = &x86_ext_save_areas[XSTATE_XTILE_CFG_BIT ]; +if (e->size && e->offset) { +const XSaveXTILECFG *tilecfg = buf + e->offset; + +memcpy (&env->xtilecfg, tilecfg,sizeof (env->xtilecfg)); + } + + e = &x86_ext_save_areas[XSTATE_XTILE_DATA_BIT ]; +if (e->size && e->offset && buflen >= e->size + e->offset) { +const XSaveXTILEDATA *tiledata = buf + e->offset; + +memcpy (&env->xtiledata, tiledata,sizeof (env->xtiledata)); + }#endif }
Signature · 1 line
2.35.1
[PULL 09/22] kvm/msi: do explicit commit when adding msi routes
In reply to Paolo BonziniFrom: "Longpeng(Mike)" <[email protected]>
We invoke the kvm_irqchip_commit_routes() for each addition to MSI route table, which is not efficient if we are adding lots of routes in some cases.
This patch lets callers invoke the kvm_irqchip_commit_routes(), so the callers can decide how to optimize.
[1] https://lists.gnu.org/archive/html/qemu-devel/2021-11/msg00967.html
Message-Id: <[email protected]>
--- accel/kvm/kvm-all.c | 7 ++++--- accel/stubs/kvm-stub.c | 2 +- hw/misc/ivshmem.c | 5 ++++- hw/vfio/pci.c | 5 ++++- hw/virtio/virtio-pci.c | 4 +++- include/sysemu/kvm.h | 4 ++-- target/i386/kvm/kvm.c | 4 +++- 7 files changed, 21 insertions(+), 10 deletions(-)
accel/kvm/kvm-all.c +4 -3
@@ -1961,10 +1961,11 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg)return kvm_set_irq (s, route->kroute.gsi,1 ); } -int kvm_irqchip_add_msi_route (KVMState *s,int vector,PCIDevice *dev) +int kvm_irqchip_add_msi_route (KVMRouteChange *c,int vector,PCIDevice *dev) {struct kvm_irq_routing_entry kroute = {};int virq; +KVMState *s = c->s;MSIMessage msg = {0 ,0 };if (pci_available && dev) {
@@ -2004,7 +2005,7 @@ int kvm_irqchip_add_msi_route(KVMState *s, int vector, PCIDevice *dev)kvm_add_routing_entry (s, &kroute);kvm_arch_add_msi_route_post (&kroute, vector, dev); -kvm_irqchip_commit_routes (s); + c->changes++;return virq; }
@@ -2162,7 +2163,7 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg)abort (); } -int kvm_irqchip_add_msi_route (KVMState *s,int vector,PCIDevice *dev) +int kvm_irqchip_add_msi_route (KVMRouteChange *c,int vector,PCIDevice *dev) {return -ENOSYS ; }
accel/stubs/kvm-stub.c +1 -1
@@ -81,7 +81,7 @@ int kvm_on_sigbus(int code, void *addr) }#ifndef CONFIG_USER_ONLY -int kvm_irqchip_add_msi_route (KVMState *s,int vector,PCIDevice *dev) +int kvm_irqchip_add_msi_route (KVMRouteChange *c,int vector,PCIDevice *dev) {return -ENOSYS ; }
hw/misc/ivshmem.c +4 -1
@@ -424,16 +424,19 @@ static void ivshmem_add_kvm_msi_virq(IVShmemState *s, int vector, Error **errp) {PCIDevice *pdev =PCI_DEVICE (s); +KVMRouteChange c;int ret;IVSHMEM_DPRINTF ("ivshmem_add_kvm_msi_virq vector:%d\n" , vector);assert (!s->msi_vectors[vector].pdev); - ret =kvm_irqchip_add_msi_route (kvm_state, vector, pdev); + c =kvm_irqchip_begin_route_changes (kvm_state); + ret =kvm_irqchip_add_msi_route (&c, vector, pdev);if (ret <0 ) {error_setg (errp,"kvm_irqchip_add_msi_route failed" );return ; } +kvm_irqchip_commit_route_changes (&c); s->msi_vectors[vector].virq = ret; s->msi_vectors[vector].pdev = pdev;
hw/vfio/pci.c +4 -1
@@ -412,6 +412,7 @@ static int vfio_enable_vectors(VFIOPCIDevice *vdev, bool msix)static void vfio_add_kvm_msi_virq (VFIOPCIDevice *vdev,VFIOMSIVector *vector,int vector_n,bool msix) { +KVMRouteChange c;int virq;if ((msix && vdev->no_kvm_msix) || (!msix && vdev->no_kvm_msi)) {
@@ -422,11 +423,13 @@ static void vfio_add_kvm_msi_virq(VFIOPCIDevice *vdev, VFIOMSIVector *vector,return ; } - virq =kvm_irqchip_add_msi_route (kvm_state, vector_n, &vdev->pdev); + c =kvm_irqchip_begin_route_changes (kvm_state); + virq =kvm_irqchip_add_msi_route (&c, vector_n, &vdev->pdev);if (virq <0 ) {event_notifier_cleanup (&vector->kvm_interrupt);return ; } +kvm_irqchip_commit_route_changes (&c);if (kvm_irqchip_add_irqfd_notifier_gsi (kvm_state, &vector->kvm_interrupt,NULL , virq) <0 ) {
hw/virtio/virtio-pci.c +3 -1
@@ -683,10 +683,12 @@ static int kvm_virtio_pci_vq_vector_use(VirtIOPCIProxy *proxy,int ret;if (irqfd->users ==0 ) { - ret =kvm_irqchip_add_msi_route (kvm_state, vector, &proxy->pci_dev); +KVMRouteChange c =kvm_irqchip_begin_route_changes (kvm_state); + ret =kvm_irqchip_add_msi_route (&c, vector, &proxy->pci_dev);if (ret <0 ) {return ret; } +kvm_irqchip_commit_route_changes (&c); irqfd->virq = ret; } irqfd->users++;
include/sysemu/kvm.h +2 -2
@@ -486,7 +486,7 @@ void kvm_init_cpu_signals(CPUState *cpu);/** * kvm_irqchip_add_msi_route - Add MSI route for specific vector -* @s: KVM state +* @c: KVMRouteChange instance. * @vector: which vector to add. This can be either MSI/MSIX * vector. The function will automatically detect whether * MSI/MSIX is enabled, and fetch corresponding MSI
@@ -495,7 +495,7 @@ void kvm_init_cpu_signals(CPUState *cpu);* as @NULL, an empty MSI message will be inited. * @return: virq (>=0) when success, errno (<0) when failed. */ -int kvm_irqchip_add_msi_route (KVMState *s,int vector,PCIDevice *dev); +int kvm_irqchip_add_msi_route (KVMRouteChange *c,int vector,PCIDevice *dev);int kvm_irqchip_update_msi_route (KVMState *s,int virq,MSIMessage msg,PCIDevice *dev);void kvm_irqchip_commit_routes (KVMState *s);
target/i386/kvm/kvm.c +3 -1
@@ -4939,16 +4939,18 @@ void kvm_arch_init_irq_routing(KVMState *s) kvm_gsi_routing_allowed = true;if (kvm_irqchip_is_split ()) { +KVMRouteChange c =kvm_irqchip_begin_route_changes (s);int i;/* If the ioapic is in QEMU and the lapics are in KVM, reserve MSI routes for signaling interrupts to the local apics. */ for (i =0 ; i <IOAPIC_NUM_PINS ; i++) { -if (kvm_irqchip_add_msi_route (s,0 ,NULL ) <0 ) { +if (kvm_irqchip_add_msi_route (&c,0 ,NULL ) <0 ) {error_report ("Could not enable split IRQ mode." );exit (1 ); } } +kvm_irqchip_commit_route_changes (&c); } }
Signature · 1 line
2.35.1
[PULL 10/22] target/i386: only include bits in pg_mode if they are not ignored
In reply to Paolo BonziniLA57/PKE/PKS is only relevant in 64-bit mode, and NXE is only relevant if PAE is in use. Since there is code that checks PG_MODE_LA57 to determine the canonicality of addresses, make sure that the bit is not set by mistake in 32-bit mode. While it would not be a problem because 32-bit addresses by definition fit in both 48-bit and 57-bit address spaces, it is nicer if get_pg_mode() actually returns whether a feature is enabled, and it allows a few simplifications in the page table walker.
--- target/i386/tcg/sysemu/excp_helper.c | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-)
target/i386/tcg/sysemu/excp_helper.c +17 -17
@@ -24,32 +24,35 @@int get_pg_mode (CPUX86State *env) {int pg_mode =0 ; +if (!(env->cr[0 ] &CR0_PG_MASK )) { +return 0 ; + }if (env->cr[0 ] &CR0_WP_MASK ) { pg_mode |=PG_MODE_WP ; }if (env->cr[4 ] &CR4_PAE_MASK ) { pg_mode |=PG_MODE_PAE ; +if (env->efer &MSR_EFER_NXE ) { + pg_mode |=PG_MODE_NXE ; + } }if (env->cr[4 ] &CR4_PSE_MASK ) { pg_mode |=PG_MODE_PSE ; } -if (env->cr[4 ] &CR4_PKE_MASK ) { - pg_mode |=PG_MODE_PKE ; - } -if (env->cr[4 ] &CR4_PKS_MASK ) { - pg_mode |=PG_MODE_PKS ; - }if (env->cr[4 ] &CR4_SMEP_MASK ) { pg_mode |=PG_MODE_SMEP ; } -if (env->cr[4 ] &CR4_LA57_MASK ) { - pg_mode |=PG_MODE_LA57 ; - }if (env->hflags &HF_LMA_MASK ) { pg_mode |=PG_MODE_LMA ; - } -if (env->efer &MSR_EFER_NXE ) { - pg_mode |=PG_MODE_NXE ; +if (env->cr[4 ] &CR4_PKE_MASK ) { + pg_mode |=PG_MODE_PKE ; + } +if (env->cr[4 ] &CR4_PKS_MASK ) { + pg_mode |=PG_MODE_PKS ; + } +if (env->cr[4 ] &CR4_LA57_MASK ) { + pg_mode |=PG_MODE_LA57 ; + } }return pg_mode; }
@@ -278,9 +281,7 @@ do_check_protect_pse36: *prot |=PAGE_EXEC ; } -if (!(pg_mode &PG_MODE_LMA )) { - pkr =0 ; - }else if (ptep &PG_USER_MASK ) { +if (ptep &PG_USER_MASK ) { pkr = pg_mode &PG_MODE_PKE ? env->pkru :0 ; }else { pkr = pg_mode &PG_MODE_PKS ? env->pkrs :0 ;
@@ -343,8 +344,7 @@ do_check_protect_pse36:if (is_user) error_code |=PG_ERROR_U_MASK ;if (is_write1 ==2 && - (((pg_mode &PG_MODE_NXE ) && (pg_mode &PG_MODE_PAE )) || - (pg_mode &PG_MODE_SMEP ))) + ((pg_mode &PG_MODE_NXE ) || (pg_mode &PG_MODE_SMEP ))) error_code |=PG_ERROR_I_D_MASK ;return error_code; }
Signature · 1 line
2.35.1
[PULL 04/22] meson: fix generic location of vss headers
In reply to Paolo BonziniFrom: Marc-André Lureau <[email protected]>
This is a left-over, despite requesting the change before the merge.
Message-Id: <[email protected]>
--- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meson.build +1 -1
@@ -1936,7 +1936,7 @@ have_vss = false if targetos == 'windows' and link_language == 'cpp' have_vss = cxx.compiles(''' #define __MIDL_user_allocate_free_DEFINED__ - #include <inc/win2003/vss.h> + #include <vss.h> int main(void) { return VSS_CTX_BACKUP; }''') endif
Signature · 1 line
2.35.1
[PULL 21/22] KVM: SVM: always set MSR_AMD64_TSC_RATIO to default value
In reply to Paolo BonziniFrom: Maxim Levitsky <[email protected]>
Even when the feature is not supported in guest CPUID, still set the msr to the default value which will be the only value KVM will accept in this case
Message-Id: <[email protected]>
--- target/i386/cpu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
target/i386/cpu.c +1 -3
@@ -5997,9 +5997,7 @@ static void x86_cpu_reset(DeviceState *dev)x86_cpu_set_sgxlepubkeyhash (env); -if (env->features[FEAT_SVM ] &CPUID_SVM_TSCSCALE ) { - env->amd_tsc_scale_msr =MSR_AMD64_TSC_RATIO_DEFAULT ; - } + env->amd_tsc_scale_msr =MSR_AMD64_TSC_RATIO_DEFAULT ;#endif }
Signature · 1 line
2.35.1
[PULL 19/22] x86: Support XFD and AMX xsave data migration
In reply to Paolo BonziniFrom: Zeng Guang <[email protected]>
XFD(eXtended Feature Disable) allows to enable a feature on xsave state while preventing specific user threads from using the feature.
Support save and restore XFD MSRs if CPUID.D.1.EAX[4] enumerate to be valid. Likewise migrate the MSRs and related xsave state necessarily.
Message-Id: <[email protected]>
--- target/i386/cpu.h | 9 +++++++++ target/i386/kvm/kvm.c | 18 +++++++++++++++++ target/i386/machine.c | 46 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+)
target/i386/cpu.h +9 -0
@@ -507,6 +507,9 @@ typedef enum X86Seg {#define MSR_VM_HSAVE_PA 0xc0010117 +#define MSR_IA32_XFD 0x000001c4 +#define MSR_IA32_XFD_ERR 0x000001c5 +#define MSR_IA32_BNDCFGS 0x00000d90#define MSR_IA32_XSS 0x00000da0#define MSR_IA32_UMWAIT_CONTROL 0xe1
@@ -872,6 +875,8 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_1_EAX_AVX_VNNI (1U << 4)/* AVX512 BFloat16 Instruction */ #define CPUID_7_1_EAX_AVX512_BF16 (1U << 5) +/* XFD Extend Feature Disabled */ +#define CPUID_D_1_EAX_XFD (1U << 4)/* Packets which contain IP payload have LIP values */ #define CPUID_14_0_ECX_LIP (1U << 31)
@@ -1616,6 +1621,10 @@ typedef struct CPUX86State {uint64_t msr_rtit_cr3_match;uint64_t msr_rtit_addrs[MAX_RTIT_ADDRS ]; +/* Per-VCPU XFD MSRs */ +uint64_t msr_xfd; +uint64_t msr_xfd_err; +/* exception/interrupt handling */ int error_code;int exception_is_int;
target/i386/kvm/kvm.c +18 -0
@@ -3276,6 +3276,13 @@ static int kvm_put_msrs(X86CPU *cpu, int level) env->msr_ia32_sgxlepubkeyhash[3]); } +if (env->features[FEAT_XSAVE ] &CPUID_D_1_EAX_XFD ) { +kvm_msr_entry_add (cpu,MSR_IA32_XFD , + env->msr_xfd); +kvm_msr_entry_add (cpu,MSR_IA32_XFD_ERR , + env->msr_xfd_err); + } +/* Note: MSR_IA32_FEATURE_CONTROL is written separately, see * kvm_put_msr_feature_control. */ }
@@ -3668,6 +3675,11 @@ static int kvm_get_msrs(X86CPU *cpu)kvm_msr_entry_add (cpu,MSR_IA32_SGXLEPUBKEYHASH3 ,0 ); } +if (env->features[FEAT_XSAVE ] &CPUID_D_1_EAX_XFD ) { +kvm_msr_entry_add (cpu,MSR_IA32_XFD ,0 ); +kvm_msr_entry_add (cpu,MSR_IA32_XFD_ERR ,0 ); + } + ret =kvm_vcpu_ioctl (CPU (cpu),KVM_GET_MSRS , cpu->kvm_msr_buf);if (ret <0 ) {return ret;
@@ -3964,6 +3976,12 @@ static int kvm_get_msrs(X86CPU *cpu) env->msr_ia32_sgxlepubkeyhash[index -MSR_IA32_SGXLEPUBKEYHASH0 ] = msrs[i].data;break ; +case MSR_IA32_XFD : + env->msr_xfd = msrs[i].data; +break ; +case MSR_IA32_XFD_ERR : + env->msr_xfd_err = msrs[i].data; +break ; } }
target/i386/machine.c +46 -0
58 lines not on this page · raw message
Signature · 1 line
2.35.1
[PULL 12/22] linux-headers: include missing changes from 5.17
In reply to Paolo Bonzini--- linux-headers/asm-x86/kvm.h | 3 +++ linux-headers/linux/kvm.h | 4 ++++ 2 files changed, 7 insertions(+)
linux-headers/asm-x86/kvm.h +3 -0
@@ -452,6 +452,9 @@ struct kvm_sync_regs {#define KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE 0x00000001 +/* attributes for system fd (group 0) */ +#define KVM_X86_XCOMP_GUEST_SUPP 0 +struct kvm_vmx_nested_state_data {__u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE ];__u8 shadow_vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE ];
linux-headers/linux/kvm.h +4 -0
@@ -1133,6 +1133,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM 206#define KVM_CAP_VM_GPA_BITS 207#define KVM_CAP_XSAVE2 208 +#define KVM_CAP_SYS_ATTRIBUTES 209#ifdef KVM_CAP_IRQ_ROUTING
@@ -2047,4 +2048,7 @@ struct kvm_stats_desc {#define KVM_GET_STATS_FD _IO(KVMIO, 0xce) +/* Available with KVM_CAP_XSAVE2 */ +#define KVM_GET_XSAVE2 _IOR(KVMIO, 0xcf, struct kvm_xsave) +#endif /* __LINUX_KVM_H */
Signature · 1 line
2.35.1
[PULL 14/22] x86: Add AMX XTILECFG and XTILEDATA components
In reply to Paolo BonziniFrom: Jing Liu <[email protected]>
The AMX TILECFG register and the TMMx tile data registers are saved/restored via XSAVE, respectively in state component 17 (64 bytes) and state component 18 (8192 bytes).
Add AMX feature bits to x86_ext_save_areas array to set up AMX components. Add structs that define the layout of AMX XSAVE areas and use QEMU_BUILD_BUG_ON to validate the structs sizes.
Message-Id: <[email protected]>
--- target/i386/cpu.c | 8 ++++++++ target/i386/cpu.h | 18 +++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-)
target/i386/cpu.c +8 -0
@@ -1402,6 +1402,14 @@ ExtSaveArea x86_ext_save_areas[XSAVE_STATE_AREA_COUNT] = { [XSTATE_PKRU_BIT ] = { .feature =FEAT_7_0_ECX , .bits =CPUID_7_0_ECX_PKU , .size = sizeof(XSavePKRU) }, + [XSTATE_XTILE_CFG_BIT ] = { + .feature =FEAT_7_0_EDX , .bits =CPUID_7_0_EDX_AMX_TILE , + .size =sizeof (XSaveXTILECFG), + }, + [XSTATE_XTILE_DATA_BIT ] = { + .feature =FEAT_7_0_EDX , .bits =CPUID_7_0_EDX_AMX_TILE , + .size =sizeof (XSaveXTILEDATA) + }, };static uint32_t xsave_area_size (uint64_t mask)
target/i386/cpu.h +17 -1
@@ -539,6 +539,8 @@ typedef enum X86Seg {#define XSTATE_ZMM_Hi256_BIT 6#define XSTATE_Hi16_ZMM_BIT 7#define XSTATE_PKRU_BIT 9 +#define XSTATE_XTILE_CFG_BIT 17 +#define XSTATE_XTILE_DATA_BIT 18#define XSTATE_FP_MASK (1ULL << XSTATE_FP_BIT)#define XSTATE_SSE_MASK (1ULL << XSTATE_SSE_BIT)
@@ -847,6 +849,8 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_EDX_TSX_LDTRK (1U << 16)/* AVX512_FP16 instruction */ #define CPUID_7_0_EDX_AVX512_FP16 (1U << 23) +/* AMX tile (two-dimensional register) */ +#define CPUID_7_0_EDX_AMX_TILE (1U << 24)/* Speculation Control */ #define CPUID_7_0_EDX_SPEC_CTRL (1U << 26)/* Single Thread Indirect Branch Predictors */
@@ -1350,6 +1354,16 @@ typedef struct XSavePKRU {uint32_t padding; } XSavePKRU; +/* Ext. save area 17: AMX XTILECFG state */ +typedef struct XSaveXTILECFG { +uint8_t xtilecfg[64 ]; +}XSaveXTILECFG ; + +/* Ext. save area 18: AMX XTILEDATA state */ +typedef struct XSaveXTILEDATA { +uint8_t xtiledata[8 ][1024 ]; +}XSaveXTILEDATA ; +QEMU_BUILD_BUG_ON (sizeof (XSaveAVX) !=0x100 );QEMU_BUILD_BUG_ON (sizeof (XSaveBNDREG) !=0x40 );QEMU_BUILD_BUG_ON (sizeof (XSaveBNDCSR) !=0x40 );
@@ -1357,6 +1371,8 @@ QEMU_BUILD_BUG_ON(sizeof(XSaveOpmask) != 0x40);QEMU_BUILD_BUG_ON (sizeof (XSaveZMM_Hi256) !=0x200 );QEMU_BUILD_BUG_ON (sizeof (XSaveHi16_ZMM) !=0x400 );QEMU_BUILD_BUG_ON (sizeof (XSavePKRU) !=0x8 ); +QEMU_BUILD_BUG_ON (sizeof (XSaveXTILECFG) !=0x40 ); +QEMU_BUILD_BUG_ON (sizeof (XSaveXTILEDATA) !=0x2000 ); typedef struct ExtSaveArea { uint32_t feature, bits;
@@ -1364,7 +1380,7 @@ typedef struct ExtSaveArea {uint32_t ecx; } ExtSaveArea; -#define XSAVE_STATE_AREA_COUNT (XSTATE_PKRU_BIT + 1) +#define XSAVE_STATE_AREA_COUNT (XSTATE_XTILE_DATA_BIT + 1)extern ExtSaveArea x86_ext_save_areas[XSAVE_STATE_AREA_COUNT ];
Signature · 1 line
2.35.1
[PULL 11/22] target/i386: Throw a #SS when loading a non-canonical IST
In reply to Paolo BonziniFrom: Gareth Webb <[email protected]>
Loading a non-canonical address into rsp when handling an interrupt or performing a far call should raise a #SS not a #GP.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/870
Message-Id: <[email protected]>
--- target/i386/tcg/seg_helper.c | 49 +++++++++++++++++++++++++++- target/i386/tcg/sysemu/excp_helper.c | 36 -------------------- 2 files changed, 48 insertions(+), 37 deletions(-)
target/i386/tcg/seg_helper.c +48 -1
@@ -28,6 +28,42 @@#include "helper-tcg.h" #include "seg_helper.h" +int get_pg_mode (CPUX86State *env) +{ +int pg_mode =0 ; +if (!(env->cr[0 ] &CR0_PG_MASK )) { +return 0 ; + } +if (env->cr[0 ] &CR0_WP_MASK ) { + pg_mode |=PG_MODE_WP ; + } +if (env->cr[4 ] &CR4_PAE_MASK ) { + pg_mode |=PG_MODE_PAE ; +if (env->efer &MSR_EFER_NXE ) { + pg_mode |=PG_MODE_NXE ; + } + } +if (env->cr[4 ] &CR4_PSE_MASK ) { + pg_mode |=PG_MODE_PSE ; + } +if (env->cr[4 ] &CR4_SMEP_MASK ) { + pg_mode |=PG_MODE_SMEP ; + } +if (env->hflags &HF_LMA_MASK ) { + pg_mode |=PG_MODE_LMA ; +if (env->cr[4 ] &CR4_PKE_MASK ) { + pg_mode |=PG_MODE_PKE ; + } +if (env->cr[4 ] &CR4_PKS_MASK ) { + pg_mode |=PG_MODE_PKS ; + } +if (env->cr[4 ] &CR4_LA57_MASK ) { + pg_mode |=PG_MODE_LA57 ; + } + } +return pg_mode; +} +/* return non zero if error */ static inline int load_segment_ra(CPUX86State *env, uint32_t *e1_ptr, uint32_t *e2_ptr, int selector,
@@ -795,6 +831,8 @@ static inline target_ulong get_rsp_from_tss(CPUX86State *env, int level) {X86CPU *cpu =env_archcpu (env);int index; +target_ulong rsp; +int32_t sext;#if 0 printf("TR: base=" TARGET_FMT_lx " limit=%x\n",
@@ -808,7 +846,16 @@ static inline target_ulong get_rsp_from_tss(CPUX86State *env, int level)if ((index +7 ) > env->tr.limit) {raise_exception_err (env,EXCP0A_TSS , env->tr.selector &0xfffc ); } -return cpu_ldq_kernel (env, env->tr.base + index); + + rsp =cpu_ldq_kernel (env, env->tr.base + index); + +/* test virtual address sign extension */ + sext = rsp >> (get_pg_mode (env) &PG_MODE_LA57 ?56 :47 ); +if (sext !=0 && sext !=-1 ) { +raise_exception_err (env,EXCP0C_STACK ,0 ); + } + +return rsp; }/* 64 bit interrupt */
target/i386/tcg/sysemu/excp_helper.c +0 -36
@@ -21,42 +21,6 @@#include "cpu.h" #include "tcg/helper-tcg.h" -int get_pg_mode (CPUX86State *env) -{ -int pg_mode =0 ; -if (!(env->cr[0 ] &CR0_PG_MASK )) { -return 0 ; - } -if (env->cr[0 ] &CR0_WP_MASK ) { - pg_mode |=PG_MODE_WP ; - } -if (env->cr[4 ] &CR4_PAE_MASK ) { - pg_mode |=PG_MODE_PAE ; -if (env->efer &MSR_EFER_NXE ) { - pg_mode |=PG_MODE_NXE ; - } - } -if (env->cr[4 ] &CR4_PSE_MASK ) { - pg_mode |=PG_MODE_PSE ; - } -if (env->cr[4 ] &CR4_SMEP_MASK ) { - pg_mode |=PG_MODE_SMEP ; - } -if (env->hflags &HF_LMA_MASK ) { - pg_mode |=PG_MODE_LMA ; -if (env->cr[4 ] &CR4_PKE_MASK ) { - pg_mode |=PG_MODE_PKE ; - } -if (env->cr[4 ] &CR4_PKS_MASK ) { - pg_mode |=PG_MODE_PKS ; - } -if (env->cr[4 ] &CR4_LA57_MASK ) { - pg_mode |=PG_MODE_LA57 ; - } - } -return pg_mode; -} -#define PG_ERROR_OK (-1) typedef hwaddr (*MMUTranslateFunc)(CPUState *cs, hwaddr gphys, MMUAccessType access_type,
Signature · 1 line
2.35.1
[PULL 16/22] x86: Add XFD faulting bit for state components
In reply to Paolo BonziniFrom: Jing Liu <[email protected]>
Intel introduces XFD faulting mechanism for extended XSAVE features to dynamically enable the features in runtime. If CPUID (EAX=0Dh, ECX=n, n>1).ECX[2] is set as 1, it indicates support for XFD faulting of this state component.
Message-Id: <[email protected]>
--- target/i386/cpu.c | 3 ++- target/i386/cpu.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-)
target/i386/cpu.c +2 -1
@@ -5496,7 +5496,8 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,const ExtSaveArea *esa = &x86_ext_save_areas[count]; *eax = esa->size; *ebx = esa->offset; - *ecx = esa->ecx &ESA_FEATURE_ALIGN64_MASK ; + *ecx = esa->ecx & + (ESA_FEATURE_ALIGN64_MASK |ESA_FEATURE_XFD_MASK ); } }break ;
target/i386/cpu.h +2 -0
@@ -557,8 +557,10 @@ typedef enum X86Seg {#define XSTATE_DYNAMIC_MASK (XSTATE_XTILE_DATA_MASK)#define ESA_FEATURE_ALIGN64_BIT 1 +#define ESA_FEATURE_XFD_BIT 2#define ESA_FEATURE_ALIGN64_MASK (1U << ESA_FEATURE_ALIGN64_BIT) +#define ESA_FEATURE_XFD_MASK (1U << ESA_FEATURE_XFD_BIT)/* CPUID feature words */
Signature · 1 line
2.35.1
[PULL 13/22] x86: Fix the 64-byte boundary enumeration for extended state
In reply to Paolo BonziniFrom: Jing Liu <[email protected]>
The extended state subleaves (EAX=0Dh, ECX=n, n>1).ECX[1] indicate whether the extended state component locates on the next 64-byte boundary following the preceding state component when the compacted format of an XSAVE area is used.
Right now, they are all zero because no supported component needed the bit to be set, but the upcoming AMX feature will use it. Fix the subleaves value according to KVM's supported cpuid.
Message-Id: <[email protected]>
--- target/i386/cpu.c | 1 + target/i386/cpu.h | 6 ++++++ target/i386/kvm/kvm-cpu.c | 1 + 3 files changed, 8 insertions(+)
target/i386/cpu.c +1 -0
@@ -5488,6 +5488,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,const ExtSaveArea *esa = &x86_ext_save_areas[count]; *eax = esa->size; *ebx = esa->offset; + *ecx = esa->ecx &ESA_FEATURE_ALIGN64_MASK ; } }break ;
target/i386/cpu.h +6 -0
@@ -550,6 +550,11 @@ typedef enum X86Seg {#define XSTATE_Hi16_ZMM_MASK (1ULL << XSTATE_Hi16_ZMM_BIT)#define XSTATE_PKRU_MASK (1ULL << XSTATE_PKRU_BIT) +#define ESA_FEATURE_ALIGN64_BIT 1 + +#define ESA_FEATURE_ALIGN64_MASK (1U << ESA_FEATURE_ALIGN64_BIT) + +/* CPUID feature words */ typedef enum FeatureWord { FEAT_1_EDX, /* CPUID[1].EDX */
@@ -1356,6 +1361,7 @@ QEMU_BUILD_BUG_ON(sizeof(XSavePKRU) != 0x8);typedef struct ExtSaveArea {uint32_t feature, bits;uint32_t offset, size; +uint32_t ecx; }ExtSaveArea ;#define XSAVE_STATE_AREA_COUNT (XSTATE_PKRU_BIT + 1)
target/i386/kvm/kvm-cpu.c +1 -0
@@ -104,6 +104,7 @@ static void kvm_cpu_xsave_init(void)if (sz !=0 ) {assert (esa->size == sz); esa->offset =kvm_arch_get_supported_cpuid (s,0xd , i,R_EBX ); + esa->ecx =kvm_arch_get_supported_cpuid (s,0xd , i,R_ECX ); } } }
Signature · 1 line
2.35.1
[PULL 22/22] gitlab-ci: do not run tests with address sanitizer
In reply to Paolo BonziniThis is flaky and sometimes fails or hangs unexplicably.
--- .gitlab-ci.d/buildtest.yml | 2 -- 1 file changed, 2 deletions(-)
.gitlab-ci.d/buildtest.yml +0 -2
@@ -515,8 +515,6 @@ build-oss-fuzz: echo Testing ${fuzzer} ... ; "${fuzzer}" -runs=1 -seed=1 || exit 1 ; done - # Unrelated to fuzzer: run some tests with -fsanitize=address - - cd build-oss-fuzz && make check-qtest-i386 check-unit build-tci: extends: .native_build_job_template
Signature · 1 line
2.35.1
[PULL 20/22] i386: Add Icelake-Server-v6 CPU model with 5-level EPT support
In reply to Paolo BonziniFrom: Vitaly Kuznetsov <[email protected]>
Windows 11 with WSL2 enabled (Hyper-V) fails to boot with Icelake-Server {-v5} CPU model but boots well with '-cpu host'. Apparently, it expects 5-level paging and 5-level EPT support to come in pair but QEMU's Icelake-Server CPU model lacks the later. Introduce 'Icelake-Server-v6' CPU model with 'vmx-page-walk-5' enabled by default.
Message-Id: <[email protected]>
--- target/i386/cpu.c | 8 ++++++++ 1 file changed, 8 insertions(+)
target/i386/cpu.c +8 -0
@@ -3526,6 +3526,14 @@ static const X86CPUDefinition builtin_x86_defs[] = { {/* end of list */ } }, }, + { + .version = 6, + .note = "5-level EPT", + .props = (PropValue[]) { + { "vmx-page-walk-5", "on" }, + { /* end of list */ } + }, + }, {/* end of list */ } } },
Signature · 1 line
2.35.1
[PULL 15/22] x86: Grant AMX permission for guest
In reply to Paolo BonziniFrom: Yang Zhong <[email protected]>
Kernel allocates 4K xstate buffer by default. For XSAVE features which require large state component (e.g. AMX), Linux kernel dynamically expands the xstate buffer only after the process has acquired the necessary permissions. Those are called dynamically- enabled XSAVE features (or dynamic xfeatures).
There are separate permissions for native tasks and guests.
Qemu should request the guest permissions for dynamic xfeatures which will be exposed to the guest. This only needs to be done once before the first vcpu is created.
KVM implemented one new ARCH_GET_XCOMP_SUPP system attribute API to get host side supported_xcr0 and Qemu can decide if it can request dynamically enabled XSAVE features permission.
https://lore.kernel.org/all/[email protected]/
Message-Id: <[email protected]>
--- target/i386/cpu.c | 7 +++++ target/i386/cpu.h | 4 +++ target/i386/kvm/kvm-cpu.c | 12 ++++---- target/i386/kvm/kvm.c | 57 ++++++++++++++++++++++++++++++++++++++ target/i386/kvm/kvm_i386.h | 1 + 5 files changed, 75 insertions(+), 6 deletions(-)
target/i386/cpu.c +7 -0
@@ -6007,6 +6007,7 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu)CPUX86State *env = &cpu->env;int i;uint64_t mask; +static bool request_perm;if (!(env->features[FEAT_1_ECX ] &CPUID_EXT_XSAVE )) { env->features[FEAT_XSAVE_COMP_LO ] =0 ;
@@ -6022,6 +6023,12 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu) } } +/* Only request permission for first vcpu */ +if (kvm_enabled () && !request_perm) { +kvm_request_xsave_components (cpu, mask); + request_perm = true; + } + env->features[FEAT_XSAVE_COMP_LO ] = mask; env->features[FEAT_XSAVE_COMP_HI ] = mask >>32 ; }
target/i386/cpu.h +4 -0
@@ -551,6 +551,10 @@ typedef enum X86Seg {#define XSTATE_ZMM_Hi256_MASK (1ULL << XSTATE_ZMM_Hi256_BIT)#define XSTATE_Hi16_ZMM_MASK (1ULL << XSTATE_Hi16_ZMM_BIT)#define XSTATE_PKRU_MASK (1ULL << XSTATE_PKRU_BIT) +#define XSTATE_XTILE_CFG_MASK (1ULL << XSTATE_XTILE_CFG_BIT) +#define XSTATE_XTILE_DATA_MASK (1ULL << XSTATE_XTILE_DATA_BIT) + +#define XSTATE_DYNAMIC_MASK (XSTATE_XTILE_DATA_MASK)#define ESA_FEATURE_ALIGN64_BIT 1
target/i386/kvm/kvm-cpu.c +6 -6
@@ -84,7 +84,7 @@ static void kvm_cpu_max_instance_init(X86CPU *cpu)static void kvm_cpu_xsave_init (void ) {static bool first = true; -KVMState *s = kvm_state; +uint32_t eax, ebx, ecx, edx;int i;if (!first) {
@@ -100,11 +100,11 @@ static void kvm_cpu_xsave_init(void)ExtSaveArea *esa = &x86_ext_save_areas[i];if (esa->size) { -int sz =kvm_arch_get_supported_cpuid (s,0xd , i,R_EAX ); -if (sz !=0 ) { -assert (esa->size == sz); - esa->offset =kvm_arch_get_supported_cpuid (s,0xd , i,R_EBX ); - esa->ecx =kvm_arch_get_supported_cpuid (s,0xd , i,R_ECX ); +host_cpuid (0xd , i, &eax, &ebx, &ecx, &edx); +if (eax !=0 ) { +assert (esa->size == eax); + esa->offset = ebx; + esa->ecx = ecx; } } }
target/i386/kvm/kvm.c +57 -0
78 lines not on this page · raw message
target/i386/kvm/kvm_i386.h +1 -0
@@ -52,5 +52,6 @@ bool kvm_hyperv_expand_features(X86CPU *cpu, Error **errp);uint64_t kvm_swizzle_msi_ext_dest_id (uint64_t address);bool kvm_enable_sgx_provisioning (KVMState *s); +void kvm_request_xsave_components (X86CPU *cpu,uint64_t mask);#endif
Signature · 1 line
2.35.1
Re: [PULL 15/22] x86: Grant AMX permission for guest
Quoted 23 lines · Paolo Bonzini
From: Yang Zhong <[email protected]>
Kernel allocates 4K xstate buffer by default. For XSAVE features which require large state component (e.g. AMX), Linux kernel dynamically expands the xstate buffer only after the process has acquired the necessary permissions. Those are called dynamically- enabled XSAVE features (or dynamic xfeatures).
There are separate permissions for native tasks and guests.
Qemu should request the guest permissions for dynamic xfeatures which will be exposed to the guest. This only needs to be done once before the first vcpu is created.
KVM implemented one new
ARCH_GET_XCOMP_SUPPsystem attribute API to get host sidesupported_xcr0and Qemu can decide if it can request dynamically enabled XSAVE features permission.
https://lore.kernel.org/all/[email protected]/Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Yang Zhong <[email protected]>Signed-off-by Jing Liu <[email protected]>Message-Id: <[email protected]>
Quoted 8 lines
Signed-off-by Paolo Bonzini <[email protected]>--- target/i386/cpu.c | 7 +++++ target/i386/cpu.h | 4 +++ target/i386/kvm/kvm-cpu.c | 12 ++++---- target/i386/kvm/kvm.c | 57 ++++++++++++++++++++++++++++++++++++++ target/i386/kvm/kvm_i386.h | 1 + 5 files changed, 75 insertions(+), 6 deletions(-)
With this commit qemu crashes for me when invoking the following QMP command:
$ ~pipo/git/qemu.git/build/qemu-system-x86_64 -S -no-user-config -nodefaults -nographic -machine none,accel=kvm -qmp stdio
{"QMP": {"version": {"qemu": {"micro": 90, "minor": 2, "major": 6}, "package": "v7.0.0-rc0-8-g1d60bb4b14"}, "capabilities": ["oob"]}}
{'execute':'qmp_capabilities'}
{"return": {}}
{"execute":"qom-list-properties","arguments":{"typename":"max-x86_64-cpu"},"id":"libvirt-41"}
qemu-system-x86_64: ../target/i386/kvm/kvm-cpu.c:105: kvm_cpu_xsave_init: Assertion `esa->size == eax' failed.
Aborted (core dumped)Note that the above is on a box with an 'AMD Ryzen 9 3900X'.
Curiously on a laptop with an Intel chip (Intel(R) Core(TM) i7-10610U) it seems to work.
Re: [PULL 15/22] x86: Grant AMX permission for guest
Quoted 33 lines · Peter Krempa
Quoted 23 lines · Paolo Bonzini
From: Yang Zhong <[email protected]>
Kernel allocates 4K xstate buffer by default. For XSAVE features which require large state component (e.g. AMX), Linux kernel dynamically expands the xstate buffer only after the process has acquired the necessary permissions. Those are called dynamically- enabled XSAVE features (or dynamic xfeatures).
There are separate permissions for native tasks and guests.
Qemu should request the guest permissions for dynamic xfeatures which will be exposed to the guest. This only needs to be done once before the first vcpu is created.
KVM implemented one new
ARCH_GET_XCOMP_SUPPsystem attribute API to get host sidesupported_xcr0and Qemu can decide if it can request dynamically enabled XSAVE features permission.
https://lore.kernel.org/all/[email protected]/Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Yang Zhong <[email protected]>Signed-off-by Jing Liu <[email protected]>Message-Id: <[email protected]>
Quoted 8 lines
Signed-off-by Paolo Bonzini <[email protected]>--- target/i386/cpu.c | 7 +++++ target/i386/cpu.h | 4 +++ target/i386/kvm/kvm-cpu.c | 12 ++++---- target/i386/kvm/kvm.c | 57 ++++++++++++++++++++++++++++++++++++++ target/i386/kvm/kvm_i386.h | 1 + 5 files changed, 75 insertions(+), 6 deletions(-)
Quoted 2 lines
With this commit qemu crashes for me when invoking the following QMP command:
It is way worse than that even. If you remove '-S' you get an immediate kaboom on startup on AMD hosts
$ ./build/qemu-system-x86_64 -accel kvm Unable to init server: Could not connect: Connection refused qemu-system-x86_64: ../target/i386/kvm/kvm-cpu.c:105: kvm_cpu_xsave_init: Assertion `esa->size == eax' failed. Aborted (core dumped)
With 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 15/22] x86: Grant AMX permission for guest
Quoted 37 lines · Daniel P. Berrangé
Quoted 33 lines · Peter Krempa
Quoted 23 lines · Paolo Bonzini
From: Yang Zhong <[email protected]>
Kernel allocates 4K xstate buffer by default. For XSAVE features which require large state component (e.g. AMX), Linux kernel dynamically expands the xstate buffer only after the process has acquired the necessary permissions. Those are called dynamically- enabled XSAVE features (or dynamic xfeatures).
There are separate permissions for native tasks and guests.
Qemu should request the guest permissions for dynamic xfeatures which will be exposed to the guest. This only needs to be done once before the first vcpu is created.
KVM implemented one new
ARCH_GET_XCOMP_SUPPsystem attribute API to get host sidesupported_xcr0and Qemu can decide if it can request dynamically enabled XSAVE features permission.
https://lore.kernel.org/all/[email protected]/Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Yang Zhong <[email protected]>Signed-off-by Jing Liu <[email protected]>Message-Id: <[email protected]>
Quoted 8 lines
Signed-off-by Paolo Bonzini <[email protected]>--- target/i386/cpu.c | 7 +++++ target/i386/cpu.h | 4 +++ target/i386/kvm/kvm-cpu.c | 12 ++++---- target/i386/kvm/kvm.c | 57 ++++++++++++++++++++++++++++++++++++++ target/i386/kvm/kvm_i386.h | 1 + 5 files changed, 75 insertions(+), 6 deletions(-)Quoted 2 lines
With this commit qemu crashes for me when invoking the following QMP command:
Quoted 7 lines
It is way worse than that even. If you remove '-S' you get an immediate kaboom on startup on AMD hosts
$ ./build/qemu-system-x86_64 -accel kvm Unable to init server: Could not connect: Connection refused qemu-system-x86_64: ../target/i386/kvm/kvm-cpu.c:105: kvm_cpu_xsave_init: Assertion `esa->size == eax' failed. Aborted (core dumped)
I'll check it tomorrow, thanks.
Paolo
Re: [PULL 15/22] x86: Grant AMX permission for guest
In reply to Daniel P. BerrangéQuoted 34 lines · Daniel P. Berrangé
Quoted 33 lines · Peter Krempa
Quoted 31 lines · Paolo Bonzini
From: Yang Zhong <[email protected]>
Kernel allocates 4K xstate buffer by default. For XSAVE features which require large state component (e.g. AMX), Linux kernel dynamically expands the xstate buffer only after the process has acquired the necessary permissions. Those are called dynamically- enabled XSAVE features (or dynamic xfeatures).
There are separate permissions for native tasks and guests.
Qemu should request the guest permissions for dynamic xfeatures which will be exposed to the guest. This only needs to be done once before the first vcpu is created.
KVM implemented one new
ARCH_GET_XCOMP_SUPPsystem attribute API to get host sidesupported_xcr0and Qemu can decide if it can request dynamically enabled XSAVE features permission.
https://lore.kernel.org/all/[email protected]/Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Yang Zhong <[email protected]>Signed-off-by Jing Liu <[email protected]>Message-Id: <[email protected]>
Signed-off-by Paolo Bonzini <[email protected]>--- target/i386/cpu.c | 7 +++++ target/i386/cpu.h | 4 +++ target/i386/kvm/kvm-cpu.c | 12 ++++---- target/i386/kvm/kvm.c | 57 ++++++++++++++++++++++++++++++++++++++ target/i386/kvm/kvm_i386.h | 1 + 5 files changed, 75 insertions(+), 6 deletions(-)
Quoted 5 lines
Quoted 2 lines
With this commit qemu crashes for me when invoking the following QMP command:
It is way worse than that even. If you remove '-S' you get an immediate kaboom on startup on AMD hosts
Which AMD CPU is in this host?
Quoted 7 lines
$ ./build/qemu-system-x86_64 -accel kvm Unable to init server: Could not connect: Connection refused qemu-system-x86_64: ../target/i386/kvm/kvm-cpu.c:105: kvm_cpu_xsave_init: Assertion `esa->size == eax' failed. Aborted (core dumped)With regards,
Daniel
dme.
Signature · 1 line
My girl Friday, she no square.
Re: [PULL 15/22] x86: Grant AMX permission for guest
Quoted 36 lines · David Edmondson
Quoted 34 lines · Daniel P. Berrangé
Quoted 33 lines · Peter Krempa
Quoted 31 lines · Paolo Bonzini
From: Yang Zhong <[email protected]>
Kernel allocates 4K xstate buffer by default. For XSAVE features which require large state component (e.g. AMX), Linux kernel dynamically expands the xstate buffer only after the process has acquired the necessary permissions. Those are called dynamically- enabled XSAVE features (or dynamic xfeatures).
There are separate permissions for native tasks and guests.
Qemu should request the guest permissions for dynamic xfeatures which will be exposed to the guest. This only needs to be done once before the first vcpu is created.
KVM implemented one new
ARCH_GET_XCOMP_SUPPsystem attribute API to get host sidesupported_xcr0and Qemu can decide if it can request dynamically enabled XSAVE features permission.
https://lore.kernel.org/all/[email protected]/Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Yang Zhong <[email protected]>Signed-off-by Jing Liu <[email protected]>Message-Id: <[email protected]>
Signed-off-by Paolo Bonzini <[email protected]>--- target/i386/cpu.c | 7 +++++ target/i386/cpu.h | 4 +++ target/i386/kvm/kvm-cpu.c | 12 ++++---- target/i386/kvm/kvm.c | 57 ++++++++++++++++++++++++++++++++++++++ target/i386/kvm/kvm_i386.h | 1 + 5 files changed, 75 insertions(+), 6 deletions(-)
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
With this commit qemu crashes for me when invoking the following QMP command:
It is way worse than that even. If you remove '-S' you get an immediate kaboom on startup on AMD hosts
Which AMD CPU is in this host?
AMD EPYC 7302P
With 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 15/22] x86: Grant AMX permission for guest
Quoted 43 lines · Daniel P. Berrangé
Quoted 42 lines · David Edmondson
Quoted 39 lines · Daniel P. Berrangé
Quoted 33 lines · Peter Krempa
Quoted 23 lines · Paolo Bonzini
From: Yang Zhong <[email protected]>
Kernel allocates 4K xstate buffer by default. For XSAVE features which require large state component (e.g. AMX), Linux kernel dynamically expands the xstate buffer only after the process has acquired the necessary permissions. Those are called dynamically- enabled XSAVE features (or dynamic xfeatures).
There are separate permissions for native tasks and guests.
Qemu should request the guest permissions for dynamic xfeatures which will be exposed to the guest. This only needs to be done once before the first vcpu is created.
KVM implemented one new
ARCH_GET_XCOMP_SUPPsystem attribute API to get host sidesupported_xcr0and Qemu can decide if it can request dynamically enabled XSAVE features permission.
https://lore.kernel.org/all/[email protected]/Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Yang Zhong <[email protected]>Signed-off-by Jing Liu <[email protected]>Message-Id: <[email protected]>
Quoted 8 lines
Signed-off-by Paolo Bonzini <[email protected]>--- target/i386/cpu.c | 7 +++++ target/i386/cpu.h | 4 +++ target/i386/kvm/kvm-cpu.c | 12 ++++---- target/i386/kvm/kvm.c | 57 ++++++++++++++++++++++++++++++++++++++ target/i386/kvm/kvm_i386.h | 1 + 5 files changed, 75 insertions(+), 6 deletions(-)Quoted 2 lines
With this commit qemu crashes for me when invoking the following QMP command:
It is way worse than that even. If you remove '-S' you get an immediate kaboom on startup on AMD hosts
Quoted 7 lines
Quoted 1 line
Which AMD CPU is in this host?
AMD EPYC 7302P
With regards,
Daniel
my 3970X - same issue.
Best regards,
Maxim Levitsky
Re: [PULL 15/22] x86: Grant AMX permission for guest
In reply to Peter KrempaQuoted 44 lines · Peter Krempa
Quoted 23 lines · Paolo Bonzini
From: Yang Zhong <[email protected]>
Kernel allocates 4K xstate buffer by default. For XSAVE features which require large state component (e.g. AMX), Linux kernel dynamically expands the xstate buffer only after the process has acquired the necessary permissions. Those are called dynamically- enabled XSAVE features (or dynamic xfeatures).
There are separate permissions for native tasks and guests.
Qemu should request the guest permissions for dynamic xfeatures which will be exposed to the guest. This only needs to be done once before the first vcpu is created.
KVM implemented one new
ARCH_GET_XCOMP_SUPPsystem attribute API to get host sidesupported_xcr0and Qemu can decide if it can request dynamically enabled XSAVE features permission.
https://lore.kernel.org/all/[email protected]/Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Yang Zhong <[email protected]>Signed-off-by Jing Liu <[email protected]>Message-Id: <[email protected]>
Quoted 8 lines
Signed-off-by Paolo Bonzini <[email protected]>--- target/i386/cpu.c | 7 +++++ target/i386/cpu.h | 4 +++ target/i386/kvm/kvm-cpu.c | 12 ++++---- target/i386/kvm/kvm.c | 57 ++++++++++++++++++++++++++++++++++++++ target/i386/kvm/kvm_i386.h | 1 + 5 files changed, 75 insertions(+), 6 deletions(-)With this commit qemu crashes for me when invoking the following QMP command:
$ ~pipo/git/qemu.git/build/qemu-system-x86_64 -S -no-user-config -nodefaults -nographic -machine none,accel=kvm -qmp stdio {"QMP": {"version": {"qemu": {"micro": 90, "minor": 2, "major": 6}, "package": "v7.0.0-rc0-8-g1d60bb4b14"}, "capabilities": ["oob"]}} {'execute':'qmp_capabilities'} {"return": {}} {"execute":"qom-list-properties","arguments":{"typename":"max-x86_64-cpu"},"id":"libvirt-41"} qemu-system-x86_64: ../target/i386/kvm/kvm-cpu.c:105: kvm_cpu_xsave_init: Assertion `esa->size == eax' failed. Aborted (core dumped)
Quoted 4 lines
Note that the above is on a box with an 'AMD Ryzen 9 3900X'.
Curiously on a laptop with an Intel chip (Intel(R) Core(TM) i7-10610U) it seems to work.
Thanks for pointing this out!
In my side, no AMD machine can be used to try this issue, I listed the FPU info from host kernel dmesg for reference.
root@984fee00bf64:~# dmesg | grep fpu [ 0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers' [ 0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers' [ 0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers' [ 0.000000] x86/fpu: Supporting XSAVE feature 0x020: 'AVX-512 opmask' [ 0.000000] x86/fpu: Supporting XSAVE feature 0x040: 'AVX-512 Hi256' [ 0.000000] x86/fpu: Supporting XSAVE feature 0x080: 'AVX-512 ZMM_Hi256' [ 0.000000] x86/fpu: Supporting XSAVE feature 0x200: 'Protection Keys User registers' [ 0.000000] x86/fpu: Supporting XSAVE feature 0x400: 'PASID state' [ 0.000000] x86/fpu: Supporting XSAVE feature 0x20000: 'AMX Tile config' [ 0.000000] x86/fpu: Supporting XSAVE feature 0x40000: 'AMX Tile data' [ 0.000000] x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256 [ 0.000000] x86/fpu: xstate_offset[5]: 832, xstate_sizes[5]: 64 [ 0.000000] x86/fpu: xstate_offset[6]: 896, xstate_sizes[6]: 512 [ 0.000000] x86/fpu: xstate_offset[7]: 1408, xstate_sizes[7]: 1024 [ 0.000000] x86/fpu: xstate_offset[9]: 2432, xstate_sizes[9]: 8 [ 0.000000] x86/fpu: xstate_offset[10]: 2440, xstate_sizes[10]: 8 [ 0.000000] x86/fpu: xstate_offset[17]: 2496, xstate_sizes[17]: 64 [ 0.000000] x86/fpu: xstate_offset[18]: 2560, xstate_sizes[18]: 8192 [ 0.000000] x86/fpu: Enabled xstate features 0x606e7, context size is 10752 bytes, using 'compacted' format.
Paolo, if you have fix patch, I can double check this from Intel SPR server. thanks!
Yang
Re: [PULL 15/22] x86: Grant AMX permission for guest
In reply to Peter KrempaQuoted 44 lines · Peter Krempa
Quoted 23 lines · Paolo Bonzini
From: Yang Zhong <[email protected]>
Kernel allocates 4K xstate buffer by default. For XSAVE features which require large state component (e.g. AMX), Linux kernel dynamically expands the xstate buffer only after the process has acquired the necessary permissions. Those are called dynamically- enabled XSAVE features (or dynamic xfeatures).
There are separate permissions for native tasks and guests.
Qemu should request the guest permissions for dynamic xfeatures which will be exposed to the guest. This only needs to be done once before the first vcpu is created.
KVM implemented one new
ARCH_GET_XCOMP_SUPPsystem attribute API to get host sidesupported_xcr0and Qemu can decide if it can request dynamically enabled XSAVE features permission.
https://lore.kernel.org/all/[email protected]/Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Yang Zhong <[email protected]>Signed-off-by Jing Liu <[email protected]>Message-Id: <[email protected]>
Quoted 8 lines
Signed-off-by Paolo Bonzini <[email protected]>--- target/i386/cpu.c | 7 +++++ target/i386/cpu.h | 4 +++ target/i386/kvm/kvm-cpu.c | 12 ++++---- target/i386/kvm/kvm.c | 57 ++++++++++++++++++++++++++++++++++++++ target/i386/kvm/kvm_i386.h | 1 + 5 files changed, 75 insertions(+), 6 deletions(-)With this commit qemu crashes for me when invoking the following QMP command:
$ ~pipo/git/qemu.git/build/qemu-system-x86_64 -S -no-user-config -nodefaults -nographic -machine none,accel=kvm -qmp stdio {"QMP": {"version": {"qemu": {"micro": 90, "minor": 2, "major": 6}, "package": "v7.0.0-rc0-8-g1d60bb4b14"}, "capabilities": ["oob"]}} {'execute':'qmp_capabilities'} {"return": {}} {"execute":"qom-list-properties","arguments":{"typename":"max-x86_64-cpu"},"id":"libvirt-41"} qemu-system-x86_64: ../target/i386/kvm/kvm-cpu.c:105: kvm_cpu_xsave_init: Assertion `esa->size == eax' failed. Aborted (core dumped)
Quoted 6 lines
Note that the above is on a box with an 'AMD Ryzen 9 3900X'.
Curiously on a laptop with an Intel chip (Intel(R) Core(TM) i7-10610U) it seems to work.
Not trying to beat a dead horse here, but I've just found another problem with this patch. On my laptop (Linux maggie 5.15.26-gentoo-x86_64 #1 SMP Thu Mar 10 08:55:28 CET 2022 x86_64 Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz GenuineIntel GNU/Linux), when I start a guest it no longer sees AVX instructions:
qemu.git $ ./build/qemu-system-x86_64 -accel kvm -cpu host ...
Michal
Re: [PULL 15/22] x86: Grant AMX permission for guest
Quoted 52 lines · Michal Prívozník
Quoted 44 lines · Peter Krempa
Quoted 23 lines · Paolo Bonzini
From: Yang Zhong <[email protected]>
Kernel allocates 4K xstate buffer by default. For XSAVE features which require large state component (e.g. AMX), Linux kernel dynamically expands the xstate buffer only after the process has acquired the necessary permissions. Those are called dynamically- enabled XSAVE features (or dynamic xfeatures).
There are separate permissions for native tasks and guests.
Qemu should request the guest permissions for dynamic xfeatures which will be exposed to the guest. This only needs to be done once before the first vcpu is created.
KVM implemented one new
ARCH_GET_XCOMP_SUPPsystem attribute API to get host sidesupported_xcr0and Qemu can decide if it can request dynamically enabled XSAVE features permission.
https://lore.kernel.org/all/[email protected]/Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Yang Zhong <[email protected]>Signed-off-by Jing Liu <[email protected]>Message-Id: <[email protected]>
Quoted 8 lines
Signed-off-by Paolo Bonzini <[email protected]>--- target/i386/cpu.c | 7 +++++ target/i386/cpu.h | 4 +++ target/i386/kvm/kvm-cpu.c | 12 ++++---- target/i386/kvm/kvm.c | 57 ++++++++++++++++++++++++++++++++++++++ target/i386/kvm/kvm_i386.h | 1 + 5 files changed, 75 insertions(+), 6 deletions(-)With this commit qemu crashes for me when invoking the following QMP command:
$ ~pipo/git/qemu.git/build/qemu-system-x86_64 -S -no-user-config -nodefaults -nographic -machine none,accel=kvm -qmp stdio {"QMP": {"version": {"qemu": {"micro": 90, "minor": 2, "major": 6}, "package": "v7.0.0-rc0-8-g1d60bb4b14"}, "capabilities": ["oob"]}} {'execute':'qmp_capabilities'} {"return": {}} {"execute":"qom-list-properties","arguments":{"typename":"max-x86_64-cpu"},"id":"libvirt-41"} qemu-system-x86_64: ../target/i386/kvm/kvm-cpu.c:105: kvm_cpu_xsave_init: Assertion `esa->size == eax' failed. Aborted (core dumped)Quoted 6 lines
Note that the above is on a box with an 'AMD Ryzen 9 3900X'.
Curiously on a laptop with an Intel chip (Intel(R) Core(TM) i7-10610U) it seems to work.
Quoted 8 lines
Not trying to beat a dead horse here, but I've just found another problem with this patch. On my laptop (Linux maggie 5.15.26-gentoo-x86_64 #1 SMP Thu Mar 10 08:55:28 CET 2022
x86_64Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz GenuineIntel GNU/Linux), when I start a guest it no longer sees AVX instructions:qemu.git $ ./build/qemu-system-x86_64 -accel kvm -cpu host ...
Thanks Michal, this issue is caused by compatibility with older kernel version.
The Qemu will report below logs:
emu-system-x86_64: warning: cannot get sys attribute capabilities 0
qemu-system-x86_64: warning: cannot get sys attribute capabilities 0
qemu-system-x86_64: warning: cannot get sys attribute capabilities 0
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 5]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 6]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 9]
......
Since the AMX changes in Qemu need read ARCH_GET_XCOMP_SUPP attribute to get host supported_xcr0 value, and new kernel release add this new API. So the older kernel can't report right xcr0 value.
I made one new patch to fix this issue, please try this patch. thanks!
https://lists.nongnu.org/archive/html/qemu-devel/2022-03/msg04732.html
Paolo, this patch only fix this compatibility issue, but the issue caused by AMD cpu is still not fixed from my side because no AMD platform can be used in my side. If you have no time to check this issue, maybe I need lookfor this platform from our internal. thanks!
Yang
Quoted 1 line
Michal
Re: [PULL 15/22] x86: Grant AMX permission for guest
In reply to Peter KrempaQuoted 44 lines · Peter Krempa
Quoted 23 lines · Paolo Bonzini
From: Yang Zhong <[email protected]>
Kernel allocates 4K xstate buffer by default. For XSAVE features which require large state component (e.g. AMX), Linux kernel dynamically expands the xstate buffer only after the process has acquired the necessary permissions. Those are called dynamically- enabled XSAVE features (or dynamic xfeatures).
There are separate permissions for native tasks and guests.
Qemu should request the guest permissions for dynamic xfeatures which will be exposed to the guest. This only needs to be done once before the first vcpu is created.
KVM implemented one new
ARCH_GET_XCOMP_SUPPsystem attribute API to get host sidesupported_xcr0and Qemu can decide if it can request dynamically enabled XSAVE features permission.
https://lore.kernel.org/all/[email protected]/Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Yang Zhong <[email protected]>Signed-off-by Jing Liu <[email protected]>Message-Id: <[email protected]>
Quoted 8 lines
Signed-off-by Paolo Bonzini <[email protected]>--- target/i386/cpu.c | 7 +++++ target/i386/cpu.h | 4 +++ target/i386/kvm/kvm-cpu.c | 12 ++++---- target/i386/kvm/kvm.c | 57 ++++++++++++++++++++++++++++++++++++++ target/i386/kvm/kvm_i386.h | 1 + 5 files changed, 75 insertions(+), 6 deletions(-)With this commit qemu crashes for me when invoking the following QMP command:
$ ~pipo/git/qemu.git/build/qemu-system-x86_64 -S -no-user-config -nodefaults -nographic -machine none,accel=kvm -qmp stdio {"QMP": {"version": {"qemu": {"micro": 90, "minor": 2, "major": 6}, "package": "v7.0.0-rc0-8-g1d60bb4b14"}, "capabilities": ["oob"]}} {'execute':'qmp_capabilities'} {"return": {}} {"execute":"qom-list-properties","arguments":{"typename":"max-x86_64-cpu"},"id":"libvirt-41"} qemu-system-x86_64: ../target/i386/kvm/kvm-cpu.c:105: kvm_cpu_xsave_init: Assertion `esa->size == eax' failed. Aborted (core dumped)
Quoted 4 lines
Note that the above is on a box with an 'AMD Ryzen 9 3900X'.
Curiously on a laptop with an Intel chip (Intel(R) Core(TM) i7-10610U) it seems to work.
Paolo, I debugged this issue and found this issue is caused by xstate feature bit9 (MPK, which like pku in intel) in the some AMD platforms.
#AMD Spec, p409
https://www.amd.com/system/files/TechDocs/24593.pdf
I checked the cpuid info from AMD EPYC 7402P server and ECX=0x9, the eax is 0x40, which is different with eax=0x00000008 in Intel platform. So, the ASSERT is generated by AMX changes.
##AMD host
0x0000000d 0x00: eax=0x00000207 ebx=0x00000340 ecx=0x00000380 edx=0x00000000 0x0000000d 0x01: eax=0x0000000f ebx=0x00000340 ecx=0x00000000 edx=0x00000000 0x0000000d 0x02: eax=0x00000100 ebx=0x00000240 ecx=0x00000000 edx=0x00000000 0x0000000d 0x09: eax=0x00000040 ebx=0x00000340 ecx=0x00000000 edx=0x00000000
##Intel host
0x0000000d 0x00: eax=0x000602e7 ebx=0x00002b00 ecx=0x00002b00 edx=0x00000000 0x0000000d 0x01: eax=0x0000001f ebx=0x00002d00 ecx=0x0000dd00 edx=0x00000000 0x0000000d 0x02: eax=0x00000100 ebx=0x00000240 ecx=0x00000000 edx=0x00000000 0x0000000d 0x05: eax=0x00000040 ebx=0x00000440 ecx=0x00000000 edx=0x00000000 0x0000000d 0x06: eax=0x00000200 ebx=0x00000480 ecx=0x00000000 edx=0x00000000 0x0000000d 0x07: eax=0x00000400 ebx=0x00000680 ecx=0x00000000 edx=0x00000000 0x0000000d 0x08: eax=0x00000080 ebx=0x00000000 ecx=0x00000001 edx=0x00000000 0x0000000d 0x09: eax=0x00000008 ebx=0x00000a80 ecx=0x00000000 edx=0x00000000 0x0000000d 0x0a: eax=0x00000008 ebx=0x00000000 ecx=0x00000001 edx=0x00000000 0x0000000d 0x0b: eax=0x00000010 ebx=0x00000000 ecx=0x00000001 edx=0x00000000 0x0000000d 0x0c: eax=0x00000018 ebx=0x00000000 ecx=0x00000001 edx=0x00000000 0x0000000d 0x0e: eax=0x00000030 ebx=0x00000000 ecx=0x00000001 edx=0x00000000 0x0000000d 0x0f: eax=0x00000328 ebx=0x00000000 ecx=0x00000001 edx=0x00000000 0x0000000d 0x11: eax=0x00000040 ebx=0x00000ac0 ecx=0x00000002 edx=0x00000000 0x0000000d 0x12: eax=0x00002000 ebx=0x00000b00 ecx=0x00000006 edx=0x00000000
But I also checked same cpuid info from AMD MILAN server, the eax=0x00000008 in ECX=0x9. So, for this ECX=0x9, the eax values in different AMD server are different.
How can we handle those different value since we have used host_cpuid() to read host's registers? thanks!
Yang
Quoted 13 lines · Paolo Bonzini
The following changes since commit
99c53410bc9d50e556f565b0960673cccb566452:Merge remote-tracking branch 'remotes/thuth-gitlab/tags/pull-request-2022-02-28' into staging (2022-03-01 13:25:54 +0000)
are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to
d722beb6ac1d457bfa3d7dd5bce7bcea5ea45540:gitlab-ci: do not run tests with address sanitizer (2022-03-08 12:34:12 +0100)
Quoted 9 lines
----------------------------------------------------------------
* whpx fixes in preparation for GDB support (Ivan)
* VSS header fixes (Marc-André)
* 5-level EPT support (Vitaly)
* AMX support (Jing Liu & Yang Zhong)
* Bundle changes to MSI routes (Longpeng)
* More precise emulation of #SS (Gareth)
* Disable ASAN testing
This seems to fail on the jobs that run check-acceptance:
https://gitlab.com/qemu-project/qemu/-/jobs/2186949883
https://gitlab.com/qemu-project/qemu/-/jobs/2186949881
https://gitlab.com/qemu-project/qemu/-/jobs/2186949890
because the TCG boot tests for i440fx and q35 hang:
(001/183) tests/avocado/boot_linux.py:BootLinuxX8664.test_pc_i440fx_tcg:
INTERRUPTED: Test interrupted by SIGTERM\nRunner error occurred:
Timeout reached\nOriginal status: ERROR\n{'name':
'001-tests/avocado/boot_linux.py:BootLinuxX8664.test_pc_i440fx_tcg', 'logdir': '/builds/qemu-project/qemu/build/tests/results/job-2022-03-10T11.02-cc7d226/t... (900.76 s)
(003/183) tests/avocado/boot_linux.py:BootLinuxX8664.test_pc_q35_tcg:
INTERRUPTED: Test interrupted by SIGTERM\nRunner error occurred:
Timeout reached\nOriginal status: ERROR\n{'name':
'003-tests/avocado/boot_linux.py:BootLinuxX8664.test_pc_q35_tcg',
'logdir': '/builds/qemu-project/qemu/build/tests/results/job-2022-03-10T11.02-cc7d226/test... (901.26 s)
-- PMM