From nobody Sun Jul 26 14:10:32 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1781156283; cv=none; d=zohomail.com; s=zohoarc; b=Ax4gnvaON8hGYTvcSqF41XX53BhVWgFYc4D60Hl6IJJQoUf9ZxZQm13HPLmk0n8/aQSgmh/9oUIxrobnMnNDsBbfQqikQa2+DRyLEUeTycNw/2YLx74rDtiiI9Ml6zWaFulgtNKKMj26wm9dadpub3j3A42aDVpuI9qw5iBE/4o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781156283; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zeFyaaj9ezk3dMnLRJvqloiuq+fIgJ0YErhEi239GAY=; b=U9XIobOzFFXalBzM/uw57qA/NBzX1y35mSxEYzXfaHd1pGod6MPNSzph4SiNIxjc/v+FE0J/VwC6qtjNMdTzltDcAn1M3RPWaYRHilKSJEu1ePRY33jgXMlbVPfLpMctOnpjTfosdeiZGEBGhKeTKrnaopfZxr82x44hov2mRmY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781156283472746.8740829539049; Wed, 10 Jun 2026 22:38:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXY2Z-0001Ey-Fy; Thu, 11 Jun 2026 01:33:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXY2W-0000yd-9P for qemu-devel@nongnu.org; Thu, 11 Jun 2026 01:33:16 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXY2U-0002bF-59 for qemu-devel@nongnu.org; Thu, 11 Jun 2026 01:33:15 -0400 Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 65B5GQXb3817115 for ; Thu, 11 Jun 2026 05:33:13 GMT Received: from mail-dy1-f200.google.com (mail-dy1-f200.google.com [74.125.82.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4eqe6uss68-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 11 Jun 2026 05:33:12 +0000 (GMT) Received: by mail-dy1-f200.google.com with SMTP id 5a478bee46e88-3074797dfa9so1752263eec.1 for ; Wed, 10 Jun 2026 22:33:12 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-30806ee207asm720800eec.29.2026.06.10.22.33.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2026 22:33:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= zeFyaaj9ezk3dMnLRJvqloiuq+fIgJ0YErhEi239GAY=; b=X4uiPtuSZ7YLsygL 9E/ewXURhL6tZaRxRLTLI4ohaT6TyWRQrdDE2fqlDcQLlaOHrtxaL0ZwY0iVZcxH CyQ92gt2TIBJBm85J7OTxkcH2/K23bmHLJP9eea9mEpOgUwYMeF/f8ueVhVMXPi3 c46vnPBCg/AMpDTFXuP460LGI01DTyPCbTECXW82V4e1RlsYzXsNdvP3jqUi02DS Fg82BKC96Jr/AKQGn7ef+m8WDK3W//8TFvrq4GVF+al7II542nU493VJMXGpIx37 2vuhVeJHvbjcnnXaIr3gsUKz8MVlZcjCjMrP/6KppjG0Dc4KjRHhcxrRzLmOuG8q Z+7Njg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1781155992; x=1781760792; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zeFyaaj9ezk3dMnLRJvqloiuq+fIgJ0YErhEi239GAY=; b=UHtOWmUbDFuctT+KIgVhfWkeoWLFUqukenTqipZxeXj+LM5X58bTNlpoLPMWHlwA0J PMeFcbW8Ufonpo6YF+9CjK3Rvs07yILJIMa7QhsdHzuEnAeT8e687stCbonJXVS/OSWB +upG02jA7AieKw5OWwvHuUR2jS5RAt7Ma1I3r2ANbUD0S1/SWJN0q4RWJky2Uken5NBs JOSIyYTh58cuEzUGELmbB51ktkS+IfwkaN6smzdzZ6c+E/WGZpoJucoDVScfQWMjzHUi vXEn1nVyvqHsk73ySR3FPpx/wJ9PrTkl0Ius0EuRwGL44M5asNwjleosOkuMMCiqaK4W x1Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781155992; x=1781760792; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-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dlJ X-Received: by 2002:a05:7301:1291:b0:304:ab8:f87c with SMTP id 5a478bee46e88-3080463b772mr1080363eec.12.1781155992149; Wed, 10 Jun 2026 22:33:12 -0700 (PDT) X-Received: by 2002:a05:7301:1291:b0:304:ab8:f87c with SMTP id 5a478bee46e88-3080463b772mr1080346eec.12.1781155991624; Wed, 10 Jun 2026 22:33:11 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: brian.cain@oss.qualcomm.com, matheus.bernardino@oss.qualcomm.com, pierrick.bouvier@oss.qualcomm.com, ltaylorsimpson@gmail.com, philmd@mailo.org, philmd@oss.qualcomm.com, Brian Cain Subject: [PATCH v6] target/hexagon: Implement exec_interrupt, set_irq Date: Wed, 10 Jun 2026 22:32:31 -0700 Message-Id: <20260611053249.3918491-11-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260611053249.3918491-1-brian.cain@oss.qualcomm.com> References: <20260611053249.3918491-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=FJ8rAeos c=1 sm=1 tr=0 ts=6a2a4898 cx=c_pps a=PfFC4Oe2JQzmKTvty2cRDw==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=COk6AnOGAAAA:8 a=pGLkceISAAAA:8 a=EUspDBNiAAAA:8 a=GA9jbsKyPMLDJDmtv64A:9 a=QEXdDO2ut3YA:10 a=6Ab_bkdmUrQuMsNx7PHu:22 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwNjExMDA1MiBTYWx0ZWRfX/WpAoznCV5ue Gvz0mSFClYnc68GTZdUMBa+Ia63dQQOQ4PHTMKzADGYyapykz/16Qdk8SYDWsyG28eROXAhL6kO n2JaluGAS5f5DsGa2dEwaz74ngWSy2g= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjExMDA1MiBTYWx0ZWRfX9vJBr1wE/dyB OmodUCD2fFbxW5ab3TYDPmIEaVUddtB+y4+HMdcdwHt0z6TFxRQ9MFQnN/ootBZZvdtbmX/OIA7 XsaPsyOJCvpF28b3Cul57Zgh1bIBkrifO0LmP40Osx/BB42T6dDwtfdfe3M5JqL02nuyNPt+5o6 nG2MmA7lpEOeFANinn9rqFpJjKEMZgMCfF9zUWs0IJ5MBOcDUPgNIlgXl0/z8HpcOWJhHvwc2j+ u3lcYHf/PDY5kW8R5r30Yj1QdoUGfRpupVs40VIkd9N7ecSjWlLco2LN2J2N/i5qapLKyKrDMv/ Hy2X30bYsEI1OTrAG/4Bm8pHsO2jquH/DFO0oadLPNjR3imEbjigxquxdiBjp5wTjD5Rn5hyTF7 Pf1NMS1TceTBjSZPd/oW1JOPsPIrbIMUp1CbSTOWChVw7V5VaefXNPwHgqjo2buX6ARipLGnykU zDW/zIevN7aBT6A5INQ== X-Proofpoint-GUID: FIu0GbzuAa5CrBFOsedrKH0cp80VuxoJ X-Proofpoint-ORIG-GUID: FIu0GbzuAa5CrBFOsedrKH0cp80VuxoJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-11_01,2026-06-09_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 adultscore=0 lowpriorityscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 spamscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606040000 definitions=main-2606110052 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @qualcomm.com) X-ZM-MESSAGEID: 1781156284969158500 From: Brian Cain Reviewed-by: Taylor Simpson Signed-off-by: Brian Cain --- target/hexagon/cpu.c | 84 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index ec0ca3ee678..0d6551dd5b6 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -16,6 +16,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/log.h" #include "qemu/qemu-print.h" #include "cpu.h" #include "internal.h" @@ -31,10 +32,12 @@ #include "hex_mmu.h" =20 #ifndef CONFIG_USER_ONLY +#include "macros.h" #include "sys_macros.h" #include "accel/tcg/cpu-ldst.h" #include "qemu/main-loop.h" #include "hex_interrupts.h" +#include "exec/cpu-interrupt.h" #endif =20 static ObjectClass *hexagon_cpu_class_by_name(const char *cpu_model) @@ -304,6 +307,36 @@ static void hexagon_cpu_synchronize_from_tb(CPUState *= cs, cpu_env(cs)->gpr[HEX_REG_PC] =3D tb->pc; } =20 +#ifndef CONFIG_USER_ONLY +bool hexagon_thread_is_enabled(CPUHexagonState *env) +{ + HexagonCPU *cpu =3D env_archcpu(env); + uint32_t modectl; + uint32_t thread_enabled_mask; + bool E_bit; + + if (!cpu->globalregs) { + return true; + } + modectl =3D + hexagon_globalreg_read(cpu->globalregs, HEX_SREG_MODECTL, + env->threadId); + thread_enabled_mask =3D GET_FIELD(MODECTL_E, modectl); + E_bit =3D thread_enabled_mask & (0x1 << env->threadId); + + return E_bit; +} + +static bool hexagon_cpu_has_work(CPUState *cs) +{ + CPUHexagonState *env =3D cpu_env(cs); + + return hexagon_thread_is_enabled(env) && + (cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_SWI + | CPU_INTERRUPT_K0_UNLOCK | CPU_INTERRUPT_TLB_UNLOCK)); +} +#endif + static void hexagon_restore_state_to_opc(CPUState *cs, const TranslationBlock *tb, const uint64_t *data) @@ -412,10 +445,58 @@ static int hexagon_cpu_mmu_index(CPUState *cs, bool i= fetch) return MMU_USER_IDX; } =20 +#ifndef CONFIG_USER_ONLY +static void hexagon_cpu_set_irq(void *opaque, int irq, int level) +{ + HexagonCPU *cpu =3D HEXAGON_CPU(opaque); + CPUState *cs =3D CPU(cpu); + CPUHexagonState *env =3D cpu_env(cs); + + switch (irq) { + case HEXAGON_CPU_IRQ_0 ... HEXAGON_CPU_IRQ_7: + qemu_log_mask(CPU_LOG_INT, "%s: irq %d, level %d\n", + __func__, irq, level); + if (level) { + hex_raise_interrupts(env, 1 << irq, CPU_INTERRUPT_HARD); + } + break; + default: + g_assert_not_reached(); + } +} +#endif + static void hexagon_cpu_init(Object *obj) { +#ifndef CONFIG_USER_ONLY + HexagonCPU *cpu =3D HEXAGON_CPU(obj); + qdev_init_gpio_in(DEVICE(cpu), hexagon_cpu_set_irq, 8); +#endif } =20 +#ifndef CONFIG_USER_ONLY + +static bool hexagon_cpu_exec_interrupt(CPUState *cs, int interrupt_request) +{ + CPUHexagonState *env =3D cpu_env(cs); + if (interrupt_request & CPU_INTERRUPT_TLB_UNLOCK) { + cs->halted =3D false; + cpu_reset_interrupt(cs, CPU_INTERRUPT_TLB_UNLOCK); + return true; + } + if (interrupt_request & CPU_INTERRUPT_K0_UNLOCK) { + cs->halted =3D false; + cpu_reset_interrupt(cs, CPU_INTERRUPT_K0_UNLOCK); + return true; + } + if (interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_SWI)) { + return hex_check_interrupts(env); + } + return false; +} + +#endif + static const TCGCPUOps hexagon_tcg_ops =3D { /* MTTCG not yet supported: require strict ordering */ .guest_default_memory_order =3D TCG_MO_ALL, @@ -426,6 +507,9 @@ static const TCGCPUOps hexagon_tcg_ops =3D { .synchronize_from_tb =3D hexagon_cpu_synchronize_from_tb, .restore_state_to_opc =3D hexagon_restore_state_to_opc, .mmu_index =3D hexagon_cpu_mmu_index, +#ifndef CONFIG_USER_ONLY + .cpu_exec_interrupt =3D hexagon_cpu_exec_interrupt, +#endif /* !CONFIG_USER_ONLY */ }; =20 static void hexagon_cpu_class_init(ObjectClass *c, const void *data) --=20 2.34.1