From patchwork Wed Feb 21 21:46: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: 774540 Delivered-To: patch@linaro.org Received: by 2002:a5d:6ac2:0:b0:33b:4db1:f5b3 with SMTP id u2csp469834wrw; Wed, 21 Feb 2024 13:50:46 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVIoq+xqNvtMe6J1umIiVmX6Wwko4FkN3WryEGE5x5QMGhiYlh1WmSImmF3bM6pqJkKcd1BOOXFd3j3P+y5h1E5 X-Google-Smtp-Source: AGHT+IEWstdOzmeYbe9Wm/qZrFzoNFDt8Y++fgD0CEHe+GkCSb6LfmELtt+B3s1Zg1UJRv6zdt/1 X-Received: by 2002:adf:f488:0:b0:33d:7f4:8ce4 with SMTP id l8-20020adff488000000b0033d07f48ce4mr11616510wro.59.1708552246531; Wed, 21 Feb 2024 13:50:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708552246; cv=none; d=google.com; s=arc-20160816; b=wowfJINg0fboIv7TQHBzbP2kh2VHvSNSuaDgwLTL1ZHE3/ixfPSOmMMaUBGvOTbBa5 SorE649aBXFl+xgMlLOYNqeM0Hxl+rTxE9NNujinKCp7jO1/szN7Z2e64TXSxpx+W4zJ Q36qd9659jyM34AzhjyGmvcTgkBada81Pd1NJDNyaitUUOKtyRaIRK+lWt3r5Pzr2T+y GiYQIVzo7B0EQiGaYW8FvyQ74epjfWvUJNMvvlrjMrTsgLgDOj9flkpPNwuqCobyICp8 azv4VhqseA0FVzzEoKAWnd+DuvP4EDZ09BHJB0CTHwqTGhelfhxhg+4tiHCqCTvPSUbC V1xg== 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; bh=dd4VPMD5bcmKKR+uhk/1VkTHR3DO4QhpG+XqEmTSX4Q=; fh=UBdS1C7FLmKCPlHt7AdVMWBqXU1mfm8RYRk8RNS2ZdY=; b=VVqnKAQYi0UWZ4A2K1YnFFgA6oqf6GRvCn4/9NCClprqyXZihB/SI5h2YDp1zpAP/e b8qnF85Koh1YE4ZufdQBdLjWLWASAJ4Ji7XWnRrjT0CWhr6hYKVzQUaDSh579wAb9siD OV2mv1V8tHg3D08rK1RdtHhmOUTjrzV6jN/npRXg+OsHUgnDdxP/82yCEZGr4Ngea3b8 yf5W+6Xkkk6MzayRMaD/6je/LMrOGxIiQhW2bm/ZbERPAalCq+24suGlZSV6mnY4gqht t/0yrlR1JkBKkTKAZYBuLx4EicF2uk8tzUU6Nz29AxVm1EwsNC17Xnolojoj/D5ZVa6m yqqw==; 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 t22-20020a7bc3d6000000b00411da6d82f9si7351230wmj.192.2024.02.21.13.50.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Feb 2024 13:50:46 -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 1rcuRG-0000sy-GG; Wed, 21 Feb 2024 16:47:38 -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 1rcuRF-0000ox-0R; Wed, 21 Feb 2024 16:47:37 -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 1rcuRD-0007LQ-71; Wed, 21 Feb 2024 16:47:36 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 44E694F861; Thu, 22 Feb 2024 00:47:46 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id E0545869E2; Thu, 22 Feb 2024 00:47:23 +0300 (MSK) Received: (nullmailer pid 2339838 invoked by uid 1000); Wed, 21 Feb 2024 21:47:23 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Peter Maydell , Bohdan Kostiv , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , Richard Henderson , Michael Tokarev Subject: [Stable-7.2.10 05/33] system/vl.c: Fix handling of '-serial none -serial something' Date: Thu, 22 Feb 2024 00:46:48 +0300 Message-Id: <20240221214723.2339742-5-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 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, 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 From: Peter Maydell Currently if the user passes multiple -serial options on the command line, we mostly treat those as applying to the different serial devices in order, so that for example -serial stdio -serial file:filename will connect the first serial port to stdio and the second to the named file. The exception to this is the '-serial none' serial device type. This means "don't allocate this serial device", but a bug means that following -serial options are not correctly handled, so that -serial none -serial stdio has the unexpected effect that stdio is connected to the first serial port, not the second. This is a very long-standing bug that dates back at least as far as commit 998bbd74b9d81 from 2009. Make the 'none' serial type move forward in the indexing of serial devices like all the other serial types, so that any subsequent -serial options are correctly handled. Note that if your commandline mistakenly had a '-serial none' that was being overridden by a following '-serial something' option, you should delete the unnecessary '-serial none'. This will give you the same behaviour as before, on QEMU versions both with and without this bug fix. Cc: qemu-stable@nongnu.org Reported-by: Bohdan Kostiv Signed-off-by: Peter Maydell Reviewed-by: Daniel P. Berrangé Reviewed-by: Richard Henderson Message-id: 20240122163607.459769-2-peter.maydell@linaro.org Fixes: 998bbd74b9d81 ("default devices: core code & serial lines") Signed-off-by: Peter Maydell (cherry picked from commit d2019a9d0c34a4fdcb5b5df550d73040dc0637d9) Signed-off-by: Michael Tokarev diff --git a/softmmu/vl.c b/softmmu/vl.c index ce88869618..ab4394c53d 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1363,18 +1363,22 @@ static void qemu_create_default_devices(void) static int serial_parse(const char *devname) { int index = num_serial_hds; - char label[32]; - if (strcmp(devname, "none") == 0) - return 0; - snprintf(label, sizeof(label), "serial%d", index); serial_hds = g_renew(Chardev *, serial_hds, index + 1); - serial_hds[index] = qemu_chr_new_mux_mon(label, devname, NULL); - if (!serial_hds[index]) { - error_report("could not connect serial device" - " to character backend '%s'", devname); - return -1; + if (strcmp(devname, "none") == 0) { + /* Don't allocate a serial device for this index */ + serial_hds[index] = NULL; + } else { + char label[32]; + snprintf(label, sizeof(label), "serial%d", index); + + serial_hds[index] = qemu_chr_new_mux_mon(label, devname, NULL); + if (!serial_hds[index]) { + error_report("could not connect serial device" + " to character backend '%s'", devname); + return -1; + } } num_serial_hds++; return 0; From patchwork Wed Feb 21 21:46:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 774541 Delivered-To: patch@linaro.org Received: by 2002:a5d:6ac2:0:b0:33b:4db1:f5b3 with SMTP id u2csp470223wrw; Wed, 21 Feb 2024 13:52:08 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW5DMXJlFPlx3qnPAGrZ5DdPu7DqcqwhBJwzEX0I5O0PFwIJ1AFZoUMnIzTkv5qr0is/2AkJ8/SfsqywSmmU5Z/ X-Google-Smtp-Source: AGHT+IHvgXgEtZ0ZtIaa0xjvNcTQhclIJc78KFatXp8/IspIhskILTBi3/giBr3wnwaATTQiBAGB X-Received: by 2002:a5d:4711:0:b0:33d:2804:fd59 with SMTP id y17-20020a5d4711000000b0033d2804fd59mr672747wrq.18.1708552328103; Wed, 21 Feb 2024 13:52:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708552328; cv=none; d=google.com; s=arc-20160816; b=hIPl5m5Y10XMthNvo0XlHsZBxT1rMMIFHqjcwAwsefrBgBm9QgbIOIzWDemHUgQwN0 DNCkO2Mg8dbufL7w3lsoNfxBukDSF7bJpTfHZDRTCKtSQ9hdB3YiHdG9QhdI5xddfiK5 AKbTL9iKjlMRMdPGAe1B29G/M/5foZVHgGUbRRoaj3DlLhbVaHdsdmxYCjSqHksuAjRn NxjI6Gt1zHjuy4TkrNbe+OFjhpdSuQSyb8r3wjcPrTac0NDGyEw3k9h2i+wSibjg4b5M eWOh88IJz71Igp1q2kTFjMsypqPwoBlVoTpM4zoWUhl4W26d1v3nR0OGitJS25GXB73c Wzrg== 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; bh=dNU9MSTaXcjXqSz/Ei5Mb4E0QzsuLOCwYwdwfYw/Jb8=; fh=QCiO3s1cvaqADEyfPI2NiS1m5l7Cs6ciWF636GXs0Bw=; b=xs2Vuenn1ghsKHFDr5L+iuyj3PEqS0CA0bHJSWXz2JVSawLqI+WSuf34OmrrJpw1qO 3bgV4EKilV+PPTW81tjTUbOXZwmvP/JGCh1gwbE+1fCIIWvMAqPTU+C5EnFcLLwl2z5T N32/4kYqbAwUXv+WpM/K59GW1mQsQTMRPnLHaQHtvrQuyOKOL7Ksv27/Ty7cxgzrGada o8pCCjtjh18kxf3zeBDi8ih8F6sxBI4mVhBjOS9CmNHczfH0cPMWFqLg/W3x453LWL9m p0tyztsB7fKfg1l8SMUWDifUBisud5DHnJJrauTBYowqsKKnF2Jh8E1iQTFVH4D3OZSL pPuA==; 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 r11-20020adff10b000000b0033d106684cesi6951088wro.597.2024.02.21.13.52.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Feb 2024 13:52:08 -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 1rcuRI-0000w3-Qh; Wed, 21 Feb 2024 16:47:40 -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 1rcuRG-0000sn-8Q; Wed, 21 Feb 2024 16:47:38 -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 1rcuRE-0007Ld-EP; Wed, 21 Feb 2024 16:47:37 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 593514F862; Thu, 22 Feb 2024 00:47:46 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id F39B2869E3; Thu, 22 Feb 2024 00:47:23 +0300 (MSK) Received: (nullmailer pid 2339841 invoked by uid 1000); Wed, 21 Feb 2024 21:47:23 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Peter Maydell , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Michael Tokarev Subject: [Stable-7.2.10 06/33] qemu-options.hx: Improve -serial option documentation Date: Thu, 22 Feb 2024 00:46:49 +0300 Message-Id: <20240221214723.2339742-6-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 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, 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 From: Peter Maydell The -serial option documentation is a bit brief about '-serial none' and '-serial null'. In particular it's not very clear about the difference between them, and it doesn't mention that it's up to the machine model whether '-serial none' means "don't create the serial port" or "don't wire the serial port up to anything". Expand on these points. Signed-off-by: Peter Maydell Reviewed-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Message-id: 20240122163607.459769-3-peter.maydell@linaro.org (cherry picked from commit 747bfaf3a9d2f3cd51674763dc1f7575100cd200) Signed-off-by: Michael Tokarev diff --git a/qemu-options.hx b/qemu-options.hx index 379692da86..7f798ce47e 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3968,7 +3968,8 @@ SRST This option can be used several times to simulate up to 4 serial ports. - Use ``-serial none`` to disable all serial ports. + You can use ``-serial none`` to suppress the creation of default + serial devices. Available character devices are: @@ -3990,10 +3991,17 @@ SRST [Linux only] Pseudo TTY (a new PTY is automatically allocated) ``none`` - No device is allocated. + No device is allocated. Note that for machine types which + emulate systems where a serial device is always present in + real hardware, this may be equivalent to the ``null`` option, + in that the serial device is still present but all output + is discarded. For boards where the number of serial ports is + truly variable, this suppresses the creation of the device. ``null`` - void device + A guest will see the UART or serial device as present in the + machine, but all output is discarded, and there is no input. + Conceptually equivalent to redirecting the output to ``/dev/null``. ``chardev:id`` Use a named character device defined with the ``-chardev`` From patchwork Wed Feb 21 21:47:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 774537 Delivered-To: patch@linaro.org Received: by 2002:a5d:6ac2:0:b0:33b:4db1:f5b3 with SMTP id u2csp469510wrw; Wed, 21 Feb 2024 13:49:29 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXEtPIRldOexnhUS/tMHr97hEU7yMNUGF+LU92IkpM3KlZjNskFlOJTvVVDFQ4w2HENCBF+b+r6fhMm8PsilY41 X-Google-Smtp-Source: AGHT+IHF4ywdvKaehD6t/Ha2h33oHTqjE5ZuVYayuaDeMGdRbXDTEdmqS+mmAy0ihqS9vx1Ge3E+ X-Received: by 2002:a5d:47a9:0:b0:33d:3a06:acbc with SMTP id 9-20020a5d47a9000000b0033d3a06acbcmr9486073wrb.70.1708552169693; Wed, 21 Feb 2024 13:49:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708552169; cv=none; d=google.com; s=arc-20160816; b=ZLcIGkSwR0BiYkkecNmB+x1gBAJ4g39muJkJnszxCEVsy7B0cYni+lVdeMDr3gGJzR NWGeGdIB19Vr84tGCKjGfwPoMz0gcOFrqDNwVATKkITT4MnYF0bllhRLdFXwsuxZk6du lXr8YeN01rSgbFniczUFDsaGmMrD/Dtp27AsQUB9vjzLJRaozV/VEcTWYgWIvOKK07Ci AG60RC1TP+xgACfiVGUl2R4cVbG9ao/hRxSW+Mk0L3MjKx6fJc1tfAX5FgxChC6rJIY7 mmBWv3G8VYYX0kJNw+BaqbAFyeQy+s621BWwFzvaNT8QrgbgIRPuGSwP2P8CHZhwIkjw DHFw== 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; bh=5XO64HjlvT8wYk/rChPRMvR1OdumJgiebOLrnFZT6jM=; fh=Mfp+ztHun75jr+I+HJ3gu9b5WkI1iGjp+6yuuqdwzx0=; b=qNLOJELscIBG4CZy6vPzI4Fa3spEzC+BXPMP3v/rj+bhBv0RTHqOoGr0b4MoZI0m6Y tDmSNlYFGoYOXvnwMaZdIagm6DUbLgPXVev+jLP1ccdHxqaofTxhTY5G/GKFW5p+BWj3 ELb3eOdbyPi7zIzneFGTIkIB2BU6psi9I82/3/xXO1Btx4CSyLGAB6wVQOqwlUeMfIDk peBFUUtWv1qQ35ehgnV2/tki8wM4v1A0XHNfjse5H693v4XpPBhBSstJLCT2s+uFgrf5 HhKZMif2C+VdRedSzlWhVzLlO6wHzmkiVrBPHavhS6fn62Azaa5+nRfutQN3fEx2PRy+ rw3w==; 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 r11-20020adff10b000000b0033cf938ad18si6923961wro.594.2024.02.21.13.49.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Feb 2024 13:49:29 -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 1rcuST-0005PD-Dd; Wed, 21 Feb 2024 16:48:53 -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 1rcuSQ-0005Ad-C1; Wed, 21 Feb 2024 16:48:50 -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 1rcuSL-0007XU-Cu; Wed, 21 Feb 2024 16:48:50 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 42EBE4F86F; Thu, 22 Feb 2024 00:47:47 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id E0545869F0; Thu, 22 Feb 2024 00:47:24 +0300 (MSK) Received: (nullmailer pid 2339880 invoked by uid 1000); Wed, 21 Feb 2024 21:47:23 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Gustavo Romero , Peter Maydell , Michael Tokarev Subject: [Stable-7.2.10 19/33] linux-user/aarch64: Choose SYNC as the preferred MTE mode Date: Thu, 22 Feb 2024 00:47:02 +0300 Message-Id: <20240221214723.2339742-19-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 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, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=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 From: Richard Henderson The API does not generate an error for setting ASYNC | SYNC; that merely constrains the selection vs the per-cpu default. For qemu linux-user, choose SYNC as the default. Cc: qemu-stable@nongnu.org Reported-by: Gustavo Romero Signed-off-by: Richard Henderson Tested-by: Gustavo Romero Message-id: 20240207025210.8837-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell (cherry picked from commit 681dfc0d552963d4d598350d26097a692900b408) Signed-off-by: Michael Tokarev diff --git a/linux-user/aarch64/target_prctl.h b/linux-user/aarch64/target_prctl.h index 907c314146..d9f6648e27 100644 --- a/linux-user/aarch64/target_prctl.h +++ b/linux-user/aarch64/target_prctl.h @@ -171,21 +171,26 @@ static abi_long do_prctl_set_tagged_addr_ctrl(CPUArchState *env, abi_long arg2) env->tagged_addr_enable = arg2 & PR_TAGGED_ADDR_ENABLE; if (cpu_isar_feature(aa64_mte, cpu)) { - switch (arg2 & PR_MTE_TCF_MASK) { - case PR_MTE_TCF_NONE: - case PR_MTE_TCF_SYNC: - case PR_MTE_TCF_ASYNC: - break; - default: - return -EINVAL; - } - /* * Write PR_MTE_TCF to SCTLR_EL1[TCF0]. - * Note that the syscall values are consistent with hw. + * + * The kernel has a per-cpu configuration for the sysadmin, + * /sys/devices/system/cpu/cpu/mte_tcf_preferred, + * which qemu does not implement. + * + * Because there is no performance difference between the modes, and + * because SYNC is most useful for debugging MTE errors, choose SYNC + * as the preferred mode. With this preference, and the way the API + * uses only two bits, there is no way for the program to select + * ASYMM mode. */ - env->cp15.sctlr_el[1] = - deposit64(env->cp15.sctlr_el[1], 38, 2, arg2 >> PR_MTE_TCF_SHIFT); + unsigned tcf = 0; + if (arg2 & PR_MTE_TCF_SYNC) { + tcf = 1; + } else if (arg2 & PR_MTE_TCF_ASYNC) { + tcf = 2; + } + env->cp15.sctlr_el[1] = deposit64(env->cp15.sctlr_el[1], 38, 2, tcf); /* * Write PR_MTE_TAG to GCR_EL1[Exclude]. From patchwork Wed Feb 21 21:47:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 774538 Delivered-To: patch@linaro.org Received: by 2002:a5d:6ac2:0:b0:33b:4db1:f5b3 with SMTP id u2csp469533wrw; Wed, 21 Feb 2024 13:49:33 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUNqu45gBxMjTWiFk/INs92K0VkvxByZXz3qtLyy9/ejk3+xfDbETXF6kgyXag1u2qGR3Cj3hOtailOoXz5xJay X-Google-Smtp-Source: AGHT+IECf+/e417Tnv5L9r8Hdit6QUt1lnAEP1mlVgO+kib1HD7EvnGaZJYLBnvW0iaq5B9UumeL X-Received: by 2002:a05:6000:1817:b0:33d:701f:d179 with SMTP id m23-20020a056000181700b0033d701fd179mr4013286wrh.19.1708552173716; Wed, 21 Feb 2024 13:49:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708552173; cv=none; d=google.com; s=arc-20160816; b=jiBT6jdIZlZIgFxxT2ZOskq2o802ytZkjw4d99+6tQqFlst9uGjDYLf6jXF2tx+5Pc rKqvw68HQipbkpMmTDpFdmrGLrJdLGdKwE4kaIrk1+/u79/xu+LFxrzQ0WoGuSvTJy25 Rg43PNs8tyKdHw0AtM2m6J6qIBPEoSKDRxT6stxBu8Tfvk+biJM1CbWnHUNZmqfXmm1h NgrH9VhVPppYaPgxOrr7xAEbpB3xnIvm9QtpkrGcH+OAJM5uZUbuhs4WuJNY9hh51gLk rRChxYaMAyaLIPIJ4GeZMaI8xasOxtw6kibL7D0NK8rApCzTdflllvIsFM2iJ83eQcsI XYLg== 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; bh=EOEUSJfLjJZh6eAuTHsQEmycHL98W8qm2kpz/GmJKOw=; fh=Mfp+ztHun75jr+I+HJ3gu9b5WkI1iGjp+6yuuqdwzx0=; b=Ejvz4GDYO1cJSA8djl9TdlkCRPD54/RO4l3k4/KIo8YKEe9I1alBrMm5JwkfSr9kEE 3wplBlIT55RJUk6Sy+xBaMVR5nx5iJjN3+jWH+konZql0I2jVIwiYDcKXK60iFtE03US X8iqYZJCA4l3UyAMr2aU4A67uGfeev6sVSHifb064xSvQriP5eazOn4HCm0LJkU20xKH j1tc+6m/TedSuLYjXYztWt+q80lWIBW7PQbb0aMAE4TblBQKLx5yX6OpHlD3F3Z0Q0/5 pXCgi2dHlAHedBm8PWgqTUpvWwWzughDrVnqPfdUhK5mDjT1I+abEyBgV4rN2ZASbaAf SqAw==; 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 f12-20020adff58c000000b0033d06ec5904si6862987wro.171.2024.02.21.13.49.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Feb 2024 13:49:33 -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 1rcuSk-00076p-Ip; Wed, 21 Feb 2024 16:49:10 -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 1rcuSi-0006y5-0g; Wed, 21 Feb 2024 16:49:08 -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 1rcuSg-0007Xf-5X; Wed, 21 Feb 2024 16:49:07 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 539A74F870; Thu, 22 Feb 2024 00:47:47 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id F0F16869F1; Thu, 22 Feb 2024 00:47:24 +0300 (MSK) Received: (nullmailer pid 2339883 invoked by uid 1000); Wed, 21 Feb 2024 21:47:23 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Gustavo Romero , Peter Maydell , Michael Tokarev Subject: [Stable-7.2.10 20/33] target/arm: Fix nregs computation in do_{ld, st}_zpa Date: Thu, 22 Feb 2024 00:47:03 +0300 Message-Id: <20240221214723.2339742-20-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 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, 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 From: Richard Henderson The field is encoded as [0-3], which is convenient for indexing our array of function pointers, but the true value is [1-4]. Adjust before calling do_mem_zpa. Add an assert, and move the comment re passing ZT to the helper back next to the relevant code. Cc: qemu-stable@nongnu.org Fixes: 206adacfb8d ("target/arm: Add mte helpers for sve scalar + int loads") Signed-off-by: Richard Henderson Tested-by: Gustavo Romero Message-id: 20240207025210.8837-3-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell (cherry picked from commit 64c6e7444dff64b42d11b836b9aec9acfbe8ecc2) Signed-off-by: Michael Tokarev diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c index 621a2abb22..7388e1dbc7 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -4587,11 +4587,7 @@ static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr, TCGv_ptr t_pg; int desc = 0; - /* - * For e.g. LD4, there are not enough arguments to pass all 4 - * registers as pointers, so encode the regno into the data field. - * For consistency, do this even for LD1. - */ + assert(mte_n >= 1 && mte_n <= 4); if (s->mte_active[0]) { int msz = dtype_msz(dtype); @@ -4605,6 +4601,11 @@ static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr, addr = clean_data_tbi(s, addr); } + /* + * For e.g. LD4, there are not enough arguments to pass all 4 + * registers as pointers, so encode the regno into the data field. + * For consistency, do this even for LD1. + */ desc = simd_desc(vsz, vsz, zt | desc); t_pg = tcg_temp_new_ptr(); @@ -4744,7 +4745,7 @@ static void do_ld_zpa(DisasContext *s, int zt, int pg, * accessible via the instruction encoding. */ assert(fn != NULL); - do_mem_zpa(s, zt, pg, addr, dtype, nreg, false, fn); + do_mem_zpa(s, zt, pg, addr, dtype, nreg + 1, false, fn); } static bool trans_LD_zprr(DisasContext *s, arg_rprr_load *a) @@ -5320,14 +5321,13 @@ static void do_st_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr, if (nreg == 0) { /* ST1 */ fn = fn_single[s->mte_active[0]][be][msz][esz]; - nreg = 1; } else { /* ST2, ST3, ST4 -- msz == esz, enforced by encoding */ assert(msz == esz); fn = fn_multiple[s->mte_active[0]][be][nreg - 1][msz]; } assert(fn != NULL); - do_mem_zpa(s, zt, pg, addr, msz_dtype(s, msz), nreg, true, fn); + do_mem_zpa(s, zt, pg, addr, msz_dtype(s, msz), nreg + 1, true, fn); } static bool trans_ST_zprr(DisasContext *s, arg_rprr_store *a) From patchwork Wed Feb 21 21:47:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 774539 Delivered-To: patch@linaro.org Received: by 2002:a5d:6ac2:0:b0:33b:4db1:f5b3 with SMTP id u2csp469572wrw; Wed, 21 Feb 2024 13:49:41 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUxGGg+9WD51leUGk7Va0r1EqjHy9TFePrp+8uUpUumjTLScMkWYa/Wn4YCRRBOTW+4XkIC9GdMVzsrTMNNj+d3 X-Google-Smtp-Source: AGHT+IFpkDPgoeJWkNrvy6nqNZzR8NKvNiuCsSjXJOfX5W0rmxy1Ta7Y7JjJA0Vf+6CqYAavgXeu X-Received: by 2002:adf:fa44:0:b0:33d:8c9d:419 with SMTP id y4-20020adffa44000000b0033d8c9d0419mr169664wrr.24.1708552181397; Wed, 21 Feb 2024 13:49:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708552181; cv=none; d=google.com; s=arc-20160816; b=Kcci+0jPCwQBb4o9ddPZjdv4Elfk1jmIbGZFv4HattoOimiFwz+I/jIeWzzRxTbEx+ bwwnkRCSi9gVGsF7Gbq5FB62IGEJ0dYxKIlNzkA2UOuamNtO/pFsV2iQqwbpq19QzDNQ Ba99X0+8N6nnCNSW6GBxCh7HPx8Yroll2gcYJGSczfEA7zgvamCHL1XtIAb/J0hToo6W Qg8Ckw0ZKuH2iFGkWbeke5o0Cq9k+GjS5w1BGD1LNBAW7G//nXSUcWdV6AWAq0V2mQPj YcO/2OTedS9+i4ytoCrpw2ZRGcgPF0Vqo8s0V3K43RrIhPvplh9X3y40wvhxV5z2pN4L Iw+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; bh=TzmYsmyGk4GJEZzkyVlnEpAQ3VM647H2/PDKCkKBU6M=; fh=OKuLB2HSwWuh27MwgB2c3Bd7RFVGc3aSQ8373fc2R0A=; b=tp2pY2Nd2l93SCZ4RWm9JvNpmDfTsTTw4Lf5v8V22wed9xe+tMFuZZLwikZhUI0mq2 qtmeLjMxv0Ss3x5rtmRzOVFaKYb37JmoZW8IQpzBqTOJMEaOahs42sUF0KH59YN8Sqgu 5QUSZct5nkgr2czuJXu/fG3EpQiLhMX0jsfGPO8cmKvj1+8M1ltP/Cs4MM/lFkUxQnZr 8RPJlT2M66vgfyWQ7Z3HqAhxHX4Wmbhd2VKBsODLzM4OkjVhUIpfPTvynP/V7xgANZDv v0oIyqIw64q1lne6qj1ERNHYxr0B0BgS9z6MPTay+s4NszOqpyRYNQCXNtyXxPXu1N4M 07AQ==; 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 cm6-20020a5d5f46000000b0033d6c8655efsi2534557wrb.371.2024.02.21.13.49.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Feb 2024 13:49:41 -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 1rcuSp-0007aU-PC; Wed, 21 Feb 2024 16:49:15 -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 1rcuSn-0007QF-U3; Wed, 21 Feb 2024 16:49:13 -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 1rcuSl-0007YC-SV; Wed, 21 Feb 2024 16:49:13 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 64B414F871; Thu, 22 Feb 2024 00:47:47 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 0DD58869F2; Thu, 22 Feb 2024 00:47:25 +0300 (MSK) Received: (nullmailer pid 2339887 invoked by uid 1000); Wed, 21 Feb 2024 21:47:23 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Peter Maydell , Gustavo Romero , Michael Tokarev Subject: [Stable-7.2.10 21/33] target/arm: Fix SVE/SME gross MTE suppression checks Date: Thu, 22 Feb 2024 00:47:04 +0300 Message-Id: <20240221214723.2339742-21-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 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, 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 From: Richard Henderson The TBI and TCMA bits are located within mtedesc, not desc. Cc: qemu-stable@nongnu.org Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Tested-by: Gustavo Romero Message-id: 20240207025210.8837-7-richard.henderson@linaro.org Signed-off-by: Peter Maydell (cherry picked from commit 855f94eca80c85a99f459e36684ea2f98f6a3243) Signed-off-by: Michael Tokarev diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c index 8856773635..d592c78ec9 100644 --- a/target/arm/sme_helper.c +++ b/target/arm/sme_helper.c @@ -606,8 +606,8 @@ void sme_ld1_mte(CPUARMState *env, void *za, uint64_t *vg, desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT); /* Perform gross MTE suppression early. */ - if (!tbi_check(desc, bit55) || - tcma_check(desc, bit55, allocation_tag_from_addr(addr))) { + if (!tbi_check(mtedesc, bit55) || + tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) { mtedesc = 0; } @@ -783,8 +783,8 @@ void sme_st1_mte(CPUARMState *env, void *za, uint64_t *vg, target_ulong addr, desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT); /* Perform gross MTE suppression early. */ - if (!tbi_check(desc, bit55) || - tcma_check(desc, bit55, allocation_tag_from_addr(addr))) { + if (!tbi_check(mtedesc, bit55) || + tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) { mtedesc = 0; } diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index 27838fb6e2..45a93755fe 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -5803,8 +5803,8 @@ void sve_ldN_r_mte(CPUARMState *env, uint64_t *vg, target_ulong addr, desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT); /* Perform gross MTE suppression early. */ - if (!tbi_check(desc, bit55) || - tcma_check(desc, bit55, allocation_tag_from_addr(addr))) { + if (!tbi_check(mtedesc, bit55) || + tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) { mtedesc = 0; } @@ -6159,8 +6159,8 @@ void sve_ldnfff1_r_mte(CPUARMState *env, void *vg, target_ulong addr, desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT); /* Perform gross MTE suppression early. */ - if (!tbi_check(desc, bit55) || - tcma_check(desc, bit55, allocation_tag_from_addr(addr))) { + if (!tbi_check(mtedesc, bit55) || + tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) { mtedesc = 0; } @@ -6413,8 +6413,8 @@ void sve_stN_r_mte(CPUARMState *env, uint64_t *vg, target_ulong addr, desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT); /* Perform gross MTE suppression early. */ - if (!tbi_check(desc, bit55) || - tcma_check(desc, bit55, allocation_tag_from_addr(addr))) { + if (!tbi_check(mtedesc, bit55) || + tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) { mtedesc = 0; } From patchwork Wed Feb 21 21:47:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 774536 Delivered-To: patch@linaro.org Received: by 2002:a5d:6ac2:0:b0:33b:4db1:f5b3 with SMTP id u2csp469458wrw; Wed, 21 Feb 2024 13:49:17 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVIMrx3Bxfl+OB9wWlteYuCjwWOfFjkNYN6IczapHno2Nfu+aA5WzNMZYiuAga7rDGPhqWfYHHIpJ4G/N9jl6HE X-Google-Smtp-Source: AGHT+IHw8qGSFVZotWRdB2qs7MMMvEli7vndczUS9k9CyEfp7C/WHvMOAK8/O6cM723/8qoP7t8H X-Received: by 2002:a05:6000:43:b0:33d:164e:5f7e with SMTP id k3-20020a056000004300b0033d164e5f7emr10584248wrx.26.1708552157496; Wed, 21 Feb 2024 13:49:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708552157; cv=none; d=google.com; s=arc-20160816; b=RFl628RMFCfeWBX56+KppPLEnSgXGeplfFGbRNOulVn5LvVcimkgPl64FdbyFG5Qlx Uhw0TEqxe04CgiCZiCMKYPdSUqFQVgXoiuJ5ItI/SPEDG/c3N+2kJyso8Uq9wRQ9SbKS fOfeg82QnPzPsMhjxPvJpUGu8TcRICNwUtNtCTWrgII7aPLj6qANoR6xsc2emIvcPHMt G0De5210fufG4wwR1fEcPb0EvRCoYijZrSVymFKAfDjwRuchBLJ8Q0eLwYc34LVwr7X5 6KYxqvXui7BZWLQhJnybJ3YBoulwm8tcIt0rZwlOUPXePeU932sQTvLzQ1SYqP/95MLB mdMA== 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; bh=Tb6ePhB1o7Hersy30d9q9jpTUDrgX8Je2OZMCmYWbhE=; fh=taStO74W/EZXcDvsT3Zoyq1h58w93JzpEc66fmdrq4s=; b=wedM9oKIWL/soUiVqUKmEx4+6aWHIJYp1L+ZxzMMin+BzryxRsAHVdrNFOKACuqdan jrIRVbeD247xe6R7l2es/Ix1HoyvFYrzbqjFPQKKqJqTKW8QuuQhw67mtoDGasLyUmrf +24vTD7yN+GHoEtqR9N7ofKaZ6A+YHdxberjnb7twy2r7hMGw+IA1WzcprBqVZ3lvV+m JmqJzKNp23nKEFm/1ynNR6PNJKSnerSGH62C+dTuIkn4JG8KflivO6QpfgAvenRP7Wpw G7Dpp8bN8x1xR8f9YY8zpfXzetig991XPLql/3MonqhbNwQpH9Oxab2l5059rSeTcor0 snIw==; 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 d6-20020adff2c6000000b0033d76a78941si1416301wrp.273.2024.02.21.13.49.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Feb 2024 13:49:17 -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 1rcuSm-0007KI-RZ; Wed, 21 Feb 2024 16:49:13 -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 1rcuSl-0007FK-Jb; Wed, 21 Feb 2024 16:49:11 -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 1rcuSj-0007bB-DV; Wed, 21 Feb 2024 16:49:11 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 757D94F872; Thu, 22 Feb 2024 00:47:47 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 1ECF3869F3; Thu, 22 Feb 2024 00:47:25 +0300 (MSK) Received: (nullmailer pid 2339890 invoked by uid 1000); Wed, 21 Feb 2024 21:47:23 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Michael Tokarev Subject: [Stable-7.2.10 22/33] target/arm: Don't get MDCR_EL2 in pmu_counter_enabled() before checking ARM_FEATURE_PMU Date: Thu, 22 Feb 2024 00:47:05 +0300 Message-Id: <20240221214723.2339742-22-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 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, 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 From: Peter Maydell It doesn't make sense to read the value of MDCR_EL2 on a non-A-profile CPU, and in fact if you try to do it we will assert: #6 0x00007ffff4b95e96 in __GI___assert_fail (assertion=0x5555565a8c70 "!arm_feature(env, ARM_FEATURE_M)", file=0x5555565a6e5c "../../target/arm/helper.c", line=12600, function=0x5555565a9560 <__PRETTY_FUNCTION__.0> "arm_security_space_below_el3") at ./assert/assert.c:101 #7 0x0000555555ebf412 in arm_security_space_below_el3 (env=0x555557bc8190) at ../../target/arm/helper.c:12600 #8 0x0000555555ea6f89 in arm_is_el2_enabled (env=0x555557bc8190) at ../../target/arm/cpu.h:2595 #9 0x0000555555ea942f in arm_mdcr_el2_eff (env=0x555557bc8190) at ../../target/arm/internals.h:1512 We might call pmu_counter_enabled() on an M-profile CPU (for example from the migration pre/post hooks in machine.c); this should always return false because these CPUs don't set ARM_FEATURE_PMU. Avoid the assertion by not calling arm_mdcr_el2_eff() before we have done the early return for "PMU not present". This fixes an assertion failure if you try to do a loadvm or savevm for an M-profile board. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2155 Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-id: 20240208153346.970021-1-peter.maydell@linaro.org (cherry picked from commit ac1d88e9e7ca0bed83e91e07ce6d0597f10cc77d) Signed-off-by: Michael Tokarev diff --git a/target/arm/helper.c b/target/arm/helper.c index 343acfab3a..2e284e048c 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -1125,13 +1125,21 @@ static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter) bool enabled, prohibited = false, filtered; bool secure = arm_is_secure(env); int el = arm_current_el(env); - uint64_t mdcr_el2 = arm_mdcr_el2_eff(env); - uint8_t hpmn = mdcr_el2 & MDCR_HPMN; + uint64_t mdcr_el2; + uint8_t hpmn; + /* + * We might be called for M-profile cores where MDCR_EL2 doesn't + * exist and arm_mdcr_el2_eff() will assert, so this early-exit check + * must be before we read that value. + */ if (!arm_feature(env, ARM_FEATURE_PMU)) { return false; } + mdcr_el2 = arm_mdcr_el2_eff(env); + hpmn = mdcr_el2 & MDCR_HPMN; + if (!arm_feature(env, ARM_FEATURE_EL2) || (counter < hpmn || counter == 31)) { e = env->cp15.c9_pmcr & PMCRE;