From patchwork Tue Apr 16 04:06:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 789206 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:dcf:b0:346:15ad:a2a with SMTP id dw15csp104755wrb; Mon, 15 Apr 2024 21:07:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVmA4t9ICTjFC1XkxEWP3hMFD2dAFLTw4WB20MmEwBy/mZdmcXmwzwm3sSjeBBO/C6JAsdeBgnTLukd2RyqIpNs X-Google-Smtp-Source: AGHT+IF0u1364vpNGkgsJa+5AVNrabcAH84NPs37n856rQ/MvvBocdV0FW4PKEPgE7937FGLTLqj X-Received: by 2002:a05:620a:214b:b0:788:31a1:4a16 with SMTP id m11-20020a05620a214b00b0078831a14a16mr13368347qkm.43.1713240444444; Mon, 15 Apr 2024 21:07:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713240444; cv=none; d=google.com; s=arc-20160816; b=JaBtvun/W6VXpYd3W7M/Jp5/79RchqRm2Kr6t/0Ok7KvRwS2LZUYKUPWOakLBdRcKX 45QJblwkEGOzcY4YMpmSiPZ91SQc7EuYiPP8Uikboem48PTIO2F6nDzzo0euZ3euxJC7 BIKRoPbKaMjYgEn3eibkuknMj+J9n+kS4sQD0fKzmTcdv/NKKWuK1AXG0hqpwAorGTtv ZU7N4HCx55VHyt8Sm5c3v6G2MSLvhH08IMSEETEXdw7oN/Nf8zksrRML6OKHwi/AzaNU PU41RT9Xq1Py08cHR94K4duebD+nqeQfsFyT4D6bJ1SKFEjXDD8PWsHuUabxjYK1/+/X F2vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=aAiLRxdfYErxgfOh0gQk21KRRPoDj9hGg+dmJqqgE+Q=; fh=HGMLmPLDRBgS2M2DmRioi6Q+pUL3jqoEM8UtJkY6Dtg=; b=M44h5a+Kd3Yyfn+W1Ph+ljCvhwHzmmBQl11ERVB3jZoahdEs303LmR3lTHOMlBZzzy uAcBtRcZJQMI1vSaBEs++0qN5LHYl/LkY37HOmnNFses2sT92yOQvlWME7J9pO9jZM7X 3dNIk2I17O/fcXJrWvMJ+Gdybvanw9EatgbXu0n8zLZz9cIwH3q+wMhztdvy+W7H6JbX bLyib0s1P7akAqxJL5SRR42Uuz+BB+u4B8jBEJLkRCocdTCgLbkD/GisPXdZIiS/nFcv xrYFVne2Sxu6o30Dz7PbQxtOq7x6CtsSvHyFFI5tL4o+VsgfIcf0frD4vQkI90CY1Le8 do/A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dmmm1wld; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i1-20020a37c201000000b0078ed69c7863si7066080qkm.389.2024.04.15.21.07.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Apr 2024 21:07:24 -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=dmmm1wld; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rwa5L-00081Q-6A; Tue, 16 Apr 2024 00:06:19 -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 1rwa5J-0007t8-5t for qemu-devel@nongnu.org; Tue, 16 Apr 2024 00:06:17 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rwa5H-00079u-8g for qemu-devel@nongnu.org; Tue, 16 Apr 2024 00:06:16 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1e6723c606dso14272295ad.1 for ; Mon, 15 Apr 2024 21:06:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713240374; x=1713845174; 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=aAiLRxdfYErxgfOh0gQk21KRRPoDj9hGg+dmJqqgE+Q=; b=dmmm1wld2bdTpFmPVDYZi7adYMZi+fk1ubyDMpALGVZS8AuhmDoRjn6dX7hvrCoxdv QpLgzv2tNGr6oFUDljkM66mFhgy0J4E+PExZKzzuMVcg4PvIcW3Bgjnzn4JwipRMISqQ md9WeCWnlqWc4X50XYl6DJrV9hiinGq69eONhxqL5eJrnoXoVfjjl8jE+LsuISN2UBGu Cwp9fZbuaPmrdKJ8v7SfjqAvPRsuiZC7bxFvfvLrCNM/Z0zCoshl+UEsEdPWh3iyYB3r At62ILxfPWredZPsPad/PbEQ+PVyyP8n6uFlzvK3i9fiH1anu/HfHYGEIlqAtWWUqFQc yt6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713240374; x=1713845174; 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=aAiLRxdfYErxgfOh0gQk21KRRPoDj9hGg+dmJqqgE+Q=; b=v6RdAS+4WWRSaSwFkuEqYgFauvzhXzEJcWsdPwGOLojIl64ZZ1bSmyKQMbatFx6Q53 qT0KdDdZMANrSQF0/hDquqb7WOdnG9MfHPBDz1u8QE27EbJ92Rw3iZxr80WTkkJdbkBC X5vmKPfdDe4lGb4SbmNmLGQKMcAOBXRY6RcXpNbJrHyt3Gim7QL9ct3OVseZYh8luI2M 4wfJtEiL/nV0t4gFmYI3kjzKzR0cYZZRb9mEa7jAKaNqducK+JmnhyyOEcySanu+2/gR O8ADow+mItif3D//rmRgcuk18hwseNiz3moujBY83/TTzSFqI1bjpTux+v7Jkt7ZRNSc GyIg== X-Gm-Message-State: AOJu0YyceXigHApE/Kx8+bI0c7XGrnoyW0QxVyoKrut6RIy9FNwVLgDI 2EmPxLf7v4OnlhVkDc/g5B0ngkHujFdBaJAQ8pHIaqvxBCdSxEXVBWJfl/wKA6kMXLEmLr+v4K+ y X-Received: by 2002:a17:902:ed4c:b0:1dd:e114:121c with SMTP id y12-20020a170902ed4c00b001dde114121cmr13250311plb.56.1713240373959; Mon, 15 Apr 2024 21:06:13 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id l1-20020a170902f68100b001e3e244e5c0sm8694439plg.78.2024.04.15.21.06.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 21:06:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org Subject: [PATCH 3/7] accel/tcg: Return the TranslationBlock from cpu_unwind_state_data Date: Mon, 15 Apr 2024 21:06:05 -0700 Message-Id: <20240416040609.1313605-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240416040609.1313605-1-richard.henderson@linaro.org> References: <20240416040609.1313605-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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 Fix the i386 get_memio_eip function to use tb->cflags instead of cs->tcg_cflags. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- include/exec/cpu-common.h | 9 +++++---- accel/tcg/translate-all.c | 9 +++++---- target/i386/helper.c | 6 ++++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 6346df17ce..f056132cab 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -176,12 +176,13 @@ void list_cpus(void); * @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. + * 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 NULL; + * otherwise @data is loaded and the TranslationBlock is returned. * 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 *data); +const TranslationBlock *cpu_unwind_state_data(CPUState *cpu, uintptr_t host_pc, + uint64_t *data); /** * cpu_restore_state: diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 83cc14fbde..c745bc5b6c 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -243,15 +243,16 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc) return false; } -bool cpu_unwind_state_data(CPUState *cpu, uintptr_t host_pc, uint64_t *data) +const TranslationBlock * +cpu_unwind_state_data(CPUState *cpu, uintptr_t host_pc, uint64_t *data) { if (in_code_gen_buffer((const void *)(host_pc - tcg_splitwx_diff))) { TranslationBlock *tb = tcg_tb_lookup(host_pc); - if (tb) { - return cpu_unwind_data_from_tb(tb, host_pc, data) >= 0; + if (tb && cpu_unwind_data_from_tb(tb, host_pc, data) >= 0) { + return tb; } } - return false; + return NULL; } void page_init(void) diff --git a/target/i386/helper.c b/target/i386/helper.c index 23ccb23a5b..eaa691a851 100644 --- a/target/i386/helper.c +++ b/target/i386/helper.c @@ -517,13 +517,15 @@ static inline target_ulong get_memio_eip(CPUX86State *env) #ifdef CONFIG_TCG uint64_t data[TARGET_INSN_START_WORDS]; CPUState *cs = env_cpu(env); + const TranslationBlock *tb; - if (!cpu_unwind_state_data(cs, cs->mem_io_pc, data)) { + tb = cpu_unwind_state_data(cs, cs->mem_io_pc, data); + if (!tb) { return env->eip; } /* Per x86_restore_state_to_opc. */ - if (cs->tcg_cflags & CF_PCREL) { + if (tb->cflags & CF_PCREL) { return (env->eip & TARGET_PAGE_MASK) | data[0]; } else { return data[0] - env->segs[R_CS].base;