From patchwork Mon Jun 26 18:49:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 696481 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3390734wrm; Mon, 26 Jun 2023 12:13:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5slZIPyzay8p4sJElRSLGMTMiTbx9Zv+jtqKniWxLsvYnSg5io25sTxUO7raFx7nGxRfyQ X-Received: by 2002:a05:620a:1a9f:b0:762:276:4d65 with SMTP id bl31-20020a05620a1a9f00b0076202764d65mr33847608qkb.61.1687806792123; Mon, 26 Jun 2023 12:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687806792; cv=none; d=google.com; s=arc-20160816; b=JfiFYC6ZWyJFg/iS6ENCZYUiyHrMelT2xQ6di1Vc1/ZeeZ0sW/TB5f/XHE0RttbdGK PSkLwMnVhhlkFtBV/zx3z6oWoE8JWUz436irwoikyn2+QAWt28r/zS6sZ4WeXK92CsAT /uEZcm/BMQceaD0/xX3ImiAmkHNh62Y2BHSiJQ/2L58VWQnb5zhJaflHlkr3cTy72ZNE WKPqwN0HLvDhE8LJx5suHPBTJp3tvTIdX2ALrHeWHmgr+gXxCa/+kK9el87RFCB8sMaq vYEPVt3zV4ZhQBJpAQqFeCsq74E5LW5J4b3i7+Spk0WBgepmfigRemx475TFQFzMo7K5 wdWg== 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=5q4mhHtLMxGpgQz6Vj7PP7vf0FVGMp7a8biusS+zqf4=; fh=0Xp2JyaTaNttgD8GBymZGxc1xOSx5UTRsLJ5GvGrdK8=; b=BqUHr8PEIz6zGXTyEGx8YSgd0mEZNpVnEIo9LcOz4DNX5lKi9h5mvqAMebFIi87UNE 6UiPUjyBqOVoWqQC+Kg3j3co0LJU+pdLU0j00VWZxxWxnOVWc3PbCVU7GG7XL6KD6zrE M72S3MQpw/FCcCQXXnGMYRmdX1Wv8Ag6++FAcgRGxg1U3oNM2SSzaMgObjq69BT0D4NO lMtAQJdjV6buu59rVqOKUhrlv1Ni8a0GypXZy/EzP4QdSqKzzTfMWq0jY++FWya1MmD3 xQofNYYWCr+zNgZ+94XhoAo9ujuSElE6gKDbmqkBMI3zqhKfGm0Rj+C6aOIdQcZAsD2k AlvA== 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 m19-20020a05620a291300b0076560e5836asi2132534qkp.687.2023.06.26.12.13.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jun 2023 12:13:12 -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 1qDrJ7-0004Yt-TC; Mon, 26 Jun 2023 14:51:26 -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 1qDrJ3-0004Wo-Re; Mon, 26 Jun 2023 14:51:21 -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 1qDrJ1-00050C-SS; Mon, 26 Jun 2023 14:51:21 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 00297EF26; Mon, 26 Jun 2023 21:50:20 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 4884FF7B5; Mon, 26 Jun 2023 21:50:19 +0300 (MSK) Received: (nullmailer pid 1574003 invoked by uid 1000); Mon, 26 Jun 2023 18:50:16 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Peter Maydell , Richard Henderson , Michael Tokarev Subject: [Stable-8.0.3 15/54] target/arm: Explicitly select short-format FSR for M-profile Date: Mon, 26 Jun 2023 21:49:22 +0300 Message-Id: <20230626185002.1573836-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, 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 For M-profile, there is no guest-facing A-profile format FSR, but we still use the env->exception.fsr field to pass fault information from the point where a fault is raised to the code in arm_v7m_cpu_do_interrupt() which interprets it and sets the M-profile specific fault status registers. So it doesn't matter whether we fill in env->exception.fsr in the short format or the LPAE format, as long as both sides agree. As it happens arm_v7m_cpu_do_interrupt() assumes short-form. In compute_fsr_fsc() we weren't explicitly choosing short-form for M-profile, but instead relied on it falling out in the wash because arm_s1_regime_using_lpae_format() would be false. This was broken in commit 452c67a4 when we added v8R support, because we said "PMSAv8 is always LPAE format" (as it is for v8R), forgetting that we were implicitly using this code path on M-profile. At that point we would hit a g_assert_not_reached(): ERROR:../../target/arm/internals.h:549:arm_fi_to_lfsc: code should not be reached #7 0x0000555555e055f7 in arm_fi_to_lfsc (fi=0x7fffecff9a90) at ../../target/arm/internals.h:549 #8 0x0000555555e05a27 in compute_fsr_fsc (env=0x555557356670, fi=0x7fffecff9a90, target_el=1, mmu_idx=1, ret_fsc=0x7fffecff9a1c) at ../../target/arm/tlb_helper.c:95 #9 0x0000555555e05b62 in arm_deliver_fault (cpu=0x555557354800, addr=268961344, access_type=MMU_INST_FETCH, mmu_idx=1, fi=0x7fffecff9a90) at ../../target/arm/tlb_helper.c:132 #10 0x0000555555e06095 in arm_cpu_tlb_fill (cs=0x555557354800, address=268961344, size=1, access_type=MMU_INST_FETCH, mmu_idx=1, probe=false, retaddr=0) at ../../target/arm/tlb_helper.c:260 The specific assertion changed when commit fcc7404eff24b4c added "assert not M-profile" to arm_is_secure_below_el3(), because the conditions being checked in compute_fsr_fsc() include arm_el_is_aa64(), which will end up calling arm_is_secure_below_el3() and asserting before we try to call arm_fi_to_lfsc(): #7 0x0000555555efaf43 in arm_is_secure_below_el3 (env=0x5555574665a0) at ../../target/arm/cpu.h:2396 #8 0x0000555555efb103 in arm_is_el2_enabled (env=0x5555574665a0) at ../../target/arm/cpu.h:2448 #9 0x0000555555efb204 in arm_el_is_aa64 (env=0x5555574665a0, el=1) at ../../target/arm/cpu.h:2509 #10 0x0000555555efbdfd in compute_fsr_fsc (env=0x5555574665a0, fi=0x7fffecff99e0, target_el=1, mmu_idx=1, ret_fsc=0x7fffecff996c) Avoid the assertion and the incorrect FSR format selection by explicitly making M-profile use the short-format in this function. Fixes: 452c67a42704 ("target/arm: Enable TTBCR_EAE for ARMv8-R AArch32")a Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1658 Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230523131726.866635-1-peter.maydell@linaro.org (cherry picked from commit d7fe699be54b2cbb8e4ee37b63588b3458a49da7) Signed-off-by: Michael Tokarev diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c index 31eb77f7df..7166923ebf 100644 --- a/target/arm/tcg/tlb_helper.c +++ b/target/arm/tcg/tlb_helper.c @@ -68,8 +68,17 @@ static uint32_t compute_fsr_fsc(CPUARMState *env, ARMMMUFaultInfo *fi, ARMMMUIdx arm_mmu_idx = core_to_arm_mmu_idx(env, mmu_idx); uint32_t fsr, fsc; - if (target_el == 2 || arm_el_is_aa64(env, target_el) || - arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) { + /* + * For M-profile there is no guest-facing FSR. We compute a + * short-form value for env->exception.fsr which we will then + * examine in arm_v7m_cpu_do_interrupt(). In theory we could + * use the LPAE format instead as long as both bits of code agree + * (and arm_fi_to_lfsc() handled the M-profile specific + * ARMFault_QEMU_NSCExec and ARMFault_QEMU_SFault cases). + */ + if (!arm_feature(env, ARM_FEATURE_M) && + (target_el == 2 || arm_el_is_aa64(env, target_el) || + arm_s1_regime_using_lpae_format(env, arm_mmu_idx))) { /* * LPAE format fault status register : bottom 6 bits are * status code in the same form as needed for syndrome From patchwork Mon Jun 26 18:49:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 696473 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3384777wrm; Mon, 26 Jun 2023 12:00:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7XHyn/v71gb/OSMtPfisyah8GbBn0DAEs6YMh9o/6JqH6HQleh21RWLG1i/S22SegXZOva X-Received: by 2002:a05:622a:1d4:b0:401:e0d8:25f with SMTP id t20-20020a05622a01d400b00401e0d8025fmr1873024qtw.10.1687806007122; Mon, 26 Jun 2023 12:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687806007; cv=none; d=google.com; s=arc-20160816; b=umrK25BBCd1L99FyVGVRu9mdthuYoVBoX1SHN1P02KdAW7BjCEliKk/EsAW0+8OvhA FFNJJCasCf2iI9j3JNipo021wUyRYYucVR/X8Me8s4ywexFBFKFQSTIJZqJJFeLh26fS U62+ih8Ygue4rX4eq0PMrlTCHE2Lcj7P0gSu07tref/I2Co19ETHwPGph/TTeCCRMDT7 A9CR/1KPtUMsS7I3F9Np/LxSIKlVdpcJMOB33YIS0Axta25X3jVYNqKfe5YybrscQA24 D1bT7I1zuECvLMpLgqwB6G9gVFyUQmU7VWCesFYp16XLuETdpFPQIr0+8quo0Ss9EJZy 7YFw== 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=URFA9I3B2IlzvXFxeP3sPjqPU7F8j79gbWZCbSYEPrc=; fh=0Xp2JyaTaNttgD8GBymZGxc1xOSx5UTRsLJ5GvGrdK8=; b=yDO+RTYy/aBtjB+PEmIzk91qNQPS3PKLE6yNwXV68L6tGVhhg+gLIlqW5CCQoWIC8i 7Zcjl39TXD5I14x3wzl5uHccPyPSz0qBSakmwHYNq9mGUmTTUn4pctzQdvDR1+o2xNBd c/pon0ImAZHSzbyRiYHYFvWfayAfvSKzhVbP+1zyhrsD7aG+bjJQqmyXP3G8qZFpfnVJ x90TYyjhqbibFoayMYuD3+dR1EQpegbEr4hFTa043r/m0wwTworPyJLOC0KGu6nBA/Gw EIzpvzp4/uz4v7rxNPa/UlnLCnetmch2fagTS1mGSXJtJ6WLPIMmXy/dAapBpayhMzxG n1wA== 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 d9-20020ac85ac9000000b003f6b3972858si2124618qtd.170.2023.06.26.12.00.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jun 2023 12:00:07 -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 1qDrN9-0003uz-9K; Mon, 26 Jun 2023 14:55:35 -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 1qDrLS-0001rP-BY; Mon, 26 Jun 2023 14:53: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 1qDrLP-0005T9-D3; Mon, 26 Jun 2023 14:53:48 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id E6607EF3E; Mon, 26 Jun 2023 21:50:27 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id B5F9CF7CD; Mon, 26 Jun 2023 21:50:25 +0300 (MSK) Received: (nullmailer pid 1574076 invoked by uid 1000); Mon, 26 Jun 2023 18:50:16 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Peter Maydell , Richard Henderson , Michael Tokarev Subject: [Stable-8.0.3 39/54] target/arm: Fix return value from LDSMIN/LDSMAX 8/16 bit atomics Date: Mon, 26 Jun 2023 21:49:46 +0300 Message-Id: <20230626185002.1573836-39-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 atomic memory operations are supposed to return the old memory data value in the destination register. This value is not sign-extended, even if the operation is the signed minimum or maximum. (In the pseudocode for the instructions the returned data value is passed to ZeroExtend() to create the value in the register.) We got this wrong because we were doing a 32-to-64 zero extend on the result for 8 and 16 bit data values, rather than the correct amount of zero extension. Fix the bug by using ext8u and ext16u for the MO_8 and MO_16 data sizes rather than ext32u. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230602155223.2040685-2-peter.maydell@linaro.org (cherry picked from commit 243705aa6ea3465b20e9f5a8bfcf36d3153f3c10) Signed-off-by: Michael Tokarev diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index dff391bfe2..3cb5128135 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -3438,8 +3438,22 @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, */ fn(tcg_rt, clean_addr, tcg_rs, get_mem_index(s), mop); - if ((mop & MO_SIGN) && size != MO_64) { - tcg_gen_ext32u_i64(tcg_rt, tcg_rt); + if (mop & MO_SIGN) { + switch (size) { + case MO_8: + tcg_gen_ext8u_i64(tcg_rt, tcg_rt); + break; + case MO_16: + tcg_gen_ext16u_i64(tcg_rt, tcg_rt); + break; + case MO_32: + tcg_gen_ext32u_i64(tcg_rt, tcg_rt); + break; + case MO_64: + break; + default: + g_assert_not_reached(); + } } } From patchwork Mon Jun 26 18:49:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 696474 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3384900wrm; Mon, 26 Jun 2023 12:00:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4hn2GRUvnYU3LmtJ9sdMCRDWNdrJBmq1HDrJ6UNwKbj4TbVfryCSgw6jJpi7jWUFETf/Pd X-Received: by 2002:a05:620a:6590:b0:763:cf57:17c1 with SMTP id qd16-20020a05620a659000b00763cf5717c1mr14702957qkn.28.1687806021128; Mon, 26 Jun 2023 12:00:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687806021; cv=none; d=google.com; s=arc-20160816; b=qWA7NF7zlN8uq5fFPJqIbCZwU6DFCmYSgZAOPitSq9XWkSG6ywop1jAA+yKu2sQhmx vFQV2gOeAus8ENnDVhjzEwWncLebszaHY9ga/elA0PnnN11QiHhw4lkW3QcdIfU1ASCw 9ICQoeWiXWjgUD8wEMQ4crSEOSufWQCilW/Ue6YAEsgXiovi6aWLQ9pSxSEmYmCjuXaK 4Ui9JYGjSweCp3NpA5voRCOvnlc/oXwHKqp/SzA9eTWFGJWxZHVBjPQW1TtjkT5LV01N Hcy8Ecf8l+LnCpmo/sfbwe6sXntONyDV6a2PQdmqy388yvqorFyO0A90ziwE8sbPb+n7 ZBAg== 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=ivTsw3wJ2jOwRuVhd5UJhHVwMfRunkD2I7WXmzeCBwE=; fh=0Xp2JyaTaNttgD8GBymZGxc1xOSx5UTRsLJ5GvGrdK8=; b=NGOxtYWCWEPqvEjkyX+qZnJ8WnjJATCkFk+4YR+FXLv8ULB2n0xIyYzE+1B4FpQQFx SU7klTCPcq7ZAWOPWQQDt0c7HoOR4kHQ8XOKWVH+dTygVTx3IBcn43Qky163Rr308Irf X9QioA5nptdVINx4m0mCyuoGyIiIlxuKjSlGWvdDAckPhv8/z4zdzI+cbXvciKdwaQ+S FQ4ChHH6hoCKOMA7WyxJ9WATOvyR/vg5jxIiqbf4DxZDz90J+u66POTL2yn3DkqyC+rp /LXWg2te2D8deJZEoelSz0tUB9a+JGwK2XABDgU1R+Ie+Pb8QfzWB1Q67JzSSh9Lnfam ILpA== 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 ox13-20020a05620a828d00b007653a71006dsi2171597qkn.81.2023.06.26.12.00.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jun 2023 12:00:21 -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 1qDrNI-00052F-9m; Mon, 26 Jun 2023 14:55:44 -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 1qDrLS-0001rO-BH; Mon, 26 Jun 2023 14:53: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 1qDrLQ-0005TJ-8F; Mon, 26 Jun 2023 14:53:49 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id E1220EF3F; Mon, 26 Jun 2023 21:50:28 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 89E91F7CE; Mon, 26 Jun 2023 21:50:26 +0300 (MSK) Received: (nullmailer pid 1574079 invoked by uid 1000); Mon, 26 Jun 2023 18:50:16 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Peter Maydell , Richard Henderson , Michael Tokarev Subject: [Stable-8.0.3 40/54] target/arm: Return correct result for LDG when ATA=0 Date: Mon, 26 Jun 2023 21:49:47 +0300 Message-Id: <20230626185002.1573836-40-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 LDG instruction loads the tag from a memory address (identified by [Xn + offset]), and then merges that tag into the destination register Xt. We implemented this correctly for the case when allocation tags are enabled, but didn't get it right when ATA=0: instead of merging the tag bits into Xt, we merged them into the memory address [Xn + offset] and then set Xt to that. Merge the tag bits into the old Xt value, as they should be. Cc: qemu-stable@nongnu.org Fixes: c15294c1e36a7dd9b25 ("target/arm: Implement LDG, STG, ST2G instructions") Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell (cherry picked from commit 7e2788471f9e079fff696a694721a7d41a451839) Signed-off-by: Michael Tokarev diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 3cb5128135..2fb27087f5 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -4091,9 +4091,13 @@ static void disas_ldst_tag(DisasContext *s, uint32_t insn) if (s->ata) { gen_helper_ldg(tcg_rt, cpu_env, addr, tcg_rt); } else { + /* + * Tag access disabled: we must check for aborts on the load + * load from [rn+offset], and then insert a 0 tag into rt. + */ clean_addr = clean_data_tbi(s, addr); gen_probe_access(s, clean_addr, MMU_DATA_LOAD, MO_8); - gen_address_with_allocation_tag0(tcg_rt, addr); + gen_address_with_allocation_tag0(tcg_rt, tcg_rt); } } else { tcg_rt = cpu_reg_sp(s, rt); From patchwork Mon Jun 26 18:49:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 696471 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3383813wrm; Mon, 26 Jun 2023 11:56:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6bBMqny6IIurf3ANZsz9CRnhlqQM4t2E81y/xoaDDvW/nmd9mNXQ5RXO3JoYfoC29n9fEF X-Received: by 2002:a67:ce07:0:b0:440:d307:76f with SMTP id s7-20020a67ce07000000b00440d307076fmr8740593vsl.3.1687805814930; Mon, 26 Jun 2023 11:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687805814; cv=none; d=google.com; s=arc-20160816; b=qrA/4nuijm6QMWdukPiso3qOxiW1ol+gCjAGfkfXSSvlEuZhazRpESg2/jlIW3fxKU VJihbTn3OmT2wP9d7j2ShQIXznsKV+HfEP2kdkp8/YcdufhtdbULsffUVgX64yABr7IR YznsveL10nCRWVtwzEWcFeA2Y0bP/4OHn8vQY364YamMQSC/a8IXs8PjGzf/eDo5RiY3 8tgfCy7dwXCCgxRHBKUpOXpf1pqZc3eOkvthz0prLCJNKZZF/b6QUPx0PAlau4TBfNRW aDR8HoyBnwhCVqy6eyCX4Jvw8pCILKbiNnn8x2aEX8uRzV+j16jUCDZriKlDtsRvFozU eb/Q== 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=pTkr1c3UDCi+G6gvuCP+fwto0MkdksVxTHS/KHd43/I=; fh=aDE9/c4c4updyTg5EjMEty1hnd1R8wyIvX5PILnUv5k=; b=MkkBFL/Nfnduh77FE62OErVDcCk4C+tbgfJ3FHhPMxd7z8T3HQAZIh0DjTPslii5U7 lAkqG4J9UxEBEcrMv2dqvL5/owXPaL2pVJ/qIOFj/kTUxX8mUPVK68V6kOD0ZCbH4KEn 7sXUdFkXdyCtvHX+IF7XTUDZThdvVOR7CutB4lvrRhqRutyZVgV6YXolwxSTq4zzaTBI AP7ej3ZV7w4SOVX202FPLG88k+Gsg2hCCOGV/Yt7FDhVNNrFltmk5ekIPo5tI9cjsybP xNHDG0T+fPnnhMLyrenUtS/t5osepZudDiv6VpiQKbpKCGJbmudL/dgRG7X7swV0knsR Rt1A== 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 c22-20020ac85a96000000b003fb558f256csi2110789qtc.154.2023.06.26.11.56.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jun 2023 11:56:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; 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 1qDrN5-0003Tf-P1; Mon, 26 Jun 2023 14:55:31 -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 1qDrMF-0001vs-Jp; Mon, 26 Jun 2023 14:54:40 -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 1qDrLn-0005Uz-T8; Mon, 26 Jun 2023 14:54:13 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 0C0B0EF40; Mon, 26 Jun 2023 21:50:29 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 6BE54F7CF; Mon, 26 Jun 2023 21:50:27 +0300 (MSK) Received: (nullmailer pid 1574082 invoked by uid 1000); Mon, 26 Jun 2023 18:50:16 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Peter Maydell , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?q?d=C3=A9?= , Guenter Roeck , Michael Tokarev Subject: [Stable-8.0.3 41/54] hw/intc/allwinner-a10-pic: Handle IRQ levels other than 0 or 1 Date: Mon, 26 Jun 2023 21:49:48 +0300 Message-Id: <20230626185002.1573836-41-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 In commit 2c5fa0778c3b430 we fixed an endianness bug in the Allwinner A10 PIC model; however in the process we introduced a regression. This is because the old code was robust against the incoming 'level' argument being something other than 0 or 1, whereas the new code was not. In particular, the allwinner-sdhost code treats its IRQ line as 0-vs-non-0 rather than 0-vs-1, so when the SD controller set its IRQ line for any reason other than transmit the interrupt controller would ignore it. The observed effect was a guest timeout when rebooting the guest kernel. Handle level values other than 0 or 1, to restore the old behaviour. Fixes: 2c5fa0778c3b430 ("hw/intc/allwinner-a10-pic: Don't use set_bit()/clear_bit()") (Mjt: af08c70ef5204fe in stable-8.0) Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Tested-by: Guenter Roeck Message-id: 20230606104609.3692557-2-peter.maydell@linaro.org (cherry picked from commit f837b468cdaa7e736b5385c7dc4f8c5adcad3bf1) Signed-off-by: Michael Tokarev diff --git a/hw/intc/allwinner-a10-pic.c b/hw/intc/allwinner-a10-pic.c index 4875e68ba6..d0bf8d545b 100644 --- a/hw/intc/allwinner-a10-pic.c +++ b/hw/intc/allwinner-a10-pic.c @@ -51,7 +51,7 @@ static void aw_a10_pic_set_irq(void *opaque, int irq, int level) AwA10PICState *s = opaque; uint32_t *pending_reg = &s->irq_pending[irq / 32]; - *pending_reg = deposit32(*pending_reg, irq % 32, 1, level); + *pending_reg = deposit32(*pending_reg, irq % 32, 1, !!level); aw_a10_pic_update(s); } From patchwork Mon Jun 26 18:49:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 696472 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3384204wrm; Mon, 26 Jun 2023 11:58:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4HH/Cn5qw96bHkkddCqjMAr88Ctn/bLF78E2xZ6b3UGjYsEc3FseJPsEmBul9znY2dx/HZ X-Received: by 2002:a05:620a:2455:b0:763:de2c:1a8a with SMTP id h21-20020a05620a245500b00763de2c1a8amr21218837qkn.57.1687805895969; Mon, 26 Jun 2023 11:58:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687805895; cv=none; d=google.com; s=arc-20160816; b=rMy2Ai1dhz+M/FPrIUqswukGA7CpCZHIkHAxnfHob9OFr2/H/TI1RfCq7e2HrITHvB vaOvhFdazMFZ1hWqOjvuQPgnWjBPn59Fl5XwE96bL6fY4mZiif5NBn9j06GVbVE9nuIZ ancKBeqM9XQfxd+AE1eXMqGibys5GlzdWqMw/Opixpn2Kpo73FFNp1D+JekjWr97PQwN Td5Nh8HzVAcwLZ8vmKfi9g0mrBwMO53Z9oS+08nemlalkjaVrUzgdo7nLF+cWIDuahgZ +PJoCA5a6vK1MQmTAta/dJdoAr9kCu055pcykAicQiIHTzNu6zRDMjoQGjiUHKOqbhNB hPmg== 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=NhRi3p1hDy9Xk0RJq9I6RZyIc/6CLrr0Ob/vBCkatbc=; fh=9Puwj9MOBIDO5gzvzLBZlV9GG/phz4th2oI9KImXtng=; b=Qo5HQDpkpyFxyYIUCTHnAZ3wBjtEdbfulE+5GFzxyd7nn4V/keJyAcf/lsIW5fjMkO L6WHjrQeS7CpQNWR3BVJUWXPDFXg/k4GRqlIRoxZllZfzt6gM+xHHIvTKjFYnGEPbtFy Si9HM3gDWIBD9vi9RynwtSiEMgPAHo+pcOzk23NIqfGfVhQU20nZTjGJyLFlDvakwDVO iFl5BKIxGwKxFy1C7sR8QGcmBq74eg0Iet9T7iaZ/KjYc98lI2QfOTUvWS1KrPO+lIL6 LfSvERdS/GFt4w6IKWG9H+21XDc4EharwFwW/z6Rb8GM9jqaNGeFu+Gwg+a7MB47UsFs f+pg== 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 p8-20020a05622a13c800b003ff3a2f91a5si2082772qtk.672.2023.06.26.11.58.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jun 2023 11:58:15 -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 1qDrN0-0003Ao-5c; Mon, 26 Jun 2023 14:55:26 -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 1qDrMP-0001ye-3E; Mon, 26 Jun 2023 14:54: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 1qDrLn-0005V0-SF; Mon, 26 Jun 2023 14:54:13 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 418D8EF41; Mon, 26 Jun 2023 21:50:29 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id C36D1F7D0; Mon, 26 Jun 2023 21:50:27 +0300 (MSK) Received: (nullmailer pid 1574085 invoked by uid 1000); Mon, 26 Jun 2023 18:50:16 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Peter Maydell , Joel Stanley , Michael Tokarev Subject: [Stable-8.0.3 42/54] hw/timer/nrf51_timer: Don't lose time when timer is queried in tight loop Date: Mon, 26 Jun 2023 21:49:49 +0300 Message-Id: <20230626185002.1573836-42-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 nrf51_timer has a free-running counter which we implement using the pattern of using two fields (update_counter_ns, counter) to track the last point at which we calculated the counter value, and the counter value at that time. Then we can find the current counter value by converting the difference in wall-clock time between then and now to a tick count that we need to add to the counter value. Unfortunately the nrf51_timer's implementation of this has a bug which means it loses time every time update_counter() is called. After updating s->counter it always sets s->update_counter_ns to 'now', even though the actual point when s->counter hit the new value will be some point in the past (half a tick, say). In the worst case (guest code in a tight loop reading the counter, icount mode) the counter is continually queried less than a tick after it was last read, so s->counter never advances but s->update_counter_ns does, and the guest never makes forward progress. The fix for this is to only advance update_counter_ns to the timestamp of the last tick, not all the way to 'now'. (This is the pattern used in hw/misc/mps2-fpgaio.c's counter.) Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Reviewed-by: Joel Stanley Message-id: 20230606134917.3782215-1-peter.maydell@linaro.org (cherry picked from commit d2f9a79a8cf6ab992e1d0f27ad05b3e582d2b18a) Signed-off-by: Michael Tokarev diff --git a/hw/timer/nrf51_timer.c b/hw/timer/nrf51_timer.c index 42be79c736..50c6772383 100644 --- a/hw/timer/nrf51_timer.c +++ b/hw/timer/nrf51_timer.c @@ -45,7 +45,12 @@ static uint32_t update_counter(NRF51TimerState *s, int64_t now) uint32_t ticks = ns_to_ticks(s, now - s->update_counter_ns); s->counter = (s->counter + ticks) % BIT(bitwidths[s->bitmode]); - s->update_counter_ns = now; + /* + * Only advance the sync time to the timestamp of the last tick, + * not all the way to 'now', so we don't lose time if we do + * multiple resyncs in a single tick. + */ + s->update_counter_ns += ticks_to_ns(s, ticks); return ticks; } From patchwork Mon Jun 26 18:49:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 696479 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3389650wrm; Mon, 26 Jun 2023 12:10:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4H7hGgLwBSS50sEYmIcnU1Wth3ChNujSg76SAH4vGgjNJxujh7lPiQB/BJmkaUD0njnkEt X-Received: by 2002:a05:6214:d69:b0:623:64cd:941d with SMTP id 9-20020a0562140d6900b0062364cd941dmr5172925qvs.2.1687806630197; Mon, 26 Jun 2023 12:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687806630; cv=none; d=google.com; s=arc-20160816; b=R3ZfXZ2U58chCjx99K5w9WizmpHpN0TEoQLWTExIMBgDvgWIM5UHRFVvzyZk9ABvBk t/uEa2R7MkKOqeJjye5zmvBfQxNaYTcev89qDdXy7ciE1Dz7MixzGAtF0mqMmDV7JAMR t+On1F5EwOIpjCufmQbuCRkVarWFG2PenK/eTw3/ocZs39jxVI7AbfN40jY3roYPA40e OXUKrJOW4a4MoRrzdQuJbIxUI+/LLP6B6JkERAuyHFAMFeVln3KrlP9MJIuJbE6Ij6xe axJjvO8auYRlLs/z6FbEmcv5aKeOvlrUIWO7XeTIlg9X/OqyYEEGFOFfhV9aQGlkAjv8 K55w== 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=kElnPohoo4QBoWSSyxFSdF/NIIn2PJdLO6bV3HJlBO0=; fh=JfuprfCedaaH4bwbV1+UfSdrVnNu3JN+V+yaHHqBUgY=; b=FUvAkEetGTYJ33i+el95rbesw1tb/ER6VFjWjTkoETUUPZsew9K6sadIXgryqIwOTS qqqxSwoSNEzR7J952Q5MyK/61xiw36HIX6Xb3gqGAszEKuqdE59Y6CqNJYKtC4rnso1V +jOircDqQ6+/bOr+3w3EwoC2cXf/nDZi1lfYBHwBAPJs/sn6GxE9BCJb8Nl+uVQ5ggYN MyQxSjDoXZoEY2i2UzWbuLpYNg6jlzGd5CLBqakQqjQH9RMSt1iU2u4lMsLizbB1FgT6 NXU0h3GHyGAa2g6edYL8syrKBU2QmFlo43B9D8eduWdE6yDvVweDbEWVeFUHPjXKf6AE eAbw== 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 pt5-20020a056214048500b00631f3773d37si2340790qvb.245.2023.06.26.12.10.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jun 2023 12:10:30 -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 1qDrN7-0003lX-Rz; Mon, 26 Jun 2023 14:55:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qDrMR-00020Z-Oo; Mon, 26 Jun 2023 14:54:51 -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 1qDrLu-0005jp-IX; Mon, 26 Jun 2023 14:54:20 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id E1E48EF44; Mon, 26 Jun 2023 21:50:29 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 6DBB2F7D3; Mon, 26 Jun 2023 21:50:28 +0300 (MSK) Received: (nullmailer pid 1574094 invoked by uid 1000); Mon, 26 Jun 2023 18:50:16 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Peter Maydell , Richard Henderson , =?utf-8?q?Daniel_P_=2E_Be?= =?utf-8?q?rrang=C3=A9?= , Daniel Bertalan , "Tested-By : Solra Bizna" , Michael Tokarev Subject: [Stable-8.0.3 45/54] host-utils: Avoid using __builtin_subcll on buggy versions of Apple Clang Date: Mon, 26 Jun 2023 21:49:52 +0300 Message-Id: <20230626185002.1573836-45-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 We use __builtin_subcll() to do a 64-bit subtract with borrow-in and borrow-out when the host compiler supports it. Unfortunately some versions of Apple Clang have a bug in their implementation of this intrinsic which means it returns the wrong value. The effect is that a QEMU built with the affected compiler will hang when emulating x86 or m68k float80 division. The upstream LLVM issue is: https://github.com/llvm/llvm-project/issues/55253 The commit that introduced the bug apparently never made it into an upstream LLVM release without the subsequent fix https://github.com/llvm/llvm-project/commit/fffb6e6afdbaba563189c1f715058ed401fbc88d but unfortunately it did make it into Apple Clang 14.0, as shipped in Xcode 14.3 (14.2 is reported to be OK). The Apple bug number is FB12210478. Add ifdefs to avoid use of __builtin_subcll() on Apple Clang version 14 or greater. There is not currently a version of Apple Clang which has the bug fix -- when one appears we should be able to add an upper bound to the ifdef condition so we can start using the builtin again. We make the lower bound a conservative "any Apple clang with major version 14 or greater" because the consequences of incorrectly disabling the builtin when it would work are pretty small and the consequences of not disabling it when we should are pretty bad. Many thanks to those users who both reported this bug and also did a lot of work in identifying the root cause; in particular to Daniel Bertalan and osy. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1631 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1659 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Daniel P. Berrangé Tested-by: Daniel Bertalan Tested-by: Tested-By: Solra Bizna Message-id: 20230622130823.1631719-1-peter.maydell@linaro.org (cherry picked from commit b0438861efe1dfbdfdd9fa1d9aa05100d37ea8ee) Signed-off-by: Michael Tokarev diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index c2f49df1f9..a309f90c76 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -184,4 +184,17 @@ #define QEMU_DISABLE_CFI #endif +/* + * Apple clang version 14 has a bug in its __builtin_subcll(); define + * BUILTIN_SUBCLL_BROKEN for the offending versions so we can avoid it. + * When a version of Apple clang which has this bug fixed is released + * we can add an upper bound to this check. + * See https://gitlab.com/qemu-project/qemu/-/issues/1631 + * and https://gitlab.com/qemu-project/qemu/-/issues/1659 for details. + * The bug never made it into any upstream LLVM releases, only Apple ones. + */ +#if defined(__apple_build_version__) && __clang_major__ >= 14 +#define BUILTIN_SUBCLL_BROKEN +#endif + #endif /* COMPILER_H */ diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h index 3ce62bf4a5..6519238774 100644 --- a/include/qemu/host-utils.h +++ b/include/qemu/host-utils.h @@ -595,7 +595,7 @@ static inline uint64_t uadd64_carry(uint64_t x, uint64_t y, bool *pcarry) */ static inline uint64_t usub64_borrow(uint64_t x, uint64_t y, bool *pborrow) { -#if __has_builtin(__builtin_subcll) +#if __has_builtin(__builtin_subcll) && !defined(BUILTIN_SUBCLL_BROKEN) unsigned long long b = *pborrow; x = __builtin_subcll(x, y, b, &b); *pborrow = b & 1; From patchwork Mon Jun 26 18:49:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 696477 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3389142wrm; Mon, 26 Jun 2023 12:09:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7+cAVXKFJV42h1MX/DhavD7yZpH7K1KJG93G2QmtUpve9WmzGP59Z14HW1/UxcijmFQg3P X-Received: by 2002:a05:6214:c66:b0:635:da80:e53a with SMTP id t6-20020a0562140c6600b00635da80e53amr5519360qvj.12.1687806557055; Mon, 26 Jun 2023 12:09:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687806557; cv=none; d=google.com; s=arc-20160816; b=XD0FtcSWit0UAd0FU4OgH5X8sLyXt+fZwfCAoYi1MvTyew9qu6KxO31ret9TKI1KaH i7nYnPnm/EarjilBtofniusXdSCZUyVuthPaFC0bsbfpUldxu/HPCBxqIlKmPc+IHqp3 WIJq9DURAQlT4WeUVgHDaeddUJQfQc6i62masoR6W7/7ZnRnOrABh3eE38bRhBnsey3B 94okRPbr5PDPSnYK8aAZFuucU3jAxE3r9p62ZRqkzW77mmjd2Q3tfi+X7ENWlW7au+GR DYXIOhmOwzan/R8MlJaC0s3K4XZ8yJVOXdrwkF+hoM9M6HMgRSr/SKmp8jjxUh2SO+rD kObA== 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=0t3Vbu2F2xhgOOMsPbnqYyceSdtg/9W8syS5MlRtldw=; fh=gnRLUxcSQFkqqnlDk6nT9jvYFtrM8UOZN4Rv8c8Mu8k=; b=xS2loK/+PTd3mqXcbwhRc3mtP3I1M3Ulkzl4wI5u9CXn9ZE5+xezVk8i4PcPqrRts7 a8HCMkocbMgjU3Epttg0zfNqs015LFwJIB3aeL8efTwf/brBHHO6dc03DUbpPeI5N5LG XRp7HmAWnC4IEzdeeDbDu0691ziuH64VwAeJJ8rM2pkzGRrh9UZlu4Z6icUGfcFrLZi6 ynPFfVcCFQ5WRrqQvegfM44HTyLS8XmGRfLr/GB59xSEn1POadFwDtHAOkTN2DwuxnaD sQROLcYJjrItYhBjHZcwIpjLNkrszFSPAoeQw7uC+sMAyddWX9dXfA89gmnNupZNZMee uWWw== 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 iu4-20020ad45cc4000000b006286abef063si2299731qvb.77.2023.06.26.12.09.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jun 2023 12:09:17 -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 1qDrNA-00044j-OG; Mon, 26 Jun 2023 14:55:36 -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 1qDrMS-00021w-9F; Mon, 26 Jun 2023 14:54:52 -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 1qDrME-0005k5-RN; Mon, 26 Jun 2023 14:54:40 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 16646EF45; Mon, 26 Jun 2023 21:50:30 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id A54BEF7D4; Mon, 26 Jun 2023 21:50:28 +0300 (MSK) Received: (nullmailer pid 1574097 invoked by uid 1000); Mon, 26 Jun 2023 18:50:16 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Peter Maydell , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , =?utf-8?q?Daniel_P_=2E_Berran?= =?utf-8?q?g=C3=A9?= , Michael Tokarev Subject: [Stable-8.0.3 46/54] pc-bios/keymaps: Use the official xkb name for Arabic layout, not the legacy synonym Date: Mon, 26 Jun 2023 21:49:53 +0300 Message-Id: <20230626185002.1573836-46-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 xkb official name for the Arabic keyboard layout is 'ara'. However xkb has for at least the past 15 years also permitted it to be named via the legacy synonym 'ar'. In xkeyboard-config 2.39 this synoynm was removed, which breaks compilation of QEMU: FAILED: pc-bios/keymaps/ar /home/fred/qemu-git/src/qemu/build-full/qemu-keymap -f pc-bios/keymaps/ar -l ar xkbcommon: ERROR: Couldn't find file "symbols/ar" in include paths xkbcommon: ERROR: 1 include paths searched: xkbcommon: ERROR: /usr/share/X11/xkb xkbcommon: ERROR: 3 include paths could not be added: xkbcommon: ERROR: /home/fred/.config/xkb xkbcommon: ERROR: /home/fred/.xkb xkbcommon: ERROR: /etc/xkb xkbcommon: ERROR: Abandoning symbols file "(unnamed)" xkbcommon: ERROR: Failed to compile xkb_symbols xkbcommon: ERROR: Failed to compile keymap The upstream xkeyboard-config change removing the compat mapping is: https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/commit/470ad2cd8fea84d7210377161d86b31999bb5ea6 Make QEMU always ask for the 'ara' xkb layout, which should work on both older and newer xkeyboard-config. We leave the QEMU name for this keyboard layout as 'ar'; it is not the only one where our name for it deviates from the xkb standard name. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé Message-id: 20230620162024.1132013-1-peter.maydell@linaro.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1709 (cherry picked from commit 497fad38979c16b6412388927401e577eba43d26) Signed-off-by: Michael Tokarev diff --git a/pc-bios/keymaps/meson.build b/pc-bios/keymaps/meson.build index 158a3b410c..1cbcdebefa 100644 --- a/pc-bios/keymaps/meson.build +++ b/pc-bios/keymaps/meson.build @@ -1,5 +1,5 @@ keymaps = { - 'ar': '-l ar', + 'ar': '-l ara', 'bepo': '-l fr -v dvorak', 'cz': '-l cz', 'da': '-l dk',