From patchwork Thu Oct 27 10:02:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 619179 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp175916pvb; Thu, 27 Oct 2022 03:06:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5nSKNyRlarAk87L4oS2vAVuvO50p3pYVqXVuUmwzB2wTLx5CAYgr9DS3H0SXj4t/qGVZn7 X-Received: by 2002:a05:620a:2809:b0:6bc:60fa:6b93 with SMTP id f9-20020a05620a280900b006bc60fa6b93mr33211881qkp.254.1666865199615; Thu, 27 Oct 2022 03:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666865199; cv=none; d=google.com; s=arc-20160816; b=cjp8pmytGmW+WL7H5XPpKNixaei92cuaFaf5Aul3PEfZIe0kSYJuf0JSypZwAvyzvz o2/bMY62MC/yvfbLHEmi/AMcSYqDUt2MtgkkzCDrBttDKWeLFF8Rc3cDq9aCl9iWt+l+ cGG404UgyXZZeLmIAhL9yFmcUqPf9F7sSFxarOeeQKFo31NKu3JHJMLF5qERvnGQhKMX jNXo1+oOlQ0qU+Vy4qnxyojfANXFNMCBvXFwZ9JP6MiNhxqO0kCQ6ie+aQMfl1cuFUrD 3V8NV4lftxOaXXl+XR9x+b1z20vmIij8IgIK12IMDEWYfNy0cYkOleJZmF6j1XF8lSoM /RGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender: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=frs+W2o45yhX0BGjDiwQgjk/MyzDxe9aB6tmUVXaXnc=; b=wINvgw2S2dhymVkmzW4bUi6RMnlPrblUphpjrS2NlpDNEdai68Y2pvSxDKquFKrdIS mjgJWEQOwNjecFzuGj3doGPULzNkwOf6nr8cmkYAVNQbhepriog5ljwKk47oQ9xMHfXe guoESP78jct/LKGLyzYbqtk/asRXdGTkS0vZd/8rZUgYjp9uT6bqjetLsZSvO5LNpOfQ XZOuQIlKbTJdGqMjbje/XCGg4F6Ek9+1OHLeTc9ZoasO6dIfw8rE9W4ESC/mqXObat+S XSXnmG9leVp1G6xGczeP8h3d0k00jyyL7qd8z+v7W3rSZAw3/Dmiz+sB9LaSjHr5ynjd qnRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Hp+yw86A; 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 e6-20020ac86706000000b0035cdfb95e79si577460qtp.425.2022.10.27.03.06.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Oct 2022 03:06:39 -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=Hp+yw86A; 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 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org 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, } } +static target_ulong get_memio_eip(CPUX86State *env) +{ + uint64_t data[TARGET_INSN_START_WORDS]; + CPUState *cs = 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 = env_archcpu(env); @@ -519,9 +536,9 @@ void cpu_report_tpr_access(CPUX86State *env, TPRAccess access) cpu_interrupt(cs, CPU_INTERRUPT_TPR); } else if (tcg_enabled()) { - cpu_restore_state(cs, cs->mem_io_pc, false); + target_ulong eip = get_memio_eip(env); - 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 */