From patchwork Thu Jul 4 15:52:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 809965 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1234829wru; Thu, 4 Jul 2024 08:59:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW1R91UGYktYgBzlNecH6q2YAnyB3a4KGp5v80P7vmRkpI/mMnabtbEDi5gCitM7f/cYq3EMAhL/QsMpd8ZC6A6 X-Google-Smtp-Source: AGHT+IG3SCwa5LGj47en95/7Y4anFTAfktI72SegFDgeVVL/S3hBHL/aVCQQlV+I5A5zlsZ1pIe5 X-Received: by 2002:a05:622a:1113:b0:446:5918:ff5d with SMTP id d75a77b69052e-447cbeee3e4mr28688281cf.9.1720108741953; Thu, 04 Jul 2024 08:59:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720108741; cv=none; d=google.com; s=arc-20160816; b=PHzCtWCzljuJXGO3oVNBwwVZ9sJsCrs2mxLF2+n03Ik5UxgZ2YyFspHPfuY6vCOZHZ oHjZSd/r0GrIWY+sgnzuKvihZYASvpMu/HbNqX2g26vGgRrPgfDzPXgDJtJyp3MpdB3o A/ohZIi07PbAR0fgSeZwZA2oteKCn7W4DNReaTlXStqCc06HcRcLZO+vupAFVBKQaq1I SfsOkykGpwvsZ3yOk/Mniw2UvFHtt2+WTmENAtRxiGYqY/eUPgzTzv/0YrenYivpHDiw aW4MMVsadsIBAWiW6t1uiJs4ze0Rnqo5vTvtG8cJUbNc9Ckl7vo6P0k1XWR7++kP2Jzv IaFg== 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=ipmvfAlIHvdTyBW5AWA6X4ZVLAWNy9zO54EQtsRJX2Y=; fh=RkVaduC9mSS2s8S4opwaBgxzh946Y+Bi0zKymkK8x08=; b=Vp3TLYbMzAwAZMBn0jegh4LeoJ6hKv8BGpIMOjHjLI7aaA8lqdVxcaxrOB/OV6PKQD rK3HojZRnSO0dv0OCQNRu3oewHRf4PZbhg35/BEQH8MsBXp+A/LL1BNMfhDqYsHWL7jL NKMpLISd+CqgBU3v5Z9I9kDW3UiYSQteDHOIzEEVyxDEphhEPwi2FiYDOiNscYC2B9yX ebm5Qj2UI8Y/nmreHtAIZu8XyO5zb0f3nqCci2ImxAzwR5clDOrsjQNcFd54XtP3bfGM /lg5Mno84COJyGjIZ2T9QH/4SFsml0YnCd6qlmXLqKuH6hlE2Z5QNhnS2MqVrvswgYRc b4+A==; 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-446513e45ebsi145297891cf.205.2024.07.04.08.59.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jul 2024 08: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; 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 1sPOlt-0000Rl-U8; Thu, 04 Jul 2024 11:53: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 1sPOli-0000Ei-Va; Thu, 04 Jul 2024 11:53:12 -0400 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 1sPOlg-00020t-Kq; Thu, 04 Jul 2024 11:53:09 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 828FA77492; Thu, 4 Jul 2024 18:52: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 4ACD9FEADD; Thu, 4 Jul 2024 18:52:51 +0300 (MSK) Received: (nullmailer pid 1481680 invoked by uid 1000); Thu, 04 Jul 2024 15:52:51 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S . Tsirkin" , Michael Tokarev Subject: [Stable-8.2.6 04/18] hw/audio/virtio-snd: Always use little endian audio format Date: Thu, 4 Jul 2024 18:52:35 +0300 Message-Id: <20240704155251.1481617-4-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 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é The VIRTIO Sound Device conforms with the Virtio spec v1.2, thus only use little endianness. Remove the suspicious target_words_bigendian() noticed during code review. Cc: qemu-stable@nongnu.org Fixes: eb9ad377bb ("virtio-sound: handle control messages and streams") Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Message-Id: <20240422211830.25606-1-philmd@linaro.org> (cherry picked from commit a276ec8e2632c9015d0f9b4e47194e4e91dfa8bb) Signed-off-by: Michael Tokarev diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index 823f9ab084..092ba2302b 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -401,7 +401,7 @@ static void virtio_snd_get_qemu_audsettings(audsettings *as, as->nchannels = MIN(AUDIO_MAX_CHANNELS, params->channels); as->fmt = virtio_snd_get_qemu_format(params->format); as->freq = virtio_snd_get_qemu_freq(params->rate); - as->endianness = target_words_bigendian() ? 1 : 0; + as->endianness = 0; /* Conforming to VIRTIO 1.0: always little endian. */ } /* From patchwork Thu Jul 4 15:52:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 809963 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1233390wru; Thu, 4 Jul 2024 08:54:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUNdnWhoNvygLtICq7FyySEIdSpmVy3pSR8oVsisnGeHqRgHS33oW7eFPJrqCtgbsla7LQfhfJu2wPWlhYuqJoZ X-Google-Smtp-Source: AGHT+IFSkEeBNWRcy0yDStbJkCLZIe2JdIA9OV28mq4t96QLiv/5kdai4zJJVbtgHIEO/cbi2kF/ X-Received: by 2002:a05:620a:2a14:b0:79c:12a4:5393 with SMTP id af79cd13be357-79eee273e81mr271614685a.57.1720108486297; Thu, 04 Jul 2024 08:54:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720108486; cv=none; d=google.com; s=arc-20160816; b=CudUfp3X/T868ToOqTNITbF6Ae3U7x2FV74w3CHOcGGCQNM6mdIMYjc64kKYlOu+rg HaVt+Y4uMZ9IUasq1mzBHz/5rjSPeKpnVmOQEauELZM0SCP6lr5irHv9+73ZhLv3eqL5 qfVSWOHlqm8HqM0kryYgpUJX2Ix2l9Z+cruSuh1F/xjSlmjWo0IryGNEmxaZN61rBd6w HV6n0/QNmURp52OqCPK09/w3ISmqD/odNWwESLJPFfiy9KF/1BckRshP1xAFsHWVajYS BkZDyreVIPE2gQTnNy8ZipTHi0t16PJXzaFbQBXaI6pHPVxqRXCA6VlUCrgWcIQ3FaNv OQng== 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=ZBLsA1ebQdetEVOIOUWREXbgYu8zZB5IWyINvhFAnHg=; fh=Ai/7iYl8PqklBRG+OcSfTczWOCBx0/sAgKz4aM3nNvc=; b=S59VYNK63Zi6XrcFQS+++B+VsDVTktwxrwgiZdqJtykm6L1GR3C9OtZFYe1xE+TJp8 Vp8WcC1HZvll2qug+nn0rgArmi5JF6VJC6d+E9cpMdcyCLXN6jGaLakdi/psNX0hJLet cTmGsSTIMUiH2OLlJCLzFjTPJdx2VLtAfJZyDcU8LsCgMtWpoAKU2eqIhW6+jE9m12j3 47zRzR97QV90t9Zv17Eh+e9cUZR9mmPr3AAL7ww6gwS5g6TVI0PjOZ6UlHiHtBmmHTtW V9cPdmvY4ARk0m0oqfhjoipvmGc4KTzQ2uNsvmmf5UbzEGW4Wa77bYNEzsUcLuVEBxUl latA==; 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-79d6934ee47si1481247085a.783.2024.07.04.08.54.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jul 2024 08:54:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; 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 1sPOlz-0000Wi-FX; Thu, 04 Jul 2024 11:53:27 -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 1sPOlv-0000St-8X; Thu, 04 Jul 2024 11:53:23 -0400 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 1sPOls-00023m-G2; Thu, 04 Jul 2024 11:53:22 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id D0B1377497; Thu, 4 Jul 2024 18:52: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 98F19FEAE2; Thu, 4 Jul 2024 18:52:51 +0300 (MSK) Received: (nullmailer pid 1481696 invoked by uid 1000); Thu, 04 Jul 2024 15:52:51 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Song Gao , Michael Tokarev Subject: [Stable-8.2.6 09/18] tcg/loongarch64: Fix tcg_out_movi vs some pcrel pointers Date: Thu, 4 Jul 2024 18:52:40 +0300 Message-Id: <20240704155251.1481617-9-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 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 Simplify the logic for two-part, 32-bit pc-relative addresses. Rather than assume all such fit in int32_t, do some arithmetic and assert a result, do some arithmetic first and then check to see if the pieces are in range. Cc: qemu-stable@nongnu.org Fixes: dacc51720db ("tcg/loongarch64: Implement tcg_out_mov and tcg_out_movi") Reviewed-by: Song Gao Reported-by: Song Gao Signed-off-by: Richard Henderson (cherry picked from commit 521d7fb3ebdf88112ed13556a93e3037742b9eb8) Signed-off-by: Michael Tokarev diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index abdc8b7f4d..6c99e799b3 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -365,8 +365,7 @@ static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, * back to the slow path. */ - intptr_t pc_offset; - tcg_target_long val_lo, val_hi, pc_hi, offset_hi; + intptr_t src_rx, pc_offset; tcg_target_long hi12, hi32, hi52; /* Value fits in signed i32. */ @@ -376,24 +375,23 @@ static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, } /* PC-relative cases. */ - pc_offset = tcg_pcrel_diff(s, (void *)val); - if (pc_offset == sextreg(pc_offset, 0, 22) && (pc_offset & 3) == 0) { - /* Single pcaddu2i. */ - tcg_out_opc_pcaddu2i(s, rd, pc_offset >> 2); - return; + src_rx = (intptr_t)tcg_splitwx_to_rx(s->code_ptr); + if ((val & 3) == 0) { + pc_offset = val - src_rx; + if (pc_offset == sextreg(pc_offset, 0, 22)) { + /* Single pcaddu2i. */ + tcg_out_opc_pcaddu2i(s, rd, pc_offset >> 2); + return; + } } - if (pc_offset == (int32_t)pc_offset) { - /* Offset within 32 bits; load with pcalau12i + ori. */ - val_lo = sextreg(val, 0, 12); - val_hi = val >> 12; - pc_hi = (val - pc_offset) >> 12; - offset_hi = val_hi - pc_hi; - - tcg_debug_assert(offset_hi == sextreg(offset_hi, 0, 20)); - tcg_out_opc_pcalau12i(s, rd, offset_hi); + pc_offset = (val >> 12) - (src_rx >> 12); + if (pc_offset == sextreg(pc_offset, 0, 20)) { + /* Load with pcalau12i + ori. */ + tcg_target_long val_lo = val & 0xfff; + tcg_out_opc_pcalau12i(s, rd, pc_offset); if (val_lo != 0) { - tcg_out_opc_ori(s, rd, rd, val_lo & 0xfff); + tcg_out_opc_ori(s, rd, rd, val_lo); } return; } From patchwork Thu Jul 4 15:52:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 809964 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1234497wru; Thu, 4 Jul 2024 08:58:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXyDzjrvcvNePOAuQrvEYcCxd1RpJ79HvYC8hkgF2Feftvwfd0B9FyvKHqBAP7fHzSkzaWYHAbMPA+f3K0r+/VB X-Google-Smtp-Source: AGHT+IHPH2/SZbU71tb1ZXwvbqTB88q+vb5DY63n5zaGbsVF+llKgP40KGRa09NnLww3W9kOYgUP X-Received: by 2002:a25:d684:0:b0:e03:a227:6476 with SMTP id 3f1490d57ef6-e03c190e7admr2120849276.17.1720108683707; Thu, 04 Jul 2024 08:58:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720108683; cv=none; d=google.com; s=arc-20160816; b=bID0NMQp6tYDUb6zpVxsh8tafpZRVM0C2FnIuTnRe72yfyJHmxcOYEHYBmUuossYVY V95p42LojDIKRLOh+Rj+fOM6whBRA3S/xUe3e1L2WYyulMivLTsni/8Zc3fjF6WEGM+3 Yf7fPWjQvy2bAfWVGNScjlhXE3b0DS3re7C1Llgcsooe0qLY0ToIx+HzVumcw0jZo/RF Z6vP2om+VANQX3dFMsllbYii6Lnr3N1hKsBRvM9xQvhNCQrXvBKzf9UphAkWjStRdFyZ +hh59ERfhvr0wkisMWKOOoLNKhKppEfXxbrK64NHlSgVebH6hWi76UTZJnmy7JhNCinL ep2w== 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=dpa00ZWK0z3zWvsAxlTHsXonch8Y5l4laAm1UlBM0zs=; fh=NoJ7n5JVE2hviRF6uNBFRIJvWH7igafuy1AIwg26ToM=; b=XS/FdTu61Ta4UyCSMF3jkaEXXwAK7LkUf6npId1zC5SpubODCIceZqnyrvOVcKbsns 4BTay4pu3MvHGx5yQyVWNu8YiojwsO/8ViXf5yq1sK6EG4hLrvRWR9zUbhLD/kRcNkUW TCSUWdndQHoZ8Qtc81whLDJ6nvfJt1o5ZVB4XKl07OegWfq1mbOEcjYJJDlyx7xY36/V xdS6pE6eSdhsKfB93tWSbac183l5Gv6jRm5BYmglHuNlcIhHPPEJ2EGhc4XBqHj+GuSS Ks/9ByXmiGleK88MNGS6uVxoXeHEuwXUuZGtyD6uJ8knvsPuYLVC5ESn+yrgUXG6i9Y+ DVVA==; 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-6b5e9f9f628si19957176d6.429.2024.07.04.08.58.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jul 2024 08:58:03 -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; 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 1sPOmV-0001Og-EV; Thu, 04 Jul 2024 11:53: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 1sPOmT-0001No-PU; Thu, 04 Jul 2024 11:53:57 -0400 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 1sPOmR-00027e-OR; Thu, 04 Jul 2024 11:53:57 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 1D03C7749B; Thu, 4 Jul 2024 18:52: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 D94B6FEAE6; Thu, 4 Jul 2024 18:52:51 +0300 (MSK) Received: (nullmailer pid 1481708 invoked by uid 1000); Thu, 04 Jul 2024 15:52:51 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Peter Maydell , Michael Tokarev Subject: [Stable-8.2.6 13/18] target/arm: Fix VCMLA Dd, Dn, Dm[idx] Date: Thu, 4 Jul 2024 18:52:44 +0300 Message-Id: <20240704155251.1481617-13-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 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 inner loop, bounded by eltspersegment, must not be larger than the outer loop, bounded by elements. Cc: qemu-stable@nongnu.org Fixes: 18fc2405781 ("target/arm: Implement SVE fp complex multiply add (indexed)") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2376 Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20240625183536.1672454-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell (cherry picked from commit 76bccf3cb9d9383da0128bbc6d1300cddbe3ae8f) Signed-off-by: Michael Tokarev diff --git a/target/arm/tcg/vec_helper.c b/target/arm/tcg/vec_helper.c index 1f93510b85..cc7cab338c 100644 --- a/target/arm/tcg/vec_helper.c +++ b/target/arm/tcg/vec_helper.c @@ -843,7 +843,7 @@ void HELPER(gvec_fcmlah_idx)(void *vd, void *vn, void *vm, void *va, intptr_t index = extract32(desc, SIMD_DATA_SHIFT + 2, 2); uint32_t neg_real = flip ^ neg_imag; intptr_t elements = opr_sz / sizeof(float16); - intptr_t eltspersegment = 16 / sizeof(float16); + intptr_t eltspersegment = MIN(16 / sizeof(float16), elements); intptr_t i, j; /* Shift boolean to the sign bit so we can xor to negate. */ @@ -905,7 +905,7 @@ void HELPER(gvec_fcmlas_idx)(void *vd, void *vn, void *vm, void *va, intptr_t index = extract32(desc, SIMD_DATA_SHIFT + 2, 2); uint32_t neg_real = flip ^ neg_imag; intptr_t elements = opr_sz / sizeof(float32); - intptr_t eltspersegment = 16 / sizeof(float32); + intptr_t eltspersegment = MIN(16 / sizeof(float32), elements); intptr_t i, j; /* Shift boolean to the sign bit so we can xor to negate. */ From patchwork Thu Jul 4 15:52:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 809962 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1233367wru; Thu, 4 Jul 2024 08:54:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWs4GJhCqAAK5ibam03ZlvxbmODySVaBH2BRw7/SfBpWTvDpV1I3VT8RXAOq9vFrC8FuUeDZht+RbsEbB7R0aaT X-Google-Smtp-Source: AGHT+IEmyYyfgxbqpE0/u1GSpqWOlm0VvWWQoXU8qXaAynu8xHlmfoTZq4zhY/qXxmViOtixZ/aE X-Received: by 2002:a05:6214:401c:b0:6b5:dd7d:f8a5 with SMTP id 6a1803df08f44-6b5ecf7b7d3mr22651796d6.11.1720108479736; Thu, 04 Jul 2024 08:54:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720108479; cv=none; d=google.com; s=arc-20160816; b=ugFgTgvn07yJfZNe53/bqh5GYTUIVVv9Ce/pW/+SphrIM+QCRTUR6lsVf3ux9VF/wV /3vcHStBypin/jNVgGUtDjzgRAaj3EG/4MWV9t8+oOI4icIoLAfbfuXvImE91GRCXM5y MAOEt3b14wtVi9kSg7mr6urJRdNqhjO0gzEhTr+l4SqPxQlyj89RY51+stw6i8eF9gsV uSm3yQTHuPpz4iAtNspiKjqr2vk04H7vEfUjLYLNIq93krMEKGhVNVGYA/49+WMtQu6M pIfODe2xwdrZNUuyvtyTKWl3q4E2GjG9eLU7o4ZRHNu/jYRQ0w/7cAv652BitMyddTku QtNw== 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=/xSfUTn6OMzucBC1oEfb0DALescQQrzzulOjVn7TlD8=; fh=NoJ7n5JVE2hviRF6uNBFRIJvWH7igafuy1AIwg26ToM=; b=qI3BVuboQ30fUogwWxNCreINOnRk5fBuswusmui/Y/sAO3UrGlU3zs1RJ5ejJtSHul zblqjDFTHOQLrgv7MG99whOdsGuv9gXGKeRR/Z5XaC8w5XYfXAgJb+XFqKNF/JjAQCND 2DKghVPQroEuS5U5Pge2q+IIW/jCHsWpekuShO3XW+SB61/Ns5+3RTOj0y94gAaYAXxf i1R+qrBs2h7FQ8g0Md+AwMRt1sIBPa8pM1JfDAfsCzgbohZTdjHvQgtJK6kea7JQ/hU2 +hZeCygz2ZhnoNnZD4186Pfp5HxpnX4uVQLfFL9wgu49RQTvAywUmgmxEUYo8uS0tRC+ hJbA==; 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-6b5e58a71f6si29481046d6.452.2024.07.04.08.54.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jul 2024 08:54:39 -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; 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 1sPOmA-0000vv-Ol; Thu, 04 Jul 2024 11:53:38 -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 1sPOm9-0000qV-Cl; Thu, 04 Jul 2024 11:53:37 -0400 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 1sPOm6-00027p-Ct; Thu, 04 Jul 2024 11:53:37 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 361B37749C; Thu, 4 Jul 2024 18:52: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 E76EAFEAE7; Thu, 4 Jul 2024 18:52:51 +0300 (MSK) Received: (nullmailer pid 1481712 invoked by uid 1000); Thu, 04 Jul 2024 15:52:51 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Peter Maydell , Michael Tokarev Subject: [Stable-8.2.6 14/18] target/arm: Fix FJCVTZS vs flush-to-zero Date: Thu, 4 Jul 2024 18:52:45 +0300 Message-Id: <20240704155251.1481617-14-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 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 Input denormals cause the Javascript inexact bit (output to Z) to be set. Cc: qemu-stable@nongnu.org Fixes: 6c1f6f2733a ("target/arm: Implement ARMv8.3-JSConv") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2375 Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20240625183536.1672454-4-richard.henderson@linaro.org [PMM: fixed hardcoded tab in test case] Signed-off-by: Peter Maydell (cherry picked from commit 7619129f0d4a14d918227c5c47ad7433662e9ccc) Signed-off-by: Michael Tokarev diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c index 3e5e37abbe..ff59bc5522 100644 --- a/target/arm/vfp_helper.c +++ b/target/arm/vfp_helper.c @@ -1121,8 +1121,8 @@ const FloatRoundMode arm_rmode_to_sf_map[] = { uint64_t HELPER(fjcvtzs)(float64 value, void *vstatus) { float_status *status = vstatus; - uint32_t inexact, frac; - uint32_t e_old, e_new; + uint32_t frac, e_old, e_new; + bool inexact; e_old = get_float_exception_flags(status); set_float_exception_flags(0, status); @@ -1130,13 +1130,13 @@ uint64_t HELPER(fjcvtzs)(float64 value, void *vstatus) e_new = get_float_exception_flags(status); set_float_exception_flags(e_old | e_new, status); - if (value == float64_chs(float64_zero)) { - /* While not inexact for IEEE FP, -0.0 is inexact for JavaScript. */ - inexact = 1; - } else { - /* Normal inexact or overflow or NaN */ - inexact = e_new & (float_flag_inexact | float_flag_invalid); - } + /* Normal inexact, denormal with flush-to-zero, or overflow or NaN */ + inexact = e_new & (float_flag_inexact | + float_flag_input_denormal | + float_flag_invalid); + + /* While not inexact for IEEE FP, -0.0 is inexact for JavaScript. */ + inexact |= value == float64_chs(float64_zero); /* Pack the result and the env->ZF representation of Z together. */ return deposit64(frac, 32, 32, inexact); diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index 70d728ae9a..4ecbca6a41 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -41,8 +41,9 @@ endif # Pauth Tests ifneq ($(CROSS_CC_HAS_ARMV8_3),) -AARCH64_TESTS += pauth-1 pauth-2 pauth-4 pauth-5 +AARCH64_TESTS += pauth-1 pauth-2 pauth-4 pauth-5 test-2375 pauth-%: CFLAGS += -march=armv8.3-a +test-2375: CFLAGS += -march=armv8.3-a run-pauth-1: QEMU_OPTS += -cpu max run-pauth-2: QEMU_OPTS += -cpu max # Choose a cpu with FEAT_Pauth but without FEAT_FPAC for pauth-[45]. diff --git a/tests/tcg/aarch64/test-2375.c b/tests/tcg/aarch64/test-2375.c new file mode 100644 index 0000000000..84c7e7de71 --- /dev/null +++ b/tests/tcg/aarch64/test-2375.c @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Copyright (c) 2024 Linaro Ltd */ +/* See https://gitlab.com/qemu-project/qemu/-/issues/2375 */ + +#include + +int main(void) +{ + int r, z; + + asm("msr fpcr, %2\n\t" + "fjcvtzs %w0, %d3\n\t" + "cset %1, eq" + : "=r"(r), "=r"(z) + : "r"(0x01000000L), /* FZ = 1 */ + "w"(0xfcff00L)); /* denormal */ + + assert(r == 0); + assert(z == 0); + return 0; +}