qemu.git
3 years agoMerge remote-tracking branch 'remotes/rth-gitlab/tags/pull-x86-20210519' into staging
Peter Maydell [Thu, 20 May 2021 12:04:12 +0000 (13:04 +0100)]
Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-x86-20210519' into staging

Eliminate user-only helper stubs for privledged insns.

# gpg: Signature made Wed 19 May 2021 19:24:27 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-x86-20210519: (50 commits)
  target/i386: Remove user-only i/o stubs
  target/i386: Move helper_check_io to sysemu
  target/i386: Create helper_check_io
  target/i386: Pass in port to gen_check_io
  target/i386: Tidy gen_check_io
  target/i386: Exit tb after wrmsr
  target/i386: Eliminate user stubs for read/write_crN, rd/wrmsr
  target/i386: Inline user cpu_svm_check_intercept_param
  target/i386: Unify invlpg, invlpga
  target/i386: Move invlpg, hlt, monitor, mwait to sysemu
  target/i386: Pass env to do_pause and do_hlt
  target/i386: Cleanup read_crN, write_crN, lmsw
  target/i386: Remove user stub for cpu_vmexit
  target/i386: Remove pc_start argument to gen_svm_check_intercept
  target/i386: Tidy svm_check_intercept from tcg
  target/i386: Simplify gen_debug usage
  target/i386: Mark some helpers as noreturn
  target/i386: Eliminate SVM helpers for user-only
  target/i386: Implement skinit in translate.c
  target/i386: Assert !GUEST for user-only
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agoMerge remote-tracking branch 'remotes/stsquad/tags/pull-testing-and-plugin-updates...
Peter Maydell [Thu, 20 May 2021 09:00:58 +0000 (10:00 +0100)]
Merge remote-tracking branch 'remotes/stsquad/tags/pull-testing-and-plugin-updates-180521-2' into staging

testing and plugin updates:

  - various fixes for binfmt_misc docker images
  - add hexagon check-tcg support docker image
  - add tricore check-tcg support
  - refactor ppc docker images
  - add missing ppc64le tests
  - don't use host_cc for test fallback
  - check-tcg configure.sh tweaks for cross compile/clang
  - fix some memory leaks in plugins

# gpg: Signature made Tue 18 May 2021 09:37:21 BST
# gpg:                using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>" [full]
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* remotes/stsquad/tags/pull-testing-and-plugin-updates-180521-2: (29 commits)
  configure: use cc, not host_cc to set cross_cc for build arch
  tests/tcg: don't allow clang as a cross compiler
  tests/tcg: fix missing return
  tests/tcg/ppc64le: tests for brh/brw/brd
  tests/docker: gcc-10 based images for ppc64{,le} tests
  tests/tcg/tricore: Add muls test
  tests/tcg/tricore: Add msub test
  tests/tcg/tricore: Add madd test
  tests/tcg/tricore: Add ftoi test
  tests/tcg/tricore: Add fmul test
  tests/tcg/tricore: Add fadd test
  tests/tcg/tricore: Add dvstep test
  tests/tcg/tricore: Add clz test
  tests/tcg/tricore: Add bmerge test
  tests/tcg/tricore: Add macros to create tests and first test 'abs'
  configure: Emit HOST_CC to config-host.mak
  tests/tcg/tricore: Add build infrastructure
  hw/tricore: Add testdevice for tests in tests/tcg/
  tests/tcg: Run timeout cmds using --foreground
  tests/tcg: Add docker_as and docker_ld cmds
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agoMerge remote-tracking branch 'remotes/dg-gitlab/tags/ppc-for-6.1-20210519' into staging
Peter Maydell [Wed, 19 May 2021 20:00:33 +0000 (21:00 +0100)]
Merge remote-tracking branch 'remotes/dg-gitlab/tags/ppc-for-6.1-20210519' into staging

ppc patch queue 2021-05-19

Next set of ppc related patches for qemu-6.1.  Highlights are:
 * Start of a significant softmmu cleanup from Richard Henderson
 * Further work towards allowing builds without CONFIG_TCG

