]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
3 years agotarget/i386: Create helper_check_io
Richard Henderson [Fri, 14 May 2021 15:13:40 +0000 (10:13 -0500)]
target/i386: Create helper_check_io

Drop helper_check_io[bwl] and expose their common
subroutine to tcg directly.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20210514151342.384376-49-richard.henderson@linaro.org>

3 years agotarget/i386: Pass in port to gen_check_io
Richard Henderson [Fri, 14 May 2021 15:13:39 +0000 (10:13 -0500)]
target/i386: Pass in port to gen_check_io

Pass in a pre-truncated TCGv_i32 value.  We were doing the
truncation of EDX in multiple places, now only once per insn.
While all callers use s->tmp2_i32, for cleanliness of the
subroutine, use a parameter anyway.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-48-richard.henderson@linaro.org>

3 years agotarget/i386: Tidy gen_check_io
Richard Henderson [Fri, 14 May 2021 15:13:38 +0000 (10:13 -0500)]
target/i386: Tidy gen_check_io

Get cur_eip from DisasContext.  Do not require the caller
to use svm_is_rep; get prefix from DisasContext.  Use the
proper symbolic constants for SVM_IOIO_*.

While we're touching all call sites, return bool in
preparation for gen_check_io raising #GP.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-47-richard.henderson@linaro.org>

3 years agotarget/i386: Exit tb after wrmsr
Richard Henderson [Fri, 14 May 2021 15:13:37 +0000 (10:13 -0500)]
target/i386: Exit tb after wrmsr

At minimum, wrmsr can change efer, which affects HF_LMA.

Cc: qemu-stable@nongnu.org
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-46-richard.henderson@linaro.org>

3 years agotarget/i386: Eliminate user stubs for read/write_crN, rd/wrmsr
Richard Henderson [Fri, 14 May 2021 15:13:36 +0000 (10:13 -0500)]
target/i386: Eliminate user stubs for read/write_crN, rd/wrmsr

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-45-richard.henderson@linaro.org>

3 years agotarget/i386: Inline user cpu_svm_check_intercept_param
Richard Henderson [Fri, 14 May 2021 15:13:35 +0000 (10:13 -0500)]
target/i386: Inline user cpu_svm_check_intercept_param

The user-version is a no-op.  This lets us completely
remove tcg/user/svm_stubs.c.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-44-richard.henderson@linaro.org>

3 years agotarget/i386: Unify invlpg, invlpga
Richard Henderson [Fri, 14 May 2021 15:13:34 +0000 (10:13 -0500)]
target/i386: Unify invlpg, invlpga

Use a single helper, flush_page, to do the work.
Use gen_svm_check_intercept.
Perform the zero-extension for invlpga inline.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-43-richard.henderson@linaro.org>

3 years agotarget/i386: Move invlpg, hlt, monitor, mwait to sysemu
Richard Henderson [Fri, 14 May 2021 15:13:33 +0000 (10:13 -0500)]
target/i386: Move invlpg, hlt, monitor, mwait to sysemu

These instructions are all privileged.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-42-richard.henderson@linaro.org>

3 years agotarget/i386: Pass env to do_pause and do_hlt
Richard Henderson [Fri, 14 May 2021 15:13:32 +0000 (10:13 -0500)]
target/i386: Pass env to do_pause and do_hlt

Having the callers upcast to X86CPU is a waste, since we
don't need it.  We even have to recover env in do_hlt.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-41-richard.henderson@linaro.org>

3 years agotarget/i386: Cleanup read_crN, write_crN, lmsw
Richard Henderson [Fri, 14 May 2021 15:13:31 +0000 (10:13 -0500)]
target/i386: Cleanup read_crN, write_crN, lmsw

Pull the svm intercept check into the translator.
Pull the entire implementation of lmsw into the translator.
Push the check for CR8LEG into the regno validation switch.
Unify the gen_io_start check between read/write.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210514151342.384376-40-richard.henderson@linaro.org>

3 years agotarget/i386: Remove user stub for cpu_vmexit
Richard Henderson [Fri, 14 May 2021 15:13:30 +0000 (10:13 -0500)]
target/i386: Remove user stub for cpu_vmexit

This function is only called from tcg/sysemu/.
There is no need for a stub in tcg/user/.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-39-richard.henderson@linaro.org>

3 years agotarget/i386: Remove pc_start argument to gen_svm_check_intercept
Richard Henderson [Fri, 14 May 2021 15:13:29 +0000 (10:13 -0500)]
target/i386: Remove pc_start argument to gen_svm_check_intercept

When exiting helper_svm_check_intercept via exception, cpu_vmexit
calls cpu_restore_state, which will recover eip and cc_op via unwind.
Therefore we do not need to store eip or cc_op before the call.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-38-richard.henderson@linaro.org>

3 years agotarget/i386: Tidy svm_check_intercept from tcg
Richard Henderson [Fri, 14 May 2021 15:13:28 +0000 (10:13 -0500)]
target/i386: Tidy svm_check_intercept from tcg

The param argument to helper_svm_check_intercept_param is always 0;
eliminate it and rename to helper_svm_check_intercept.  Fold
gen_svm_check_intercept_param into gen_svm_check_intercept.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-37-richard.henderson@linaro.org>

3 years agotarget/i386: Simplify gen_debug usage
Richard Henderson [Fri, 14 May 2021 15:13:27 +0000 (10:13 -0500)]
target/i386: Simplify gen_debug usage

Both invocations pass the start of the current instruction,
which is available as s->base.pc_next.  The function sets
is_jmp, so we can eliminate a second setting.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-36-richard.henderson@linaro.org>

3 years agotarget/i386: Mark some helpers as noreturn
Richard Henderson [Fri, 14 May 2021 15:13:26 +0000 (10:13 -0500)]
target/i386: Mark some helpers as noreturn

Any helper that always raises an exception or interrupt,
or simply exits to the main loop, can be so marked.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-35-richard.henderson@linaro.org>

3 years agotarget/i386: Eliminate SVM helpers for user-only
Richard Henderson [Fri, 14 May 2021 15:13:25 +0000 (10:13 -0500)]
target/i386: Eliminate SVM helpers for user-only

