-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for RME extension to SBSA #231
Conversation
I wonder can we move PcdSystemMemoryBase by those 1072MB always. Then check "is there RME present" and if not then add that memory as another entry in memory map. That may require SMC call to TF-A to ask for RME (or other way as I am not familiar with RME yet). This way one firmware image would work for the platform despite which firmware options are enabled/present. |
@hrw ok, that's a valuable point. I am completely new to EDK2, can you provide pointers to here the SMC call should be made and the memory map entry added? |
All SMC are in Silicon/Qemu/SbsaQemu/Library/SbsaQemuHardwareInfoLib/SbsaQemuHardwareInfoLib.c on EDK2 side and in plat/qemu/qemu_sbsa/sbsa_sip_svc.c on TF-A side. When it comes to memory map - check functions which call GetMemInfo() in Silicon/Qemu/* - on NUMA systems we use SMC to get info about all memory nodes and add them into memory map. So maybe instead of creating copy of dsc/fdf etc:
NOTE: TF-A 2.12 and edk202411 are coming. RME code for both of them will rather be merged after releases to make sure that we have combo which works for users. |
When an RMM is not present, should I add the extra memory to VirtualMemoryTable[3] in ArmPlatformGetVirtualMemoryMap() and zero-out VirtualMemoryTable[4]? To do so I would obviously change MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS to 5 instead of 4. |
Apologies for late reply, caught a cold on a trip last week, just getting back into it. While there is nothing wrong (aside from some minor naming conventions, this is CamelCaseCountry, not dash-country) with this approach, is there a particular rationale/philosophy behind creating separate .dsc/.fdf files? As in, the syntax supports conditionals - it would have been possible to implement the same functionality to be disabled by default, but enabled (and image output names changed) within the existing files given a command line parameter. But clearly with/without RMM are fundamentally different platforms, just with an awful lot of overlap, so it's a valid thing to split them out to highlight. Just wondering if that was the thinking behind it :) |
Is there any documentation on how this functions in qemu? What options affect the sbsa-ref machine memory map? (Only thing I can find on a quick grep of the qemu docs is a comment that FEAT_RME is supported but experimental.) |
OK, we have 3 components here:
I wonder how exactly it is supposed to work and will guess a bit below. If we boot QEMU (-m 8G) with RME enabled then TF-A notices it, starts RMM, 1GB ram is reserved for it and EDK2 starts, does own stuff and OS loads with RMM enabled and we can use RME functionality. Memory map says that 7GB ram is present. If we boot QEMU without RME then TF-A loads, do not start RMM, EDK2 boots, notice 'no RMM' and adds that 1GB ram to memory map. OS loads. Memory map says that 8GB ram is present. Note that I assume that Physical memory stays the same in both cases. For normal boot OS sees whole memory, for RME boot it sees whole memory - 1GB reserved for RMM. In other words: the only "physical" part which changes is CPU. |
To complement @hrw's description, RME support is enabled in TF-A with a compilation flag, i.e "ENABLE_RME=1". This can't be a runtime configuration as we are doing with EDK2 because the Granule Protection Table is installed at the top of the secure RAM and other components of the boot firmware, i.e BL2 and BL31, are installed below that. |
Any input on this? |
Right, so this answers a question I didn't ask yet - whether we will need separate TF-A binaries in edk2-non-osi for this. |
The MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS is kind of an ugly idiom anyway. The #define is not used for anything outside of the file, and I don't see any serious drawback in having two terminating null entries instead of one :) But I'd ideally want to refrain from hardcoding the 1GB thing. TF-A will per definition know this, right? So the same SMC call that tells us RMM is enabled could also tell us size of reservation from start of DRAM (which we depend on hardcoding anyway)? And then we could set that dynamically and keep only one VirtualMemoryTable entry for DRAM? |
The SMC call that tells us the RMM is enabled is already part of the RMM specification by way of RMI_VERSION. That part is already implemented in the TF-A and I'm simply re-using it. As such, if we get a valid ABI version from that call, the RMM is present. If not, or the call is not supported, we don't have an RMM. But looking at the code further, we may not need to do an SMC call. The call to GetMemInfo() in SbsaQemuLibConstructor() will return the base address and size of the memory with the RMM taken into account. The only problem is the ASSERT() in SbsaQemuLibConstructor(). If we get rid of that check we should be able to have a single, dynamic, entry for DRAM in VirtualMemoryTable[]. If I am correct, are you in agreement with dropping the ASSERT()? |
Ah, right. Makes sense.
I mean ... we may want to change it to a <= instead of a ==, just to sanity check that the offset from the hardwired base is positive? |
I'll send out a new patchset based on the above conversation - we can continue from there. |
Can you in meantime share info how to build tf-a for sbsa-ref/x-rme?
|
RME support for SBSA is not yet upstream, something I will start working on after EDK2/EDK2-platforms have been dealt with. In the meantime the code is hosted here, branch "cca/v3". Note that you will also need to compile an RMM image. How to get the RMM code base and compile both RMM and TF-A, please refer to instructions here. |
Thanks. "./boot-sbsa-ref.py --cpu max,x-rme=on" boots:
|
One unforeseen problem with the above scheme is variable PcdCPUCoresStackBase - it is used very early on in the boot process, well before any kind of information about the platform can be requested from EL3. Its value is statically set to (PcdSystemMemoryBase + 0x7c000) but that obviously won't work if PcdSystemMemoryBase becomes dynamic. I have reflected long and hard on how to address this and came up empty. I'm hoping that people more familiar with the project will be able to provide guidance. Otherwise we are back to my initial solution of using different binaries to support RME. |
Hmm, there are some complications here. I'll try to spend some cycles to consider possibilities on Monday. |
OK, none of my clever ideas seemed to work. |
Very well, we can settle on that for the time being. I will send another revision. |
6da24d1
to
2d66a9e
Compare
Hi maintainers,
This pull request is adding support for the RME extension to the SBSA machine. When RME is enabled, the RMM is occupying the first 1GB of system RAM, followed by the DT. This reality needs to be reflected in the base RAM address and more space in flash need to be reserved. Otherwise it is the same configuration as the non-RME aware SBSA implementation.
Thanks,
Mathieu