Skip to content

Commit

Permalink
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
Browse files Browse the repository at this point in the history
* Some hw/isa cleanups
* Fixes for x86 CPUID
* Cleanups for configure, hw/isa and x86

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmXPW5sUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroO1Mgf/USSqZxAyS1tyutpVslKmQjCyUiNW
# xEuHhAqoTz4Xg/8Q1J9aCcs2hdpBx2ULEQryUiTlH3LPLy3j9lGxMfg9Ma65mPVg
# KOSm/vfnw2VPXav8MJVNbm0gSI5fPmprRYgFi4TrkknmKnDo2TElrCG6Oe6LN/X+
# kiJD9K8PE+OE7xVhNDf7JAxUHt531oX7iM8p6JGGBYQdPOZ8rGf4K5PDrDxnHckG
# dbKHhqkbrSHaX/gu4q0ukgfIprs40ChYQ10vZ95mYyuWgIHOi51PciPmQ/qLPof0
# b/au08F0SpTE5cxx1Rk4cAuhP/PtzVln5lsSl9r9KzJ3Hcv6qnwXUU1nUg==
# =U+N2
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 16 Feb 2024 12:56:59 GMT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "pbonzini@redhat.com"
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full]
# gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>" [full]
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* tag 'for-upstream' of https://gitlab.com/bonzini/qemu:
  ci: Fix again build-previous-qemu
  usb: inline device creation functions
  target/i386: Generate an illegal opcode exception on cmp instructions with lock prefix
  i386: xen: fix compilation --without-default-devices
  configure: put all symlink creation together
  configure: do not create legacy symlinks
  smc37c669: remove useless is_enabled functions
  isa-superio: validate floppy.count value
  mips: remove unnecessary "select PTIMER"
  i386/cpuid: Move leaf 7 to correct group
  i386/cpuid: Remove subleaf constraint on CPUID leaf 1F
  i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F
  physmem: replace function name with __func__ in ram_block_discard_range()
  i386/pc: Drop pc_machine_kvm_type()
  target/i386: Add support of KVM_FEATURE_ASYNC_PF_VMEXIT for guest
  i386/cpu: Mask with XCR0/XSS mask for FEAT_XSAVE_XCR0_HI and FEAT_XSAVE_XSS_HI leafs
  i386/cpu: Clear FEAT_XSAVE_XSS_LO/HI leafs when CPUID_EXT_XSAVE is not available

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Feb 20, 2024
2 parents 8bef947 + 5f9beb5 commit 760b4dc
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 103 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.d/buildtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ build-previous-qemu:
before_script:
- export QEMU_PREV_VERSION="$(sed 's/\([0-9.]*\)\.[0-9]*/v\1.0/' VERSION)"
- git remote add upstream https://gitlab.com/qemu-project/qemu
- git fetch upstream $QEMU_PREV_VERSION
- git fetch upstream refs/tags/$QEMU_PREV_VERSION:refs/tags/$QEMU_PREV_VERSION
- git checkout $QEMU_PREV_VERSION
after_script:
- mv build build-previous
Expand Down
1 change: 1 addition & 0 deletions accel/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ config KVM
config XEN
bool
select FSDEV_9P if VIRTFS
select XEN_BUS
20 changes: 5 additions & 15 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,11 @@ for f in $LINKS ; do
fi
done

# use included Linux headers for KVM architectures
if test "$host_os" = "linux" && test -n "$linux_arch"; then
symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
fi

echo "# Automatically generated by configure - do not modify" > Makefile.prereqs

# Mac OS X ships with a broken assembler
Expand Down Expand Up @@ -1605,21 +1610,6 @@ echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
echo "MESON=$meson" >> $config_host_mak
echo "NINJA=$ninja" >> $config_host_mak
echo "EXESUF=$EXESUF" >> $config_host_mak

# use included Linux headers for KVM architectures
if test "$host_os" = "linux" && test -n "$linux_arch"; then
symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
fi

for target in $target_list; do
target_dir="$target"
target_name=$(echo $target | cut -d '-' -f 1)$EXESUF
case $target in
*-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
*) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
esac
done