# gpg: Signature made Wed 19 May 2021 13:36:45 BST
# gpg:                using RSA key 75F46586AE61A66CC44E87DC6C38CACA20D9B392
# gpg: Good signature from "David Gibson <david@gibson.dropbear.id.au>" [full]
# gpg:                 aka "David Gibson (Red Hat) <dgibson@redhat.com>" [full]
# gpg:                 aka "David Gibson (ozlabs.org) <dgibson@ozlabs.org>" [full]
# gpg:                 aka "David Gibson (kernel.org) <dwg@kernel.org>" [unknown]
# Primary key fingerprint: 75F4 6586 AE61 A66C C44E  87DC 6C38 CACA 20D9 B392

* remotes/dg-gitlab/tags/ppc-for-6.1-20210519: (48 commits)
  target/ppc: Remove type argument for mmubooke206_get_physical_address
  target/ppc: Remove type argument from mmubooke206_check_tlb
  target/ppc: Remove type argument from mmubooke_get_physical_address
  target/ppc: Remove type argument from mmubooke_check_tlb
  target/ppc: Remove type argument from mmu40x_get_physical_address
  target/ppc: Remove type argument from get_bat_6xx_tlb
  target/ppc: Remove type argument from ppc6xx_tlb_check
  target/ppc: Remove type argument from ppc6xx_tlb_pte_check
  target/ppc: Remove type argument from check_prot
  target/ppc: Use MMUAccessType in mmu_helper.c
  target/ppc: Rename access_type to type in mmu_helper.c
  target/ppc: Use MMUAccessType in mmu-hash32.c
  target/ppc: Use MMUAccessType in mmu-hash64.c
  target/ppc: Use MMUAccessType in mmu-radix64.c
  target/ppc: Introduce prot_for_access_type
  target/ppc: Fix load endianness for lxvwsx/lxvdsx
  target/ppc: Use translator_loop_temp_check
  target/ppc: Mark helper_raise_exception* as noreturn
  target/ppc: Tidy exception vs exit_tb
  target/ppc: Move single-step check to ppc_tr_tb_stop
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agotarget/i386: Remove user-only i/o stubs
Richard Henderson [Fri, 14 May 2021 15:13:42 +0000 (10:13 -0500)]
target/i386: Remove user-only i/o stubs

With the previous patch for check_io, we now have enough for
the compiler to dead-code eliminate all of the i/o helpers.

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-51-richard.henderson@linaro.org>

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

The we never allow i/o from user-only, and the tss check
that helper_check_io does will always fail.  Use an ifdef
within gen_check_io and return false, indicating that an
exception is known to be raised.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-50-richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
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/kevin/tags/for-upstream' into staging
Peter Maydell [Wed, 19 May 2021 15:10:35 +0000 (16:10 +0100)]
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block layer patches

- vhost-user-blk: Fix error handling during initialisation
- Add test cases for the vhost-user-blk export
- Fix leaked Transaction objects
- qcow2: Expose dirty bit in 'qemu-img info'

# gpg: Signature made Tue 18 May 2021 11:57:46 BST
# gpg:                using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6
# gpg:                issuer "kwolf@redhat.com"
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full]
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* remotes/kevin/tags/for-upstream:
  vhost-user-blk: Check that num-queues is supported by backend
  virtio: Fail if iommu_platform is requested, but unsupported
  vhost-user-blk: Get more feature flags from vhost device
  vhost-user-blk: Improve error reporting in realize
  vhost-user-blk: Don't reconnect during initialisation
  vhost-user-blk: Make sure to set Error on realize failure
  vhost-user-blk-test: test discard/write zeroes invalid inputs
  tests/qtest: add multi-queue test case to vhost-user-blk-test
  test: new qTest case to test the vhost-user-blk-server
  block/export: improve vu_blk_sect_range_ok()
  block: Fix Transaction leak in bdrv_reopen_multiple()
  block: Fix Transaction leak in bdrv_root_attach_child()
  qcow2: set bdi->is_dirty

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3 years agotarget/ppc: Remove type argument for mmubooke206_get_physical_address
Richard Henderson [Tue, 18 May 2021 20:11:37 +0000 (15:11 -0500)]
target/ppc: Remove type argument for mmubooke206_get_physical_address

