[PULL 02/42] target/i386: fix implementation of ICEBP

2024-06-08 Thread Paolo Bonzini
ICEBP generates a trap-like exception, while gen_exception() produces a fault. Resurrect gen_update_eip_next() to implement the desired semantics. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/helper.h | 1 + target/i386/tcg/helper-tcg.h | 12 ++

[PULL 05/42] target/i386: implement DR7.GD

2024-06-08 Thread Paolo Bonzini
DR7.GD triggers a #DB exception on any access to debug registers. The GD bit is cleared so that the #DB handler itself can access the debug registers. Signed-off-by: Paolo Bonzini --- target/i386/tcg/sysemu/bpt_helper.c | 12 1 file changed, 12 insertions(+) diff --git a/target/i38

[PULL 12/42] target/i386: use local X86DecodedOp in gen_POP()

2024-06-08 Thread Paolo Bonzini
From: Mark Cave-Ayland This will make subsequent changes a little easier to read. Signed-off-by: Mark Cave-Ayland Message-ID: <20240606095319.229650-2-mark.cave-ayl...@ilande.co.uk> Signed-off-by: Paolo Bonzini --- target/i386/tcg/emit.c.inc | 6 -- 1 file changed, 4 insertions(+), 2 dele

[PULL 09/42] target/i386: fix TF/RF handling for HLT

2024-06-08 Thread Paolo Bonzini
HLT uses DISAS_NORETURN because the corresponding helper calls cpu_loop_exit(). However, while gen_eob() clears HF_RF_MASK and synthesizes a #DB exception if single-step is active, none of this is done by HLT. Note that the single-step trap is generated after the halt is finished. Signed-off-by:

[PULL 01/42] target/i386: fix pushed value of EFLAGS.RF

2024-06-08 Thread Paolo Bonzini
When preparing an exception stack frame for a fault exception, the value pushed for RF is 1. Take that into account. The same should be true of interrupts for repeated string instructions, but the situation there is complicated. Signed-off-by: Paolo Bonzini --- target/i386/tcg/seg_helper.c | 4

[PULL 07/42] target/i386: fix INHIBIT_IRQ/TF/RF handling for VMRUN

2024-06-08 Thread Paolo Bonzini
>From vm entry to exit, VMRUN is handled as a single instruction. It uses DISAS_NORETURN in order to avoid processing TF or RF before the first instruction executes in the guest. However, the corresponding handling is missing in vmexit. Add it, and at the same time reorganize the comments with q

[PULL 03/42] target/i386: cleanup HLT helpers

2024-06-08 Thread Paolo Bonzini
Use decode.c's support for intercepts, doing the check in TCG-generated code rather than the helper. This is cleaner because it allows removing the eip_addend argument to helper_hlt(). Signed-off-by: Paolo Bonzini --- target/i386/helper.h | 2 +- target/i386/tcg/sysemu/misc_hel

[PULL 00/42] i386, scsi. hostmem fixes for 2024-06-08

2024-06-08 Thread Paolo Bonzini
The following changes since commit f1572ab94738bd5787b7badcd4bd93a3657f0680: Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2024-06-05 07:45:23 -0700) are available in the Git repository at: https://gitlab.com/bonzini/qemu.git tags/for-upstream for you to fetch c

[PULL 13/42] target/i386: use gen_writeback() within gen_POP()

2024-06-08 Thread Paolo Bonzini
From: Mark Cave-Ayland Instead of directly implementing the writeback using gen_op_st_v(), use the existing gen_writeback() function. Suggested-by: Paolo Bonzini Signed-off-by: Mark Cave-Ayland Message-ID: <20240606095319.229650-3-mark.cave-ayl...@ilande.co.uk> Signed-off-by: Paolo Bonzini --

[PULL 34/42] vmxcap: add support for VMX FRED controls

2024-06-08 Thread Paolo Bonzini
From: Xin Li Report secondary vm-exit controls and the VMX controls used to save/load FRED MSRs. Tested-by: Shan Kang Signed-off-by: Xin Li Message-ID: <20231109072012.8078-5-xin3...@intel.com> Signed-off-by: Paolo Bonzini --- scripts/kvm/vmxcap | 12 1 file changed, 12 insertio

[PULL 04/42] target/i386: cleanup PAUSE helpers

2024-06-08 Thread Paolo Bonzini
Use decode.c's support for intercepts, doing the check in TCG-generated code rather than the helper. This is cleaner because it allows removing the eip_addend argument to helper_pause(), even though it adds a bit of bloat for opcode 0x90's new decoding function. Signed-off-by: Paolo Bonzini ---

[PULL 08/42] target/i386: fix INHIBIT_IRQ/TF/RF handling for PAUSE

2024-06-08 Thread Paolo Bonzini
PAUSE uses DISAS_NORETURN because the corresponding helper calls cpu_loop_exit(). However, while HLT clear HF_INHIBIT_IRQ_MASK to correctly handle "STI; HLT", the same is missing from PAUSE. And also gen_eob() clears HF_RF_MASK and synthesizes a #DB exception if single-step is active; none of this