Use STUB_HELPER to ensure that such calls are always eliminated.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-34-richard.henderson@linaro.org>

3 years agotarget/i386: Implement skinit in translate.c
Richard Henderson [Fri, 14 May 2021 15:13:24 +0000 (10:13 -0500)]
target/i386: Implement skinit in translate.c

Our sysemu implementation is a stub.  We can already intercept
instructions for vmexit, and raising #UD is trivial.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-33-richard.henderson@linaro.org>

3 years agotarget/i386: Assert !GUEST for user-only
Richard Henderson [Fri, 14 May 2021 15:13:23 +0000 (10:13 -0500)]
target/i386: Assert !GUEST for user-only

For user-only, we do not need to check for VMM intercept.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-32-richard.henderson@linaro.org>

3 years agotarget/i386: Assert !SVME for user-only
Richard Henderson [Fri, 14 May 2021 15:13:22 +0000 (10:13 -0500)]
target/i386: Assert !SVME for user-only

Most of the VMM instructions are already disabled for user-only,
by being usable only from ring 0.

The spec is intentionally loose for VMMCALL, allowing the VMM to
define syscalls for user-only.  However, we're not emulating any
VMM, so VMMCALL can just raise #UD unconditionally.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210514151342.384376-31-richard.henderson@linaro.org>

3 years agotarget/i386: Add stub generator for helper_set_dr
Richard Henderson [Fri, 14 May 2021 15:13:21 +0000 (10:13 -0500)]
target/i386: Add stub generator for helper_set_dr

This removes an ifdef from the middle of disas_insn,
and ensures that the branch is not reachable.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-30-richard.henderson@linaro.org>

3 years agotarget/i386: Reorder DisasContext members
Richard Henderson [Fri, 14 May 2021 15:13:20 +0000 (10:13 -0500)]
target/i386: Reorder DisasContext members

Sort all of the single-byte members to the same area
of the structure, eliminating 8 bytes of padding.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-29-richard.henderson@linaro.org>

3 years agotarget/i386: Fix the comment for repz_opt
Richard Henderson [Fri, 14 May 2021 15:13:19 +0000 (10:13 -0500)]
target/i386: Fix the comment for repz_opt

After fixing a typo in the comment, fixup for CODING_STYLE.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210514151342.384376-28-richard.henderson@linaro.org>

3 years agotarget/i386: Reduce DisasContext jmp_opt, repz_opt to bool
Richard Henderson [Fri, 14 May 2021 15:13:18 +0000 (10:13 -0500)]
target/i386: Reduce DisasContext jmp_opt, repz_opt to bool

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-27-richard.henderson@linaro.org>

3 years agotarget/i386: Leave TF in DisasContext.flags
Richard Henderson [Fri, 14 May 2021 15:13:17 +0000 (10:13 -0500)]
target/i386: Leave TF in DisasContext.flags

It's just as easy to clear the flag with AND than assignment.
In two cases the test for the bit can be folded together with
the test for HF_INHIBIT_IRQ_MASK.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-26-richard.henderson@linaro.org>

3 years agotarget/i386: Reduce DisasContext popl_esp_hack and rip_offset to uint8_t
Richard Henderson [Fri, 14 May 2021 15:13:16 +0000 (10:13 -0500)]
target/i386: Reduce DisasContext popl_esp_hack and rip_offset to uint8_t

Both of these fields store the size of a single memory access,
so the range of values is 0-8.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-25-richard.henderson@linaro.org>

3 years agotarget/i386: Reduce DisasContext.vex_[lv] to uint8_t
Richard Henderson [Fri, 14 May 2021 15:13:15 +0000 (10:13 -0500)]
target/i386: Reduce DisasContext.vex_[lv] to uint8_t

Currently, vex_l is either {0,1}; if in the future we implement
AVX-512, the max value will be 2.  In vex_v we store a register
number.  This is 0-15 for SSE, and 0-31 for AVX-512.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-24-richard.henderson@linaro.org>

3 years agotarget/i386: Reduce DisasContext.prefix to uint8_t
Richard Henderson [Fri, 14 May 2021 15:13:14 +0000 (10:13 -0500)]
target/i386: Reduce DisasContext.prefix to uint8_t

The highest bit in this set is 0x40 (PREFIX_REX).

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-23-richard.henderson@linaro.org>

3 years agotarget/i386: Reduce DisasContext.override to int8_t
Richard Henderson [Fri, 14 May 2021 15:13:13 +0000 (10:13 -0500)]
target/i386: Reduce DisasContext.override to int8_t

The range of values is -1 (none) to 5 (R_GS).

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-22-richard.henderson@linaro.org>

3 years agotarget/i386: Reduce DisasContext.flags to uint32_t
Richard Henderson [Fri, 14 May 2021 15:13:12 +0000 (10:13 -0500)]
target/i386: Reduce DisasContext.flags to uint32_t

The value comes from tb->flags, which is uint32_t.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-21-richard.henderson@linaro.org>

3 years agotarget/i386: Remove DisasContext.f_st as unused
Richard Henderson [Fri, 14 May 2021 15:13:11 +0000 (10:13 -0500)]
target/i386: Remove DisasContext.f_st as unused

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-20-richard.henderson@linaro.org>

3 years agotarget/i386: Move rex_w into DisasContext
Richard Henderson [Fri, 14 May 2021 15:13:10 +0000 (10:13 -0500)]
target/i386: Move rex_w into DisasContext

Treat this flag exactly like we treat the other rex bits.
The -1 initialization is unused; the two tests are > 0 and == 1,
so the value can be reduced to a bool.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-19-richard.henderson@linaro.org>

3 years agotarget/i386: Move rex_r into DisasContext
Richard Henderson [Fri, 14 May 2021 15:13:09 +0000 (10:13 -0500)]
target/i386: Move rex_r into DisasContext

Treat this flag exactly like we treat rex_b and rex_x.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-18-richard.henderson@linaro.org>