It is no longer used.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210518201146.794854-16-richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Remove type argument from mmubooke206_check_tlb
Richard Henderson [Tue, 18 May 2021 20:11:36 +0000 (15:11 -0500)]
target/ppc: Remove type argument from mmubooke206_check_tlb

We can now use MMU_INST_FETCH from access_type for this.
Unify the I/D code paths, making use of prot_for_access_type.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210518201146.794854-15-richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Remove type argument from mmubooke_get_physical_address
Richard Henderson [Tue, 18 May 2021 20:11:35 +0000 (15:11 -0500)]
target/ppc: Remove type argument from mmubooke_get_physical_address

It is no longer used.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210518201146.794854-14-richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Remove type argument from mmubooke_check_tlb
Richard Henderson [Tue, 18 May 2021 20:11:34 +0000 (15:11 -0500)]
target/ppc: Remove type argument from mmubooke_check_tlb

We can now use MMU_INST_FETCH from access_type for this.
Unify the I/D code paths, making use of prot_for_access_type.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210518201146.794854-13-richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Remove type argument from mmu40x_get_physical_address
Richard Henderson [Tue, 18 May 2021 20:11:33 +0000 (15:11 -0500)]
target/ppc: Remove type argument from mmu40x_get_physical_address

It is no longer used.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210518201146.794854-12-richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Remove type argument from get_bat_6xx_tlb
Richard Henderson [Tue, 18 May 2021 20:11:32 +0000 (15:11 -0500)]
target/ppc: Remove type argument from get_bat_6xx_tlb

We can now use MMU_INST_FETCH from access_type for this.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210518201146.794854-11-richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Remove type argument from ppc6xx_tlb_check
Richard Henderson [Tue, 18 May 2021 20:11:31 +0000 (15:11 -0500)]
target/ppc: Remove type argument from ppc6xx_tlb_check

We can now use MMU_INST_FETCH from access_type for this.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210518201146.794854-10-richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Remove type argument from ppc6xx_tlb_pte_check
Richard Henderson [Tue, 18 May 2021 20:11:30 +0000 (15:11 -0500)]
target/ppc: Remove type argument from ppc6xx_tlb_pte_check

It is no longer used.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210518201146.794854-9-richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Remove type argument from check_prot
Richard Henderson [Tue, 18 May 2021 20:11:29 +0000 (15:11 -0500)]
target/ppc: Remove type argument from check_prot

We can now use MMU_INST_FETCH from access_type for this.
Use prot_for_access_type to simplify everything.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210518201146.794854-8-richard.henderson@linaro.org>
[dwg: Remove a stray trailing whitespace]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Use MMUAccessType in mmu_helper.c
Richard Henderson [Tue, 18 May 2021 20:11:28 +0000 (15:11 -0500)]
target/ppc: Use MMUAccessType in mmu_helper.c

This replaces 'int rw' with 'MMUAccessType access_type'.
Comparisons vs zero become either MMU_DATA_LOAD or MMU_DATA_STORE,
since we had previously squashed rw to 0 for code access.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210518201146.794854-7-richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Rename access_type to type in mmu_helper.c
Richard Henderson [Tue, 18 May 2021 20:11:27 +0000 (15:11 -0500)]
target/ppc: Rename access_type to type in mmu_helper.c

The variable that holds ACCESS_INT, ACCESS_FLOAT, etc is
variously called 'int type' or 'int access_type' within
this file.  Standardize on 'int type' throughout.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210518201146.794854-6-richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Use MMUAccessType in mmu-hash32.c
Richard Henderson [Tue, 18 May 2021 20:11:26 +0000 (15:11 -0500)]
target/ppc: Use MMUAccessType in mmu-hash32.c

We must leave the 'int rwx' parameter to ppc_hash32_handle_mmu_fault
for now, but will clean that up later.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210518201146.794854-5-richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Use MMUAccessType in mmu-hash64.c
Richard Henderson [Tue, 18 May 2021 20:11:25 +0000 (15:11 -0500)]
target/ppc: Use MMUAccessType in mmu-hash64.c

