From patchwork Mon Apr 28 20:10:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 885490 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp5364997wrs; Mon, 28 Apr 2025 13:11:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVEfDPM4KiKOiSqJDJNZOHERLh2+D8wHDdC/wCgNcdiFySjcErjoCB7WrbkV4W23sJ88j0FBA==@linaro.org X-Google-Smtp-Source: AGHT+IF14LWr5RjnsfMvWpiAO6ZFky6BYyPqccaCmJwKT9nn6ohP1xKsSAQvLUOdYY3cL/iiwqEx X-Received: by 2002:a05:622a:5819:b0:478:f755:95ab with SMTP id d75a77b69052e-488656734b1mr8893691cf.18.1745871113946; Mon, 28 Apr 2025 13:11:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1745871113; cv=none; d=google.com; s=arc-20240605; b=gcBOO1MtYYONGQ/CbDFt8ZEUEQoXtDr3b0deY7LvKug5jyjzQf4mAhC6x1EU1WYpxi wQKqFY1nm/vQELsxErUmrO7cGxlh5W5DhUUIkmnuQVx4FKoV9DVxbrSUm1fYVYxLEpGC XWzCW+SULPeD3EcOo84+yKjWmJY/WYkUSwao0R3I2azLtAkf9dZJwqUonp51ThMpC3t4 MdWCSBRpCvT2Gfqa9abTtk+nEF0jPMSb2yxWBnSwa4oJlbRNJ02/UPeBG0LH3u7iCXS/ yDhnt3b+dE7au3AivumbpIEJp4nS3kAc37OzeypoXeIfxZLgTWyzbC2/1Zmq9uNa97Gi CjzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pZ0ltXmMLAseVMXMt+PRkdJL8bxs0+GQjSw4gZylX5E=; fh=6c3iePwzSVcIevU/n11cXtkmPbvvYSh1prLosaYzn/o=; b=LQTaj7O2eFyfUri5Q1kE9rXOX3R5jhUosbB8MH4kAifWHH4xswvMbZyyW33g9SM4T7 oTOuaNum6e4cCvXZuciGCCnfdO/IBDJBCOOKlkAJ7Aqm7ik3W+q5I1xtQolfYoTvndBm LOzcGP6J6qvCMR1vzpVKtuo/mpBK65XoO4e1it5rTx7hilxZyJRM5lEB6Xn82bef6B0v gs/m3fEPeb8uZBR/9YNG4uxJ3HJrS2+ubbHZSWmidctvriEV3grfxmKupojqmQJGkMqb tLKjo28JUOCXtTMItZtE6Tp4jxuFihkSHgX8D6YR3Q3dwW4fh/m6jW01aJdN1RhytUP1 JT0g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uCW9e5E6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-47ea19869e3si114149811cf.246.2025.04.28.13.11.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Apr 2025 13:11:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uCW9e5E6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9UoI-00058h-PF; Mon, 28 Apr 2025 16:10:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9UoG-00057v-8S for qemu-devel@nongnu.org; Mon, 28 Apr 2025 16:10:36 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u9UoE-0000cG-Dp for qemu-devel@nongnu.org; Mon, 28 Apr 2025 16:10:35 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-736b350a22cso4632630b3a.1 for ; Mon, 28 Apr 2025 13:10:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745871033; x=1746475833; 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=pZ0ltXmMLAseVMXMt+PRkdJL8bxs0+GQjSw4gZylX5E=; b=uCW9e5E6mjVlhSrqS/3gtuYaIWW61l7CZhwWw3qt4YmpJFNkrXuSyp5HFRZR0bw2fw n7Wy7EOLF0khvPZHplJw1lOmsxBbrHI2pUmeT7pFB9F+Blqbz84eZGcSMWPqEFkQl/or b+F0aqoP/eREZRwaH3FtMmxGJBLcGhLvFuMH8I4hiG73AfeFwuQ2PNjwDqDBEi2NafBo +6bvcoxFoo7cy8TzdCaLwH1EwnEqm7Z/3E/Wya4UvDPsYY/bGM8W/KPqbqiDrReiQq6B 6+UUhuOyuDjIJS20Rww/2FxtxjoCGMiK6hKuMuGaXROm2KJoI+l1w8XtLGDQnT7vIn5K CzgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745871033; x=1746475833; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pZ0ltXmMLAseVMXMt+PRkdJL8bxs0+GQjSw4gZylX5E=; b=ec8uV/dPNJ3hvisL2vsh4iRizprJIMI2IzO9zl+zKHi1MJ02YJmIV2Ma3MnDSZNNWF 9sEnnaB6NnUaOH+IOX7v9EEOAE+TNKwHxSk4LjbTzyZ4HcVXPNFBsqwEQWu38nWM1xfe VYJ5h7giVo77PEBVtAOFJNbhICjoMtIFCJxZFBOSfafQFeTNhxiDYsGL7nOdIGMEEQSH 5tCgJFq6Ig+hvXqYZb9HENxVCFFMOvYyrmG3O9PgCpW03IHU5MV++rNpww9xRUGSCeqz L83YqMvXqyItOoCOXVIxShHyiQASxjkkZ5CYTlhG3rJL0R7533Lwe9NAEu4ivyC4BrQ4 03Tg== X-Gm-Message-State: AOJu0YyLUD6HXgTRpC8qVyAGriLs6tUYnmcoskag5H+Iy9eyHFJ1JpSU tL0v/vDM+ZrL+U2yCsSVk4FwJzQ2mEAEyMkdLLPbFunEO16cb+Pu8Rt7Sgge4QBJHpDQgJSvgp7 A X-Gm-Gg: ASbGncsPrUhxWb+FyVVZzdU38fAAive7ZtiR2+739b2F9SSQmjpVHfgxRSTUgitKxSm xs75WXafRuYNxTejIRS66tfTLgOSZzL0WaXLmbzCFNqpwDVH+L1cAUl99zho9wFUPnEy0qZBK1M n1NlMn0Fff48nYi4eTGbcCLOgg0Lrdj8LgaapDo1qufQknx01eyCkgP5ZOwuTtVBOMYeqMHtolL //WYJ4gckjeT1J2hEprqVktA0q9uvOFd1mR1AiKwI1K7vYQyTIG+8w/JNOZYQBRc6TzZgSUz8yO SE5sIyNcEWhd+n0/RAG5U8mnMmIEw7Spt5yeUOQYi7v06LYHMmvh5ftIqDA15ABbu6jRPwmoAYc = X-Received: by 2002:a05:6a00:3a14:b0:736:b101:aed3 with SMTP id d2e1a72fcca58-74028f93bffmr541451b3a.1.1745871032817; Mon, 28 Apr 2025 13:10:32 -0700 (PDT) Received: from stoup.. (71-212-47-143.tukw.qwest.net. [71.212.47.143]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73e25912fb9sm8469976b3a.34.2025.04.28.13.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Apr 2025 13:10:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, philmd@linaro.org Subject: [PATCH 04/10] target/i386: Split out x86_cpu_exec_reset Date: Mon, 28 Apr 2025 13:10:22 -0700 Message-ID: <20250428201028.1699157-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250428201028.1699157-1-richard.henderson@linaro.org> References: <20250428201028.1699157-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Note that target/i386/cpu.h defines CPU_INTERRUPT_INIT as CPU_INTERRUPT_RESET. Therefore we can handle the #if TARGET_I386 block in cpu_handle_interrupt with the new TCGCPUOps.cpu_exec_reset hook. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- accel/tcg/cpu-exec.c | 39 ++++++++++++++------------------------- target/i386/tcg/tcg-cpu.c | 11 ++++++++++- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 010f38edaa..c21c5d202d 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -819,33 +819,22 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, cpu->exception_index = EXCP_HLT; bql_unlock(); return true; - } -#if defined(TARGET_I386) - else if (interrupt_request & CPU_INTERRUPT_INIT) { - X86CPU *x86_cpu = X86_CPU(cpu); - CPUArchState *env = &x86_cpu->env; - replay_interrupt(); - cpu_svm_check_intercept_param(env, SVM_EXIT_INIT, 0, 0); - do_cpu_init(x86_cpu); - cpu->exception_index = EXCP_HALTED; - bql_unlock(); - return true; - } -#else - else if (interrupt_request & CPU_INTERRUPT_RESET) { - replay_interrupt(); - cpu->cc->tcg_ops->cpu_exec_reset(cpu); - bql_unlock(); - return true; - } -#endif /* !TARGET_I386 */ - /* The target hook has 3 exit conditions: - False when the interrupt isn't processed, - True when it is, and we should restart on a new TB, - and via longjmp via cpu_loop_exit. */ - else { + } else { const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; + if (interrupt_request & CPU_INTERRUPT_RESET) { + replay_interrupt(); + tcg_ops->cpu_exec_reset(cpu); + bql_unlock(); + return true; + } + + /* + * The target hook has 3 exit conditions: + * False when the interrupt isn't processed, + * True when it is, and we should restart on a new TB, + * and via longjmp via cpu_loop_exit. + */ if (tcg_ops->cpu_exec_interrupt(cpu, interrupt_request)) { if (!tcg_ops->need_replay_interrupt || tcg_ops->need_replay_interrupt(interrupt_request)) { diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c index 63ddf87aa8..0184e308e6 100644 --- a/target/i386/tcg/tcg-cpu.c +++ b/target/i386/tcg/tcg-cpu.c @@ -120,6 +120,15 @@ static bool x86_debug_check_breakpoint(CPUState *cs) /* RF disables all architectural breakpoints. */ return !(env->eflags & RF_MASK); } + +static void x86_cpu_exec_reset(CPUState *cs) +{ + CPUArchState *env = cpu_env(cs); + + cpu_svm_check_intercept_param(env, SVM_EXIT_INIT, 0, 0); + do_cpu_init(env_archcpu(env)); + cs->exception_index = EXCP_HALTED; +} #endif #include "accel/tcg/cpu-ops.h" @@ -147,7 +156,7 @@ const TCGCPUOps x86_tcg_ops = { .do_interrupt = x86_cpu_do_interrupt, .cpu_exec_halt = x86_cpu_exec_halt, .cpu_exec_interrupt = x86_cpu_exec_interrupt, - .cpu_exec_reset = cpu_reset, + .cpu_exec_reset = x86_cpu_exec_reset, .do_unaligned_access = x86_cpu_do_unaligned_access, .debug_excp_handler = breakpoint_handler, .debug_check_breakpoint = x86_debug_check_breakpoint,