3 years agotarget/i386: Tidy REX_B, REX_X definition
Richard Henderson [Fri, 14 May 2021 15:13:08 +0000 (10:13 -0500)]
target/i386: Tidy REX_B, REX_X definition

Change the storage from int to uint8_t since the value is in {0,8}.
For x86_64 add 0 in the macros to (1) promote the type back to int,
and (2) make the macro an rvalue.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-17-richard.henderson@linaro.org>

3 years agotarget/i386: Introduce REX_PREFIX
Richard Henderson [Fri, 14 May 2021 15:13:07 +0000 (10:13 -0500)]
target/i386: Introduce REX_PREFIX

The existing flag, x86_64_hregs, does not accurately describe
its setting.  It is true if and only if a REX prefix has been
seen.  Yes, that affects the "h" regs, but that's secondary.

Add PREFIX_REX and include this bit in s->prefix.  Add REX_PREFIX
so that the check folds away when x86_64 is compiled out.

Fold away the reg >= 8 check, because bit 3 of the register
number comes from the REX prefix in the first place.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-16-richard.henderson@linaro.org>

3 years agotarget/i386: Assert !ADDSEG for x86_64 user-only
Richard Henderson [Fri, 14 May 2021 15:13:06 +0000 (10:13 -0500)]
target/i386: Assert !ADDSEG for x86_64 user-only

LMA disables traditional segmentation, exposing a flat address space.
This means that ADDSEG is off.

Since we're adding an accessor macro, pull the value directly out
of flags otherwise.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-15-richard.henderson@linaro.org>

3 years agotarget/i386: Assert LMA for x86_64 user-only
Richard Henderson [Fri, 14 May 2021 15:13:05 +0000 (10:13 -0500)]
target/i386: Assert LMA for x86_64 user-only

LMA is a pre-requisite for CODE64, so there is no way to disable it
for x86_64-linux-user, and there is no way to enable it for i386.

Since we're adding an accessor macro, pull the value directly out
of flags when we're not assuming a constant.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-14-richard.henderson@linaro.org>

3 years agotarget/i386: Assert CODE64 for x86_64 user-only
Richard Henderson [Fri, 14 May 2021 15:13:04 +0000 (10:13 -0500)]
target/i386: Assert CODE64 for x86_64 user-only

For x86_64 user-only, there is no way to leave 64-bit mode.

Without x86_64, there is no way to enter 64-bit mode.  There is
an existing macro to aid with that; simply place it in the right
place in the ifdef chain.

Since we're adding an accessor macro, pull the value directly out
of flags when we're not assuming a constant.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-13-richard.henderson@linaro.org>

3 years agotarget/i386: Assert SS32 for x86_64 user-only
Richard Henderson [Fri, 14 May 2021 15:13:03 +0000 (10:13 -0500)]
target/i386: Assert SS32 for x86_64 user-only

For user-only, SS32 == !VM86, because we are never in
real-mode.  Since we cannot enter vm86 mode for x86_64
user-only, SS32 is always set.

Since we're adding an accessor macro, pull the value
directly out of flags otherwise.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-12-richard.henderson@linaro.org>

3 years agotarget/i386: Assert CODE32 for x86_64 user-only
Richard Henderson [Fri, 14 May 2021 15:13:02 +0000 (10:13 -0500)]
target/i386: Assert CODE32 for x86_64 user-only

For user-only, CODE32 == !VM86, because we are never in real-mode.
Since we cannot enter vm86 mode for x86_64 user-only, CODE32 is
always set.

Since we're adding an accessor macro, pull the value directly out
of flags otherwise.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-11-richard.henderson@linaro.org>

3 years agotarget/i386: Assert !VM86 for x86_64 user-only
Richard Henderson [Fri, 14 May 2021 15:13:01 +0000 (10:13 -0500)]
target/i386: Assert !VM86 for x86_64 user-only

For i386-linux-user, we can enter vm86 mode via the vm86(2) syscall.
That syscall explicitly returns to 32-bit mode, and the syscall does
not exist for a 64-bit x86_64 executable.

Since we're adding an accessor macro, pull the value directly out of
flags otherwise.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-10-richard.henderson@linaro.org>

3 years agotarget/i386: Assert IOPL is 0 for user-only
Richard Henderson [Fri, 14 May 2021 15:13:00 +0000 (10:13 -0500)]
target/i386: Assert IOPL is 0 for user-only

On real hardware, the linux kernel has the iopl(2) syscall which
can set IOPL to 3, to allow e.g. the xserver to briefly disable
interrupts while programming the graphics card.

However, QEMU cannot and does not implement this syscall, so the
IOPL is never changed from 0.  Which means that all of the checks
vs CPL <= IOPL are false for user-only.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-9-richard.henderson@linaro.org>

3 years agotarget/i386: Assert CPL is 3 for user-only
Richard Henderson [Fri, 14 May 2021 15:12:59 +0000 (10:12 -0500)]
target/i386: Assert CPL is 3 for user-only

A user-mode executable always runs in ring 3.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-8-richard.henderson@linaro.org>

3 years agotarget/i386: Assert PE is set for user-only
Richard Henderson [Fri, 14 May 2021 15:12:58 +0000 (10:12 -0500)]
target/i386: Assert PE is set for user-only

A user-mode executable is never in real-mode.  Since we're adding
an accessor macro, pull the value directly out of flags for sysemu.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-7-richard.henderson@linaro.org>

3 years agotarget/i386: Split out check_iopl
Richard Henderson [Fri, 14 May 2021 15:12:57 +0000 (10:12 -0500)]
target/i386: Split out check_iopl

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-6-richard.henderson@linaro.org>

3 years agotarget/i386: Split out check_vm86_iopl
Richard Henderson [Fri, 14 May 2021 15:12:56 +0000 (10:12 -0500)]
target/i386: Split out check_vm86_iopl

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-5-richard.henderson@linaro.org>

3 years agotarget/i386: Unify code paths for IRET
Richard Henderson [Fri, 14 May 2021 15:12:55 +0000 (10:12 -0500)]
target/i386: Unify code paths for IRET

In vm86 mode, we use the same helper as real-mode, but with
an extra check for IOPL.  All non-exceptional paths set EFLAGS.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-4-richard.henderson@linaro.org>

