From nobody Sat May 18 10:30:12 2024 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666865151; cv=none; d=zohomail.com; s=zohoarc; b=h+T4ERHM6BOHs/N1NfojuT6dh0nRRUK+A2In6c1T3NB8gvewxwbRuGMzzivCV8a6kVVl0cmWSMzpJLNwEDXvrdKeP6PCPrqsge6cvNfXgd/mEP4akjpo8V9FldngI8X+hGyVpii5iqPsVFDA8WBOy4dWxRy/ODMmx89b38fHy5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666865151; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nSG/K4mlF2KPY6JS4R2kh3NiVBne+gqPMQQ357pKXcA=; b=Sy7/eANaS/xvXuK2Y1LgF5/SLZMXAni1mV9Y9gVNqCEjxWovHXA/Zc7TEtKLg8wXJ6e2z9zgLLZXeo9+DI0r+z1NtxkqpaUv/oTgOsmoanCJA8ohvcU6DvbZaAsuSTyr4VKVH05/PS7rwFruSlPI7butTvyd8x4MiJ7ZqihB1NI= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166686515180821.42537558400886; Thu, 27 Oct 2022 03:05:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onzjZ-0007VX-Gk; Thu, 27 Oct 2022 06:03:33 -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 1onzjA-0006sZ-Tl for qemu-devel@nongnu.org; Thu, 27 Oct 2022 06:03:09 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onzj8-0004Ef-Iz for qemu-devel@nongnu.org; Thu, 27 Oct 2022 06:03:08 -0400 Received: by mail-pf1-x434.google.com with SMTP id g62so974409pfb.10 for ; Thu, 27 Oct 2022 03:03:05 -0700 (PDT) Received: from localhost.localdomain ([2001:8003:501a:d301:3a91:9408:3918:55a]) by smtp.gmail.com with ESMTPSA id n13-20020a17090a2bcd00b0020a825fc912sm2354631pje.45.2022.10.27.03.03.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 03:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=nSG/K4mlF2KPY6JS4R2kh3NiVBne+gqPMQQ357pKXcA=; b=u1ktNpJ4RM7TK79E1Gk+5LixuoKLqNpIzJkYHsMmmgwwyZqxT//d/yia5tYUPc8kMF gSOiSoo+WLL5LqdV20bc5l3dG00tRJzZ1uGXji76eCqcHX14m06GOg+brRFUsdyNYR93 ellQuaw78vTNGkkXrRMmPwEPkZ1pq/8BcCYbb7/QVU1QBfCPkvvyAX1kCrQYoYIa68b8 L1UBhv8mpyCDhwnD7j4dPFyid5nk1u8uj2goczv0UYTamVnme92pxIwFqVI1U5qDM81b WmHXLTos8e73saRJ3/2587qPq/uO9xzem/IskCSN2XbAj1FkoGlQIl+xLS2IuT/cS32T tEyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=nSG/K4mlF2KPY6JS4R2kh3NiVBne+gqPMQQ357pKXcA=; b=PMD5+4R+ioo22/jlGdcTLA7lbBbX6tHw2d0N8y+9JbFs1W0kMWhqfVHgEnqTVAmGDe pQnme0NrBjoL1XsLR40d9vF4Me1vMYxkqsgXi5RTYw26aC1C1s8GYYo3jzNK+WbWqDnO L1XvLOtpWJ5fG0d+yiIhsXK0KGB0NuAykb8HmagVs6OL2j2gcdhuGrWsnOVgUNOGxfbb iuo3n32POcWfW5ZH9cMQqmbXEii7g14sxHTv2XDjow40CocJZbuUKiGtyxLn2C9aT1uO LbEQSJ3cc05vos1dQKy4yXBc2bJRsIa8kzCtRyzrn20NOFimTAneLMDC0VnTqaBVFhTf PQlw== X-Gm-Message-State: ACrzQf0nX0ZIJxS9H1IemF+7Px7HFDIiOuBNv6j7UeyTgKCedgPYMVM2 QFpOQAfnq1pKl8RlmGqh0k/FYku2uAg4B/9E X-Google-Smtp-Source: AMsMyM4PHxmlc6CzeCa74ZElq65mOdOHCi3C2/wJtrty9b2TKbeyObcdxyBbqB6vAg2XNTxes97e4w== X-Received: by 2002:a65:6158:0:b0:46f:55fe:9be6 with SMTP id o24-20020a656158000000b0046f55fe9be6mr1078594pgv.301.1666864984528; Thu, 27 Oct 2022 03:03:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: cfontana@suse.de Subject: [PATCH v2 1/6] accel/tcg: Introduce cpu_unwind_state_data Date: Thu, 27 Oct 2022 21:02:49 +1100 Message-Id: <20221027100254.215253-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221027100254.215253-1-richard.henderson@linaro.org> References: <20221027100254.215253-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666865152231100001 Content-Type: text/plain; charset="utf-8" Add a way to examine the unwind data without actually restoring the data back into env. Signed-off-by: Richard Henderson Reviewed-by: Claudio Fontana --- accel/tcg/internal.h | 4 +-- include/exec/exec-all.h | 21 ++++++++--- accel/tcg/translate-all.c | 74 ++++++++++++++++++++++++++------------- 3 files changed, 68 insertions(+), 31 deletions(-) diff --git a/accel/tcg/internal.h b/accel/tcg/internal.h index 1227bb69bd..9c06b320b7 100644 --- a/accel/tcg/internal.h +++ b/accel/tcg/internal.h @@ -106,8 +106,8 @@ void tb_reset_jump(TranslationBlock *tb, int n); TranslationBlock *tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_p= c, tb_page_addr_t phys_page2); bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc); -int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, - uintptr_t searched_pc, bool reset_icount); +void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, + uintptr_t host_pc, bool reset_icount); =20 /* Return the current PC from CPU, which may be cached in TB. */ static inline target_ulong log_pc(CPUState *cpu, const TranslationBlock *t= b) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index e948992a80..7d851f5907 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -39,20 +39,33 @@ typedef ram_addr_t tb_page_addr_t; #define TB_PAGE_ADDR_FMT RAM_ADDR_FMT #endif =20 +/** + * cpu_unwind_state_data: + * @cpu: the cpu context + * @host_pc: the host pc within the translation + * @data: output data + * + * Attempt to load the the unwind state for a host pc occurring in + * translated code. If @host_pc is not in translated code, the + * function returns false; otherwise @data is loaded. + * This is the same unwind info as given to restore_state_to_opc. + */ +bool cpu_unwind_state_data(CPUState *cpu, uintptr_t host_pc, uint64_t *dat= a); + /** * cpu_restore_state: - * @cpu: the vCPU state is to be restore to - * @searched_pc: the host PC the fault occurred at + * @cpu: the cpu context + * @host_pc: the host pc within the translation * @will_exit: true if the TB executed will be interrupted after some cpu adjustments. Required for maintaining the correct icount valus * @return: true if state was restored, false otherwise * * Attempt to restore the state for a fault occurring in translated - * code. If the searched_pc is not in translated code no state is + * code. If @host_pc is not in translated code no state is * restored and the function returns false. */ -bool cpu_restore_state(CPUState *cpu, uintptr_t searched_pc, bool will_exi= t); +bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit); =20 G_NORETURN void cpu_loop_exit_noexc(CPUState *cpu); G_NORETURN void cpu_loop_exit(CPUState *cpu); diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index f185356a36..319becb698 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -247,52 +247,66 @@ static int encode_search(TranslationBlock *tb, uint8_= t *block) return p - block; } =20 -/* The cpu state corresponding to 'searched_pc' is restored. - * When reset_icount is true, current TB will be interrupted and - * icount should be recalculated. - */ -int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, - uintptr_t searched_pc, bool reset_icount) +static int cpu_unwind_data_from_tb(TranslationBlock *tb, uintptr_t host_pc, + uint64_t *data) { - uint64_t data[TARGET_INSN_START_WORDS]; - uintptr_t host_pc =3D (uintptr_t)tb->tc.ptr; + uintptr_t iter_pc =3D (uintptr_t)tb->tc.ptr; const uint8_t *p =3D tb->tc.ptr + tb->tc.size; int i, j, num_insns =3D tb->icount; -#ifdef CONFIG_PROFILER - TCGProfile *prof =3D &tcg_ctx->prof; - int64_t ti =3D profile_getclock(); -#endif =20 - searched_pc -=3D GETPC_ADJ; + host_pc -=3D GETPC_ADJ; =20 - if (searched_pc < host_pc) { + if (host_pc < iter_pc) { return -1; } =20 - memset(data, 0, sizeof(data)); + memset(data, 0, sizeof(uint64_t) * TARGET_INSN_START_WORDS); if (!TARGET_TB_PCREL) { data[0] =3D tb_pc(tb); } =20 - /* Reconstruct the stored insn data while looking for the point at - which the end of the insn exceeds the searched_pc. */ + /* + * Reconstruct the stored insn data while looking for the point + * at which the end of the insn exceeds host_pc. + */ for (i =3D 0; i < num_insns; ++i) { for (j =3D 0; j < TARGET_INSN_START_WORDS; ++j) { data[j] +=3D decode_sleb128(&p); } - host_pc +=3D decode_sleb128(&p); - if (host_pc > searched_pc) { - goto found; + iter_pc +=3D decode_sleb128(&p); + if (iter_pc > host_pc) { + return num_insns - i; } } return -1; +} + +/* + * The cpu state corresponding to 'host_pc' is restored. + * When reset_icount is true, current TB will be interrupted and + * icount should be recalculated. + */ +void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, + uintptr_t host_pc, bool reset_icount) +{ + uint64_t data[TARGET_INSN_START_WORDS]; +#ifdef CONFIG_PROFILER + TCGProfile *prof =3D &tcg_ctx->prof; + int64_t ti =3D profile_getclock(); +#endif + int insns_left =3D cpu_unwind_data_from_tb(tb, host_pc, data); + + if (insns_left < 0) { + return; + } =20 - found: if (reset_icount && (tb_cflags(tb) & CF_USE_ICOUNT)) { assert(icount_enabled()); - /* Reset the cycle counter to the start of the block - and shift if to the number of actually executed instructions */ - cpu_neg(cpu)->icount_decr.u16.low +=3D num_insns - i; + /* + * Reset the cycle counter to the start of the block and + * shift if to the number of actually executed instructions. + */ + cpu_neg(cpu)->icount_decr.u16.low +=3D insns_left; } =20 cpu->cc->tcg_ops->restore_state_to_opc(cpu, tb, data); @@ -302,7 +316,6 @@ int cpu_restore_state_from_tb(CPUState *cpu, Translatio= nBlock *tb, prof->restore_time + profile_getclock() - ti); qatomic_set(&prof->restore_count, prof->restore_count + 1); #endif - return 0; } =20 bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit) @@ -335,6 +348,17 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t host_p= c, bool will_exit) return false; } =20 +bool cpu_unwind_state_data(CPUState *cpu, uintptr_t host_pc, uint64_t *dat= a) +{ + if (in_code_gen_buffer((const void *)(host_pc - tcg_splitwx_diff))) { + TranslationBlock *tb =3D tcg_tb_lookup(host_pc); + if (tb) { + return cpu_unwind_data_from_tb(tb, host_pc, data) >=3D 0; + } + } + return false; +} + void page_init(void) { page_size_init(); --=20 2.34.1 From nobody Sat May 18 10:30:12 2024 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666865199; cv=none; d=zohomail.com; s=zohoarc; b=NZK33SGwTtHfQr5sgPV9U2jW+7O53s2xrtGuN2FwxaaC4KemshlQ0qKZL2Y7BcgCcEMxE1Y5mQUb3nGAfMX5T05IBXvZbW+asdKUx1LClF7rQCuS8wcD3to5WXjbO0rqNeq3cbdJgmywLO72vxu7BJWse6aIJ0q+w8qLh8nJs+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666865199; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=frs+W2o45yhX0BGjDiwQgjk/MyzDxe9aB6tmUVXaXnc=; b=Bxin8lxBUz1mxNEa7y2RY/pfzUNUlKDoUM8Pe6EY6tmqrzuyYr9msYC0gKsj5CrofQv51w4D/9eymo/zMclxnL9wDZ7nm+kJ9XKfu9ZaCJeBB6t7lzZC+09nl3XTsPYOaqcHv2mAP4TKfO3AU2BNlV/83AFW/HTIuYnpmjZzDHg= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666865199547676.7351632447812; Thu, 27 Oct 2022 03:06:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onzje-0007tD-Df; Thu, 27 Oct 2022 06:03: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 1onzjS-00078k-B3 for qemu-devel@nongnu.org; Thu, 27 Oct 2022 06:03:30 -0400 Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onzjP-0004GF-2M for qemu-devel@nongnu.org; Thu, 27 Oct 2022 06:03:25 -0400 Received: by mail-oi1-x22e.google.com with SMTP id r187so1269409oia.8 for ; Thu, 27 Oct 2022 03:03:22 -0700 (PDT) Received: from localhost.localdomain ([2001:8003:501a:d301:3a91:9408:3918:55a]) by smtp.gmail.com with ESMTPSA id n13-20020a17090a2bcd00b0020a825fc912sm2354631pje.45.2022.10.27.03.03.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 03:03:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=frs+W2o45yhX0BGjDiwQgjk/MyzDxe9aB6tmUVXaXnc=; b=Hp+yw86AcrWqTBhyTzK12oyevSFNr6K35CAcFznA3/ya2Rx8n/KmyYNyKfVeupegU2 wAlEVC02S5fyfIfe1UZrgTrILfiXVny2xceQ6NZu8JClFAG+amJbjeWMsOcS94Sw/O+M HqlFkCon3LidSztiaXW0RZ5W0mbyiJeOfmlVyBogfJc4UMJoDxtBCI9ehsNyo8HMplzK AMtQL2dkNLz9UHVnbbyvO1f0qE4wJ8Z+iYEyrcpynrBfILFatx9PhopYSL2eZQP0y52R CxRCG40tRwy8q6PnRWzCjc9fOvKi1U5Gix3Okm85/NeemWoN40dNPuKfpZ8iZA8kRkCw COqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=frs+W2o45yhX0BGjDiwQgjk/MyzDxe9aB6tmUVXaXnc=; b=rK9E2A4X3wm0SSdPWgcEJptfsENm46jkIt8+BAHWrbwBfWTcZlGrcapCVjLiaaYVMH 8vR5m0H9X6tpr9IVGGYTj/sfUjNENtT0ia88MSws6Bl7huJVRTNcisf6ssTteGdakXkN BfSP3cICAD6gbQvJfF779oMEJfhXkVG1qaKws1em4bPWkiC5TilYAPDw0RhrcQT+12K0 geN+5KD5qU9Ry68XhM4GiRo4zrLdopRWY9xGDv3+xJd3u2Oi6J+z0Gu3xb4O/zs0iKxB Rs316QlYNHq90Mp9dncbalEHQuyz0Bn5slP85M7IikyPXJBlVFj/CHWXl8tG7oy6k0Qh ynuA== X-Gm-Message-State: ACrzQf3ATzCUvqJbSSG0DrqwFKh6/l395P+zTd2W0Lh/EzwcEKVMIXm4 dfEv5y7nPgl9RNi5oqhQHIPH4/z4wv0EuurO X-Google-Smtp-Source: AMsMyM7zs6SjSIiFllyQ+QygM5+CzwnewwChYkVwhoz9umHIahvRRjOZMMF9qGEOgcgtH2FBPVyYlw== X-Received: by 2002:a17:90b:1a8a:b0:213:20c:a427 with SMTP id ng10-20020a17090b1a8a00b00213020ca427mr9349640pjb.9.1666864990620; Thu, 27 Oct 2022 03:03:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: cfontana@suse.de Subject: [PATCH v2 2/6] target/i386: Use cpu_unwind_state_data for tpr access Date: Thu, 27 Oct 2022 21:02:50 +1100 Message-Id: <20221027100254.215253-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221027100254.215253-1-richard.henderson@linaro.org> References: <20221027100254.215253-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::22e; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22e.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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666865200413100001 Content-Type: text/plain; charset="utf-8" Avoid cpu_restore_state, and modifying env->eip out from underneath the translator with TARGET_TB_PCREL. There is some slight duplication from x86_restore_state_to_opc, but it's just a few lines. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1269 Signed-off-by: Richard Henderson Reviewed-by: Claudio Fontana --- target/i386/helper.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/target/i386/helper.c b/target/i386/helper.c index b62a1e48e2..2cd1756f1a 100644 --- a/target/i386/helper.c +++ b/target/i386/helper.c @@ -509,6 +509,23 @@ void cpu_x86_inject_mce(Monitor *mon, X86CPU *cpu, int= bank, } } =20 +static target_ulong get_memio_eip(CPUX86State *env) +{ + uint64_t data[TARGET_INSN_START_WORDS]; + CPUState *cs =3D env_cpu(env); + + if (!cpu_unwind_state_data(cs, cs->mem_io_pc, data)) { + return env->eip; + } + + /* Per x86_restore_state_to_opc. */ + if (TARGET_TB_PCREL) { + return (env->eip & TARGET_PAGE_MASK) | data[0]; + } else { + return data[0] - env->segs[R_CS].base; + } +} + void cpu_report_tpr_access(CPUX86State *env, TPRAccess access) { X86CPU *cpu =3D env_archcpu(env); @@ -519,9 +536,9 @@ void cpu_report_tpr_access(CPUX86State *env, TPRAccess = access) =20 cpu_interrupt(cs, CPU_INTERRUPT_TPR); } else if (tcg_enabled()) { - cpu_restore_state(cs, cs->mem_io_pc, false); + target_ulong eip =3D get_memio_eip(env); =20 - apic_handle_tpr_access_report(cpu->apic_state, env->eip, access); + apic_handle_tpr_access_report(cpu->apic_state, eip, access); } } #endif /* !CONFIG_USER_ONLY */ --=20 2.34.1 From nobody Sat May 18 10:30:12 2024 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666865242; cv=none; d=zohomail.com; s=zohoarc; b=LWRf7KYdj8O8gGT/gboQQx2sG+9BS9iuk80m3QmfThZmktUyzeyumgW43PWBWVgMHEkEOJDxbt7KESvkWJUO4DBsTzFV1gc+CnE+/GBmSZzuGS5t7p2PJok7lOdfLtzlmMlrUgYHGXzjp1G/GlFCcKrPTFKr9nmlR6rAte5Kaq4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666865242; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=27tU7q4skqyWhNaj53PDReLhseNs0R74OdN+/vV4qx0=; b=R/ORlpArxAQseNJEJOeCBuXRTlBNeGKrjTCqAl7hUHPfIZ4Xum2E52corhxBI/zSTQVWWysC2Pr1eomEYUF0YHzXtLFCgvLGCJqNqr6bAsWdIVK27c2xZngWuL24LGOdVeq2a7Tf+7PVnIaKcNHKQmf+Rlti/fqi3c4/GnCbHd8= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666865242635681.8809231253537; Thu, 27 Oct 2022 03:07:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onzjb-0007mq-N9; Thu, 27 Oct 2022 06:03:35 -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 1onzjK-00074D-Kq for qemu-devel@nongnu.org; Thu, 27 Oct 2022 06:03:22 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onzjI-0004Fk-Gw for qemu-devel@nongnu.org; Thu, 27 Oct 2022 06:03:17 -0400 Received: by mail-pf1-x42d.google.com with SMTP id e4so1008024pfl.2 for ; Thu, 27 Oct 2022 03:03:15 -0700 (PDT) Received: from localhost.localdomain ([2001:8003:501a:d301:3a91:9408:3918:55a]) by smtp.gmail.com with ESMTPSA id n13-20020a17090a2bcd00b0020a825fc912sm2354631pje.45.2022.10.27.03.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 03:03:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=27tU7q4skqyWhNaj53PDReLhseNs0R74OdN+/vV4qx0=; b=afTJeOoXkkYIDOk3H7ZGJ4lUWq+jJsPbsXfvwL7lcFznokxqDDe5f+kb0vW0606uog qvAjy1sPR1cchr2Uuz5njE5uo+fNmTuvhnApbG268B2Xh++pCMgUq6EQkUL6m18jGoJi AR2eA+2h74BqNOEk/rjHetd/KaqJks8XNPzpuq7msvTfksi7W7GM1QdO4q+MyIDrEE6/ 7hE0+936iSnC15K1AEwhGsMR0hrDY2aRqrkHdgaPjkwiySaHsC0U1D/THlfLMX6GRtTJ 1IPdLV+8UI5iIuICgwFmiIvFOr80Wzh4QAWp21ZXCKDM+P4VTs4L2tDyIsRo53rJ91eL C+gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=27tU7q4skqyWhNaj53PDReLhseNs0R74OdN+/vV4qx0=; b=SF1lXl5M7gxT1/LxFs2gVGjM6cXNB94CmtBNoKskCYINVnOfbcrk1nwdHG8B2IlSTM Ac78wvSyZJND5detPjd4Mb3X19X/ELzo147XOAWbKhMyzeqBQe0ifm2Oc4gNQO79E5Kn xhdQkhUuuA6QV30uxDX5JbAK3a2VQqVjHjkVvV8SQOTtN175VuTfHSC4zIieZMxVkois CLprw58C5EwsL+iUrEWq963pF6Idinxx8eggrwA/P3NSfL218K9dmj9w1bYu71MIHRoA UIlyygS5kxF9dVQUvCQ9hQLpk1jgEHBhlEXN+RelfBzAfPfVnXeGDjU6PfFa6pxAWOHa 6iUQ== X-Gm-Message-State: ACrzQf3tW2MN5w/4/6D+qa+fNO2RtLKxiYImJRl3KDODWymmUK28cEZr bibMus/uTbfK9VfyKoDO0W5rRGsC9jRTbG5E X-Google-Smtp-Source: AMsMyM778PONPyoUHLPp7pfRGBR2hZPAmU2OPdtnz3Jq+IXDYCeDsd2NFGDuz+fttcy5PjhXFpphyw== X-Received: by 2002:a65:6041:0:b0:449:8b9c:8d29 with SMTP id a1-20020a656041000000b004498b9c8d29mr40411698pgp.335.1666864994205; Thu, 27 Oct 2022 03:03:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: cfontana@suse.de Subject: [PATCH v2 3/6] target/openrisc: Always exit after mtspr npc Date: Thu, 27 Oct 2022 21:02:51 +1100 Message-Id: <20221027100254.215253-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221027100254.215253-1-richard.henderson@linaro.org> References: <20221027100254.215253-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666865244800100001 Content-Type: text/plain; charset="utf-8" We have called cpu_restore_state asserting will_exit. Do not go back on that promise. This affects icount. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/openrisc/sys_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index 09b3c97d7c..a3508e421d 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -51,8 +51,8 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong sp= r, target_ulong rb) if (env->pc !=3D rb) { env->pc =3D rb; env->dflag =3D 0; - cpu_loop_exit(cs); } + cpu_loop_exit(cs); break; =20 case TO_SPR(0, 17): /* SR */ --=20 2.34.1 From nobody Sat May 18 10:30:12 2024 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666865432; cv=none; d=zohomail.com; s=zohoarc; b=E/VYdm5WCh712IcZCVyaqSqck278h92S8TxsdTfxY7xRmJmHaLrrRfftXZg60YkOJbUWTGIzVwP1AeJo/H7tHVSEcMZaJ3HMTIy95cdGzSTpc7UQ/1jptYTGlwxiKDHD9tSpWSQ5f+9qjVdzOV6Xew6E3VdmZV62S2mNwAfYW0I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666865432; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Oz6SbhxWMBqT3eH0LGJA5+0yBaJCELCj9GF6rT/F9o0=; b=dlgHYsexVMk6N36amw8w8UabtoigAAw/K5HcPB+IKJSoi2xkcU3BtCLq0ebY7/D8YanXrStvvA13x9Uq7PSOZsHNtP2/kGTI3vyEqgDcpYYVIhwPTXEnBoG6r/wydfudBkEoitHPlA66o3PCSoRu1bwE98rfmibDofFpMpVqXds= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666865432373809.1620216406108; Thu, 27 Oct 2022 03:10:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onzjd-0007pL-62; Thu, 27 Oct 2022 06:03:37 -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 1onzjQ-00078d-DT for qemu-devel@nongnu.org; Thu, 27 Oct 2022 06:03:28 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onzjO-0004GB-4f for qemu-devel@nongnu.org; Thu, 27 Oct 2022 06:03:23 -0400 Received: by mail-pg1-x530.google.com with SMTP id h185so827529pgc.10 for ; Thu, 27 Oct 2022 03:03:20 -0700 (PDT) Received: from localhost.localdomain ([2001:8003:501a:d301:3a91:9408:3918:55a]) by smtp.gmail.com with ESMTPSA id n13-20020a17090a2bcd00b0020a825fc912sm2354631pje.45.2022.10.27.03.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 03:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=Oz6SbhxWMBqT3eH0LGJA5+0yBaJCELCj9GF6rT/F9o0=; b=Z6IpPF6YEC3aoReax7k9p+yt6O0jopCUepnfq6j0IY2m9QhiFdxG25MilVlY7fyO1L 2pG7HIxRblOvfXPWX7aGJspS1g1dGagzFsHv64x5CVhz0BfvhJh9tY6i3bvpeEHwtPx9 RmKD5PnnHF9Efs8k4R8krWCXDZfn23W72JUZ36ufTIWi2ioJQgF6HEnGFt3sd59e5EqQ 0RNFPtVI10WE71JEYNoLiZdBN+BbGesPzoKlrjUeDkB3wDmYtLBjIMtRodGpECe9/X4U oixXO+JLFaJ7SlhrRkJZA6sDn3+GkCzg5F9hkDCoY18tyHQyFKsH728T4zD+EVyKpK54 Jp4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Oz6SbhxWMBqT3eH0LGJA5+0yBaJCELCj9GF6rT/F9o0=; b=vMRJPVfgV7BhRie1jTgLfIlHV9nFMLVRp9JNkQrGDjukwdM50g0XldgptBcPiHTuPR jyhu1EZPegM54b87yVXmm35cYdaj4IshombJc+eD6QP97LpxN2Sy/rfVqUhiUNb4/+cQ CIO0Qqi6Qdk/fE2F0i8CzT9hIU+g2mNRBq/EBvrVwCWJ2BCYBvdIlbUo/q7WMW2BpcU2 rXp5IxhtqwZ8p2G5luW933n/N9n8GPbCO02QB+hIYeO87a8mQqq0CKBdWz+yKkk+iVwK F4v0ENe8j99msMRrzXQkEROnG+2WnA3pPlh05LzIsr4bof/l5292k2mMOmBeKNYFea7G TmsA== X-Gm-Message-State: ACrzQf1H74I0i8IK07DKwvJqvv1vWFvKk4l06GmiYV6c3mfwkAZVv3qz 8f5xWuG0aFIKOJw1bGFsrLomQristhEx5kDX X-Google-Smtp-Source: AMsMyM57l56RZ16vJayfbFJ3SBO/32a1MCsASmXACW/SmeMTKEXqjHbZypxbY5cDlkGCwwj+5fF2Xg== X-Received: by 2002:a63:e211:0:b0:43b:f03e:3cc5 with SMTP id q17-20020a63e211000000b0043bf03e3cc5mr41866170pgh.256.1666864999682; Thu, 27 Oct 2022 03:03:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: cfontana@suse.de Subject: [PATCH v2 4/6] target/openrisc: Use cpu_unwind_state_data for mfspr Date: Thu, 27 Oct 2022 21:02:52 +1100 Message-Id: <20221027100254.215253-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221027100254.215253-1-richard.henderson@linaro.org> References: <20221027100254.215253-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666865434609100003 Content-Type: text/plain; charset="utf-8" Since we do not plan to exit, use cpu_unwind_state_data and extract exactly the data requested. Signed-off-by: Richard Henderson --- target/openrisc/sys_helper.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index a3508e421d..dde2fa1623 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -199,6 +199,7 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, targe= t_ulong rd, target_ulong spr) { #ifndef CONFIG_USER_ONLY + uint64_t data[TARGET_INSN_START_WORDS]; MachineState *ms =3D MACHINE(qdev_get_machine()); OpenRISCCPU *cpu =3D env_archcpu(env); CPUState *cs =3D env_cpu(env); @@ -232,14 +233,20 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, tar= get_ulong rd, return env->evbar; =20 case TO_SPR(0, 16): /* NPC (equals PC) */ - cpu_restore_state(cs, GETPC(), false); + if (cpu_unwind_state_data(cs, GETPC(), data)) { + return data[0]; + } return env->pc; =20 case TO_SPR(0, 17): /* SR */ return cpu_get_sr(env); =20 case TO_SPR(0, 18): /* PPC */ - cpu_restore_state(cs, GETPC(), false); + if (cpu_unwind_state_data(cs, GETPC(), data)) { + if (data[1] & 2) { + return data[0] - 4; + } + } return env->ppc; =20 case TO_SPR(0, 32): /* EPCR */ --=20 2.34.1 From nobody Sat May 18 10:30:12 2024 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666865215; cv=none; d=zohomail.com; s=zohoarc; b=Pe/R4lAaZMJ3qNeStGFe0td5E6wUDHNoSXLVdS3NPwW7Aiq6zYCY7YwwV4LFpVj+6p+kbU3cQy3O0HGiRY2Hq76rDh1dhMy1V9BJxTdSSSKZ8C9cR0k1M803SrhP68xp/Ctyv9FAGVMtWHgsqkbtVez2wRNvRr3l+dM4p3LQwtg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666865215; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=C9qAXoDzlHGtWJjESxhzwvdwIiiEZj3DJdEKDv+hjRU=; b=FsWv1Lwe81HvXm/R1yDCGtrTXANnGW/K3VHV1fcci573UxaQkrxoUNrOj0kEp40UNIBpR81qjvHLP/23gT+JlksKapq7bNHns/H96FW/8NqEJk0+xYwZtsimqWxBKJ8MvM/yCUwaqC9mKHuy4cYCEpeGD8u2N0qxDYCSol4aINs= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666865215250405.6133819109616; Thu, 27 Oct 2022 03:06:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onzjh-000817-8U; Thu, 27 Oct 2022 06:03:41 -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 1onzjU-0007Au-Oz for qemu-devel@nongnu.org; Thu, 27 Oct 2022 06:03:31 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onzjS-0004GM-4G for qemu-devel@nongnu.org; Thu, 27 Oct 2022 06:03:28 -0400 Received: by mail-pl1-x633.google.com with SMTP id d24so921111pls.4 for ; Thu, 27 Oct 2022 03:03:24 -0700 (PDT) Received: from localhost.localdomain ([2001:8003:501a:d301:3a91:9408:3918:55a]) by smtp.gmail.com with ESMTPSA id n13-20020a17090a2bcd00b0020a825fc912sm2354631pje.45.2022.10.27.03.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 03:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=C9qAXoDzlHGtWJjESxhzwvdwIiiEZj3DJdEKDv+hjRU=; b=h21+ZlQTNV01rfBSlIeJKJmHuUNU0aozL+UEAbujbEHEq83uLuf99BcuaMQEyJW4/N uW09JAH6oH4GyNWpf1iS0BV8k+i5R7a1VOUGBEeDrU5yd+8te6H65n6P84/hs5NMXhFT EQMVFW7x8tAmSEpN6sykdHzSexqSR8IT7Vlr6AnzPOGPJALsPFxUJRCTrZLeXQRr6T3Y DrNO5sFDZZH3lOuTWq2RGAdEmRgqxy49df5vglteZldbCn+iHkNCNOk8pOfFawpg2Kxa 7YLCJBycF+iFFqazz4QqE+OqkZxMId1uDr4O2y4D4Im4lHpIEdZrogQipXDl7VZlD6NP /Vog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=C9qAXoDzlHGtWJjESxhzwvdwIiiEZj3DJdEKDv+hjRU=; b=QAHKLReSRT/PiezuV+Q212PjNnbBw2JbRTpsyXUwao4pUBYPa4phF+10kz1VHbQXb7 TNfn7cmjB8QQkAKl8XLzlGmaPLfjt0g3siQ/EulZZ2JA3BqUI+/emVaeeaF17h3ZKp9l dQ3lmeccgfqPEGRhtA+w0kcE6AC3NTbSf0595UjZFiVo6SMwdellsTQ44KlP95HwdxU9 QJ5yKQn+asIgAF7c0MNFhpt152+8mDe6xo6bZh+juzw2ceg8SA8Lpvn4GPH5IGTkxvMH BAi7rUAr+As5F+KYSus0+Jtm/RtMG/VY7Nt71usHXbWO+on04lPSQ+zFtilbIKCbMLEj dwAA== X-Gm-Message-State: ACrzQf01yaxokVmgytdbaHnxMeI9s51pk4KFBLK449MD0OnS6il5K8MQ 5ycCyLGctxqNMXjTbbk5fWcl1yLz6yBM9xKV X-Google-Smtp-Source: AMsMyM4gwrLiC/ul1QvLilkmTgDcpNdftXTZRla4bA1PKdSrdM8ayYN+XUjKtoF7wTvwuqYK3L4iRw== X-Received: by 2002:a17:90b:4a02:b0:213:63e7:d0b1 with SMTP id kk2-20020a17090b4a0200b0021363e7d0b1mr6039669pjb.208.1666865003763; Thu, 27 Oct 2022 03:03:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: cfontana@suse.de Subject: [PATCH v2 5/6] accel/tcg: Remove will_exit argument from cpu_restore_state Date: Thu, 27 Oct 2022 21:02:53 +1100 Message-Id: <20221027100254.215253-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221027100254.215253-1-richard.henderson@linaro.org> References: <20221027100254.215253-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666865216504100001 Content-Type: text/plain; charset="utf-8" The value passed is always true, and if the target's synchronize_from_tb hook is non-trivial, not exiting may be erroneous. Reviewed-by: Claudio Fontana Signed-off-by: Richard Henderson --- include/exec/exec-all.h | 5 +---- accel/tcg/cpu-exec-common.c | 2 +- accel/tcg/translate-all.c | 12 ++---------- target/alpha/helper.c | 2 +- target/alpha/mem_helper.c | 2 +- target/arm/op_helper.c | 2 +- target/arm/tlb_helper.c | 8 ++++---- target/cris/helper.c | 2 +- target/i386/tcg/sysemu/svm_helper.c | 2 +- target/m68k/op_helper.c | 4 ++-- target/microblaze/helper.c | 2 +- target/nios2/op_helper.c | 2 +- target/openrisc/sys_helper.c | 4 ++-- target/ppc/excp_helper.c | 2 +- target/s390x/tcg/excp_helper.c | 2 +- target/tricore/op_helper.c | 2 +- target/xtensa/helper.c | 6 +++--- 17 files changed, 25 insertions(+), 36 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 7d851f5907..9b7bfbf09a 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -56,16 +56,13 @@ bool cpu_unwind_state_data(CPUState *cpu, uintptr_t hos= t_pc, uint64_t *data); * cpu_restore_state: * @cpu: the cpu context * @host_pc: the host pc within the translation - * @will_exit: true if the TB executed will be interrupted after some - cpu adjustments. Required for maintaining the correct - icount valus * @return: true if state was restored, false otherwise * * Attempt to restore the state for a fault occurring in translated * code. If @host_pc is not in translated code no state is * restored and the function returns false. */ -bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit); +bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc); =20 G_NORETURN void cpu_loop_exit_noexc(CPUState *cpu); G_NORETURN void cpu_loop_exit(CPUState *cpu); diff --git a/accel/tcg/cpu-exec-common.c b/accel/tcg/cpu-exec-common.c index be6fe45aa5..c7bc8c6efa 100644 --- a/accel/tcg/cpu-exec-common.c +++ b/accel/tcg/cpu-exec-common.c @@ -71,7 +71,7 @@ void cpu_loop_exit(CPUState *cpu) void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc) { if (pc) { - cpu_restore_state(cpu, pc, true); + cpu_restore_state(cpu, pc); } cpu_loop_exit(cpu); } diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 319becb698..90997fed47 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -318,16 +318,8 @@ void cpu_restore_state_from_tb(CPUState *cpu, Translat= ionBlock *tb, #endif } =20 -bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit) +bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc) { - /* - * The pc update associated with restore without exit will - * break the relative pc adjustments performed by TARGET_TB_PCREL. - */ - if (TARGET_TB_PCREL) { - assert(will_exit); - } - /* * The host_pc has to be in the rx region of the code buffer. * If it is not we will not be able to resolve it here. @@ -341,7 +333,7 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc= , bool will_exit) if (in_code_gen_buffer((const void *)(host_pc - tcg_splitwx_diff))) { TranslationBlock *tb =3D tcg_tb_lookup(host_pc); if (tb) { - cpu_restore_state_from_tb(cpu, tb, host_pc, will_exit); + cpu_restore_state_from_tb(cpu, tb, host_pc, true); return true; } } diff --git a/target/alpha/helper.c b/target/alpha/helper.c index a5a389b5a3..970c869771 100644 --- a/target/alpha/helper.c +++ b/target/alpha/helper.c @@ -532,7 +532,7 @@ G_NORETURN void dynamic_excp(CPUAlphaState *env, uintpt= r_t retaddr, cs->exception_index =3D excp; env->error_code =3D error; if (retaddr) { - cpu_restore_state(cs, retaddr, true); + cpu_restore_state(cs, retaddr); /* Floating-point exceptions (our only users) point to the next PC= . */ env->pc +=3D 4; } diff --git a/target/alpha/mem_helper.c b/target/alpha/mem_helper.c index 47283a0612..a39b52c5dd 100644 --- a/target/alpha/mem_helper.c +++ b/target/alpha/mem_helper.c @@ -28,7 +28,7 @@ static void do_unaligned_access(CPUAlphaState *env, vaddr= addr, uintptr_t retadd uint64_t pc; uint32_t insn; =20 - cpu_restore_state(env_cpu(env), retaddr, true); + cpu_restore_state(env_cpu(env), retaddr); =20 pc =3D env->pc; insn =3D cpu_ldl_code(env, pc); diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index c5bde1cfcc..70672bcd9f 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -78,7 +78,7 @@ void raise_exception_ra(CPUARMState *env, uint32_t excp, = uint32_t syndrome, * we must restore CPU state here before setting the syndrome * the caller passed us, and cannot use cpu_loop_exit_restore(). */ - cpu_restore_state(cs, ra, true); + cpu_restore_state(cs, ra); raise_exception(env, excp, syndrome, target_el); } =20 diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c index 69b0dc69df..0f4f4fc809 100644 --- a/target/arm/tlb_helper.c +++ b/target/arm/tlb_helper.c @@ -156,7 +156,7 @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr va= ddr, ARMMMUFaultInfo fi =3D {}; =20 /* now we have a real cpu fault */ - cpu_restore_state(cs, retaddr, true); + cpu_restore_state(cs, retaddr); =20 fi.type =3D ARMFault_Alignment; arm_deliver_fault(cpu, vaddr, access_type, mmu_idx, &fi); @@ -196,7 +196,7 @@ void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr= physaddr, ARMMMUFaultInfo fi =3D {}; =20 /* now we have a real cpu fault */ - cpu_restore_state(cs, retaddr, true); + cpu_restore_state(cs, retaddr); =20 fi.ea =3D arm_extabort_type(response); fi.type =3D ARMFault_SyncExternal; @@ -252,7 +252,7 @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int = size, return false; } else { /* now we have a real cpu fault */ - cpu_restore_state(cs, retaddr, true); + cpu_restore_state(cs, retaddr); arm_deliver_fault(cpu, address, access_type, mmu_idx, fi); } } @@ -271,7 +271,7 @@ void arm_cpu_record_sigsegv(CPUState *cs, vaddr addr, * We report both ESR and FAR to signal handlers. * For now, it's easiest to deliver the fault normally. */ - cpu_restore_state(cs, ra, true); + cpu_restore_state(cs, ra); arm_deliver_fault(cpu, addr, access_type, MMU_USER_IDX, &fi); } =20 diff --git a/target/cris/helper.c b/target/cris/helper.c index 91e4aeb178..81a72699b5 100644 --- a/target/cris/helper.c +++ b/target/cris/helper.c @@ -87,7 +87,7 @@ bool cris_cpu_tlb_fill(CPUState *cs, vaddr address, int s= ize, cs->exception_index =3D EXCP_BUSFAULT; env->fault_vector =3D res.bf_vec; if (retaddr) { - if (cpu_restore_state(cs, retaddr, true)) { + if (cpu_restore_state(cs, retaddr)) { /* Evaluate flags after retranslation. */ helper_top_evaluate_flags(env); } diff --git a/target/i386/tcg/sysemu/svm_helper.c b/target/i386/tcg/sysemu/s= vm_helper.c index 8e88567399..2d27731b60 100644 --- a/target/i386/tcg/sysemu/svm_helper.c +++ b/target/i386/tcg/sysemu/svm_helper.c @@ -704,7 +704,7 @@ void cpu_vmexit(CPUX86State *env, uint32_t exit_code, u= int64_t exit_info_1, { CPUState *cs =3D env_cpu(env); =20 - cpu_restore_state(cs, retaddr, true); + cpu_restore_state(cs, retaddr); =20 qemu_log_mask(CPU_LOG_TB_IN_ASM, "vmexit(%08x, %016" PRIx64 ", %016" PRIx64 ", " TARGET_FMT_lx ")!\n", diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c index 5da176d642..1ce850bbc5 100644 --- a/target/m68k/op_helper.c +++ b/target/m68k/op_helper.c @@ -460,7 +460,7 @@ void m68k_cpu_transaction_failed(CPUState *cs, hwaddr p= hysaddr, vaddr addr, M68kCPU *cpu =3D M68K_CPU(cs); CPUM68KState *env =3D &cpu->env; =20 - cpu_restore_state(cs, retaddr, true); + cpu_restore_state(cs, retaddr); =20 if (m68k_feature(env, M68K_FEATURE_M68040)) { env->mmu.mmusr =3D 0; @@ -558,7 +558,7 @@ raise_exception_format2(CPUM68KState *env, int tt, int = ilen, uintptr_t raddr) cs->exception_index =3D tt; =20 /* Recover PC and CC_OP for the beginning of the insn. */ - cpu_restore_state(cs, raddr, true); + cpu_restore_state(cs, raddr); =20 /* Flags are current in env->cc_*, or are undefined. */ env->cc_op =3D CC_OP_FLAGS; diff --git a/target/microblaze/helper.c b/target/microblaze/helper.c index a607fe68e5..98bdb82de8 100644 --- a/target/microblaze/helper.c +++ b/target/microblaze/helper.c @@ -277,7 +277,7 @@ void mb_cpu_do_unaligned_access(CPUState *cs, vaddr add= r, uint32_t esr, iflags; =20 /* Recover the pc and iflags from the corresponding insn_start. */ - cpu_restore_state(cs, retaddr, true); + cpu_restore_state(cs, retaddr); iflags =3D cpu->env.iflags; =20 qemu_log_mask(CPU_LOG_INT, diff --git a/target/nios2/op_helper.c b/target/nios2/op_helper.c index 2e30d0a908..0aaf33ffc2 100644 --- a/target/nios2/op_helper.c +++ b/target/nios2/op_helper.c @@ -40,7 +40,7 @@ void nios2_cpu_loop_exit_advance(CPUNios2State *env, uint= ptr_t retaddr) * Do this here, rather than in restore_state_to_opc(), * lest we affect QEMU internal exceptions, like EXCP_DEBUG. */ - cpu_restore_state(cs, retaddr, true); + cpu_restore_state(cs, retaddr); env->pc +=3D 4; cpu_loop_exit(cs); } diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index dde2fa1623..ec145960e3 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -45,7 +45,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong sp= r, target_ulong rb) break; =20 case TO_SPR(0, 16): /* NPC */ - cpu_restore_state(cs, GETPC(), true); + cpu_restore_state(cs, GETPC()); /* ??? Mirror or1ksim in not trashing delayed branch state when "jumping" to the current instruction. */ if (env->pc !=3D rb) { @@ -131,7 +131,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong = spr, target_ulong rb) case TO_SPR(8, 0): /* PMR */ env->pmr =3D rb; if (env->pmr & PMR_DME || env->pmr & PMR_SME) { - cpu_restore_state(cs, GETPC(), true); + cpu_restore_state(cs, GETPC()); env->pc +=3D 4; cs->halted =3D 1; raise_exception(cpu, EXCP_HALTED); diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 43f2480e94..3ded309265 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -2414,7 +2414,7 @@ void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr = vaddr, uint32_t insn; =20 /* Restore state and reload the insn we executed, for filling in DSISR= . */ - cpu_restore_state(cs, retaddr, true); + cpu_restore_state(cs, retaddr); insn =3D cpu_ldl_code(env, env->nip); =20 switch (env->mmu_model) { diff --git a/target/s390x/tcg/excp_helper.c b/target/s390x/tcg/excp_helper.c index 29ccf70df1..2cd6d062b9 100644 --- a/target/s390x/tcg/excp_helper.c +++ b/target/s390x/tcg/excp_helper.c @@ -39,7 +39,7 @@ G_NORETURN void tcg_s390_program_interrupt(CPUS390XState = *env, { CPUState *cs =3D env_cpu(env); =20 - cpu_restore_state(cs, ra, true); + cpu_restore_state(cs, ra); qemu_log_mask(CPU_LOG_INT, "program interrupt at %#" PRIx64 "\n", env->psw.addr); trigger_pgm_exception(env, code); diff --git a/target/tricore/op_helper.c b/target/tricore/op_helper.c index a79c838a92..532ae6b74c 100644 --- a/target/tricore/op_helper.c +++ b/target/tricore/op_helper.c @@ -31,7 +31,7 @@ void raise_exception_sync_internal(CPUTriCoreState *env, = uint32_t class, int tin { CPUState *cs =3D env_cpu(env); /* in case we come from a helper-call we need to restore the PC */ - cpu_restore_state(cs, pc, true); + cpu_restore_state(cs, pc); =20 /* Tin is loaded into d[15] */ env->gpr_d[15] =3D tin; diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c index e0a9caab4b..2aa9777a8e 100644 --- a/target/xtensa/helper.c +++ b/target/xtensa/helper.c @@ -253,7 +253,7 @@ void xtensa_cpu_do_unaligned_access(CPUState *cs, =20 assert(xtensa_option_enabled(env->config, XTENSA_OPTION_UNALIGNED_EXCEPTION)); - cpu_restore_state(CPU(cpu), retaddr, true); + cpu_restore_state(CPU(cpu), retaddr); HELPER(exception_cause_vaddr)(env, env->pc, LOAD_STORE_ALIGNMENT_CAUSE, addr); @@ -284,7 +284,7 @@ bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, i= nt size, } else if (probe) { return false; } else { - cpu_restore_state(cs, retaddr, true); + cpu_restore_state(cs, retaddr); HELPER(exception_cause_vaddr)(env, env->pc, ret, address); } } @@ -297,7 +297,7 @@ void xtensa_cpu_do_transaction_failed(CPUState *cs, hwa= ddr physaddr, vaddr addr, XtensaCPU *cpu =3D XTENSA_CPU(cs); CPUXtensaState *env =3D &cpu->env; =20 - cpu_restore_state(cs, retaddr, true); + cpu_restore_state(cs, retaddr); HELPER(exception_cause_vaddr)(env, env->pc, access_type =3D=3D MMU_INST_FETCH ? INSTR_PIF_ADDR_ERROR_CAUSE : --=20 2.34.1 From nobody Sat May 18 10:30:12 2024 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666865169; cv=none; d=zohomail.com; s=zohoarc; b=gC9YLd7oNiSZ36666+EmRgUI+KjBbN2Pd7e3DYH3WFhuLtmTfRTAc65rniNe8canNR6LAw93aP3DzSppYO7rVKBc5p4yMBgReRoNC9Gyg+MXlx3Xx0BgpZy3cGGaQFaFxUrOR0DUdZpJs9NqsFbldHs8M0qwY2sH/dJIAUQAM3M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666865169; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=i4zXGhAahLgSXdO3U/esGQ4mxgb9DP6esDERUUVmeB4=; b=BK8NRtf37/M9HuRa3zpYlNFNAZ3p0K3jJMP6JpRbRjfy/UXushRLU6W9Dk2HsF8pBZbNfYdzka5V2jxrx5EMkQ9NTybhmlMY8jYEbI/EFMXxRq0BlNF7w59FwHTSsGcvNbwAoQXfBb4DSGYJWsNugiDZUaNGMsGxcp+XehraOTQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666865169236297.04346199155384; Thu, 27 Oct 2022 03:06:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onzji-00083t-Dw; Thu, 27 Oct 2022 06:03:42 -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 1onzjY-0007O7-EK for qemu-devel@nongnu.org; Thu, 27 Oct 2022 06:03:32 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onzjV-0004Gd-I4 for qemu-devel@nongnu.org; Thu, 27 Oct 2022 06:03:32 -0400 Received: by mail-pg1-x531.google.com with SMTP id h2so851611pgp.4 for ; Thu, 27 Oct 2022 03:03:27 -0700 (PDT) Received: from localhost.localdomain ([2001:8003:501a:d301:3a91:9408:3918:55a]) by smtp.gmail.com with ESMTPSA id n13-20020a17090a2bcd00b0020a825fc912sm2354631pje.45.2022.10.27.03.03.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 03:03:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=i4zXGhAahLgSXdO3U/esGQ4mxgb9DP6esDERUUVmeB4=; b=kZP9a0wrjTxiZWCgdkAAOSMDxyZPtKB7Sr0kkfzSMVgib+KoU09/9I/Gqy46voRYSq OSv6T03K1HM6gVxdWI9Yq7ItWPA/vcehP90iycBOTxtnURpx1aUHfL0mcprcwVKg2I3A PPRRspUXaIQUEg8qkqFdXn4XY5hXlA1DKMrdv+L04maZE5GmBkR02Fhu9FhkBF41ii66 SVYDkHZTrvH8xzvj5fxi7J9rsZ2nVh2HumSpuH3tkNf7d484hLo/LSXqFbFc9W/ekK5l 4YunTfcPSxRriHYhdWiJgWOZqqUUki6o8gq6TIthx7zT8yJ/sLMx/aKxYqOFkWtJWFoT oDmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=i4zXGhAahLgSXdO3U/esGQ4mxgb9DP6esDERUUVmeB4=; b=wcDLTovkm9mW5zljs+v6mu6ZwXFTHGK2HAB0wqKYzPs6hZxZtURqRUJDQyVkIViPR3 AT0xaiRv5YAHG2PxvP8/yWrTZxSAeeugiO5OEnTVdbfF05oqH1wcD7WarU+X64VIrueQ N+K5YAU6GLxrAplLv6EyCeSOuUVKXqmdtSNKIbX5xlHbjeRBEJ2WpP/KfrUL4GkoyaaM F3h7Yrn0K5Al7wGZzAUX6Xr7lAw34t0ba31jNYXatE4pIpbR+RZGQcfXd2153qb5A9Nc LiHHEr2Xwygym8VgpYWT2zSKdQVAFYech9AB7idUq08k1FXRluSwCyBKlWGnXFzIcCXp M76w== X-Gm-Message-State: ACrzQf0DedicHp4mFxVcKbqduijrD+gtw63xnLKa1CXvBDvE5gpl8jKy xXpEC8Lnu0Zy7g/JJXKsxCdRBYxGktMc7blj X-Google-Smtp-Source: AMsMyM5nxpZvQZTP732Y/vPFSaKKJ0B3k1HGWtHdw8qQjTHYOn9GGZavB/gqqZ31w7OQuRb9zx/KXw== X-Received: by 2002:a63:2c4c:0:b0:434:e001:89fd with SMTP id s73-20020a632c4c000000b00434e00189fdmr41231987pgs.444.1666865006768; Thu, 27 Oct 2022 03:03:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: cfontana@suse.de Subject: [PATCH v2 6/6] accel/tcg: Remove reset_icount argument from cpu_restore_state_from_tb Date: Thu, 27 Oct 2022 21:02:54 +1100 Message-Id: <20221027100254.215253-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221027100254.215253-1-richard.henderson@linaro.org> References: <20221027100254.215253-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x531.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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666865170337100001 Content-Type: text/plain; charset="utf-8" The value passed is always true. Reviewed-by: Claudio Fontana Signed-off-by: Richard Henderson --- accel/tcg/internal.h | 2 +- accel/tcg/tb-maint.c | 4 ++-- accel/tcg/translate-all.c | 15 +++++++-------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/accel/tcg/internal.h b/accel/tcg/internal.h index 9c06b320b7..cb13bade4f 100644 --- a/accel/tcg/internal.h +++ b/accel/tcg/internal.h @@ -107,7 +107,7 @@ TranslationBlock *tb_link_page(TranslationBlock *tb, tb= _page_addr_t phys_pc, tb_page_addr_t phys_page2); bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc); void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, - uintptr_t host_pc, bool reset_icount); + uintptr_t host_pc); =20 /* Return the current PC from CPU, which may be cached in TB. */ static inline target_ulong log_pc(CPUState *cpu, const TranslationBlock *t= b) diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index c8e921089d..0cdb35548c 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -536,7 +536,7 @@ tb_invalidate_phys_page_range__locked(struct page_colle= ction *pages, * restore the CPU state. */ current_tb_modified =3D true; - cpu_restore_state_from_tb(cpu, current_tb, retaddr, true); + cpu_restore_state_from_tb(cpu, current_tb, retaddr); } #endif /* TARGET_HAS_PRECISE_SMC */ tb_phys_invalidate__locked(tb); @@ -685,7 +685,7 @@ bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr= , uintptr_t pc) * function to partially restore the CPU state. */ current_tb_modified =3D true; - cpu_restore_state_from_tb(cpu, current_tb, pc, true); + cpu_restore_state_from_tb(cpu, current_tb, pc); } #endif /* TARGET_HAS_PRECISE_SMC */ tb_phys_invalidate(tb, addr); diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 90997fed47..0089578f8f 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -282,12 +282,11 @@ static int cpu_unwind_data_from_tb(TranslationBlock *= tb, uintptr_t host_pc, } =20 /* - * The cpu state corresponding to 'host_pc' is restored. - * When reset_icount is true, current TB will be interrupted and - * icount should be recalculated. + * The cpu state corresponding to 'host_pc' is restored in + * preparation for exiting the TB. */ void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, - uintptr_t host_pc, bool reset_icount) + uintptr_t host_pc) { uint64_t data[TARGET_INSN_START_WORDS]; #ifdef CONFIG_PROFILER @@ -300,7 +299,7 @@ void cpu_restore_state_from_tb(CPUState *cpu, Translati= onBlock *tb, return; } =20 - if (reset_icount && (tb_cflags(tb) & CF_USE_ICOUNT)) { + if (tb_cflags(tb) & CF_USE_ICOUNT) { assert(icount_enabled()); /* * Reset the cycle counter to the start of the block and @@ -333,7 +332,7 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc) if (in_code_gen_buffer((const void *)(host_pc - tcg_splitwx_diff))) { TranslationBlock *tb =3D tcg_tb_lookup(host_pc); if (tb) { - cpu_restore_state_from_tb(cpu, tb, host_pc, true); + cpu_restore_state_from_tb(cpu, tb, host_pc); return true; } } @@ -1032,7 +1031,7 @@ void tb_check_watchpoint(CPUState *cpu, uintptr_t ret= addr) tb =3D tcg_tb_lookup(retaddr); if (tb) { /* We can use retranslation to find the PC. */ - cpu_restore_state_from_tb(cpu, tb, retaddr, true); + cpu_restore_state_from_tb(cpu, tb, retaddr); tb_phys_invalidate(tb, -1); } else { /* The exception probably happened in a helper. The CPU state sho= uld @@ -1068,7 +1067,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retadd= r) cpu_abort(cpu, "cpu_io_recompile: could not find TB for pc=3D%p", (void *)retaddr); } - cpu_restore_state_from_tb(cpu, tb, retaddr, true); + cpu_restore_state_from_tb(cpu, tb, retaddr); =20 /* * Some guests must re-execute the branch when re-executing a delay --=20 2.34.1