We must leave the 'int rwx' parameter to ppc_hash64_handle_mmu_fault
for now, but will clean that up later.

Signed-off-by: Ricgard Henderson <richard.henderson@linaro.org>
Message-Id: <20210518201146.794854-4-richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Use MMUAccessType in mmu-radix64.c
Richard Henderson [Tue, 18 May 2021 20:11:24 +0000 (15:11 -0500)]
target/ppc: Use MMUAccessType in mmu-radix64.c

We must leave the 'int rwx' parameter to ppc_radix64_handle_mmu_fault
for now, but will clean that up later.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210518201146.794854-3-richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Introduce prot_for_access_type
Richard Henderson [Tue, 18 May 2021 20:11:23 +0000 (15:11 -0500)]
target/ppc: Introduce prot_for_access_type

Use this in the three places we currently have a local array
indexed by rwx (which happens to have the same values).
The types will match up correctly with additional changes.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210518201146.794854-2-richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Fix load endianness for lxvwsx/lxvdsx
Giuseppe Musacchio [Tue, 18 May 2021 13:30:20 +0000 (15:30 +0200)]
target/ppc: Fix load endianness for lxvwsx/lxvdsx

TARGET_WORDS_BIGENDIAN may not match the machine endianness if that's a
runtime-configurable parameter.

Fixes: bcb0b7b1a1c05707304f80ca6f523d557816f85c
Fixes: afae37d98ae991c0792c867dbd9f32f988044318
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/212

Signed-off-by: Giuseppe Musacchio <thatlemon@gmail.com>
Message-Id: <20210518133020.58927-1-thatlemon@gmail.com>
Tested-by: Paul A. Clarke <pc@us.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Use translator_loop_temp_check
Richard Henderson [Mon, 17 May 2021 20:50:10 +0000 (17:50 -0300)]
target/ppc: Use translator_loop_temp_check

The special logging is unnecessary.  It will have been done
immediately before in the log file.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Reviewed-by: Bruno Larsen (billionai) <bruno.larsen@eldorado.org.br>
Message-Id: <20210517205025.3777947-9-matheus.ferst@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Mark helper_raise_exception* as noreturn
Richard Henderson [Mon, 17 May 2021 20:50:09 +0000 (17:50 -0300)]
target/ppc: Mark helper_raise_exception* as noreturn

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20210517205025.3777947-8-matheus.ferst@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Tidy exception vs exit_tb
Richard Henderson [Mon, 17 May 2021 20:50:08 +0000 (17:50 -0300)]
target/ppc: Tidy exception vs exit_tb

We do not need to emit an exit_tb after an exception,
as the latter will exit via longjmp.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20210517205025.3777947-7-matheus.ferst@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Move single-step check to ppc_tr_tb_stop
Richard Henderson [Mon, 17 May 2021 20:50:07 +0000 (17:50 -0300)]
target/ppc: Move single-step check to ppc_tr_tb_stop

When single-stepping, force max_insns to 1 in init_disas
so that we exit the translation loop immediately.

Combine the single-step checks in tb_stop, and give the
gdb exception priority over the cpu exception, just as
we already do in gen_lookup_and_goto_ptr.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20210517205025.3777947-6-matheus.ferst@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Remove DisasContext.exception
Richard Henderson [Mon, 17 May 2021 20:50:06 +0000 (17:50 -0300)]
target/ppc: Remove DisasContext.exception

Now that we have removed all of the fake exceptions, and all real
exceptions exit via DISAS_NORETURN, we can remove this field.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20210517205025.3777947-5-matheus.ferst@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Replace POWERPC_EXCP_BRANCH with DISAS_NORETURN
Richard Henderson [Mon, 17 May 2021 20:50:05 +0000 (17:50 -0300)]
target/ppc: Replace POWERPC_EXCP_BRANCH with DISAS_NORETURN

