From nobody Sun Oct 5 07:43:04 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.46 as permitted sender) client-ip=209.85.128.46; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f46.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.46 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1619088445; cv=none; d=zohomail.com; s=zohoarc; b=dXtLFCSaczZVKI5xXcuWH4mUyS44wA9Bp2BiaYwsCgafc4jy+io1XxfM08LjMhrwLjHv6YIlCQVW/qW6XnQKyiFhi8IYYv44rHyRHUbz/HJrGu7S28nbG9R7K9BZpQQ45OnrK5S5m/asRjQHFce6LH7Hb+w+v4qEgAANMTbQLao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619088445; 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=CdYSkRrV/5LJyjhUxRTsz4dQ3UfCPXLEtRYZHauRI5gIv9tgoha4G6gzD9wFpK7yFnBWHwYD5vIGwUxQG/SGsG3zXKNTsuWIpMGmvBoOLq+f+OtWtPjuMDJw7GIKDtqpNdmonKTSgZGYgWvBwpLPFVonG6vHXdwiYrmdBAtennQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.46 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by mx.zohomail.com with SMTPS id 1619088445660178.24385085856102; Thu, 22 Apr 2021 03:47:25 -0700 (PDT) Received: by mail-wm1-f46.google.com with SMTP id y124-20020a1c32820000b029010c93864955so2968207wmy.5 for ; Thu, 22 Apr 2021 03:47:25 -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 f6sm2768689wrt.19.2021.04.22.03.47.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 03:47:23 -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=SPMN0H58jaHy0OX/UysQKeTE2Rhtc7A1t+nFo8oh3564mNJm90y1sv3Zk1eyrjRGm3 bpNNXVST+Zuo63EXV1xc/3+MTGD/FgL8u1tgDTpslvaLEDWyzirtOTkOOiOYSu1jvNkT 46xq6ELy/biINIn2FxOMWY33tJAO8rbvsb6jE/hqRZBLm3GwkgEQju5NDcCdfrdIy2Ip ZyChfiqZfUqwMwhRg6H4z/jpJYjis1ZnutC7dzzi/1/JHnTBwe2zHJIw9UaNaJEPOf/f z2Gj9E7UpVqMn13DgxSH8d8W8MsLm2lPfRZnmAeb/pka5MSjSV+4Cb7jWmoY5ODosZjI 06VA== 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=dOGo/ZoUM3+AZUJNjWL+qDj5/pm3RkfntN2rgBzm7zcUdhNNl+6+lr7GsfUucUbh1R 4oGryfSfs11WPuqVbYc9vZz6h45Vv2uWo+rMfpzZKstwUAToW0ayI37EKpXj+1XAiYaS HuwruXHc+SnO9X9NJd62CH768FZSVyXrDqasdfPuotdJ5ayEd3LXH0v1vbvDJpSbxsMC PnMdSvQl0iPRjPlgvoSpl2KbDrhj7Qgy+Ui+8swFI3pIFwBjm7Tz5Lf1Cq+pAYvbI3MA K/4w/Z4dXZHyiEke4e0ioXILX5LXglmOKQk2Nqw3dC/jjVl4dw3P0lBEr5HUhYBNwrlQ +org== X-Gm-Message-State: AOAM533SrVZN+ThtAA5GFBKRgO/prwvCtYsueSYxUAYpcQnup9ssuu4C 9fMylBJfnoAGN8qpyLk/aoA= X-Google-Smtp-Source: ABdhPJwNE277zfbHJw8ofaurHJkJ3I0dHiDB5LhPo5J75HLMPOIjjUXuipWzaaONrEOcNlM6Q5iBVw== X-Received: by 2002:a1c:7fcd:: with SMTP id a196mr14897761wmd.180.1619088443920; Thu, 22 Apr 2021 03:47:23 -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: Paolo Bonzini , Claudio Fontana , Juan Quintela , Greg Kurz , Laurent Vivier , qemu-riscv@nongnu.org, "Michael S. Tsirkin" , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Peter Maydell , qemu-arm@nongnu.org, Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Marcel Apfelbaum Subject: [PATCH v5 03/15] cpu: Directly use cpu_write_elf*() fallback handlers in place Date: Thu, 22 Apr 2021 12:46:52 +0200 Message-Id: <20210422104705.2454166-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210422104705.2454166-1-f4bug@amsat.org> References: <20210422104705.2454166-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