3 years agotarget/i386: Split out check_cpl0
Richard Henderson [Fri, 14 May 2021 15:12:54 +0000 (10:12 -0500)]
target/i386: Split out check_cpl0

Split out the check for CPL != 0 and the raising of #GP.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-3-richard.henderson@linaro.org>

3 years agotarget/i386: Split out gen_exception_gpf
Richard Henderson [Fri, 14 May 2021 15:12:53 +0000 (10:12 -0500)]
target/i386: Split out gen_exception_gpf

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-2-richard.henderson@linaro.org>

3 years agoMerge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-6.1-pull-request...
Peter Maydell [Tue, 18 May 2021 15:17:22 +0000 (16:17 +0100)]
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-6.1-pull-request' into staging

linux-user pull request 20210517

- alpha sigaction fixes/cleanups
- s390x sigaction fixes/cleanup
- sparc sigaction fixes/cleanup
- s390x core dumping support
- core dump fix (app name)
- arm  fpa11 fix and cleanup
- strace fixes (unshare(), llseek())
- fix copy_file_range()
- use GDateTime
- Remove dead code

# gpg: Signature made Tue 18 May 2021 06:31:12 BST
# gpg:                using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C
# gpg:                issuer "laurent@vivier.eu"
# gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full]
# gpg:                 aka "Laurent Vivier <laurent@vivier.eu>" [full]
# gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [full]
# Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* remotes/vivier2/tags/linux-user-for-6.1-pull-request: (59 commits)
  linux-user/elfload: add s390x core dumping support
  linux-user/elfload: fix filling psinfo->pr_psargs
  linux-user: Tidy TARGET_NR_rt_sigaction
  linux-user/alpha: Share code for TARGET_NR_sigaction
  linux-user/alpha: Define TARGET_ARCH_HAS_KA_RESTORER
  linux-user: Honor TARGET_ARCH_HAS_SA_RESTORER in do_syscall
  linux-user: Pass ka_restorer to do_sigaction
  linux-user/alpha: Rename the sigaction restorer field
  linux-user/alpha: Fix rt sigframe return
  linux-user: use GDateTime for formatting timestamp for core file
  linux-user: Fix erroneous conversion in copy_file_range
  linux-user: Add copy_file_range to strace.list
  linux-user/s390x: Handle vector regs in signal stack
  linux-user/s390x: Clean up signal.c
  linux-user/s390x: Add build asserts for sigset sizes
  linux-user/s390x: Fix frame_addr corruption in setup_frame
  linux-user/s390x: Add stub sigframe argument for last_break
  linux-user/s390x: Set psw.mask properly for the signal handler
  linux-user/s390x: Clean up single-use gotos in signal.c
  linux-user/s390x: Tidy save_sigregs
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agoMerge remote-tracking branch 'remotes/nvme/tags/nvme-next-pull-request' into staging
Peter Maydell [Tue, 18 May 2021 11:22:16 +0000 (12:22 +0100)]
Merge remote-tracking branch 'remotes/nvme/tags/nvme-next-pull-request' into staging

emulated nvme updates

* various fixes (Gollu Appalanaidu)
* refactoring (me)
* move to hw/nvme from hw/block (me)

# gpg: Signature made Mon 17 May 2021 10:16:01 BST
# gpg:                using RSA key 522833AA75E2DCE6A24766C04DE1AF316D4F0DE9
# gpg: Good signature from "Klaus Jensen <its@irrelevant.dk>" [unknown]
# gpg:                 aka "Klaus Jensen <k.jensen@samsung.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: DDCA 4D9C 9EF9 31CC 3468  4272 63D5 6FC5 E55D A838
#      Subkey fingerprint: 5228 33AA 75E2 DCE6 A247  66C0 4DE1 AF31 6D4F 0DE9

* remotes/nvme/tags/nvme-next-pull-request:
  hw/nvme: move nvme emulation out of hw/block
  hw/block/nvme: move zoned constraints checks
  hw/block/nvme: remove irrelevant zone resource checks
  hw/block/nvme: remove num_namespaces member
  hw/block/nvme: streamline namespace array indexing
  hw/block/nvme: add metadata offset helper
  hw/block/nvme: cache lba and ms sizes
  hw/block/nvme: replace nvme_ns_status
  hw/block/nvme: remove non-shared defines from header file
  hw/block/nvme: cleanup includes
  hw/block/nvme: consolidate header files
  hw/block/nvme: rename __nvme_select_ns_iocs
  hw/block/nvme: rename __nvme_advance_zone_wp
  hw/block/nvme: rename __nvme_zrm_open
  hw/block/nvme: align with existing style
  hw/block/nvme: function formatting fix
  hw/block/nvme: fix io-command set profile feature
  hw/block/nvme: consider metadata read aio return value in compare
  hw/block/nvme: rename reserved fields declarations
  hw/block/nvme: remove redundant invalid_lba_range trace

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agoMerge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210516' into staging
Peter Maydell [Tue, 18 May 2021 10:11:26 +0000 (11:11 +0100)]
Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210516' into staging

Minor MAINTAINERS update.
Tweak to includes.
Add tcg_constant_tl.
Improve constant pool dump.

# gpg: Signature made Sun 16 May 2021 15:08:42 BST
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full]
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* remotes/rth-gitlab/tags/pull-tcg-20210516:
  accel/tcg: Align data dumped at end of TB
  tcg: Add tcg_constant_tl
  exec/gen-icount.h: Add missing "exec/exec-all.h" include
  MAINTAINERS: Add include/exec/gen-icount.h to 'Main Loop' section

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agolinux-user/elfload: add s390x core dumping support
Ilya Leoshkevich [Tue, 13 Apr 2021 20:56:08 +0000 (22:56 +0200)]
linux-user/elfload: add s390x core dumping support

Provide the following definitions required by the common code:

