Final batch of patches for QEMU 8.1 soft freeze
The following changes since commit 97c81ef4b8e203d9620fd46e7eb77004563e3675:
Merge tag 'pull-9p-20230706' of https://github.com/cschoenebeck/qemu into staging (2023-07-06 18:19:42 +0100)
are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to 6d5e9694ef374159072984c0958c3eaab6dd1d52:
target/i386: Add new CPU model GraniteRapids (2023-07-07 12:52:27 +0200)
----------------------------------------------------------------
* Granite Rapids CPU model
* Miscellaneous bugfixes
----------------------------------------------------------------
Fiona Ebner (1):
qemu_cleanup: begin drained section after vm_shutdown()
Lei Wang (1):
target/i386: Add few security fix bits in ARCH_CAPABILITIES into SapphireRapids CPU model
Paolo Bonzini (1):
python: bump minimum requirements so they are compatible with 3.12
Tao Su (5):
target/i386: Adjust feature level according to FEAT_7_1_EDX target/i386: Add support for MCDT_NO in CPUID enumeration target/i386: Allow MCDT_NO if host supports target/i386: Add new bit definitions of MSR_IA32_ARCH_CAPABILITIES target/i386: Add new CPU model GraniteRapids
Thomas Huth (1):
meson.build: Remove the logic to link C code with the C++ linker
meson.build | 22 ++---- python/qemu/qmp/qmp_tui.py | 5 +- python/setup.cfg | 2 +- python/tests/minreqs.txt | 9 ++- qga/meson.build | 2 +- scripts/main.c | 1 - softmmu/runstate.c | 20 +++--- target/i386/cpu.c | 172 +++++++++++++++++++++++++++++++++++++++++++++ target/i386/cpu.h | 8 +++ target/i386/kvm/kvm.c | 4 ++ 10 files changed, 210 insertions(+), 35 deletions(-) delete mode 100644 scripts/main.c
Signature · 1 line
2.41.0
[PULL 1/9] python: bump minimum requirements so they are compatible with 3.12
There are many Python 3.12 issues right now, but a particularly problematic one when debugging them is that one cannot even use minreqs.txt in a Python 3.12 virtual environment to test with locked package versions.
Bump the mypy and wrapt versions to fix this, while remaining within the realm of versions compatible with Python 3.7.
This requires a workaround for a mypy false positive
qemu/qmp/qmp_tui.py:350: error: Non-overlapping equality check (left operand type: "Literal[Runstate.DISCONNECTING]", right operand type: "Literal[Runstate.IDLE]") [comparison-overlap]
where mypy does not realize that self.disconnect() could change the value of self.runstate.
--- python/qemu/qmp/qmp_tui.py | 5 ++++- python/setup.cfg | 2 +- python/tests/minreqs.txt | 9 ++++----- 3 files changed, 9 insertions(+), 7 deletions(-)
python/qemu/qmp/qmp_tui.py +4 -1
@@ -346,7 +346,10 @@ async def manage_connection(self) -> None: self._set_status('[Disconnected]') await self.disconnect() # check if a retry is needed - if self.runstate == Runstate.IDLE: + # mypy 1.4.0 doesn't believe runstate can change after + # disconnect(), hence the cast. + state = cast(Runstate, self.runstate) + if state == Runstate.IDLE: continue await self.runstate_changed()
python/setup.cfg +1 -1
@@ -39,7 +39,7 @@ devel = flake8 >= 5.0.4 fusepy >= 2.0.4 isort >= 5.1.2 - mypy >= 0.780 + mypy >= 1.4.0 pylint >= 2.17.3 tox >= 3.18.0 urwid >= 2.1.2
python/tests/minreqs.txt +4 -5
@@ -28,7 +28,7 @@ avocado-framework==90.0 # Linters flake8==5.0.4 isort==5.1.2 -mypy==0.780 +mypy==1.4.0 pylint==2.17.3 # Transitive flake8 dependencies
@@ -37,12 +37,11 @@ pycodestyle==2.9.1 pyflakes==2.5.0 # Transitive mypy dependencies -mypy-extensions==0.4.3 -typed-ast==1.4.0 -typing-extensions==4.5.0 +mypy-extensions==1.0.0 +typing-extensions==4.7.1 # Transitive pylint dependencies astroid==2.15.4 lazy-object-proxy==1.4.0 toml==0.10.0 -wrapt==1.12.1 +wrapt==1.14.0
Signature · 1 line
2.41.0
[PULL 2/9] meson.build: Remove the logic to link C code with the C++ linker
In reply to Paolo BonziniFrom: Thomas Huth <[email protected]>
We are not mixing C++ with C code anymore, the only remaining C++ code in qga/vss-win32/ is used for a plain C++ executable. Thus we can remove the hacks for linking C code with the C++ linker now to simplify meson.build a little bit, and also to avoid that some C++ code sneaks in by accident again.
Message-ID: <[email protected]>
--- meson.build | 22 ++++++---------------- qga/meson.build | 2 +- scripts/main.c | 1 - 3 files changed, 7 insertions(+), 18 deletions(-) delete mode 100644 scripts/main.c
meson.build +6 -16
@@ -473,19 +473,10 @@ if targetos != 'darwin' warn_flags += ['-Wthread-safety'] endif -# Check that the C++ compiler exists and works with the C compiler. -link_language = 'c' -linker = cc +# Set up C++ compiler flags qemu_cxxflags = [] if 'cpp' in all_languages qemu_cxxflags = ['-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS', '-D__STDC_FORMAT_MACROS'] + qemu_cflags - if cxx.links(files('scripts/main.c'), args: qemu_cflags) - link_language = 'cpp' - linker = cxx - else - message('C++ compiler does not work with C compiler') - message('Disabling C++-specific optional code') - endif endif # clang does not support glibc + FORTIFY_SOURCE (is it still true?)
@@ -1600,7 +1591,7 @@ if not get_option('snappy').auto() or have_system snappy = cc.find_library('snappy', has_headers: ['snappy-c.h'], required: get_option('snappy')) endif -if snappy.found() and not linker.links(''' +if snappy.found() and not cc.links(''' #include <snappy-c.h> int main(void) { snappy_max_compressed_length(4096); return 0; }''', dependencies: snappy) snappy = not_found
@@ -2746,7 +2737,7 @@ config_host_data.set('CONFIG_AF_VSOCK', cc.has_header_symbol( have_vss = false have_vss_sdk = false # old xp/2003 SDK -if targetos == 'windows' and link_language == 'cpp' +if targetos == 'windows' and 'cpp' in all_languages have_vss = cxx.compiles(''' #define __MIDL_user_allocate_free_DEFINED__ #include <vss.h>
@@ -3827,7 +3818,6 @@ foreach target : target_dirs c_args: c_args, dependencies: arch_deps + deps + exe['dependencies'], objects: lib.extract_all_objects(recursive: true), - link_language: link_language, link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []), link_args: link_args, win_subsystem: exe['win_subsystem'])
@@ -4061,7 +4051,7 @@ summary_info += {'host CPU': cpu} summary_info += {'host endianness': build_machine.endian()} summary_info += {'C compiler': ' '.join(meson.get_compiler('c').cmd_array())} summary_info += {'Host C compiler': ' '.join(meson.get_compiler('c', native: true).cmd_array())} -if link_language == 'cpp' +if 'cpp' in all_languages summary_info += {'C++ compiler': ' '.join(meson.get_compiler('cpp').cmd_array())} else summary_info += {'C++ compiler': false}
@@ -4074,13 +4064,13 @@ if get_option('optimization') != 'plain' option_cflags += ['-O' + get_option('optimization')] endif summary_info += {'CFLAGS': ' '.join(get_option('c_args') + option_cflags)} -if link_language == 'cpp' +if 'cpp' in all_languages summary_info += {'CXXFLAGS': ' '.join(get_option('cpp_args') + option_cflags)} endif if targetos == 'darwin' summary_info += {'OBJCFLAGS': ' '.join(get_option('objc_args') + option_cflags)} endif -link_args = get_option(link_language + '_link_args') +link_args = get_option('c_link_args') if link_args.length() > 0 summary_info += {'LDFLAGS': ' '.join(link_args)} endif
qga/meson.build +1 -1
@@ -9,7 +9,7 @@ endif have_qga_vss = get_option('qga_vss') \ .require(targetos == 'windows', error_message: 'VSS support requires Windows') \ - .require(link_language == 'cpp', + .require('cpp' in all_languages, error_message: 'VSS support requires a C++ compiler') \ .require(have_vss, error_message: '''VSS support requires VSS headers. If your Visual Studio installation doesn't have the VSS headers,
scripts/main.c deleted +0 -1
@@ -1 +0,0 @@ -int main (void ) {}
Signature · 1 line
2.41.0
[PULL 4/9] target/i386: Adjust feature level according to FEAT_7_1_EDX
In reply to Paolo BonziniFrom: Tao Su <[email protected]>
If FEAT_7_1_EAX is 0 and FEAT_7_1_EDX is non-zero, as is the case with a Granite Rapids host and
'-cpu host,-avx-vnni,-avx512-bf16,-fzrm,-fsrs,-fsrc,-amx-fp16', we can't get CPUID_7_1 leaf even though CPUID_7_1_EDX has non-zero value.
Update cpuid_level_func7 according to CPUID_7_1_EDX, otherwise guest may report wrong maximum number sub-leaves in leaf 07H.
Message-ID: <[email protected]>
--- target/i386/cpu.c | 1 + 1 file changed, 1 insertion(+)
target/i386/cpu.c +1 -0
@@ -6880,6 +6880,7 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **errp)x86_cpu_adjust_feat_level (cpu,FEAT_6_EAX );x86_cpu_adjust_feat_level (cpu,FEAT_7_0_ECX );x86_cpu_adjust_feat_level (cpu,FEAT_7_1_EAX ); +x86_cpu_adjust_feat_level (cpu,FEAT_7_1_EDX );x86_cpu_adjust_feat_level (cpu,FEAT_8000_0001_EDX );x86_cpu_adjust_feat_level (cpu,FEAT_8000_0001_ECX );x86_cpu_adjust_feat_level (cpu,FEAT_8000_0007_EDX );
Signature · 1 line
2.41.0
Re: [PULL 4/9] target/i386: Adjust feature level according to FEAT_7_1_EDX
Quoted 7 lines · Paolo Bonzini
From: Tao Su <[email protected]>
If
FEAT_7_1_EAXis 0 andFEAT_7_1_EDXis non-zero, as is the case with a Granite Rapids host and
'-cpu host,-avx-vnni,-avx512-bf16,-fzrm,-fsrs,-fsrc,-amx-fp16', we can't getCPUID_7_1leaf even thoughCPUID_7_1_EDXhas non-zero value.
Quoted 5 lines
Update
cpuid_level_func7according toCPUID_7_1_EDX, otherwise guest may report wrong maximum number sub-leaves in leaf 07H.Fixes eaaa197d5b11 ("target/i386: Add support for AVX-VNNI-INT8 in CPUID enumeration")
This patch is not applicable for any stable qemu releases, since the commit it fixes (eaaa197d5b11, which also introduced FEAT_7_1_EDX) is not in any released version, it is v8.0.0-290-geaaa197d5b.
This is just for the information (I'm not picking it up for stable), there's nothing wrong with it tagged for stable initially.
Thanks!
/mjt
[PULL 3/9] qemu_cleanup: begin drained section after vm_shutdown()
In reply to Paolo BonziniFrom: Fiona Ebner <[email protected]>
in order to avoid requests being stuck in a BlockBackend's request queue during cleanup. Having such requests can lead to a deadlock [0] with a virtio-scsi-pci device using iothread that's busy with IO when initiating a shutdown with QMP 'quit'.
There is a race where such a queued request can continue sometime (maybe after bdrv_child_free()?) during bdrv_root_unref_child() [1]. The completion will hold the AioContext lock and wait for the BQL during SCSI completion, but the main thread will hold the BQL and wait for the AioContext as part of bdrv_root_unref_child(), leading to the deadlock [0].
[0]:
Quoted 49 lines
Thread 3 (Thread
0x7f3bbd87b700(LWP 135952) "qemu-system-x86"):#0 __lll_lock_wait (futex=futex@entry=0x564183365f00 <qemu_global_mutex>, private=0) at lowlevellock.c:52 #1 0x00007f3bc1c0d843 in __GI___pthread_mutex_lock (mutex=0x564183365f00 <qemu_global_mutex>) at ../nptl/pthread_mutex_lock.c:80 #2 0x0000564182939f2e in qemu_mutex_lock_impl (mutex=0x564183365f00 <qemu_global_mutex>, file=0x564182b7f774 "../softmmu/physmem.c", line=2593) at ../util/qemu-thread-posix.c:94 #3 0x000056418247cc2a in qemu_mutex_lock_iothread_impl (file=0x564182b7f774 "../softmmu/physmem.c", line=2593) at ../softmmu/cpus.c:504 #4 0x00005641826d5325 in prepare_mmio_access (mr=0x5641856148a0) at ../softmmu/physmem.c:2593 #5 0x00005641826d6fe7 in address_space_stl_internal (as=0x56418679b310, addr=4276113408, val=16418, attrs=..., result=0x0, endian=DEVICE_LITTLE_ENDIAN) at /home/febner/repos/qemu/memory_ldst.c.inc:318 #6 0x00005641826d7154 in address_space_stl_le (as=0x56418679b310, addr=4276113408, val=16418, attrs=..., result=0x0) at /home/febner/repos/qemu/memory_ldst.c.inc:357 #7 0x0000564182374b07 in pci_msi_trigger (dev=0x56418679b0d0, msg=...) at ../hw/pci/pci.c:359 #8 0x000056418237118b in msi_send_message (dev=0x56418679b0d0, msg=...) at ../hw/pci/msi.c:379 #9 0x0000564182372c10 in msix_notify (dev=0x56418679b0d0, vector=8) at ../hw/pci/msix.c:542#10
0x000056418243719cinvirtio_pci_notify(d=0x56418679b0d0, vector=8) at../hw/virtio/virtio-pci.c:77
#110x00005641826933b0invirtio_notify_vector(vdev=0x5641867a34a0, vector=8) at../hw/virtio/virtio.c:1985#120x00005641826948d6invirtio_irq(vq=0x5641867ac078) at../hw/virtio/virtio.c:2461
#130x0000564182694978invirtio_notify(vdev=0x5641867a34a0, vq=0x5641867ac078) at../hw/virtio/virtio.c:2473#140x0000564182665b83invirtio_scsi_complete_req(req=0x7f3bb000e5d0) at../hw/scsi/virtio-scsi.c:115
#150x00005641826670ceinvirtio_scsi_complete_cmd_req(req=0x7f3bb000e5d0) at../hw/scsi/virtio-scsi.c:641#160x000056418266736binvirtio_scsi_command_complete(r=0x7f3bb0010560, resid=0) at../hw/scsi/virtio-scsi.c:712#170x000056418239aac6inscsi_req_complete(req=0x7f3bb0010560, status=2) at../hw/scsi/scsi-bus.c:1526
#180x000056418239e090inscsi_handle_rw_error(r=0x7f3bb0010560, ret=-123, acct_failed=false) at../hw/scsi/scsi-disk.c:242#190x000056418239e13finscsi_disk_req_check_error(r=0x7f3bb0010560, ret=-123, acct_failed=false) at../hw/scsi/scsi-disk.c:265#200x000056418239e482inscsi_dma_complete_noio(r=0x7f3bb0010560, ret=-123) at../hw/scsi/scsi-disk.c:340#210x000056418239e5d9inscsi_dma_complete(opaque=0x7f3bb0010560, ret=-123) at../hw/scsi/scsi-disk.c:371#220x00005641824809adindma_complete(dbs=0x7f3bb000d9d0, ret=-123) at../softmmu/dma-helpers.c:107
#230x0000564182480a72indma_blk_cb(opaque=0x7f3bb000d9d0, ret=-123) at../softmmu/dma-helpers.c:127
#240x00005641827bf78ainblk_aio_complete(acb=0x7f3bb00021a0) at../block/block-backend.c:1563
#250x00005641827bfa5einblk_aio_write_entry(opaque=0x7f3bb00021a0) at../block/block-backend.c:1630
#260x000056418295638aincoroutine_trampoline(i0=-1342102448, i1=32571) at../util/coroutine-ucontext.c:177#270x00007f3bc0caed40in ?? () from/lib/x86_64-linux-gnu/libc.so.6
#280x00007f3bbd8757f0in ?? ()
#290x0000000000000000in ?? ()Thread 1 (Thread
0x7f3bbe3e9280(LWP 135944) "qemu-system-x86"):#0 __lll_lock_wait (futex=futex@entry=0x5641856f2a00, private=0) at lowlevellock.c:52 #1 0x00007f3bc1c0d8d1 in __GI___pthread_mutex_lock (mutex=0x5641856f2a00) at ../nptl/pthread_mutex_lock.c:115 #2 0x0000564182939f2e in qemu_mutex_lock_impl (mutex=0x5641856f2a00, file=0x564182c0e319 "../util/async.c", line=728) at ../util/qemu-thread-posix.c:94 #3 0x000056418293a140 in qemu_rec_mutex_lock_impl (mutex=0x5641856f2a00, file=0x564182c0e319 "../util/async.c", line=728) at ../util/qemu-thread-posix.c:149 #4 0x00005641829532d5 in aio_context_acquire (ctx=0x5641856f29a0) at ../util/async.c:728 #5 0x000056418279d5df in bdrv_set_aio_context_commit (opaque=0x5641856e6e50) at ../block.c:7493 #6 0x000056418294e288 in tran_commit (tran=0x56418630bfe0) at ../util/transactions.c:87 #7 0x000056418279d880 in bdrv_try_change_aio_context (bs=0x5641856f7130, ctx=0x56418548f810, ignore_child=0x0, errp=0x0) at ../block.c:7626 #8 0x0000564182793f39 in bdrv_root_unref_child (child=0x5641856f47d0) at ../block.c:3242 #9 0x00005641827be137 in blk_remove_bs (blk=0x564185709880) at ../block/block-backend.c:914#10
0x00005641827bd689inblk_remove_all_bs() at../block/block-backend.c:583#110x0000564182798699inbdrv_close_all() at../block.c:5117
#120x000056418248a5b2inqemu_cleanup() at../softmmu/runstate.c:821#130x0000564182738603inqemu_default_main() at../softmmu/main.c:38#140x0000564182738631in main (argc=30, argv=0x7ffd675a8a48) at../softmmu/main.c:48
Quoted 4 lines
(gdb) p *((QemuMutex*)0x5641856f2a00)
$1 = {lock = {__data= {__lock= 2,__count= 2,__owner= 135952, ... (gdb) p *((QemuMutex*)0x564183365f00)
$2 = {lock = {__data= {__lock= 2,__count= 0,__owner= 135944, ...
[1]:
Quoted 14 lines
Thread 1 "qemu-system-x86" hit Breakpoint 5,
bdrv_drain_all_end() at../block/io.c:551#0 bdrv_drain_all_end () at ../block/io.c:551 #1 0x00005569810f0376 in bdrv_graph_wrlock (bs=0x0) at ../block/graph-lock.c:156 #2 0x00005569810bd3e0 in bdrv_replace_child_noperm (child=0x556982e2d7d0, new_bs=0x0) at ../block.c:2897 #3 0x00005569810bdef2 in bdrv_root_unref_child (child=0x556982e2d7d0) at ../block.c:3227 #4 0x00005569810e8137 in blk_remove_bs (blk=0x556982e42880) at ../block/block-backend.c:914 #5 0x00005569810e7689 in blk_remove_all_bs () at ../block/block-backend.c:583 #6 0x00005569810c2699 in bdrv_close_all () at ../block.c:5117 #7 0x0000556980db45b2 in qemu_cleanup () at ../softmmu/runstate.c:821 #8 0x0000556981062603 in qemu_default_main () at ../softmmu/main.c:38 #9 0x0000556981062631 in main (argc=30, argv=0x7ffd7a82a418) at ../softmmu/main.c:48[Switching to Thread
0x7fe76dab2700(LWP 103649)]Thread 3 "qemu-system-x86" hit Breakpoint 4,
blk_inc_in_flight(blk=0x556982e42880) at../block/block-backend.c:1505
Quoted 8 lines
#0 blk_inc_in_flight (blk=0x556982e42880) at ../block/block-backend.c:1505 #1 0x00005569810e8f36 in blk_wait_while_drained (blk=0x556982e42880) at ../block/block-backend.c:1312 #2 0x00005569810e9231 in blk_co_do_pwritev_part (blk=0x556982e42880, offset=3422961664, bytes=4096, qiov=0x556983028060, qiov_offset=0, flags=0) at ../block/block-backend.c:1402 #3 0x00005569810e9a4b in blk_aio_write_entry (opaque=0x556982e2cfa0) at ../block/block-backend.c:1628 #4 0x000055698128038a in coroutine_trampoline (i0=-2090057872, i1=21865) at ../util/coroutine-ucontext.c:177 #5 0x00007fe770f50d40 in ?? () from /lib/x86_64-linux-gnu/libc.so.6 #6 0x00007ffd7a829570 in ?? () #7 0x0000000000000000 in ?? ()
Message-ID: <[email protected]>
--- softmmu/runstate.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
softmmu/runstate.c +10 -10
@@ -802,21 +802,21 @@ void qemu_cleanup(void)*/ blk_exp_close_all (); -/* -* We must cancel all block jobs while the block layer is drained, -* or cancelling will be affected by throttling and thus may block -* for an extended period of time. -* vm_shutdown() will bdrv_drain_all(), so we may as well include -* it in the drained section. -* We do not need to end this section, because we do not want any -* requests happening from here on anyway. -*/ -bdrv_drain_all_begin ();/* No more vcpu or device emulation activity beyond this point */ vm_shutdown ();replay_finish (); +/* +* We must cancel all block jobs while the block layer is drained, +* or cancelling will be affected by throttling and thus may block +* for an extended period of time. +* Begin the drained section after vm_shutdown() to avoid requests being +* stuck in the BlockBackend's request queue. +* We do not need to end this section, because we do not want any +* requests happening from here on anyway. +*/ +bdrv_drain_all_begin ();job_cancel_sync_all ();bdrv_close_all ();
Signature · 1 line
2.41.0
[PULL 5/9] target/i386: Add support for MCDT_NO in CPUID enumeration
In reply to Paolo BonziniFrom: Tao Su <[email protected]>
CPUID.(EAX=7,ECX=2):EDX[bit 5] enumerates MCDT_NO. Processors enumerate this bit as 1 do not exhibit MXCSR Configuration Dependent Timing (MCDT) behavior and do not need to be mitigated to avoid data-dependent behavior for certain instructions.
Since MCDT_NO is in a new sub-leaf, add a new CPUID feature word FEAT_7_2_EDX. Also update cpuid_level_func7 by FEAT_7_2_EDX.
Message-ID: <[email protected]>
--- target/i386/cpu.c | 26 ++++++++++++++++++++++++++ target/i386/cpu.h | 4 ++++ 2 files changed, 30 insertions(+)
target/i386/cpu.c +26 -0
@@ -739,6 +739,7 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1,#define TCG_7_1_EAX_FEATURES (CPUID_7_1_EAX_FZRM | CPUID_7_1_EAX_FSRS | \ CPUID_7_1_EAX_FSRC)#define TCG_7_1_EDX_FEATURES 0 +#define TCG_7_2_EDX_FEATURES 0#define TCG_APM_FEATURES 0#define TCG_6_EAX_FEATURES CPUID_6_EAX_ARAT#define TCG_XSAVE_FEATURES (CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XGETBV1)
@@ -993,6 +994,25 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = { }, .tcg_features = TCG_7_1_EDX_FEATURES, }, + [FEAT_7_2_EDX] = { + .type = CPUID_FEATURE_WORD, + .feat_names = { +NULL ,NULL ,NULL ,NULL , +NULL ,"mcdt-no" ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , + NULL, NULL, NULL, NULL, + }, + .cpuid = { + .eax =7 , + .needs_ecx = true, .ecx = 2, + .reg = R_EDX, + }, + .tcg_features = TCG_7_2_EDX_FEATURES, + }, [FEAT_8000_0007_EDX] = { .type =CPUID_FEATURE_WORD , .feat_names = {
@@ -6017,6 +6037,11 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *edx = env->features[FEAT_7_1_EDX ]; *ebx =0 ; *ecx =0 ; + }else if (count ==2 ) { + *edx = env->features[FEAT_7_2_EDX ]; + *eax =0 ; + *ebx =0 ; + *ecx =0 ; }else { *eax =0 ; *ebx =0 ;
@@ -6881,6 +6906,7 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **errp)x86_cpu_adjust_feat_level (cpu,FEAT_7_0_ECX );x86_cpu_adjust_feat_level (cpu,FEAT_7_1_EAX );x86_cpu_adjust_feat_level (cpu,FEAT_7_1_EDX ); +x86_cpu_adjust_feat_level (cpu,FEAT_7_2_EDX );x86_cpu_adjust_feat_level (cpu,FEAT_8000_0001_EDX );x86_cpu_adjust_feat_level (cpu,FEAT_8000_0001_ECX );x86_cpu_adjust_feat_level (cpu,FEAT_8000_0007_EDX );
target/i386/cpu.h +4 -0
@@ -628,6 +628,7 @@ typedef enum FeatureWord {FEAT_XSAVE_XSS_LO ,/* CPUID[EAX=0xd,ECX=1].ECX */ FEAT_XSAVE_XSS_HI ,/* CPUID[EAX=0xd,ECX=1].EDX */ FEAT_7_1_EDX ,/* CPUID[EAX=7,ECX=1].EDX */ +FEAT_7_2_EDX ,/* CPUID[EAX=7,ECX=2].EDX */ FEATURE_WORDS , } FeatureWord;
@@ -932,6 +933,9 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWord w,/* PREFETCHIT0/1 Instructions */ #define CPUID_7_1_EDX_PREFETCHITI (1U << 14) +/* Do not exhibit MXCSR Configuration Dependent Timing (MCDT) behavior */ +#define CPUID_7_2_EDX_MCDT_NO (1U << 5) +/* XFD Extend Feature Disabled */ #define CPUID_D_1_EAX_XFD (1U << 4)
Signature · 1 line
2.41.0
[PULL 8/9] target/i386: Add few security fix bits in ARCH_CAPABILITIES into SapphireRapids CPU model
In reply to Paolo BonziniFrom: Lei Wang <[email protected]>
SapphireRapids has bit 13, 14 and 15 of MSR_IA32_ARCH_CAPABILITIES enabled, which are related to some security fixes.
Add version 2 of SapphireRapids CPU model with those bits enabled also.
Message-ID: <[email protected]>
--- target/i386/cpu.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
target/i386/cpu.c +11 -2
@@ -3944,8 +3944,17 @@ static const X86CPUDefinition builtin_x86_defs[] = { .model_id = "Intel Xeon Processor (SapphireRapids)", .versions = (X86CPUVersionDefinition []) { { .version =1 }, - { /* end of list */ }, - }, + { + .version =2 , + .props = (PropValue []) { + {"sbdr-ssdp-no" ,"on" }, + {"fbsdp-no" ,"on" }, + {"psdp-no" ,"on" }, + {/* end of list */ } + } + }, + {/* end of list */ } + } }, { .name = "Denverton",
Signature · 1 line
2.41.0
[PULL 9/9] target/i386: Add new CPU model GraniteRapids
In reply to Paolo BonziniFrom: Tao Su <[email protected]>
The GraniteRapids CPU model mainly adds the following new features based on SapphireRapids:
- PREFETCHITI CPUID.(EAX=7,ECX=1):EDX[bit 14]
- AMX-FP16 CPUID.(EAX=7,ECX=1):EAX[bit 21]
And adds the following security fix for corresponding vulnerabilities:
- MCDT_NO CPUID.(EAX=7,ECX=2):EDX[bit 5]
- SBDR_SSDP_NO MSR_IA32_ARCH_CAPABILITIES[bit 13]
- FBSDP_NO MSR_IA32_ARCH_CAPABILITIES[bit 14]
- PSDP_NO MSR_IA32_ARCH_CAPABILITIES[bit 15]
- PBRSB_NO MSR_IA32_ARCH_CAPABILITIES[bit 24]
Message-ID: <[email protected]>
--- target/i386/cpu.c | 136 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+)
target/i386/cpu.c +136 -0
@@ -3956,6 +3956,142 @@ static const X86CPUDefinition builtin_x86_defs[] = { {/* end of list */ } } }, + { + .name = "GraniteRapids", + .level = 0x20, + .vendor = CPUID_VENDOR_INTEL, + .family = 6, + .model = 173, + .stepping = 0, +/* +* please keep the ascending order so that we can have a clear view of +* bit position of each feature. +*/ + .features[FEAT_1_EDX ] = +CPUID_FP87 |CPUID_VME |CPUID_DE |CPUID_PSE |CPUID_TSC | +CPUID_MSR |CPUID_PAE |CPUID_MCE |CPUID_CX8 |CPUID_APIC | +CPUID_SEP |CPUID_MTRR |CPUID_PGE |CPUID_MCA |CPUID_CMOV | +CPUID_PAT |CPUID_PSE36 |CPUID_CLFLUSH |CPUID_MMX |CPUID_FXSR | + CPUID_SSE | CPUID_SSE2, + .features[FEAT_1_ECX ] = +CPUID_EXT_SSE3 |CPUID_EXT_PCLMULQDQ |CPUID_EXT_SSSE3 | +CPUID_EXT_FMA |CPUID_EXT_CX16 |CPUID_EXT_PCID |CPUID_EXT_SSE41 | +CPUID_EXT_SSE42 |CPUID_EXT_X2APIC |CPUID_EXT_MOVBE | +CPUID_EXT_POPCNT |CPUID_EXT_TSC_DEADLINE_TIMER |CPUID_EXT_AES | + CPUID_EXT_XSAVE | CPUID_EXT_AVX | CPUID_EXT_F16C | CPUID_EXT_RDRAND, + .features[FEAT_8000_0001_EDX ] = +CPUID_EXT2_SYSCALL |CPUID_EXT2_NX |CPUID_EXT2_PDPE1GB | + CPUID_EXT2_RDTSCP | CPUID_EXT2_LM, + .features[FEAT_8000_0001_ECX ] = + CPUID_EXT3_LAHF_LM | CPUID_EXT3_ABM | CPUID_EXT3_3DNOWPREFETCH, + .features[FEAT_8000_0008_EBX ] = + CPUID_8000_0008_EBX_WBNOINVD, + .features[FEAT_7_0_EBX ] = +CPUID_7_0_EBX_FSGSBASE |CPUID_7_0_EBX_BMI1 |CPUID_7_0_EBX_HLE | +CPUID_7_0_EBX_AVX2 |CPUID_7_0_EBX_SMEP |CPUID_7_0_EBX_BMI2 | +CPUID_7_0_EBX_ERMS |CPUID_7_0_EBX_INVPCID |CPUID_7_0_EBX_RTM | +CPUID_7_0_EBX_AVX512F |CPUID_7_0_EBX_AVX512DQ | +CPUID_7_0_EBX_RDSEED |CPUID_7_0_EBX_ADX |CPUID_7_0_EBX_SMAP | +CPUID_7_0_EBX_AVX512IFMA |CPUID_7_0_EBX_CLFLUSHOPT | +CPUID_7_0_EBX_CLWB |CPUID_7_0_EBX_AVX512CD |CPUID_7_0_EBX_SHA_NI | + CPUID_7_0_EBX_AVX512BW | CPUID_7_0_EBX_AVX512VL, + .features[FEAT_7_0_ECX ] = +CPUID_7_0_ECX_AVX512_VBMI |CPUID_7_0_ECX_UMIP |CPUID_7_0_ECX_PKU | +CPUID_7_0_ECX_AVX512_VBMI2 |CPUID_7_0_ECX_GFNI | +CPUID_7_0_ECX_VAES |CPUID_7_0_ECX_VPCLMULQDQ | +CPUID_7_0_ECX_AVX512VNNI |CPUID_7_0_ECX_AVX512BITALG | +CPUID_7_0_ECX_AVX512_VPOPCNTDQ |CPUID_7_0_ECX_LA57 | + CPUID_7_0_ECX_RDPID | CPUID_7_0_ECX_BUS_LOCK_DETECT, + .features[FEAT_7_0_EDX ] = +CPUID_7_0_EDX_FSRM |CPUID_7_0_EDX_SERIALIZE | +CPUID_7_0_EDX_TSX_LDTRK |CPUID_7_0_EDX_AMX_BF16 | +CPUID_7_0_EDX_AVX512_FP16 |CPUID_7_0_EDX_AMX_TILE | +CPUID_7_0_EDX_AMX_INT8 |CPUID_7_0_EDX_SPEC_CTRL | + CPUID_7_0_EDX_ARCH_CAPABILITIES | CPUID_7_0_EDX_SPEC_CTRL_SSBD, + .features[FEAT_ARCH_CAPABILITIES ] = +MSR_ARCH_CAP_RDCL_NO |MSR_ARCH_CAP_IBRS_ALL | +MSR_ARCH_CAP_SKIP_L1DFL_VMENTRY |MSR_ARCH_CAP_MDS_NO | +MSR_ARCH_CAP_PSCHANGE_MC_NO |MSR_ARCH_CAP_TAA_NO | +MSR_ARCH_CAP_SBDR_SSDP_NO |MSR_ARCH_CAP_FBSDP_NO | + MSR_ARCH_CAP_PSDP_NO | MSR_ARCH_CAP_PBRSB_NO, + .features[FEAT_XSAVE ] = +CPUID_XSAVE_XSAVEOPT |CPUID_XSAVE_XSAVEC | + CPUID_XSAVE_XGETBV1 | CPUID_XSAVE_XSAVES | CPUID_D_1_EAX_XFD, + .features[FEAT_6_EAX ] = + CPUID_6_EAX_ARAT, + .features[FEAT_7_1_EAX ] = +CPUID_7_1_EAX_AVX_VNNI |CPUID_7_1_EAX_AVX512_BF16 | +CPUID_7_1_EAX_FZRM |CPUID_7_1_EAX_FSRS |CPUID_7_1_EAX_FSRC | + CPUID_7_1_EAX_AMX_FP16, + .features[FEAT_7_1_EDX ] = + CPUID_7_1_EDX_PREFETCHITI, + .features[FEAT_7_2_EDX ] = + CPUID_7_2_EDX_MCDT_NO, + .features[FEAT_VMX_BASIC ] = + MSR_VMX_BASIC_INS_OUTS | MSR_VMX_BASIC_TRUE_CTLS, + .features[FEAT_VMX_ENTRY_CTLS ] = +VMX_VM_ENTRY_LOAD_DEBUG_CONTROLS |VMX_VM_ENTRY_IA32E_MODE | +VMX_VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL | + VMX_VM_ENTRY_LOAD_IA32_PAT | VMX_VM_ENTRY_LOAD_IA32_EFER, + .features[FEAT_VMX_EPT_VPID_CAPS ] = +MSR_VMX_EPT_EXECONLY | +MSR_VMX_EPT_PAGE_WALK_LENGTH_4 |MSR_VMX_EPT_PAGE_WALK_LENGTH_5 | +MSR_VMX_EPT_WB |MSR_VMX_EPT_2MB |MSR_VMX_EPT_1GB | +MSR_VMX_EPT_INVEPT |MSR_VMX_EPT_AD_BITS | +MSR_VMX_EPT_INVEPT_SINGLE_CONTEXT |MSR_VMX_EPT_INVEPT_ALL_CONTEXT | +MSR_VMX_EPT_INVVPID |MSR_VMX_EPT_INVVPID_SINGLE_ADDR | +MSR_VMX_EPT_INVVPID_SINGLE_CONTEXT | +MSR_VMX_EPT_INVVPID_ALL_CONTEXT | + MSR_VMX_EPT_INVVPID_SINGLE_CONTEXT_NOGLOBALS, + .features[FEAT_VMX_EXIT_CTLS ] = +VMX_VM_EXIT_SAVE_DEBUG_CONTROLS | +VMX_VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL | +VMX_VM_EXIT_ACK_INTR_ON_EXIT |VMX_VM_EXIT_SAVE_IA32_PAT | +VMX_VM_EXIT_LOAD_IA32_PAT |VMX_VM_EXIT_SAVE_IA32_EFER | + VMX_VM_EXIT_LOAD_IA32_EFER | VMX_VM_EXIT_SAVE_VMX_PREEMPTION_TIMER, + .features[FEAT_VMX_MISC ] = +MSR_VMX_MISC_STORE_LMA |MSR_VMX_MISC_ACTIVITY_HLT | + MSR_VMX_MISC_VMWRITE_VMEXIT, + .features[FEAT_VMX_PINBASED_CTLS ] = +VMX_PIN_BASED_EXT_INTR_MASK |VMX_PIN_BASED_NMI_EXITING | +VMX_PIN_BASED_VIRTUAL_NMIS |VMX_PIN_BASED_VMX_PREEMPTION_TIMER | + VMX_PIN_BASED_POSTED_INTR, + .features[FEAT_VMX_PROCBASED_CTLS ] = +VMX_CPU_BASED_VIRTUAL_INTR_PENDING | +VMX_CPU_BASED_USE_TSC_OFFSETING |VMX_CPU_BASED_HLT_EXITING | +VMX_CPU_BASED_INVLPG_EXITING |VMX_CPU_BASED_MWAIT_EXITING | +VMX_CPU_BASED_RDPMC_EXITING |VMX_CPU_BASED_RDTSC_EXITING | +VMX_CPU_BASED_CR3_LOAD_EXITING |VMX_CPU_BASED_CR3_STORE_EXITING | +VMX_CPU_BASED_CR8_LOAD_EXITING |VMX_CPU_BASED_CR8_STORE_EXITING | +VMX_CPU_BASED_TPR_SHADOW |VMX_CPU_BASED_VIRTUAL_NMI_PENDING | +VMX_CPU_BASED_MOV_DR_EXITING |VMX_CPU_BASED_UNCOND_IO_EXITING | +VMX_CPU_BASED_USE_IO_BITMAPS |VMX_CPU_BASED_MONITOR_TRAP_FLAG | +VMX_CPU_BASED_USE_MSR_BITMAPS |VMX_CPU_BASED_MONITOR_EXITING | +VMX_CPU_BASED_PAUSE_EXITING | + VMX_CPU_BASED_ACTIVATE_SECONDARY_CONTROLS, + .features[FEAT_VMX_SECONDARY_CTLS ] = +VMX_SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES | +VMX_SECONDARY_EXEC_ENABLE_EPT |VMX_SECONDARY_EXEC_DESC | +VMX_SECONDARY_EXEC_RDTSCP | +VMX_SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE | +VMX_SECONDARY_EXEC_ENABLE_VPID |VMX_SECONDARY_EXEC_WBINVD_EXITING | +VMX_SECONDARY_EXEC_UNRESTRICTED_GUEST | +VMX_SECONDARY_EXEC_APIC_REGISTER_VIRT | +VMX_SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY | +VMX_SECONDARY_EXEC_RDRAND_EXITING | +VMX_SECONDARY_EXEC_ENABLE_INVPCID | +VMX_SECONDARY_EXEC_ENABLE_VMFUNC |VMX_SECONDARY_EXEC_SHADOW_VMCS | +VMX_SECONDARY_EXEC_RDSEED_EXITING |VMX_SECONDARY_EXEC_ENABLE_PML | + VMX_SECONDARY_EXEC_XSAVES, + .features[FEAT_VMX_VMFUNC ] = + MSR_VMX_VMFUNC_EPT_SWITCHING, + .xlevel = 0x80000008, + .model_id = "Intel Xeon Processor (GraniteRapids)", + .versions = (X86CPUVersionDefinition []) { + { .version =1 }, + {/* end of list */ }, + }, + }, { .name = "Denverton", .level = 21,
Signature · 1 line
2.41.0
[PULL 6/9] target/i386: Allow MCDT_NO if host supports
In reply to Paolo BonziniFrom: Tao Su <[email protected]>
MCDT_NO bit indicates HW contains the security fix and doesn't need to be mitigated to avoid data-dependent behaviour for certain instructions. It needs no hypervisor support. Treat it as supported regardless of what KVM reports.
Message-ID: <[email protected]>
--- target/i386/kvm/kvm.c | 4 ++++ 1 file changed, 4 insertions(+)
target/i386/kvm/kvm.c +4 -0
@@ -432,6 +432,10 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,uint32_t eax;host_cpuid (7 ,1 , &eax, &unused, &unused, &unused); ret |= eax & (CPUID_7_1_EAX_FZRM |CPUID_7_1_EAX_FSRS |CPUID_7_1_EAX_FSRC ); + }else if (function ==7 && index ==2 && reg ==R_EDX ) { +uint32_t edx; +host_cpuid (7 ,2 , &unused, &unused, &unused, &edx); + ret |= edx &CPUID_7_2_EDX_MCDT_NO ; }else if (function ==0xd && index ==0 && (reg ==R_EAX || reg ==R_EDX )) {/*
Signature · 1 line
2.41.0
[PULL 7/9] target/i386: Add new bit definitions of MSR_IA32_ARCH_CAPABILITIES
In reply to Paolo BonziniFrom: Tao Su <[email protected]>
Currently, bit 13, 14, 15 and 24 of MSR_IA32_ARCH_CAPABILITIES are disclosed for fixing security issues, so add those bit definitions.
Message-ID: <[email protected]>
--- target/i386/cpu.h | 4 ++++ 1 file changed, 4 insertions(+)
target/i386/cpu.h +4 -0
@@ -1022,7 +1022,11 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWord w,#define MSR_ARCH_CAP_PSCHANGE_MC_NO (1U << 6)#define MSR_ARCH_CAP_TSX_CTRL_MSR (1U << 7)#define MSR_ARCH_CAP_TAA_NO (1U << 8) +#define MSR_ARCH_CAP_SBDR_SSDP_NO (1U << 13) +#define MSR_ARCH_CAP_FBSDP_NO (1U << 14) +#define MSR_ARCH_CAP_PSDP_NO (1U << 15)#define MSR_ARCH_CAP_FB_CLEAR (1U << 17) +#define MSR_ARCH_CAP_PBRSB_NO (1U << 24)#define MSR_CORE_CAP_SPLIT_LOCK_DETECT (1U << 5)
Signature · 1 line
2.41.0
Richard Henderson
AppliedQuoted 8 lines · Paolo Bonzini
The following changes since commit
97c81ef4b8e203d9620fd46e7eb77004563e3675:Merge tag 'pull-9p-20230706' ofhttps://github.com/cschoenebeck/qemu into staging (2023-07-06 18:19:42 +0100)are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
Quoted 7 lines
for you to fetch changes up to
6d5e9694ef374159072984c0958c3eaab6dd1d52:target/i386: Add new CPU model GraniteRapids (2023-07-07 12:52:27 +0200)----------------------------------------------------------------
* Granite Rapids CPU model
* Miscellaneous bugfixes
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/8.1 as appropriate.
r~