From nobody Tue Feb 10 07:43:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.208.51 as permitted sender) client-ip=209.85.208.51; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-f51.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.51 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1614697133; cv=none; d=zohomail.com; s=zohoarc; b=g9+xHTzshs/NGyzpG6ICrkRzOgVvYT9nINE1YpsbrdOzCPkElQodZTWe7W9zA14HpgVMFSaS1iewDfP6RFWSAAOhXZuf5xz3i79hIIdg2yIHDcWubX8rTjNx1DhlBLZY2DDHsVB4eMsXAYoNueTKLD+3OKp6NOuDJZlu7Nnu2ik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614697133; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VJm0iGgu/pocJ2Vudv8ibS2Ot9Xd+ih0+p5aBEZz7PY=; b=emED/NGB5XA7GNjgWyXEREoFHKqYhWpA2YTNflZr5byxW4K4MRIuDbIzjTyXUqiX/7qz9BM6tn9cJp+c0inw5jfLxJfyvQHQ5FwYBONXl+0UhlXTOryKI04JFdInQFw3pkk9IjTqOhbo3e1+8equWaNw6Tg0Z31wOaBjN6sxLD4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.208.51 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by mx.zohomail.com with SMTPS id 1614697133346684.029056794768; Tue, 2 Mar 2021 06:58:53 -0800 (PST) Received: by mail-ed1-f51.google.com with SMTP id h10so25494290edl.6 for ; Tue, 02 Mar 2021 06:58:52 -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 v8sm9399397edq.76.2021.03.02.06.58.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 06:58:50 -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=VJm0iGgu/pocJ2Vudv8ibS2Ot9Xd+ih0+p5aBEZz7PY=; b=PzxnRz+TT21E51h00VO4w6EwBK4uBXlC1idOB18LgNi+3yV1fU5phsOnJrU5RYNakr 45TD1MtBXFcmbFMan7ALS+EzqYisulDtIvV2Z8tjR51nqKVFiXoaguBA8refjEweF98i WKaQLMj/+2mirtCXfH+rpe6GOPmUbHM9R4/VxGr+Y51sMjwRsaKsUbgwZ6XFhw0eIk5p mUb8iSvgDsvh69RpipuDaGhyRNcxBgEtmA/PuC4BpU8tR1hjx9UQgzIbw9JDPRIgeF4W Lx1HUYOABTY1r4WldGrla5fKkrrz3Ycbg5W1MgBHxn3l7ufNxC/K+j0rAu8z3aUj5+uQ wCzg== 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=VJm0iGgu/pocJ2Vudv8ibS2Ot9Xd+ih0+p5aBEZz7PY=; b=lLzz/Yx1kjCgM3aLuR9sy8wOuxd1xfk4wFuWwOzih5LNG2L1LgFWmx4YRl8o3hqUV1 FwePm07SqdkA5OuqcWm5tbS6IBvhMQGjHIfBPoYfS03TKacNurSu1OuqSh6tddZE7Zrc XMc3Gvu/FuKMV/6suMDJLIVhNqb8eOyfeh5HFB2B9Mhr7G89imyABCKDCMehVsqXDEjt jJ0/lIfYnhK0cTZGuH8oMo2ODO7iTpuk/UvDZVm9AdOvaIWxb8VXdkxP2cz5EBurLL9n pBHCurSvO2TrPkEY6g2Wsr1sMDHu3uX680y5z4fSBZqMOLI3/vtnaqEk5T3rQe/YrHBI vc8g== X-Gm-Message-State: AOAM530A+nDfPkcrTgfvxvatWxP3WpbC/UWWkmQSa5RC4tYLKlSbOzR3 1a7HjisvSCO5qPahi7XFiYU= X-Google-Smtp-Source: ABdhPJwVwRfRNiu2er/OHpx+xArXr0gZ7SPEHZUCgD/YEmWg0lWrzGwKDNXy+KYAT/7EtK3rnC5gww== X-Received: by 2002:a05:6402:348c:: with SMTP id v12mr20696747edc.314.1614697131429; Tue, 02 Mar 2021 06:58:51 -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: Thomas Huth , qemu-arm@nongnu.org, Max Filippov , David Gibson , "Edgar E. Iglesias" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Guan Xuetao , Alistair Francis , Michael Rolnik , Palmer Dabbelt , Richard Henderson , Laurent Vivier , Paolo Bonzini , Greg Kurz , Stafford Horne , qemu-ppc@nongnu.org, Anthony Green , Aurelien Jarno , Jiaxun Yang , Cornelia Huck , Claudio Fontana , Sagar Karandikar , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Michael Walle , Marek Vasut , Marcel Apfelbaum , Artyom Tarasenko , Peter Maydell , Aleksandar Rikalo , Chris Wulff , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-s390x@nongnu.org, Sarah Harris , Eduardo Habkost , Bastian Koppelmann , qemu-riscv@nongnu.org, Mark Cave-Ayland , "Michael S. Tsirkin" , Yoshinori Sato , Taylor Simpson Subject: [PATCH v3 04/27] cpu: Directly use cpu_write_elf*() fallback handlers in place Date: Tue, 2 Mar 2021 15:57:55 +0100 Message-Id: <20210302145818.1161461-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210302145818.1161461-1-f4bug@amsat.org> References: <20210302145818.1161461-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) No code directly accesses CPUClass::write_elf*() handlers out of hw/core/cpu.c (the rest are assignation in target/ code): $ git grep -F -- '->write_elf' hw/core/cpu.c:157: return (*cc->write_elf32_qemunote)(f, cpu, opaque); hw/core/cpu.c:171: return (*cc->write_elf32_note)(f, cpu, cpuid, opaqu= e); hw/core/cpu.c:186: return (*cc->write_elf64_qemunote)(f, cpu, opaque); hw/core/cpu.c:200: return (*cc->write_elf64_note)(f, cpu, cpuid, opaqu= e); hw/core/cpu.c:440: k->write_elf32_qemunote =3D cpu_common_write_elf32_= qemunote; hw/core/cpu.c:441: k->write_elf32_note =3D cpu_common_write_elf32_note; hw/core/cpu.c:442: k->write_elf64_qemunote =3D cpu_common_write_elf64_= qemunote; hw/core/cpu.c:443: k->write_elf64_note =3D cpu_common_write_elf64_note; target/arm/cpu.c:2304: cc->write_elf64_note =3D arm_cpu_write_elf64_no= te; target/arm/cpu.c:2305: cc->write_elf32_note =3D arm_cpu_write_elf32_no= te; target/i386/cpu.c:7425: cc->write_elf64_note =3D x86_cpu_write_elf64_n= ote; target/i386/cpu.c:7426: cc->write_elf64_qemunote =3D x86_cpu_write_elf= 64_qemunote; target/i386/cpu.c:7427: cc->write_elf32_note =3D x86_cpu_write_elf32_n= ote; target/i386/cpu.c:7428: cc->write_elf32_qemunote =3D x86_cpu_write_elf= 32_qemunote; target/ppc/translate_init.c.inc:10891: cc->write_elf64_note =3D ppc64_= cpu_write_elf64_note; target/ppc/translate_init.c.inc:10892: cc->write_elf32_note =3D ppc32_= cpu_write_elf32_note; target/s390x/cpu.c:522: cc->write_elf64_note =3D s390_cpu_write_elf64_= note; Check the handler presence in place and remove the common fallback code. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/cpu.c | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/hw/core/cpu.c b/hw/core/cpu.c index daaff56a79e..a9ee2c74ec5 100644 --- a/hw/core/cpu.c +++ b/hw/core/cpu.c @@ -154,60 +154,45 @@ int cpu_write_elf32_qemunote(WriteCoreDumpFunction f,= CPUState *cpu, { CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 + if (!cc->write_elf32_qemunote) { + return 0; + } return (*cc->write_elf32_qemunote)(f, cpu, opaque); } =20 -static int cpu_common_write_elf32_qemunote(WriteCoreDumpFunction f, - CPUState *cpu, void *opaque) -{ - return 0; -} - int cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cpu, int cpuid, void *opaque) { CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 + if (!cc->write_elf32_note) { + return -1; + } return (*cc->write_elf32_note)(f, cpu, cpuid, opaque); } =20 -static int cpu_common_write_elf32_note(WriteCoreDumpFunction f, - CPUState *cpu, int cpuid, - void *opaque) -{ - return -1; -} - int cpu_write_elf64_qemunote(WriteCoreDumpFunction f, CPUState *cpu, void *opaque) { CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 + if (!cc->write_elf64_qemunote) { + return 0; + } return (*cc->write_elf64_qemunote)(f, cpu, opaque); } =20 -static int cpu_common_write_elf64_qemunote(WriteCoreDumpFunction f, - CPUState *cpu, void *opaque) -{ - return 0; -} - int cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cpu, int cpuid, void *opaque) { CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 + if (!cc->write_elf64_note) { + return -1; + } return (*cc->write_elf64_note)(f, cpu, cpuid, opaque); } =20 -static int cpu_common_write_elf64_note(WriteCoreDumpFunction f, - CPUState *cpu, int cpuid, - void *opaque) -{ - return -1; -} - - static int cpu_common_gdb_read_register(CPUState *cpu, GByteArray *buf, in= t reg) { return 0; @@ -437,10 +422,6 @@ static void cpu_class_init(ObjectClass *klass, void *d= ata) k->has_work =3D cpu_common_has_work; k->get_paging_enabled =3D cpu_common_get_paging_enabled; k->get_memory_mapping =3D cpu_common_get_memory_mapping; - k->write_elf32_qemunote =3D cpu_common_write_elf32_qemunote; - k->write_elf32_note =3D cpu_common_write_elf32_note; - k->write_elf64_qemunote =3D cpu_common_write_elf64_qemunote; - k->write_elf64_note =3D cpu_common_write_elf64_note; k->gdb_read_register =3D cpu_common_gdb_read_register; k->gdb_write_register =3D cpu_common_gdb_write_register; set_bit(DEVICE_CATEGORY_CPU, dc->categories); --=20 2.26.2