]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
14 months agolinux-user: Add translation for argument of msync()
Helge Deller [Thu, 15 Dec 2022 07:27:46 +0000 (08:27 +0100)]
linux-user: Add translation for argument of msync()

msync() uses the flags MS_ASYNC, MS_INVALIDATE and MS_SYNC, which differ
between platforms, specifcally on alpha and hppa.

Add a target to host translation for those and wire up a nicer strace
output.

This fixes the testsuite of the macaulay2 debian package with a hppa-linux
guest on a x86-64 host.

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <Y5rMcts4qe15RaVN@p100>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
14 months agolinux-user: handle netlink flag NLA_F_NESTED
Mathis Marion [Tue, 7 Mar 2023 15:42:56 +0000 (16:42 +0100)]
linux-user: handle netlink flag NLA_F_NESTED

Newer kernel versions require this flag to be present contrary to older
ones. Depending on the libnl version it is added or not.

Typically when using rtnl_link_inet6_set_addr_gen_mode, the netlink
packet generated may contain the following attribute:

with libnl 3.4

  {nla_len=16, nla_type=IFLA_AF_SPEC},
  [
    {nla_len=12, nla_type=AF_INET6},
    [{nla_len=5, nla_type=IFLA_INET6_ADDR_GEN_MODE}, IN6_ADDR_GEN_MODE_NONE]
  ]

with libnl 3.7

  {nla_len=16, nla_type=NLA_F_NESTED|IFLA_AF_SPEC},
  [
    {nla_len=12, nla_type=NLA_F_NESTED|AF_INET6},
    [{nla_len=5, nla_type=IFLA_INET6_ADDR_GEN_MODE}, IN6_ADDR_GEN_MODE_NONE]]
  ]

Masking the type is likely needed in other places. Only the above cases
are implemented in this patch.

Signed-off-by: Mathis Marion <mathis.marion@silabs.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20230307154256.101528-3-Mathis.Marion@silabs.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
14 months agolinux-user: fix sockaddr_in6 endianness
Mathis Marion [Tue, 7 Mar 2023 15:42:55 +0000 (16:42 +0100)]
linux-user: fix sockaddr_in6 endianness

The sin6_scope_id field uses the host byte order, so there is a
conversion to be made when host and target endianness differ.

Signed-off-by: Mathis Marion <mathis.marion@silabs.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230307154256.101528-2-Mathis.Marion@silabs.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
14 months agolinux-user: Add strace for prlimit64() syscall
Helge Deller [Thu, 22 Dec 2022 19:06:39 +0000 (20:06 +0100)]
linux-user: Add strace for prlimit64() syscall

Add proper prlimit64() strace output.

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20221222190639.124078-1-deller@gmx.de>
[lvivier: use print_raw_param64()]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
14 months agolinux-user: Provide print_raw_param64() for 64-bit values
Helge Deller [Tue, 31 Jan 2023 17:18:36 +0000 (18:18 +0100)]
linux-user: Provide print_raw_param64() for 64-bit values

Add a new function print_raw_param64() to print 64-bit values in the
same way as print_raw_param(). This prevents that qemu_log() is used to
work around the problem that print_raw_param() can only print 32-bit
values when compiled for 32-bit targets.

Additionally convert the existing 64-bit users in print_timespec64(),
print_rlimit64() and print_preadwrite64() over to this new function and
drop some unneccessary spaces.

Suggested-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <Y9lNbFNyRSUhhrHa@p100>
[lvivier: remove print_preadwrite64 and print_rlimit64 part]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
14 months agolinux-user: Fix brk() to release pages
Helge Deller [Sun, 25 Dec 2022 08:23:19 +0000 (09:23 +0100)]
linux-user: Fix brk() to release pages

The current brk() implementation does not de-allocate pages if a lower
address is given compared to earlier brk() calls.
But according to the manpage, brk() shall deallocate memory in this case
and currently it breaks a real-world application, specifically building
the debian gcl package in qemu-user.

Fix this issue by reworking the qemu brk() implementation.

Tested with the C-code testcase included in qemu commit 4d1de87c750, and
by building debian package of gcl in a hppa-linux guest on a x86-64
host.

Signed-off-by: Helge Deller <deller@gmx.de>
Message-Id: <Y6gId80ek49TK1xB@p100>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
14 months agolinux-user: fill out task state in /proc/self/stat
Andreas Schwab [Mon, 6 Mar 2023 09:59:29 +0000 (10:59 +0100)]
linux-user: fill out task state in /proc/self/stat

Some programs want to match an actual task state character.

Signed-off-by: Andreas Schwab <schwab@suse.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <mvmedq2kxoe.fsf@suse.de>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
14 months agolinux-user: add support for xtensa FDPIC
Max Filippov [Sun, 5 Feb 2023 06:12:30 +0000 (22:12 -0800)]
linux-user: add support for xtensa FDPIC

Define xtensa-specific info_is_fdpic and fill in FDPIC-specific
registers in the xtensa version of init_thread.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Message-Id: <20230205061230.544451-1-jcmvbkbc@gmail.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
14 months agolinux-user: Fix unaligned memory access in prlimit64 syscall
Ilya Leoshkevich [Fri, 24 Feb 2023 00:39:06 +0000 (01:39 +0100)]
linux-user: Fix unaligned memory access in prlimit64 syscall

target_rlimit64 contains uint64_t fields, so it's 8-byte aligned on
some hosts, while some guests may align their respective type on a
4-byte boundary. This may lead to an unaligned access, which is an UB.

Fix by defining the fields as abi_ullong. This makes the host alignment
match that of the guest, and lets the compiler know that it should emit
code that can deal with the guest alignment.

While at it, also use __get_user() and __put_user() instead of
tswap64().

Fixes: 163a05a8398b ("linux-user: Implement prlimit64 syscall")
Reported-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20230224003907.263914-2-iii@linux.ibm.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
14 months agolinux-user: add target to host netlink conversions
Mathis Marion [Mon, 20 Feb 2023 08:58:21 +0000 (09:58 +0100)]
linux-user: add target to host netlink conversions

Added conversions for:
- IFLA_MTU
- IFLA_TXQLEN
- IFLA_AF_SPEC AF_INET6 IFLA_INET6_ADDR_GEN_MODE
These relate to the libnl functions rtnl_link_set_mtu,
rtnl_link_set_txqlen, and rtnl_link_inet6_set_addr_gen_mode.

