From patchwork Tue Apr 9 19:35:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787246 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383873wrs; Tue, 9 Apr 2024 12:38:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV8r2fg2oYLhO7xCprjTElljId4zWjyi+FhFRtkAFPQdR9mfnAVcvLflUxW0pWAUTXETN8SERt/jvT4GTQK1gSi X-Google-Smtp-Source: AGHT+IF23B81bMCnv7FyEqgGXMOvr4QVK+ojmT5lqh0DU/w+A7D2AvaK6uIAKl2E+DXnn9JhPEBV X-Received: by 2002:a05:620a:5685:b0:78d:39ef:c1e4 with SMTP id wg5-20020a05620a568500b0078d39efc1e4mr710971qkn.24.1712691515264; Tue, 09 Apr 2024 12:38:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691515; cv=none; d=google.com; s=arc-20160816; b=RxJV1mhC5/aj4Hyo2x3OXfu+cRtcJQnkTfLHHdIfhiF64nNe9AUvYoRJYl+j4mMh2v Bb0yY/4quO1dKUvjI2OwHUn9s/x3IqLotTtD8mzV79fuDJWQ3fTnUf7VWMq/xRNDir79 Xfdz2KdOmFqx6M7Q7gKWg2DkXetz22M6AsoVAFdY+1TCwtGGNuYBSpWcVkXkdEUC1/cz ljJ0qiwuZSIibaHD3KdJ0w5ljLvlUiBnc7AQWqjFxNEEGSpUoftldbePl8j30e8/zyVk 0w3i030PjTn4Qza/HKNJkz+99emgtJuA/wM1KUFLxN4DE6oWySFI74Yk8cGFCHIdxVS8 rHQA== 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:to:from :dkim-signature; bh=0/ekaTyyBHEzg2gMKpvUq/mv6Nl9iOhi1rhUNF8qDbI=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=TcojPDz7H2qvAIKBsAM06r3e0FOOLvMUhM1atOBBOhn/9ksmjnmrEILnAE1F+90C7P SO/hQC+HuSU9XnsHEj8CGezkUmMpmevBpwqksxQtx4CwYYPwqWNu2erwHXm/ZyGF5z0A qEMBXvGkwU7XbtpHsVeUjKLnXybMxwGAmWtYtzc6CNjvq0zPxNCg8PlOma5PcjUNzZJS i24YIpe2pXO713XreXqc5xw+gsP0fr+lV2Nm/r2ezUgKOZkjFgltY3KwQmglJKCT4hTl xrI0w6lj9ibiN8h+SFzoBkU3r6JECqoStqigLUYTYD78OIvrwQ6Qo85gznSJpzOvEeGR M/qw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Vupl/HD7"; 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 c22-20020a05620a0cf600b0078d73c8b3b8si1375200qkj.587.2024.04.09.12.38.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:38:35 -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="Vupl/HD7"; 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 1ruHGN-0000Wm-JE; Tue, 09 Apr 2024 15:36:11 -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 1ruHGM-0000Wa-Eu for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:10 -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 1ruHGK-0004ch-Mq for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:10 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1e2b1cd446fso44162425ad.3 for ; Tue, 09 Apr 2024 12:36:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691367; x=1713296167; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=0/ekaTyyBHEzg2gMKpvUq/mv6Nl9iOhi1rhUNF8qDbI=; b=Vupl/HD7D60CsOuas8d1rhFSjgblZaHPdwrS4MOwkUzlAl6UGBAUDbAWA0cLir+V4U 4QAOvbSZ8fNpgoJVuWdmPqG9tsaflo+Uo7SJ2ahzGd2O9SNlCiqvUFYqzeySus4m4Njs bB+BGyGCeZQ+DK2dZuKXtaalqr/dT4GtmQ/aXEHBg+1YnF5i6bItkCPrZ+Te0X6FqAGD qlMw6BsHNd/SjANVfQwhtQZovzixqAGLMxlpK/gtyp61jjxvG/fmyARv7Keio9AhdIag QksbIBTvU4vqugeL9Unzold0pmkQWBd4uxkJ7moiIM56depruhS7j5eoLpGhYVDIarEn wuOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691367; x=1713296167; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0/ekaTyyBHEzg2gMKpvUq/mv6Nl9iOhi1rhUNF8qDbI=; b=fJcliDiQ2TsB6Awp7hcGKa4mE6sQhmqPET4Cbr1Y7bL32tmF2AGBKh/SiPRAHHJDhU erwlzZB3YZT8rdIgOBKATczTbWVIVtZZyc+JTrJLnuumTL3Yj5C+kgjh76ZoCTivE5a3 AUza7AP/T25r1JAgPc33FEc15cFWjU/21/+pwqbAzJDgrr+Xv51EbHTIfj4b6a8FyQ50 GPPXgEaGYWR756UMxaIwbPH8HAD5dougGm8ZnmgVoNFvzinBBKCWdD96P6wA8htBbskf V604DjgDZkQxDwdhIDQUKwDDqdw4ELO23XFtdVrA/06n6/O937mwde3aD0YC0b/3LZdQ O/Qw== X-Gm-Message-State: AOJu0YyJQgNgDMWQa39BaFGZLjqWmDbCGZ70ErZLj/axktdnv3WuekLd iApDLEYkQoC7mFmQOsiFJW0cjQ4Ou4Qb+COCEXKh36+qJWpZmGdN2min12IObuJ9x3q5LkobLy5 y X-Received: by 2002:a17:902:e944:b0:1e3:e093:b5f0 with SMTP id b4-20020a170902e94400b001e3e093b5f0mr766918pll.8.1712691367109; Tue, 09 Apr 2024 12:36:07 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL v2 01/20] tcg/optimize: Do not attempt to constant fold neg_vec Date: Tue, 9 Apr 2024 09:35:44 -1000 Message-Id: <20240409193603.1703216-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-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 Split out the tail of fold_neg to fold_neg_no_const so that we can avoid attempting to constant fold vector negate. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2150 Signed-off-by: Richard Henderson --- tcg/optimize.c | 17 ++++++++--------- tests/tcg/aarch64/test-2150.c | 12 ++++++++++++ tests/tcg/aarch64/Makefile.target | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 tests/tcg/aarch64/test-2150.c diff --git a/tcg/optimize.c b/tcg/optimize.c index 275db77b42..2e9e5725a9 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1990,16 +1990,10 @@ static bool fold_nand(OptContext *ctx, TCGOp *op) return false; } -static bool fold_neg(OptContext *ctx, TCGOp *op) +static bool fold_neg_no_const(OptContext *ctx, TCGOp *op) { - uint64_t z_mask; - - if (fold_const1(ctx, op)) { - return true; - } - /* Set to 1 all bits to the left of the rightmost. */ - z_mask = arg_info(op->args[1])->z_mask; + uint64_t z_mask = arg_info(op->args[1])->z_mask; ctx->z_mask = -(z_mask & -z_mask); /* @@ -2010,6 +2004,11 @@ static bool fold_neg(OptContext *ctx, TCGOp *op) return true; } +static bool fold_neg(OptContext *ctx, TCGOp *op) +{ + return fold_const1(ctx, op) || fold_neg_no_const(ctx, op); +} + static bool fold_nor(OptContext *ctx, TCGOp *op) { if (fold_const2_commutative(ctx, op) || @@ -2418,7 +2417,7 @@ static bool fold_sub_to_neg(OptContext *ctx, TCGOp *op) if (have_neg) { op->opc = neg_op; op->args[1] = op->args[2]; - return fold_neg(ctx, op); + return fold_neg_no_const(ctx, op); } return false; } diff --git a/tests/tcg/aarch64/test-2150.c b/tests/tcg/aarch64/test-2150.c new file mode 100644 index 0000000000..fb86c11958 --- /dev/null +++ b/tests/tcg/aarch64/test-2150.c @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* See https://gitlab.com/qemu-project/qemu/-/issues/2150 */ + +int main() +{ + asm volatile( + "movi v6.4s, #1\n" + "movi v7.4s, #0\n" + "sub v6.2d, v7.2d, v6.2d\n" + : : : "v6", "v7"); + return 0; +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index 0efd565f05..70d728ae9a 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -10,7 +10,7 @@ VPATH += $(AARCH64_SRC) # Base architecture tests AARCH64_TESTS=fcvt pcalign-a64 lse2-fault -AARCH64_TESTS += test-2248 +AARCH64_TESTS += test-2248 test-2150 fcvt: LDFLAGS+=-lm From patchwork Tue Apr 9 19:35:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787240 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383750wrs; Tue, 9 Apr 2024 12:38:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUuMDytj19X8p0Y4jblwO/o7M6v/xn0e8saM67WwgBWwZn//KkIhJKhpTrJ7h6lLUDPU4zWA97EHQybg0vyyteA X-Google-Smtp-Source: AGHT+IE/us4kio+euJ3gCaUqTcr1WCr288e4NFRXZwmzJipaHKWsRVZI130divmwjMYMrvnDKvNt X-Received: by 2002:a05:6214:d85:b0:69b:1342:f3a3 with SMTP id e5-20020a0562140d8500b0069b1342f3a3mr779910qve.25.1712691493082; Tue, 09 Apr 2024 12:38:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691493; cv=none; d=google.com; s=arc-20160816; b=Lo4G4NuMikxQc9kNJDeVZ0pcEpgrEAS65sK8dAZ5NhONig9azztsCIaZ7C7u0MVv7r oRIY34Y//26kF0BcomZtCL3o1dokd78p5lfkNYJZFh6B7N7aToaw1WNchxCRrAmJ98Jt Ne4OPeypEkTNrPvF7umkDA3BBhPfaVTxLPURWG1/dTam+BTMu9yjL0lWn/eunlLI/Xe4 l25aBwkpM6ixKkuZloHAUIBr9G+/lFX01RDgms9B/sjpDgN4uyJM3VnlGxnYM1b9DUQ0 hs/z+uw1NkUuiFNxVytjb8xYNU9SIPOqswQRP1MnQVfy9aV9wNXEw5s70KfC0pfs5jJL AdNQ== 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=WEK6zSUurL5c5k/x0P2XhXs6AUgqTg+iWS/4jd0p2Dg=; fh=OgLM0n3PrDiY1S+jEilkS5pRNdLFRHpJ/sL9jXTr7DA=; b=Zp6PRuIR60UIUR+0MSMFg4sYBLgp7GNvx65MBVsCBqSr89sGHqdV5MWfdL2qQ5gnn3 WEv0n9S4EHrs0eFVOLV3ytycfcpBbO/HoUztVzZQk+2p0yjOHPYTB3+lsHfAFNb/1QHX wQyOs8wfIBxPdpDp4YBqT7DY13MS8POKaNoMvO3bZRHTyF7bki+xU42twGfDOpcGIsCq S3HWxLhrd6NX7ABw7zwq8uKW6cwuqMfPtmoYDJzSaANRW/sDsJ+/hTMvec1RyiJbULH6 IEdKqY+UTRDTvAosYsrJJ48X3sKthkn017k0IP8e/1625/6fJNojcHn7MRDAk5RkKD87 rI5Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z8qCRVXM; 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 u9-20020a0cea49000000b0069b1f36ee95si4074425qvp.438.2024.04.09.12.38.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:38: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=Z8qCRVXM; 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 1ruHGP-0000XX-8c; Tue, 09 Apr 2024 15:36:13 -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 1ruHGN-0000Wn-Sr for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:11 -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 1ruHGM-0004cn-59 for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:11 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1e419d203bdso17890705ad.1 for ; Tue, 09 Apr 2024 12:36:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691369; x=1713296169; 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=WEK6zSUurL5c5k/x0P2XhXs6AUgqTg+iWS/4jd0p2Dg=; b=Z8qCRVXM4cOfMlTJalO+eP7UjsmthD+Uf33jk4cfqo6BX73sA8IY95nlulHTpqqVsT W5f8iLmtOomkFt7Or+aDNGZB6gctUX028Bf2Km7py5E9MxPoEZXx+ymcDrtfPCo/Uwmt jAK4iUQf0qG7zAJwtpsLkFpNhcTnM+bX5vqSp6y+Ck4Aew47OzWM0lxlTaBGGt14HP1x Q2ay9wJFqRJZDqPbNncH49IWYAyTGC6lrrFDnGOjTB8PjBbkd3OwH4WOhJ1IjBAcHwEU mZlnrv9hOQsa/35+VyPqrtJREpqeDbecKcd2xHKKrkAbhUlE4s66W/povDyeFK7GCD34 nsbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691369; x=1713296169; 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=WEK6zSUurL5c5k/x0P2XhXs6AUgqTg+iWS/4jd0p2Dg=; b=lppAkZSkxXCeg9yWBRv5FLbG1n65NW9wQBAsC+paVoGTwVgmJmeQEBzN+joDtZFTCh hqc96KhaHiWSj/x7UEZhgID5yKJqGXcQjQaJUTitOL79AkRqE3+fe084BXx9uAZpdb1b HV8yzcNxtyL9aDmbaK5TVIw+PDHNoT9C1MeG6aE6c7vpXrRIxFrvqE8nTAD3OWbSdBnj 5NKYWDPj+gicNt7x9/uGpb9YVjvwmrWrZWmTTjOu/CmWyFcbgLJZ2po+ws2Cn43reurz kQkKws6VtJE4GCuO7WOS2+mRjyS2clDlhrYgvNBJptiMwz8U8XrEz/Tw4DRKBKFMiL4v sIaQ== X-Gm-Message-State: AOJu0Yw+80XoCBTBGMaHmI17kLbhYCCUOLUVz9m/8Uc3QJebEAwqmRK8 kqiVr4Rf87wEg/J6zIp7lR46TdwCg1yAeMupZ3SR1egc5Y5r8gw9RfrYL/DmUsp+6GtkoJ2bmY7 a X-Received: by 2002:a17:902:c405:b0:1e2:7015:6a1d with SMTP id k5-20020a170902c40500b001e270156a1dmr887279plk.60.1712691368681; Tue, 09 Apr 2024 12:36:08 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alex Fan , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL v2 02/20] linux-user: Fix waitid return of siginfo_t and rusage Date: Tue, 9 Apr 2024 09:35:45 -1000 Message-Id: <20240409193603.1703216-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-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 The copy back to siginfo_t should be conditional only on arg3, not the specific values that might have been written. The copy back to rusage was missing entirely. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2262 Signed-off-by: Richard Henderson Tested-by: Alex Fan Reviewed-by: Philippe Mathieu-Daudé --- linux-user/syscall.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e12d969c2e..3df2b94d9a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9272,14 +9272,24 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_waitid case TARGET_NR_waitid: { + struct rusage ru; siginfo_t info; - info.si_pid = 0; - ret = get_errno(safe_waitid(arg1, arg2, &info, arg4, NULL)); - if (!is_error(ret) && arg3 && info.si_pid != 0) { - if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0))) + + ret = get_errno(safe_waitid(arg1, arg2, (arg3 ? &info : NULL), + arg4, (arg5 ? &ru : NULL))); + if (!is_error(ret)) { + if (arg3) { + p = lock_user(VERIFY_WRITE, arg3, + sizeof(target_siginfo_t), 0); + if (!p) { + return -TARGET_EFAULT; + } + host_to_target_siginfo(p, &info); + unlock_user(p, arg3, sizeof(target_siginfo_t)); + } + if (arg5 && host_to_target_rusage(arg5, &ru)) { return -TARGET_EFAULT; - host_to_target_siginfo(p, &info); - unlock_user(p, arg3, sizeof(target_siginfo_t)); + } } } return ret; From patchwork Tue Apr 9 19:35:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787234 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383303wrs; Tue, 9 Apr 2024 12:36:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVip2cgara2SYUt1Plcdt/mVfjBCMwAzTretSU7ZD6z5Ek93Rt/Vhu3p3vZ4IZcCgxq8fshJQgeb8vGs9lubH5b X-Google-Smtp-Source: AGHT+IG1GGiIMueqwffP+nX5+t4qAM2MwQDISVJNzFBY60n1lTCL2VSb1zK4hhGhd+ugIrWTvkvn X-Received: by 2002:a0d:e855:0:b0:615:fb2:1e61 with SMTP id r82-20020a0de855000000b006150fb21e61mr730945ywe.4.1712691406738; Tue, 09 Apr 2024 12:36:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691406; cv=none; d=google.com; s=arc-20160816; b=zxsQzBEvMxhQDsOsZ+zH/CoXUkTBVu3z+AOXhyNDfg8XAG167k8Pn//zSGkqNznghk lsGZV/n3v8Jm7RwAB53Hns3DXMpnEr1y20XcNbxxzPfkICSE7lRobraQUdLyk1ytD4hG kQIHVWWgXKdkHgVeiSiDlf6eaxbz/3T37JqJM6sjE3ODfqBlBTp3sEAULk4S6JIA0otx Rb98hE9fw1gEIMUCbprkP0PBs2Rx+wz2ehLV1FjbvmWOl+fYQ+/medcAqZ1Rvv8iA5qu 3XfHYe3VTyMj18VOAVj8c+cME0VTGTAIP8fuh7W2e/y/QXy9/ixNYXUgR+PKcoO7RH+K OgZw== 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=Lw/beNU1QugcC97gSnNNo3jFHiOgyIQNiC5qPkBLROQ=; fh=JowuhYM/cawvxwSjj4eVbOc0NCc2c2dukzC2TrxwJhM=; b=jAKPxe/JZlSBhI5XbB/qMAdQrlDowIb4bTjoV5NJoD/qnDx+gBzLJjVQGqfBo53tOd UULt9tnhsq6mI2MBvNEA9tx3BsLtvOYMeyWos1GL/HVyfNfXoVLLs9JkgSrEvCkrmWyV AAEMycydxy7m9JTc4aQxXirHcbJlkanvn9VexVlEXDxJtX/5dG0gdDeSXYNJJQvjpwxB Aug0uhZ8rPPq5ntE15BvtWrUOORiKwhGDvseAIR7aaMitJg7pyoyeol+5Fy3GdzZmW+B nLxB5lYBeEFiavPMq4FTQ/F+Uc+hPbmJDDcV+1C6K/INBQK+IdteGIQoJ1rkvfFuAqZX u89g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EvzIyHcg; 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 e16-20020ac85dd0000000b004344c626782si4955689qtx.625.2024.04.09.12.36.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:36:46 -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=EvzIyHcg; 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 1ruHGQ-0000Xt-Rs; Tue, 09 Apr 2024 15:36:14 -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 1ruHGO-0000XQ-Vu for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:13 -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 1ruHGN-0004d3-DJ for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:12 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1e2b1cd446fso44162825ad.3 for ; Tue, 09 Apr 2024 12:36:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691370; x=1713296170; 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=Lw/beNU1QugcC97gSnNNo3jFHiOgyIQNiC5qPkBLROQ=; b=EvzIyHcgo7LtCmPPB/9RcOJZmakueXCqPF0UgeUDSE9EO+f0Tvf+bfOQH/weCHHtH5 SrifWB/GVrkCUFKIQL/Sb88YZxK07KqaajafMqV7ERPM48oXOow8I9+oCZrZI/i3Z6wM wWWw4AEl/80pRXlO8n+EHd4bOcWuU7/JnFhvhGvRjuynY+TTSiZq/CACp7apljeNpoC9 KoVYUVkL0Ft8HFa4m3R4sMFYBGzjNBjFqFlq0CJFW222BGI+ETL+NrPmUaiOSLf+4K8j 5EflQ6BiwkdssOlxZJHALfW0rwN4KbKed4TuggWBziQveAk77uVb9vSylXwXE9/9pRNU /ckQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691370; x=1713296170; 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=Lw/beNU1QugcC97gSnNNo3jFHiOgyIQNiC5qPkBLROQ=; b=lNMqsrIV5WSBzrMRTGZBbQDF5Q7+uWl7azySwtUt+TTEIY1FOugd1nPeOE0BPQYPkJ 3jknxj5PASd5uVn5MwM2pu43baGjcpzZwHTABtH0OFWWbuG9AYYpjlHcp4QjQs1QsVo4 KKCbqn2s34gIZdsa+cX225u6SmWNBPN7Rocez2s57lRi8DmElRo/clw3kQKnMAtwqXT3 zKOK+RDwIGtdFF8m8jCNfA2H2Gukz3Z2YNCcIm3S7Pm/M59VImTlW6ed2lHtFuHOZl+Z 93GdUiyPLa+bxa16XiifMiPQpgcfA2SkwARal0HPeFUEGW2I5MOVTrZNg6SQw2++Qu5i 776w== X-Gm-Message-State: AOJu0YxiHTJ5hTn71tg7ToyzDPxhFWIbjWLr5lPUfX1Zdh3W6I2kk7k/ c0xvFRNmk+XJjIQap8ahJZmBYFYMn4fFGT5D+3tmkz/FoWzlIkCVp5cMNRUeSa1q/voygWjI4eH 3 X-Received: by 2002:a17:902:eb8b:b0:1e0:afbb:7a89 with SMTP id q11-20020a170902eb8b00b001e0afbb7a89mr906459plg.22.1712691370019; Tue, 09 Apr 2024 12:36:10 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Nguyen Dinh Phi , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL v2 03/20] linux-user: replace calloc() with g_new0() Date: Tue, 9 Apr 2024 09:35:46 -1000 Message-Id: <20240409193603.1703216-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-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 From: Nguyen Dinh Phi Use glib allocation as recommended by the coding convention Signed-off-by: Nguyen Dinh Phi Message-Id: <20240317171747.1642207-1-phind.uet@gmail.com> Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- linux-user/main.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 9277df2e9d..149e35432e 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -928,11 +928,7 @@ int main(int argc, char **argv, char **envp) * Prepare copy of argv vector for target. */ target_argc = argc - optind; - target_argv = calloc(target_argc + 1, sizeof (char *)); - if (target_argv == NULL) { - (void) fprintf(stderr, "Unable to allocate memory for target_argv\n"); - exit(EXIT_FAILURE); - } + target_argv = g_new0(char *, target_argc + 1); /* * If argv0 is specified (using '-0' switch) we replace From patchwork Tue Apr 9 19:35:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787253 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp384359wrs; Tue, 9 Apr 2024 12:40:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWw4ID7z4H/2T38Pa4CI3b2xmatzFa7oSb/YAXievhVtV+7KNwT2fQmkJ1uf+eD6GxKPts6iY/3MiDM7pUQhltk X-Google-Smtp-Source: AGHT+IFCC4lUZCQx32w5yJ+e2jr4h9nIKwXesMLTe1DMbkU6/k0vpH4vv4rQsFlBjv5wtSNUs1QW X-Received: by 2002:a05:620a:5742:b0:78d:68fe:f73b with SMTP id wj2-20020a05620a574200b0078d68fef73bmr637404qkn.63.1712691606638; Tue, 09 Apr 2024 12:40:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691606; cv=none; d=google.com; s=arc-20160816; b=J0qsT4zYb9pw5+ehhixQNkoUMCkmS21MK44ereFQd7Cw4jsNZs+uqQtZJ6UgWkuUuO pCevHgKH91UjO9TpNQ1f7/M28Uq82Up13Qa1dLq2uC5282WEA86a4/GtLJgrmrvyd2lo qmRZT6NCxOO46lvoI5U2qyvvv0sA2QzMKwyRCxvfvW9AFSTr7SOjFbrFBMBlQSojk4W8 wGngMbPOmfz59yKrZgwXv5CIBtqKAF1n0oYZTeVgOZcy0Rm8NKIHFbCoDLguZRVjM4Zj bv7/aWSgB/ZWOuxAU9ctx1Rh6hmpj7Ggbnx6G+rFxoJD6S9Ma+fwJquMQNSyvQWXp9PD cOsw== 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=+6xA9uOxQL6GHFyuuAVL91EMcYGjdhkuoxzjyRnEesc=; fh=j6oUJOIe/HZ0oApVqODA+wb5Tv03Z1vlJlVjpDwxhHo=; b=HNOMj4TLSdb9J7C5L1ohY8wUkOWX/sRGj+JwkaZT7iBVxNBmEr6QBDF78eeAu4t6om m1e/vPeKqabBhkHNVGEYqv+P6t8MqXl4wytTKbMfmhzBXoA3h+COnlcQrVr6ZR5gtuOV J30yUm25OkKPv1RXFGI/j5TZ8QS8CGtl8v2Qza/jNsu8vwkfLTtV0Ar7CCB5p9skIrxQ br/NlAdUCNBJmScjxslWxyQESZC5GhOVWzdjaTzzFQZzES1uklYwMa/q+Bg7j8jrIszy CaNsCZn+ZBhcVI+tXPfXgG60d+RoGkwZmKHpBYVrk9fEipWlL5Z3eWagHCQxr4Qi2DeW dkjw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zzednVjR; 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 t12-20020a05620a450c00b0078bea4bfe3csi12384861qkp.769.2024.04.09.12.40.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:40:06 -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=zzednVjR; 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 1ruHGR-0000YK-Ey; Tue, 09 Apr 2024 15:36:15 -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 1ruHGQ-0000Xr-LE for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:14 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruHGO-0004dI-Uv for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:14 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6ed054f282aso3541071b3a.0 for ; Tue, 09 Apr 2024 12:36:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691371; x=1713296171; 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=+6xA9uOxQL6GHFyuuAVL91EMcYGjdhkuoxzjyRnEesc=; b=zzednVjRbN/2iPwxXCBlLXvi3F8W8UpCZ+BKARDqHNddJie0VaEB3ya2fruYfezvSs dgp89U5/nikhR7tNzktwpn5YdcwyQKzVTCgxbgVYFcgpquJ/9klSNdgUJIDC8GBj/UFH nSmpO09kRyNZ5rmoTg0Ox+gSiD4DOwb2rKNle0ZkxN4JFWPZB4xIQ+epuAgRDHA7EoI9 Lk4961TIENhFFbdqDX0WQ39KRMfYstFX959zoNAdk4CSQp6mQtmwWdo29lN9+CjHkWs2 XE7qiuyruzDBBQpzICbF1VRA4lK/qeSr1cEeiri6CGrF8vSgKIBX6Zux7uSHBc7sMkuS ChaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691371; x=1713296171; 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=+6xA9uOxQL6GHFyuuAVL91EMcYGjdhkuoxzjyRnEesc=; b=fNFq8tnzYD2l6q89vzJVtlZIxw12wjN/J9cug1NSGifAf8HITH69sGh56hCBKJQ3AZ x39yFADYbNh7Ou/NjG4vMeyohn1aHDKTCkwzicA3Yy6LH8LyE3jemcIRjVWqPxU2LPEl ZHZ18gncp6/uFMDgj+wGdbEqVRYlVAfQgB5KhzI9LYmf+Uwn5kpJUtICvHOtWjokoaBo eCKaQKJTzmBzQL1Y4S9efVKjMcLZFwMoQCi/z2wBpfojRLBEZrVII4MBIDlH99rWj9bb j4+b3M/9nNKIKdEhjok2BYo5ujKQWitfhwLMclbzJycxKym89LxBtQfIj/LqwPZ8TtPG QOyg== X-Gm-Message-State: AOJu0YzKjTNFudc0kVSZP3i58SaLcOlzFAeZQHjl1plaQCoRNuD6+Eab YU/MaQHSpHzaAbXak29aZjikPb+9xIHNTO4e09mUDUddS/UKKL6Ql7s9Yau59m369HlKxOjfxt9 E X-Received: by 2002:a05:6a20:5618:b0:1a7:5614:a8a0 with SMTP id ir24-20020a056a20561800b001a75614a8a0mr714514pzc.44.1712691371343; Tue, 09 Apr 2024 12:36:11 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Sven Schnelle , Helge Deller Subject: [PULL v2 04/20] target/hppa: Fix IIAOQ, IIASQ for pa2.0 Date: Tue, 9 Apr 2024 09:35:47 -1000 Message-Id: <20240409193603.1703216-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.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 The contents of IIAOQ depend on PSW_W. Follow the text in "Interruption Instruction Address Queues", pages 2-13 through 2-15. Tested-by: Sven Schnelle Tested-by: Helge Deller Reported-by: Sven Schnelle Fixes: b10700d826c ("target/hppa: Update IIAOQ, IIASQ for pa2.0") Signed-off-by: Richard Henderson --- target/hppa/int_helper.c | 20 +++++++++++--------- target/hppa/sys_helper.c | 18 +++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/target/hppa/int_helper.c b/target/hppa/int_helper.c index 90437a92cd..a667ee380d 100644 --- a/target/hppa/int_helper.c +++ b/target/hppa/int_helper.c @@ -107,14 +107,10 @@ void hppa_cpu_do_interrupt(CPUState *cs) /* step 3 */ /* - * For pa1.x, IIASQ is simply a copy of IASQ. - * For pa2.0, IIASQ is the top bits of the virtual address, - * or zero if translation is disabled. + * IIASQ is the top bits of the virtual address, or zero if translation + * is disabled -- with PSW_W == 0, this will reduce to the space. */ - if (!hppa_is_pa20(env)) { - env->cr[CR_IIASQ] = env->iasq_f >> 32; - env->cr_back[0] = env->iasq_b >> 32; - } else if (old_psw & PSW_C) { + if (old_psw & PSW_C) { env->cr[CR_IIASQ] = hppa_form_gva_psw(old_psw, env->iasq_f, env->iaoq_f) >> 32; env->cr_back[0] = @@ -123,8 +119,14 @@ void hppa_cpu_do_interrupt(CPUState *cs) env->cr[CR_IIASQ] = 0; env->cr_back[0] = 0; } - env->cr[CR_IIAOQ] = env->iaoq_f; - env->cr_back[1] = env->iaoq_b; + /* IIAOQ is the full offset for wide mode, or 32 bits for narrow mode. */ + if (old_psw & PSW_W) { + env->cr[CR_IIAOQ] = env->iaoq_f; + env->cr_back[1] = env->iaoq_b; + } else { + env->cr[CR_IIAOQ] = (uint32_t)env->iaoq_f; + env->cr_back[1] = (uint32_t)env->iaoq_b; + } if (old_psw & PSW_Q) { /* step 5 */ diff --git a/target/hppa/sys_helper.c b/target/hppa/sys_helper.c index 208e51c086..22d6c89964 100644 --- a/target/hppa/sys_helper.c +++ b/target/hppa/sys_helper.c @@ -78,21 +78,21 @@ target_ulong HELPER(swap_system_mask)(CPUHPPAState *env, target_ulong nsm) void HELPER(rfi)(CPUHPPAState *env) { - env->iasq_f = (uint64_t)env->cr[CR_IIASQ] << 32; - env->iasq_b = (uint64_t)env->cr_back[0] << 32; - env->iaoq_f = env->cr[CR_IIAOQ]; - env->iaoq_b = env->cr_back[1]; + uint64_t mask; + + cpu_hppa_put_psw(env, env->cr[CR_IPSW]); /* * For pa2.0, IIASQ is the top bits of the virtual address. * To recreate the space identifier, remove the offset bits. + * For pa1.x, the mask reduces to no change to space. */ - if (hppa_is_pa20(env)) { - env->iasq_f &= ~env->iaoq_f; - env->iasq_b &= ~env->iaoq_b; - } + mask = gva_offset_mask(env->psw); - cpu_hppa_put_psw(env, env->cr[CR_IPSW]); + env->iaoq_f = env->cr[CR_IIAOQ]; + env->iaoq_b = env->cr_back[1]; + env->iasq_f = (env->cr[CR_IIASQ] << 32) & ~(env->iaoq_f & mask); + env->iasq_b = (env->cr_back[0] << 32) & ~(env->iaoq_b & mask); } static void getshadowregs(CPUHPPAState *env) From patchwork Tue Apr 9 19:35:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787238 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383642wrs; Tue, 9 Apr 2024 12:37:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWFPrQr/aF7FZBCxxBytLehn6LvSxEolMAf/bu6WgMfScqlPcpS9gJ7YX839zqrS/9a042xAdBhnJD9CNxpBoGq X-Google-Smtp-Source: AGHT+IE9ZVx5PBImEYLpjH4BREQ9K7RcXeu3vSYtqiwFtzM7O4v0kFb1MO3LIfEpbkFs0zWeNIoy X-Received: by 2002:a05:620a:198c:b0:78d:67b1:ca90 with SMTP id bm12-20020a05620a198c00b0078d67b1ca90mr919381qkb.62.1712691470143; Tue, 09 Apr 2024 12:37:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691470; cv=none; d=google.com; s=arc-20160816; b=bLfKrzkQ3EzDH+KLg01K1QlMSXOdxT6na2I86xBDBXWpg7iCvncKytZGwnjfdBUGlL 9ZcSNLQuBxkCz90zScZU9kfnM7jgoQmRZq/IBp9uc36TuMDZIxPRRy3H6r3r3MAQqsL8 E6/pMFATzsXbEpJqB/HQJGkcn9GaqUIHPKj0Dm2f6b/PGDe01qRh4bUTMHa1JOEKE/R0 2CpArCn1jsOww3sCX9K+DhcnLjv+55V1E/1mm7HSCJVdcFaHXSNs4qTzQLL9whaqD2+S M+3JH31cpDyklWpFPBFeHTx4olFNgI/kJ9H8KvFPfChWHc64owi5c93dZSdOaS7EjzPL 2KOA== 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=RcrZGxEnfZgrLqlhciK4hABUGUNHIg16hIoNjeHOda0=; fh=UxcOinUvtH9RCUG8YjsmzGmJmYoXEUythTaZQ7RVwi0=; b=ZNv52PM09qp/ftM6AtCxvywYCQtaWA/hFn0q54zeTwSfzhZyRbkCRvl4Qf2bsmQQuI 9WbEft9ZZxJsRDs836BHxwvCyAZUhpuE4iroi4z/awmN7hexj4O6/k2Lo7MtS0EB1YYq w8X6ro28RhmQJ2mFqvth97tf/H60i3iLszstHxf7HSrb3EH6QrRb+veZoDQ82aroxKbZ /lt8gFl7k/dzGI0FVcdNIJRprD4PAk+8NCzDot6hXoEXaEvmJPk5Vdaywdk69elIT05e qY8HN/dE1RM7fGIFSafob3Uum+fkUQCBRzx7kwNSFeQli7ULf1ZuVfsUVIPL59X4Y0sH YTOg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O0XjgK0B; 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 v25-20020ae9e319000000b0078d5b690bcesi7562090qkf.681.2024.04.09.12.37.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:37:50 -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=O0XjgK0B; 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 1ruHGT-0000Yj-6a; Tue, 09 Apr 2024 15:36: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 1ruHGR-0000Ya-V2 for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:15 -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 1ruHGQ-0004dV-97 for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:15 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1e3ca546d40so32787645ad.3 for ; Tue, 09 Apr 2024 12:36:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691373; x=1713296173; 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=RcrZGxEnfZgrLqlhciK4hABUGUNHIg16hIoNjeHOda0=; b=O0XjgK0BOwClsrHSD5SVhItjS0tXD5REhSWHRaLcsuoHHSTR5ZKYWhk4sn4yr0uvy5 GpAhRKyJB52zRXjE11IY0FpYSD1MEYSU5xNypA1OW9HC7UqZhieTLx0e3Ckdm4E09pW7 I7nsWq8yJQBGHIO0CBqTIxbWwGFYXqI1RnwKhz9YIKMknIi6Z4S0lkDvvV8AcEIRkil9 KpQKIl6ZjZ++GORxWMbMk1PJpzPYo77idXjyJhOJi5BfYhrLOC2hxuVx2kWBRIlY+f7q WHNb5IowYYcPoSqZKRp/Ix3aNTXGFdgUAKzBHQ27oBHqr3Yq0q2rvopDRIJoIjRKVT9q e4HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691373; x=1713296173; 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=RcrZGxEnfZgrLqlhciK4hABUGUNHIg16hIoNjeHOda0=; b=BPGnub6gilv+W0pYLEsWTlyr8lkxehhroRgBhF0KLt8WU+r7CY5h5dvCHe7xbfQV// 8R6xKTO6Hx/WGf4P6RdpdXJeEgDP0mbkPJj4TSlY3Ym9L/HTZZf3FIRFCvHlU+/tIHeQ i3UKE2RoqCI58zQ/hZNwTzij7SsgrWN1W+Yon0Cz0F8aOi3rAKpxc16ib8bErhpp/7dB 10uiL2LrjvaJjdDHb8t3IrqXjVzK1lqu2O4sqRt4E7r59q2S/DzaCd+CGPUj8LTpBcw0 91fkdbHiIiZ1M7Ar+lOfRPrx00eYH9vMwU9wlbyuQ9pHiI6NYJOz8jMnGFGiHtg1MXsl yCxw== X-Gm-Message-State: AOJu0YzymKBEoT0HlmlkEdb22TTl2bVGmIKX+G0Qa2PMZOfhMFz2dIpY Z/3aVwGupvUTYlX4gz0rUmZ78yWBrxwaKQnamL0Xkm5bry/lApayRe+CXhgulvDlAZeELIMxmba A X-Received: by 2002:a17:902:e541:b0:1e2:a5b3:e4 with SMTP id n1-20020a170902e54100b001e2a5b300e4mr996525plf.0.1712691372878; Tue, 09 Apr 2024 12:36:12 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Zack Buhman , Yoshinori Sato , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?q?d=C3=A9?= Subject: [PULL v2 05/20] target/sh4: mac.w: memory accesses are 16-bit words Date: Tue, 9 Apr 2024 09:35:48 -1000 Message-Id: <20240409193603.1703216-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Zack Buhman Before this change, executing a code sequence such as: mova tblm,r0 mov r0,r1 mova tbln,r0 clrs clrmac mac.w @r0+,@r1+ mac.w @r0+,@r1+ .align 4 tblm: .word 0x1234 .word 0x5678 tbln: .word 0x9abc .word 0xdefg Does not result in correct behavior: Expected behavior: first macw : macl = 0x1234 * 0x9abc + 0x0 mach = 0x0 second macw: macl = 0x5678 * 0xdefg + 0xb00a630 mach = 0x0 Observed behavior (qemu-sh4eb, prior to this commit): first macw : macl = 0x5678 * 0xdefg + 0x0 mach = 0x0 second macw: (unaligned longword memory access, SIGBUS) Various SH-4 ISA manuals also confirm that `mac.w` is a 16-bit word memory access, not a 32-bit longword memory access. Signed-off-by: Zack Buhman Reviewed-by: Yoshinori Sato Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20240402093756.27466-1-zack@buhman.org> Signed-off-by: Richard Henderson --- target/sh4/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/sh4/translate.c b/target/sh4/translate.c index a9b1bc7524..6643c14dde 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -816,10 +816,10 @@ static void _decode_opc(DisasContext * ctx) TCGv arg0, arg1; arg0 = tcg_temp_new(); tcg_gen_qemu_ld_i32(arg0, REG(B7_4), ctx->memidx, - MO_TESL | MO_ALIGN); + MO_TESW | MO_ALIGN); arg1 = tcg_temp_new(); tcg_gen_qemu_ld_i32(arg1, REG(B11_8), ctx->memidx, - MO_TESL | MO_ALIGN); + MO_TESW | MO_ALIGN); gen_helper_macw(tcg_env, arg0, arg1); tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 2); tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 2); From patchwork Tue Apr 9 19:35:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787233 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383300wrs; Tue, 9 Apr 2024 12:36:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX3JkLm/AU39lJRZHOzPdF6HMWyzYHVWIWcVgkVZsMHGtmavoAJppnDEf3fI61+9vtkxoGUDXHrOM4Bx1bx0Cx+ X-Google-Smtp-Source: AGHT+IHlIj6sdhsI+M+hyNpYNF2VFLN5FFeNec392HaXeeyB2r4tabibHJAGytTkZ5/gwStYh/s3 X-Received: by 2002:a05:6808:1cd:b0:3c5:f70d:f83 with SMTP id x13-20020a05680801cd00b003c5f70d0f83mr504057oic.18.1712691406421; Tue, 09 Apr 2024 12:36:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691406; cv=none; d=google.com; s=arc-20160816; b=CuiZAutAmxsUiSjI3zzN1qQRdESamDm7jWCUssd88jvO0Crjck3U/80BjCskwicv6r sTLyC6fCZI1w5nuv51AVvzC+GDv3xHGJAjcsAlf3Rl8VUAGGyZlmVMC0FTB5yGRUnkYH vyRhbYpllEcct8QO7sY1v+dxYk7WNs2wuHzadFZK/TagHgGRxlzCgJHLo/G0HOtILNuY ziV1fnARrrP0plSqEzm1Y9mAUysdQ4BUwkddnLgQZnF7E9OLKp6UQhzk9Iz7oJ7xzFho ddr7Y00maLiu42w9T49/h5bT/JpHbVCPFCZu9ytO/CElWOCgMWkmP0HpbfHOYVV/46hx esjg== 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=RlIBc4Oj7n9g5uv4QxhhxdXhuzA6b3JMjencPErHv6I=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=xIMNjkxI96P9NKlcG2ghxeqvNIncfMMQj9CdwELWdcBV480dkHExc4dDmyb0AHjZx5 Zrf59VevfIJbxagmF9cdO17iUNWft2tdSPVulx1JmTITr4/zMgKSdQTvcNA8zRV1/EP+ UZL9aMughAPgQxJHlcf+QZlmXwFQLsE6j+dwvOH9kRi46UMlIBCYdAjI8z0AsZ5DBOUg IdctEkFlhWzrCktPniI9HoOB1XR8CPnWNQGrBa2J1kJ7wBasTPcDqqJAIIp+GwohPyzy vXJDH6RVxMuec9N2wUK+QVBqfv3S6fi+1fDEWOSiS3qpduedDdGQYmeNWmr+cEd26GjR SDiQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HcFeQ8EH; 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 z6-20020a05622a060600b004346bb494f2si8548052qta.729.2024.04.09.12.36.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:36:46 -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=HcFeQ8EH; 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 1ruHGU-0000ZO-W9; Tue, 09 Apr 2024 15:36: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 1ruHGT-0000Yk-5N for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:17 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruHGR-0004de-FX for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:16 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1e4149e7695so19667785ad.0 for ; Tue, 09 Apr 2024 12:36:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691374; x=1713296174; 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=RlIBc4Oj7n9g5uv4QxhhxdXhuzA6b3JMjencPErHv6I=; b=HcFeQ8EHDy7FfHzk+m+Zbkkfy4RC+p/Pf8rnZphSCTwgbAzNuyljJgolJz9uABlVsH xYrPo1mMYc0FuEm26h0gwM+T3g+3l3Hlb6F30kmIOuLoPnM8qJop53YuSmt3ORSRf0Oe fbMoRxHG8GBsV7g9LY683xj5hOHtRpiLdWfECa7XEmrBCqxEgH+3EW5j1oNL3Vmy6WQo dMzHgez7tOKlGD8Hj4waytvi5/fOVsXZanhnOgGp6ZFDqCuPzpCdc1MlzskrTgm7lY9J DxZTPDCSHorkM+X2WT4vgrJ1QA7o6ZKOAaQdquourS/bn1E+a0QHH/mnUOVgpoaG4eji VISg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691374; x=1713296174; 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=RlIBc4Oj7n9g5uv4QxhhxdXhuzA6b3JMjencPErHv6I=; b=WDbOfHAKOVEkMtrUowmYVdWmpRIvONnDf/MQZN96jYqNN1p3lMpv/bkN1ylDuPcmya RwSCE+VumXoS2EA4py1pZEhjbkNUNjQkhMfPxAQKsTmDFq4OO6hbGio2/N4a8rkQ6zl1 3+7BeTe19tp7BCk/OproRbv26ZElLkrqGKbFoTnRXIaee40RYR/jmgaAe0K0PpCfu6eK EkKJQJxZg6W1tJIDxdSSMDKtp8UDsSJIgv3Yv8HqQ5krE5jXNSS8nc1dFVlnQl0/0B4v 7i2GC8vmk/leb6eI2C3yVxA1MT+Xq2P6ZwPZ3aVwtFVz+K7Cc2rnAaA/lDBGdI+xcC6j lm8w== X-Gm-Message-State: AOJu0YxCjPjoRWzREa6e+mw14Wz6DgmfxW+DeVdSiYXK5k/gZZt8RM3c kKVpqhmJteGp1Gw9tZb+NAMCYGAdpJTbuORmRJvgv2Cyfi2HDh6l8LmKIuVkFlVJ+nSkI4ilha1 W X-Received: by 2002:a17:902:efd6:b0:1e4:203d:ab80 with SMTP id ja22-20020a170902efd600b001e4203dab80mr691318plb.57.1712691374178; Tue, 09 Apr 2024 12:36:14 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL v2 06/20] target/sh4: Merge mach and macl into a union Date: Tue, 9 Apr 2024 09:35:49 -1000 Message-Id: <20240409193603.1703216-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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 Allow host access to the entire 64-bit accumulator. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/sh4/cpu.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h index 9211da6bde..d928bcf006 100644 --- a/target/sh4/cpu.h +++ b/target/sh4/cpu.h @@ -155,12 +155,22 @@ typedef struct CPUArchState { uint32_t pc; /* program counter */ uint32_t delayed_pc; /* target of delayed branch */ uint32_t delayed_cond; /* condition of delayed branch */ - uint32_t mach; /* multiply and accumulate high */ - uint32_t macl; /* multiply and accumulate low */ uint32_t pr; /* procedure register */ uint32_t fpscr; /* floating point status/control register */ uint32_t fpul; /* floating point communication register */ + /* multiply and accumulate: high, low and combined. */ + union { + uint64_t mac; + struct { +#if HOST_BIG_ENDIAN + uint32_t mach, macl; +#else + uint32_t macl, mach; +#endif + }; + }; + /* float point status register */ float_status fp_status; From patchwork Tue Apr 9 19:35:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787235 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383299wrs; Tue, 9 Apr 2024 12:36:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW0Je2eFNQa3lop3j+/NE3FgKXltagkKmyKNNlYkEqGN8ZpIKepStAhHUtpDYbxyGaoVviSUXDdmX88CM/yCebO X-Google-Smtp-Source: AGHT+IGlyFsEHM/2zLR9aDoa8hYysybZ9uB7O0IeUXcNjDAYlf9ug85gO/zfOrbFy8L31Alm5kaZ X-Received: by 2002:a05:622a:1ba2:b0:434:668b:32d1 with SMTP id bp34-20020a05622a1ba200b00434668b32d1mr844058qtb.9.1712691406577; Tue, 09 Apr 2024 12:36:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691406; cv=none; d=google.com; s=arc-20160816; b=OLPgbkwN+X/BSAau2osnd28LjUOS4NscFOXbIHnZeRx2yIrETiTIB5pl6F9Za0hQVi 3U6eAeorj3svIk5bvzbsCTL15MF4rsA4hPf+FCkKVu7gm2E/JB7vgQ5OQFmJDu0uhTc3 llPyQDsCChBRgPAuXHgA7oZDb7MikKl87+2UoAYthn6VEWItfGW8z8sG1KSnrepbT+YW QwuKTXr9BJuugellkOw1qsQuEqb/FeXuq4uJjBTOBUwwDshG3w927mQ/NHcrh9FV6SZH F/ClDFBYxjpur0b6o+Gy6vp95crtO9mLxrF4GtPyrLhOJwi/LEmPGgnyEP9t3bDAqHZv 1JPA== 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=kLktQTH6TNyDdnNQxMnhQfTJfTanNKRfEbSAV10avAE=; fh=HJpP7WWWMf63xDEKZYjQL9Y0mK13c8dar/udiJ/djJ4=; b=w2CwpwZxNDxclgnfTZeZaHwsVt/QeVqCfbkDlvgL+6O0H0dotn8mXJ8pNsp2BbsOz9 8Epv1l8qZDZhpmVrvK3/AEEM+IbcR6inh7hS4M5EOAgkDuHtOSDJIhmUEjlBhQ2Ub3f7 N1Kp2WNU1wyXSlPOFu6k9+nv8G8yte3C4VFZYWY/BUt0E1NFRtNGSyHBS04sRkobt1VR E+F7ONyO0RxHWz5DQBjviO5DlLVtViK0pK7e67GAOrbUIIIn25B71Gy08kthmQxvl5// 9hGpwTH13AijkS8cC+SjTcDjzcBVQ9Fdv0jRt+ku4LzVtTDv5xSVjKJ/C9ALQu1n6Ans 8urQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dnh+ZjsJ; 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 z10-20020ac87f8a000000b004348b9e8431si6130289qtj.598.2024.04.09.12.36.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:36:46 -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=dnh+ZjsJ; 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 1ruHGW-0000Zr-Hy; Tue, 09 Apr 2024 15:36:20 -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 1ruHGU-0000ZE-Rb for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:18 -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 1ruHGT-0004dq-1P for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:18 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1e3c7549078so26647645ad.0 for ; Tue, 09 Apr 2024 12:36:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691376; x=1713296176; 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=kLktQTH6TNyDdnNQxMnhQfTJfTanNKRfEbSAV10avAE=; b=dnh+ZjsJlns20lT2lNHhCO3aGUQdDzne+R01XIRDmXp11Zx70gK8Udc8M9jacuintM egkWeZ8hjoAkFDZ73k0sEz+tXFYPT5PvGpjLz9CH14xlX8juey9Q5SOfzsKH4Wtv9YEj dSdKVXUaSJ+KGBiOzw+uPDnsiQ84owbQneopjGl/LV8irkDo9byT3KhpCmRAM/my2fLW wEkNAqt064IKuFVMGiJxb4VCB7D/UoeMPIG6n5BpEEHJMqAFcz+Tj5Jy/QjhgE4csrdp qs7poTN1w45fZFTQPNS8B5G8qHvZmoj8DGFfvowjTF7uTjLd5FsYGJNVrowx83Vti76J XL+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691376; x=1713296176; 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=kLktQTH6TNyDdnNQxMnhQfTJfTanNKRfEbSAV10avAE=; b=GRmsMCqPdipiGjnlJa0JQEVwElKv0VncU1vuurwe1TLEscoRrdxSRb6KWYCBHcobQc pkzmGb54n94diARiQRBFEABCQkIfVDsHhxb8Xm5oZmaCuJNZDH3aDEJYKzoanL/9j4BX P0qA6jUyRnumA+gw6LPCltxPwPODMdkW1BUICx3wR3cE56rgG2l4VCVmi3f8CmtYbkYm 07sRxQjGDgUYLO68tM+j71tNBmwfHXsN5mBXNW+zlau4e76IvODTU34JdyeZPEu5rcfF m2NEgJ1geYQGAM85qaeDL0kenZVoYPTtBsM26KTT3K6+ZnrMB+Ry6odo5wr8Xj5QP3T4 X+Ww== X-Gm-Message-State: AOJu0YyHHD9okGOr8X5vEj2xtpxMRhl6MD49wjMg9YJrVpCSu7wSQ3HL L5ikuND68Y64vJdGSKrxxmC9ZiJfwkbsK2OQpuEylUnBtDtM0N9n3wccK8JEXjTED4mEHjf1rvv l X-Received: by 2002:a17:903:185:b0:1e2:7734:63dd with SMTP id z5-20020a170903018500b001e2773463ddmr5742263plg.30.1712691375703; Tue, 09 Apr 2024 12:36:15 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Zack Buhman , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL v2 07/20] target/sh4: Fix mac.l with saturation enabled Date: Tue, 9 Apr 2024 09:35:50 -1000 Message-Id: <20240409193603.1703216-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-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 From: Zack Buhman The saturation arithmetic logic in helper_macl is not correct. I tested and verified this behavior on a SH7091. Signed-off-by: Zack Buhman Message-Id: <20240404162641.27528-2-zack@buhman.org> [rth: Reformat helper_macl, add a test case.] Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/sh4/helper.h | 2 +- target/sh4/op_helper.c | 23 ++++++------ tests/tcg/sh4/test-macl.c | 67 +++++++++++++++++++++++++++++++++++ tests/tcg/sh4/Makefile.target | 5 +++ 4 files changed, 86 insertions(+), 11 deletions(-) create mode 100644 tests/tcg/sh4/test-macl.c diff --git a/target/sh4/helper.h b/target/sh4/helper.h index 8d792f6b55..64056e4a39 100644 --- a/target/sh4/helper.h +++ b/target/sh4/helper.h @@ -11,7 +11,7 @@ DEF_HELPER_3(movcal, void, env, i32, i32) DEF_HELPER_1(discard_movcal_backup, void, env) DEF_HELPER_2(ocbi, void, env, i32) -DEF_HELPER_3(macl, void, env, i32, i32) +DEF_HELPER_3(macl, void, env, s32, s32) DEF_HELPER_3(macw, void, env, i32, i32) DEF_HELPER_2(ld_fpscr, void, env, i32) diff --git a/target/sh4/op_helper.c b/target/sh4/op_helper.c index 4559d0d376..d0bae0cc00 100644 --- a/target/sh4/op_helper.c +++ b/target/sh4/op_helper.c @@ -158,20 +158,23 @@ void helper_ocbi(CPUSH4State *env, uint32_t address) } } -void helper_macl(CPUSH4State *env, uint32_t arg0, uint32_t arg1) +void helper_macl(CPUSH4State *env, int32_t arg0, int32_t arg1) { + const int64_t min = -(1ll << 47); + const int64_t max = (1ll << 47) - 1; + int64_t mul = (int64_t)arg0 * arg1; + int64_t mac = env->mac; int64_t res; - res = ((uint64_t) env->mach << 32) | env->macl; - res += (int64_t) (int32_t) arg0 *(int64_t) (int32_t) arg1; - env->mach = (res >> 32) & 0xffffffff; - env->macl = res & 0xffffffff; - if (env->sr & (1u << SR_S)) { - if (res < 0) - env->mach |= 0xffff0000; - else - env->mach &= 0x00007fff; + if (!(env->sr & (1u << SR_S))) { + res = mac + mul; + } else if (sadd64_overflow(mac, mul, &res)) { + res = mac < 0 ? min : max; + } else { + res = MIN(MAX(res, min), max); } + + env->mac = res; } void helper_macw(CPUSH4State *env, uint32_t arg0, uint32_t arg1) diff --git a/tests/tcg/sh4/test-macl.c b/tests/tcg/sh4/test-macl.c new file mode 100644 index 0000000000..b66c854365 --- /dev/null +++ b/tests/tcg/sh4/test-macl.c @@ -0,0 +1,67 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include + +#define MACL_S_MIN (-(1ll << 47)) +#define MACL_S_MAX ((1ll << 47) - 1) + +int64_t mac_l(int64_t mac, const int32_t *a, const int32_t *b) +{ + register uint32_t macl __asm__("macl") = mac; + register uint32_t mach __asm__("mach") = mac >> 32; + + asm volatile("mac.l @%0+,@%1+" + : "+r"(a), "+r"(b), "+x"(macl), "+x"(mach)); + + return ((uint64_t)mach << 32) | macl; +} + +typedef struct { + int64_t mac; + int32_t a, b; + int64_t res[2]; +} Test; + +__attribute__((noinline)) +void test(const Test *t, int sat) +{ + int64_t res; + + if (sat) { + asm volatile("sets"); + } else { + asm volatile("clrs"); + } + res = mac_l(t->mac, &t->a, &t->b); + + if (res != t->res[sat]) { + fprintf(stderr, "%#llx + (%#x * %#x) = %#llx -- got %#llx\n", + t->mac, t->a, t->b, t->res[sat], res); + abort(); + } +} + +int main() +{ + static const Test tests[] = { + { 0x00007fff12345678ll, INT32_MAX, INT32_MAX, + { 0x40007ffe12345679ll, MACL_S_MAX } }, + { MACL_S_MIN, -1, 1, + { 0xffff7fffffffffffll, MACL_S_MIN } }, + { INT64_MIN, -1, 1, + { INT64_MAX, MACL_S_MIN } }, + { 0x00007fff00000000ll, INT32_MAX, INT32_MAX, + { 0x40007ffe00000001ll, MACL_S_MAX } }, + { 4, 1, 2, { 6, 6 } }, + { -4, -1, -2, { -2, -2 } }, + }; + + for (int i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i) { + for (int j = 0; j < 2; ++j) { + test(&tests[i], j); + } + } + return 0; +} diff --git a/tests/tcg/sh4/Makefile.target b/tests/tcg/sh4/Makefile.target index 16eaa850a8..9a11c10924 100644 --- a/tests/tcg/sh4/Makefile.target +++ b/tests/tcg/sh4/Makefile.target @@ -9,3 +9,8 @@ run-signals: signals $(call skip-test, $<, "BROKEN") run-plugin-signals-with-%: $(call skip-test, $<, "BROKEN") + +VPATH += $(SRC_PATH)/tests/tcg/sh4 + +test-macl: CFLAGS += -O -g +TESTS += test-macl From patchwork Tue Apr 9 19:35:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787243 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383848wrs; Tue, 9 Apr 2024 12:38:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUVhLp3rHx4uV3pS/CvIbCCZD8366PHuCg2rOiz5pobkWz09feIE6CYhF2w7kZfC/8ADFkemXdvE9z6fTrtkVBa X-Google-Smtp-Source: AGHT+IGv7x5bJ7V2l+3hLgLaqYjXf6DnXOEGU0Js4VmY/6SJFyIA1S7f8Kqj8hFsesBwP+GY6eAG X-Received: by 2002:ac8:7d91:0:b0:434:e2d7:c4c7 with SMTP id c17-20020ac87d91000000b00434e2d7c4c7mr862715qtd.9.1712691512229; Tue, 09 Apr 2024 12:38:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691512; cv=none; d=google.com; s=arc-20160816; b=z2zGXaSAN2vo8cXWLnt29kTSsxYSnD9iVniPBP51qVPCdUSC2d/188xYAsw/sHqbXy aVkmvRCgoexiu2fH/fh4YBkPYWRV4Pc6zIvnLScV9LizVn6CwDfSFD3+AFm2TJ9GOyqz pH+1rO7Uc1dn5RV+AC6ZA7thWmpXuawxjar2M9MSNoRJSOq3va1Accu/HoNWQAyWjAQl CQyTpH9zmiemI4s4DL/iQu3ltvJpGOQuu1dR3sHt960CKu9L+m8u0ChM9bEg53xuPuPl ZPyNe0gsFsnlFJ1JAUerWlQsZVX8VZQ3QiNpG/73Xa8LHFIxZgpWdZpjZkFrJLsdVrAq 5D/g== 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=/A33LtPdfhd6ZXxcd3sa54LWhQX38sygsNQTelB9lyU=; fh=UxcOinUvtH9RCUG8YjsmzGmJmYoXEUythTaZQ7RVwi0=; b=hBUf0K8WjGx9QeTjvdABYPqrC1E6JbbGn8LZVn931WyYxK8XWU4XqlC6bCVkNbHtuS kxiFne+Zo+noJRoYo1qv6C2UAqf9uy+4ypdvINoqquHtS9Vxi46Kn4VWwruWIP3HAfVK EJuvKTtNmhC+UnlLMzjZ821MNcVGPl8BeKqC8pJkpTaSMjM1w5IvSym/76eZv69T2iR/ kFDlPA1/vHRGZ98vQY6f8jFeWTgqzKl/DHG5yOfnuq6nhkXZsdvvjjbNKtEz/n3tILVF rqEJ6mdiWDK1KteZLCZtFlMeHwRivYyu0WVK5NrL0DTlfvn7s1rYDYUu0iLgwWlj8pJ2 rANg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="msmHIh8/"; 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 j4-20020ac85f84000000b0043466522979si4793477qta.127.2024.04.09.12.38.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:38:32 -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="msmHIh8/"; 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 1ruHGY-0000aA-6U; Tue, 09 Apr 2024 15:36: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 1ruHGW-0000Zt-IJ for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:20 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruHGU-0004e1-QW for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:20 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1e3ca4fe4cfso24517255ad.2 for ; Tue, 09 Apr 2024 12:36:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691377; x=1713296177; 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=/A33LtPdfhd6ZXxcd3sa54LWhQX38sygsNQTelB9lyU=; b=msmHIh8/wnogAEyQ61lxKBxfhYiEUJj8nyaXWfPJwbB3C3gZAxHaysnLjqcM7m8qwg xd5ZAuLKjwnQeZhkZyrKeQz7kgmUjYVjfdDotEvdc+6fjtVkQHedeovKQeYJGxsP8rXi LrjEnyiYgT7sYASfoM5RVYP6OZkVAcxPXifNAWHGRjVVDxlqvsGk4B15jJPUQVxdh7kU zbOiwdhYTox3LDwMuL0v4g4akm8l/60telfHshbJeF7mIrOReC4K/amiyOaEQRuYINo9 tryJx1Qo6B5Q4z8MjVXaGp5T+XEjJf0AFRrquX/6+vaF8qzQ1KqhMuKZ7O7uFAHlcIHy oZBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691377; x=1713296177; 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=/A33LtPdfhd6ZXxcd3sa54LWhQX38sygsNQTelB9lyU=; b=RNy2mVky6YbEYuG/AgSPpFGfH+Wf5rMjDiFhBTFzM/bEkIB2ovapiBUBt3fsrkaV4L EQBRoMTCEevnvRffY8pTARm5TV+oNwU5doApAejI6IyMsGIJPopf0PGJCmJJWB8slEHJ A2Rm2bMjy5GxpbB6SuCKx30cRUAdvtDN5wnJdoZcBlx9/eC11haKvLaz4PZ41UdD9iZO g8lbiFujBZcSxc5oy2ylnorKIc3xx3rUz0aElN1cfA0rmGBJXHRIj+zyMKxiwn24eAZV +X9Sqdebn2FHd5XGcRkogX2F/kzASdbmfOOoo12zv6Z65LglWMjPJRbVi9+bQLxchILD LpWQ== X-Gm-Message-State: AOJu0YwRIOS8fOXYrzVIiqNWvzpGsjUJbg4h5BCqkB+7rjAwFGDCLtuc /OuMFwumjwUUZKWBNabl5N1nFdh+98WftuL5DF18F/qsV9GP75irAyuE5OxhAMN+B0LICqyEBXR p X-Received: by 2002:a17:902:ee46:b0:1e4:970e:37a7 with SMTP id 6-20020a170902ee4600b001e4970e37a7mr735831plo.60.1712691377298; Tue, 09 Apr 2024 12:36:17 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Zack Buhman , Yoshinori Sato , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?q?d=C3=A9?= Subject: [PULL v2 08/20] target/sh4: Fix mac.w with saturation enabled Date: Tue, 9 Apr 2024 09:35:51 -1000 Message-Id: <20240409193603.1703216-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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 From: Zack Buhman The saturation arithmetic logic in helper_macw is not correct. I tested and verified this behavior on a SH7091. Reviewd-by: Yoshinori Sato Signed-off-by: Zack Buhman Message-Id: <20240405233802.29128-3-zack@buhman.org> [rth: Reformat helper_macw, add a test case.] Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/sh4/helper.h | 2 +- target/sh4/op_helper.c | 28 +++++++++------- tests/tcg/sh4/test-macw.c | 61 +++++++++++++++++++++++++++++++++++ tests/tcg/sh4/Makefile.target | 3 ++ 4 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 tests/tcg/sh4/test-macw.c diff --git a/target/sh4/helper.h b/target/sh4/helper.h index 64056e4a39..29011d3dbb 100644 --- a/target/sh4/helper.h +++ b/target/sh4/helper.h @@ -12,7 +12,7 @@ DEF_HELPER_1(discard_movcal_backup, void, env) DEF_HELPER_2(ocbi, void, env, i32) DEF_HELPER_3(macl, void, env, s32, s32) -DEF_HELPER_3(macw, void, env, i32, i32) +DEF_HELPER_3(macw, void, env, s32, s32) DEF_HELPER_2(ld_fpscr, void, env, i32) diff --git a/target/sh4/op_helper.c b/target/sh4/op_helper.c index d0bae0cc00..99394b714c 100644 --- a/target/sh4/op_helper.c +++ b/target/sh4/op_helper.c @@ -177,22 +177,28 @@ void helper_macl(CPUSH4State *env, int32_t arg0, int32_t arg1) env->mac = res; } -void helper_macw(CPUSH4State *env, uint32_t arg0, uint32_t arg1) +void helper_macw(CPUSH4State *env, int32_t arg0, int32_t arg1) { - int64_t res; + /* Inputs are already sign-extended from 16 bits. */ + int32_t mul = arg0 * arg1; - res = ((uint64_t) env->mach << 32) | env->macl; - res += (int64_t) (int16_t) arg0 *(int64_t) (int16_t) arg1; - env->mach = (res >> 32) & 0xffffffff; - env->macl = res & 0xffffffff; if (env->sr & (1u << SR_S)) { - if (res < -0x80000000) { + /* + * In saturation arithmetic mode, the accumulator is 32-bit + * with carry. MACH is not considered during the addition + * operation nor the 32-bit saturation logic. + */ + int32_t res, macl = env->macl; + + if (sadd32_overflow(macl, mul, &res)) { + res = macl < 0 ? INT32_MIN : INT32_MAX; + /* If overflow occurs, the MACH register is set to 1. */ env->mach = 1; - env->macl = 0x80000000; - } else if (res > 0x000000007fffffff) { - env->mach = 1; - env->macl = 0x7fffffff; } + env->macl = res; + } else { + /* In non-saturation arithmetic mode, the accumulator is 64-bit */ + env->mac += mul; } } diff --git a/tests/tcg/sh4/test-macw.c b/tests/tcg/sh4/test-macw.c new file mode 100644 index 0000000000..4eceec8634 --- /dev/null +++ b/tests/tcg/sh4/test-macw.c @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include + +int64_t mac_w(int64_t mac, const int16_t *a, const int16_t *b) +{ + register uint32_t macl __asm__("macl") = mac; + register uint32_t mach __asm__("mach") = mac >> 32; + + asm volatile("mac.w @%0+,@%1+" + : "+r"(a), "+r"(b), "+x"(macl), "+x"(mach)); + + return ((uint64_t)mach << 32) | macl; +} + +typedef struct { + int64_t mac; + int16_t a, b; + int64_t res[2]; +} Test; + +__attribute__((noinline)) +void test(const Test *t, int sat) +{ + int64_t res; + + if (sat) { + asm volatile("sets"); + } else { + asm volatile("clrs"); + } + res = mac_w(t->mac, &t->a, &t->b); + + if (res != t->res[sat]) { + fprintf(stderr, "%#llx + (%#x * %#x) = %#llx -- got %#llx\n", + t->mac, t->a, t->b, t->res[sat], res); + abort(); + } +} + +int main() +{ + static const Test tests[] = { + { 0, 2, 3, { 6, 6 } }, + { 0x123456787ffffffell, 2, -3, + { 0x123456787ffffff8ll, 0x123456787ffffff8ll } }, + { 0xabcdef127ffffffall, 2, 3, + { 0xabcdef1280000000ll, 0x000000017fffffffll } }, + { 0xfffffffffll, INT16_MAX, INT16_MAX, + { 0x103fff0000ll, 0xf3fff0000ll } }, + }; + + for (int i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i) { + for (int j = 0; j < 2; ++j) { + test(&tests[i], j); + } + } + return 0; +} diff --git a/tests/tcg/sh4/Makefile.target b/tests/tcg/sh4/Makefile.target index 9a11c10924..4d09291c0c 100644 --- a/tests/tcg/sh4/Makefile.target +++ b/tests/tcg/sh4/Makefile.target @@ -14,3 +14,6 @@ VPATH += $(SRC_PATH)/tests/tcg/sh4 test-macl: CFLAGS += -O -g TESTS += test-macl + +test-macw: CFLAGS += -O -g +TESTS += test-macw From patchwork Tue Apr 9 19:35:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787252 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp384327wrs; Tue, 9 Apr 2024 12:40:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWJiZ/pTduiZcRwjMCaQCX+cZQgaZ4fvCKTYSLDW3YhWSQCm1n1jakvz38XAR4ZvRVyHI9ZwHTvuSGK5E3ap9wZ X-Google-Smtp-Source: AGHT+IFVIIsArVbLtwd3hJc6fwD/UP7XIrn0n9KxevbS634j2ajRC4RR5iLXNet4hKIRe306yUfv X-Received: by 2002:a25:a565:0:b0:dcc:a446:551 with SMTP id h92-20020a25a565000000b00dcca4460551mr747705ybi.52.1712691600253; Tue, 09 Apr 2024 12:40:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691600; cv=none; d=google.com; s=arc-20160816; b=OjH4BC5DJ/+j3wOTMMABKxdF/ttokM6PP5x8ehgjKc0oQkGOYHvVxcV3y74mTtUijI X5gbGH7eI9CWOiU7pPKzZtPDa8PDR+E77yjMEHCT/6+qxmH5Xkmmq0qR8Fcj6KFkJk2C VXQSFq2V6XYTbD1rOM3yU2rDeHvj13uav+kU5WPumO+Tqi0LSLuKrMQPhbxaUPRlNOkY DG+e0U4jUUf9GFcBOR2ARmHLhfu5z1dB+73F2NU6EantFC3xMmobGO7DpfdwdmdcJX0/ fFlVRIN+XwyStl7JQuKV7Wl9Zk7X1n5Fx//CW4J8jQAGvs6k9od8tjr4D+zlVR7oc2Ar jF+Q== 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=dcOly76/DhggOn/gIOyjbUFt0Yi/pTy/JSDCl4K3h8A=; fh=K7lFbwafzDFe9RlZVtFGWQUxhy0uw4Mr/E9DDf1LH8k=; b=bw8yJw2+S42WR4jnij3vnTeFgY748cHwwBs6+2GZTO2CFQ7/Qt0pjfKZwn6J3zk3FL sNjAdvrw/6yRfE0+C+Td+QSBBCyfLlc2lmjW/drbwvB4N/6axk83S2YP1oxIxC6RjCM7 5jzRrBNXM5oKa6+zemr71HNbQz02MN9LxOWLvF/GIqHg4k2IKgJTszNw/WcgBCjV/Hp6 oh3Xtbq1l1HK33EykL5Gw8YndGqfxsb7qyXFfDGP9CA7a0kxl6/loFb/m60RoN2635y9 0ZRZVKV+fl6stuzwskRjj6Eh1hJlpplpxl1IAMACqGZ5yiZ0WT4Ove02L0EYE/EBsOV7 C46g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="jwqxI3/4"; 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-20020a05620a454c00b0078d572d4811si8962680qkp.443.2024.04.09.12.40.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:40:00 -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="jwqxI3/4"; 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 1ruHGY-0000aR-QF; Tue, 09 Apr 2024 15:36: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 1ruHGX-0000a3-Qk for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:21 -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 1ruHGW-0004eG-5O for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:21 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1e220e40998so38065785ad.1 for ; Tue, 09 Apr 2024 12:36:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691379; x=1713296179; 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=dcOly76/DhggOn/gIOyjbUFt0Yi/pTy/JSDCl4K3h8A=; b=jwqxI3/4Zfon+kR8l7DTN8rsjOlg6srLqxNmOC/f2Dg0C38qoU1GjeD8gpruqlqyyi SYZ6jPr676/iLBdm+aTEVU3B7UcJnBW3tUBcTGjaRu/Qpfepnm3DAD/iHRXoGExC5tuT Ap0qYqhKPd5SithiuFnEy651oG1gzzefygP2wugdrFwN5eHOZIudV3kYQj9rk3XJET1X b3I7josc37xF6XXnLGVGlzrOrF3+hsphZY9ST0FDoBk9CZslvt3iU3Twag9/tGxYDPXw und2zIZ7a2iw+++0j9qR7xYBj3saKfM5DrZWGqYdXADS5xY7O9nkLDbTuaNbSKz2mXY0 WLow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691379; x=1713296179; 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=dcOly76/DhggOn/gIOyjbUFt0Yi/pTy/JSDCl4K3h8A=; b=Fl6CKWKFrX/Nq252By6fOveyn+J51+fCzlUekwTzpgFfcTTZ90YrbESlBmvLyIhobs CHbjBIaz+GLGwTS7v1S1BPomxfrdRDGqwx10+5I5znSK/ov6SszwamcAlVC3R5YyTY/1 D8fkHbJEAyBiey93l4phbvgb1UbQpRYMe+MqbInEPhfu9sQP6gJ/5J3X6qY/9m4rlWS/ 90AtJxwXWuSXU8EfgbCHmmEdAiKPS6WEQQpAbF0GQhyF2oIHjHvJtuu4QWDs+5LimjI4 5WTbuWKi54NorVHomhEVtAes63Jt7h8sbdG1v68ti9iIGyjWYOh7Z0R8+I3MEnjlzazL iZYQ== X-Gm-Message-State: AOJu0Yz8PcnwUN2zjpEonQoEKVR9GycZt8VM1B0YohuUtYfSbezZ/G2S 5sqXn6+NGLFdiwBg1IKJ1s8ZM51IIflkGYL7uvHGUArO6rtMmnPkUkj5UuJyadZR6Pm4L/xa0+U m X-Received: by 2002:a17:902:e80f:b0:1e3:e0a2:ccc3 with SMTP id u15-20020a170902e80f00b001e3e0a2ccc3mr875818plg.30.1712691378795; Tue, 09 Apr 2024 12:36:18 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Zack Buhman , Yoshinori Sato Subject: [PULL v2 09/20] target/sh4: add missing CHECK_NOT_DELAY_SLOT Date: Tue, 9 Apr 2024 09:35:52 -1000 Message-Id: <20240409193603.1703216-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-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 From: Zack Buhman CHECK_NOT_DELAY_SLOT is correctly applied to the branch-related instructions, but not to the PC-relative mov* instructions. I verified the existence of an illegal slot exception on a SH7091 when any of these instructions are attempted inside a delay slot. This also matches the behavior described in the SH-4 ISA manual. Signed-off-by: Zack Buhman Reviewed-by: Richard Henderson Message-Id: <20240407150705.5965-1-zack@buhman.org> Signed-off-by: Richard Henderson Reviewd-by: Yoshinori Sato --- target/sh4/translate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 6643c14dde..ebb6c901bf 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -523,6 +523,7 @@ static void _decode_opc(DisasContext * ctx) tcg_gen_movi_i32(REG(B11_8), B7_0s); return; case 0x9000: /* mov.w @(disp,PC),Rn */ + CHECK_NOT_DELAY_SLOT { TCGv addr = tcg_constant_i32(ctx->base.pc_next + 4 + B7_0 * 2); tcg_gen_qemu_ld_i32(REG(B11_8), addr, ctx->memidx, @@ -530,6 +531,7 @@ static void _decode_opc(DisasContext * ctx) } return; case 0xd000: /* mov.l @(disp,PC),Rn */ + CHECK_NOT_DELAY_SLOT { TCGv addr = tcg_constant_i32((ctx->base.pc_next + 4 + B7_0 * 4) & ~3); tcg_gen_qemu_ld_i32(REG(B11_8), addr, ctx->memidx, @@ -1236,6 +1238,7 @@ static void _decode_opc(DisasContext * ctx) } return; case 0xc700: /* mova @(disp,PC),R0 */ + CHECK_NOT_DELAY_SLOT tcg_gen_movi_i32(REG(0), ((ctx->base.pc_next & 0xfffffffc) + 4 + B7_0 * 4) & ~3); return; From patchwork Tue Apr 9 19:35:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787244 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383851wrs; Tue, 9 Apr 2024 12:38:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXL/Ku29zyRb4p9GY0oeZ6JMh4U4g8FEzU7AmNp0HkG7nI5KCRzpYMO8Zt3klGGnJRs6xks3U9LwxPWK8nOkP6N X-Google-Smtp-Source: AGHT+IEEu6pxbDBLkB+QX8VPHU8R79eVUlYaaQpX4SByz4vsomiDCpDWvQFhiBjw5G+7QBzGmrTC X-Received: by 2002:a05:6102:6cc:b0:47a:19c7:1565 with SMTP id m12-20020a05610206cc00b0047a19c71565mr617903vsg.14.1712691512460; Tue, 09 Apr 2024 12:38:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691512; cv=none; d=google.com; s=arc-20160816; b=Whg4fhZWiU3e1whP1G1UyYPO8kLI9UpTYOVQs8diYaJ7RWPadS3whwIAr65ty/oGfV QFGzfL8K3D4W0ZgMpXvaI5LKEQaHmZ4dfGP9B9oVjroO1oi4KkcKYeBO48V6i+0yRmwf Syr3kZDFfiM0P4+18DTzMojqS9pmZMoZNUNGJohbCn7P7zoTJS8CWEzVQqLPYGiyQqM7 scHVAfHmJlzP5wG09kIyuMORccK46F0xkwgMdz2kCo7zgWdS8UT4qRuyvOUlBcbUacCZ 4ywCJ01z2A8/ZFZ0a3SLkQLOW/S2GETL32KbpoYVJnHSdxZE6fyoqP1wdJT/5Bzktc2u SXhQ== 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=cRQqZ9oBK6iehJFrs+uDcTw60o+LKkDegjDNYSUR+vc=; fh=LEzS/2znb383K59gW/mE4txfpskH6W/tMhITWj/DbfA=; b=H8eADZ4Bpg1oWBqC35ycMmtFbhOcwDxNTpwExfdRkFne8yQQsiNF+VI80MCTKZxOOO rKj2irblhDOk1RkYnv63SiBMlRS3LrNNo6DnQ7F0Hbl4fyRaO/ZqgL+z4ofuE+Ob/108 Fj9hmmKFEY4BAVWCla0T1xBREn55gdwI3gWgFktY/znSNZ4dvK2czuWIkrpNl6En+2lF 0W5hFv8n8MkNKRYZ04GmGZ4YfzwBN+1Gf73C8gZUWJteWcG24OF7xHYeqOqv96YwgUPD WIeXMuV3p3JKUIrZUSj0M/0Il5QkYKhWQyQQMLSrStyODsZEu79jQJP3uT8vJRiSXeqQ TY8A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Njv6Klsn; 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 ke14-20020a056214300e00b0069b1ed1a34csi4739105qvb.532.2024.04.09.12.38.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:38:32 -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=Njv6Klsn; 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 1ruHGb-0000bM-GD; Tue, 09 Apr 2024 15:36:25 -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 1ruHGZ-0000ak-Kq for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:23 -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 1ruHGX-0004eT-Ln for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:23 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1e3e84a302eso22005155ad.0 for ; Tue, 09 Apr 2024 12:36:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691380; x=1713296180; 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=cRQqZ9oBK6iehJFrs+uDcTw60o+LKkDegjDNYSUR+vc=; b=Njv6Klsn32MQZyMu2C4khd0Qe6fc2lROL9mL4z/4uwi3ImU+enqWydBS9xh62QDFy6 JEM9OMnWME8nenjgjCDEvCxyL0sPRxO74oA8u0HxlAy84anPjrL5ajHw9LZNg3BmRoVf XZZtxOdIOYAJdITPJayEf4wtkgwRwHKRbyawO2u4Axg1QtCGF3ibgdBw6vhmxIxPjmk+ atQlfXgSF9Ee1d0lBJX89UpR5ZdMchUCaifLYWkcSsgfhvZnJTDGewZm282ptZ5kH+1s V7XU3ePVk6aSKKYNp2Sf+dFJfDTMWgWhP01XAgy5czYquTVRCxAH3JYliNdcNgtoA/nv ucgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691380; x=1713296180; 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=cRQqZ9oBK6iehJFrs+uDcTw60o+LKkDegjDNYSUR+vc=; b=nHpUcDC7GdmK38sLYmOc/VQHmBF0V1X2AI+iWmh0Q8xdpU07WKflBueomMc4Wc8Y7m 0I90Sd+9HtjNnfYNA33JxGw5RZ5VnPU6JszeIvpj41jIfI7txE8MZYaJZ2exGZq1WYTp ZleslvlgkZzyUweVATqPX9u2V30BN3ls5/q1/OrCs7ipUgrakNrMdwY8z2fSxJmdAEeH UoM8vGeR/U7axImLFRcQMrAl7jzbvfYdHXxPvcbvAMvMLiJ9/RhN2S+ZPXj5Oa60GZyB pgdEz3tSs3al5z2g6yn9fNvSnM1AwOxDRYo4vge/aC80GpIksjyYzIooOl5Shal5jhC2 33tQ== X-Gm-Message-State: AOJu0Yw7Z7oQRm5ElYaovUtD284V1FSK7gN+FbEpfjLd8xNSKg/+1eM5 Ygvitdk6J7/68FCCZVj4KR410OgN1s6n2oUMol0K9kPpTcoRtOx1X554NdOiIuo3T/qzeUbwGf8 O X-Received: by 2002:a17:902:a3c8:b0:1e2:992a:ae3 with SMTP id q8-20020a170902a3c800b001e2992a0ae3mr782012plb.45.1712691380359; Tue, 09 Apr 2024 12:36:20 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Keith Packard Subject: [PULL v2 10/20] target/m68k: Map FPU exceptions to FPSR register Date: Tue, 9 Apr 2024 09:35:53 -1000 Message-Id: <20240409193603.1703216-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-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 From: Keith Packard Add helpers for reading/writing the 68881 FPSR register so that changes in floating point exception state can be seen by the application. Call these helpers in pre_load/post_load hooks to synchronize exception state. Signed-off-by: Keith Packard Reviewed-by: Richard Henderson Message-Id: <20230803035231.429697-1-keithp@keithp.com> Signed-off-by: Richard Henderson --- target/m68k/cpu.h | 3 +- target/m68k/helper.h | 2 ++ target/m68k/cpu.c | 12 +++++-- target/m68k/fpu_helper.c | 72 ++++++++++++++++++++++++++++++++++++++++ target/m68k/helper.c | 4 +-- target/m68k/translate.c | 4 +-- 6 files changed, 90 insertions(+), 7 deletions(-) diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index 346427e144..e184239a81 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -199,7 +199,8 @@ void cpu_m68k_set_ccr(CPUM68KState *env, uint32_t); void cpu_m68k_set_sr(CPUM68KState *env, uint32_t); void cpu_m68k_restore_fp_status(CPUM68KState *env); void cpu_m68k_set_fpcr(CPUM68KState *env, uint32_t val); - +uint32_t cpu_m68k_get_fpsr(CPUM68KState *env); +void cpu_m68k_set_fpsr(CPUM68KState *env, uint32_t val); /* * Instead of computing the condition codes after each m68k instruction, diff --git a/target/m68k/helper.h b/target/m68k/helper.h index 2bbe0dc032..95aa5e53bb 100644 --- a/target/m68k/helper.h +++ b/target/m68k/helper.h @@ -54,6 +54,8 @@ DEF_HELPER_4(fsdiv, void, env, fp, fp, fp) DEF_HELPER_4(fddiv, void, env, fp, fp, fp) DEF_HELPER_4(fsgldiv, void, env, fp, fp, fp) DEF_HELPER_FLAGS_3(fcmp, TCG_CALL_NO_RWG, void, env, fp, fp) +DEF_HELPER_2(set_fpsr, void, env, i32) +DEF_HELPER_1(get_fpsr, i32, env) DEF_HELPER_FLAGS_2(set_fpcr, TCG_CALL_NO_RWG, void, env, i32) DEF_HELPER_FLAGS_2(ftst, TCG_CALL_NO_RWG, void, env, fp) DEF_HELPER_3(fconst, void, env, fp, i32) diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 7c8efbb42c..df49ff1880 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -390,12 +390,19 @@ static const VMStateDescription vmstate_freg = { } }; +static int fpu_pre_save(void *opaque) +{ + M68kCPU *s = opaque; + + s->env.fpsr = cpu_m68k_get_fpsr(&s->env); + return 0; +} + static int fpu_post_load(void *opaque, int version) { M68kCPU *s = opaque; - cpu_m68k_restore_fp_status(&s->env); - + cpu_m68k_set_fpsr(&s->env, s->env.fpsr); return 0; } @@ -404,6 +411,7 @@ const VMStateDescription vmmstate_fpu = { .version_id = 1, .minimum_version_id = 1, .needed = fpu_needed, + .pre_save = fpu_pre_save, .post_load = fpu_post_load, .fields = (const VMStateField[]) { VMSTATE_UINT32(env.fpcr, M68kCPU), diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c index ab120b5f59..8314791f50 100644 --- a/target/m68k/fpu_helper.c +++ b/target/m68k/fpu_helper.c @@ -164,6 +164,78 @@ void HELPER(set_fpcr)(CPUM68KState *env, uint32_t val) cpu_m68k_set_fpcr(env, val); } +/* Convert host exception flags to cpu_m68k form. */ +static int cpu_m68k_exceptbits_from_host(int host_bits) +{ + int target_bits = 0; + + if (host_bits & float_flag_invalid) { + target_bits |= 0x80; + } + if (host_bits & float_flag_overflow) { + target_bits |= 0x40; + } + if (host_bits & (float_flag_underflow | float_flag_output_denormal)) { + target_bits |= 0x20; + } + if (host_bits & float_flag_divbyzero) { + target_bits |= 0x10; + } + if (host_bits & float_flag_inexact) { + target_bits |= 0x08; + } + return target_bits; +} + +/* Convert cpu_m68k exception flags to target form. */ +static int cpu_m68k_exceptbits_to_host(int target_bits) +{ + int host_bits = 0; + + if (target_bits & 0x80) { + host_bits |= float_flag_invalid; + } + if (target_bits & 0x40) { + host_bits |= float_flag_overflow; + } + if (target_bits & 0x20) { + host_bits |= float_flag_underflow; + } + if (target_bits & 0x10) { + host_bits |= float_flag_divbyzero; + } + if (target_bits & 0x08) { + host_bits |= float_flag_inexact; + } + return host_bits; +} + +uint32_t cpu_m68k_get_fpsr(CPUM68KState *env) +{ + int host_flags = get_float_exception_flags(&env->fp_status); + int target_flags = cpu_m68k_exceptbits_from_host(host_flags); + int except = (env->fpsr & ~(0xf8)) | target_flags; + return except; +} + +uint32_t HELPER(get_fpsr)(CPUM68KState *env) +{ + return cpu_m68k_get_fpsr(env); +} + +void cpu_m68k_set_fpsr(CPUM68KState *env, uint32_t val) +{ + env->fpsr = val; + + int host_flags = cpu_m68k_exceptbits_to_host((int) env->fpsr); + set_float_exception_flags(host_flags, &env->fp_status); +} + +void HELPER(set_fpsr)(CPUM68KState *env, uint32_t val) +{ + cpu_m68k_set_fpsr(env, val); +} + #define PREC_BEGIN(prec) \ do { \ FloatX80RoundPrec old = \ diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 1a475f082a..7a91f33b17 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -87,7 +87,7 @@ static int m68k_fpu_gdb_get_reg(CPUState *cs, GByteArray *mem_buf, int n) case 8: /* fpcontrol */ return gdb_get_reg32(mem_buf, env->fpcr); case 9: /* fpstatus */ - return gdb_get_reg32(mem_buf, env->fpsr); + return gdb_get_reg32(mem_buf, cpu_m68k_get_fpsr(env)); case 10: /* fpiar, not implemented */ return gdb_get_reg32(mem_buf, 0); } @@ -109,7 +109,7 @@ static int m68k_fpu_gdb_set_reg(CPUState *cs, uint8_t *mem_buf, int n) cpu_m68k_set_fpcr(env, ldl_p(mem_buf)); return 4; case 9: /* fpstatus */ - env->fpsr = ldl_p(mem_buf); + cpu_m68k_set_fpsr(env, ldl_p(mem_buf)); return 4; case 10: /* fpiar, not implemented */ return 4; diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 6ae3df43bc..8a194f2f21 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -4686,7 +4686,7 @@ static void gen_load_fcr(DisasContext *s, TCGv res, int reg) tcg_gen_movi_i32(res, 0); break; case M68K_FPSR: - tcg_gen_ld_i32(res, tcg_env, offsetof(CPUM68KState, fpsr)); + gen_helper_get_fpsr(res, tcg_env); break; case M68K_FPCR: tcg_gen_ld_i32(res, tcg_env, offsetof(CPUM68KState, fpcr)); @@ -4700,7 +4700,7 @@ static void gen_store_fcr(DisasContext *s, TCGv val, int reg) case M68K_FPIAR: break; case M68K_FPSR: - tcg_gen_st_i32(val, tcg_env, offsetof(CPUM68KState, fpsr)); + gen_helper_set_fpsr(tcg_env, val); break; case M68K_FPCR: gen_helper_set_fpcr(tcg_env, val); From patchwork Tue Apr 9 19:35:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787249 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383968wrs; Tue, 9 Apr 2024 12:38:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX1TzrKU37+n5qHfD45CGt15H4wS4NVKNEK7k2tXbIjGsAhbBT8TppZr3c4y6kcHN/0rwdnGiB4iZaKL7w6TM6n X-Google-Smtp-Source: AGHT+IG2H6aBvWQNSvNmTbcZpnUwb8ugF/nZYiV5Crf10Hzn/8caANnGwvwdgqwyQlQ/vU9qXWBQ X-Received: by 2002:a05:6808:4184:b0:3c5:e66b:1f79 with SMTP id dj4-20020a056808418400b003c5e66b1f79mr519580oib.16.1712691536320; Tue, 09 Apr 2024 12:38:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691536; cv=none; d=google.com; s=arc-20160816; b=Pm3TrlOZEBLbDgs1XBFBGRpjWJ6YkTHikStcj2YpYqVR4Rqc/K/82O1g06YnHR/0TA omElZOvLxRPlhgb8q4kfbdDEHxN/eRXecZESy2+UPRmHMabeXCaV+PnNHwrVk0d55WG3 I5LrIzJtuKYlcNB6q97IKogoQBt7eR/Wykmt80kUVD/FIYJSEFNaaCK3U+VAYTJ6/qfL S7QroKpcy3qIIe0ZHAgq22o13NmL0vF5yeHiaIpR0xQYArHvYuoJnDNTKpYDz4Jt7FDw 7aXvK50MLXvhDR0VqeeH8DR2KUwpg+gCH4Ufd9KOmW5O9NTDkyIzhGMMK5co2vCLXcKh 6gug== 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=gHgrMBfJl0EWko+KOSUm9E0b6yMA9Veb8odtrLbxwoY=; fh=XWt4jYijdNxai0FT2E6j/i4Lx4wzcENDxh6icUDNRFQ=; b=0RO8raVUNvR9sPAZ8c71HvPmGCy/BGot5foWx3swQeOYOrc9jsOFDgxbCXG9BKpVYa QMi6zIP6YeLUv4Smpw7/bGFPLajh+ufsKvR3+Lew+lQ6D+Ido5grQJiXI3iXvqYy/ith tsl1eWJ7ELGoouyr5NkGwHvGkx+p1GNG1+z5YCrR+FYgayqi+Q0gK+a28MO/1t+REUuW WrdaFnArg2dmH9nMQaPfskN1v8DFvpVJGVVagqMFXb7RBE1CCgEGb/0VnSorgvvkRo0S EgpLIMY/wO7B1Kp1DkrhqM/bsKHDwlIJkK1oKKpJ8IsWAtZiPRSz6t6pAgUG4kjByq2j xw9w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IEqn9q4m; 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 e13-20020ac8598d000000b00434996df207si5659924qte.402.2024.04.09.12.38.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:38:56 -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=IEqn9q4m; 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 1ruHGc-0000bd-3f; Tue, 09 Apr 2024 15:36:26 -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 1ruHGa-0000av-Px for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:24 -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 1ruHGZ-0004ee-4I for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:24 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1e3c9300c65so34837365ad.0 for ; Tue, 09 Apr 2024 12:36:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691382; x=1713296182; 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=gHgrMBfJl0EWko+KOSUm9E0b6yMA9Veb8odtrLbxwoY=; b=IEqn9q4mI7uGEEJ8Bwg0zenUgpV5E8P3xggkUB6+c0qc/04iha6C7W0R1PC6Ac7tjZ aAZQiNKmSdOFVoGEU+jUeRqcrq4RGu2/c51hc86oyEYt+PhODRBNzt80A9q79a+tNlbe DNmeFvRe8s7dzsx3/4itAWIzNv9caW9J6/YZGW7SUl2KEo6brYUk4SkGuhN5qK2m0M0u O5VsheCPWSRau8ePLnQB7+i4QcKBZ1crrF8xRqCxcNEnAe8HDgNv1TnSxSKEE6m7nsE/ sPmdgvCKXCPMJF7tzIYbAEm93yasvU3hu7Kyo06kzqbtacB56156/LT4dkr5K+bfO8YG JpLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691382; x=1713296182; 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=gHgrMBfJl0EWko+KOSUm9E0b6yMA9Veb8odtrLbxwoY=; b=F1mla7Qmk++vjGB+eSfh2TIzpInReSzpvSHKZX2XPHfqPhQsslOz8+0OFSfubbfTLx Yv+Gayj78hlfoNp4L1IxAtvL+lmAbgjUu3likIh+KYpdvLCfqqViQ0lQKV7tGTkpOKiF w9C+XFlEBTogUNuPizLI+VHpQ+N4w+R3VRyfsAghsaLidGwKD7bYeqzfnfOoKBpFA8g/ l2+mMK7sb/NWDfQXYHGOq97t3uZ/LuMLIWxmU7KW1LZ0KeJ3K/tjYZ9pm2QpeEfe63wZ Hw+JNX3T2Yl7+VpBX6rKUu5zlOgSNqkomlDJ/DwBsEdNNBCAQNxwDd9wc9CpGFACtNH7 FjCg== X-Gm-Message-State: AOJu0Yx6oRUARM5Tpany3MU4rV83orT7XjdNFWm0rMAkbyrwsw5aAmYc jvJhA6RkQWpyvx3jMrv1AmM+QfQVg7TI4j181dw4IN0fmEKYTzCBhu5rOqOKAQIwZBITg/oqPb1 / X-Received: by 2002:a17:903:41ce:b0:1e3:e081:d29b with SMTP id u14-20020a17090341ce00b001e3e081d29bmr808905ple.45.1712691381899; Tue, 09 Apr 2024 12:36:21 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?J=C3=B8rgen_Hansen?= , =?utf-8?q?Philip?= =?utf-8?q?pe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PULL v2 11/20] tcg: Add TCGContext.emit_before_op Date: Tue, 9 Apr 2024 09:35:54 -1000 Message-Id: <20240409193603.1703216-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-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 Allow operations to be emitted via normal expanders into the middle of the opcode stream. Tested-by: Jørgen Hansen Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 6 ++++++ tcg/tcg.c | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 451f3fec41..05a1912f8a 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -553,6 +553,12 @@ struct TCGContext { QTAILQ_HEAD(, TCGOp) ops, free_ops; QSIMPLEQ_HEAD(, TCGLabel) labels; + /* + * When clear, new ops are added to the tail of @ops. + * When set, new ops are added in front of @emit_before_op. + */ + TCGOp *emit_before_op; + /* Tells which temporary holds a given register. It does not take into account fixed registers */ TCGTemp *reg_to_temp[TCG_TARGET_NB_REGS]; diff --git a/tcg/tcg.c b/tcg/tcg.c index d6670237fb..0c0bb9d169 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1521,6 +1521,7 @@ void tcg_func_start(TCGContext *s) QTAILQ_INIT(&s->ops); QTAILQ_INIT(&s->free_ops); + s->emit_before_op = NULL; QSIMPLEQ_INIT(&s->labels); tcg_debug_assert(s->addr_type == TCG_TYPE_I32 || @@ -2332,7 +2333,11 @@ static void tcg_gen_callN(TCGHelperInfo *info, TCGTemp *ret, TCGTemp **args) op->args[pi++] = (uintptr_t)info; tcg_debug_assert(pi == total_args); - QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); + if (tcg_ctx->emit_before_op) { + QTAILQ_INSERT_BEFORE(tcg_ctx->emit_before_op, op, link); + } else { + QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); + } tcg_debug_assert(n_extend < ARRAY_SIZE(extend_free)); for (i = 0; i < n_extend; ++i) { @@ -3215,7 +3220,12 @@ static TCGOp *tcg_op_alloc(TCGOpcode opc, unsigned nargs) TCGOp *tcg_emit_op(TCGOpcode opc, unsigned nargs) { TCGOp *op = tcg_op_alloc(opc, nargs); - QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); + + if (tcg_ctx->emit_before_op) { + QTAILQ_INSERT_BEFORE(tcg_ctx->emit_before_op, op, link); + } else { + QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); + } return op; } From patchwork Tue Apr 9 19:35:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787236 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383306wrs; Tue, 9 Apr 2024 12:36:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXqfjjw4vq6HsaUwBW7dPCflk+qP2ZeGT3KOpbEdwSzcH2MTRoDaL4FlxumN+EqEynC/szPMkLBGmujzPZyz3QW X-Google-Smtp-Source: AGHT+IH3Zfq0uEhkJRrPRtOa9k8ZfK0PSwCEjfokh9akmLyi0MO9BKbzim8gJiCAolOfhUZ6Ml14 X-Received: by 2002:a5b:9c8:0:b0:dd1:6fab:81e4 with SMTP id y8-20020a5b09c8000000b00dd16fab81e4mr757224ybq.37.1712691407313; Tue, 09 Apr 2024 12:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691407; cv=none; d=google.com; s=arc-20160816; b=K++7gvwrc0JOptKiMQ1qHIHslGn88dbaDEUSakt2d+AdsfLOncwafeVhn95w88qZWi wNIZXvGPDSu4RzEjH23ag3PjgzOgz0yhykzTJ2v15Hk6BQygwk1Xjhm+y7+4C/QUZrn4 8Py6xTisT3p2PLgUs22+ZJmSYOiUBnLy1pLAgm93hF6f+l4T7GonO+HjALGjSs0Z0pWO iDdM8tjW4634RqqV5AibwbATBUqlbq/iInOc60f8k2NhKiuDJTjNX/98X8QDB7hvlCFZ mezvPUuaHp4zL2TGLnbFYLF9Jw1/Q2YSA1iopgCgOxhS3o55/LkwENGzRe0jMMP9EZ/Q cV5w== 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=7jtBLExS0tGWR2Q7Hyghjc2ZDJ4QMJ89vJLFL0IAkpg=; fh=feciRXMMXjL5Zdx/9FYuVSJ4fTkSvjANJ3wyTAeS3QU=; b=XpRGK9wlKTJIpLK1ldRt1ceBE3Kv7S1Kkbzf0pmG2ofqiS62p5NVwZ70i1TPWOrz8D t4I3kth0geNWR+HCoBHg0beEt6jRno+KMrJLKgHZfblUzKRi9pynN0WnTBEizWlp4jh9 KD7XtCcXlYaaWv6wgMSf2fY949qWU19hPmB+l7zFhDLf5BbIVOvR/5/19fNAsU1m46U5 RiDWfziTSFqiHrf1ZWjtcTkqJ5Sy4MZzqYTocFEyEqEB7c6qjPz/FEss+hBLlihtAuBp 70L+8MpTxMbsZCqAXu+D/DFv+2rPWAS3HfUMqJUFG38SlXCBID5Nf2hnDLy7MlpgNdpr qVNQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DE7+tfS1; 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 i10-20020a0cf94a000000b00696a7b66b6dsi11050325qvo.12.2024.04.09.12.36.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:36:47 -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=DE7+tfS1; 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 1ruHGe-0000br-Sx; Tue, 09 Apr 2024 15:36:28 -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 1ruHGc-0000bf-Pe for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:27 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruHGb-0004et-5d for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:26 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1e4bf0b3e06so6927745ad.1 for ; Tue, 09 Apr 2024 12:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691384; x=1713296184; 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=7jtBLExS0tGWR2Q7Hyghjc2ZDJ4QMJ89vJLFL0IAkpg=; b=DE7+tfS1CW0d35m42dYOF78cC4Rxy9Gp4aOG1pi2/GYpIdTmMLh4r56c6O/XPoL0sK B8BG4vwx/tFFQ8FW9GhJhuH80q05gny+fhAguXplem1mgpsMxChUhK54Dbuzn6cN/PWq CKrE+JJ7BkYFGEd2VMdDTD1b2IdkwWa+U8lAYJmHW19R0MpIsauhBpMvIZrpE3z5QBha GaVn/HmO5uR27s2vUmWg9DHHmMb+tsMKpO+/PhKLHydhUoDJi5pqji16XRBBKyvxZOKa Qde+6xHGDRa0w9fYiYKRTz8jRGlFmfNX/t6kpMJBhZZ4CtNaJyHGzc3UywOcQ1Ypah8W ZjiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691384; x=1713296184; 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=7jtBLExS0tGWR2Q7Hyghjc2ZDJ4QMJ89vJLFL0IAkpg=; b=IhZXXnIkjj80m8TjLFJSklvqwSiifJ+8rcEndj3Dc+5keiLdcWRYdQUX/qqJzKs4lf ty7NE2Q3ey+nXRrNtDXzMgjXhsNF2scTOSK91b5xPO29hGVyyEJpoU33Gm4gmPOkMzM7 a5M0IR49Pm2qH0STF3FpEVoS8rAdA8j4gT21qxtbVQ9TxIYeZtpv28TqIjVNm+y2a4XM s65AWXHQBEGD8jcQ3/ecllWlZHyTGwMndCpNvo1S0lN6Olpo/iY3UEGzo9VxCK3z1xFU g0OVcBuWF20hqr2jv6VIfS3+HgzJkVxIJWMvzbxnNi8PTkBN1WHDSS8h2gYOqd2zUOLm YbVg== X-Gm-Message-State: AOJu0YymX/vF1/XQUUlVGXGrgbJu+kxSaXVJ7vmzE2A+Yd0DFVGUK8jA lZDc8NSNC3p0vL4SLv4CIdHrZIf8zpwT9rSmeD3Wmu8gc07233+hOkSE0vEz5iY9vNHY1ZhSbNo F X-Received: by 2002:a17:902:cece:b0:1e2:61c9:85de with SMTP id d14-20020a170902cece00b001e261c985demr883385plg.4.1712691383985; Tue, 09 Apr 2024 12:36:23 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?J=C3=B8rgen_Hansen?= , =?utf-8?q?Philip?= =?utf-8?q?pe_Mathieu-Daud=C3=A9?= Subject: [PULL v2 12/20] accel/tcg: Add insn_start to DisasContextBase Date: Tue, 9 Apr 2024 09:35:55 -1000 Message-Id: <20240409193603.1703216-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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 currently target-specific for many; begin making it target independent. Tested-by: Jørgen Hansen Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/exec/translator.h | 3 +++ accel/tcg/translator.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/include/exec/translator.h b/include/exec/translator.h index 51624feb10..ceaeca8c91 100644 --- a/include/exec/translator.h +++ b/include/exec/translator.h @@ -74,6 +74,8 @@ typedef enum DisasJumpType { * @singlestep_enabled: "Hardware" single stepping enabled. * @saved_can_do_io: Known value of cpu->neg.can_do_io, or -1 for unknown. * @plugin_enabled: TCG plugin enabled in this TB. + * @insn_start: The last op emitted by the insn_start hook, + * which is expected to be INDEX_op_insn_start. * * Architecture-agnostic disassembly context. */ @@ -87,6 +89,7 @@ typedef struct DisasContextBase { bool singlestep_enabled; int8_t saved_can_do_io; bool plugin_enabled; + struct TCGOp *insn_start; void *host_addr[2]; } DisasContextBase; diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index 38c34009a5..ae61c154c2 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -140,6 +140,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns, db->max_insns = *max_insns; db->singlestep_enabled = cflags & CF_SINGLE_STEP; db->saved_can_do_io = -1; + db->insn_start = NULL; db->host_addr[0] = host_pc; db->host_addr[1] = NULL; @@ -157,6 +158,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns, while (true) { *max_insns = ++db->num_insns; ops->insn_start(db, cpu); + db->insn_start = tcg_last_op(); tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */ if (plugin_enabled) { From patchwork Tue Apr 9 19:35:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787245 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383864wrs; Tue, 9 Apr 2024 12:38:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUkYtF6f3UzTZSmAnhwJp13WN7kVLMZvjld2eLEbxbf4S9oTa4DkA04YobMJ90Ljx7z0Nn46eX0CBi3IfJ4KnZO X-Google-Smtp-Source: AGHT+IHoM5VRYISgxAgK/QAsaLNN+LFBTexeclDoIYfHR71JuHJl7foqajFFWbjPxOUoMU3V0VFI X-Received: by 2002:a05:6214:e4f:b0:69b:1f8d:3013 with SMTP id o15-20020a0562140e4f00b0069b1f8d3013mr424976qvc.59.1712691513833; Tue, 09 Apr 2024 12:38:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691513; cv=none; d=google.com; s=arc-20160816; b=cbtSJg9TCK/eEZNuRh8yx10/XLGJxbmZPngX/Hjb1rFaiVXr2c2phUeemmMtDRtSWj EoA7VrrKyR2+OhB/WbW71wYYpFgGLudrRl7QjeNzgiaTCgfrz61a/BH+Df3t2WND512O UWpOAzjjfpWKdsv60SO8xk5kS5mTaxCzBbplcejJPCOVWIDm1tkHBT2js27HcsMMFmgw rZ49/tCx1p3cKwkSlu7THPdOzkgOn2BBBl6pkYN+s5G/c6FKlvLB3goZd6TScy18ylcD NNbvvqJaMCeZufIyZ37ugLIAFnLXv5HmDLSD1HPALF52hg5Eld3IRcZ+6H12QcZh+eSo 5O8Q== 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=qu730y1a5bhHx8+lUgk6PRHwUAMG8x1kinVBmiKeHm0=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=smuAIwpdtxogDEB3t/mF37j/tbLo7eYLiiS8hix6jGy21sjn+4a5/ZPibOgOG27kO8 87O6jIMnzjBLB/fhUlja7aLdQcelx7UPcd7Cnw79keMwoSAnqiJYc1Bl0aTcKP4rJu3N EXbBmbNBRIMV0moi9v7Njna2qHx1kLKMphBT2AMXS6hUYwnycOtrQ2X+eG09s9m9NTXc 1+/z77++fnGl/iMqRds6zeM0XiD6nGJHyUT3R5/5AF9MSosnMWInhVm+gw5gh21ZcymY HZNTw8lISL/hKR1CxCgBhk+ERZ3PhL0VXceP068+ZwtKYSmzgJlLkSyVru26RK9WaoZW w81A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nxaagpPB; 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 u16-20020a0cf890000000b0069b205e9420si3989928qvn.350.2024.04.09.12.38.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:38:33 -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=nxaagpPB; 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 1ruHGh-0000dW-ML; Tue, 09 Apr 2024 15:36:31 -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 1ruHGg-0000d0-O9 for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:30 -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 1ruHGe-0004fA-Jl for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:30 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1e3dda73192so21587385ad.3 for ; Tue, 09 Apr 2024 12:36:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691385; x=1713296185; 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=qu730y1a5bhHx8+lUgk6PRHwUAMG8x1kinVBmiKeHm0=; b=nxaagpPBYzpTx3yZRMSBsGGRkBaJHvUGLmVx7to+4cHY8oitsJ6bFJSNmqWji7fWEo nadJ80bqriMTJlTl+099JOHnp+4h6ERFWW4qCsnVArI/IRvnpt6isTuqoxzsr3FEDkI4 F4Vlu7LjWE6M3UuRMIvqNqHN852hHHL6q3VHkO45+0SxILAkJxtGZi9WTFoL4+OfYd0d Vn2C7JB/wzeFMte3Gb0nB+k+cjE6nbnjgoDf9KoHpCV2JYxMm5oJukGOjrmT3I5wi8u5 Eokh/HJ82oPzMuKjOEP5ASJ1Ju/sBm8/obz/TJKpq7P3kk0QVufmblC64FFudGsR8rKn mr/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691385; x=1713296185; 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=qu730y1a5bhHx8+lUgk6PRHwUAMG8x1kinVBmiKeHm0=; b=KkExLiWQW5QcbHD9sxo7Om4cISxRRE81/6RXO/aTqflJqyrhjzr4dKfW8YHNeiXZBP RuzrIQjenjbBdrotBGUlAPd3+X3u0SrMsGor8IV9puE4nFNVAs6OtiJdaJ0IMF1dhGY4 YpzyMEvYnCzC9pbdowZiEItwaIxIdD5g6Bh1v6TJyDi0JwVBOJNfbFIMkx8cevG5z190 uxbPaoa2XttHsXKRxA83HKHYMKnZ4FLr1NFsY4n7CVtLe26s+V2x+O2/2Qe7QaLV2HHP c9/jPW9J1jyAiMyHRUfjgeuF79AI0UIaWbDm7YGNrp3QZ/EKLO8FS9vgkuhAC2Tkl/zj secQ== X-Gm-Message-State: AOJu0Yx3aAUy9JiAfjuaueMQiFlnZJzsSBH4ltf2Wo+wgOjT0KA70NGP vN0mhm08vW8jHBQnny+q0GM0IedhmbPH46lLryW7mJbcSvRoY4fDZO1D/wLKfGn3VgWCDvUJid2 k X-Received: by 2002:a17:902:7ec1:b0:1e2:7d3b:353c with SMTP id p1-20020a1709027ec100b001e27d3b353cmr615668plb.18.1712691385219; Tue, 09 Apr 2024 12:36:25 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL v2 13/20] target/arm: Use insn_start from DisasContextBase Date: Tue, 9 Apr 2024 09:35:56 -1000 Message-Id: <20240409193603.1703216-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-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 To keep the multiple update check, replace insn_start with insn_start_updated. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/arm/tcg/translate.h | 12 ++++++------ target/arm/tcg/translate-a64.c | 2 +- target/arm/tcg/translate.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h index 93be745cf3..dc66ff2190 100644 --- a/target/arm/tcg/translate.h +++ b/target/arm/tcg/translate.h @@ -165,10 +165,10 @@ typedef struct DisasContext { uint8_t gm_blocksize; /* True if this page is guarded. */ bool guarded_page; + /* True if the current insn_start has been updated. */ + bool insn_start_updated; /* Bottom two bits of XScale c15_cpar coprocessor access control reg */ int c15_cpar; - /* TCG op of the current insn_start. */ - TCGOp *insn_start; /* Offset from VNCR_EL2 when FEAT_NV2 redirects this reg to memory */ uint32_t nv2_redirect_offset; } DisasContext; @@ -276,10 +276,10 @@ static inline void disas_set_insn_syndrome(DisasContext *s, uint32_t syn) syn &= ARM_INSN_START_WORD2_MASK; syn >>= ARM_INSN_START_WORD2_SHIFT; - /* We check and clear insn_start_idx to catch multiple updates. */ - assert(s->insn_start != NULL); - tcg_set_insn_start_param(s->insn_start, 2, syn); - s->insn_start = NULL; + /* Check for multiple updates. */ + assert(!s->insn_start_updated); + s->insn_start_updated = true; + tcg_set_insn_start_param(s->base.insn_start, 2, syn); } static inline int curr_insn_len(DisasContext *s) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 340265beb0..2666d52711 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -14179,7 +14179,7 @@ static void aarch64_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) pc_arg &= ~TARGET_PAGE_MASK; } tcg_gen_insn_start(pc_arg, 0, 0); - dc->insn_start = tcg_last_op(); + dc->insn_start_updated = false; } static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c index 69585e6003..dc49a8d806 100644 --- a/target/arm/tcg/translate.c +++ b/target/arm/tcg/translate.c @@ -9273,7 +9273,7 @@ static void arm_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) condexec_bits = (dc->condexec_cond << 4) | (dc->condexec_mask >> 1); } tcg_gen_insn_start(pc_arg, condexec_bits, 0); - dc->insn_start = tcg_last_op(); + dc->insn_start_updated = false; } static bool arm_check_kernelpage(DisasContext *dc) From patchwork Tue Apr 9 19:35:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787242 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383829wrs; Tue, 9 Apr 2024 12:38:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWF1B1T6VPs65jfSLPsDnPiphxWtswxj0XLy9trhjZvTsRt+gqUvIbbtC/IaOFaxwBuk9h0sDz5L9cvV94vzLZI X-Google-Smtp-Source: AGHT+IH2z6pCwx+L4wMsa7CzmJcWQI46Q52X0iOCIap/EukGAXzK3syCJoSJfNArr+Wu2tryXfzF X-Received: by 2002:a05:620a:994:b0:78d:70f7:be79 with SMTP id x20-20020a05620a099400b0078d70f7be79mr715156qkx.45.1712691509692; Tue, 09 Apr 2024 12:38:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691509; cv=none; d=google.com; s=arc-20160816; b=fk+9sjdrGiKYGxVZYSrIkxJ6DSuHn2+ctC0djpRTHwE0nw2C+H0DsGC0CqOqc/SLxW hugtsg91aUUO943akxFhp2mJn5NmMa12FE9YidYlWitvJ0eCgSa2jlOU2nUXeMahNopG LqoQ8X4pBcbRx3t47Xet/ZcQg4X7iMcT6zuJzH3LiURFIvgRYTZNjXJJnFUJtcM5mCOS IRlbNpoqgBbs+1njkTlUZfTV93tzFfgVqlfQtJAvRNKmb59/7VZr8VK1VRPGVrBoOV2m iyKXl58Q4a0tmHmXVtVv6fqjoYg1FNIf4pNvgjbweoGYCUuQ+yZJNqJY5GIFd4/2EaA9 Aztg== 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=RFanGzrvK8VkKk4csReRv0GVjABsPRaur2/zSeJo0ZU=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=OOtCzwrn1hLaDv5MwCp3N4lQLGuYK8VEHz4A6RKgKycWJHf+0ogJvk1nLnlhCxHkpG Oal4Oi4jz7hYOJU7ETZso9yLNM2lREG68zZq1wfuuSX0vkDubokltkl79flXc5XBw6Cm z040pT1DN4dUYbi8dGKgJyKu2ZNsiKVguyf9SwHLUxadfjof/MnWQSMaeSwVqDjYAodz L2ZhypoD9xSfbOtOakCNvMoyn+3irhPq1w+Xj9gaVn+3H+x3TAeEuYVWYW+HHKe2aoHI U1D3i7Ck3IUWIOo2mxFO4cSRfTsrjw7HOlYcIAkYPZjglYVKO5qF4DSLPBfdDs6I7xKz l3Xw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aZM1ux2U; 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 pi40-20020a05620a37a800b0078d4bca2743si9577220qkn.319.2024.04.09.12.38.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:38:29 -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=aZM1ux2U; 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 1ruHGg-0000cc-K1; Tue, 09 Apr 2024 15:36:30 -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 1ruHGf-0000c7-GE for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:29 -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 1ruHGd-0004fM-W4 for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:29 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1e244c7cbf8so50588075ad.0 for ; Tue, 09 Apr 2024 12:36:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691387; x=1713296187; 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=RFanGzrvK8VkKk4csReRv0GVjABsPRaur2/zSeJo0ZU=; b=aZM1ux2UJCV1OgPgSgP9Fy6HBJQbKnCxBVXqiuXG6s4ChKTxmqisZIkltudV5ApwZQ rVfKw9NBqiUT8ilZ6dFDSdEKk9ZtlGUHY8dSEnXpaIAF4lc1uXMZqbJO6B57PuGtVnYD TpQVYiWa0eO4vj0TnfYWseSQ5X/Sp4SOOJFm9+CAci1UyL4EvonhI0xCGFpYS6ccBnjp n/WI1j0I4/58AA4WZ9Us0SjvA6jN6FjqhkVYw7anoH/yXypITqXotKfU/CZzYDX1P8HB oAIq4vY1odvmu0RaqlO4RSRimkPMXFDIYmpTgdE+OR4Kn1aBORAY9Uoq0s+4xNX8E69Z H6fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691387; x=1713296187; 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=RFanGzrvK8VkKk4csReRv0GVjABsPRaur2/zSeJo0ZU=; b=rxZoLQsHfy7zwbSreO67daRWvQcP2FvBlyMHAwNMLXnqfze3MZw2QAPr8yCvcrhumV 0RIiHCIai2H7cBv/TLPhaHnd8zIy/R7doQo7jzZhzXbmatgZm82T38xXLPsi3bIycIJ5 GBML2o5O9TMpspTPCNQuFES8BbU8Bax2q6XRQpQQiKVVjDjXMHNNBAD+F9eECUG6EExz mhcvH+DsLwCpBNxrDBkIA/aKvv5jLEL7TTjluNUwrOFrBeIlY/nb/O0wOzZ6u2hmEdyg DyVNm285dCpSajr2EGic1W7fo35wfEYe1oL4zGLgWWUhfetPYMh4XZGQlQ99Yiq9d15J bHVg== X-Gm-Message-State: AOJu0YxIS+Asw7RovcWGRwDubRMcQOA/gmS+HKJrj3vRtCDzhJwWq/aG Q2Q7dwObqmq+DQDMVH/iPZenQ0HajBQ3hszQJ8OQfhQsRoBC14eDInOegToR/kNn/Vfwk/hdooR 2 X-Received: by 2002:a17:902:f392:b0:1e2:23b9:eb24 with SMTP id f18-20020a170902f39200b001e223b9eb24mr705753ple.33.1712691386735; Tue, 09 Apr 2024 12:36:26 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL v2 14/20] target/hppa: Use insn_start from DisasContextBase Date: Tue, 9 Apr 2024 09:35:57 -1000 Message-Id: <20240409193603.1703216-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-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 To keep the multiple update check, replace insn_start with insn_start_updated. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/hppa/translate.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 8a1a8bc3aa..42fa480950 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -44,7 +44,6 @@ typedef struct DisasCond { typedef struct DisasContext { DisasContextBase base; CPUState *cs; - TCGOp *insn_start; uint64_t iaoq_f; uint64_t iaoq_b; @@ -62,6 +61,7 @@ typedef struct DisasContext { int privilege; bool psw_n_nonzero; bool is_pa20; + bool insn_start_updated; #ifdef CONFIG_USER_ONLY MemOp unalign; @@ -300,9 +300,9 @@ void hppa_translate_init(void) static void set_insn_breg(DisasContext *ctx, int breg) { - assert(ctx->insn_start != NULL); - tcg_set_insn_start_param(ctx->insn_start, 2, breg); - ctx->insn_start = NULL; + assert(!ctx->insn_start_updated); + ctx->insn_start_updated = true; + tcg_set_insn_start_param(ctx->base.insn_start, 2, breg); } static DisasCond cond_make_f(void) @@ -4694,7 +4694,7 @@ static void hppa_tr_insn_start(DisasContextBase *dcbase, CPUState *cs) DisasContext *ctx = container_of(dcbase, DisasContext, base); tcg_gen_insn_start(ctx->iaoq_f, ctx->iaoq_b, 0); - ctx->insn_start = tcg_last_op(); + ctx->insn_start_updated = false; } static void hppa_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) From patchwork Tue Apr 9 19:35:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787250 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp384265wrs; Tue, 9 Apr 2024 12:39:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVxyrPv2x2Bbzc8TWnY108GvWaHqToqxSECUQcYPj1xgYuwHbK9bA1CofQ+3PllVy2kb4UgrZ5UYbZ61YSeZclS X-Google-Smtp-Source: AGHT+IFZ4NZpQBocX5Ivv3xU+bcCBvIJ9agmmEfe/ePnIJmdN+XSo7e/SUoVnLManUvz7nHq64Bk X-Received: by 2002:a81:6e8b:0:b0:618:b08:2ab6 with SMTP id j133-20020a816e8b000000b006180b082ab6mr736890ywc.47.1712691587408; Tue, 09 Apr 2024 12:39:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691587; cv=none; d=google.com; s=arc-20160816; b=MPl57r7PNo8Yyx/X+z6uK+BHxWgS+iyL6R4nZgjhkO6aUFzf1QNG9HTez1/rXQYyrs LXmgrWxJQ0rXDC2LlQGhezic9l9KHxxFdNO/hiEng7NX2crNyXQP1jke+5Em5SiIGOMt JdP+WDwH2dH9gKggV1mNF36yej+CDfx2/tsGm9ZnpzbiwqunsLxz2F1sr1jSA9v6YTzk Gh6eC0pNDXltvanqRLLSQlyx+2/kp3dbbjhZijXwZrW2E4pLb59R32fZUM+1x8YAAXzB hfVoJFHmoZYz2IF8U7dnRObEQL8zGqr4bpYbivkpwJvO6+iP94U37sZ6Q81lYqWMNhSd hqyQ== 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=qqej1cqMOghQjm8tlS0ZXIP7cn0Zxc/ocvLIj3d7Cp0=; fh=69wYhyM+2lwzu21CVQStuhnFbyS0KWUUX3s78fgxEOA=; b=zKOx99WooJCXcSDLGOEQ1CEp4TjNo/RS+E0KZB7lcx8kRUKGYE0q0WibAROX6vmgEY PEEUOcNjRIfjuEGJYe2FZzt4xSjLCwCRoK45PXZQ+xfjWUIsO/L6lW8FTWdnybd+9v1j RU8DXvV+/EiqU8L5Mz1gTWraEvdREm9+oSU9nF6yM1nT5AflH40Q+e99U5EICFv8KI9B I+qREX0rnNXa9SKmx+m5MHhJbPq+EkAdYQwz168DgzNN9BdDk9I0F8cVO5nHOZKcOZgV F1awrgg4hT1OIUAsvszvvVMT0dkprgWd403OEDltoc36vGtTy5xZTn+GBpk8y23Bu9IP mOVA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C2LY+22D; 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 m13-20020a05622a118d00b004343f236d85si2729212qtk.702.2024.04.09.12.39.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:39:47 -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=C2LY+22D; 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 1ruHGj-0000e9-CU; Tue, 09 Apr 2024 15:36: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 1ruHGh-0000dB-3h for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:31 -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 1ruHGf-0004fU-IW for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:30 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1e3ca4fe4cfso24518625ad.2 for ; Tue, 09 Apr 2024 12:36:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691388; x=1713296188; 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=qqej1cqMOghQjm8tlS0ZXIP7cn0Zxc/ocvLIj3d7Cp0=; b=C2LY+22DL8Nx/SZfG6LqgC+WG8D1Icnl6pSLExAjj8WVy9uQkliL3iduFENtY09lIB 8ORDRXsdLLlZ1JaGcnuof0DP3vS/oRDIP56j4anQs2EpfwtQrY8ICANiz7KrgbD+k2f/ oqtz9TYDEm4y8Mne0YYlgo6QsgXt/wkI2vhQmiblCusAZdiePRMaCf7yBaMDHliD4sDj vOsUCp/knPNSUqy50hAai5/uQYdKcqFqnyQIptNJAtpLn1cxgc1gWCSpvf74VNkrFsIW lD4J+r7UnDEtKJy3kKVb4V8s/XlxoR13qQryN/OEe8jBQElbcrMeCYfSCAgvgBwsCvFP tFNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691388; x=1713296188; 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=qqej1cqMOghQjm8tlS0ZXIP7cn0Zxc/ocvLIj3d7Cp0=; b=Wcm2a3luocN0FJDwtLbfd+IDeU9sfD2hv98Y8/alZm0zf3T5CBY4LimG7gzIsgsF8d hWHNwCFPG66PjyLFuVFolmyzV9MSH+CUt8kveVLakmzpbc3dciGi9XKBoXlc0gSDNVet XblQUvinuEhWguTKbZbQjCAnsSBWd+0xul10uvtlvLg/OtlHZAJogjXllR7LnGrT7tYs tpHDEPlExNrmENqz3FNqYReZirr4vdpUmROdDWuqRGjy/w6itpRKefq3vUnXm5Qc40Uz YNZUpqytE9Wp4g0KCcmVMnQaoSyAFXaL6vE2pHpfSpfLx5805sF0Fihp1MGyuK4uBrFO YfJQ== X-Gm-Message-State: AOJu0YwrsLRQRYmrHZKOjyGBv2UmLZGyKRKm6yJSwK/frnW5UlzyN+Ps 7TaDhSW+lh2iWvS1g7J5AJEQ8Iyf3clZMq2N6fjYMUKmGH9nOIx8IYUaIc+5pzpZgnCaKGOMZaD O X-Received: by 2002:a17:903:22d0:b0:1e2:aa62:2fbf with SMTP id y16-20020a17090322d000b001e2aa622fbfmr747566plg.45.1712691388290; Tue, 09 Apr 2024 12:36:28 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?J=C3=B8rgen_Hansen?= , =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PULL v2 15/20] target/i386: Preserve DisasContextBase.insn_start across rewind Date: Tue, 9 Apr 2024 09:35:58 -1000 Message-Id: <20240409193603.1703216-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-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 When aborting translation of the current insn, restore the previous value of insn_start. Acked-by: Paolo Bonzini Tested-by: Jørgen Hansen Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/i386/tcg/translate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 07f642dc9e..76a42c679c 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -139,6 +139,7 @@ typedef struct DisasContext { TCGv_i64 tmp1_i64; sigjmp_buf jmpbuf; + TCGOp *prev_insn_start; TCGOp *prev_insn_end; } DisasContext; @@ -3123,6 +3124,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) /* END TODO */ s->base.num_insns--; tcg_remove_ops_after(s->prev_insn_end); + s->base.insn_start = s->prev_insn_start; s->base.is_jmp = DISAS_TOO_MANY; return false; default: @@ -6995,6 +6997,7 @@ static void i386_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) DisasContext *dc = container_of(dcbase, DisasContext, base); target_ulong pc_arg = dc->base.pc_next; + dc->prev_insn_start = dc->base.insn_start; dc->prev_insn_end = tcg_last_op(); if (tb_cflags(dcbase->tb) & CF_PCREL) { pc_arg &= ~TARGET_PAGE_MASK; From patchwork Tue Apr 9 19:35:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787241 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383825wrs; Tue, 9 Apr 2024 12:38:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWlvrA0mJOhuBqijolA3BkLVrbp+gZ0OSFkknwhV9gAvdKW2vpJsFmqEVreK5SxrxZ+aZzdYMQq4BaQ9VQs606+ X-Google-Smtp-Source: AGHT+IGH5b/ymybyCI7tY+A3Oo/5oLns0rY3towGRhjMk7T+jMds5apeMP3oTEV5zu0ms5nWL4Q0 X-Received: by 2002:ad4:596f:0:b0:699:247e:a69a with SMTP id eq15-20020ad4596f000000b00699247ea69amr598104qvb.9.1712691509190; Tue, 09 Apr 2024 12:38:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691509; cv=none; d=google.com; s=arc-20160816; b=CFbP8SuVzPIFSU+ZG4zlswgKQmHrW4SG6rDWaSqqKTtNC7cBUmamf+Jd+iATmmURZA ZipeGDPAsLbIhFnsh7ecly8OT9Ja4fy/nHny96jYF5lSQPTRnCEQrdacqIhUj55J5NQs bRwy/9vBKdvL3VOnCTbxiG6Nh2iJ/EBXlBOsyJJcLablAZM0V5o41dm/dFIWpqJbfNnA Z7+HssNAjHmzESAGkeWkZXAkU/M+24NR8lpHUn3XzhY5mTN/xqBH70xEmwJajOKApFfE sDrhgzii073Lq3xPDPnQUFKBU6YWARtJ+JhrHAlwBlSSnottwwkTwHk7HFJQjdyFlmzS cRGg== 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=cP8jA9GFq1yR+e10bjvG/FkvD/Ggh4PQtWX+MXPzUjs=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=GS56OoUfub0UDJywD5lZCnGj8npPgZPmDZ8fvQzquz4HkWM4YgkKjJOxApWSg77JX7 +F5IKB9pKFXwLL/khPAwDe3klsuJvLnL0TsNMQaK4Ip6o3IC+z3ivItZnTiigRjxKTWQ oiKYomM4N3UOh531tltcxlitYLWj824B0VbBkQ1f3Xn8cZLOBphmm77Ofvzi/lt3Id0X BvZi14JUnkxV/xdbm9dgDd5dvKy3g4yEvaVuIVspy7mTq+ckS6Jgmj378anP7FCN6iKd fjHzNqb3UE6Ga7jO/Qdh6o4e7I/boGCXuIfqhUhEAID8yN+TJcG6xAVTUV7kUCrAljiR 8C/w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VYwTp0IK; 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 v17-20020ad45291000000b0069927e1eecasi11267186qvr.193.2024.04.09.12.38.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:38:29 -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=VYwTp0IK; 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 1ruHGk-0000ef-EV; Tue, 09 Apr 2024 15:36:34 -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 1ruHGi-0000dr-B2 for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:32 -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 1ruHGg-0004fg-Mi for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:32 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1e2bbc2048eso49678125ad.3 for ; Tue, 09 Apr 2024 12:36:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691389; x=1713296189; 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=cP8jA9GFq1yR+e10bjvG/FkvD/Ggh4PQtWX+MXPzUjs=; b=VYwTp0IKCKzfZuD34eB9t0TO0IwCX/KgzvXf3jsqFCgxQJYuLPRsp/dOWKl6j7zWQ+ ll5RE5ucA0Wcppt+x+gRoKO63O0yblAcPb32FWsIyfSAV2MV1alk2aY1teW+wMugbZnk H7L1/r69JwTDhULlc4mft0m7NE3j4E5LpQyZxBcXv3fpLj2BGZHvi9nlbZvp6DHMkuLE dDmL9RtJJKbTqIlEbUO931CaT5mqm3j5lThAl0KAc0fMBnXQWZkUPFyeHyTw5xaQW40B WdAEfWXxi3R25XTOORLzTZ6tBpA9F74MNihJ33hEm2iA/Id/bvBT7Oo+PgrlNJCgDW0m sFDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691389; x=1713296189; 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=cP8jA9GFq1yR+e10bjvG/FkvD/Ggh4PQtWX+MXPzUjs=; b=stJEXMPpy0oQ7A7PLXTxOLjTfn7XSygzVOEWkcbHqD3F/jzn6HciiLjc764Jg48Ixv t0yIqxoo8dS37PAb31vUJtQrsTnSIbooDWoHkCdtm50n+4yswuBs3CWDnjd1aR69JRb9 a+qJ2T5dBqSLE+gWYk5EQ6JbjlLs94eT8rAkJv011tHgem+QZ9fMbkW/Ax5feRfnAq/5 lmt2xXxXgHgIohzuSKL7CeaQFoly5YgYTqhz9jB2Y64cs5vvrOvrHD1z5h4mTgNvkaVq RIScY4ZEZ11mj7u9FrPd9O7rCLPG9KoxPOxBxwjLDOZzUHTS+H/0syl6hTY/Gq2HfBsI XOUw== X-Gm-Message-State: AOJu0YzwHXmpPBd1rXt9etleBe/sTj7xaFANuEzxFqEeVSlwrYBK4Mxn ObgsDuHk6Qb+qI/XhIAQSHeUQIeN7/Z2I0dyZcmQXSwGjJoKnVyWeHHgI0MYLb/ykjlTbdf32ND p X-Received: by 2002:a17:902:a384:b0:1e3:e1e8:bb5 with SMTP id x4-20020a170902a38400b001e3e1e80bb5mr720667pla.28.1712691389488; Tue, 09 Apr 2024 12:36:29 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL v2 16/20] target/microblaze: Use insn_start from DisasContextBase Date: Tue, 9 Apr 2024 09:35:59 -1000 Message-Id: <20240409193603.1703216-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/microblaze/translate.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 4e52ef32db..fc451befae 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -62,9 +62,6 @@ typedef struct DisasContext { DisasContextBase base; const MicroBlazeCPUConfig *cfg; - /* TCG op of the current insn_start. */ - TCGOp *insn_start; - TCGv_i32 r0; bool r0_set; @@ -699,14 +696,14 @@ static TCGv compute_ldst_addr_ea(DisasContext *dc, int ra, int rb) static void record_unaligned_ess(DisasContext *dc, int rd, MemOp size, bool store) { - uint32_t iflags = tcg_get_insn_start_param(dc->insn_start, 1); + uint32_t iflags = tcg_get_insn_start_param(dc->base.insn_start, 1); iflags |= ESR_ESS_FLAG; iflags |= rd << 5; iflags |= store * ESR_S; iflags |= (size == MO_32) * ESR_W; - tcg_set_insn_start_param(dc->insn_start, 1, iflags); + tcg_set_insn_start_param(dc->base.insn_start, 1, iflags); } #endif @@ -1624,7 +1621,6 @@ static void mb_tr_insn_start(DisasContextBase *dcb, CPUState *cs) DisasContext *dc = container_of(dcb, DisasContext, base); tcg_gen_insn_start(dc->base.pc_next, dc->tb_flags & ~MSR_TB_MASK); - dc->insn_start = tcg_last_op(); } static void mb_tr_translate_insn(DisasContextBase *dcb, CPUState *cs) From patchwork Tue Apr 9 19:36:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787248 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383959wrs; Tue, 9 Apr 2024 12:38:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVeNpFExgWUn6b/2SYiWNmaXYlCBexSIEgEmy1lqexS19B8O0W2y+NmyHDdgvF72T4ImAi3KXtxoWnIABiK0POr X-Google-Smtp-Source: AGHT+IFSRwnFQfxFRhKQL0JejD9OS//Qw0R2NZ9VNefy2vxRBBUyfwhkYypIdQj/1GINFTgR8xVQ X-Received: by 2002:a05:620a:2a0a:b0:78d:6191:caae with SMTP id o10-20020a05620a2a0a00b0078d6191caaemr676276qkp.53.1712691533901; Tue, 09 Apr 2024 12:38:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691533; cv=none; d=google.com; s=arc-20160816; b=FFUpLRenft7YPAyfOCevBdCoUMs1QFKDwtPkqBiKowCIQ4QIRKrDwJ3q+KBB/HWZIq V2uT9Bq5MfnbQUcptTX8rJLmrhDlzH5CDyCpm7uY845XwwsY28NGrnhjcuxm4ewiyBva tjZJhH4dIcnH1DC9Q62qrz3amfUs2/T0PsiOJlb0VWBUXfLHR+CFWsQJ9tcbTiloeT+K nUMz0QsLz9bSuKFO9deqRqC5li/TN4B8iw1xtk4ec+F0yPVclSZ6aZ28ujgkblqNoLg1 R4DAV9SXKG7kM9IVL01RqL1xkUd0wZvYQK82f4LWyUbR/z5/fxgPulFmRig/9zkBd12z Mjxg== 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=ZPbK/NhQe1+jKC23+AkIKSjI/CWiYdFRaJAq7oh1b28=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=FJaph+Ak79WyTkzORmguPQODbjMtGbyqC40gBPTSfoE9BgrNEUN0nzIjRNp6P9np4s 9KttnmqvbyuDD9zM8Keu4CyK4f+K7pLxkx0mhI3N2yhWu1SdvNzh6VW3HaDzMrmmACIW RpEDqGKO/R3HiAorfVdxrwJdx3Rp5/aVXZK+6uLtvEHXInE0rdud1BURQKqfBFrm00g5 RYgiZBHzkBBSixvYnMwlptQHaPOzOSBysbbCuEB+QKYGNsW/KT4Nn7YncmVqzD/ErxRd RPhi2gcwb9F5QVjBMuNG17H2ASvC/snilAtufGqpeFyQHQQh+QXTG4CRimJmqWx39Tl5 WChQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="eQig0s/C"; 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 bs32-20020a05620a472000b0078d5f259b19si8000031qkb.662.2024.04.09.12.38.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:38:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="eQig0s/C"; 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 1ruHGl-0000f8-Lr; Tue, 09 Apr 2024 15:36: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 1ruHGj-0000eW-Nx for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:33 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruHGi-0004fx-8Z for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:33 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1e0bfc42783so51977105ad.0 for ; Tue, 09 Apr 2024 12:36:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691391; x=1713296191; 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=ZPbK/NhQe1+jKC23+AkIKSjI/CWiYdFRaJAq7oh1b28=; b=eQig0s/CPdmF+V+aC0/7ks4SFPAW4XFCi805/nVCH9GAZBb59ySEplKPKObIotCc7d VEy2DNzyOZ08E0L1YejANirDtzM4LXzESRcpjtruG+pLeU4Cj1HAhRv7wn9UvUicvTG7 agKLa2iBkwYGl0FVwTKPGD0ircy5PewGmQZhLALXAkLkgd1xxQ2SwNsXGEn5axJyJoxO fnXWlZugjBZaLPy6hYrtLvLyosItoPd0E1Ogp1TZt2vuIaymp70HTjenpSIW+7qstS7B oPurHvKykLbu7ezDxg4DotDmMuLwpb3OFgs4VTq22wUkAMHVd9yPSlhFi0XDFPwUJdLf 7bew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691391; x=1713296191; 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=ZPbK/NhQe1+jKC23+AkIKSjI/CWiYdFRaJAq7oh1b28=; b=Zz5WzBWFJm7NGFOKewk5adTIxW1x+Z8KlfVwd6nIpual3/2WWxL1sUKEuDxeMknqm2 lAbxV13a5xnWAn1arKFpjzMuMJGB55ZsWibGmyc3umgJUepzuRtPu2pOcZOhpA+F99wn hDx/ogxfzDdT5mEBQB0ZfQAjgy2DOBrULnqg7Rbs5v9UvAX9KzVf2eKLw+PHMx87+bwl O9Se01yViLSdHfWIXCMhM7L8T9okzcnmPdF/tlL71MuM9TkQDiLZaCypZnqyIiwsjn1B d6yO/5WgMYbAG79Rgl2+xgUiXEMC4yfYqYvrJVckTm5F77A/m/aSizPPHeFsN2HsOzRh pTgg== X-Gm-Message-State: AOJu0YwYrOGZzpZVpWTdukbpLa6+vXKuna0aKHRAqC8mz11b+ppNBCo5 S6omokRAKsbqdxzUXb+I+D3fXZ9beSSY6wdr4r8SqZXPaP2exk5DHrucEYIcoDl0yX+UrNlcwLc X X-Received: by 2002:a17:902:eb8f:b0:1e2:b8fc:745e with SMTP id q15-20020a170902eb8f00b001e2b8fc745emr942414plg.8.1712691390747; Tue, 09 Apr 2024 12:36:30 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL v2 17/20] target/riscv: Use insn_start from DisasContextBase Date: Tue, 9 Apr 2024 09:36:00 -1000 Message-Id: <20240409193603.1703216-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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 To keep the multiple update check, replace insn_start with insn_start_updated. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/riscv/translate.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 9d57089fcc..9ff09ebdb6 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -115,8 +115,7 @@ typedef struct DisasContext { bool itrigger; /* FRM is known to contain a valid value. */ bool frm_valid; - /* TCG of the current insn_start */ - TCGOp *insn_start; + bool insn_start_updated; } DisasContext; static inline bool has_ext(DisasContext *ctx, uint32_t ext) @@ -207,9 +206,9 @@ static void gen_check_nanbox_s(TCGv_i64 out, TCGv_i64 in) static void decode_save_opc(DisasContext *ctx) { - assert(ctx->insn_start != NULL); - tcg_set_insn_start_param(ctx->insn_start, 1, ctx->opcode); - ctx->insn_start = NULL; + assert(!ctx->insn_start_updated); + ctx->insn_start_updated = true; + tcg_set_insn_start_param(ctx->base.insn_start, 1, ctx->opcode); } static void gen_pc_plus_diff(TCGv target, DisasContext *ctx, @@ -1224,7 +1223,7 @@ static void riscv_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) } tcg_gen_insn_start(pc_next, 0); - ctx->insn_start = tcg_last_op(); + ctx->insn_start_updated = false; } static void riscv_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) From patchwork Tue Apr 9 19:36:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787239 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383744wrs; Tue, 9 Apr 2024 12:38:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVczw3nVn6Hrg1yY124/AC98w/DFAmsUNn2bm+owUYgacykuNk6pthEPLF4HIwLZGzl5KN+ifTtESqvpz4pei9j X-Google-Smtp-Source: AGHT+IE9tr4ZbkEBwWh8zqZGZugCLG0ybo5iTUTRtzi1EBp5Cyql6GX1CbqDv/xbuUgMrVXWJh2Y X-Received: by 2002:a05:622a:118c:b0:434:d1a9:9793 with SMTP id m12-20020a05622a118c00b00434d1a99793mr625113qtk.40.1712691492315; Tue, 09 Apr 2024 12:38:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691492; cv=none; d=google.com; s=arc-20160816; b=tYFoSFsEGsgzX8EC2PNp48MEK9VPrecjark4N7wgZ33ocJhkEJm5sUjDtIsmMlNZfX ZPalRdmDNtLQkatUQOwC7t1i8yIlI25NYHFudyaA9I2hCvZBBd/85ibR1l34QA2vXnqj HL/FzHCMA4nUL6Po6a03REpVYzKD30A4QZPX5XqBUxAHLeE2gja4zThswQT/tqnZww2U 4UkxDOHU9uU0l31JXq453i/+baSUl6bMxF9lx3UtddQ3AlZdG0voFXwREBCpZlA4locu fgEBfhEe/KhkqWgd++eUuRiu8lmeZiog0pgtDRhx1p1koQOiaaPxwOyQW35LogGry+ny fS2A== 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=pLzmDWgl8qUDWCq3D57/PwLyiFcPLxohH0NJBMBSEDg=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=S93S6qjVcnP2mY8EZID8G6rD9ZJdfXbNms3vkByQMTVv33jOHePm/2VASdslwhmZVZ 51h19SELHp/m2hW2Wf9s/7/3lBaLz+VgYemTDDpBlpUDbIRsCtfk0ClYfL9lzRhxFfeu eqPMDhSJvi8VjAYH15Kn1IaXmZy12N11MNSFQaN1yfW4ygtYSmfj8B6hK26HXw+GYHU3 HW1qZoaJ0+FTi4prjFYE+zDq4BDNJA0GpCb02qFvqm3nLWvH+GyKw0VwkvRbHn1G3qjw A05pryBRglJmV8W9V2kN3PfnBJz96eGfujmFGj3xme4pCx+o5y3iEVXUYx3Oxzlq6OAT L79A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o9Qut07X; 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 c3-20020a05622a024300b00434ff9cdc6csi214553qtx.44.2024.04.09.12.38.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:38:12 -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=o9Qut07X; 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 1ruHGn-0000go-2Z; Tue, 09 Apr 2024 15:36: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 1ruHGk-0000ev-T7 for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:34 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruHGj-0004gA-Bl for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:34 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-5d8ddbac4fbso4757312a12.0 for ; Tue, 09 Apr 2024 12:36:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691392; x=1713296192; 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=pLzmDWgl8qUDWCq3D57/PwLyiFcPLxohH0NJBMBSEDg=; b=o9Qut07XbMczd7B1Kb2LlS8YoQ5gcYQgNZ6KeFSY37HTW7pCttILpTBtagi/Zoc/fC QrDn5cNqYEIfqzsGCzielU/H0Hbptj5eG5tqbpHrKaN1tASPtgsYI9IxOJveEEXx81f5 lFJGS/56weGIqGM2HMghvp3JVp1O18ToS7O8X5zhCpERSlr8nRLnx/wqMRTSVu2capDt MwKdGwxG7DapfEIX/5gXDof6C12QvgQAYnOLt/o/n8Q9aNkuRT1u97abW9KoQ31oqpWh YUrzM63chS6iOT1+hs+2l5bkwwtpr1tut4P/90BxTYT0Z9czpr6AoscpiKaBYUROro/K u+Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691392; x=1713296192; 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=pLzmDWgl8qUDWCq3D57/PwLyiFcPLxohH0NJBMBSEDg=; b=pjxqgHoJeUVM5vbFVsvx5teWyR5hzwjBFka//SdDc8MDMNyEbwS8+07KRc7Iw+gYWF pGxXBuNUxNJdw1PyxEZS4H7isgdcahFlQQM0ucpFrV4ejhAbCJ0YeuzS5pYphB+ttSu+ npYcK3Whec0/1p+FRcSzmDcF5UdXh71Zd7Ha28FU1g/wMIKs8gwxpB0KHXsYnO+MOdxr Pq+SOLbv68zqoHyYa+qZTAPJxzpjTtGE/S8DQFVC2fL+tTBb/348m5/DmjWm6FZwtg9s htFwZ3sXsrqWXapNi0b3/UbkmlZ+Mv+a8Mi8xbevfXHbk1n/4W0DewSjIpCVdYVr/44G BYAg== X-Gm-Message-State: AOJu0YxmDvgyZvjBQTROGIY0/jLT2mM05Y4Tm8mAd8iltd1V0M8I8VMa 3E1LUjjKFK9lFrMTbX2CIXIoSP0jGQdnB8QSyxy0q7yQ4La2LaAQTLKhMuhamWeo51kVtYR8OO6 u X-Received: by 2002:a17:903:2302:b0:1e4:344b:734c with SMTP id d2-20020a170903230200b001e4344b734cmr1114683plh.19.1712691391996; Tue, 09 Apr 2024 12:36:31 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL v2 18/20] target/s390x: Use insn_start from DisasContextBase Date: Tue, 9 Apr 2024 09:36:01 -1000 Message-Id: <20240409193603.1703216-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/s390x/tcg/translate.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c index 57b7db1ee9..90a74ee795 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -141,7 +141,6 @@ struct DisasFields { struct DisasContext { DisasContextBase base; const DisasInsn *insn; - TCGOp *insn_start; DisasFields fields; uint64_t ex_value; /* @@ -6314,7 +6313,7 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s) insn = extract_insn(env, s); /* Update insn_start now that we know the ILEN. */ - tcg_set_insn_start_param(s->insn_start, 2, s->ilen); + tcg_set_insn_start_param(s->base.insn_start, 2, s->ilen); /* Not found means unimplemented/illegal opcode. */ if (insn == NULL) { @@ -6468,7 +6467,6 @@ static void s390x_tr_insn_start(DisasContextBase *dcbase, CPUState *cs) /* Delay the set of ilen until we've read the insn. */ tcg_gen_insn_start(dc->base.pc_next, dc->cc_op, 0); - dc->insn_start = tcg_last_op(); } static target_ulong get_next_pc(CPUS390XState *env, DisasContext *s, From patchwork Tue Apr 9 19:36:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787237 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383349wrs; Tue, 9 Apr 2024 12:36:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUIq2pljWJ+tIAI9pfiorNJwzCf74Pa2RbqpfwXRrbX/m1RCVKCnBiQoj/qO7mtX3fKX+wX3EZ9XCAQddZ068aw X-Google-Smtp-Source: AGHT+IGf3gLsx6TFuT9mQfgWamCfEPAHrsWHCF6+4Wweb6aanI5l/y5nDNkri6sFb1TXwk//y9ay X-Received: by 2002:ad4:5b8b:0:b0:699:2fde:3a2a with SMTP id 11-20020ad45b8b000000b006992fde3a2amr519564qvp.51.1712691415568; Tue, 09 Apr 2024 12:36:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691415; cv=none; d=google.com; s=arc-20160816; b=JZhJBv2rBmNkPwAvENX6dznlp7d6LR/CPxI+kZSooKBOfWk64gODQ4ONKSkvbLi6ud SXFeRcldoLINY12OwItrVMSXKDdUAFlnj9f7jpy61z6ISrf5rGqKHgyP0GBZ338iXJ4V gtakVgbtNlCldl3U1X/mBAV15gwvgaxdoR2YMjjnjrd3fXN4W8e036No0wi5R9J96h8Z mA+CZhnvkuo9TUj+RlQJztGSbjFRROBNinVFqJ6fHdXaGX0Cc+HInF09+SuLJVbwViq7 47zXyCwBatvInb7JG5q8tzAI48mQ2S3UG5Q2hAMcYmZ6PqFzyV2p6gZ29LHxtgjsMsVx bQrA== 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=LWeWfrDPztEwkV9YuE7zu+DtIohBh0oWfxn6udjmQ4s=; fh=feciRXMMXjL5Zdx/9FYuVSJ4fTkSvjANJ3wyTAeS3QU=; b=oMMSftej/gZ5CVyyqUvxuMcfv3I2kEZpVPMAZ3HGlftogTlYFZRmKmfoQCqsTQrhIT ZgsbCWGwrwq7hilR8MIrv1XWrJfFctNtqGHP7qhZvJGSudrPX2+ZYIppQb8Rp8NSghV8 XnsgpWa5aOsFVgSjt59xqdQXApnHIi2vwUM4kw5FU2Np8/ac3PBzBpgLZZVg26+MOIrP 03nr5PmcFZPgrdgKJtGGdTCknhZAu9ZiDCw8t6eEU2IbCsXo8bXgCp21r5mGKQ8beXt2 77qTJNc24lR3kUdE6sFfKOFWXdepHOyQy8UXkvVCIOuRIjl8gkTxgPJRA97n+zxQkyKK GEtQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hfDSbyaB; 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 m12-20020ad44d4c000000b0069b245b0e0asi3224912qvm.490.2024.04.09.12.36.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:36:55 -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=hfDSbyaB; 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 1ruHGp-0000ho-ML; Tue, 09 Apr 2024 15:36:39 -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 1ruHGn-0000gr-Fe for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:37 -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 1ruHGk-0004gK-Ng for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:36 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1e4266673bbso22532875ad.2 for ; Tue, 09 Apr 2024 12:36:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691393; x=1713296193; 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=LWeWfrDPztEwkV9YuE7zu+DtIohBh0oWfxn6udjmQ4s=; b=hfDSbyaBzkl5eQ8A3w3/i15lcs4dlSVlqe/IKxEkMMGDQa1RCwiL9omjh7v2s3eXSO E4dNnrpiluSqppj1XZSqFnyzd/sWAHLHIepzbwtVuwrW3hHqyoBxMJ1hUTH3qs+RbOXo yaoBXHmpWp+1lMbM+Kmpuo4RcCF9Vrk3Xm/I+zNry6oIdIGVVcLe2WdlojrfyxjUG2NG zJL5Y/PUjO7Hi3D4YwTqUr7elSix56gx0EgChlx7ftV5ermovGGWxu1YYmVLGKRGLYRa PV/95kLuiq26jtlM65YGO5H5vbREMzEIKYbOmi/3IE9nVDlfSqFhfMXmoASTmJiSSXui 4NjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691393; x=1713296193; 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=LWeWfrDPztEwkV9YuE7zu+DtIohBh0oWfxn6udjmQ4s=; b=eftH58S4avBnucUICkYCcld6c+kk4hRW+uvRoVzYBrgVL4f8+J+hog7xwtXyzS2f53 o62pyRgMXeL0UaldqnaKtWOJCZzIxBDgWDovWlGZ2PxwAlrxuXnG9XwOBbgHn8uipgx5 RwGh8g2Gx6HZk7RlAgDSitFlZz+RbujpxXhcFUD2zaeA7xhxKfofC2Y9ImRWowrg9YnJ Fvy+3LipKnVkKZzarI9Zt65RYHyVFPO0IDWT4qebxyOQw59U58/qt0nSF+vUek8oFZaf Y60N64DldhDVqPHM7bBulHSfU6/gLy5k+KtJqSsUhmKFqyfEEeM7cptSrCPK0DbPWaih uKPQ== X-Gm-Message-State: AOJu0YxVlc2jX0ovJJ2ShV6W9sjqdZNlFjbCjrtYkp4c3Mv0UfjRdA94 PqB5+StSAKhpBAWdu1stlXryACHIoei8f7F/RfSESNYesuzn1eJOnSSFF9z9T43Trz0+718taco b X-Received: by 2002:a17:903:28c:b0:1e0:4dfd:c121 with SMTP id j12-20020a170903028c00b001e04dfdc121mr825476plr.68.1712691393520; Tue, 09 Apr 2024 12:36:33 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?J=C3=B8rgen_Hansen?= , =?utf-8?q?Philip?= =?utf-8?q?pe_Mathieu-Daud=C3=A9?= Subject: [PULL v2 19/20] accel/tcg: Improve can_do_io management Date: Tue, 9 Apr 2024 09:36:02 -1000 Message-Id: <20240409193603.1703216-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-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 We already attempted to set and clear can_do_io before the first and last insns, but only used the initial value of max_insns and the call to translator_io_start to find those insns. Now that we track insn_start in DisasContextBase, and now that we have emit_before_op, we can wait until we have finished translation to identify the true first and last insns and emit the sets of can_do_io at that time. This fixes the case of a translation block which crossed a page boundary, and for which the second page turned out to be mmio. In this case we truncate the block, and the previous logic for can_do_io could leave a block with a single insn with can_do_io set to false, which would fail an assertion in cpu_io_recompile. Reported-by: Jørgen Hansen Reviewed-by: Philippe Mathieu-Daudé Tested-by: Jørgen Hansen Signed-off-by: Richard Henderson --- include/exec/translator.h | 1 - accel/tcg/translator.c | 45 ++++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/exec/translator.h b/include/exec/translator.h index ceaeca8c91..2c4fb818e7 100644 --- a/include/exec/translator.h +++ b/include/exec/translator.h @@ -87,7 +87,6 @@ typedef struct DisasContextBase { int num_insns; int max_insns; bool singlestep_enabled; - int8_t saved_can_do_io; bool plugin_enabled; struct TCGOp *insn_start; void *host_addr[2]; diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index ae61c154c2..9de0bc34c8 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -18,20 +18,14 @@ static void set_can_do_io(DisasContextBase *db, bool val) { - if (db->saved_can_do_io != val) { - db->saved_can_do_io = val; - - QEMU_BUILD_BUG_ON(sizeof_field(CPUState, neg.can_do_io) != 1); - tcg_gen_st8_i32(tcg_constant_i32(val), tcg_env, - offsetof(ArchCPU, parent_obj.neg.can_do_io) - - offsetof(ArchCPU, env)); - } + QEMU_BUILD_BUG_ON(sizeof_field(CPUState, neg.can_do_io) != 1); + tcg_gen_st8_i32(tcg_constant_i32(val), tcg_env, + offsetof(ArchCPU, parent_obj.neg.can_do_io) - + offsetof(ArchCPU, env)); } bool translator_io_start(DisasContextBase *db) { - set_can_do_io(db, true); - /* * Ensure that this instruction will be the last in the TB. * The target may override this to something more forceful. @@ -84,13 +78,6 @@ static TCGOp *gen_tb_start(DisasContextBase *db, uint32_t cflags) - offsetof(ArchCPU, env)); } - /* - * cpu->neg.can_do_io is set automatically here at the beginning of - * each translation block. The cost is minimal, plus it would be - * very easy to forget doing it in the translator. - */ - set_can_do_io(db, db->max_insns == 1); - return icount_start_insn; } @@ -129,6 +116,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns, { uint32_t cflags = tb_cflags(tb); TCGOp *icount_start_insn; + TCGOp *first_insn_start = NULL; bool plugin_enabled; /* Initialize DisasContext */ @@ -139,7 +127,6 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns, db->num_insns = 0; db->max_insns = *max_insns; db->singlestep_enabled = cflags & CF_SINGLE_STEP; - db->saved_can_do_io = -1; db->insn_start = NULL; db->host_addr[0] = host_pc; db->host_addr[1] = NULL; @@ -159,6 +146,9 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns, *max_insns = ++db->num_insns; ops->insn_start(db, cpu); db->insn_start = tcg_last_op(); + if (first_insn_start == NULL) { + first_insn_start = db->insn_start; + } tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */ if (plugin_enabled) { @@ -171,10 +161,6 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns, * done next -- either exiting this loop or locate the start of * the next instruction. */ - if (db->num_insns == db->max_insns) { - /* Accept I/O on the last instruction. */ - set_can_do_io(db, true); - } ops->translate_insn(db, cpu); /* @@ -207,6 +193,21 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns, ops->tb_stop(db, cpu); gen_tb_end(tb, cflags, icount_start_insn, db->num_insns); + /* + * Manage can_do_io for the translation block: set to false before + * the first insn and set to true before the last insn. + */ + if (db->num_insns == 1) { + tcg_debug_assert(first_insn_start == db->insn_start); + } else { + tcg_debug_assert(first_insn_start != db->insn_start); + tcg_ctx->emit_before_op = first_insn_start; + set_can_do_io(db, false); + } + tcg_ctx->emit_before_op = db->insn_start; + set_can_do_io(db, true); + tcg_ctx->emit_before_op = NULL; + if (plugin_enabled) { plugin_gen_tb_end(cpu, db->num_insns); } From patchwork Tue Apr 9 19:36:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787247 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383882wrs; Tue, 9 Apr 2024 12:38:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUdw0KlNtgPtC9GDcx0TQPCJhHnbJBpUhau5gDzrgiRGgVf90z2OnxbkOXrpuTVp5c6Dg9iKOU50FMkzF/2MZtT X-Google-Smtp-Source: AGHT+IGkI0b8BcIH38W3uaza/LurLNifROsbYlhA5eG6L5Hsgtd/WQi6HrBy2vo9ExePn0AG948s X-Received: by 2002:a05:6830:130f:b0:6ea:2a51:149c with SMTP id p15-20020a056830130f00b006ea2a51149cmr794142otq.27.1712691517805; Tue, 09 Apr 2024 12:38:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691517; cv=none; d=google.com; s=arc-20160816; b=hcKSHafppsS6Lm1P1kSqdCnFUwZ8Hxz/wG0/Iy10/ovnUw3vCiIxZVfqsg9lSvvVRp fhpic3NLPyEQezB5fog4XB3HVzzuCloij17JpYZ/EnBOZiLpYwGzysvuFCeyOLLN2C6a DVeEcM5W29NcdbeTCfbecq6ReeHhbRVf+08lJNJqWlUxp5zUM5fS8d3sVKmAv/KqSHtm Hwccse3n9FWXSF9dwRIn3bNGFiEkiz3mZ4yxQ9GnFTxAvR4lBlarny0r4TILyawg0LIA VuvOGFr6wBAR/U3tZ2Sah2RSBXsYJUlnKUOKGyc8ac7iM9PrYv5r7TJ818bE+0HILO7I DNgw== 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=xpaONpZX7TzlKuP+L0GxHPWtvRjew/38IVUtIRwPa5c=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=GzJtoVNhCQ17qHUx8nL5+fSK2gg14yf967Ev9+/9aff5Wd0qn8317GYlxY0zv3S2pY 2ohJoKgcJZ2V1w/gkn+o1rAFepKSDBC4hInVnxCYSzfvTNLWnhBG2FsG1FtdLuam27dG dcPJZMg94v510xbhi0FnLeWyDRp7uXKXkkZBLXnkfRyNCRY+GJ9WlBKlVTiHRlTqCFQ8 lDnVYWs6XyAsHB1O7oacObenTWxxpIYU2nnKgFuBpZi+aqQiuWaADcNonn3z0kHkXTXO plHZ/yRaMSFJOPwDuuPBCRDbinOo+yJ4YwvuCITQbAOZ/KPqVU3p2Rdk+0KluCnqbEKo KvzA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u32rTkWj; 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 cx20-20020a05620a51d400b0078d620b73b0si6037019qkb.652.2024.04.09.12.38.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:38:37 -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=u32rTkWj; 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 1ruHGr-0000iN-Fy; Tue, 09 Apr 2024 15:36: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 1ruHGp-0000i5-IS for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:39 -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 1ruHGl-0004hs-UW for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:38 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1e4149e7695so19670915ad.0 for ; Tue, 09 Apr 2024 12:36:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691395; x=1713296195; 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=xpaONpZX7TzlKuP+L0GxHPWtvRjew/38IVUtIRwPa5c=; b=u32rTkWjDpvUVunMYXf5Bu2wHhCy/Usc1g7CLOneDWr3CvNZDldf77QLkTy7uJAJeF jKjwHAHVoz/J8x7SWlyw+Wg5NlDRFNJU7xlEi41cSeozDniZhExe5GwhufFh9tf+sTZR G22po88Kf69jRlOSzmOlyKjqnuxkJPJoFX+mTvO9FbKO/b5FH1tXTTMQF3/ZUbII/6/+ n82dPxddUJ67AFHdtpCmQ+AmqgGcMfhGR7HYsHPjl2W074cdDyGgXWOBhO2GXOWvdHR9 4EospU6vHMXGJA4gf9/lLZ5qE+0fx5zAcY9iE6lvHqc/jh5BgPmvHRS6Hf4iIVAbiBNl oYzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691395; x=1713296195; 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=xpaONpZX7TzlKuP+L0GxHPWtvRjew/38IVUtIRwPa5c=; b=xC5teEQB+BvuuMILMXArzU9KZB0WOVSuJD2txact+Ber2zU2xUbnX9FRrALv7zchCd 0NpNEF3ulfDzcLmmqKWjpXnoY4VrDWi5KX81ueoAaKgxY2tvpp+o7OCwaDzm0zB+gtqQ lm/kQj2UFRAj0ql03bXtGwawQH440fVrv18Jt+uQnyqVYSJZaYUBqlKiblWJAgShkn6A 5wxjJI+RYX4U0FMY3hDv0qaujut9xvG8HVNaLXtuEXbP369VLZ4hSPO9xCq4M9GUk4NA UCkvWD6GrWRrKToIJYnsDawqLbuzKFtR+9k9Xr9Jw+plQGMRclPuDGf9qVPO6X2G0sZg CZQQ== X-Gm-Message-State: AOJu0Yw9gIoxtngFHLH5xYLiramuvImzzngUwA3lxNmU1cuu/oCCMZb6 3UH+W/q8SyzQKSBlxDsWMNi9mtUDrH9aLCwYnJHnfKEDmaOwiI/zqfaq0PcjzJDwJVndEiqW9s2 / X-Received: by 2002:a17:902:eb8f:b0:1e0:a7cc:3750 with SMTP id q15-20020a170902eb8f00b001e0a7cc3750mr963465plg.3.1712691394748; Tue, 09 Apr 2024 12:36:34 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL v2 20/20] linux-user: Preserve unswapped siginfo_t for strace Date: Tue, 9 Apr 2024 09:36:03 -1000 Message-Id: <20240409193603.1703216-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-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 Passing the tswapped structure to strace means that our internal si_type is also gone, which then aborts in print_siginfo. Fixes: 4d6d8a05a0a ("linux-user: Move tswap_siginfo out of target code") Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/signal.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index a93148a4cb..05dc4afb52 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -1173,6 +1173,7 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig, CPUState *cpu = env_cpu(cpu_env); abi_ulong handler; sigset_t set; + target_siginfo_t unswapped; target_sigset_t target_old_set; struct target_sigaction *sa; TaskState *ts = get_task_state(cpu); @@ -1182,9 +1183,14 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig, k->pending = 0; /* - * Writes out siginfo values byteswapped, accordingly to the target. It also - * cleans the si_type from si_code making it correct for the target. + * Writes out siginfo values byteswapped, accordingly to the target. + * It also cleans the si_type from si_code making it correct for + * the target. We must hold on to the original unswapped copy for + * strace below, because si_type is still required there. */ + if (unlikely(qemu_loglevel_mask(LOG_STRACE))) { + unswapped = k->info; + } tswap_siginfo(&k->info, &k->info); sig = gdb_handlesig(cpu, sig, NULL, &k->info, sizeof(k->info)); @@ -1197,7 +1203,7 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig, } if (unlikely(qemu_loglevel_mask(LOG_STRACE))) { - print_taken_signal(sig, &k->info); + print_taken_signal(sig, &unswapped); } if (handler == TARGET_SIG_DFL) {