From nobody Mon Feb 9 20:46:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1574180636; cv=none; d=zoho.com; s=zohoarc; b=fhZvalBbVI2QUcOJ0w9DR+0ezDuhPp2o8jHNH59lj7slmVi02uDwLDUTkqxnBKNjNtsUSNLeXoCDNP8yVEwbZXkVAHo1BW52E4cigBwLTsFBQNBy7HkeEXfAHFc0GryS9OzgXCBqz39GCoCMRM7gWU8MxixIrpMZViP6I0ayC5E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574180636; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=x/7dL5GKaLKKTQGfreBczzCpIjJHYavx06Q35HIG390=; b=oKQ9UvI48oJlmSr7JBOuE6fA0PtgBmJ2sxMch8xkIWQEFbmkGi1iMMEFXujJrxYA17EsWGOsHP/AIFLiUtV1svyM1YRhL49GphxA4e2MLSV57Ypa6h6/ikynD7k9aPFpdZqN4CHkU1xGt9i8MM/BhvvK/9u7aegWrdFDC2JCe28= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574180636229116.61112687517641; Tue, 19 Nov 2019 08:23:56 -0800 (PST) Received: from localhost ([::1]:47166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iX6IE-00032p-78 for importer@patchew.org; Tue, 19 Nov 2019 11:23:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60751) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iX63t-0001y2-88 for qemu-devel@nongnu.org; Tue, 19 Nov 2019 11:09:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iX63r-00068B-U8 for qemu-devel@nongnu.org; Tue, 19 Nov 2019 11:09:05 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:56265) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iX63r-00067d-NS for qemu-devel@nongnu.org; Tue, 19 Nov 2019 11:09:03 -0500 Received: by mail-wm1-x335.google.com with SMTP id b11so3787858wmb.5 for ; Tue, 19 Nov 2019 08:09:03 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id n13sm3442203wmi.25.2019.11.19.08.09.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Nov 2019 08:09:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=x/7dL5GKaLKKTQGfreBczzCpIjJHYavx06Q35HIG390=; b=TCf3KC0qFWAh0xKFRO1aICnowVi48ggU3kqnGK086BL9n8CxtURNgl33MjgnWfcCfS 11IdGh/KNEzM1Ex2dcIEaJxlbMcgq94DL6fRsI93VYBQp29SsVCqKm/RIYmqi65CwYcF Pkre4xgIisl53+qcgLCjnsKunoVtr4lRYIq3wShUGaGdacc10ZwgNZHS2ZkHhIDGtEup 2VomiIS4/sOdDXppw4TkVFZdKp6ZvHTSb9kEkWSuYafZFJ/yZqEBY44QWSyUY8s1Qxir LT0lPQVB/prsSzp2wC9ov+lx55hLmBP2BNBBp0KDcCcVzMRNcZ1Fjx85Zc6kdTMwqZ4G quGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=x/7dL5GKaLKKTQGfreBczzCpIjJHYavx06Q35HIG390=; b=OuezyzA277/kjf9YGpCu01E5rCblh0KeJra6v4jrPliu33UQBNaAs2o5AeAnytMid6 4kmPhVGolzcF7ipLJI0PJn3qDvTO8rIqhBxeiZrqQnc03FKfsxksXm23zpIgP4B7364n oSO378pcQ8tDE8oISMAxZY4nCurGvtMt9ON/tuzUmimeo6gDi8ZuA/f6B/AEx/8Zshe6 s2sXLhbrXQEfv1PVbNpyVcdXrE6duhaJYemuYC7biXyfuJ1H0tReIVNDpn95d53bdMGb S+mt3RqWed2xtUkd6/B7FP4MohUr+Ag2Noun7BN1x/7q3jnmSn2gaxDbp6DAm/1YH7rO o8gQ== X-Gm-Message-State: APjAAAUUWFT1cZzA5g5Jsv0vY2xBdFB7TQbgA0z3fiJCzECmjG8Brqus Ocm2dTWTIcpHwUo4lerQwXuzpPxa X-Google-Smtp-Source: APXvYqwQehVMicSYylTIpO1o1FBNKYcTaIYZYtkjBXfK9aqFrSoKcoEKuYZrZ6X04o21HnedQw/1Sg== X-Received: by 2002:a1c:1b86:: with SMTP id b128mr4551301wmb.127.1574179742270; Tue, 19 Nov 2019 08:09:02 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 09/12] hw/i386: Move save_tsc_khz from PCMachineClass to X86MachineClass Date: Tue, 19 Nov 2019 17:08:45 +0100 Message-Id: <1574179728-35535-10-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1574179728-35535-1-git-send-email-pbonzini@redhat.com> References: <1574179728-35535-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::335 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Liam Merwick Attempting to migrate a VM using the microvm machine class results in the s= ource QEMU aborting with the following message/backtrace: target/i386/machine.c:955:tsc_khz_needed: Object 0x555556608fa0 is not an instance of type generic-pc-machine abort() object_class_dynamic_cast_assert() vmstate_save_state_v() vmstate_save_state() vmstate_save() qemu_savevm_state_complete_precopy() migration_thread() migration_thread() migration_thread() qemu_thread_start() start_thread() clone() The access to the machine class returned by MACHINE_GET_CLASS() in tsc_khz_needed() is crashing as it is trying to dereference a different type of machine class object (TYPE_PC_MACHINE) to that of this microVM. This can be resolved by extending the changes in the following commit f0bb276bf8d5 ("hw/i386: split PCMachineState deriving X86MachineState from = it") and moving the save_tsc_khz field in PCMachineClass to X86MachineClass. Fixes: f0bb276bf8d5 ("hw/i386: split PCMachineState deriving X86MachineStat= e from it") Signed-off-by: Liam Merwick Reviewed-by: Darren Kenny Message-Id: <1574075605-25215-1-git-send-email-liam.merwick@oracle.com> Reviewed-by: Sergio Lopez Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 1 - hw/i386/pc_piix.c | 4 ++-- hw/i386/pc_q35.c | 4 ++-- hw/i386/x86.c | 1 + include/hw/i386/pc.h | 2 -- include/hw/i386/x86.h | 2 ++ target/i386/machine.c | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 96715f8..ac08e63 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2195,7 +2195,6 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) /* BIOS ACPI tables: 128K. Other BIOS datastructures: less than 4K rep= orted * to be used at the moment, 32K should be enough for a while. */ pcmc->acpi_data_size =3D 0x20000 + 0x8000; - pcmc->save_tsc_khz =3D true; pcmc->linuxboot_dma_enabled =3D true; pcmc->pvh_enabled =3D true; assert(!mc->get_hotplug_handler); diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 849ee12..1bd70d1 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -567,10 +567,10 @@ DEFINE_I440FX_MACHINE(v2_6, "pc-i440fx-2.6", NULL, =20 static void pc_i440fx_2_5_machine_options(MachineClass *m) { - PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); + X86MachineClass *x86mc =3D X86_MACHINE_CLASS(m); =20 pc_i440fx_2_6_machine_options(m); - pcmc->save_tsc_khz =3D false; + x86mc->save_tsc_khz =3D false; m->legacy_fw_cfg_order =3D 1; compat_props_add(m->compat_props, hw_compat_2_5, hw_compat_2_5_len); compat_props_add(m->compat_props, pc_compat_2_5, pc_compat_2_5_len); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index d51f524..385e5cf 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -508,10 +508,10 @@ DEFINE_Q35_MACHINE(v2_6, "pc-q35-2.6", NULL, =20 static void pc_q35_2_5_machine_options(MachineClass *m) { - PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); + X86MachineClass *x86mc =3D X86_MACHINE_CLASS(m); =20 pc_q35_2_6_machine_options(m); - pcmc->save_tsc_khz =3D false; + x86mc->save_tsc_khz =3D false; m->legacy_fw_cfg_order =3D 1; compat_props_add(m->compat_props, hw_compat_2_5, hw_compat_2_5_len); compat_props_add(m->compat_props, pc_compat_2_5, pc_compat_2_5_len); diff --git a/hw/i386/x86.c b/hw/i386/x86.c index fd84b23..394edc2 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -763,6 +763,7 @@ static void x86_machine_class_init(ObjectClass *oc, voi= d *data) mc->get_default_cpu_node_id =3D x86_get_default_cpu_node_id; mc->possible_cpu_arch_ids =3D x86_possible_cpu_arch_ids; x86mc->compat_apic_id_mode =3D false; + x86mc->save_tsc_khz =3D true; nc->nmi_monitor_handler =3D x86_nmi; =20 object_class_property_add(oc, X86_MACHINE_MAX_RAM_BELOW_4G, "size", diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index e6fa841..1f86eba 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -116,8 +116,6 @@ typedef struct PCMachineClass { bool enforce_aligned_dimm; bool broken_reserved_end; =20 - /* TSC rate migration: */ - bool save_tsc_khz; /* generate legacy CPU hotplug AML */ bool legacy_cpu_hotplug; =20 diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h index 82d09fd..4b84917 100644 --- a/include/hw/i386/x86.h +++ b/include/hw/i386/x86.h @@ -30,6 +30,8 @@ typedef struct { =20 /*< public >*/ =20 + /* TSC rate migration: */ + bool save_tsc_khz; /* Enables contiguous-apic-ID mode */ bool compat_apic_id_mode; } X86MachineClass; diff --git a/target/i386/machine.c b/target/i386/machine.c index 6481f84..7bdeb78 100644 --- a/target/i386/machine.c +++ b/target/i386/machine.c @@ -988,8 +988,8 @@ static bool tsc_khz_needed(void *opaque) X86CPU *cpu =3D opaque; CPUX86State *env =3D &cpu->env; MachineClass *mc =3D MACHINE_GET_CLASS(qdev_get_machine()); - PCMachineClass *pcmc =3D PC_MACHINE_CLASS(mc); - return env->tsc_khz && pcmc->save_tsc_khz; + X86MachineClass *x86mc =3D X86_MACHINE_CLASS(mc); + return env->tsc_khz && x86mc->save_tsc_khz; } =20 static const VMStateDescription vmstate_tsc_khz =3D { --=20 1.8.3.1