Signed-off-by: Mathis Marion <mathis.marion@silabs.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20230220085822.626798-4-Mathis.Marion@silabs.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
14 months agolinux-user: fix timerfd read endianness conversion
Mathis Marion [Mon, 20 Feb 2023 08:58:19 +0000 (09:58 +0100)]
linux-user: fix timerfd read endianness conversion

When reading the expiration count from a timerfd, the endianness of the
64bit value read is the one of the host, just as for eventfds.

Signed-off-by: Mathis Marion <mathis.marion@silabs.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20230220085822.626798-2-Mathis.Marion@silabs.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
14 months agolinux-user: Fix access to /proc/self/exe
Helge Deller [Mon, 5 Dec 2022 11:38:25 +0000 (12:38 +0100)]
linux-user: Fix access to /proc/self/exe

When accsssing /proc/self/exe from a userspace program, linux-user tries
to resolve the name via realpath(), which may fail if the process
changed the working directory in the meantime.

An example:
- a userspace program ist started with ./testprogram
- the program runs chdir("/tmp")
- then the program calls readlink("/proc/self/exe")
- linux-user tries to run realpath("./testprogram") which fails
  because ./testprogram isn't in /tmp
- readlink() will return -ENOENT back to the program

Avoid this issue by resolving the full path name of the started process
at startup of linux-user and store it in real_exec_path[]. This then
simplifies the emulation of readlink() and readlinkat() as well, because
they can simply copy the path string to userspace.

I noticed this bug because the testsuite of the debian package "pandoc"
failed on linux-user while it succeeded on real hardware.  The full log
is here:
https://buildd.debian.org/status/fetch.php?pkg=pandoc&arch=hppa&ver=2.17.1.1-1.1%2Bb1&stamp=1670153210&raw=0

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20221205113825.20615-1-deller@gmx.de>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
14 months agoMerge tag 'audio-pull-request' of https://gitlab.com/marcandre.lureau/qemu into staging
Peter Maydell [Mon, 6 Mar 2023 14:06:06 +0000 (14:06 +0000)]
Merge tag 'audio-pull-request' of https://gitlab.com/marcandre.lureau/qemu into staging

Audio patches for QEMU 8.0

Cleanups and improvements from Volker Rümelin.

# -----BEGIN PGP SIGNATURE-----
#
# iQJQBAABCAA6FiEEh6m9kz+HxgbSdvYt2ujhCXWWnOUFAmQFjUccHG1hcmNhbmRy
# ZS5sdXJlYXVAcmVkaGF0LmNvbQAKCRDa6OEJdZac5ZLMD/sFWmVYccRqvOfOJvuC
# dJ7EtABmC6b4MxLkMyP5WLMoCezSha0vgcYwAL3oZX1dIBoGfaUXXdxIM8IK8rAv
# J2Fe2p9D+6tqzqc8jkbx0DmY040A3Gb18P60jL3NeQfmqCt7KmzuQoCMn6htPyyy
# NMgSRG3wy+esglmeU2majhxQZh2Vmwsi6i37A5Fg8b27oWLYHxeS6Lgp3PNAwJsA
# k/RKJeZDMjDh0f0wSHZN+8w0VVFQa3BjqoNV4UAgqSjsPaRlnQxppG2FEXNNrtLb
# bJ4rbXgSO68wrcweHgC2L7qWhLnYwdcdQFAPotmt2V1jtH4xx6f+ovwCdf0vZ5Fo
# YhHixpP41gFvF7sJWSZO0wUFKXTyLSdWIPaUKP9iMTZfXpBxo5H6rkPsZ6v5yyG2
# tLFlL0Rv/h3liEkngmRbw81gB9te92ZGXOjkB2Q69tGQl/tXRkhrn5VT2mufb7BV
# WUsdtSFl6P231lDuzQkFp85PkoRtr8eDPkkZW8/xgRx5h8j5I2bc6LRMd63w2tE6
# TGdUfiaqH396r1T87ynBdBWSc4H6YuImTouy27rAv/50x8w4cgk66wY+UGB7D8FX
# Eg4rU5Dzco2D+1RY50zSqZgPxIWjnC4xtYQXLaJURe0Way1HQqt/Pvp/aVFKUOef
# snYV1FLDvHg2Cf9LCGqvpW8b/w==
# =d4LY
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 06 Mar 2023 06:50:47 GMT
# gpg:                using RSA key 87A9BD933F87C606D276F62DDAE8E10975969CE5
# gpg:                issuer "marcandre.lureau@redhat.com"
# gpg: Good signature from "Marc-André Lureau <marcandre.lureau@redhat.com>" [full]
# gpg:                 aka "Marc-André Lureau <marcandre.lureau@gmail.com>" [full]
# Primary key fingerprint: 87A9 BD93 3F87 C606 D276  F62D DAE8 E109 7596 9CE5

* tag 'audio-pull-request' of https://gitlab.com/marcandre.lureau/qemu: (27 commits)
  audio: remove sw->ratio
  audio/audio_template: substitute sw->hw with hw
  audio: handle leftover audio frame from upsampling
  audio: make recording packet length calculation exact
  audio: rename variables in audio_pcm_sw_read()
  audio: replace the resampling loop in audio_pcm_sw_read()
  audio: make playback packet length calculation exact
  audio: remove unused noop_conv() function
  audio: don't misuse audio_pcm_sw_write()
  audio: rename variables in audio_pcm_sw_write()
  audio: remove sw == NULL check
  audio: replace the resampling loop in audio_pcm_sw_write()
  audio: make the resampling code greedy
  audio: change type and name of the resample buffer
  audio: change type of mix_buf and conv_buf
  alsaaudio: reintroduce default recording settings
  alsaaudio: change default playback settings
  audio: remove audio_calloc() function
  audio/audio_template: use g_new0() to replace audio_calloc()
  audio/audio_template: use g_malloc0() to replace audio_calloc()
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14 months agoMerge tag 'pull-tcg-20230305' of https://gitlab.com/rth7680/qemu into staging
Peter Maydell [Mon, 6 Mar 2023 10:20:04 +0000 (10:20 +0000)]
Merge tag 'pull-tcg-20230305' of https://gitlab.com/rth7680/qemu into staging

