OSDN Git Service

qmiga/qemu.git
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>
3 years agohw/ppc/spapr.c: Make sure the host supports the selected MMU mode
Fabiano Rosas [Wed, 5 May 2021 00:11:30 +0000 (21:11 -0300)]
hw/ppc/spapr.c: Make sure the host supports the selected MMU mode

Starting with Linux kernel v5.12 we dropped support[1] in KVM for
hosts that can't have their threads running in different MMU modes
(POWER9 < DD2.2). In these hosts, KVM will no longer report the
KVM_CAP_PPC_MMU_HASH_V3 capability[2] when the host is running Radix.

For guests that support both MMU modes, the negotiation during CAS
will make sure it selects the correct one.

For guests that only support Hash, such as P8 compat mode guests, the
following error is currently thrown:

  $ ~/qemu-system-ppc64 -machine pseries,accel=kvm,max-cpu-compat=power8 ...
  error: kvm run failed Invalid argument
  NIP 0000000000000100   LR 0000000000000000 CTR 0000000000000000 XER 0000000000000000 CPU#0
  MSR 8000000000001000 HID0 0000000000000000  HF 8000000000000000 iidx 3 didx 3
  TB 00000000 00000000 DECR 0
  GPR00 0000000000000000 0000000000000000 0000000000000000 000000007ff00000
  GPR04 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR08 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR12 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR16 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR20 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR24 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR28 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  CR 00000000  [ -  -  -  -  -  -  -  -  ]             RES ffffffffffffffff
   SRR0 0000000000000000  SRR1 0000000000000000    PVR 00000000004e1201 VRSAVE 0000000000000000
  SPRG0 0000000000000000 SPRG1 0000000000000000  SPRG2 0000000000000000  SPRG3 0000000000000000
  SPRG4 0000000000000000 SPRG5 0000000000000000  SPRG6 0000000000000000  SPRG7 0000000000000000
  HSRR0 0000000000000000 HSRR1 0000000000000000
   CFAR 0000000000000000
   LPCR 000000000004f01f
   PTCR 0000000000000000   DAR 0000000000000000  DSISR 0000000000000000

This patch adds a verification during the writing of the platform
support vector so that we error out as soon as we determine this guest
only supports Hash and the host doesn't.

  ~/qemu-system-ppc64 -machine pseries,accel=kvm,max-cpu-compat=power8 ...
  qemu-system-ppc64: Guest requested unavailable MMU mode (hash).

1- https://git.kernel.org/torvalds/p/b1b1697ae0cc8
2- https://git.kernel.org/torvalds/p/a722076e94702

Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
Message-Id: <20210505001130.3999968-3-farosas@linux.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
3 years agohw/ppc/spapr.c: Extract MMU mode error reporting into a function
Fabiano Rosas [Wed, 5 May 2021 00:11:29 +0000 (21:11 -0300)]
hw/ppc/spapr.c: Extract MMU mode error reporting into a function

A following patch will make use of it.

Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
Message-Id: <20210505001130.3999968-2-farosas@linux.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
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>
3 years agosoftfloat: Implement float128_add/sub via parts
Richard Henderson [Sat, 24 Oct 2020 02:22:50 +0000 (19:22 -0700)]
softfloat: Implement float128_add/sub via parts

Replace the existing Berkeley implementation with the
FloatParts implementation.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Move addsub_floats to softfloat-parts.c.inc
Richard Henderson [Thu, 22 Oct 2020 22:22:55 +0000 (15:22 -0700)]
softfloat: Move addsub_floats to softfloat-parts.c.inc

In preparation for implementing multiple sizes.  Rename to parts_addsub,
split out parts_add/sub_normal for future reuse with muladd.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Use uadd64_carry, usub64_borrow in softfloat-macros.h
Richard Henderson [Fri, 13 Nov 2020 04:19:08 +0000 (04:19 +0000)]
softfloat: Use uadd64_carry, usub64_borrow in softfloat-macros.h

Use compiler support for carry arithmetic.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Move round_canonical to softfloat-parts.c.inc
Richard Henderson [Sat, 24 Oct 2020 00:53:55 +0000 (17:53 -0700)]
softfloat: Move round_canonical to softfloat-parts.c.inc

