From patchwork Sun Jul 14 11:12:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 168966 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3117493ilk; Sun, 14 Jul 2019 04:13:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4HSYkbBQgp62h6jiI96krn34Cz2Ap4ux0wXL/5HZySPIBsHkUSBgSlqr/jaWMt2Yk7NWG X-Received: by 2002:a50:fa05:: with SMTP id b5mr17643810edq.269.1563102799155; Sun, 14 Jul 2019 04:13:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563102799; cv=none; d=google.com; s=arc-20160816; b=JBMiZ6CUnyu85Y+5z4agnJA+3Pnd/Qmli7YfYg6rXwibGp64LiJ+Zc8/7uZnWQBcTy U5RMQcQ+RroQQJ1J3nbIwZfbIBQTfrb353NS5+4M4oaJWwbHD6IymQ12IQPoBNCSuDwL KS1Wzi5QtPd82nNAgCN/aAbpASnCJ6Z86hF1mFGXt8m1NLK9M0b7zzUeFbb1XSbVadkn 85Z1IebjhGAvTaPfiC9S+rhEGeswyFbJx6aAahUvF6iHILr8OA63UTkNSMIGqgDqhCgh CKN6NU0yIVxkNCCBRGJgztMj/oJYnFIjT4+BfZH7ZILjWTts+HNcgh2HOxfctHD54kE9 ln0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=QWcqefmxLRbmEUfSEqDtCzXI1bFjI9WN8pfzB0Jzwck=; b=G9EtNmJw9O3H3j8OPXVZPvEXbFyeRJZ5q0f7nLxtuZiQlEv+lT6yUCbW1h1lyj6Ybb PHlHH1VokgYsOj1Uqa26NF0ZX7clNOJhjm0lZUPXaRDptZrnVqZa01JAtMY8U5GGs/YB utmQqjWPR9wIRkZBazFwdHXv6IpGiqlGAqFWpPi0LwYZDOSUemFOi3so6LLbWLznI8JN DL4zMAWmeahjHPnGmnGUqUvEb4mn7epjM6OUTDjiP05UvpDO3e+jeLpugli4bcYEvTRN yMN6UZguc7d6OlLv5mHbmgOv9SjaRp0WrBz6g6HmR9SPi6HI6JwvBkYFsWpfLDzgwqMq ED6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=yO8ROLXJ; 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=fail (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 j33si8488303ede.413.2019.07.14.04.13.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 14 Jul 2019 04:13:19 -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=fail header.i=@linaro.org header.s=google header.b=yO8ROLXJ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmcRQ-0005fg-Hy for patch@linaro.org; Sun, 14 Jul 2019 07:13:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60303) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmcR4-0005TY-ER for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hmcR3-0006M8-9z for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:54 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:33094) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hmcR3-0006Ld-3t for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:53 -0400 Received: by mail-wr1-x441.google.com with SMTP id n9so14202034wru.0 for ; Sun, 14 Jul 2019 04:12:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QWcqefmxLRbmEUfSEqDtCzXI1bFjI9WN8pfzB0Jzwck=; b=yO8ROLXJyDL9A3nECDL4t13PvlssQCtGuq0AZBc8cK2TxiTHdE6FcIugdsxGumIdZq vD8r3BnSrk+8KZ10H/OYgWPHYjv2e/vk/pf7ciCyP6dkaxeappvffvQX6S9o3uiiGD2c v3qGaesrOoaA8OPOW1sde5O+snZNOtxe5SuqdsUAuvpvYPjb629vd4+bVwOZPwbrxkzP HAXk7mqtEkZhGz0iUutmniKhNf8mwd52WjaNzWbAszn/713VS6LEoRXQBp8jTQjr5ySj whR9bO+Gkcg2ChsOhGRlGAocd3s6n0+sC8KsS33Z27I4h6C9Yx9Y9ilZxeFBCCzZ7uWK NKsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QWcqefmxLRbmEUfSEqDtCzXI1bFjI9WN8pfzB0Jzwck=; b=YyrIUENhFGf/KFBCrxWBGxlkFEBHKbTexFLvEsQMkyU9TIXRgDNdRW7Nf+Pvb4yhu7 14B8YqZkpZ/imri41JP4paoRsaBKOfryrPIe/xsM0IK/cw1a/qrZf84cl3pgVvDeB30t Z5BJoJutfdbq09KddMDAKg4hSLILUgIiQVzlJYlhBhkpONkCof1E1R9qJaykJo7g4iE3 ArFv6MVDvCKfCoqm7YZkkWcxntNQyVHEN6HDN3O7apnOEguhrjixB2VOJU2CC5WK4UnS 8Jdod7UAbj/S6zXZKL2GkAL8cSaKX8OfI2/Tdj5P2nEf7ZBdn2RjEMHs5oBNE8nvmfpg MWEw== X-Gm-Message-State: APjAAAXhPoWyXI/U0WwGK+yEYF0myas1b7LPgFzqgDanholFTvFRtY+8 4Q1Ii60++HjQ8xwSA98RZiEEeHH7iI+4GA== X-Received: by 2002:a5d:42c5:: with SMTP id t5mr21875470wrr.5.1563102771773; Sun, 14 Jul 2019 04:12:51 -0700 (PDT) Received: from localhost.localdomain ([194.144.248.241]) by smtp.gmail.com with ESMTPSA id f17sm12675795wmf.27.2019.07.14.04.12.50 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 14 Jul 2019 04:12:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 14 Jul 2019 11:12:43 +0000 Message-Id: <20190714111249.13859-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190714111249.13859-1-richard.henderson@linaro.org> References: <20190714111249.13859-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PULL for-4.1 1/7] tcg: Fix constant folding of INDEX_op_extract2_i32 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" On a 64-bit host, discard any replications of the 32-bit sign bit when performing the shift and merge. Fixes: https://bugs.launchpad.net/bugs/1834496 Tested-by: Christophe Lyon Tested-by: Alex Bennée Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- tcg/optimize.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/tcg/optimize.c b/tcg/optimize.c index d7c71a6085..d2424de4af 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1213,8 +1213,8 @@ void tcg_optimize(TCGContext *s) if (opc == INDEX_op_extract2_i64) { tmp = (v1 >> op->args[3]) | (v2 << (64 - op->args[3])); } else { - tmp = (v1 >> op->args[3]) | (v2 << (32 - op->args[3])); - tmp = (int32_t)tmp; + tmp = (int32_t)(((uint32_t)v1 >> op->args[3]) | + ((uint32_t)v2 << (32 - op->args[3]))); } tcg_opt_gen_movi(s, op, op->args[0], tmp); break; From patchwork Sun Jul 14 11:12:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 168970 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3118039ilk; Sun, 14 Jul 2019 04:13:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqyoHk69dxxnz6EMkaLDYANdsltENe+oCi/HdM9h8pfL3lfJhLMPBMvVqTqA9/9kscb+++5F X-Received: by 2002:a05:6402:652:: with SMTP id u18mr17918632edx.85.1563102835663; Sun, 14 Jul 2019 04:13:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563102835; cv=none; d=google.com; s=arc-20160816; b=kBl8F4qWjdEorng28b+43ccsRwESgQS3fu+0Poitrj5xFPKVhIYYABhRBeviiex2n6 1BcM5QSUZhviAbPzQkDBErzh6pHYXBBdOqjRkgvpxu5xu0tiFJ7KYZ08DGg75LfHHC5A 21ncoJ3AA0fNi2EyRW6EOaiNqDF4swvHRXRuicmCGeTEv8a7ZJZJpE43/D7WKdDnwzsp c6NV78DeGA/wCPeGm+uttBk6tXJvKA9RfqZgNA2oAWKMtz/ZHhFy2+rf84Af0+09s5Yr dCjJpyDhGc8gPNnPWZ15xi+KMCzRpcO2cIyLgW18aE7CFgLxCGQ+h6wwNL5X7VNAz/o1 fOKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=0wQZY7BwhMGbzrEOB1c2143JMgOfq1mTVa8os+QOs8k=; b=mpTlGD0wk1MKppWci4iFTyic+c5H7V+NCazZIwOE92bH3D+Z4qjZg/f0wsBeuTzaKl efDrUKjRGVfUACFUzBOz3sje3sY3ekdBwOrFveqb/RgnhC6VOwP0LVVM14ESGgIAYfbp 6UDZ24Jx7IV1A3z2PcZuWMyU+AKvXJ1Q/IocVsLFaKTK/RdrgbMax/vqYpRNrKADbAIS OyPJZeAMHL0r5+dckZBAkZVemlsJskVxuFB1drypZfNqQlVXHgHb888N8N4EcOAS4hgn rsbijBAJkOJCFJHaUdpjwtggIx0wrqOQrVBkc8eZ+9FbKH+ldj24GxSfuJRzDXJ1b128 GuTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SnjNwwFg; 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=fail (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 z31si8774020edz.165.2019.07.14.04.13.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 14 Jul 2019 04:13: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=fail header.i=@linaro.org header.s=google header.b=SnjNwwFg; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmcS2-0000IG-93 for patch@linaro.org; Sun, 14 Jul 2019 07:13:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60318) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmcR5-0005Tg-D0 for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hmcR4-0006MU-D7 for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:55 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:44266) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hmcR4-0006MC-6a for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:54 -0400 Received: by mail-wr1-x442.google.com with SMTP id p17so14119335wrf.11 for ; Sun, 14 Jul 2019 04:12:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0wQZY7BwhMGbzrEOB1c2143JMgOfq1mTVa8os+QOs8k=; b=SnjNwwFgWLWo/sDnqsLQa0H3gMnaxxiVUJy1ljCTHjzYy15C7DEYkZWxwCFNs+/Cto I9f2O6uftSECOxttpVsh4bm0kNG5y3Pbf5cTFG/KrTpA3llKreMJUulW1Z9FXCoW6csa zT393DLvo2oLMNZ3iX9Teb9KaSV4xhjqXPbXfHzc6a4dG38/Nc4gFYQMeS7hRH2Pttcn Q7BuEYZ4fnfKyN2zj5TVZoWJ/E4icvgeUknkvIgNUR1r4aq6o/33Ou3EKf/u0VnCGhz5 UpUOmP5DCPYIcr9CcJRi+HDQ9TykD1+P5vKMuCGU+dEDr7Yu++5NZ8dZmtatco04KhYv vU9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0wQZY7BwhMGbzrEOB1c2143JMgOfq1mTVa8os+QOs8k=; b=CaHoM9CSNLHxBOoISCaBF2Ky68ZTE3ahZl3ckM0TqwQ3UtiQXTzlgf1PZdSNIG519W YtQ9o/+hUGE0fDKjHZmw1bSwimaWyk1f7NL1ZujxkK7pr7CNoJVjXlAVIrTNCW5IyYBt tIXj95yyPSwjH8UI9WAPsXiZa2vokx5m67FBntC2U+yQUqpIaRor8/lAj4vwU1R6cvBF /6VJicng1pOqMxTAz9QSqj+kTi0cpl6mSTysq46qm7tyAIwMQwP9ux+MI5CfUB3PBHgj X6znzS3jFKDbGhBel+JkuNyP8jrQvLkxD4zHpfakNyn3jFczA5idU7A2mu7trYqrlsWp 6Lmg== X-Gm-Message-State: APjAAAXB4w5fXU4xo2XFT9lDKYO1MOKEZCC9XRsf07H5p23kISB+ZBIQ gZT4Uqp28Ki4Bdds/7xeqJ3HCiDz1A7ubg== X-Received: by 2002:adf:80e6:: with SMTP id 93mr22588812wrl.298.1563102772979; Sun, 14 Jul 2019 04:12:52 -0700 (PDT) Received: from localhost.localdomain ([194.144.248.241]) by smtp.gmail.com with ESMTPSA id f17sm12675795wmf.27.2019.07.14.04.12.51 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 14 Jul 2019 04:12:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 14 Jul 2019 11:12:44 +0000 Message-Id: <20190714111249.13859-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190714111249.13859-1-richard.henderson@linaro.org> References: <20190714111249.13859-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PULL for-4.1 2/7] tcg/aarch64: Fix output of extract2 opcodes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This patch fixes two problems: (1) The inputs to the EXTR insn were reversed, (2) The input constraints use rZ, which means that we need to use the REG0 macro in order to supply XZR for a constant 0 input. Fixes: 464c2969d5d Reported-by: Peter Maydell Tested-by: Alex Bennée Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index b0f8106642..0713448bf5 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -2226,7 +2226,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_extract2_i64: case INDEX_op_extract2_i32: - tcg_out_extr(s, ext, a0, a1, a2, args[3]); + tcg_out_extr(s, ext, a0, REG0(2), REG0(1), args[3]); break; case INDEX_op_add2_i32: From patchwork Sun Jul 14 11:12:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 168964 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3117236ilk; Sun, 14 Jul 2019 04:13:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBnIWOtvjjGvWG2L1qv4oCA8+HFV7hjlSV093bIlFGy2Rp4fCLFTWPLZjwPd4X8UxRhbfh X-Received: by 2002:a17:906:d052:: with SMTP id bo18mr11499622ejb.311.1563102784463; Sun, 14 Jul 2019 04:13:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563102784; cv=none; d=google.com; s=arc-20160816; b=xZeeLcPE8RZtOaqYGnPGmL9kBsYSdglFoHtab6awcvDfWvaMZvuYtFYNZO/D0XaVOV 90EbM0nfYkKIoottPEUs5QCEFhKZMSInp3fRTklPhiMyqzY4qabChLFMxZwUy8InSqFA S3OQ+88EUOV/cbEAREFNGt+7s7SRzhY4mrVlQ5TiHQVwyuz9C+bSOuF9bu65U2UvI4bV w1qyUDY+2FRO3F1jY5RvIgrSPLj28EVeeTbGfTWoZNM1M/KbJdMdy2mSaZC0Khf2AWmx a9HSthf5FHgfUfrAymtZI9ItF79UXekPgjbOR0MUX8J3msXmEfUCrlNiix0tZK/cx/P4 vabg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=PPHqcOU6slcSwGsgrcyJjEFtFg9+d324ttSckt/Z6xM=; b=IU6CpUk80Z4mC25brxsmW3vPt8EDvL+ViVtQOkol+IoQr3+FJMazE8oRDYIPzJjvX9 bpvjUEoaaxsqfC3mX/hYDw2RJagpYiZ9WMdT6hiNiTgg/mEXXlY6RGcLW4t1UocsF6gK kMVQCkyXRS+EdVYjxrXp1xsrsrVyheRcIQtlGvSrE4ac+sL0KnLfHJM5muXjHQsm5rhM cO1Xk6PXL52qUBq2voDzs5y5caKRtlpC81PNJGcqzNqguMdKNDHxXZFm3qGwdXWIO5ei K3CQ9q/33YgB4n3U/aOZQ9pO5DsQmAK8OkwprDpH23V5yrM8cBLmSQH6Pl0q5M8q14XR VerA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eWNh56k9; 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=fail (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 l31si9819563edc.248.2019.07.14.04.13.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 14 Jul 2019 04:13:04 -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=fail header.i=@linaro.org header.s=google header.b=eWNh56k9; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmcRC-0005db-OE for patch@linaro.org; Sun, 14 Jul 2019 07:13:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60329) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmcR6-0005WB-9i for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hmcR5-0006Ms-Au for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:56 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:36136) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hmcR5-0006Me-4O for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:55 -0400 Received: by mail-wr1-x442.google.com with SMTP id n4so14178818wrs.3 for ; Sun, 14 Jul 2019 04:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PPHqcOU6slcSwGsgrcyJjEFtFg9+d324ttSckt/Z6xM=; b=eWNh56k93wj+RmSdz9aRxl3EMTH1CZOzmYQtY7HwH4K6XbyLBVGryCpg08oI3eD1pF ivcEGZwDO0cUkWJXy/rKojvMY/nmKVXvGX+GslGGkBLR0XHju/pKqnWA4k3s2mU09/6k qRI8OcCDSwCT1Tktma9XJ8mJBi3jAthYyP2k3gIstLrRDiF6dysGamhUr8ZtdnblOs1n bcEAZuiNb/D4bkHP/MxQ/+WN0UvmSxqvgTuxhBCKa2SbJiHtlPIFEu/5kWMtMwFzPF8Z WotIGWuj9zxh4NAlwe2Z4MCC+7Du7ZDik14kFsMFBGP67BSR7/+gctzHGkMo4++d6ubj SpXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PPHqcOU6slcSwGsgrcyJjEFtFg9+d324ttSckt/Z6xM=; b=o+vsQDv92qZHkAc36fiOR0nb71DRsjPc7WhfPGDSLU9hfxAx4iNGVZQVsUkohmiQVZ tPNVlWxJuOLecgZxDiFfRNvzMZt+Erbdt1N/u1jQfXFJsHEXzliDPzC1jalJDIE0Z2iq lrmtNfeSzVqq4yBUwMABcmLF8avLNOKQZo/w7Y8i+huA8iBJax0dQjU2qqQrCUlQI6IN 9moEdfcPh9JSZ8dU57mAl44HDaGaO0m/duR7wnjN/nc0WsW3y5GAJ/rgPM+OoIj1PNV7 WDKiun6ZFuAXS453JFQqdiD7iYHIwlkTWt4+342cxEbLcJxapaKH8KC08Sw6lswOML7O LAcA== X-Gm-Message-State: APjAAAUjNyx4Qbe3nfB51m6OZQaGTd0003PKIWVDkP4JkoIjcsHhMy2F qB2sWlPc+We3l+4QhXWNakYR9bQ0hvSHCg== X-Received: by 2002:a5d:4309:: with SMTP id h9mr22181473wrq.221.1563102774015; Sun, 14 Jul 2019 04:12:54 -0700 (PDT) Received: from localhost.localdomain ([194.144.248.241]) by smtp.gmail.com with ESMTPSA id f17sm12675795wmf.27.2019.07.14.04.12.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 14 Jul 2019 04:12:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 14 Jul 2019 11:12:45 +0000 Message-Id: <20190714111249.13859-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190714111249.13859-1-richard.henderson@linaro.org> References: <20190714111249.13859-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PULL for-4.1 3/7] include/qemu/atomic.h: Add signal_barrier X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We have some potential race conditions vs our user-exec signal handler that will be solved with this barrier. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- include/qemu/atomic.h | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.17.1 diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h index a6ac188188..f9cd24c899 100644 --- a/include/qemu/atomic.h +++ b/include/qemu/atomic.h @@ -88,6 +88,13 @@ #define smp_read_barrier_depends() barrier() #endif +/* + * A signal barrier forces all pending local memory ops to be observed before + * a SIGSEGV is delivered to the *same* thread. In practice this is exactly + * the same as barrier(), but since we have the correct builtin, use it. + */ +#define signal_barrier() __atomic_signal_fence(__ATOMIC_SEQ_CST) + /* Sanity check that the size of an atomic operation isn't "overly large". * Despite the fact that e.g. i686 has 64-bit atomic operations, we do not * want to use them because we ought not need them, and this lets us do a @@ -308,6 +315,10 @@ #define smp_read_barrier_depends() barrier() #endif +#ifndef signal_barrier +#define signal_barrier() barrier() +#endif + /* These will only be atomic if the processor does the fetch or store * in a single issue memory operation */ From patchwork Sun Jul 14 11:12:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 168969 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3117963ilk; Sun, 14 Jul 2019 04:13:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvtqjstG42qO5UsxF07zjnPXYqxUB4wIwG3cwyqnKSG/YB+e7Q2iY3atDUMIFs0ryf19mj X-Received: by 2002:aa7:d64f:: with SMTP id v15mr17969410edr.132.1563102830454; Sun, 14 Jul 2019 04:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563102830; cv=none; d=google.com; s=arc-20160816; b=FT7KdTctzRSqdWEBvplIaPkh8WLQijNokuOC30gbSIR9OgxFQMaXw4Kvd6XL2NT6L8 UyRJCyizUBW/u4VHwszyD+dC8skolQUXHtLfmZ/aWnpyU5sEC2jUDrHk5xAhUHnSRkWL 2FsFC26jbMrab/fkdH9b/6rnzreM184fzwhpTiUCW3wA+IuEGSzPGJBaECnoTTtAU1gs ffrNAL4nXDmQ1TbFj28XlVl5dStyWi0zcRla/nlALN0+uOmZqqyFI1i7GsnDQ8mdKLsg LqNygzZRowuqnT9jd4tYfXDiUT54rZPYkvnKZchIl5D630AWpW2InHDnEjYXHuuwxUyd vzfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=KHFpSRHm8eke5kb9WIbzFk3DWe+3YkG7SdTFpV8kP0M=; b=NXEMf/Mx/jYZiKpXAnoPaSGqDv+VSbkXO4Y+aMtrndVuNA/oUwOi0ZMPC9AjMERD5g ZIzLSB1dLoAdl77SmRIxR5fN4sX4onHUHh8YhbYCyO27pap/EfSIleHNbucIJZADFmvW ji4R30xcL0l/05D0KKfANUPkB4mnk9Qa1Bx3LlDlFlnGM3MG8IrhUiGMNUz4lGDcj8a0 aekWApg0jrVZltpsn6kdou3624AP0g4y7HpICe8fbguA6eSbbDnYg/texXPyRL5uqnKp ErYvSu/5tG6DWiTR2aoEcU449tLtTcn15ZV0HKaLVKqWUCA4wTIRKURlyTXR/vKD7eXI tqKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CX0UOX1u; 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=fail (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 e4si8393969edb.419.2019.07.14.04.13.50 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 14 Jul 2019 04:13: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=fail header.i=@linaro.org header.s=google header.b=CX0UOX1u; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmcRw-0000Z0-US for patch@linaro.org; Sun, 14 Jul 2019 07:13:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60353) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmcR8-0005he-PW for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:13:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hmcR6-0006NQ-SQ for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:58 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:36590) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hmcR6-0006N8-Kj for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:56 -0400 Received: by mail-wm1-x333.google.com with SMTP id g67so8393093wme.1 for ; Sun, 14 Jul 2019 04:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KHFpSRHm8eke5kb9WIbzFk3DWe+3YkG7SdTFpV8kP0M=; b=CX0UOX1uqVpfp2rjhTU1HltFf39Mebnt7EbpNmQg+pSQHEs3GPQKh8vgFVyZWXE/o9 PC9NYuiL9HinzFoXryopKFW65ycCHr3MkrHKwuqsGxksWSagi6qy0po0S/G6t89R061U KXXXBv06BHl1lwTznxzHb3KerRQrDIGcUe/QTg7R8W5qRqUA+QKnRRgXHaD+ppBqNkr8 H1jg60nu8tfeaF3Sjacso7bXR1Y/VEjV6lsNFSSjnw49l2v5QbSUB0+JiaFJKNldReZn pxV5TEjm0PLjvnUM/Yhtqlak+PpxxVphYI3rWsRQyOyKsOdmP5HZSYwRLI948WP8tLzL k+SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KHFpSRHm8eke5kb9WIbzFk3DWe+3YkG7SdTFpV8kP0M=; b=R7J+5KG0qs6XlOAm/MsKGAqtF+J6qVggd1Hm3pAcyvBxTIO6na/zqmNGGxNgHuM9eK cpNlLodF0MbQ/wXn5O2ST64LW5fdHkpTNF1C4qpm/LoRfudvqzGvUYfllStEwQruyEr9 Rm+bj5tRpPj7gQ1eBcLGIDn6eFSvT7gLQw+F9gc37gn2l8xEI0gPMpCF7FUHX2Wde4Rb bv5GsmcnHQoIaSiqiKkYIH42ihYUL1eBdPmPh0pMqtg6FQ/OBu2jt6yGFB2WlKbMuVG3 tDcFTG0ImJ16XaXk5pavi+lmZh+YjokdzpyZCS5DTAukF9WVIlWuJ+MzNKqL3QUInO6s jfCw== X-Gm-Message-State: APjAAAW4dlHMgmA7h88QDJuqYpoi7LV9k+C/onuKk/xp0HzmvxHJPVAX EYD4rOsH91wPr96qCdngNRRpPES2Ok69WQ== X-Received: by 2002:a1c:b707:: with SMTP id h7mr18788939wmf.45.1563102775188; Sun, 14 Jul 2019 04:12:55 -0700 (PDT) Received: from localhost.localdomain ([194.144.248.241]) by smtp.gmail.com with ESMTPSA id f17sm12675795wmf.27.2019.07.14.04.12.54 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 14 Jul 2019 04:12:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 14 Jul 2019 11:12:46 +0000 Message-Id: <20190714111249.13859-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190714111249.13859-1-richard.henderson@linaro.org> References: <20190714111249.13859-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::333 Subject: [Qemu-devel] [PULL for-4.1 4/7] tcg: Introduce set/clear_helper_retaddr X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" At present we have a potential error in that helper_retaddr contains data for handle_cpu_signal, but we have not ensured that those stores will be scheduled properly before the operation that may fault. It might be that these races are not in practice observable, due to our use of -fno-strict-aliasing, but better safe than sorry. Adjust all of the setters of helper_retaddr. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- include/exec/cpu_ldst.h | 20 +++++++++++ include/exec/cpu_ldst_useronly_template.h | 12 +++---- accel/tcg/user-exec.c | 11 +++--- target/arm/helper-a64.c | 8 ++--- target/arm/sve_helper.c | 43 +++++++++++------------ 5 files changed, 57 insertions(+), 37 deletions(-) -- 2.17.1 diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h index a08b11bd2c..9de8c93303 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -89,6 +89,26 @@ typedef target_ulong abi_ptr; extern __thread uintptr_t helper_retaddr; +static inline void set_helper_retaddr(uintptr_t ra) +{ + helper_retaddr = ra; + /* + * Ensure that this write is visible to the SIGSEGV handler that + * may be invoked due to a subsequent invalid memory operation. + */ + signal_barrier(); +} + +static inline void clear_helper_retaddr(void) +{ + /* + * Ensure that previous memory operations have succeeded before + * removing the data visible to the signal handler. + */ + signal_barrier(); + helper_retaddr = 0; +} + /* In user-only mode we provide only the _code and _data accessors. */ #define MEMSUFFIX _data diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h index bc45e2b8d4..e65733f7e2 100644 --- a/include/exec/cpu_ldst_useronly_template.h +++ b/include/exec/cpu_ldst_useronly_template.h @@ -78,9 +78,9 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, uintptr_t retaddr) { RES_TYPE ret; - helper_retaddr = retaddr; + set_helper_retaddr(retaddr); ret = glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(env, ptr); - helper_retaddr = 0; + clear_helper_retaddr(); return ret; } @@ -102,9 +102,9 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, uintptr_t retaddr) { int ret; - helper_retaddr = retaddr; + set_helper_retaddr(retaddr); ret = glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(env, ptr); - helper_retaddr = 0; + clear_helper_retaddr(); return ret; } #endif @@ -128,9 +128,9 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, RES_TYPE v, uintptr_t retaddr) { - helper_retaddr = retaddr; + set_helper_retaddr(retaddr); glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(env, ptr, v); - helper_retaddr = 0; + clear_helper_retaddr(); } #endif diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index cb5f4b19c5..4384b59a4d 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -134,7 +134,7 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info, * currently executing TB was modified and must be exited * immediately. Clear helper_retaddr for next execution. */ - helper_retaddr = 0; + clear_helper_retaddr(); cpu_exit_tb_from_sighandler(cpu, old_set); /* NORETURN */ @@ -152,7 +152,7 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info, * an exception. Undo signal and retaddr state prior to longjmp. */ sigprocmask(SIG_SETMASK, old_set, NULL); - helper_retaddr = 0; + clear_helper_retaddr(); cc = CPU_GET_CLASS(cpu); access_type = is_write ? MMU_DATA_STORE : MMU_DATA_LOAD; @@ -682,14 +682,15 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, if (unlikely(addr & (size - 1))) { cpu_loop_exit_atomic(env_cpu(env), retaddr); } - helper_retaddr = retaddr; - return g2h(addr); + void *ret = g2h(addr); + set_helper_retaddr(retaddr); + return ret; } /* Macro to call the above, with local variables from the use context. */ #define ATOMIC_MMU_DECLS do {} while (0) #define ATOMIC_MMU_LOOKUP atomic_mmu_lookup(env, addr, DATA_SIZE, GETPC()) -#define ATOMIC_MMU_CLEANUP do { helper_retaddr = 0; } while (0) +#define ATOMIC_MMU_CLEANUP do { clear_helper_retaddr(); } while (0) #define ATOMIC_NAME(X) HELPER(glue(glue(atomic_ ## X, SUFFIX), END)) #define EXTRA_ARGS diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 44e45a8037..060699b901 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -554,7 +554,7 @@ uint64_t HELPER(paired_cmpxchg64_le)(CPUARMState *env, uint64_t addr, /* ??? Enforce alignment. */ uint64_t *haddr = g2h(addr); - helper_retaddr = ra; + set_helper_retaddr(ra); o0 = ldq_le_p(haddr + 0); o1 = ldq_le_p(haddr + 1); oldv = int128_make128(o0, o1); @@ -564,7 +564,7 @@ uint64_t HELPER(paired_cmpxchg64_le)(CPUARMState *env, uint64_t addr, stq_le_p(haddr + 0, int128_getlo(newv)); stq_le_p(haddr + 1, int128_gethi(newv)); } - helper_retaddr = 0; + clear_helper_retaddr(); #else int mem_idx = cpu_mmu_index(env, false); TCGMemOpIdx oi0 = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); @@ -624,7 +624,7 @@ uint64_t HELPER(paired_cmpxchg64_be)(CPUARMState *env, uint64_t addr, /* ??? Enforce alignment. */ uint64_t *haddr = g2h(addr); - helper_retaddr = ra; + set_helper_retaddr(ra); o1 = ldq_be_p(haddr + 0); o0 = ldq_be_p(haddr + 1); oldv = int128_make128(o0, o1); @@ -634,7 +634,7 @@ uint64_t HELPER(paired_cmpxchg64_be)(CPUARMState *env, uint64_t addr, stq_be_p(haddr + 0, int128_gethi(newv)); stq_be_p(haddr + 1, int128_getlo(newv)); } - helper_retaddr = 0; + clear_helper_retaddr(); #else int mem_idx = cpu_mmu_index(env, false); TCGMemOpIdx oi0 = make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx); diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index fd434c66ea..fc0c1755d2 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -4125,12 +4125,11 @@ static intptr_t max_for_page(target_ulong base, intptr_t mem_off, return MIN(split, mem_max - mem_off) + mem_off; } -static inline void set_helper_retaddr(uintptr_t ra) -{ -#ifdef CONFIG_USER_ONLY - helper_retaddr = ra; +#ifndef CONFIG_USER_ONLY +/* These are normally defined only for CONFIG_USER_ONLY in */ +static inline void set_helper_retaddr(uintptr_t ra) { } +static inline void clear_helper_retaddr(void) { } #endif -} /* * The result of tlb_vaddr_to_host for user-only is just g2h(x), @@ -4188,7 +4187,7 @@ static void sve_ld1_r(CPUARMState *env, void *vg, const target_ulong addr, if (test_host_page(host)) { mem_off = host_fn(vd, vg, host - mem_off, mem_off, mem_max); tcg_debug_assert(mem_off == mem_max); - set_helper_retaddr(0); + clear_helper_retaddr(); /* After having taken any fault, zero leading inactive elements. */ swap_memzero(vd, reg_off); return; @@ -4239,7 +4238,7 @@ static void sve_ld1_r(CPUARMState *env, void *vg, const target_ulong addr, } #endif - set_helper_retaddr(0); + clear_helper_retaddr(); memcpy(vd, &scratch, reg_max); } @@ -4312,7 +4311,7 @@ static void sve_ld2_r(CPUARMState *env, void *vg, target_ulong addr, addr += 2 * size; } while (i & 15); } - set_helper_retaddr(0); + clear_helper_retaddr(); /* Wait until all exceptions have been raised to write back. */ memcpy(&env->vfp.zregs[rd], &scratch[0], oprsz); @@ -4341,7 +4340,7 @@ static void sve_ld3_r(CPUARMState *env, void *vg, target_ulong addr, addr += 3 * size; } while (i & 15); } - set_helper_retaddr(0); + clear_helper_retaddr(); /* Wait until all exceptions have been raised to write back. */ memcpy(&env->vfp.zregs[rd], &scratch[0], oprsz); @@ -4372,7 +4371,7 @@ static void sve_ld4_r(CPUARMState *env, void *vg, target_ulong addr, addr += 4 * size; } while (i & 15); } - set_helper_retaddr(0); + clear_helper_retaddr(); /* Wait until all exceptions have been raised to write back. */ memcpy(&env->vfp.zregs[rd], &scratch[0], oprsz); @@ -4494,7 +4493,7 @@ static void sve_ldff1_r(CPUARMState *env, void *vg, const target_ulong addr, if (test_host_page(host)) { mem_off = host_fn(vd, vg, host - mem_off, mem_off, mem_max); tcg_debug_assert(mem_off == mem_max); - set_helper_retaddr(0); + clear_helper_retaddr(); /* After any fault, zero any leading inactive elements. */ swap_memzero(vd, reg_off); return; @@ -4537,7 +4536,7 @@ static void sve_ldff1_r(CPUARMState *env, void *vg, const target_ulong addr, } #endif - set_helper_retaddr(0); + clear_helper_retaddr(); record_fault(env, reg_off, reg_max); } @@ -4740,7 +4739,7 @@ static void sve_st1_r(CPUARMState *env, void *vg, target_ulong addr, addr += msize; } while (i & 15); } - set_helper_retaddr(0); + clear_helper_retaddr(); } static void sve_st2_r(CPUARMState *env, void *vg, target_ulong addr, @@ -4766,7 +4765,7 @@ static void sve_st2_r(CPUARMState *env, void *vg, target_ulong addr, addr += 2 * msize; } while (i & 15); } - set_helper_retaddr(0); + clear_helper_retaddr(); } static void sve_st3_r(CPUARMState *env, void *vg, target_ulong addr, @@ -4794,7 +4793,7 @@ static void sve_st3_r(CPUARMState *env, void *vg, target_ulong addr, addr += 3 * msize; } while (i & 15); } - set_helper_retaddr(0); + clear_helper_retaddr(); } static void sve_st4_r(CPUARMState *env, void *vg, target_ulong addr, @@ -4824,7 +4823,7 @@ static void sve_st4_r(CPUARMState *env, void *vg, target_ulong addr, addr += 4 * msize; } while (i & 15); } - set_helper_retaddr(0); + clear_helper_retaddr(); } #define DO_STN_1(N, NAME, ESIZE) \ @@ -4932,7 +4931,7 @@ static void sve_ld1_zs(CPUARMState *env, void *vd, void *vg, void *vm, i += 4, pg >>= 4; } while (i & 15); } - set_helper_retaddr(0); + clear_helper_retaddr(); /* Wait until all exceptions have been raised to write back. */ memcpy(vd, &scratch, oprsz); @@ -4955,7 +4954,7 @@ static void sve_ld1_zd(CPUARMState *env, void *vd, void *vg, void *vm, tlb_fn(env, &scratch, i * 8, base + (off << scale), oi, ra); } } - set_helper_retaddr(0); + clear_helper_retaddr(); /* Wait until all exceptions have been raised to write back. */ memcpy(vd, &scratch, oprsz * 8); @@ -5133,7 +5132,7 @@ static inline void sve_ldff1_zs(CPUARMState *env, void *vd, void *vg, void *vm, tlb_fn(env, vd, reg_off, addr, oi, ra); /* The rest of the reads will be non-faulting. */ - set_helper_retaddr(0); + clear_helper_retaddr(); } /* After any fault, zero the leading predicated false elements. */ @@ -5175,7 +5174,7 @@ static inline void sve_ldff1_zd(CPUARMState *env, void *vd, void *vg, void *vm, tlb_fn(env, vd, reg_off, addr, oi, ra); /* The rest of the reads will be non-faulting. */ - set_helper_retaddr(0); + clear_helper_retaddr(); } /* After any fault, zero the leading predicated false elements. */ @@ -5299,7 +5298,7 @@ static void sve_st1_zs(CPUARMState *env, void *vd, void *vg, void *vm, i += 4, pg >>= 4; } while (i & 15); } - set_helper_retaddr(0); + clear_helper_retaddr(); } static void sve_st1_zd(CPUARMState *env, void *vd, void *vg, void *vm, @@ -5318,7 +5317,7 @@ static void sve_st1_zd(CPUARMState *env, void *vd, void *vg, void *vm, tlb_fn(env, vd, i * 8, base + (off << scale), oi, ra); } } - set_helper_retaddr(0); + clear_helper_retaddr(); } #define DO_ST1_ZPZ_S(MEM, OFS) \ From patchwork Sun Jul 14 11:12:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 168967 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3117559ilk; Sun, 14 Jul 2019 04:13:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/5wWl4YWeEXYOydd3CN6QyMgBaoXiB9NIRjPzi1VnozL42i6Gj9OgTKcWH93Fmf3d+qN/ X-Received: by 2002:a17:906:7d12:: with SMTP id u18mr15570228ejo.24.1563102802868; Sun, 14 Jul 2019 04:13:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563102802; cv=none; d=google.com; s=arc-20160816; b=iKH8rCg81Mi8aLrxX8URvdXs4nIbjoMyu7RVdDnHSNvhvHfzL05moxti0KRGVuQqQI igmmZuMQSfbViqHlOBkH6uYaE0BwTbDvdU3SW3fLdT+rwWGRQ3cIM6ZQTPCxXEIeYrYi SzqE0Drk67IHafbUAnNHg7IjsrkL/Z++wgZaTSAycHKf1JNoA6ZOj6EfVU4CaAPzrqm4 NcriA9PFxmr7TVkHMhpAWXDDhzc0sFKbiOi8Qo/TYG7hFPv7JcDejp5gH8bNW1b8olvl TGhMfcsFlRpqrYNioOdbxnaCijODO2oQ6PP58agT/WJ9rTjDTZP8Z2iPGvm9Maz4wFAI l7Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=+/eu9Ji8fYpnUOznN+zYDis1fLw1ZhoxMJAE0l0+5Bg=; b=qelgqo5GvfYFupuqtvMiw9FLVaC0w4r/YnnDudnt7WZC0ngIeI0oONVYzXddxutjUv EcTLiofZPJPsOyTxdPkMSUYJMJQtHs2xC+BYx8BU+FXc78i728B/xkUPp1cSuSXhufBh y/ih5l7Tex1jex9aBt6/iDAmU2ALcD2U3tq+7pDWtlsfnPkT+qbtZ1hr6TmiUz25B63W 40cvJ8f1Uwqi6oHc65YxXLiSRgqnOhGsXd1OGFmOVH/5lsYIKsdnosGDqPhykvxWrXjj VIw8vG45247NmmukUfufCx11b28rondgz4jBRoRnwAQ6MFq7XyxnC4LMY12Xp1whzunB ELGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UzJe8QRz; 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=fail (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 gg12si7460803ejb.225.2019.07.14.04.13.22 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 14 Jul 2019 04:13:22 -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=fail header.i=@linaro.org header.s=google header.b=UzJe8QRz; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmcRV-0005wu-3N for patch@linaro.org; Sun, 14 Jul 2019 07:13:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60356) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmcR8-0005i1-TS for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hmcR7-0006O7-Ta for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:58 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:44268) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hmcR7-0006Nb-Ng for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:57 -0400 Received: by mail-wr1-x444.google.com with SMTP id p17so14119413wrf.11 for ; Sun, 14 Jul 2019 04:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+/eu9Ji8fYpnUOznN+zYDis1fLw1ZhoxMJAE0l0+5Bg=; b=UzJe8QRzH+KGTW0P/KITp2+31soeoocQ45TSMRRDS0RgGkcdAsLjIm3aeznlBWzy0Y V6UrX59zeP+4BbAWmUIaJLJkGLeMrC+fmwr41Kq0BrqsZfg/rC8o8BTASHl1m76db6DO 3xp7ftmIoiZTjG5fkYtvsIhzzkUf1G3ekL8TV7v3s0Ht/awxhdPEnRxa8adW5HPTkkse GVwoxb/VcrbcJlcHVOHH7Dzk4acLKyjduKVfaoPYkBN1ubt/VdvwIgiBAW2llQV6gDW4 1vCVU5yQEAdr4guejcJS8kvB3OdF3B2N87RbbbYjtVC+xgZrq/U7oKcutKeLlHpxdTJi h16A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+/eu9Ji8fYpnUOznN+zYDis1fLw1ZhoxMJAE0l0+5Bg=; b=mmrGCzxDMgdjH6H6dGbHD5MiGYcwoXveGbAqxxml6wAzQxmFf5+nB+C/o+yrSOJyzJ 405JgV3yaAGKEJNAC9q69YMKBpC8Gr68FwAWwvFTFZ+meoxfK4z+d6cDVFZVqEC7m68z bd/eu1DbyrZ1apKxn9BXJegJxOSC/wLFSV/jzvxdqsnh+78wvjwBEdh0yyrxFxcKgvrT 3eaS2d06XlTjZ5yy4xm/WQCgNfplZh1imUQ9qEaPUsK1NzBjcTOdtrFpKk9M6sy9Mb42 loAkZq6YeUyAXlH+vPzQfFWwXTVcuc9K1AMLGVn46ljuAU3O2fj0ZjZ/rX4hNcxClhfn FdFw== X-Gm-Message-State: APjAAAVvLtijJr2MqEWcL1SFd7ZMZec6tA3YB2xHFAKWFDHeX5rs8eON VPg+oFXm9xY8Y/3qlUTICHgaPZKazai8Sw== X-Received: by 2002:adf:f088:: with SMTP id n8mr22737575wro.58.1563102776408; Sun, 14 Jul 2019 04:12:56 -0700 (PDT) Received: from localhost.localdomain ([194.144.248.241]) by smtp.gmail.com with ESMTPSA id f17sm12675795wmf.27.2019.07.14.04.12.55 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 14 Jul 2019 04:12:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 14 Jul 2019 11:12:47 +0000 Message-Id: <20190714111249.13859-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190714111249.13859-1-richard.henderson@linaro.org> References: <20190714111249.13859-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PULL for-4.1 5/7] tcg: Remove cpu_ld*_code_ra X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" These functions are not used, and are not usable in the context of code generation, because we never have a helper return address to pass in to them. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- include/exec/cpu_ldst_useronly_template.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h index e65733f7e2..8c7a2c6cd7 100644 --- a/include/exec/cpu_ldst_useronly_template.h +++ b/include/exec/cpu_ldst_useronly_template.h @@ -72,6 +72,7 @@ glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr) return glue(glue(ld, USUFFIX), _p)(g2h(ptr)); } +#ifndef CODE_ACCESS static inline RES_TYPE glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, abi_ptr ptr, @@ -83,6 +84,7 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, clear_helper_retaddr(); return ret; } +#endif #if DATA_SIZE <= 2 static inline int @@ -96,6 +98,7 @@ glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr) return glue(glue(lds, SUFFIX), _p)(g2h(ptr)); } +#ifndef CODE_ACCESS static inline int glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, abi_ptr ptr, @@ -107,7 +110,8 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, clear_helper_retaddr(); return ret; } -#endif +#endif /* CODE_ACCESS */ +#endif /* DATA_SIZE <= 2 */ #ifndef CODE_ACCESS static inline void From patchwork Sun Jul 14 11:12:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 168968 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3117905ilk; Sun, 14 Jul 2019 04:13:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrDg7tz29ZzmgMIhsS1wBp+kzbb1i+7893CKRPTpiXoXcxhdnM36EIok9db1O/9PnkVscR X-Received: by 2002:a50:9999:: with SMTP id m25mr18108961edb.183.1563102826651; Sun, 14 Jul 2019 04:13:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563102826; cv=none; d=google.com; s=arc-20160816; b=KoiRinQFdLv8UFDMJSpKquXFbo/e39G+1QF+KugXFmXPJdD98Ek7jKbFlXsJwSk06t myL95GGQUtEF1g9fdT7tO62Zn/M7V4LUa6L+56M4GT7VoCT8H/auD8HnUAWlLHqw8Qgq DNqsUJc4aaTH2Bfah/45tLB1ExSvpLmbb5zkqqFNj+FthFaTDq1gk00LlsteKmo8ed1o UIX0MjAFSfI0x+G4ASVUQKx03ezLiAIZoRhsK0dOWd0yQniwGalF//eqyq0FnMxVFDWG g0WsDKfuOVX2OMTdnrbI1IzIsDwtxHPwA3A9RzpTUF/a+J3OcgvyBXqiN8hfDMvi0SJf Idkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=sH3HXM90i35Znfmo2ZGAwhUVyrLtmUH4wH93sEFL2IQ=; b=FWmFW/Ycxco/6ANKxy1k/u0VDo5pU5d/GLBlarcbWC4GpxvKqHUJwYuu0lZSNUXiVE erS4em6luv1neG8xW2AL6PW0JQB4YhKivEp2FjzA2KX4XzgfkG2H5+RMcTOZSsZGooax bjgmqCHaiGPIb57MKujGX4hf6Dx7GWR6Jf5zcMmhU3qU7wTI6NEQOOGpIkoD8ERGNDWZ grZ6IEt6w8dbl9dBU/KDuhR2+z7mdI98r7pFOQGZ+1vhZqLZ0O4WI9d8BGqXtLea/LlO 0We/0Uy1SB5WlxZTOsjN8yalryME8GcKNqQE0AvS2nbHHRCDLSkg0cYd8+SiKk6K91Uc BoSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FNjk2n86; 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=fail (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 d36si8452575eda.396.2019.07.14.04.13.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 14 Jul 2019 04:13: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=fail header.i=@linaro.org header.s=google header.b=FNjk2n86; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmcRt-0000Gq-1x for patch@linaro.org; Sun, 14 Jul 2019 07:13:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60370) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmcR9-0005nQ-U2 for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:13:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hmcR8-0006OY-T2 for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:59 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:45923) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hmcR8-0006OC-N6 for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:58 -0400 Received: by mail-wr1-x42c.google.com with SMTP id f9so14098213wre.12 for ; Sun, 14 Jul 2019 04:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sH3HXM90i35Znfmo2ZGAwhUVyrLtmUH4wH93sEFL2IQ=; b=FNjk2n86XqOV+bcaFG3i2ym7stY8kbk3QuTSCTKFYAGFtzJ9OOCK6xJluyGrcmz3dp 8z8Pjo9NY9M5JVT5CDvtA5DnyuTm43b/4Ru6FBLGt+62jFbsmuFyCn1tvyF08Hy6py7W k+HuWlUuuFiXVbTn6InvKQfBb4schKihRliARlYCbNE3Sd4GRZDnBwuvhmd/eKf5C1dr OGHTjHOmlbMGtaA6101E/uateFO5i0bCfHfvAOBlwwvY4bPitqDVdlZTBm7r9iotyAGx SQQyki+zoSmiWaaW7wf9sVJ8QBWkLJHbvPtjrLg+bQzRoJkXkp/YphPpGW2ku3OkNC+V toeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sH3HXM90i35Znfmo2ZGAwhUVyrLtmUH4wH93sEFL2IQ=; b=dNr/3Uf1tx9E/JQpXfzQ0Y8sIdQ2nJdLBwAKcKFCW8JjwYbALprSvhUSFuop8asNEz XKKDcrRMyqTienDOffgDv69fm9vgQ7elATTXD79VOfYzYe+zYoj2yOgZIDTQ+Tk58Nmf h+hHVPUiSlfoNsiQImSd0sMumZwLwiTUXxlEUFrhN5PPS9OYFBqeXGK0ilwBg3PDX0x1 aZjc3QA2gK5tdLZJ1oMazLyJyDZf5OdAzhKfNLtJJKs1Fmyj4XWr0tZnqj9lmhb4Cc2P 67aLEnMyv80q/P5nbXTn4ngUrzV4d3ck9IxQZtyL1PfpATZqj6z0BfiX6g+Iu5WLye2s xwYw== X-Gm-Message-State: APjAAAUumxIZ9kBhK9WRYFKFVmg4XlPMfZkIMvB68vKJVteNDkdRX8Yb nUjKAlaTU79xNUn6ZXFxzCFEGAMqPLrMlw== X-Received: by 2002:adf:e602:: with SMTP id p2mr16142780wrm.306.1563102777433; Sun, 14 Jul 2019 04:12:57 -0700 (PDT) Received: from localhost.localdomain ([194.144.248.241]) by smtp.gmail.com with ESMTPSA id f17sm12675795wmf.27.2019.07.14.04.12.56 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 14 Jul 2019 04:12:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 14 Jul 2019 11:12:48 +0000 Message-Id: <20190714111249.13859-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190714111249.13859-1-richard.henderson@linaro.org> References: <20190714111249.13859-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42c Subject: [Qemu-devel] [PULL for-4.1 6/7] tcg: Remove duplicate #if !defined(CODE_ACCESS) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This code block is already surrounded by #ifndef CODE_ACCESS. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- include/exec/cpu_ldst_useronly_template.h | 2 -- 1 file changed, 2 deletions(-) -- 2.17.1 diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h index 8c7a2c6cd7..d663826ac2 100644 --- a/include/exec/cpu_ldst_useronly_template.h +++ b/include/exec/cpu_ldst_useronly_template.h @@ -118,11 +118,9 @@ static inline void glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr, RES_TYPE v) { -#if !defined(CODE_ACCESS) trace_guest_mem_before_exec( env_cpu(env), ptr, trace_mem_build_info(SHIFT, false, MO_TE, true)); -#endif glue(glue(st, SUFFIX), _p)(g2h(ptr), v); } From patchwork Sun Jul 14 11:12:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 168971 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3118527ilk; Sun, 14 Jul 2019 04:14:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKGqp7Lxw+ocqrKv9KTXB050Q1ZpZNgqukMCmWq74TnRjOFX6BFmB9xkUw1smHhlmUHEXT X-Received: by 2002:aa7:c554:: with SMTP id s20mr17517895edr.209.1563102860940; Sun, 14 Jul 2019 04:14:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563102860; cv=none; d=google.com; s=arc-20160816; b=ocwwK/37m82RLDU3V8LheoBSYzf9M0sCbsTzSnbiTkzmRXOrOm0F0KD6cTcyeaIBjr 7BamDLPXVZSVbmb9Z4oER6wDorJWUqswZ+cA8V3wG4aSulSo18SDg2zLAY+Eq9tGsopr fHB8ZG1NrdxpD0EWh6850MaFp1Ik8j2cQUS4W0U2OW+7G5Fa8Hp6in0baj+I0KyaFjhr DCwC0nb+PkZk+R6sE7zKJJLAJnOg4eyX4XUf5TpvDUSBkgnOWEBrinp0cbkrn5LgkpQW BZVS5gv9fqF0o0m1vYdCoZo292F9A43aRjV+hoxKcdv5jTv8DpmnuUtsUHbk7gQwjPLP JaIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=lrFuCc5Kh7yR4Plfx6C/M8vdRg/qQANiKVV3zv9IyqE=; b=KkJnO7Q+5QtnLyXFfcuTFf9iHluPAIB5C48mofa4IjHJ0XbspPDlQX1ryjlWvK17Ba KGiVHYakrtUISvMdvPM7Z0QKhRnIYVcjW+i6EuQ+Mk9kcqgT3HzIBk4aXAZRX0WonFwv /o5LoSvYqR1qDritHRFflbno37rVVb4DSmbp6tHmOC7z2Rlcz6j4dUcTQZUQu/1PKzdq 1DwftUcupJOLZC9sVqmUC+PnvfX7MtDT0vF2xBnMrrZyePHNWdI0jyngLGF1zwGNEVDT iA6FJgMKx5hpL+fm+KQy9wwMvu9yVXwTWlYbIWft0Dj/01U83fi8PBYkqFWSubR1k/0Q uBHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BLXCiQBr; 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=fail (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 p16si7718785ejr.358.2019.07.14.04.14.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 14 Jul 2019 04:14:20 -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=fail header.i=@linaro.org header.s=google header.b=BLXCiQBr; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmcSR-0002iY-UI for patch@linaro.org; Sun, 14 Jul 2019 07:14:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60397) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmcRB-0005tm-EM for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:13:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hmcR9-0006Oz-Sm for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:13:01 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:36565) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hmcR9-0006Oe-Kl for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:59 -0400 Received: by mail-wm1-x344.google.com with SMTP id g67so8393185wme.1 for ; Sun, 14 Jul 2019 04:12:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lrFuCc5Kh7yR4Plfx6C/M8vdRg/qQANiKVV3zv9IyqE=; b=BLXCiQBrVW0eEY3m+JSCMjwSUT4j+IPCcr6ebq8qdmiFVrSfrjsiN7lPU+y2JNKrLW NXgpGJPnakWBUXEdw4k8mVn74Ma3nwJAsolCv6j+4UU7FJV6zREW8Sci7Ys4AzuJbYWx 4zpk/Hmd2RiNBEWwVkIZN58fbGTbPpXR4PQng73mspke8KJoYBo+kQNBgSXwjdw6/emU +6ERd2i0gFUK5HwwADeq1ZpQI1UUjaaNBvlQBn49VimWRtGFwXJn+rl11tG3NQyQklEy qYhY8WUQHFl73tUH3jWH9dNtwHSDNMpy9m6iojyLRyuWuY3+ZA73PJ5pGIMidTqG/xN3 lgkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lrFuCc5Kh7yR4Plfx6C/M8vdRg/qQANiKVV3zv9IyqE=; b=V2qjmBay1SLUeeM8jlsnIJ+vyHtszgW5QO/zcNpWa488KOwfpOc00Uh0Ef30ZV/g7V fFh1jh+Vfy9xPV7tphBPmZxR+WsNiC6MnYB9G2owz0WU1fAlko+O/B/ts+iIUKO48PgB YfEcPVrazCjLfqOReIBdCJ2C/JD1ar03YBXW/kesF9NIUZM07yjVWX1IGOYSNavg5TXE 1KlR5s8Km4e6xeLbBtXmiWMXTrPVoWYhdXOwjNdFcP4+YHGy01j9MxSSqyY48+IOo308 DbqZQ4Qk56vfFmmrO7MZdFMrAOidu8U5steBjIjAJvPoWhmtlkGAX6/lws895u58x/wI XMNw== X-Gm-Message-State: APjAAAXxsr7Arlb/HD0iX6Vyag80JjoWZi5mjGU/uu0EF0dTqZIvHmJq eTO44ImMDI5U0cLxnRIcETdwrrQ3RiGGRA== X-Received: by 2002:a7b:c04f:: with SMTP id u15mr18828164wmc.106.1563102778326; Sun, 14 Jul 2019 04:12:58 -0700 (PDT) Received: from localhost.localdomain ([194.144.248.241]) by smtp.gmail.com with ESMTPSA id f17sm12675795wmf.27.2019.07.14.04.12.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 14 Jul 2019 04:12:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 14 Jul 2019 11:12:49 +0000 Message-Id: <20190714111249.13859-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190714111249.13859-1-richard.henderson@linaro.org> References: <20190714111249.13859-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PULL for-4.1 7/7] tcg: Release mmap_lock on translation fault X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Turn helper_retaddr into a multi-state flag that may now also indicate when we're performing a read on behalf of the translator. In this case, release the mmap_lock before the longjmp back to the main cpu loop, and thereby avoid a failing assert therein. Fixes: https://bugs.launchpad.net/qemu/+bug/1832353 Tested-by: Alex Bennée Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- include/exec/cpu_ldst_useronly_template.h | 20 +++++-- accel/tcg/user-exec.c | 66 ++++++++++++++++------- 2 files changed, 63 insertions(+), 23 deletions(-) -- 2.17.1 diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_ldst_useronly_template.h index d663826ac2..2378f2958c 100644 --- a/include/exec/cpu_ldst_useronly_template.h +++ b/include/exec/cpu_ldst_useronly_template.h @@ -64,12 +64,18 @@ static inline RES_TYPE glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr) { -#if !defined(CODE_ACCESS) +#ifdef CODE_ACCESS + RES_TYPE ret; + set_helper_retaddr(1); + ret = glue(glue(ld, USUFFIX), _p)(g2h(ptr)); + clear_helper_retaddr(); + return ret; +#else trace_guest_mem_before_exec( env_cpu(env), ptr, trace_mem_build_info(SHIFT, false, MO_TE, false)); -#endif return glue(glue(ld, USUFFIX), _p)(g2h(ptr)); +#endif } #ifndef CODE_ACCESS @@ -90,12 +96,18 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUArchState *env, static inline int glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr) { -#if !defined(CODE_ACCESS) +#ifdef CODE_ACCESS + int ret; + set_helper_retaddr(1); + ret = glue(glue(lds, SUFFIX), _p)(g2h(ptr)); + clear_helper_retaddr(); + return ret; +#else trace_guest_mem_before_exec( env_cpu(env), ptr, trace_mem_build_info(SHIFT, true, MO_TE, false)); -#endif return glue(glue(lds, SUFFIX), _p)(g2h(ptr)); +#endif } #ifndef CODE_ACCESS diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 4384b59a4d..897d1571c4 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -64,27 +64,56 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info, CPUState *cpu = current_cpu; CPUClass *cc; unsigned long address = (unsigned long)info->si_addr; - MMUAccessType access_type; + MMUAccessType access_type = is_write ? MMU_DATA_STORE : MMU_DATA_LOAD; - /* We must handle PC addresses from two different sources: - * a call return address and a signal frame address. - * - * Within cpu_restore_state_from_tb we assume the former and adjust - * the address by -GETPC_ADJ so that the address is within the call - * insn so that addr does not accidentally match the beginning of the - * next guest insn. - * - * However, when the PC comes from the signal frame, it points to - * the actual faulting host insn and not a call insn. Subtracting - * GETPC_ADJ in that case may accidentally match the previous guest insn. - * - * So for the later case, adjust forward to compensate for what - * will be done later by cpu_restore_state_from_tb. - */ - if (helper_retaddr) { + switch (helper_retaddr) { + default: + /* + * Fault during host memory operation within a helper function. + * The helper's host return address, saved here, gives us a + * pointer into the generated code that will unwind to the + * correct guest pc. + */ pc = helper_retaddr; - } else { + break; + + case 0: + /* + * Fault during host memory operation within generated code. + * (Or, a unrelated bug within qemu, but we can't tell from here). + * + * We take the host pc from the signal frame. However, we cannot + * use that value directly. Within cpu_restore_state_from_tb, we + * assume PC comes from GETPC(), as used by the helper functions, + * so we adjust the address by -GETPC_ADJ to form an address that + * is within the call insn, so that the address does not accidentially + * match the beginning of the next guest insn. However, when the + * pc comes from the signal frame it points to the actual faulting + * host memory insn and not the return from a call insn. + * + * Therefore, adjust to compensate for what will be done later + * by cpu_restore_state_from_tb. + */ pc += GETPC_ADJ; + break; + + case 1: + /* + * Fault during host read for translation, or loosely, "execution". + * + * The guest pc is already pointing to the start of the TB for which + * code is being generated. If the guest translator manages the + * page crossings correctly, this is exactly the correct address + * (and if the translator doesn't handle page boundaries correctly + * there's little we can do about that here). Therefore, do not + * trigger the unwinder. + * + * Like tb_gen_code, release the memory lock before cpu_loop_exit. + */ + pc = 0; + access_type = MMU_INST_FETCH; + mmap_unlock(); + break; } /* For synchronous signals we expect to be coming from the vCPU @@ -155,7 +184,6 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info, clear_helper_retaddr(); cc = CPU_GET_CLASS(cpu); - access_type = is_write ? MMU_DATA_STORE : MMU_DATA_LOAD; cc->tlb_fill(cpu, address, 0, access_type, MMU_USER_IDX, false, pc); g_assert_not_reached(); }