From nobody Wed Nov 5 23:49:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.42 as permitted sender) client-ip=209.85.128.42; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f42.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.42 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1619120362; cv=none; d=zohomail.com; s=zohoarc; b=EoZG0Ayk0c3loycdYGqnPgLl8nKIDmCI5whhHzAOtU+e5GnL+ebnT7a/zrfev8K9NTVBzM9rxqqQCDvq12Q49Zy4DBGwY7LA4n5/dM8JFbqyOmm5Bx1nn/HX9srDiB2H2BkuY29OEWuEK71QHx6iiYYjywuhVbPvIMBM0pCdPaE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619120362; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=J6YQeevinF+UxncXXirBs+TNeTtBEGxrSMPU7gVD3MU=; b=dgOPd+YVHrEbanUFgxBgOELYZnXE01t9njtzQY3X/MV13CWhUZhxnP5CN29s+gGD6fq6e4uct/fajEk2xO3WBISlEkBrOcNp3r5gKwfwMbslnBg1K3M1wVGdS1RgHD/JOV2LJrNLo9I3SvDDh/YxjFcg7HEa5IYw7hJ+HeHgn8U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.42 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by mx.zohomail.com with SMTPS id 1619120362814931.2310996212008; Thu, 22 Apr 2021 12:39:22 -0700 (PDT) Received: by mail-wm1-f42.google.com with SMTP id n10-20020a05600c4f8ab0290130f0d3cba3so4701557wmq.1 for ; Thu, 22 Apr 2021 12:39:22 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (39.red-81-40-121.staticip.rima-tde.net. [81.40.121.39]) by smtp.gmail.com with ESMTPSA id c15sm5287828wrr.3.2021.04.22.12.39.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 12:39:19 -0700 (PDT) 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=J6YQeevinF+UxncXXirBs+TNeTtBEGxrSMPU7gVD3MU=; b=R/moRZZ4c/y/LytyMN+wjV1mwDXDkhoT85uL0akSO41gWVv/C1vgmSDNZRwlyTLfde cOvNizbIUk/d6t5ZcJa1y8rNyl8aZ74AjJrbmHoYnahICZECo6Cu+lI0+DZ/nUXIPHVt YfQfFuTysTK2y1YPFhL0LVrP5tKrV9WWpuSPGrC/mX7FDOxA5T7waLP2REqFL0zTp1x2 IQylqtu3R7/1EILg1Gl1JOpln3KlnZVIfwj6z4sd7bMjNcGY0N/DPUyVyi++f+H4rixv duCFlWwe4l5qRlSOOZnaDoFP9LRtigOjHVVwuAu2zlk1sUAo54Pnc6UHYSPLWIZftjrO 6guQ== 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=J6YQeevinF+UxncXXirBs+TNeTtBEGxrSMPU7gVD3MU=; b=oUfJ4N6eGPXQoxrz+xwy7kZe62n3+DOIV1ZkFy6hUlroJc5RImYLdnv/97+Q5Q2viW gopXecVKpHErAVdy1TkHvE2/3Xn6c3sOObOI/73+XjbVzPMDzkIW2N5sQ1r1Vk7mG/JN WijiQ+P4OQlL6KcQpYRMZwSLyhJ6iog8C7alC3yfcMlTK5AzIIqrUYd3zQfSqe2B/WG3 BrNU2qrcvWkHfxb4Y5qw4keV0yXgauND+gN5m0EZt3qBCU2djtDKsz9gvNP5uBc1xBUv CFy07nJv2mjCvqX2jujejZhmBpTZ1wssOtodGjPB/nsypDb6z+HWUx59rVa2qN4xT3R4 tDAQ== X-Gm-Message-State: AOAM530VbBX7wGere5HmZsXCm6GahYf+0vEM5KakB8L2etPUCj/XjBgP GTSMsJtcTtCUG9dT+G+Sd50= X-Google-Smtp-Source: ABdhPJxItIbUjNhRpmmaJBQYrpeQf7tDHu/V9XV4sBbnuZw+wZyqong/VFrRstYleBeofBXfBdXplg== X-Received: by 2002:a1c:2857:: with SMTP id o84mr1650722wmo.181.1619120360024; Thu, 22 Apr 2021 12:39:20 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Dr. David Alan Gilbert" , qemu-riscv@nongnu.org, Juan Quintela , Peter Maydell , Claudio Fontana , qemu-arm@nongnu.org, Eduardo Habkost , qemu-ppc@nongnu.org, Richard Henderson , Laurent Vivier , qemu-s390x@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum Subject: [PATCH v6 03/18] cpu: Directly use cpu_write_elf*() fallback handlers in place Date: Thu, 22 Apr 2021 21:38:47 +0200 Message-Id: <20210422193902.2644064-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210422193902.2644064-1-f4bug@amsat.org> References: <20210422193902.2644064-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. Reviewed-by: Richard Henderson 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.3