* ELF_NREG: with the value of sizeof(s390_regs) / sizeof(long).
* target_elf_gregset_t: define it like all the other arches do.
* elf_core_copy_regs(): similar to kernel's s390_regs_get().
* USE_ELF_CORE_DUMP.
* ELF_EXEC_PAGESIZE.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20210413205608.22587-1-iii@linux.ibm.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
3 years agolinux-user/elfload: fix filling psinfo->pr_psargs
Ilya Leoshkevich [Tue, 13 Apr 2021 20:58:14 +0000 (22:58 +0200)]
linux-user/elfload: fix filling psinfo->pr_psargs

The current code dumps the memory between arg_start and arg_end,
which contains the argv pointers. This results in the

    Core was generated by `<garbage>`

message when opening the core file in GDB. This is because the code is
supposed to dump the actual arg strings. Fix by using arg_strings and
env_strings instead of arg_start and arg_end.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20210413205814.22821-1-iii@linux.ibm.com>
[lv: add missing braces]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
3 years agolinux-user: Tidy TARGET_NR_rt_sigaction
Richard Henderson [Thu, 22 Apr 2021 23:02:27 +0000 (16:02 -0700)]
linux-user: Tidy TARGET_NR_rt_sigaction

Initialize variables instead of elses.
Use an else instead of a goto.
Add braces.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20210422230227.314751-8-richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
3 years agolinux-user/alpha: Share code for TARGET_NR_sigaction
Richard Henderson [Thu, 22 Apr 2021 23:02:26 +0000 (16:02 -0700)]
linux-user/alpha: Share code for TARGET_NR_sigaction

There's no longer a difference between the alpha code and
the generic code.

There is a type difference in target_old_sigaction.sa_flags,
which can be resolved with a very much smaller ifdef, which
allows us to finish sharing the target_sigaction definition.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20210422230227.314751-7-richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
3 years agolinux-user/alpha: Define TARGET_ARCH_HAS_KA_RESTORER
Richard Henderson [Thu, 22 Apr 2021 23:02:25 +0000 (16:02 -0700)]
linux-user/alpha: Define TARGET_ARCH_HAS_KA_RESTORER

This means that we can share the TARGET_NR_rt_sigaction code,
and the target_rt_sigaction structure is unused.  Untangling
the ifdefs so that target_sigaction can be shared will wait
until the next patch.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20210422230227.314751-6-richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
3 years agolinux-user: Honor TARGET_ARCH_HAS_SA_RESTORER in do_syscall
Richard Henderson [Thu, 22 Apr 2021 23:02:24 +0000 (16:02 -0700)]
linux-user: Honor TARGET_ARCH_HAS_SA_RESTORER in do_syscall

Do not access a field that may not be present.  This will
become an issue when sharing more code in the next patch.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20210422230227.314751-5-richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
3 years agolinux-user: Pass ka_restorer to do_sigaction
Richard Henderson [Thu, 22 Apr 2021 23:02:23 +0000 (16:02 -0700)]
linux-user: Pass ka_restorer to do_sigaction

The value of ka_restorer needs to be saved in sigact_table.
At the moment, the attempt to save it in do_syscall is
improperly clobbering user memory.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20210422230227.314751-4-richard.henderson@linaro.org>
[lv: remove tab]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
3 years agolinux-user/alpha: Rename the sigaction restorer field
Richard Henderson [Thu, 22 Apr 2021 23:02:22 +0000 (16:02 -0700)]
linux-user/alpha: Rename the sigaction restorer field

Use ka_restorer, in line with TARGET_ARCH_HAS_KA_RESTORER
vs TARGET_ARCH_HAS_SA_RESTORER, since Alpha passes this
field as a syscall argument.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20210422230227.314751-3-richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
3 years agolinux-user/alpha: Fix rt sigframe return
Richard Henderson [Thu, 22 Apr 2021 23:02:21 +0000 (16:02 -0700)]
linux-user/alpha: Fix rt sigframe return

We incorrectly used the offset of the non-rt sigframe.

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20210422230227.314751-2-richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
3 years agolinux-user: use GDateTime for formatting timestamp for core file
Daniel P. Berrangé [Wed, 5 May 2021 10:37:01 +0000 (11:37 +0100)]
linux-user: use GDateTime for formatting timestamp for core file

The GDateTime APIs provided by GLib avoid portability pitfalls, such
as some platforms where 'struct timeval.tv_sec' field is still 'long'
instead of 'time_t'. When combined with automatic cleanup, GDateTime
often results in simpler code too.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210505103702.521457-7-berrange@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
3 years agolinux-user: Fix erroneous conversion in copy_file_range
Giuseppe Musacchio [Mon, 3 May 2021 17:41:59 +0000 (19:41 +0200)]
linux-user: Fix erroneous conversion in copy_file_range

The implicit cast from abi_long to size_t may introduce an intermediate
unwanted sign-extension of the value for 32bit targets running on 64bit
hosts.

Signed-off-by: Giuseppe Musacchio <thatlemon@gmail.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210503174159.54302-3-thatlemon@gmail.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
3 years agolinux-user: Add copy_file_range to strace.list
Giuseppe Musacchio [Mon, 3 May 2021 17:41:58 +0000 (19:41 +0200)]
linux-user: Add copy_file_range to strace.list

Signed-off-by: Giuseppe Musacchio <thatlemon@gmail.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210503174159.54302-2-thatlemon@gmail.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
3 years agolinux-user/s390x: Handle vector regs in signal stack
Richard Henderson [Wed, 28 Apr 2021 19:34:08 +0000 (12:34 -0700)]
linux-user/s390x: Handle vector regs in signal stack

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210428193408.233706-16-richard.henderson@linaro.org>
[lv: fix indentation]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
3 years agoMerge remote-tracking branch 'remotes/rth-gitlab/tags/pull-fp-20210516' into staging
Peter Maydell [Mon, 17 May 2021 19:02:55 +0000 (20:02 +0100)]
Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-fp-20210516' into staging

Reorg FloatParts to use QEMU_GENERIC.
Begin replacing the Berkeley float128 routines with FloatParts128.
  - includes a new implementation of float128_muladd
  - includes the snan silencing that was missing from
    float{32,64}_to_float128 and float128_to_float{32,64}.
  - does not include float128_min/max* (written but not yet reviewed).