The translation of branch instructions always results in exit from
the TB. Remove the synthetic "exception" after no more uses.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20210517205025.3777947-4-matheus.ferst@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Replace POWERPC_EXCP_STOP with DISAS_EXIT_UPDATE
Richard Henderson [Mon, 17 May 2021 20:50:04 +0000 (17:50 -0300)]
target/ppc: Replace POWERPC_EXCP_STOP with DISAS_EXIT_UPDATE

Remove the synthetic "exception" after no more uses.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20210517205025.3777947-3-matheus.ferst@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Introduce gen_icount_io_start
Richard Henderson [Mon, 17 May 2021 20:50:03 +0000 (17:50 -0300)]
target/ppc: Introduce gen_icount_io_start

Create a function to handle the details for interacting with icount.

Force the exit from the tb via DISAS_TOO_MANY, which allows chaining
to the next tb, where the code emitted for gen_tb_start() will
determine if we must exit.  We can thus remove any matching
conditional call to gen_stop_exception.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20210517205025.3777947-2-matheus.ferst@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Remove unnecessary gen_io_end calls
Richard Henderson [Wed, 12 May 2021 18:54:19 +0000 (15:54 -0300)]
target/ppc: Remove unnecessary gen_io_end calls

Since ba3e7926691ed33, we switched the implementation of icount
to always reset can_do_io at the start of the following TB.
Most of them were removed in 9e9b10c64911, but some were missed.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20210512185441.3619828-10-matheus.ferst@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Replace POWERPC_EXCP_SYNC with DISAS_EXIT
Richard Henderson [Wed, 12 May 2021 18:54:18 +0000 (15:54 -0300)]
target/ppc: Replace POWERPC_EXCP_SYNC with DISAS_EXIT

Remove the synthetic "exception" after no more uses.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20210512185441.3619828-9-matheus.ferst@eldorado.org.br>
Reviewed-by: Bruno Larsen (billionai) <bruno.larsen@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Introduce DISAS_{EXIT,CHAIN}{,_UPDATE}
Richard Henderson [Wed, 12 May 2021 18:54:17 +0000 (15:54 -0300)]
target/ppc: Introduce DISAS_{EXIT,CHAIN}{,_UPDATE}

Rewrite ppc_tr_tb_stop to handle these new codes.

Convert ctx->exception into these new codes at the end of
ppc_tr_translate_insn, prior to pushing the change back
throughout translate.c.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20210512185441.3619828-8-matheus.ferst@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Simplify gen_debug_exception
Richard Henderson [Wed, 12 May 2021 18:54:16 +0000 (15:54 -0300)]
target/ppc: Simplify gen_debug_exception

Two of the call sites that use gen_debug_exception have already
updated NIP.  Only ppc_tr_breakpoint_check requires the update.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20210512185441.3619828-7-matheus.ferst@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Remove special case for POWERPC_EXCP_TRAP
Richard Henderson [Wed, 12 May 2021 18:54:15 +0000 (15:54 -0300)]
target/ppc: Remove special case for POWERPC_EXCP_TRAP

Since POWERPC_EXCP_TRAP is raised by gen_exception_err,
we will have also set DISAS_NORETURN.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Luis Pires <luis.pires@eldorado.org.br>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20210512185441.3619828-6-matheus.ferst@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Remove special case for POWERPC_SYSCALL
Richard Henderson [Wed, 12 May 2021 18:54:14 +0000 (15:54 -0300)]
target/ppc: Remove special case for POWERPC_SYSCALL

Since POWERPC_SYSCALL is raised by gen_exception_err,
we will have also set DISAS_NORETURN.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Luis Pires <luis.pires@eldorado.org.br>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20210512185441.3619828-5-matheus.ferst@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Move DISAS_NORETURN setting into gen_exception*
Richard Henderson [Wed, 12 May 2021 18:54:13 +0000 (15:54 -0300)]
target/ppc: Move DISAS_NORETURN setting into gen_exception*

