From patchwork Thu Jul 4 21:00: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: 809968 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1334923wru; Thu, 4 Jul 2024 14:03:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVccktJN/Z6c8jFfFQDHU7rWrHGSZIeOXBxIUEEdwNlK7bRAAQJoriIvvPk9lO6N8xnmtzE2Q3w7Wj80eVB9fUs X-Google-Smtp-Source: AGHT+IGyCtQAMq9vbPpygE1ZBE12oQExhAqGVtXFQLTca9HDz8d13mM1Q5SKJ+KSgOMlmouQZUgo X-Received: by 2002:ac8:5a93:0:b0:445:229:3888 with SMTP id d75a77b69052e-447cce9c512mr38288601cf.4.1720126991456; Thu, 04 Jul 2024 14:03:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720126991; cv=none; d=google.com; s=arc-20160816; b=apu50OQljdwz960SZVNFpdCtAIRew0XiK1o5aI/QGWUG+i5lxncx20rgKCDoXSsY4o siYKIEEX+Ug1H6WqdgZQBcLGOWjrpSjykLX488A/fuphRONkjxTpWvgE9x3xY/fH2SP/ KtGsg5cffCBMgnsVVkp3KKu9PX8mjtp6O06i5FEb+T0WQKE2dgkTCckNBET46FmLVNI3 gPAasgHQQgmhzSG4kdEw4h36dbcpFYu1T2+ez6lnCyOJP8PQ2YBe6j5M/SKj2ghA/bsM EltsXNrmVUhPQpHH1D+hzXfQLRD1RvyYGeFbCSSjrYzr1g+wcbSI1PGHqd4+Zny6h73t x7dA== 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=BVcwRG4S7go97zWG2/wkciHm+zfdscflwda6MmIA09U=; fh=RkVaduC9mSS2s8S4opwaBgxzh946Y+Bi0zKymkK8x08=; b=wx3M11cwAizowahL4smg9jSc0Z1ztrnCJDL3wja+YNJVevsm6s/yxTh7nn+Y0awYgu CxLzdqrmvTGHTUJp/030f4IaGQIzOXqv114FZDcD0SXggB1q8kBFo7PAHegbVTyfs4ra UV8AqVisMgd8vy/HnF93+JCu8uplk7XMI2yAi7r40uG1mHkRHkGNoVhyQ2N8QTNTEmUD hXKLhIR4ylyGhzM59sFc+uL+fComdrwHhLgLVfZeyLk9yJjxyc33M8gjRxL53dZ06GAm Xk9Kfuvr5fjyJ9+DIbR81xkpHIEcC8+wLg7+1JLA/uFRvB4pXR9g1iKybP9sgZIGYbho kOHg==; 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-4468beb94acsi65566471cf.49.2024.07.04.14.03.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jul 2024 14:03:11 -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 1sPTZs-0006tG-NI; Thu, 04 Jul 2024 17:01:16 -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 1sPTZp-0006lG-4t; Thu, 04 Jul 2024 17:01:13 -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 1sPTZm-0004KY-Gh; Thu, 04 Jul 2024 17:01:12 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 9F5D077562; Fri, 5 Jul 2024 00:00:50 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id B5E5DFEC9C; Fri, 5 Jul 2024 00:00:55 +0300 (MSK) Received: (nullmailer pid 1507727 invoked by uid 1000); Thu, 04 Jul 2024 21:00:55 -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-9.0.2 05/22] hw/audio/virtio-snd: Always use little endian audio format Date: Fri, 5 Jul 2024 00:00:35 +0300 Message-Id: <20240704210055.1507652-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 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 c80b58bf5d..4a56c00ec9 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 21:00: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: 809966 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1334530wru; Thu, 4 Jul 2024 14:02:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW02fBVZ+tmDCmjQyOssq2aSW7vefjzv+w62SIi2vCPQ4XVEkqJE898xZgvq4sCyjJLna/DS0T3seYdImzOkjgC X-Google-Smtp-Source: AGHT+IGTPmUuEtDQ+bL+3emj6oXFMDQGSOUwC8pX+J2gDG1ralmJlWtH08tQcejf8jssEqbexHcH X-Received: by 2002:a05:620a:4005:b0:795:5842:2457 with SMTP id af79cd13be357-79eee19eb19mr373901985a.15.1720126934843; Thu, 04 Jul 2024 14:02:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720126934; cv=none; d=google.com; s=arc-20160816; b=sZZK34HPCcFcpVggFh52bvkChHnhKYzFvoY4Lc2wVsXbc4epXlZqZTwY+wKfHKuakv xGL42ZWhYjHmVyJyweSWHb45qXzB0C4WRV3U9owWCGW0esW7ScAhLUBCMUZ+iZ/X4A2B S2tEAhGVPWki+eOKJKO+fnUKRlxkceMO3geb828lC3uvd1jZWgbeElUYXyQYDRCQ4joj QQSzL+ZdoUlmcMhGIdKwPHbo+0+kG0ZMASa7RRythPBF4HnPIxzxwhXwWqYwwJ0w8ME6 NMai2BwlzLQPgQ70+ANPVS9GDFHk/kyBOP4GU50jUhsnhd08j3+8KLAKr0NDlbtgobHd LVog== 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=c2fuvPEXLT/qBQ7Zr3P5m1AYchzV3q1kTRscXa1aiT0=; fh=Ai/7iYl8PqklBRG+OcSfTczWOCBx0/sAgKz4aM3nNvc=; b=qO9rPYJG97e5JJJsxq48agN+/YKRV/nASPQSPY9cnOJmfVC7CGpvw4TlWZDrYhMBet JtKlkRn5pMkmzE023VJ7Ll1oNofccvHnyDIirRI51h+pcJF+/rcN9SaNWy5guYN2i8ba vdLcraQNy6CNZhQVBBduvyrM7Q0YnzT3ZHU9WuSXs/kEBfK+28BVyeLYc7WAqIi5Gbnv by2s7Q5jqyFO5Tdis0BuQVz7C/7GJdgdrWYgWQWjN7uqkcSy/5EZuDD4vuy7MGLqBWGR ZrrN6hjKvHo9HUMA7tlLp3v+Aa/oVjfelrHCiJGIAwAnPFxvn+lgCqefeRGAbWpa47f5 w0hQ==; 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-79d6933a2c4si1547610285a.598.2024.07.04.14.02.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jul 2024 14:02:14 -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 1sPTZz-0007EI-Ch; Thu, 04 Jul 2024 17:01:23 -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 1sPTZv-000728-Ht; Thu, 04 Jul 2024 17:01:19 -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 1sPTZt-0004Ll-S5; Thu, 04 Jul 2024 17:01:19 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id EE12377567; Fri, 5 Jul 2024 00:00:50 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 10AAFFECA1; Fri, 5 Jul 2024 00:00:56 +0300 (MSK) Received: (nullmailer pid 1507743 invoked by uid 1000); Thu, 04 Jul 2024 21:00:55 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Song Gao , Michael Tokarev Subject: [Stable-9.0.2 10/22] tcg/loongarch64: Fix tcg_out_movi vs some pcrel pointers Date: Fri, 5 Jul 2024 00:00:40 +0300 Message-Id: <20240704210055.1507652-10-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 06ca1ab11c..8f68bd3e51 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -366,8 +366,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. */ @@ -377,24 +376,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 21:00: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: 809967 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1334755wru; Thu, 4 Jul 2024 14:02:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVEpXjUSYZApgKwt5QWiFHfYZvV8Eaxmmu0zks5vJr0ZPQ6DZIhjfucDh9gd4rDHt2T5RqywFULC15jA0xFkTSy X-Google-Smtp-Source: AGHT+IEIGUD1ELdzga61c8S89j/xIMmRwOwiVs4gHaMLQjFPwyEDlNBkQ/zptKL/6j6XDjJh1x4b X-Received: by 2002:a05:6214:3011:b0:6b5:eaa0:6cac with SMTP id 6a1803df08f44-6b5ed08586cmr35011376d6.63.1720126965790; Thu, 04 Jul 2024 14:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720126965; cv=none; d=google.com; s=arc-20160816; b=XHncDzxKp5yseSqZ3SVcaqoWXfMGyC6xjb4NiYbA36E6VrEaHxfK++5vtmjJQTQ5WE TPiMbNSnMq97f2LwH+7cssMM9CmZjpWAVItOYvJ05GTtArZXfKGZHC6DD4UJ6GpuZLWO 55f35sOiY7q5vmoF0pBeElnmzT4mWoDL0FbG34O75GGYzTkyyQOaL6WzICfCVdrDIBqL hTBDG/t3+VXlROxBUZ1hdFtas5uvG625dLzxAr3ayGbF8ZFsqiaBqbbTTEPu40QYlq/z GoeqzS06s/43nXPTFtyZL0XSWbUZzkNm0qqGt/h60OM+juR1SIJ7hcBeJHvQIU13LeTc 4avw== 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=WeS30IHPxM8yB/vzzkOBmSbKT5V33Tpcvvpd6wJKESG0ea8DaorfPbHuA82gjUbO/T BpUHkTGuFt8+WBkWd07Vqd5p64wAfmwSpaVNgojiBbuz2cUdkXYajqKENTEYuMM5WILV fhDLcQbMk36wIu4YTISKIZ3mhw0r9A3rnWlTY6Cu6ztEzqo6hsvDMUYvxBD/vs1kR8gh 2X/PQdaSPKE/6rQIByHP1K8yY0RWwYAJHId+B2jEpkogqRCsotqyrxgx9zX+5d4lpyYa LMy4wd8ZoZR52rovAtAO6tQi3ouRX84G1rCsHoD6U77Lkui5ujYPwttFFYVzyA03nRV2 Xx9Q==; 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-6b59e5ef618si158346636d6.396.2024.07.04.14.02.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jul 2024 14:02:45 -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 1sPTaR-0008Tp-UH; Thu, 04 Jul 2024 17:01:52 -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 1sPTaP-0008Iq-6G; Thu, 04 Jul 2024 17:01:49 -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 1sPTaN-0004Pa-F5; Thu, 04 Jul 2024 17:01:48 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 3A8F87756C; Fri, 5 Jul 2024 00:00:51 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 511A5FECA5; Fri, 5 Jul 2024 00:00:56 +0300 (MSK) Received: (nullmailer pid 1507755 invoked by uid 1000); Thu, 04 Jul 2024 21:00:55 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Peter Maydell , Michael Tokarev Subject: [Stable-9.0.2 14/22] target/arm: Fix VCMLA Dd, Dn, Dm[idx] Date: Fri, 5 Jul 2024 00:00:44 +0300 Message-Id: <20240704210055.1507652-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 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 21:00: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: 809970 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1335483wru; Thu, 4 Jul 2024 14:04:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVUwpEy2fjKGslA+vSdLX30m96BcZ+vvSzTZYURWIGdmQA5pH6jmInUj8/fxuXTA/lcxw8TdyAZVwNz35xH5BYo X-Google-Smtp-Source: AGHT+IG5n+I08K4naKnUEi4VTFbS8knyTSqoihkEfzmTnEAL7fDvLiwIpK+CC3LaViMFkm9bpNFj X-Received: by 2002:ad4:574d:0:b0:6b5:47d5:6139 with SMTP id 6a1803df08f44-6b5ed01ebc4mr33935366d6.34.1720127076828; Thu, 04 Jul 2024 14:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720127076; cv=none; d=google.com; s=arc-20160816; b=g94bzy40H6AEf0drAJOSG+mKsSgn9XZBViCyZ35DUTHPfe5aOqthqv8GV9yKmAZfZz aY5sHVQ5f1gcPK7/S4bfEJKm614MeQN5IJKz3IpvQqxxqp1FUKkAO6mwU1OOardxew6x l/wwUwUjLKf/dHiSVp+uDhlX1VeYd3kE33mM2lW7aPwtg9RNtH1OqfolJQQO68OR8snE HX0gwdynOZutlSQZoD+1oWwviEH8D89q5/Rm5RY3Jog19zheAdVPjowMHSRVg7kZKIGe 2SF1wBlusQ9dPk4RIWot/e46xWRBFyAzMNVrKINZgxQUrFAt79Pg58IV7xZ2PoERqu0k UMQg== 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=fuSTiVFe05XK5gUQE+DGw7kqwT2OS76kKQMl2p5p7Yrzm3F5ud7HqQ2C4gEywZDrG1 jwVmV9y++iOIetS7BA0O9biFt7tntHbFgHGyW4EWgQjDo1lPh4oYRdUJ2vJMDqI51sSH 8uosyi0VmnScgoGOPBhCr4iqV8L8ejcUBVKY83YzJo6bfAXvzbz/xSa18V4p05JN42PN tdU2mNPEFdfmEDyPmDMyIdUJNLe75hJVuwO1DEeM6X5xXVbaEQgBNDJ6rm88poXLhPsZ BVartMm09QO6zsj1KTxM1BM7x4cRJ9MlOFzPnTW6e2RI92bDg5reBGNkstuMHyvSW5Wu R1XQ==; 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-6b59e36379csi161567536d6.103.2024.07.04.14.04.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jul 2024 14:04:36 -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 1sPTaV-0000Tv-I5; Thu, 04 Jul 2024 17:01:55 -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 1sPTaT-0000Jv-DJ; Thu, 04 Jul 2024 17:01:53 -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 1sPTaR-0004Pz-Jv; Thu, 04 Jul 2024 17:01:53 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 540327756D; Fri, 5 Jul 2024 00:00:51 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 5F375FECA6; Fri, 5 Jul 2024 00:00:56 +0300 (MSK) Received: (nullmailer pid 1507759 invoked by uid 1000); Thu, 04 Jul 2024 21:00:55 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Peter Maydell , Michael Tokarev Subject: [Stable-9.0.2 15/22] target/arm: Fix FJCVTZS vs flush-to-zero Date: Fri, 5 Jul 2024 00:00:45 +0300 Message-Id: <20240704210055.1507652-15-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; +} From patchwork Thu Jul 4 21:00:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 809969 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1334966wru; Thu, 4 Jul 2024 14:03:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXGwKSolBcpRLBiHAqMsYMkMUZdNyAgbrmgNrWuejz3dyUyCQ5HhFuPoxqdUvXkA7DU+YAZTYIqtempcIP1S2Ap X-Google-Smtp-Source: AGHT+IFbEZ59w0A20/BMq2ZbgRE7fy2XOGmnTJ2VzCYuq8GoXJ55wUAc8r6E9SlFwJPUFJruQwbt X-Received: by 2002:a05:6214:529c:b0:6b5:5485:dec9 with SMTP id 6a1803df08f44-6b5ed196e73mr31081936d6.62.1720126996272; Thu, 04 Jul 2024 14:03:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720126996; cv=none; d=google.com; s=arc-20160816; b=A19qXl9cZGyIse0W1epDp4jTWdsqy4cn6xL8uJzrH2sNuIRNeBy++DpY0Vii61gAKZ iQkot0rDmd/MEV8V2BDpjIAdJZbwyAkbzlJEcNZCxH3GvU3xD6bi8W0bjOLMq5ZtGJV0 HyJSI2m0Vh16LtW3o1NXCIOAvLFaj6H1+J1sWFc4wuPVCXBOF12fst7kw25nFOaFNSyv VkOjJt8ePjBVz8NH2NmMHFWK4GEmllg5rDXozTVRti0X00sZucn2WiBlr19i1trCjwx8 IvlGwpM5AQWwdZ8P7j4p3qAhLz28pdqhOGaxSsdRzLtdS5+vRXoCGM4CV5lkPewh4EQ8 SVyg== 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=EfiaJOFHOi/bNbuAef2XkTZVjQ8B7IdryJWzfP4OXAY=; fh=fA8wXgZkOijV3QzeJqIqYxlGqKQb9nNVVJRQwjQ6hao=; b=SSpp9P81VSY2aFT3+Hu/iVuDTiv0wybaS8xbr61XOQ4dLSNRqTzKhI9BeQ7kY/fPoG i0mopcPNZuOo69hWNdJ29rrmY8bPbwdeGg8+0YA7EEvVn3Uepir5V4hjxpeeJnkeLfjp E6s30SYjZouDCQhH67P8W/ecDwh+6MGy+SjTRxpZetutuAeZ6BLARguctWG0nxVTi36d 0WduY/mi3FO6OzEUCeTgbp6EteHYIwfNxrXVz2VJGeVDAiWj8td03Khtp0qv+IG7S+/q kPTsSSjkEzNz8HEkcCD1wavy7uB9Otis1QThvLkbGWFLTom4gNuabO/ydM2G88YtjOGr /evw==; 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-6b5eb71e2absi23437526d6.65.2024.07.04.14.03.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jul 2024 14:03:16 -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 1sPTbT-0004H9-OZ; Thu, 04 Jul 2024 17:02:56 -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 1sPTbO-0003Ts-3a; Thu, 04 Jul 2024 17:02:50 -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 1sPTbK-0004T2-6Q; Thu, 04 Jul 2024 17:02:49 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id D509E77574; Fri, 5 Jul 2024 00:00:51 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id EBC76FECAD; Fri, 5 Jul 2024 00:00:56 +0300 (MSK) Received: (nullmailer pid 1507781 invoked by uid 1000); Thu, 04 Jul 2024 21:00:55 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9e?= , Michael Tokarev Subject: [Stable-9.0.2 22/22] tcg/optimize: Fix TCG_COND_TST* simplification of setcond2 Date: Fri, 5 Jul 2024 00:00:52 +0300 Message-Id: <20240704210055.1507652-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 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 Argument ordering for setcond2 is: output, a_low, a_high, b_low, b_high, cond The test is supposed to be against b_low, not a_high. Cc: qemu-stable@nongnu.org Fixes: ceb9ee06b71 ("tcg/optimize: Handle TCG_COND_TST{EQ,NE}") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2413 Signed-off-by: Richard Henderson Tested-by: Alex Bennée Message-Id: <20240701024623.1265028-1-richard.henderson@linaro.org> (cherry picked from commit a71d9dfbf63db42d6e6ae87fc112d1f5502183bd) Signed-off-by: Michael Tokarev diff --git a/tcg/optimize.c b/tcg/optimize.c index 2e9e5725a9..8c49229d6f 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2274,7 +2274,7 @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op) case TCG_COND_TSTEQ: case TCG_COND_TSTNE: - if (arg_is_const_val(op->args[2], 0)) { + if (arg_is_const_val(op->args[3], 0)) { goto do_setcond_high; } if (arg_is_const_val(op->args[4], 0)) { diff --git a/tests/tcg/x86_64/Makefile.target b/tests/tcg/x86_64/Makefile.target index e64aab1b81..1d427cdc2c 100644 --- a/tests/tcg/x86_64/Makefile.target +++ b/tests/tcg/x86_64/Makefile.target @@ -8,6 +8,8 @@ include $(SRC_PATH)/tests/tcg/i386/Makefile.target +X86_64_TESTS += test-2413 + ifeq ($(filter %-linux-user, $(TARGET)),$(TARGET)) X86_64_TESTS += vsyscall X86_64_TESTS += noexec diff --git a/tests/tcg/x86_64/test-2413.c b/tests/tcg/x86_64/test-2413.c new file mode 100644 index 0000000000..456e5332fc --- /dev/null +++ b/tests/tcg/x86_64/test-2413.c @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Copyright 2024 Linaro, Ltd. */ +/* See https://gitlab.com/qemu-project/qemu/-/issues/2413 */ + +#include + +void test(unsigned long *a, unsigned long *d, unsigned long c) +{ + asm("xorl %%eax, %%eax\n\t" + "xorl %%edx, %%edx\n\t" + "testb $0x20, %%cl\n\t" + "sete %%al\n\t" + "setne %%dl\n\t" + "shll %%cl, %%eax\n\t" + "shll %%cl, %%edx\n\t" + : "=a"(*a), "=d"(*d) + : "c"(c)); +} + +int main(void) +{ + unsigned long a, c, d; + + for (c = 0; c < 64; c++) { + test(&a, &d, c); + assert(a == (c & 0x20 ? 0 : 1u << (c & 0x1f))); + assert(d == (c & 0x20 ? 1u << (c & 0x1f) : 0)); + } + return 0; +}