From nobody Tue Feb 10 20:48:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.41 as permitted sender) client-ip=209.85.221.41; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f41.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.41 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1632695376; cv=none; d=zohomail.com; s=zohoarc; b=iFMvN5riAK7BgN2zzXLCTYiMnh8w0TmDPakLYJMkjEb+V9ehlZbcJDAUyQkZFHk1n8iBMPuth9gvzWTNx1bO8Vf3dGhRw4GaxU+TLk9y80bhtmJQeOOt6PuZbApVhfmvQLkCVVKRBw1DJmM0XnUDl1Z0+OKBKq5lKGMHGEmMrTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632695376; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7WPGnjIwDqq9FNiuzjIUo9e3oGnINOP8qAvzXoIP118=; b=DlldeLHYg7RGadXIA9934aRaE6ZPkWEFFZOXd2O6OmSnw8s519zmu10gBwqWubdOH3o5onZFgNNNQ6lhpVKQaE1lSXNyr3ckUIBggD2RnVFIoaWY8bcuCHFcIhhndHqD5v6QXd43s9xhxVHMu+MRc/TquivvsknQKWp56bIHiwI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.41 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by mx.zohomail.com with SMTPS id 1632695376371935.5747486739664; Sun, 26 Sep 2021 15:29:36 -0700 (PDT) Received: by mail-wr1-f41.google.com with SMTP id i23so46579257wrb.2 for ; Sun, 26 Sep 2021 15:29:35 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id g13sm14346201wmh.20.2021.09.26.15.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 15:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7WPGnjIwDqq9FNiuzjIUo9e3oGnINOP8qAvzXoIP118=; b=hCe0fCS4MOLhSwXTjcBRw4hAldZ1NJCy+uvUvygejf96gtPcF/y5JQ9D9WgCmg1u/K OWznFrolwmDnc/pTbOAuX3wxJGPUc8zgS3nx5kWkQ+2o3cVU+SbKbfReOADm3mXs1uTW REKInPjRrCmHM1i+NswEXMIst5aUVzqK8fnXyc0KcJSzkzzkIoq2rT1jaZtzdBQM06kH Sp8qL+QcNWIeoaJiClgQfW9DRhgQtIximReK1xdqkN6Ef6loHNzWyNdsiMjjBQpFtcSK EoG1ixUMlatT65yr41KndSMdrmL3KELZIxIteNmccZjIM2VZ/5pLM4ujGbi41zzKYgLp uS+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=7WPGnjIwDqq9FNiuzjIUo9e3oGnINOP8qAvzXoIP118=; b=riRgpsq3FyWi+RQP//FvcLBZzYInMjubZfzHUyZ7+OhINb7Xq4tZ+6sdeEPGE6ch5S ow58cbtbuEHJSQ22gun3d2GyrlYQVALnbhp4qLoxmOE5CjAbEkzsVm580KUHBKF/vY8y IrCBflT8KH/000Kb7FlIU7W9/6tX4k4/rMKwbs5Qwxb7M01bT8EZw/7eQdO/cudDKfV4 gGdek3ReNSiaTGuuAIkwfDZVvQYSB86ZBkzGFLO4kjiVkH/NNFbkUwI21i1JyLQ/yVT+ m/Gq779CCRFb7jHPC4hvmzedaIQoOckWVWv4bwgxnbXMCr3+ZsElu9/hIi/axk+Hkm8B l3CA== X-Gm-Message-State: AOAM533/PAk2wFf9CCXaAXTgNxFYTj+426Fgm948/W0tN9+RH7ZgKlIU 5HQibfWzBUifFD17mP3m3kg= X-Google-Smtp-Source: ABdhPJz/EK5OqLlhoi1NR9ti7v37hBrWrS44S4o/F652aagSMzpbUuyfWEFtemA3Kpk56nkow1zSGA== X-Received: by 2002:a1c:3b0a:: with SMTP id i10mr1495559wma.132.1632695374608; Sun, 26 Sep 2021 15:29:34 -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: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v8 29/40] target/ppc: Introduce PowerPCCPUClass::has_work() Date: Mon, 27 Sep 2021 00:27:05 +0200 Message-Id: <20210926222716.1732932-30-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210926222716.1732932-1-f4bug@amsat.org> References: <20210926222716.1732932-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) X-ZM-MESSAGEID: 1632695378326100001 We're moving the hook from CPUState to TCGCPUOps. TCGCPUOps is a const structure, so to avoid creating multiple versions of the same structure, simply changing the has_work() handler, introduce yet another indirection with a has_work() handler in PowerPCCPUClass, and ppc_cpu_has_work() method which dispatch to it. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/ppc/cpu-qom.h | 1 + target/ppc/cpu_init.c | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index 5800fa324e8..36110112506 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -188,6 +188,7 @@ struct PowerPCCPUClass { uint32_t flags; int bfd_mach; uint32_t l1_dcache_size, l1_icache_size; + bool (*has_work)(CPUState *cpu); #ifndef CONFIG_USER_ONLY unsigned int gdb_num_sprs; const char *gdb_spr_xml; diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 6aad01d1d3a..2f7d262b176 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -7621,7 +7621,6 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); PowerPCCPUClass *pcc =3D POWERPC_CPU_CLASS(oc); - CPUClass *cc =3D CPU_CLASS(oc); =20 dc->fw_name =3D "PowerPC,POWER7"; dc->desc =3D "POWER7"; @@ -7630,7 +7629,7 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data) pcc->pcr_supported =3D PCR_COMPAT_2_06 | PCR_COMPAT_2_05; pcc->init_proc =3D init_proc_POWER7; pcc->check_pow =3D check_pow_nocheck; - cc->has_work =3D cpu_has_work_POWER7; + pcc->has_work =3D cpu_has_work_POWER7; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB= | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -7789,7 +7788,6 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); PowerPCCPUClass *pcc =3D POWERPC_CPU_CLASS(oc); - CPUClass *cc =3D CPU_CLASS(oc); =20 dc->fw_name =3D "PowerPC,POWER8"; dc->desc =3D "POWER8"; @@ -7798,7 +7796,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data) pcc->pcr_supported =3D PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_COMPAT_= 2_05; pcc->init_proc =3D init_proc_POWER8; pcc->check_pow =3D check_pow_nocheck; - cc->has_work =3D cpu_has_work_POWER8; + pcc->has_work =3D cpu_has_work_POWER8; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB= | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -8003,7 +8001,6 @@ POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); PowerPCCPUClass *pcc =3D POWERPC_CPU_CLASS(oc); - CPUClass *cc =3D CPU_CLASS(oc); =20 dc->fw_name =3D "PowerPC,POWER9"; dc->desc =3D "POWER9"; @@ -8013,7 +8010,7 @@ POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data) PCR_COMPAT_2_05; pcc->init_proc =3D init_proc_POWER9; pcc->check_pow =3D check_pow_nocheck; - cc->has_work =3D cpu_has_work_POWER9; + pcc->has_work =3D cpu_has_work_POWER9; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB= | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -8212,7 +8209,6 @@ POWERPC_FAMILY(POWER10)(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); PowerPCCPUClass *pcc =3D POWERPC_CPU_CLASS(oc); - CPUClass *cc =3D CPU_CLASS(oc); =20 dc->fw_name =3D "PowerPC,POWER10"; dc->desc =3D "POWER10"; @@ -8223,7 +8219,7 @@ POWERPC_FAMILY(POWER10)(ObjectClass *oc, void *data) PCR_COMPAT_2_06 | PCR_COMPAT_2_05; pcc->init_proc =3D init_proc_POWER10; pcc->check_pow =3D check_pow_nocheck; - cc->has_work =3D cpu_has_work_POWER10; + pcc->has_work =3D cpu_has_work_POWER10; pcc->insns_flags =3D PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB= | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | @@ -8790,7 +8786,7 @@ static void ppc_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.nip =3D value; } =20 -static bool ppc_cpu_has_work(CPUState *cs) +static bool cpu_has_work_default(CPUState *cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *env =3D &cpu->env; @@ -8798,6 +8794,14 @@ static bool ppc_cpu_has_work(CPUState *cs) return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD); } =20 +static bool ppc_cpu_has_work(CPUState *cs) +{ + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); + + return pcc->has_work(cs); +} + static void ppc_cpu_reset(DeviceState *dev) { CPUState *s =3D CPU(dev); @@ -9037,6 +9041,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void = *data) device_class_set_parent_unrealize(dc, ppc_cpu_unrealize, &pcc->parent_unrealize); pcc->pvr_match =3D ppc_pvr_match_default; + pcc->has_work =3D cpu_has_work_default; device_class_set_props(dc, ppc_cpu_properties); =20 device_class_set_parent_reset(dc, ppc_cpu_reset, &pcc->parent_reset); --=20 2.31.1