[PULL 41/42] Revert "python: use vendored tomli"

2024-06-08 Thread Paolo Bonzini
Now that Ubuntu 20.04 is not included anymore, there is no need to ship it as part of QEMU; Ubuntu 22.04 includes it and Leap users anyway need to install all the required dependencies from PyPI. This mostly reverts commit ec77ee7634de123b7c899739711000fd21dab68b, with just some changes to the wor

[PULL 33/42] target/i386: mark CR4.FRED not reserved

2024-06-08 Thread Paolo Bonzini
From: Xin Li The CR4.FRED bit, i.e., CR4[32], is no longer a reserved bit when FRED is exposed to guests, otherwise it is still a reserved bit. Tested-by: Shan Kang Signed-off-by: Xin Li Reviewed-by: Zhao Liu Message-ID: <20231109072012.8078-3-xin3...@intel.com> Signed-off-by: Paolo Bonzini

[PULL 24/42] stubs/meson: Fix qemuutil build when --disable-system

2024-06-08 Thread Paolo Bonzini
From: Zhao Liu Compiling without system, user, tools or guest-agent fails with the following error message: ./configure --disable-system --disable-user --disable-tools \ --disable-guest-agent error message: /usr/bin/ld: libqemuutil.a.p/util_error-report.c.o: in function `error_printf': /media/

[PULL 06/42] target/i386: disable/enable breakpoints on vmentry/vmexit

2024-06-08 Thread Paolo Bonzini
If the required DR7 (either from the VMCB or from the host save area) disables a breakpoint that was enabled prior to vmentry or vmexit, it is left enabled and will trigger EXCP_DEBUG. This causes a spurious #DB on the next crossing of the breakpoint. To disable it, vmentry/vmexit must use cpu_x86

[PULL 23/42] scsi-disk: Don't silently truncate serial number

2024-06-08 Thread Paolo Bonzini
From: Kevin Wolf Before this commit, scsi-disk accepts a string of arbitrary length for its "serial" property. However, the value visible on the guest is actually truncated to 36 characters. This limitation doesn't come from the SCSI specification, it is an arbitrary limit that was initially pick

[PULL 29/42] i386/hvf: In kick_vcpu use hv_vcpu_interrupt to force exit

2024-06-08 Thread Paolo Bonzini
From: Phil Dennis-Jordan When interrupting a vCPU thread, this patch actually tells the hypervisor to stop running guest code on that vCPU. Calling hv_vcpu_interrupt actually forces a vCPU exit, analogously to hv_vcpus_exit on aarch64. Alternatively, if the vCPU thread is not running the VM, it

[PULL 16/42] machine: default -M mem-merge to off is QEMU_MADV_MERGEABLE is not available

2024-06-08 Thread Paolo Bonzini
Otherwise, starting any guest on a non-Linux guests results in qemu-system-arm: Couldn't set property 'merge' on 'memory-backend-ram': Invalid argument Cc: Michal Privoznik Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a

[PULL 32/42] target/i386: add support for FRED in CPUID enumeration

2024-06-08 Thread Paolo Bonzini
From: Xin Li FRED, i.e., the Intel flexible return and event delivery architecture, defines simple new transitions that change privilege level (ring transitions). The new transitions defined by the FRED architecture are FRED event delivery and, for returning from events, two FRED return instruct

[PULL 22/42] hostmem: simplify the code for merge and dump properties

2024-06-08 Thread Paolo Bonzini
No semantic change, just simpler control flow. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Paolo Bonzini --- backends/hostmem.c | 22 -- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/backends/hostmem.c b/backends/hostmem.c index 6da3d7383e3..4e5576a4a

[PULL 37/42] docs: i386: pc: Avoid mentioning limit of maximum vCPUs

2024-06-08 Thread Paolo Bonzini
From: Zhao Liu Different versions of PC machine support different maximum vCPUs, and even different features have limits on the maximum number of vCPUs ( For example, if x2apic is not enabled in the TCG case, the maximum of 255 vCPUs are supported). It is difficult to list the maximum vCPUs unde

[PULL 14/42] target/i386: fix SP when taking a memory fault during POP

2024-06-08 Thread Paolo Bonzini
From: Mark Cave-Ayland When OS/2 Warp configures its segment descriptors, many of them are configured with the P flag clear to allow for a fault-on-demand implementation. In the case where the stack value is POPped into the segment registers, the SP is incremented before calling gen_helper_loa

[PULL 19/42] osdep: Make qemu_madvise() return ENOSYS on unsupported OSes

2024-06-08 Thread Paolo Bonzini
From: Michal Privoznik Not every OS is capable of madvise() or posix_madvise() even. In that case, errno should be set to ENOSYS as it reflects the cause better. Signed-off-by: Michal Privoznik Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: David Hildenbrand Message-ID: Signed-off-by: Pao

[PULL 18/42] osdep: Make qemu_madvise() to set errno in all cases

2024-06-08 Thread Paolo Bonzini
From: Michal Privoznik The unspoken premise of qemu_madvise() is that errno is set on error. And it is mostly the case except for posix_madvise() which is documented to return either zero (on success) or a positive error number. This means, we must set errno ourselves. And while at it, make the f

[PULL 42/42] python: mkvenv: remove ensure command

2024-06-08 Thread Paolo Bonzini
This was used to bootstrap the venv with a TOML parser, after which ensuregroup is used. Now that we expect it to be present as a system package (either tomli or, for Python 3.11, tomllib), it is not needed anymore. Note that this means that, when implemented, the hypothetical "isolated" mode tha

[PULL 36/42] target/i386: Add get/set/migrate support for FRED MSRs

2024-06-08 Thread Paolo Bonzini
From: Xin Li FRED CPU states are managed in 9 new FRED MSRs, in addtion to a few existing CPU registers and MSRs, e.g., CR4.FRED and MSR_IA32_PL0_SSP. Save/restore/migrate FRED MSRs if FRED is exposed to the guest. Tested-by: Shan Kang Signed-off-by: Xin Li Message-ID: <20231109072012.8078-7-

[PULL 30/42] i386/hvf: Updates API usage to use modern vCPU run function

2024-06-08 Thread Paolo Bonzini
From: Phil Dennis-Jordan macOS 10.15 introduced the more efficient hv_vcpu_run_until() function to supersede hv_vcpu_run(). According to the documentation, there is no longer any reason to use the latter on modern host OS versions, especially after 11.0 added support for an indefinite deadline.

[PULL 17/42] meson: Don't even detect posix_madvise() on Darwin

2024-06-08 Thread Paolo Bonzini
From: Michal Privoznik On Darwin, posix_madvise() has the same return semantics as plain madvise() [1]. That's not really what our usage expects. Fortunately, madvise() is available and preferred anyways so we may stop detecting posix_madvise() on Darwin. 1: https://opensource.apple.com/source/

[PULL 10/42] target/i386: document incorrect semantics of watchpoint following MOV/POP SS

2024-06-08 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini --- target/i386/tcg/sysemu/bpt_helper.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/target/i386/tcg/sysemu/bpt_helper.c b/target/i386/tcg/sysemu/bpt_helper.c index c1d5fce250c..b29acf41c38 100644 --- a/target/i386/tcg/sysemu/bpt_helper.c +++ b/target/i3

[PULL 39/42] i386: Add support for SUCCOR feature

2024-06-08 Thread Paolo Bonzini
From: John Allen Add cpuid bit definition for the SUCCOR feature. This cpuid bit is required to be exposed to guests to allow them to handle machine check exceptions on AMD hosts. v2: - Add "succor" feature word. - Add case to kvm_arch_get_supported_cpuid for the SUCCOR feature. Report

[PULL 35/42] target/i386: enumerate VMX nested-exception support

2024-06-08 Thread Paolo Bonzini
From: Xin Li Allow VMX nested-exception support to be exposed in KVM guests, thus nested KVM guests can enumerate it. Tested-by: Shan Kang Signed-off-by: Xin Li Message-ID: <20231109072012.8078-6-xin3...@intel.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 1 + target/i386/cpu.c

[PULL 15/42] target/i386: fix size of EBP writeback in gen_enter()

2024-06-08 Thread Paolo Bonzini
From: Mark Cave-Ayland The calculation of FrameTemp is done using the size indicated by mo_pushpop() before being written back to EBP, but the final writeback to EBP is done using the size indicated by mo_stacksize(). In the case where mo_pushpop() is MO_32 and mo_stacksize() is MO_16 then the f

[PULL 21/42] machine, hostmem: improve error messages for unsupported features

2024-06-08 Thread Paolo Bonzini
Detect early unsupported MADV_MERGEABLE and MADV_DONTDUMP, and print a clearer error message that points to the deficiency of the host. Cc: Michal Privoznik Signed-off-by: Paolo Bonzini --- backends/hostmem.c | 16 hw/core/machine.c | 8 2 files changed, 24 insertion

[PULL 20/42] backends/hostmem: Report error when memory size is unaligned

2024-06-08 Thread Paolo Bonzini
From: Michal Privoznik If memory-backend-{file,ram} has a size that's not aligned to underlying page size it is not only wasteful, but also may lead to hard to debug behaviour. For instance, in case memory-backend-file and hugepages, madvise() and mbind() fail. Rightfully so, page is the smallest

[PULL 31/42] hvf: Makes assert_hvf_ok report failed expression

2024-06-08 Thread Paolo Bonzini
From: Phil Dennis-Jordan When a macOS Hypervisor.framework call fails which is checked by assert_hvf_ok(), Qemu exits printing the error value, but not the location in the code, as regular assert() macro expansions would. This change turns assert_hvf_ok() into a macro similar to other assertions

[PULL 11/42] target/i386: document use of DISAS_NORETURN

2024-06-08 Thread Paolo Bonzini
DISAS_NORETURN suppresses the work normally done by gen_eob(), and therefore must be used in special cases only. Document them. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/target/i386/tcg/translate.c b/target/i386

[PULL 40/42] i386: Add support for overflow recovery

2024-06-08 Thread Paolo Bonzini
From: John Allen Add cpuid bit definition for overflow recovery. This is needed in the case where a deferred error has been sent to the guest, a guest process accesses the poisoned memory, but the machine_check_poll function has not yet handled the original deferred error. If overflow recovery is

[PULL 38/42] i386: Fix MCE support for AMD hosts

2024-06-08 Thread Paolo Bonzini
From: John Allen For the most part, AMD hosts can use the same MCE injection code as Intel, but there are instances where the qemu implementation is Intel specific. First, MCE delivery works differently on AMD and does not support broadcast. Second, kvm_mce_inject generates MCEs that include a nu

[PATCH 02/25] target/i386: rewrite flags writeback for ADCX/ADOX

2024-06-08 Thread Paolo Bonzini
Avoid using set_cc_op() in preparation for implementing APX; treat CC_OP_EFLAGS similar to the case where we have the "opposite" cc_op (CC_OP_ADOX for ADCX and CC_OP_ADCX for ADOX), except the resulting cc_op is not CC_OP_ADCOX. This is written easily as two "if"s, whose conditions are both false f

[PATCH 00/25] target/i386: more progress towards new decoder

2024-06-08 Thread Paolo Bonzini
Just like in previous installments, this series ends with a specific thing that is now done entirely in the new decoder. After removing the legacy prefix decoding in the previous series, now it's _all_ decoding that is done by decode-new.c.inc. Most two byte opcodes are converted, leaving out onl

[PATCH 03/25] target/i386: put BLS* input in T1, use generic flag writeback

2024-06-08 Thread Paolo Bonzini
This makes for easier cpu_cc_* setup, and not using set_cc_op() should come in handy if QEMU ever implements APX. Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.c.inc | 4 ++-- target/i386/tcg/emit.c.inc | 24 +--- 2 files changed, 11 insertions(+), 17 del

[PATCH 09/25] target/i386: fix bad sorting of entries in the 0F table

2024-06-08 Thread Paolo Bonzini
Aesthetic change only. Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.c.inc | 93 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc index 4c567911f41..4e745f10dd8 10064

[PATCH 12/25] target/i386: split X86_CHECK_prot into PE and VM86 checks

2024-06-08 Thread Paolo Bonzini
SYSENTER is allowed in VM86 mode, but not in real mode. Split the check so that PE and !VM86 are covered by separate bits. Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.h | 8 ++-- target/i386/tcg/decode-new.c.inc | 9 +++-- 2 files changed, 13 insertions(+), 4 deletio

[PATCH 06/25] target/i386: replace NoSeg special with NoLoadEA

2024-06-08 Thread Paolo Bonzini
This is a bit more generic, as it can be applied to MPX as well. Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.h | 5 +++-- target/i386/tcg/decode-new.c.inc | 12 target/i386/tcg/emit.c.inc | 3 ++- 3 files changed, 9 insertions(+), 11 deletions(-) diff --

[PATCH 18/25] target/i386: convert LZCNT/TZCNT/BSF/BSR/POPCNT to new decoder

2024-06-08 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.h | 1 + target/i386/tcg/translate.c | 74 target/i386/tcg/decode-new.c.inc | 51 +++- target/i386/tcg/emit.c.inc | 82 4 files changed, 132 in

[PATCH 19/25] target/i386: convert XADD to new decoder

2024-06-08 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 35 target/i386/tcg/decode-new.c.inc | 3 ++- target/i386/tcg/emit.c.inc | 24 ++ 3 files changed, 26 insertions(+), 36 deletions(-) diff --git a/target/i386/tcg/transl

[PATCH 01/25] target/i386: remove CPUX86State argument from generator functions

2024-06-08 Thread Paolo Bonzini
CPUX86State argument would only be used to fetch bytes, but that has to be done before the generator function is called. So remove it, and all temptation together with it. Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.h | 2 +- target/i386/tcg/decode-new.c.inc | 4 +- targ

[PATCH 08/25] target/i386: convert MOV from/to CR and DR to new decoder

2024-06-08 Thread Paolo Bonzini
Complete implementation of C and D operand types, then the operations are just MOVs. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 79 target/i386/tcg/decode-new.c.inc | 53 +++-- target/i386/tcg/emit.c.inc | 20 +++

[PATCH 11/25] target/i386: replace read_crN helper with read_cr8

2024-06-08 Thread Paolo Bonzini
All other control registers are stored plainly in CPUX86State. Signed-off-by: Paolo Bonzini --- target/i386/helper.h | 2 +- target/i386/tcg/sysemu/misc_helper.c | 20 +--- target/i386/tcg/emit.c.inc | 2 +- 3 files changed, 7 insertions(+), 17 deletio

[PATCH 20/25] target/i386: convert CMPXCHG to new decoder

2024-06-08 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 79 target/i386/tcg/decode-new.c.inc | 3 +- target/i386/tcg/emit.c.inc | 51 + 3 files changed, 53 insertions(+), 80 deletions(-) diff --git a/target/i386/tcg/translat

[PATCH 21/25] target/i386: decode address before going back to translate.c

2024-06-08 Thread Paolo Bonzini
There are now relatively few unconverted opcodes in translate.c (there are 13 of them including 8 for x87), and all of them have the same format with a mod/rm byte and no immediate. A good next step is to remove the early bail out to disas_insn_x87/disas_insn_old, instead giving these legacy trans

[PATCH 07/25] target/i386: fix processing of intercept 0 (read CR0)

2024-06-08 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.h | 1 + target/i386/tcg/decode-new.c.inc | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/target/i386/tcg/decode-new.h b/target/i386/tcg/decode-new.h index 46a96b220d0..8465717ea21 100644 --- a/target/i386/tc

[PATCH 04/25] target/i386: change X86_ENTRYr to use T0

2024-06-08 Thread Paolo Bonzini
I am not sure why I made it use T1. It is a bit more symmetric with respect to X86_ENTRYwr (which uses T0 for the "w"ritten operand and T1 for the "r"ead operand), but it is also less flexible because it does not let you apply zextT0/sextT0. Signed-off-by: Paolo Bonzini --- target/i386/tcg/deco

[PATCH 15/25] target/i386: pull load/writeback out of gen_shiftd_rm_T1

2024-06-08 Thread Paolo Bonzini
Use gen_ld_modrm/gen_st_modrm, moving them and gen_shift_flags to the caller. This way, gen_shiftd_rm_T1 becomes something that the new decoder can call. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 55 ++--- 1 file changed, 14 insertions(+), 41

[PATCH 10/25] target/i386: finish converting 0F AE to the new decoder

2024-06-08 Thread Paolo Bonzini
This is already partly implemented due to VLDMXCSR and VSTMXCSR; finish the job. Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.h | 7 ++ target/i386/tcg/translate.c | 188 --- target/i386/tcg/decode-new.c.inc | 48 +++- target/i386/tcg/em

[PATCH 24/25] target/i386: do not check PREFIX_LOCK in old-style decoder

2024-06-08 Thread Paolo Bonzini
It is already checked before getting there. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 26 -- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 67f2e792166..ee5ef3ccbc6 100644

[PATCH 22/25] target/i386: list instructions still in translate.c

2024-06-08 Thread Paolo Bonzini
Group them so that it is easier to figure out which two-byte opcodes to tackle together. Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.c.inc | 18 ++ 1 file changed, 18 insertions(+) diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc i

[PATCH 17/25] target/i386: convert SHLD/SHRD to new decoder

2024-06-08 Thread Paolo Bonzini
Use the same flag generation code as SHL and SHR, but use the existing gen_shiftd_rm_T1 function to compute the result as well as CC_SRC. Decoding-wise, SHLD/SHRD by immediate count as a 4 operand instruction because s->T0 and s->T1 actually occupy three op slots. The infrastructure used by opcod

[PATCH 25/25] target/i386: remove gen_ext_tl

2024-06-08 Thread Paolo Bonzini
With the introduction of tcg_gen_ext_tl, most uses can be converted directly because they do not have a NULL destination. tcg_gen_ext_tl is able to drop no-ops like "tcg_gen_ext_tl(tcgv, tcgv, MO_TL)" just fine, and the only thing that gen_ext_tl was adding on top was avoiding the creation of a us

[PATCH 16/25] target/i386: adapt gen_shift_count for SHLD/SHRD

2024-06-08 Thread Paolo Bonzini
SHLD/SHRD can have 3 register operands - s->T0, s->T1 and either 1 or CL - and therefore decode->op[2] is taken by the low part of the register being shifted. Pass X86_OP_* to gen_shift_count from its current callers and hardcode cpu_regs[R_ECX] as the shift count. Signed-off-by: Paolo Bonzini -

[PATCH 13/25] target/i386: convert non-grouped, helper-based 2-byte opcodes

2024-06-08 Thread Paolo Bonzini
These have very simple generators and no need for complex group decoding. Apart from LAR/LSL which are simplified to use gen_op_deposit_reg_v and movcond, the code is generally lifted from translate.c into the generators. Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.h | 7 +

[PATCH 05/25] target/i386: change X86_ENTRYwr to use T0, use it for moves

2024-06-08 Thread Paolo Bonzini
Just like X86_ENTRYr, X86_ENTRYwr is easily changed to use only T0. In this case, the motivation is to use it for the MOV instruction family. The case when you need to preserve the input value is the odd one, as it is used basically only for BLS* instructions. Signed-off-by: Paolo Bonzini --- t

[PATCH 14/25] target/i386: convert bit test instructions to new decoder

2024-06-08 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.h | 3 + target/i386/tcg/translate.c | 147 +-- target/i386/tcg/decode-new.c.inc | 45 +++--- target/i386/tcg/emit.c.inc | 130 ++- 4 files changed, 166 insertions

[PATCH 23/25] target/i386: assert that cc_op* and pc_save are preserved

2024-06-08 Thread Paolo Bonzini
Now all decoding has been done before any code generation. There is no need anymore to save and restore cc_op* and pc_save but, for the time being, assert that this is indeed the case. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 12 +++- 1 file changed, 3 insertions(+)

Re: [PATCH] nbd: Prevent NULL pointer dereference in nbd_blockdev_client_closed()

2024-06-08 Thread Alexander Ivanov
There is a bug reproducer in the attachment. On 6/7/24 17:00, Alexander Ivanov wrote: In some cases, the NBD server can be stopped before nbd_blockdev_client_closed() is called, causing the nbd_server variable to be nullified. This leads to a NULL pointer dereference when accessing nbd_server.

Re: [PATCH 01/25] target/i386: remove CPUX86State argument from generator functions

2024-06-08 Thread Richard Henderson
On 6/8/24 01:40, Paolo Bonzini wrote: CPUX86State argument would only be used to fetch bytes, but that has to be done before the generator function is called. So remove it, and all temptation together with it. Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.h | 2 +- target

Re: [PATCH] hw/usb/hcd-ohci: Fix ohci_service_td: accept valid TDs

2024-06-08 Thread Cord Amfmgm
On Fri, Jun 7, 2024 at 8:23 AM Peter Maydell wrote: > On Fri, 31 May 2024 at 19:16, Cord Amfmgm wrote: > > On Fri, May 31, 2024 at 9:03 AM Peter Maydell > wrote: > >> What I would like to see is what we could classify under > >> "rationale", which is to say "what prompted us to make this > >> c

Re: [PATCH 02/25] target/i386: rewrite flags writeback for ADCX/ADOX

2024-06-08 Thread Richard Henderson
On 6/8/24 01:40, Paolo Bonzini wrote: Avoid using set_cc_op() in preparation for implementing APX; treat CC_OP_EFLAGS similar to the case where we have the "opposite" cc_op (CC_OP_ADOX for ADCX and CC_OP_ADCX for ADOX), except the resulting cc_op is not CC_OP_ADCOX. This is written easily as two

Re: [PATCH 03/25] target/i386: put BLS* input in T1, use generic flag writeback

2024-06-08 Thread Richard Henderson
On 6/8/24 01:40, Paolo Bonzini wrote: This makes for easier cpu_cc_* setup, and not using set_cc_op() should come in handy if QEMU ever implements APX. Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.c.inc | 4 ++-- target/i386/tcg/emit.c.inc | 24 +---

Re: [PATCH 04/25] target/i386: change X86_ENTRYr to use T0

2024-06-08 Thread Richard Henderson
On 6/8/24 01:40, Paolo Bonzini wrote: I am not sure why I made it use T1. It is a bit more symmetric with respect to X86_ENTRYwr (which uses T0 for the "w"ritten operand and T1 for the "r"ead operand), but it is also less flexible because it does not let you apply zextT0/sextT0. Signed-off-by:

Re: [PATCH 05/25] target/i386: change X86_ENTRYwr to use T0, use it for moves

2024-06-08 Thread Richard Henderson
On 6/8/24 01:40, Paolo Bonzini wrote: Just like X86_ENTRYr, X86_ENTRYwr is easily changed to use only T0. In this case, the motivation is to use it for the MOV instruction family. The case when you need to preserve the input value is the odd one, as it is used basically only for BLS* instruction

Re: [PATCH 06/25] target/i386: replace NoSeg special with NoLoadEA

2024-06-08 Thread Richard Henderson
On 6/8/24 01:40, Paolo Bonzini wrote: This is a bit more generic, as it can be applied to MPX as well. Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.h | 5 +++-- target/i386/tcg/decode-new.c.inc | 12 target/i386/tcg/emit.c.inc | 3 ++- 3 files changed

Re: [PATCH 07/25] target/i386: fix processing of intercept 0 (read CR0)

2024-06-08 Thread Richard Henderson
On 6/8/24 01:40, Paolo Bonzini wrote: Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.h | 1 + target/i386/tcg/decode-new.c.inc | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) Reviewed-by: Richard Henderson r~

Re: [PATCH 08/25] target/i386: convert MOV from/to CR and DR to new decoder

2024-06-08 Thread Richard Henderson
On 6/8/24 01:40, Paolo Bonzini wrote: Complete implementation of C and D operand types, then the operations are just MOVs. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 79 target/i386/tcg/decode-new.c.inc | 53 +++-- tar

Re: [PATCH 09/25] target/i386: fix bad sorting of entries in the 0F table

2024-06-08 Thread Richard Henderson
On 6/8/24 01:40, Paolo Bonzini wrote: Aesthetic change only. Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.c.inc | 93 1 file changed, 46 insertions(+), 47 deletions(-) Reviewed-by: Richard Henderson r~

Re: [PATCH 10/25] target/i386: finish converting 0F AE to the new decoder

2024-06-08 Thread Richard Henderson
On 6/8/24 01:40, Paolo Bonzini wrote: +static void gen_FXRSTOR(DisasContext *s, X86DecodedInsn *decode) +{ +if ((s->flags & HF_EM_MASK) || (s->flags & HF_TS_MASK)) { +gen_NM_exception(s); +} +gen_helper_fxrstor(tcg_env, s->A0); +} + +static void gen_FXSAVE(DisasContext *s, X86

Re: [PATCH 11/25] target/i386: replace read_crN helper with read_cr8

2024-06-08 Thread Richard Henderson
On 6/8/24 01:40, Paolo Bonzini wrote: All other control registers are stored plainly in CPUX86State. s/stored/read/ Reviewed-by: Richard Henderson r~

Re: [PATCH 12/25] target/i386: split X86_CHECK_prot into PE and VM86 checks

2024-06-08 Thread Richard Henderson
On 6/8/24 01:41, Paolo Bonzini wrote: SYSENTER is allowed in VM86 mode, but not in real mode. Split the check so that PE and !VM86 are covered by separate bits. Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.h | 8 ++-- target/i386/tcg/decode-new.c.inc | 9 +++-- 2

Re: [PATCH 13/25] target/i386: convert non-grouped, helper-based 2-byte opcodes

2024-06-08 Thread Richard Henderson
On 6/8/24 01:41, Paolo Bonzini wrote: These have very simple generators and no need for complex group decoding. Apart from LAR/LSL which are simplified to use gen_op_deposit_reg_v and movcond, the code is generally lifted from translate.c into the generators. Signed-off-by: Paolo Bonzini ---

Re: [PATCH 14/25] target/i386: convert bit test instructions to new decoder

2024-06-08 Thread Richard Henderson
On 6/8/24 01:41, Paolo Bonzini wrote: -if (mod != 3) { -AddressParts a = gen_lea_modrm_0(env, s, modrm); -/* specific case: we need to add a displacement */ -gen_exts(ot, s->T1); -tcg_gen_sari_tl(s->tmp0, s->T1, 3 + ot); -tcg_gen

Re: [PATCH 15/25] target/i386: pull load/writeback out of gen_shiftd_rm_T1

2024-06-08 Thread Richard Henderson
On 6/8/24 01:41, Paolo Bonzini wrote: Use gen_ld_modrm/gen_st_modrm, moving them and gen_shift_flags to the caller. This way, gen_shiftd_rm_T1 becomes something that the new decoder can call. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 55 ++-

Re: [PATCH 16/25] target/i386: adapt gen_shift_count for SHLD/SHRD

2024-06-08 Thread Richard Henderson
On 6/8/24 01:41, Paolo Bonzini wrote: SHLD/SHRD can have 3 register operands - s->T0, s->T1 and either 1 or CL - and therefore decode->op[2] is taken by the low part of the register being shifted. Pass X86_OP_* to gen_shift_count from its current callers and hardcode cpu_regs[R_ECX] as the shift

Re: [PATCH 17/25] target/i386: convert SHLD/SHRD to new decoder

2024-06-08 Thread Richard Henderson
On 6/8/24 01:41, Paolo Bonzini wrote: Use the same flag generation code as SHL and SHR, but use the existing gen_shiftd_rm_T1 function to compute the result as well as CC_SRC. Decoding-wise, SHLD/SHRD by immediate count as a 4 operand instruction because s->T0 and s->T1 actually occupy three op

Re: [PATCH 18/25] target/i386: convert LZCNT/TZCNT/BSF/BSR/POPCNT to new decoder

2024-06-08 Thread Richard Henderson
On 6/8/24 01:41, Paolo Bonzini wrote: Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.h | 1 + target/i386/tcg/translate.c | 74 target/i386/tcg/decode-new.c.inc | 51 +++- target/i386/tcg/emit.c.inc | 82 ++

Re: [PATCH 19/25] target/i386: convert XADD to new decoder

2024-06-08 Thread Richard Henderson
On 6/8/24 01:41, Paolo Bonzini wrote: Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 35 target/i386/tcg/decode-new.c.inc | 3 ++- target/i386/tcg/emit.c.inc | 24 ++ 3 files changed, 26 insertions(+), 36 deleti

Re: [PATCH 20/25] target/i386: convert CMPXCHG to new decoder

2024-06-08 Thread Richard Henderson
On 6/8/24 01:41, Paolo Bonzini wrote: Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 79 target/i386/tcg/decode-new.c.inc | 3 +- target/i386/tcg/emit.c.inc | 51 + 3 files changed, 53 insertions(+), 80 deletion

Re: [PATCH 21/25] target/i386: decode address before going back to translate.c

2024-06-08 Thread Richard Henderson
On 6/8/24 01:41, Paolo Bonzini wrote: There are now relatively few unconverted opcodes in translate.c (there are 13 of them including 8 for x87), and all of them have the same format with a mod/rm byte and no immediate. A good next step is to remove the early bail out to disas_insn_x87/disas_ins

Re: [PATCH 22/25] target/i386: list instructions still in translate.c

2024-06-08 Thread Richard Henderson
On 6/8/24 01:41, Paolo Bonzini wrote: Group them so that it is easier to figure out which two-byte opcodes to tackle together. Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.c.inc | 18 ++ 1 file changed, 18 insertions(+) Reviewed-by: Richard Henderson r~

Re: [PATCH 23/25] target/i386: assert that cc_op* and pc_save are preserved

2024-06-08 Thread Richard Henderson
On 6/8/24 01:41, Paolo Bonzini wrote: Now all decoding has been done before any code generation. There is no need anymore to save and restore cc_op* and pc_save but, for the time being, assert that this is indeed the case. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 12 +++--

Re: [PATCH 24/25] target/i386: do not check PREFIX_LOCK in old-style decoder

2024-06-08 Thread Richard Henderson
On 6/8/24 01:41, Paolo Bonzini wrote: It is already checked before getting there. Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 26 -- 1 file changed, 8 insertions(+), 18 deletions(-) Reviewed-by: Richard Henderson r~

Re: [PATCH 25/25] target/i386: remove gen_ext_tl

2024-06-08 Thread Richard Henderson
On 6/8/24 01:41, Paolo Bonzini wrote: With the introduction of tcg_gen_ext_tl, most uses can be converted directly because they do not have a NULL destination. tcg_gen_ext_tl is able to drop no-ops like "tcg_gen_ext_tl(tcgv, tcgv, MO_TL)" just fine, and the only thing that gen_ext_tl was adding

Re: [PULL 00/42] i386, scsi. hostmem fixes for 2024-06-08

2024-06-08 Thread Richard Henderson
On 6/8/24 01:33, Paolo Bonzini wrote: The following changes since commit f1572ab94738bd5787b7badcd4bd93a3657f0680: Merge tag 'for-upstream' ofhttps://gitlab.com/bonzini/qemu into staging (2024-06-05 07:45:23 -0700) are available in the Git repository at: https://gitlab.com/bonzini/qemu

[PATCH 3/3] ui/cocoa: Adds support for mouse cursors

2024-06-08 Thread Phil Dennis-Jordan
This change implements the callbacks dpy_cursor_define and dpy_mouse_set for the Cocoa UI. The incoming mouse cursor image is converted into an NSCursor object, allowing the guest mouse cursor to be rendered as the host's native OS cursor on macOS. This is straightforward in absolute pointing mode

[PATCH 0/3] Mouse cursor improvements on macOS and VNC

2024-06-08 Thread Phil Dennis-Jordan
This series of loosely related changes provides some minor improvements in mouse cursor usability. 1. This one-liner changes alpha downsampling when using a UI frontend which does not support alpha-blended mouse cursors. Previously, any pixel with an alpha value other than 255 was treated

[PATCH 1/3] Cursor: 8 -> 1 bit alpha downsampling improvement

2024-06-08 Thread Phil Dennis-Jordan
Mouse cursors with 8 bit alpha were downsampled to 1-bit opacity maps by turning alpha values of 255 into 1 and everything else into 0. This means that mostly-opaque pixels ended up completely invisible. This patch changes the behaviour so that only pixels with less than 50% alpha (0-127) are trea

[PATCH 2/3] hw: Moves int_clamp() implementations to header

2024-06-08 Thread Phil Dennis-Jordan
Both hw/input/hid.c and hw/usb/dev-wacom.c define identical versions (aside from code formatting) of a clamping function, int_clamp(). (marked inline) To avoid duplication and to enable further re-use, this change moves the function into qemu/cutils.h. Signed-off-by: Phil Dennis-Jordan --- hw/inp

Re: [PATCH] ui/cocoa: Use qemu_add_mouse_change_notifier

2024-06-08 Thread Phil Dennis-Jordan
This looks fine to me. I've tested it briefly with a graphical Linux guest and some tracing in the notifyMouseModeChange on a macOS 13 host. When I hot-unplug the usb-tablet I get an absolute -> relative notification; everything works in relative mode after hot-adding a USB mouse. Hot-unplugging an

Re: [PATCH] hw/openrisc: Fixed undercounting of TTCR in continuous mode

2024-06-08 Thread Stafford Horne
Hi Joel, I am away and wont be able to have too much time to look at this. But have a few comments below and questions. - You sent this 2 times, is the only change in v2 the sender address? On Fri, Jun 07, 2024 at 03:29:33PM -0700, Joel Holdsworth via wrote: > In the existing design, TTCR is p

[PULL 0/6] hex queue

2024-06-08 Thread Brian Cain
The following changes since commit 3e246da2c3f85298b52f8a1154b832acf36aa656: Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2024-06-08 07:40:08 -0700) are available in the Git repository at: https://github.com/quic/qemu tags/pull-hex-20240608 for yo

  1   2   >