]> xenbits.xensource.com Git - qemu-xen.git/log
qemu-xen.git
11 months ago.gitlab-ci.d/buildtest.yml: Use -fno-sanitize=function in the clang-system job
Thomas Huth [Mon, 3 Jun 2024 17:53:24 +0000 (18:53 +0100)]
.gitlab-ci.d/buildtest.yml: Use -fno-sanitize=function in the clang-system job

The latest version of Clang (version 18 from Fedora 40) now reports
bad function pointer casts as undefined behavior. Unfortunately, we are
still doing this in quite a lot of places in the QEMU code and some of
them are not easy to fix. So for the time being, temporarily switch this
off in the failing clang-system job until all spots in the QEMU sources
have been tackled.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20240601070543.37786-4-thuth@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240603175328.3823123-9-alex.bennee@linaro.org>

11 months agotests/lcitool: Delete obsolete centos-stream-8.yml file
Thomas Huth [Mon, 3 Jun 2024 17:53:23 +0000 (18:53 +0100)]
tests/lcitool: Delete obsolete centos-stream-8.yml file

We've missed to delete this file when removing support for CentOS 8.
Since the current upstream version of the lcitool removed support
for CentOS 8 now, too, we have to remove the file before updating.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20240601070543.37786-2-thuth@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240603175328.3823123-8-alex.bennee@linaro.org>

11 months agodocs/ci: clean-up references for consistency
Alex Bennée [Mon, 3 Jun 2024 17:53:22 +0000 (18:53 +0100)]
docs/ci: clean-up references for consistency

Document we have split up build-environment by distro and update the
references that exist in the code base to be correct.

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

11 months agoscripts/ci: remove CentOS bits from common build-environment
Alex Bennée [Mon, 3 Jun 2024 17:53:21 +0000 (18:53 +0100)]
scripts/ci: remove CentOS bits from common build-environment

Although I've just removed the CentOS specific build-environment its
probably a bit too confusing to have multiple distros mixed up in one
place. Prior to moving clean-up what will be just for ubuntu.

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

11 months agotests/vm: remove plain centos image
Alex Bennée [Mon, 3 Jun 2024 17:53:20 +0000 (18:53 +0100)]
tests/vm: remove plain centos image

This isn't really used and we have lighter weight docker containers
for testing this stuff directly.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240603175328.3823123-5-alex.bennee@linaro.org>

11 months agotests/vm: update centos.aarch64 image to 9
Alex Bennée [Mon, 3 Jun 2024 17:53:19 +0000 (18:53 +0100)]
tests/vm: update centos.aarch64 image to 9

As Centos Stream 8 goes out of support we need to update. To do this
powertools is replaced by crb and we don't over specify the python3 we
want.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240603175328.3823123-4-alex.bennee@linaro.org>

11 months agodocs/devel: update references to centos to non-versioned container
Alex Bennée [Mon, 3 Jun 2024 17:53:18 +0000 (18:53 +0100)]
docs/devel: update references to centos to non-versioned container

>From the website:

"After May 31, 2024, CentOS Stream 8 will be archived and no further
updates will be provided."

We have updated a few bits but there are still references that need
fixing. Rather than bump I've replaced them with references to the
Debian image so we don't have to bump at the next update.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240603175328.3823123-3-alex.bennee@linaro.org>

11 months agoci: remove centos-steam-8 customer runner
Alex Bennée [Mon, 3 Jun 2024 17:53:17 +0000 (18:53 +0100)]
ci: remove centos-steam-8 customer runner

This broke since eef0bae3a7 (migration: Remove block migration) but
even after that was addressed it still fails to complete. As it will
shortly be EOL lets to remove the runner definition and the related
ansible setup bits.

We still have centos9 docker images build and test.

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

11 months agoMerge tag 'pull-misc-20240605' of https://gitlab.com/rth7680/qemu into staging
Richard Henderson [Wed, 5 Jun 2024 21:17:01 +0000 (14:17 -0700)]
Merge tag 'pull-misc-20240605' of https://gitlab.com/rth7680/qemu into staging

util/hexdump: Use a GString for qemu_hexdump_line.
system/qtest: Replace sprintf by qemu_hexdump_line
hw/scsi/scsi-disk: Use qemu_hexdump_line to avoid sprintf
hw/ide/atapi: Use qemu_hexdump_line to avoid sprintf
hw/dma/pl330: Use qemu_hexdump_line to avoid sprintf
disas/microblaze: Reorg to avoid intermediate sprintf
disas/riscv: Use GString in format_inst

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmZg1RMdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV+6mgf6AjEdU91vBXAUxabs
# kmVl5HaAD3NHU1VCM+ruPQkm6xv4kLlMsTibmkiS7+WZYvHfPlGfozjRJxtvZj8K
# 8J2Qp9iHjny8NQPkMCValDvmzkxaIT7ZzYCBdS4jfTdIThuYNJnXsI3NNP7ghnl6
# xv8O62dQbc5gjWF8G+q6PKWSxY6BEuFJ3Pt82cJ/Fj/8bhsjd48pgiLv66F/+q1z
# U9Gy8fWqmkKEzTqBigSYU98yae5CA89T6JBKtgFV07pkYa4A7BUyCR5EBirARyhM
# P0OAqR1GCAbSXWFaJ1sSpU8ATq33FoSQYwWwcmEET7FZYZqvbd6Jd4HtpOPqmu9W
# Fc4taw==
# =VgLB
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 05 Jun 2024 02:13:55 PM PDT
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate]

