From patchwork Tue Jul 25 14:58:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 706146 Delivered-To: patch@linaro.org Received: by 2002:a5d:464f:0:b0:317:2194:b2bc with SMTP id j15csp232199wrs; Tue, 25 Jul 2023 07:59:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlG6MoEofsGIrqQDI2cI1Ck8tkBMKmnBT+xNCJ4yqrE5k11ZEwkpKIvWz2gHMOv+ZeZaYmlv X-Received: by 2002:a05:620a:84c:b0:767:26d:1142 with SMTP id u12-20020a05620a084c00b00767026d1142mr2703208qku.21.1690297145242; Tue, 25 Jul 2023 07:59:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690297145; cv=none; d=google.com; s=arc-20160816; b=Undncr8AJTf+ZZTx+lq5Te4LfxEpKd7m4Gixe3Zx5gCqnMXBJqhQx+zic0DzCoMv3a 9031vok0JAJsH7VW4JrdYkdH4JWgRjjnpk1uetEHXz5ccd3Vr4A7W3/dQIsHJncOi5i+ q62yv0cTqIM9CU/G4+tqPSt9FqGSeKikMxF3B9n5QctncoH3V9HwVwkmPampqMn9wILj GW4ZHiejiTsWS3SkrMKJHACzdHNHA8Tjyeu6Le4z1fW2hsSW3o2CFuPi7t9wKuELGhil YZlhU2wjcYRp+fx2yR6mCdnKDQt11gmBE997Apag0ogczAaDsbhJeI/vrxF+HwOmT4ml N2yQ== 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=DhnCXjeG6foMHO/pwqkkfiFKoYWFYE9Zpc0uinZfEBU=; fh=cAVbrfFkWvcwNzOBIuMOECe2+UysFbEcdySBEl/J6Ow=; b=H9ObnI7E+9yNEWC2O3/r1+oUyP11EkOCOigWdqfIePNkJc3908uGXYFeA318d4sjiY MA5UKmx8wmoE+/sWfxHRLOIeoHLz3JHvsEh1b1CIJMBW5akzTtflzXBwC1Nn/Z1Hk2RO 0s1S+8dYsk+iRo0CwulEP2B4wVt/DJJTmnRwzVxH5yaD20L2XD1wlo8GzwR4MOodFWah vnaoB/CY4aLZz40Bd2rTU4izxAiix6BeCg637BlHrPAIN4KbQY4y7fGgVixeb5xfNH+Q PSG0igS5GEo1HdKoHHIz6cCtmdzeKocEJd/NrRMFoUPMFl0bHoCfQS+GMzEYEKyKzTYd 5Vuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X8CpoZHE; 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-20020a05620a268300b00767580e4f12si6703732qkp.511.2023.07.25.07.59.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jul 2023 07:59:05 -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=X8CpoZHE; 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 1qOJUt-0002JA-9K; Tue, 25 Jul 2023 10:58:47 -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 1qOJUq-0002IW-8w for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:58:44 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qOJUn-00012c-Kz for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:58:43 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fbc5d5742bso56711415e9.2 for ; Tue, 25 Jul 2023 07:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690297118; x=1690901918; 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=DhnCXjeG6foMHO/pwqkkfiFKoYWFYE9Zpc0uinZfEBU=; b=X8CpoZHEgq8X7n4mbuvPTxbx+hEWD2MPr0eMSt1Jkh8ud9vftH2e5E+2EN3Fg5NqbG odzZQNX7RW8BqGlx2bMJ7n6Es58Nadm10YmM3cKOZUF1wNxOEU6Y7IYd85MNrS8m/LNj Iv5Yl+gLXUINn+wX0uq0sBHYskKG/ZqcRHfd8bmWtw/pKxcVmOWZZzDV6c7uqHrhVRPP Ra8/mT61QspqTDPSfPrPsD9QMlsRWKqt7MNvH0AVMH6jJ5SYuLwx978VR51pn0AJfeob sBZ0pVRqP/8t4EUeq8UisCAIbIq7xBEEu5FCvtHZl/qU8iNHKrdeExOP4Mbzvh2nfGBi uDNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690297118; x=1690901918; 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=DhnCXjeG6foMHO/pwqkkfiFKoYWFYE9Zpc0uinZfEBU=; b=QIWIUZXmAp2sLgTsnnxQGHPYI8IZ+D5MYyYJjTvkRsMuXL/c7O+6BqPnjPcc/V3Ffe JqeGz+bGSruxePryET0nm05w/QQZosbeI76qpBBnuJu7cFzHCK0cVRFvD/phRyzdavT0 AAgmAnO1rImxxnbCznbF+jYgCnF2NaslCPjVGSjm7XgDd3ehpnZd1f0FWp7SPY6sk0H2 SzRSzAXrzwYVlqhayQDKRlzIqN2XESML0Wtr1hPf5kDaUHVV5k24GIj1LOpzeb7UFN6Q La1Wc7woLwhV6tpJwRAUI3Zqbnbhr5KE9Ge8GwKojIqQPnFaq9gcfSPnh/dzb/2h5GD+ Vp6g== X-Gm-Message-State: ABy/qLYB5PHjCd6quQe18cmQxLXBbRYpiZhYkMEdD4M4nLIDKYx5oOi0 kkDoG7nN3aWnoY8OLKQWxti9zZWrqQQaGHmkieI= X-Received: by 2002:a05:600c:40c:b0:3fb:dd9c:72d2 with SMTP id q12-20020a05600c040c00b003fbdd9c72d2mr10615707wmb.31.1690297117837; Tue, 25 Jul 2023 07:58:37 -0700 (PDT) Received: from localhost.localdomain ([176.187.203.142]) by smtp.gmail.com with ESMTPSA id u6-20020a05600c00c600b003fbdd9c72aasm13264194wmm.21.2023.07.25.07.58.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Jul 2023 07:58:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , qemu-block@nongnu.org, Bernhard Beschow , Guenter Roeck Subject: [PULL 01/10] hw/sd/sdhci: Do not force sdhci_mmio_*_ops onto all SD controllers Date: Tue, 25 Jul 2023 16:58:20 +0200 Message-Id: <20230725145829.37782-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230725145829.37782-1-philmd@linaro.org> References: <20230725145829.37782-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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: Bernhard Beschow Since commit c0a55a0c9da2 "hw/sd/sdhci: Support big endian SD host controller interfaces" sdhci_common_realize() forces all SD card controllers to use either sdhci_mmio_le_ops or sdhci_mmio_be_ops, depending on the "endianness" property. However, there are device models which use different MMIO ops: TYPE_IMX_USDHC uses usdhc_mmio_ops and TYPE_S3C_SDHCI uses sdhci_s3c_mmio_ops. Forcing sdhci_mmio_le_ops breaks SD card handling on the "sabrelite" board, for example. Fix this by defaulting the io_ops to little endian and switch to big endian in sdhci_common_realize() only if there is a matchig big endian variant available. Fixes: c0a55a0c9da2 ("hw/sd/sdhci: Support big endian SD host controller interfaces") Signed-off-by: Bernhard Beschow Tested-by: Guenter Roeck Message-Id: <20230709080950.92489-1-shentey@gmail.com> --- hw/sd/sdhci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 6811f0f1a8..362c2c86aa 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -1382,6 +1382,8 @@ void sdhci_initfn(SDHCIState *s) s->insert_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sdhci_raise_insertion_irq, s); s->transfer_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sdhci_data_transfer, s); + + s->io_ops = &sdhci_mmio_le_ops; } void sdhci_uninitfn(SDHCIState *s) @@ -1399,9 +1401,13 @@ void sdhci_common_realize(SDHCIState *s, Error **errp) switch (s->endianness) { case DEVICE_LITTLE_ENDIAN: - s->io_ops = &sdhci_mmio_le_ops; + /* s->io_ops is little endian by default */ break; case DEVICE_BIG_ENDIAN: + if (s->io_ops != &sdhci_mmio_le_ops) { + error_setg(errp, "SD controller doesn't support big endianness"); + return; + } s->io_ops = &sdhci_mmio_be_ops; break; default: From patchwork Tue Jul 25 14:58:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 706144 Delivered-To: patch@linaro.org Received: by 2002:a5d:464f:0:b0:317:2194:b2bc with SMTP id j15csp232145wrs; Tue, 25 Jul 2023 07:58:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlF+TYH3iYwOGXITltMoK3uh5CWXLqfywNTl1o/AioDj6GPTVmbCrdENgW59gMoC8tLUziWI X-Received: by 2002:a05:620a:19aa:b0:765:a84f:7860 with SMTP id bm42-20020a05620a19aa00b00765a84f7860mr3229046qkb.34.1690297137674; Tue, 25 Jul 2023 07:58:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690297137; cv=none; d=google.com; s=arc-20160816; b=Ke2Af+SyOP5E166I6KP+gfamnWfz7g+Nzrpm0mrsrgtMvfQFUDKRVbRw7a5h8WBRW1 JM2YdOO2lSo6jnGWbgao9nISUOSRXy5eYzP/vuHMh0l9Ip/ScBC3/x3yGycaafnN3cXf k+3n1BSk8mou7z19mlwoeolTlzWD3J3SXFkvTwkDeIBM36DG6bjuUbXmUhrLM1lm/xVj NIgsY+6nsbLbjj8gPLFle6Y8VVjzGmb4+7tNa5BawfZR+ytsx3RFToH4QpcrqmS5KORV LnKLqt9QDADTlBpWTGRu2rDC1j/BaPCz0FG7HvMEAAedp+7HdPyPlVmRcvO1RtKrIX8q +o1A== 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=7Kl1/XJm+nsk8XiPEGJ2hmrVRAWR21KAyzVWiw2Ygbs=; fh=gpyhyxzFDYK4uDfrBx8pBc6xFbhZ9o0/T0jlrJPRJiE=; b=MTqlZ8qFEgrSLvXMoNLwxcUSwN836fjZLl3n31MdN907c7jW5yMzCAUeRWTRtfYmrm gsW6mNFsADGu9CuHy0hiUXwhtEYM9MDN/74P+T5tvVbzK3YP8CjvtfV6yEnBeF3UwSpo IvB4pIN27jdFGFS8w4GnF2OgnISlIZYJgCoH/eOt4UES+msnZ40oJSgkNisdQ8cnaFAg OZ542yi1QkljmhhEcFeFKz9ar/sq++TaIikhodLGojKyHOc67BEX9Ak8WfnmIQ7i9Tyz 6ol/XBxP7G/GQ4e+gIDBQxXRURpTxA3iurciqaUUOMhT+gLkECS1D02uhN46DGTvX1JG fcMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gOqlZKkF; 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 rj12-20020a05620a8fcc00b007674cb2312asi6453708qkn.769.2023.07.25.07.58.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jul 2023 07:58:57 -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=gOqlZKkF; 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 1qOJUu-0002Ji-JT; Tue, 25 Jul 2023 10:58:48 -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 1qOJUt-0002J6-4P for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:58:47 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450: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 1qOJUr-00013Z-LR for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:58:46 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3176a439606so888610f8f.3 for ; Tue, 25 Jul 2023 07:58:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690297123; x=1690901923; 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=7Kl1/XJm+nsk8XiPEGJ2hmrVRAWR21KAyzVWiw2Ygbs=; b=gOqlZKkFqdsig6Y8OXGnU/MheahSVybUX2RU1lfwAtCk7d4/yWV//O0a/U6Q90sSal iYS8q6rgehP+F+I9xyE5+G5mP9+wcoeVH+r/Qqw2rkR9t3FzkdUNFviYbWpNXjbE6RS5 J+AZsRbiR8eYcWx+ENWqUpjgM0NhHl168JOO7m7LVCNDPUTHs3xJD9KG1AftRdxBACQd TEdl87mC8aTrUGHb9Axioc1NLCS91g3S/Xg9F1+BFSURmR+14zBrAKFaUjSmFxzANJjm mT1Ivwd6q4a3L8uQ1pB+qeTob+Arg/pkCCt2bbh0Ot/0LaS1BJTX00ce9iILsfgm+8UW a39g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690297123; x=1690901923; 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=7Kl1/XJm+nsk8XiPEGJ2hmrVRAWR21KAyzVWiw2Ygbs=; b=IoFACSWE3fdcBFIVATI6LWg1x/GXb7tYnv05MQtGjZn6tTS/gojx7zpJ5E86RqpC6d GKCzf6AvGyz8j00bbYtsNbqZfhaEuzfV2VWD1TeZIhlwmh/EyXhHllpdvP1vZeRaNoT+ psqITVxTkoB5p0NXy2g6ZpmUdOxMdJPFpIg8nvOE06HisqPiwbER9HN6virjcgXhvZ7m iKtx6D1kMd3nLXLYWMYoO06dah0Qe8gnlEhiL5aY4E7Uz7mb3141hKF81Evq4JSeea78 CRn/M187+IWiqm9vPgLAbKmbA2b/E7RGSDF00JhFbxPaVcIJtNSFQJJvGylDZtLN7Ms5 iHaQ== X-Gm-Message-State: ABy/qLa0/+zyXiCZ7PBmPgdFXvOz9Gmp+dyImIPRlirens2OLG+FtOli G8gWY0tndAn4wMQqHpK8gyhMJ3Ppk4YffSm9ZRk= X-Received: by 2002:a5d:68ce:0:b0:311:3fdc:109d with SMTP id p14-20020a5d68ce000000b003113fdc109dmr8233456wrw.1.1690297123801; Tue, 25 Jul 2023 07:58:43 -0700 (PDT) Received: from localhost.localdomain ([176.187.203.142]) by smtp.gmail.com with ESMTPSA id j9-20020a5d4529000000b0030fd03e3d25sm16615358wra.75.2023.07.25.07.58.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Jul 2023 07:58:43 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , qemu-block@nongnu.org, Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 02/10] hw/mips: Improve the default USB settings in the loongson3-virt machine Date: Tue, 25 Jul 2023 16:58:21 +0200 Message-Id: <20230725145829.37782-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230725145829.37782-1-philmd@linaro.org> References: <20230725145829.37782-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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: Thomas Huth It's possible to compile QEMU without the USB devices (e.g. when using "--without-default-devices" as option for the "configure" script). To be still able to run the loongson3-virt machine in default mode with such a QEMU binary, we have to check here for the availability of the OHCI controller first before instantiating the USB devices. Signed-off-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230714104903.284845-1-thuth@redhat.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/mips/loongson3_virt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c index 4018b8c1d3..3ad0a223df 100644 --- a/hw/mips/loongson3_virt.c +++ b/hw/mips/loongson3_virt.c @@ -447,7 +447,7 @@ static inline void loongson3_virt_devices_init(MachineState *machine, pci_vga_init(pci_bus); - if (defaults_enabled()) { + if (defaults_enabled() && object_class_by_name("pci-ohci")) { pci_create_simple(pci_bus, -1, "pci-ohci"); usb_create_simple(usb_bus_find(-1), "usb-kbd"); usb_create_simple(usb_bus_find(-1), "usb-tablet"); From patchwork Tue Jul 25 14:58:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 706145 Delivered-To: patch@linaro.org Received: by 2002:a5d:464f:0:b0:317:2194:b2bc with SMTP id j15csp232168wrs; Tue, 25 Jul 2023 07:59:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlG+uIl8cFK7uD5YFaiEZjW1aHhSXemzVzTLtkFH3RX3gCniTF39Rfuqtq8RzVijP7QDjIcO X-Received: by 2002:a05:622a:1447:b0:406:9532:55ab with SMTP id v7-20020a05622a144700b00406953255abmr3093173qtx.42.1690297141501; Tue, 25 Jul 2023 07:59:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690297141; cv=none; d=google.com; s=arc-20160816; b=L78d1FJKBttDMWZBv5Ev1JxD+ZOP0iSJ5y3AuXpK51+1WwIVOV3DPmHb+7gK9anNHn uEHXrmfBB99yt/wXLPjJ8gqWYSnrh0wisNsZfQshH3UXVxDGs5bZOPl6196y/1htgyv9 5TTJ4Z0G7kKkfGcoYzqxB0n3Aq0ECKc6DrxhWqsO3sOU79PCYIwaQyleNcc9YaaZvQS0 wW5sIyvfsBD7JlGZSmiRlj7tdeMQuur0dshS5wI56ngQLwf/hWbPER15qrSGuL5i9jnI F11gIyzxQapSaTWNnrpsyRDUFz8SULzjbfs12nPMnNe9Zuq9DaM5lTyNguDnpO4tSv+s io0Q== 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=s4i7zxWBFbwawN5hoH2WbNEPh79dMjPmIuyC9TUA1JY=; fh=Xi7/snscDoB0Hr+3dWviD7jG1jzi7qlbQpNfWsDXgHM=; b=c7XdS4xVw0rzq1ciJ17ouO1AFbZ+0M3Bg2VP4aZdI/+Nfi6P9ghH1ARJuKmTmoBHRm uMCGUTqWjRCl3NboJChDC3poc2P63QFniloqAjFORPSmQfOhnRWgC6sk3qBYNdLzB6M2 hB7LjxAl0TQ9smDYdEFUa6Vk+HJvaHPxY6bsjJ4ZzEn42j6XgZ5D0KBWm7nEEOCUgRRs FyAmyFyDi3tn9Xi2W0C1frNM03EP5EsB317wowGH2DglPkjqhRo/vtP+i5m0vgcbp+T+ D4F9qVenSZDWi1APZsrF4DEHANjvjDW6Oa8YEwnvBkTDHJtm5M5L3t5z/r68M21bDUXy VBnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WiQqv8hJ; 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 y6-20020a05622a164600b0040546ea0f80si6384920qtj.367.2023.07.25.07.59.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jul 2023 07:59:01 -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=WiQqv8hJ; 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 1qOJV0-0002Ot-Sx; Tue, 25 Jul 2023 10:58:54 -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 1qOJUz-0002Ns-3U for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:58:53 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qOJUw-00018A-Ni for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:58:51 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fbc63c2e84so56767785e9.3 for ; Tue, 25 Jul 2023 07:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690297129; x=1690901929; 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=s4i7zxWBFbwawN5hoH2WbNEPh79dMjPmIuyC9TUA1JY=; b=WiQqv8hJyi5mTdrFxdItBf6EP6yakFcGpCeLGwfToTsBSqIgfXkN9CUv172FDVUpD5 WIbcnuX6x4kuC3kRzBU/US8d6zPVwprnsopR6xJBSxV/B4Z0f/vZGC+iIfuc2N8En/ME vvy2srS1dmLwM7jrEqUc8aOxk5pfLlro+owIvwq9bAvQSn5JlTE+5JMSB9Je5aZwregr O0s3z2lCp/Rru+niPG1dI/LMxp1o0tMFVyGHd0qfE4ARjEi3Aa+OCo8n6Fk/8NdW3hTe x4K2DWHKbEfOAZcUwZo8YWtd9VDL66ZQ5tgl0AGp9ywqBQPwd+dsuZ4zC0qVwng3JlEN eYng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690297129; x=1690901929; 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=s4i7zxWBFbwawN5hoH2WbNEPh79dMjPmIuyC9TUA1JY=; b=RPqkfQm1Q726tMPSll7brhNhlRbpkaMwdhp6O21JqmzwXk186GAOWuPa0BO18uBTJ6 2sg7/pFjxuukTGvIoYZRfTLBJprdR61wMc61XLXyXNQLhevFuXN1BSMdLXvR063i+3rb +zFqQXveKL1sPeeJiNGuHggWQ0JqROpnpRWUIuOH2XNH+QywU5zSuJ6P9C6ZYptn133a dsETte1AtRzCXUS88usl7a03++RH4u/tFH7iifsPl2vPiIx2LndLMru0TnDqFwbiyNGe 19W9k6RKAJIQ9DZOR8Z+A6eQQVWmDI137JtxFkAexWx197zMgdTHiZg2BMSLc3bHOAVs fQEw== X-Gm-Message-State: ABy/qLYMV7dzsLL4Gdiu97hiuRlbDtZxg9XiusMwcPsWKDcIAPTbTHy6 WQ7x2fOJ2bnv2B9MHy8t/+2I4Vimn9Z7J1VXMPM= X-Received: by 2002:adf:f092:0:b0:317:5ece:e16a with SMTP id n18-20020adff092000000b003175ecee16amr4969070wro.50.1690297129252; Tue, 25 Jul 2023 07:58:49 -0700 (PDT) Received: from localhost.localdomain ([176.187.203.142]) by smtp.gmail.com with ESMTPSA id d1-20020a5d6441000000b00317643a93f4sm5219042wrw.96.2023.07.25.07.58.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Jul 2023 07:58:48 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , qemu-block@nongnu.org, Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 03/10] hw/char/escc: Implement loopback mode Date: Tue, 25 Jul 2023 16:58:22 +0200 Message-Id: <20230725145829.37782-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230725145829.37782-1-philmd@linaro.org> References: <20230725145829.37782-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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: Thomas Huth The firmware of the m68k next-cube machine uses the loopback mode for self-testing the hardware and currently fails during this step. By implementing the loopback mode, we can make the firmware pass to the next step. Signed-off-by: Thomas Huth Reviewed-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230716153519.31722-1-huth@tuxfamily.org> --- hw/char/escc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/char/escc.c b/hw/char/escc.c index 4f3872bfe9..4be66053c1 100644 --- a/hw/char/escc.c +++ b/hw/char/escc.c @@ -653,7 +653,9 @@ static void escc_mem_write(void *opaque, hwaddr addr, escc_update_irq(s); s->tx = val; if (s->wregs[W_TXCTRL2] & TXCTRL2_TXEN) { /* tx enabled */ - if (qemu_chr_fe_backend_connected(&s->chr)) { + if (s->wregs[W_MISC2] & MISC2_LCL_LOOP) { + serial_receive_byte(s, s->tx); + } else if (qemu_chr_fe_backend_connected(&s->chr)) { /* * XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks From patchwork Tue Jul 25 14:58:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 706148 Delivered-To: patch@linaro.org Received: by 2002:a5d:464f:0:b0:317:2194:b2bc with SMTP id j15csp232383wrs; Tue, 25 Jul 2023 07:59:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlH8f04fZpQaZkFnt1ExdzljleavQ1B6aEwdVdxK+O72LYmRRwiUvMMOAWrNb12ZvTH81KUd X-Received: by 2002:a05:620a:f0f:b0:768:1394:45e5 with SMTP id v15-20020a05620a0f0f00b00768139445e5mr3066783qkl.12.1690297166958; Tue, 25 Jul 2023 07:59:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690297166; cv=none; d=google.com; s=arc-20160816; b=Hqzifjv7K2URUyehqrlUoQ4KoqwXo09fGle3CgiyX2FGnWuglgRocXoV6JlSkE7VHL WjvYiMI8KQKl57GD6yryc67w7bpJU9FiPmmjYLfF6ofi50zsrmD/Iy5y863YqiJ5Xmno CPvXqhfpiK/+j7sLWwuwgwsp0r1oFgT+xmT3bxiRcTjoVzld/99uiUHTU4DR+cEMe7io ZXSHOsVLtn4YSZsLxvmHzk8fbxF1DBNCobQkfh+c3SiG14Vt/vaxt2bUSF2CjnLJTPGl AaakOJNAMd7i/SFqv/FqYd4ZAw0FwzvFFGtAuxfbmcvP9BBhOlv2XF1DRub2gwzIKENu H5gg== 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=3kaAuYnsnnMWtTSiYZvwlvHyAf+VE1JNjcN8fmFo6ns=; fh=LuuFZBQYVL40+QyI1x9zvzj8G0F/ihI4h4jmUPqNsOc=; b=IXpf53urU3Khl0hsCCCLqD3IoPwJGPhgeBOm8ye39UUKW3zmEp231YrWEXwbstHP3P x5qPFfe9RgaVn9jfk8reDuXM6sL3D7ConreFqz7lETxw2TZorqoh6j19TX7bGglFZ0hU bLc/kh6cluje6uUSNAzqMwKlzwCwEi+SEcSrhBQXbKTy+2rBtN9FPvupcUexV2QBBeRv cS15mb8N1Mj4t3kD3oGa+NGcZOx5uW5kLbPzTjgi5IZAlX6MkNcE1n7RGVAZjy5v0JzO JsrHPoLbe45n68iF9rNbldLOBDIcx8RJ7yThu06tW9qQigkCUNsl66g5LNjewJJ3BSIx a9Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AFM4mtYd; 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 v3-20020a05620a440300b007673e688d91si6527594qkp.237.2023.07.25.07.59.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jul 2023 07:59:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AFM4mtYd; 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 1qOJV5-0002Xb-Lz; Tue, 25 Jul 2023 10:58:59 -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 1qOJV4-0002Sx-Jd for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:58:58 -0400 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qOJV3-0001AA-2Q for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:58:58 -0400 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2b93fba1f62so81524491fa.1 for ; Tue, 25 Jul 2023 07:58:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690297135; x=1690901935; 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=3kaAuYnsnnMWtTSiYZvwlvHyAf+VE1JNjcN8fmFo6ns=; b=AFM4mtYd7EGukXFTJv1Uis88MT/Ui7yMn7/8Pmpm7xJ149rk7fKyiQJOyWEOcBzcqe xDOvgmjMr/YvRNnTQc7PWLzDV+ZCrscitBflofwfafIAHWI4fcZXMfmLHaOqwe+ZJZVA HxH0JD0Neo3TBohPC7IEgIkjTxZa5kMyfLA9FDG6xDfdvbTFvRjgnn4C1I3mNFdLAjo7 Z3YjWdGqo78QplyFf4ViWhrbCkyTEEydv90y1PFFwvawO4+OmQprTsgmECc02HaCXzGS 6N5Aw9VNeYQeV/8x27ldo4IKGEPdvQ9N/iU+0XAspsOhXfQg5xikZjWxzfOuynZzj3cT Jesg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690297135; x=1690901935; 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=3kaAuYnsnnMWtTSiYZvwlvHyAf+VE1JNjcN8fmFo6ns=; b=XPpEQPie/PdcsT7hD416ctbItILEcNC8O4+RwDlgpok0tz71/qM6K7n2MPg4yFTUT7 BF4WbK8A3v8Rc1vNGlSNIVj/onvlI2HR8CUZcO7wWBplMCCgICtnYFgo/tL/WHOo3ERS aQKKvGTRLPPfziq6q+maJieOCF8zonZLIx0gOqlJzpq17ZgcDZckz44tFJu+2o+OsvPZ 7lZYCdfHIc70tJhx3vCmdm9lBzpXyQROPjg3RQwicg4Dg4k39FfZcQducorDNH3XsuF7 zn1PKP5yw9UDCyShxl+D1W/O5TMqEoutnekZLPSQKngUNUjz3Ymjvh4Sia6kbC11PalD 5XWA== X-Gm-Message-State: ABy/qLY/7Fn+qlMbiUB0FQMLcwqHg/Js8FpQu6Chd+cux2xdvN2f0n/g SWnAJfVp6ngWJm83LacrmonH9BZ5lFa4TD0Wk6k= X-Received: by 2002:a2e:7312:0:b0:2b8:377a:22f1 with SMTP id o18-20020a2e7312000000b002b8377a22f1mr9005520ljc.32.1690297134970; Tue, 25 Jul 2023 07:58:54 -0700 (PDT) Received: from localhost.localdomain ([176.187.203.142]) by smtp.gmail.com with ESMTPSA id z5-20020a7bc7c5000000b003fbe4cecc3bsm16245610wmk.16.2023.07.25.07.58.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Jul 2023 07:58:54 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 04/10] target/mips/mxu: Replace magic array size by its definition Date: Tue, 25 Jul 2023 16:58:23 +0200 Message-Id: <20230725145829.37782-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230725145829.37782-1-philmd@linaro.org> References: <20230725145829.37782-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22d; envelope-from=philmd@linaro.org; helo=mail-lj1-x22d.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20230712060806.82323-2-philmd@linaro.org> --- target/mips/tcg/mxu_translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index deb8060a17..b007948a73 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -609,7 +609,7 @@ enum { static TCGv mxu_gpr[NUMBER_OF_MXU_REGISTERS - 1]; static TCGv mxu_CR; -static const char mxuregnames[][4] = { +static const char mxuregnames[NUMBER_OF_MXU_REGISTERS][4] = { "XR1", "XR2", "XR3", "XR4", "XR5", "XR6", "XR7", "XR8", "XR9", "XR10", "XR11", "XR12", "XR13", "XR14", "XR15", "XCR", }; From patchwork Tue Jul 25 14:58:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 706147 Delivered-To: patch@linaro.org Received: by 2002:a5d:464f:0:b0:317:2194:b2bc with SMTP id j15csp232353wrs; Tue, 25 Jul 2023 07:59:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlHx3yFtYt2G+GlfKEGCud4ftaiq+O+BkkoYL2EgO13qCIpm47bDH3wZy8ov10EFglLoKy7v X-Received: by 2002:a05:6214:5d0:b0:63c:c5fe:d634 with SMTP id t16-20020a05621405d000b0063cc5fed634mr2853773qvz.12.1690297162839; Tue, 25 Jul 2023 07:59:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690297162; cv=none; d=google.com; s=arc-20160816; b=qQXaDIEB81oo1mPP2556kN37FrJbAl4PeBPHecP9j5SeP6tSWLW5D1WAAL9cQcOa0X kWlnqHOYZQPoEKUN17BeIKp6gzyzxqWxExqlAKnesvmXvd2EoRyDiSDHeFcNiA/c64AN Cj1CnkfGXEJPPw/KVOYvty+n4apWnjAfkAxLtpZyTQFavJD5Qm6Zqb+j4FjQhu5r0hPj 0yNikfsSKE7o7pNQJrZT3KHr98UyuqjNNVmSywCx3n1sqGYHjSPZNdfQlr8fpCh1tLoU aycVK5NggusAfIzGBfTrRRR1gwaJ/wbtlj1wFxeHg1XOx0GvzH8we43zXi/fEAoQtGdd MdvQ== 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=kPH7ythNpojxEEqzURXeFxVEUkiCc46BFyGsLCbiaqo=; fh=LuuFZBQYVL40+QyI1x9zvzj8G0F/ihI4h4jmUPqNsOc=; b=BwoVIwtX7j0IHey/hYErHoAOK898ikWA2zxlwjXA+IXltiJ4qR+JLDKZFwqGkt46Vo 393pHQIQtk6jkc9OR70tYq1acSpk5MQO9Xy41z1YdvRHG5BUSecBvDpe7I8f8+CdryB5 8SB0UxacipmlPzUXgaTCNSCoi9JSMSQiBJcfzYcsEn4pnfYrHZVlOneBHLSvPsopXsRz kPQqHI3JPejPaJi9YV+o237ioWpfyZPJ6P7Cw9aJPvwXnsWAFWjRgTSXPbZoTjIxzt46 fpVmBd2EB1abay6Tev/x6iZmZMmQW2c+Lc/Rqt5DTGv3Nnc+zNhUXyjuo5UH85YASLfD c1sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KYfsELiA; 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 v3-20020a05622a014300b00403a6629564si6743460qtw.538.2023.07.25.07.59.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jul 2023 07:59: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=pass header.i=@linaro.org header.s=google header.b=KYfsELiA; 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 1qOJVB-0002wM-FH; Tue, 25 Jul 2023 10:59:05 -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 1qOJV9-0002sE-N3 for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:59:03 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qOJV8-0001BW-6W for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:59:03 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-31297125334so3671920f8f.0 for ; Tue, 25 Jul 2023 07:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690297140; x=1690901940; 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=kPH7ythNpojxEEqzURXeFxVEUkiCc46BFyGsLCbiaqo=; b=KYfsELiAwrTyUqIo8zERZv2OdU9ogs7+kAJWnJYxc7hf3Gj4v3cAkX3oMlQWhuwLyR Sg9u2gQiLc6ECHQtwJDj4ZuwaEIU0Jw0e04iEzblsN1ohnzh3119cwC+O4R0RcHmcF7S HX4Py4vUDBXET3gsp2Q5mwW0CkGGP4xkr/1kiAVbl5PjK9w93/aOQouRQHkoZCaPz8mu wWkH4IyqqOE8Tz7YxRJepmHAJ/08enuiocM6+SaX5Gebc7v5VHI81oUxFZNpX/BI4F4O a/JleMFwEPqPz+xfItmmvk/oRGMrlVAHVGvaBq2Ch+jPCMFcAYrBNLt5j5WV3rU2ZMhk Zqng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690297140; x=1690901940; 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=kPH7ythNpojxEEqzURXeFxVEUkiCc46BFyGsLCbiaqo=; b=IaxtOik8JDOriA1exqiD1DwKVOe4RptXhkeR+DLuQbsnYxY+9lql8j763F92wSFxaq 00aqRiU+i2XwxkjVeuTvnhIyWVxxXJOS9aiIgrOlpqaqS+1FGRSJQpWw+pjDvmlZzewp tkrDJ1KiXLXI+JmdzOnSL+ovU3drs+hklHGoLYfLGtfnTJApLF+Pr/tXxhOjoesgJc74 ZcQjOB4CPqEkr6h8Ka/aB4dy0fbiX916qT2JNT4tINGj+XEYitkvPXSeJ4tpbCJ1737z oHVzpkCeUSEkceUiQn8qSRctBAmq6q2gSkoIZKfGiyh2cryMs13eXKmlW8ZtVRutdsfv esyw== X-Gm-Message-State: ABy/qLYQBAeuddM04P48FvQlcV02uFymavhQVveDtXnVHvm201VwhaMx HK7vYElTiZjVJuwhgCfKFRzYKZ/YxaxT6mCEflE= X-Received: by 2002:a5d:69cd:0:b0:315:7f1d:7790 with SMTP id s13-20020a5d69cd000000b003157f1d7790mr2097576wrw.6.1690297140648; Tue, 25 Jul 2023 07:59:00 -0700 (PDT) Received: from localhost.localdomain ([176.187.203.142]) by smtp.gmail.com with ESMTPSA id y9-20020a5d4709000000b003143801f8d8sm16535769wrq.103.2023.07.25.07.58.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Jul 2023 07:59:00 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 05/10] target/mips/mxu: Avoid overrun in gen_mxu_S32SLT() Date: Tue, 25 Jul 2023 16:58:24 +0200 Message-Id: <20230725145829.37782-6-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230725145829.37782-1-philmd@linaro.org> References: <20230725145829.37782-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Coverity reports a potential overrun (CID 1517769): Overrunning array "mxu_gpr" of 15 8-byte elements at element index 4294967295 (byte offset 34359738367) using index "XRb - 1U" (which evaluates to 4294967295). Use gen_load_mxu_gpr() to safely load MXU registers. Fixes: ff7936f009 ("target/mips/mxu: Add S32SLT ... insns") Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20230712060806.82323-3-philmd@linaro.org> --- target/mips/tcg/mxu_translate.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index b007948a73..520747a597 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -2434,8 +2434,12 @@ static void gen_mxu_S32SLT(DisasContext *ctx) tcg_gen_movi_tl(mxu_gpr[XRa - 1], 0); } else { /* the most general case */ - tcg_gen_setcond_tl(TCG_COND_LT, mxu_gpr[XRa - 1], - mxu_gpr[XRb - 1], mxu_gpr[XRc - 1]); + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + + gen_load_mxu_gpr(t0, XRb); + gen_load_mxu_gpr(t1, XRc); + tcg_gen_setcond_tl(TCG_COND_LT, mxu_gpr[XRa - 1], t0, t1); } } From patchwork Tue Jul 25 14:58:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 706150 Delivered-To: patch@linaro.org Received: by 2002:a5d:464f:0:b0:317:2194:b2bc with SMTP id j15csp232502wrs; Tue, 25 Jul 2023 07:59:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlEsLSopGd2yYhkfVcdyAAs6IwdD9qVTyBCw7KJeLxGMVSHLbKxBgUbjRJd67a2F/1KQy0ar X-Received: by 2002:a0c:e1d4:0:b0:63c:ff05:5ddd with SMTP id v20-20020a0ce1d4000000b0063cff055dddmr2799295qvl.64.1690297185000; Tue, 25 Jul 2023 07:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690297184; cv=none; d=google.com; s=arc-20160816; b=IqMt3bKHSxMjTigvWItj+rqHPyb1XYWXXz8E3KSUF5OqSIMNxXcVCP0Owkf3/mQ6qn 0fM8Bv3QqBbb1+Y7fNjki7YcgaObK4yqY5LcKLTF06Kpw4+QrvfkAIAJTjZ9+BiKZHmP lFvohBgGti5SEQQIaVRgISEa5OflZz9/yb93VeDX62zllA1Ja+QiA0d6Vzh/lvfq0ADY ka8CP6DL/TZpy8nkVSbc5H6tbcAQ6W35bWPbNAglNh+Am7jQD8a6Um8Iy2D3x7y0Mege CyyOsJfvRf37MuA5u5DhP0KDEOtRsc2x9128MhKGJfQj4g2ZNpp/V7HCTkJoSvw9lxWN ZKmw== 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=qSioxDMzRpvFdzVJXhUN5omfX+PmBMAzJgemy6xBhaw=; fh=LuuFZBQYVL40+QyI1x9zvzj8G0F/ihI4h4jmUPqNsOc=; b=YIGf3+5t68CPRRGS1VFtZeDXMI8Q7aUTyDaQZ3JHOtLUZj8n7ehdmXi8ZEY9s8BTLc gv5N7rrejtaPO06ycgEUKo06Mm+ws78KOm+lYnzqIYKNgq3yjbqFKZjkxa4DW4RzOloo +Rpt7hH6I82ciWXtnw+jfWmSUgfoVlqoO0kSTFJ2WIpGK3AhKxCJhJ74vqcXHY9G5Zuy 5VOvy4vJji16sCYDVIxBNSEjHeGfJSvBUC4a0kJgD0i6cFJnMf2+9axSX2Tu+21BaHxY 7BVlUGipYdQZvvd8sdBI8OwUUmYdXZ5yXPc0Xx6JSUXN0hR0lriQF1ZE9M7Bm0nwBvsH HBcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xpX1GZZ9; 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 l4-20020a0ce084000000b0063cf6957da7si3815494qvk.554.2023.07.25.07.59.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jul 2023 07:59:44 -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=xpX1GZZ9; 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 1qOJVJ-0003Of-Ad; Tue, 25 Jul 2023 10:59: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 1qOJVH-0003HF-I1 for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:59:11 -0400 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qOJVE-0001Cs-3s for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:59:11 -0400 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-4fdd31bf179so8695067e87.2 for ; Tue, 25 Jul 2023 07:59:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690297146; x=1690901946; 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=qSioxDMzRpvFdzVJXhUN5omfX+PmBMAzJgemy6xBhaw=; b=xpX1GZZ9V+sqeNY+hafzPXiByHa8UJTrgdvqxOxcdEzPPIDWDDKGWmIrD5rLzUnSOn I1zHheeFzdfqqADapYCYvGhJ+hgYsmf1w4QE1aRqyv50aEjEaXG+4Jvofi0xD6BhBBen DstFHBunl+A7uiHc5Qj22Eu81Fi6o3SpqJEY0t8JthMHT+7pVjvGKbJvuG15RNS6xueo W/OpvOlAbqm8uzAPLHg63oUqmKGAkR0zmdaZz3VTFI8n2R2eFUoD6X1rgOwNY0/G0o/i Dfhkdb6dOkO/s/VZxi+gVhjHHxQ5GNWUENmmRbSbAtn7/0d+MpQvswWwhJf8vmXWC2fP nicQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690297146; x=1690901946; 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=qSioxDMzRpvFdzVJXhUN5omfX+PmBMAzJgemy6xBhaw=; b=YV/YQF3ywhIYliPq2eIS/9Fz6QHCGU+oRAulQb8m7+SzlvOnTbcwR/XwLPBTxNuxnE fuLm0NNz9zGZYzlX27JUWX7p4G4K5gqY6Gc1VW9QqqE8vepsHnQrjpLy2WJzP/3q0Zoe pELOtYxj36aKMCgjs99EMg+jvTam+B/jTHpCqKlNLt683E3gGfBTye04kb7RgL+fsMTs /TBQmdxLglxRCoGnwv1qzsI35Gu08o2icsvkpMB70cRTlSkN5aI43yomgTaEEtt/9OgJ FVkZfzTuZQWxmcT5lU4yQoNLKxj+YAq16clUt6HO3wT23XMNwstb4WnAyRCiBKtlXGMg XlJA== X-Gm-Message-State: ABy/qLaXZpcOsnaI0a+pna2bR3aoATqjzBVP9YjJCVcIeArVtdQBjEuA r29FZB15TiqnVF2yPTFVB56O0EKoTgXeOgulPfA= X-Received: by 2002:a05:6512:401e:b0:4fb:7447:e71a with SMTP id br30-20020a056512401e00b004fb7447e71amr8173027lfb.63.1690297146152; Tue, 25 Jul 2023 07:59:06 -0700 (PDT) Received: from localhost.localdomain ([176.187.203.142]) by smtp.gmail.com with ESMTPSA id w9-20020adfd4c9000000b0031423a8f4f7sm16821042wrk.56.2023.07.25.07.59.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Jul 2023 07:59:05 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 06/10] target/mips/mxu: Avoid overrun in gen_mxu_q8adde() Date: Tue, 25 Jul 2023 16:58:25 +0200 Message-Id: <20230725145829.37782-7-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230725145829.37782-1-philmd@linaro.org> References: <20230725145829.37782-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12c; envelope-from=philmd@linaro.org; helo=mail-lf1-x12c.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 Coverity reports a potential overruns (CID 1517770): Overrunning array "mxu_gpr" of 15 8-byte elements at element index 4294967295 (byte offset 34359738367) using index "XRb - 1U" (which evaluates to 4294967295). Add a gen_extract_mxu_gpr() helper similar to gen_load_mxu_gpr() to safely extract MXU registers. Fixes: eb79951ab6 ("target/mips/mxu: Add Q8ADDE ... insns") Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20230712060806.82323-4-philmd@linaro.org> --- target/mips/tcg/mxu_translate.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 520747a597..e662acd5df 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -644,6 +644,16 @@ static inline void gen_store_mxu_gpr(TCGv t, unsigned int reg) } } +static inline void gen_extract_mxu_gpr(TCGv t, unsigned int reg, + unsigned int ofs, unsigned int len) +{ + if (reg == 0) { + tcg_gen_movi_tl(t, 0); + } else if (reg <= 15) { + tcg_gen_extract_tl(t, mxu_gpr[reg - 1], ofs, len); + } +} + /* MXU control register moves. */ static inline void gen_load_mxu_cr(TCGv t) { @@ -3004,10 +3014,10 @@ static void gen_mxu_q8adde(DisasContext *ctx, bool accumulate) TCGv t5 = tcg_temp_new(); if (XRa != 0) { - tcg_gen_extract_tl(t0, mxu_gpr[XRb - 1], 16, 8); - tcg_gen_extract_tl(t1, mxu_gpr[XRc - 1], 16, 8); - tcg_gen_extract_tl(t2, mxu_gpr[XRb - 1], 24, 8); - tcg_gen_extract_tl(t3, mxu_gpr[XRc - 1], 24, 8); + gen_extract_mxu_gpr(t0, XRb, 16, 8); + gen_extract_mxu_gpr(t1, XRc, 16, 8); + gen_extract_mxu_gpr(t2, XRb, 24, 8); + gen_extract_mxu_gpr(t3, XRc, 24, 8); if (aptn2 & 2) { tcg_gen_sub_tl(t0, t0, t1); tcg_gen_sub_tl(t2, t2, t3); @@ -3027,10 +3037,10 @@ static void gen_mxu_q8adde(DisasContext *ctx, bool accumulate) tcg_gen_or_tl(t4, t2, t0); } if (XRd != 0) { - tcg_gen_extract_tl(t0, mxu_gpr[XRb - 1], 0, 8); - tcg_gen_extract_tl(t1, mxu_gpr[XRc - 1], 0, 8); - tcg_gen_extract_tl(t2, mxu_gpr[XRb - 1], 8, 8); - tcg_gen_extract_tl(t3, mxu_gpr[XRc - 1], 8, 8); + gen_extract_mxu_gpr(t0, XRb, 0, 8); + gen_extract_mxu_gpr(t1, XRc, 0, 8); + gen_extract_mxu_gpr(t2, XRb, 8, 8); + gen_extract_mxu_gpr(t3, XRc, 8, 8); if (aptn2 & 1) { tcg_gen_sub_tl(t0, t0, t1); tcg_gen_sub_tl(t2, t2, t3); From patchwork Tue Jul 25 14:58:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 706151 Delivered-To: patch@linaro.org Received: by 2002:a5d:464f:0:b0:317:2194:b2bc with SMTP id j15csp232515wrs; Tue, 25 Jul 2023 07:59:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlGqIN3qNoEMlZLbJtV89v1dbdXwn93apFoXuvS+dqsMFobzzMM1QViwARXogsnhFLkictK1 X-Received: by 2002:a25:9387:0:b0:d0c:15e8:97af with SMTP id a7-20020a259387000000b00d0c15e897afmr5335928ybm.5.1690297187087; Tue, 25 Jul 2023 07:59:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690297187; cv=none; d=google.com; s=arc-20160816; b=JekmVkxZEG8p3lcJOFH4wvFJZTdEufvYSSZ0+tBadXUgvVXJ1OP3dFIU/IT5tkUtfa lKeVXLvBTcKkNKtI4NqE4sp8X5Kq2LbCjLycnnZqAjCZ4hzFBqtMnBwwAvGflhslJqRJ AWv82fNA31lRleUHi3eQo0fgDK2nL28Q8iLpQCkJ0hTM4JVWZNJN1SD0XSbuW4pHz+kQ 7/EWOM7AdtSn39BjXrjER0F9/QvpqAKEkGNxA5YSTY4Rl3S2zMtDiEQJa8ZrIWECdH7F sMSrwQaCw7D6HvamZ29hD1jBF04kJVewlH9uSmA4Ybvqm+fHpCeoVqwgN6LxEHE/Cc// XuKQ== 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=OKc1nCq76nawigLZznM8ag7fG6Cw9/XuF4yM8SD334c=; fh=Stq2SV/xhy3nSB1W3Xp07nF/pIUdKhH/vDshjHjvMuw=; b=y/6fQfnEN8UdMETyP1q/hKq2SlVp0bsL+kpIMFO4iqoAIsTTnGdRZepq7T7SYjj6kQ ykWoJlDPMAgTg8n/+kinzDhxUhMfrCfStvKpgs0kFCRgmD8ZDI/ANFY85aGl0lMobFKl N6ILkWrWgtExBQ4fOYbofZosmrj0EDFpjueHjKTfMdpsGJh6KaK78yqdRbV7nELZG9gK muM2zQrbCq1gvDF+UWwYwDh905dZz6AAvyFEUNQVqF2txg+jPnf6oT5suydsAaohN71V 8LgoGc5fQMj4WH0/5on0rJhWfcUQnsC5L9iaDhp0Yk+YJrUWax6Pi4/N4+w2TA40Ak11 o6ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CPqhoQd6; 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 i4-20020ac85c04000000b00403c200aae5si6572579qti.638.2023.07.25.07.59.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jul 2023 07:59: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=CPqhoQd6; 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 1qOJVP-0003RD-6Y; Tue, 25 Jul 2023 10:59: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 1qOJVN-0003QK-Lg for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:59:17 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qOJVJ-0001Dh-3x for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:59:17 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fd18b1d924so45472415e9.1 for ; Tue, 25 Jul 2023 07:59:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690297151; x=1690901951; 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=OKc1nCq76nawigLZznM8ag7fG6Cw9/XuF4yM8SD334c=; b=CPqhoQd6FLmqn1MMGy3g8W4/8T9X+jlPCcQMS0UQOlDgh1o3xo/Qf9WOhkBvDhy0Qh UUrZSmxCKGsaMtHk/Bex/hGum32XTjxJ0q4F1FWGDHMpRP3sKHWSCscNA3eFxtNY5CYi ZzZo/Y5ByxCnyTTeP7KVF68zR3AT44p7W5MMudy1VYhPVjLVW5R2CefskZ/JswCz0Dip E1keItNma0paIsl0W3DFJqqttxC8KPUb9n4CnUpDGRWKQ3hMGaUI75UJe7bsU7FP/WrA 3TDaPlBlE9tLixQN6m3Elhx7cwKCD5/pTefN/mV/A1RWS0L4r74s3GfUbLLbiz9xXQqe wo5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690297151; x=1690901951; 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=OKc1nCq76nawigLZznM8ag7fG6Cw9/XuF4yM8SD334c=; b=b5zYnnvA+96QYNX2qAEtjBrnjyVLfyxJLWncPeXpIQMDFWGn7oZpir9oXTZDBDFgRA L9CNUmuAINJzsKdovi+ODI+/lA5/YXOji9U0K/A7lnzc4LW4sZncCjm/tCYkoBxkk4b7 4Lp/v+OTV4M2iGGs47od4kmLxZIm6DPtr3HNVSTLRAOR5gWm5tFqJkKAnw22xB1YF97t MLO3HcMo6hLCZUdVxCVscYuIz5dlRhXzc6rX3uoofDnisHHHNJpfMGJqqEmqodnTkQp7 m9WgrrdtdLquHijFIodz3nokKpPNHdpMD0y/EuQaYgB1lqYRoErZiUr6yhZJZYnBHl/3 hJmA== X-Gm-Message-State: ABy/qLaDoZVRxFt3Hh89/oa6Rjzs4ICGmK8z8l9IDQQTDktAbXZTA6et Rb54lE+afK+taD1ZQhml6MczMoWe9E2SYJbkxuM= X-Received: by 2002:a5d:5185:0:b0:314:dea:f1f8 with SMTP id k5-20020a5d5185000000b003140deaf1f8mr8847145wrv.11.1690297151578; Tue, 25 Jul 2023 07:59:11 -0700 (PDT) Received: from localhost.localdomain ([176.187.203.142]) by smtp.gmail.com with ESMTPSA id b17-20020a5d40d1000000b00314417f5272sm16586989wrq.64.2023.07.25.07.59.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Jul 2023 07:59:11 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell Subject: [PULL 07/10] target/mips: Pass directory/leaf shift values to walk_directory() Date: Tue, 25 Jul 2023 16:58:26 +0200 Message-Id: <20230725145829.37782-8-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230725145829.37782-1-philmd@linaro.org> References: <20230725145829.37782-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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, T_SCC_BODY_TEXT_LINE=-0.01 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 evaluated directory_shift and leaf_shift in page_table_walk_refill(), no need to do that again: pass as argument. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Message-Id: <20230717213504.24777-2-philmd@linaro.org> --- target/mips/tcg/sysemu/tlb_helper.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/target/mips/tcg/sysemu/tlb_helper.c b/target/mips/tcg/sysemu/tlb_helper.c index e5e1e9dd3f..e7be649b02 100644 --- a/target/mips/tcg/sysemu/tlb_helper.c +++ b/target/mips/tcg/sysemu/tlb_helper.c @@ -623,18 +623,13 @@ static uint64_t get_tlb_entry_layout(CPUMIPSState *env, uint64_t entry, static int walk_directory(CPUMIPSState *env, uint64_t *vaddr, int directory_index, bool *huge_page, bool *hgpg_directory_hit, - uint64_t *pw_entrylo0, uint64_t *pw_entrylo1) + uint64_t *pw_entrylo0, uint64_t *pw_entrylo1, + int directory_shift, int leaf_shift) { int dph = (env->CP0_PWCtl >> CP0PC_DPH) & 0x1; int psn = (env->CP0_PWCtl >> CP0PC_PSN) & 0x3F; int hugepg = (env->CP0_PWCtl >> CP0PC_HUGEPG) & 0x1; int pf_ptew = (env->CP0_PWField >> CP0PF_PTEW) & 0x3F; - int ptew = (env->CP0_PWSize >> CP0PS_PTEW) & 0x3F; - int native_shift = (((env->CP0_PWSize >> CP0PS_PS) & 1) == 0) ? 2 : 3; - int directory_shift = (ptew > 1) ? -1 : - (hugepg && (ptew == 1)) ? native_shift + 1 : native_shift; - int leaf_shift = (ptew > 1) ? -1 : - (ptew == 1) ? native_shift + 1 : native_shift; uint32_t direntry_size = 1 << (directory_shift + 3); uint32_t leafentry_size = 1 << (leaf_shift + 3); uint64_t entry; @@ -779,7 +774,8 @@ static bool page_table_walk_refill(CPUMIPSState *env, vaddr address, if (gdw > 0) { vaddr |= goffset; switch (walk_directory(env, &vaddr, pf_gdw, &huge_page, &hgpg_gdhit, - &pw_entrylo0, &pw_entrylo1)) + &pw_entrylo0, &pw_entrylo1, + directory_shift, leaf_shift)) { case 0: return false; @@ -795,7 +791,8 @@ static bool page_table_walk_refill(CPUMIPSState *env, vaddr address, if (udw > 0) { vaddr |= uoffset; switch (walk_directory(env, &vaddr, pf_udw, &huge_page, &hgpg_udhit, - &pw_entrylo0, &pw_entrylo1)) + &pw_entrylo0, &pw_entrylo1, + directory_shift, leaf_shift)) { case 0: return false; @@ -811,7 +808,8 @@ static bool page_table_walk_refill(CPUMIPSState *env, vaddr address, if (mdw > 0) { vaddr |= moffset; switch (walk_directory(env, &vaddr, pf_mdw, &huge_page, &hgpg_mdhit, - &pw_entrylo0, &pw_entrylo1)) + &pw_entrylo0, &pw_entrylo1, + directory_shift, leaf_shift)) { case 0: return false; From patchwork Tue Jul 25 14:58:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 706149 Delivered-To: patch@linaro.org Received: by 2002:a5d:464f:0:b0:317:2194:b2bc with SMTP id j15csp232485wrs; Tue, 25 Jul 2023 07:59:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlF4w7BWlxtfqb1M4Ksqwmkd6PvJerxgDC9wN2nbxcXtXo0x908Dwb/TsqDoT5n0p98bvodh X-Received: by 2002:ad4:559c:0:b0:635:dd9a:ade4 with SMTP id f28-20020ad4559c000000b00635dd9aade4mr2338657qvx.16.1690297181256; Tue, 25 Jul 2023 07:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690297181; cv=none; d=google.com; s=arc-20160816; b=y84+DHE4mcb/PverF/RBp6/mrDbqXdTy1/LymO8r0r3JR/r3C9Hv3tLPC/PyFEa0Se yiWjwW8AtLrueOW36bojFc/quOnkH+OiPwH0Ku1EOUV5NlgjptOQP+uabf/4cklJF3c6 8EeozW7y330HOxJ6ecxmh2uXo3Cc8jMyAK8syAMpcvwdy3zV+MGcW3o5DiW1E0oMNyec Z7c+rQFVFTFhrjFPvDOXHuQWnebThFhaBHL+I0DZHUbGiVSrlYv/2cT+bm/bsbXeCnb6 LO0Mc+ysufZ9LHpE45VtmaFBOH4HeknI8od55ld5VxXRyA9v41NgrpJK4A7OaYzjwha1 KidQ== 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=4bJCBZZCEPCtzonH3X6oi/HIov7CTT54+j4YPc7XUYQ=; fh=zwTK8ddUb+oJpQ0Q0YpkZTPD1i+R3bv3S+Tgd8q4XyQ=; b=YWL3rIDdJ08ZqrzRC28B2gWP70oEplE0z9a8hyMRZrA/ZoO3y/59MC/J/y1V776uCw o2DspiT5RrDcsYDgvTMdFUjEX5Anrp56VHSmqm1russ9KsPNhVx7FhBCKF3oBvl3gICy zss+WLX91jkj6U4Tw+4HvJ3UcCc6Ybrc8mzU58ab3EAbJ7/1ft+TwaNNesopmitwIv/R JfAXRx6fZluAx4yAQcHni2rdujQwVKlJpwTwme6fyEWYdhsgHjnYZWLYxqZx7Wsurbu3 RDBUhiQMck3VWHfiAJXjbq7mcgJWw04OgcKsC135Tl3cqEED/1wSV7IiXEL4a2kiI84w J4ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=k1yQs1Vr; 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 l2-20020a0ce502000000b0063d020d976asi2636828qvm.459.2023.07.25.07.59.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jul 2023 07:59:41 -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=k1yQs1Vr; 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 1qOJVS-0003eK-1I; Tue, 25 Jul 2023 10:59: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 1qOJVQ-0003Xr-6y for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:59:20 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qOJVO-0001Eo-Iw for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:59:19 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fbab0d0b88so42440175e9.0 for ; Tue, 25 Jul 2023 07:59:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690297157; x=1690901957; 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=4bJCBZZCEPCtzonH3X6oi/HIov7CTT54+j4YPc7XUYQ=; b=k1yQs1VrxTLtmBjlGpSGj5HvLaN4LLWHxP+h/uZCP4LPny2pQZndZlBLsP3JKID6Ho stsOkQHK/dlmzwbXmdyGgmRw1cLt9tSN5t8QO4WBUXSmZ7bJ8JSBvjGvRx02Insz+eLF Zl+upnppy95hO/+6ShukF+8+JLrITJQ27ZqUX4NnSsauBZ0+/BZGRMLuWQAgFrwwkamH m65IDWGN1hSJz/odO2AXBq+JTcTvvGzNwWoSjcs28JWGryBmX10FprOjOfecQ+lswidh SNHyaOk9eD/B9jnA5a8725m19bay2K7RPp6dAKGMwylarawOaZplLbmxI9mXJIHqCwXF ollg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690297157; x=1690901957; 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=4bJCBZZCEPCtzonH3X6oi/HIov7CTT54+j4YPc7XUYQ=; b=jMn7hOoquBtOqfqmnNf/3pxCxIR7GDWKS43xtqyTn/fv0gwrjxdnsdvpAmh2Pwo/37 NDJlK+x5TsvNSBq9s7YsZEcMhiNFUp+uCVZwQwNypItND0UzZl9fwu6yNnIzSa1Ozovz PxQ8C3NBf65cIqSCxuDudSAxG/pIHsEjuURrp2s2yncdxWYZwlBCt639ofUnwlSrZtlH cCz3p6+3VF189ZlTOL0b4xG03gW9FdfZz2vVXuhKzG5rhvadAVpzxPTX/8GuFyjdVH+M qJxHR9XRCLznztMq6fGpiUXmJZSoJDWMUJ83CTitplUAyqbNFVmJmrx6ejN9oZWHux2n gQ2w== X-Gm-Message-State: ABy/qLYIjTzBvkqxM7jA1Lues8sg02EbpM/K08VYT4TqeD4sVBx5wosl F7cGa1lVYlAF87aB5MUGGWKjISPiYMTiiFJNwXo= X-Received: by 2002:a05:6000:8d:b0:30a:e70d:8022 with SMTP id m13-20020a056000008d00b0030ae70d8022mr2254173wrx.26.1690297157043; Tue, 25 Jul 2023 07:59:17 -0700 (PDT) Received: from localhost.localdomain ([176.187.203.142]) by smtp.gmail.com with ESMTPSA id z17-20020a5d4411000000b003176eab8868sm1851191wrq.82.2023.07.25.07.59.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Jul 2023 07:59:16 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , qemu-block@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 08/10] target/mips: Avoid shift by negative number in page_table_walk_refill() Date: Tue, 25 Jul 2023 16:58:27 +0200 Message-Id: <20230725145829.37782-9-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230725145829.37782-1-philmd@linaro.org> References: <20230725145829.37782-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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: Peter Maydell Coverity points out that in page_table_walk_refill() we can shift by a negative number, which is undefined behaviour (CID 1452918, 1452920, 1452922). We already catch the negative directory_shift and leaf_shift as being a "bail out early" case, but not until we've already used them to calculated some offset values. The shifts can be negative only if ptew > 1, so make the bail-out-early check look directly at that, and only calculate the shift amounts and the offsets based on them after we have done that check. This allows us to simplify the expressions used to calculate the shift amounts, use an unsigned type, and avoids the undefined behaviour. Signed-off-by: Peter Maydell [PMD: Check for ptew > 1, use unsigned type] Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Message-Id: <20230717213504.24777-3-philmd@linaro.org> --- target/mips/tcg/sysemu/tlb_helper.c | 32 +++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/target/mips/tcg/sysemu/tlb_helper.c b/target/mips/tcg/sysemu/tlb_helper.c index e7be649b02..7dbc2e24c4 100644 --- a/target/mips/tcg/sysemu/tlb_helper.c +++ b/target/mips/tcg/sysemu/tlb_helper.c @@ -624,7 +624,7 @@ static uint64_t get_tlb_entry_layout(CPUMIPSState *env, uint64_t entry, static int walk_directory(CPUMIPSState *env, uint64_t *vaddr, int directory_index, bool *huge_page, bool *hgpg_directory_hit, uint64_t *pw_entrylo0, uint64_t *pw_entrylo1, - int directory_shift, int leaf_shift) + unsigned directory_shift, unsigned leaf_shift) { int dph = (env->CP0_PWCtl >> CP0PC_DPH) & 0x1; int psn = (env->CP0_PWCtl >> CP0PC_PSN) & 0x3F; @@ -730,21 +730,11 @@ static bool page_table_walk_refill(CPUMIPSState *env, vaddr address, /* Other HTW configs */ int hugepg = (env->CP0_PWCtl >> CP0PC_HUGEPG) & 0x1; - - /* HTW Shift values (depend on entry size) */ - int directory_shift = (ptew > 1) ? -1 : - (hugepg && (ptew == 1)) ? native_shift + 1 : native_shift; - int leaf_shift = (ptew > 1) ? -1 : - (ptew == 1) ? native_shift + 1 : native_shift; + unsigned directory_shift, leaf_shift; /* Offsets into tables */ - int goffset = gindex << directory_shift; - int uoffset = uindex << directory_shift; - int moffset = mindex << directory_shift; - int ptoffset0 = (ptindex >> 1) << (leaf_shift + 1); - int ptoffset1 = ptoffset0 | (1 << (leaf_shift)); - - uint32_t leafentry_size = 1 << (leaf_shift + 3); + unsigned goffset, uoffset, moffset, ptoffset0, ptoffset1; + uint32_t leafentry_size; /* Starting address - Page Table Base */ uint64_t vaddr = env->CP0_PWBase; @@ -766,10 +756,22 @@ static bool page_table_walk_refill(CPUMIPSState *env, vaddr address, /* no structure to walk */ return false; } - if ((directory_shift == -1) || (leaf_shift == -1)) { + if (ptew > 1) { return false; } + /* HTW Shift values (depend on entry size) */ + directory_shift = (hugepg && (ptew == 1)) ? native_shift + 1 : native_shift; + leaf_shift = (ptew == 1) ? native_shift + 1 : native_shift; + + goffset = gindex << directory_shift; + uoffset = uindex << directory_shift; + moffset = mindex << directory_shift; + ptoffset0 = (ptindex >> 1) << (leaf_shift + 1); + ptoffset1 = ptoffset0 | (1 << (leaf_shift)); + + leafentry_size = 1 << (leaf_shift + 3); + /* Global Directory */ if (gdw > 0) { vaddr |= goffset; From patchwork Tue Jul 25 14:58:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 706152 Delivered-To: patch@linaro.org Received: by 2002:a5d:464f:0:b0:317:2194:b2bc with SMTP id j15csp232551wrs; Tue, 25 Jul 2023 07:59:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlFV6Wge8rYqA884XiSwfir4HpTaGoq0RoxHz/Imyn6iGe9oZsvllpyTnJgw+BP3p57isaYt X-Received: by 2002:a0c:f2cb:0:b0:63c:f548:7788 with SMTP id c11-20020a0cf2cb000000b0063cf5487788mr1666983qvm.55.1690297189598; Tue, 25 Jul 2023 07:59:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690297189; cv=none; d=google.com; s=arc-20160816; b=N1zNZ23w7SJjJ3BGd8MdjytxOGopKqySZy5TlnPdtaAEg+nlqjuBMPl6qOHx0dG/PW pPe7uQTp0Ml9k1CuNmLB5e0hJsHGZS5JpPYY+fBjYHHw+Sru+O40tY05E+Ek2/sQFZBY nHt7D6djbi6YHz4c9GWDdPJlw22n8FWyF/ukCArGRFp/a5d83eyYfAknP05AUkSjfKSZ uG612mNBwpBf5E8IJ0mAGUt8Y90gTd2Hp0FyjHDGjFAkJdBwgV1SyhwyH7uE4geNIR1W qh2LnEtCK8lrBz0hRrBoNrhZnoWowGVshYJCBQ/mbVcR3d+SqEXLw16Q4gW9yNsLSf+c KC+w== 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=wx51puJDtBC7dYR0MEeEvjQpQ/NCjXemSL1PA8RzYqg=; fh=ncvhVgPRlafDS6fQuO8YGqCKbNYfTWmZkNzxvhOZPlE=; b=IU5HlgUHtk8APBT9uRw+yWNuWDD+0THBDx3e4w02QwhJ3lQVzzbj+7uzhfo2xjvEbN Ppl+h1tVP52yyHS17b+O62KWiQ5AjLsXx6MtPTXbnddWJ9C2cGBgP8jtUJspt4hPSskL vfZaY2waLkYc9Ki9zt1iQx9dgivpp10l1U3jdClhhsUpa3RGr75FWmqo8oeiu9LOIMOy vCYC9iXzzcEE/slhjF+JBJVfDbyEr6PhKHtX2KgmomtvPu7/KiKJk7l5REgbM5bOpm9y 4BiySgrkjyzQDTwdmVuoJXxGjbFAv0DdyuhFkM5qpB6jOEjodfiD914l2O4LM0ZVVz5i 5uKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RSDdW74q; 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 g9-20020a0ce4c9000000b006236d96c8e3si268073qvm.348.2023.07.25.07.59.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jul 2023 07:59:49 -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=RSDdW74q; 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 1qOJVY-0004bw-1s; Tue, 25 Jul 2023 10:59: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 1qOJVW-0004Ir-6A for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:59:26 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qOJVU-0001Ft-Af for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:59:25 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3fd0f000f1cso36772965e9.1 for ; Tue, 25 Jul 2023 07:59:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690297163; x=1690901963; 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=wx51puJDtBC7dYR0MEeEvjQpQ/NCjXemSL1PA8RzYqg=; b=RSDdW74qn2bmpSFkU/VAVeYYbLHVqt6F7bmPrYXt5dZ2Y1rL84xmMGfeJajWjNuP6M 740FrR/sxKsVGVVFvNhWUhEuzv2S6Kbq6al9x7IV0kj9EROIsVQEzwurWnBlALfUfPhw 0554HdBabu9FwlLT45ufOZ5nU3oqaojm0/iG0YHzPYLwGfjngUOchy4vuu32LJqFUBRx OTQJKhaTBNOzIR8/KLF+X+wl4zpN5+DDq2SY+cUYccWNaW6k47MUPIo7oaum+DNfcRfa 51O229/y2w16W0tGijOrkEQyNb7SxOBNf+xcoiAGunXPT0/1W5f9I2DbrCaLCERYWWX7 WZtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690297163; x=1690901963; 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=wx51puJDtBC7dYR0MEeEvjQpQ/NCjXemSL1PA8RzYqg=; b=VGRvCEGyr7tH32dcEBv7NxNRxSBaFmL1ATtv2iv9Dcu3ioKSESrYSSGXjkE+V+499Q VCPT2YZ9bOS4lznQZKJ5jkKlUiFs/WWtwNTOEbJd9wslM2h+0jJoZarq5XWHkV7i3zPV eGyIZPVyc9ZAvEIqHpuG05bBZ/LOPzbjrdaNC0WgG6ByeVr8d9HWFGAkTMwL2SHVslpL oF+FvTkQg96VeDiMjHD5S5O72nN2S6/7/6MBacotXuhDOVOyI+eiAHEprMlff6B8lQi+ TuG2XfSnweZLbU8PiHnf8PsSJZYqmyPSwZb1NImVhpx2sM4KjvfdVTtZ6WjLFy30E5ex o4NA== X-Gm-Message-State: ABy/qLaUPlFj/i0KOvCkDdk+BMvkW4rBykmFXQEmFsJBLLMtBjgpiKmt PXNbNh2s24RVGzQlf0fJoRU6nXi8AzSlNHFyhLA= X-Received: by 2002:a1c:7914:0:b0:3f6:d90:3db with SMTP id l20-20020a1c7914000000b003f60d9003dbmr2286273wme.3.1690297162799; Tue, 25 Jul 2023 07:59:22 -0700 (PDT) Received: from localhost.localdomain ([176.187.203.142]) by smtp.gmail.com with ESMTPSA id x3-20020adfdd83000000b00314398e4dd4sm16683079wrl.54.2023.07.25.07.59.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Jul 2023 07:59:22 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , qemu-block@nongnu.org, Peter Maydell , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PULL 09/10] target/sparc: Handle FPRS correctly on big-endian hosts Date: Tue, 25 Jul 2023 16:58:28 +0200 Message-Id: <20230725145829.37782-10-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230725145829.37782-1-philmd@linaro.org> References: <20230725145829.37782-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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: Peter Maydell In CPUSparcState we define the fprs field as uint64_t. However we then refer to it in translate.c via a TCGv_i32 which we set up with tcg_global_mem_new_ptr(). This means that on a big-endian host when the guest does something to writo te the FPRS register this value ends up in the wrong half of the uint64_t, and the QEMU C code that refers to env->fprs sees the wrong value. The effect of this is that guest code that enables the FPU crashes with spurious FPU Disabled exceptions. In particular, this is why tests/avocado/machine_sparc64_sun4u.py:Sun4uMachine.test_sparc64_sun4u times out on an s390 host. There are multiple ways we could fix this; since there are actually only three bits in the FPRS register and the code in translate.c would be a bit painful to convert to dealing with a TCGv_i64, change the type of the CPU state struct field to match what translate.c is expecting. (None of the other fields referenced by the r32[] array in sparc_tcg_init() have the wrong type.) Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Mark Cave-Ayland Message-Id: <20230717103544.637453-1-peter.maydell@linaro.org> --- target/sparc/cpu.h | 2 +- target/sparc/cpu.c | 4 ++-- target/sparc/machine.c | 3 ++- target/sparc/monitor.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index 95d2d0da71..98044572f2 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -521,7 +521,7 @@ struct CPUArchState { uint64_t igregs[8]; /* interrupt general registers */ uint64_t mgregs[8]; /* mmu general registers */ uint64_t glregs[8 * MAXTL_MAX]; - uint64_t fprs; + uint32_t fprs; uint64_t tick_cmpr, stick_cmpr; CPUTimer *tick, *stick; #define TICK_NPT_MASK 0x8000000000000000ULL diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index e329a7aece..130ab8f578 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -673,8 +673,8 @@ static void sparc_cpu_dump_state(CPUState *cs, FILE *f, int flags) "cleanwin: %d cwp: %d\n", env->cansave, env->canrestore, env->otherwin, env->wstate, env->cleanwin, env->nwindows - 1 - env->cwp); - qemu_fprintf(f, "fsr: " TARGET_FMT_lx " y: " TARGET_FMT_lx " fprs: " - TARGET_FMT_lx "\n", env->fsr, env->y, env->fprs); + qemu_fprintf(f, "fsr: " TARGET_FMT_lx " y: " TARGET_FMT_lx " fprs: %016x\n", + env->fsr, env->y, env->fprs); #else qemu_fprintf(f, "psr: %08x (icc: ", cpu_get_psr(env)); diff --git a/target/sparc/machine.c b/target/sparc/machine.c index 44b9e7d75d..274e1217df 100644 --- a/target/sparc/machine.c +++ b/target/sparc/machine.c @@ -168,7 +168,8 @@ const VMStateDescription vmstate_sparc_cpu = { VMSTATE_UINT64_ARRAY(env.bgregs, SPARCCPU, 8), VMSTATE_UINT64_ARRAY(env.igregs, SPARCCPU, 8), VMSTATE_UINT64_ARRAY(env.mgregs, SPARCCPU, 8), - VMSTATE_UINT64(env.fprs, SPARCCPU), + VMSTATE_UNUSED(4), /* was unused high half of uint64_t fprs */ + VMSTATE_UINT32(env.fprs, SPARCCPU), VMSTATE_UINT64(env.tick_cmpr, SPARCCPU), VMSTATE_UINT64(env.stick_cmpr, SPARCCPU), VMSTATE_CPU_TIMER(env.tick, SPARCCPU), diff --git a/target/sparc/monitor.c b/target/sparc/monitor.c index 318413686a..73f15aa272 100644 --- a/target/sparc/monitor.c +++ b/target/sparc/monitor.c @@ -154,7 +154,7 @@ const MonitorDef monitor_defs[] = { { "otherwin", offsetof(CPUSPARCState, otherwin) }, { "wstate", offsetof(CPUSPARCState, wstate) }, { "cleanwin", offsetof(CPUSPARCState, cleanwin) }, - { "fprs", offsetof(CPUSPARCState, fprs) }, + { "fprs", offsetof(CPUSPARCState, fprs), NULL, MD_I32 }, #endif { NULL }, }; From patchwork Tue Jul 25 14:58:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 706153 Delivered-To: patch@linaro.org Received: by 2002:a5d:464f:0:b0:317:2194:b2bc with SMTP id j15csp232595wrs; Tue, 25 Jul 2023 07:59:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlEvCLftczGj3yuB4QJ2hiXtfjNbFPYzKr44U6SgArMzZE968kmLa5/X2CHVfE84Z3N3XYq7 X-Received: by 2002:a0c:cb08:0:b0:61a:d6af:cb00 with SMTP id o8-20020a0ccb08000000b0061ad6afcb00mr2648277qvk.9.1690297194572; Tue, 25 Jul 2023 07:59:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690297194; cv=none; d=google.com; s=arc-20160816; b=MvIUWnQx4keO8M5ZpaoRAxpw0LYuGX1Ot5B52qc98E96Rk92sY0BubS+P5bi4LLU7M ROSgsSCddXHsZoj5HO3oQTdbN6MjQT0bZbvUW+c2lcjT7dzqGeD0DzMM0nq0iCMflTeS QDE95JgdXECiOsz0q0tUk25kTvEBjZBHrRSkluAPkW6wsyPhiFj+mnYcV/vEXwrv38b9 HQ49CYEWLOxYtUI41Yietfsv5G06+QaaxueAkkdreVek7XbmgXq2Yz/jt4RMey8LLrR8 UoxgGCZbYjOQAroThUUvjfH6r0cyo8mal3Yq2Wpnet0ra/ksho2xgdGd3q+XkMJhOg+i z5Vg== 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=2oHA/J/s7nN4RB2ZZD2qvJIrA12HJjmnHfA5XOpzEbY=; fh=t8cTMBG+DPAOM+Csye7RvQWAL7MOWUNRsu9mnS5OpgY=; b=ogFtCAPZuzWIpqkQcWCAcW3ZvjhueoAAk/sMweynot5lawq2+emso5n6TAOFIc1Q/C 75VVJFnTjgwH8+LSMoeWhWSEbNxKK9YWMYmONeP8IpUFX3zZdrMmolXQ/KK6ClOJtuvS rAwn8PEQwaSsGWvJIPvayK7a+yB6QBlAum3gL2O9zR0ccf++eD8vOS7GJZvyuRwtS1B9 xHxzs+n8kuOd8T5P9GHuRTXElufG2tk2pDRdIq8x6z7D0X7vqe+Vsrk7EuBtSFZaDHgM MFpaRcfpBQi4Ofm/LWYtV+2L14tm7DTvQgGXnqJro9QOTp92CEN+Pt3JvDf5PKWaZDBn G0SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ydlt6aK5; 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 m1-20020a0cf181000000b00631e69834e9si6723310qvl.195.2023.07.25.07.59.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jul 2023 07:59:54 -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=ydlt6aK5; 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 1qOJVe-0005RR-1k; Tue, 25 Jul 2023 10:59: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 1qOJVc-0005DN-2Y for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:59:32 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qOJVa-0001Iu-4S for qemu-devel@nongnu.org; Tue, 25 Jul 2023 10:59:31 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fbc244d384so47311725e9.0 for ; Tue, 25 Jul 2023 07:59:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690297168; x=1690901968; 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=2oHA/J/s7nN4RB2ZZD2qvJIrA12HJjmnHfA5XOpzEbY=; b=ydlt6aK5A1/6P/qQ7zKH4QmRgrq/B8e7qzgVGZiFj/wWurh79WedVhp6BOfkJn733d LBfH+TvnQMp8VkRo4hfjEncjLurFOVADMkiqDNg4pr1hsU3Odn/4V1cZBlnoBCn5ouWH 9DuYfLjIGxAmaxzADJwXo1eDyT0Q1qV1il/LOcxW3k+m+/dMwlAEMYBEsMkIo+VbJ0Lm 0HNXkROIpBbbQrA5CHO4gqjEX9mwqx9IiUMQFj/OeP+uO5hLOvF0Mgl4DySZMKFWc+Ou soBapIcbuE1AN2yQCOb56kc1eSI+y+cPZmMRk0X4+KzdxF0LBse2DDw9FObTck+CpV5c 2kMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690297168; x=1690901968; 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=2oHA/J/s7nN4RB2ZZD2qvJIrA12HJjmnHfA5XOpzEbY=; b=OifC2S4ds3YmeVyPZBbedPRkrafgfKmGBiQC+kgWDKHGdk8SiAyHyvPiivnCBINWCO yOCJLJkxwq7V+hBYe460Vq4RyUu1SakLVPVlgiBSXUX9ag/HdJLHaJr4hKmlNvSz3YI0 y+VfhbwrRSrzqP5Fq69hzecPZwAGs0XsZiM6sLY/atgKTrbmlr90D/Uzzxr5tMkKSuwF uAUXYfWk7TJ0l5zQy7NwXN9VVzTlHeHKPvgbA28ZYxVh/qhYJYB/thA2fxFglULujK2U b/b7GbKcfFT0Wftys3njYQ4K6Bi6bSAcVuMJF7vSFgyFNEftdfkw11t5oqSKfgb9xAQ/ uiIw== X-Gm-Message-State: ABy/qLYEQCqc/cmfBWsrqUe7BIeRBfsABrxLTbkiRaOHI9vWd8Kse1rO TxZ6KrE6qcH2GdlkYxd+bIC+UeByjPISmOcP4Ds= X-Received: by 2002:a7b:cc17:0:b0:3fa:e92e:7a8b with SMTP id f23-20020a7bcc17000000b003fae92e7a8bmr9454243wmh.13.1690297168700; Tue, 25 Jul 2023 07:59:28 -0700 (PDT) Received: from localhost.localdomain ([176.187.203.142]) by smtp.gmail.com with ESMTPSA id w3-20020a1cf603000000b003fd2eba5a9esm8850789wmc.5.2023.07.25.07.59.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Jul 2023 07:59:28 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Artyom Tarasenko , Bastian Koppelmann , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth Subject: [PULL 10/10] target/tricore: Rename tricore_feature Date: Tue, 25 Jul 2023 16:58:29 +0200 Message-Id: <20230725145829.37782-11-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230725145829.37782-1-philmd@linaro.org> References: <20230725145829.37782-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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: Bastian Koppelmann this name is used by capstone and will lead to a build failure of QEMU, when capstone is enabled. So we rename it to tricore_has_feature(), to match has_feature() in translate.c. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1774 Signed-off-by: Bastian Koppelmann Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth Message-Id: <20230721060605.76636-1-kbastian@mail.uni-paderborn.de> --- target/tricore/cpu.h | 2 +- target/tricore/cpu.c | 8 ++++---- target/tricore/helper.c | 4 ++-- target/tricore/op_helper.c | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h index a50b91cc36..3708405be8 100644 --- a/target/tricore/cpu.h +++ b/target/tricore/cpu.h @@ -277,7 +277,7 @@ enum tricore_features { TRICORE_FEATURE_162, }; -static inline int tricore_feature(CPUTriCoreState *env, int feature) +static inline int tricore_has_feature(CPUTriCoreState *env, int feature) { return (env->features & (1ULL << feature)) != 0; } diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index f15169bd1b..133a9ac70e 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -104,18 +104,18 @@ static void tricore_cpu_realizefn(DeviceState *dev, Error **errp) } /* Some features automatically imply others */ - if (tricore_feature(env, TRICORE_FEATURE_162)) { + if (tricore_has_feature(env, TRICORE_FEATURE_162)) { set_feature(env, TRICORE_FEATURE_161); } - if (tricore_feature(env, TRICORE_FEATURE_161)) { + if (tricore_has_feature(env, TRICORE_FEATURE_161)) { set_feature(env, TRICORE_FEATURE_16); } - if (tricore_feature(env, TRICORE_FEATURE_16)) { + if (tricore_has_feature(env, TRICORE_FEATURE_16)) { set_feature(env, TRICORE_FEATURE_131); } - if (tricore_feature(env, TRICORE_FEATURE_131)) { + if (tricore_has_feature(env, TRICORE_FEATURE_131)) { set_feature(env, TRICORE_FEATURE_13); } cpu_reset(cs); diff --git a/target/tricore/helper.c b/target/tricore/helper.c index 951024d491..731a6e9cb6 100644 --- a/target/tricore/helper.c +++ b/target/tricore/helper.c @@ -155,7 +155,7 @@ void psw_write(CPUTriCoreState *env, uint32_t val) #define FIELD_GETTER_WITH_FEATURE(NAME, REG, FIELD, FEATURE) \ uint32_t NAME(CPUTriCoreState *env) \ { \ - if (tricore_feature(env, TRICORE_FEATURE_##FEATURE)) { \ + if (tricore_has_feature(env, TRICORE_FEATURE_##FEATURE)) { \ return FIELD_EX32(env->REG, REG, FIELD ## _ ## FEATURE); \ } \ return FIELD_EX32(env->REG, REG, FIELD ## _13); \ @@ -170,7 +170,7 @@ uint32_t NAME(CPUTriCoreState *env) \ #define FIELD_SETTER_WITH_FEATURE(NAME, REG, FIELD, FEATURE) \ void NAME(CPUTriCoreState *env, uint32_t val) \ { \ - if (tricore_feature(env, TRICORE_FEATURE_##FEATURE)) { \ + if (tricore_has_feature(env, TRICORE_FEATURE_##FEATURE)) { \ env->REG = FIELD_DP32(env->REG, REG, FIELD ## _ ## FEATURE, val); \ } \ env->REG = FIELD_DP32(env->REG, REG, FIELD ## _13, val); \ diff --git a/target/tricore/op_helper.c b/target/tricore/op_helper.c index 821a4b67cb..89be1ed648 100644 --- a/target/tricore/op_helper.c +++ b/target/tricore/op_helper.c @@ -2584,7 +2584,7 @@ void helper_ret(CPUTriCoreState *env) /* PCXI = new_PCXI; */ env->PCXI = new_PCXI; - if (tricore_feature(env, TRICORE_FEATURE_131)) { + if (tricore_has_feature(env, TRICORE_FEATURE_131)) { /* PSW = {new_PSW[31:26], PSW[25:24], new_PSW[23:0]}; */ psw_write(env, (new_PSW & ~(0x3000000)) + (psw & (0x3000000))); } else { /* TRICORE_FEATURE_13 only */ @@ -2695,7 +2695,7 @@ void helper_rfm(CPUTriCoreState *env) env->gpr_a[10] = cpu_ldl_data(env, env->DCX+8); env->gpr_a[11] = cpu_ldl_data(env, env->DCX+12); - if (tricore_feature(env, TRICORE_FEATURE_131)) { + if (tricore_has_feature(env, TRICORE_FEATURE_131)) { env->DBGTCR = 0; } }