tcg: Merge two sequential labels
accel/tcg: Retain prot flags from tlb_fill
accel/tcg: Honor TLB_DISCARD_WRITE in atomic_mmu_lookup
accel/tcg: Honor TLB_WATCHPOINTS in atomic_mmu_lookup
target/sparc: Use tlb_set_page_full
include/qemu/cpuid: Introduce xgetbv_low
tcg/i386: Mark Win64 call-saved vector regs as reserved
tcg: Decode the operand to INDEX_op_mb in dumps

Portion of the target/ patchset which eliminates use of tcg_temp_free*
Portion of the target/ patchset which eliminates use of tcg_const*

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmQFNegdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV9WsQf+Ljs3WA5lvMPlpaSn
# Li35ay/A1f2cU6FYspl81su4/c7Ft9Q8rkPF4K1n1rwuvqR91G25WTQIrw8NFPXZ
# VU9GNGQc1qIVYO/hAH3fvgDmPxUF+tJDgT/BTNc1ldy6/v7QM3GWcEy8+O3H9S+K
# uj6vIuWke0ukq6ZGmSAZnXEaJFq3HU26mcP4KxDxfIUcezMtDVp6QevqzVxM65aa
# pUDh3qtsLGOxIYwthvu6avMQXORBhSB75awCuYH4QPJRpr3ahigcGsCr2gdVAQ8p
# R7BbpUUdK5Huos971oouJrt5FwwbVgGEx78eF27sl0H8QMoNhsfyn6PcN8nPENLJ
# MZYd+w==
# =8goQ
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 06 Mar 2023 00:38:00 GMT
# 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

* tag 'pull-tcg-20230305' of https://gitlab.com/rth7680/qemu: (84 commits)
  target/xtensa: Avoid tcg_const_i32
  target/xtensa: Split constant in bit shift
  target/xtensa: Use tcg_gen_subfi_i32 in translate_sll
  target/xtensa: Avoid tcg_const_i32 in translate_l32r
  target/xtensa: Tidy translate_clamps
  target/xtensa: Tidy translate_bb
  target/sparc: Avoid tcg_const_{tl,i32}
  target/s390x: Split out gen_ri2
  target/riscv: Avoid tcg_const_*
  target/microblaze: Avoid tcg_const_* throughout
  target/i386: Simplify POPF
  target/hexagon/idef-parser: Use gen_constant for gen_extend_tcg_width_op
  target/hexagon/idef-parser: Use gen_tmp for gen_rvalue_pred
  target/hexagon/idef-parser: Use gen_tmp for gen_pred_assign
  target/hexagon/idef-parser: Use gen_tmp for LPCFG
  target/hexagon: Use tcg_constant_* for gen_constant_from_imm
  docs/devel/tcg-ops: Drop recommendation to free temps
  tracing: remove transform.py
  include/exec/gen-icount: Drop tcg_temp_free in gen_tb_start
  target/tricore: Drop tcg_temp_free
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14 months agoaudio: remove sw->ratio
Volker Rümelin [Fri, 24 Feb 2023 19:05:55 +0000 (20:05 +0100)]
audio: remove sw->ratio

Simplify the resample buffer size calculation.

For audio playback we have
sw->ratio = ((int64_t)sw->hw->info.freq << 32) / sw->info.freq;
samples = ((int64_t)sw->HWBUF.size << 32) / sw->ratio;

This can be simplified to
samples = muldiv64(sw->HWBUF.size, sw->info.freq, sw->hw->info.freq);

For audio recording we have
sw->ratio = ((int64_t)sw->info.freq << 32) / sw->hw->info.freq;
samples = (int64_t)sw->HWBUF.size * sw->ratio >> 32;

This can be simplified to
samples = muldiv64(sw->HWBUF.size, sw->info.freq, sw->hw->info.freq);

With hw = sw->hw this becomes in both cases
samples = muldiv64(HWBUF.size, sw->info.freq, hw->info.freq);

Now that sw->ratio is no longer needed, remove sw->ratio.

Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20230224190555.7409-15-vr_qemu@t-online.de>

14 months agoaudio/audio_template: substitute sw->hw with hw
Volker Rümelin [Fri, 24 Feb 2023 19:05:54 +0000 (20:05 +0100)]
audio/audio_template: substitute sw->hw with hw

Substitute sw->hw with hw in the audio_pcm_sw_alloc_resources_*
functions.

Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20230224190555.7409-14-vr_qemu@t-online.de>

14 months agoaudio: handle leftover audio frame from upsampling
Volker Rümelin [Fri, 24 Feb 2023 19:05:53 +0000 (20:05 +0100)]
audio: handle leftover audio frame from upsampling

Upsampling may leave one remaining audio frame in the input
buffer. The emulated audio playback devices are currently
resposible to write this audio frame again in the next write
cycle. Push that task down to audio_pcm_sw_write.

This is another step towards an audio callback interface that
guarantees that when audio frontends are told they can write
n audio frames, they can actually do so.

Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20230224190555.7409-13-vr_qemu@t-online.de>

14 months agoaudio: make recording packet length calculation exact
Volker Rümelin [Fri, 24 Feb 2023 19:05:52 +0000 (20:05 +0100)]
audio: make recording packet length calculation exact

Introduce the new function st_rate_frames_out() to calculate the
exact number of audio output frames the resampling code can
generate from a given number of audio input frames. When upsampling,
this function returns the maximum number of output frames.

This new function replaces the audio_frontend_frames_in()
function, which calculated the average number of output frames
rounded down to the nearest integer. The audio_frontend_frames_in()
function was additionally used to limit the number of output frames
to the resample buffer size. In audio_pcm_sw_read() the variable
resample_buf.size replaces the open coded audio_frontend_frames_in()
function. In audio_run_in() an additional MIN() function is
necessary.

After this patch the audio packet length calculation for audio
recording is exact.

Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20230224190555.7409-12-vr_qemu@t-online.de>

14 months agoaudio: rename variables in audio_pcm_sw_read()
Volker Rümelin [Fri, 24 Feb 2023 19:05:51 +0000 (20:05 +0100)]
audio: rename variables in audio_pcm_sw_read()

The audio_pcm_sw_read() function uses a few very unspecific
variable names. Rename them for better readability.

ret => total_out
total => total_in
size => buf_len
samples => frames_out_max

Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20230224190555.7409-11-vr_qemu@t-online.de>

