From nobody Tue Feb 10 00:23:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.52 as permitted sender) client-ip=209.85.221.52; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f52.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.52 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1632174386; cv=none; d=zohomail.com; s=zohoarc; b=YgTbjXcuY+MH2X9Cecp/amCrB0aoTlBS79LXd9Us6+xJ3ZDLWIZB0QAaDRFIYHdXhFW47y3A8M7/l5zAwOn1GbUrF4yQF+foecH/b+n/9yvprWrzhaBCodBP2D0DWZLMCMGXSEKrRAWA8x9vHWTJzs56pBgN5YXb1yPZRQ59KSM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632174386; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7WPGnjIwDqq9FNiuzjIUo9e3oGnINOP8qAvzXoIP118=; b=di2xB501lVhZG4raNR+fhLaD6pfJFNR20nMEylx693prU/KTcPaK6wvKKHrYhIq84xzJ0eA8foUkKCau8OdIfcJW2bf+9SJBXz0tGtRQKKZ8rZmOtMMnhZYsuThw+v1Dp0H9lyYkk1EPvgcXJ3isTPoNnUknPd7g/zn0TXsFiuQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.52 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by mx.zohomail.com with SMTPS id 1632174386767213.75785722127296; Mon, 20 Sep 2021 14:46:26 -0700 (PDT) Received: by mail-wr1-f52.google.com with SMTP id d21so33521558wra.12 for ; Mon, 20 Sep 2021 14:46:26 -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 j23sm768229wmo.14.2021.09.20.14.46.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Sep 2021 14:46:24 -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=bT/vg+vkwtKXTMpukqDINGoyLEmiMIGNN4BhbQOWnZPr/j5CpH7aOsp0j8bWPlF+k7 TQMcrquYxF2pNjOE5sGHJkhpPO35rZyblgsq2zPf/4iuaXpqA+fYqNuJOjWt5ReEKufZ 6jfVllNP1Bm1+Ruf72y7NiaAHVZxDFr/9nB4/zS/vMWRZ5ikhsOsVykdSe/iGUpiAoxD AGcoCeP5JLAiqkuvkRBOeHnMntk3KDrxOEUUYkwenRxlyD80nlysBFT38YwNqeADgzOA D+nGSFw7IHcNNyhN6x75VgeR+FCDrap1iW9UOzg6b7DiLy7NZ+x9YLT5frgR3Z+fvj7J 6lBA== 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=uRmzYKbdCqZTuRzYeYsfdXbBPtuGA8QVGDIW0Zid7M/VKjK/lFVpj8HYfqEkJha/Ks HGl/3GumSg68HzrSqW2Hnyv4gvBD/uo2gV4O8Rwyt+ns14Pzozvp98fqkXSFMDaPzmCZ 6dGr5joBoXXlF4c7czo4bCTf5L9PfQOfQ1tK5g8PFZ75eNPmdjdrSVv4NacZCaalG3ML gvp9DxcZZJ4q0TGr0cNAmaJ8VL7jpNZeM206zUYsaOHANk6Xyy0GrWo1qj7Tj7Cddw5u wuzWsM7fZLz7TX0pvroXVGC5cgg1+BlQjvzx3jAzPbUlSFcR3NsAK8EZXXe2oTMd1eRY Y5hg== X-Gm-Message-State: AOAM531uaRQG6isQlf5hKo9Jt0zYY+jDk76d1ZBGyTLZ2ViEUA431Llo CbnoZG9EySWGN5zIpIIuoEw= X-Google-Smtp-Source: ABdhPJwdxqe2DyXo+xpeKs60iMYldzID2g/tPLJsL26Jt9nJ1wysh8AiOnmo+HmM13VGkYH6WE+opw== X-Received: by 2002:adf:82a8:: with SMTP id 37mr31371267wrc.409.1632174384961; Mon, 20 Sep 2021 14:46:24 -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 v5 21/31] target/ppc: Introduce PowerPCCPUClass::has_work() Date: Mon, 20 Sep 2021 23:44:37 +0200 Message-Id: <20210920214447.2998623-22-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210920214447.2998623-1-f4bug@amsat.org> References: <20210920214447.2998623-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: 1632174388079100001 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