Skip to content

Commit 08a9b68

Browse files
committed
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* Meson version update * fix search path when configuring with --cpu * support for measured SEV boot with -kernel (Dov) * fix missing BQL locks (Emanuele) * retrieve applesmc key from the host (Pedro) * KVM PV feature documentation (Vitaly) # gpg: Signature made Tue 05 Oct 2021 04:13:00 AM PDT # gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83 # gpg: issuer "[email protected]" # gpg: Good signature from "Paolo Bonzini <[email protected]>" [full] # gpg: aka "Paolo Bonzini <[email protected]>" [full] * remotes/bonzini/tags/for-upstream: meson: show library versions in the summary target/xtensa: list cores in a text file hexagon: use env keyword argument to pass PYTHONPATH meson: switch minimum meson version to 0.58.2, minimum recommended to 0.59.2 meson: bump submodule to 0.59.2 migration: add missing qemu_mutex_lock_iothread in migration_completion migration: block-dirty-bitmap: add missing qemu_mutex_lock_iothread configure, meson: move CPU_CFLAGS out of QEMU_CFLAGS hw/misc: applesmc: use host osk as default on macs x86/sev: generate SEV kernel loader hashes in x86_load_linux sev/i386: Introduce sev_add_kernel_loader_hashes for measured linux boot i386: docs: Briefly describe KVM PV features Signed-off-by: Richard Henderson <[email protected]>
2 parents 9618c5b + bb647c4 commit 08a9b68

File tree

23 files changed

+598
-127
lines changed

23 files changed

+598
-127
lines changed

configure

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ lines: ${BASH_LINENO[*]}"
142142
}
143143

144144
do_cc() {
145-
do_compiler "$cc" "$@"
145+
do_compiler "$cc" $CPU_CFLAGS "$@"
146146
}
147147

148148
do_cxx() {
149-
do_compiler "$cxx" "$@"
149+
do_compiler "$cxx" $CPU_CFLAGS "$@"
150150
}
151151

152152
# Append $2 to the variable named $1, with space separation
@@ -1688,7 +1688,6 @@ esac
16881688

16891689
eval "cross_cc_${cpu}=\$cc"
16901690
cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
1691-
QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
16921691