if test "$default_targets" = "yes"; then
echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
fi
Expand Down
5 changes: 0 additions & 5 deletions hw/i386/pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1756,11 +1756,6 @@ static void pc_machine_initfn(Object *obj)
cxl_machine_init(obj, &pcms->cxl_devices_state);
}

int pc_machine_kvm_type(MachineState *machine, const char *kvm_type)
{
return 0;
}

static void pc_machine_reset(MachineState *machine, ShutdownCause reason)
{
CPUState *cs;
Expand Down
4 changes: 3 additions & 1 deletion hw/isa/isa-superio.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ static void isa_superio_realize(DeviceState *dev, Error **errp)
}

/* Floppy disc */
if (!k->floppy.is_enabled || k->floppy.is_enabled(sio, 0)) {
assert(k->floppy.count <= 1);
if (k->floppy.count &&
(!k->floppy.is_enabled || k->floppy.is_enabled(sio, 0))) {
isa = isa_new(TYPE_ISA_FDC);
d = DEVICE(isa);
if (k->floppy.get_iobase) {
Expand Down
18 changes: 0 additions & 18 deletions hw/isa/smc37c669-superio.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@

/* UARTs (compatible with NS16450 or PC16550) */

static bool is_serial_enabled(ISASuperIODevice *sio, uint8_t index)
{
return index < 2;
}

static uint16_t get_serial_iobase(ISASuperIODevice *sio, uint8_t index)
{
return index ? 0x2f8 : 0x3f8;
Expand All @@ -31,11 +26,6 @@ static unsigned int get_serial_irq(ISASuperIODevice *sio, uint8_t index)

/* Parallel port */

static bool is_parallel_enabled(ISASuperIODevice *sio, uint8_t index)
{
return index < 1;
}

static uint16_t get_parallel_iobase(ISASuperIODevice *sio, uint8_t index)
{
return 0x378;
Expand All @@ -53,11 +43,6 @@ static unsigned int get_parallel_dma(ISASuperIODevice *sio, uint8_t index)

/* Diskette controller (Software compatible with the Intel PC8477) */

static bool is_fdc_enabled(ISASuperIODevice *sio, uint8_t index)
{
return index < 1;
}

static uint16_t get_fdc_iobase(ISASuperIODevice *sio, uint8_t index)
{
return 0x3f0;
Expand All @@ -79,20 +64,17 @@ static void smc37c669_class_init(ObjectClass *klass, void *data)

sc->parallel = (ISASuperIOFuncs){
.count = 1,
.is_enabled = is_parallel_enabled,
.get_iobase = get_parallel_iobase,
.get_irq = get_parallel_irq,
.get_dma = get_parallel_dma,
};
sc->serial = (ISASuperIOFuncs){
.count = 2,
.is_enabled = is_serial_enabled,
.get_iobase = get_serial_iobase,
.get_irq = get_serial_irq,
};
sc->floppy = (ISASuperIOFuncs){
.count = 1,
.is_enabled = is_fdc_enabled,
.get_iobase = get_fdc_iobase,
.get_irq = get_fdc_irq,
.get_dma = get_fdc_dma,
Expand Down
23 changes: 0 additions & 23 deletions hw/usb/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,29 +329,6 @@ void usb_legacy_register(const char *typename, const char *usbdevice_name,
}
}

USBDevice *usb_new(const char *name)
{
return USB_DEVICE(qdev_new(name));
}

static USBDevice *usb_try_new(const char *name)
{
return USB_DEVICE(qdev_try_new(name));
}

bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp)
{
return qdev_realize_and_unref(&dev->qdev, &bus->qbus, errp);
}

USBDevice *usb_create_simple(USBBus *bus, const char *name)
{
USBDevice *dev = usb_new(name);

usb_realize_and_unref(dev, bus, &error_abort);
return dev;
}

static void usb_fill_port(USBPort *port, void *opaque, int index,
USBPortOps *ops, int speedmask)
{
Expand Down
3 changes: 0 additions & 3 deletions include/hw/i386/pc.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,12 @@ extern const size_t pc_compat_1_5_len;
extern GlobalProperty pc_compat_1_4[];
extern const size_t pc_compat_1_4_len;

int pc_machine_kvm_type(MachineState *machine, const char *vm_type);

#define DEFINE_PC_MACHINE(suffix, namestr, initfn, optsfn) \
static void pc_machine_##suffix##_class_init(ObjectClass *oc, void *data) \
{ \
MachineClass *mc = MACHINE_CLASS(oc); \
optsfn(mc); \
mc->init = initfn; \
mc->kvm_type = pc_machine_kvm_type; \
} \
static const TypeInfo pc_machine_type_##suffix = { \
.name = namestr TYPE_MACHINE_SUFFIX, \
Expand Down
27 changes: 24 additions & 3 deletions include/hw/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "qemu/iov.h"
#include "qemu/queue.h"
#include "qom/object.h"
#include "qapi/error.h"

/* Constants related to the USB / PCI interaction */
#define USB_SBRN 0x60 /* Serial Bus Release Number Register */
Expand Down Expand Up @@ -500,9 +501,6 @@ void usb_bus_release(USBBus *bus);
USBBus *usb_bus_find(int busnr);
void usb_legacy_register(const char *typename, const char *usbdevice_name,
USBDevice *(*usbdevice_init)(void));
USBDevice *usb_new(const char *name);
bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp);
USBDevice *usb_create_simple(USBBus *bus, const char *name);
USBDevice *usbdevice_create(const char *cmdline);
void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index,
USBPortOps *ops, int speedmask);
Expand Down Expand Up @@ -582,4 +580,27 @@ void usb_pcap_init(FILE *fp);
void usb_pcap_ctrl(USBPacket *p, bool setup);
void usb_pcap_data(USBPacket *p, bool setup);

static inline USBDevice *usb_new(const char *name)
{
return USB_DEVICE(qdev_new(name));
}

static inline USBDevice *usb_try_new(const char *name)
{
return USB_DEVICE(qdev_try_new(name));
}

static inline bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp)
{
return qdev_realize_and_unref(&dev->qdev, &bus->qbus, errp);
}

static inline USBDevice *usb_create_simple(USBBus *bus, const char *name)
{
USBDevice *dev = usb_new(name);

usb_realize_and_unref(dev, bus, &error_abort);
return dev;
}

#endif
38 changes: 17 additions & 21 deletions system/physmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -3495,16 +3495,15 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)
uint8_t *host_startaddr = rb->host + start;

if (!QEMU_PTR_IS_ALIGNED(host_startaddr, rb->page_size)) {
error_report("ram_block_discard_range: Unaligned start address: %p",
host_startaddr);
error_report("%s: Unaligned start address: %p",
__func__, host_startaddr);
goto err;
}

if ((start + length) <= rb->max_length) {
bool need_madvise, need_fallocate;
if (!QEMU_IS_ALIGNED(length, rb->page_size)) {
error_report("ram_block_discard_range: Unaligned length: %zx",
length);
error_report("%s: Unaligned length: %zx", __func__, length);
goto err;
}

Expand All @@ -3528,8 +3527,8 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)
* proper error message.
*/
if (rb->flags & RAM_READONLY_FD) {
error_report("ram_block_discard_range: Discarding RAM"
" with readonly files is not supported");
error_report("%s: Discarding RAM with readonly files is not"
" supported", __func__);
goto err;

}
Expand All @@ -3544,27 +3543,26 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)
* file.
*/
if (!qemu_ram_is_shared(rb)) {
warn_report_once("ram_block_discard_range: Discarding RAM"
warn_report_once("%s: Discarding RAM"
" in private file mappings is possibly"
" dangerous, because it will modify the"
" underlying file and will affect other"
" users of the file");
" users of the file", __func__);
}

ret = fallocate(rb->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
start, length);
if (ret) {
ret = -errno;
error_report("ram_block_discard_range: Failed to fallocate "
"%s:%" PRIx64 " +%zx (%d)",
rb->idstr, start, length, ret);
error_report("%s: Failed to fallocate %s:%" PRIx64 " +%zx (%d)",
__func__, rb->idstr, start, length, ret);
goto err;
}
#else
ret = -ENOSYS;
error_report("ram_block_discard_range: fallocate not available/file"
error_report("%s: fallocate not available/file"
"%s:%" PRIx64 " +%zx (%d)",
rb->idstr, start, length, ret);
__func__, rb->idstr, start, length, ret);
goto err;
#endif
}
Expand All @@ -3582,25 +3580,23 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)
}
if (ret) {
ret = -errno;
error_report("ram_block_discard_range: Failed to discard range "
error_report("%s: Failed to discard range "
"%s:%" PRIx64 " +%zx (%d)",
rb->idstr, start, length, ret);
__func__, rb->idstr, start, length, ret);
goto err;
}
#else
ret = -ENOSYS;
error_report("ram_block_discard_range: MADVISE not available"
"%s:%" PRIx64 " +%zx (%d)",
rb->idstr, start, length, ret);
error_report("%s: MADVISE not available %s:%" PRIx64 " +%zx (%d)",
__func__, rb->idstr, start, length, ret);
goto err;
#endif
}
trace_ram_block_discard_range(rb->idstr, host_startaddr, length,
need_madvise, need_fallocate, ret);
} else {
error_report("ram_block_discard_range: Overrun block '%s' (%" PRIu64
"/%zx/" RAM_ADDR_FMT")",
rb->idstr, start, length, rb->max_length);
error_report("%s: Overrun block '%s' (%" PRIu64 "/%zx/" RAM_ADDR_FMT")",
__func__, rb->idstr, start, length, rb->max_length);
}

