From patchwork Mon Jun 26 18:58:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 696475 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3386315wrm; Mon, 26 Jun 2023 12:03:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5FDq4pucn4d4amr4kzfVYj9KbRUlShBUNf/azMlfz+BIdPLkPz6UsbMzwp4N0M6zLWTuT3 X-Received: by 2002:a05:622a:1a1e:b0:3ff:407e:1f with SMTP id f30-20020a05622a1a1e00b003ff407e001fmr19146967qtb.41.1687806182041; Mon, 26 Jun 2023 12:03:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687806182; cv=none; d=google.com; s=arc-20160816; b=rF8glsMAYBhIsrROOeNlejC6Q5Y/++9vkCkQbNw/Ez+5goutu7qQfwL8MOxy1xq+pp /3oJSlEXqhARjXclB1lnRetv9FVKTuyonPuXeYErKmzuGiquxD1PUVaOyElqKEvvDKOE tH5NqaoIyYkTbdyZ1qQX3S83uuAxtwHLnhgdnVwapA9uErKFXY2S5pYx+Qv/S+nragm7 SNCXDHzeeHgi4fRj75cPo/8tXuasqQqf4tFMF9LhYafEFt+Lyauy43mVu61shUgLPlkd QSF0nvzpuPzHN1fyqaeG8MqH/MqDbFPhSp9yAnPePY5XoULNGvFLqtt1TiaA2N0HmlMA 8FYw== 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=6llPYcjiTXdZLw8cBLQyrj+248jZdgbd55G7cNkuDu0=; fh=0Xp2JyaTaNttgD8GBymZGxc1xOSx5UTRsLJ5GvGrdK8=; b=SA6mzazTAJLPxfX4jLuUw6Kx6EEmc8APK7HrtUiUxfsBeBBn3kDIFhY1FooilZ811Y puW+7+v4m+SLGtcPjLGv1RnTpjJ158y9A5F/UPRsfZZ5kxjX/mde8v3b87jIodGDUOXS 2bI9Q0FdgnCdH6HBytRPkH0KaIEUckFSlv270YIdR49BL1bhvqeJkNttw0uEKLJEjcE9 0V9VBVi1KSCdb0CmfuxIpexRCPfFN+MdG3wHHvgy6H10sUMud4zkGEhluId+hf1Vw3M6 0jWweoAhBaHHD8uM9ZwEgtqGS123RP0jFlCyTWqpMDR36ystZbWK9cuk8WMgVdtxrCoq 4Gqg== 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-20020a05622a119300b0040079a9afabsi2093648qtk.304.2023.06.26.12.03.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jun 2023 12:03:02 -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 1qDrRc-00031i-5W; Mon, 26 Jun 2023 15:00:12 -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 1qDrRF-0001wl-JK; Mon, 26 Jun 2023 14:59: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 1qDrRD-00076l-HR; Mon, 26 Jun 2023 14:59:49 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 3B6DAEFAE; Mon, 26 Jun 2023 21:59:09 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id B9848F7EA; Mon, 26 Jun 2023 21:59:07 +0300 (MSK) Received: (nullmailer pid 1575315 invoked by uid 1000); Mon, 26 Jun 2023 18:59:05 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Peter Maydell , Richard Henderson , Michael Tokarev Subject: [Stable-7.2.4 13/43] target/arm: Explicitly select short-format FSR for M-profile Date: Mon, 26 Jun 2023 21:58:31 +0300 Message-Id: <20230626185902.1575177-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, 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/tlb_helper.c b/target/arm/tlb_helper.c index 0f4f4fc809..1384fe6f98 100644 --- a/target/arm/tlb_helper.c +++ b/target/arm/tlb_helper.c @@ -82,8 +82,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:58: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: 696484 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3392178wrm; Mon, 26 Jun 2023 12:16:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5HR2yYSATzitJa0r9f1z5ET6EjNpB1eOsW3gtfOup/AlZN0f5nTDVGMF2AGw402a/Zteow X-Received: by 2002:a05:620a:8e04:b0:762:55f7:7105 with SMTP id re4-20020a05620a8e0400b0076255f77105mr22327399qkn.28.1687807009593; Mon, 26 Jun 2023 12:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687807009; cv=none; d=google.com; s=arc-20160816; b=CindFTvTMv09xw0GxDn264eFb32IkPi4ongF9ULSMM6utT3qldPyeDB30qOFKpKVp2 WY+FJMzGNs0n0V+4Mg/WTsToMoeevd6trfIhNnewewBePesVzsLt9i/BamlaSu+ixkzG TrD4d6giOCXI+1cO6fzdNqlcpNfp4loyiSogHNuzB122t1bMfpaS0mY3D70r6dFnBBOQ EVc+7u0K8bTupKnkmy/0Lr3xHCHD4vOB4XB7MuAEUo9AJW+prmdGhvfV2dqR88z2h1fW ME4QP1ZXBqFrwOLGR9X3VnqqdYvdDKm/ByXh+2qoxlIEuPLvdRaPhzwFWtR8pxFQ5MG4 yJ/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=KBSbbNh44nS2xiZYeDKAmdRVBSEXxV17K8hgTI3W3GA=; fh=0Xp2JyaTaNttgD8GBymZGxc1xOSx5UTRsLJ5GvGrdK8=; b=z9Qg/bZBWs4M3hv/Fym+johV2aiYsx9eyzG9kSpPsnxJ4aJHjSHIJwGT0J4bCYDrMc kI9xLNze5aibqJZDvOu8wZNTzP2RlHYEZQChUX/GTdlFnukQIi+41C7KfiCIsjAEYg3x 2FkGGllXtHVwz8dsIsOIh3SOO3FkfVh3jgoe4xG9FYbfBK/ebTy9d3B4yhOV9giSrl1s 7Z7672i1DX09drG8u9GfXSffjhVZQLASHB5TYityrcOY9kA+jKt4y6MDW+KfXT3ThwNn ofqmyrCFHGbiOIZkmG9DqbKExZwosnEXLSzvptDZlP1rsFM91mupyYVkxcz51vEAYnBg qMMA== 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 bm20-20020a05620a199400b0075c9c3c3b75si2139202qkb.645.2023.06.26.12.16.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jun 2023 12:16:49 -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 1qDrTL-00018r-U2; Mon, 26 Jun 2023 15:02:00 -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 1qDrTA-0000CW-Np; Mon, 26 Jun 2023 15: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 1qDrT9-0007nd-5k; Mon, 26 Jun 2023 15:01:48 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 9B9C7EFC0; Mon, 26 Jun 2023 21:59:13 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 2DFA9F7FC; Mon, 26 Jun 2023 21:59:12 +0300 (MSK) Received: (nullmailer pid 1575370 invoked by uid 1000); Mon, 26 Jun 2023 18:59:05 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Peter Maydell , Richard Henderson , Michael Tokarev Subject: [Stable-7.2.4 31/43] target/arm: Fix return value from LDSMIN/LDSMAX 8/16 bit atomics Date: Mon, 26 Jun 2023 21:58:49 +0300 Message-Id: <20230626185902.1575177-31-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/translate-a64.c b/target/arm/translate-a64.c index 2ee171f249..3c356d238f 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -3536,8 +3536,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:58:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 696483 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3391808wrm; Mon, 26 Jun 2023 12:15:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ42gNiND36UpdtNzdJDVfNAD7DDJjfcPpg7AFsLmENFK7ckmx1enMvk7LcLdAttrErFFDYV X-Received: by 2002:a05:6214:401d:b0:635:d5c5:15d2 with SMTP id kd29-20020a056214401d00b00635d5c515d2mr7232777qvb.18.1687806953637; Mon, 26 Jun 2023 12:15:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687806953; cv=none; d=google.com; s=arc-20160816; b=Vioms4Jw9F/qZf2JjVy8Zu9p6+zu4ivVL7/w0iGk3itJfXyX/C1GvS0PoWVEHMBOx6 7kkWSsvDOLRw1YUf8ku3K3nkRf3ruuOTjjWa4lGyso+9qYhDPgWn6jUZksw6s4hragUw CqWdxYPIRvwitLOHBVikUcG2CzocuH0/gp5VFw3gmaEs/R13PjFWTRUNlJQ9LdNlxet/ xUmGEP6WXCy+UpCvL9t8tKY2VAUR5DS2U4qtI/P4ufOTUYrQQ/O71M5tHfR6ZbPqUYFF GLPotkutFvy10+Jbt5SF9xQVatJfEh6ne0LHpAgbZAwzEg2WS8n5mpWyrbfcXdmojOUI poLg== 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=gOwyi3v41yaY9FMB03KFlGMRdNwlN1ulHodlb1zTIf0=; fh=0Xp2JyaTaNttgD8GBymZGxc1xOSx5UTRsLJ5GvGrdK8=; b=C1D9IzyVDjP1wPF9NQwR2AHVjb2z1IhBCzewvVPnztqOz4T+3BrRuHInISI8N3LwLn 2lF25d/dMlPuwvdcK8ukjI+gnfQ7RuoQAqUICylCmYL5/r/xLHVhw3vj+xuRZaKnHmv8 7acAXcWRjeXXT/3tf85AJsXA0i+M7e5wvMyLCjRAFeSPlx4BUF4L4uOqKUfRLuqOy1M0 rpHxcY7Hd/HYAIiKJyzf1L9kA5H5Q+zWj4vqmUbJ/Sy0VzoLymWogVcbFjeBv6LrsERU eGVE7LKoUuaKcJiKFdRE37oLmJhLCnnsAsDjzoGJoUUQWsja9J+tL9uVDuUQbNwcW7Kn a1hA== 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 4-20020a0562140d0400b0063001e0134dsi2395535qvh.43.2023.06.26.12.15.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jun 2023 12:15:53 -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 1qDrTH-0000WC-Ke; Mon, 26 Jun 2023 15: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 1qDrTD-0000NU-A2; Mon, 26 Jun 2023 15:01: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 1qDrTB-0007oS-JZ; Mon, 26 Jun 2023 15:01:51 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id C9E84EFC1; Mon, 26 Jun 2023 21:59:13 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 5C1C9F7FD; Mon, 26 Jun 2023 21:59:12 +0300 (MSK) Received: (nullmailer pid 1575373 invoked by uid 1000); Mon, 26 Jun 2023 18:59:05 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Peter Maydell , Richard Henderson , Michael Tokarev Subject: [Stable-7.2.4 32/43] target/arm: Return correct result for LDG when ATA=0 Date: Mon, 26 Jun 2023 21:58:50 +0300 Message-Id: <20230626185902.1575177-32-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/translate-a64.c b/target/arm/translate-a64.c index 3c356d238f..f0b8db7ce5 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -4190,9 +4190,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:58:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 696480 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3390274wrm; Mon, 26 Jun 2023 12:12:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5GeYEQbpupX8RoVUeiSgnxRCzs7H0mr24fhuVM2XFNE1hWBWjkbLEMod9kN29MIsHVwEdM X-Received: by 2002:a0d:d9c7:0:b0:565:a3e6:1b7b with SMTP id b190-20020a0dd9c7000000b00565a3e61b7bmr29923113ywe.18.1687806729864; Mon, 26 Jun 2023 12:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687806729; cv=none; d=google.com; s=arc-20160816; b=GCYdmyQfSWMayhGdydjCO6Pgi4SmFqwCjiW4Ri7sy9BAETFaxkAwPv/OUjyRu533L7 +ct7fyVjW10JAJ0YVR8k/7YB5MemToA980mMc+JDTCqIv8phP2cpAGMq/Dk6a89v0s/B 1P/nQceecU88PbgJm3w72zpSqjsGx1gu3WxW/KuWJnMye3OlSV2JhuUDBKMEP6AH0Pd+ kM5R2xXnTsjFzenvTK8gozBFv+uDhbP+lcMnLYO4hqn7DC1sIS18Nrf+yTxUu9OSJTqh gCmCpvJioHnjFt33c+SOkBZ0nXt7zGg6pecPnwaPpIbLYPX6tqk3n1a3l544DQOZ0s6e kQcw== 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=+6wr5riQEs84r4DX8fVIKbQW+ymbnnvOaCUJc9Pl2fw=; fh=aDE9/c4c4updyTg5EjMEty1hnd1R8wyIvX5PILnUv5k=; b=e9NnPePnuELi7CExAVNYZs+D3m5QkKZtYSkljx+xKhDeO9m4fsCFIZZw/ui/QLToKk rmPTJdg9cW42VReMyM9EvH47alV5/gYU6CsfFwnpHUNFREMOxBNDIXq/ujIT9vBUXGpL +JAYz4BATfLWN7GBHi7iZbm9aL0zJAILls4zzq096gIMvClghBRx6kIX2h/NFJxqavlc pUCjlZ+Dmw9UOzvW3kzG9AkJGOXDtTxjOZEe7FUfpqJj0rWLcuryo6QgdNk9C5wppAwX SeCxvheoYpEAWIwHPON50cI70gmh4Cl9e1H1prQCzzolgAAvsEg9cK/cQvK48Fd9fd9O NXNw== 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 br35-20020a05620a462300b007625731b2besi2175676qkb.551.2023.06.26.12.12.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jun 2023 12:12:09 -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 1qDrTs-0002ha-5O; Mon, 26 Jun 2023 15:02: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 1qDrTG-0000Vc-F5; Mon, 26 Jun 2023 15:01:54 -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 1qDrTD-0007qp-86; Mon, 26 Jun 2023 15:01:54 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 03CDDEFC2; Mon, 26 Jun 2023 21:59:14 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 8ABD3F7FE; Mon, 26 Jun 2023 21:59:12 +0300 (MSK) Received: (nullmailer pid 1575376 invoked by uid 1000); Mon, 26 Jun 2023 18:59:05 -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-7.2.4 33/43] hw/intc/allwinner-a10-pic: Handle IRQ levels other than 0 or 1 Date: Mon, 26 Jun 2023 21:58:51 +0300 Message-Id: <20230626185902.1575177-33-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: 5eb742fce562dc7 in stable-7.2) 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:58:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 696476 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3388904wrm; Mon, 26 Jun 2023 12:08:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5B9XKTp3p10KVrVypytaQ2ohvuwhUsTb+b6erqhZfL41lwI3SC1KEXZFbv6C0jwNM0UwSE X-Received: by 2002:a05:620a:8e11:b0:75b:23a1:3ee with SMTP id re17-20020a05620a8e1100b0075b23a103eemr20959089qkn.4.1687806519323; Mon, 26 Jun 2023 12:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687806519; cv=none; d=google.com; s=arc-20160816; b=Eck5/DG294dQqcqME84L62ulZ449HL9S9AlN0fIjLZWquTXM6UjUOToQfUOhFDGk7R SX4EXDTx/U7vaVXyuumRmBYwcaQewzP7ioj5scDL8ZuN68PgrroqCoZMm2AgR5uaooQj D2VNMabwICLuc34Wc2PWREuqaq6s0tnQ2HwltqwlOTQ9Fbt1Rb6Lj57FRSpXu6J1fqK6 jy2pVU9ury6wyeWbKWpllHRqsCooVPLIp8mhAspTryvYTw4F4NbPkhGbv5y+jnvytbC3 +xl5rymvbqxypoW3E23FmEKvrTnVCTgLGkhnHA6d2vSNwPWpKRYwhHdaFjK+xu5TY1TE gEeQ== 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=sPZE2WImT27UwJMnNTPNXP+UB33PV+a5VQSxN7877LUrMHrmKLL8+bFA2i4StL58bt H9dECW47dfNflHgdyA9SKlYrKtdtA5JMtt4kzu9p2hka0Wu6Be8YRqGKo6jH/XPqnKub suGgewlGgCBX+UXJd8sEW3vMy5TZrsZ6rMsoKB3N2hYjikjd8+Za23YAkpgDgDfJuj8B xgEJCEsUXrnsHG5lHB3WlqvR2WoNkybVJ/hAeBBeih1Bwkn3Jx87OHiFtpHjRqD+SAra XT3Mks8Z9r/LF4ZfAaDJ/g9dF5eXORyBI3DZW9m7osxjR9ZqjLhv89B0R5VM3SQEgjoQ gLzw== 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 dt45-20020a05620a47ad00b0075ec02993d5si1242891qkb.50.2023.06.26.12.08.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jun 2023 12:08: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 1qDrTf-00027j-85; Mon, 26 Jun 2023 15:02:19 -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 1qDrTH-0000WP-4U; Mon, 26 Jun 2023 15:01:55 -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 1qDrTF-0007rP-97; Mon, 26 Jun 2023 15:01:54 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 48C60EFC3; Mon, 26 Jun 2023 21:59:14 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id B82F4F7FF; Mon, 26 Jun 2023 21:59:12 +0300 (MSK) Received: (nullmailer pid 1575379 invoked by uid 1000); Mon, 26 Jun 2023 18:59:05 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Peter Maydell , Joel Stanley , Michael Tokarev Subject: [Stable-7.2.4 34/43] hw/timer/nrf51_timer: Don't lose time when timer is queried in tight loop Date: Mon, 26 Jun 2023 21:58:52 +0300 Message-Id: <20230626185902.1575177-34-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:58: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: 696478 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3389607wrm; Mon, 26 Jun 2023 12:10:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7yr7XmGajsSv88yMb1L0WFVR2vi+U7TrVyZb9uqTqjqOPhzlZsYUD7avCrTkdvOWna43qg X-Received: by 2002:a05:6214:2426:b0:626:1b09:1d4f with SMTP id gy6-20020a056214242600b006261b091d4fmr37484213qvb.46.1687806624205; Mon, 26 Jun 2023 12:10:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687806624; cv=none; d=google.com; s=arc-20160816; b=D35pKZxi/lWdV71lGSd4N49mzPzk8kfUufrmtKNqpEk0lznMjZQo7+X0de+74TOPWo cGzhq8ZzI2dtmhZC+uWdtot585zJhCDJ15Hfs7PZPufTgLfoXlpaqlr314KmdFDxThix 5G9BSg0hjl5aDv0bonzFkrchF2T99ahfjmS5LhHUvQjQJe7mlZ1AZdtkfLAtJxCsGDjc jqGb5FRONkMQvZag7amHanXuUr+2zgwlHpYrUnNXTQ3d1Wkrhjhq7WVDFdCPcGvRo8z/ czxaLCuXHKdT28IsnAUSbQMO9ENsNKLl9kiYtRRFfpi/twIwJ4DJ/hkLQ3U7Ro6iKd4l FDHQ== 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=PKdG5zBlRii32b3yk+Z/rsxcHJ+zHxKrMbz8RsdLgII=; fh=JfuprfCedaaH4bwbV1+UfSdrVnNu3JN+V+yaHHqBUgY=; b=t1wZ0CjqaiML2BD8LSapnppGATanx2WkxzlY2Pm8BxeuoGkv2AbWqzSex5nLaDIPEs JGQ2AvA6ANAnvccV03EY6OCp5aa7KAClAFHc6QfsOWH2anO0jDjjBpu7+fAWOX7ihgCI kCKzTNCOWXiR6so0OsN8T1IxO7RVLT9+ARDlrcH8MD3v90hehgljgv1tr/9GiyGpO63c UYnVvHmJru1t9MemFcWG8MqzbfaA6GUd2ZVfXYp1IKRMtIdmMhW+IsKvAZtlZoPKHTCh bSOHc91c5Lx7JJXcLXxWhEaTnu2QWr9LYKQsnaysXhaDj4ppOC3Na5Z0vbE/iac5IV03 4ICA== 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 a3-20020ad45c43000000b00635db21d14esi1364527qva.303.2023.06.26.12.10.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jun 2023 12:10:24 -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 1qDrTy-0002o5-4J; Mon, 26 Jun 2023 15:02: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 1qDrTJ-0000sK-Sr; Mon, 26 Jun 2023 15:01: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 1qDrTH-0007sI-SJ; Mon, 26 Jun 2023 15:01:57 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 8C191EFC5; Mon, 26 Jun 2023 21:59:14 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 08FA9F800; Mon, 26 Jun 2023 21:59:13 +0300 (MSK) Received: (nullmailer pid 1575382 invoked by uid 1000); Mon, 26 Jun 2023 18:59:05 -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-7.2.4 35/43] host-utils: Avoid using __builtin_subcll on buggy versions of Apple Clang Date: Mon, 26 Jun 2023 21:58:53 +0300 Message-Id: <20230626185902.1575177-35-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 f20a76e4a2..c7ffcaba43 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 88d476161c..b3434ec0bc 100644 --- a/include/qemu/host-utils.h +++ b/include/qemu/host-utils.h @@ -596,7 +596,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:58:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 696482 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3391677wrm; Mon, 26 Jun 2023 12:15:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6YDRMKJj+7yW3ePJ8f8euShpjOybhXHPu+eb7KuK56hPupZpvVkWbS14c8RPPmaRUgZgTO X-Received: by 2002:ac8:5903:0:b0:400:aa47:a4a1 with SMTP id 3-20020ac85903000000b00400aa47a4a1mr2988103qty.25.1687806932605; Mon, 26 Jun 2023 12:15:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687806932; cv=none; d=google.com; s=arc-20160816; b=wFev+KUBSbzN12aM8Jp0pbmH6tYZNiMQ4XgNugXL4X6CBc/vEsER5vZ5B1u5rTZqbG lby3buCTZg3Up3N8qxyeZxWVvcurt5ialUSLzqkhe93z14UlTrqpGVEGZmpA0i/F/TEa MzWT9ME2KzzkffPcBSwT3iDqzv9iXxA2vOPNSMTwIzuEAciJS21prz9r9BgH0liqh7ix 38nYTOGtYbYleiZ/mPQpZpfQlzjmeTDJtG/AZzfK/OwoneqL7uCPg8QxNtRTlt8o18t2 Y67DwDzHiYuDjlhFMdhHsdh2XYVsTqoCPaA4fWhyJYD8r8GMU/hPs9rdYmi7RaxSIJm7 11lA== 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=iNA+VUTYfbEdx/vQeF8+9JE2SRU0GW5WPBNix8y3ge4=; fh=gnRLUxcSQFkqqnlDk6nT9jvYFtrM8UOZN4Rv8c8Mu8k=; b=nCLpDxljKoI0zM2Rj3WCU7c/Y5y9IxhCzGy4vJXQzZNwYhSdOHh06XPU893uiejsxF MfMoMYZHJ/X1gnXL7Kl/N+AboAoCodqxNrm2dncPCfYHFJy52esy4dEsh1y+tQGIL7fy ajDr81XqOEGpyVOeTa00TnZnLQGdycaS18YRpZYGTRxUNNlIKKI0xT+m/fJFOOG1GMCW BrTYSojl86uxvbZn5ENuAW9T65K/bn5GXx+bcSydKTU5x+l/DX5SG5LmSv+LheYfw1rY /X/jQ8B0uvQhib0AnpF0M6AWVt6U8ze+dHHo16/FgqzwC2iZB84ttxR/9IdQSEl4fqew P/YA== 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 t15-20020a05622a01cf00b003f4f306ce56si2148557qtw.495.2023.06.26.12.15.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jun 2023 12:15:32 -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 1qDrU0-00033I-T5; Mon, 26 Jun 2023 15:02:42 -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 1qDrTf-0002BZ-Kj; Mon, 26 Jun 2023 15:02:20 -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 1qDrTc-0007to-Kh; Mon, 26 Jun 2023 15:02:19 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id B2CE4EFC6; Mon, 26 Jun 2023 21:59:14 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 4C203F801; Mon, 26 Jun 2023 21:59:13 +0300 (MSK) Received: (nullmailer pid 1575385 invoked by uid 1000); Mon, 26 Jun 2023 18:59:05 -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-7.2.4 36/43] pc-bios/keymaps: Use the official xkb name for Arabic layout, not the legacy synonym Date: Mon, 26 Jun 2023 21:58:54 +0300 Message-Id: <20230626185902.1575177-36-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 06c75e646b..452395b962 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',