Patch Round-up for stable 2.11.1, freeze on 2018-02-12
Subsystems (2)
cover Patch Round-up for stable 2.11.1, freeze on 2018-02-12
Hi everyone,
The following new patches are queued for QEMU stable v2.11.1:
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2017-02-14:
https://wiki.qemu.org/Planning/2.11
Please respond here or CC [email protected] on any patches you think should be included in the release.
Of particular importance would be any feedback on the various QEMU patches relating to Spectre/Meltdown mitigation. The current tree has what I understand to be the QEMU components required for x86, s390, and pseries, but feedback/confirmation from the various authors would be greatly appreciated.
Thanks!
----------------------------------------------------------------
The following changes since commit 0a0dc59d27527b78a195c2d838d28b7b49e5a639:
Update version for v2.11.0 release (2017-12-13 14:31:09 +0000)
are available in the git repository at:
git://github.com/mdroth/qemu.git stable-2.11-staging
for you to fetch changes up to ed8b4ecc68d6bfe98000b08d649049d0c1174c11:
target/ppc/spapr: Add H-Call H_GET_CPU_CHARACTERISTICS (2018-02-05 19:07:38 -0600)
----------------------------------------------------------------
Alex Bennée (1):
target/sh4: fix TCG leak during gusa sequence
Alex Williamson (1):
vfio: Fix vfio-kvm group registration
Christian Borntraeger (2):
s390x/kvm: Handle bpb feature
s390x/kvm: provide stfle.81Claudio Imbrenda (1):
s390x: fix storage attributes migration for non-small guests
Cornelia Huck (1):
linux-headers: update
Cédric Le Goater (1):
target/ppc: introduce the PPC_BIT() macro
David Gibson (7):
spapr: Add pseries-2.12 machine type
spapr: Capabilities infrastructure
spapr: Treat Hardware Transactional Memory (HTM) as an optional capability
spapr: Validate capabilities on migration
target/ppc: Clean up probing of VMX, VSX and DFP availability on KVM
spapr: Handle VMX/VSX presence as an spapr capability flag
spapr: Handle Decimal Floating Point (DFP) as an optional capability
Eduardo Habkost (5):
i386: Change X86CPUDefinition::model_id to const char*
i386: Add spec-ctrl CPUID bit
i386: Add FEAT_8000_0008_EBX CPUID feature word
i386: Add new -IBRS versions of Intel CPU models
i386: Add EPYC-IBPB CPU model
Eric Auger (1):
linux-headers: update to 4.15-rc1
Fam Zheng (3):
block: Open backing image in force share mode for size probe
osdep: Retry SETLK upon EINTR
usb-storage: Fix share-rw option parsing
Greg Kurz (2):
spapr_pci: fix MSI/MSIX selection
spapr: fix device tree properties when using compatibility mode
Jay Zhou (1):
vhost: remove assertion to prevent crash
Jose Ricardo Ziviani (1):
ppc: Change Power9 compat table to support at most 8 threads/core
Kevin Wolf (2):
block: Make bdrv_drain_invoke() recursive
block: Call .drain_begin only once in bdrv_drain_all_begin()
Laurent Vivier (1):
spapr: don't initialize PATB entry if max-cpu-compat < power9
Marcel Apfelbaum (1):
hw/pci-bridge: fix QEMU crash because of pcie-root-port
Markus Armbruster (1):
qemu-options: Remove stray colons from output of --help
Michael S. Tsirkin (1):
virtio_error: don't invoke status callbacks
Murilo Opsfelder Araujo (1):
block/nbd: fix segmentation fault when .desc is not null-terminated
Paolo Bonzini (2):
qemu-pr-helper: miscellaneous fixes
i386: Add support for SPEC_CTRL MSR
Peter Lieven (1):
block/iscsi: dont leave allocmap in an invalid state on UNMAP failure
Peter Maydell (8):
target/i386: Fix handling of VEX prefixes hw/intc/arm_gicv3: Make reserved register addresses RAZ/WI hw/intc/arm_gic: reserved register addresses are RAZ/WI hw/sd/pl181: Reset SD card on controller reset hw/sd/milkymist-memcard: Reset SD card on controller reset hw/sd/ssi-sd: Reset SD card on controller reset
linux-user: Fix locking order in fork_start() linux-user/signal.c: Rename MC_* defines
Stefan Hajnoczi (1):
scsi-disk: release AioContext in unaligned WRITE SAME case
Suraj Jitindar Singh (8):
hw/ppc/spapr_caps: Rework spapr_caps to use uint8 internal representation target/ppc/spapr_caps: Add macro to generate spapr_caps migration vmstate target/ppc/kvm: Add cap_ppc_safe_[cache/bounds_check/indirect_branch] target/ppc/spapr_caps: Add support for tristate spapr_capabilities target/ppc/spapr_caps: Add new tristate cap safe_cache target/ppc/spapr_caps: Add new tristate cap safe_bounds_check target/ppc/spapr_caps: Add new tristate cap safe_indirect_branch target/ppc/spapr: Add H-Call H_GET_CPU_CHARACTERISTICS
block.c | 3 +- block/io.c | 13 +- block/iscsi.c | 8 +- block/nbd.c | 1 + hw/intc/arm_gic.c | 5 +- hw/intc/arm_gicv3_dist.c | 13 + hw/intc/arm_gicv3_its_common.c | 8 +- hw/intc/arm_gicv3_redist.c | 13 + hw/pci-bridge/gen_pcie_root_port.c | 7 +- hw/ppc/Makefile.objs | 2 +- hw/ppc/spapr.c | 130 ++++-- hw/ppc/spapr_caps.c | 443 ++++++++++++++++++++ hw/ppc/spapr_cpu_core.c | 7 + hw/ppc/spapr_hcall.c | 58 +++ hw/ppc/spapr_pci.c | 61 ++- hw/s390x/s390-stattrib-kvm.c | 4 +- hw/scsi/scsi-bus.c | 9 +- hw/scsi/scsi-disk.c | 1 + hw/sd/milkymist-memcard.c | 4 + hw/sd/pl181.c | 4 + hw/sd/ssi-sd.c | 25 +- hw/usb/dev-storage.c | 3 +- hw/vfio/common.c | 1 + hw/virtio/vhost-user.c | 5 +- hw/virtio/virtio.c | 2 +- include/hw/compat.h | 2 + include/hw/ppc/spapr.h | 74 ++++ include/hw/scsi/scsi.h | 1 + include/scsi/utils.h | 6 +- include/standard-headers/asm-s390/virtio-ccw.h | 5 +- include/standard-headers/asm-x86/hyperv.h | 394 +----------------- include/standard-headers/linux/input-event-codes.h | 2 + include/standard-headers/linux/input.h | 1 + include/standard-headers/linux/pci_regs.h | 45 +- linux-headers/asm-arm/kvm.h | 8 + linux-headers/asm-arm/kvm_para.h | 1 + linux-headers/asm-arm/unistd.h | 2 + linux-headers/asm-arm64/kvm.h | 8 + linux-headers/asm-arm64/unistd.h | 1 + linux-headers/asm-powerpc/epapr_hcalls.h | 1 + linux-headers/asm-powerpc/kvm.h | 26 ++ linux-headers/asm-powerpc/kvm_para.h | 1 + linux-headers/asm-powerpc/unistd.h | 1 + linux-headers/asm-s390/kvm.h | 10 +- linux-headers/asm-s390/kvm_para.h | 5 +- linux-headers/asm-s390/unistd.h | 4 +- linux-headers/asm-x86/kvm.h | 1 + linux-headers/asm-x86/kvm_para.h | 2 +- linux-headers/asm-x86/unistd.h | 1 + linux-headers/linux/kvm.h | 10 +- linux-headers/linux/kvm_para.h | 1 + linux-headers/linux/psci.h | 1 + linux-headers/linux/userfaultfd.h | 1 + linux-headers/linux/vfio.h | 1 + linux-headers/linux/vfio_ccw.h | 1 + linux-headers/linux/vhost.h | 1 + linux-user/main.c | 4 +- linux-user/signal.c | 118 +++--- qemu-options-wrapper.h | 2 +- qemu-options.hx | 27 +- scripts/hxtool | 3 +- scsi/qemu-pr-helper.c | 30 +- scsi/utils.c | 10 + target/i386/cpu.c | 455 ++++++++++++++++++++- target/i386/cpu.h | 7 + target/i386/kvm.c | 14 + target/i386/machine.c | 20 + target/i386/translate.c | 2 +- target/ppc/compat.c | 9 +- target/ppc/cpu.h | 105 ++--- target/ppc/kvm.c | 85 +++- target/ppc/kvm_ppc.h | 20 +- target/s390x/cpu.c | 1 + target/s390x/cpu.h | 1 + target/s390x/cpu_features.c | 2 + target/s390x/cpu_features_def.h | 2 + target/s390x/gen-features.c | 2 + target/s390x/kvm.c | 14 + target/s390x/machine.c | 17 + target/sh4/translate.c | 2 +- util/osdep.c | 4 +- 81 files changed, 1746 insertions(+), 658 deletions(-) create mode 100644 hw/ppc/spapr_caps.c
PATCH 1/54 target/i386: Fix handling of VEX prefixes
From: Peter Maydell <[email protected]>
In commit e3af7c788b73a6495eb9d94992ef11f6ad6f3c56 we replaced direct calls to to cpu_ld*_code() with calls to the x86_ld*_code() wrappers which incorporate an advance of s->pc. Unfortunately we didn't notice that in one place the old code was deliberately not incrementing s->pc:
@@ -4501,7 +4528,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)
static const int pp_prefix[4] = {
0, PREFIX_DATA, PREFIX_REPZ, PREFIX_REPNZ
};- int vex3, vex2 = cpu_ldub_code(env, s->pc);
+ int vex3, vex2 = x86_ldub_code(env, s);
if (!CODE64(s) && (vex2 & 0xc0) != 0xc0) {
/* 4.1.4.6: In 32-bit mode, bits [7:6] must be 11b,This meant we were mishandling this set of instructions. Remove the manual advance of s->pc for the "is VEX" case (which is now done by x86_ldub_code()) and instead rewind PC in the case where we decide that this isn't really VEX.
Message-Id: <[email protected]>
--- target/i386/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/translate.c +1 -1
@@ -4547,9 +4547,9 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)if (!CODE64 (s) && (vex2 &0xc0 ) !=0xc0 ) {/* 4.1.4.6: In 32-bit mode, bits [7:6] must be 11b, otherwise the instruction is LES or LDS. */ + s->pc--;/* rewind the advance_pc() x86_ldub_code() did */ break ; } - s->pc++;/* 4.1.1-4.1.3: No preceding lock, 66, f2, f3, or rex prefixes. */ if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ
Signature · 1 line
2.11.0
PATCH 2/54 block/iscsi: dont leave allocmap in an invalid state on UNMAP failure
In reply to Michael RothFrom: Peter Lieven <[email protected]>
we forgot to set the allocmap to invalid if an UNMAP call fails.
Message-Id: <[email protected]>
--- block/iscsi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
block/iscsi.c +4 -4
@@ -2,7 +2,7 @@* QEMU Block driver for iSCSI images * * Copyright (c) 2010-2011 Ronnie Sahlberg <[email protected]> -* Copyright (c) 2012-2016 Peter Lieven <[email protected]> +* Copyright (c) 2012-2017 Peter Lieven <[email protected]> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal
@@ -1128,6 +1128,9 @@ retry: goto retry; } +iscsi_allocmap_set_invalid (iscsilun, offset >>BDRV_SECTOR_BITS , + bytes >>BDRV_SECTOR_BITS ); +if (iTask.status ==SCSI_STATUS_CHECK_CONDITION ) {/* the target might fail with a check condition if it is not happy with the alignment of the UNMAP request
@@ -1140,9 +1143,6 @@ retry: goto out_unlock; } -iscsi_allocmap_set_invalid (iscsilun, offset >>BDRV_SECTOR_BITS , - bytes >>BDRV_SECTOR_BITS ); - out_unlock:qemu_mutex_unlock (&iscsilun->mutex);return r;
Signature · 1 line
2.11.0
PATCH 3/54 target/sh4: fix TCG leak during gusa sequence
In reply to Michael RothFrom: Alex Bennée <[email protected]>
This fixes bug #1735384 while running java under qemu-sh4. When debug was enabled it showed a problem with TCG temps. Once fixed I was able to run java -version normally.
Message-Id: <[email protected]>
--- target/sh4/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/sh4/translate.c +1 -1
@@ -2189,7 +2189,7 @@ static int decode_gusa(DisasContext *ctx, CPUSH4State *env, int *pmax_insns) }/* If op_src is not a valid register, then op_arg was a constant. */ -if (op_src <0 ) { +if (op_src <0 && !TCGV_IS_UNUSED (op_arg)) {tcg_temp_free_i32 (op_arg); }
Signature · 1 line
2.11.0
PATCH 4/54 qemu-options: Remove stray colons from output of --help
In reply to Michael RothFrom: Markus Armbruster <[email protected]>
Commit 43f187a broke --help: it put colons into blank lines. It removed the colon from DEFHEADING(TITLE:) and added it back in the macro expansion of DEFHEADING(TITLE), so hxtool can emit "@subsection TITLE" more easily. Trouble is it's added back even for the blank lines made with DEFHEADING().
Put the colons back where they were before commit 43f187a, and strip them in hxtool instead.
Message-Id: <[email protected]>
--- qemu-options-wrapper.h | 2 +- qemu-options.hx | 27 ++++++++++++++------------- scripts/hxtool | 3 ++- 3 files changed, 17 insertions(+), 15 deletions(-)
qemu-options-wrapper.h +1 -1
@@ -14,7 +14,7 @@#define ARCHHEADING (text, arch_mask) \ if ((arch_mask) & arch_type) \ - puts(stringify(text) ":"); + puts(stringify(text));#define DEFHEADING (text) ARCHHEADING(text, QEMU_ARCH_ALL)
qemu-options.hx +14 -13
@@ -6,7 +6,7 @@ HXCOMM construct option structures, enums and help message for specified HXCOMM architectures. HXCOMM HXCOMM can be used for comments, discarded from both texi and C -DEFHEADING(Standard options) +DEFHEADING(Standard options:) STEXI @table @option ETEXI
@@ -578,7 +578,7 @@ STEXI ETEXI DEFHEADING() -DEFHEADING(Block device options) +DEFHEADING(Block device options:) STEXI @table @option ETEXI
@@ -1181,7 +1181,7 @@ STEXI ETEXI DEFHEADING() -DEFHEADING(USB options) +DEFHEADING(USB options:) STEXI @table @option ETEXI
@@ -1246,7 +1246,7 @@ STEXI ETEXI DEFHEADING() -DEFHEADING(Display options) +DEFHEADING(Display options:) STEXI @table @option ETEXI
@@ -1783,7 +1783,7 @@ STEXI ETEXI ARCHHEADING(, QEMU_ARCH_I386) -ARCHHEADING(i386 target only, QEMU_ARCH_I386) +ARCHHEADING(i386 target only:, QEMU_ARCH_I386) STEXI @table @option ETEXI
@@ -1899,7 +1899,7 @@ STEXI ETEXI DEFHEADING() -DEFHEADING(Network options) +DEFHEADING(Network options:) STEXI @table @option ETEXI
@@ -2480,7 +2480,7 @@ STEXI ETEXI DEFHEADING() -DEFHEADING(Character device options) +DEFHEADING(Character device options:) STEXI The general form of a character device option is:
@@ -2813,7 +2813,7 @@ STEXI ETEXI DEFHEADING() -DEFHEADING(Device URL Syntax) +DEFHEADING(Device URL Syntax:) STEXI In addition to using normal file images for the emulated storage devices,
@@ -3043,7 +3043,7 @@ STEXI @end table ETEXI -DEFHEADING(Bluetooth(R) options) +DEFHEADING(Bluetooth(R) options:) STEXI @table @option ETEXI
@@ -3119,7 +3119,7 @@ ETEXI DEFHEADING() #ifdef CONFIG_TPM -DEFHEADING(TPM device options) +DEFHEADING(TPM device options:) DEF("tpmdev", HAS_ARG, QEMU_OPTION_tpmdev, \ "-tpmdev passthrough,id=id[,path=path][,cancel-path=path]\n"
@@ -3209,7 +3209,7 @@ DEFHEADING() #endif -DEFHEADING(Linux/Multiboot boot specific) +DEFHEADING(Linux/Multiboot boot specific:) STEXI When using these options, you can use a given Linux or Multiboot
@@ -3265,7 +3265,7 @@ STEXI ETEXI DEFHEADING() -DEFHEADING(Debug/Expert options) +DEFHEADING(Debug/Expert options:) STEXI @table @option ETEXI
@@ -4171,7 +4171,8 @@ STEXI @end table ETEXI DEFHEADING() -DEFHEADING(Generic object creation) + +DEFHEADING(Generic object creation:) STEXI @table @option ETEXI
scripts/hxtool +2 -1
@@ -19,7 +19,8 @@ hxtoh() print_texi_heading() { if test "$*" != ""; then - printf "@subsection %s\n" "$*" + title="$*" + printf "@subsection %s\n" "${title%:}" fi }
Signature · 1 line
2.11.0
PATCH 5/54 qemu-pr-helper: miscellaneous fixes
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
1) Return a generic sense if TEST UNIT READY does not provide one;
2) Fix two mistakes in copying from the spec.
--- include/scsi/utils.h | 6 +++++- scsi/qemu-pr-helper.c | 30 ++++++++++++++++++++++++++---- scsi/utils.c | 10 ++++++++++ 3 files changed, 41 insertions(+), 5 deletions(-)
include/scsi/utils.h +5 -1
@@ -76,7 +76,11 @@ extern const struct SCSISense sense_code_LUN_FAILURE;extern const struct SCSISense sense_code_LUN_COMM_FAILURE;/* Command aborted, Overlapped Commands Attempted */ extern const struct SCSISense sense_code_OVERLAPPED_COMMANDS; -/* LUN not ready, Capacity data has changed */ +/* Medium error, Unrecovered read error */ +extern const struct SCSISense sense_code_READ_ERROR; +/* LUN not ready, Cause not reportable */ +extern const struct SCSISense sense_code_NOT_READY; +/* Unit attention, Capacity data has changed */ extern const struct SCSISense sense_code_CAPACITY_CHANGED;/* Unit attention, SCSI bus reset */ extern const struct SCSISense sense_code_SCSI_BUS_RESET;
scsi/qemu-pr-helper.c +26 -4
@@ -314,6 +314,22 @@ static int is_mpath(int fd)return !strncmp (tgt->target_type,"multipath" ,DM_MAX_TYPE_NAME ); } +static SCSISense mpath_generic_sense (int r) +{ +switch (r) { +case MPATH_PR_SENSE_NOT_READY : +return SENSE_CODE (NOT_READY ); +case MPATH_PR_SENSE_MEDIUM_ERROR : +return SENSE_CODE (READ_ERROR ); +case MPATH_PR_SENSE_HARDWARE_ERROR : +return SENSE_CODE (TARGET_FAILURE ); +case MPATH_PR_SENSE_ABORTED_COMMAND : +return SENSE_CODE (IO_ERROR ); +default : +abort (); + } +} +static int mpath_reconstruct_sense (int fd,int r,uint8_t *sense) {switch (r) {
@@ -329,7 +345,13 @@ static int mpath_reconstruct_sense(int fd, int r, uint8_t *sense)*/ uint8_t cdb[6 ] = {TEST_UNIT_READY };int sz =0 ; -return do_sgio (fd, cdb, sense,NULL , &sz,SG_DXFER_NONE ); +int r =do_sgio (fd, cdb, sense,NULL , &sz,SG_DXFER_NONE ); + +if (r !=GOOD ) { +return r; + } +scsi_build_sense (sense,mpath_generic_sense (r)); +return CHECK_CONDITION ; }case MPATH_PR_SENSE_UNIT_ATTENTION :
@@ -449,7 +471,7 @@ static int multipath_pr_out(int fd, const uint8_t *cdb, uint8_t *sense,memset (¶mp,0 ,sizeof (paramp));memcpy (¶mp.key, ¶m[0 ],8 );memcpy (¶mp.sa_key, ¶m[8 ],8 ); - paramp.sa_flags = param[10 ]; + paramp.sa_flags = param[20 ];if (sz >PR_OUT_FIXED_PARAM_SIZE ) {size_t transportid_len;int i, j;
@@ -478,8 +500,8 @@ static int multipath_pr_out(int fd, const uint8_t *cdb, uint8_t *sense, j += offsetof(struct transportid, n_port_name[8]); i +=24 ;break ; -case 3 : -case 0x43 : +case 5 : +case 0x45 :/* iSCSI transport. */ len =lduw_be_p (¶m[i +2 ]);if (len >252 || (len &3 ) || i + len +4 > transportid_len) {
scsi/utils.c +10 -0
@@ -211,6 +211,16 @@ const struct SCSISense sense_code_LUN_COMM_FAILURE = { .key = ABORTED_COMMAND, .asc = 0x08, .ascq = 0x00 }; +/* Medium Error, Unrecovered read error */ +const struct SCSISense sense_code_READ_ERROR = { + .key =MEDIUM_ERROR , .asc =0x11 , .ascq =0x00 +}; + +/* Not ready, Cause not reportable */ +const struct SCSISense sense_code_NOT_READY = { + .key =NOT_READY , .asc =0x04 , .ascq =0x00 +}; +/* Unit attention, Capacity data has changed */ const struct SCSISense sense_code_CAPACITY_CHANGED = { .key =UNIT_ATTENTION , .asc =0x2a , .ascq =0x09
Signature · 1 line
2.11.0
PATCH 6/54 block/nbd: fix segmentation fault when .desc is not null-terminated
In reply to Michael RothFrom: Murilo Opsfelder Araujo <[email protected]>
The find_desc_by_name() from util/qemu-option.c relies on the .name not being NULL to call strcmp(). This check becomes unsafe when the list is not NULL-terminated, which is the case of nbd_runtime_opts in block/nbd.c, and can result in segmentation fault when strcmp() tries to access an invalid memory:
#0 0x00007fff8c75f7d4 in __strcmp_power9 () from /lib64/libc.so.6
#1 0x00000000102d3ec8 in find_desc_by_name (desc=0x1036d6f0, name=0x28e46670 "server.path") at util/qemu-option.c:166
#2 0x00000000102d93e0 in qemu_opts_absorb_qdict (opts=0x28e47a80, qdict=0x28e469a0, errp=0x7fffec247c98) at util/qemu-option.c:1026
#3 0x000000001012a2e4 in nbd_open (bs=0x28e42290, options=0x28e469a0, flags=24578, errp=0x7fffec247d80) at block/nbd.c:406
#4 0x00000000100144e8 in bdrv_open_driver (bs=0x28e42290, drv=0x1036e070 <bdrv_nbd_unix>, node_name=0x0, options=0x28e469a0, open_flags=24578, errp=0x7fffec247f50) at block.c:1135
#5 0x0000000010015b04 in bdrv_open_common (bs=0x28e42290, file=0x0, options=0x28e469a0, errp=0x7fffec247f50) at block.c:1395Quoted 1 line
From gdb, the desc[i].name was not NULL and resulted in
strcmp()accessing an
invalid memory:
Quoted 1 line
Quoted 1 line
Quoted 1 line
p desc[5]
$8 = {
name = 0x1037f098 "R27A",
type = 1561964883,
help = 0xc0bbb23e <error: Cannot access memory at address 0xc0bbb23e>,
def_value_str = 0x2 <error: Cannot access memory at address 0x2>
}
>>> p desc[6]
$9 = {
name = 0x103dac78 <__gcov0.do_qemu_init_bdrv_nbd_init> "\001",
type = 272101528,
help = 0x29ec0b754403e31f <error: Cannot access memory at address 0x29ec0b754403e31f>,
def_value_str = 0x81f343b9 <error: Cannot access memory at address 0x81f343b9>
}This patch fixes the segmentation fault in strcmp() by adding a NULL element at the end of nbd_runtime_opts.desc list, which is the common practice to most of other structs like runtime_opts in block/null.c. Thus, the desc[i].name != NULL check becomes safe because it will not evaluate to true when .desc list reached its end.
Message-Id: <[email protected]>
--- block/nbd.c | 1 + 1 file changed, 1 insertion(+)
block/nbd.c +1 -0
@@ -388,6 +388,7 @@ static QemuOptsList nbd_runtime_opts = { .type = QEMU_OPT_STRING, .help = "ID of the TLS credentials to use", }, + {/* end of list */ } }, };
Signature · 1 line
2.11.0
PATCH 7/54 block: Make bdrv_drain_invoke() recursive
In reply to Michael RothFrom: Kevin Wolf <[email protected]>
This change separates bdrv_drain_invoke(), which calls the BlockDriver drain callbacks, from bdrv_drain_recurse(). Instead, the function performs its own recursion now.
One reason for this is that bdrv_drain_recurse() can be called multiple times by bdrv_drain_all_begin(), but the callbacks may only be called once. The separation is necessary to fix this bug.
The other reason is that we intend to go to a model where we call all driver callbacks first, and only then start polling. This is not fully achieved yet with this patch, as bdrv_drain_invoke() contains a BDRV_POLL_WHILE() loop for the block driver callbacks, which can still call callbacks for any unrelated event. It's a step in this direction anyway.
--- block/io.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
block/io.c +11 -3
@@ -175,8 +175,10 @@ static void coroutine_fn bdrv_drain_invoke_entry(void *opaque)bdrv_wakeup (bs); } +/* Recursively call BlockDriver.bdrv_co_drain_begin/end callbacks */ static void bdrv_drain_invoke (BlockDriverState *bs,bool begin) { +BdrvChild *child, *tmp;BdrvCoDrainData data = { .bs = bs, .done = false, .begin = begin}; if (!bs->drv || (begin && !bs->drv->bdrv_co_drain_begin) ||
@@ -187,6 +189,10 @@ static void bdrv_drain_invoke(BlockDriverState *bs, bool begin) data.co =qemu_coroutine_create (bdrv_drain_invoke_entry, &data);bdrv_coroutine_enter (bs, data.co);BDRV_POLL_WHILE (bs, !data.done); + + QLIST_FOREACH_SAFE(child, &bs->children, next, tmp) { +bdrv_drain_invoke (child->bs, begin); + } }static bool bdrv_drain_recurse (BlockDriverState *bs,bool begin)
@@ -194,9 +200,6 @@ static bool bdrv_drain_recurse(BlockDriverState *bs, bool begin)BdrvChild *child, *tmp;bool waited; -/* Ensure any pending metadata writes are submitted to bs->file. */ -bdrv_drain_invoke (bs, begin); -/* Wait for drained requests to finish */ waited =BDRV_POLL_WHILE (bs,atomic_read (&bs->in_flight) >0 );
@@ -279,6 +282,7 @@ void bdrv_drained_begin(BlockDriverState *bs)bdrv_parent_drained_begin (bs); } +bdrv_drain_invoke (bs, true);bdrv_drain_recurse (bs, true); }
@@ -294,6 +298,7 @@ void bdrv_drained_end(BlockDriverState *bs) }bdrv_parent_drained_end (bs); +bdrv_drain_invoke (bs, false);bdrv_drain_recurse (bs, false);aio_enable_external (bdrv_get_aio_context (bs)); }
@@ -372,6 +377,8 @@ void bdrv_drain_all_begin(void)aio_context_acquire (aio_context);for (bs =bdrv_first (&it); bs; bs =bdrv_next (&it)) {if (aio_context ==bdrv_get_aio_context (bs)) { +/* FIXME Calling this multiple times is wrong */ +bdrv_drain_invoke (bs, true); waited |=bdrv_drain_recurse (bs, true); } }
@@ -393,6 +400,7 @@ void bdrv_drain_all_end(void)aio_context_acquire (aio_context);aio_enable_external (aio_context);bdrv_parent_drained_end (bs); +bdrv_drain_invoke (bs, false);bdrv_drain_recurse (bs, false);aio_context_release (aio_context); }
Signature · 1 line
2.11.0
PATCH 8/54 block: Call .drain_begin only once in bdrv_drain_all_begin()
In reply to Michael RothFrom: Kevin Wolf <[email protected]>
bdrv_drain_all_begin() used to call the .bdrv_co_drain_begin() driver callback inside its polling loop. This means that how many times it got called for each node depended on long it had to poll the event loop.
This is obviously not right and results in nodes that stay drained even after bdrv_drain_all_end(), which calls .bdrv_co_drain_begin() once per node.
Fix bdrv_drain_all_begin() to call the callback only once, too.
--- block/io.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
block/io.c +1 -2
@@ -355,6 +355,7 @@ void bdrv_drain_all_begin(void)aio_context_acquire (aio_context);bdrv_parent_drained_begin (bs);aio_disable_external (aio_context); +bdrv_drain_invoke (bs, true);aio_context_release (aio_context);if (!g_slist_find (aio_ctxs, aio_context)) {
@@ -377,8 +378,6 @@ void bdrv_drain_all_begin(void)aio_context_acquire (aio_context);for (bs =bdrv_first (&it); bs; bs =bdrv_next (&it)) {if (aio_context ==bdrv_get_aio_context (bs)) { -/* FIXME Calling this multiple times is wrong */ -bdrv_drain_invoke (bs, true); waited |=bdrv_drain_recurse (bs, true); } }
Signature · 1 line
2.11.0
PATCH 9/54 block: Open backing image in force share mode for size probe
In reply to Michael RothFrom: Fam Zheng <[email protected]>
Management tools create overlays of running guests with qemu-img:
$ qemu-img create -b /image/in/use.qcow2 -f qcow2 /overlay/image.qcow2
but this doesn't work anymore due to image locking:
qemu-img: /overlay/image.qcow2: Failed to get shared "write" lock Is another process using the image?
Could not open backing image to determine size.
Use the force share option to allow this use case again.
--- block.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block.c +2 -1
@@ -4593,10 +4593,11 @@ void bdrv_img_create(const char *filename, const char *fmt, back_flags = flags; back_flags &= ~(BDRV_O_RDWR |BDRV_O_SNAPSHOT |BDRV_O_NO_BACKING ); + backing_options =qdict_new ();if (backing_fmt) { - backing_options =qdict_new ();qdict_put_str (backing_options,"driver" , backing_fmt); } +qdict_put_bool (backing_options,BDRV_OPT_FORCE_SHARE , true); bs =bdrv_open (full_backing,NULL , backing_options, back_flags, &local_err);
Signature · 1 line
2.11.0
PATCH 10/54 vfio: Fix vfio-kvm group registration
In reply to Michael RothFrom: Alex Williamson <[email protected]>
Commit 8c37faa475f3 ("vfio-pci, ppc64/spapr: Reorder group-to-container attaching") moved registration of groups with the vfio-kvm device from vfio_get_group() to vfio_connect_container(), but it missed the case where a group is attached to an existing container and takes an early exit. Perhaps this is a less common case on ppc64/spapr, but on x86 (without viommu) all groups are connected to the same container and thus only the first group gets registered with the vfio-kvm device. This becomes a problem if we then hot-unplug the devices associated with that first group and we end up with KVM being misinformed about any vfio connections that might remain. Fix by including the call to vfio_kvm_device_add_group() in this early exit path.
--- hw/vfio/common.c | 1 + 1 file changed, 1 insertion(+)
hw/vfio/common.c +1 -0
@@ -968,6 +968,7 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,if (!ioctl (group->fd,VFIO_GROUP_SET_CONTAINER , &container->fd)) { group->container = container;QLIST_INSERT_HEAD (&container->group_list, group, container_next); +vfio_kvm_device_add_group (group);return 0 ; } }
Signature · 1 line
2.11.0
PATCH 11/54 hw/intc/arm_gicv3: Make reserved register addresses RAZ/WI
In reply to Michael RothFrom: Peter Maydell <[email protected]>
The GICv3 specification says that reserved register addresses should RAZ/WI. This means we need to return MEMTX_OK, not MEMTX_ERROR, because now that we support generating external aborts the latter will cause an abort on new board models.
Message-id: [email protected]
--- hw/intc/arm_gicv3_dist.c | 13 +++++++++++++ hw/intc/arm_gicv3_its_common.c | 8 +++----- hw/intc/arm_gicv3_redist.c | 13 +++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-)
hw/intc/arm_gicv3_dist.c +13 -0
@@ -817,6 +817,13 @@ MemTxResult gicv3_dist_read(void *opaque, hwaddr offset, uint64_t *data,"%s: invalid guest read at offset " TARGET_FMT_plx "size %u\n", __func__, offset, size);trace_gicv3_dist_badread (offset, size, attrs.secure); +/* The spec requires that reserved registers are RAZ/WI; +* so use MEMTX_ERROR returns from leaf functions as a way to +* trigger the guest-error logging but don't return it to +* the caller, or we'll cause a spurious guest data abort. +*/ + r =MEMTX_OK ; + *data =0 ; }else {trace_gicv3_dist_read (offset, *data, size, attrs.secure); }
@@ -852,6 +859,12 @@ MemTxResult gicv3_dist_write(void *opaque, hwaddr offset, uint64_t data,"%s: invalid guest write at offset " TARGET_FMT_plx "size %u\n", __func__, offset, size);trace_gicv3_dist_badwrite (offset, data, size, attrs.secure); +/* The spec requires that reserved registers are RAZ/WI; +* so use MEMTX_ERROR returns from leaf functions as a way to +* trigger the guest-error logging but don't return it to +* the caller, or we'll cause a spurious guest data abort. +*/ + r =MEMTX_OK ; }else {trace_gicv3_dist_write (offset, data, size, attrs.secure); }
hw/intc/arm_gicv3_its_common.c +3 -5
@@ -67,7 +67,8 @@ static MemTxResult gicv3_its_trans_read(void *opaque, hwaddr offset, MemTxAttrs attrs) {qemu_log_mask (LOG_GUEST_ERROR ,"ITS read at offset 0x%" PRIx64"\n" , offset); -return MEMTX_ERROR ; + *data =0 ; +return MEMTX_OK ; } static MemTxResult gicv3_its_trans_write(void *opaque, hwaddr offset,
@@ -82,15 +83,12 @@ static MemTxResult gicv3_its_trans_write(void *opaque, hwaddr offset,if (ret <=0 ) {qemu_log_mask (LOG_GUEST_ERROR ,"ITS: Error sending MSI: %s\n" ,strerror (-ret)); -return MEMTX_DECODE_ERROR ; } - -return MEMTX_OK ; }else {qemu_log_mask (LOG_GUEST_ERROR ,"ITS write at bad offset 0x%" PRIx64"\n" , offset); -return MEMTX_DECODE_ERROR ; } +return MEMTX_OK ; }static const MemoryRegionOps gicv3_its_trans_ops = {
hw/intc/arm_gicv3_redist.c +13 -0
@@ -455,6 +455,13 @@ MemTxResult gicv3_redist_read(void *opaque, hwaddr offset, uint64_t *data, "size %u\n", __func__, offset, size);trace_gicv3_redist_badread (gicv3_redist_affid (cs), offset, size, attrs.secure); +/* The spec requires that reserved registers are RAZ/WI; +* so use MEMTX_ERROR returns from leaf functions as a way to +* trigger the guest-error logging but don't return it to +* the caller, or we'll cause a spurious guest data abort. +*/ + r =MEMTX_OK ; + *data =0 ; }else {trace_gicv3_redist_read (gicv3_redist_affid (cs), offset, *data, size, attrs.secure);
@@ -505,6 +512,12 @@ MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data, "size %u\n", __func__, offset, size);trace_gicv3_redist_badwrite (gicv3_redist_affid (cs), offset, data, size, attrs.secure); +/* The spec requires that reserved registers are RAZ/WI; +* so use MEMTX_ERROR returns from leaf functions as a way to +* trigger the guest-error logging but don't return it to +* the caller, or we'll cause a spurious guest data abort. +*/ + r =MEMTX_OK ; }else {trace_gicv3_redist_write (gicv3_redist_affid (cs), offset, data, size, attrs.secure);
Signature · 1 line
2.11.0
PATCH 12/54 hw/intc/arm_gic: reserved register addresses are RAZ/WI
In reply to Michael RothFrom: Peter Maydell <[email protected]>
The GICv2 specification says that reserved register addresses must RAZ/WI; now that we implement external abort handling for Arm CPUs this means we must return MEMTX_OK rather than MEMTX_ERROR, to avoid generating a spurious guest data abort.
Message-id: [email protected]
--- hw/intc/arm_gic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/intc/arm_gic.c +3 -2
@@ -1261,7 +1261,8 @@ static MemTxResult gic_cpu_read(GICState *s, int cpu, int offset,default :qemu_log_mask (LOG_GUEST_ERROR ,"gic_cpu_read: Bad offset %x\n" , (int )offset); -return MEMTX_ERROR ; + *data =0 ; +break ; }return MEMTX_OK ; }
@@ -1329,7 +1330,7 @@ static MemTxResult gic_cpu_write(GICState *s, int cpu, int offset,default :qemu_log_mask (LOG_GUEST_ERROR ,"gic_cpu_write: Bad offset %x\n" , (int )offset); -return MEMTX_ERROR ; +return MEMTX_OK ; }gic_update (s);return MEMTX_OK ;
Signature · 1 line
2.11.0
PATCH 13/54 virtio_error: don't invoke status callbacks
In reply to Michael RothFrom: "Michael S. Tsirkin" <[email protected]>
Backends don't need to know what frontend requested a reset, and notifying then from virtio_error is messy because virtio_error itself might be invoked from backend.
Let's just set the status directly.
--- hw/virtio/virtio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio.c +1 -1
@@ -2469,7 +2469,7 @@ void GCC_FMT_ATTR(2, 3) virtio_error(VirtIODevice *vdev, const char *fmt, ...)va_end (ap);if (virtio_vdev_has_feature (vdev,VIRTIO_F_VERSION_1 )) { -virtio_set_status (vdev, vdev->status |VIRTIO_CONFIG_S_NEEDS_RESET ); + vdev->status = vdev->status |VIRTIO_CONFIG_S_NEEDS_RESET ;virtio_notify_config (vdev); }
Signature · 1 line
2.11.0
PATCH 14/54 vhost: remove assertion to prevent crash
In reply to Michael RothFrom: Jay Zhou <[email protected]>
QEMU will assert on vhost-user backed virtio device hotplug if QEMU is using more RAM regions than VHOST_MEMORY_MAX_NREGIONS (for example if it were started with a lot of DIMM devices).
Fix it by returning error instead of asserting and let callers of vhost_set_mem_table() handle error condition gracefully.
--- hw/virtio/vhost-user.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
hw/virtio/vhost-user.c +4 -1
@@ -317,11 +317,14 @@ static int vhost_user_set_mem_table(struct vhost_dev *dev, &offset); fd =memory_region_get_fd (mr);if (fd >0 ) { +if (fd_num ==VHOST_MEMORY_MAX_NREGIONS ) { +error_report ("Failed preparing vhost-user memory table msg" ); +return -1 ; + } msg.payload.memory.regions[fd_num].userspace_addr = reg->userspace_addr; msg.payload.memory.regions[fd_num].memory_size = reg->memory_size; msg.payload.memory.regions[fd_num].guest_phys_addr = reg->guest_phys_addr; msg.payload.memory.regions[fd_num].mmap_offset = offset; -assert (fd_num <VHOST_MEMORY_MAX_NREGIONS ); fds[fd_num++] = fd; } }
Signature · 1 line
2.11.0
PATCH 15/54 hw/sd/pl181: Reset SD card on controller reset
In reply to Michael RothFrom: Peter Maydell <[email protected]>
Since pl181 is still using the legacy SD card API, the SD card created by sd_init() is not plugged into any bus. This means that the controller has to reset it manually.
Failing to do this mostly didn't affect the guest since the guest typically does a programmed SD card reset as part of its SD controller driver initialization, but meant that migration failed because it's only in sd_reset() that we set up the wpgrps_size field.
Message-id: [email protected]
--- hw/sd/pl181.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/sd/pl181.c +4 -0
@@ -480,6 +480,10 @@ static void pl181_reset(DeviceState *d)/* We can assume our GPIO outputs have been wired up now */ sd_set_cb (s->card, s->cardstatus[0 ], s->cardstatus[1 ]); +/* Since we're still using the legacy SD API the card is not plugged +* into any bus, and we must reset it manually. +*/ +device_reset (DEVICE (s->card)); }static void pl181_init (Object *obj)
Signature · 1 line
2.11.0
PATCH 16/54 hw/sd/milkymist-memcard: Reset SD card on controller reset
In reply to Michael RothFrom: Peter Maydell <[email protected]>
Since milkymist-memcard is still using the legacy SD card API, the SD card created by sd_init() is not plugged into any bus. This means that the controller has to reset it manually.
Failing to do this mostly didn't affect the guest since the guest typically does a programmed SD card reset as part of its SD controller driver initialization, but meant that migration failed because it's only in sd_reset() that we set up the wpgrps_size field.
Message-id: [email protected]
--- hw/sd/milkymist-memcard.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/sd/milkymist-memcard.c +4 -0
@@ -248,6 +248,10 @@ static void milkymist_memcard_reset(DeviceState *d)for (i =0 ; i <R_MAX ; i++) { s->regs[i] =0 ; } +/* Since we're still using the legacy SD API the card is not plugged +* into any bus, and we must reset it manually. +*/ +device_reset (DEVICE (s->card)); }static int milkymist_memcard_init (SysBusDevice *dev)
Signature · 1 line
2.11.0
PATCH 17/54 hw/sd/ssi-sd: Reset SD card on controller reset
In reply to Michael RothFrom: Peter Maydell <[email protected]>
Since ssi-sd is still using the legacy SD card API, the SD card created by sd_init() is not plugged into any bus. This means that the controller has to reset it manually.
Failing to do this mostly didn't affect the guest since the guest typically does a programmed SD card reset as part of its SD controller driver initialization, but meant that migration failed because it's only in sd_reset() that we set up the wpgrps_size field.
In the case of sd-ssi, we have to implement an entire reset function since there wasn't one previously, and that requires a QOM cast macro that got omitted when this device was QOMified.
Message-id: [email protected]
--- hw/sd/ssi-sd.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
hw/sd/ssi-sd.c +23 -2
@@ -50,6 +50,9 @@ typedef struct {SDState *sd; } ssi_sd_state; +#define TYPE_SSI_SD "ssi-sd" +#define SSI_SD (obj) OBJECT_CHECK(ssi_sd_state, (obj), TYPE_SSI_SD) +/* State word bits. */ #define SSI_SDR_LOCKED 0x0001#define SSI_SDR_WP_ERASE 0x0002
@@ -241,7 +244,6 @@ static void ssi_sd_realize(SSISlave *d, Error **errp)ssi_sd_state *s =FROM_SSI_SLAVE (ssi_sd_state, d);DriveInfo *dinfo; - s->mode =SSI_SD_CMD ;/* FIXME use a qdev drive property instead of drive_get_next() */ dinfo =drive_get_next (IF_SD ); s->sd =sd_init (dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , true);
@@ -251,6 +253,24 @@ static void ssi_sd_realize(SSISlave *d, Error **errp) } } +static void ssi_sd_reset (DeviceState *dev) +{ +ssi_sd_state *s =SSI_SD (dev); + + s->mode =SSI_SD_CMD ; + s->cmd =0 ; +memset (s->cmdarg,0 ,sizeof (s->cmdarg)); +memset (s->response,0 ,sizeof (s->response)); + s->arglen =0 ; + s->response_pos =0 ; + s->stopping =0 ; + +/* Since we're still using the legacy SD API the card is not plugged +* into any bus, and we must reset it manually. +*/ +device_reset (DEVICE (s->sd)); +} +static void ssi_sd_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -260,10 +280,11 @@ static void ssi_sd_class_init(ObjectClass *klass, void *data) k->transfer = ssi_sd_transfer; k->cs_polarity =SSI_CS_LOW ; dc->vmsd = &vmstate_ssi_sd; + dc->reset = ssi_sd_reset; }static const TypeInfo ssi_sd_info = { - .name ="ssi-sd" , + .name =TYPE_SSI_SD , .parent =TYPE_SSI_SLAVE , .instance_size =sizeof (ssi_sd_state), .class_init = ssi_sd_class_init,
Signature · 1 line
2.11.0
PATCH 18/54 scsi-disk: release AioContext in unaligned WRITE SAME case
In reply to Michael RothFrom: Stefan Hajnoczi <[email protected]>
scsi_write_same_complete() can retry the write if the request was unaligned. Make sure to release the AioContext when that code path is taken!
This patch fixes a hang when QEMU terminates after an unaligned WRITE SAME request has been processed with dataplane. The hang occurs because iothread_stop_all() cannot acquire the AioContext lock that was leaked by the IOThread in scsi_write_same_complete().
Message-Id: <[email protected]>
--- hw/scsi/scsi-disk.c | 1 + 1 file changed, 1 insertion(+)
hw/scsi/scsi-disk.c +1 -0
@@ -1755,6 +1755,7 @@ static void scsi_write_same_complete(void *opaque, int ret) data->sector <<BDRV_SECTOR_BITS , &data->qiov,0 , scsi_write_same_complete, data); +aio_context_release (blk_get_aio_context (s->qdev.conf.blk));return ; }
Signature · 1 line
2.11.0
PATCH 19/54 hw/pci-bridge: fix QEMU crash because of pcie-root-port
In reply to Michael RothFrom: Marcel Apfelbaum <[email protected]>
If we try to use more pcie_root_ports then available slots and an IO hint is passed to the port, QEMU crashes because we try to init the "IO hint" capability even if the device is not created.
Fix it by checking for error before adding the capability, so QEMU can fail gracefully.
--- hw/pci-bridge/gen_pcie_root_port.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
hw/pci-bridge/gen_pcie_root_port.c +6 -1
@@ -74,8 +74,13 @@ static void gen_rp_realize(DeviceState *dev, Error **errp)PCIDevice *d =PCI_DEVICE (dev);GenPCIERootPort *grp =GEN_PCIE_ROOT_PORT (d);PCIERootPortClass *rpc =PCIE_ROOT_PORT_GET_CLASS (d); +Error *local_err =NULL ; - rpc->parent_realize (dev, errp); + rpc->parent_realize (dev, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + } int rc = pci_bridge_qemu_reserve_cap_init(d, 0, grp->bus_reserve, grp->io_reserve, grp->mem_reserve, grp->pref32_reserve,
Signature · 1 line
2.11.0
PATCH 20/54 i386: Change X86CPUDefinition::model_id to const char*
In reply to Michael RothFrom: Eduardo Habkost <[email protected]>
It is valid to have a 48-character model ID on CPUID, however the definition of X86CPUDefinition::model_id is char[48], which can make the compiler drop the null terminator from the string.
If a CPU model happens to have 48 bytes on model_id, "-cpu help" will print garbage and the object_property_set_str() call at x86_cpu_load_def() will read data outside the model_id array.
We could increase the array size to 49, but this would mean the compiler would not issue a warning if a 49-char string is used by mistake for model_id.
To make things simpler, simply change model_id to be const char*, and validate the string length using an assert() on x86_register_cpudef_type().
Message-Id: <[email protected]>
--- target/i386/cpu.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
target/i386/cpu.c +8 -1
@@ -748,7 +748,7 @@ struct X86CPUDefinition {int model;int stepping;FeatureWordArray features; -char model_id[48 ]; +const char *model_id; };static X86CPUDefinition builtin_x86_defs[] = {
@@ -917,6 +917,7 @@ static X86CPUDefinition builtin_x86_defs[] = { .features[FEAT_1_EDX] = I486_FEATURES, .xlevel = 0, + .model_id = "", }, { .name = "pentium",
@@ -928,6 +929,7 @@ static X86CPUDefinition builtin_x86_defs[] = { .features[FEAT_1_EDX] = PENTIUM_FEATURES, .xlevel = 0, + .model_id = "", }, { .name = "pentium2",
@@ -939,6 +941,7 @@ static X86CPUDefinition builtin_x86_defs[] = { .features[FEAT_1_EDX] = PENTIUM2_FEATURES, .xlevel = 0, + .model_id = "", }, { .name = "pentium3",
@@ -950,6 +953,7 @@ static X86CPUDefinition builtin_x86_defs[] = { .features[FEAT_1_EDX] = PENTIUM3_FEATURES, .xlevel = 0, + .model_id = "", }, { .name = "athlon",
@@ -2708,6 +2712,9 @@ static void x86_register_cpudef_type(X86CPUDefinition *def)* they shouldn't be set on the CPU model table. */ assert (!(def->features[FEAT_8000_0001_EDX ] &CPUID_EXT2_AMD_ALIASES )); +/* catch mistakes instead of silently truncating model_id when too long */ +assert (def->model_id &&strlen (def->model_id) <=48 ); +type_register (&ti);g_free (typename);
Signature · 1 line
2.11.0
PATCH 21/54 i386: Add support for SPEC_CTRL MSR
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
Message-Id: <[email protected]>
--- target/i386/cpu.h | 3 +++ target/i386/kvm.c | 14 ++++++++++++++ target/i386/machine.c | 20 ++++++++++++++++++++ 3 files changed, 37 insertions(+)
target/i386/cpu.h +3 -0
@@ -335,6 +335,7 @@#define MSR_IA32_APICBASE_BASE (0xfffffU<<12)#define MSR_IA32_FEATURE_CONTROL 0x0000003a#define MSR_TSC_ADJUST 0x0000003b +#define MSR_IA32_SPEC_CTRL 0x48#define MSR_IA32_TSCDEADLINE 0x6e0#define FEATURE_CONTROL_LOCKED (1<<0)
@@ -1082,6 +1083,8 @@ typedef struct CPUX86State {uint32_t pkru; +uint64_t spec_ctrl; +/* End of state preserved by INIT (dummy marker). */ struct {} end_init_save;
target/i386/kvm.c +14 -0
@@ -91,6 +91,7 @@ static bool has_msr_hv_synic;static bool has_msr_hv_stimer;static bool has_msr_hv_frequencies;static bool has_msr_xss; +static bool has_msr_spec_ctrl;static bool has_msr_architectural_pmu;static uint32_t num_architectural_pmu_counters;
@@ -1144,6 +1145,9 @@ static int kvm_get_supported_msrs(KVMState *s)case HV_X64_MSR_TSC_FREQUENCY : has_msr_hv_frequencies = true;break ; +case MSR_IA32_SPEC_CTRL : + has_msr_spec_ctrl = true; +break ; } } }
@@ -1626,6 +1630,9 @@ static int kvm_put_msrs(X86CPU *cpu, int level)if (has_msr_xss) {kvm_msr_entry_add (cpu,MSR_IA32_XSS , env->xss); } +if (has_msr_spec_ctrl) { +kvm_msr_entry_add (cpu,MSR_IA32_SPEC_CTRL , env->spec_ctrl); + }#ifdef TARGET_X86_64 if (lm_capable_kernel) {kvm_msr_entry_add (cpu,MSR_CSTAR , env->cstar);
@@ -1634,6 +1641,7 @@ static int kvm_put_msrs(X86CPU *cpu, int level) kvm_msr_entry_add(cpu, MSR_LSTAR, env->lstar); }#endif +/* * The following MSRs have side effects on the guest or are too heavy * for normal writeback. Limit them to reset or full state updates.
@@ -1998,6 +2006,9 @@ static int kvm_get_msrs(X86CPU *cpu)if (has_msr_xss) {kvm_msr_entry_add (cpu,MSR_IA32_XSS ,0 ); } +if (has_msr_spec_ctrl) { +kvm_msr_entry_add (cpu,MSR_IA32_SPEC_CTRL ,0 ); + }if (!env->tsc_valid) {
@@ -2347,6 +2358,9 @@ static int kvm_get_msrs(X86CPU *cpu) env->mtrr_var[MSR_MTRRphysIndex (index)].base = msrs[i].data; }break ; +case MSR_IA32_SPEC_CTRL : + env->spec_ctrl = msrs[i].data; +break ; } }
target/i386/machine.c +20 -0
@@ -818,6 +818,25 @@ static const VMStateDescription vmstate_mcg_ext_ctl = { } }; +static bool spec_ctrl_needed (void *opaque) +{ +X86CPU *cpu = opaque; +CPUX86State *env = &cpu->env; + +return env->spec_ctrl !=0 ; +} + +static const VMStateDescription vmstate_spec_ctrl = { + .name ="cpu/spec_ctrl" , + .version_id =1 , + .minimum_version_id =1 , + .needed = spec_ctrl_needed, + .fields = (VMStateField []){ +VMSTATE_UINT64 (env.spec_ctrl,X86CPU ), +VMSTATE_END_OF_LIST () + } +}; +VMStateDescription vmstate_x86_cpu = { .name ="cpu" , .version_id =12 ,
@@ -936,6 +955,7 @@ VMStateDescription vmstate_x86_cpu = {#ifdef TARGET_X86_64 &vmstate_pkru, #endif + &vmstate_spec_ctrl, &vmstate_mcg_ext_ctl,NULL }
Signature · 1 line
2.11.0
PATCH 22/54 i386: Add spec-ctrl CPUID bit
In reply to Michael RothFrom: Eduardo Habkost <[email protected]>
Add the feature name and a CPUID_7_0_EDX_SPEC_CTRL macro.
Message-Id: <[email protected]>
--- target/i386/cpu.c | 2 +- target/i386/cpu.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
target/i386/cpu.c +1 -1
@@ -458,7 +458,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL , -NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,"spec-ctrl" ,NULL , NULL, NULL, NULL, NULL, }, .cpuid_eax = 7,
target/i386/cpu.h +1 -0
@@ -642,6 +642,7 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_EDX_AVX512_4VNNIW (1U << 2)/* AVX512 Neural Network Instructions */ #define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3)/* AVX512 Multiply Accumulation Single Precision */ +#define CPUID_7_0_EDX_SPEC_CTRL (1U << 26)/* Speculation Control */ #define CPUID_XSAVE_XSAVEOPT (1U << 0)#define CPUID_XSAVE_XSAVEC (1U << 1)
Signature · 1 line
2.11.0
PATCH 23/54 i386: Add FEAT_8000_0008_EBX CPUID feature word
In reply to Michael RothFrom: Eduardo Habkost <[email protected]>
Add the new feature word and the "ibpb" feature flag.
Based on a patch by Paolo Bonzini.
Message-Id: <[email protected]>
--- target/i386/cpu.c | 19 ++++++++++++++++++- target/i386/cpu.h | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-)
target/i386/cpu.c +18 -1
@@ -482,6 +482,22 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = { .tcg_features = TCG_APM_FEATURES, .unmigratable_flags = CPUID_APM_INVTSC, }, + [FEAT_8000_0008_EBX] = { + .feat_names = { +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +"ibpb" ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,NULL ,NULL , + NULL, NULL, NULL, NULL, + }, + .cpuid_eax =0x80000008 , + .cpuid_reg = R_EBX, + .tcg_features = 0, + .unmigratable_flags = 0, + }, [FEAT_XSAVE] = { .feat_names = { "xsaveopt", "xsavec", "xgetbv1", "xsaves",
@@ -3097,7 +3113,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, }else { *eax = cpu->phys_bits; } - *ebx =0 ; + *ebx = env->features[FEAT_8000_0008_EBX ]; *ecx =0 ; *edx =0 ;if (cs->nr_cores * cs->nr_threads >1 ) {
@@ -3553,6 +3569,7 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)x86_cpu_adjust_feat_level (cpu,FEAT_8000_0001_EDX );x86_cpu_adjust_feat_level (cpu,FEAT_8000_0001_ECX );x86_cpu_adjust_feat_level (cpu,FEAT_8000_0007_EDX ); +x86_cpu_adjust_feat_level (cpu,FEAT_8000_0008_EBX );x86_cpu_adjust_feat_level (cpu,FEAT_C000_0001_EDX );x86_cpu_adjust_feat_level (cpu,FEAT_SVM );x86_cpu_adjust_feat_level (cpu,FEAT_XSAVE );
target/i386/cpu.h +3 -0
@@ -454,6 +454,7 @@ typedef enum FeatureWord {FEAT_8000_0001_EDX ,/* CPUID[8000_0001].EDX */ FEAT_8000_0001_ECX ,/* CPUID[8000_0001].ECX */ FEAT_8000_0007_EDX ,/* CPUID[8000_0007].EDX */ +FEAT_8000_0008_EBX ,/* CPUID[8000_0008].EBX */ FEAT_C000_0001_EDX ,/* CPUID[C000_0001].EDX */ FEAT_KVM ,/* CPUID[4000_0001].EAX (KVM_CPUID_FEATURES) */ FEAT_HYPERV_EAX, /* CPUID[4000_0003].EAX */
@@ -644,6 +645,8 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];#define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3)/* AVX512 Multiply Accumulation Single Precision */ #define CPUID_7_0_EDX_SPEC_CTRL (1U << 26)/* Speculation Control */ +#define CPUID_8000_0008_EBX_IBPB (1U << 12)/* Indirect Branch Prediction Barrier */ +#define CPUID_XSAVE_XSAVEOPT (1U << 0)#define CPUID_XSAVE_XSAVEC (1U << 1)#define CPUID_XSAVE_XGETBV1 (1U << 2)
Signature · 1 line
2.11.0
PATCH 24/54 i386: Add new -IBRS versions of Intel CPU models
In reply to Michael RothFrom: Eduardo Habkost <[email protected]>
The new MSR IA32_SPEC_CTRL MSR was introduced by a recent Intel microcode updated and can be used by OSes to mitigate CVE-2017-5715. Unfortunately we can't change the existing CPU models without breaking existing setups, so users need to explicitly update their VM configuration to use the new *-IBRS CPU model if they want to expose IBRS to guests.
The new CPU models are simple copies of the existing CPU models, with just CPUID_7_0_EDX_SPEC_CTRL added and model_id updated.
Message-Id: <[email protected]>
--- target/i386/cpu.c | 379 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 378 insertions(+), 1 deletion(-)
target/i386/cpu.c +378 -1
@@ -1080,6 +1080,31 @@ static X86CPUDefinition builtin_x86_defs[] = { .model_id = "Intel Core i7 9xx (Nehalem Class Core i7)", }, { + .name = "Nehalem-IBRS", + .level = 11, + .vendor = CPUID_VENDOR_INTEL, + .family = 6, + .model = 26, + .stepping = 3, + .features[FEAT_1_EDX ] = +CPUID_VME |CPUID_SSE2 |CPUID_SSE |CPUID_FXSR |CPUID_MMX | +CPUID_CLFLUSH |CPUID_PSE36 |CPUID_PAT |CPUID_CMOV |CPUID_MCA | +CPUID_PGE |CPUID_MTRR |CPUID_SEP |CPUID_APIC |CPUID_CX8 | +CPUID_MCE |CPUID_PAE |CPUID_MSR |CPUID_TSC |CPUID_PSE | + CPUID_DE | CPUID_FP87, + .features[FEAT_1_ECX ] = +CPUID_EXT_POPCNT |CPUID_EXT_SSE42 |CPUID_EXT_SSE41 | + CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | CPUID_EXT_SSE3, + .features[FEAT_7_0_EDX ] = + CPUID_7_0_EDX_SPEC_CTRL, + .features[FEAT_8000_0001_EDX ] = + CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX, + .features[FEAT_8000_0001_ECX ] = + CPUID_EXT3_LAHF_LM, + .xlevel = 0x80000008, + .model_id = "Intel Core i7 9xx (Nehalem Core i7, IBRS update)", + }, + { .name = "Westmere", .level = 11, .vendor = CPUID_VENDOR_INTEL,
@@ -1106,6 +1131,34 @@ static X86CPUDefinition builtin_x86_defs[] = { .model_id = "Westmere E56xx/L56xx/X56xx (Nehalem-C)", }, { + .name = "Westmere-IBRS", + .level = 11, + .vendor = CPUID_VENDOR_INTEL, + .family = 6, + .model = 44, + .stepping = 1, + .features[FEAT_1_EDX ] = +CPUID_VME |CPUID_SSE2 |CPUID_SSE |CPUID_FXSR |CPUID_MMX | +CPUID_CLFLUSH |CPUID_PSE36 |CPUID_PAT |CPUID_CMOV |CPUID_MCA | +CPUID_PGE |CPUID_MTRR |CPUID_SEP |CPUID_APIC |CPUID_CX8 | +CPUID_MCE |CPUID_PAE |CPUID_MSR |CPUID_TSC |CPUID_PSE | + CPUID_DE | CPUID_FP87, + .features[FEAT_1_ECX ] = +CPUID_EXT_AES |CPUID_EXT_POPCNT |CPUID_EXT_SSE42 | +CPUID_EXT_SSE41 |CPUID_EXT_CX16 |CPUID_EXT_SSSE3 | + CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3, + .features[FEAT_8000_0001_EDX ] = + CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX, + .features[FEAT_8000_0001_ECX ] = + CPUID_EXT3_LAHF_LM, + .features[FEAT_7_0_EDX ] = + CPUID_7_0_EDX_SPEC_CTRL, + .features[FEAT_6_EAX ] = + CPUID_6_EAX_ARAT, + .xlevel = 0x80000008, + .model_id = "Westmere E56xx/L56xx/X56xx (IBRS update)", + }, + { .name = "SandyBridge", .level = 0xd, .vendor = CPUID_VENDOR_INTEL,
@@ -1137,6 +1190,39 @@ static X86CPUDefinition builtin_x86_defs[] = { .model_id = "Intel Xeon E312xx (Sandy Bridge)", }, { + .name = "SandyBridge-IBRS", + .level = 0xd, + .vendor = CPUID_VENDOR_INTEL, + .family = 6, + .model = 42, + .stepping = 1, + .features[FEAT_1_EDX ] = +CPUID_VME |CPUID_SSE2 |CPUID_SSE |CPUID_FXSR |CPUID_MMX | +CPUID_CLFLUSH |CPUID_PSE36 |CPUID_PAT |CPUID_CMOV |CPUID_MCA | +CPUID_PGE |CPUID_MTRR |CPUID_SEP |CPUID_APIC |CPUID_CX8 | +CPUID_MCE |CPUID_PAE |CPUID_MSR |CPUID_TSC |CPUID_PSE | + CPUID_DE | CPUID_FP87, + .features[FEAT_1_ECX ] = +CPUID_EXT_AVX |CPUID_EXT_XSAVE |CPUID_EXT_AES | +CPUID_EXT_TSC_DEADLINE_TIMER |CPUID_EXT_POPCNT | +CPUID_EXT_X2APIC |CPUID_EXT_SSE42 |CPUID_EXT_SSE41 | +CPUID_EXT_CX16 |CPUID_EXT_SSSE3 |CPUID_EXT_PCLMULQDQ | + CPUID_EXT_SSE3, + .features[FEAT_8000_0001_EDX ] = +CPUID_EXT2_LM |CPUID_EXT2_RDTSCP |CPUID_EXT2_NX | + CPUID_EXT2_SYSCALL, + .features[FEAT_8000_0001_ECX ] = + CPUID_EXT3_LAHF_LM, + .features[FEAT_7_0_EDX ] = + CPUID_7_0_EDX_SPEC_CTRL, + .features[FEAT_XSAVE ] = + CPUID_XSAVE_XSAVEOPT, + .features[FEAT_6_EAX ] = + CPUID_6_EAX_ARAT, + .xlevel = 0x80000008, + .model_id = "Intel Xeon E312xx (Sandy Bridge, IBRS update)", + }, + { .name = "IvyBridge", .level = 0xd, .vendor = CPUID_VENDOR_INTEL,
@@ -1171,6 +1257,42 @@ static X86CPUDefinition builtin_x86_defs[] = { .model_id = "Intel Xeon E3-12xx v2 (Ivy Bridge)", }, { + .name = "IvyBridge-IBRS", + .level = 0xd, + .vendor = CPUID_VENDOR_INTEL, + .family = 6, + .model = 58, + .stepping = 9, + .features[FEAT_1_EDX ] = +CPUID_VME |CPUID_SSE2 |CPUID_SSE |CPUID_FXSR |CPUID_MMX | +CPUID_CLFLUSH |CPUID_PSE36 |CPUID_PAT |CPUID_CMOV |CPUID_MCA | +CPUID_PGE |CPUID_MTRR |CPUID_SEP |CPUID_APIC |CPUID_CX8 | +CPUID_MCE |CPUID_PAE |CPUID_MSR |CPUID_TSC |CPUID_PSE | + CPUID_DE | CPUID_FP87, + .features[FEAT_1_ECX ] = +CPUID_EXT_AVX |CPUID_EXT_XSAVE |CPUID_EXT_AES | +CPUID_EXT_TSC_DEADLINE_TIMER |CPUID_EXT_POPCNT | +CPUID_EXT_X2APIC |CPUID_EXT_SSE42 |CPUID_EXT_SSE41 | +CPUID_EXT_CX16 |CPUID_EXT_SSSE3 |CPUID_EXT_PCLMULQDQ | + CPUID_EXT_SSE3 | CPUID_EXT_F16C | CPUID_EXT_RDRAND, + .features[FEAT_7_0_EBX ] = +CPUID_7_0_EBX_FSGSBASE |CPUID_7_0_EBX_SMEP | + CPUID_7_0_EBX_ERMS, + .features[FEAT_8000_0001_EDX ] = +CPUID_EXT2_LM |CPUID_EXT2_RDTSCP |CPUID_EXT2_NX | + CPUID_EXT2_SYSCALL, + .features[FEAT_8000_0001_ECX ] = + CPUID_EXT3_LAHF_LM, + .features[FEAT_7_0_EDX ] = + CPUID_7_0_EDX_SPEC_CTRL, + .features[FEAT_XSAVE ] = + CPUID_XSAVE_XSAVEOPT, + .features[FEAT_6_EAX ] = + CPUID_6_EAX_ARAT, + .xlevel = 0x80000008, + .model_id = "Intel Xeon E3-12xx v2 (Ivy Bridge, IBRS)", + }, + { .name = "Haswell-noTSX", .level = 0xd, .vendor = CPUID_VENDOR_INTEL,
@@ -1205,7 +1327,46 @@ static X86CPUDefinition builtin_x86_defs[] = { CPUID_6_EAX_ARAT, .xlevel = 0x80000008, .model_id = "Intel Core Processor (Haswell, no TSX)", - }, { + }, + { + .name = "Haswell-noTSX-IBRS", + .level = 0xd, + .vendor = CPUID_VENDOR_INTEL, + .family = 6, + .model = 60, + .stepping = 1, + .features[FEAT_1_EDX ] = +CPUID_VME |CPUID_SSE2 |CPUID_SSE |CPUID_FXSR |CPUID_MMX | +CPUID_CLFLUSH |CPUID_PSE36 |CPUID_PAT |CPUID_CMOV |CPUID_MCA | +CPUID_PGE |CPUID_MTRR |CPUID_SEP |CPUID_APIC |CPUID_CX8 | +CPUID_MCE |CPUID_PAE |CPUID_MSR |CPUID_TSC |CPUID_PSE | + CPUID_DE | CPUID_FP87, + .features[FEAT_1_ECX ] = +CPUID_EXT_AVX |CPUID_EXT_XSAVE |CPUID_EXT_AES | +CPUID_EXT_POPCNT |CPUID_EXT_X2APIC |CPUID_EXT_SSE42 | +CPUID_EXT_SSE41 |CPUID_EXT_CX16 |CPUID_EXT_SSSE3 | +CPUID_EXT_PCLMULQDQ |CPUID_EXT_SSE3 | +CPUID_EXT_TSC_DEADLINE_TIMER |CPUID_EXT_FMA |CPUID_EXT_MOVBE | + CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND, + .features[FEAT_8000_0001_EDX ] = +CPUID_EXT2_LM |CPUID_EXT2_RDTSCP |CPUID_EXT2_NX | + CPUID_EXT2_SYSCALL, + .features[FEAT_8000_0001_ECX ] = + CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM, + .features[FEAT_7_0_EDX ] = + CPUID_7_0_EDX_SPEC_CTRL, + .features[FEAT_7_0_EBX ] = +CPUID_7_0_EBX_FSGSBASE |CPUID_7_0_EBX_BMI1 | +CPUID_7_0_EBX_AVX2 |CPUID_7_0_EBX_SMEP | + CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCID, + .features[FEAT_XSAVE ] = + CPUID_XSAVE_XSAVEOPT, + .features[FEAT_6_EAX ] = + CPUID_6_EAX_ARAT, + .xlevel = 0x80000008, + .model_id = "Intel Core Processor (Haswell, no TSX, IBRS)", + }, + { .name = "Haswell", .level = 0xd, .vendor = CPUID_VENDOR_INTEL,
@@ -1243,6 +1404,45 @@ static X86CPUDefinition builtin_x86_defs[] = { .model_id = "Intel Core Processor (Haswell)", }, { + .name = "Haswell-IBRS", + .level = 0xd, + .vendor = CPUID_VENDOR_INTEL, + .family = 6, + .model = 60, + .stepping = 4, + .features[FEAT_1_EDX ] = +CPUID_VME |CPUID_SSE2 |CPUID_SSE |CPUID_FXSR |CPUID_MMX | +CPUID_CLFLUSH |CPUID_PSE36 |CPUID_PAT |CPUID_CMOV |CPUID_MCA | +CPUID_PGE |CPUID_MTRR |CPUID_SEP |CPUID_APIC |CPUID_CX8 | +CPUID_MCE |CPUID_PAE |CPUID_MSR |CPUID_TSC |CPUID_PSE | + CPUID_DE | CPUID_FP87, + .features[FEAT_1_ECX ] = +CPUID_EXT_AVX |CPUID_EXT_XSAVE |CPUID_EXT_AES | +CPUID_EXT_POPCNT |CPUID_EXT_X2APIC |CPUID_EXT_SSE42 | +CPUID_EXT_SSE41 |CPUID_EXT_CX16 |CPUID_EXT_SSSE3 | +CPUID_EXT_PCLMULQDQ |CPUID_EXT_SSE3 | +CPUID_EXT_TSC_DEADLINE_TIMER |CPUID_EXT_FMA |CPUID_EXT_MOVBE | + CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND, + .features[FEAT_8000_0001_EDX ] = +CPUID_EXT2_LM |CPUID_EXT2_RDTSCP |CPUID_EXT2_NX | + CPUID_EXT2_SYSCALL, + .features[FEAT_8000_0001_ECX ] = + CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM, + .features[FEAT_7_0_EDX ] = + CPUID_7_0_EDX_SPEC_CTRL, + .features[FEAT_7_0_EBX ] = +CPUID_7_0_EBX_FSGSBASE |CPUID_7_0_EBX_BMI1 | +CPUID_7_0_EBX_HLE |CPUID_7_0_EBX_AVX2 |CPUID_7_0_EBX_SMEP | +CPUID_7_0_EBX_BMI2 |CPUID_7_0_EBX_ERMS |CPUID_7_0_EBX_INVPCID | + CPUID_7_0_EBX_RTM, + .features[FEAT_XSAVE ] = + CPUID_XSAVE_XSAVEOPT, + .features[FEAT_6_EAX ] = + CPUID_6_EAX_ARAT, + .xlevel = 0x80000008, + .model_id = "Intel Core Processor (Haswell, IBRS)", + }, + { .name = "Broadwell-noTSX", .level = 0xd, .vendor = CPUID_VENDOR_INTEL,
@@ -1281,6 +1481,46 @@ static X86CPUDefinition builtin_x86_defs[] = { .model_id = "Intel Core Processor (Broadwell, no TSX)", }, { + .name = "Broadwell-noTSX-IBRS", + .level = 0xd, + .vendor = CPUID_VENDOR_INTEL, + .family = 6, + .model = 61, + .stepping = 2, + .features[FEAT_1_EDX ] = +CPUID_VME |CPUID_SSE2 |CPUID_SSE |CPUID_FXSR |CPUID_MMX | +CPUID_CLFLUSH |CPUID_PSE36 |CPUID_PAT |CPUID_CMOV |CPUID_MCA | +CPUID_PGE |CPUID_MTRR |CPUID_SEP |CPUID_APIC |CPUID_CX8 | +CPUID_MCE |CPUID_PAE |CPUID_MSR |CPUID_TSC |CPUID_PSE | + CPUID_DE | CPUID_FP87, + .features[FEAT_1_ECX ] = +CPUID_EXT_AVX |CPUID_EXT_XSAVE |CPUID_EXT_AES | +CPUID_EXT_POPCNT |CPUID_EXT_X2APIC |CPUID_EXT_SSE42 | +CPUID_EXT_SSE41 |CPUID_EXT_CX16 |CPUID_EXT_SSSE3 | +CPUID_EXT_PCLMULQDQ |CPUID_EXT_SSE3 | +CPUID_EXT_TSC_DEADLINE_TIMER |CPUID_EXT_FMA |CPUID_EXT_MOVBE | + CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND, + .features[FEAT_8000_0001_EDX ] = +CPUID_EXT2_LM |CPUID_EXT2_RDTSCP |CPUID_EXT2_NX | + CPUID_EXT2_SYSCALL, + .features[FEAT_8000_0001_ECX ] = + CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM | CPUID_EXT3_3DNOWPREFETCH, + .features[FEAT_7_0_EDX ] = + CPUID_7_0_EDX_SPEC_CTRL, + .features[FEAT_7_0_EBX ] = +CPUID_7_0_EBX_FSGSBASE |CPUID_7_0_EBX_BMI1 | +CPUID_7_0_EBX_AVX2 |CPUID_7_0_EBX_SMEP | +CPUID_7_0_EBX_BMI2 |CPUID_7_0_EBX_ERMS |CPUID_7_0_EBX_INVPCID | +CPUID_7_0_EBX_RDSEED |CPUID_7_0_EBX_ADX | + CPUID_7_0_EBX_SMAP, + .features[FEAT_XSAVE ] = + CPUID_XSAVE_XSAVEOPT, + .features[FEAT_6_EAX ] = + CPUID_6_EAX_ARAT, + .xlevel = 0x80000008, + .model_id = "Intel Core Processor (Broadwell, no TSX, IBRS)", + }, + { .name = "Broadwell", .level = 0xd, .vendor = CPUID_VENDOR_INTEL,
@@ -1319,6 +1559,46 @@ static X86CPUDefinition builtin_x86_defs[] = { .model_id = "Intel Core Processor (Broadwell)", }, { + .name = "Broadwell-IBRS", + .level = 0xd, + .vendor = CPUID_VENDOR_INTEL, + .family = 6, + .model = 61, + .stepping = 2, + .features[FEAT_1_EDX ] = +CPUID_VME |CPUID_SSE2 |CPUID_SSE |CPUID_FXSR |CPUID_MMX | +CPUID_CLFLUSH |CPUID_PSE36 |CPUID_PAT |CPUID_CMOV |CPUID_MCA | +CPUID_PGE |CPUID_MTRR |CPUID_SEP |CPUID_APIC |CPUID_CX8 | +CPUID_MCE |CPUID_PAE |CPUID_MSR |CPUID_TSC |CPUID_PSE | + CPUID_DE | CPUID_FP87, + .features[FEAT_1_ECX ] = +CPUID_EXT_AVX |CPUID_EXT_XSAVE |CPUID_EXT_AES | +CPUID_EXT_POPCNT |CPUID_EXT_X2APIC |CPUID_EXT_SSE42 | +CPUID_EXT_SSE41 |CPUID_EXT_CX16 |CPUID_EXT_SSSE3 | +CPUID_EXT_PCLMULQDQ |CPUID_EXT_SSE3 | +CPUID_EXT_TSC_DEADLINE_TIMER |CPUID_EXT_FMA |CPUID_EXT_MOVBE | + CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND, + .features[FEAT_8000_0001_EDX ] = +CPUID_EXT2_LM |CPUID_EXT2_RDTSCP |CPUID_EXT2_NX | + CPUID_EXT2_SYSCALL, + .features[FEAT_8000_0001_ECX ] = + CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM | CPUID_EXT3_3DNOWPREFETCH, + .features[FEAT_7_0_EDX ] = + CPUID_7_0_EDX_SPEC_CTRL, + .features[FEAT_7_0_EBX ] = +CPUID_7_0_EBX_FSGSBASE |CPUID_7_0_EBX_BMI1 | +CPUID_7_0_EBX_HLE |CPUID_7_0_EBX_AVX2 |CPUID_7_0_EBX_SMEP | +CPUID_7_0_EBX_BMI2 |CPUID_7_0_EBX_ERMS |CPUID_7_0_EBX_INVPCID | +CPUID_7_0_EBX_RTM |CPUID_7_0_EBX_RDSEED |CPUID_7_0_EBX_ADX | + CPUID_7_0_EBX_SMAP, + .features[FEAT_XSAVE ] = + CPUID_XSAVE_XSAVEOPT, + .features[FEAT_6_EAX ] = + CPUID_6_EAX_ARAT, + .xlevel = 0x80000008, + .model_id = "Intel Core Processor (Broadwell, IBRS)", + }, + { .name = "Skylake-Client", .level = 0xd, .vendor = CPUID_VENDOR_INTEL,
@@ -1364,6 +1644,53 @@ static X86CPUDefinition builtin_x86_defs[] = { .model_id = "Intel Core Processor (Skylake)", }, { + .name = "Skylake-Client-IBRS", + .level = 0xd, + .vendor = CPUID_VENDOR_INTEL, + .family = 6, + .model = 94, + .stepping = 3, + .features[FEAT_1_EDX ] = +CPUID_VME |CPUID_SSE2 |CPUID_SSE |CPUID_FXSR |CPUID_MMX | +CPUID_CLFLUSH |CPUID_PSE36 |CPUID_PAT |CPUID_CMOV |CPUID_MCA | +CPUID_PGE |CPUID_MTRR |CPUID_SEP |CPUID_APIC |CPUID_CX8 | +CPUID_MCE |CPUID_PAE |CPUID_MSR |CPUID_TSC |CPUID_PSE | + CPUID_DE | CPUID_FP87, + .features[FEAT_1_ECX ] = +CPUID_EXT_AVX |CPUID_EXT_XSAVE |CPUID_EXT_AES | +CPUID_EXT_POPCNT |CPUID_EXT_X2APIC |CPUID_EXT_SSE42 | +CPUID_EXT_SSE41 |CPUID_EXT_CX16 |CPUID_EXT_SSSE3 | +CPUID_EXT_PCLMULQDQ |CPUID_EXT_SSE3 | +CPUID_EXT_TSC_DEADLINE_TIMER |CPUID_EXT_FMA |CPUID_EXT_MOVBE | + CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND, + .features[FEAT_8000_0001_EDX ] = +CPUID_EXT2_LM |CPUID_EXT2_RDTSCP |CPUID_EXT2_NX | + CPUID_EXT2_SYSCALL, + .features[FEAT_8000_0001_ECX ] = + CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM | CPUID_EXT3_3DNOWPREFETCH, + .features[FEAT_7_0_EDX ] = + CPUID_7_0_EDX_SPEC_CTRL, + .features[FEAT_7_0_EBX ] = +CPUID_7_0_EBX_FSGSBASE |CPUID_7_0_EBX_BMI1 | +CPUID_7_0_EBX_HLE |CPUID_7_0_EBX_AVX2 |CPUID_7_0_EBX_SMEP | +CPUID_7_0_EBX_BMI2 |CPUID_7_0_EBX_ERMS |CPUID_7_0_EBX_INVPCID | +CPUID_7_0_EBX_RTM |CPUID_7_0_EBX_RDSEED |CPUID_7_0_EBX_ADX | + CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_MPX, +/* Missing: XSAVES (not supported by some Linux versions, +* including v4.1 to v4.12). +* KVM doesn't yet expose any XSAVES state save component, +* and the only one defined in Skylake (processor tracing) +* probably will block migration anyway. +*/ + .features[FEAT_XSAVE ] = +CPUID_XSAVE_XSAVEOPT |CPUID_XSAVE_XSAVEC | + CPUID_XSAVE_XGETBV1, + .features[FEAT_6_EAX ] = + CPUID_6_EAX_ARAT, + .xlevel = 0x80000008, + .model_id = "Intel Core Processor (Skylake, IBRS)", + }, + { .name = "Skylake-Server", .level = 0xd, .vendor = CPUID_VENDOR_INTEL,
@@ -1412,6 +1739,56 @@ static X86CPUDefinition builtin_x86_defs[] = { .model_id = "Intel Xeon Processor (Skylake)", }, { + .name = "Skylake-Server-IBRS", + .level = 0xd, + .vendor = CPUID_VENDOR_INTEL, + .family = 6, + .model = 85, + .stepping = 4, + .features[FEAT_1_EDX ] = +CPUID_VME |CPUID_SSE2 |CPUID_SSE |CPUID_FXSR |CPUID_MMX | +CPUID_CLFLUSH |CPUID_PSE36 |CPUID_PAT |CPUID_CMOV |CPUID_MCA | +CPUID_PGE |CPUID_MTRR |CPUID_SEP |CPUID_APIC |CPUID_CX8 | +CPUID_MCE |CPUID_PAE |CPUID_MSR |CPUID_TSC |CPUID_PSE | + CPUID_DE | CPUID_FP87, + .features[FEAT_1_ECX ] = +CPUID_EXT_AVX |CPUID_EXT_XSAVE |CPUID_EXT_AES | +CPUID_EXT_POPCNT |CPUID_EXT_X2APIC |CPUID_EXT_SSE42 | +CPUID_EXT_SSE41 |CPUID_EXT_CX16 |CPUID_EXT_SSSE3 | +CPUID_EXT_PCLMULQDQ |CPUID_EXT_SSE3 | +CPUID_EXT_TSC_DEADLINE_TIMER |CPUID_EXT_FMA |CPUID_EXT_MOVBE | + CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND, + .features[FEAT_8000_0001_EDX ] = +CPUID_EXT2_LM |CPUID_EXT2_PDPE1GB |CPUID_EXT2_RDTSCP | + CPUID_EXT2_NX | CPUID_EXT2_SYSCALL, + .features[FEAT_8000_0001_ECX ] = + CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM | CPUID_EXT3_3DNOWPREFETCH, + .features[FEAT_7_0_EDX ] = + CPUID_7_0_EDX_SPEC_CTRL, + .features[FEAT_7_0_EBX ] = +CPUID_7_0_EBX_FSGSBASE |CPUID_7_0_EBX_BMI1 | +CPUID_7_0_EBX_HLE |CPUID_7_0_EBX_AVX2 |CPUID_7_0_EBX_SMEP | +CPUID_7_0_EBX_BMI2 |CPUID_7_0_EBX_ERMS |CPUID_7_0_EBX_INVPCID | +CPUID_7_0_EBX_RTM |CPUID_7_0_EBX_RDSEED |CPUID_7_0_EBX_ADX | +CPUID_7_0_EBX_SMAP |CPUID_7_0_EBX_MPX |CPUID_7_0_EBX_CLWB | +CPUID_7_0_EBX_AVX512F |CPUID_7_0_EBX_AVX512DQ | +CPUID_7_0_EBX_AVX512BW |CPUID_7_0_EBX_AVX512CD | + CPUID_7_0_EBX_AVX512VL, +/* Missing: XSAVES (not supported by some Linux versions, +* including v4.1 to v4.12). +* KVM doesn't yet expose any XSAVES state save component, +* and the only one defined in Skylake (processor tracing) +* probably will block migration anyway. +*/ + .features[FEAT_XSAVE ] = +CPUID_XSAVE_XSAVEOPT |CPUID_XSAVE_XSAVEC | + CPUID_XSAVE_XGETBV1, + .features[FEAT_6_EAX ] = + CPUID_6_EAX_ARAT, + .xlevel = 0x80000008, + .model_id = "Intel Xeon Processor (Skylake, IBRS)", + }, + { .name = "Opteron_G1", .level = 5, .vendor = CPUID_VENDOR_AMD,
Signature · 1 line
2.11.0
PATCH 25/54 i386: Add EPYC-IBPB CPU model
In reply to Michael RothFrom: Eduardo Habkost <[email protected]>
EPYC-IBPB is a copy of the EPYC CPU model with
just CPUID_8000_0008_EBX_IBPB added.
Message-Id: <[email protected]>
--- target/i386/cpu.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
target/i386/cpu.c +46 -0
@@ -1962,6 +1962,52 @@ static X86CPUDefinition builtin_x86_defs[] = { .xlevel = 0x8000000A, .model_id = "AMD EPYC Processor", }, + { + .name = "EPYC-IBPB", + .level = 0xd, + .vendor = CPUID_VENDOR_AMD, + .family = 23, + .model = 1, + .stepping = 2, + .features[FEAT_1_EDX] = + CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | CPUID_CLFLUSH | + CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA | CPUID_PGE | + CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | CPUID_MCE | + CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | CPUID_DE | + CPUID_VME | CPUID_FP87, + .features[FEAT_1_ECX] = + CPUID_EXT_RDRAND | CPUID_EXT_F16C | CPUID_EXT_AVX | + CPUID_EXT_XSAVE | CPUID_EXT_AES | CPUID_EXT_POPCNT | + CPUID_EXT_MOVBE | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 | + CPUID_EXT_CX16 | CPUID_EXT_FMA | CPUID_EXT_SSSE3 | + CPUID_EXT_MONITOR | CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3, + .features[FEAT_8000_0001_EDX] = + CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_PDPE1GB | + CPUID_EXT2_FFXSR | CPUID_EXT2_MMXEXT | CPUID_EXT2_NX | + CPUID_EXT2_SYSCALL, + .features[FEAT_8000_0001_ECX] = + CPUID_EXT3_OSVW | CPUID_EXT3_3DNOWPREFETCH | + CPUID_EXT3_MISALIGNSSE | CPUID_EXT3_SSE4A | CPUID_EXT3_ABM | + CPUID_EXT3_CR8LEG | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM, + .features[FEAT_8000_0008_EBX] = + CPUID_8000_0008_EBX_IBPB, + .features[FEAT_7_0_EBX] = + CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | CPUID_7_0_EBX_AVX2 | + CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_RDSEED | + CPUID_7_0_EBX_ADX | CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_CLFLUSHOPT | + CPUID_7_0_EBX_SHA_NI, + /* Missing: XSAVES (not supported by some Linux versions, + * including v4.1 to v4.12). + * KVM doesn't yet expose any XSAVES state save component. + */ + .features[FEAT_XSAVE] = + CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | + CPUID_XSAVE_XGETBV1, + .features[FEAT_6_EAX] = + CPUID_6_EAX_ARAT, + .xlevel = 0x8000000A, + .model_id = "AMD EPYC Processor (with IBPB)", + }, }; typedef struct PropValue {
Signature · 1 line
2.11.0
PATCH 26/54 linux-user: Fix locking order in fork_start()
In reply to Michael RothFrom: Peter Maydell <[email protected]>
Our locking order is that the tb lock should be taken inside the mmap_lock, but fork_start() grabs locks the other way around. This means that if a heavily multithreaded guest process (such as Java) calls fork() it can deadlock, with the thread that called fork() stuck in fork_start() with the tb lock and waiting for the mmap lock, but some other thread in tb_find() with the mmap lock and waiting for the tb lock. The cpu_list_lock() should also always be taken last, not first.
Fix this by making fork_start() grab the locks in the right order. The order in which we drop locks doesn't matter, so we leave fork_end() the way it is.
Message-Id: <[email protected]>
--- linux-user/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
linux-user/main.c +2 -2
@@ -128,9 +128,9 @@ int cpu_get_pic_interrupt(CPUX86State *env)/* Make sure everything is in a consistent state for calling fork(). */ void fork_start (void ) { -cpu_list_lock (); -qemu_mutex_lock (&tb_ctx.tb_lock);mmap_fork_start (); +qemu_mutex_lock (&tb_ctx.tb_lock); +cpu_list_lock (); }void fork_end (int child)
Signature · 1 line
2.11.0
PATCH 27/54 s390x: fix storage attributes migration for non-small guests
In reply to Michael RothFrom: Claudio Imbrenda <[email protected]>
Fix storage attribute migration so that it does not fail for guests with more than a few GB of RAM.
With such guests, the index in the buffer would go out of bounds, usually by large amounts, thus receiving -EFAULT from the kernel. Migration itself would be successful, but storage attributes would then not be migrated completely.
This patch fixes the out of bounds access, and thus migration of all storage attributes when the guest have large amounts of memory.
Message-Id: <[email protected]>
--- hw/s390x/s390-stattrib-kvm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/s390x/s390-stattrib-kvm.c +2 -2
@@ -116,7 +116,7 @@ static void kvm_s390_stattrib_synchronize(S390StAttribState *sa)for (cx =0 ; cx + len <= max; cx += len) { clog.start_gfn = cx; clog.count = len; - clog.values = (uint64_t )(sas->incoming_buffer + cx * len); + clog.values = (uint64_t )(sas->incoming_buffer + cx); r =kvm_vm_ioctl (kvm_state,KVM_S390_SET_CMMA_BITS , &clog);if (r) {error_report ("KVM_S390_SET_CMMA_BITS failed: %s" ,strerror (-r));
@@ -126,7 +126,7 @@ static void kvm_s390_stattrib_synchronize(S390StAttribState *sa)if (cx < max) { clog.start_gfn = cx; clog.count = max - cx; - clog.values = (uint64_t )(sas->incoming_buffer + cx * len); + clog.values = (uint64_t )(sas->incoming_buffer + cx); r =kvm_vm_ioctl (kvm_state,KVM_S390_SET_CMMA_BITS , &clog);if (r) {error_report ("KVM_S390_SET_CMMA_BITS failed: %s" ,strerror (-r));
Signature · 1 line
2.11.0
PATCH 28/54 linux-headers: update to 4.15-rc1
In reply to Michael RothFrom: Eric Auger <[email protected]>
Update headers against v4.15-rc1.
Message-id: [email protected]
--- include/standard-headers/asm-s390/virtio-ccw.h | 1 + include/standard-headers/asm-x86/hyperv.h | 394 +-------------------- include/standard-headers/linux/input-event-codes.h | 2 + include/standard-headers/linux/input.h | 1 + include/standard-headers/linux/pci_regs.h | 45 ++- linux-headers/asm-arm/kvm.h | 8 + linux-headers/asm-arm/kvm_para.h | 1 + linux-headers/asm-arm/unistd.h | 2 + linux-headers/asm-arm64/kvm.h | 8 + linux-headers/asm-arm64/unistd.h | 1 + linux-headers/asm-powerpc/epapr_hcalls.h | 1 + linux-headers/asm-powerpc/kvm.h | 1 + linux-headers/asm-powerpc/kvm_para.h | 1 + linux-headers/asm-powerpc/unistd.h | 1 + linux-headers/asm-s390/kvm.h | 1 + linux-headers/asm-s390/kvm_para.h | 1 + linux-headers/asm-s390/unistd.h | 4 +- linux-headers/asm-x86/kvm.h | 1 + linux-headers/asm-x86/kvm_para.h | 2 +- linux-headers/asm-x86/unistd.h | 1 + linux-headers/linux/kvm.h | 2 + linux-headers/linux/kvm_para.h | 1 + linux-headers/linux/psci.h | 1 + linux-headers/linux/userfaultfd.h | 1 + linux-headers/linux/vfio.h | 1 + linux-headers/linux/vfio_ccw.h | 1 + linux-headers/linux/vhost.h | 1 + 27 files changed, 74 insertions(+), 411 deletions(-)
include/standard-headers/asm-s390/virtio-ccw.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * Definitions for virtio-ccw devices. *
include/standard-headers/asm-x86/hyperv.h +1 -393
394 lines not on this page · raw message
include/standard-headers/linux/input-event-codes.h +2 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * Input event codes *
@@ -406,6 +407,7 @@#define BTN_TOOL_MOUSE 0x146#define BTN_TOOL_LENS 0x147#define BTN_TOOL_QUINTTAP 0x148/* Five fingers on trackpad */ +#define BTN_STYLUS3 0x149#define BTN_TOUCH 0x14a#define BTN_STYLUS 0x14b#define BTN_STYLUS2 0x14c
include/standard-headers/linux/input.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * Copyright (c) 1999-2002 Vojtech Pavlik *
include/standard-headers/linux/pci_regs.h +29 -16
72 lines not on this page · raw message
linux-headers/asm-arm/kvm.h +8 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * Copyright (C) 2012 - Virtual Open Systems and Columbia University * Author: Christoffer Dall <[email protected]>
@@ -151,6 +152,12 @@ struct kvm_arch_memory_slot { (__ARM_CP15_REG(op1, 0, crm, 0) | KVM_REG_SIZE_U64)#define ARM_CP15_REG64 (...) __ARM_CP15_REG64(__VA_ARGS__) +/* PL1 Physical Timer Registers */ +#define KVM_REG_ARM_PTIMER_CTL ARM_CP15_REG32(0, 14, 2, 1) +#define KVM_REG_ARM_PTIMER_CNT ARM_CP15_REG64(0, 14) +#define KVM_REG_ARM_PTIMER_CVAL ARM_CP15_REG64(2, 14) + +/* Virtual Timer Registers */ #define KVM_REG_ARM_TIMER_CTL ARM_CP15_REG32(0, 14, 3, 1)#define KVM_REG_ARM_TIMER_CNT ARM_CP15_REG64(1, 14)#define KVM_REG_ARM_TIMER_CVAL ARM_CP15_REG64(3, 14)
@@ -215,6 +222,7 @@ struct kvm_arch_memory_slot {#define KVM_DEV_ARM_ITS_SAVE_TABLES 1#define KVM_DEV_ARM_ITS_RESTORE_TABLES 2#define KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES 3 +#define KVM_DEV_ARM_ITS_CTRL_RESET 4/* KVM_IRQ_LINE irq field index values */ #define KVM_ARM_IRQ_TYPE_SHIFT 24
linux-headers/asm-arm/kvm_para.h +1 -0
@@ -1 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #include <asm-generic/kvm_para.h>
linux-headers/asm-arm/unistd.h +2 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * arch/arm/include/asm/unistd.h *
@@ -35,5 +36,6 @@#define __ARM_NR_usr26 (__ARM_NR_BASE+3)#define __ARM_NR_usr32 (__ARM_NR_BASE+4)#define __ARM_NR_set_tls (__ARM_NR_BASE+5) +#define __ARM_NR_get_tls (__ARM_NR_BASE+6)#endif /* __ASM_ARM_UNISTD_H */
linux-headers/asm-arm64/kvm.h +8 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * Copyright (C) 2012,2013 - ARM Ltd * Author: Marc Zyngier <[email protected]>
@@ -195,6 +196,12 @@ struct kvm_arch_memory_slot {#define ARM64_SYS_REG (...) (__ARM64_SYS_REG(__VA_ARGS__) | KVM_REG_SIZE_U64) +/* Physical Timer EL0 Registers */ +#define KVM_REG_ARM_PTIMER_CTL ARM64_SYS_REG(3, 3, 14, 2, 1) +#define KVM_REG_ARM_PTIMER_CVAL ARM64_SYS_REG(3, 3, 14, 2, 2) +#define KVM_REG_ARM_PTIMER_CNT ARM64_SYS_REG(3, 3, 14, 0, 1) + +/* EL0 Virtual Timer Registers */ #define KVM_REG_ARM_TIMER_CTL ARM64_SYS_REG(3, 3, 14, 3, 1)#define KVM_REG_ARM_TIMER_CNT ARM64_SYS_REG(3, 3, 14, 3, 2)#define KVM_REG_ARM_TIMER_CVAL ARM64_SYS_REG(3, 3, 14, 0, 2)
@@ -227,6 +234,7 @@ struct kvm_arch_memory_slot {#define KVM_DEV_ARM_ITS_SAVE_TABLES 1#define KVM_DEV_ARM_ITS_RESTORE_TABLES 2#define KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES 3 +#define KVM_DEV_ARM_ITS_CTRL_RESET 4/* Device Control API on vcpu fd */ #define KVM_ARM_VCPU_PMU_V3_CTRL 0
linux-headers/asm-arm64/unistd.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * Copyright (C) 2012 ARM Ltd. *
linux-headers/asm-powerpc/epapr_hcalls.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) */ /* * ePAPR hcall interface *
linux-headers/asm-powerpc/kvm.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as
linux-headers/asm-powerpc/kvm_para.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as
linux-headers/asm-powerpc/unistd.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ /* * This file contains the system call numbers. *
linux-headers/asm-s390/kvm.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __LINUX_KVM_S390_H#define __LINUX_KVM_S390_H/*
linux-headers/asm-s390/kvm_para.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * User API definitions for paravirtual devices on s390 *
linux-headers/asm-s390/unistd.h +3 -1
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * S390 version *
@@ -315,7 +316,8 @@#define __NR_pwritev2 377#define __NR_s390_guarded_storage 378#define __NR_statx 379 -#define NR_syscalls 380 +#define __NR_s390_sthyi 380 +#define NR_syscalls 381/* * There are some system calls that are not present on 64 bit, some
linux-headers/asm-x86/kvm.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_X86_KVM_H#define _ASM_X86_KVM_H
linux-headers/asm-x86/kvm_para.h +1 -1
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_X86_KVM_PARA_H#define _ASM_X86_KVM_PARA_H
@@ -109,5 +110,4 @@ struct kvm_vcpu_pv_apf_data {#define KVM_PV_EOI_ENABLED KVM_PV_EOI_MASK#define KVM_PV_EOI_DISABLED 0x0 -#endif /* _ASM_X86_KVM_PARA_H */
linux-headers/asm-x86/unistd.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_X86_UNISTD_H#define _ASM_X86_UNISTD_H
linux-headers/linux/kvm.h +2 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __LINUX_KVM_H#define __LINUX_KVM_H
@@ -930,6 +931,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_PPC_SMT_POSSIBLE 147#define KVM_CAP_HYPERV_SYNIC2 148#define KVM_CAP_HYPERV_VP_INDEX 149 +#define KVM_CAP_S390_AIS_MIGRATION 150#ifdef KVM_CAP_IRQ_ROUTING
linux-headers/linux/kvm_para.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __LINUX_KVM_PARA_H#define __LINUX_KVM_PARA_H
linux-headers/linux/psci.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * ARM Power State and Coordination Interface (PSCI) header *
linux-headers/linux/userfaultfd.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * include/linux/userfaultfd.h *
linux-headers/linux/vfio.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * VFIO API definition *
linux-headers/linux/vfio_ccw.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * Interfaces for vfio-ccw *
linux-headers/linux/vhost.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _LINUX_VHOST_H#define _LINUX_VHOST_H/* Userspace interface for in-kernel virtio accelerators. */
Signature · 1 line
2.11.0
PATCH 29/54 linux-headers: update
In reply to Michael RothFrom: Cornelia Huck <[email protected]>
Update headers against 4.15-rc9.
--- include/standard-headers/asm-s390/virtio-ccw.h | 6 +----- linux-headers/asm-powerpc/kvm.h | 25 +++++++++++++++++++++++++ linux-headers/asm-s390/kvm.h | 9 ++++----- linux-headers/asm-s390/kvm_para.h | 4 ---- linux-headers/linux/kvm.h | 8 ++++++-- 5 files changed, 36 insertions(+), 16 deletions(-)
include/standard-headers/asm-s390/virtio-ccw.h +1 -5
@@ -1,13 +1,9 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ /* * Definitions for virtio-ccw devices. * * Copyright IBM Corp. 2013 * -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License (version 2 only) -* as published by the Free Software Foundation. -* * Author(s): Cornelia Huck <[email protected]> */ #ifndef __KVM_VIRTIO_CCW_H
linux-headers/asm-powerpc/kvm.h +25 -0
@@ -443,6 +443,31 @@ struct kvm_ppc_rmmu_info {__u32 ap_encodings[8 ]; }; +/* For KVM_PPC_GET_CPU_CHAR */ +struct kvm_ppc_cpu_char { +__u64 character;/* characteristics of the CPU */ +__u64 behaviour;/* recommended software behaviour */ +__u64 character_mask;/* valid bits in character */ +__u64 behaviour_mask;/* valid bits in behaviour */ +}; + +/* +* Values for character and character_mask. +* These are identical to the values used by H_GET_CPU_CHARACTERISTICS. +*/ +#define KVM_PPC_CPU_CHAR_SPEC_BAR_ORI31 (1ULL << 63) +#define KVM_PPC_CPU_CHAR_BCCTRL_SERIALISED (1ULL << 62) +#define KVM_PPC_CPU_CHAR_L1D_FLUSH_ORI30 (1ULL << 61) +#define KVM_PPC_CPU_CHAR_L1D_FLUSH_TRIG2 (1ULL << 60) +#define KVM_PPC_CPU_CHAR_L1D_THREAD_PRIV (1ULL << 59) +#define KVM_PPC_CPU_CHAR_BR_HINT_HONOURED (1ULL << 58) +#define KVM_PPC_CPU_CHAR_MTTRIG_THR_RECONF (1ULL << 57) +#define KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS (1ULL << 56) + +#define KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY (1ULL << 63) +#define KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR (1ULL << 62) +#define KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR (1ULL << 61) +/* Per-vcpu XICS interrupt controller state */ #define KVM_REG_PPC_ICP_STATE (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x8c)
linux-headers/asm-s390/kvm.h +4 -5
@@ -6,10 +6,6 @@* * Copyright IBM Corp. 2008 * -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License (version 2 only) -* as published by the Free Software Foundation. -* * Author(s): Carsten Otte <[email protected]> * Christian Borntraeger <[email protected]> */
@@ -228,6 +224,7 @@ struct kvm_guest_debug_arch {#define KVM_SYNC_RICCB (1UL << 7)#define KVM_SYNC_FPRS (1UL << 8)#define KVM_SYNC_GSCB (1UL << 9) +#define KVM_SYNC_BPBC (1UL << 10)/* length and alignment of the sdnx as a power of two */ #define SDNXC 8#define SDNXL (1UL << SDNXC)
@@ -251,7 +248,9 @@ struct kvm_sync_regs { };__u8 reserved[512 ];/* for future vector expansion */ __u32 fpc;/* valid on KVM_SYNC_VRS or KVM_SYNC_FPRS */ -__u8 padding1[52 ];/* riccb needs to be 64byte aligned */ + __u8 bpbc : 1; /* bp mode */ + __u8 reserved2 : 7; +__u8 padding1[51 ];/* riccb needs to be 64byte aligned */ __u8 riccb[64 ];/* runtime instrumentation controls block */ __u8 padding2[192 ];/* sdnx needs to be 256byte aligned */ union {
linux-headers/asm-s390/kvm_para.h +0 -4
@@ -4,9 +4,5 @@* * Copyright IBM Corp. 2008 * -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License (version 2 only) -* as published by the Free Software Foundation. -* * Author(s): Christian Borntraeger <[email protected]> */
linux-headers/linux/kvm.h +6 -2
@@ -630,9 +630,9 @@ struct kvm_s390_irq {struct kvm_s390_irq_state {__u64 buf; -__u32 flags; +__u32 flags;/* will stay unused for compatibility reasons */ __u32 len; -__u32 reserved[4 ]; +__u32 reserved[4 ];/* will stay unused for compatibility reasons */ };/* for KVM_SET_GUEST_DEBUG */
@@ -932,6 +932,8 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_HYPERV_SYNIC2 148#define KVM_CAP_HYPERV_VP_INDEX 149#define KVM_CAP_S390_AIS_MIGRATION 150 +#define KVM_CAP_PPC_GET_CPU_CHAR 151 +#define KVM_CAP_S390_BPB 152#ifdef KVM_CAP_IRQ_ROUTING
@@ -1261,6 +1263,8 @@ struct kvm_s390_ucas_mapping {#define KVM_PPC_CONFIGURE_V3_MMU _IOW(KVMIO, 0xaf, struct kvm_ppc_mmuv3_cfg)/* Available with KVM_CAP_PPC_RADIX_MMU */ #define KVM_PPC_GET_RMMU_INFO _IOW(KVMIO, 0xb0, struct kvm_ppc_rmmu_info) +/* Available with KVM_CAP_PPC_GET_CPU_CHAR */ +#define KVM_PPC_GET_CPU_CHAR _IOR(KVMIO, 0xb1, struct kvm_ppc_cpu_char)/* ioctl for vm fd */ #define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device)
Signature · 1 line
2.11.0
PATCH 30/54 s390x/kvm: Handle bpb feature
In reply to Michael RothFrom: Christian Borntraeger <[email protected]>
We need to handle the bpb control on reset and migration. Normally stfle.82 is transparent (and the normal guest part works without hypervisor activity). To prevent any issues we require full host kernel support for this feature.
Message-Id: <[email protected]>
--- target/s390x/cpu.c | 1 + target/s390x/cpu.h | 1 + target/s390x/cpu_features.c | 1 + target/s390x/cpu_features_def.h | 1 + target/s390x/gen-features.c | 1 + target/s390x/kvm.c | 14 ++++++++++++++ target/s390x/machine.c | 17 +++++++++++++++++ 7 files changed, 36 insertions(+)
target/s390x/cpu.c +1 -0
@@ -89,6 +89,7 @@ static void s390_cpu_reset(CPUState *s)CPUS390XState *env = &cpu->env; env->pfault_token =-1UL ; + env->bpbc = false; scc->parent_reset (s); cpu->env.sigp_order =0 ;s390_cpu_set_state (CPU_STATE_STOPPED , cpu);
target/s390x/cpu.h +1 -0
@@ -93,6 +93,7 @@ struct CPUS390XState {uint32_t fpc;/* floating-point control register */ uint32_t cc_op; +bool bpbc;/* branch prediction blocking */ float_status fpu_status;/* passed to softfloat lib */
target/s390x/cpu_features.c +1 -0
@@ -89,6 +89,7 @@ static const S390FeatDef s390_features[] = {FEAT_INIT ("msa4-base" ,S390_FEAT_TYPE_STFL ,77 ,"Message-security-assist-extension-4 facility (excluding subfunctions)" ),FEAT_INIT ("edat2" ,S390_FEAT_TYPE_STFL ,78 ,"Enhanced-DAT facility 2" ),FEAT_INIT ("dfppc" ,S390_FEAT_TYPE_STFL ,80 ,"Decimal-floating-point packed-conversion facility" ), +FEAT_INIT ("bpb" ,S390_FEAT_TYPE_STFL ,82 ,"Branch prediction blocking" ),FEAT_INIT ("vx" ,S390_FEAT_TYPE_STFL ,129 ,"Vector facility" ),FEAT_INIT ("iep" ,S390_FEAT_TYPE_STFL ,130 ,"Instruction-execution-protection facility" ), FEAT_INIT("sea_esop2", S390_FEAT_TYPE_STFL, 131, "Side-effect-access facility and Enhanced-suppression-on-protection facility 2"),
target/s390x/cpu_features_def.h +1 -0
@@ -80,6 +80,7 @@ typedef enum {S390_FEAT_MSA_EXT_4 ,S390_FEAT_EDAT_2 ,S390_FEAT_DFP_PACKED_CONVERSION , +S390_FEAT_BPB ,S390_FEAT_VECTOR ,S390_FEAT_INSTRUCTION_EXEC_PROT , S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2,
target/s390x/gen-features.c +1 -0
@@ -352,6 +352,7 @@ static uint16_t base_GEN14_GA1[] = {* support these features yet. */ static uint16_t full_GEN7_GA1[] = { +S390_FEAT_BPB ,S390_FEAT_SIE_F2 ,S390_FEAT_SIE_SKEY ,S390_FEAT_SIE_GPERE ,
target/s390x/kvm.c +14 -0
@@ -490,6 +490,11 @@ int kvm_arch_put_registers(CPUState *cs, int level) cs->kvm_run->kvm_dirty_regs |=KVM_SYNC_GSCB ; } +if (can_sync_regs (cs,KVM_SYNC_BPBC )) { + cs->kvm_run->s.regs.bpbc = env->bpbc; + cs->kvm_run->kvm_dirty_regs |=KVM_SYNC_BPBC ; + } +/* Finally the prefix */ if (can_sync_regs (cs,KVM_SYNC_PREFIX )) { cs->kvm_run->s.regs.prefix = env->psa;
@@ -600,6 +605,10 @@ int kvm_arch_get_registers(CPUState *cs)memcpy (env->gscb, cs->kvm_run->s.regs.gscb,32 ); } +if (can_sync_regs (cs,KVM_SYNC_BPBC )) { + env->bpbc = cs->kvm_run->s.regs.bpbc; + } +/* pfault parameters */ if (can_sync_regs (cs,KVM_SYNC_PFAULT )) { env->pfault_token = cs->kvm_run->s.regs.pft;
@@ -2298,6 +2307,11 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp)clear_bit (S390_FEAT_CMM_NT , model->features); } +/* bpb needs kernel support for migration, VSIE and reset */ +if (!kvm_check_extension (kvm_state,KVM_CAP_S390_BPB )) { +clear_bit (S390_FEAT_BPB , model->features); + } +/* We emulate a zPCI bus and AEN, therefore we don't need HW support */ if (pci_available) {set_bit (S390_FEAT_ZPCI , model->features);
target/s390x/machine.c +17 -0
@@ -194,6 +194,22 @@ const VMStateDescription vmstate_gscb = { } }; +static bool bpbc_needed (void *opaque) +{ +return s390_has_feat (S390_FEAT_BPB ); +} + +const VMStateDescription vmstate_bpbc = { + .name ="cpu/bpbc" , + .version_id =1 , + .minimum_version_id =1 , + .needed = bpbc_needed, + .fields = (VMStateField []) { +VMSTATE_BOOL (env.bpbc,S390CPU ), +VMSTATE_END_OF_LIST () + } +}; +const VMStateDescription vmstate_s390_cpu = { .name ="cpu" , .post_load = cpu_post_load,
@@ -228,6 +244,7 @@ const VMStateDescription vmstate_s390_cpu = { &vmstate_riccb, &vmstate_exval, &vmstate_gscb, + &vmstate_bpbc, NULL }, };
Signature · 1 line
2.11.0
PATCH 31/54 s390x/kvm: provide stfle.81
In reply to Michael RothFrom: Christian Borntraeger <[email protected]>
stfle.81 (ppa15) is a transparent facility that can be passed to the guest without the need to implement hypervisor support. As this feature can be provided by firmware we add it to all full models.
Message-Id: <[email protected]>
--- target/s390x/cpu_features.c | 1 + target/s390x/cpu_features_def.h | 1 + target/s390x/gen-features.c | 1 + 3 files changed, 3 insertions(+)
target/s390x/cpu_features.c +1 -0
@@ -89,6 +89,7 @@ static const S390FeatDef s390_features[] = {FEAT_INIT ("msa4-base" ,S390_FEAT_TYPE_STFL ,77 ,"Message-security-assist-extension-4 facility (excluding subfunctions)" ),FEAT_INIT ("edat2" ,S390_FEAT_TYPE_STFL ,78 ,"Enhanced-DAT facility 2" ),FEAT_INIT ("dfppc" ,S390_FEAT_TYPE_STFL ,80 ,"Decimal-floating-point packed-conversion facility" ), +FEAT_INIT ("ppa15" ,S390_FEAT_TYPE_STFL ,81 ,"PPA15 is installed" ),FEAT_INIT ("bpb" ,S390_FEAT_TYPE_STFL ,82 ,"Branch prediction blocking" ),FEAT_INIT ("vx" ,S390_FEAT_TYPE_STFL ,129 ,"Vector facility" ), FEAT_INIT("iep", S390_FEAT_TYPE_STFL, 130, "Instruction-execution-protection facility"),
target/s390x/cpu_features_def.h +1 -0
@@ -80,6 +80,7 @@ typedef enum {S390_FEAT_MSA_EXT_4 ,S390_FEAT_EDAT_2 ,S390_FEAT_DFP_PACKED_CONVERSION , +S390_FEAT_PPA15 ,S390_FEAT_BPB ,S390_FEAT_VECTOR , S390_FEAT_INSTRUCTION_EXEC_PROT,
target/s390x/gen-features.c +1 -0
@@ -352,6 +352,7 @@ static uint16_t base_GEN14_GA1[] = {* support these features yet. */ static uint16_t full_GEN7_GA1[] = { +S390_FEAT_PPA15 ,S390_FEAT_BPB ,S390_FEAT_SIE_F2 ,S390_FEAT_SIE_SKEY ,
Signature · 1 line
2.11.0
PATCH 32/54 osdep: Retry SETLK upon EINTR
In reply to Michael RothFrom: Fam Zheng <[email protected]>
We could hit lock failure if there is a signal that makes fcntl return -1 and errno set to EINTR. In this case we should retry.
--- util/osdep.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
util/osdep.c +3 -1
@@ -244,7 +244,9 @@ static int qemu_lock_fcntl(int fd, int64_t start, int64_t len, int fl_type) .l_type = fl_type, };qemu_probe_lock_ops (); - ret =fcntl (fd, fcntl_op_setlk, &fl); +do { + ret =fcntl (fd, fcntl_op_setlk, &fl); + }while (ret ==-1 && errno ==EINTR );return ret ==-1 ? -errno :0 ; }
Signature · 1 line
2.11.0
PATCH 33/54 usb-storage: Fix share-rw option parsing
In reply to Michael RothFrom: Fam Zheng <[email protected]>
Because usb-storage creates an internal scsi device, we should propagate options. We already do so for bootindex etc, but failed to take care of share-rw. Fix it in an apparent way: add a new parameter to scsi_bus_legacy_add_drive and pass in s->conf.share_rw.
Message-id: [email protected]
Conflicts:
hw/usb/dev-storage.c
* dropped context dep on ceff3e1f01e
--- hw/scsi/scsi-bus.c | 9 ++++++++- hw/usb/dev-storage.c | 3 ++- include/hw/scsi/scsi.h | 1 + 3 files changed, 11 insertions(+), 2 deletions(-)
hw/scsi/scsi-bus.c +8 -1
@@ -224,6 +224,7 @@ static void scsi_qdev_unrealize(DeviceState *qdev, Error **errp)/* handle legacy '-drive if=scsi,...' cmd line args */ SCSIDevice *scsi_bus_legacy_add_drive (SCSIBus *bus,BlockBackend *blk,int unit,bool removable,int bootindex, +bool share_rw,const char *serial,Error **errp) {const char *driver;
@@ -254,6 +255,12 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,object_unparent (OBJECT (dev));return NULL ; } +object_property_set_bool (OBJECT (dev), share_rw,"share-rw" , &err); +if (err !=NULL ) { +error_propagate (errp, err); +object_unparent (OBJECT (dev)); +return NULL ; + }object_property_set_bool (OBJECT (dev), true,"realized" , &err);if (err !=NULL ) {error_propagate (errp, err);
@@ -288,7 +295,7 @@ void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, bool deprecated) } }scsi_bus_legacy_add_drive (bus,blk_by_legacy_dinfo (dinfo), - unit, false,-1 ,NULL , &error_fatal); + unit, false,-1 , false,NULL , &error_fatal); }loc_pop (&loc); }
hw/usb/dev-storage.c +2 -1
@@ -635,7 +635,8 @@ static void usb_msd_realize_storage(USBDevice *dev, Error **errp)scsi_bus_new (&s->bus,sizeof (s->bus),DEVICE (dev), &usb_msd_scsi_info_storage,NULL ); scsi_dev =scsi_bus_legacy_add_drive (&s->bus, blk,0 , !!s->removable, - s->conf.bootindex, dev->serial, + s->conf.bootindex, s->conf.share_rw, + dev->serial, &err);blk_unref (blk);if (!scsi_dev) {
include/hw/scsi/scsi.h +1 -0
@@ -151,6 +151,7 @@ static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d)SCSIDevice *scsi_bus_legacy_add_drive (SCSIBus *bus,BlockBackend *blk,int unit,bool removable,int bootindex, +bool share_rw,const char *serial,Error **errp);void scsi_bus_legacy_handle_cmdline (SCSIBus *bus,bool deprecated);void scsi_legacy_handle_cmdline (void );
Signature · 1 line
2.11.0
PATCH 34/54 spapr_pci: fix MSI/MSIX selection
In reply to Michael RothFrom: Greg Kurz <[email protected]>
In various place we don't correctly check if the device supports MSI or MSI-X. This can cause devices to be advertised with MSI support, even if they only support MSI-X (like virtio-pci-* devices for example):
ethernet@0 {
ibm,req#msi = <0x1>; <--- wrong!
.
ibm,loc-code = "qemu_virtio-net-pci:0000:00:00.0";
.
ibm,req#msi-x = <0x3>;
};Worse, this can also cause the "ibm,change-msi" RTAS call to corrupt the PCI status and cause migration to fail:
qemu-system-ppc64: get_pci_config_device: Bad config data: i=0x6
read: 0 device: 10 cmask: 10 wmask: 0 w1cmask:0
^^
PCI_STATUS_CAP_LIST bit which is assumed to be constantThis patch changes spapr_populate_pci_child_dt() to properly check for MSI support using msi_present(): this ensures that PCIDevice::msi_cap was set by msi_init() and that msi_nr_vectors_allocated() will look at the right place in the config space.
Checking PCIDevice::msix_entries_nr is enough for MSI-X but let's add a call to msix_present() there as well for consistency.
It also changes rtas_ibm_change_msi() to select the appropriate MSI type in Function 1 instead of always selecting plain MSI. This new behaviour is compliant with LoPAPR 1.1, as described in "Table 71. ibm,change-msi Argument Call Buffer":
Function 1: If Number Outputs is equal to 3, request to set to a new
number of MSIs (including set to 0).
If the “ibm,change-msix-capable” property exists and Number Outputs is equal to 4, request is to set to a new number of MSI or MSI-X (platform choice) interrupts (including set to 0).
Since MSI is the the platform default (LoPAPR 6.2.3 MSI Option), let's check for MSI support first.
And finally, it checks the input parameters are valid, as described in LoPAPR 1.1 "R1–7.3.10.5.1–3":
For the MSI option: The platform must return a Status of -3 (Parameter error) from ibm,change-msi, with no change in interrupt assignments if the PCI configuration address does not support MSI and Function 3 was requested (that is, the “ibm,req#msi” property must exist for the PCI configuration address in order to use Function 3), or does not support MSI-X and Function 4 is requested (that is, the “ibm,req#msi-x” property must exist for the PCI configuration address in order to use Function 4), or if neither MSIs nor MSI-Xs are supported and Function 1 is requested.
This ensures that the ret_intr_type variable contains a valid MSI type for this device, and that spapr_msi_setmsg() won't corrupt the PCI status.
--- hw/ppc/spapr_pci.c | 61 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 19 deletions(-)
hw/ppc/spapr_pci.c +42 -19
@@ -280,13 +280,42 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr,int *config_addr_key;Error *err =NULL ; +/* Fins sPAPRPHBState */ + phb =spapr_pci_find_phb (spapr, buid); +if (phb) { + pdev =spapr_pci_find_dev (spapr, buid, config_addr); + } +if (!phb || !pdev) { +rtas_st (rets,0 ,RTAS_OUT_PARAM_ERROR ); +return ; + } +switch (func) { -case RTAS_CHANGE_MSI_FN :case RTAS_CHANGE_FN : - ret_intr_type =RTAS_TYPE_MSI ; +if (msi_present (pdev)) { + ret_intr_type =RTAS_TYPE_MSI ; + }else if (msix_present (pdev)) { + ret_intr_type =RTAS_TYPE_MSIX ; + }else { +rtas_st (rets,0 ,RTAS_OUT_PARAM_ERROR ); +return ; + } +break ; +case RTAS_CHANGE_MSI_FN : +if (msi_present (pdev)) { + ret_intr_type =RTAS_TYPE_MSI ; + }else { +rtas_st (rets,0 ,RTAS_OUT_PARAM_ERROR ); +return ; + }break ;case RTAS_CHANGE_MSIX_FN : - ret_intr_type =RTAS_TYPE_MSIX ; +if (msix_present (pdev)) { + ret_intr_type =RTAS_TYPE_MSIX ; + }else { +rtas_st (rets,0 ,RTAS_OUT_PARAM_ERROR ); +return ; + }break ;default :error_report ("rtas_ibm_change_msi(%u) is not implemented" , func);
@@ -294,16 +323,6 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr,return ; } -/* Fins sPAPRPHBState */ - phb =spapr_pci_find_phb (spapr, buid); -if (phb) { - pdev =spapr_pci_find_dev (spapr, buid, config_addr); - } -if (!phb || !pdev) { -rtas_st (rets,0 ,RTAS_OUT_PARAM_ERROR ); -return ; - } - msi = (spapr_pci_msi *)g_hash_table_lookup (phb->msi, &config_addr);/* Releasing MSIs */
@@ -1286,13 +1305,17 @@ static void spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset,_FDT (fdt_setprop_cell (fdt, offset,"#size-cells" ,RESOURCE_CELLS_SIZE )); - max_msi =msi_nr_vectors_allocated (dev); -if (max_msi) { -_FDT (fdt_setprop_cell (fdt, offset,"ibm,req#msi" , max_msi)); +if (msi_present (dev)) { + max_msi =msi_nr_vectors_allocated (dev); +if (max_msi) { +_FDT (fdt_setprop_cell (fdt, offset,"ibm,req#msi" , max_msi)); + } } - max_msix = dev->msix_entries_nr; -if (max_msix) { -_FDT (fdt_setprop_cell (fdt, offset,"ibm,req#msi-x" , max_msix)); +if (msix_present (dev)) { + max_msix = dev->msix_entries_nr; +if (max_msix) { +_FDT (fdt_setprop_cell (fdt, offset,"ibm,req#msi-x" , max_msix)); + } }populate_resource_props (dev, &rp);
Signature · 1 line
2.11.0
PATCH 35/54 linux-user/signal.c: Rename MC_* defines
In reply to Michael RothFrom: Peter Maydell <[email protected]>
The SPARC code in linux-user/signal.c defines a set of MC_* constants. On some SPARC hosts these are also defined by sys/ucontext.h, resulting in build failures:
linux-user/signal.c:2786:0: error: "MC_NGREG" redefined [-Werror]
#define MC_NGREG 19
In file included from /usr/include/signal.h:302:0,
from include/qemu/osdep.h:86,
from linux-user/signal.c:19:/usr/include/sparc64-linux-gnu/sys/ucontext.h:59:0: note: this is the location of the previous definition
# define MC_NGREG __MC_NGREG
Rename all these constants to SPARC_MC_* to avoid the clash.
Message-id: [email protected]
--- linux-user/signal.c | 118 ++++++++++++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 59 deletions(-)
linux-user/signal.c +59 -59
@@ -2758,29 +2758,29 @@ long do_rt_sigreturn(CPUSPARCState *env) } #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) -#define MC_TSTATE 0 -#define MC_PC 1 -#define MC_NPC 2 -#define MC_Y 3 -#define MC_G1 4 -#define MC_G2 5 -#define MC_G3 6 -#define MC_G4 7 -#define MC_G5 8 -#define MC_G6 9 -#define MC_G7 10 -#define MC_O0 11 -#define MC_O1 12 -#define MC_O2 13 -#define MC_O3 14 -#define MC_O4 15 -#define MC_O5 16 -#define MC_O6 17 -#define MC_O7 18 -#define MC_NGREG 19 +#define SPARC_MC_TSTATE 0 +#define SPARC_MC_PC 1 +#define SPARC_MC_NPC 2 +#define SPARC_MC_Y 3 +#define SPARC_MC_G1 4 +#define SPARC_MC_G2 5 +#define SPARC_MC_G3 6 +#define SPARC_MC_G4 7 +#define SPARC_MC_G5 8 +#define SPARC_MC_G6 9 +#define SPARC_MC_G7 10 +#define SPARC_MC_O0 11 +#define SPARC_MC_O1 12 +#define SPARC_MC_O2 13 +#define SPARC_MC_O3 14 +#define SPARC_MC_O4 15 +#define SPARC_MC_O5 16 +#define SPARC_MC_O6 17 +#define SPARC_MC_O7 18 +#define SPARC_MC_NGREG 19 typedef abi_ulong target_mc_greg_t; -typedef target_mc_greg_t target_mc_gregset_t[MC_NGREG]; +typedef target_mc_greg_t target_mc_gregset_t[SPARC_MC_NGREG]; struct target_mc_fq { abi_ulong *mcfq_addr;
@@ -2840,8 +2840,8 @@ void sparc64_set_context(CPUSPARCState *env) goto do_sigsegv; } grp = &ucp->tuc_mcontext.mc_gregs; -__get_user (pc, &((*grp)[MC_PC ])); -__get_user (npc, &((*grp)[MC_NPC ])); +__get_user (pc, &((*grp)[SPARC_MC_PC ])); +__get_user (npc, &((*grp)[SPARC_MC_NPC ]));if ((pc | npc) &3 ) { goto do_sigsegv; }
@@ -2864,26 +2864,26 @@ void sparc64_set_context(CPUSPARCState *env) } env->pc = pc; env->npc = npc; -__get_user (env->y, &((*grp)[MC_Y ])); -__get_user (tstate, &((*grp)[MC_TSTATE ])); +__get_user (env->y, &((*grp)[SPARC_MC_Y ])); +__get_user (tstate, &((*grp)[SPARC_MC_TSTATE ])); env->asi = (tstate >>24 ) &0xff ;cpu_put_ccr (env, tstate >>32 );cpu_put_cwp64 (env, tstate &0x1f ); -__get_user (env->gregs[1 ], (&(*grp)[MC_G1 ])); -__get_user (env->gregs[2 ], (&(*grp)[MC_G2 ])); -__get_user (env->gregs[3 ], (&(*grp)[MC_G3 ])); -__get_user (env->gregs[4 ], (&(*grp)[MC_G4 ])); -__get_user (env->gregs[5 ], (&(*grp)[MC_G5 ])); -__get_user (env->gregs[6 ], (&(*grp)[MC_G6 ])); -__get_user (env->gregs[7 ], (&(*grp)[MC_G7 ])); -__get_user (env->regwptr[UREG_I0 ], (&(*grp)[MC_O0 ])); -__get_user (env->regwptr[UREG_I1 ], (&(*grp)[MC_O1 ])); -__get_user (env->regwptr[UREG_I2 ], (&(*grp)[MC_O2 ])); -__get_user (env->regwptr[UREG_I3 ], (&(*grp)[MC_O3 ])); -__get_user (env->regwptr[UREG_I4 ], (&(*grp)[MC_O4 ])); -__get_user (env->regwptr[UREG_I5 ], (&(*grp)[MC_O5 ])); -__get_user (env->regwptr[UREG_I6 ], (&(*grp)[MC_O6 ])); -__get_user (env->regwptr[UREG_I7 ], (&(*grp)[MC_O7 ])); +__get_user (env->gregs[1 ], (&(*grp)[SPARC_MC_G1 ])); +__get_user (env->gregs[2 ], (&(*grp)[SPARC_MC_G2 ])); +__get_user (env->gregs[3 ], (&(*grp)[SPARC_MC_G3 ])); +__get_user (env->gregs[4 ], (&(*grp)[SPARC_MC_G4 ])); +__get_user (env->gregs[5 ], (&(*grp)[SPARC_MC_G5 ])); +__get_user (env->gregs[6 ], (&(*grp)[SPARC_MC_G6 ])); +__get_user (env->gregs[7 ], (&(*grp)[SPARC_MC_G7 ])); +__get_user (env->regwptr[UREG_I0 ], (&(*grp)[SPARC_MC_O0 ])); +__get_user (env->regwptr[UREG_I1 ], (&(*grp)[SPARC_MC_O1 ])); +__get_user (env->regwptr[UREG_I2 ], (&(*grp)[SPARC_MC_O2 ])); +__get_user (env->regwptr[UREG_I3 ], (&(*grp)[SPARC_MC_O3 ])); +__get_user (env->regwptr[UREG_I4 ], (&(*grp)[SPARC_MC_O4 ])); +__get_user (env->regwptr[UREG_I5 ], (&(*grp)[SPARC_MC_O5 ])); +__get_user (env->regwptr[UREG_I6 ], (&(*grp)[SPARC_MC_O6 ])); +__get_user (env->regwptr[UREG_I7 ], (&(*grp)[SPARC_MC_O7 ]));__get_user (fp, &(ucp->tuc_mcontext.mc_fp));__get_user (i7, &(ucp->tuc_mcontext.mc_i7));
@@ -2971,25 +2971,25 @@ void sparc64_get_context(CPUSPARCState *env) }/* XXX: tstate must be saved properly */ -// __put_user(env->tstate, &((*grp)[MC_TSTATE])); -__put_user (env->pc, &((*grp)[MC_PC ])); -__put_user (env->npc, &((*grp)[MC_NPC ])); -__put_user (env->y, &((*grp)[MC_Y ])); -__put_user (env->gregs[1 ], &((*grp)[MC_G1 ])); -__put_user (env->gregs[2 ], &((*grp)[MC_G2 ])); -__put_user (env->gregs[3 ], &((*grp)[MC_G3 ])); -__put_user (env->gregs[4 ], &((*grp)[MC_G4 ])); -__put_user (env->gregs[5 ], &((*grp)[MC_G5 ])); -__put_user (env->gregs[6 ], &((*grp)[MC_G6 ])); -__put_user (env->gregs[7 ], &((*grp)[MC_G7 ])); -__put_user (env->regwptr[UREG_I0 ], &((*grp)[MC_O0 ])); -__put_user (env->regwptr[UREG_I1 ], &((*grp)[MC_O1 ])); -__put_user (env->regwptr[UREG_I2 ], &((*grp)[MC_O2 ])); -__put_user (env->regwptr[UREG_I3 ], &((*grp)[MC_O3 ])); -__put_user (env->regwptr[UREG_I4 ], &((*grp)[MC_O4 ])); -__put_user (env->regwptr[UREG_I5 ], &((*grp)[MC_O5 ])); -__put_user (env->regwptr[UREG_I6 ], &((*grp)[MC_O6 ])); -__put_user (env->regwptr[UREG_I7 ], &((*grp)[MC_O7 ])); +// __put_user(env->tstate, &((*grp)[SPARC_MC_TSTATE])); +__put_user (env->pc, &((*grp)[SPARC_MC_PC ])); +__put_user (env->npc, &((*grp)[SPARC_MC_NPC ])); +__put_user (env->y, &((*grp)[SPARC_MC_Y ])); +__put_user (env->gregs[1 ], &((*grp)[SPARC_MC_G1 ])); +__put_user (env->gregs[2 ], &((*grp)[SPARC_MC_G2 ])); +__put_user (env->gregs[3 ], &((*grp)[SPARC_MC_G3 ])); +__put_user (env->gregs[4 ], &((*grp)[SPARC_MC_G4 ])); +__put_user (env->gregs[5 ], &((*grp)[SPARC_MC_G5 ])); +__put_user (env->gregs[6 ], &((*grp)[SPARC_MC_G6 ])); +__put_user (env->gregs[7 ], &((*grp)[SPARC_MC_G7 ])); +__put_user (env->regwptr[UREG_I0 ], &((*grp)[SPARC_MC_O0 ])); +__put_user (env->regwptr[UREG_I1 ], &((*grp)[SPARC_MC_O1 ])); +__put_user (env->regwptr[UREG_I2 ], &((*grp)[SPARC_MC_O2 ])); +__put_user (env->regwptr[UREG_I3 ], &((*grp)[SPARC_MC_O3 ])); +__put_user (env->regwptr[UREG_I4 ], &((*grp)[SPARC_MC_O4 ])); +__put_user (env->regwptr[UREG_I5 ], &((*grp)[SPARC_MC_O5 ])); +__put_user (env->regwptr[UREG_I6 ], &((*grp)[SPARC_MC_O6 ])); +__put_user (env->regwptr[UREG_I7 ], &((*grp)[SPARC_MC_O7 ])); w_addr =TARGET_STACK_BIAS +env->regwptr[UREG_I6 ]; fp = i7 =0 ;
Signature · 1 line
2.11.0
PATCH 36/54 spapr: don't initialize PATB entry if max-cpu-compat < power9
In reply to Michael RothFrom: Laurent Vivier <[email protected]>
if KVM is enabled and KVM capabilities MMU radix is available, the partition table entry (patb_entry) for the radix mode is initialized by default in ppc_spapr_reset().
It's a problem if we want to migrate the guest to a POWER8 host while the kernel is not started to set the value to the one expected for a POWER8 CPU.
The "-machine max-cpu-compat=power8" should allow to migrate a POWER9 KVM host to a POWER8 KVM host, but because patb_entry is set, the destination QEMU tries to enable radix mode on the POWER8 host. This fails and cancels the migration:
Process table config unsupported by the host
error while loading state for instance 0x0 of device 'spapr' load of migration failed: Invalid argument
This patch doesn't set the PATB entry if the user provides a CPU compatibility mode that doesn't support radix mode.
--- hw/ppc/spapr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +4 -2
@@ -1440,7 +1440,10 @@ static void ppc_spapr_reset(void)/* Check for unknown sysbus devices */ foreach_dynamic_sysbus_device (find_unknown_sysbus_device,NULL ); -if (kvm_enabled () &&kvmppc_has_cap_mmu_radix ()) { + first_ppc_cpu =POWERPC_CPU (first_cpu); +if (kvm_enabled () &&kvmppc_has_cap_mmu_radix () && +ppc_check_compat (first_ppc_cpu,CPU_POWERPC_LOGICAL_3_00 ,0 , + spapr->max_compat_pvr)) {/* If using KVM with radix mode available, VCPUs can be started * without a HPT because KVM will start them in radix mode. * Set the GR bit in PATB so that we know there is no HPT. */
@@ -1499,7 +1502,6 @@ static void ppc_spapr_reset(void)g_free (fdt);/* Set up the entry state */ - first_ppc_cpu =POWERPC_CPU (first_cpu); first_ppc_cpu->env.gpr[3 ] = fdt_addr; first_ppc_cpu->env.gpr[5 ] =0 ; first_cpu->halted =0 ;
Signature · 1 line
2.11.0
PATCH 37/54 spapr: Add pseries-2.12 machine type
In reply to Michael RothFrom: David Gibson <[email protected]>
While we're at it fix a couple of small errors in the 2.11 and 2.10 models (they didn't have any real effect, but don't quite match the template).
--- hw/ppc/spapr.c | 26 +++++++++++++++++++++++--- include/hw/compat.h | 2 ++ 2 files changed, 25 insertions(+), 3 deletions(-)
hw/ppc/spapr.c +23 -3
@@ -3716,27 +3716,47 @@ static const TypeInfo spapr_machine_info = { type_init(spapr_machine_register_##suffix)/* +* pseries-2.12 +*/ +static void spapr_machine_2_12_instance_options(MachineState *machine) +{ +} + +static void spapr_machine_2_12_class_options (MachineClass *mc) +{ +/* Defaults for the latest behaviour inherited from the base class */ +} + +DEFINE_SPAPR_MACHINE(2_12, "2.12", true); + +/* * pseries-2.11 */ +#define SPAPR_COMPAT_2_11 \ + HW_COMPAT_2_11 +static void spapr_machine_2_11_instance_options (MachineState *machine) { +spapr_machine_2_12_instance_options (machine); }static void spapr_machine_2_11_class_options (MachineClass *mc) { -/* Defaults for the latest behaviour inherited from the base class */ +spapr_machine_2_12_class_options (mc); +SET_MACHINE_COMPAT (mc,SPAPR_COMPAT_2_11 ); } -DEFINE_SPAPR_MACHINE(2_11, "2.11", true); +DEFINE_SPAPR_MACHINE(2_11, "2.11", false);/* * pseries-2.10 */ #define SPAPR_COMPAT_2_10 \ - HW_COMPAT_2_10 \ + HW_COMPAT_2_10static void spapr_machine_2_10_instance_options (MachineState *machine) { +spapr_machine_2_11_instance_options (machine); }static void spapr_machine_2_10_class_options (MachineClass *mc)
include/hw/compat.h +2 -0
@@ -1,6 +1,8 @@#ifndef HW_COMPAT_H #define HW_COMPAT_H +#define HW_COMPAT_2_11 +#define HW_COMPAT_2_10 \ {\ .driver = "virtio-mouse-device",\
Signature · 1 line
2.11.0
PATCH 38/54 spapr: Capabilities infrastructure
In reply to Michael RothFrom: David Gibson <[email protected]>
Because PAPR is a paravirtual environment access to certain CPU (or other) facilities can be blocked by the hypervisor. PAPR provides ways to advertise in the device tree whether or not those features are available to the guest.
In some places we automatically determine whether to make a feature available based on whether our host can support it, in most cases this is based on limitations in the available KVM implementation.
Although we correctly advertise this to the guest, it means that host factors might make changes to the guest visible environment which is bad:
as well as generaly reducing reproducibility, it means that a migration between different host environments can easily go bad.
We've mostly gotten away with it because the environments considered mature enough to be well supported (basically, KVM on POWER8) have had consistent feature availability. But, it's still not right and some limitations on POWER9 is going to make it more of an issue in future.
This introduces an infrastructure for defining "sPAPR capabilities". These are set by default based on the machine version, masked by the capabilities of the chosen cpu, but can be overriden with machine properties.
The intention is at reset time we verify that the requested capabilities can be supported on the host (considering TCG, KVM and/or host cpu limitations). If not we simply fail, rather than silently modifying the advertised featureset to the guest.
This does mean that certain configurations that "worked" may now fail, but such configurations were already more subtly broken.
Conflicts:
include/hw/ppc/spapr.h
*drop context dep on 60c6823b9bc
--- hw/ppc/Makefile.objs | 2 +- hw/ppc/spapr.c | 7 ++ hw/ppc/spapr_caps.c | 181 +++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 31 +++++++++ 4 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 hw/ppc/spapr_caps.c
hw/ppc/Makefile.objs +1 -1
@@ -1,7 +1,7 @@ # shared objects obj-y += ppc.o ppc_booke.o fdt.o # IBM pSeries (sPAPR) -obj-$(CONFIG_PSERIES) += spapr.o spapr_vio.o spapr_events.o +obj-$(CONFIG_PSERIES) += spapr.o spapr_caps.o spapr_vio.o spapr_events.o obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_rtc.o spapr_drc.o spapr_rng.o obj-$(CONFIG_PSERIES) += spapr_cpu_core.o spapr_ovec.o
hw/ppc/spapr.c +7 -0
@@ -1440,6 +1440,8 @@ static void ppc_spapr_reset(void)/* Check for unknown sysbus devices */ foreach_dynamic_sysbus_device (find_unknown_sysbus_device,NULL ); +spapr_caps_reset (spapr); + first_ppc_cpu =POWERPC_CPU (first_cpu);if (kvm_enabled () &&kvmppc_has_cap_mmu_radix () && ppc_check_compat(first_ppc_cpu, CPU_POWERPC_LOGICAL_3_00, 0,
@@ -2285,6 +2287,8 @@ static void ppc_spapr_init(MachineState *machine)char *filename;Error *resize_hpt_err =NULL ; +spapr_caps_validate (spapr, &error_fatal); + msi_nonbroken = true;QLIST_INIT (&spapr->phbs);
@@ -3665,6 +3669,9 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)* in which LMBs are represented and hot-added */ mc->numa_mem_align_shift =28 ; + + smc->default_caps =spapr_caps (0 ); +spapr_caps_add_properties (smc, &error_abort); }static const TypeInfo spapr_machine_info = {
hw/ppc/spapr_caps.c new file +181 -0
181 lines not on this page · raw message
include/hw/ppc/spapr.h +31 -0
@@ -51,6 +51,15 @@ typedef enum { } sPAPRResizeHPT;/** +* Capabilities +*/ + +typedef struct sPAPRCapabilities sPAPRCapabilities ; +struct sPAPRCapabilities { +uint64_t mask; +}; + +/** * sPAPRMachineClass: */ struct sPAPRMachineClass {
@@ -66,6 +75,7 @@ struct sPAPRMachineClass { hwaddr *mmio32, hwaddr *mmio64, unsigned n_dma, uint32_t *liobns, Error **errp);sPAPRResizeHPT resize_hpt_default; +sPAPRCapabilities default_caps; };/**
@@ -127,6 +137,9 @@ struct sPAPRMachineState {MemoryHotplugState hotplug_memory;const char *icp_type; + +sPAPRCapabilities forced_caps, forbidden_caps; +sPAPRCapabilities effective_caps; };#define H_SUCCESS 0
@@ -707,4 +720,22 @@ void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg);int spapr_vcpu_id (PowerPCCPU *cpu);PowerPCCPU *spapr_find_cpu (int vcpu_id); +/* +* Handling of optional capabilities +*/ +static inline sPAPRCapabilities spapr_caps (uint64_t mask) +{ +sPAPRCapabilities caps = { mask }; +return caps; +} + +static inline bool spapr_has_cap (sPAPRMachineState *spapr,uint64_t cap) +{ +return !!(spapr->effective_caps.mask & cap); +} + +void spapr_caps_reset (sPAPRMachineState *spapr); +void spapr_caps_validate (sPAPRMachineState *spapr,Error **errp); +void spapr_caps_add_properties (sPAPRMachineClass *smc,Error **errp); +#endif /* HW_SPAPR_H */
Signature · 1 line
2.11.0
PATCH 39/54 spapr: Treat Hardware Transactional Memory (HTM) as an optional capability
In reply to Michael RothFrom: David Gibson <[email protected]>
This adds an spapr capability bit for Hardware Transactional Memory. It is enabled by default for pseries-2.11 and earlier machine types. with POWER8 or later CPUs (as it must be, since earlier qemu versions would implicitly allow it). However it is disabled by default for the latest pseries-2.12 machine type.
This means that with the latest machine type, HTM will not be available, regardless of CPU, unless it is explicitly enabled on the command line. That change is made on the basis that:
* This way running with -M pseries,accel=tcg will start with whatever cpu and will provide the same guest visible model as with accel=kvm.
- More specifically, this means existing make check tests don't have to be modified to use cap-htm=off in order to run with TCG
* We hope to add a new "HTM without suspend" feature in the not too distant future which could work on both POWER8 and POWER9 cpus, and could be enabled by default.
* Best guesses suggest that future POWER cpus may well only support the HTM-without-suspend model, not the (frankly, horribly overcomplicated) POWER8 style HTM with suspend.
* Anecdotal evidence suggests problems with HTM being enabled when it wasn't wanted are more common than being missing when it was.
--- hw/ppc/spapr.c | 15 ++++++++++----- hw/ppc/spapr_caps.c | 29 ++++++++++++++++++++++++++++- include/hw/ppc/spapr.h | 3 +++ 3 files changed, 41 insertions(+), 6 deletions(-)
hw/ppc/spapr.c +10 -5
@@ -253,7 +253,9 @@ static int spapr_fixup_cpu_numa_dt(void *fdt, int offset, PowerPCCPU *cpu) }/* Populate the "ibm,pa-features" property */ -static void spapr_populate_pa_features (PowerPCCPU *cpu,void *fdt,int offset, +static void spapr_populate_pa_features (sPAPRMachineState *spapr, +PowerPCCPU *cpu, +void *fdt,int offset,bool legacy_guest) {CPUPPCState *env = &cpu->env;
@@ -318,7 +320,7 @@ static void spapr_populate_pa_features(PowerPCCPU *cpu, void *fdt, int offset,*/ pa_features[3 ] |=0x20 ; } -if (kvmppc_has_cap_htm () && pa_size >24 ) { +if (spapr_has_cap (spapr,SPAPR_CAP_HTM ) && pa_size >24 ) { pa_features[24 ] |=0x80 ;/* Transactional memory support */ }if (legacy_guest && pa_size >40 ) {
@@ -384,8 +386,8 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr)return ret; } -spapr_populate_pa_features (cpu, fdt, offset, - spapr->cas_legacy_guest_workaround); +spapr_populate_pa_features (spapr, cpu, fdt, offset, + spapr->cas_legacy_guest_workaround); }return ret; }
@@ -579,7 +581,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset, page_sizes_prop, page_sizes_prop_size))); } -spapr_populate_pa_features (cpu, fdt, offset, false); +spapr_populate_pa_features (spapr, cpu, fdt, offset, false);_FDT ((fdt_setprop_cell (fdt, offset,"ibm,chip-id" , cs->cpu_index / vcpus_per_socket)));
@@ -3749,7 +3751,10 @@ static void spapr_machine_2_11_instance_options(MachineState *machine)static void spapr_machine_2_11_class_options (MachineClass *mc) { +sPAPRMachineClass *smc =SPAPR_MACHINE_CLASS (mc); +spapr_machine_2_12_class_options (mc); + smc->default_caps =spapr_caps (SPAPR_CAP_HTM );SET_MACHINE_COMPAT (mc,SPAPR_COMPAT_2_11 ); }
hw/ppc/spapr_caps.c +28 -1
@@ -24,6 +24,10 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qapi/visitor.h" +#include "sysemu/hw_accel.h" +#include "target/ppc/cpu.h" +#include "cpu-models.h" +#include "kvm_ppc.h" #include "hw/ppc/spapr.h"
@@ -40,18 +44,41 @@ typedef struct sPAPRCapabilityInfo {void (*disallow)(sPAPRMachineState *spapr,Error **errp); } sPAPRCapabilityInfo; +static void cap_htm_allow (sPAPRMachineState *spapr,Error **errp) +{ +if (tcg_enabled ()) { +error_setg (errp, +"No Transactional Memory support in TCG, try cap-htm=off" ); + }else if (kvm_enabled () && !kvmppc_has_cap_htm ()) { +error_setg (errp, +"KVM implementation does not support Transactional Memory, try cap-htm=off" + ); + } +} +static sPAPRCapabilityInfo capability_table[] = { + { + .name ="htm" , + .description ="Allow Hardware Transactional Memory (HTM)" , + .flag =SPAPR_CAP_HTM , + .allow = cap_htm_allow, +/* TODO: add cap_htm_disallow */ + }, };static sPAPRCapabilities default_caps_with_cpu (sPAPRMachineState *spapr,CPUState *cs) {sPAPRMachineClass *smc =SPAPR_MACHINE_GET_CLASS (spapr); +PowerPCCPU *cpu =POWERPC_CPU (cs);sPAPRCapabilities caps; caps = smc->default_caps; -/* TODO: clamp according to cpu model */ +if (!ppc_check_compat (cpu,CPU_POWERPC_LOGICAL_2_07 , +0 , spapr->max_compat_pvr)) { + caps.mask &= ~SPAPR_CAP_HTM ; + }return caps; }
include/hw/ppc/spapr.h +3 -0
@@ -54,6 +54,9 @@ typedef enum {* Capabilities */ +/* Hardware Transactional Memory */ +#define SPAPR_CAP_HTM 0x0000000000000001ULL +typedef struct sPAPRCapabilities sPAPRCapabilities ;struct sPAPRCapabilities {uint64_t mask;
Signature · 1 line
2.11.0
PATCH 40/54 spapr: Validate capabilities on migration
In reply to Michael RothFrom: David Gibson <[email protected]>
Now that the "pseries" machine type implements optional capabilities (well, one so far) there's the possibility of having different capabilities available at either end of a migration. Although arguably a user error, it would be nice to catch this situation and fail as gracefully as we can.
This adds code to migrate the capabilities flags. These aren't pulled directly into the destination's configuration since what the user has specified on the destination command line should take precedence. However, they are checked against the destination capabilities.
If the source was using a capability which is absent on the destination, we fail the migration, since that could easily cause a guest crash or other bad behaviour. If the source lacked a capability which is present on the destination we warn, but allow the migration to proceed.
--- hw/ppc/spapr.c | 6 ++++ hw/ppc/spapr_caps.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++-- include/hw/ppc/spapr.h | 6 ++++ 3 files changed, 105 insertions(+), 3 deletions(-)
hw/ppc/spapr.c +6 -0
@@ -1563,6 +1563,11 @@ static int spapr_post_load(void *opaque, int version_id)sPAPRMachineState *spapr = (sPAPRMachineState *)opaque;int err =0 ; + err =spapr_caps_post_migration (spapr); +if (err) { +return err; + } +if (!object_dynamic_cast (OBJECT (spapr->ics),TYPE_ICS_KVM )) {CPUState *cs;CPU_FOREACH (cs) {
@@ -1729,6 +1734,7 @@ static const VMStateDescription vmstate_spapr = { &vmstate_spapr_ov5_cas, &vmstate_spapr_patb_entry, &vmstate_spapr_pending_events, + &vmstate_spapr_caps, NULL } };
hw/ppc/spapr_caps.c +93 -3
120 lines not on this page · raw message
include/hw/ppc/spapr.h +6 -0
@@ -54,6 +54,8 @@ typedef enum {* Capabilities */ +/* These bits go in the migration stream, so they can't be reassigned */ +/* Hardware Transactional Memory */ #define SPAPR_CAP_HTM 0x0000000000000001ULL
@@ -142,6 +144,7 @@ struct sPAPRMachineState {const char *icp_type;sPAPRCapabilities forced_caps, forbidden_caps; +sPAPRCapabilities mig_forced_caps, mig_forbidden_caps;sPAPRCapabilities effective_caps; };
@@ -726,6 +729,8 @@ PowerPCCPU *spapr_find_cpu(int vcpu_id);/* * Handling of optional capabilities */ +extern const VMStateDescription vmstate_spapr_caps; +static inline sPAPRCapabilities spapr_caps (uint64_t mask) {sPAPRCapabilities caps = { mask };
@@ -740,5 +745,6 @@ static inline bool spapr_has_cap(sPAPRMachineState *spapr, uint64_t cap)void spapr_caps_reset (sPAPRMachineState *spapr);void spapr_caps_validate (sPAPRMachineState *spapr,Error **errp);void spapr_caps_add_properties (sPAPRMachineClass *smc,Error **errp); +int spapr_caps_post_migration (sPAPRMachineState *spapr);#endif /* HW_SPAPR_H */
Signature · 1 line
2.11.0
PATCH 41/54 target/ppc: Clean up probing of VMX, VSX and DFP availability on KVM
In reply to Michael RothFrom: David Gibson <[email protected]>
When constructing the "host" cpu class we modify whether the VMX and VSX vector extensions and DFP (Decimal Floating Point) are available based on whether KVM can support those instructions. This can depend on policy in the host kernel as well as on the actual host cpu capabilities.
However, the way we probe for this is not very nice: we explicitly check the host's device tree. That works in practice, but it's not really correct, since the device tree is a property of the host kernel's platform which we don't really know about. We get away with it because the only modern POWER platforms happen to encode VMX, VSX and DFP availability in the device tree in the same way.
Arguably we should have an explicit KVM capability for this, but we haven't needed one so far. Barring specific KVM policies which don't yet exist, each of these instruction classes will be available in the guest if and only if they're available in the qemu userspace process. We can determine that from the ELF AUX vector we're supplied with.
Once reworked like this, there are no more callers for kvmppc_get_vmx() and kvmppc_get_dfp() so remove them.
--- target/ppc/kvm.c | 27 ++++++--------------------- target/ppc/kvm_ppc.h | 2 -- 2 files changed, 6 insertions(+), 23 deletions(-)
target/ppc/kvm.c +6 -21
@@ -2014,16 +2014,6 @@ uint64_t kvmppc_get_clockfreq(void)return kvmppc_read_int_cpu_dt ("clock-frequency" ); } -uint32_t kvmppc_get_vmx (void ) -{ -return kvmppc_read_int_cpu_dt ("ibm,vmx" ); -} - -uint32_t kvmppc_get_dfp (void ) -{ -return kvmppc_read_int_cpu_dt ("ibm,dfp" ); -} -static int kvmppc_get_pvinfo (CPUPPCState *env,struct kvm_ppc_pvinfo *pvinfo) {PowerPCCPU *cpu =ppc_env_get_cpu (env);
@@ -2407,23 +2397,18 @@ static void alter_insns(uint64_t *word, uint64_t flags, bool on)static void kvmppc_host_cpu_class_init (ObjectClass *oc,void *data) {PowerPCCPUClass *pcc =POWERPC_CPU_CLASS (oc); -uint32_t vmx =kvmppc_get_vmx (); -uint32_t dfp =kvmppc_get_dfp ();uint32_t dcache_size =kvmppc_read_int_cpu_dt ("d-cache-size" );uint32_t icache_size =kvmppc_read_int_cpu_dt ("i-cache-size" );/* Now fix up the class with information we can query from the host */ pcc->pvr =mfpvr (); -if (vmx !=-1 ) { -/* Only override when we know what the host supports */ -alter_insns (&pcc->insns_flags,PPC_ALTIVEC , vmx >0 ); -alter_insns (&pcc->insns_flags2,PPC2_VSX , vmx >1 ); - } -if (dfp !=-1 ) { -/* Only override when we know what the host supports */ -alter_insns (&pcc->insns_flags2,PPC2_DFP , dfp); - } +alter_insns (&pcc->insns_flags,PPC_ALTIVEC , +qemu_getauxval (AT_HWCAP ) &PPC_FEATURE_HAS_ALTIVEC ); +alter_insns (&pcc->insns_flags2,PPC2_VSX , +qemu_getauxval (AT_HWCAP ) &PPC_FEATURE_HAS_VSX ); +alter_insns (&pcc->insns_flags2,PPC2_DFP , +qemu_getauxval (AT_HWCAP ) &PPC_FEATURE_HAS_DFP );if (dcache_size !=-1 ) { pcc->l1_dcache_size = dcache_size;
target/ppc/kvm_ppc.h +0 -2
@@ -15,8 +15,6 @@uint32_t kvmppc_get_tbfreq (void );uint64_t kvmppc_get_clockfreq (void ); -uint32_t kvmppc_get_vmx (void ); -uint32_t kvmppc_get_dfp (void );bool kvmppc_get_host_model (char **buf);bool kvmppc_get_host_serial (char **buf);int kvmppc_get_hasidle (CPUPPCState *env);
Signature · 1 line
2.11.0
PATCH 42/54 spapr: Handle VMX/VSX presence as an spapr capability flag
In reply to Michael RothFrom: David Gibson <[email protected]>
We currently have some conditionals in the spapr device tree code to decide whether or not to advertise the availability of the VMX (aka Altivec) and VSX vector extensions to the guest, based on whether the guest cpu has those features.
This can lead to confusion and subtle failures on migration, since it makes a guest visible change based only on host capabilities. We now have a better mechanism for this, in spapr capabilities flags, which explicitly depend on user options rather than host capabilities.
Rework the advertisement of VSX and VMX based on a new VSX capability. We no longer bother with a conditional for VMX support, because every CPU that's ever been supported by the pseries machine type supports VMX.
NOTE: Some userspace distributions (e.g. RHEL7.4) already rely on availability of VSX in libc, so using cap-vsx=off may lead to a fatal SIGILL in init.
--- hw/ppc/spapr.c | 20 +++++++++++--------- hw/ppc/spapr_caps.c | 25 +++++++++++++++++++++++++ include/hw/ppc/spapr.h | 3 +++ 3 files changed, 39 insertions(+), 9 deletions(-)
hw/ppc/spapr.c +11 -9
@@ -557,14 +557,16 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset, segs, sizeof(segs)))); } -/* Advertise VMX/VSX (vector extensions) if available -* 0 / no property == no vector extensions +/* Advertise VSX (vector extensions) if available * 1 == VMX / Altivec available -* 2 == VSX available */ -if (env->insns_flags &PPC_ALTIVEC ) { -uint32_t vmx = (env->insns_flags2 &PPC2_VSX ) ?2 :1 ; - -_FDT ((fdt_setprop_cell (fdt, offset,"ibm,vmx" , vmx))); +* 2 == VSX available +* +* Only CPUs for which we create core types in spapr_cpu_core.c +* are possible, and all of those have VMX */ +if (spapr_has_cap (spapr,SPAPR_CAP_VSX )) { +_FDT ((fdt_setprop_cell (fdt, offset,"ibm,vmx" ,2 ))); + }else { +_FDT ((fdt_setprop_cell (fdt, offset,"ibm,vmx" ,1 ))); }/* Advertise DFP (Decimal Floating Point) if available
@@ -3678,7 +3680,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)*/ mc->numa_mem_align_shift =28 ; - smc->default_caps =spapr_caps (0 ); + smc->default_caps =spapr_caps (SPAPR_CAP_VSX );spapr_caps_add_properties (smc, &error_abort); }
@@ -3760,7 +3762,7 @@ static void spapr_machine_2_11_class_options(MachineClass *mc)sPAPRMachineClass *smc =SPAPR_MACHINE_CLASS (mc);spapr_machine_2_12_class_options (mc); - smc->default_caps =spapr_caps (SPAPR_CAP_HTM ); + smc->default_caps =spapr_caps (SPAPR_CAP_HTM |SPAPR_CAP_VSX );SET_MACHINE_COMPAT (mc,SPAPR_COMPAT_2_11 ); }
hw/ppc/spapr_caps.c +25 -0
@@ -57,6 +57,19 @@ static void cap_htm_allow(sPAPRMachineState *spapr, Error **errp) } } +static void cap_vsx_allow (sPAPRMachineState *spapr,Error **errp) +{ +PowerPCCPU *cpu =POWERPC_CPU (first_cpu); +CPUPPCState *env = &cpu->env; + +/* Allowable CPUs in spapr_cpu_core.c should already have gotten +* rid of anything that doesn't do VMX */ +g_assert (env->insns_flags &PPC_ALTIVEC ); +if (!(env->insns_flags2 &PPC2_VSX )) { +error_setg (errp,"VSX support not available, try cap-vsx=off" ); + } +} +static sPAPRCapabilityInfo capability_table[] = { { .name ="htm" ,
@@ -65,6 +78,13 @@ static sPAPRCapabilityInfo capability_table[] = { .allow = cap_htm_allow, /* TODO: add cap_htm_disallow */ }, + { + .name = "vsx", + .description = "Allow Vector Scalar Extensions (VSX)", + .flag = SPAPR_CAP_VSX, + .allow = cap_vsx_allow, + /* TODO: add cap_vsx_disallow */ + }, }; static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr,
@@ -81,6 +101,11 @@ static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr, caps.mask &= ~SPAPR_CAP_HTM ; } +if (!ppc_check_compat (cpu,CPU_POWERPC_LOGICAL_2_06 , +0 , spapr->max_compat_pvr)) { + caps.mask &= ~SPAPR_CAP_VSX ; + } +return caps; }
include/hw/ppc/spapr.h +3 -0
@@ -59,6 +59,9 @@ typedef enum {/* Hardware Transactional Memory */ #define SPAPR_CAP_HTM 0x0000000000000001ULL +/* Vector Scalar Extensions */ +#define SPAPR_CAP_VSX 0x0000000000000002ULL +typedef struct sPAPRCapabilities sPAPRCapabilities ;struct sPAPRCapabilities {uint64_t mask;
Signature · 1 line
2.11.0
PATCH 43/54 spapr: Handle Decimal Floating Point (DFP) as an optional capability
In reply to Michael RothFrom: David Gibson <[email protected]>
Decimal Floating Point has been available on POWER7 and later (server) cpus. However, it can be disabled on the hypervisor, meaning that it's not available to guests.
We currently handle this by conditionally advertising DFP support in the device tree depending on whether the guest CPU model supports it - which can also depend on what's allowed in the host for -cpu host. That can lead to confusion on migration, since host properties are silently affecting guest visible properties.
This patch handles it by treating it as an optional capability for the pseries machine type.
--- hw/ppc/spapr.c | 7 ++++--- hw/ppc/spapr_caps.c | 18 ++++++++++++++++++ include/hw/ppc/spapr.h | 3 +++ 3 files changed, 25 insertions(+), 3 deletions(-)
hw/ppc/spapr.c +4 -3
@@ -572,7 +572,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset,/* Advertise DFP (Decimal Floating Point) if available * 0 / no property == no DFP * 1 == DFP available */ -if (env->insns_flags2 &PPC2_DFP ) { +if (spapr_has_cap (spapr,SPAPR_CAP_DFP )) {_FDT ((fdt_setprop_cell (fdt, offset,"ibm,dfp" ,1 ))); }
@@ -3680,7 +3680,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)*/ mc->numa_mem_align_shift =28 ; - smc->default_caps =spapr_caps (SPAPR_CAP_VSX ); + smc->default_caps =spapr_caps (SPAPR_CAP_VSX |SPAPR_CAP_DFP );spapr_caps_add_properties (smc, &error_abort); }
@@ -3762,7 +3762,8 @@ static void spapr_machine_2_11_class_options(MachineClass *mc)sPAPRMachineClass *smc =SPAPR_MACHINE_CLASS (mc);spapr_machine_2_12_class_options (mc); - smc->default_caps =spapr_caps (SPAPR_CAP_HTM |SPAPR_CAP_VSX ); + smc->default_caps =spapr_caps (SPAPR_CAP_HTM |SPAPR_CAP_VSX + |SPAPR_CAP_DFP );SET_MACHINE_COMPAT (mc,SPAPR_COMPAT_2_11 ); }
hw/ppc/spapr_caps.c +18 -0
@@ -70,6 +70,16 @@ static void cap_vsx_allow(sPAPRMachineState *spapr, Error **errp) } } +static void cap_dfp_allow (sPAPRMachineState *spapr,Error **errp) +{ +PowerPCCPU *cpu =POWERPC_CPU (first_cpu); +CPUPPCState *env = &cpu->env; + +if (!(env->insns_flags2 &PPC2_DFP )) { +error_setg (errp,"DFP support not available, try cap-dfp=off" ); + } +} +static sPAPRCapabilityInfo capability_table[] = { { .name ="htm" ,
@@ -85,6 +95,13 @@ static sPAPRCapabilityInfo capability_table[] = { .allow = cap_vsx_allow, /* TODO: add cap_vsx_disallow */ }, + { + .name = "dfp", + .description = "Allow Decimal Floating Point (DFP)", + .flag = SPAPR_CAP_DFP, + .allow = cap_dfp_allow, + /* TODO: add cap_dfp_disallow */ + }, }; static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr,
@@ -104,6 +121,7 @@ static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr,if (!ppc_check_compat (cpu,CPU_POWERPC_LOGICAL_2_06 ,0 , spapr->max_compat_pvr)) { caps.mask &= ~SPAPR_CAP_VSX ; + caps.mask &= ~SPAPR_CAP_DFP ; }return caps;
include/hw/ppc/spapr.h +3 -0
@@ -62,6 +62,9 @@ typedef enum {/* Vector Scalar Extensions */ #define SPAPR_CAP_VSX 0x0000000000000002ULL +/* Decimal Floating Point */ +#define SPAPR_CAP_DFP 0x0000000000000004ULL +typedef struct sPAPRCapabilities sPAPRCapabilities ;struct sPAPRCapabilities {uint64_t mask;
Signature · 1 line
2.11.0
PATCH 44/54 hw/ppc/spapr_caps: Rework spapr_caps to use uint8 internal representation
In reply to Michael RothFrom: Suraj Jitindar Singh <[email protected]>
Currently spapr_caps are tied to boolean values (on or off). This patch reworks the caps so that they can have any uint8 value. This allows more capabilities with various values to be represented in the same way internally. Capabilities are numbered in ascending order. The internal representation of capability values is an array of uint8s in the sPAPRMachineState, indexed by capability number.
Capabilities can have their own name, description, options, getter and setter functions, type and allow functions. They also each have their own section in the migration stream. Capabilities are only migrated if they were explictly set on the command line, with the assumption that otherwise the default will match.
On migration we ensure that the capability value on the destination is greater than or equal to the capability value from the source. So long at this remains the case then the migration is considered compatible and allowed to continue.
This patch implements generic getter and setter functions for boolean capabilities. It also converts the existings cap-htm, cap-vsx and cap-dfp capabilities to this new format.
Conflicts:
include/hw/ppc/spapr.h
*drop context dep on 60c6823b9bc
--- hw/ppc/spapr.c | 45 +++++-- hw/ppc/spapr_caps.c | 322 +++++++++++++++++++++++++------------------------ include/hw/ppc/spapr.h | 44 +++---- 3 files changed, 224 insertions(+), 187 deletions(-)
hw/ppc/spapr.c +36 -9
@@ -320,7 +320,7 @@ static void spapr_populate_pa_features(sPAPRMachineState *spapr,*/ pa_features[3 ] |=0x20 ; } -if (spapr_has_cap (spapr,SPAPR_CAP_HTM ) && pa_size >24 ) { +if ((spapr_get_cap (spapr,SPAPR_CAP_HTM ) !=0 ) && pa_size >24 ) { pa_features[24 ] |=0x80 ;/* Transactional memory support */ }if (legacy_guest && pa_size >40 ) {
@@ -563,7 +563,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset,* * Only CPUs for which we create core types in spapr_cpu_core.c * are possible, and all of those have VMX */ -if (spapr_has_cap (spapr,SPAPR_CAP_VSX )) { +if (spapr_get_cap (spapr,SPAPR_CAP_VSX ) !=0 ) {_FDT ((fdt_setprop_cell (fdt, offset,"ibm,vmx" ,2 ))); }else {_FDT ((fdt_setprop_cell (fdt, offset,"ibm,vmx" ,1 )));
@@ -572,7 +572,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset,/* Advertise DFP (Decimal Floating Point) if available * 0 / no property == no DFP * 1 == DFP available */ -if (spapr_has_cap (spapr,SPAPR_CAP_DFP )) { +if (spapr_get_cap (spapr,SPAPR_CAP_DFP ) !=0 ) {_FDT ((fdt_setprop_cell (fdt, offset,"ibm,dfp" ,1 ))); }
@@ -1560,6 +1560,18 @@ static bool spapr_vga_init(PCIBus *pci_bus, Error **errp) } } +static int spapr_pre_load (void *opaque) +{ +int rc; + + rc =spapr_caps_pre_load (opaque); +if (rc) { +return rc; + } + +return 0 ; +} +static int spapr_post_load (void *opaque,int version_id) {sPAPRMachineState *spapr = (sPAPRMachineState *)opaque;
@@ -1601,6 +1613,18 @@ static int spapr_post_load(void *opaque, int version_id)return err; } +static int spapr_pre_save (void *opaque) +{ +int rc; + + rc =spapr_caps_pre_save (opaque); +if (rc) { +return rc; + } + +return 0 ; +} +static bool version_before_3 (void *opaque,int version_id) {return version_id <3 ;
@@ -1721,7 +1745,9 @@ static const VMStateDescription vmstate_spapr = { .name = "spapr", .version_id = 3, .minimum_version_id = 1, + .pre_load = spapr_pre_load, .post_load = spapr_post_load, + .pre_save = spapr_pre_save, .fields = (VMStateField []) {/* used to be @next_irq */ VMSTATE_UNUSED_BUFFER (version_before_3,0 ,4 ),
@@ -1736,7 +1762,9 @@ static const VMStateDescription vmstate_spapr = { &vmstate_spapr_ov5_cas, &vmstate_spapr_patb_entry, &vmstate_spapr_pending_events, - &vmstate_spapr_caps, + &vmstate_spapr_cap_htm, + &vmstate_spapr_cap_vsx, + &vmstate_spapr_cap_dfp, NULL } };
@@ -2297,8 +2325,6 @@ static void ppc_spapr_init(MachineState *machine)char *filename;Error *resize_hpt_err =NULL ; -spapr_caps_validate (spapr, &error_fatal); - msi_nonbroken = true;QLIST_INIT (&spapr->phbs);
@@ -3680,7 +3706,9 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)*/ mc->numa_mem_align_shift =28 ; - smc->default_caps =spapr_caps (SPAPR_CAP_VSX |SPAPR_CAP_DFP ); + smc->default_caps.caps[SPAPR_CAP_HTM ] =SPAPR_CAP_OFF ; + smc->default_caps.caps[SPAPR_CAP_VSX ] =SPAPR_CAP_ON ; + smc->default_caps.caps[SPAPR_CAP_DFP ] =SPAPR_CAP_ON ;spapr_caps_add_properties (smc, &error_abort); }
@@ -3762,8 +3790,7 @@ static void spapr_machine_2_11_class_options(MachineClass *mc)sPAPRMachineClass *smc =SPAPR_MACHINE_CLASS (mc);spapr_machine_2_12_class_options (mc); - smc->default_caps =spapr_caps (SPAPR_CAP_HTM |SPAPR_CAP_VSX - |SPAPR_CAP_DFP ); + smc->default_caps.caps[SPAPR_CAP_HTM ] =SPAPR_CAP_ON ;SET_MACHINE_COMPAT (mc,SPAPR_COMPAT_2_11 ); }
hw/ppc/spapr_caps.c +165 -157
447 lines not on this page · raw message
include/hw/ppc/spapr.h +23 -21
76 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH 45/54 ppc: Change Power9 compat table to support at most 8 threads/core
In reply to Michael RothFrom: Jose Ricardo Ziviani <[email protected]>
Increases the max smt mode to 8 for Power9. That's because KVM supports smt emulation in this platform so QEMU should allow users to use it as well.
Today if we try to pass -smp ...,threads=8, QEMU will silently truncate it to smt4 mode and may cause a crash if we try to perform a cpu hotplug.
--- target/ppc/compat.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
target/ppc/compat.c +8 -1
@@ -73,7 +73,14 @@ static const CompatInfo compat_table[] = { .pvr = CPU_POWERPC_LOGICAL_3_00, .pcr = PCR_COMPAT_3_00, .pcr_level = PCR_COMPAT_3_00, - .max_threads = 4, +/* +* POWER9 hardware only supports 4 threads / core, but this +* limit is for guests. We need to support 8 vthreads/vcore +* on POWER9 for POWER8 compatibility guests, and it's very +* confusing if half of the threads disappear from the guest +* if it announces it's POWER9 aware at CAS time. +*/ + .max_threads = 8, }, };
Signature · 1 line
2.11.0
PATCH 46/54 spapr: fix device tree properties when using compatibility mode
In reply to Michael RothFrom: Greg Kurz <[email protected]>
Commit 51f84465dd98 changed the compatility mode setting logic:
- machine reset only sets compatibility mode for the boot CPU
- compatibility mode is set for other CPUs when they are put online by the guest with the "start-cpu" RTAS call
This causes a regression for machines started with max-compat-cpu:
the device tree nodes related to secondary CPU cores contain wrong "cpu-version" and "ibm,pa-features" values, as shown below.
Guest started on a POWER8 host with:
-smp cores=2 -machine pseries,max-cpu-compat=compat7
ibm,pa-features = [18 00 f6 3f c7 c0 80 f0 80 00
00 00 00 00 00 00 00 00 80 00 80 00 80 00 00 00];
cpu-version = <0x4d0200>;
^^^
second CPU core
ibm,pa-features = <0x600f63f 0xc70080c0>;
cpu-version = <0xf000003>;
^^^
boot CPU coreThe second core is advertised in raw POWER8 mode. This happens because CAS assumes all CPUs to have the same compatibility mode. Since the boot CPU already has the requested compatibility mode, the CAS code does not set it for the secondary one, and exposes the bogus device tree properties in in the CAS response to the guest.
A similar situation is observed when hot-plugging a CPU core. The related device tree properties are generated and exposed to guest with the "ibm,configure-connector" RTAS before "start-cpu" is called. The CPU core is advertised to the guest in raw mode as well.
It both cases, it boils down to the fact that "start-cpu" happens too late. This can be fixed globally by propagating the compatibility mode of the boot CPU to the other CPUs during reset. For this to work, the compatibility mode of the boot CPU must be set before the machine code actually resets all CPUs.
It is not needed to set the compatibility mode in "start-cpu" anymore, so the code is dropped.
Conflicts:
hw/ppc/spapr_cpu_core.c
hw/ppc/spapr_rtas.c
* drop context dep on d6322252b32
--- hw/ppc/spapr.c | 18 +++++++++--------- hw/ppc/spapr_cpu_core.c | 7 +++++++ 2 files changed, 16 insertions(+), 9 deletions(-)
hw/ppc/spapr.c +9 -9
@@ -1458,6 +1458,15 @@ static void ppc_spapr_reset(void)spapr_setup_hpt_and_vrma (spapr); } +/* if this reset wasn't generated by CAS, we should reset our +* negotiated options and start from scratch */ +if (!spapr->cas_reboot) { +spapr_ovec_cleanup (spapr->ov5_cas); + spapr->ov5_cas =spapr_ovec_new (); + +ppc_set_compat (first_ppc_cpu, spapr->max_compat_pvr, &error_fatal); + } +qemu_devices_reset ();/* DRC reset may cause a device to be unplugged. This will cause troubles
@@ -1478,15 +1487,6 @@ static void ppc_spapr_reset(void) rtas_addr = rtas_limit -RTAS_MAX_SIZE ; fdt_addr = rtas_addr -FDT_MAX_SIZE ; -/* if this reset wasn't generated by CAS, we should reset our -* negotiated options and start from scratch */ -if (!spapr->cas_reboot) { -spapr_ovec_cleanup (spapr->ov5_cas); - spapr->ov5_cas =spapr_ovec_new (); - -ppc_set_compat_all (spapr->max_compat_pvr, &error_fatal); - } - fdt =spapr_build_fdt (spapr, rtas_addr, spapr->rtas_size);spapr_load_rtas (spapr, fdt, rtas_addr);
hw/ppc/spapr_cpu_core.c +7 -0
@@ -35,6 +35,13 @@ static void spapr_cpu_reset(void *opaque) cs->halted =1 ; env->spr[SPR_HIOR ] =0 ; + +/* Set compatibility mode to match the boot CPU, which was either set +* by the machine reset code or by CAS. This should never fail. +*/ +if (cs != first_cpu) { +ppc_set_compat (cpu,POWERPC_CPU (first_cpu)->compat_pvr, &error_abort); + } }static void spapr_cpu_destroy (PowerPCCPU *cpu)
Signature · 1 line
2.11.0
PATCH 47/54 target/ppc: introduce the PPC_BIT() macro
In reply to Michael RothFrom: Cédric Le Goater <[email protected]>
and use them in a couple of obvious places. Other macros will be used in the model of the XIVE interrupt controller.
--- target/ppc/cpu.h | 105 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 56 insertions(+), 49 deletions(-)
target/ppc/cpu.h +56 -49
@@ -87,6 +87,13 @@#define PPC_ELF_MACHINE EM_PPC#endif +#define PPC_BIT (bit) (0x8000000000000000UL >> (bit)) +#define PPC_BIT32 (bit) (0x80000000UL >> (bit)) +#define PPC_BIT8 (bit) (0x80UL >> (bit)) +#define PPC_BITMASK (bs, be) ((PPC_BIT(bs) - PPC_BIT(be)) | PPC_BIT(bs)) +#define PPC_BITMASK32 (bs, be) ((PPC_BIT32(bs) - PPC_BIT32(be)) | \ + PPC_BIT32(bs)) +/*****************************************************************************/ /* Exception vectors definitions */ enum {
@@ -371,10 +378,10 @@ struct ppc_slb_t {#define MSR_LE 0/* Little-endian mode 1 hflags */ /* LPCR bits */ -#define LPCR_VPM0 (1ull << (63 - 0)) -#define LPCR_VPM1 (1ull << (63 - 1)) -#define LPCR_ISL (1ull << (63 - 2)) -#define LPCR_KBV (1ull << (63 - 3)) +#define LPCR_VPM0 PPC_BIT(0) +#define LPCR_VPM1 PPC_BIT(1) +#define LPCR_ISL PPC_BIT(2) +#define LPCR_KBV PPC_BIT(3)#define LPCR_DPFD_SHIFT (63 - 11)#define LPCR_DPFD (0x7ull << LPCR_DPFD_SHIFT)#define LPCR_VRMASD_SHIFT (63 - 16)
@@ -382,41 +389,41 @@ struct ppc_slb_t {/* P9: Power-saving mode Exit Cause Enable (Upper Section) Mask */ #define LPCR_PECE_U_SHIFT (63 - 19)#define LPCR_PECE_U_MASK (0x7ull << LPCR_PECE_U_SHIFT) -#define LPCR_HVEE (1ull << (63 - 17))/* Hypervisor Virt Exit Enable */ +#define LPCR_HVEE PPC_BIT(17)/* Hypervisor Virt Exit Enable */ #define LPCR_RMLS_SHIFT (63 - 37)#define LPCR_RMLS (0xfull << LPCR_RMLS_SHIFT) -#define LPCR_ILE (1ull << (63 - 38)) +#define LPCR_ILE PPC_BIT(38)#define LPCR_AIL_SHIFT (63 - 40)/* Alternate interrupt location */ #define LPCR_AIL (3ull << LPCR_AIL_SHIFT) -#define LPCR_UPRT (1ull << (63 - 41))/* Use Process Table */ -#define LPCR_EVIRT (1ull << (63 - 42))/* Enhanced Virtualisation */ -#define LPCR_ONL (1ull << (63 - 45)) -#define LPCR_LD (1ull << (63 - 46))/* Large Decrementer */ -#define LPCR_P7_PECE0 (1ull << (63 - 49)) -#define LPCR_P7_PECE1 (1ull << (63 - 50)) -#define LPCR_P7_PECE2 (1ull << (63 - 51)) -#define LPCR_P8_PECE0 (1ull << (63 - 47)) -#define LPCR_P8_PECE1 (1ull << (63 - 48)) -#define LPCR_P8_PECE2 (1ull << (63 - 49)) -#define LPCR_P8_PECE3 (1ull << (63 - 50)) -#define LPCR_P8_PECE4 (1ull << (63 - 51)) +#define LPCR_UPRT PPC_BIT(41)/* Use Process Table */ +#define LPCR_EVIRT PPC_BIT(42)/* Enhanced Virtualisation */ +#define LPCR_ONL PPC_BIT(45) +#define LPCR_LD PPC_BIT(46)/* Large Decrementer */ +#define LPCR_P7_PECE0 PPC_BIT(49) +#define LPCR_P7_PECE1 PPC_BIT(50) +#define LPCR_P7_PECE2 PPC_BIT(51) +#define LPCR_P8_PECE0 PPC_BIT(47) +#define LPCR_P8_PECE1 PPC_BIT(48) +#define LPCR_P8_PECE2 PPC_BIT(49) +#define LPCR_P8_PECE3 PPC_BIT(50) +#define LPCR_P8_PECE4 PPC_BIT(51)/* P9: Power-saving mode Exit Cause Enable (Lower Section) Mask */ #define LPCR_PECE_L_SHIFT (63 - 51)#define LPCR_PECE_L_MASK (0x1full << LPCR_PECE_L_SHIFT) -#define LPCR_PDEE (1ull << (63 - 47))/* Privileged Doorbell Exit EN */ -#define LPCR_HDEE (1ull << (63 - 48))/* Hyperv Doorbell Exit Enable */ -#define LPCR_EEE (1ull << (63 - 49))/* External Exit Enable */ -#define LPCR_DEE (1ull << (63 - 50))/* Decrementer Exit Enable */ -#define LPCR_OEE (1ull << (63 - 51))/* Other Exit Enable */ -#define LPCR_MER (1ull << (63 - 52)) -#define LPCR_GTSE (1ull << (63 - 53))/* Guest Translation Shootdown */ -#define LPCR_TC (1ull << (63 - 54)) -#define LPCR_HEIC (1ull << (63 - 59))/* HV Extern Interrupt Control */ -#define LPCR_LPES0 (1ull << (63 - 60)) -#define LPCR_LPES1 (1ull << (63 - 61)) -#define LPCR_RMI (1ull << (63 - 62)) -#define LPCR_HVICE (1ull << (63 - 62))/* HV Virtualisation Int Enable */ -#define LPCR_HDICE (1ull << (63 - 63)) +#define LPCR_PDEE PPC_BIT(47)/* Privileged Doorbell Exit EN */ +#define LPCR_HDEE PPC_BIT(48)/* Hyperv Doorbell Exit Enable */ +#define LPCR_EEE PPC_BIT(49)/* External Exit Enable */ +#define LPCR_DEE PPC_BIT(50)/* Decrementer Exit Enable */ +#define LPCR_OEE PPC_BIT(51)/* Other Exit Enable */ +#define LPCR_MER PPC_BIT(52) +#define LPCR_GTSE PPC_BIT(53)/* Guest Translation Shootdown */ +#define LPCR_TC PPC_BIT(54) +#define LPCR_HEIC PPC_BIT(59)/* HV Extern Interrupt Control */ +#define LPCR_LPES0 PPC_BIT(60) +#define LPCR_LPES1 PPC_BIT(61) +#define LPCR_RMI PPC_BIT(62) +#define LPCR_HVICE PPC_BIT(62)/* HV Virtualisation Int Enable */ +#define LPCR_HDICE PPC_BIT(63)#define msr_sf ((env->msr >> MSR_SF) & 1)#define msr_isf ((env->msr >> MSR_ISF) & 1)
@@ -507,22 +514,22 @@ struct ppc_slb_t {#define FSCR_IC_TAR 8/* Exception state register bits definition */ -#define ESR_PIL (1 << (63 - 36))/* Illegal Instruction */ -#define ESR_PPR (1 << (63 - 37))/* Privileged Instruction */ -#define ESR_PTR (1 << (63 - 38))/* Trap */ -#define ESR_FP (1 << (63 - 39))/* Floating-Point Operation */ -#define ESR_ST (1 << (63 - 40))/* Store Operation */ -#define ESR_AP (1 << (63 - 44))/* Auxiliary Processor Operation */ -#define ESR_PUO (1 << (63 - 45))/* Unimplemented Operation */ -#define ESR_BO (1 << (63 - 46))/* Byte Ordering */ -#define ESR_PIE (1 << (63 - 47))/* Imprecise exception */ -#define ESR_DATA (1 << (63 - 53))/* Data Access (Embedded page table) */ -#define ESR_TLBI (1 << (63 - 54))/* TLB Ineligible (Embedded page table) */ -#define ESR_PT (1 << (63 - 55))/* Page Table (Embedded page table) */ -#define ESR_SPV (1 << (63 - 56))/* SPE/VMX operation */ -#define ESR_EPID (1 << (63 - 57))/* External Process ID operation */ -#define ESR_VLEMI (1 << (63 - 58))/* VLE operation */ -#define ESR_MIF (1 << (63 - 62))/* Misaligned instruction (VLE) */ +#define ESR_PIL PPC_BIT(36)/* Illegal Instruction */ +#define ESR_PPR PPC_BIT(37)/* Privileged Instruction */ +#define ESR_PTR PPC_BIT(38)/* Trap */ +#define ESR_FP PPC_BIT(39)/* Floating-Point Operation */ +#define ESR_ST PPC_BIT(40)/* Store Operation */ +#define ESR_AP PPC_BIT(44)/* Auxiliary Processor Operation */ +#define ESR_PUO PPC_BIT(45)/* Unimplemented Operation */ +#define ESR_BO PPC_BIT(46)/* Byte Ordering */ +#define ESR_PIE PPC_BIT(47)/* Imprecise exception */ +#define ESR_DATA PPC_BIT(53)/* Data Access (Embedded page table) */ +#define ESR_TLBI PPC_BIT(54)/* TLB Ineligible (Embedded page table) */ +#define ESR_PT PPC_BIT(55)/* Page Table (Embedded page table) */ +#define ESR_SPV PPC_BIT(56)/* SPE/VMX operation */ +#define ESR_EPID PPC_BIT(57)/* External Process ID operation */ +#define ESR_VLEMI PPC_BIT(58)/* VLE operation */ +#define ESR_MIF PPC_BIT(62)/* Misaligned instruction (VLE) */ /* Transaction EXception And Summary Register bits */ #define TEXASR_FAILURE_PERSISTENT (63 - 7)
@@ -1991,7 +1998,7 @@ void ppc_compat_add_property(Object *obj, const char *name,#define HID0_DEEPNAP (1 << 24)/* pre-2.06 */ #define HID0_DOZE (1 << 23)/* pre-2.06 */ #define HID0_NAP (1 << 22)/* pre-2.06 */ -#define HID0_HILE (1ull << (63 - 19))/* POWER8 */ +#define HID0_HILE PPC_BIT(19)/* POWER8 */ /*****************************************************************************/ /* PowerPC Instructions types definitions */
Signature · 1 line
2.11.0
PATCH 48/54 target/ppc/spapr_caps: Add macro to generate spapr_caps migration vmstate
In reply to Michael RothFrom: Suraj Jitindar Singh <[email protected]>
The vmstate description and the contained needed function for migration of spapr_caps is the same for each cap, with the name of the cap substituted. As such introduce a macro to allow for easier generation of these.
Convert the three existing spapr_caps (htm, vsx, and dfp) to use this macro.
--- hw/ppc/spapr_caps.c | 78 +++++++++++++++++------------------------------------ 1 file changed, 24 insertions(+), 54 deletions(-)
hw/ppc/spapr_caps.c +24 -54
@@ -232,62 +232,32 @@ int spapr_caps_post_migration(sPAPRMachineState *spapr)return ok ?0 : -EINVAL ; } -static bool spapr_cap_htm_needed (void *opaque) -{ -sPAPRMachineState *spapr = opaque; - -return spapr->cmd_line_caps[SPAPR_CAP_HTM ] && - (spapr->eff.caps[SPAPR_CAP_HTM ] != spapr->def.caps[SPAPR_CAP_HTM ]); -} - -const VMStateDescription vmstate_spapr_cap_htm = { - .name ="spapr/cap/htm" , - .version_id =1 , - .minimum_version_id =1 , - .needed = spapr_cap_htm_needed, - .fields = (VMStateField []) { -VMSTATE_UINT8 (mig.caps[SPAPR_CAP_HTM ], sPAPRMachineState), -VMSTATE_END_OF_LIST () - }, -}; - -static bool spapr_cap_vsx_needed (void *opaque) -{ -sPAPRMachineState *spapr = opaque; - -return spapr->cmd_line_caps[SPAPR_CAP_VSX ] && - (spapr->eff.caps[SPAPR_CAP_VSX ] != spapr->def.caps[SPAPR_CAP_VSX ]); +/* Used to generate the migration field and needed function for a spapr cap */ +#define SPAPR_CAP_MIG_STATE (cap, ccap) \ +static bool spapr_cap_##cap##_needed(void *opaque) \ +{ \ + sPAPRMachineState *spapr = opaque; \ + \ + return spapr->cmd_line_caps[SPAPR_CAP_##ccap] && \ + (spapr->eff.caps[SPAPR_CAP_##ccap] != \ + spapr->def.caps[SPAPR_CAP_##ccap]); \ +} \ + \ +const VMStateDescription vmstate_spapr_cap_##cap = { \ + .name = "spapr/cap/" #cap, \ + .version_id = 1, \ + .minimum_version_id = 1, \ + .needed = spapr_cap_##cap##_needed, \ + .fields = (VMStateField[]) { \ + VMSTATE_UINT8(mig.caps[SPAPR_CAP_##ccap], \ + sPAPRMachineState), \ + VMSTATE_END_OF_LIST() \ + }, \ } -const VMStateDescription vmstate_spapr_cap_vsx = { - .name ="spapr/cap/vsx" , - .version_id =1 , - .minimum_version_id =1 , - .needed = spapr_cap_vsx_needed, - .fields = (VMStateField []) { -VMSTATE_UINT8 (mig.caps[SPAPR_CAP_VSX ], sPAPRMachineState), -VMSTATE_END_OF_LIST () - }, -}; - -static bool spapr_cap_dfp_needed (void *opaque) -{ -sPAPRMachineState *spapr = opaque; - -return spapr->cmd_line_caps[SPAPR_CAP_DFP ] && - (spapr->eff.caps[SPAPR_CAP_DFP ] != spapr->def.caps[SPAPR_CAP_DFP ]); -} - -const VMStateDescription vmstate_spapr_cap_dfp = { - .name ="spapr/cap/dfp" , - .version_id =1 , - .minimum_version_id =1 , - .needed = spapr_cap_dfp_needed, - .fields = (VMStateField []) { -VMSTATE_UINT8 (mig.caps[SPAPR_CAP_DFP ], sPAPRMachineState), -VMSTATE_END_OF_LIST () - }, -}; +SPAPR_CAP_MIG_STATE (htm,HTM ); +SPAPR_CAP_MIG_STATE (vsx,VSX ); +SPAPR_CAP_MIG_STATE (dfp,DFP );void spapr_caps_reset (sPAPRMachineState *spapr) {
Signature · 1 line
2.11.0
PATCH 49/54 target/ppc/kvm: Add cap_ppc_safe_[cache/bounds_check/indirect_branch]
In reply to Michael RothFrom: Suraj Jitindar Singh <[email protected]>
Add three new kvm capabilities used to represent the level of host support for three corresponding workarounds.
Host support for each of the capabilities is queried through the new ioctl KVM_PPC_GET_CPU_CHAR which returns four uint64 quantities. The first two, character and behaviour, represent the available characteristics of the cpu and the behaviour of the cpu respectively. The second two, c_mask and b_mask, represent the mask of known bits for the character and beheviour dwords respectively.
[dwg: Correct some compile errors due to name change in final kernel
patch version]
--- include/hw/ppc/spapr.h | 12 +++++++++++ target/ppc/kvm.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ target/ppc/kvm_ppc.h | 18 ++++++++++++++++ 3 files changed, 88 insertions(+)
include/hw/ppc/spapr.h +12 -0
@@ -295,6 +295,18 @@ struct sPAPRMachineState {#define H_DABRX_KERNEL (1ULL<<(63-62))#define H_DABRX_USER (1ULL<<(63-63)) +/* Values for KVM_PPC_GET_CPU_CHAR & H_GET_CPU_CHARACTERISTICS */ +#define H_CPU_CHAR_SPEC_BAR_ORI31 PPC_BIT(0) +#define H_CPU_CHAR_BCCTRL_SERIALISED PPC_BIT(1) +#define H_CPU_CHAR_L1D_FLUSH_ORI30 PPC_BIT(2) +#define H_CPU_CHAR_L1D_FLUSH_TRIG2 PPC_BIT(3) +#define H_CPU_CHAR_L1D_THREAD_PRIV PPC_BIT(4) +#define H_CPU_CHAR_HON_BRANCH_HINTS PPC_BIT(5) +#define H_CPU_CHAR_THR_RECONF_TRIG PPC_BIT(6) +#define H_CPU_BEHAV_FAVOUR_SECURITY PPC_BIT(0) +#define H_CPU_BEHAV_L1D_FLUSH_PR PPC_BIT(1) +#define H_CPU_BEHAV_BNDS_CHK_SPEC_BAR PPC_BIT(2) +/* Each control block has to be on a 4K boundary */ #define H_CB_ALIGNMENT 4096
target/ppc/kvm.c +58 -0
82 lines not on this page · raw message
target/ppc/kvm_ppc.h +18 -0
@@ -59,6 +59,9 @@ bool kvmppc_has_cap_fixup_hcalls(void);bool kvmppc_has_cap_htm (void );bool kvmppc_has_cap_mmu_radix (void );bool kvmppc_has_cap_mmu_hash_v3 (void ); +int kvmppc_get_cap_safe_cache (void ); +int kvmppc_get_cap_safe_bounds_check (void ); +int kvmppc_get_cap_safe_indirect_branch (void );int kvmppc_enable_hwrng (void );int kvmppc_put_books_sregs (PowerPCCPU *cpu);PowerPCCPUClass *kvm_ppc_get_host_cpu_class (void );
@@ -290,6 +293,21 @@ static inline bool kvmppc_has_cap_mmu_hash_v3(void)return false; } +static inline int kvmppc_get_cap_safe_cache (void ) +{ +return 0 ; +} + +static inline int kvmppc_get_cap_safe_bounds_check (void ) +{ +return 0 ; +} + +static inline int kvmppc_get_cap_safe_indirect_branch (void ) +{ +return 0 ; +} +static inline int kvmppc_enable_hwrng (void ) {return -1 ;
Signature · 1 line
2.11.0
PATCH 50/54 target/ppc/spapr_caps: Add support for tristate spapr_capabilities
In reply to Michael RothFrom: Suraj Jitindar Singh <[email protected]>
spapr_caps are used to represent the level of support for various capabilities related to the spapr machine type. Currently there is only support for boolean capabilities.
Add support for tristate capabilities by implementing their get/set functions. These capabilities can have the values 0, 1 or 2 corresponding to broken, workaround and fixed.
--- hw/ppc/spapr_caps.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 4 +++ 2 files changed, 70 insertions(+)
hw/ppc/spapr_caps.c +66 -0
@@ -74,6 +74,72 @@ static void spapr_cap_set_bool(Object *obj, Visitor *v, const char *name, spapr->eff.caps[cap->index] = value ?SPAPR_CAP_ON :SPAPR_CAP_OFF ; } +static void __attribute__ ((unused))spapr_cap_get_tristate (Object *obj, +Visitor *v, +const char *name, +void *opaque, +Error **errp) +{ +sPAPRCapabilityInfo *cap = opaque; +sPAPRMachineState *spapr =SPAPR_MACHINE (obj); +char *val =NULL ; +uint8_t value =spapr_get_cap (spapr, cap->index); + +switch (value) { +case SPAPR_CAP_BROKEN : + val =g_strdup ("broken" ); +break ; +case SPAPR_CAP_WORKAROUND : + val =g_strdup ("workaround" ); +break ; +case SPAPR_CAP_FIXED : + val =g_strdup ("fixed" ); +break ; +default : +error_setg (errp,"Invalid value (%d) for cap-%s" , value, cap->name); +return ; + } + +visit_type_str (v, name, &val, errp); +g_free (val); +} + +static void __attribute__ ((unused))spapr_cap_set_tristate (Object *obj, +Visitor *v, +const char *name, +void *opaque, +Error **errp) +{ +sPAPRCapabilityInfo *cap = opaque; +sPAPRMachineState *spapr =SPAPR_MACHINE (obj); +char *val; +Error *local_err =NULL ; +uint8_t value; + +visit_type_str (v, name, &val, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + } + +if (!strcasecmp (val,"broken" )) { + value =SPAPR_CAP_BROKEN ; + }else if (!strcasecmp (val,"workaround" )) { + value =SPAPR_CAP_WORKAROUND ; + }else if (!strcasecmp (val,"fixed" )) { + value =SPAPR_CAP_FIXED ; + }else { +error_setg (errp,"Invalid capability mode \"%s\" for cap-%s" , val, + cap->name); + goto out; + } + + spapr->cmd_line_caps[cap->index] = true; + spapr->eff.caps[cap->index] = value; +out: +g_free (val); +} +static void cap_htm_apply (sPAPRMachineState *spapr,uint8_t val,Error **errp) {if (!val) {
include/hw/ppc/spapr.h +4 -0
@@ -69,6 +69,10 @@ typedef enum {/* Bool Caps */ #define SPAPR_CAP_OFF 0x00#define SPAPR_CAP_ON 0x01 +/* Broken | Workaround | Fixed Caps */ +#define SPAPR_CAP_BROKEN 0x00 +#define SPAPR_CAP_WORKAROUND 0x01 +#define SPAPR_CAP_FIXED 0x02typedef struct sPAPRCapabilities sPAPRCapabilities ;struct sPAPRCapabilities {
Signature · 1 line
2.11.0
PATCH 51/54 target/ppc/spapr_caps: Add new tristate cap safe_cache
In reply to Michael RothFrom: Suraj Jitindar Singh <[email protected]>
Add new tristate cap cap-cfpc to represent the cache flush on privilege change capability.
--- hw/ppc/spapr.c | 2 ++ hw/ppc/spapr_caps.c | 36 ++++++++++++++++++++++++++---------- include/hw/ppc/spapr.h | 5 ++++- 3 files changed, 32 insertions(+), 11 deletions(-)
hw/ppc/spapr.c +2 -0
@@ -1765,6 +1765,7 @@ static const VMStateDescription vmstate_spapr = { &vmstate_spapr_cap_htm, &vmstate_spapr_cap_vsx, &vmstate_spapr_cap_dfp, + &vmstate_spapr_cap_cfpc, NULL } };
@@ -3709,6 +3710,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) smc->default_caps.caps[SPAPR_CAP_HTM ] =SPAPR_CAP_OFF ; smc->default_caps.caps[SPAPR_CAP_VSX ] =SPAPR_CAP_ON ; smc->default_caps.caps[SPAPR_CAP_DFP ] =SPAPR_CAP_ON ; + smc->default_caps.caps[SPAPR_CAP_CFPC ] =SPAPR_CAP_BROKEN ;spapr_caps_add_properties (smc, &error_abort); }
hw/ppc/spapr_caps.c +26 -10
@@ -74,11 +74,8 @@ static void spapr_cap_set_bool(Object *obj, Visitor *v, const char *name, spapr->eff.caps[cap->index] = value ?SPAPR_CAP_ON :SPAPR_CAP_OFF ; } -static void __attribute__ ((unused))spapr_cap_get_tristate (Object *obj, -Visitor *v, -const char *name, -void *opaque, -Error **errp) +static void spapr_cap_get_tristate (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp) {sPAPRCapabilityInfo *cap = opaque;sPAPRMachineState *spapr =SPAPR_MACHINE (obj);
@@ -104,11 +101,8 @@ static void __attribute__ ((unused)) spapr_cap_get_tristate(Object *obj,g_free (val); } -static void __attribute__ ((unused))spapr_cap_set_tristate (Object *obj, -Visitor *v, -const char *name, -void *opaque, -Error **errp) +static void spapr_cap_set_tristate (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp) {sPAPRCapabilityInfo *cap = opaque;sPAPRMachineState *spapr =SPAPR_MACHINE (obj);
@@ -187,6 +181,18 @@ static void cap_dfp_apply(sPAPRMachineState *spapr, uint8_t val, Error **errp) } } +static void cap_safe_cache_apply (sPAPRMachineState *spapr,uint8_t val, +Error **errp) +{ +if (tcg_enabled () && val) { +/* TODO - for now only allow broken for TCG */ +error_setg (errp,"Requested safe cache capability level not supported by tcg, try a different value for cap-cfpc" ); + }else if (kvm_enabled () && (val >kvmppc_get_cap_safe_cache ())) { +error_setg (errp,"Requested safe cache capability level not supported by kvm, try a different value for cap-cfpc" ); + } +} + +#define VALUE_DESC_TRISTATE " (broken, workaround, fixed)"sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM ] = { [SPAPR_CAP_HTM ] = {
@@ -219,6 +225,15 @@ sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] = { .type = "bool", .apply = cap_dfp_apply, }, + [SPAPR_CAP_CFPC] = { + .name = "cfpc", + .description = "Cache Flush on Privilege Change" VALUE_DESC_TRISTATE, + .index = SPAPR_CAP_CFPC, + .get = spapr_cap_get_tristate, + .set = spapr_cap_set_tristate, + .type = "string", + .apply = cap_safe_cache_apply, + }, }; static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr,
@@ -324,6 +339,7 @@ const VMStateDescription vmstate_spapr_cap_##cap = { \SPAPR_CAP_MIG_STATE (htm,HTM );SPAPR_CAP_MIG_STATE (vsx,VSX );SPAPR_CAP_MIG_STATE (dfp,DFP ); +SPAPR_CAP_MIG_STATE (cfpc,CFPC );void spapr_caps_reset (sPAPRMachineState *spapr) {
include/hw/ppc/spapr.h +4 -1
@@ -60,8 +60,10 @@ typedef enum {#define SPAPR_CAP_VSX 0x01/* Decimal Floating Point */ #define SPAPR_CAP_DFP 0x02 +/* Cache Flush on Privilege Change */ +#define SPAPR_CAP_CFPC 0x03/* Num Caps */ -#define SPAPR_CAP_NUM (SPAPR_CAP_DFP + 1) +#define SPAPR_CAP_NUM (SPAPR_CAP_CFPC + 1)/* * Capability Values
@@ -761,6 +763,7 @@ int spapr_caps_pre_save(void *opaque);extern const VMStateDescription vmstate_spapr_cap_htm;extern const VMStateDescription vmstate_spapr_cap_vsx;extern const VMStateDescription vmstate_spapr_cap_dfp; +extern const VMStateDescription vmstate_spapr_cap_cfpc;static inline uint8_t spapr_get_cap (sPAPRMachineState *spapr,int cap) {
Signature · 1 line
2.11.0
PATCH 52/54 target/ppc/spapr_caps: Add new tristate cap safe_bounds_check
In reply to Michael RothFrom: Suraj Jitindar Singh <[email protected]>
Add new tristate cap cap-sbbc to represent the speculation barrier bounds checking capability.
--- hw/ppc/spapr.c | 2 ++ hw/ppc/spapr_caps.c | 21 +++++++++++++++++++++ include/hw/ppc/spapr.h | 5 ++++- 3 files changed, 27 insertions(+), 1 deletion(-)
hw/ppc/spapr.c +2 -0
@@ -1766,6 +1766,7 @@ static const VMStateDescription vmstate_spapr = { &vmstate_spapr_cap_vsx, &vmstate_spapr_cap_dfp, &vmstate_spapr_cap_cfpc, + &vmstate_spapr_cap_sbbc, NULL } };
@@ -3711,6 +3712,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) smc->default_caps.caps[SPAPR_CAP_VSX ] =SPAPR_CAP_ON ; smc->default_caps.caps[SPAPR_CAP_DFP ] =SPAPR_CAP_ON ; smc->default_caps.caps[SPAPR_CAP_CFPC ] =SPAPR_CAP_BROKEN ; + smc->default_caps.caps[SPAPR_CAP_SBBC ] =SPAPR_CAP_BROKEN ;spapr_caps_add_properties (smc, &error_abort); }
hw/ppc/spapr_caps.c +21 -0
@@ -192,6 +192,17 @@ static void cap_safe_cache_apply(sPAPRMachineState *spapr, uint8_t val, } } +static void cap_safe_bounds_check_apply (sPAPRMachineState *spapr,uint8_t val, +Error **errp) +{ +if (tcg_enabled () && val) { +/* TODO - for now only allow broken for TCG */ +error_setg (errp,"Requested safe bounds check capability level not supported by tcg, try a different value for cap-sbbc" ); + }else if (kvm_enabled () && (val >kvmppc_get_cap_safe_bounds_check ())) { +error_setg (errp,"Requested safe bounds check capability level not supported by kvm, try a different value for cap-sbbc" ); + } +} +#define VALUE_DESC_TRISTATE " (broken, workaround, fixed)"sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM ] = {
@@ -234,6 +245,15 @@ sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] = { .type = "string", .apply = cap_safe_cache_apply, }, + [SPAPR_CAP_SBBC] = { + .name = "sbbc", + .description = "Speculation Barrier Bounds Checking" VALUE_DESC_TRISTATE, + .index = SPAPR_CAP_SBBC, + .get = spapr_cap_get_tristate, + .set = spapr_cap_set_tristate, + .type = "string", + .apply = cap_safe_bounds_check_apply, + }, }; static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr,
@@ -340,6 +360,7 @@ SPAPR_CAP_MIG_STATE(htm, HTM);SPAPR_CAP_MIG_STATE (vsx,VSX );SPAPR_CAP_MIG_STATE (dfp,DFP );SPAPR_CAP_MIG_STATE (cfpc,CFPC ); +SPAPR_CAP_MIG_STATE (sbbc,SBBC );void spapr_caps_reset (sPAPRMachineState *spapr) {
include/hw/ppc/spapr.h +4 -1
@@ -62,8 +62,10 @@ typedef enum {#define SPAPR_CAP_DFP 0x02/* Cache Flush on Privilege Change */ #define SPAPR_CAP_CFPC 0x03 +/* Speculation Barrier Bounds Checking */ +#define SPAPR_CAP_SBBC 0x04/* Num Caps */ -#define SPAPR_CAP_NUM (SPAPR_CAP_CFPC + 1) +#define SPAPR_CAP_NUM (SPAPR_CAP_SBBC + 1)/* * Capability Values
@@ -764,6 +766,7 @@ extern const VMStateDescription vmstate_spapr_cap_htm;extern const VMStateDescription vmstate_spapr_cap_vsx;extern const VMStateDescription vmstate_spapr_cap_dfp;extern const VMStateDescription vmstate_spapr_cap_cfpc; +extern const VMStateDescription vmstate_spapr_cap_sbbc;static inline uint8_t spapr_get_cap (sPAPRMachineState *spapr,int cap) {
Signature · 1 line
2.11.0
PATCH 53/54 target/ppc/spapr_caps: Add new tristate cap safe_indirect_branch
In reply to Michael RothFrom: Suraj Jitindar Singh <[email protected]>
Add new tristate cap cap-ibs to represent the indirect branch serialisation capability.
--- hw/ppc/spapr.c | 2 ++ hw/ppc/spapr_caps.c | 21 +++++++++++++++++++++ include/hw/ppc/spapr.h | 5 ++++- 3 files changed, 27 insertions(+), 1 deletion(-)
hw/ppc/spapr.c +2 -0
@@ -1767,6 +1767,7 @@ static const VMStateDescription vmstate_spapr = { &vmstate_spapr_cap_dfp, &vmstate_spapr_cap_cfpc, &vmstate_spapr_cap_sbbc, + &vmstate_spapr_cap_ibs, NULL } };
@@ -3713,6 +3714,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) smc->default_caps.caps[SPAPR_CAP_DFP ] =SPAPR_CAP_ON ; smc->default_caps.caps[SPAPR_CAP_CFPC ] =SPAPR_CAP_BROKEN ; smc->default_caps.caps[SPAPR_CAP_SBBC ] =SPAPR_CAP_BROKEN ; + smc->default_caps.caps[SPAPR_CAP_IBS ] =SPAPR_CAP_BROKEN ;spapr_caps_add_properties (smc, &error_abort); }
hw/ppc/spapr_caps.c +21 -0
@@ -203,6 +203,17 @@ static void cap_safe_bounds_check_apply(sPAPRMachineState *spapr, uint8_t val, } } +static void cap_safe_indirect_branch_apply (sPAPRMachineState *spapr, +uint8_t val,Error **errp) +{ +if (tcg_enabled () && val) { +/* TODO - for now only allow broken for TCG */ +error_setg (errp,"Requested safe indirect branch capability level not supported by tcg, try a different value for cap-ibs" ); + }else if (kvm_enabled () && (val >kvmppc_get_cap_safe_indirect_branch ())) { +error_setg (errp,"Requested safe indirect branch capability level not supported by kvm, try a different value for cap-ibs" ); + } +} +#define VALUE_DESC_TRISTATE " (broken, workaround, fixed)"sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM ] = {
@@ -254,6 +265,15 @@ sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] = { .type = "string", .apply = cap_safe_bounds_check_apply, }, + [SPAPR_CAP_IBS] = { + .name = "ibs", + .description = "Indirect Branch Serialisation" VALUE_DESC_TRISTATE, + .index = SPAPR_CAP_IBS, + .get = spapr_cap_get_tristate, + .set = spapr_cap_set_tristate, + .type = "string", + .apply = cap_safe_indirect_branch_apply, + }, }; static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr,
@@ -361,6 +381,7 @@ SPAPR_CAP_MIG_STATE(vsx, VSX);SPAPR_CAP_MIG_STATE (dfp,DFP );SPAPR_CAP_MIG_STATE (cfpc,CFPC );SPAPR_CAP_MIG_STATE (sbbc,SBBC ); +SPAPR_CAP_MIG_STATE (ibs,IBS );void spapr_caps_reset (sPAPRMachineState *spapr) {
include/hw/ppc/spapr.h +4 -1
@@ -64,8 +64,10 @@ typedef enum {#define SPAPR_CAP_CFPC 0x03/* Speculation Barrier Bounds Checking */ #define SPAPR_CAP_SBBC 0x04 +/* Indirect Branch Serialisation */ +#define SPAPR_CAP_IBS 0x05/* Num Caps */ -#define SPAPR_CAP_NUM (SPAPR_CAP_SBBC + 1) +#define SPAPR_CAP_NUM (SPAPR_CAP_IBS + 1)/* * Capability Values
@@ -767,6 +769,7 @@ extern const VMStateDescription vmstate_spapr_cap_vsx;extern const VMStateDescription vmstate_spapr_cap_dfp;extern const VMStateDescription vmstate_spapr_cap_cfpc;extern const VMStateDescription vmstate_spapr_cap_sbbc; +extern const VMStateDescription vmstate_spapr_cap_ibs;static inline uint8_t spapr_get_cap (sPAPRMachineState *spapr,int cap) {
Signature · 1 line
2.11.0
Quoted 4 lines · Michael Roth
Hi everyone,
The following new patches are queued for QEMU stable v2.11.1:
Quoted 8 lines
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2017-02-14:
https://wiki.qemu.org/Planning/2.11
Please respond here or CC [email protected] on any patches you think should be included in the release.
Looking for "CVE" in the changelog, these look like good candidates for stable as well:
191f59dc17396bb5a8da50f8c59b6e0a430711a4
vga: check the validation of memory addr when draw text
f887cf165db20f405cb8805c716bd363aaadf815
ui: place a hard cap on VNC server output buffer size (and the preceding patches)
Quoted 5 lines
Of particular importance would be any feedback on the various QEMU patches relating to Spectre/Meltdown mitigation. The current tree has what I understand to be the QEMU components required for x86, s390, and pseries, but feedback/confirmation from the various authors would be greatly appreciated.
[...]
Quoted 3 lines
Christian Borntraeger (2):
s390x/kvm: Handle bpb feature s390x/kvm: provide stfle.81
Confirmed, AFAIK that are the only two patches that are required for Spectre on s390x (together with the linux-headers update).
Thomas
Quoted 17 lines · Thomas Huth
Quoted 4 lines · Michael Roth
Hi everyone,
The following new patches are queued for QEMU stable v2.11.1:
Quoted 8 lines
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2017-02-14:
https://wiki.qemu.org/Planning/2.11
Please respond here or CC [email protected] on any patches you think should be included in the release.
Looking for "CVE" in the changelog, these look like good candidates for stable as well:
Quoted 6 lines
191f59dc17396bb5a8da50f8c59b6e0a430711a4
vga: check the validation of memory addr when draw text
f887cf165db20f405cb8805c716bd363aaadf815
ui: place a hard cap on VNC server output buffer size (and the preceding patches)
FYI, to fix the VNC problem you'll need alot of patches. To get clean cherry-pick's I think you'll probably need all of this:
627ebec208a8809818589e17f4fce55a59420ad2 ui: correctly advance output buffer when writing SASL data 4c956bd81e2e16afd19d38d1fdeba6d9faa8a1ae ui: avoid sign extension using client width/height 30b80fd5269257f55203b7072c505b4ebaab5115 ui: mix misleading comments & return types of VNC I/O helper methods 6aa22a29187e1908f5db738d27c64a9efc8d0bfa ui: add trace events related to VNC client throttling f887cf165db20f405cb8805c716bd363aaadf815 ui: place a hard cap on VNC server output buffer size ada8d2e4369ea49677d8672ac81bce73eefd5b54 ui: fix VNC client throttling when forced update is requested e2b72cb6e0443d90d7ab037858cb6834b6cca852 ui: fix VNC client throttling when audio capture is active 0bad834228b9ee63e4239108d02dcb94568254d0 ui: refactor code for determining if an update should be sent to the client 728a7ac95484a7ba5e624ccbac4c1326571576b0 ui: correctly reset framebuffer update state after processing dirty regions fef1bbadfb2c3027208eb3d14b43e1bdb51166ca ui: introduce enum to track VNC client framebuffer update request state 8f61f1c5a6bc06438a1172efa80bc7606594fa07 ui: track how much decoded data we consumed when doing SASL encoding 3541b08475d51bddf8aded36576a0ff5a547a978 ui: avoid pointless VNC updates if framebuffer isn't dirty b939eb89b6f320544a9328fa908d881d0024c1ee ui: remove redundant indentation in vnc_client_update c53df961617736f94731d94b62c2954c261d2bae ui: remove unreachable code in vnc_update_client 6af998db05aec9af95a06f84ad94f1b96785e667 ui: remove 'sync' parameter from vnc_update_client
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 13 lines · On Tue, 6 Feb 2018 13:14:21 -0600 Michael Roth <[email protected]>…
Hi everyone,
The following new patches are queued for QEMU stable v2.11.1:
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2017-02-14:
https://wiki.qemu.org/Planning/2.11
Please respond here or CC [email protected] on any patches you think should be included in the release.
Quoted 7 lines
Of particular importance would be any feedback on the various QEMU patches relating to Spectre/Meltdown mitigation. The current tree has what I understand to be the QEMU components required for x86, s390, and pseries, but feedback/confirmation from the various authors would be greatly appreciated.
Thanks!
AFAICS, the patches include everything we need for s390x. Thanks!
Hi Michael,
Quoted 4 lines · On Tue, 6 Feb 2018 13:14:21 -0600 Michael Roth <[email protected]>…
Hi everyone,
The following new patches are queued for QEMU stable v2.11.1:
Quoted 9 lines
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2017-02-14:
https://wiki.qemu.org/Planning/2.11
Please respond here or CC [email protected] on any patches you think should be included in the release.
Maybe worth to pick the following patch when it gets merged:
http://patchwork.ozlabs.org/patch/869873/
It fixes a 2.11 regression with RAM postcopy.
Quoted 6 lines
Of particular importance would be any feedback on the various QEMU patches relating to Spectre/Meltdown mitigation. The current tree has what I understand to be the QEMU components required for x86, s390, and pseries, but feedback/confirmation from the various authors would be greatly appreciated.
Patch 54 "target/ppc/spapr: Add H-Call H_GET_CPU_CHARACTERISTICS" has a trivial but potentially embarrassing bug (QEMU aborts if the host supports KVM_PPC_CPU_CHAR_BCCTRL_SERIALISED and cap-ibs="fixed" is used).
A patch was sent to the list:
http://patchwork.ozlabs.org/patch/868426/
AFAIK David Gibson (Cc'd) is away and I don't know when this patch will be merged.
Cheers,
--
Greg
Quoted 204 lines
Thanks!
----------------------------------------------------------------
The following changes since commit
0a0dc59d27527b78a195c2d838d28b7b49e5a639:Update version for v2.11.0 release (2017-12-13 14:31:09 +0000)
are available in the git repository at:
git://github.com/mdroth/qemu.gitstable-2.11-stagingfor you to fetch changes up to
ed8b4ecc68d6bfe98000b08d649049d0c1174c11:target/ppc/spapr: Add H-Call
H_GET_CPU_CHARACTERISTICS(2018-02-05 19:07:38 -0600)----------------------------------------------------------------
Alex Bennée (1):
target/sh4: fix TCG leak during gusa sequenceAlex Williamson (1):
vfio: Fix vfio-kvm group registrationChristian Borntraeger (2):
s390x/kvm: Handle bpb feature s390x/kvm: provide stfle.81Claudio Imbrenda (1):
s390x: fix storage attributes migration for non-small guestsCornelia Huck (1):
linux-headers: updateCédric Le Goater (1):
target/ppc: introduce thePPC_BIT()macroDavid Gibson (7):
spapr: Add pseries-2.12 machine type
spapr: Capabilities infrastructure
spapr: Treat Hardware Transactional Memory (HTM) as an optional capability
spapr: Validate capabilities on migration
target/ppc: Clean up probing of VMX, VSX and DFP availability on KVM
spapr: Handle VMX/VSX presence as an spapr capability flag
spapr: Handle Decimal Floating Point (DFP) as an optional capabilityEduardo Habkost (5):
i386: ChangeX86CPUDefinition::model_idto const char*
i386: Add spec-ctrl CPUID bit
i386: AddFEAT_8000_0008_EBXCPUID feature word
i386: Add new -IBRS versions of Intel CPU models
i386: Add EPYC-IBPB CPU modelEric Auger (1):
linux-headers: update to 4.15-rc1Fam Zheng (3):
block: Open backing image in force share mode for size probe
osdep: Retry SETLK upon EINTR
usb-storage: Fix share-rw option parsingGreg Kurz (2):
spapr_pci: fix MSI/MSIX selection
spapr: fix device tree properties when using compatibility modeJay Zhou (1):
vhost: remove assertion to prevent crashJose Ricardo Ziviani (1):
ppc: Change Power9 compat table to support at most 8 threads/coreKevin Wolf (2):
block: Makebdrv_drain_invoke()recursive
block: Call .drain_begin only once inbdrv_drain_all_begin()Laurent Vivier (1):
spapr: don't initialize PATB entry if max-cpu-compat < power9Marcel Apfelbaum (1):
hw/pci-bridge: fix QEMU crash because of pcie-root-portMarkus Armbruster (1):
qemu-options: Remove stray colons from output of --helpMichael S. Tsirkin (1):
virtio_error: don't invoke status callbacksMurilo Opsfelder Araujo (1):
block/nbd: fix segmentation fault when .desc is not null-terminatedPaolo Bonzini (2):
qemu-pr-helper: miscellaneous fixes
i386: Add support forSPEC_CTRLMSRPeter Lieven (1):
block/iscsi: dont leave allocmap in an invalid state on UNMAP failurePeter Maydell (8):
target/i386: Fix handling of VEX prefixes hw/intc/arm_gicv3: Make reserved register addresses RAZ/WI hw/intc/arm_gic: reserved register addresses are RAZ/WI hw/sd/pl181: Reset SD card on controller reset hw/sd/milkymist-memcard: Reset SD card on controller reset hw/sd/ssi-sd: Reset SD card on controller reset
linux-user: Fix locking order infork_start()linux-user/signal.c: Rename MC_* definesStefan Hajnoczi (1):
scsi-disk: release AioContext in unaligned WRITE SAME caseSuraj Jitindar Singh (8):
hw/ppc/spapr_caps: Reworkspapr_capsto use uint8 internal representation target/ppc/spapr_caps: Add macro to generatespapr_capsmigration vmstate target/ppc/kvm: Add cap_ppc_safe_[cache/bounds_check/indirect_branch] target/ppc/spapr_caps: Add support for tristatespapr_capabilitiestarget/ppc/spapr_caps: Add new tristate capsafe_cachetarget/ppc/spapr_caps: Add new tristate capsafe_bounds_checktarget/ppc/spapr_caps: Add new tristate capsafe_indirect_branchtarget/ppc/spapr: Add H-CallH_GET_CPU_CHARACTERISTICSblock.c | 3 +- block/io.c | 13 +- block/iscsi.c | 8 +- block/nbd.c | 1 + hw/intc/arm_gic.c | 5 +- hw/intc/arm_gicv3_dist.c | 13 + hw/intc/arm_gicv3_its_common.c | 8 +- hw/intc/arm_gicv3_redist.c | 13 + hw/pci-bridge/gen_pcie_root_port.c | 7 +- hw/ppc/Makefile.objs | 2 +- hw/ppc/spapr.c | 130 ++++-- hw/ppc/spapr_caps.c | 443 ++++++++++++++++++++ hw/ppc/spapr_cpu_core.c | 7 + hw/ppc/spapr_hcall.c | 58 +++ hw/ppc/spapr_pci.c | 61 ++- hw/s390x/s390-stattrib-kvm.c | 4 +- hw/scsi/scsi-bus.c | 9 +- hw/scsi/scsi-disk.c | 1 + hw/sd/milkymist-memcard.c | 4 + hw/sd/pl181.c | 4 + hw/sd/ssi-sd.c | 25 +- hw/usb/dev-storage.c | 3 +- hw/vfio/common.c | 1 + hw/virtio/vhost-user.c | 5 +- hw/virtio/virtio.c | 2 +- include/hw/compat.h | 2 + include/hw/ppc/spapr.h | 74 ++++ include/hw/scsi/scsi.h | 1 + include/scsi/utils.h | 6 +- include/standard-headers/asm-s390/virtio-ccw.h | 5 +- include/standard-headers/asm-x86/hyperv.h | 394 +----------------- include/standard-headers/linux/input-event-codes.h | 2 + include/standard-headers/linux/input.h | 1 + include/standard-headers/linux/pci_regs.h | 45 +- linux-headers/asm-arm/kvm.h | 8 + linux-headers/asm-arm/kvm_para.h | 1 + linux-headers/asm-arm/unistd.h | 2 + linux-headers/asm-arm64/kvm.h | 8 + linux-headers/asm-arm64/unistd.h | 1 + linux-headers/asm-powerpc/epapr_hcalls.h | 1 + linux-headers/asm-powerpc/kvm.h | 26 ++ linux-headers/asm-powerpc/kvm_para.h | 1 + linux-headers/asm-powerpc/unistd.h | 1 + linux-headers/asm-s390/kvm.h | 10 +- linux-headers/asm-s390/kvm_para.h | 5 +- linux-headers/asm-s390/unistd.h | 4 +- linux-headers/asm-x86/kvm.h | 1 + linux-headers/asm-x86/kvm_para.h | 2 +- linux-headers/asm-x86/unistd.h | 1 + linux-headers/linux/kvm.h | 10 +- linux-headers/linux/kvm_para.h | 1 + linux-headers/linux/psci.h | 1 + linux-headers/linux/userfaultfd.h | 1 + linux-headers/linux/vfio.h | 1 + linux-headers/linux/vfio_ccw.h | 1 + linux-headers/linux/vhost.h | 1 + linux-user/main.c | 4 +- linux-user/signal.c | 118 +++--- qemu-options-wrapper.h | 2 +- qemu-options.hx | 27 +- scripts/hxtool | 3 +- scsi/qemu-pr-helper.c | 30 +- scsi/utils.c | 10 + target/i386/cpu.c | 455 ++++++++++++++++++++- target/i386/cpu.h | 7 + target/i386/kvm.c | 14 + target/i386/machine.c | 20 + target/i386/translate.c | 2 +- target/ppc/compat.c | 9 +- target/ppc/cpu.h | 105 ++--- target/ppc/kvm.c | 85 +++- target/ppc/kvm_ppc.h | 20 +- target/s390x/cpu.c | 1 + target/s390x/cpu.h | 1 + target/s390x/cpu_features.c | 2 + target/s390x/cpu_features_def.h | 2 + target/s390x/gen-features.c | 2 + target/s390x/kvm.c | 14 + target/s390x/machine.c | 17 + target/sh4/translate.c | 2 +- util/osdep.c | 4 +- 81 files changed, 1746 insertions(+), 658 deletions(-) create mode 100644 hw/ppc/spapr_caps.c
Am 06.02.2018 um 20:14 schrieb Michael Roth:
Quoted 10 lines
Hi everyone,
The following new patches are queued for QEMU stable v2.11.1:
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2017-02-14:
https://wiki.qemu.org/Planning/2.11
Quoted 8 lines
Please respond here or CC [email protected] on any patches you think should be included in the release.
Of particular importance would be any feedback on the various QEMU patches relating to Spectre/Meltdown mitigation. The current tree has what I understand to be the QEMU components required for x86, s390, and pseries, but feedback/confirmation from the various authors would be greatly appreciated.
Hi,
I also found the following patches that affect migration:
migration: Don't leak IO channels
migration: Recover block devices if failure in device state migration/savevm.c: set MAX_VM_CMD_PACKAGED_SIZE to 1ul << 32
In general it seems that migration related patches are often not tagged qemu-stable. David, can you check if there are patches missing?
Thank you,
Peter
Quoted 22 lines · * Peter Lieven ([email protected]) wrote:
Am 06.02.2018 um 20:14 schrieb Michael Roth:
Quoted 10 lines
Hi everyone,
The following new patches are queued for QEMU stable v2.11.1:
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2017-02-14:
https://wiki.qemu.org/Planning/2.11Quoted 8 lines
Please respond here or CC [email protected] on any patches you think should be included in the release.
Of particular importance would be any feedback on the various QEMU patches relating to Spectre/Meltdown mitigation. The current tree has what I understand to be the QEMU components required for x86, s390, and pseries, but feedback/confirmation from the various authors would be greatly appreciated.
Hi,
Quoted 8 lines
I also found the following patches that affect migration:
migration: Don't leak IO channels
migration: Recover block devices if failure in device statemigration/savevm.c: setMAX_VM_CMD_PACKAGED_SIZEto 1ul << 32In general it seems that migration related patches are often not tagged qemu-stable. David, can you check if there are patches missing?
I'm always a bit cautious about forwarding stuff to stable; just because it's landed in our main branch it doesn't mean many people have tested it, so I'd rather wait unless it was particularly urgent.
The 'migration: Recover block devices if failure in device state' is
probably a good candidate.
Another one would be Greg Kurz's:875fcd013ab68c64802998b22f54f0184479d21b - migration: incoming postcopy advise sanity checks
Dave
Quoted 3 lines
Thank you,
Peter
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 32 lines · On Mon, 12 Feb 2018 16:13:23 +0000 "Dr. David Alan Gilbert"…
Quoted 22 lines · * Peter Lieven ([email protected]) wrote:
Am 06.02.2018 um 20:14 schrieb Michael Roth:
Quoted 10 lines
Hi everyone,
The following new patches are queued for QEMU stable v2.11.1:
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2017-02-14:
https://wiki.qemu.org/Planning/2.11Quoted 8 lines
Please respond here or CC [email protected] on any patches you think should be included in the release.
Of particular importance would be any feedback on the various QEMU patches relating to Spectre/Meltdown mitigation. The current tree has what I understand to be the QEMU components required for x86, s390, and pseries, but feedback/confirmation from the various authors would be greatly appreciated.
Hi,
Quoted 8 lines
I also found the following patches that affect migration:
migration: Don't leak IO channels
migration: Recover block devices if failure in device statemigration/savevm.c: setMAX_VM_CMD_PACKAGED_SIZEto 1ul << 32In general it seems that migration related patches are often not tagged qemu-stable. David, can you check if there are patches missing?
Quoted 9 lines
I'm always a bit cautious about forwarding stuff to stable; just because it's landed in our main branch it doesn't mean many people have tested it, so I'd rather wait unless it was particularly urgent.
The 'migration: Recover block devices if failure in device state' is
probably a good candidate.
Another one would be Greg Kurz's:875fcd013ab68c64802998b22f54f0184479d21b- migration: incoming postcopy advise sanity checks
Yeah. Mike pushed it to its stable-2.11-staging tree:
https://github.com/mdroth/qemu/commit/a3fd64f2fe9f90c7b4d002910a54049ee6a09b64
Cheers,
--
Greg
Quoted 8 lines
Dave
Quoted 3 lines
Thank you,
Peter--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Am 12.02.2018 um 17:13 schrieb Dr. David Alan Gilbert:
Quoted 28 lines · * Peter Lieven ([email protected]) wrote:
Quoted 27 lines
Am 06.02.2018 um 20:14 schrieb Michael Roth:
Quoted 10 lines
Hi everyone,
The following new patches are queued for QEMU stable v2.11.1:
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2017-02-14:
https://wiki.qemu.org/Planning/2.11Quoted 8 lines
Please respond here or CC [email protected] on any patches you think should be included in the release.
Of particular importance would be any feedback on the various QEMU patches relating to Spectre/Meltdown mitigation. The current tree has what I understand to be the QEMU components required for x86, s390, and pseries, but feedback/confirmation from the various authors would be greatly appreciated.
Hi,
I also found the following patches that affect migration:
migration: Don't leak IO channels
migration: Recover block devices if failure in device statemigration/savevm.c: setMAX_VM_CMD_PACKAGED_SIZEto 1ul << 32
Quoted 5 lines
Quoted 2 lines
In general it seems that migration related patches are often not tagged qemu-stable. David, can you check if there are patches missing?
I'm always a bit cautious about forwarding stuff to stable; just because it's landed in our main branch it doesn't mean many people have tested it, so I'd rather wait unless it was particularly urgent.
Understood. Maybe we need a special mechanism to track such patches.
It would be good to have them in a stable release. Maybe tag them as stable-candidate or sth. Then we can recheck their status when a stable release is going to be released.
Peter
Hi Michael,
Quoted 11 lines · Michael Roth
The release is planned for 2017-02-14:
https://wiki.qemu.org/Planning/2.11
Please respond here or CC [email protected] on any patches you think should be included in the release.
----------------------------------------------------------------
----------------------------------------------------------------
Alex Bennée (1):
target/sh4: fix TCG leak during gusa sequence
There is also e691e0ed135 "target/sh4: add missing tcg_temp_free() in _decode_opc()"
PATCH 54/54 target/ppc/spapr: Add H-Call H_GET_CPU_CHARACTERISTICS
In reply to Michael RothFrom: Suraj Jitindar Singh <[email protected]>
The new H-Call H_GET_CPU_CHARACTERISTICS is used by the guest to query behaviours and available characteristics of the cpu.
Implement the handler for this new H-Call which formulates its response based on the setting of the spapr_caps cap-cfpc, cap-sbbc and cap-ibs.
--- hw/ppc/spapr_hcall.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 1 + 2 files changed, 59 insertions(+)
hw/ppc/spapr_hcall.c +58 -0
@@ -1655,6 +1655,60 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,return H_SUCCESS ; } +static target_ulong h_get_cpu_characteristics (PowerPCCPU *cpu, +sPAPRMachineState *spapr, +target_ulong opcode, +target_ulong *args) +{ +uint64_t characteristics =H_CPU_CHAR_HON_BRANCH_HINTS & + ~H_CPU_CHAR_THR_RECONF_TRIG ; +uint64_t behaviour =H_CPU_BEHAV_FAVOUR_SECURITY ; +uint8_t safe_cache =spapr_get_cap (spapr,SPAPR_CAP_CFPC ); +uint8_t safe_bounds_check =spapr_get_cap (spapr,SPAPR_CAP_SBBC ); +uint8_t safe_indirect_branch =spapr_get_cap (spapr,SPAPR_CAP_IBS ); + +switch (safe_cache) { +case SPAPR_CAP_WORKAROUND : + characteristics |=H_CPU_CHAR_L1D_FLUSH_ORI30 ; + characteristics |=H_CPU_CHAR_L1D_FLUSH_TRIG2 ; + characteristics |=H_CPU_CHAR_L1D_THREAD_PRIV ; + behaviour |=H_CPU_BEHAV_L1D_FLUSH_PR ; +break ; +case SPAPR_CAP_FIXED : +break ; +default :/* broken */ +assert (safe_cache ==SPAPR_CAP_BROKEN ); + behaviour |=H_CPU_BEHAV_L1D_FLUSH_PR ; +break ; + } + +switch (safe_bounds_check) { +case SPAPR_CAP_WORKAROUND : + characteristics |=H_CPU_CHAR_SPEC_BAR_ORI31 ; + behaviour |=H_CPU_BEHAV_BNDS_CHK_SPEC_BAR ; +break ; +case SPAPR_CAP_FIXED : +break ; +default :/* broken */ +assert (safe_bounds_check ==SPAPR_CAP_BROKEN ); + behaviour |=H_CPU_BEHAV_BNDS_CHK_SPEC_BAR ; +break ; + } + +switch (safe_indirect_branch) { +case SPAPR_CAP_FIXED : + characteristics |=H_CPU_CHAR_BCCTRL_SERIALISED ; +default :/* broken */ +assert (safe_indirect_branch ==SPAPR_CAP_BROKEN ); +break ; + } + + args[0 ] = characteristics; + args[1 ] = behaviour; + +return H_SUCCESS ; +} +static spapr_hcall_fn papr_hypercall_table[(MAX_HCALL_OPCODE /4 ) +1 ];static spapr_hcall_fn kvmppc_hypercall_table[KVMPPC_HCALL_MAX -KVMPPC_HCALL_BASE +1 ];
@@ -1734,6 +1788,10 @@ static void hypercall_register_types(void)spapr_register_hypercall (H_INVALIDATE_PID , h_invalidate_pid);spapr_register_hypercall (H_REGISTER_PROC_TBL , h_register_process_table); +/* hcall-get-cpu-characteristics */ +spapr_register_hypercall (H_GET_CPU_CHARACTERISTICS , + h_get_cpu_characteristics); +/* "debugger" hcalls (also used by SLOF). Note: We do -not- differenciate * here between the "CI" and the "CACHE" variants, they will use whatever * mapping attributes qemu is using. When using KVM, the kernel will
include/hw/ppc/spapr.h +1 -0
@@ -404,6 +404,7 @@ struct sPAPRMachineState {#define H_GET_HCA_INFO 0x1B8#define H_GET_PERF_COUNT 0x1BC#define H_MANAGE_TRACE 0x1C0 +#define H_GET_CPU_CHARACTERISTICS 0x1C8#define H_FREE_LOGICAL_LAN_BUFFER 0x1D4#define H_QUERY_INT_STATE 0x1E4#define H_POLL_PENDING 0x1D8
Signature · 1 line
2.11.0
Quoting Michael Roth (2018-02-06 13:14:21)
Quoted 10 lines
Hi everyone,
The following new patches are queued for QEMU stable v2.11.1:
https://github.com/mdroth/qemu/commits/stable-2.11-staging
The release is planned for 2017-02-14:
Quoted 8 lines
Please respond here or CC [email protected] on any patches you think should be included in the release.
Of particular importance would be any feedback on the various QEMU patches relating to Spectre/Meltdown mitigation. The current tree has what I understand to be the QEMU components required for x86, s390, and pseries, but feedback/confirmation from the various authors would be greatly appreciated.
Thank you for the responses/suggestions. The following additional patches have been queued for the release and pushed to:
https://github.com/mdroth/qemu/commits/stable-2.11-staging
spapr: add missing break in h_get_cpu_characteristics() (Greg Kurz)
vga: check the validation of memory addr when draw text (linzhecheng)
input: fix memory leak (linzhecheng)
ui: correctly advance output buffer when writing SASL data (Daniel P. Berrangé)
ui: avoid sign extension using client width/height (Daniel P. Berrange)
ui: mix misleading comments & return types of VNC I/O helper methods (Daniel P. Berrange)
ui: add trace events related to VNC client throttling (Daniel P. Berrange)
ui: place a hard cap on VNC server output buffer size (Daniel P. Berrange)
ui: fix VNC client throttling when forced update is requested (Daniel P. Berrange)
ui: fix VNC client throttling when audio capture is active (Daniel P. Berrange)
ui: refactor code for determining if an update should be sent to the client (Daniel P. Berrange)
ui: correctly reset framebuffer update state after processing dirty regions (Daniel P. Berrange)
ui: introduce enum to track VNC client framebuffer update request state (Daniel P. Berrange)
ui: track how much decoded data we consumed when doing SASL encoding (Daniel P. Berrange)
ui: avoid pointless VNC updates if framebuffer isn't dirty (Daniel P. Berrange)
ui: remove redundant indentation in vnc_client_update (Daniel P. Berrange)
ui: remove unreachable code in vnc_update_client (Daniel P. Berrange)
ui: remove 'sync' parameter from vnc_update_client (Daniel P. Berrange)
migration: incoming postcopy advise sanity checks (Greg Kurz)
target/sh4: add missing tcg_temp_free() in _decode_opc() (Philippe Mathieu-Daudé) migration/savevm.c: set MAX_VM_CMD_PACKAGED_SIZE to 1ul << 32 (Daniel Henrique Barboza)
migration: Recover block devices if failure in device state (Dr. David Alan Gilbert)
migration: Don't leak IO channels (Ross Lagerwall)
s390x/sclp: fix event mask handling (Christian Borntraeger)
memory: set ioeventfd_update_pending after address_space_update_ioeventfds (linzhecheng)
Quoted 205 lines
Thanks!
----------------------------------------------------------------
The following changes since commit
0a0dc59d27527b78a195c2d838d28b7b49e5a639:Update version for v2.11.0 release (2017-12-13 14:31:09 +0000)
are available in the git repository at:
git://github.com/mdroth/qemu.gitstable-2.11-stagingfor you to fetch changes up to
ed8b4ecc68d6bfe98000b08d649049d0c1174c11:target/ppc/spapr: Add H-Call
H_GET_CPU_CHARACTERISTICS(2018-02-05 19:07:38 -0600)----------------------------------------------------------------
Alex Bennée (1):
target/sh4: fix TCG leak during gusa sequenceAlex Williamson (1):
vfio: Fix vfio-kvm group registrationChristian Borntraeger (2):
s390x/kvm: Handle bpb feature s390x/kvm: provide stfle.81Claudio Imbrenda (1):
s390x: fix storage attributes migration for non-small guestsCornelia Huck (1):
linux-headers: updateCédric Le Goater (1):
target/ppc: introduce thePPC_BIT()macroDavid Gibson (7):
spapr: Add pseries-2.12 machine type
spapr: Capabilities infrastructure
spapr: Treat Hardware Transactional Memory (HTM) as an optional capability
spapr: Validate capabilities on migration
target/ppc: Clean up probing of VMX, VSX and DFP availability on KVM
spapr: Handle VMX/VSX presence as an spapr capability flag
spapr: Handle Decimal Floating Point (DFP) as an optional capabilityEduardo Habkost (5):
i386: ChangeX86CPUDefinition::model_idto const char*
i386: Add spec-ctrl CPUID bit
i386: AddFEAT_8000_0008_EBXCPUID feature word
i386: Add new -IBRS versions of Intel CPU models
i386: Add EPYC-IBPB CPU modelEric Auger (1):
linux-headers: update to 4.15-rc1Fam Zheng (3):
block: Open backing image in force share mode for size probe
osdep: Retry SETLK upon EINTR
usb-storage: Fix share-rw option parsingGreg Kurz (2):
spapr_pci: fix MSI/MSIX selection
spapr: fix device tree properties when using compatibility modeJay Zhou (1):
vhost: remove assertion to prevent crashJose Ricardo Ziviani (1):
ppc: Change Power9 compat table to support at most 8 threads/coreKevin Wolf (2):
block: Makebdrv_drain_invoke()recursive
block: Call .drain_begin only once inbdrv_drain_all_begin()Laurent Vivier (1):
spapr: don't initialize PATB entry if max-cpu-compat < power9Marcel Apfelbaum (1):
hw/pci-bridge: fix QEMU crash because of pcie-root-portMarkus Armbruster (1):
qemu-options: Remove stray colons from output of --helpMichael S. Tsirkin (1):
virtio_error: don't invoke status callbacksMurilo Opsfelder Araujo (1):
block/nbd: fix segmentation fault when .desc is not null-terminatedPaolo Bonzini (2):
qemu-pr-helper: miscellaneous fixes
i386: Add support forSPEC_CTRLMSRPeter Lieven (1):
block/iscsi: dont leave allocmap in an invalid state on UNMAP failurePeter Maydell (8):
target/i386: Fix handling of VEX prefixes hw/intc/arm_gicv3: Make reserved register addresses RAZ/WI hw/intc/arm_gic: reserved register addresses are RAZ/WI hw/sd/pl181: Reset SD card on controller reset hw/sd/milkymist-memcard: Reset SD card on controller reset hw/sd/ssi-sd: Reset SD card on controller reset
linux-user: Fix locking order infork_start()linux-user/signal.c: Rename MC_* definesStefan Hajnoczi (1):
scsi-disk: release AioContext in unaligned WRITE SAME caseSuraj Jitindar Singh (8):
hw/ppc/spapr_caps: Reworkspapr_capsto use uint8 internal representation target/ppc/spapr_caps: Add macro to generatespapr_capsmigration vmstate target/ppc/kvm: Add cap_ppc_safe_[cache/bounds_check/indirect_branch] target/ppc/spapr_caps: Add support for tristatespapr_capabilitiestarget/ppc/spapr_caps: Add new tristate capsafe_cachetarget/ppc/spapr_caps: Add new tristate capsafe_bounds_checktarget/ppc/spapr_caps: Add new tristate capsafe_indirect_branchtarget/ppc/spapr: Add H-CallH_GET_CPU_CHARACTERISTICSblock.c | 3 +- block/io.c | 13 +- block/iscsi.c | 8 +- block/nbd.c | 1 + hw/intc/arm_gic.c | 5 +- hw/intc/arm_gicv3_dist.c | 13 + hw/intc/arm_gicv3_its_common.c | 8 +- hw/intc/arm_gicv3_redist.c | 13 + hw/pci-bridge/gen_pcie_root_port.c | 7 +- hw/ppc/Makefile.objs | 2 +- hw/ppc/spapr.c | 130 ++++-- hw/ppc/spapr_caps.c | 443 ++++++++++++++++++++ hw/ppc/spapr_cpu_core.c | 7 + hw/ppc/spapr_hcall.c | 58 +++ hw/ppc/spapr_pci.c | 61 ++- hw/s390x/s390-stattrib-kvm.c | 4 +- hw/scsi/scsi-bus.c | 9 +- hw/scsi/scsi-disk.c | 1 + hw/sd/milkymist-memcard.c | 4 + hw/sd/pl181.c | 4 + hw/sd/ssi-sd.c | 25 +- hw/usb/dev-storage.c | 3 +- hw/vfio/common.c | 1 + hw/virtio/vhost-user.c | 5 +- hw/virtio/virtio.c | 2 +- include/hw/compat.h | 2 + include/hw/ppc/spapr.h | 74 ++++ include/hw/scsi/scsi.h | 1 + include/scsi/utils.h | 6 +- include/standard-headers/asm-s390/virtio-ccw.h | 5 +- include/standard-headers/asm-x86/hyperv.h | 394 +----------------- include/standard-headers/linux/input-event-codes.h | 2 + include/standard-headers/linux/input.h | 1 + include/standard-headers/linux/pci_regs.h | 45 +- linux-headers/asm-arm/kvm.h | 8 + linux-headers/asm-arm/kvm_para.h | 1 + linux-headers/asm-arm/unistd.h | 2 + linux-headers/asm-arm64/kvm.h | 8 + linux-headers/asm-arm64/unistd.h | 1 + linux-headers/asm-powerpc/epapr_hcalls.h | 1 + linux-headers/asm-powerpc/kvm.h | 26 ++ linux-headers/asm-powerpc/kvm_para.h | 1 + linux-headers/asm-powerpc/unistd.h | 1 + linux-headers/asm-s390/kvm.h | 10 +- linux-headers/asm-s390/kvm_para.h | 5 +- linux-headers/asm-s390/unistd.h | 4 +- linux-headers/asm-x86/kvm.h | 1 + linux-headers/asm-x86/kvm_para.h | 2 +- linux-headers/asm-x86/unistd.h | 1 + linux-headers/linux/kvm.h | 10 +- linux-headers/linux/kvm_para.h | 1 + linux-headers/linux/psci.h | 1 + linux-headers/linux/userfaultfd.h | 1 + linux-headers/linux/vfio.h | 1 + linux-headers/linux/vfio_ccw.h | 1 + linux-headers/linux/vhost.h | 1 + linux-user/main.c | 4 +- linux-user/signal.c | 118 +++--- qemu-options-wrapper.h | 2 +- qemu-options.hx | 27 +- scripts/hxtool | 3 +- scsi/qemu-pr-helper.c | 30 +- scsi/utils.c | 10 + target/i386/cpu.c | 455 ++++++++++++++++++++- target/i386/cpu.h | 7 + target/i386/kvm.c | 14 + target/i386/machine.c | 20 + target/i386/translate.c | 2 +- target/ppc/compat.c | 9 +- target/ppc/cpu.h | 105 ++--- target/ppc/kvm.c | 85 +++- target/ppc/kvm_ppc.h | 20 +- target/s390x/cpu.c | 1 + target/s390x/cpu.h | 1 + target/s390x/cpu_features.c | 2 + target/s390x/cpu_features_def.h | 2 + target/s390x/gen-features.c | 2 + target/s390x/kvm.c | 14 + target/s390x/machine.c | 17 + target/sh4/translate.c | 2 +- util/osdep.c | 4 +- 81 files changed, 1746 insertions(+), 658 deletions(-) create mode 100644 hw/ppc/spapr_caps.c