Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1008497lqe; Sun, 7 Apr 2024 14:33:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXYxLL9ZUaq/L5mynBYHJXRYF99ZCjgT2wdK2Pm1d7kuB0ZEZYF1GnnJ08UNdB7ifG2BfL3/SMJ6oe6YgOZNcxeXSvaHyXm3fw7LYCz9A== X-Google-Smtp-Source: AGHT+IH2ytd439cTVamiLWt5KZcPkPwwIZyarBKx8UljlVPXaCS68abD1FKwNGLTa4nYnmbQ+a0r X-Received: by 2002:a19:6a0a:0:b0:516:d0ec:5308 with SMTP id u10-20020a196a0a000000b00516d0ec5308mr5504041lfu.10.1712525594720; Sun, 07 Apr 2024 14:33:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712525594; cv=pass; d=google.com; s=arc-20160816; b=DcMZ5d2NK+7A4oeL5Rmt+6UMoMhtF5tHsTq/zXy+iPFbhoMZEHACnQkVxmx2Me7LZy oqv0OgGRrHqoq7ySksCmv60AzTVEcKevqLKmnG1qgm+ChuKVgnj0yH9QAOdxcMBQU/oS /okZuaLNTmbHq91pfp9OUObF0I8FIRCAebg7H4jqAS0KhHQ8XxXpe81yMAQeTGgpCHHK YDrRKhDj2o0ZJi5GiajNsqvYtO2IP0UpdhPHFzoC/bjIKJjjym+CsRKU1i/IreCcoE68 9rWYLY63X7MFYIEchsw8gptyDNoFUaPXE+lPM/uxkbDq8b114Mmic1NtxDPVUarnAcYW 9IKQ== 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=Cpsym7Sf/nHOWsd3i9dIJWLFXouR7iLMcrTGkY+MhkE=; fh=Op0UXm4wBKHg1Wbc2xg540DokygRGPJmuLt3R9DiNc4=; b=vvW/JhXFqLAmYF+AqurhjwayuKMY4jKUVwx+FxlTmBnqzMxDYt+QoT7hhOJGGRx67K pgg54s+MNzCT7gqIf6Wn4pfUUKZ1pz85UtBZdK9WfUM1vmQcV8gdg7hf3CcLBIOwnQ6n F2cbwxQpxWc/2aZqLecp8zCET/wjYKDJ9B8laaGK+7RCWnAYSl9s2y1elgnxBF7qNxhX K9w2sZYAiW3LgOUTXsEa22Wd99LLmfZWZ+iopiDzRJpiaWyWUvn7PsP6HmrDFCcrBh2H pMxKxHIL6AondPeEeh4j3XsqcEO/7xgY5+qGJqVl/FnjqXkDYPMvhCbLVORxDjEQ4ofT P0kA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=JH6ZEESO; arc=pass (i=1 spf=pass spfdomain=vrull.eu dkim=pass dkdomain=vrull.eu); spf=pass (google.com: domain of linux-kernel+bounces-134649-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134649-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id dl17-20020a170907945100b00a465f2ed58esi3201894ejc.837.2024.04.07.14.33.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 14:33:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134649-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=JH6ZEESO; arc=pass (i=1 spf=pass spfdomain=vrull.eu dkim=pass dkdomain=vrull.eu); spf=pass (google.com: domain of linux-kernel+bounces-134649-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134649-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 47BB91F2146B for ; Sun, 7 Apr 2024 21:33:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08EF747F7D; Sun, 7 Apr 2024 21:32:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vrull.eu header.i=@vrull.eu header.b="JH6ZEESO" Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (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 7506544C85 for ; Sun, 7 Apr 2024 21:32:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712525566; cv=none; b=GTHPSWfdm6sjgGEyQIQ+ELfKLbf4wzSqvh8gyFKzUKIPNCZzWv+KP+bYzppJKTuNsd1mLYZWLhtyhvmBxpfSSrG4m4MXoy+D+JSq8c0jkb9D29ZK3lWVDktC4NzvZgXRYyAJ55dJ8fz6m4/7+L/tznxiX+0U7DIZ/gRWVQbzLo8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712525566; c=relaxed/simple; bh=PrvneksNVywBX9QBVW+e4qsjCsF+Bt3beRefKOIht/I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g+RAj4zuIJy62o8i9xOYu0uKH/SljXWpjj9qfJY3kDtS7N5ut/gTc/DAOYg23GrpxK+QZI1yFAf91MRj/wTHBQMA+7Q8NReMoYqeOr2pLH1VXMmCdITmYFRI1nJOajCKfNeLiDJljqZr09+VE0oqtqBgNGzGdxC8HqVuQDSu/IE= 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=JH6ZEESO; arc=none smtp.client-ip=209.85.208.178 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-lj1-f178.google.com with SMTP id 38308e7fff4ca-2d476d7972aso50176521fa.1 for ; Sun, 07 Apr 2024 14:32:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1712525562; x=1713130362; 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=Cpsym7Sf/nHOWsd3i9dIJWLFXouR7iLMcrTGkY+MhkE=; b=JH6ZEESOBzikNz0D3qPxE0u+uBcqISo07Ku8US6GA5U5chXYFI/RDsgnUhPAn9oHu4 QjQAqO4qRqOs9NdR67jnE+9tKgkfhnG4nleIS1xF42waEq2rWIvgEFN0NxfH+5VGTWlT c9jAJZVLRM35O5pICOADlKrlNvmCB+v3wTaMXWAr3U2eAq7tkO1n5ELtjpRXoN+ZXO2y H/Zn/bfMA9da+RYJ/BO/HIb3QVDNZjfE9lQbQB60N8K8bUx9byxkA2q9fvDU4LoC4Th2 3KHC4880JT2A/sareWtAyNAmU5OwqWcF0stgl3ne9HA2Hqyme43IzHo5MADsYHuMhRN2 JwWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712525562; x=1713130362; 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=Cpsym7Sf/nHOWsd3i9dIJWLFXouR7iLMcrTGkY+MhkE=; b=j5yal9rEqR1DWuBPH2iqd6jgcOCH6sj1ip87Bq0KGIGv6kECOEcBZeuWT2ENy4trPF 2YHoCtJsTrShjFli9oNuC18sTdQLxdZSFb2gal28bbYcMS3SWVfFF+CnW4nTlLjCK7u6 S3uPPRT9e7MmQx5OfhqaauhuMQ4uFWDsZj7WdpggBNBTnu0RlVDYf6OFBftwe+S6eozm kjD4/TVysiyCOO0vdBjGb2VDv0OhYK/ayNlqG6U1BSM0qRd6raS30Zc9rB1N8vzpuFbK Ns3ZY7IJGGsgCosHJEVFGuukPhCsG1WtQXv/agBoKxzEYOkXbsoy3oogQvd66tdxqsXP uqKQ== X-Forwarded-Encrypted: i=1; AJvYcCVmIwDwBunv1iXY1CWkBf2tvJHNbe7E2vkHcrA/hBf1HhYrc0ZrTi1/hlizS+VvXffWLWtmyDw+AnNE9I3JZPV1Ky2hX25ZP1EQMzhL X-Gm-Message-State: AOJu0YzOPpYHGBM2BfX7TB+qhK6pGmujUUH0kuCDs8VzUxdfCn/YVRVP +G58crlh4HpySSJkD5luQDiDM0deE0WY+txzqYeyoNoNDHkRfaLRrRbXceiF+i4= X-Received: by 2002:a2e:bb91:0:b0:2d6:c001:d87 with SMTP id y17-20020a2ebb91000000b002d6c0010d87mr4816723lje.8.1712525562496; Sun, 07 Apr 2024 14:32:42 -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 i2-20020a50fc02000000b0056e22be831dsm3267562edr.42.2024.04.07.14.32.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 14:32:41 -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 , Qingfang Deng , Alexandre Ghiti , Samuel Holland Cc: =?UTF-8?q?Christoph=20M=C3=BCllner?= , Conor Dooley Subject: [PATCH v3 2/2] riscv: T-Head: Test availability bit before enabling MAE errata Date: Sun, 7 Apr 2024 23:32:36 +0200 Message-ID: <20240407213236.2121592-3-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240407213236.2121592-1-christoph.muellner@vrull.eu> References: <20240407213236.2121592-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 memory attribute extension (XTheadMae) (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 XTheadMae uses reserved bits in PTEs and Linux applies the MAE 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 MAE-enable bit in the th.sxstatus CSR. This CSR is available in HW and can be emulated in QEMU. This patch also makes the XTheadMae probing mechanism reliable, because a test for the right combination of mvendorid, marchid, and mimpid is not sufficient to enable MAE. Reviewed-by: Conor Dooley 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 6e7ee1f16bee..bf6a0a6318ee 100644 --- a/arch/riscv/errata/thead/errata.c +++ b/arch/riscv/errata/thead/errata.c @@ -19,6 +19,9 @@ #include #include +#define CSR_TH_SXSTATUS 0x5c0 +#define SXSTATUS_MAEE _AC(0x200000, UL) + static bool errata_probe_mae(unsigned int stage, unsigned long arch_id, unsigned long impid) { @@ -28,11 +31,14 @@ static bool errata_probe_mae(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_SXSTATUS) & SXSTATUS_MAEE)) + return false; + + return true; } /* -- 2.44.0