Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp207376lqe; Wed, 27 Mar 2024 03:32:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXoGsQL2FR+o8oR/pVtt0f6V5ZLkLxiihChjq42781LogXvQ7oBiUhoFo08aLHuhO3uct3p/PQ+N4Tr940tI2JKH4yvnDBamtvays4OEg== X-Google-Smtp-Source: AGHT+IH7kLOW0ylboPjJH93BSMYc8db7Tv/dV213ZM6w9soM6vwHT64FJ25d0fIIC2S5YcrDRzwt X-Received: by 2002:a17:903:228b:b0:1e0:ac2b:44b6 with SMTP id b11-20020a170903228b00b001e0ac2b44b6mr952960plh.18.1711535521753; Wed, 27 Mar 2024 03:32:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711535521; cv=pass; d=google.com; s=arc-20160816; b=y4VpkvInIO05BraMU/AK4+fX2xubDreOV2RcYDVQetjL8i4p/pc22jBJnyh1toNBlr 0DM/ZYivcLSs542NNAmPw1PeHW54dgh2I06AUIRRtsFMy/bIYPDpyJWtYdDfdurnYDg4 CIBJtD1UASh2oF/CrJSSoYdLg9o+d1kwEoz2ahlTNf0rpR0t7CsuBCeknSst+VTy5qbV U3ZPHeRbgRlbRzdEBu30YoCLOl9MoT+oR/B2wgR0sqqdKEjdEdqfVK9ftSpCz2da03/E Op54/41H8S+NlLTo5sJHt77bqxLlENbWjgw3zS7kiWVclI4siRkDJCZcZXJ4A4sdlucJ RsVg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NSJ+UjWyV6VDqHK474kxHesTXDBqeer09Qi3VieNTqM=; fh=hk00GWPnhV9Tx51DsAJ4Sc6dH+B6/yZTgJtcGiX2KFE=; b=ZJ6oj0a68jU/L7IEQ5qkCqFh697s48ikxDqsf5loI8/wRbO98Aw7pAafsWuTGa2rM4 E86pWvMJD8sIXsm+v6C3sw355cAVSG4K316Rfa5xFG0nAzsuTH3B6W0g66KMK1kcv7ni LWZ4SGlPTCVQxx68FPvNugIJ8Al6V6y7oXtPHqecqa16pN7htLQlYfdGeOkqZOEN9os8 VU80rTgGozgTwpV8ZSkbYgtFVCfmJI0l6TkXPBTlQEQ1Hoj4lgd5X65Y+iBlPPcVSmb5 NPubKFNSGWHPqX8yg8Y62qXhlaxD00MXkSyQNleS1NmVgHna2f52UitI6I6wlLAq1vgs MvSA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=UEV5VsL6; arc=pass (i=1 spf=pass spfdomain=vrull.eu dkim=pass dkdomain=vrull.eu); spf=pass (google.com: domain of linux-kernel+bounces-120670-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120670-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x15-20020a170902ec8f00b001dca6272e21si9502249plg.36.2024.03.27.03.32.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 03:32:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120670-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=UEV5VsL6; arc=pass (i=1 spf=pass spfdomain=vrull.eu dkim=pass dkdomain=vrull.eu); spf=pass (google.com: domain of linux-kernel+bounces-120670-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120670-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2F5F82984D9 for ; Wed, 27 Mar 2024 10:32:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 584C04F1EE; Wed, 27 Mar 2024 10:31:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vrull.eu header.i=@vrull.eu header.b="UEV5VsL6" Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFF111BDE2 for ; Wed, 27 Mar 2024 10:31:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711535499; cv=none; b=OT/N7nPBp3t4fICl9UKH9/7lR8RV/QQBH2BjJNdFVyGbLtny/o1Lx0G8Mpg2tOH80D3NEWeeaPsH0SqFmzjgJ/xU86YHe2Tl/AlxporRVkfMum9Qgp4c5YkPgKI7z0x2t4ZRTpgh4DY3Pzfnb5CK0hefEDu5vZKjX38yhlRB5o8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711535499; c=relaxed/simple; bh=5zk6kq3UFGadP+2Yq4Dm+tPe0GlFy4sAWp32ibDLS0c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pymuWZCRxrVKJl062apC17B67G/Js0BVMQx0fyY9bg8W+ng3tQ7iVEDZw49kdzW2e5BEZPBthe2dL8bzVsdcIVpaiq5xCJ6hBvrR5I7+qXQ0LjDGJmEx0Kqdgu2ktwnPmYRQEuLM7ei4bhLKfV3hz1obVwD178hfVI1yf9od8Lk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=vrull.eu; spf=pass smtp.mailfrom=vrull.eu; dkim=pass (2048-bit key) header.d=vrull.eu header.i=@vrull.eu header.b=UEV5VsL6; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vrull.eu Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-56bf6591865so6259368a12.0 for ; Wed, 27 Mar 2024 03:31:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1711535496; x=1712140296; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NSJ+UjWyV6VDqHK474kxHesTXDBqeer09Qi3VieNTqM=; b=UEV5VsL6Pzq6GZpzN/ArTyAtdDh5efa6ZSv4Rx6GhjNsLVDxDn/H7EVZW0hU+cRYHs RCGdSJYwxvPpA72S0PpdZL0ntDyxqaby37ZToyI8ntmJIwMdkP/kn7grSxF3zu1PVGcj 1xl7OZpHGlr5w9sFd8OX+8sMi3JoFBXpsqnRf0L+hOPC/xGpi4POFMcxE197kmAnODJX 7ua3WI2bslhLx2y6cgIfD3PAH9lU/whgOorvzz/1PLH7cjz5GvLXxzyeoUQkPB+2O9FA 6A/0V+7bOaSyq5zAn163nyS7DsXDIlSV/3DieZRuANLeKCikq1oTZzvunpy/KDUFf+sP xIag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711535496; x=1712140296; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NSJ+UjWyV6VDqHK474kxHesTXDBqeer09Qi3VieNTqM=; b=ZMPNceEQ6XOVAcdxwEN7EuBbcqcX0K/JTCrqyeSVlpnL/Q1l7ASJ7v4PGBWVJqHhZG q9E05eGUCmdTy6nDOWelGaWkyCormsYYcUmZkAut5iHZkxFoBR7VCK3GV9/n4PTyQs2s 3lOqL03FyrWDac6cHtBSoAd3VLkUO8Y5dZ8zSDmN6SJEtd69Yy06AwAYAR55Nu2GbDHg w8kqj3tQZZ7jKVzb3KXUmny0oYUvGCVZY64GvcTLqBnG3Au6YtfjI4tXbCX6DMvRx+zE +CNZYXGS9Ui0oiKtVVXSHRBLMdTLkeqSQU76ulwE1vzefB1bfdXeRntyDvbLZjZc4CEb UCxg== X-Forwarded-Encrypted: i=1; AJvYcCULBPfVj+XgpZdI7kMqSPIIsfsqv/cazSTyOowSxIKScrVetqtIErfWhWWmcrmly4h3IDJt0XGbwrK08hLAHsXhRfM2JQG0MWt6I40x X-Gm-Message-State: AOJu0YwN/ox4fGgOq+rNJsDqDnOOsdub2GVws3x6O/+Yj4Ohb75YmOlD BSnEtWKb9LN/RVoF0y48WWTBWArgWgK3yr6g+7xBhbMeIz5wVAgv1YMJKB4vmhk= X-Received: by 2002:a17:906:6b8e:b0:a46:e595:f357 with SMTP id l14-20020a1709066b8e00b00a46e595f357mr2781223ejr.9.1711535496207; Wed, 27 Mar 2024 03:31:36 -0700 (PDT) Received: from antares.fritz.box (62-178-148-172.cable.dynamic.surfer.at. [62.178.148.172]) by smtp.gmail.com with ESMTPSA id z15-20020a170906270f00b00a46b8cd9b51sm5294078ejc.185.2024.03.27.03.31.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 03:31:35 -0700 (PDT) From: =?UTF-8?q?Christoph=20M=C3=BCllner?= To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Albert Ou , Philipp Tomsich , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Daniel Henrique Barboza , Heiko Stuebner , Cooper Qu , Zhiwei Liu , Huang Tao , Alistair Francis , Andrew Jones , Conor Dooley Cc: =?UTF-8?q?Christoph=20M=C3=BCllner?= Subject: [PATCH 2/2] riscv: T-Head: Test availability bit before enabling MAEE errata Date: Wed, 27 Mar 2024 11:31:30 +0100 Message-ID: <20240327103130.3651950-3-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327103130.3651950-1-christoph.muellner@vrull.eu> References: <20240327103130.3651950-1-christoph.muellner@vrull.eu> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit T-Head's MAEE mechanism (non-compatible equivalent of RVI's Svpbmt) is currently assumed for all T-Head harts. However, QEMU recently decided to drop acceptance of guests that write reserved bits in PTEs. As MAEE uses reserved bits in PTEs and Linux applies the MAEE errata for all T-Head harts, this broke the Linux startup on QEMU emulations of the C906 emulation. This patch attempts to address this issue by testing the MAEE bit in TH_MXSTATUS CSR. As the TH_MXSTATUS CSR is only accessible in M-mode this patch depends on M-mode firmware that handles this for us transparently. As this patch breaks Linux bootup on all C9xx machines with MAEE, which don't have M-mode firmware that handles the access to the TH_MXSTATUS CSR, this patch is marked as RFC. Signed-off-by: Christoph Müllner --- arch/riscv/errata/thead/errata.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/riscv/errata/thead/errata.c b/arch/riscv/errata/thead/errata.c index 8c8a8a4b0421..dd7bf6c62a35 100644 --- a/arch/riscv/errata/thead/errata.c +++ b/arch/riscv/errata/thead/errata.c @@ -19,6 +19,9 @@ #include #include +#define CSR_TH_MXSTATUS 0x7c0 +#define MXSTATUS_MAEE _AC(0x200000, UL) + static bool errata_probe_maee(unsigned int stage, unsigned long arch_id, unsigned long impid) { @@ -28,11 +31,14 @@ static bool errata_probe_maee(unsigned int stage, if (arch_id != 0 || impid != 0) return false; - if (stage == RISCV_ALTERNATIVES_EARLY_BOOT || - stage == RISCV_ALTERNATIVES_MODULE) - return true; + if (stage != RISCV_ALTERNATIVES_EARLY_BOOT && + stage != RISCV_ALTERNATIVES_MODULE) + return false; - return false; + if (!(csr_read(CSR_TH_MXSTATUS) & MXSTATUS_MAEE)) + return false; + + return true; } /* -- 2.44.0