From nobody Fri May 17 14:40:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+113382+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+113382+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1704713823; cv=none; d=zohomail.com; s=zohoarc; b=EULb6Mvldt5byafU7nHMgNrJVKQrxWgaLnuP44xoUupv+rE4dRNnvfP1PLHU8+pwXoV8j0155G4ODEBR3+Pssc44SSnsfNIglFXBF5uETpxPbDD+gAPDxuFmv0TdhqbhbkYkUlpVK9rs0pGLLK0c/0eLwWKfOKTqMBtz4MQTYk8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704713823; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=1FFzdY19JyBxRUGSAb5P1wyJSTwmHdTzkEUSPcEpVPE=; b=dMa7gWy1V/ZBYsbNG/VPw+wwCRLKqufqih8MCgMpPNlO4wVq3NK5r5Lj+fVCg1eVNIHra2+zy7FL1H9Kza6aiy3HI4eOPVlbUM4FkkQEV6PAHRGBKu9WypRe6jsbCy7rhOhsfhVnsMKVrLVZtNMkmjgeH+a4oeKlL4LbligyoYU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+113382+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1704713823718139.2819814801453; Mon, 8 Jan 2024 03:37:03 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=YgxeHwdFd/duE21KOH/jkM98j7jkeXwOzecmOrpThPQ=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1704713823; v=1; b=vwO0hdRZdqVpR+fVbcI29fNcqa9mlLy2lD4gdwRxcIMHBb8cd9b4AFgrXNgC7QbRdxLPa8qo 9bdAcBl3IDWcf8HyNOS8zkp380kpVjrst3SHn9E/M1EfZHZjsr7oRzBH7VljOLGOwVBYJ619iAG zE3SMSHhe8hbrQBsdy8/j6+g= X-Received: by 127.0.0.2 with SMTP id lkRGYY1788612xQ9ScqyiP7L; Mon, 08 Jan 2024 03:37:03 -0800 X-Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by mx.groups.io with SMTP id smtpd.web11.4717.1704713822834207695 for ; Mon, 08 Jan 2024 03:37:02 -0800 X-Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-6dad22e13dcso681864b3a.3 for ; Mon, 08 Jan 2024 03:37:02 -0800 (PST) X-Gm-Message-State: pNx1Upcv7LMkUqHvFPcqrKC9x1787277AA= X-Google-Smtp-Source: AGHT+IGtK/MA6oV+J7LeBTTYPnB4U2kr/A1ToyPvE7qGH7M4DQIwcAyISfv6ZmWcBSoqa3RLUc5j8A== X-Received: by 2002:a05:6a00:3a24:b0:6d9:d71c:d1a3 with SMTP id fj36-20020a056a003a2400b006d9d71cd1a3mr1084253pfb.66.1704713821372; Mon, 08 Jan 2024 03:37:01 -0800 (PST) X-Received: from localhost.localdomain ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id i12-20020aa787cc000000b006d9af59eecesm5846618pfo.20.2024.01.08.03.36.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 03:37:00 -0800 (PST) From: "Sunil V L" To: devel@edk2.groups.io Cc: Sunil V L , Liming Gao , Michael D Kinney , Zhiguang Liu , Andrei Warkentin Subject: [edk2-devel] [PATCH v2 1/4] MdePkg.dec: RISC-V: Define override bit for Sstc extension Date: Mon, 8 Jan 2024 17:06:47 +0530 Message-Id: <20240108113650.454940-2-sunilvl@ventanamicro.com> In-Reply-To: <20240108113650.454940-1-sunilvl@ventanamicro.com> References: <20240108113650.454940-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sunilvl@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1704713825173100001 Content-Type: text/plain; charset="utf-8" Define the BIT 1 as the override bit for Sstc extension. This will be used by the timer driver to decide whether to use SBI calls or direct CSR access to configure the timer. Cc: Liming Gao Cc: Michael D Kinney Cc: Zhiguang Liu Cc: Andrei Warkentin Signed-off-by: Sunil V L Reviewed-by: Andrei Warkentin --- MdePkg/MdePkg.dec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 2ee112cc087a..0459418906f8 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -2405,6 +2405,8 @@ [PcdsFixedAtBuild.RISCV64, PcdsPatchableInModule.RISC= V64] # Configurability to override RISC-V CPU Features # BIT 0 =3D Cache Management Operations. This bit is relevant only if # previous stage has feature enabled and user wants to disable it. + # BIT 1 =3D Supervisor Time Compare (Sstc). This bit is relevant only if + # previous stage has feature enabled and user wants to disable it. # gEfiMdePkgTokenSpaceGuid.PcdRiscVFeatureOverride|0xFFFFFFFFFFFFFFFF|UINT= 64|0x69 =20 --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113382): https://edk2.groups.io/g/devel/message/113382 Mute This Topic: https://groups.io/mt/103595208/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 17 14:40:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+113383+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+113383+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1704713826; cv=none; d=zohomail.com; s=zohoarc; b=e9/OvLU4bW2wl7BH2qhTpElUZv+Tvomv3bOvw1ThxT6uww/D/ajfNqu5SygIAbXccEhqPkUYg6OLvch6iNx6d0pMcqlrbtOHQgZAsWA65GAieRIbLPkKExnGuQjiBl64GJ1bIoDsACMIjgBfiyZcQkWEzE6WMf4NjkDVoR7bdhM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704713826; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=JNYyn2v2Y6DKhQtDJNvH6+NwNeQ8wH8Ms8q9OdFebiA=; b=kEcFwgmRBD2t4/EFRnqWYNCi6YsJWUKkA6rwPI/7WWKeoYeFYTm7mPOyrpEyA+NR1YFS4932dPeDOJHamEplLQX5rCyIm8L7bnTAPkPiuu0CbFnaODeptTKwNE/1PIlMA98iR7tfWYLL+8+bF4e7RsS5K7Z4WNgf4tV6x3QI910= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+113383+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1704713826685559.5945919715349; Mon, 8 Jan 2024 03:37:06 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=E6S9upRmHFilS6IBuHl+U4Ezb8qPQYI6QlLZIC+LPss=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1704713826; v=1; b=aaf58YZx0JrvxneOJOTNj6V5toGnqpK71QIsoo1fYXWB7YAHodJ1AJmfZoN+Ousa+9ozMflj cLGSJ0MOnC7empFrEVfqjCOnYNtFF6JiTySfm+NPA6PF+i9v9ik1mUm9IIwiRIsnErIc225Iy0r YNt/zu5LtNu1FyfFwXyAqZDQ= X-Received: by 127.0.0.2 with SMTP id 9koHYY1788612xCr54JU7A94; Mon, 08 Jan 2024 03:37:06 -0800 X-Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by mx.groups.io with SMTP id smtpd.web11.4720.1704713825872707279 for ; Mon, 08 Jan 2024 03:37:05 -0800 X-Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6d9e62ff056so1492074b3a.1 for ; Mon, 08 Jan 2024 03:37:05 -0800 (PST) X-Gm-Message-State: 8GR9DV5Zdb6fdvDb5Sd4O38px1787277AA= X-Google-Smtp-Source: AGHT+IGpD8tG0VLllVBG+XCdrdzKuFKXtOUvK8mkYEhPIkTuf+EU56Pr8+dyRZwJPfl9GszHoGYSww== X-Received: by 2002:a05:6a00:4b43:b0:6d9:9ee8:9a2b with SMTP id kr3-20020a056a004b4300b006d99ee89a2bmr3925365pfb.13.1704713824458; Mon, 08 Jan 2024 03:37:04 -0800 (PST) X-Received: from localhost.localdomain ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id i12-20020aa787cc000000b006d9af59eecesm5846618pfo.20.2024.01.08.03.37.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 03:37:04 -0800 (PST) From: "Sunil V L" To: devel@edk2.groups.io Cc: Sunil V L , Michael D Kinney , Liming Gao , Zhiguang Liu , Andrei Warkentin Subject: [edk2-devel] [PATCH v2 2/4] MdePkg/BaseLib: RISC-V: Add function to update stimecmp register Date: Mon, 8 Jan 2024 17:06:48 +0530 Message-Id: <20240108113650.454940-3-sunilvl@ventanamicro.com> In-Reply-To: <20240108113650.454940-1-sunilvl@ventanamicro.com> References: <20240108113650.454940-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sunilvl@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1704713827161100005 Content-Type: text/plain; charset="utf-8" stimecmp is a CSR supported only when Sstc extension is supported by the platform. This register can be used to set the timer interrupt directly in S-mode instead of going via SBI call. Add a function to update this register. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Andrei Warkentin Signed-off-by: Sunil V L Reviewed-by: Andrei Warkentin --- MdePkg/Include/Library/BaseLib.h | 5 +++++ MdePkg/Include/Register/RiscV64/RiscVEncoding.h | 3 +++ MdePkg/Library/BaseLib/RiscV64/ReadTimer.S | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/Base= Lib.h index b71e47f41b7f..ca0d06c7f335 100644 --- a/MdePkg/Include/Library/BaseLib.h +++ b/MdePkg/Include/Library/BaseLib.h @@ -191,6 +191,11 @@ RiscVReadTimer ( VOID ); =20 +VOID +RiscVSetSupervisorTimeCompareRegister ( + IN UINT64 + ); + VOID RiscVEnableTimerInterrupt ( VOID diff --git a/MdePkg/Include/Register/RiscV64/RiscVEncoding.h b/MdePkg/Inclu= de/Register/RiscV64/RiscVEncoding.h index 2bde8db478ff..8ccdea2f4fcd 100644 --- a/MdePkg/Include/Register/RiscV64/RiscVEncoding.h +++ b/MdePkg/Include/Register/RiscV64/RiscVEncoding.h @@ -96,6 +96,9 @@ /* Supervisor Protection and Translation */ #define CSR_SATP 0x180 =20 +/* Sstc extension */ +#define CSR_STIMECMP 0x14D + /* Trap/Exception Causes */ #define CAUSE_MISALIGNED_FETCH 0x0 #define CAUSE_FETCH_ACCESS 0x1 diff --git a/MdePkg/Library/BaseLib/RiscV64/ReadTimer.S b/MdePkg/Library/Ba= seLib/RiscV64/ReadTimer.S index 39a06efa51ef..36781c29c0b9 100644 --- a/MdePkg/Library/BaseLib/RiscV64/ReadTimer.S +++ b/MdePkg/Library/BaseLib/RiscV64/ReadTimer.S @@ -21,3 +21,10 @@ ASM_FUNC (RiscVReadTimer) csrr a0, CSR_TIME ret + +// +// Set Supervisor Time Compare Register +// +ASM_FUNC (RiscVSetSupervisorTimeCompareRegister) + csrw CSR_STIMECMP, a0 + ret --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113383): https://edk2.groups.io/g/devel/message/113383 Mute This Topic: https://groups.io/mt/103595209/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 17 14:40:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+113384+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+113384+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1704713830; cv=none; d=zohomail.com; s=zohoarc; b=ESKE2OtcyrpiUQnXflnUHyG+TRxZtJPOjg6sx/g7kyXUMXoCjXYGIy8fzw41MAPrNVmnzPZjgNFiI73isIQ5uWD+bLeiPkyDDIQh3P4L3+MXcRTa+qQUWsNFLiwl0WDdjEv3qhSgGPeTwI3rcjnRrZSZF5TNtZ5Ca1MwWhNCc4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704713830; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=3OOHJnQjG9p5Ht0uIoUv3dJUjG/j3QIQhxcTmdiqGE4=; b=jyDUJbChvgMYC+h54QBFJ9/VSN4OPyjRLtqV+vhdM495pLWul5CRwptL2y2NWRk06JOrF8orfQmcaJtDqLPtI5YfYfnnRilhOh/tGM3h0aZMSi5EAeoZq0gVQw05ajmSR3EDCNDuPuTyigE+1UCfaX682QPpXJaflJOqsD8JjE8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+113384+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1704713830031323.76519840132414; Mon, 8 Jan 2024 03:37:10 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=Dyw/i2aLcWT6U+cDAPlyVht68kGHNtw8ew5kjXV/Upo=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1704713829; v=1; b=PV5BkRM21+VcZUZ0vL/yABLgwzK1v1EJpKjzlayBV82wZXz0tqcu1S6GHaGXealmgmf7pmo2 k5TGE+W3JTyleRSNzbdtvAkgK4XvMhzB72E1H+NvhEo6F9f7sKod3cUDh/MAbv/opZjSIVK9WB9 jZgO/REfBIME/qbojA1TdB0c= X-Received: by 127.0.0.2 with SMTP id XVRAYY1788612xlQpgXFGwiO; Mon, 08 Jan 2024 03:37:09 -0800 X-Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by mx.groups.io with SMTP id smtpd.web11.4721.1704713829189811893 for ; Mon, 08 Jan 2024 03:37:09 -0800 X-Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6d9a79a1ad4so388393b3a.2 for ; Mon, 08 Jan 2024 03:37:09 -0800 (PST) X-Gm-Message-State: MCYmaOTBqA93ROqy4tYgfUrDx1787277AA= X-Google-Smtp-Source: AGHT+IFk+Q5znJ+dj6ar9vO3AVdFCDPBia1MKXSOgWQnFc6o1DO6g7Q26j/QGa+NfWM4dDJCduqEVg== X-Received: by 2002:a05:6a00:2e25:b0:6da:c21e:40c0 with SMTP id fc37-20020a056a002e2500b006dac21e40c0mr1054599pfb.18.1704713827874; Mon, 08 Jan 2024 03:37:07 -0800 (PST) X-Received: from localhost.localdomain ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id i12-20020aa787cc000000b006d9af59eecesm5846618pfo.20.2024.01.08.03.37.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 03:37:07 -0800 (PST) From: "Sunil V L" To: devel@edk2.groups.io Cc: Sunil V L , Gerd Hoffmann , Rahul Kumar , Laszlo Ersek , Ray Ni , Andrei Warkentin Subject: [edk2-devel] [PATCH v2 3/4] UefiCpuPkg/CpuTimerDxeRiscV64: Add support for Sstc Date: Mon, 8 Jan 2024 17:06:49 +0530 Message-Id: <20240108113650.454940-4-sunilvl@ventanamicro.com> In-Reply-To: <20240108113650.454940-1-sunilvl@ventanamicro.com> References: <20240108113650.454940-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sunilvl@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1704713831310100001 Content-Type: text/plain; charset="utf-8" Sstc extension allows to program the timer and receive the interrupt without using an SBI call. This reduces the latency to generate the timer interrupt. So, detect whether Sstc extension is supported and use the stimecmp register directly to program the timer interrupt. Cc: Gerd Hoffmann Cc: Rahul Kumar Cc: Laszlo Ersek Cc: Ray Ni Cc: Andrei Warkentin Signed-off-by: Sunil V L Reviewed-by: Andrei Warkentin Reviewed-by: Dhaval Sharma Reviewed-by: Laszlo Ersek --- .../CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf | 1 + UefiCpuPkg/CpuTimerDxeRiscV64/Timer.h | 2 + UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c | 49 +++++++++++++++++-- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf b/UefiCpu= Pkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf index aba660186dc0..f2a2cf12caef 100644 --- a/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf +++ b/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf @@ -41,6 +41,7 @@ [Sources.RISCV64] Timer.c =20 [Pcd] + gEfiMdePkgTokenSpaceGuid.PcdRiscVFeatureOverride ## CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuCoreCrystalClockFrequency ## CONSUMES =20 [Protocols] diff --git a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.h b/UefiCpuPkg/CpuTimerDxe= RiscV64/Timer.h index 9b3542230cb5..067bbd29f377 100644 --- a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.h +++ b/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.h @@ -26,6 +26,8 @@ // #define DEFAULT_TIMER_TICK_DURATION 100000 =20 +#define RISCV_CPU_FEATURE_SSTC_BITMASK BIT1 + extern VOID RiscvSetTimerPeriod ( UINT32 TimerPeriod diff --git a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c b/UefiCpuPkg/CpuTimerDxe= RiscV64/Timer.c index 30e48061cd06..216f48a52931 100644 --- a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c +++ b/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c @@ -44,6 +44,45 @@ STATIC EFI_TIMER_NOTIFY mTimerNotifyFunction; STATIC UINT64 mTimerPeriod =3D 0; STATIC UINT64 mLastPeriodStart =3D 0; =20 +// +// Sstc support +// +STATIC BOOLEAN mSstcEnabled =3D FALSE; + +/** + Program the timer. + + Program either using stimecmp (when Sstc extension is enabled) or using = SBI + TIME call. + + @param NextValue Core tick value the timer should expire. +**/ +STATIC +VOID +RiscVProgramTimer ( + UINT64 NextValue + ) +{ + if (mSstcEnabled) { + RiscVSetSupervisorTimeCompareRegister (NextValue); + } else { + SbiSetTimer (NextValue); + } +} + +/** + Check whether Sstc is enabled in PCD. + +**/ +STATIC +BOOLEAN +RiscVIsSstcEnabled ( + VOID + ) +{ + return ((PcdGet64 (PcdRiscVFeatureOverride) & RISCV_CPU_FEATURE_SSTC_BIT= MASK) !=3D 0); +} + /** Timer Interrupt Handler. =20 @@ -94,7 +133,7 @@ TimerInterruptHandler ( ), 1000000u ); // convert to tick - SbiSetTimer (PeriodStart); + RiscVProgramTimer (PeriodStart); RiscVEnableTimerInterrupt (); // enable SMode timer int gBS->RestoreTPL (OriginalTPL); } @@ -197,8 +236,7 @@ TimerDriverSetTimerPeriod ( ), 1000000u ); // convert to tick - SbiSetTimer (PeriodStart); - + RiscVProgramTimer (PeriodStart); mCpu->EnableInterrupt (mCpu); RiscVEnableTimerInterrupt (); // enable SMode timer int return EFI_SUCCESS; @@ -282,6 +320,11 @@ TimerDriverInitialize ( // mTimerNotifyFunction =3D NULL; =20 + if (RiscVIsSstcEnabled ()) { + mSstcEnabled =3D TRUE; + DEBUG ((DEBUG_INFO, "TimerDriverInitialize: Timer interrupt is via Sst= c extension\n")); + } + // // Make sure the Timer Architectural Protocol is not already installed i= n the system // --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113384): https://edk2.groups.io/g/devel/message/113384 Mute This Topic: https://groups.io/mt/103595210/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 17 14:40:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+113385+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+113385+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1704713833; cv=none; d=zohomail.com; s=zohoarc; b=fBbBXTDlGrPfWK7YS0KROOQAuy4kXyiZu9LBWbqd6lb4cQlcU5WJj8vX+thhBS971mBTfgzVF7V6hyI34uOMcHMPDkytxgSuXedGgGv2BC8kkoTQ9NhOM8dQslzBidY/IlPXGaajoi+FtnvKwHcFgbjqxSq3sunuPKLWQHVnQBU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704713833; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=8jeg+m+WD1wA2/zzI2jhNdKARIa6eYpDH4ZuqEik9GQ=; b=MQc0gq79oSbVxt9DLC1070+rogNfjeYFEUldVa3Trhuy5qHPH+E0lDz9FeycMOzIYxQNb+GClOeSUxkIgXmIPnjdoK2LeQghGoUdQq+zPBfJYghj5GYrRg+QQLvstWFzzIc7a3DoK0gpH4gBFWoCNN4CX5esBCrJQiU2JIzcaQM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+113385+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1704713833650965.5820786713721; Mon, 8 Jan 2024 03:37:13 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=EBtlo2kSa9XY892R6PVPovOwBDpo4dc7Ci/jpb+//ag=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1704713833; v=1; b=N3Q/ObGtu0NU4ilWez0t09NujBlD//5hsA6lJn/8D8JoEMdxV6XXvaF7I3WZuG6obDpmIM55 JiPp/Reap78b7XagqfE9om+/yycpNF+19qmICJiBj97JTZnRa301+soYoiMjN4qorO+8FRwedN3 Xs9p6YqwzZR72x3y+Miy2GFM= X-Received: by 127.0.0.2 with SMTP id wcPhYY1788612xikYory4yoB; Mon, 08 Jan 2024 03:37:13 -0800 X-Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) by mx.groups.io with SMTP id smtpd.web11.4722.1704713832782558727 for ; Mon, 08 Jan 2024 03:37:12 -0800 X-Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-3bbbc6b4ed1so1506289b6e.2 for ; Mon, 08 Jan 2024 03:37:12 -0800 (PST) X-Gm-Message-State: Mp5KQbM8aGSPlWGmUK20E03px1787277AA= X-Google-Smtp-Source: AGHT+IFzY4JixqqVskuxJMbiE7WfCBcyTaS9R66cVU+YFmfQaSqxK5osilkIpNHxRQTMEd39x4G6sA== X-Received: by 2002:a05:6358:7e13:b0:175:9261:c2e2 with SMTP id o19-20020a0563587e1300b001759261c2e2mr820061rwm.51.1704713831113; Mon, 08 Jan 2024 03:37:11 -0800 (PST) X-Received: from localhost.localdomain ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id i12-20020aa787cc000000b006d9af59eecesm5846618pfo.20.2024.01.08.03.37.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 03:37:10 -0800 (PST) From: "Sunil V L" To: devel@edk2.groups.io Cc: Sunil V L , Andrei Warkentin , Ard Biesheuvel , Gerd Hoffmann , Jiewen Yao , Laszlo Ersek Subject: [edk2-devel] [PATCH v2 4/4] OvmfPkg/RiscVVirt: Override Sstc extension Date: Mon, 8 Jan 2024 17:06:50 +0530 Message-Id: <20240108113650.454940-5-sunilvl@ventanamicro.com> In-Reply-To: <20240108113650.454940-1-sunilvl@ventanamicro.com> References: <20240108113650.454940-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sunilvl@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1704713835199100001 Content-Type: text/plain; charset="utf-8" Override Sstc extension and use SBI calls itself by default for RISC-V qemu virt platform. Cc: Andrei Warkentin Cc: Ard Biesheuvel Cc: Gerd Hoffmann Cc: Jiewen Yao Cc: Laszlo Ersek Signed-off-by: Sunil V L Reviewed-by: Laszlo Ersek Reviewed-by: Andrei Warkentin --- OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc b/OvmfPkg/RiscVVirt/RiscVV= irt.dsc.inc index d3624e899e8d..6bc7c90f31dc 100644 --- a/OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc +++ b/OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc @@ -203,7 +203,7 @@ [PcdsFeatureFlag] gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE =20 [PcdsFixedAtBuild.common] - gEfiMdePkgTokenSpaceGuid.PcdRiscVFeatureOverride|0xFFFFFFFFFFFFFFFE + gEfiMdePkgTokenSpaceGuid.PcdRiscVFeatureOverride|0xFFFFFFFFFFFFFFFC gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000 gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|1000000 gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|0 --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113385): https://edk2.groups.io/g/devel/message/113385 Mute This Topic: https://groups.io/mt/103595212/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-