Hi Dhaval,
To clarify this further there are two aspects:
- A need to have a specification for various ways of ISA string discovery in FW. For now I am focused on this point.
- How that discovery happens could be a combination of DT, SBI extension (or even HOB in case of UEFI). This point is mute if we do not think #1 is required.
So first I wanted to discuss if adding some sort of standardization helps. That would mean, we add details on how ISA discovery happens as part of BRS. My point was that such clarity will help different FW developers given that ISA string discovery is quite fundamental to the boot flow.
Take a look at this patch where we are planning to define EFI_HOB_TYPE_CPU_RISCV. Would it not be better to add an ISA string as part of this HOB? To me it sounds more natural to have it there instead of parsing it from DT when PI is passing this information to Dxe. While in OpenSBI as you mentioned below DT might make more sense.
Unless I am missing something, creating a HOB for FDT and pass to next phase is a standard across architectures and it is required anyway to install FDT pointer UEFI configuration table for DT based systems. Why should we define new thing for ISA alone when we can pass entire FDT?
Thanks,
Sunil
Hi Dhaval,
On 31/07/23 10:08, Dhaval Sharma wrote:
To clarify this further there are two aspects:
- A need to have a specification for various ways of ISA string discovery in FW. For now I am focused on this point.
- How that discovery happens could be a combination of DT, SBI extension (or even HOB in case of UEFI). This point is mute if we do not think #1 is required.
So first I wanted to discuss if adding some sort of standardization helps. That would mean, we add details on how ISA discovery happens as part of BRS. My point was that such clarity will help different FW developers given that ISA string discovery is quite fundamental to the boot flow.
Take a look at this patch where we are planning to define EFI_HOB_TYPE_CPU_RISCV. Would it not be better to add an ISA string as part of this HOB? To me it sounds more natural to have it there instead of parsing it from DT when PI is passing this information to Dxe. While in OpenSBI as you mentioned below DT might make more sense.Unless I am missing something, creating a HOB for FDT and pass to next phase is a standard across architectures and it is required anyway to install FDT pointer UEFI configuration table for DT based systems. Why should we define new thing for ISA alone when we can pass entire FDT?
To view this discussion on the web visit https://groups.google.com/a/riscv.org/d/msgid/fw-exchange/b9226766-163b-5c84-6127-f636dfec72d8%40ventanamicro.com.
Hi Tuan,
There is already libfdt and recently it is added in MdePkg itself so that it is easier to use in different packages without introducing cyclic dependencies. IMO, defining GUID for ISA is not necessary. We may need more things from DT like this (ex: CBO sizes etc). Better to use FDT library for all such use cases.
Thanks,
Sunil
Hi Sunil,
It is not about functionality, it is about the easy to use from user perspective. Yes you can using libfdt to retrieve anything from FDT. My view is fdt should only visible before DXE phase as it is the meant to pass information from M-mode to firmware. All info that EDK2 DXE needed should be prepared in HOB.
Also, there no need to pass FDT configuration to Linux if we only want ACPI support only.
Hi Dhaval,
I think you are right. I guess Andrei's proposal would document in the spec if it removes FIRMWARE_CONTEXT and suggests to use the gFdtHobGuid.
Thanks,
Sunil
Yes, FIRMWARE_CONTEXT is gone from PI spec (at least in the sense that the ECR has been accepted).
So I haven’t yet created a PI spec ECR to introduce a special RISCV CPU HOB. But I will, the code first implementation is already done and tested with RiscVVirt – this is the next natural step (followed by tons of painful cleanup to U5Pkg, but I digress). This will only contain the boot hart ID at the moment. Really, if the UEFI implementation wishes to rely on parsing an FDT passed to it (a solid idea), then there’s already the gFdtHobGuid mechanism to do just that.
I’m a big believer that FDT is a useful tool for firmware autoconfiguration. I.e. it’s okay to make it available to the DXE phase – this doesn’t mean that it gets exposed to the OS, necessarily. Systems that boot ACPI OSes won’t expose the FDT (but may use the FDT, for example, to generate ACPI tables or configure BS drivers).
As far as the ISA string detection… you could get it from the DT or use a custom ecall if you don’t like DT. Or maybe you just get it straight from your HV-populated ACPI tables (in a VM). Different choices may be valid. What I don’t think is necessary is sticking the ISA string in a HOB.
A
To unsubscribe from this group and stop receiving emails from it, send an email to
fw-exchange...@riscv.org.
To view this discussion on the web visit
https://groups.google.com/a/riscv.org/d/msgid/fw-exchange/8076c007-28b7-6a2f-470a-b8baa908156f%40ventanamicro.com.
Okay, I can see the reasoning where we can parse out some useful info into the CPU hob, like CMO info (i.e. not just an ISA string but useful data).
Did you have a list of such parameters in mind? This way when we propose the PI Spec ECR we won’t have to immediately churn again on it in a few months…
A
I brought up the topic of extending the RISCV CPU HOB in the PIWG call. Because it’s clear that we’re going to have to evolve it over time.
The consensus is that we should have a version field in there (as the first field). And then we can add whatever new fields we want. Revving the spec is not the problem (but we should of course think first before adding stuff).
We can go with a bitfield (and just add extra fields). I don’t see anything too wrong with that. At the same time, the RISCVCPU HOB really needs to be used for either:
Coming back to this… how does this sound for a definition? HartCaps is 32-bit to ensure 64-bit alignment for BootHartId. We can always add further HartCapsX fields if we need them (and we’re not going to be adding a bit for every extension…)
//
// EFI_HOB_CPU_RISCV Version.
//
#define EFI_HOB_CPU_RISCV_VERSION_1 0x0001
//
// EFI_HOB_CPU_RISCV HartCaps.
//
#define EFI_RISCV_CAP_SSTC 0x0001
#define EFI_RISCV_CAP_ZICBOM 0x0002
#define EFI_RISCV_CAP_ZICBOZ 0x0004
#define EFI_RISCV_CAP_ZICBOP 0x0008
#define EFI_RISCV_CAP_SVPBMT 0x0010
///
/// Describes additional RISC-V processor information,
/// on top of information provided by EFI_HOB_CPU.
///
typedef struct {
///
/// The HOB generic header. Header.HobType = EFI_HOB_TYPE_CPU_RISCV.
///
EFI_HOB_GENERIC_HEADER Header;
///
/// The version number of the EFI_HOB_TYPE_CPU_RISCV HOB definition,
/// which may evolve over time.
///
UINT32 Version;
///
/// Describes universal capabilities that are expected to be queried
/// and used by multiple Tiano components, making it beneficial for
/// discovery info to be cached.
///
UINT32 HartCaps;
///
/// Only valid if EFI_RISCV_CAP_ZICBOM or EFI_RISCV_CAP_ZICBOP is
/// set in HartCaps.
///
UINT32 CboBlockSize;
///
/// Only valid if EFI_RISCV_CAP_ZICBOZ is set in HartCaps.
///
UINT32 CboZeroBlockSize;
///
/// Booting hart ID.
///
UINT64 BootHartId;
} EFI_HOB_CPU_RISCV;
To view this discussion on the web visit https://groups.google.com/a/riscv.org/d/msgid/fw-exchange/SN7PR11MB6849EA08D8A421BA410B15778313A%40SN7PR11MB6849.namprd11.prod.outlook.com.
Hi Dhaval,
Good point… we could accommodate this via adding another field, envcfg, which would reflect the capabilities in the *current* privilege level.
Would that solve the problem? The field could be, in an implementation:
Ok, acknowledged.
To view this discussion on the web visit https://groups.google.com/a/riscv.org/d/msgid/fw-exchange/CAAxYnhSP5dA6xW%3DThL0B%2BrDmgs_EE%3De8ofVjmboyE_-OUcQMgA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/riscv.org/d/msgid/fw-exchange/CAAxYnhSqNxFF2ABrBPoRkjj0YfM39STmDH49Z0mZWT4mndm-6g%40mail.gmail.com.