Re: [PATCH v4 29/31] hw/i386/sev: Allow use of pflash in conjunction with -bios

2024-06-03 Thread Paolo Bonzini
On Mon, Jun 3, 2024 at 1:55 PM Daniel P. Berrangé wrote: > I really wish we didn't have to introduce this though - is there really > no way to make it possible to use pflash for both CODE & VARS with SNP, > as is done with traditional VMs, so we don't diverge in setup, needing > yet more changes u

[PATCH 4/4] update-linux-headers: import linux/kvm_para.h header

2024-06-03 Thread Paolo Bonzini
"standard-headers/linux/kvm_para.h" will not because it can be used in architecture-independent files. This could easily be extended to other architectures, but right now they do not need any symbol in their specific kvm_para.h files. Signed-off-by: Paolo Bonzini --- include/st

[PATCH] target/i386: fix xsave.flat from kvm-unit-tests

2024-06-03 Thread Paolo Bonzini
E and XRSTOR of AVX registers", 2022-10-18) Reported-by: Thomas Huth Signed-off-by: Paolo Bonzini --- target/i386/tcg/fpu_helper.c | 5 + 1 file changed, 5 insertions(+) diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c index e322293371c..e1b850f3fc2 100644 -

Re: [PATCH] target/i386/tcg: Fix RDPID feature check

2024-06-03 Thread Paolo Bonzini
Queued, thanks. Paolo

Re: [PATCH] target/i386: fix memory opsize for Mov to/from Seg

2024-06-03 Thread Paolo Bonzini
On 6/2/24 12:05, lixinyu...@ict.ac.cn wrote: From: Xinyu Li This commit fixes an issue with MOV instructions (0x8C and 0x8E) involving segment registers by explicitly setting the memory operand size to 16 bits. It introduces a new flag X86_SPECIAL_MovSeg to handle this specification correctly.

Re: [PATCH] target/i386: fix SSE and SSE2 featue check

2024-06-03 Thread Paolo Bonzini
Queued, thanks. Paolo

Re: [PATCH] i386: removes microvm from default build since microvm doesn't support Xen accel.

2024-06-02 Thread Paolo Bonzini
On 6/2/24 12:38, Will Gyda wrote: i386: removes microvm from default build since microvm doesn't support Xen accel. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2294 This is already done in (what will be) QEMU 9.1; configs/devices/i386-softmmu.mak has: # Boards are selected by d

Re: [PATCH v4 00/31] Add AMD Secure Nested Paging (SEV-SNP) support

2024-05-31 Thread Paolo Bonzini
On Fri, May 31, 2024 at 7:41 PM Gupta, Pankaj wrote: > > please check if branch qemu-coco-queue of > > https://gitlab.com/bonzini/qemu works for you! > > Getting compilation error here: Hope I am looking at correct branch. Oops, sorry: diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c i

Re: [PATCH v4 00/31] Add AMD Secure Nested Paging (SEV-SNP) support

2024-05-31 Thread Paolo Bonzini
On Fri, May 31, 2024 at 1:20 PM Paolo Bonzini wrote: > > On Thu, May 30, 2024 at 1:16 PM Pankaj Gupta wrote: > > > > These patches implement SEV-SNP base support along with CPUID enforcement > > support for QEMU, and are also available at: > > > > https:/

Re: [PATCH v4 18/31] hw/i386/sev: Add function to get SEV metadata from OVMF header

2024-05-31 Thread Paolo Bonzini
On Fri, May 31, 2024 at 5:20 PM Liam Merwick wrote: > > +metadata = (OvmfSevMetadata *)(flash_ptr + flash_size - data->offset); > > +if (memcmp(metadata->signature, "ASEV", 4) != 0) { > > +return; > > +} > > + > > +ovmf_sev_metadata_table = g_malloc(metadata->len); > > Ther

Re: [PATCH v4 02/31] linux-headers: Update to current kvm/next