There are other valid settings for is_jmp besides
DISAS_NEXT and DISAS_NORETURN, so eliminating that
dichotomy from ppc_tr_translate_insn is helpful.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Luis Pires <luis.pires@eldorado.org.br>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20210512185441.3619828-4-matheus.ferst@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Split out decode_legacy
Richard Henderson [Wed, 12 May 2021 18:54:12 +0000 (15:54 -0300)]
target/ppc: Split out decode_legacy

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Luis Pires <luis.pires@eldorado.org.br>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20210512185441.3619828-3-matheus.ferst@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Add cia field to DisasContext
Richard Henderson [Wed, 12 May 2021 18:54:11 +0000 (15:54 -0300)]
target/ppc: Add cia field to DisasContext

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Bruno Larsen (billionai) <bruno.larsen@eldorado.org.br>
Reviewed-by: Luis Pires <luis.pires@eldorado.org.br>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20210512185441.3619828-2-matheus.ferst@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: moved ppc_cpu_dump_state to cpu_init.c
Bruno Larsen (billionai) [Wed, 12 May 2021 14:08:05 +0000 (11:08 -0300)]
target/ppc: moved ppc_cpu_dump_state to cpu_init.c

This function was forgotten in the cpu_init code motion series, but it
seems to be used regardless of TCG, and so needs to be moved to support
disabling TCG.

Signed-off-by: Bruno Larsen (billionai) <bruno.larsen@eldorado.org.br>
Message-Id: <20210512140813.112884-4-bruno.larsen@eldorado.org.br>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: moved ppc_store_sdr1 to cpu.c
Bruno Larsen (billionai) [Wed, 12 May 2021 14:08:04 +0000 (11:08 -0300)]
target/ppc: moved ppc_store_sdr1 to cpu.c

Moved this function that is required in !TCG cases into a
common code file

Signed-off-by: Bruno Larsen (billionai) <bruno.larsen@eldorado.org.br>
Message-Id: <20210512140813.112884-3-bruno.larsen@eldorado.org.br>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
[dwg: Fixed compile error with linux-user targets]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: updated vscr manipulation in machine.c
Bruno Larsen (billionai) [Wed, 12 May 2021 14:08:08 +0000 (11:08 -0300)]
target/ppc: updated vscr manipulation in machine.c

Updated the code in machine.c to use the generic ppc_{store,get}_vscr
instead of helper style functions, so it can build without TCG

Signed-off-by: Bruno Larsen (billionai) <bruno.larsen@eldorado.org.br>
Message-Id: <20210512140813.112884-7-bruno.larsen@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: created ppc_{store,get}_vscr for generic vscr usage
Bruno Larsen (billionai) [Wed, 12 May 2021 14:08:03 +0000 (11:08 -0300)]
target/ppc: created ppc_{store,get}_vscr for generic vscr usage

Some functions unrelated to TCG use helper_m{t,f}vscr, so generic versions
of those functions were added to cpu.c, in preparation for compilation
without TCG

Signed-off-by: Bruno Larsen (billionai) <bruno.larsen@eldorado.org.br>
Message-Id: <20210512140813.112884-2-bruno.larsen@eldorado.org.br>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: isolated cpu init from translation logic
Bruno Larsen (billionai) [Fri, 7 May 2021 11:55:51 +0000 (08:55 -0300)]
target/ppc: isolated cpu init from translation logic

finished isolation of CPU initialization logic from
translation logic. CPU initialization now only has common code
and may or may not call accelerator-specific code, as the
build options require.

Signed-off-by: Bruno Larsen (billionai) <bruno.larsen@eldorado.org.br>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Message-Id: <20210507115551.11436-1-bruno.larsen@eldorado.org.br>
[dwg: Fix compile error with clang linux-user builds]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: turned SPR R/W callbacks not static
Bruno Larsen (billionai) [Fri, 7 May 2021 11:55:12 +0000 (08:55 -0300)]
target/ppc: turned SPR R/W callbacks not static

To be able to compile translate_init.c.inc as a standalone file,
we have to make the callbacks accessible outside of translate.c;
This patch does exactly that

Signed-off-by: Bruno Larsen (billionai) <bruno.larsen@eldorado.org.br>
Message-Id: <20210507115512.11376-1-bruno.larsen@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agohw/ppc: moved has_spr to cpu.h
Lucas Mateus Castro (alqotel) [Fri, 7 May 2021 16:41:46 +0000 (13:41 -0300)]
hw/ppc: moved has_spr to cpu.h