16931692
# For user-mode emulation the host arch has to be one we explicitly
16941693
# support, even if we're using TCI.
@@ -1995,7 +1994,7 @@ python_version=$($python -c 'import sys; print("%d.%d.%d" % (sys.version_info[0]
19951994
python="$python -B"
19961995

19971996
if test -z "$meson"; then
1998-
if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.55.3; then
1997+
if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.2; then
19991998
meson=meson
20001999
elif test $git_submodules_action != 'ignore' ; then
20012000
meson=git
@@ -5114,9 +5113,9 @@ if test "$skip_meson" = no; then
51145113
echo "c_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
51155114
echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
51165115
echo "[binaries]" >> $cross
5117-
echo "c = [$(meson_quote $cc)]" >> $cross
5118-
test -n "$cxx" && echo "cpp = [$(meson_quote $cxx)]" >> $cross
5119-
test -n "$objcc" && echo "objc = [$(meson_quote $objcc)]" >> $cross
5116+
echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
5117+
test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
5118+
test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
51205119
echo "ar = [$(meson_quote $ar)]" >> $cross
51215120
echo "nm = [$(meson_quote $nm)]" >> $cross
51225121
echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
@@ -5164,10 +5163,6 @@ if test "$skip_meson" = no; then
51645163
mv $cross config-meson.cross
51655164

51665165
rm -rf meson-private meson-info meson-logs
5167-
unset staticpic
5168-
if ! version_ge "$($meson --version)" 0.56.0; then
5169-
staticpic=$(if test "$pie" = yes; then echo true; else echo false; fi)
5170-
fi
51715166
NINJA=$ninja $meson setup \
51725167
--prefix "$prefix" \
51735168
--libdir "$libdir" \
@@ -5187,7 +5182,6 @@ if test "$skip_meson" = no; then
51875182
-Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
51885183
-Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
51895184
-Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
5190-
${staticpic:+-Db_staticpic=$staticpic} \
51915185
-Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
51925186
-Db_lto=$lto -Dcfi=$cfi -Dcfi_debug=$cfi_debug \
51935187
-Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \
@@ -5223,6 +5217,7 @@ else
52235217
perl -i -ne '
52245218
s/^gettext = true$/gettext = auto/;
52255219
s/^gettext = false$/gettext = disabled/;
5220+
/^b_staticpic/ && next;
52265221
print;' meson-private/cmd_line.txt
52275222
fi
52285223
fi

docs/meson.build

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ endif
3737
if build_docs
3838
SPHINX_ARGS += ['-Dversion=' + meson.project_version(), '-Drelease=' + config_host['PKGVERSION']]
3939

40-
sphinx_extn_depends = [ meson.source_root() / 'docs/sphinx/depfile.py',
41-
meson.source_root() / 'docs/sphinx/hxtool.py',
42-
meson.source_root() / 'docs/sphinx/kerneldoc.py',
43-
meson.source_root() / 'docs/sphinx/kernellog.py',
44-
meson.source_root() / 'docs/sphinx/qapidoc.py',
45-
meson.source_root() / 'docs/sphinx/qmp_lexer.py',
40+
sphinx_extn_depends = [ meson.current_source_dir() / 'sphinx/depfile.py',
41+
meson.current_source_dir() / 'sphinx/hxtool.py',
42+
meson.current_source_dir() / 'sphinx/kerneldoc.py',
43+
meson.current_source_dir() / 'sphinx/kernellog.py',
44+
meson.current_source_dir() / 'sphinx/qapidoc.py',
45+
meson.current_source_dir() / 'sphinx/qmp_lexer.py',
4646
qapi_gen_depends ]
47-
sphinx_template_files = [ meson.source_root() / 'docs/_templates/footer.html' ]
47+
sphinx_template_files = [ meson.project_source_root() / 'docs/_templates/footer.html' ]
4848

4949
have_ga = have_tools and config_host.has_key('CONFIG_GUEST_AGENT')
5050

docs/system/i386/kvm-pv.rst

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
Paravirtualized KVM features
2+
============================
3+
4+
Description
5+
-----------
6+
7+
In some cases when implementing hardware interfaces in software is slow, ``KVM``
8+
implements its own paravirtualized interfaces.
9+
10+
Setup
11+
-----
12+
13+
Paravirtualized ``KVM`` features are represented as CPU flags. The following
14+
features are enabled by default for any CPU model when ``KVM`` acceleration is
15+
enabled:
16+
17+
- ``kvmclock``
18+
- ``kvm-nopiodelay``
19+
- ``kvm-asyncpf``
20+
- ``kvm-steal-time``
21+
- ``kvm-pv-eoi``
22+
- ``kvmclock-stable-bit``
23+
24+
``kvm-msi-ext-dest-id`` feature is enabled by default in x2apic mode with split
25+
irqchip (e.g. "-machine ...,kernel-irqchip=split -cpu ...,x2apic").
26+
27+
Note: when CPU model ``host`` is used, QEMU passes through all supported
28+
paravirtualized ``KVM`` features to the guest.
29+
30+
Existing features
31+
-----------------
32+
33+
``kvmclock``
34+
Expose a ``KVM`` specific paravirtualized clocksource to the guest. Supported
35+
since Linux v2.6.26.
36+
37+
``kvm-nopiodelay``
38+
The guest doesn't need to perform delays on PIO operations. Supported since
39+
Linux v2.6.26.
40+
41+
``kvm-mmu``
42+
This feature is deprecated.
43+
44+
``kvm-asyncpf``
45+
Enable asynchronous page fault mechanism. Supported since Linux v2.6.38.
46+
Note: since Linux v5.10 the feature is deprecated and not enabled by ``KVM``.
47+
Use ``kvm-asyncpf-int`` instead.
48+
49+
``kvm-steal-time``
50+
Enable stolen (when guest vCPU is not running) time accounting. Supported
51+
since Linux v3.1.
52+
53+
``kvm-pv-eoi``
54+
Enable paravirtualized end-of-interrupt signaling. Supported since Linux
55+
v3.10.
56+
57+
``kvm-pv-unhalt``
58+
Enable paravirtualized spinlocks support. Supported since Linux v3.12.
59+
60+
``kvm-pv-tlb-flush``
61+
Enable paravirtualized TLB flush mechanism. Supported since Linux v4.16.
62+
63+
``kvm-pv-ipi``
64+
Enable paravirtualized IPI mechanism. Supported since Linux v4.19.
65+
66+
``kvm-poll-control``
67+
Enable host-side polling on HLT control from the guest. Supported since Linux
68+
v5.10.
69+
70+
``kvm-pv-sched-yield``
71+
Enable paravirtualized sched yield feature. Supported since Linux v5.10.
72+
73+
``kvm-asyncpf-int``
74+
Enable interrupt based asynchronous page fault mechanism. Supported since Linux
75+
v5.10.
76+
77+
``kvm-msi-ext-dest-id``
78+
Support 'Extended Destination ID' for external interrupts. The feature allows
79+
to use up to 32768 CPUs without IRQ remapping (but other limits may apply making
80+
the number of supported vCPUs for a given configuration lower). Supported since
81+
Linux v5.10.
82+
83+
``kvmclock-stable-bit``
84+
Tell the guest that guest visible TSC value can be fully trusted for kvmclock
85+
computations and no warps are expected. Supported since Linux v2.6.35.
86+
87+
Supplementary features
88+
----------------------
89+
90+
``kvm-pv-enforce-cpuid``
91+
Limit the supported paravirtualized feature set to the exposed features only.
92+
Note, by default, ``KVM`` allows the guest to use all currently supported
93+
paravirtualized features even when they were not announced in guest visible
94+
CPUIDs. Supported since Linux v5.10.
95+
96+
97+
Useful links
98+
------------
99+
100+
Please refer to Documentation/virt/kvm in Linux for additional details.

docs/system/target-i386.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Architectural features
2626
:maxdepth: 1
2727

2828
i386/cpu
29+
i386/kvm-pv
2930
i386/sgx
3031

3132
.. _pcsys_005freq:

hw/i386/x86.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include "hw/i386/fw_cfg.h"
4848
#include "hw/intc/i8259.h"
4949
#include "hw/rtc/mc146818rtc.h"
50+
#include "target/i386/sev_i386.h"
5051

5152
#include "hw/acpi/cpu_hotplug.h"
5253
#include "hw/irq.h"
@@ -780,6 +781,7 @@ void x86_load_linux(X86MachineState *x86ms,
780781
const char *initrd_filename = machine->initrd_filename;
781782
const char *dtb_filename = machine->dtb;
782783
const char *kernel_cmdline = machine->kernel_cmdline;
784+
SevKernelLoaderContext sev_load_ctx = {};
783785

784786
/* Align to 16 bytes as a paranoia measure */
785787
cmdline_size = (strlen(kernel_cmdline) + 16) & ~15;
@@ -926,6 +928,8 @@ void x86_load_linux(X86MachineState *x86ms,
926928
fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_ADDR, cmdline_addr);
927929
fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(kernel_cmdline) + 1);
928930
fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline);
931+
sev_load_ctx.cmdline_data = (char *)kernel_cmdline;
932+
sev_load_ctx.cmdline_size = strlen(kernel_cmdline) + 1;
929933

930934
if (protocol >= 0x202) {
931935
stl_p(header + 0x228, cmdline_addr);
@@ -1007,6 +1011,8 @@ void x86_load_linux(X86MachineState *x86ms,
10071011
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr);
10081012
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);
10091013
fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, initrd_data, initrd_size);
1014+
sev_load_ctx.initrd_data = initrd_data;
1015+
sev_load_ctx.initrd_size = initrd_size;
10101016