14 months agoaudio: replace the resampling loop in audio_pcm_sw_read()
Volker Rümelin [Fri, 24 Feb 2023 19:05:50 +0000 (20:05 +0100)]
audio: replace the resampling loop in audio_pcm_sw_read()

Replace the resampling loop in audio_pcm_sw_read() with the new
function audio_pcm_sw_resample_in(). Unlike the old resample
loop the new function will try to consume input frames even if
the output buffer is full. This is necessary when downsampling
to avoid reading less audio frames than calculated in advance.
The loop was unrolled to avoid complicated loop control conditions
in this case.

Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20230224190555.7409-10-vr_qemu@t-online.de>

14 months agoaudio: make playback packet length calculation exact
Volker Rümelin [Fri, 24 Feb 2023 19:05:49 +0000 (20:05 +0100)]
audio: make playback packet length calculation exact

Introduce the new function st_rate_frames_in() to calculate the
exact number of audio input frames needed to get a given number
of audio output frames. The exact number of frames depends only
on the difference of opos - ipos and the number of output frames.
When downsampling, this function returns the maximum number of
input frames needed.

This new function replaces the audio_frontend_frames_out() function,
which calculated the average number of input frames rounded down
to the nearest integer. Because audio_frontend_frames_out() also
limited the number of input frames to the size of the resample
buffer, st_rate_frames_in() is not a direct replacement and two
additional MIN() functions are needed. One to prevent resample
buffer overflows and one to limit the available bytes for the audio
frontends.

After this patch the audio packet length calculation for playback is
exact. When upsampling, it's still possible that the audio frontends
can't write the last audio frame. This will be fixed later.

Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20230224190555.7409-9-vr_qemu@t-online.de>

14 months agoaudio: remove unused noop_conv() function
Volker Rümelin [Fri, 24 Feb 2023 19:05:48 +0000 (20:05 +0100)]
audio: remove unused noop_conv() function

The function audio_capture_mix_and_clear() no longer uses
audio_pcm_sw_write() to resample audio frames from one internal
buffer to another. For this reason, the noop_conv() function is
now unused. Remove it.

Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20230224190555.7409-8-vr_qemu@t-online.de>

14 months agoaudio: don't misuse audio_pcm_sw_write()
Volker Rümelin [Fri, 24 Feb 2023 19:05:47 +0000 (20:05 +0100)]
audio: don't misuse audio_pcm_sw_write()

The audio_pcm_sw_write() function is intended to convert a
PCM audio stream to the internal representation, adjust the
volume, and then mix it with the other audio streams with a
possibly changed sample rate in mix_buf. In order for the
audio_capture_mix_and_clear() function to use audio_pcm_sw_write(),
it must bypass the first two tasks of audio_pcm_sw_write().

Since patch "audio: split out the resampling loop in
audio_pcm_sw_write()" this is no longer necessary, because now
the audio_pcm_sw_resample_out() function can be used instead of
audio_pcm_sw_write().

Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20230224190555.7409-7-vr_qemu@t-online.de>

14 months agoaudio: rename variables in audio_pcm_sw_write()
Volker Rümelin [Fri, 24 Feb 2023 19:05:46 +0000 (20:05 +0100)]
audio: rename variables in audio_pcm_sw_write()

The audio_pcm_sw_write() function uses a lot of very unspecific
variable names. Rename them for better readability.

ret => total_in
total => total_out
size => buf_len
hwsamples => hw->mix_buf.size
samples => frames_in_max

Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20230224190555.7409-6-vr_qemu@t-online.de>

14 months agoaudio: remove sw == NULL check
Volker Rümelin [Fri, 24 Feb 2023 19:05:45 +0000 (20:05 +0100)]
audio: remove sw == NULL check

All call sites of audio_pcm_sw_write() guarantee that sw is not
NULL. Remove the unnecessary NULL check.

Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20230224190555.7409-5-vr_qemu@t-online.de>

14 months agoaudio: replace the resampling loop in audio_pcm_sw_write()
Volker Rümelin [Fri, 24 Feb 2023 19:05:44 +0000 (20:05 +0100)]
audio: replace the resampling loop in audio_pcm_sw_write()

Replace the resampling loop in audio_pcm_sw_write() with the new
function audio_pcm_sw_resample_out(). Unlike the old resample
loop the new function will try to consume input frames even if
the output buffer is full. This is necessary when downsampling
to avoid reading less audio frames than calculated in advance.
The loop was unrolled to avoid complicated loop control conditions
in this case.

Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20230224190555.7409-4-vr_qemu@t-online.de>

14 months agoaudio: make the resampling code greedy
Volker Rümelin [Fri, 24 Feb 2023 19:05:43 +0000 (20:05 +0100)]
audio: make the resampling code greedy

Read the maximum possible number of audio frames instead of the
minimum necessary number of frames when the audio stream is
downsampled and the output buffer is limited. This makes the
function symmetrical to upsampling when the input buffer is
limited. The maximum possible number of frames is written here.

With this change it's easier to calculate the exact number of
audio frames the resample function will read or write. These two
functions will be introduced later.

Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20230224190555.7409-3-vr_qemu@t-online.de>

14 months agoaudio: change type and name of the resample buffer
Volker Rümelin [Fri, 24 Feb 2023 19:05:42 +0000 (20:05 +0100)]
audio: change type and name of the resample buffer

Change the type of the resample buffer from struct st_sample *
to STSampleBuffer. Also change the name from buf to resample_buf
for better readability.

The new variables resample_buf.size and resample_buf.pos will be
used after the next patches. There is no functional change.

Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20230224190555.7409-2-vr_qemu@t-online.de>

14 months agoaudio: change type of mix_buf and conv_buf
Volker Rümelin [Fri, 24 Feb 2023 19:05:41 +0000 (20:05 +0100)]
audio: change type of mix_buf and conv_buf

Change the type of mix_buf in struct HWVoiceOut and conv_buf
in struct HWVoiceIn from STSampleBuffer * to STSampleBuffer.
However, a buffer pointer is still needed. For this reason in
struct STSampleBuffer samples[] is changed to *buffer.

This is a preparation for the next patch. The next patch will
add this line, which is not possible with the current struct
STSampleBuffer definition.

+        sw->resample_buf.buffer = hw->mix_buf.buffer + rpos2;

There are no functional changes.

Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20230224190555.7409-1-vr_qemu@t-online.de>

