From patchwork Tue Oct 1 16:06:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Deepak Gupta X-Patchwork-Id: 13818593 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C5B41CEACF1 for ; Tue, 1 Oct 2024 17:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/XsC2hdzpCi0zyhtEA5stFXmWpF/SIAnN1IrYe8NOMw=; b=FcXwwNpxfQED/c C5LVBdRsibdR/mtOqQ3FKvQHcy0KEWe9WCzu+EvjE2l34lxrHqmS2A6WGac8xXHVHVuXfX3pra7T7 Xvdd9MWifLm09/QZhsKUwuUs8io7JzcWOiM4dpBrJ/UQLqJsLmIWOQrbXFdnnfKBV54FcqtnQ0u6h LfQ14qMH/2/eVlr1Fz7hrpr2riZKegzwPuTCF90prTe3xzXQvPdE/2vq1TSf4MmF14o3ZHrEdOCsJ 7NvLRNxUGp1Rzutm9HIxRdciV3c8ZwdBlftDSdarJqoXMbOegH4W6hSfb4R1tFfbG3FNI5BDSdxYy bo6mNe+ZLZnT1zHveoiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1svgim-00000003fBr-1mSH; Tue, 01 Oct 2024 17:31:36 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1svfQ4-00000003RY3-3CSZ for linux-riscv@lists.infradead.org; Tue, 01 Oct 2024 16:08:14 +0000 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-2e07d85e956so4868780a91.3 for ; Tue, 01 Oct 2024 09:08:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1727798892; x=1728403692; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=hq3DaQ4YpzTwJN9yZW6Sl3gPyL1m035+b/05XFtk9T8=; b=QSNLksMULnSI6FWXU4VHywZriflVrh+QR1cwUKn/kAFl/vNs5W2XuySblF1AdOBZUZ 16bAQvWPCJ6wmpFkdWdkEwfAiYJ/DtX/lqEtOo4fBLqAUwvFRjQjUhoFZJAjWG2Vl73n F0qv5o/Spw7jfcCbb8CNT5eC7fz5opH061/LgzVTAvFkiGfsI1kdk6HHZX1D8c52M3Sg nSVCyiHsX72zCJKA1kZWbb3oUqkDFS8GNmSjdi1/xEDQMo0TW+AKE79ToekLAVX4ISHk BOKUtKrNVre6Egw4mQ1NxmRxTSWPGEjrfbOCNi9CkK5b4GARXPIBXDQWsVBxQRURJeHB 3JYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727798892; x=1728403692; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hq3DaQ4YpzTwJN9yZW6Sl3gPyL1m035+b/05XFtk9T8=; b=bsmFBq9Lb+/VmKAPtW6GbfbUPnFP552T2St5FQV7kHuyd/7Z1YgsNwfoUwEDUS4Oig GcxMCHua7xdQy17TWJsQDIzi9SN8AFPkVXCixRwpiYm99q3MQd4/uhKeIuAN4pdtGAA+ aGeVlEYtybAmKg8mFtkjPaLyvZ9LqdkfLgnW1744MmZUfPd8cFTjcgUFC3USKtaeezHK I+oFhGgN1vj5BIFN3iaz5S9Hn/S0b2gFW/NExg3/jK04jLB8wDjXodimsYKRGRkWtYqE N4ZtGYr2/Gj2RFOqPZPuiTTYNwGY/rbeUYYtaDJXbaVN7cxvfbiHpCCx8oEzX2mDSTRy 5P3A== X-Forwarded-Encrypted: i=1; AJvYcCWr2I+77dWo2ifewnIYvZYzVOj+FuYUWBhfunG3ggpCx1xk4GasW659so+Zo9jfiVgUd8cx1vQ5Ha1fAQ==@lists.infradead.org X-Gm-Message-State: AOJu0YwusU9bbgU0QgxI17gpCTSOGlq3cxN4fOj2UWqlHebsf62bVb9a UYZwiDyqZDFtmgdZARVq+apSqmWymwAgk0mLuGBm41muIV0ceRww6pkwhbPiX9A= X-Google-Smtp-Source: AGHT+IE1mC9nGVWp9Ep/VDB2JSrhkpX0Jq7sG4mPQqlp/n+0JH5ZZvXoSkfUlTtqgO8CiZuzgQPUOQ== X-Received: by 2002:a17:90b:264e:b0:2d8:82da:2627 with SMTP id 98e67ed59e1d1-2e1848f671bmr199013a91.27.1727798892044; Tue, 01 Oct 2024 09:08:12 -0700 (PDT) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e06e1d7d47sm13843973a91.28.2024.10.01.09.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 09:08:11 -0700 (PDT) From: Deepak Gupta Date: Tue, 01 Oct 2024 09:06:32 -0700 Subject: [PATCH 27/33] riscv: Add Firmware Feature SBI extensions definitions MIME-Version: 1.0 Message-Id: <20241001-v5_user_cfi_series-v1-27-3ba65b6e550f@rivosinc.com> References: <20241001-v5_user_cfi_series-v1-0-3ba65b6e550f@rivosinc.com> In-Reply-To: <20241001-v5_user_cfi_series-v1-0-3ba65b6e550f@rivosinc.com> To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Lorenzo Stoakes , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Rob Herring , Krzysztof Kozlowski , Arnd Bergmann , Christian Brauner , Peter Zijlstra , Oleg Nesterov , Eric Biederman , Kees Cook , Jonathan Corbet , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, alistair.francis@wdc.com, richard.henderson@linaro.org, jim.shu@sifive.com, andybnac@gmail.com, kito.cheng@sifive.com, charlie@rivosinc.com, atishp@rivosinc.com, evan@rivosinc.com, cleger@rivosinc.com, alexghiti@rivosinc.com, samitolvanen@google.com, broonie@kernel.org, rick.p.edgecombe@intel.com, Deepak Gupta X-Mailer: b4 0.14.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241001_090812_857229_F28FABBC X-CRM114-Status: GOOD ( 11.41 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Clément Léger Add necessary SBI definitions to use the FWFT extension. Signed-off-by: Clément Léger --- arch/riscv/include/asm/sbi.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h index 98f631b051db..754e5cdabf46 100644 --- a/arch/riscv/include/asm/sbi.h +++ b/arch/riscv/include/asm/sbi.h @@ -34,6 +34,7 @@ enum sbi_ext_id { SBI_EXT_PMU = 0x504D55, SBI_EXT_DBCN = 0x4442434E, SBI_EXT_STA = 0x535441, + SBI_EXT_FWFT = 0x46574654, /* Experimentals extensions must lie within this range */ SBI_EXT_EXPERIMENTAL_START = 0x08000000, @@ -281,6 +282,32 @@ struct sbi_sta_struct { #define SBI_SHMEM_DISABLE -1 +/* SBI function IDs for FW feature extension */ +#define SBI_EXT_FWFT_SET 0x0 +#define SBI_EXT_FWFT_GET 0x1 + +enum sbi_fwft_feature_t { + SBI_FWFT_MISALIGNED_EXC_DELEG = 0x0, + SBI_FWFT_LANDING_PAD = 0x1, + SBI_FWFT_SHADOW_STACK = 0x2, + SBI_FWFT_DOUBLE_TRAP = 0x3, + SBI_FWFT_PTE_AD_HW_UPDATING = 0x4, + SBI_FWFT_LOCAL_RESERVED_START = 0x5, + SBI_FWFT_LOCAL_RESERVED_END = 0x3fffffff, + SBI_FWFT_LOCAL_PLATFORM_START = 0x40000000, + SBI_FWFT_LOCAL_PLATFORM_END = 0x7fffffff, + + SBI_FWFT_GLOBAL_RESERVED_START = 0x80000000, + SBI_FWFT_GLOBAL_RESERVED_END = 0xbfffffff, + SBI_FWFT_GLOBAL_PLATFORM_START = 0xc0000000, + SBI_FWFT_GLOBAL_PLATFORM_END = 0xffffffff, +}; + +#define SBI_FWFT_GLOBAL_FEATURE_BIT (1 << 31) +#define SBI_FWFT_PLATFORM_FEATURE_BIT (1 << 30) + +#define SBI_FWFT_SET_FLAG_LOCK (1 << 0) + /* SBI spec version fields */ #define SBI_SPEC_VERSION_DEFAULT 0x1 #define SBI_SPEC_VERSION_MAJOR_SHIFT 24