2024-05-31 Thread Paolo Bonzini
On Fri, May 31, 2024 at 4:38 PM Liam Merwick wrote: > > --- a/linux-headers/asm-x86/kvm.h > > +++ b/linux-headers/asm-x86/kvm.h > > @@ -870,5 +919,6 @@ struct kvm_hyperv_eventfd { > > #define KVM_X86_SW_PROTECTED_VM 1 > > #define KVM_X86_SEV_VM 2 > > #define KVM_X86_SEV_ES_V

Re: [PATCH v4 29/31] hw/i386/sev: Allow use of pflash in conjunction with -bios

2024-05-31 Thread Paolo Bonzini
On Thu, May 30, 2024 at 1:17 PM Pankaj Gupta wrote: > diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c > index def77a4429fb24e62748 > +static void pc_system_flash_map(PCMachineState *pcms, > +MemoryRegion *rom_memory) > +{ > +pc_system_flash_map_partial(pcms

Re: [PATCH v4 27/31] hw/i386/sev: Use guest_memfd for legacy ROMs

2024-05-31 Thread Paolo Bonzini
On Thu, May 30, 2024 at 1:17 PM Pankaj Gupta wrote: > > From: Michael Roth > > Current SNP guest kernels will attempt to access these regions with > with C-bit set, so guest_memfd is needed to handle that. Otherwise, > kvm_convert_memory() will fail when the guest kernel tries to access it > and

[PATCH] machine: allow early use of machine_require_guest_memfd

2024-05-31 Thread Paolo Bonzini
Ask the ConfidentialGuestSupport object whether to use guest_memfd for KVM-backend private memory. This bool can be set in instance_init (or user_complete) so that it is available when the machine is created. Signed-off-by: Paolo Bonzini --- include/exec/confidential-guest-support.h | 5

Re: [PATCH v4 28/31] hw/i386: Add support for loading BIOS using guest_memfd

2024-05-31 Thread Paolo Bonzini
On Thu, May 30, 2024 at 1:17 PM Pankaj Gupta wrote: > if (bios_size <= 0 || > (bios_size % 65536) != 0) { > -goto bios_error; > +if (!machine_require_guest_memfd(MACHINE(x86ms))) { > +g_warning("%s: Unaligned BIOS size %d", __func__, bios_size); > +

Re: [PATCH v4 00/31] Add AMD Secure Nested Paging (SEV-SNP) support

2024-05-31 Thread Paolo Bonzini
On Thu, May 30, 2024 at 1:16 PM Pankaj Gupta wrote: > > These patches implement SEV-SNP base support along with CPUID enforcement > support for QEMU, and are also available at: > > https://github.com/pagupta/qemu/tree/snp_v4 > > Latest version of kvm changes are posted here [2] and also queued in

Re: [PATCH v4 23/31] i386/sev: Allow measured direct kernel boot on SNP

2024-05-31 Thread Paolo Bonzini
On Thu, May 30, 2024 at 1:17 PM Pankaj Gupta wrote: > > From: Dov Murik > > In SNP, the hashes page designated with a specific metadata entry > published in AmdSev OVMF. > > Therefore, if the user enabled kernel hashes (for measured direct boot), > QEMU should prepare the content of hashes table,

Re: [PATCH v4 22/31] i386/sev: Reorder struct declarations

2024-05-31 Thread Paolo Bonzini
On Thu, May 30, 2024 at 1:17 PM Pankaj Gupta wrote: > > From: Dov Murik > > Move the declaration of PaddedSevHashTable before SevSnpGuest so > we can add a new such field to the latter. > No functional change intended. > > Signed-off-by: Dov Murik > Signed-off-by: Michael Roth > Signed-off-by:

Re: [PATCH v4 25/31] i386/sev: Invoke launch_updata_data() for SEV class

2024-05-31 Thread Paolo Bonzini
On Thu, May 30, 2024 at 1:17 PM Pankaj Gupta wrote: > > Add launch_update_data() in SevCommonStateClass and > invoke as sev_launch_update_data() for SEV object. > > Signed-off-by: Pankaj Gupta > --- > target/i386/sev.c | 15 +++ > 1 file changed, 7 insertions(+), 8 deletions(-) > > d

Re: [PATCH v4 10/31] i386/sev: Add snp_kvm_init() override for SNP class

2024-05-31 Thread Paolo Bonzini
On Thu, May 30, 2024 at 1:17 PM Pankaj Gupta wrote: > +} else if (x86ms->smm == ON_OFF_AUTO_ON) { > +error_setg(errp, "SEV-SNP does not support SMM."); > +ram_block_discard_disable(false); Unnecessary line, there is no matching ram_block_discard_disable(true). Paolo

Re: [PATCH v4 09/31] i386/sev: Add sev_kvm_init() override for SEV class

2024-05-31 Thread Paolo Bonzini
On Thu, May 30, 2024 at 1:17 PM Pankaj Gupta wrote: > +/* > + * SEV uses these notifiers to register/pin pages prior to guest use, > + * but SNP relies on guest_memfd for private pages, which has it's > + * own internal mechanisms for registering/pinning private memory. > + */

Re: [PATCH v4 07/31] i386/sev: Introduce 'sev-snp-guest' object

2024-05-31 Thread Paolo Bonzini
On Thu, May 30, 2024 at 1:17 PM Pankaj Gupta wrote: > +++ b/qapi/qom.json > @@ -928,6 +928,61 @@ > '*policy': 'uint32', > '*handle': 'uint32', > '*legacy-vm-type': 'bool' } } Nit, missing empty line here. > +## > +# @SevSnpGuestProperties: > +# [...] > d

Re: [PATCH v4 04/31] i386/sev: Introduce "sev-common" type to encapsulate common SEV state

2024-05-31 Thread Paolo Bonzini
On Thu, May 30, 2024 at 1:17 PM Pankaj Gupta wrote: > > -#define TYPE_SEV_GUEST "sev-guest" > -OBJECT_DECLARE_SIMPLE_TYPE(SevGuestState, SEV_GUEST) > > +OBJECT_DECLARE_TYPE(SevCommonState, SevCommonStateClass, SEV_COMMON) > +OBJECT_DECLARE_TYPE(SevGuestState, SevGuestStateClass, SEV_GUEST) A sepa

[PATCH 6/6] host/i386: assume presence of POPCNT

2024-05-31 Thread Paolo Bonzini
QEMU now requires an x86-64-v2 host, which has the POPCNT instruction. Use it freely in TCG-generated code. Signed-off-by: Paolo Bonzini --- host/include/i386/host/cpuinfo.h | 1 - tcg/i386/tcg-target.h| 5 ++--- util/cpuinfo-i386.c | 1 - 3 files changed, 2 insertions

[PATCH 3/6] host/i386: assume presence of CMOV

2024-05-31 Thread Paolo Bonzini
QEMU now requires an x86-64-v2 host, which always has CMOV. Use it freely in TCG generated code. Signed-off-by: Paolo Bonzini --- host/include/i386/host/cpuinfo.h | 1 - util/cpuinfo-i386.c | 1 - tcg/i386/tcg-target.c.inc| 15 +-- 3 files changed, 1 insertion

[PATCH 2/6] meson: assume x86-64-v2 baseline ISA

2024-05-31 Thread Paolo Bonzini
x86-64-v2 processors were released in 2008, assume that we have one. Unfortunately there is no GCC flag to enable all the features without disabling what came after; so enable them one by one. Signed-off-by: Paolo Bonzini --- meson.build | 10 +++--- 1 file changed, 7 insertions(+), 3

[PATCH 5/6] host/i386: assume presence of SSSE3

2024-05-31 Thread Paolo Bonzini
QEMU now requires an x86-64-v2 host, which has SSSE3 instructions (notably, PSHUFB which is used by QEMU's AES implementation). Do not bother checking it. Signed-off-by: Paolo Bonzini --- util/cpuinfo-i386.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/cp

[PATCH 0/6] host/i386: require x86-64-v2 ISA

2024-05-31 Thread Paolo Bonzini
x86-64-v2 processors were released in 2008, assume that we have one. This provides CMOV on 32-bit processors, and also POPCNT and various vector ISA extensions. Paolo Paolo Bonzini (6): host/i386: nothing looks at CPUINFO_SSE4 meson: assume x86-64-v2 baseline ISA host/i386: assume presence

[PATCH 1/6] host/i386: nothing looks at CPUINFO_SSE4

2024-05-31 Thread Paolo Bonzini
The only user was the SSE4.1 variant of buffer_is_zero, which has been removed; code to compute CPUINFO_SSE4 is dead. Signed-off-by: Paolo Bonzini --- host/include/i386/host/cpuinfo.h | 1 - util/cpuinfo-i386.c | 1 - 2 files changed, 2 deletions(-) diff --git a/host/include/i386

[PATCH 4/6] host/i386: assume presence of SSE2

2024-05-31 Thread Paolo Bonzini
QEMU now requires an x86-64-v2 host, which has SSE2. Use it freely in buffer_is_zero. Signed-off-by: Paolo Bonzini --- host/include/i386/host/cpuinfo.h | 1 - util/bufferiszero.c | 2 +- util/cpuinfo-i386.c | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff

Re: [PATCH 3/3] semihosting: Restrict to TCG

2024-05-30 Thread Paolo Bonzini
On Thu, May 30, 2024 at 9:22 AM Philippe Mathieu-Daudé wrote: > > On 30/5/24 08:02, Paolo Bonzini wrote: > > On Wed, May 29, 2024 at 5:56 PM Philippe Mathieu-Daudé > > wrote: > >> It is pointless to build semihosting when TCG is not available. > > > > W

Re: [PATCH 2/5] qtest: use cpu interface in qtest_clock_warp

2024-05-29 Thread Paolo Bonzini
On Fri, May 17, 2024 at 12:21 AM Pierrick Bouvier wrote: > > From: Alex Bennée > > This generalises the qtest_clock_warp code to use the AccelOps > handlers for updating its own sense of time. This will make the next > patch which moves the warp code closer to pure code motion. > > From: Alex Ben

Re: [PATCH 1/5] sysemu: add set_virtual_time to accel ops

2024-05-29 Thread Paolo Bonzini
On Fri, May 17, 2024 at 12:21 AM Pierrick Bouvier wrote: > diff --git a/stubs/meson.build b/stubs/meson.build > index 3b9d42023cb..672213b7482 100644 > --- a/stubs/meson.build > +++ b/stubs/meson.build > @@ -3,6 +3,11 @@ > # below, so that it is clear who needs the stubbed functionality. > > stu

Re: [PATCH 3/3] semihosting: Restrict to TCG

2024-05-29 Thread Paolo Bonzini
On Wed, May 29, 2024 at 5:56 PM Philippe Mathieu-Daudé wrote: > It is pointless to build semihosting when TCG is not available. Why? I would have naively assumed that a suitable semihosting API could be implemented by KVM. The justification (and thus the commit message) needs to be different for

Re: [PATCH 0/3] semihosting: Restrict to TCG

2024-05-29 Thread Paolo Bonzini
On Wed, May 29, 2024 at 9:11 PM Alex Bennée wrote: > > Philippe Mathieu-Daudé writes: > > > It is pointless to build semihosting when TCG is not available. > > > > Philippe Mathieu-Daudé (3): > > target/mips: Restrict semihosting to TCG > > target/riscv: Restrict semihosting to TCG > > semi

Re: [PATCH] Issue #2294 | Machine microvm doesn't run under Xen accel for x86_64

2024-05-29 Thread Paolo Bonzini
On 5/28/24 12:23, Will Gyda wrote: Issue #2294: Machine microvm doesn't run under Xen accel for qemu-system-x86_64. Solution: microvm is now not build if only Xen is available. This does not fix the issue that microvm does not start with a Xen accelerator. I think it would be better to try an

Re: [PATCH 3/4] usb/ohci-pci: deprecate, don't build by default

2024-05-28 Thread Paolo Bonzini
On Tue, May 28, 2024 at 12:35 PM Thomas Huth wrote: > > diff --git a/hw/usb/Kconfig b/hw/usb/Kconfig > > index 84bc7fbe36cd..c4a6ea5a687f 100644 > > --- a/hw/usb/Kconfig > > +++ b/hw/usb/Kconfig > > @@ -17,7 +17,6 @@ config USB_OHCI_SYSBUS > > > > config USB_OHCI_PCI > > bool > > -defa

[RFC PATCH v2 2/5] meson: move block.syms dependency out of libblock

2024-05-27 Thread Paolo Bonzini
dd the link_args and link_depends to the executables directly; fortunately there is just four of them. It is possible (and I will look into it) to add "link_depends" to declare_dependency(), but it probably will be a while before QEMU can use it. Signed-off-by: Paolo Bonzini --- meson.build

[RFC PATCH v2 0/5] meson: Pass objects to declare_dependency()

2024-05-27 Thread Paolo Bonzini
move the .fa suffixes. This series can be evaluated independently from that. Paolo Akihiko Odaki (2): meson: Pass objects and dependencies to declare_dependency() Revert "meson: Propagate gnutls dependency" Paolo Bonzini (3): meson: move shared_module() calls where module

[RFC PATCH v2 3/5] meson: Pass objects and dependencies to declare_dependency()

2024-05-27 Thread Paolo Bonzini
pendencies can be added as well so that they are propagated, because object files on the linker command line are always deduplicated. This requires Meson 1.1.0 or later. Signed-off-by: Akihiko Odaki Message-ID: <20240524-objects-v1-1-07cbbe961...@daynix.com> Signed-off

[RFC PATCH v2 1/5] meson: move shared_module() calls where modules are already walked

2024-05-27 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini --- meson.build | 34 +++--- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/meson.build b/meson.build index 63866071445..92ddbd17c32 100644 --- a/meson.build +++ b/meson.build @@ -3562,21 +3562,28 @@ modinfo_files

[RFC PATCH v2 4/5] Revert "meson: Propagate gnutls dependency"

2024-05-27 Thread Paolo Bonzini
. Signed-off-by: Akihiko Odaki Message-ID: <20240524-objects-v1-2-07cbbe961...@daynix.com> Signed-off-by: Paolo Bonzini --- meson.build| 4 ++-- block/meson.build | 2 +- io/meson.build | 2 +- storage-daemon/meson.build | 2 +- ui/meson.build

[RFC PATCH v2 5/5] meson: Drop the .fa library suffix

2024-05-27 Thread Paolo Bonzini
ree-wide search with 'fa' and .fa (note the quotes and dot). Signed-off-by: Akihiko Odaki Message-ID: <20240524-xkb-v4-4-2de564e5c...@daynix.com> Signed-off-by: Paolo Bonzini --- docs/devel/build-system.rst | 5 - meson.build | 17 ++---

[PULL 24/24] migration: remove unnecessary zlib dependency

2024-05-25 Thread Paolo Bonzini
zlib code is only used by the emulators, not by the tests. Signed-off-by: Paolo Bonzini --- meson.build | 2 +- migration/dirtyrate.c | 1 - migration/qemu-file.c | 1 - migration/meson.build | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/meson.build b

[PULL 13/24] target/i386: reg in gen_ldst_modrm is always OR_TMP0

2024-05-25 Thread Paolo Bonzini
Values other than OR_TMP0 were only ever used by MOV and MOVNTI opcodes. Now that these have been converted to the new decoder, remove the argument. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 33 - 1 file

[PULL 06/24] target/i386: cpu_load_eflags already sets cc_op

2024-05-25 Thread Paolo Bonzini
No need to set it again at the end of the translation block, cc_op_dirty can be set to false. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 37 - target/i386/tcg/emit.c.inc | 2 +- 2 files changed, 25

[PULL 21/24] meson: remove unnecessary dependency

2024-05-25 Thread Paolo Bonzini
The dbus_display1_dep is not really used since all occurrences also request gio independently. Just list the generated sources and drop dbus_display1_dep. Signed-off-by: Paolo Bonzini --- audio/meson.build | 4 ++-- tests/qtest/meson.build | 2 +- ui/meson.build | 5 ++--- 3

[PULL 04/24] target/i386: cleanup eob handling of RSM

2024-05-25 Thread Paolo Bonzini
s non-dirty and gen_eob will not overwrite the CC_OP_EFLAGS value that is placed there by the helper. But let's clean it up. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/targe

[PULL 10/24] target/i386: avoid calling gen_eob_inhibit_irq before tb_stop

2024-05-25 Thread Paolo Bonzini
sti only has one exit, so it does not need to generate the end-of-translation code inline. It can be deferred to tb_stop. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 13 - target/i386/tcg/emit.c.inc | 4 +--- 2 files changed, 1

[PULL 17/24] target/i386: introduce gen_lea_ss_ofs

2024-05-25 Thread Paolo Bonzini
Generalize gen_stack_A0() to include an initial add and to use an arbitrary destination. This is a common pattern and it is not a huge burden to add the extra arguments to the only caller of gen_stack_A0(). Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg

[PULL 18/24] target/i386: clean up repeated string operations

2024-05-25 Thread Paolo Bonzini
Do not bother generating inline wrappers for gen_repz and gen_repz2; use s->prefix to separate REPZ from REPNZ in the case of SCAS and CMPS. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 22 -- target/i386/tcg/emit.c.inc |

[PULL 16/24] target/i386: use mo_stacksize more

2024-05-25 Thread Paolo Bonzini
Use mo_stacksize for all stack accesses, including when a 64-bit code segment is impossible and the code is therefore checking only for SS32(s). Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 8 1 file changed, 4 insertions(+), 4

[PULL 01/24] configure: move -mcx16 flag out of CPU_CFLAGS

2024-05-25 Thread Paolo Bonzini
gned-off-by: Paolo Bonzini --- configure | 7 ++- meson.build | 7 +++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 38ee2577013..4d01a42ba65 100755 --- a/configure +++ b/configure @@ -512,10 +512,7 @@ case "$cpu" in cpu="x86

[PULL 14/24] target/i386: split gen_ldst_modrm for load and store

2024-05-25 Thread Paolo Bonzini
The is_store argument of gen_ldst_modrm has only ever been passed a constant. Just split the function in two. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 52 + 1 file changed, 29 insertions(+), 23 deletions

[PULL 20/24] meson: remove unnecessary reference to libm

2024-05-25 Thread Paolo Bonzini
libm is linked into all targets via libqemuutil, no need to specify it explicitly. Signed-off-by: Paolo Bonzini --- block/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/meson.build b/block/meson.build index e1f03fd773e..8993055c75e 100644 --- a/block

[PULL 05/24] target/i386: remove unnecessary gen_update_cc_op before gen_eob*

2024-05-25 Thread Paolo Bonzini
This is already handled in gen_eob(). Before adding another DISAS_* case, remove the double calls. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg

[PULL 23/24] meson: do not query modules before they are processed

2024-05-25 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini --- block/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/meson.build b/block/meson.build index 8993055c75e..158dc3b89db 100644 --- a/block/meson.build +++ b/block/meson.build @@ -119,7 +119,7 @@ foreach m : [ module_ss

[PULL 03/24] target/i386: no single-step exception after MOV or POP SS

2024-05-25 Thread Paolo Bonzini
Intel SDM 18.3.1.4 "If an occurrence of the MOV or POP instruction loads the SS register executes with EFLAGS.TF = 1, no single-step debug exception occurs following the MOV or POP instruction." Cc: qemu-sta...@nongnu.org Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c

[PULL 08/24] target/i386: document and group DISAS_* constants

2024-05-25 Thread Paolo Bonzini
Place DISAS_* constants that update cpu_eip first, and the "jump" ones last. Add comments explaining the differences and usage. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 25 ++--- 1 file changed, 22 insert

[PULL 22/24] tcg: include dependencies in static_library()

2024-05-25 Thread Paolo Bonzini
This ensures that for example libffi can be reached even if it is not in /usr/include. Signed-off-by: Paolo Bonzini --- tcg/meson.build | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tcg/meson.build b/tcg/meson.build index 8251589fd4e..ffbe754d8b3 100644 --- a/tcg

[PULL 11/24] target/i386: assert that gen_update_eip_cur and gen_update_eip_next are the same in tb_stop

2024-05-25 Thread Paolo Bonzini
This is an invariant now that there are no calls to gen_eob_inhibit_irq() outside tb_stop. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c

[PULL 12/24] target/i386: raze the gen_eob* jungle

2024-05-25 Thread Paolo Bonzini
Make gen_eob take the DISAS_* constant as an argument, so that it is not necessary to have wrappers around it. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 62 + 1 file changed, 15 insertions(+), 47 deletions

[PULL 15/24] target/i386: inline gen_add_A0_ds_seg

2024-05-25 Thread Paolo Bonzini
It is only used in MONITOR, where a direct call of gen_lea_v_seg is simpler, and in XLAT. Inline it in the latter. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 9 + target/i386/tcg/emit.c.inc | 2 +- 2 files changed, 2 insertions(+), 9

[PULL 19/24] target/i386: remove aflag argument of gen_lea_v_seg

2024-05-25 Thread Paolo Bonzini
It is always s->aflag. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 20 ++-- target/i386/tcg/emit.c.inc | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/

[PULL 07/24] target/i386: set CC_OP in helpers if they want CC_OP_EFLAGS

2024-05-25 Thread Paolo Bonzini
which case cc_op would not be overwritten * anyway the cost is probably dwarfed by that of computing flags. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/ops_sse.h| 8 target/i386/tcg/fpu_helper.c | 2 ++ target/i386/tcg/int_helper.c | 13

[PULL 09/24] target/i386: avoid calling gen_eob_syscall before tb_stop

2024-05-25 Thread Paolo Bonzini
syscall and sysret only have one exit, so they do not need to generate the end-of-translation code inline. It can be deferred to tb_stop. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 13 +++-- 1 file changed, 11 insertions(+), 2

[PULL 02/24] target/i386: disable jmp_opt if EFLAGS.RF is 1

2024-05-25 Thread Paolo Bonzini
If EFLAGS.RF is 1, special processing in gen_eob_worker() is needed and therefore goto_tb cannot be used. Suggested-by: Richard Henderson Reviewed-by: Richard Henderson Cc: qemu-sta...@nongnu.org Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 2 +- 1 file changed, 1 insertion

[PULL 00/24] Build system and target/i386/translate.c cleanups for 2025-05-25

2024-05-25 Thread Paolo Bonzini
c cleanups Artyom Kunakovsky (1): configure: move -mcx16 flag out of CPU_CFLAGS Paolo Bonzini (23): target/i386: disable jmp_opt if EFLAGS.RF is 1 target/i386: no single-step exception after MOV or POP SS target/i386: cleanup eob handling of RSM t

Re: [PATCH] target/i386: always go through gen_eob*()

2024-05-25 Thread Paolo Bonzini
On Fri, May 24, 2024 at 6:51 PM Richard Henderson wrote: > > static void gen_set_hflag(DisasContext *s, uint32_t mask) > > @@ -2354,7 +2354,7 @@ static void gen_jmp_rel(DisasContext *s, MemOp ot, > > int diff, int tb_num) > > tcg_gen_movi_tl(cpu_eip, new_eip); > > } > >

[PATCH 2/5] meson: remove unnecessary dependency

2024-05-24 Thread Paolo Bonzini
The dbus_display1_dep is not really used since all occurrences also request gio independently. Just list the generated sources and drop dbus_display1_dep. Signed-off-by: Paolo Bonzini --- audio/meson.build | 4 ++-- tests/qtest/meson.build | 2 +- ui/meson.build | 5 ++--- 3

[PATCH 1/5] meson: remove unnecessary reference to libm

2024-05-24 Thread Paolo Bonzini
libm is linked into all targets via libqemuutil, no need to specify it explicitly. Signed-off-by: Paolo Bonzini --- block/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/meson.build b/block/meson.build index e1f03fd773e..8993055c75e 100644 --- a/block

[PATCH 4/5] meson: do not query modules before they are processed

2024-05-24 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini --- block/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/meson.build b/block/meson.build index 8993055c75e..158dc3b89db 100644 --- a/block/meson.build +++ b/block/meson.build @@ -119,7 +119,7 @@ foreach m : [ module_ss

[PATCH 5/5] migration: remove unnecessary zlib dependency

2024-05-24 Thread Paolo Bonzini
zlib code is only used by the emulators, not by the tests. Signed-off-by: Paolo Bonzini --- meson.build | 2 +- migration/dirtyrate.c | 1 - migration/qemu-file.c | 1 - migration/meson.build | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/meson.build b

[PATCH 3/5] tcg: include dependencies in static_library()

2024-05-24 Thread Paolo Bonzini
This ensures that for example libffi can be reached even if it is not in /usr/include. Signed-off-by: Paolo Bonzini --- tcg/meson.build | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tcg/meson.build b/tcg/meson.build index 8251589fd4e..ffbe754d8b3 100644 --- a/tcg

[PATCH 0/5] meson: small cleanups

2024-05-24 Thread Paolo Bonzini
All found while looking at Akihiko's issues with declare_dependency( objects: ...). https://patchew.org/QEMU/20240524-objects-v1-0-07cbbe961...@daynix.com/ Paolo Bonzini (5): meson: remove unnecessary reference to libm meson: remove unnecessary dependency tcg: include dependenci

Re: [RFC PATCH 1/4] target/riscv/kvm: add software breakpoints support

2024-05-24 Thread Paolo Bonzini
On Tue, Apr 16, 2024 at 11:23 AM Daniel Henrique Barboza wrote: > > +int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint > > *bp, > > + vaddr len) > > +{ > > +if (len != 4 && len != 2) { > > +return -EINVAL; > > +} > > I wonder

[PATCH] target/i386: always go through gen_eob*()

2024-05-24 Thread Paolo Bonzini
Using DISAS_NORETURN does not process any of HF_INHIBIT_IRQ_MASK, HF_RF_MASK or HF_TF_MASK. Never use it, instead there is DISAS_EOB_ONLY. Cc: qemu-sta...@nongnu.org Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 18 -- target/i386/tcg/emit.c.inc | 4 ++-- 2

[PATCH] target/i386: disable jmp_opt if EFLAGS.RF is 1

2024-05-24 Thread Paolo Bonzini
If EFLAGS.RF is 1, special processing in gen_eob_worker() is needed and therefore goto_tb cannot be used. Suggested-by: Richard Henderson Cc: qemu-sta...@nongnu.org Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a

Re: [PATCH 03/16] target/i386: document and group DISAS_* constants

2024-05-24 Thread Paolo Bonzini
On Fri, May 24, 2024 at 5:13 PM Richard Henderson wrote: > > On 5/24/24 08:04, Paolo Bonzini wrote: > > ... and nope, it's the other way round - DISAS_NORETURN is a bug > > waiting to happen for x86 translation because it doesn't process any > > of HF_INHIBIT_

Re: [PATCH 03/16] target/i386: document and group DISAS_* constants

2024-05-24 Thread Paolo Bonzini
On Fri, May 24, 2024 at 5:02 PM Paolo Bonzini wrote: > > On Fri, May 24, 2024 at 4:23 PM Richard Henderson > wrote: > > > > On 5/24/24 01:10, Paolo Bonzini wrote: > > > Place DISAS_* constants that update cpu_eip first, and > > > the "jump" on

Re: [PATCH 03/16] target/i386: document and group DISAS_* constants

2024-05-24 Thread Paolo Bonzini
On Fri, May 24, 2024 at 4:23 PM Richard Henderson wrote: > > On 5/24/24 01:10, Paolo Bonzini wrote: > > Place DISAS_* constants that update cpu_eip first, and > > the "jump" ones last. Add comments explaining the differences > > and usage. &g

Re: [PATCH RFC 0/2] meson: Pass objects to declare_dependency()

2024-05-24 Thread Paolo Bonzini
On Fri, May 24, 2024 at 10:00 AM Akihiko Odaki wrote: > > Based-on: <20240524-xkb-v4-0-2de564e5c...@daynix.com> > ("[PATCH v4 0/4] Fix sanitizer errors with clang 18.1.1") > > This is changes suggested by Paolo Bonzini at: > https://lore.kernel.org/all/C

[PATCH 13/16] target/i386: clean up repeated string operations

2024-05-24 Thread Paolo Bonzini
Do not bother generating inline wrappers for gen_repz and gen_repz2; use s->prefix to separate REPZ from REPNZ in the case of SCAS and CMPS. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 22 -- target/i386/tcg/emit.c.inc | 22 +- 2 fi

[PATCH 16/16] target/i386: set CC_OP in helpers if they want CC_OP_EFLAGS

2024-05-24 Thread Paolo Bonzini
which case the spilling of cc_op would be there anyway * even in other cases, the cost is probably dwarfed by that of computing flags. Signed-off-by: Paolo Bonzini --- target/i386/ops_sse.h| 8 target/i386/tcg/fpu_helper.c | 2 ++ target/i386/tcg/int_helper.c | 13

[PATCH 07/16] target/i386: raze the gen_eob* jungle

2024-05-24 Thread Paolo Bonzini
Make gen_eob take the DISAS_* constant as an argument, so that it is not necessary to have wrappers around it. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 60 + 1 file changed, 14 insertions(+), 46 deletions(-) diff --git a/target/i386/tcg

[PATCH 10/16] target/i386: inline gen_add_A0_ds_seg

2024-05-24 Thread Paolo Bonzini
It is only used in MONITOR, where a direct call of gen_lea_v_seg is simpler, and in XLAT. Inline it in the latter. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 9 + target/i386/tcg/emit.c.inc | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a

[PATCH 04/16] target/i386: avoid calling gen_eob_syscall before tb_stop

2024-05-24 Thread Paolo Bonzini
syscall and sysret only have one exit, so they do not need to generate the end-of-translation code inline. It can be deferred to tb_stop. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/target/i386

[PATCH 02/16] target/i386: cleanup eob handling of RSM

2024-05-24 Thread Paolo Bonzini
s non-dirty and gen_eob will not overwrite the CC_OP_EFLAGS value that is placed there by the helper. But let's clean it up. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/i386/tcg/translate.c b/targe

[PATCH 08/16] target/i386: reg in gen_ldst_modrm is always OR_TMP0

2024-05-24 Thread Paolo Bonzini
Values other than OR_TMP0 were only ever used by MOV and MOVNTI opcodes. Now that these have been converted to the new decoder, remove the argument. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 33 - 1 file changed, 12 insertions(+), 21

[PATCH 09/16] target/i386: split gen_ldst_modrm for load and store

2024-05-24 Thread Paolo Bonzini
The is_store argument of gen_ldst_modrm has only ever been passed a constant. Just split the function in two. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 52 + 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/target/i386/tcg

[PATCH 12/16] target/i386: introduce gen_lea_ss_ofs

2024-05-24 Thread Paolo Bonzini
Generalize gen_stack_A0() to include an initial add and to use an arbitrary destination. This is a common pattern and it is not a huge burden to add the extra arguments to the only caller of gen_stack_A0(). Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 51

[PATCH 11/16] target/i386: use mo_stacksize more

2024-05-24 Thread Paolo Bonzini
Use mo_stacksize for all stack accesses, including when a 64-bit code segment is impossible and the code is therefore checking only for SS32(s). Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/target/i386

[PATCH 05/16] target/i386: avoid calling gen_eob_inhibit_irq before tb_stop

2024-05-24 Thread Paolo Bonzini
sti only has one exit, so it does not need to generate the end-of-translation code inline. It can be deferred to tb_stop. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 13 - target/i386/tcg/emit.c.inc | 4 +--- 2 files changed, 1 insertion(+), 16 deletions

[PATCH 03/16] target/i386: document and group DISAS_* constants

2024-05-24 Thread Paolo Bonzini
Place DISAS_* constants that update cpu_eip first, and the "jump" ones last. Add comments explaining the differences and usage. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 25 ++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --gi

[PATCH 14/16] target/i386: remove aflag argument of gen_lea_v_seg

2024-05-24 Thread Paolo Bonzini
It is always s->aflag. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 20 ++-- target/i386/tcg/emit.c.inc | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 18d8c0de

[PATCH 15/16] target/i386: cpu_load_eflags already sets cc_op

2024-05-24 Thread Paolo Bonzini
No need to set it again at the end of the translation block, cc_op_dirty can be set to false. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 37 - target/i386/tcg/emit.c.inc | 2 +- 2 files changed, 25 insertions(+), 14 deletions(-) diff

[PATCH 00/16] target/i386/tcg: translation cleanups

2024-05-24 Thread Paolo Bonzini
Some cleanups in translate.c, which I could make now that the it's smaller and it's easier to understand how the various utility functions are used. 1-7: cleanups for gen_eob 8-14: inlining and removing macros 15-16: cleanups for cc_op vs. helpers Paolo Paolo Bonzini (16): t

[PATCH 06/16] target/i386: assert that gen_update_eip_cur and gen_update_eip_next are the same in tb_stop

2024-05-24 Thread Paolo Bonzini
This is an invariant, since these cases of tb_stop() should only be reached through the "instruction decoding completed" path of i386_tr_translate_insn(). Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/targe

[PATCH 01/16] target/i386: remove unnecessary gen_update_cc_op before gen_eob*

2024-05-24 Thread Paolo Bonzini
This is already handled in gen_eob(). Before adding another DISAS_* case, remove the double calls. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 76be7425800

Re: [PATCH v2] meson.build: add -mcx16 flag for x86_64 host

2024-05-24 Thread Paolo Bonzini
mail.com> [rewrite commit message, remove from configure. - Paolo] Signed-off-by: Paolo Bonzini diff --git a/configure b/configure index 38ee2577013..4d01a42ba65 100755 --- a/configure +++ b/configure @@ -512,10 +512,7 @@ case "$cpu" in cpu="x86_64" host_arch=x86_64

<    2   3   4   5   6   7   8   9   10   11   >