From nobody Sat May 11 13:50:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1668468883; cv=none; d=zohomail.com; s=zohoarc; b=btnwZzwrRMVX017gm5c5LcyPkjArWbLebBpIWhTjYCqVjDwk21aSEhnJVOnSzg5rswLXIpW/j84LD5ktlknL000P6Q21+3ItPfn61+tHTtTdGT2Bjr1w8GjljNWa/yBvS2ak5HRbC++58zzyLw+v/TR+b6Stmpg5U+8BRA3ZoKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668468883; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=tfneRg/gsPSVQlEdifSjggr7QvzAAQiGCHa04CF2Nj4=; b=f31Gg5vXpt57PFeSgLk1iv7zm/Rx9i2MfJh22C9miCOpJF37jntbV57wVF44OQeYEeN24kSsXhFhU9iFWsvn0EH4kgtWud/pXjxVH06HttP/5MfXk7jzrKimqOOgoODr0pabhsyfegTDSWVFZQvD1g9CheSFaKwDWjPAHQUKfGo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668468883489974.1816213763182; Mon, 14 Nov 2022 15:34:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouinx-0008LR-3G; Mon, 14 Nov 2022 18:23:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouifP-0005Ez-B5 for qemu-devel@nongnu.org; Mon, 14 Nov 2022 18:15:04 -0500 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ouZaP-0006Rz-Jp for qemu-devel@nongnu.org; Mon, 14 Nov 2022 08:33:20 -0500 Received: by mail-lj1-x22f.google.com with SMTP id s24so13166606ljs.11 for ; Mon, 14 Nov 2022 05:33:15 -0800 (PST) Received: from jade.urgonet (h-79-136-84-253.A175.priv.bahnhof.se. [79.136.84.253]) by smtp.gmail.com with ESMTPSA id y15-20020a05651c106f00b0027760138c53sm2006609ljm.72.2022.11.14.05.33.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 05:33:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tfneRg/gsPSVQlEdifSjggr7QvzAAQiGCHa04CF2Nj4=; b=D4QKCpPeCgFSMTCODtX9SYWW+gkq9ep1DeKfadZD48i8WsomBOT9cli55m1ELNyGV6 9kHzCO/PHeOxAnmSuseC+VA4LprKh3Dbx9qVpZ9cJnRTOxApd8PLfEXu8UaXB46b/sTD ObzZk1L/81pGki4DMiWkTRKM2PbZFk5LEMsHTgUR01QGUqf8Pf7XWXqn87j1MVhcaZDr 5w8u5UM7vNiARvPdp7msFPBcHvkWYKa2hKGr2pjjDpDYXRPvVlBadCLEpL/qUxaXLL03 3teltm4dWahR5K2Q+6qR6iwtc24KFCAdmswNLuoQQ1B8p2aJlhvLVUD1vVqEIVUOY5o1 LFxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tfneRg/gsPSVQlEdifSjggr7QvzAAQiGCHa04CF2Nj4=; b=6Jh+1TdYWsCKXI7f/UbaxNLx3Pd/JY95BSsyqM2r0LdF/dHvuCyEfS0EtWAmdxs6FE QPVCYUbBiZlGc4Y2nxs3rCNxD4gT023/ezW8YTa1OCUPL+d8nQk3pQ1y6rT1HaKlV8Ty rrowka6eOuh2ojzrCeGrMTUESZkT540uW8EkFLSVNRHQc6/pZU/aatet01y1fsd1G2kN MVrsT8VTSgy7OmPxsTf5ceA2K+A6WDsKkNH5rHoz3ddfp1pdeSjy5r2grECog36kXjpE WkHLr++GDYc4HleU03xexZ3jqYJrGM/VXlQJafjj5F1vw9va8bSLVA5v2uwgLTBwEZzA qX5A== X-Gm-Message-State: ANoB5pms+ZiQVaq3gkpO4cQpCEH/51c/GXkSZSW21BXxReYV7B+m6MWw 8wG0Pr9j/vKGFy5F9ylfI/IkRw== X-Google-Smtp-Source: AA0mqf6s0iVKavET9PCDmpQu4WW3PmN4JoiHS+vNpZf9U+WlCZJH7qroVqnyGTHDGh6g0rxkpMJJTA== X-Received: by 2002:a2e:711a:0:b0:277:2f15:4179 with SMTP id m26-20020a2e711a000000b002772f154179mr4193619ljc.408.1668432793718; Mon, 14 Nov 2022 05:33:13 -0800 (PST) From: Jens Wiklander To: qemu-arm@nongnu.org Cc: Peter Maydell , qemu-devel@nongnu.org, Jens Wiklander Subject: [PATCH] hw/intc/arm_gicv3: fix prio masking on pmr write Date: Mon, 14 Nov 2022 14:32:57 +0100 Message-Id: <20221114133257.1752176-1-jens.wiklander@linaro.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=jens.wiklander@linaro.org; helo=mail-lj1-x22f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1668468883885100001 Content-Type: text/plain; charset="utf-8" With commit 39f29e599355 ("hw/intc/arm_gicv3: Use correct number of priority bits for the CPU") the number of priority bits was changed from the maximum value 8 to typically 5. As a consequence a few of the lowest bits in ICC_PMR_EL1 becomes RAZ/WI. However prior to this patch one of these bits was still used since the supplied priority value is masked before it's eventually right shifted with one bit. So the bit is not lost as one might expect when the register is read again. The Linux kernel depends on lowest valid bit to be reset to zero, see commit 33625282adaa ("irqchip/gic-v3: Probe for SCR_EL3 being clear before resetting AP0Rn") for details. So fix this by masking the priority value after it may have been right shifted by one bit. Fixes: 39f29e599355 ("hw/intc/arm_gicv3: Use correct number of priority bit= s for the CPU") Signed-off-by: Jens Wiklander --- Hi, I've only tested this patch on top of v7.1.0 since I couldn't get current to run in my test setup. In case anyone wonders what I'm testing, it's a setup with Hafnium at S-EL2, OP-TEE at S-EL1 and the Linux kernel at NS-EL1 (no NS-EL2 for simplicity). Regards, Jens hw/intc/arm_gicv3_cpuif.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c index 8ca630e5ad1e..b17b29288c73 100644 --- a/hw/intc/arm_gicv3_cpuif.c +++ b/hw/intc/arm_gicv3_cpuif.c @@ -1016,8 +1016,6 @@ static void icc_pmr_write(CPUARMState *env, const ARM= CPRegInfo *ri, =20 trace_gicv3_icc_pmr_write(gicv3_redist_affid(cs), value); =20 - value &=3D icc_fullprio_mask(cs); - if (arm_feature(env, ARM_FEATURE_EL3) && !arm_is_secure(env) && (env->cp15.scr_el3 & SCR_FIQ)) { /* NS access and Group 0 is inaccessible to NS: return the @@ -1029,6 +1027,7 @@ static void icc_pmr_write(CPUARMState *env, const ARM= CPRegInfo *ri, } value =3D (value >> 1) | 0x80; } + value &=3D icc_fullprio_mask(cs); cs->icc_pmr_el1 =3D value; gicv3_cpuif_update(cs); } --=20 2.31.1