Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6159901rwl; Tue, 4 Apr 2023 08:36:47 -0700 (PDT) X-Google-Smtp-Source: AKy350Z92UVYiPgv0OkiHWqDVDRNLmEE67+Q8LUOzflp5/Ms996Z59bznM+hfK98XsxxRSBVUEVF X-Received: by 2002:a17:903:234a:b0:19d:f7e:9864 with SMTP id c10-20020a170903234a00b0019d0f7e9864mr4144181plh.57.1680622606722; Tue, 04 Apr 2023 08:36:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680622606; cv=none; d=google.com; s=arc-20160816; b=KDR+zY3UnTDqFtPpaaR+6EP6Y9FbQY7PfZ8h77frP2YGn6WylLoVSgqCex3LE9CPvN 9MbXfxN1impH71otk89BCHC8xCKZxfmE8nvQB+h5Up3lQ7AVG4koielg7cRMHu8WXEu/ HXKyZptB6Cq572uNl3YUNWC9lOlbDXlzURTfv7LhKJsgy4X5D1kYYLy5A1rEbLTOD6WA gmM/cRKMv5d7tJZxd86/rPwLdzgPBnRzOUZnq3mfbKj3dBJTcu/LnK6KuCFN/r7jPjmD Bn7N46XwpLFLiPicJuk7NU3FLfeUCabReDTBVQISze8t025dOlzwM30OhifQTFFcA2+T B1ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=E6PZQdmlp+AewPgEtW0ao3qnJU+39FICYhAuMPUXgt4=; b=04Une0HOFI0gzuk+kkS4uvOD2ETEmcsi5P6C6EMpI+NQkjVvoiGyc2u63RTaBUwUwh 54FfHItXUrt3+vEQjO7xmMjr2StdGc6ZMp5DK9xcLYk1eB35tjYPKgrY7b2zf7eftaYb CyF5oaXjgxb+ojWBBI1ae1q1wc1kK0c4s83R4yDP4QuX6OaaEkscJnI1tNyyD1ZH3XOU DVdZ1dT1ZRLsgk/a+MUzLXgQHxSuRv6TyMSTjaE59yUupScUWEIV26GOGDbOpKzbhDnY QUMp3hNSCiLRq3XTulhRjqJdrsC9O/t1zaD+u9zMcIbuBncV/5YMxayZ8AG/8qK4J9xH uUtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=hF65p47N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k184-20020a6384c1000000b004fb33a76e2csi10713925pgd.834.2023.04.04.08.36.33; Tue, 04 Apr 2023 08:36:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=hF65p47N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235644AbjDDPfY (ORCPT + 99 others); Tue, 4 Apr 2023 11:35:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235625AbjDDPfS (ORCPT ); Tue, 4 Apr 2023 11:35:18 -0400 Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 436F04C17 for ; Tue, 4 Apr 2023 08:35:17 -0700 (PDT) Received: by mail-oi1-x22c.google.com with SMTP id l18so24477602oic.13 for ; Tue, 04 Apr 2023 08:35:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1680622516; x=1683214516; 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=E6PZQdmlp+AewPgEtW0ao3qnJU+39FICYhAuMPUXgt4=; b=hF65p47NPrT1CyH5ot5Dshcf0XlqljIPyA8iF2xy+M51/gGgowlUDKMvmiq9O+bdu6 NzNScv87kEtMtK4tzpbIY0gvdl3j6lp0nba7YnmyN7RHiFBnolYWQU6ryEaqX/ih/Gt+ UgO4lZjqXe/NiG+x4ZEvjKHFPj3tf5olnZL0D80Z0wATlhk3STH8l6zPLLppYqQUyM4A rdWChR3X9xz+o7423vNDClF3N1zmpADV0pS6OrmOQqxffLYXM7tTsOInDrY1xMIB2HAf 5fre0AvPLy1It/TGPe/EFKoWsLEnmk4FJq4IdKEzbzQtEJnymQGlgBQqxVqwtjLETF61 d0VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680622516; x=1683214516; 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=E6PZQdmlp+AewPgEtW0ao3qnJU+39FICYhAuMPUXgt4=; b=tODsqby1zEAkqLhHozsvrJ8JlFSmhYexMuws7kncJROLmisDZW+2gQqEoNs3sqWRbS 6b+n5kvOlZ5SBp0vuc3pfvd3EbQ/VDgfpizyyN2ImYMUDcyRxV7JXLeBGPWN6ye59K1/ /fk2XNw4hPLDV5KnLSsnQoDpDkTosoFVIgDRCfcyTYeVDwWr2Wyav+aG3ugdGTQPnE0s punK7uB/EyDVvNDyi42cqtPlDIxD9XwoHNfaJ+MocOfeWsnTN7m2bHBXaZvbKNF6gxkm bhFEXf7o08ojt9bxv7baiLUxnofVh6VX5dtkaoV8toxxqHjWa6COpQA07IiLMFHw1usj 6Kag== X-Gm-Message-State: AAQBX9e4cWbS9t30eOQDFKlyPqFRju4IWIgZVioEmPXDCbWeiAKO0VEr nbRxemianOgLko457J8t8kD+Xw== X-Received: by 2002:a05:6808:278d:b0:383:eff6:d3c3 with SMTP id es13-20020a056808278d00b00383eff6d3c3mr1335168oib.3.1680622516486; Tue, 04 Apr 2023 08:35:16 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id w124-20020acadf82000000b00387384dc768sm5325803oig.9.2023.04.04.08.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 08:35:15 -0700 (PDT) From: Anup Patel To: Paolo Bonzini , Atish Patra Cc: Palmer Dabbelt , Paul Walmsley , Andrew Jones , Anup Patel , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel , Conor Dooley , Atish Patra , Palmer Dabbelt Subject: [PATCH v4 1/9] RISC-V: Add AIA related CSR defines Date: Tue, 4 Apr 2023 21:04:44 +0530 Message-Id: <20230404153452.2405681-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230404153452.2405681-1-apatel@ventanamicro.com> References: <20230404153452.2405681-1-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The RISC-V AIA specification improves handling per-HART local interrupts in a backward compatible manner. This patch adds defines for new RISC-V AIA CSRs. Signed-off-by: Anup Patel Reviewed-by: Conor Dooley Reviewed-by: Andrew Jones Reviewed-by: Atish Patra Acked-by: Palmer Dabbelt --- arch/riscv/include/asm/csr.h | 95 +++++++++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h index 0e571f6483d9..3c8d68152bce 100644 --- a/arch/riscv/include/asm/csr.h +++ b/arch/riscv/include/asm/csr.h @@ -7,7 +7,7 @@ #define _ASM_RISCV_CSR_H #include -#include +#include /* Status register flags */ #define SR_SIE _AC(0x00000002, UL) /* Supervisor Interrupt Enable */ @@ -73,7 +73,10 @@ #define IRQ_S_EXT 9 #define IRQ_VS_EXT 10 #define IRQ_M_EXT 11 +#define IRQ_S_GEXT 12 #define IRQ_PMU_OVF 13 +#define IRQ_LOCAL_MAX (IRQ_PMU_OVF + 1) +#define IRQ_LOCAL_MASK GENMASK((IRQ_LOCAL_MAX - 1), 0) /* Exception causes */ #define EXC_INST_MISALIGNED 0 @@ -156,6 +159,27 @@ (_AC(1, UL) << IRQ_S_TIMER) | \ (_AC(1, UL) << IRQ_S_EXT)) +/* AIA CSR bits */ +#define TOPI_IID_SHIFT 16 +#define TOPI_IID_MASK GENMASK(11, 0) +#define TOPI_IPRIO_MASK GENMASK(7, 0) +#define TOPI_IPRIO_BITS 8 + +#define TOPEI_ID_SHIFT 16 +#define TOPEI_ID_MASK GENMASK(10, 0) +#define TOPEI_PRIO_MASK GENMASK(10, 0) + +#define ISELECT_IPRIO0 0x30 +#define ISELECT_IPRIO15 0x3f +#define ISELECT_MASK GENMASK(8, 0) + +#define HVICTL_VTI BIT(30) +#define HVICTL_IID GENMASK(27, 16) +#define HVICTL_IID_SHIFT 16 +#define HVICTL_DPR BIT(9) +#define HVICTL_IPRIOM BIT(8) +#define HVICTL_IPRIO GENMASK(7, 0) + /* xENVCFG flags */ #define ENVCFG_STCE (_AC(1, ULL) << 63) #define ENVCFG_PBMTE (_AC(1, ULL) << 62) @@ -250,6 +274,18 @@ #define CSR_STIMECMP 0x14D #define CSR_STIMECMPH 0x15D +/* Supervisor-Level Window to Indirectly Accessed Registers (AIA) */ +#define CSR_SISELECT 0x150 +#define CSR_SIREG 0x151 + +/* Supervisor-Level Interrupts (AIA) */ +#define CSR_STOPEI 0x15c +#define CSR_STOPI 0xdb0 + +/* Supervisor-Level High-Half CSRs (AIA) */ +#define CSR_SIEH 0x114 +#define CSR_SIPH 0x154 + #define CSR_VSSTATUS 0x200 #define CSR_VSIE 0x204 #define CSR_VSTVEC 0x205 @@ -279,8 +315,32 @@ #define CSR_HGATP 0x680 #define CSR_HGEIP 0xe12 +/* Virtual Interrupts and Interrupt Priorities (H-extension with AIA) */ +#define CSR_HVIEN 0x608 +#define CSR_HVICTL 0x609 +#define CSR_HVIPRIO1 0x646 +#define CSR_HVIPRIO2 0x647 + +/* VS-Level Window to Indirectly Accessed Registers (H-extension with AIA) */ +#define CSR_VSISELECT 0x250 +#define CSR_VSIREG 0x251 + +/* VS-Level Interrupts (H-extension with AIA) */ +#define CSR_VSTOPEI 0x25c +#define CSR_VSTOPI 0xeb0 + +/* Hypervisor and VS-Level High-Half CSRs (H-extension with AIA) */ +#define CSR_HIDELEGH 0x613 +#define CSR_HVIENH 0x618 +#define CSR_HVIPH 0x655 +#define CSR_HVIPRIO1H 0x656 +#define CSR_HVIPRIO2H 0x657 +#define CSR_VSIEH 0x214 +#define CSR_VSIPH 0x254 + #define CSR_MSTATUS 0x300 #define CSR_MISA 0x301 +#define CSR_MIDELEG 0x303 #define CSR_MIE 0x304 #define CSR_MTVEC 0x305 #define CSR_MENVCFG 0x30a @@ -297,6 +357,25 @@ #define CSR_MIMPID 0xf13 #define CSR_MHARTID 0xf14 +/* Machine-Level Window to Indirectly Accessed Registers (AIA) */ +#define CSR_MISELECT 0x350 +#define CSR_MIREG 0x351 + +/* Machine-Level Interrupts (AIA) */ +#define CSR_MTOPEI 0x35c +#define CSR_MTOPI 0xfb0 + +/* Virtual Interrupts for Supervisor Level (AIA) */ +#define CSR_MVIEN 0x308 +#define CSR_MVIP 0x309 + +/* Machine-Level High-Half CSRs (AIA) */ +#define CSR_MIDELEGH 0x313 +#define CSR_MIEH 0x314 +#define CSR_MVIENH 0x318 +#define CSR_MVIPH 0x319 +#define CSR_MIPH 0x354 + #ifdef CONFIG_RISCV_M_MODE # define CSR_STATUS CSR_MSTATUS # define CSR_IE CSR_MIE @@ -307,6 +386,13 @@ # define CSR_TVAL CSR_MTVAL # define CSR_IP CSR_MIP +# define CSR_IEH CSR_MIEH +# define CSR_ISELECT CSR_MISELECT +# define CSR_IREG CSR_MIREG +# define CSR_IPH CSR_MIPH +# define CSR_TOPEI CSR_MTOPEI +# define CSR_TOPI CSR_MTOPI + # define SR_IE SR_MIE # define SR_PIE SR_MPIE # define SR_PP SR_MPP @@ -324,6 +410,13 @@ # define CSR_TVAL CSR_STVAL # define CSR_IP CSR_SIP +# define CSR_IEH CSR_SIEH +# define CSR_ISELECT CSR_SISELECT +# define CSR_IREG CSR_SIREG +# define CSR_IPH CSR_SIPH +# define CSR_TOPEI CSR_STOPEI +# define CSR_TOPI CSR_STOPI + # define SR_IE SR_SIE # define SR_PIE SR_SPIE # define SR_PP SR_SPP -- 2.34.1