14 months agoalsaaudio: reintroduce default recording settings
Volker Rümelin [Sat, 21 Jan 2023 09:47:35 +0000 (10:47 +0100)]
alsaaudio: reintroduce default recording settings

Audio recording with ALSA default settings currently doesn't
work. The debug log shows updates every 0.75s and 1.5s.

audio: Elapsed since last alsa run (running): 0.743030
audio: Elapsed since last alsa run (running): 1.486048
audio: Elapsed since last alsa run (running): 0.743008
audio: Elapsed since last alsa run (running): 1.485878
audio: Elapsed since last alsa run (running): 1.486040
audio: Elapsed since last alsa run (running): 1.485886

The time between updates should be in the 10ms range. Audio
recording with ALSA has the same timing contraints as playback.
Reintroduce the default recording settings and use the same
default settings for recording as for playback.

The term "reintroduce" is correct because commit a93f328177
("alsaaudio: port to -audiodev config") removed the default
settings for recording.

Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20230121094735.11644-11-vr_qemu@t-online.de>

14 months agoalsaaudio: change default playback settings
Volker Rümelin [Sat, 21 Jan 2023 09:47:34 +0000 (10:47 +0100)]
alsaaudio: change default playback settings

The currently used default playback settings in the ALSA audio
backend are a bit unfortunate. With a few emulated audio devices,
audio playback does not work properly. Here is a short part of
the debug log while audio is playing (elapsed time in seconds).

audio: Elapsed since last alsa run (running): 0.046244
audio: Elapsed since last alsa run (running): 0.023137
audio: Elapsed since last alsa run (running): 0.023170
audio: Elapsed since last alsa run (running): 0.023650
audio: Elapsed since last alsa run (running): 0.060802
audio: Elapsed since last alsa run (running): 0.031931

For some audio devices the time of more than 23ms between updates
is too long.

Set the period time to 5.8ms so that the maximum time between
two updates typically does not exceed 11ms. This roughly matches
the 10ms period time when doing playback with the audio timer.
After this patch the debug log looks like this.

audio: Elapsed since last alsa run (running): 0.011919
audio: Elapsed since last alsa run (running): 0.005788
audio: Elapsed since last alsa run (running): 0.005995
audio: Elapsed since last alsa run (running): 0.011069
audio: Elapsed since last alsa run (running): 0.005901
audio: Elapsed since last alsa run (running): 0.006084

Acked-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20230121094735.11644-10-vr_qemu@t-online.de>

14 months agoaudio: remove audio_calloc() function
Volker Rümelin [Sat, 21 Jan 2023 09:47:33 +0000 (10:47 +0100)]
audio: remove audio_calloc() function

Now that the last call site of audio_calloc() was removed, remove
the unused audio_calloc() function.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20230121094735.11644-9-vr_qemu@t-online.de>

14 months agoaudio/audio_template: use g_new0() to replace audio_calloc()
Volker Rümelin [Sat, 21 Jan 2023 09:47:32 +0000 (10:47 +0100)]
audio/audio_template: use g_new0() to replace audio_calloc()

Replace audio_calloc() with the equivalent g_new0().

With a n_structs argument >= 1, g_new0() never returns NULL.
Also remove the unnecessary NULL checks.

Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20230121094735.11644-8-vr_qemu@t-online.de>

14 months agoaudio/audio_template: use g_malloc0() to replace audio_calloc()
Volker Rümelin [Sat, 21 Jan 2023 09:47:31 +0000 (10:47 +0100)]
audio/audio_template: use g_malloc0() to replace audio_calloc()

Use g_malloc0() as a direct replacement for audio_calloc().

Since the type of the parameter n_bytes of the function g_malloc0()
is unsigned, the type of the variables voice_size_out and
voice_size_in has been changed to size_t. This means that the
function argument no longer has to be checked for negative values.

Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20230121094735.11644-7-vr_qemu@t-online.de>

14 months agoaudio/alsaaudio: use g_new0() instead of audio_calloc()
Volker Rümelin [Sat, 21 Jan 2023 09:47:30 +0000 (10:47 +0100)]
audio/alsaaudio: use g_new0() instead of audio_calloc()

Replace audio_calloc() with the equivalent g_new0().

The value of the g_new0() argument count is >= 1, which means
g_new0() will never return NULL. Also remove the unnecessary
NULL check.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20230121094735.11644-6-vr_qemu@t-online.de>

14 months agoaudio/mixeng: use g_new0() instead of audio_calloc()
Volker Rümelin [Sat, 21 Jan 2023 09:47:29 +0000 (10:47 +0100)]
audio/mixeng: use g_new0() instead of audio_calloc()

Replace audio_calloc() with the equivalent g_new0().

With a n_structs argument of 1, g_new0() never returns NULL.
Also remove the unnecessary NULL checks.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20230121094735.11644-5-vr_qemu@t-online.de>

14 months agoaudio: remove unused #define AUDIO_STRINGIFY
Volker Rümelin [Sat, 21 Jan 2023 09:47:28 +0000 (10:47 +0100)]
audio: remove unused #define AUDIO_STRINGIFY

Remove the unused #define AUDIO_STRINGIFY. It was last used before
commit 470bcabd8f ("audio: Replace AUDIO_FUNC with __func__").

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20230121094735.11644-4-vr_qemu@t-online.de>

14 months agoaudio: rename hardware store to backend
Volker Rümelin [Sat, 21 Jan 2023 09:47:27 +0000 (10:47 +0100)]
audio: rename hardware store to backend

Use a consistent friendly name for the HWVoiceOut and HWVoiceIn
structures.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230121094735.11644-3-vr_qemu@t-online.de>

14 months agoaudio: don't show unnecessary error messages
Volker Rümelin [Sat, 21 Jan 2023 09:47:26 +0000 (10:47 +0100)]
audio: don't show unnecessary error messages

Let the audio_pcm_create_voice_pair_* functions handle error
reporting. This avoids an additional error message in case
the guest selected an unimplemented sample rate.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20230121094735.11644-2-vr_qemu@t-online.de>

14 months agoaudio: log unimplemented audio device sample rates
Volker Rümelin [Sat, 21 Jan 2023 09:47:25 +0000 (10:47 +0100)]
audio: log unimplemented audio device sample rates

