From patchwork Tue Apr 16 04:06:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 789203 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:dcf:b0:346:15ad:a2a with SMTP id dw15csp104693wrb; Mon, 15 Apr 2024 21:07:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW5FloxnTvGWpQgyIs73C6nWcPOyrr0XP83HAvwI7Z19NwW25OeV/yAWjQfAcvoIIMpbhNsvLSW7NFEF0Iz8N5+ X-Google-Smtp-Source: AGHT+IEdGwCcEREcg18ctN4rd8xErdwQkOEjqdOYncBpA99dAOff5Ah+vOyPW7orJLz6LNG2u9cm X-Received: by 2002:a05:620a:1092:b0:78d:77cd:1bd4 with SMTP id g18-20020a05620a109200b0078d77cd1bd4mr13341116qkk.71.1713240429502; Mon, 15 Apr 2024 21:07:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713240429; cv=none; d=google.com; s=arc-20160816; b=aTWqRVG0on6mDsu9ZXwa4c9nBI5VVK61U1vCy8Ea1amTOAPEf6dwekWWEklc8sKwBt MdRctyR76Sjc1doYIReW8Whnh2BF0Kfl2vbBSpyFEJyrG+CpEamt3trL1Y6FGJ3RORc4 N1dZ7AlNcRPV1zQnkzt7Opc7NsqwU9v5xMAir/J+aTnqe5XI9ZNDPMX2COIhJ8rrCPgZ H/dg7uHf0dDOsPsOUiE4SxiKoWkpixLC1OnjJhBtcdMANXPLuhPGI3SAe/D0qdrDlenD fuHpJhddtXZU7G/bf6vLzG4kCucj6eJNAMXOHfzZlzORlSL740ZXd1p5jVUYTwlpihza l0iA== 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=q/kvkzaV0z5p/8QW/Fxpj7Ie/nTETi6lfyNRR9fnonw=; fh=HGMLmPLDRBgS2M2DmRioi6Q+pUL3jqoEM8UtJkY6Dtg=; b=0pPZm6FavKrJP/t8ioNSHNEGyRYG43eNcxB8w2v5CYOpaRC4xqzrLy0JcTVyQ30w1q 2r/Wm+QglL6WnI0ONt0BvE/txI8IbsiymrxOsT7MO+0U92e4KlcDGK41P/h7xv4qxcXR ZhQdgULsf1XeOffPIMmpM1INr4UNtUjgLkuZDaOWuyXnwpA9gpa6quajV/8lOfl2X55Z 6M8iyafJyRpU4cpjxal+JNKE8iwjE0kQrPeRG8ASOP6yorPOzWrt6PIW5+nKZYAZO9vE bmlTds9qxmHLJPF5FYpZSzyTVmfs/vk8Dzn/v2eJbOhazJTgLhTFEIQ5wF3li9778dvq X9Ag==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R87zjJKI; 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 g8-20020a37e208000000b0078d68ef2bcbsi11328993qki.620.2024.04.15.21.07.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Apr 2024 21:07:09 -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=R87zjJKI; 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 1rwa5J-0007sz-9u; Tue, 16 Apr 2024 00:06:17 -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 1rwa5H-0007ox-PY for qemu-devel@nongnu.org; Tue, 16 Apr 2024 00:06:15 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rwa5G-00079c-6j for qemu-devel@nongnu.org; Tue, 16 Apr 2024 00:06:15 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1e2178b2cf2so36553085ad.0 for ; Mon, 15 Apr 2024 21:06:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713240372; x=1713845172; 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=q/kvkzaV0z5p/8QW/Fxpj7Ie/nTETi6lfyNRR9fnonw=; b=R87zjJKIxmKNxfeEW385F8KhXvlfNIrfrIX7Mb9PKRcEaXJOcvaRcwGhKdJBKKq8z5 Lnz6L0iDt/mVRAbLBztcQfYMJRV0rEEvs7al4p2GTJLxxymZpON4ayQT0sPOkPlituuT KEE1Du5IPm0BdYfXNNgo+xUwn2PwX+SPVSZTO4X+hvp1OduKZ9TkzcYaM9g/Zdw90bRK B90ZwIMhX7/A8tt0rhPRCxkwCZwcTR+mX1+C9P6T4q4Djivmw8kdBn/zDZ/hWqAd1hJA ITR6yDLeCb+EOoA1tOEaJMomndusyogUL9tFZqr9pBuUTXRknKqpKf76qh3nPm70eu++ I+SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713240372; x=1713845172; 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=q/kvkzaV0z5p/8QW/Fxpj7Ie/nTETi6lfyNRR9fnonw=; b=NQLMOFhArE3SU3BjMjhlzj8cFmaTzcnUFadfyPt0grqJOH3a7NyFf+AUd1a7ktmSIJ tLk9E74IB0sMuZ+2hPe+gw1hD+qo/NRf3nzYfeFCF/7jcKuvzjdQcgtxV/Qk7aWqh/fP xql+paNVNw+tu2K2ZKgPFyBcWJoFGkm/WW1FCfCCKBVzCSNmhKGUy5/hwh62wE0FJ9GZ ux+POXWAouNT3g6+Fok+Pky1biClEmlsv73bmFs8XUjgNV0rl3rp9T23N2lu+Wx+QPi3 Oi2rAoh2I7ND6SPFglg3DfReED+hZU5mBcNLn/IlYdjcQTO75mMmouxrPS3+Hr8t9Npz lgRw== X-Gm-Message-State: AOJu0YzJybsAojQFvBHRpxZw114aDwxlpAxc/oOkQlyYcKMksNkiNfxE ytQz9iIXMzvyvUTYbbwn6WLuKjcEC6IMAcmxJ+QJqwgPAPK4iSFuUtwrIzmHRVgvV510/2xHTvU J X-Received: by 2002:a17:903:287:b0:1e5:5be8:15af with SMTP id j7-20020a170903028700b001e55be815afmr16035469plr.17.1713240371908; Mon, 15 Apr 2024 21:06:11 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 21:06:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org Subject: [PATCH 1/7] tcg: Introduce INDEX_op_plugin_pc Date: Mon, 15 Apr 2024 21:06:03 -0700 Message-Id: <20240416040609.1313605-2-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::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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 Add an opcode to find a code address within the current insn, for later use with unwinding. Generate the code generically using tcg_reg_alloc_do_movi. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- include/tcg/tcg-op-common.h | 1 + include/tcg/tcg-opc.h | 1 + tcg/tcg-op.c | 5 +++++ tcg/tcg.c | 10 ++++++++++ 4 files changed, 17 insertions(+) diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h index 009e2778c5..a32c88a182 100644 --- a/include/tcg/tcg-op-common.h +++ b/include/tcg/tcg-op-common.h @@ -76,6 +76,7 @@ void tcg_gen_lookup_and_goto_ptr(void); void tcg_gen_plugin_cb(unsigned from); void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo); +void tcg_gen_plugin_pc(TCGv_ptr); /* 32 bit ops */ diff --git a/include/tcg/tcg-opc.h b/include/tcg/tcg-opc.h index 546eb49c11..087d1b82da 100644 --- a/include/tcg/tcg-opc.h +++ b/include/tcg/tcg-opc.h @@ -199,6 +199,7 @@ DEF(goto_ptr, 0, 1, 0, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) DEF(plugin_cb, 0, 0, 1, TCG_OPF_NOT_PRESENT) DEF(plugin_mem_cb, 0, 1, 1, TCG_OPF_NOT_PRESENT) +DEF(plugin_pc, 1, 0, 0, TCG_OPF_NOT_PRESENT) /* Replicate ld/st ops for 32 and 64-bit guest addresses. */ DEF(qemu_ld_a32_i32, 1, 1, 1, diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index eff3728622..b8ca78cbe4 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -322,6 +322,11 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo) tcg_gen_op2(INDEX_op_plugin_mem_cb, tcgv_i64_arg(addr), meminfo); } +void tcg_gen_plugin_pc(TCGv_ptr arg) +{ + tcg_gen_op1(INDEX_op_plugin_pc, tcgv_ptr_arg(arg)); +} + /* 32 bit ops */ void tcg_gen_discard_i32(TCGv_i32 arg) diff --git a/tcg/tcg.c b/tcg/tcg.c index d248c52e96..42e2b53729 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -4701,6 +4701,13 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) } } +static void tcg_reg_alloc_plugin_pc(TCGContext *s, const TCGOp *op) +{ + tcg_reg_alloc_do_movi(s, arg_temp(op->args[0]), + (uintptr_t)tcg_splitwx_to_rx(s->code_ptr), + op->life, output_pref(op, 0)); +} + /* * Specialized code generation for INDEX_op_dup_vec. */ @@ -6208,6 +6215,9 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb, uint64_t pc_start) case INDEX_op_mov_vec: tcg_reg_alloc_mov(s, op); break; + case INDEX_op_plugin_pc: + tcg_reg_alloc_plugin_pc(s, op); + break; case INDEX_op_dup_vec: tcg_reg_alloc_dup(s, op); break; From patchwork Tue Apr 16 04:06:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 789202 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:dcf:b0:346:15ad:a2a with SMTP id dw15csp104604wrb; Mon, 15 Apr 2024 21:06:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX+b+ty/UU/5TcWCvGhSdE81fgUZ8dsSnDjaI2s45FXMIal9ud4UZww+CuZakIegRDbHjxIamuTgybZaukrFgHi X-Google-Smtp-Source: AGHT+IE4WU/TeyRCSjK8KmngFuk8tc6OUnPdCeJZvygE6QOaTevEcDL8AtwOr9eBbUy7SFnhP6SF X-Received: by 2002:a05:620a:2a08:b0:78d:42d8:7123 with SMTP id o8-20020a05620a2a0800b0078d42d87123mr2714366qkp.21.1713240403767; Mon, 15 Apr 2024 21:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713240403; cv=none; d=google.com; s=arc-20160816; b=PcHOzrnXxGDijpZmxGvxG4JOv7fF2rBnzMSM1pva8SEwe3cEOG6T8C78mPx73K/Lmz Q5V2AcYHcRv0ZX0COf3d+Zd2NhewXRoBLw2e5EyAtx0EUE9wslAkzRj8JLPDjh2UXrLq Bapbrs8ZrHkEuTuzYh+/z1cLJUHsWhFZbeEyjFxH3hZc/OoYPloBfEVUk9JsjSmwiWHd MuvujVGm+N5dLVeVjLo/YtD3JQGfIxfc/A1W8GxfUIARPvfgBoyYNl1c8TsDvjfEHrSI ITuGya8TGHD5mOhnFlww89UEfdXlffsaiD6u5YmpIykJZ304GN2Iortsr8VrqoosS+fs tBSw== 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=3ETaHVvoHKNHLSSeeGS1BiYVkaanEylQv/HH8WSVcLo=; fh=HGMLmPLDRBgS2M2DmRioi6Q+pUL3jqoEM8UtJkY6Dtg=; b=VdGzEe3o5roBpnzHTyHudoEhiCIs370kj5WwhovICpULXOk1D0eaYUSZ7fX06IwwDR JveUVRj+LZl0GYWFOWNl5QQjIl87iSDAS4nnjmdEw3tW906FIHjV4bmbWIRQEFaSt0Po 5RRJjRaWduhVRIm15m0BZsBxKlWlMTyQpMfe9+t7UCqcIhzJWSHJ7G0BPEMsKaPNx6a9 zl2SI9ZcbEOC80njhV9a3T7KVhXSSSjtZy62xqztdItaGs6kgk1GbZQQknRYeD8zuVsz 0/8l+DZ2wn47s1vX+/4nEqPhZTsRGQctasgCScXDhgURvCscW7T5VUtvCN9dICgu9cqg 5rOw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EkHcV20Z; 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 xz14-20020a05620a5e0e00b0078d645cbc39si11590655qkn.174.2024.04.15.21.06.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Apr 2024 21:06:43 -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=EkHcV20Z; 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 1rwa5K-0007xm-ET; Tue, 16 Apr 2024 00:06:18 -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 1rwa5I-0007rZ-MA for qemu-devel@nongnu.org; Tue, 16 Apr 2024 00:06:16 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rwa5G-00079h-MQ for qemu-devel@nongnu.org; Tue, 16 Apr 2024 00:06:16 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1e5aa82d1f6so21593665ad.0 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=1713240373; x=1713845173; 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=3ETaHVvoHKNHLSSeeGS1BiYVkaanEylQv/HH8WSVcLo=; b=EkHcV20Zj/NA54i21wioS079qCAEzd26Ouu+t4j+Z7ZydDaF6JFE79ob5LcCJzspPR sP65/pDSCLPX/bQeKw+x+yAfg3tlI7T4vTM3UFxpqUarbop1NXL2Yfp/QASlsgibCzT6 m355bHJo+93+cqTv3uNg9o6diyenwDwnfY6JdA0nvleHG3qNxRMhlhqJ/I9GzhCpoKVh oe3C0ymyW7SzsTFf4mG7PPXaRsiCxp3iohVZQtmvovzrL0ljdkWMC5BzuHpbdAukjBmJ yCphbzBPfMeuuo/20VIQHQGtUsN2oeCx34pwapQpR+IWzOm0hzJYQjVUQte+EeOwo70d 8qfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713240373; x=1713845173; 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=3ETaHVvoHKNHLSSeeGS1BiYVkaanEylQv/HH8WSVcLo=; b=BFXRRlRAtaakOezLgYdJMGPwZO367iNueLRt+tseHjXtJo0hFIGsE6FHnQuR1IY4DY UaaC1OB2L4h18K3G9iec5H6cu5VZsMfDDwW1ZgPuCVQWCiiX6PiP7lI/ekc1kKuN6YMz 3AmFvv1zU9sKj3XqwKP93AmkcCofhK8zvZp0X5O1/aHOLIQJjUzifsqdn9phBIxz+foP GzgFPI1S2kxq6ijV65fus2WoSJxtUvhEFiifS2F/DPiNlLp+t9TdevqJBjbZHOM2KiG4 fau7Rm3cZIS5YW2YOnpAZeJtCRNV9m+6S1/KLzEX4AjRbPi6sowybDJnPYclvRVgygvY 1FYQ== X-Gm-Message-State: AOJu0YxYOzZmSbrrST5H8YwdC34//7rB3uQJCjgSN0rd2r601a+alO64 pbU8vN8ayiAD3OdZjWz+x1TchdJYbVNHp6o5MyFlVfgj5Vf8+8Qwxs8067K5TJY0wJBXUXM1IEX b X-Received: by 2002:a17:902:e811:b0:1e4:6cd7:30b3 with SMTP id u17-20020a170902e81100b001e46cd730b3mr1246254plg.23.1713240373219; 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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 21:06:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org Subject: [PATCH 2/7] accel/tcg: Set CPUState.plugin_ra before all plugin callbacks Date: Mon, 15 Apr 2024 21:06:04 -0700 Message-Id: <20240416040609.1313605-3-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::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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 Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- include/hw/core/cpu.h | 1 + accel/tcg/plugin-gen.c | 50 +++++++++++++++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 10cd492aff..f4af37c13d 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -350,6 +350,7 @@ typedef union IcountDecr { typedef struct CPUNegativeOffsetState { CPUTLB tlb; #ifdef CONFIG_PLUGIN + uintptr_t plugin_ra; GArray *plugin_mem_cbs; #endif IcountDecr icount_decr; diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 36e9134a5d..f96b49cce6 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -37,6 +37,12 @@ enum plugin_gen_from { PLUGIN_GEN_AFTER_TB, }; +enum plugin_gen_ra { + GEN_RA_DONE, + GEN_RA_FROM_TB, + GEN_RA_FROM_INSN, +}; + /* called before finishing a TB with exit_tb, goto_tb or goto_ptr */ void plugin_gen_disable_mem_helpers(void) { @@ -151,11 +157,38 @@ static void gen_mem_cb(struct qemu_plugin_dyn_cb *cb, tcg_temp_free_i32(cpu_index); } -static void inject_cb(struct qemu_plugin_dyn_cb *cb) +static void inject_ra(enum plugin_gen_ra *gen_ra) +{ + TCGv_ptr ra; + + switch (*gen_ra) { + case GEN_RA_DONE: + return; + case GEN_RA_FROM_TB: + ra = tcg_constant_ptr(NULL); + break; + case GEN_RA_FROM_INSN: + ra = tcg_temp_ebb_new_ptr(); + tcg_gen_plugin_pc(ra); + break; + default: + g_assert_not_reached(); + } + + tcg_gen_st_ptr(ra, tcg_env, + offsetof(CPUState, neg.plugin_ra) - + offsetof(ArchCPU, env)); + tcg_temp_free_ptr(ra); + *gen_ra = GEN_RA_DONE; +} + +static void inject_cb(struct qemu_plugin_dyn_cb *cb, + enum plugin_gen_ra *gen_ra) { switch (cb->type) { case PLUGIN_CB_REGULAR: + inject_ra(gen_ra); gen_udata_cb(cb); break; case PLUGIN_CB_INLINE: @@ -167,16 +200,18 @@ static void inject_cb(struct qemu_plugin_dyn_cb *cb) } static void inject_mem_cb(struct qemu_plugin_dyn_cb *cb, + enum plugin_gen_ra *gen_ra, enum qemu_plugin_mem_rw rw, qemu_plugin_meminfo_t meminfo, TCGv_i64 addr) { if (cb->rw & rw) { switch (cb->type) { case PLUGIN_CB_MEM_REGULAR: + inject_ra(gen_ra); gen_mem_cb(cb, meminfo, addr); break; default: - inject_cb(cb); + inject_cb(cb, gen_ra); break; } } @@ -186,6 +221,7 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) { TCGOp *op, *next; int insn_idx = -1; + enum plugin_gen_ra gen_ra; if (unlikely(qemu_loglevel_mask(LOG_TB_OP_PLUGIN) && qemu_log_in_addr_range(plugin_tb->vaddr))) { @@ -205,10 +241,12 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) */ memset(tcg_ctx->free_temps, 0, sizeof(tcg_ctx->free_temps)); + gen_ra = GEN_RA_FROM_TB; QTAILQ_FOREACH_SAFE(op, &tcg_ctx->ops, link, next) { switch (op->opc) { case INDEX_op_insn_start: insn_idx++; + gen_ra = GEN_RA_FROM_INSN; break; case INDEX_op_plugin_cb: @@ -244,7 +282,8 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) cbs = plugin_tb->cbs; for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { inject_cb( - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i)); + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i), + &gen_ra); } break; @@ -256,7 +295,8 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) cbs = insn->insn_cbs; for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { inject_cb( - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i)); + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i), + &gen_ra); } break; @@ -288,7 +328,7 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) cbs = insn->mem_cbs; for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { inject_mem_cb(&g_array_index(cbs, struct qemu_plugin_dyn_cb, i), - rw, meminfo, addr); + &gen_ra, rw, meminfo, addr); } tcg_ctx->emit_before_op = NULL; 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; From patchwork Tue Apr 16 04:06:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 789207 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:dcf:b0:346:15ad:a2a with SMTP id dw15csp104763wrb; Mon, 15 Apr 2024 21:07:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV4nXSrVRodZua5iSEb4Eau9EjpzHTFxrDzTOEExXioL9M1i2zrh01OzG9qgzSiumYiQN75a9eMl0HBL/8neHSV X-Google-Smtp-Source: AGHT+IG9XRDxmXCmraBhbqQbO0SLnZ+7ZWsjq1q1d27wrUTdmNFrTqHTPnkkDPdNl98j3mV3iXE1 X-Received: by 2002:a05:622a:a027:b0:437:3729:41ed with SMTP id jt39-20020a05622aa02700b00437372941edmr1868066qtb.0.1713240446048; Mon, 15 Apr 2024 21:07:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713240446; cv=none; d=google.com; s=arc-20160816; b=KU8CUua9YpVWzkItRElkpsfD1Slayu37BvzF5dY3R6UnvBxi8qdxNz8Xb+J95rFhnQ lN+/eztVoZFt/54cSKmomm3AefcGvQMS5uFnpIJYblwSJ0V3N9nuXnxNTqY2NQgDKdo6 fIDTh4ItlGHg5WY853vIyJHs4Tm4qN/qcJRH/FiqHWSFAYA/VXpVsEo1QRwuRQJSR6FH R6Gv0IhsEvmSom1p9nKUNDL8PuHgxmQfEls+mwJSZYZSwmR6olz+UY+FkJnrwCMVUaD9 WiVEXdZS5eO3QxkKSKYCDGVf3DjyHt6dqemnsD15CDHZcS69CdLMKvQWp5/8qxqH1c34 q7AQ== 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=cliU8saQcbFVDKE5SoNvV+Ccq9QeWmSvOygbDeWVqyc=; fh=HGMLmPLDRBgS2M2DmRioi6Q+pUL3jqoEM8UtJkY6Dtg=; b=MVF7DMwmeD36vqS+YBiKizKBxqYq/0+VA7WorcHRBt6hrUkc3OfS4atpb5ja1Gd7xY jLEpm2RnF8x79V8kIhAiZ7UAgjjYvfEGcfaNbmUU9gcdy3A/LZhHsxDdjQNhsXLWbOQE e/SOM9Z1i03tNsRTji9aGlJ5DrieAOKin0BDIDM1/5fbIkudhvUw8kFAeJzNlp7Um/d7 adpGg7rurCilCTVKtURkWRjzSxK63nrSa5DXTpkBkNfNZvBtSnY/uCNuZKEamJahiQOH Tf+Lbs/eshbz88jVM4YvawZKzhLM2mq8JXSHw90oEc2N54KRyMJpgaOY7ohhp1t17Ufg Kkdg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=luzu0gxg; 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 u12-20020a05622a14cc00b00434587753a0si11643416qtx.119.2024.04.15.21.07.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Apr 2024 21:07:26 -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=luzu0gxg; 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 1rwa5O-0008FA-Ni; Tue, 16 Apr 2024 00:06:22 -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 1rwa5L-00086k-Vk for qemu-devel@nongnu.org; Tue, 16 Apr 2024 00:06:20 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rwa5K-0007AS-1A for qemu-devel@nongnu.org; Tue, 16 Apr 2024 00:06:19 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1e2c725e234so35216825ad.1 for ; Mon, 15 Apr 2024 21:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713240375; x=1713845175; 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=cliU8saQcbFVDKE5SoNvV+Ccq9QeWmSvOygbDeWVqyc=; b=luzu0gxgEWpKRlZGu5XpCFtm6bU5c27OYDieBqxPoxVX0KE77Z2oL5dTwpC10j14VQ WWvM/jur3wZh1f7J2IPhklnQeCjUp/MOpUNGb6T5zeBsAxFXBxaw3p43wZJW4JTl4zox HW0KBYDfkKuDwrxgxv3aI/M9Th+BtWSpVRhCoXcdmXuF2N8u1anHUr1azZyd3FXurdUR KhNnAYnkm4BQaqGvFrFguPqa+DxaENiX1t6IEdmfCGnHnZpkH19k6aj/53z0mz2hZy6v mVf7oElgr3QfszFtVlb9XytDuu/TPJghoI4+3GRXiwr6mtmtbFNC1aRJhwnlHYLi0A7W 4kBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713240375; x=1713845175; 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=cliU8saQcbFVDKE5SoNvV+Ccq9QeWmSvOygbDeWVqyc=; b=P2bbQIvH1OGu1Pp00FIiipBpHLOq0bYkTfhxAWc/DR8wdYY+kslu0QFQdhXBQvUDW9 5df8xP2NvXyMQd8WiIHAbLguJe2eK3VAjmKrqp41mJzsnaQD8BGN2AxaqmS/OwiLOW0M lmYSGNL3dNmvC1/OnUE35ISd7QyG/5ixByzc0gK83BHI4/1y5RAz0wN5Cu9FoevarFeI uVuXFezEDxVjQfesLG2/sTx745330U7lN9C8GgNxRE5t9DGVxpUDTJSFB2uPhlCdmQG+ BgMtKpdRqHlNQk/68oh+oBhyptzE9fFGN5OboEq+Uc0N1kW+rifnacTWAAYbTI2+uN8g AKDg== X-Gm-Message-State: AOJu0YzeqxsYX1aImKuM+uMG6Rsrald/Nuy5utfuZQJR5sTvjY6DXrsm EP+DZ12CD7sd9nyqzfQRp+44hQLxGHMCsaujRUwDdOp3HWWuFX6I+P73hK1dV40f6rm/3UnFJyG D X-Received: by 2002:a17:902:e741:b0:1e5:5c69:fcda with SMTP id p1-20020a170902e74100b001e55c69fcdamr2235414plf.26.1713240375547; Mon, 15 Apr 2024 21:06:15 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 21:06:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org Subject: [PATCH 5/7] target/i386: Split out gdb-internal.h Date: Mon, 15 Apr 2024 21:06:07 -0700 Message-Id: <20240416040609.1313605-6-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::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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 Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Alex Bennée --- target/i386/gdb-internal.h | 65 ++++++++++++++++++++++++++++++++++++++ target/i386/gdbstub.c | 1 + 2 files changed, 66 insertions(+) create mode 100644 target/i386/gdb-internal.h diff --git a/target/i386/gdb-internal.h b/target/i386/gdb-internal.h new file mode 100644 index 0000000000..7cf4c1a656 --- /dev/null +++ b/target/i386/gdb-internal.h @@ -0,0 +1,65 @@ +/* + * x86 gdb server stub + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2013 SUSE LINUX Products GmbH + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef I386_GDB_INTERNAL_H +#define I386_GDB_INTERNAL_H + +/* + * Keep these in sync with assignment to + * gdb_num_core_regs in target/i386/cpu.c + * and with the machine description + */ + +/* + * SEG: 6 segments, plus fs_base, gs_base, kernel_gs_base + */ + +/* + * general regs -----> 8 or 16 + */ +#define IDX_NB_IP 1 +#define IDX_NB_FLAGS 1 +#define IDX_NB_SEG (6 + 3) +#define IDX_NB_CTL 6 +#define IDX_NB_FP 16 +/* + * fpu regs ----------> 8 or 16 + */ +#define IDX_NB_MXCSR 1 +/* + * total ----> 8+1+1+9+6+16+8+1=50 or 16+1+1+9+6+16+16+1=66 + */ + +#define IDX_IP_REG CPU_NB_REGS +#define IDX_FLAGS_REG (IDX_IP_REG + IDX_NB_IP) +#define IDX_SEG_REGS (IDX_FLAGS_REG + IDX_NB_FLAGS) +#define IDX_CTL_REGS (IDX_SEG_REGS + IDX_NB_SEG) +#define IDX_FP_REGS (IDX_CTL_REGS + IDX_NB_CTL) +#define IDX_XMM_REGS (IDX_FP_REGS + IDX_NB_FP) +#define IDX_MXCSR_REG (IDX_XMM_REGS + CPU_NB_REGS) + +#define IDX_CTL_CR0_REG (IDX_CTL_REGS + 0) +#define IDX_CTL_CR2_REG (IDX_CTL_REGS + 1) +#define IDX_CTL_CR3_REG (IDX_CTL_REGS + 2) +#define IDX_CTL_CR4_REG (IDX_CTL_REGS + 3) +#define IDX_CTL_CR8_REG (IDX_CTL_REGS + 4) +#define IDX_CTL_EFER_REG (IDX_CTL_REGS + 5) + +#endif diff --git a/target/i386/gdbstub.c b/target/i386/gdbstub.c index ebb000df6a..9662509b82 100644 --- a/target/i386/gdbstub.c +++ b/target/i386/gdbstub.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "include/gdbstub/helpers.h" +#include "gdb-internal.h" #ifdef TARGET_X86_64 static const int gpr_map[16] = { From patchwork Tue Apr 16 04:06:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 789205 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:dcf:b0:346:15ad:a2a with SMTP id dw15csp104709wrb; Mon, 15 Apr 2024 21:07:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVA+pOrKp78/Qqpz+512YHBcSWCfwbip7vXP5YnoaB1WCDNQBqAVHt9S4N+aQ7FP/2zmmSYVDwcKB9yQreySHI8 X-Google-Smtp-Source: AGHT+IFbE0prUxP6/6P1rpIPn9ZVXTq45Fw7X9xvSWKeSGCClrQhxVutZN2beqAi6r/p3u5dVBtu X-Received: by 2002:ac8:5d05:0:b0:437:53:4ab8 with SMTP id f5-20020ac85d05000000b0043700534ab8mr6739772qtx.1.1713240433455; Mon, 15 Apr 2024 21:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713240433; cv=none; d=google.com; s=arc-20160816; b=UYjrnFB32Nc8sA0ELIjiHwGc8Io2derp+4dB+l6WZggFigl/6H96SHSKE27DpnhEIj HxeL1pqJ/vUKiSSstGQW9id/khrKJKtDkjHWJ6iLR3+56+axUeFcdR7sAdqGo4DCSHy8 MpNo2xs1TjMzJUrS/CHhLSoA4eFC3Sjll1h9WvgMAD+w2V2jH3ksLDFar+Xr63ehR3fo vK0VoUFEtYurqMSTIiGTWwmMBpAMtDSJRw7cOGhz/W9yQQ6cNTfv/Nn6BFFH8bWovSr+ 6+z1OzsVuqcsUqavHpqtVToBoQzZAjifxUJv/m6TfPIW9s7kL2LzUCG4nJTvfjEjbGfY ziAA== 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=IZaZlRSWcRP8TIIFtrlkzqwhRaKDjzyacbuo5KubVSI=; fh=HGMLmPLDRBgS2M2DmRioi6Q+pUL3jqoEM8UtJkY6Dtg=; b=XJ0OMz+wQdVJaJ8DyePC6IXStZySpXdtu5c/K+r9O55rKldVQe+aDh6S00w9+HXTaE YquiGl3Aky/F1ENpkP1sfQlk4m/MQwhqwuXbmLpkjrwOfj0JjC3rxoO8yyqml2eYo6ZZ vEA8GzUN6a46tpANDyI3wUI9WRTD8mjR+hDKW4pJOfOfvOkScXozYAcO6mt8yXJ63Adu En7q/Mh77AwxW59ZMGSyEzmWuDojnRas1gAR4Ud3f139GrO+/dIqij1VROYZfd2dJNyR OcISloTqFqL7UUQ1FTUgC2/67UGA/epFOZ8TEBeIpHc+3DNsiBJRl4thJpKN4oD1D3p5 EtAQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TS9yRPru; 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 g8-20020ac85808000000b0043699deced2si8733106qtg.475.2024.04.15.21.07.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Apr 2024 21:07:13 -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=TS9yRPru; 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 1rwa5O-0008Em-4f; Tue, 16 Apr 2024 00:06:22 -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 1rwa5L-00085B-J6 for qemu-devel@nongnu.org; Tue, 16 Apr 2024 00:06:19 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rwa5J-0007AM-Qe for qemu-devel@nongnu.org; Tue, 16 Apr 2024 00:06:19 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1e4f341330fso32496925ad.0 for ; Mon, 15 Apr 2024 21:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713240376; x=1713845176; 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=IZaZlRSWcRP8TIIFtrlkzqwhRaKDjzyacbuo5KubVSI=; b=TS9yRPrupgnRGUxLgkS1MrwrA1KW3h7M937fpIRazfr5rJq/03hJKWyKs/7NKqB+OW XMAzqduRZWuO1BOfBvG3eGy6pZIU+4N7rRG/MRQmW6/WOvroTcGWfJRavSc0ZZD39bKa JQ7kXEdAB8nzTc618g4aNo42qYecF75DzPwvGZquzWXQ5Tfb3++sK5dU4VqPXV+vqDgi GpEEb+mNDs796AafXKkb7Zs3GjPvAn9iIFpxEdNtEc0HUUPtrQuhvmewVXOQA6nwDerG PB9KGdxA7QOnPDJgNKUaQ/cqjwDLCea5+ez7sefKNL2S31H7FmVEBTTewg8URf9ldnqO xJlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713240376; x=1713845176; 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=IZaZlRSWcRP8TIIFtrlkzqwhRaKDjzyacbuo5KubVSI=; b=LcDuJUXIXlDGCtsCBEc2sYq81DN2DEm0FaWD2cz3hVSQa8QYZpXcLl8hFzIJKn+bqv utZ6zCvCMPGmhewNLsRqkql2zv0UtqIr2+EyudHKkEKCP21hV41lOK7cDFpYVxJCH053 ANfJorONozA1tR9+sHTOXqUuvvZ3jlvSsQKHvmSSJXRCLK/Jv14oF4lO0ZlBUgYovfBD KJ8EoWhrqavLLrbT+PrrAWc//jcDpxTy+pfAoaVTPpfZP84djVYkCnJEjOOQwXqTPfKA 39J6tTsXngl025Mke+8vR0jM2+HMIHTjatQFxoSGM7Mel9BiSXsHB8y3of3MouM636ER pnJw== X-Gm-Message-State: AOJu0Yze3dHi1Ra1vrgSpiMSO4GUvPIisApym7tGoL0TqLPm+sUZYwYm njzWx3y/xu8ElG7wXnzzDLIRqISHlooQXhxSiOvhH+F38EFOK9s+yllqaxDIgr1CZmIIDQ/N3ki c X-Received: by 2002:a17:902:eacd:b0:1e2:23b9:eb24 with SMTP id p13-20020a170902eacd00b001e223b9eb24mr9864530pld.33.1713240376408; Mon, 15 Apr 2024 21:06:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 21:06:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org Subject: [PATCH 6/7] target/i386: Introduce cpu_compute_eflags_ccop Date: Mon, 15 Apr 2024 21:06:08 -0700 Message-Id: <20240416040609.1313605-7-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::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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 This is a generalization of cpu_compute_eflags, with a dynamic value of cc_op, and is thus tcg specific. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/i386/cpu.h | 2 ++ target/i386/tcg/cc_helper.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 6b05738079..285f26d99d 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2379,6 +2379,8 @@ void cpu_x86_inject_mce(Monitor *mon, X86CPU *cpu, int bank, uint32_t cpu_cc_compute_all(CPUX86State *env1); +uint32_t cpu_compute_eflags_ccop(CPUX86State *env, CCOp op); + static inline uint32_t cpu_compute_eflags(CPUX86State *env) { uint32_t eflags = env->eflags; diff --git a/target/i386/tcg/cc_helper.c b/target/i386/tcg/cc_helper.c index f76e9cb8cf..8203682ca8 100644 --- a/target/i386/tcg/cc_helper.c +++ b/target/i386/tcg/cc_helper.c @@ -225,6 +225,16 @@ uint32_t cpu_cc_compute_all(CPUX86State *env) return helper_cc_compute_all(CC_DST, CC_SRC, CC_SRC2, CC_OP); } +uint32_t cpu_compute_eflags_ccop(CPUX86State *env, CCOp op) +{ + uint32_t eflags; + + eflags = helper_cc_compute_all(CC_DST, CC_SRC, CC_SRC2, op); + eflags |= env->df & DF_MASK; + eflags |= env->eflags & ~(VM_MASK | RF_MASK); + return eflags; +} + target_ulong helper_cc_compute_c(target_ulong dst, target_ulong src1, target_ulong src2, int op) { From patchwork Tue Apr 16 04:06:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 789204 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:dcf:b0:346:15ad:a2a with SMTP id dw15csp104708wrb; Mon, 15 Apr 2024 21:07:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWpKRyyPEAHswngrbxoDkoSk8FWpMviyUhLV8mi/WSNWVd/gI8VMnrsl12bahAcPxj5eS0rU9LtLAd9PwLg82xd X-Google-Smtp-Source: AGHT+IG+LmCxVTj3XWBk0xLekud6noqpes67MRH8SDUQOxGspf9a2qpnUWvrbMgVkh0dhmScGLPj X-Received: by 2002:a05:622a:1a95:b0:435:15d:8495 with SMTP id s21-20020a05622a1a9500b00435015d8495mr1413224qtc.20.1713240433468; Mon, 15 Apr 2024 21:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713240433; cv=none; d=google.com; s=arc-20160816; b=o940KltHjhoOXTMQvv0axvltoVZbP2jYDVY7EroVanKa+6H4HclX/aK1UgvBY+DsLM CqOpcuS7YU10Ltihxp1iJZxBb552tgdj1/AVE7B4nopbyYiOqvRkndEQrhi7Q3sLEYZ7 BzcH1tEVa0LUg1a/jpxTi3laDDVDS89ms/3PV20URdfiY8jnHuMD+f1L75Ns5P1hNkff nUvKVWKcqB4hqMFjaYHuyqzYyeBWpHQwqD/2HrU4pEt++JZZnWlrqdL+QWKaPCJ4jc3V oE+CgP+dXID82wxYzbYygGm64xVzEY5hEH1Grdr185KL4TMfNMOw4HUOj6SLmlIn1Pxn rQvg== 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=SGHcSo147SgN6rnFLSb3VGek6gUZYoiow/EIARfgQaI=; fh=HGMLmPLDRBgS2M2DmRioi6Q+pUL3jqoEM8UtJkY6Dtg=; b=NzfsiV8Jv4qTA+LZYrnBIRUAAmSJ1Dqyn85eAz8nuTlmp8CApZnLp8sl4gqXg9plY4 hS8SYrXSNfLOhf0TGvIE1uOSouIp4Qr9UfN9BYF2X+DQMOPA/T482zpZuFuvyuc/zzo7 TBdedXKoofj4v56JX7ecO3whu7WjRf+wgk/c1jKv1W+HhjmpqZN7DDwcvfevQYjGDXgQ xJPzKQCw94Kba9+xdN/pSSm9JYuU0rkteP+S7Ww8RYdGPxtwlQ5jn3n10kbGi5eHqz5y zG1prMuTiT6sizlfMolk9Btb+xnO+pxkX2qBLL6P+QY1tBB2qiwHpW4NEG/2DezZ9pOX Cjvg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qnvBKeqv; 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 a14-20020a05622a064e00b004369300f12fsi9101930qtb.684.2024.04.15.21.07.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Apr 2024 21:07:13 -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=qnvBKeqv; 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 1rwa5P-0008Ff-As; Tue, 16 Apr 2024 00:06:23 -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 1rwa5N-0008C0-5E for qemu-devel@nongnu.org; Tue, 16 Apr 2024 00:06:21 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rwa5K-0007Aa-St for qemu-devel@nongnu.org; Tue, 16 Apr 2024 00:06:20 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1e3ff14f249so30376775ad.1 for ; Mon, 15 Apr 2024 21:06:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713240377; x=1713845177; 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=SGHcSo147SgN6rnFLSb3VGek6gUZYoiow/EIARfgQaI=; b=qnvBKeqvUCwKHGbcCgTHflcOR52tZpqyQ3ziHizT+ldJO9Z2Xe72jluHKDGdjStJPX 2lVqogXRpVUiU3Nrl3iVM5AmaS/P7Dl4VKd0GwFBG0xqsDO3Nc/NHy4YPn6GZmYYtPUv ZgUQ8ofPQfp9mFnSzz5huoXWdWzSJUaMVdy5KcKu0PCdpUYDvsL/GggYmkWrQJt9K11y 6Fw7QXaiqWidt6V+HJkx4bg0+rYFk6dm7/rPGNSCwmTJLwH4g1ucFOPezP6NCemyLx19 VtVBQ7iI4TiXU84Z7ng4QblT42b44e0wwkI9DTbjKhuyDbGoa2GFxPhwLyzSWI9+JtY9 v4DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713240377; x=1713845177; 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=SGHcSo147SgN6rnFLSb3VGek6gUZYoiow/EIARfgQaI=; b=cx9bqepdFcVCV54jYIZnzyIUloNCnf5hbGxXt7F6/AwbxwZKvkwzVUyAfQ/x15usfV tGzFkd0MIYHGmIcuZEFD7JK10a/87HP0INZ7Gziz1dXrG23onB1VxaZWVTlgorx/cJ/W bGyzDBsGJhFfkvexaUmM9P9tWPMY3Kro/g4v8ZOasAinSU1tHefauI5ebThTgLpxQEIi 6d5JEMyHTRZDgaQylw9XDViwqgXEy1i7F8bSoZRuC67CAIjhzEBT5GCnQbU7XK8tp8iW Gcv8WBgNsWXViUzvMSwOzWRbFx0NbI3F/U1sm3XI1BoAN50CRWk04j/XREIwQzVXSwxH V78A== X-Gm-Message-State: AOJu0YzYPeMDB1MdfmF6tAM1g0qbLgsdDBZF8fRY6cp1ZkZU6+t+EyEq cDqJnsGHHP7IxIlBfMqVDwYi0MgDj0I4dsewgpJSUPg/ICYPDRhVPeSw62PpzWjEk9xqzaDNM36 n X-Received: by 2002:a17:903:41c7:b0:1e3:ce12:ef77 with SMTP id u7-20020a17090341c700b001e3ce12ef77mr1256616ple.11.1713240377293; Mon, 15 Apr 2024 21:06:17 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 21:06:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org Subject: [PATCH 7/7] target/i386: Implement TCGCPUOps for plugin register reads Date: Mon, 15 Apr 2024 21:06:09 -0700 Message-Id: <20240416040609.1313605-8-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::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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 Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/i386/tcg/tcg-cpu.c | 72 ++++++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 16 deletions(-) diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c index cca19cd40e..2370053df2 100644 --- a/target/i386/tcg/tcg-cpu.c +++ b/target/i386/tcg/tcg-cpu.c @@ -22,9 +22,11 @@ #include "helper-tcg.h" #include "qemu/accel.h" #include "hw/core/accel-cpu.h" - +#include "gdbstub/helpers.h" +#include "gdb-internal.h" #include "tcg-cpu.h" + /* Frob eflags into and out of the CPU temporary format. */ static void x86_cpu_exec_enter(CPUState *cs) @@ -61,38 +63,74 @@ static void x86_cpu_synchronize_from_tb(CPUState *cs, } } -static void x86_restore_state_to_opc(CPUState *cs, - const TranslationBlock *tb, - const uint64_t *data) +static uint64_t eip_from_unwind(CPUX86State *env, const TranslationBlock *tb, + uint64_t data0) { - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; - int cc_op = data[1]; uint64_t new_pc; if (tb_cflags(tb) & CF_PCREL) { /* - * data[0] in PC-relative TBs is also a linear address, i.e. an address with - * the CS base added, because it is not guaranteed that EIP bits 12 and higher - * stay the same across the translation block. Add the CS base back before - * replacing the low bits, and subtract it below just like for !CF_PCREL. + * data[0] in PC-relative TBs is also a linear address, + * i.e. an address with the CS base added, because it is + * not guaranteed that EIP bits 12 and higher stay the + * same across the translation block. Add the CS base + * back before replacing the low bits, and subtract it + * below just like for !CF_PCREL. */ uint64_t pc = env->eip + tb->cs_base; - new_pc = (pc & TARGET_PAGE_MASK) | data[0]; + new_pc = (pc & TARGET_PAGE_MASK) | data0; } else { - new_pc = data[0]; + new_pc = data0; } if (tb->flags & HF_CS64_MASK) { - env->eip = new_pc; - } else { - env->eip = (uint32_t)(new_pc - tb->cs_base); + return new_pc; } + return (uint32_t)(new_pc - tb->cs_base); +} +static void x86_restore_state_to_opc(CPUState *cs, + const TranslationBlock *tb, + const uint64_t *data) +{ + CPUX86State *env = cpu_env(cs); + CCOp cc_op; + + env->eip = eip_from_unwind(env, tb, data[0]); + + cc_op = data[1]; if (cc_op != CC_OP_DYNAMIC) { env->cc_op = cc_op; } } +static bool x86_plugin_need_unwind_for_reg(CPUState *cs, int reg) +{ + return reg == IDX_IP_REG || reg == IDX_FLAGS_REG; +} + +static int x86_plugin_unwind_read_reg(CPUState *cs, GByteArray *buf, int reg, + const TranslationBlock *tb, + const uint64_t *data) +{ + CPUX86State *env = cpu_env(cs); + CCOp cc_op; + + switch (reg) { + case IDX_IP_REG: + return gdb_get_regl(buf, eip_from_unwind(env, tb, data[0])); + + case IDX_FLAGS_REG: + cc_op = data[1]; + if (cc_op == CC_OP_DYNAMIC) { + cc_op = env->cc_op; + } + return gdb_get_reg32(buf, cpu_compute_eflags_ccop(env, cc_op)); + + default: + g_assert_not_reached(); + } +} + #ifndef CONFIG_USER_ONLY static bool x86_debug_check_breakpoint(CPUState *cs) { @@ -110,6 +148,8 @@ static const TCGCPUOps x86_tcg_ops = { .initialize = tcg_x86_init, .synchronize_from_tb = x86_cpu_synchronize_from_tb, .restore_state_to_opc = x86_restore_state_to_opc, + .plugin_need_unwind_for_reg = x86_plugin_need_unwind_for_reg, + .plugin_unwind_read_reg = x86_plugin_unwind_read_reg, .cpu_exec_enter = x86_cpu_exec_enter, .cpu_exec_exit = x86_cpu_exec_exit, #ifdef CONFIG_USER_ONLY