# gpg: Signature made Sun 16 May 2021 13:27:10 BST
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full]
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* remotes/rth-gitlab/tags/pull-fp-20210516: (46 commits)
  softfloat: Move round_to_int_and_pack to softfloat-parts.c.inc
  softfloat: Move round_to_int to softfloat-parts.c.inc
  softfloat: Convert float-to-float conversions with float128
  softfloat: Split float_to_float
  softfloat: Move div_floats to softfloat-parts.c.inc
  softfloat: Introduce sh[lr]_double primitives
  softfloat: Tidy mul128By64To192
  softfloat: Use add192 in mul128To256
  softfloat: Use mulu64 for mul64To128
  softfloat: Move muladd_floats to softfloat-parts.c.inc
  softfloat: Move mul_floats to softfloat-parts.c.inc
  softfloat: Implement float128_add/sub via parts
  softfloat: Move addsub_floats to softfloat-parts.c.inc
  softfloat: Use uadd64_carry, usub64_borrow in softfloat-macros.h
  softfloat: Move round_canonical to softfloat-parts.c.inc
  softfloat: Move sf_canonicalize to softfloat-parts.c.inc
  softfloat: Move pick_nan_muladd to softfloat-parts.c.inc
  softfloat: Move pick_nan to softfloat-parts.c.inc
  softfloat: Move return_nan to softfloat-parts.c.inc
  softfloat: Convert float128_default_nan to parts
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agoMerge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-for-6.1-pull-reques...
Peter Maydell [Mon, 17 May 2021 15:44:47 +0000 (16:44 +0100)]
Merge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-for-6.1-pull-request' into staging

Pull request trivial-branch 20210515

# gpg: Signature made Sat 15 May 2021 11:02:59 BST
# gpg:                using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C
# gpg:                issuer "laurent@vivier.eu"
# gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full]
# gpg:                 aka "Laurent Vivier <laurent@vivier.eu>" [full]
# gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [full]
# Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* remotes/vivier2/tags/trivial-branch-for-6.1-pull-request:
  target/avr: Ignore unimplemented WDR opcode
  hw/avr/atmega.c: use the avr51 cpu for atmega1280
  target/sh4: Return error if CPUClass::get_phys_page_debug() fails
  multi-process: Avoid logical AND of mutually exclusive tests
  hw/pci-host: Do not build gpex-acpi.c if GPEX is not selected
  hw/mem/meson: Fix linking sparse-mem device with fuzzer
  cutils: fix memory leak in get_relocated_path()
  hw/rtc/mc146818rtc: Convert to 3-phase reset (Resettable interface)
  hw/timer/etraxfs_timer: Convert to 3-phase reset (Resettable interface)
  hw/gpio/aspeed: spelling fix (addtional)
  qapi: spelling fix (addtional)
  virtiofsd: Fix check of chown()'s return value
  virtio-net: Constify VirtIOFeature feature_sizes[]
  virtio-blk: Constify VirtIOFeature feature_sizes[]
  hw/virtio: Pass virtio_feature_get_config_size() a const argument
  backends/tpm: Replace qemu_mutex_lock calls with QEMU_LOCK_GUARD

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agoMerge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2021-05-14' into staging
Peter Maydell [Mon, 17 May 2021 10:29:59 +0000 (11:29 +0100)]
Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2021-05-14' into staging

Block patches:
- drop block/io write notifiers
- qemu-iotests enhancements to make debugging easier
- rbd parsing fix
- HMP qemu-io fix (for iothreads)
- mirror job cancel relaxation (do not cancel in-flight requests when a
  READY mirror job is canceled with force=false)
- document qcow2's data_file and data_file_raw features
- fix iotest 297 for pylint 2.8
- block/copy-on-read refactoring

# gpg: Signature made Fri 14 May 2021 17:43:40 BST
# gpg:                using RSA key 91BEB60A30DB3E8857D11829F407DB0061D5CF40
# gpg:                issuer "mreitz@redhat.com"
# gpg: Good signature from "Max Reitz <mreitz@redhat.com>" [full]
# Primary key fingerprint: 91BE B60A 30DB 3E88 57D1  1829 F407 DB00 61D5 CF40

* remotes/maxreitz/tags/pull-block-2021-05-14:
  write-threshold: deal with includes
  test-write-threshold: drop extra TestStruct structure
  test-write-threshold: drop extra tests
  block/write-threshold: drop extra APIs
  test-write-threshold: rewrite test_threshold_(not_)trigger tests
  block: drop write notifiers
  block/write-threshold: don't use write notifiers
  qemu-iotests: fix pylint 2.8 consider-using-with error
  block/copy-on-read: use bdrv_drop_filter() and drop s->active
  Document qemu-img options data_file and data_file_raw
  qemu-iotests: fix case of SOCK_DIR already in the environment
  qemu-iotests: let "check" spawn an arbitrary test command
  qemu-iotests: move command line and environment handling from TestRunner to TestEnv
  qemu-iotests: allow passing unittest.main arguments to the test scripts
  qemu-iotests: do not buffer the test output
  mirror: stop cancelling in-flight requests on non-force cancel in READY
  monitor: hmp_qemu_io: acquire aio contex, fix crash
  block/rbd: Add an escape-aware strchr helper
  iotests/231: Update expected deprecation message

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agohw/nvme: move nvme emulation out of hw/block
Klaus Jensen [Wed, 14 Apr 2021 20:14:30 +0000 (22:14 +0200)]
hw/nvme: move nvme emulation out of hw/block

With the introduction of the nvme-subsystem device we are really
cluttering up the hw/block directory.

As suggested by Philippe previously, move the nvme emulation to hw/nvme.

Suggested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
3 years agohw/block/nvme: move zoned constraints checks
Klaus Jensen [Tue, 9 Mar 2021 11:20:41 +0000 (12:20 +0100)]
hw/block/nvme: move zoned constraints checks

Validation of the max_active and max_open zoned parameters are
independent of any other state, so move them to the early
nvme_ns_check_constraints parameter checks.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
3 years agohw/block/nvme: remove irrelevant zone resource checks
Klaus Jensen [Tue, 9 Mar 2021 11:17:15 +0000 (12:17 +0100)]
hw/block/nvme: remove irrelevant zone resource checks