Moved has_spr to cpu.h as ppc_has_spr and turned it into an inline function.
Change spr verification in pnv.c and spapr.c to a version that can
compile in a !TCG environment.

Signed-off-by: Lucas Mateus Castro (alqotel) <lucas.araujo@eldorado.org.br>
Message-Id: <20210507164146.67086-1-lucas.araujo@eldorado.org.br>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: moved ppc_store_lpcr to misc_helper.c
Lucas Mateus Castro (alqotel) [Thu, 6 May 2021 16:39:40 +0000 (13:39 -0300)]
target/ppc: moved ppc_store_lpcr to misc_helper.c

Moved the function ppc_store from mmu-hash64.c to misc_helper.c and the
prototype from mmu-hash64.h to cpu.h as it is a more appropriate place,
but it will have to have its implementation moved to a new file as
misc_helper.c should not be compiled in a !TCG environment.

Signed-off-by: Lucas Mateus Castro (alqotel) <lucas.araujo@eldorado.org.br>
Message-Id: <20210506163941.106984-4-lucas.araujo@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: moved function out of mmu-hash64
Lucas Mateus Castro (alqotel) [Thu, 6 May 2021 16:39:39 +0000 (13:39 -0300)]
target/ppc: moved function out of mmu-hash64

The function ppc_hash64_filter_pagesizes has been moved from a function
with prototype in mmu-hash64.h and implemented in mmu-hash64.c to
a static function in hw/ppc/spapr_caps.c as it's only used in that file.

Signed-off-by: Lucas Mateus Castro (alqotel) <lucas.araujo@eldorado.org.br>
Message-Id: <20210506163941.106984-3-lucas.araujo@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agohw/ppc: moved hcalls that depend on softmmu
Lucas Mateus Castro (alqotel) [Thu, 6 May 2021 16:39:38 +0000 (13:39 -0300)]
hw/ppc: moved hcalls that depend on softmmu

The hypercalls h_enter, h_remove, h_bulk_remove, h_protect, and h_read,
have been moved to spapr_softmmu.c with the functions they depend on. The
functions is_ram_address and push_sregs_to_kvm_pr are not static anymore
as functions on both spapr_hcall.c and spapr_softmmu.c depend on them.
The hypercalls h_resize_hpt_prepare and h_resize_hpt_commit have been
divided, the KVM part stayed in spapr_hcall.c while the softmmu part
was moved to spapr_softmmu.c

Signed-off-by: Lucas Mateus Castro (alqotel) <lucas.araujo@eldorado.org.br>
Message-Id: <20210506163941.106984-2-lucas.araujo@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: move SPR R/W callbacks to translate.c
Bruno Larsen (billionai) [Thu, 6 May 2021 19:08:37 +0000 (16:08 -0300)]
target/ppc: move SPR R/W callbacks to translate.c

Moved all read and write callbacks for SPRs away from
translate_init.c.inc and into translate.c; these functions are
TCG only, so this motion is required to enable building with
the flag disable-tcg

Signed-off-by: Bruno Larsen (billionai) <bruno.larsen@eldorado.org.br>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210506190837.6921-1-bruno.larsen@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: renamed SPR registration functions
Bruno Larsen (billionai) [Wed, 5 May 2021 15:53:07 +0000 (12:53 -0300)]
target/ppc: renamed SPR registration functions

Renamed all gen_spr_* and gen_* functions specifically related to
registering SPRs to register_*_sprs and register_*, to avoid future
confusion with other TCG related code.

Signed-off-by: Bruno Larsen (billionai) <bruno.larsen@eldorado.org.br>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210505155310.62710-2-bruno.larsen@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agotarget/ppc: Fold gen_*_xer into their callers
Bruno Larsen (billionai) [Tue, 4 May 2021 14:01:53 +0000 (11:01 -0300)]
target/ppc: Fold gen_*_xer into their callers

folded gen_{read,write}_xer into their only callers, spr_{read,write}_xer

Signed-off-by: Bruno Larsen (billionai) <bruno.larsen@eldorado.org.br>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210504140157.76066-2-bruno.larsen@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>