10111017
stl_p(header + 0x218, initrd_addr);
10121018
stl_p(header + 0x21c, initrd_size);
@@ -1065,15 +1071,32 @@ void x86_load_linux(X86MachineState *x86ms,
10651071
load_image_size(dtb_filename, setup_data->data, dtb_size);
10661072
}
10671073

1068-
memcpy(setup, header, MIN(sizeof(header), setup_size));
1074+
/*
1075+
* If we're starting an encrypted VM, it will be OVMF based, which uses the
1076+
* efi stub for booting and doesn't require any values to be placed in the
1077+
* kernel header. We therefore don't update the header so the hash of the
1078+
* kernel on the other side of the fw_cfg interface matches the hash of the
1079+
* file the user passed in.
1080+
*/
1081+
if (!sev_enabled()) {
1082+
memcpy(setup, header, MIN(sizeof(header), setup_size));
1083+
}
10691084

10701085
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr);
10711086
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
10721087
fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size);
1088+
sev_load_ctx.kernel_data = (char *)kernel;
1089+
sev_load_ctx.kernel_size = kernel_size;
10731090

10741091
fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_ADDR, real_addr);
10751092
fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_SIZE, setup_size);
10761093
fw_cfg_add_bytes(fw_cfg, FW_CFG_SETUP_DATA, setup, setup_size);
1094+
sev_load_ctx.setup_data = (char *)setup;
1095+
sev_load_ctx.setup_size = setup_size;
1096+
1097+
if (sev_enabled()) {
1098+
sev_add_kernel_loader_hashes(&sev_load_ctx, &error_fatal);
1099+
}
10771100

10781101
option_rom[nb_option_roms].bootindex = 0;
10791102
option_rom[nb_option_roms].name = "linuxboot.bin";

0 commit comments

Comments
 (0)