It is not an error to report more active/open zones supported than the
number of zones in the namespace.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
3 years agohw/block/nvme: remove num_namespaces member
Klaus Jensen [Wed, 14 Apr 2021 19:46:00 +0000 (21:46 +0200)]
hw/block/nvme: remove num_namespaces member

The NvmeCtrl num_namespaces member is just an indirection for the
NVME_MAX_NAMESPACES constant.

Remove the indirection.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
3 years agohw/block/nvme: streamline namespace array indexing
Klaus Jensen [Wed, 14 Apr 2021 19:40:40 +0000 (21:40 +0200)]
hw/block/nvme: streamline namespace array indexing

Streamline namespace array indexing such that both the subsystem and
controller namespaces arrays are 1-indexed.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
3 years agohw/block/nvme: add metadata offset helper
Klaus Jensen [Tue, 13 Apr 2021 19:51:30 +0000 (21:51 +0200)]
hw/block/nvme: add metadata offset helper

Add an nvme_moff() helper.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
3 years agohw/block/nvme: cache lba and ms sizes
Klaus Jensen [Wed, 14 Apr 2021 19:34:44 +0000 (21:34 +0200)]
hw/block/nvme: cache lba and ms sizes

There is no need to look up the lba size and metadata size in the LBA
Format structure everytime we want to use it. And we use it a lot.

Cache the values in the NvmeNamespace and update them if the namespace
is formatted.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
3 years agohw/block/nvme: replace nvme_ns_status
Klaus Jensen [Wed, 14 Apr 2021 18:43:50 +0000 (20:43 +0200)]
hw/block/nvme: replace nvme_ns_status

The inline nvme_ns_status() helper only has a single call site. Remove
it from the header file and inline it for real.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
3 years agohw/block/nvme: remove non-shared defines from header file
Klaus Jensen [Wed, 14 Apr 2021 18:42:27 +0000 (20:42 +0200)]
hw/block/nvme: remove non-shared defines from header file

Remove non-shared defines from the shared header.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
3 years agohw/block/nvme: cleanup includes
Klaus Jensen [Wed, 14 Apr 2021 18:41:20 +0000 (20:41 +0200)]
hw/block/nvme: cleanup includes

Clean up includes.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
3 years agohw/block/nvme: consolidate header files
Klaus Jensen [Wed, 14 Apr 2021 17:10:01 +0000 (19:10 +0200)]
hw/block/nvme: consolidate header files

In preparation for moving the nvme device into its own subtree, merge
the header files into one.

Also add missing copyright notice and add list of authors with
substantial contributions.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
3 years agohw/block/nvme: rename __nvme_select_ns_iocs
Klaus Jensen [Thu, 15 Apr 2021 06:39:08 +0000 (08:39 +0200)]
hw/block/nvme: rename __nvme_select_ns_iocs

Get rid of the (reserved) double underscore use.

Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
3 years agohw/block/nvme: rename __nvme_advance_zone_wp
Klaus Jensen [Thu, 15 Apr 2021 06:38:28 +0000 (08:38 +0200)]
hw/block/nvme: rename __nvme_advance_zone_wp

Get rid of the (reserved) double underscore use.

Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
3 years agohw/block/nvme: rename __nvme_zrm_open
Klaus Jensen [Thu, 15 Apr 2021 06:37:36 +0000 (08:37 +0200)]
hw/block/nvme: rename __nvme_zrm_open

Get rid of the (reserved) double underscore use. Rename the "generic"
zone open function to nvme_zrm_open_flags() and add a generic `int
flags` argument instead which allows more flags to be easily added in
the future. There is at least one TP under standardization that would
add an additional flag.

Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
3 years agohw/block/nvme: align with existing style
Gollu Appalanaidu [Fri, 16 Apr 2021 03:52:28 +0000 (09:22 +0530)]
hw/block/nvme: align with existing style

While QEMU coding style prefers lowercase hexadecimals in constants, the
NVMe subsystem uses the format from the NVMe specifications in comments,
i.e. 'h' suffix instead of '0x' prefix.

Fix this up across the code base.

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
[k.jensen: updated message; added conversion in a couple of missing comments]
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years agohw/block/nvme: function formatting fix
Gollu Appalanaidu [Tue, 20 Apr 2021 19:22:59 +0000 (00:52 +0530)]
hw/block/nvme: function formatting fix

nvme_map_addr_pmr function arguments not aligned, fix that.

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years agohw/block/nvme: fix io-command set profile feature
Gollu Appalanaidu [Mon, 19 Apr 2021 10:48:32 +0000 (16:18 +0530)]
hw/block/nvme: fix io-command set profile feature

Currently IO Command Set Profile feature is supported, but the feature
support flag not set. Further, this feature is changable. Fix that.

Additionally, remove filling default value of the CQE result with zero,
since it will fall back to the default case anyway.

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
[k.jensen: fix up commit message]
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years agohw/block/nvme: consider metadata read aio return value in compare
Gollu Appalanaidu [Fri, 16 Apr 2021 07:22:33 +0000 (12:52 +0530)]
hw/block/nvme: consider metadata read aio return value in compare

Currently in compare command metadata aio read blk_aio_preadv return
value ignored. Consider it and complete the block accounting.

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
Fixes: 0a384f923f51 ("hw/block/nvme: add compare command")
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years agohw/block/nvme: rename reserved fields declarations
Gollu Appalanaidu [Wed, 17 Mar 2021 09:30:06 +0000 (15:00 +0530)]
hw/block/nvme: rename reserved fields declarations

Align the 'rsvd1' reserved field declaration in NvmeBar with existing
style.

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
[k.jensen: minor commit message fixup]
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years agohw/block/nvme: remove redundant invalid_lba_range trace
Gollu Appalanaidu [Wed, 14 Apr 2021 07:04:35 +0000 (12:34 +0530)]
hw/block/nvme: remove redundant invalid_lba_range trace

