From nobody Wed Nov 19 04:32:53 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.43 as permitted sender) client-ip=209.85.128.43; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f43.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.43 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1614357219; cv=none; d=zohomail.com; s=zohoarc; b=kakiPWzGtnZKOZxvDhmVc3r1IOstwUbNqYiwZDSvt5Bg5TRS7zpi6nLfmu3GWPSg9ZaMR8qKdq8ELKQdPLr0H1TeFwIDNWkSLLZiB5nAgF9R3USWC3xPsd/llkndr93VG9n0UGOsHGjTfmesSo+IUC8sOJJb3770R/dL4e+zhcA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614357219; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yppSFDQsnap9fkQDMIB4LM/Hd6+rcDegPvCr9hlrbG4=; b=g7KJekmypf83XTvTI+undZKEaly4Rc5b20JbqkOqQ+BvtX6syJ5svxqceg+jV4QAjLEbGjJW1K+wWBIHgMKLd4eyr2PbX8yrvuGHY+ZBJFY2uBUoDf4oWf5C9XaVBZL6WfO3gvXclwsBSfnCt2ahi0hX8p6HW3Ya76KcPJ9mf0k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.43 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by mx.zohomail.com with SMTPS id 1614357219137223.01495935114554; Fri, 26 Feb 2021 08:33:39 -0800 (PST) Received: by mail-wm1-f43.google.com with SMTP id o16so8346467wmh.0 for ; Fri, 26 Feb 2021 08:33:38 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id i8sm15756579wry.90.2021.02.26.08.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Feb 2021 08:33:36 -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 :mime-version:content-transfer-encoding; bh=yppSFDQsnap9fkQDMIB4LM/Hd6+rcDegPvCr9hlrbG4=; b=RqsbZxiETkb9P1vuejki+clVSger/BhVc0Y+i01T/lyJFro47QMOYFEMQqeEX1LpL7 egUkAka5uPw2lBcHNJ0vmPvzX9kShILCt1LYd8Pc9NUFZF7PVRR9mU/2Ba6LPYuoFGiX 0QzMPnkIQ8Gipw3mRI7eJ5wJbatX3hOLnjEQwf7/+Ea9Hazd3VKiE3yb8f1F8053wia+ 8dVtdlIqd1a81+yFEZNVyrWfaC1WXzW0A1HUaR85voFyhcrK+7V6v7I6GBmEZphGFTaO SNXSDtatdL7TS9VV6VAY2aMOUueFGtwOyHf5y1DLVof1oYhLzgBmOalNvfEGE7DeiYIl 6cRQ== 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:mime-version:content-transfer-encoding; bh=yppSFDQsnap9fkQDMIB4LM/Hd6+rcDegPvCr9hlrbG4=; b=gSKjS+GoyMB2RVO0s9QY0xIF8UOUmKS+UmV9x0fgDD92LZocsFqH/ZtF4IRTuoBZjs cwG6po1LmzOYroJavL3XP8EfmbXYq5LKqJJqdpwLigQmqxtxo1mOHXZZAfOpa2ofHRrk SYF9WMxwHA1pfcruFDSki7xmnaEUXiZk2JlGMJTcCuzl9mvJ98XOfhFCPS7d2Jw+Ix8M ceg/aituIaAcskx4RTkvcOrc/xEEthtOEcbb8+FKpon3nEiBlTTUA2FI79KcpTcDfh9e o7pYLgbjlHKwepIufD0djifRvVprBVBKi9yYE/ChoCtVq+l1eYKGEA6Oa+mxg1EXoUkA fdFA== X-Gm-Message-State: AOAM5338z20PmBXWOKjxLC/hrjt0yqYDMF6AYXchnlDqcKgC7hiiDqii jWaNE2oEb0LyH10CIj9e4i4= X-Google-Smtp-Source: ABdhPJyOK9RTuFTedODbjc7g1TL8cebAOnvvMApPg5J3vznBAKYuBzcDbmpndB9iBqkymNzHHyJROA== X-Received: by 2002:a1c:f409:: with SMTP id z9mr3633637wma.141.1614357217212; Fri, 26 Feb 2021 08:33:37 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Sarah Harris , Paolo Bonzini , Max Filippov , Yoshinori Sato , qemu-s390x@nongnu.org, Michael Rolnik , qemu-ppc@nongnu.org, Marek Vasut , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alistair Francis , Michael Walle , Guan Xuetao , Laurent Vivier , Anthony Green , Palmer Dabbelt , David Hildenbrand , qemu-riscv@nongnu.org, David Gibson , Peter Maydell , Cornelia Huck , Jiaxun Yang , Richard Henderson , Chris Wulff , "Michael S. Tsirkin" , Aurelien Jarno , Aleksandar Rikalo , Sagar Karandikar , Claudio Fontana , Thomas Huth , Artyom Tarasenko , Greg Kurz , Stafford Horne , Bastian Koppelmann , Mark Cave-Ayland , Marcel Apfelbaum , "Edgar E. Iglesias" Subject: [PATCH 11/16] cpu: Move CPUClass::write_elf* to CPUSystemOperations Date: Fri, 26 Feb 2021 17:32:22 +0100 Message-Id: <20210226163227.4097950-12-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210226163227.4097950-1-f4bug@amsat.org> References: <20210226163227.4097950-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The write_elf*() handlers are used to dump vmcore images. This feature is only meaningful for system emulation. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/core/cpu.h | 41 +++++++++++++++++++-------------- hw/core/cpu.c | 16 ++++++------- target/arm/cpu.c | 4 ++-- target/i386/cpu.c | 8 +++---- target/s390x/cpu.c | 2 +- target/ppc/translate_init.c.inc | 4 ++-- 6 files changed, 41 insertions(+), 34 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 87186e85d44..e8c2e9af3bb 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -89,6 +89,30 @@ typedef struct CPUSystemOperations { * GUEST_PANICKED events. */ GuestPanicInformation* (*get_crash_info)(CPUState *cpu); + /** + * @write_elf32_note: Callback for writing a CPU-specific ELF note to a + * 32-bit VM coredump. + */ + int (*write_elf32_note)(WriteCoreDumpFunction f, CPUState *cpu, + int cpuid, void *opaque); + /** + * @write_elf64_note: Callback for writing a CPU-specific ELF note to a + * 64-bit VM coredump. + */ + int (*write_elf64_note)(WriteCoreDumpFunction f, CPUState *cpu, + int cpuid, void *opaque); + /** + * @write_elf32_qemunote: Callback for writing a CPU- and QEMU-specifi= c ELF + * note to a 32-bit VM coredump. + */ + int (*write_elf32_qemunote)(WriteCoreDumpFunction f, CPUState *cpu, + void *opaque); + /** + * @write_elf64_qemunote: Callback for writing a CPU- and QEMU-specifi= c ELF + * note to a 64-bit VM coredump. + */ + int (*write_elf64_qemunote)(WriteCoreDumpFunction f, CPUState *cpu, + void *opaque); /** * @virtio_is_big_endian: Callback to return %true if a CPU which supp= orts * runtime configurable endianness is currently big-endian. @@ -133,14 +157,6 @@ typedef struct CPUSystemOperations { * a memory access with the specified memory transaction attributes. * @gdb_read_register: Callback for letting GDB read a register. * @gdb_write_register: Callback for letting GDB write a register. - * @write_elf64_note: Callback for writing a CPU-specific ELF note to a - * 64-bit VM coredump. - * @write_elf32_qemunote: Callback for writing a CPU- and QEMU-specific ELF - * note to a 32-bit VM coredump. - * @write_elf32_note: Callback for writing a CPU-specific ELF note to a - * 32-bit VM coredump. - * @write_elf32_qemunote: Callback for writing a CPU- and QEMU-specific ELF - * note to a 32-bit VM coredump. * @gdb_num_core_regs: Number of core registers accessible to GDB. * @gdb_core_xml_file: File name for core registers GDB XML description. * @gdb_stop_before_watchpoint: Indicates whether GDB expects the CPU to s= top @@ -184,15 +200,6 @@ struct CPUClass { int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg); int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg); =20 - int (*write_elf64_note)(WriteCoreDumpFunction f, CPUState *cpu, - int cpuid, void *opaque); - int (*write_elf64_qemunote)(WriteCoreDumpFunction f, CPUState *cpu, - void *opaque); - int (*write_elf32_note)(WriteCoreDumpFunction f, CPUState *cpu, - int cpuid, void *opaque); - int (*write_elf32_qemunote)(WriteCoreDumpFunction f, CPUState *cpu, - void *opaque); - const char *gdb_core_xml_file; gchar * (*gdb_arch_name)(CPUState *cpu); const char * (*gdb_get_dynamic_xml)(CPUState *cpu, const char *xmlname= ); diff --git a/hw/core/cpu.c b/hw/core/cpu.c index ddf5635d87b..3dc8faf6086 100644 --- a/hw/core/cpu.c +++ b/hw/core/cpu.c @@ -151,10 +151,10 @@ int cpu_write_elf32_qemunote(WriteCoreDumpFunction f,= CPUState *cpu, { CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 - if (!cc->write_elf32_qemunote) { + if (!cc->system_ops.write_elf32_qemunote) { return 0; } - return (*cc->write_elf32_qemunote)(f, cpu, opaque); + return (*cc->system_ops.write_elf32_qemunote)(f, cpu, opaque); } =20 int cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cpu, @@ -162,10 +162,10 @@ int cpu_write_elf32_note(WriteCoreDumpFunction f, CPU= State *cpu, { CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 - if (!cc->write_elf32_note) { + if (!cc->system_ops.write_elf32_note) { return -1; } - return (*cc->write_elf32_note)(f, cpu, cpuid, opaque); + return (*cc->system_ops.write_elf32_note)(f, cpu, cpuid, opaque); } =20 int cpu_write_elf64_qemunote(WriteCoreDumpFunction f, CPUState *cpu, @@ -173,10 +173,10 @@ int cpu_write_elf64_qemunote(WriteCoreDumpFunction f,= CPUState *cpu, { CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 - if (!cc->write_elf64_qemunote) { + if (!cc->system_ops.write_elf64_qemunote) { return 0; } - return (*cc->write_elf64_qemunote)(f, cpu, opaque); + return (*cc->system_ops.write_elf64_qemunote)(f, cpu, opaque); } =20 int cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cpu, @@ -184,10 +184,10 @@ int cpu_write_elf64_note(WriteCoreDumpFunction f, CPU= State *cpu, { CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 - if (!cc->write_elf64_note) { + if (!cc->system_ops.write_elf64_note) { return -1; } - return (*cc->write_elf64_note)(f, cpu, cpuid, opaque); + return (*cc->system_ops.write_elf64_note)(f, cpu, cpuid, opaque); } =20 static int cpu_common_gdb_read_register(CPUState *cpu, GByteArray *buf, in= t reg) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 3cbb17a5879..4941a651e64 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2301,8 +2301,8 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) cc->asidx_from_attrs =3D arm_asidx_from_attrs; cc->system_ops.vmsd =3D &vmstate_arm_cpu; cc->system_ops.virtio_is_big_endian =3D arm_cpu_virtio_is_big_endian; - cc->write_elf64_note =3D arm_cpu_write_elf64_note; - cc->write_elf32_note =3D arm_cpu_write_elf32_note; + cc->system_ops.write_elf64_note =3D arm_cpu_write_elf64_note; + cc->system_ops.write_elf32_note =3D arm_cpu_write_elf32_note; #endif cc->gdb_num_core_regs =3D 26; cc->gdb_core_xml_file =3D "arm-core.xml"; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 9692843256c..c34d41d4c79 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7422,10 +7422,10 @@ static void x86_cpu_common_class_init(ObjectClass *= oc, void *data) cc->get_memory_mapping =3D x86_cpu_get_memory_mapping; cc->get_phys_page_attrs_debug =3D x86_cpu_get_phys_page_attrs_debug; cc->system_ops.get_crash_info =3D x86_cpu_get_crash_info; - cc->write_elf64_note =3D x86_cpu_write_elf64_note; - cc->write_elf64_qemunote =3D x86_cpu_write_elf64_qemunote; - cc->write_elf32_note =3D x86_cpu_write_elf32_note; - cc->write_elf32_qemunote =3D x86_cpu_write_elf32_qemunote; + cc->system_ops.write_elf64_note =3D x86_cpu_write_elf64_note; + cc->system_ops.write_elf64_qemunote =3D x86_cpu_write_elf64_qemunote; + cc->system_ops.write_elf32_note =3D x86_cpu_write_elf32_note; + cc->system_ops.write_elf32_qemunote =3D x86_cpu_write_elf32_qemunote; cc->system_ops.vmsd =3D &vmstate_x86_cpu; #endif /* !CONFIG_USER_ONLY */ =20 diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index f9107cb7179..dcfbb7832e1 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -519,7 +519,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) cc->get_phys_page_debug =3D s390_cpu_get_phys_page_debug; cc->system_ops.vmsd =3D &vmstate_s390_cpu; cc->system_ops.get_crash_info =3D s390_cpu_get_crash_info; - cc->write_elf64_note =3D s390_cpu_write_elf64_note; + cc->system_ops.write_elf64_note =3D s390_cpu_write_elf64_note; #endif cc->disas_set_info =3D s390_cpu_disas_set_info; cc->gdb_num_core_regs =3D S390_NUM_CORE_REGS; diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.= inc index 2e5c272190b..b1ac3291be1 100644 --- a/target/ppc/translate_init.c.inc +++ b/target/ppc/translate_init.c.inc @@ -10888,8 +10888,8 @@ static void ppc_cpu_class_init(ObjectClass *oc, voi= d *data) cc->system_ops.vmsd =3D &vmstate_ppc_cpu; #endif #if defined(CONFIG_SOFTMMU) - cc->write_elf64_note =3D ppc64_cpu_write_elf64_note; - cc->write_elf32_note =3D ppc32_cpu_write_elf32_note; + cc->system_ops.write_elf64_note =3D ppc64_cpu_write_elf64_note; + cc->system_ops.write_elf32_note =3D ppc32_cpu_write_elf32_note; #endif =20 cc->gdb_num_core_regs =3D 71; --=20 2.26.2