From patchwork Sat Nov 9 06:38:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 842064 Delivered-To: patch@linaro.org Received: by 2002:a5d:6307:0:b0:381:e71e:8f7b with SMTP id i7csp2028558wru; Fri, 8 Nov 2024 22:40:21 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU+uoLq+j9lc3dJP+1b/NpHQRjzuP5eomyuGOvFatYcz/IJ4TwoQtZWUP8Eh+X5geZWXg93Og==@linaro.org X-Google-Smtp-Source: AGHT+IFO1N33dWPM+9qEbCXpHcf/nuz22qlmuta3t7Ke8pjhK/j07KvzONvvBpIISwQuJrzBbs7k X-Received: by 2002:a05:620a:1999:b0:7a9:be53:fe3b with SMTP id af79cd13be357-7b331de24ecmr782754785a.14.1731134421103; Fri, 08 Nov 2024 22:40:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731134421; cv=none; d=google.com; s=arc-20240605; b=P3NQwW8KMHFfrBLXomjC7kk9GAQr5KtGYAdK49kVAFm9Kz9m7VOQV6vtgBRd8pfzXw 6p6XsTvoWKG16xh4luJKTb3jpOaPCH97+VXdrDeZqgsTI06y8mLMlvaUrpspIHslaCpn 9VAiiAyBON/fiOM3hEjw9PNDnHsEXaq+B1TFTWUKArUgXqfTnoLStbDm3pF0w+obOSi9 qJAbx9aOWb1YmZcjL4tgOZl2lhNVk1hqHWNuZmGoUldDU+C6CX1hYjbj/OaGsILfxMIq etT4Q6dr66RUkrzmjuIY/5ab/188eA8Zt0QpMVzG0CYCffktZt41wnhYqWShhfWjAlJi 3iVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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; bh=OSA/LUpQX0XgrjM3M+6BzZlQ+SLPocCQJI2bHxRO0zA=; fh=UbSczJHoK8QyPNwfbKMWepRwzNWZsm+gkdUzUXKForo=; b=IXkqowXKJo7qkA+L052v7ol8If5LKI0Mtp6LPyXSJLcsQrZ1vyyQTdVWWQL0022YTm rBLzJXnSDJ3IYRYL58XSqpjxaXMJUBLEPgyhZehjZXnCSsXnkXF85wDMtAVnyTCIS/EG vCFOCKCPlIhbGlx/cJ1VxU08958uLD8fwKWnAIRtZeNEndw+hK1/pSyZC0Jgby+Hmaq0 uAv2UVsFMieO5DkLWS1a7EJAYPGl5vjAreqaO3086ICOovjOFrmrY9GoWaCpx0n0oUg6 gLS6+9ntmudgGudAAKcYn5herapSePCCjRpWDxmV/5HZCqelPOCDLkrQ4O8jKl3n+IUY KA+w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b32acba63bsi569865185a.302.2024.11.08.22.40.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Nov 2024 22:40:21 -0800 (PST) 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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9f8R-0003NC-T6; Sat, 09 Nov 2024 01:39:52 -0500 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 1t9f87-00034A-Vr; Sat, 09 Nov 2024 01:39:32 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9f85-0001zF-Rs; Sat, 09 Nov 2024 01:39:31 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id BB164A12ED; Sat, 9 Nov 2024 09:38:09 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 3159F167DD1; Sat, 9 Nov 2024 09:39:04 +0300 (MSK) Received: (nullmailer pid 3272509 invoked by uid 1000); Sat, 09 Nov 2024 06:39:03 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Michael Tokarev Subject: [Stable-7.2.15 06/33] linux-user/flatload: Take mmap_lock in load_flt_binary() Date: Sat, 9 Nov 2024 09:38:32 +0300 Message-Id: <20241109063903.3272404-6-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé load_flt_binary() calls load_flat_file() -> page_set_flags(). page_set_flags() must be called with the mmap_lock held, otherwise it aborts: $ qemu-arm -L stm32/lib/ stm32/bin/busybox qemu-arm: ../accel/tcg/user-exec.c:505: page_set_flags: Assertion `have_mmap_lock()' failed. Aborted (core dumped) Fix by taking the lock in load_flt_binary(). Fixes: fbd3c4cff6 ("linux-user/arm: Mark the commpage executable") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2525 Suggested-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-ID: <20240822095045.72643-3-philmd@linaro.org> Signed-off-by: Richard Henderson (cherry picked from commit a9ee641bd46f5462eeed183ac3c3760bddfc2600) Signed-off-by: Michael Tokarev diff --git a/linux-user/flatload.c b/linux-user/flatload.c index e99570ca18..7f243500b3 100644 --- a/linux-user/flatload.c +++ b/linux-user/flatload.c @@ -747,7 +747,10 @@ int load_flt_binary(struct linux_binprm *bprm, struct image_info *info) stack_len += (bprm->envc + 1) * 4; /* the envp array */ + mmap_lock(); res = load_flat_file(bprm, libinfo, 0, &stack_len); + mmap_unlock(); + if (is_error(res)) { return res; } From patchwork Sat Nov 9 06:38:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 842065 Delivered-To: patch@linaro.org Received: by 2002:a5d:6307:0:b0:381:e71e:8f7b with SMTP id i7csp2029137wru; Fri, 8 Nov 2024 22:43:09 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUKTNvhH5vXLHCcsSpbdD1hJWVZ8r2577RMKLhm1ozfXJksWbHwIfqGmp1IW0KiZlMrnctGfA==@linaro.org X-Google-Smtp-Source: AGHT+IGft3z3XzxslC9EjzwiZL56e5oiBIdOlbbLswx00Y2TGeUPxJKAdDkFU8WW+3JSWJFu7HfU X-Received: by 2002:a05:620a:1a8e:b0:7b1:4579:80fc with SMTP id af79cd13be357-7b331f26ac7mr627526585a.60.1731134589509; Fri, 08 Nov 2024 22:43:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731134589; cv=none; d=google.com; s=arc-20240605; b=O+yWZbRxP245p1cgYZNCb6dCzuktWj+PU4bLRr3TQkgSkhaCggOcSkE7xFBT3lMHS+ Sgi6puOxG9aHUSRopd1hrzgnKG/RgAicbgfzo6D+k0sBoe7g+RHbHYRwr8muM9QYYdH2 T7Axa3dStW8fW5PRc7/LW4gTXFUGWRrYr8kAhipeHCvw5uDoTAIQ40RCWAKNRFd52FAT 2ZamOsF5MAAlm3s6xw5QLsJru1Wjhfyr7SGfwYNlHwugBvEvmePM76bimAWZhJ4sx5hl qWB4ASRy8LtDSm/W7S/CAdcwe5KQ+sWahvUwJEzwj+fxvv18LlcfhRPvNrLwxsm4tGPb iRyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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; bh=fW3xlArfAu+YmkvscocZkepM8sSJXeunOlMRfvOKqqU=; fh=K4abbxCgZAPvqzOXA+PZ7RIZh+KufMVJze7rXLOwES0=; b=F8TKYfTUuTIjOgDanJQhdIYtuZnM0aitn1PovZkhjxzosxPfbUZQfLzFj+YBG8cEGU DbJK0K4+S1wbq4mjpi6ngEdVjSSw4poqHfDnXmM0Hf8fFj9MOKLk4I+HhwkIho3g24hp W2jPYFLiSLYhTlSd3WdviAmdsxcXiJuoS1WrRt99DJMMMd8yVcFC6BRyHf0Wa8qPD343 LhTf8lJhsZ4QUOJr12aIAQ3e5gGPxMOaltRDPre4GlCm95+HPcXTEA+JwJCWAdxm6rcm tFJj+e+x6sG7pKPD5nHPp6mcZJ+0qN4PT/4c2M5u0laeMcxhGZXS33/a6yLJe0whX+t5 1L0A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b32acfbe22si612068585a.480.2024.11.08.22.43.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Nov 2024 22:43:09 -0800 (PST) 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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9f8N-0003Co-PE; Sat, 09 Nov 2024 01:39:47 -0500 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 1t9f8C-00035K-6h; Sat, 09 Nov 2024 01:39:40 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9f87-000208-1P; Sat, 09 Nov 2024 01:39:33 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id C94B2A12EE; Sat, 9 Nov 2024 09:38:09 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 3F71B167DD2; Sat, 9 Nov 2024 09:39:04 +0300 (MSK) Received: (nullmailer pid 3272512 invoked by uid 1000); Sat, 09 Nov 2024 06:39:03 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Michael Tokarev Subject: [Stable-7.2.15 07/33] linux-user: Fix parse_elf_properties GNU0_MAGIC check Date: Sat, 9 Nov 2024 09:38:33 +0300 Message-Id: <20241109063903.3272404-7-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Comparing a string of 4 bytes only works in little-endian. Adjust bulk bswap to only apply to the note payload. Perform swapping of the note header manually; the magic is defined so that it does not need a runtime swap. Fixes: 83f990eb5adb ("linux-user/elfload: Parse NT_GNU_PROPERTY_TYPE_0 notes") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2596 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael Tokarev (cherry picked from commit 2884596f5f385b5712c356310dd4125a089888a8) Signed-off-by: Michael Tokarev diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 87895847ec..97528a13ed 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2899,11 +2899,11 @@ static bool parse_elf_properties(int image_fd, } /* - * The contents of a valid PT_GNU_PROPERTY is a sequence - * of uint32_t -- swap them all now. + * The contents of a valid PT_GNU_PROPERTY is a sequence of uint32_t. + * Swap most of them now, beyond the header and namesz. */ #ifdef BSWAP_NEEDED - for (int i = 0; i < n / 4; i++) { + for (int i = 4; i < n / 4; i++) { bswap32s(note.data + i); } #endif @@ -2913,15 +2913,15 @@ static bool parse_elf_properties(int image_fd, * immediately follows nhdr and is thus at the 4th word. Further, all * of the inputs to the kernel's round_up are multiples of 4. */ - if (note.nhdr.n_type != NT_GNU_PROPERTY_TYPE_0 || - note.nhdr.n_namesz != NOTE_NAME_SZ || + if (tswap32(note.nhdr.n_type) != NT_GNU_PROPERTY_TYPE_0 || + tswap32(note.nhdr.n_namesz) != NOTE_NAME_SZ || note.data[3] != GNU0_MAGIC) { error_setg(errp, "Invalid note in PT_GNU_PROPERTY"); return false; } off = sizeof(note.nhdr) + NOTE_NAME_SZ; - datasz = note.nhdr.n_descsz + off; + datasz = tswap32(note.nhdr.n_descsz) + off; if (datasz > n) { error_setg(errp, "Invalid note size in PT_GNU_PROPERTY"); return false; From patchwork Sat Nov 9 06:38:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 842070 Delivered-To: patch@linaro.org Received: by 2002:a5d:6307:0:b0:381:e71e:8f7b with SMTP id i7csp2030052wru; Fri, 8 Nov 2024 22:47:38 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVkQTlwM0RLTLUdcy5pLltWHLWOVMzBf1qtZC3otahC/rdJL4Eev/CrhcVeqYyZcT1GWrBLrQ==@linaro.org X-Google-Smtp-Source: AGHT+IEUOqxZ4VFTh0LFNVcspasdmDm0jjJz1zK/tW6gTY5Bx0iS7Efcv1cZUiJKIPQp0uGu9/m/ X-Received: by 2002:a05:622a:13ca:b0:461:20b0:9909 with SMTP id d75a77b69052e-4630935ccf7mr78411771cf.29.1731134858366; Fri, 08 Nov 2024 22:47:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731134858; cv=none; d=google.com; s=arc-20240605; b=DQTCllvBDwR9RDm3jDLrPg3WjOWwP1SMfXEgOpSHuW2vAWGdJw+T5aBE8VRObGUf7q MTgreAXfWwvy4jOKcFs8gurl/e5NaEEX92/7AwaAWxBLNFTCreS2VEj7fjIIQuNJmAZV qXihs1tIh/9gbbhUnNGmaGrpk/s89CsizdoACV6Pi2W/kpHINrkooi6BK/aa1Iqfym4Z x0TmDCRZZqSBi5SXVcHpMVL5HodBHjPUPSSZB3Js8bV9VdGZTosbdKqECOzkaHrE/CeT JQvIfjy+yygyzE8fQ4fPdJ412RU8JS4yWvsJ9T8mjTvpvd5UkAOLyMT/6HmTu0XJxwIf fKgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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; bh=gBZN0nJOG5+3fXJtYDlkUQ0Qew6bIqgwSyCBRtxVPug=; fh=vuhzQW7LNVNfoCzrQU/zlJ6j/7aL6vBNEyQhm6VZot4=; b=FYVGRQrJwPSs1sSUenPc5fXD1auWg9mBTu2BlT91bODYMLThkiWzXMp09IL8J0FYLM dV9hQSsmbwZ/U+Y6+gJVkwmqL1kU/ZPU4MP/dklQm492J8jn5jSmcHg5HosTKJs0Gd+o e4ztsuz3I0UBLeN9pCU9ImQgbRndqUB9AqQ8T5FC2JB6xYbDidkTQK3pNh3xnto0Pjz4 yfn+GAURQpZO2OZs2Jvq+DRjnOb81J9w583fdmnUL83JvD3CYGlrzHFQf4sTXtNRrlou HLk7IDou2xffz6W9SlkQf3SccqwtPzuNDGYkSz86pfJIy27vlOFe5QNdzmvV3rj1q1m8 0vmQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-462ff680c98si57144071cf.594.2024.11.08.22.47.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Nov 2024 22:47:38 -0800 (PST) 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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9f9V-00058R-St; Sat, 09 Nov 2024 01:40:58 -0500 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 1t9f8m-0003yI-V5; Sat, 09 Nov 2024 01:40:14 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9f8k-0002Qx-5x; Sat, 09 Nov 2024 01:40:11 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 5F819A12F6; Sat, 9 Nov 2024 09:38:10 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id C6A58167DDA; Sat, 9 Nov 2024 09:39:04 +0300 (MSK) Received: (nullmailer pid 3272537 invoked by uid 1000); Sat, 09 Nov 2024 06:39:03 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Alistair Francis , Pierrick Bouvier , LIU Zhiwei , Michael Tokarev Subject: [Stable-7.2.15 15/33] tcg: Reset data_gen_ptr correctly Date: Sat, 9 Nov 2024 09:38:41 +0300 Message-Id: <20241109063903.3272404-15-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson This pointer needs to be reset after overflow just like code_buf and code_ptr. Cc: qemu-stable@nongnu.org Fixes: 57a269469db ("tcg: Infrastructure for managing constant pools") Acked-by: Alistair Francis Reviewed-by: Pierrick Bouvier Reviewed-by: LIU Zhiwei Signed-off-by: Richard Henderson (cherry picked from commit a7cfd751fb269de4a93bf1658cb13911c7ac77cc) Signed-off-by: Michael Tokarev diff --git a/tcg/tcg.c b/tcg/tcg.c index 436fcf6ebd..e7aa02c447 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -716,7 +716,6 @@ TranslationBlock *tcg_tb_alloc(TCGContext *s) goto retry; } qatomic_set(&s->code_gen_ptr, next); - s->data_gen_ptr = NULL; return tb; } @@ -4249,6 +4248,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb, target_ulong pc_start) */ s->code_buf = tcg_splitwx_to_rw(tb->tc.ptr); s->code_ptr = s->code_buf; + s->data_gen_ptr = NULL; #ifdef TCG_TARGET_NEED_LDST_LABELS QSIMPLEQ_INIT(&s->ldst_labels); From patchwork Sat Nov 9 06:38:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 842067 Delivered-To: patch@linaro.org Received: by 2002:a5d:6307:0:b0:381:e71e:8f7b with SMTP id i7csp2029262wru; Fri, 8 Nov 2024 22:43:48 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUb5UYCRmMmHX3ucfrgsZuCAffNHugxp9mvXNx6ouZO6zcpsa+KhA3wuIaTHjoOHz/GjVYPkw==@linaro.org X-Google-Smtp-Source: AGHT+IHnG08cDayiSz3En8PfbrhnFUixc88Iw+hwTBON4g7OSlgU6dWsHEg/ORakyn+AiprS1hnn X-Received: by 2002:a05:622a:4d05:b0:462:c42e:7400 with SMTP id d75a77b69052e-463085b8166mr113415771cf.6.1731134628104; Fri, 08 Nov 2024 22:43:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731134628; cv=none; d=google.com; s=arc-20240605; b=M/AjY0cPb/rRmwyY/3CocAQcJTZxniPnyAxfqN2ljFnZrpjfQtF/i0pUUQAqULtWDt DpwiXDPDyG27F/tLkGmzr9aqscE+53619sZETiDIsRGPL+J0cFo9RTiwf/2gaCoBF2eC B2yfVgWlq9R1C76+nFAKRI1k9kXwUYILU46+cI9GpKHnYPEXgTn1Flnw5pX35VhBxsa9 kk9+BM6wRoc6r0jc9fdRHBtL6ZqzXMKgpX0yLmLwzCN5RAT0gfPYZxmndWjEEHUB7pbI Q2OfOvM7/2FyF9GxxsiWZjlZECfD45uXbRccM/EGBgib+Q175vg03ynxm6xA5ylxu+xb KGqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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; bh=G/pG8V+L7q75qLYYRXU16ZBdvnPH9cgfQwFrq4SrMnw=; fh=tMa47au2sw5piyxOJuQsGBLvYh0d/gfD9bj/VCraw+I=; b=Tcp1SDFNpbQTJnXIT1ELggAf78F6AJtZGNtyPDh6oLjdZ/wGgB1ICThD+fdHQe5tv6 2E2MHajvtTDHD3pdLVYWr+mwdrBQRMFT0vxmPqJ4nBs1FM4ELRtrrz7G6ddSSinCsIrl +e4B5JLPMJ+KP3Q+SxvBXb0C9m3HjGlSQJA3FKPulFjseemLGI5TPmk75won4tp/gbBp fwy3Cbl2uZ3T+7R16Hiy38Vq+J+ebjgJ+SkbIRD8dliFUjQmPVpo0VAjdrHnWYfOyYbO QNNpnAyICAIcjwJEWXJSw+h+rZ2wzSa11FHCIJ1Woy+r1vgZIWbBdIwbPj0Swqy0+gqw OM/w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-462ff675c82si55683791cf.556.2024.11.08.22.43.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Nov 2024 22:43:48 -0800 (PST) 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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9f9n-0005Ux-I7; Sat, 09 Nov 2024 01:41:18 -0500 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 1t9f8o-0003zX-4q; Sat, 09 Nov 2024 01:40:14 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9f8k-0002RY-Rg; Sat, 09 Nov 2024 01:40:13 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 6D8A0A12F7; Sat, 9 Nov 2024 09:38:10 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id D7E0E167DDB; Sat, 9 Nov 2024 09:39:04 +0300 (MSK) Received: (nullmailer pid 3272540 invoked by uid 1000); Sat, 09 Nov 2024 06:39:03 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Peter Maydell , Paolo Bonzini , Michael Tokarev Subject: [Stable-7.2.15 16/33] target/i386: Avoid unreachable variable declaration in mmu_translate() Date: Sat, 9 Nov 2024 09:38:42 +0300 Message-Id: <20241109063903.3272404-16-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Peter Maydell Coverity complains (CID 1507880) that the declaration "int error_code;" in mmu_translate() is unreachable code. Since this is only a declaration, this isn't actually a bug, but: * it's a bear-trap for future changes, because if it was changed to include an initialization 'int error_code = foo;' then the initialization wouldn't actually happen (being dead code) * it's against our coding style, which wants declarations to be at the start of blocks * it means that anybody reading the code has to go and look up exactly what the C rules are for skipping over variable declarations using a goto Move the declaration to the top of the function. Signed-off-by: Peter Maydell Message-Id: <20230406155946.3362077-1-peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini (cherry picked from commit 987b63f24afe027a09b1c549c05a032a477f7e96) Signed-off-by: Michael Tokarev (Mjt: cherry-pick this for stable-7.2 so that the next patch applies cleanly) diff --git a/target/i386/tcg/sysemu/excp_helper.c b/target/i386/tcg/sysemu/excp_helper.c index 5f13252d68..eb78fcba11 100644 --- a/target/i386/tcg/sysemu/excp_helper.c +++ b/target/i386/tcg/sysemu/excp_helper.c @@ -146,6 +146,7 @@ static bool mmu_translate(CPUX86State *env, const TranslateParams *in, hwaddr pte_addr, paddr; uint32_t pkr; int page_size; + int error_code; restart_all: rsvd_mask = ~MAKE_64BIT_MASK(0, env_archcpu(env)->phys_bits); @@ -464,7 +465,6 @@ do_check_protect_pse36: out->page_size = page_size; return true; - int error_code; do_fault_rsvd: error_code = PG_ERROR_RSVD_MASK; goto do_fault_cont; From patchwork Sat Nov 9 06:38:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 842066 Delivered-To: patch@linaro.org Received: by 2002:a5d:6307:0:b0:381:e71e:8f7b with SMTP id i7csp2029161wru; Fri, 8 Nov 2024 22:43:13 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW7D2dQSgU5ENpaXm3OZ3v4Jp+M8tbZLpzD2ifD9LoYv3CxjoQjg/p4/ApG8oHpXPTUUz0kuw==@linaro.org X-Google-Smtp-Source: AGHT+IF5QLqAycSYT5G5otsv7EgeCQS0Mu0lai6wSLQCRUypJamqugA22DYGUDa5Q4P51uKpWU0A X-Received: by 2002:a05:620a:25cf:b0:7b1:7f5b:72c7 with SMTP id af79cd13be357-7b331e98d8amr801617885a.1.1731134593638; Fri, 08 Nov 2024 22:43:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731134593; cv=none; d=google.com; s=arc-20240605; b=O+Reso2zL0Dlc79vqnm2qQMaT/MXdh0N7SsBYlsC5ZLOf8hqkukkIqcYNMY2/IZhqh 5eVeYR2irUDSfeAOMGB+ZOk/xufTHFltlonJ3/9n9Ac/HQho9cmIhW95pjh11rseByxo RzktHpEUMNU77QmSN5Gzy2ukuSRSZ9XOHyUou6wSPVmklaSi3FTinELW1hzGqcwiSxkE fNSQoDYrOgrJ9bjgebalj7eK+YuIfZvzgu5+MKobS1/SUdJt/VnZNgFxLtqVa4iYLdMa qb3fjBTtqThK42+Q/5+IRsVuduc3YPI8YvuUc0CoyMpaRQuHBboTysX7dZeRbygLqLua 7i4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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; bh=W//s0qTbXHTebXGJydI+ArO79+LkOZf6xdmo+4ffi+8=; fh=QunmYwzbXWilzKUSCm5rGLvrKB9FGWCyqo7FW/+IwZI=; b=Ubag50SVcqSuyUSmWdRGaRbxJmDlm9AAyh7EuaSE/+d6Bko19IAGo04N8Bymoweudb rWLhCQVuKP7XBtvrBryfHLpLrHYboFJjUc27hP4/lyxBbteCJeh7QOIhngMXDMvuVYsh ODT8UNnZFHEb9+4kHybBnt6FksCaI5qPrWHzhwConnFY5l6zSlRhoy7IM6Ovc9n5sFHZ q1i+wLk+qF1z56lyzICAprcVwAIYYXqnIXBQSKq3/ExxF/AqRTxV03D5mJccBgAYAqxI oWAkSqujFkBuKfg/93X1tB8nmWfezIHFTBVrpirOqdx4W2RqZxWUFcHhyb6UhXvaGpJI ee4Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b32ac3d5b3si627044085a.137.2024.11.08.22.43.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Nov 2024 22:43:13 -0800 (PST) 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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9fAl-0006am-RM; Sat, 09 Nov 2024 01:42:22 -0500 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 1t9f9E-0004Vt-Jt; Sat, 09 Nov 2024 01:40:40 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9f9C-0002VD-JA; Sat, 09 Nov 2024 01:40:40 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id A638EA12FB; Sat, 9 Nov 2024 09:38:10 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 1C5F5167DDE; Sat, 9 Nov 2024 09:39:05 +0300 (MSK) Received: (nullmailer pid 3272550 invoked by uid 1000); Sat, 09 Nov 2024 06:39:03 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Daniel_P_?= =?utf-8?q?=2E_Berrang=C3=A9?= , Michael Tokarev Subject: [Stable-7.2.15 19/33] gitlab: make check-[dco|patch] a little more verbose Date: Sat, 9 Nov 2024 09:38:45 +0300 Message-Id: <20241109063903.3272404-19-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Alex Bennée When git fails the rather terse backtrace only indicates it failed without some useful context. Add some to make the log a little more useful. Reviewed-by: Daniel P. Berrangé Signed-off-by: Alex Bennée Message-Id: <20241023113406.1284676-11-alex.bennee@linaro.org> (cherry picked from commit 97f116f9c6fd127b6ed2953993fa9fb05e82f450) Signed-off-by: Michael Tokarev (Mjt: context fix for stable-7.2) diff --git a/.gitlab-ci.d/check-dco.py b/.gitlab-ci.d/check-dco.py index b929571eed..8780d73e31 100755 --- a/.gitlab-ci.d/check-dco.py +++ b/.gitlab-ci.d/check-dco.py @@ -19,10 +19,9 @@ reponame = os.path.basename(cwd) repourl = "https://gitlab.com/%s/%s.git" % (namespace, reponame) +print(f"adding upstream git repo @ {repourl}") subprocess.check_call(["git", "remote", "add", "check-dco", repourl]) -subprocess.check_call(["git", "fetch", "check-dco", "stable-7.2"], - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL) +subprocess.check_call(["git", "fetch", "check-dco", "stable-7.2"]) ancestor = subprocess.check_output(["git", "merge-base", "check-dco/stable-7.2", "HEAD"], diff --git a/.gitlab-ci.d/check-patch.py b/.gitlab-ci.d/check-patch.py index 39e2b403c9..68c549a146 100755 --- a/.gitlab-ci.d/check-patch.py +++ b/.gitlab-ci.d/check-patch.py @@ -19,13 +19,12 @@ reponame = os.path.basename(cwd) repourl = "https://gitlab.com/%s/%s.git" % (namespace, reponame) +print(f"adding upstream git repo @ {repourl}") # GitLab CI environment does not give us any direct info about the # base for the user's branch. We thus need to figure out a common # ancestor between the user's branch and current git master. subprocess.check_call(["git", "remote", "add", "check-patch", repourl]) -subprocess.check_call(["git", "fetch", "check-patch", "master"], - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL) +subprocess.check_call(["git", "fetch", "check-patch", "master"]) ancestor = subprocess.check_output(["git", "merge-base", "check-patch/master", "HEAD"], From patchwork Sat Nov 9 06:38:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 842068 Delivered-To: patch@linaro.org Received: by 2002:a5d:6307:0:b0:381:e71e:8f7b with SMTP id i7csp2029268wru; Fri, 8 Nov 2024 22:43:50 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWQGyM/LeDhJ5TdYnyFRgg9JHbrSyjS6+n7iExH8CJXHoxGs5kpDwyzWjs24zU7ncLmeP5uYw==@linaro.org X-Google-Smtp-Source: AGHT+IGDY64DpYHJAbLZmN0Yn4If2m6OYYbDZUx74scYSdevibvy71bM8DBkB18sC793Q9hiLDnm X-Received: by 2002:a05:6214:3290:b0:6cb:ee76:fee1 with SMTP id 6a1803df08f44-6d39e1caa37mr70479086d6.41.1731134629882; Fri, 08 Nov 2024 22:43:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731134629; cv=none; d=google.com; s=arc-20240605; b=hJfZ7ZukgV78gm+PqzpQJfyO6Oh31vA5JRrtHdm/30dfw0TR/TsEQQT9KsaITUWycp ygv7CjdYf96nhSgj+9Ux2D6L3lcfA2HqwK/HI9nP9tfoZefdCWVl20+xuDgjEnN7P5Nu JZT0NFn2tmNfqkkM+WJCEcMVzbompT1vcJ2G9dgzdVO13CPOtd+muB5IyRIq84tCZh0M 8ukeQDy8xjiRHTYBAXet1j2KoqFAc9e/90oxAl7sg2RqETAG/iS1Mp63fAKkUQpboEPZ KL8QgoQ8hs3RQOAX6vmHW4yqCW992NKnOzOLMU6qRMp2JBqJY28ehsOq7mWBWA+1R/hj UMKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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; bh=uwJgWH3aMcK7yI8RY3lQM775d/JCz9pT4VuLG0z9ros=; fh=GanseRjrcQuAMREH5dzTEIrzdKej3kFdmGlqcUMu4ko=; b=keqsUOv2Wk8cRs3h5IyGAjfhyR46MxLHQbB59tRmuQGo08Aj0rEfHD+ht2NzYSCJmg rVknFAYbovQvUQLat0IsmamiV4SZUy+WWdOoNgX/b4OwXNhcFYc/TlVsRLobdLtiqIVO WX6/9FW+i+X2gxofjM+v/lczPsmqsFkC2kpFesclnUUBci8VTOZnGnyT/ufAiWRe3Db3 YmjL3fN89GBElqFfUNVd7D5yx/vKR1ymQlMuPdqivogPI2AGOCzFfpgg/GvOFWFAljLU 265iFUI074O4fzXccDxIuum/7aYP9/71jWl/UxNdYtA3pdU5ioTYtkDjfcbjHEq8y+TI KaBg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6d3966682d5si61773436d6.393.2024.11.08.22.43.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Nov 2024 22:43:49 -0800 (PST) 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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9fBk-0000jT-76; Sat, 09 Nov 2024 01:43:16 -0500 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 1t9f9b-0005LN-Vw; Sat, 09 Nov 2024 01:41:04 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9f9a-0002YU-Cj; Sat, 09 Nov 2024 01:41:03 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id D6D40A12FE; Sat, 9 Nov 2024 09:38:10 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 4AB46167DE1; Sat, 9 Nov 2024 09:39:05 +0300 (MSK) Received: (nullmailer pid 3272559 invoked by uid 1000); Sat, 09 Nov 2024 06:39:03 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Peter Maydell , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Michael Tokarev Subject: [Stable-7.2.15 22/33] target/arm: Don't assert in regime_is_user() for E10 mmuidx values Date: Sat, 9 Nov 2024 09:38:48 +0300 Message-Id: <20241109063903.3272404-22-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Peter Maydell In regime_is_user() we assert if we're passed an ARMMMUIdx_E10_* mmuidx value. This used to make sense because we only used this function in ptw.c and would never use it on this kind of stage 1+2 mmuidx, only for an individual stage 1 or stage 2 mmuidx. However, when we implemented FEAT_E0PD we added a callsite in aa64_va_parameters(), which means this can now be called for stage 1+2 mmuidx values if the guest sets the TCG_ELX.{E0PD0,E0PD1} bits to enable use of the feature. This will then result in an assertion failure later, for instance on a TLBI operation: #6 0x00007ffff6d0e70f in g_assertion_message_expr (domain=0x0, file=0x55555676eeba "../../target/arm/internals.h", line=978, func=0x555556771d48 <__func__.5> "regime_is_user", expr=) at ../../../glib/gtestutils.c:3279 #7 0x0000555555f286d2 in regime_is_user (env=0x555557f2fe00, mmu_idx=ARMMMUIdx_E10_0) at ../../target/arm/internals.h:978 #8 0x0000555555f3e31c in aa64_va_parameters (env=0x555557f2fe00, va=18446744073709551615, mmu_idx=ARMMMUIdx_E10_0, data=true, el1_is_aa32=false) at ../../target/arm/helper.c:12048 #9 0x0000555555f3163b in tlbi_aa64_get_range (env=0x555557f2fe00, mmuidx=ARMMMUIdx_E10_0, value=106721347371041) at ../../target/arm/helper.c:5214 #10 0x0000555555f317e8 in do_rvae_write (env=0x555557f2fe00, value=106721347371041, idxmap=21, synced=true) at ../../target/arm/helper.c:5260 #11 0x0000555555f31925 in tlbi_aa64_rvae1is_write (env=0x555557f2fe00, ri=0x555557fbeae0, value=106721347371041) at ../../target/arm/helper.c:5302 #12 0x0000555556036f8f in helper_set_cp_reg64 (env=0x555557f2fe00, rip=0x555557fbeae0, value=106721347371041) at ../../target/arm/tcg/op_helper.c:965 Since we do know whether these mmuidx values are for usermode or not, we can easily make regime_is_user() handle them: ARMMMUIdx_E10_0 is user, and the other two are not. Cc: qemu-stable@nongnu.org Fixes: e4c93e44ab103f ("target/arm: Implement FEAT_E0PD") Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Tested-by: Alex Bennée Message-id: 20241017172331.822587-1-peter.maydell@linaro.org (cherry picked from commit 1505b651fdbd9af59a4a90876a62ae7ea2d4cd39) Signed-off-by: Michael Tokarev diff --git a/target/arm/internals.h b/target/arm/internals.h index 3c7ff51c99..bdd89ae21e 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -723,6 +723,7 @@ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) { switch (mmu_idx) { + case ARMMMUIdx_E10_0: case ARMMMUIdx_E20_0: case ARMMMUIdx_Stage1_E0: case ARMMMUIdx_MUser: @@ -732,10 +733,6 @@ static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) return true; default: return false; - case ARMMMUIdx_E10_0: - case ARMMMUIdx_E10_1: - case ARMMMUIdx_E10_1_PAN: - g_assert_not_reached(); } } From patchwork Sat Nov 9 06:38:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 842069 Delivered-To: patch@linaro.org Received: by 2002:a5d:6307:0:b0:381:e71e:8f7b with SMTP id i7csp2029694wru; Fri, 8 Nov 2024 22:45:52 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWaMgmcJKckijJH0HOjtTmnElCGXRrX9LH9l/4SUvAvmSJ2dIzU7f2H6vacFAf4G3xTcXh9ew==@linaro.org X-Google-Smtp-Source: AGHT+IFC/dJvQOdCt2N1WfzEtyu+O1tDHcsIUCTkBpxX/Pm9JE5Z4BnQPNPGvJdvrtB5IkHB4lq5 X-Received: by 2002:a05:620a:2614:b0:7b1:19f4:c6e0 with SMTP id af79cd13be357-7b331f195dbmr602826285a.51.1731134751886; Fri, 08 Nov 2024 22:45:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731134751; cv=none; d=google.com; s=arc-20240605; b=MpDMq4ON2fCf55SIygqvdF8R7vz08zT38WII5GAP3CwRWN1BLqRx/ASz16tXjWZWPy 5/hAinpGBPsMHZrPx9G/J9ihmcELsYFArf8FQFIkWqFcCkP1PdVs7vh5dS5eypX6YZ0R udQFG1mFVGJELqEj1koZ29tChYHCceEGfttPuu9tmWTgnlSnWI21azEK3i2e7UkQZM+K AypeV6wXfYZqjW+Ow4SMEHRLjwCKFcsEbIuCON6XGysveznRBs9oKplZIobNk5p7hBoO bMhLoN/hn8kh4XR6PStHb3PbMjFS22zMYprxuYLE/QxyZt5NH+1CJWiKEmb/SqmDqqqo opTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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; bh=s6VnczZAxDGa9M7lb3DR0bTFTe8PPh9Yge8gIp/wd0k=; fh=xJ1URYKcMN3TM0/XAv5v+aCN+5tIbzAdcfBx5UNgoLw=; b=L7z5BEM9xxEnSmyUu14l54gwhvMLz2O9fcGKZoBZkNkZraMwrCRmh2YYPr6S2t71e/ 4k4eEZeoywgyPqP2l/SlEGKxT4vE9W3P0HezBDusmbEnMDyxyt2ZsKWw38qy9H0SONs/ C6CNLsVFzVyzUxbEZvySxpPttnk2kIcgwrpMtcaovJecXYELVZijXTJoISvLimflHCgE e9RsZe1i6kgmkyx6DRAusy4qU7rnbKTnGDZz0YrUo0DhBnVWnkJf+kGf3wNVl8nQbRfJ ZHAvmENUUntKyWfmeqBpam0v7gst6LnsRHaaRlYvL//lqO39O0xqYeeg0PyOQP5hIKhV HVpg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b32acba1a2si599463885a.328.2024.11.08.22.45.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Nov 2024 22:45:51 -0800 (PST) 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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9fC3-0001zh-Dp; Sat, 09 Nov 2024 01:43:36 -0500 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 1t9fAW-0006aV-7p; Sat, 09 Nov 2024 01:42:04 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9fAU-0002dH-8t; Sat, 09 Nov 2024 01:41:59 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 82D2DA1308; Sat, 9 Nov 2024 09:38:11 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id E1945167DEA; Sat, 9 Nov 2024 09:39:05 +0300 (MSK) Received: (nullmailer pid 3272587 invoked by uid 1000); Sat, 09 Nov 2024 06:39:03 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Peter Maydell , Richard Henderson , Michael Tokarev Subject: [Stable-7.2.15 31/33] target/arm: Fix SVE SDOT/UDOT/USDOT (4-way, indexed) Date: Sat, 9 Nov 2024 09:38:57 +0300 Message-Id: <20241109063903.3272404-31-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Peter Maydell Our implementation of the indexed version of SVE SDOT/UDOT/USDOT got the calculation of the inner loop terminator wrong. Although we correctly account for the element size when we calculate the terminator for the first iteration: intptr_t segend = MIN(16 / sizeof(TYPED), opr_sz_n); we don't do that when we move it forward after the first inner loop completes. The intention is that we process the vector in 128-bit segments, which for a 64-bit element size should mean (1, 2), (3, 4), (5, 6), etc. This bug meant that we would iterate (1, 2), (3, 4, 5, 6), (7, 8, 9, 10) etc and apply the wrong indexed element to some of the operations, and also index off the end of the vector. You don't see this bug if the vector length is small enough that we don't need to iterate the outer loop, i.e. if it is only 128 bits, or if it is the 64-bit special case from AA32/AA64 AdvSIMD. If the vector length is 256 bits then we calculate the right results for the elements in the vector but do index off the end of the vector. Vector lengths greater than 256 bits see wrong answers. The instructions that produce 32-bit results behave correctly. Fix the recalculation of 'segend' for subsequent iterations, and restore a version of the comment that was lost in the refactor of commit 7020ffd656a5 that explains why we only need to clamp segend to opr_sz_n for the first iteration, not the later ones. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2595 Fixes: 7020ffd656a5 ("target/arm: Macroize helper_gvec_{s,u}dot_idx_{b,h}") Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20241101185544.2130972-1-peter.maydell@linaro.org (cherry picked from commit e6b2fa1b81ac6b05c4397237c846a295a9857920) Signed-off-by: Michael Tokarev diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c index 859366e264..77678aca78 100644 --- a/target/arm/vec_helper.c +++ b/target/arm/vec_helper.c @@ -691,6 +691,13 @@ void HELPER(NAME)(void *vd, void *vn, void *vm, void *va, uint32_t desc) \ { \ intptr_t i = 0, opr_sz = simd_oprsz(desc); \ intptr_t opr_sz_n = opr_sz / sizeof(TYPED); \ + /* \ + * Special case: opr_sz == 8 from AA64/AA32 advsimd means the \ + * first iteration might not be a full 16 byte segment. But \ + * for vector lengths beyond that this must be SVE and we know \ + * opr_sz is a multiple of 16, so we need not clamp segend \ + * to opr_sz_n when we advance it at the end of the loop. \ + */ \ intptr_t segend = MIN(16 / sizeof(TYPED), opr_sz_n); \ intptr_t index = simd_data(desc); \ TYPED *d = vd, *a = va; \ @@ -708,7 +715,7 @@ void HELPER(NAME)(void *vd, void *vn, void *vm, void *va, uint32_t desc) \ n[i * 4 + 2] * m2 + \ n[i * 4 + 3] * m3); \ } while (++i < segend); \ - segend = i + 4; \ + segend = i + (16 / sizeof(TYPED)); \ } while (i < opr_sz_n); \ clear_tail(d, opr_sz, simd_maxsz(desc)); \ }