Currently pci_nvme_err_invalid_lba_range trace is called individually at
each nvme_check_bounds() call site.

Move the trace event to nvme_check_bounds() and remove the redundant
events.

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
[k.jensen: commit message fixup]
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
3 years agoMerge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
Peter Maydell [Sun, 16 May 2021 16:22:46 +0000 (17:22 +0100)]
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging

pc,pci,virtio: bugfixes, improvements

Fixes all over the place. Faster boot for virtio. ioeventfd support for
mmio.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
# gpg: Signature made Fri 14 May 2021 15:27:13 BST
# gpg:                using RSA key 5D09FD0871C8F85B94CA8A0D281F0DB8D28D5469
# gpg:                issuer "mst@redhat.com"
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" [full]
# gpg:                 aka "Michael S. Tsirkin <mst@redhat.com>" [full]
# Primary key fingerprint: 0270 606B 6F3C DF3D 0B17  0970 C350 3912 AFBE 8E67
#      Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA  8A0D 281F 0DB8 D28D 5469

* remotes/mst/tags/for_upstream:
  Fix build with 64 bits time_t
  vhost-vdpa: Make vhost_vdpa_get_device_id() static
  hw/virtio: enable ioeventfd configuring for mmio
  hw/smbios: support for type 41 (onboard devices extended information)
  checkpatch: Fix use of uninitialized value
  virtio-scsi: Configure all host notifiers in a single MR transaction
  virtio-scsi: Set host notifiers and callbacks separately
  virtio-blk: Configure all host notifiers in a single MR transaction
  virtio-blk: Fix rollback path in virtio_blk_data_plane_start()
  pc-dimm: remove unnecessary get_vmstate_memory_region() method
  amd_iommu: fix wrong MMIO operations
  virtio-net: Constify VirtIOFeature feature_sizes[]
  virtio-blk: Constify VirtIOFeature feature_sizes[]
  hw/virtio: Pass virtio_feature_get_config_size() a const argument
  x86: acpi: use offset instead of pointer when using build_header()
  amd_iommu: Fix pte_override_page_mask()

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
# Conflicts:
# hw/arm/virt.c

3 years agoaccel/tcg: Align data dumped at end of TB
Philippe Mathieu-Daudé [Sat, 15 May 2021 10:42:02 +0000 (12:42 +0200)]
accel/tcg: Align data dumped at end of TB

To better visualize the data dumped at the end of a TB, left-align it
(padding it with 0).  Print ".long" instead of ".quad" on 32-bit hosts.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20210515104202.241504-1-f4bug@amsat.org>
[rth: Split the qemu_log and print .long for 32-bit hosts.]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Move round_to_int_and_pack to softfloat-parts.c.inc
Richard Henderson [Sat, 14 Nov 2020 21:21:43 +0000 (13:21 -0800)]
softfloat: Move round_to_int_and_pack to softfloat-parts.c.inc

Rename to parts$N_float_to_sint.  Reimplement
float128_to_int{32,64}{_round_to_zero} with FloatParts128.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Move round_to_int to softfloat-parts.c.inc
Richard Henderson [Sat, 14 Nov 2020 20:53:12 +0000 (12:53 -0800)]
softfloat: Move round_to_int to softfloat-parts.c.inc

At the same time, convert to pointers, split out
parts$N_round_to_int_normal, define a macro for
parts_round_to_int using QEMU_GENERIC.

This necessarily meant some rearrangement to the
rount_to_{,u}int_and_pack routines, so go ahead and
convert to parts_round_to_int_normal, which in turn
allows cleaning up of the raised exception handling.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Convert float-to-float conversions with float128
Richard Henderson [Sat, 14 Nov 2020 02:17:39 +0000 (18:17 -0800)]
softfloat: Convert float-to-float conversions with float128

Introduce parts_float_to_float_widen and parts_float_to_float_narrow.
Use them for float128_to_float{32,64} and float{32,64}_to_float128.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Split float_to_float
Richard Henderson [Sat, 14 Nov 2020 01:43:41 +0000 (17:43 -0800)]
softfloat: Split float_to_float

Split out parts_float_to_ahp and parts_float_to_float.
Convert to pointers.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Move div_floats to softfloat-parts.c.inc
Richard Henderson [Wed, 11 Nov 2020 20:50:44 +0000 (12:50 -0800)]
softfloat: Move div_floats to softfloat-parts.c.inc

Rename to parts$N_div.
Implement float128_div with FloatParts128.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Introduce sh[lr]_double primitives
Richard Henderson [Tue, 10 Nov 2020 03:08:30 +0000 (19:08 -0800)]
softfloat: Introduce sh[lr]_double primitives

Have x86_64 assembly for them, with a fallback.
This avoids shuffling values through %cl in the x86 case.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Tidy mul128By64To192
Richard Henderson [Thu, 12 Nov 2020 19:40:12 +0000 (11:40 -0800)]
softfloat: Tidy mul128By64To192

Clean up the formatting and variables; no functional change.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Use add192 in mul128To256
Richard Henderson [Mon, 26 Oct 2020 21:33:53 +0000 (14:33 -0700)]
softfloat: Use add192 in mul128To256

We can perform the operation in 6 total adds instead of 8.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Use mulu64 for mul64To128
Richard Henderson [Wed, 23 Sep 2020 15:57:01 +0000 (08:57 -0700)]
softfloat: Use mulu64 for mul64To128

Via host-utils.h, we use a host widening multiply for
64-bit hosts, and a common subroutine for 32-bit hosts.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Move muladd_floats to softfloat-parts.c.inc
Richard Henderson [Sat, 24 Oct 2020 13:04:19 +0000 (06:04 -0700)]
softfloat: Move muladd_floats to softfloat-parts.c.inc

Rename to parts$N_muladd.
Implement float128_muladd with FloatParts128.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Move mul_floats to softfloat-parts.c.inc
Richard Henderson [Thu, 12 Nov 2020 04:44:57 +0000 (20:44 -0800)]
softfloat: Move mul_floats to softfloat-parts.c.inc

Rename to parts$N_mul.
Reimplement float128_mul with FloatParts128.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>