Some emulated audio devices allow guests to select very low
sample rates that the audio subsystem doesn't support. The lowest
supported sample rate depends on the audio backend used and in
most cases can be changed with various -audiodev arguments. Until
now, the audio_bug function emits an error message similar to the
following error message

A bug was just triggered in audio_calloc
Save all your work and restart without audio
I am sorry
Context:
audio_pcm_sw_alloc_resources_out passed invalid arguments to
 audio_calloc
nmemb=0 size=16 (len=0)
audio: Could not allocate buffer for `ac97.po' (0 samples)

and the audio subsystem continues without sound for the affected
device.

The fact that the selected sample rate is not supported is not a
guest error. Instead of displaying an error message, the missing
audio support is now logged. Simply continuing without sound is
correct, since the audio stream won't transport anything
reasonable at such high resample ratios anyway.

The AUD_open_* functions return NULL like before. The opened
audio device will not be registered in the audio subsystem and
consequently the audio frontend callback functions will not be
called. The AUD_read and AUD_write functions return early in this
case. This is necessary because, for example, the Sound Blaster 16
emulation calls AUD_write from the DMA callback function.

Acked-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20230121094735.11644-1-vr_qemu@t-online.de>

14 months agoMAINTAINERS: add myself to ui/ and audio/
Marc-André Lureau [Tue, 7 Feb 2023 08:56:10 +0000 (12:56 +0400)]
MAINTAINERS: add myself to ui/ and audio/

Helping out with patch review & queue handling.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230207085610.1033536-1-marcandre.lureau@redhat.com>

14 months agotarget/xtensa: Avoid tcg_const_i32
Richard Henderson [Sun, 26 Feb 2023 23:21:36 +0000 (13:21 -1000)]
target/xtensa: Avoid tcg_const_i32

All remaining uses are strictly read-only.

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/xtensa: Split constant in bit shift
Richard Henderson [Sun, 26 Feb 2023 23:21:14 +0000 (13:21 -1000)]
target/xtensa: Split constant in bit shift

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/xtensa: Use tcg_gen_subfi_i32 in translate_sll
Richard Henderson [Sun, 26 Feb 2023 23:19:46 +0000 (13:19 -1000)]
target/xtensa: Use tcg_gen_subfi_i32 in translate_sll

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/xtensa: Avoid tcg_const_i32 in translate_l32r
Richard Henderson [Sun, 26 Feb 2023 23:19:01 +0000 (13:19 -1000)]
target/xtensa: Avoid tcg_const_i32 in translate_l32r

Use addi on the addition side and tcg_constant_i32 on the other.

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/xtensa: Tidy translate_clamps
Richard Henderson [Sun, 26 Feb 2023 22:58:20 +0000 (12:58 -1000)]
target/xtensa: Tidy translate_clamps

All writes to arg[0].out; use tcg_constant_i32.

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/xtensa: Tidy translate_bb
Richard Henderson [Sun, 26 Feb 2023 22:56:56 +0000 (12:56 -1000)]
target/xtensa: Tidy translate_bb

Replace ifdefs with C, tcg_const_i32 with tcg_constant_i32.
We only need a single temporary for this.

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/sparc: Avoid tcg_const_{tl,i32}
Richard Henderson [Sun, 26 Feb 2023 21:15:00 +0000 (11:15 -1000)]
target/sparc: Avoid tcg_const_{tl,i32}

All remaining uses are strictly read-only.

Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/s390x: Split out gen_ri2
Richard Henderson [Mon, 27 Feb 2023 03:55:31 +0000 (17:55 -1000)]
target/s390x: Split out gen_ri2

Use tcg_constant_i64.  Adjust in2_mri2_* to allocate a new
temporary for the output, using gen_ri2 for the address.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/riscv: Avoid tcg_const_*
Richard Henderson [Sun, 26 Feb 2023 19:15:34 +0000 (09:15 -1000)]
target/riscv: Avoid tcg_const_*

All uses are strictly read-only.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/microblaze: Avoid tcg_const_* throughout
Richard Henderson [Sun, 26 Feb 2023 01:42:20 +0000 (15:42 -1000)]
target/microblaze: Avoid tcg_const_* throughout

All uses are strictly read-only.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/i386: Simplify POPF
Richard Henderson [Sat, 25 Feb 2023 23:24:35 +0000 (13:24 -1000)]
target/i386: Simplify POPF

Compute the eflags write mask separately, leaving one call
to the helper.  Use tcg_constant_i32.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/hexagon/idef-parser: Use gen_constant for gen_extend_tcg_width_op
Richard Henderson [Mon, 27 Feb 2023 03:12:05 +0000 (17:12 -1000)]
target/hexagon/idef-parser: Use gen_constant for gen_extend_tcg_width_op

We already have a temporary, res, which we can use for the intermediate
shift result.  Simplify the constant to -1 instead of 0xf*f.
This was the last use of gen_tmp_value, so remove it.

Reviewed-by: Taylor Simpson <tsimpson@quicinc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/hexagon/idef-parser: Use gen_tmp for gen_rvalue_pred
Richard Henderson [Mon, 27 Feb 2023 03:00:35 +0000 (17:00 -1000)]
target/hexagon/idef-parser: Use gen_tmp for gen_rvalue_pred

The allocation is immediately followed by either tcg_gen_mov_i32
or gen_read_preg (which contains tcg_gen_mov_i32), so the zero
initialization is immediately discarded.

Reviewed-by: Taylor Simpson <tsimpson@quicinc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/hexagon/idef-parser: Use gen_tmp for gen_pred_assign
Richard Henderson [Mon, 27 Feb 2023 02:58:38 +0000 (16:58 -1000)]
target/hexagon/idef-parser: Use gen_tmp for gen_pred_assign

The allocation is immediately followed by tcg_gen_mov_i32,
so the initial assignment of zero is discarded.

Reviewed-by: Taylor Simpson <tsimpson@quicinc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/hexagon/idef-parser: Use gen_tmp for LPCFG
Richard Henderson [Mon, 27 Feb 2023 02:44:05 +0000 (16:44 -1000)]
target/hexagon/idef-parser: Use gen_tmp for LPCFG

The GET_USR_FIELD macro initializes the output, so the initial assignment
of zero is discarded.  This is the only use of get_tmp_value outside of
parser-helper.c, so make it static.

Reviewed-by: Taylor Simpson <tsimpson@quicinc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/hexagon: Use tcg_constant_* for gen_constant_from_imm
Richard Henderson [Mon, 27 Feb 2023 02:19:36 +0000 (16:19 -1000)]
target/hexagon: Use tcg_constant_* for gen_constant_from_imm

Rename from gen_tmp_value_from_imm to match gen_constant vs gen_tmp.

Reviewed-by: Taylor Simpson <tsimpson@quicinc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agodocs/devel/tcg-ops: Drop recommendation to free temps
Richard Henderson [Sat, 25 Feb 2023 08:48:05 +0000 (22:48 -1000)]
docs/devel/tcg-ops: Drop recommendation to free temps

Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotracing: remove transform.py
Richard Henderson [Sat, 25 Feb 2023 09:41:12 +0000 (23:41 -1000)]
tracing: remove transform.py

This file, and a couple of uses, got left behind when the
tcg stuff was removed from tracetool.

Fixes: 126d4123c50a ("tracing: excise the tcg related from tracetool")
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agoinclude/exec/gen-icount: Drop tcg_temp_free in gen_tb_start
Richard Henderson [Sat, 25 Feb 2023 08:10:35 +0000 (22:10 -1000)]
include/exec/gen-icount: Drop tcg_temp_free in gen_tb_start

Translators are no longer required to free tcg temporaries.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/tricore: Drop tcg_temp_free
Richard Henderson [Sat, 25 Feb 2023 07:50:24 +0000 (21:50 -1000)]
target/tricore: Drop tcg_temp_free

Translators are no longer required to free tcg temporaries.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/mips: Fix trans_mult_acc return
Richard Henderson [Sat, 25 Feb 2023 05:35:02 +0000 (19:35 -1000)]
target/mips: Fix trans_mult_acc return

Success from trans_* subroutines should be true.

Fixes: 5fa38eedbd ("target/mips: Convert Vr54xx MACC* opcodes to decodetree")
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/mips: Drop tcg_temp_free from mips16e_translate.c.inc
Richard Henderson [Sat, 25 Feb 2023 05:21:28 +0000 (19:21 -1000)]
target/mips: Drop tcg_temp_free from mips16e_translate.c.inc

Translators are no longer required to free tcg temporaries.

Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/i386: Drop tcg_temp_free
Richard Henderson [Sat, 25 Feb 2023 04:56:08 +0000 (18:56 -1000)]
target/i386: Drop tcg_temp_free

Translators are no longer required to free tcg temporaries.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/xtensa: Drop tcg_temp_free
Richard Henderson [Sat, 25 Feb 2023 08:02:33 +0000 (22:02 -1000)]
target/xtensa: Drop tcg_temp_free

Translators are no longer required to free tcg temporaries.

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/xtensa: Drop reset_sar_tracker
Richard Henderson [Sat, 25 Feb 2023 07:53:49 +0000 (21:53 -1000)]
target/xtensa: Drop reset_sar_tracker

Translators are no longer required to free tcg temporaries.
Remove sar_m32_allocated, as sar_m32 non-null is equivalent.

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/sparc: Drop tcg_temp_free
Richard Henderson [Sat, 25 Feb 2023 07:37:17 +0000 (21:37 -1000)]
target/sparc: Drop tcg_temp_free

Translators are no longer required to free tcg temporaries.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/sparc: Drop free_compare
Richard Henderson [Sat, 25 Feb 2023 07:32:54 +0000 (21:32 -1000)]
target/sparc: Drop free_compare

Translators are no longer required to free tcg temporaries.
Remove the g1 and g2 members of DisasCompare, as they were
used to track which temps needed to be freed.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/sparc: Remove egress label in disas_sparc_context
Richard Henderson [Sat, 25 Feb 2023 07:29:17 +0000 (21:29 -1000)]
target/sparc: Remove egress label in disas_sparc_context

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/sparc: Drop get_temp_i32
Richard Henderson [Sat, 25 Feb 2023 07:26:59 +0000 (21:26 -1000)]
target/sparc: Drop get_temp_i32

Translators are no longer required to free tcg temporaries,
therefore there's no need to record temps for later freeing.
Replace the few uses with tcg_temp_new_i32.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/sparc: Drop get_temp_tl
Richard Henderson [Sat, 25 Feb 2023 07:24:23 +0000 (21:24 -1000)]
target/sparc: Drop get_temp_tl

Translators are no longer required to free tcg temporaries,
therefore there's no need to record temps for later freeing.
Replace the few uses with tcg_temp_new.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/sh4: Drop tcg_temp_free
Richard Henderson [Sat, 25 Feb 2023 07:21:32 +0000 (21:21 -1000)]
target/sh4: Drop tcg_temp_free

Translators are no longer required to free tcg temporaries.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/rx: Drop tcg_temp_free
Richard Henderson [Sat, 25 Feb 2023 06:31:26 +0000 (20:31 -1000)]
target/rx: Drop tcg_temp_free

Translators are no longer required to free tcg temporaries.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/riscv: Drop tcg_temp_free
Richard Henderson [Sat, 25 Feb 2023 06:28:43 +0000 (20:28 -1000)]
target/riscv: Drop tcg_temp_free

Translators are no longer required to free tcg temporaries.

Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/riscv: Drop temp_new
Richard Henderson [Sat, 25 Feb 2023 06:27:57 +0000 (20:27 -1000)]
target/riscv: Drop temp_new

Translators are no longer required to free tcg temporaries,
therefore there's no need to record temps for later freeing.
Replace the few uses with tcg_temp_new.

Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/riscv: Drop ftemp_new
Richard Henderson [Sat, 25 Feb 2023 06:25:02 +0000 (20:25 -1000)]
target/riscv: Drop ftemp_new

Translators are no longer required to free tcg temporaries,
therefore there's no need to record temps for later freeing.
Replace the few uses with tcg_temp_new_i64.

Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/ppc: Drop tcg_temp_free
Richard Henderson [Sat, 25 Feb 2023 06:16:38 +0000 (20:16 -1000)]
target/ppc: Drop tcg_temp_free

Translators are no longer required to free tcg temporaries.

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/openrisc: Drop tcg_temp_free
Richard Henderson [Sat, 25 Feb 2023 05:52:13 +0000 (19:52 -1000)]
target/openrisc: Drop tcg_temp_free

Translators are no longer required to free tcg temporaries.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/nios2: Drop tcg_temp_free
Richard Henderson [Sat, 25 Feb 2023 05:50:43 +0000 (19:50 -1000)]
target/nios2: Drop tcg_temp_free

Translators are no longer required to free tcg temporaries.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/microblaze: Drop tcg_temp_free
Richard Henderson [Sat, 25 Feb 2023 05:19:12 +0000 (19:19 -1000)]
target/microblaze: Drop tcg_temp_free

Translators are no longer required to free tcg temporaries.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/m68k: Drop tcg_temp_free
Richard Henderson [Sat, 25 Feb 2023 05:16:49 +0000 (19:16 -1000)]
target/m68k: Drop tcg_temp_free

Translators are no longer required to free tcg temporaries.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/m68k: Drop free_cond
Richard Henderson [Sat, 25 Feb 2023 05:12:09 +0000 (19:12 -1000)]
target/m68k: Drop free_cond

Translators are no longer required to free tcg temporaries.
Remove the g1 and g2 members of DisasCompare, as they were
used to track which temps needed to be freed.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/m68k: Drop mark_to_release
Richard Henderson [Sat, 25 Feb 2023 05:09:19 +0000 (19:09 -1000)]
target/m68k: Drop mark_to_release

Translators are no longer required to free tcg temporaries,
therefore there's no need to record temps for later freeing.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/loongarch: Drop tcg_temp_free
Richard Henderson [Sat, 25 Feb 2023 05:06:42 +0000 (19:06 -1000)]
target/loongarch: Drop tcg_temp_free

Translators are no longer required to free tcg temporaries.

Reviewed-by: Song Gao <gaosong@loongson.cn>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/loongarch: Drop temp_new
Richard Henderson [Sat, 25 Feb 2023 05:05:39 +0000 (19:05 -1000)]
target/loongarch: Drop temp_new

Translators are no longer required to free tcg temporaries,
therefore there's no need to record temps for later freeing.
Replace the few uses with tcg_temp_new.

Reviewed-by: Song Gao <gaosong@loongson.cn>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/hppa: Drop tcg_temp_free
Richard Henderson [Sat, 25 Feb 2023 04:52:25 +0000 (18:52 -1000)]
target/hppa: Drop tcg_temp_free

Translators are no longer required to free tcg temporaries.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/hexagon/idef-parser: Drop HexValue.is_manual
Richard Henderson [Sat, 25 Feb 2023 04:48:00 +0000 (18:48 -1000)]
target/hexagon/idef-parser: Drop HexValue.is_manual

This field is no longer used.

Reviewed-by: Taylor Simpson <tsimpson@quicinc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/hexagon/idef-parser: Drop tcg_temp_free
Richard Henderson [Sat, 25 Feb 2023 04:40:56 +0000 (18:40 -1000)]
target/hexagon/idef-parser: Drop tcg_temp_free

Translators are no longer required to free tcg temporaries.
This removes gen_rvalue_free, gen_rvalue_free_manual and
free_variables, whose only purpose was to emit tcg_temp_free.

Reviewed-by: Taylor Simpson <tsimpson@quicinc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/hexagon: Drop tcg_temp_free from gen_tcg_funcs.py
Richard Henderson [Sat, 25 Feb 2023 04:33:03 +0000 (18:33 -1000)]
target/hexagon: Drop tcg_temp_free from gen_tcg_funcs.py

Translators are no longer required to free tcg temporaries.

Reviewed-by: Taylor Simpson <tsimpson@quicinc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/hexagon: Drop tcg_temp_free from C code
Richard Henderson [Sat, 25 Feb 2023 04:27:22 +0000 (18:27 -1000)]
target/hexagon: Drop tcg_temp_free from C code

Translators are no longer required to free tcg temporaries.

Reviewed-by: Taylor Simpson <tsimpson@quicinc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/cris: Drop tcg_temp_free
Richard Henderson [Sat, 25 Feb 2023 04:22:12 +0000 (18:22 -1000)]
target/cris: Drop tcg_temp_free

Translators are no longer required to free tcg temporaries.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/cris: Drop addr from dec10_ind_move_m_pr
Richard Henderson [Sat, 25 Feb 2023 04:20:56 +0000 (18:20 -1000)]
target/cris: Drop addr from dec10_ind_move_m_pr

This variable is not used, only allocated and freed.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/cris: Drop cris_alu_m_free_temps
Richard Henderson [Sat, 25 Feb 2023 04:18:10 +0000 (18:18 -1000)]
target/cris: Drop cris_alu_m_free_temps

Translators are no longer required to free tcg temporaries.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/cris: Drop cris_alu_free_temps
Richard Henderson [Sat, 25 Feb 2023 04:14:58 +0000 (18:14 -1000)]
target/cris: Drop cris_alu_free_temps

Translators are no longer required to free tcg temporaries.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/avr: Drop tcg_temp_free
Richard Henderson [Sat, 25 Feb 2023 04:12:28 +0000 (18:12 -1000)]
target/avr: Drop tcg_temp_free

Translators are no longer required to free tcg temporaries.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/avr: Drop R from trans_COM
Richard Henderson [Sat, 25 Feb 2023 04:11:32 +0000 (18:11 -1000)]
target/avr: Drop R from trans_COM

This variable is not used, only allocated and freed.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/avr: Drop DisasContext.free_skip_var0
Richard Henderson [Sat, 25 Feb 2023 04:05:08 +0000 (18:05 -1000)]
target/avr: Drop DisasContext.free_skip_var0

Translators are no longer required to free tcg temporaries,
therefore there's no need to record for later freeing.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/arm: Drop tcg_temp_free from translator.h
Richard Henderson [Sat, 25 Feb 2023 04:02:13 +0000 (18:02 -1000)]
target/arm: Drop tcg_temp_free from translator.h

Translators are no longer required to free tcg temporaries.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/arm: Drop tcg_temp_free from translator-vfp.c
Richard Henderson [Sat, 25 Feb 2023 04:01:37 +0000 (18:01 -1000)]
target/arm: Drop tcg_temp_free from translator-vfp.c

Translators are no longer required to free tcg temporaries.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14 months agotarget/arm: Drop tcg_temp_free from translator-sve.c
Richard Henderson [Sat, 25 Feb 2023 03:56:09 +0000 (17:56 -1000)]
target/arm: Drop tcg_temp_free from translator-sve.c

Translators are no longer required to free tcg temporaries.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>