* tag 'pull-misc-20240605' of https://gitlab.com/rth7680/qemu:
  disas/riscv: Use GString in format_inst
  disas/microblaze: Split get_field_special
  disas/microblaze: Print registers directly with PRIrfsl
  disas/microblaze: Print immediates directly with PRIimm
  disas/microblaze: Print registers directly with PRIreg
  disas/microblaze: Merge op->name output into each fprintf
  disas/microblaze: Re-indent print_insn_microblaze
  disas/microblaze: Split out print_immval_addr
  hw/dma/pl330: Use qemu_hexdump_line to avoid sprintf
  hw/ide/atapi: Use qemu_hexdump_line to avoid sprintf
  hw/scsi/scsi-disk: Use qemu_hexdump_line to avoid sprintf
  system/qtest: Replace sprintf by qemu_hexdump_line
  hw/mips/malta: Add re-usable rng_seed_hex_new() method
  util/hexdump: Inline g_string_append_printf "%02x"
  util/hexdump: Add unit_len and block_len to qemu_hexdump_line
  util/hexdump: Use a GString for qemu_hexdump_line

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agodisas/riscv: Use GString in format_inst
Richard Henderson [Fri, 12 Apr 2024 07:33:40 +0000 (00:33 -0700)]
disas/riscv: Use GString in format_inst

Allocate and fill a GString instead of snprintf and
appending to a fixed sized buffer.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240412073346.458116-22-richard.henderson@linaro.org>

11 months agodisas/microblaze: Split get_field_special
Richard Henderson [Fri, 12 Apr 2024 07:33:39 +0000 (00:33 -0700)]
disas/microblaze: Split get_field_special

Extract the raw special index and a function to lookup a name.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240412073346.458116-21-richard.henderson@linaro.org>

11 months agodisas/microblaze: Print registers directly with PRIrfsl
Richard Henderson [Fri, 12 Apr 2024 07:33:38 +0000 (00:33 -0700)]
disas/microblaze: Print registers directly with PRIrfsl

Use a printf format instead of sprintf into a buffer.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240412073346.458116-20-richard.henderson@linaro.org>

11 months agodisas/microblaze: Print immediates directly with PRIimm
Richard Henderson [Fri, 12 Apr 2024 07:33:37 +0000 (00:33 -0700)]
disas/microblaze: Print immediates directly with PRIimm

Use a printf format instead of sprintf into a buffer.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240412073346.458116-19-richard.henderson@linaro.org>

11 months agodisas/microblaze: Print registers directly with PRIreg
Richard Henderson [Fri, 12 Apr 2024 07:33:36 +0000 (00:33 -0700)]
disas/microblaze: Print registers directly with PRIreg

Use a printf format instead of sprintf into a buffer.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240412073346.458116-18-richard.henderson@linaro.org>

11 months agodisas/microblaze: Merge op->name output into each fprintf
Richard Henderson [Fri, 12 Apr 2024 07:33:35 +0000 (00:33 -0700)]
disas/microblaze: Merge op->name output into each fprintf

In the common case, issue one single fprintf.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240412073346.458116-17-richard.henderson@linaro.org>

11 months agodisas/microblaze: Re-indent print_insn_microblaze
Richard Henderson [Fri, 12 Apr 2024 07:33:34 +0000 (00:33 -0700)]
disas/microblaze: Re-indent print_insn_microblaze

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240412073346.458116-16-richard.henderson@linaro.org>

11 months agodisas/microblaze: Split out print_immval_addr
Richard Henderson [Fri, 12 Apr 2024 07:33:33 +0000 (00:33 -0700)]
disas/microblaze: Split out print_immval_addr

Unify the code blocks that try to print a symbolic address.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240412073346.458116-15-richard.henderson@linaro.org>

11 months agohw/dma/pl330: Use qemu_hexdump_line to avoid sprintf
Philippe Mathieu-Daudé [Fri, 12 Apr 2024 07:33:29 +0000 (00:33 -0700)]
hw/dma/pl330: Use qemu_hexdump_line to avoid sprintf

sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1.
Using qemu_hexdump_line both fixes the deprecation warning and
simplifies the code base.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240412073346.458116-11-richard.henderson@linaro.org>

11 months agohw/ide/atapi: Use qemu_hexdump_line to avoid sprintf
Philippe Mathieu-Daudé [Fri, 12 Apr 2024 07:33:28 +0000 (00:33 -0700)]
hw/ide/atapi: Use qemu_hexdump_line to avoid sprintf

sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1.
Using qemu_hexdump_line both fixes the deprecation warning and
simplifies the code base.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240412073346.458116-10-richard.henderson@linaro.org>

11 months agohw/scsi/scsi-disk: Use qemu_hexdump_line to avoid sprintf
Philippe Mathieu-Daudé [Fri, 12 Apr 2024 07:33:27 +0000 (00:33 -0700)]
hw/scsi/scsi-disk: Use qemu_hexdump_line to avoid sprintf

sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1.
Using qemu_hexdump_line both fixes the deprecation warning and
simplifies the code base.

Note that this drops the "0x" prefix to every byte, which should
be of no consequence to tracing.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20240412073346.458116-9-richard.henderson@linaro.org>

11 months agosystem/qtest: Replace sprintf by qemu_hexdump_line
Philippe Mathieu-Daudé [Fri, 12 Apr 2024 07:33:26 +0000 (00:33 -0700)]
system/qtest: Replace sprintf by qemu_hexdump_line

sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1.
Using qemu_hexdump_line both fixes the deprecation warning and
simplifies the code base.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>`
[rth: Use qemu_hexdump_line]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20240412073346.458116-8-richard.henderson@linaro.org>

11 months agohw/mips/malta: Add re-usable rng_seed_hex_new() method
Philippe Mathieu-Daudé [Fri, 12 Apr 2024 07:33:25 +0000 (00:33 -0700)]
hw/mips/malta: Add re-usable rng_seed_hex_new() method

sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1.

Extract common code from reinitialize_rng_seed and load_kernel
to rng_seed_hex_new.  Using qemu_hexdump_line both fixes the
deprecation warning and simplifies the code base.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
[rth: Use qemu_hexdump_line.]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240412073346.458116-7-richard.henderson@linaro.org>

11 months agoutil/hexdump: Inline g_string_append_printf "%02x"
Richard Henderson [Fri, 12 Apr 2024 07:33:24 +0000 (00:33 -0700)]
util/hexdump: Inline g_string_append_printf "%02x"

Trivial arithmetic can be used for emitting the nibbles,
rather than full-blown printf formatting.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20240412073346.458116-6-richard.henderson@linaro.org>

11 months agoutil/hexdump: Add unit_len and block_len to qemu_hexdump_line
Richard Henderson [Fri, 12 Apr 2024 07:33:23 +0000 (00:33 -0700)]
util/hexdump: Add unit_len and block_len to qemu_hexdump_line

Generalize the current 1 byte unit and 4 byte blocking
within the output.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20240412073346.458116-5-richard.henderson@linaro.org>

11 months agoutil/hexdump: Use a GString for qemu_hexdump_line
Richard Henderson [Fri, 12 Apr 2024 07:33:22 +0000 (00:33 -0700)]
util/hexdump: Use a GString for qemu_hexdump_line

Allocate a new, or append to an existing GString instead of
using a fixed sized buffer.  Require the caller to determine
the length of the line -- do not bound len here.

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

11 months agoMerge tag 'pull-sp-20240605' of https://gitlab.com/rth7680/qemu into staging
Richard Henderson [Wed, 5 Jun 2024 17:24:03 +0000 (10:24 -0700)]
Merge tag 'pull-sp-20240605' of https://gitlab.com/rth7680/qemu into staging

target/sparc: Implement FMAF, IMA, VIS3 and VIS4 extensions
linux-user: Add ioctl for BLKBSZSET

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmZgjpgdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV98zwf+OUnUolzhyhBFcCuo
# xZRuHiQLgPMLvBpBCY7OcGMTHjh53pYRJAKuSd623WaIs8olshdgo4xRc2tn6WAb
# oSoABkiJ0H/f7N8XGC7cDVvpG9kCbtXJfzz6s3GkoEWGu557ecflsV5ODEoyeI3O
# otilWnCsj43bt7lyltS4YGHWU7Dc9MBLrziPnSWhHuyTv1olFJFXoBAentZnfIAa
# lKTu0y/koqael15cUZfYCYDinot5ssIh906E2u7q5Rd9T0N+IGmmQ3auybMLlGR8
# 8lw4UR0LceErHP6/GTT6VgSHeiaLXBQmqKeTXu+6Yy+ABH21b4Nkgj+PHdv2lxRf
# h057tw==
# =E35I
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 05 Jun 2024 09:13:12 AM PDT
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate]

* tag 'pull-sp-20240605' of https://gitlab.com/rth7680/qemu: (38 commits)
  target/sparc: Enable VIS4 feature bit
  target/sparc: Implement monitor ASIs
  target/sparc: Implement MWAIT
  target/sparc: Implement SUBXC, SUBXCcc
  target/sparc: Implement FPMIN, FPMAX
  target/sparc: Implement VIS4 comparisons
  target/sparc: Implement 8-bit FPADD, FPADDS, and FPADDUS
  target/sparc: Implement FALIGNDATAi
  target/sparc: Add feature bit for VIS4
  target/sparc: Implement IMA extension
  target/sparc: Enable VIS3 feature bit
  target/sparc: Implement XMULX
  target/sparc: Implement UMULXHI
  target/sparc: Implement PDISTN
  target/sparc: Implement MOVsTOw, MOVdTOx, MOVwTOs, MOVxTOd
  target/sparc: Implement LZCNT
  target/sparc: Implement LDXEFSR
  target/sparc: Implement FSLL, FSRL, FSRA, FSLAS
  target/sparc: Implement FPCMPEQ8, FPCMPNE8, FPCMPULE8, FPCMPUGT8
  target/sparc: Implement FPADDS, FPSUBS
  ...

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Enable VIS4 feature bit
Richard Henderson [Sun, 5 Nov 2023 05:19:26 +0000 (22:19 -0700)]
target/sparc: Enable VIS4 feature bit

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement monitor ASIs
Richard Henderson [Sun, 5 Nov 2023 05:13:06 +0000 (22:13 -0700)]
target/sparc: Implement monitor ASIs

Ignore the "monitor" portion and treat them the same
as their base ASIs.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement MWAIT
Richard Henderson [Sun, 5 Nov 2023 05:12:24 +0000 (22:12 -0700)]
target/sparc: Implement MWAIT

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement SUBXC, SUBXCcc
Richard Henderson [Sun, 5 Nov 2023 04:44:01 +0000 (21:44 -0700)]
target/sparc: Implement SUBXC, SUBXCcc

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement FPMIN, FPMAX
Richard Henderson [Sun, 5 Nov 2023 04:39:59 +0000 (21:39 -0700)]
target/sparc: Implement FPMIN, FPMAX

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement VIS4 comparisons
Richard Henderson [Sun, 5 Nov 2023 04:31:54 +0000 (21:31 -0700)]
target/sparc: Implement VIS4 comparisons

VIS4 completes the set, adding missing signed 8-bit ops
and missing unsigned 16 and 32-bit ops.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement 8-bit FPADD, FPADDS, and FPADDUS
Richard Henderson [Sun, 5 Nov 2023 04:04:27 +0000 (21:04 -0700)]
target/sparc: Implement 8-bit FPADD, FPADDS, and FPADDUS

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement FALIGNDATAi
Richard Henderson [Sun, 5 Nov 2023 03:00:10 +0000 (20:00 -0700)]
target/sparc: Implement FALIGNDATAi

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Add feature bit for VIS4
Richard Henderson [Sun, 5 Nov 2023 02:44:28 +0000 (19:44 -0700)]
target/sparc: Add feature bit for VIS4

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement IMA extension
Richard Henderson [Sun, 5 Nov 2023 02:40:36 +0000 (19:40 -0700)]
target/sparc: Implement IMA extension

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Enable VIS3 feature bit
Richard Henderson [Sun, 5 Nov 2023 01:49:08 +0000 (18:49 -0700)]
target/sparc: Enable VIS3 feature bit

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement XMULX
Richard Henderson [Sun, 5 Nov 2023 01:31:59 +0000 (18:31 -0700)]
target/sparc: Implement XMULX

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement UMULXHI
Richard Henderson [Sun, 5 Nov 2023 01:22:42 +0000 (18:22 -0700)]
target/sparc: Implement UMULXHI

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement PDISTN
Richard Henderson [Sun, 5 Nov 2023 01:16:44 +0000 (18:16 -0700)]
target/sparc: Implement PDISTN

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement MOVsTOw, MOVdTOx, MOVwTOs, MOVxTOd
Richard Henderson [Sun, 5 Nov 2023 01:07:35 +0000 (18:07 -0700)]
target/sparc: Implement MOVsTOw, MOVdTOx, MOVwTOs, MOVxTOd

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement LZCNT
Richard Henderson [Sun, 5 Nov 2023 00:48:25 +0000 (17:48 -0700)]
target/sparc: Implement LZCNT

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement LDXEFSR
Richard Henderson [Sun, 5 Nov 2023 00:38:34 +0000 (17:38 -0700)]
target/sparc: Implement LDXEFSR

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement FSLL, FSRL, FSRA, FSLAS
Richard Henderson [Sun, 5 Nov 2023 00:24:01 +0000 (17:24 -0700)]
target/sparc: Implement FSLL, FSRL, FSRA, FSLAS

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement FPCMPEQ8, FPCMPNE8, FPCMPULE8, FPCMPUGT8
Richard Henderson [Sat, 4 Nov 2023 23:53:28 +0000 (16:53 -0700)]
target/sparc: Implement FPCMPEQ8, FPCMPNE8, FPCMPULE8, FPCMPUGT8

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement FPADDS, FPSUBS
Richard Henderson [Sun, 5 Nov 2023 03:54:48 +0000 (20:54 -0700)]
target/sparc: Implement FPADDS, FPSUBS

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement FPADD64, FPSUB64
Richard Henderson [Sat, 4 Nov 2023 23:39:12 +0000 (16:39 -0700)]
target/sparc: Implement FPADD64, FPSUB64

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement FMEAN16
Richard Henderson [Sat, 4 Nov 2023 22:40:39 +0000 (15:40 -0700)]
target/sparc: Implement FMEAN16

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement FLCMP
Richard Henderson [Sat, 4 Nov 2023 22:23:35 +0000 (15:23 -0700)]
target/sparc: Implement FLCMP

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement FHADD, FHSUB, FNHADD, FNADD, FNMUL
Richard Henderson [Sat, 4 Nov 2023 21:59:24 +0000 (14:59 -0700)]
target/sparc: Implement FHADD, FHSUB, FNHADD, FNADD, FNMUL

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement FCHKSM16
Richard Henderson [Sat, 4 Nov 2023 21:57:27 +0000 (14:57 -0700)]
target/sparc: Implement FCHKSM16

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement CMASK instructions
Richard Henderson [Sat, 4 Nov 2023 19:55:49 +0000 (12:55 -0700)]
target/sparc: Implement CMASK instructions

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement ADDXC, ADDXCcc
Richard Henderson [Sat, 4 Nov 2023 19:33:08 +0000 (12:33 -0700)]
target/sparc: Implement ADDXC, ADDXCcc

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Add feature bits for VIS 3
Richard Henderson [Sat, 4 Nov 2023 19:21:37 +0000 (12:21 -0700)]
target/sparc: Add feature bits for VIS 3

The manual separates VIS 3 and VIS 3B, even though they are both
present in all extant cpus.  For clarity, let the translator
match the manual but otherwise leave them on the same feature bit.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Implement FMAf extension
Richard Henderson [Sat, 4 Nov 2023 19:13:00 +0000 (12:13 -0700)]
target/sparc: Implement FMAf extension

Rearrange PDIST so that do_dddd is general purpose and may
be re-used for FMADDd etc.  Add pickNaN and pickNaNMulAdd.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Use gvec for VIS1 parallel add/sub
Richard Henderson [Fri, 3 Nov 2023 21:52:45 +0000 (14:52 -0700)]
target/sparc: Use gvec for VIS1 parallel add/sub

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Remove cpu_fpr[]
Richard Henderson [Fri, 3 Nov 2023 21:38:55 +0000 (14:38 -0700)]
target/sparc: Remove cpu_fpr[]

Use explicit loads and stores to env instead.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Remove gen_dest_fpr_D
Richard Henderson [Fri, 3 Nov 2023 20:21:36 +0000 (13:21 -0700)]
target/sparc: Remove gen_dest_fpr_D

Replace with tcg_temp_new_i64.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Perform DFPREG/QFPREG in decodetree
Richard Henderson [Fri, 3 Nov 2023 20:13:05 +0000 (13:13 -0700)]
target/sparc: Perform DFPREG/QFPREG in decodetree

Form the proper register decoding from the start.

Because we're removing the translation from the inner-most
gen_load_fpr_* and gen_store_fpr_* routines, this must be
done for all insns at once.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Fix helper_fmul8ulx16
Richard Henderson [Sat, 25 May 2024 05:04:03 +0000 (22:04 -0700)]
target/sparc: Fix helper_fmul8ulx16

This operation returns the high 16 bits of a 24-bit multiply
that has been sign-extended to 32 bits.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Fix do_dc
Richard Henderson [Sat, 25 May 2024 04:33:01 +0000 (21:33 -0700)]
target/sparc: Fix do_dc

Apply DFPREG to compute the register number.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Rewrite gen_edge
Richard Henderson [Sat, 25 May 2024 04:26:24 +0000 (21:26 -0700)]
target/sparc: Rewrite gen_edge

Drop the tables and compute the left and right edges directly.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agotarget/sparc: Fix ARRAY8
Richard Henderson [Sat, 25 May 2024 02:23:11 +0000 (19:23 -0700)]
target/sparc: Fix ARRAY8

Follow the Oracle Sparc 2015 implementation note and bound
the input value of N to 5 from the lower 3 bits of rs2.
Spell out all of the intermediate values, matching the diagram
in the manual.  Fix extraction of upper_x and upper_y for N=0.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agolinux-user: Add ioctl for BLKBSZSET
Michael Vogt [Tue, 23 Apr 2024 15:24:39 +0000 (17:24 +0200)]
linux-user: Add ioctl for BLKBSZSET

Tiny patch to add the ioctl wrapper definition for BLKBSZSET.

Signed-off-by: Michael Vogt <mvogt@redhat.com>
Message-Id: <20240423152438.19841-2-mvogt@redhat.com>

11 months agoMerge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
Richard Henderson [Wed, 5 Jun 2024 14:45:23 +0000 (07:45 -0700)]
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging

* virtio-blk: remove SCSI passthrough functionality
* require x86-64-v2 baseline ISA
* SEV-SNP host support
* fix xsave.flat with TCG
* fixes for CPUID checks done by TCG

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmZgKVYUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroPKYgf/QkWrNXdjjD3yAsv5LbJFVTVyCYW3
# b4Iax29kEDy8k9wbzfLxOfIk9jXIjmbOMO5ZN9LFiHK6VJxbXslsMh6hm50M3xKe
# 49X1Rvf9YuVA7KZX+dWkEuqLYI6Tlgj3HaCilYWfXrjyo6hY3CxzkPV/ChmaeYlV
# Ad4Y8biifoUuuEK8OTeTlcDWLhOHlFXylG3AXqULsUsXp0XhWJ9juXQ60eATv/W4
# eCEH7CSmRhYFu2/rV+IrWFYMnskLRTk1OC1/m6yXGPKOzgnOcthuvQfiUgPkbR/d
# llY6Ni5Aaf7+XX3S7Avcyvoq8jXzaaMzOrzL98rxYGDR1sYBYO+4h4ZToA==
# =qQeP
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 05 Jun 2024 02:01:10 AM PDT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "pbonzini@redhat.com"
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full]
# gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>" [full]

* tag 'for-upstream' of https://gitlab.com/bonzini/qemu: (46 commits)
  hw/i386: Add support for loading BIOS using guest_memfd
  hw/i386/sev: Use guest_memfd for legacy ROMs
  memory: Introduce memory_region_init_ram_guest_memfd()
  i386/sev: Allow measured direct kernel boot on SNP
  i386/sev: Reorder struct declarations
  i386/sev: Extract build_kernel_loader_hashes
  i386/sev: Enable KVM_HC_MAP_GPA_RANGE hcall for SNP guests
  i386/kvm: Add KVM_EXIT_HYPERCALL handling for KVM_HC_MAP_GPA_RANGE
  i386/sev: Invoke launch_updata_data() for SNP class
  i386/sev: Invoke launch_updata_data() for SEV class
  hw/i386/sev: Add support to encrypt BIOS when SEV-SNP is enabled
  i386/sev: Add support for SNP CPUID validation
  i386/sev: Add support for populating OVMF metadata pages
  hw/i386/sev: Add function to get SEV metadata from OVMF header
  i386/sev: Set CPU state to protected once SNP guest payload is finalized
  i386/sev: Add handling to encrypt/finalize guest launch data
  i386/sev: Add the SNP launch start context
  i386/sev: Update query-sev QAPI format to handle SEV-SNP
  i386/sev: Add a class method to determine KVM VM type for SNP guests
  i386/sev: Don't return launch measurements for SEV-SNP guests
  ...

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11 months agohw/i386: Add support for loading BIOS using guest_memfd
Michael Roth [Thu, 30 May 2024 11:16:40 +0000 (06:16 -0500)]
hw/i386: Add support for loading BIOS using guest_memfd

When guest_memfd is enabled, the BIOS is generally part of the initial
encrypted guest image and will be accessed as private guest memory. Add
the necessary changes to set up the associated RAM region with a
guest_memfd backend to allow for this.

Current support centers around using -bios to load the BIOS data.
Support for loading the BIOS via pflash requires additional enablement
since those interfaces rely on the use of ROM memory regions which make
use of the KVM_MEM_READONLY memslot flag, which is not supported for
guest_memfd-backed memslots.

Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-29-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agohw/i386/sev: Use guest_memfd for legacy ROMs
Michael Roth [Thu, 30 May 2024 11:16:39 +0000 (06:16 -0500)]
hw/i386/sev: Use guest_memfd for legacy ROMs

Current SNP guest kernels will attempt to access these regions with
with C-bit set, so guest_memfd is needed to handle that. Otherwise,
kvm_convert_memory() will fail when the guest kernel tries to access it
and QEMU attempts to call KVM_SET_MEMORY_ATTRIBUTES to set these ranges
to private.

Whether guests should actually try to access ROM regions in this way (or
need to deal with legacy ROM regions at all), is a separate issue to be
addressed on kernel side, but current SNP guest kernels will exhibit
this behavior and so this handling is needed to allow QEMU to continue
running existing SNP guest kernels.

Signed-off-by: Michael Roth <michael.roth@amd.com>
[pankaj: Added sev_snp_enabled() check]
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-28-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agomemory: Introduce memory_region_init_ram_guest_memfd()
Xiaoyao Li [Thu, 30 May 2024 11:16:15 +0000 (06:16 -0500)]
memory: Introduce memory_region_init_ram_guest_memfd()

Introduce memory_region_init_ram_guest_memfd() to allocate private
guset memfd on the MemoryRegion initialization. It's for the use case of
TDVF, which must be private on TDX case.

Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-4-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Allow measured direct kernel boot on SNP
Dov Murik [Thu, 30 May 2024 11:16:35 +0000 (06:16 -0500)]
i386/sev: Allow measured direct kernel boot on SNP

In SNP, the hashes page designated with a specific metadata entry
published in AmdSev OVMF.

Therefore, if the user enabled kernel hashes (for measured direct boot),
QEMU should prepare the content of hashes table, and during the
processing of the metadata entry it copy the content into the designated
page and encrypt it.

Note that in SNP (unlike SEV and SEV-ES) the measurements is done in
whole 4KB pages.  Therefore QEMU zeros the whole page that includes the
hashes table, and fills in the kernel hashes area in that page, and then
encrypts the whole page.  The rest of the page is reserved for SEV
launch secrets which are not usable anyway on SNP.

If the user disabled kernel hashes, QEMU pre-validates the kernel hashes
page as a zero page.

Signed-off-by: Dov Murik <dovmurik@linux.ibm.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-24-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Reorder struct declarations
Dov Murik [Thu, 30 May 2024 11:16:34 +0000 (06:16 -0500)]
i386/sev: Reorder struct declarations

Move the declaration of PaddedSevHashTable before SevSnpGuest so
we can add a new such field to the latter.

No functional change intended.

Signed-off-by: Dov Murik <dovmurik@linux.ibm.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-23-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Extract build_kernel_loader_hashes
Dov Murik [Thu, 30 May 2024 11:16:33 +0000 (06:16 -0500)]
i386/sev: Extract build_kernel_loader_hashes

Extract the building of the kernel hashes table out from
sev_add_kernel_loader_hashes() to allow building it in
other memory areas (for SNP support).

No functional change intended.

Signed-off-by: Dov Murik <dovmurik@linux.ibm.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-22-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Enable KVM_HC_MAP_GPA_RANGE hcall for SNP guests
Michael Roth [Thu, 30 May 2024 11:16:43 +0000 (06:16 -0500)]
i386/sev: Enable KVM_HC_MAP_GPA_RANGE hcall for SNP guests

KVM will forward GHCB page-state change requests to userspace in the
form of KVM_HC_MAP_GPA_RANGE, so make sure the hypercall handling is
enabled for SNP guests.

Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-32-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/kvm: Add KVM_EXIT_HYPERCALL handling for KVM_HC_MAP_GPA_RANGE
Michael Roth [Thu, 30 May 2024 11:16:42 +0000 (06:16 -0500)]
i386/kvm: Add KVM_EXIT_HYPERCALL handling for KVM_HC_MAP_GPA_RANGE

KVM_HC_MAP_GPA_RANGE will be used to send requests to userspace for
private/shared memory attribute updates requested by the guest.
Implement handling for that use-case along with some basic
infrastructure for enabling specific hypercall events.

Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-31-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Invoke launch_updata_data() for SNP class
Pankaj Gupta [Thu, 30 May 2024 11:16:38 +0000 (06:16 -0500)]
i386/sev: Invoke launch_updata_data() for SNP class

Invoke as sev_snp_launch_update_data() for SNP object.

Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-27-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Invoke launch_updata_data() for SEV class
Paolo Bonzini [Fri, 31 May 2024 10:51:44 +0000 (12:51 +0200)]
i386/sev: Invoke launch_updata_data() for SEV class

Add launch_update_data() in SevCommonStateClass and
invoke as sev_launch_update_data() for SEV object.

Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-26-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agohw/i386/sev: Add support to encrypt BIOS when SEV-SNP is enabled
Brijesh Singh [Thu, 30 May 2024 11:16:36 +0000 (06:16 -0500)]
hw/i386/sev: Add support to encrypt BIOS when SEV-SNP is enabled

As with SEV, an SNP guest requires that the BIOS be part of the initial
encrypted/measured guest payload. Extend sev_encrypt_flash() to handle
the SNP case and plumb through the GPA of the BIOS location since this
is needed for SNP.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-25-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Add support for SNP CPUID validation
Michael Roth [Thu, 30 May 2024 11:16:32 +0000 (06:16 -0500)]
i386/sev: Add support for SNP CPUID validation

SEV-SNP firmware allows a special guest page to be populated with a
table of guest CPUID values so that they can be validated through
firmware before being loaded into encrypted guest memory where they can
be used in place of hypervisor-provided values[1].

As part of SEV-SNP guest initialization, use this interface to validate
the CPUID entries reported by KVM_GET_CPUID2 prior to initial guest
start and populate the CPUID page reserved by OVMF with the resulting
encrypted data.

[1] SEV SNP Firmware ABI Specification, Rev. 0.8, 8.13.2.6

Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-21-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Add support for populating OVMF metadata pages
Brijesh Singh [Thu, 30 May 2024 11:16:31 +0000 (06:16 -0500)]
i386/sev: Add support for populating OVMF metadata pages

OVMF reserves various pages so they can be pre-initialized/validated
prior to launching the guest. Add support for populating these pages
with the expected content.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Co-developed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-20-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agohw/i386/sev: Add function to get SEV metadata from OVMF header
Brijesh Singh [Thu, 30 May 2024 11:16:30 +0000 (06:16 -0500)]
hw/i386/sev: Add function to get SEV metadata from OVMF header

A recent version of OVMF expanded the reset vector GUID list to add
SEV-specific metadata GUID. The SEV metadata describes the reserved
memory regions such as the secrets and CPUID page used during the SEV-SNP
guest launch.

The pc_system_get_ovmf_sev_metadata_ptr() is used to retieve the SEV
metadata pointer from the OVMF GUID list.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-19-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Set CPU state to protected once SNP guest payload is finalized
Michael Roth [Thu, 30 May 2024 11:16:29 +0000 (06:16 -0500)]
i386/sev: Set CPU state to protected once SNP guest payload is finalized

Once KVM_SNP_LAUNCH_FINISH is called the vCPU state is copied into the
vCPU's VMSA page and measured/encrypted. Any attempt to read/write CPU
state afterward will only be acting on the initial data and so are
effectively no-ops.

Set the vCPU state to protected at this point so that QEMU don't
continue trying to re-sync vCPU data during guest runtime.

Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-18-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Add handling to encrypt/finalize guest launch data
Brijesh Singh [Thu, 30 May 2024 11:16:28 +0000 (06:16 -0500)]
i386/sev: Add handling to encrypt/finalize guest launch data

Process any queued up launch data and encrypt/measure it into the SNP
guest instance prior to initial guest launch.

This also updates the KVM_SEV_SNP_LAUNCH_UPDATE call to handle partial
update responses.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Co-developed-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Co-developed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-17-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Add the SNP launch start context
Brijesh Singh [Thu, 30 May 2024 11:16:27 +0000 (06:16 -0500)]
i386/sev: Add the SNP launch start context

The SNP_LAUNCH_START is called first to create a cryptographic launch
context within the firmware.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Co-developed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-16-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Update query-sev QAPI format to handle SEV-SNP
Michael Roth [Thu, 30 May 2024 11:16:26 +0000 (06:16 -0500)]
i386/sev: Update query-sev QAPI format to handle SEV-SNP

Most of the current 'query-sev' command is relevant to both legacy
SEV/SEV-ES guests and SEV-SNP guests, with 2 exceptions:

  - 'policy' is a 64-bit field for SEV-SNP, not 32-bit, and
    the meaning of the bit positions has changed
  - 'handle' is not relevant to SEV-SNP

To address this, this patch adds a new 'sev-type' field that can be
used as a discriminator to select between SEV and SEV-SNP-specific
fields/formats without breaking compatibility for existing management
tools (so long as management tools that add support for launching
SEV-SNP guest update their handling of query-sev appropriately).

The corresponding HMP command has also been fixed up similarly.

Signed-off-by: Michael Roth <michael.roth@amd.com>
Co-developed-by:Pankaj Gupta <pankaj.gupta@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-15-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Add a class method to determine KVM VM type for SNP guests
Paolo Bonzini [Fri, 31 May 2024 10:44:44 +0000 (12:44 +0200)]
i386/sev: Add a class method to determine KVM VM type for SNP guests

SEV guests can use either KVM_X86_DEFAULT_VM, KVM_X86_SEV_VM,
or KVM_X86_SEV_ES_VM depending on the configuration and what
the host kernel supports. SNP guests on the other hand can only
ever use KVM_X86_SNP_VM, so split determination of VM type out
into a separate class method that can be set accordingly for
sev-guest vs. sev-snp-guest objects and add handling for SNP.

Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-14-pankaj.gupta@amd.com>
[Remove unnecessary function pointer declaration. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Don't return launch measurements for SEV-SNP guests
Michael Roth [Thu, 30 May 2024 11:16:24 +0000 (06:16 -0500)]
i386/sev: Don't return launch measurements for SEV-SNP guests

For SEV-SNP guests, launch measurement is queried from within the guest
during attestation, so don't attempt to return it as part of
query-sev-launch-measure.

Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-13-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/cpu: Set SEV-SNP CPUID bit when SNP enabled
Michael Roth [Thu, 30 May 2024 11:16:23 +0000 (06:16 -0500)]
i386/cpu: Set SEV-SNP CPUID bit when SNP enabled

SNP guests will rely on this bit to determine certain feature support.

Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-12-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Add snp_kvm_init() override for SNP class
Pankaj Gupta [Thu, 30 May 2024 11:16:22 +0000 (06:16 -0500)]
i386/sev: Add snp_kvm_init() override for SNP class

SNP does not support SMM and requires guest_memfd for
private guest memory, so add SNP specific kvm_init()
functionality in snp_kvm_init() class method.

Signed-off-by: Michael Roth <michael.roth@amd.com>
Co-developed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-11-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Add sev_kvm_init() override for SEV class
Pankaj Gupta [Thu, 30 May 2024 11:16:21 +0000 (06:16 -0500)]
i386/sev: Add sev_kvm_init() override for SEV class

Some aspects of the init routine SEV are specific to SEV and not
applicable for SNP guests, so move the SEV-specific bits into
separate class method and retain only the common functionality.

Co-developed-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-10-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Add a sev_snp_enabled() helper
Michael Roth [Thu, 30 May 2024 11:16:20 +0000 (06:16 -0500)]
i386/sev: Add a sev_snp_enabled() helper

Add a simple helper to check if the current guest type is SNP. Also have
SNP-enabled imply that SEV-ES is enabled as well, and fix up any places
where the sev_es_enabled() check is expecting a pure/non-SNP guest.

Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-9-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Introduce 'sev-snp-guest' object
Brijesh Singh [Thu, 30 May 2024 11:16:19 +0000 (06:16 -0500)]
i386/sev: Introduce 'sev-snp-guest' object

SEV-SNP support relies on a different set of properties/state than the
existing 'sev-guest' object. This patch introduces the 'sev-snp-guest'
object, which can be used to configure an SEV-SNP guest. For example,
a default-configured SEV-SNP guest with no additional information
passed in for use with attestation:

  -object sev-snp-guest,id=sev0

or a fully-specified SEV-SNP guest where all spec-defined binary
blobs are passed in as base64-encoded strings:

  -object sev-snp-guest,id=sev0, \
    policy=0x30000, \
    init-flags=0, \
    id-block=YWFhYWFhYWFhYWFhYWFhCg==, \
    id-auth=CxHK/OKLkXGn/KpAC7Wl1FSiisWDbGTEKz..., \
    author-key-enabled=on, \
    host-data=LNkCWBRC5CcdGXirbNUV1OrsR28s..., \
    guest-visible-workarounds=AA==, \

See the QAPI schema updates included in this patch for more usage
details.

In some cases these blobs may be up to 4096 characters, but this is
generally well below the default limit for linux hosts where
command-line sizes are defined by the sysconf-configurable ARG_MAX
value, which defaults to 2097152 characters for Ubuntu hosts, for
example.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Co-developed-by: Michael Roth <michael.roth@amd.com>
Acked-by: Markus Armbruster <armbru@redhat.com> (for QAPI schema)
Signed-off-by: Michael Roth <michael.roth@amd.com>
Co-developed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-8-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Move sev_launch_finish to separate class method
Pankaj Gupta [Thu, 30 May 2024 11:16:18 +0000 (06:16 -0500)]
i386/sev: Move sev_launch_finish to separate class method

When sev-snp-guest objects are introduced there will be a number of
differences in how the launch finish is handled compared to the existing
sev-guest object. Move sev_launch_finish() to a class method to make it
easier to implement SNP-specific launch update functionality later.

Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-7-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Move sev_launch_update to separate class method
Pankaj Gupta [Thu, 30 May 2024 11:16:17 +0000 (06:16 -0500)]
i386/sev: Move sev_launch_update to separate class method

When sev-snp-guest objects are introduced there will be a number of
differences in how the launch data is handled compared to the existing
sev-guest object. Move sev_launch_start() to a class method to make it
easier to implement SNP-specific launch update functionality later.

Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-6-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Introduce "sev-common" type to encapsulate common SEV state
Michael Roth [Thu, 30 May 2024 11:16:16 +0000 (06:16 -0500)]
i386/sev: Introduce "sev-common" type to encapsulate common SEV state

Currently all SEV/SEV-ES functionality is managed through a single
'sev-guest' QOM type. With upcoming support for SEV-SNP, taking this
same approach won't work well since some of the properties/state
managed by 'sev-guest' is not applicable to SEV-SNP, which will instead
rely on a new QOM type with its own set of properties/state.

To prepare for this, this patch moves common state into an abstract
'sev-common' parent type to encapsulate properties/state that are
common to both SEV/SEV-ES and SEV-SNP, leaving only SEV/SEV-ES-specific
properties/state in the current 'sev-guest' type. This should not
affect current behavior or command-line options.

As part of this patch, some related changes are also made:

  - a static 'sev_guest' variable is currently used to keep track of
    the 'sev-guest' instance. SEV-SNP would similarly introduce an
    'sev_snp_guest' static variable. But these instances are now
    available via qdev_get_machine()->cgs, so switch to using that
    instead and drop the static variable.

  - 'sev_guest' is currently used as the name for the static variable
    holding a pointer to the 'sev-guest' instance. Re-purpose the name
    as a local variable referring the 'sev-guest' instance, and use
    that consistently throughout the code so it can be easily
    distinguished from sev-common/sev-snp-guest instances.

  - 'sev' is generally used as the name for local variables holding a
    pointer to the 'sev-guest' instance. In cases where that now points
    to common state, use the name 'sev_common'; in cases where that now
    points to state specific to 'sev-guest' instance, use the name
    'sev_guest'

In order to enable kernel-hashes for SNP, pull it from
SevGuestProperties to its parent SevCommonProperties so
it will be available for both SEV and SNP.

Signed-off-by: Michael Roth <michael.roth@amd.com>
Co-developed-by: Dov Murik <dovmurik@linux.ibm.com>
Signed-off-by: Dov Murik <dovmurik@linux.ibm.com>
Acked-by: Markus Armbruster <armbru@redhat.com> (QAPI schema)
Co-developed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-5-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoi386/sev: Replace error_report with error_setg
Pankaj Gupta [Thu, 30 May 2024 11:16:13 +0000 (06:16 -0500)]
i386/sev: Replace error_report with error_setg

Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-2-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agomachine: allow early use of machine_require_guest_memfd
Paolo Bonzini [Fri, 31 May 2024 11:29:53 +0000 (13:29 +0200)]
machine: allow early use of machine_require_guest_memfd

Ask the ConfidentialGuestSupport object whether to use guest_memfd
for KVM-backend private memory.  This bool can be set in instance_init
(or user_complete) so that it is available when the machine is created.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoupdate-linux-headers: import linux/kvm_para.h header
Paolo Bonzini [Mon, 3 Jun 2024 12:25:06 +0000 (14:25 +0200)]
update-linux-headers: import linux/kvm_para.h header

Right now QEMU is importing arch/x86/include/uapi/asm/kvm_para.h
because it includes definitions for kvmclock and for KVM CPUID
bits.  However, other definitions for KVM hypercall values and return
codes are included in include/uapi/linux/kvm_para.h and they will be
used by SEV-SNP.

To ensure that it is possible to include both <linux/kvm_para.h> and
"standard-headers/asm-x86/kvm_para.h" without conflicts, provide
linux/kvm_para.h as a portable header too, and forward linux-headers/
files to those in include/standard-headers.  Note that <linux/kvm_para.h>
will include architecture-specific definitions as well, but
"standard-headers/linux/kvm_para.h" will not because it can be used in
architecture-independent files.

This could easily be extended to other architectures, but right now
they do not need any symbol in their specific kvm_para.h files.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agolinux-headers: Update to current kvm/next
Pankaj Gupta [Thu, 30 May 2024 11:16:14 +0000 (06:16 -0500)]
linux-headers: Update to current kvm/next

This updates kernel headers to commit 6f627b425378 ("KVM: SVM: Add module
parameter to enable SEV-SNP", 2024-05-12).  The SNP host patches will
be included in Linux 6.11, to be released next July.

Also brings in an linux-headers/linux/vhost.h fix from v6.9-rc4.

Co-developed-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-3-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoupdate-linux-headers: move pvpanic.h to correct directory
Paolo Bonzini [Mon, 3 Jun 2024 12:16:55 +0000 (14:16 +0200)]
update-linux-headers: move pvpanic.h to correct directory

Linux has <misc/pvpanic.h>, not <linux/pvpanic.h>.  Use the same
directory for QEMU's include/standard-headers/ copy.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agoupdate-linux-headers: fix forwarding to asm-generic headers
Paolo Bonzini [Mon, 3 Jun 2024 11:49:49 +0000 (13:49 +0200)]
update-linux-headers: fix forwarding to asm-generic headers

Afer commit 3efc75ad9d9 ("scripts/update-linux-headers.sh: Remove
temporary directory inbetween", 2024-05-29), updating linux-headers/
results in errors such as

   cp: cannot stat '/tmp/tmp.1A1Eejh1UE/headers/include/asm/bitsperlong.h': No such file or directory

because Loongarch does not have an asm/bitsperlong.h file and uses the
generic version.  Before commit 3efc75ad9d9, the missing file would
incorrectly cause stale files to be included in linux-headers/.  The files
were never committed to qemu.git, but were wrong nevertheless. The build
would just use the system version of the files, which is opposite to
the idea of importing Linux header files into QEMU's tree.

Create forwarding headers, resembling the ones that are generated during a
kernel build by scripts/Makefile.asm-generic, if a file is only installed
under include/asm-generic/.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
11 months agotarget/i386: fix xsave.flat from kvm-unit-tests
Paolo Bonzini [Mon, 3 Jun 2024 10:01:12 +0000 (12:01 +0200)]
target/i386: fix xsave.flat from kvm-unit-tests

xsave.flat checks that "executing the XSETBV instruction causes a general-
protection fault (#GP) if ECX = 0 and EAX[2:1] has the value 10b".  QEMU allows
that option, so the test fails.  Add the condition.

Cc: qemu-stable@nongnu.org
Fixes: 892544317fe ("target/i386: implement XSAVE and XRSTOR of AVX registers", 2022-10-18)
Reported-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>