At the same time, convert to pointers, renaming to parts$N_uncanon,
and define a macro for parts_uncanon using QEMU_GENERIC.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Move sf_canonicalize to softfloat-parts.c.inc
Richard Henderson [Sun, 8 Nov 2020 21:01:55 +0000 (13:01 -0800)]
softfloat: Move sf_canonicalize to softfloat-parts.c.inc

At the same time, convert to pointers, rename to parts$N_canonicalize
and define a macro for parts_canonicalize using QEMU_GENERIC.

Rearrange the cases to recognize float_class_normal as
early as possible.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Move pick_nan_muladd to softfloat-parts.c.inc
Richard Henderson [Sat, 24 Oct 2020 00:12:12 +0000 (17:12 -0700)]
softfloat: Move pick_nan_muladd to softfloat-parts.c.inc

At the same time, convert to pointers, rename to pick_nan_muladd$N
and define a macro for pick_nan_muladd using QEMU_GENERIC.

Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Move pick_nan to softfloat-parts.c.inc
Richard Henderson [Sat, 24 Oct 2020 00:03:11 +0000 (17:03 -0700)]
softfloat: Move pick_nan to softfloat-parts.c.inc

At the same time, convert to pointers, rename to parts$N_pick_nan
and define a macro for parts_pick_nan using QEMU_GENERIC.

Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Move return_nan to softfloat-parts.c.inc
Richard Henderson [Fri, 23 Oct 2020 23:47:04 +0000 (16:47 -0700)]
softfloat: Move return_nan to softfloat-parts.c.inc

At the same time, convert to pointers, rename to return_nan$N
and define a macro for return_nan using QEMU_GENERIC.

Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Convert float128_default_nan to parts
Richard Henderson [Fri, 23 Oct 2020 23:37:01 +0000 (16:37 -0700)]
softfloat: Convert float128_default_nan to parts

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Convert float128_silence_nan to parts
Richard Henderson [Fri, 23 Oct 2020 23:36:19 +0000 (16:36 -0700)]
softfloat: Convert float128_silence_nan to parts

This is the minimal change that also introduces float128_params,
float128_unpack_raw, and float128_pack_raw without running into
unused symbol Werrors.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Rearrange FloatParts64
Richard Henderson [Thu, 12 Nov 2020 01:36:39 +0000 (17:36 -0800)]
softfloat: Rearrange FloatParts64

Shuffle the fraction to the end, otherwise sort by size.
Add frac_hi and frac_lo members to alias frac.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Use pointers with parts_silence_nan
Richard Henderson [Fri, 23 Oct 2020 23:23:06 +0000 (16:23 -0700)]
softfloat: Use pointers with parts_silence_nan

At the same time, rename to parts64_silence_nan, split out
parts_silence_nan_frac, and define a macro for parts_silence_nan.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Use pointers with ftype_round_pack_canonical
Richard Henderson [Fri, 23 Oct 2020 22:38:52 +0000 (15:38 -0700)]
softfloat: Use pointers with ftype_round_pack_canonical

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Use pointers with ftype_unpack_canonical
Richard Henderson [Fri, 23 Oct 2020 22:32:34 +0000 (15:32 -0700)]
softfloat: Use pointers with ftype_unpack_canonical

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Use pointers with ftype_pack_raw
Richard Henderson [Fri, 23 Oct 2020 22:25:33 +0000 (15:25 -0700)]
softfloat: Use pointers with ftype_pack_raw

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Use pointers with pack_raw
Richard Henderson [Fri, 23 Oct 2020 22:22:08 +0000 (15:22 -0700)]
softfloat: Use pointers with pack_raw

At the same time, rename to pack_raw64.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Use pointers with ftype_unpack_raw
Richard Henderson [Fri, 23 Oct 2020 22:16:14 +0000 (15:16 -0700)]
softfloat: Use pointers with ftype_unpack_raw

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Use pointers with unpack_raw
Richard Henderson [Fri, 23 Oct 2020 21:17:19 +0000 (14:17 -0700)]
softfloat: Use pointers with unpack_raw

At the same time, rename to unpack_raw64.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Use pointers with parts_default_nan
Richard Henderson [Fri, 23 Oct 2020 21:00:33 +0000 (14:00 -0700)]
softfloat: Use pointers with parts_default_nan

At the same time, rename to parts64_default_nan and add a
macro for parts_default_nan.  This will be flushed out once
128-bit support is added.

Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Move type-specific pack/unpack routines
Richard Henderson [Fri, 23 Oct 2020 20:34:19 +0000 (13:34 -0700)]
softfloat: Move type-specific pack/unpack routines