err:
Expand Down
8 changes: 5 additions & 3 deletions target/i386/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
.feat_names = {
"kvmclock", "kvm-nopiodelay", "kvm-mmu", "kvmclock",
"kvm-asyncpf", "kvm-steal-time", "kvm-pv-eoi", "kvm-pv-unhalt",
NULL, "kvm-pv-tlb-flush", NULL, "kvm-pv-ipi",
NULL, "kvm-pv-tlb-flush", "kvm-asyncpf-vmexit", "kvm-pv-ipi",
"kvm-poll-control", "kvm-pv-sched-yield", "kvm-asyncpf-int", "kvm-msi-ext-dest-id",
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
Expand Down Expand Up @@ -6927,6 +6927,8 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu)
if (!(env->features[FEAT_1_ECX] & CPUID_EXT_XSAVE)) {
env->features[FEAT_XSAVE_XCR0_LO] = 0;
env->features[FEAT_XSAVE_XCR0_HI] = 0;
env->features[FEAT_XSAVE_XSS_LO] = 0;
env->features[FEAT_XSAVE_XSS_HI] = 0;
return;
}

Expand All @@ -6945,9 +6947,9 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu)
}

env->features[FEAT_XSAVE_XCR0_LO] = mask & CPUID_XSTATE_XCR0_MASK;
env->features[FEAT_XSAVE_XCR0_HI] = mask >> 32;
env->features[FEAT_XSAVE_XCR0_HI] = (mask & CPUID_XSTATE_XCR0_MASK) >> 32;
env->features[FEAT_XSAVE_XSS_LO] = mask & CPUID_XSTATE_XSS_MASK;
env->features[FEAT_XSAVE_XSS_HI] = mask >> 32;
env->features[FEAT_XSAVE_XSS_HI] = (mask & CPUID_XSTATE_XSS_MASK) >> 32;
}

/***** Steps involved on loading and filtering CPUID data
Expand Down
7 changes: 2 additions & 5 deletions target/i386/kvm/kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1914,6 +1914,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
}
case 0x1f:
if (env->nr_dies < 2) {
cpuid_i--;
break;
}
/* fallthrough */
Expand All @@ -1925,10 +1926,6 @@ int kvm_arch_init_vcpu(CPUState *cs)
break;
}

if (i == 0x1f && j == 64) {
break;
}

c->function = i;
c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
c->index = j;
Expand All @@ -1954,7 +1951,6 @@ int kvm_arch_init_vcpu(CPUState *cs)
c = &cpuid_data.entries[cpuid_i++];
}
break;
case 0x7:
case 0x12:
for (j = 0; ; j++) {
c->function = i;
Expand All @@ -1974,6 +1970,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
c = &cpuid_data.entries[cpuid_i++];
}
break;
case 0x7:
case 0x14:
case 0x1d:
case 0x1e: {
Expand Down

0 comments on commit 760b4dc

Please sign in to comment.