In preparation from moving sf_canonicalize.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Rename FloatParts to FloatParts64
Richard Henderson [Thu, 22 Oct 2020 16:50:03 +0000 (09:50 -0700)]
softfloat: Rename FloatParts to FloatParts64

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Do not produce a default_nan from parts_silence_nan
Richard Henderson [Thu, 22 Oct 2020 16:23:46 +0000 (09:23 -0700)]
softfloat: Do not produce a default_nan from parts_silence_nan

Require default_nan_mode to be set instead.

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 agotarget/mips: Set set_default_nan_mode with set_snan_bit_is_one
Richard Henderson [Thu, 22 Oct 2020 16:17:46 +0000 (09:17 -0700)]
target/mips: Set set_default_nan_mode with set_snan_bit_is_one

This behavior is currently hard-coded in parts_silence_nan,
but setting this bit properly will allow this to be cleaned up.

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: fix return_nan vs default_nan_mode
Richard Henderson [Fri, 20 Nov 2020 01:34:28 +0000 (17:34 -0800)]
softfloat: fix return_nan vs default_nan_mode

Do not call parts_silence_nan when default_nan_mode is in
effect.  This will avoid an assert in a later patch.

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: Use return_nan in float_to_float
Richard Henderson [Thu, 22 Oct 2020 17:48:48 +0000 (10:48 -0700)]
softfloat: Use return_nan in float_to_float

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: Add float_cmask and constants
Richard Henderson [Wed, 23 Sep 2020 22:00:13 +0000 (15:00 -0700)]
softfloat: Add float_cmask and constants

Testing more than one class at a time is better done with masks.
This reduces the static branch count.

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: Tidy a * b + inf return
Richard Henderson [Wed, 23 Sep 2020 21:58:59 +0000 (14:58 -0700)]
softfloat: Tidy a * b + inf return

No reason to set values in 'a', when we already
have float_class_inf in 'c', and can flip that sign.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
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: Use float_raise in more places
Richard Henderson [Thu, 22 Oct 2020 17:45:04 +0000 (10:45 -0700)]
softfloat: Use float_raise in more places

We have been somewhat inconsistent about when to use
float_raise and when to or in the bit by hand.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Inline float_raise
Richard Henderson [Wed, 21 Oct 2020 03:05:57 +0000 (20:05 -0700)]
softfloat: Inline float_raise

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agosoftfloat: Move the binary point to the msb
Richard Henderson [Sat, 7 Nov 2020 19:19:32 +0000 (11:19 -0800)]
softfloat: Move the binary point to the msb

Rather than point the binary point at msb-1, put it at the msb.
Use uadd64_overflow to detect when addition overflows instead
of DECOMPOSED_OVERFLOW_BIT.

This reduces the number of special cases within the code, such
as shifting an int64_t either left or right during conversion.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agotests/fp: add quad support to the benchmark utility
Alex Bennée [Tue, 20 Oct 2020 16:37:37 +0000 (17:37 +0100)]
tests/fp: add quad support to the benchmark utility

Currently this only support softfloat calculations because working out
if the hardware supports 128 bit floats needs configure magic. The 3
op muladd operation is currently unimplemented so commented out for
now.

Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20201020163738.27700-8-alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agoaccel/tcg: Use add/sub overflow routines in tcg-runtime-gvec.c
Richard Henderson [Sat, 7 Nov 2020 02:51:27 +0000 (18:51 -0800)]
accel/tcg: Use add/sub overflow routines in tcg-runtime-gvec.c

Obvious uses of the new functions.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
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 agoqemu/host-utils: Add wrappers for carry builtins
Richard Henderson [Fri, 13 Nov 2020 03:22:23 +0000 (03:22 +0000)]
qemu/host-utils: Add wrappers for carry builtins

These builtins came in clang 3.8, but are not present in gcc through
version 11.  Even in clang the optimization is only ideal on x86_64,
but never worse than the hand-coding that we currently do.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3 years agoqemu/host-utils: Add wrappers for overflow builtins
Richard Henderson [Sat, 7 Nov 2020 01:42:36 +0000 (17:42 -0800)]
qemu/host-utils: Add wrappers for overflow builtins

These builtins came in with gcc 5 and clang 3.8, which are
slightly newer than our supported minimum compiler versions.

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