-
Notifications
You must be signed in to change notification settings - Fork 16
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
GICv3 register context is not saved during system suspend #464
Comments
@soby-mathew storing in secure memory carve out opens us up for a physical attack? Should'nt we put in hooks such that OPTEE or some other OS will provide encryption services prior to store into DDR? |
Hi Nishanth, Perhaps, within ARM Trusted Firmware, we can provide GICv3 driver helpers to save and restore secure and non-secure context separately. Thus a platform can choose to save secure GICv3 context in Secure SRAM and the non-secure context in secure DDR carve-out. This reduces the security risk in case of a physical attack. |
@soby-mathew instead of a piecemeal approach, maybe a generic api needs to be present for allocating out of context save and restore region and gic code allocate, save and restore from the same perhaps? |
OK, I may not have understood your suggestion completely. As we don't support memory allocation at run-time, an API to allocate memory at runtime may not be possible. What is possible though is to define a platform API to get the region statically allocated for this purpose If you have any ideas for the same, we are happy to hear them. |
Hmm.. I was thinking of a simpler requestor mechanism at boot similar to linux kernel's genalloc framework - something that linux kernel's sram driver already uses -> it just needs a section to be defined, and allocation happens on a need basis from the section, it does'nt need to continue providing functionality after boot is done (but that is something that is easily supported). |
OK, now I understand your
The support we are planning to add will also ensure that this can be done by platform if it desires. But this is a piecemeal solution as you said. If we can justify other usecases with the same requirement, perhaps we can think of a framework along these lines. |
@soby-mathew how do we manage tlbs for system mmu for example? arm side, we can rebuild, but with components in SoC that ATF is supposed to manage, dont we need to save and restore those configs? |
From my understanding, the SMMU, unlike GICv3, does not have any registers that are Perhaps, a framework to use pre-allocated region in firmware would be useful I think. Need more thoughts on this. |
Internal ref : https://jira.arm.com/browse/GENFW-1800 |
Is there any progress on this? I'm looking to add the general functionality to restore the gicv3 state on resume. I'm looking to put this in ATF. I was going to have platforms that lose state for the gicv3 recall the init functions for the gicd and gicr. Then any registers that can be changed would be restored after that. For the allocated memory problem, I was going to rely on --gc-sections to remove the functions/data from the ATF binary for the platforms that don't use it. I would also leave the memory allocation up to the platform (so it could decide on whether to put it in Secure SRAM or somewhere else). How is the GIC ITS unable to be restored in a general manner? Is there something that needs to be done besides storing the writable registers in the GIC Distributor space for it? |
@dbasehore, Although we had some initial design discussions regarding this, I did not have time to progress the implementation due to other priorities. This is planned for the next month. Yes, your suggestion for doing init and then restoring the register context sounds correct to me. The ITS tables are configured via ITS commands. My knowledge of ITS is also very weak, but as I understand, the specification says that "details of power management of ITS are implementation defined". For example, when GITS_BASER is restored, if the address pointed to by the register is non - zero (because the tables are already present in memory), the behaviour is unpredictable. There are other nuances in the spec which prevents the generic save/restore of ITS. |
@soby-mathew Is there a plan to deal with restoring ITS then? I have it working on the RK3399 with just a register restore. For a general implementation, will the platform specific code have to do this, or can the general code restore the registers and the platform code can do whatever it needs to do after that to get it working? |
The current plan is not to handle ITS restore in generic driver.
Yes, this might just work for most platforms. But since the spec says this behaviour is implementation defined, the current plan is to leave this choice to the platform.
The idea was to introduce helper functions to save and restore GICv3 registers and these helpers will get invoked by the appropriate platform hooks during power management. The GICv3 driver by itself will not do anything unless invoked by the platform. These are the proposed APIs for the GICv3 driver :
So during SYSTEM suspend, the Similarly, the counterpart APIs will be invoked after GICv3 init during power up. If you have something working, it would be very helpful if you can share your work through a branch or Pull request and that will help to expedite this task. |
There's just code specific to the RK3399 right now. I'm working to make it generic, though. |
During system suspend, the GICv3 Distributor and Redistributor context can be lost due to power gating of the system power domain. This means that the GICv3 context needs to be saved prior to system suspend and restored on wakeup. Currently the consensus is that the Firmware should be in charge of this. See tf-issues#464 for more details. This patch introduces helper APIs in the GICv3 driver to save and restore the Distributor and Redistributor contexts. The GICv3 ITS context is not considered in this patch because the specification says that the details of ITS power management is implementation-defined. These APIs are expected to be appropriately invoked by the platform layer during system suspend. Fixes ARM-software/tf-issues#464 Change-Id: Iebb9c6770ab8c4d522546f161fa402d2fe02ec00 Signed-off-by: Soby Mathew <soby.mathew@arm.com> Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
During system suspend, the GICv3 Distributor and Redistributor context can be lost due to power gating of the system power domain. This means that the GICv3 context needs to be saved prior to system suspend and restored on wakeup. Currently the consensus is that the Firmware should be in charge of this. See tf-issues#464 for more details. This patch introduces helper APIs in the GICv3 driver to save and restore the Distributor and Redistributor contexts. The GICv3 ITS context is not considered in this patch because the specification says that the details of ITS power management is implementation-defined. These APIs are expected to be appropriately invoked by the platform layer during system suspend. Fixes ARM-software/tf-issues#464 Change-Id: Iebb9c6770ab8c4d522546f161fa402d2fe02ec00 Signed-off-by: Soby Mathew <soby.mathew@arm.com> Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
During system suspend, the GICv3 Distributor and Redistributor context can be lost due to power gating of the system power domain. This means that the GICv3 context needs to be saved prior to system suspend and restored on wakeup. Currently the consensus is that the Firmware should be in charge of this. See tf-issues#464 for more details. This patch introduces helper APIs in the GICv3 driver to save and restore the Distributor and Redistributor contexts. The GICv3 ITS context is not considered in this patch because the specification says that the details of ITS power management is implementation-defined. These APIs are expected to be appropriately invoked by the platform layer during system suspend. Fixes ARM-software/tf-issues#464 Change-Id: Iebb9c6770ab8c4d522546f161fa402d2fe02ec00 Signed-off-by: Soby Mathew <soby.mathew@arm.com> Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
Okay, it seems that the map collection ITS commands need to be resent on RK3399 after resume if the GIC loses power. I know that the preference was to implement this in ATF, but it's really simple to just have the drivers/irqchip/irq-gic-v3-its.c code call its its_cpu_init_collection function during syscore resume in just several lines of code. It seems that implementing this in the firmware would require significantly more work than that. Is this the correct thing to do on all GICv3 platforms? Provided that there's not an issue with systems that don't cut power to the GIC, is anyone against having the GIC driver in the kernel restore this part of the GIC state? |
Yes, I agree it is not possible to replay GIC ITS commands from ARM TF for ITS restore. The ITS
There were some concerns from the kernel team regarding this. Those concerns would need to be addressed if it is to be done generically for GICv3 platforms.
IMO, if this is the case, then it is good to be specified in appropriate documentation (if possible in PSCI Spec). That will ensure all the involved stake holders are having the same expectations during system suspend. But first this would need agreement that it is right way for all GICv3 platforms. There were some internal discussions which I will try to revive. Are the corresponding linux patches posted to the lists ? |
No, but I can post an RFC patch to get a discussion going if you want. Are there any specific concerns from the kernel team at ARM regarding this? |
There were some concerns around whether the LPI pendings bits would be retained when ITS is reinitialized and it might involve implementation specifc sequences which the kernel team were not keen on adding. Not sure if there were more concerns but I guess these will have to ironed out through discussions. |
Would replaying the MAPC commands affect the LPI pending bits? I'm just calling the its_cpu_init_collection function which doesn't reallocate the LPIs. |
There is some doubt whether MAPI/MAPTI are allowed to clear a pending bit which means the kernel would need to take a copy of the pending table on resume in order to inject an INT command for each pending bit. That's all my understanding about this. |
During system suspend, the GICv3 Distributor and Redistributor context can be lost due to power gating of the system power domain. This means that the GICv3 context needs to be saved prior to system suspend and restored on wakeup. Currently the consensus is that the Firmware should be in charge of this. See tf-issues#464 for more details. This patch introduces helper APIs in the GICv3 driver to save and restore the Distributor and Redistributor contexts. The GICv3 ITS context is not considered in this patch because the specification says that the details of ITS power management is implementation-defined. These APIs are expected to be appropriately invoked by the platform layer during system suspend. Fixes ARM-software/tf-issues#464 Change-Id: Iebb9c6770ab8c4d522546f161fa402d2fe02ec00 Signed-off-by: Soby Mathew <soby.mathew@arm.com> Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
During system suspend, the GICv3 Distributor and Redistributor context can be lost due to power gating of the system power domain. This means that the GICv3 context needs to be saved prior to system suspend and restored on wakeup. Currently the consensus is that the Firmware should be in charge of this. See tf-issues#464 for more details. This patch introduces helper APIs in the GICv3 driver to save and restore the Distributor and Redistributor contexts. The GICv3 ITS context is not considered in this patch because the specification says that the details of ITS power management is implementation-defined. These APIs are expected to be appropriately invoked by the platform layer during system suspend. Fixes ARM-software/tf-issues#464 Change-Id: Iebb9c6770ab8c4d522546f161fa402d2fe02ec00 Signed-off-by: Soby Mathew <soby.mathew@arm.com> Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
During system suspend, the GICv3 Distributor and Redistributor context can be lost due to power gating of the system power domain. This means that the GICv3 context needs to be saved prior to system suspend and restored on wakeup. Currently the consensus is that the Firmware should be in charge of this. See tf-issues#464 for more details. This patch introduces helper APIs in the GICv3 driver to save and restore the Distributor and Redistributor contexts. The GICv3 ITS context is not considered in this patch because the specification says that the details of ITS power management is implementation-defined. These APIs are expected to be appropriately invoked by the platform layer during system suspend. Fixes ARM-software/tf-issues#464 Change-Id: Iebb9c6770ab8c4d522546f161fa402d2fe02ec00 Signed-off-by: Soby Mathew <soby.mathew@arm.com> Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
During system suspend, the GICv3 Distributor and Redistributor context can be lost due to power gating of the system power domain. This means that the GICv3 context needs to be saved prior to system suspend and restored on wakeup. Currently the consensus is that the Firmware should be in charge of this. See tf-issues#464 for more details. This patch introduces helper APIs in the GICv3 driver to save and restore the Distributor and Redistributor contexts. The GICv3 ITS context is not considered in this patch because the specification says that the details of ITS power management is implementation-defined. These APIs are expected to be appropriately invoked by the platform layer during system suspend. Fixes ARM-software/tf-issues#464 Change-Id: Iebb9c6770ab8c4d522546f161fa402d2fe02ec00 Signed-off-by: Soby Mathew <soby.mathew@arm.com> Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
Is there any update on what the kernel team thought was acceptable for resending the MAPC commands? |
Perhaps there have been discussions, but I haven't had any updates. I can try to get the status of this sometime next week. |
During system suspend, the GICv3 Distributor and Redistributor context can be lost due to power gating of the system power domain. This means that the GICv3 context needs to be saved prior to system suspend and restored on wakeup. Currently the consensus is that the Firmware should be in charge of this. See tf-issues#464 for more details. This patch introduces helper APIs in the GICv3 driver to save and restore the Distributor and Redistributor contexts. The GICv3 ITS context is not considered in this patch because the specification says that the details of ITS power management is implementation-defined. These APIs are expected to be appropriately invoked by the platform layer during system suspend. Fixes ARM-software/tf-issues#464 Change-Id: Iebb9c6770ab8c4d522546f161fa402d2fe02ec00 Signed-off-by: Soby Mathew <soby.mathew@arm.com> Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
During system suspend, the GICv3 Distributor and Redistributor context can be lost due to power gating of the system power domain. This means that the GICv3 context needs to be saved prior to system suspend and restored on wakeup. Currently the consensus is that the Firmware should be in charge of this. See tf-issues#464 for more details. This patch introduces helper APIs in the GICv3 driver to save and restore the Distributor and Redistributor contexts. The GICv3 ITS context is not considered in this patch because the specification says that the details of ITS power management is implementation-defined. These APIs are expected to be appropriately invoked by the platform layer during system suspend. Fixes ARM-software/tf-issues#464 Change-Id: Iebb9c6770ab8c4d522546f161fa402d2fe02ec00 Signed-off-by: Soby Mathew <soby.mathew@arm.com> Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
@dbasehore, sorry for the delay, but many people were away due to conferences. I have had a prelimanary discussion but no conclusion yet. Hope to get some clarity on this during this week. |
On a related note, is there an ETA for when the Trusted Firmware patches for this will land? |
During system suspend, the GICv3 Distributor and Redistributor context can be lost due to power gating of the system power domain. This means that the GICv3 context needs to be saved prior to system suspend and restored on wakeup. Currently the consensus is that the Firmware should be in charge of this. See tf-issues#464 for more details. This patch introduces helper APIs in the GICv3 driver to save and restore the Distributor and Redistributor contexts. The GICv3 ITS context is not considered in this patch because the specification says that the details of ITS power management is implementation-defined. These APIs are expected to be appropriately invoked by the platform layer during system suspend. Fixes ARM-software/tf-issues#464 Change-Id: Iebb9c6770ab8c4d522546f161fa402d2fe02ec00 Signed-off-by: Soby Mathew <soby.mathew@arm.com> Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
We hope to have this merged by end of this week. |
Having MAPC commands to I have updated the PR to leave the GITS_CTLR.Enabled to 0 within the ITS resume helper. This could be used to indicate to the kernel whether GIC ITS needs restore or not. This needs to be specified properly somewhere. |
During system suspend, the GICv3 Distributor and Redistributor context can be lost due to power gating of the system power domain. This means that the GICv3 context needs to be saved prior to system suspend and restored on wakeup. Currently the consensus is that the Firmware should be in charge of this. See tf-issues#464 for more details. This patch introduces helper APIs in the GICv3 driver to save and restore the Distributor and Redistributor contexts. The GICv3 ITS context is not considered in this patch because the specification says that the details of ITS power management is implementation-defined. These APIs are expected to be appropriately invoked by the platform layer during system suspend. Fixes ARM-software/tf-issues#464 Change-Id: Iebb9c6770ab8c4d522546f161fa402d2fe02ec00 Signed-off-by: Soby Mathew <soby.mathew@arm.com> Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
Today neither the kernel nor the firmware saves and restores GICv3 distributor context during system suspend. This was not a problem on Juno because it was GICv2 and the kernel caters for the save and restore of Distributor because the assumptions of GICv2 systems are different from those with GICv3. A firmware is expected to be always present on GICv3 systems.
This leaves us with 2 choices , save/restore GICv3 Distributor context in Kernel or firmware. The problems of implementing this in kernel are:
If the implementation is in firmware, since the firmware is aware of power domains, it can save and restore GICv3 when required. If system suspend might result in loss of ITS information, then firmware can choose to downgrade SYSTEM domain power down to a shallower power down state which does not result in loss of power to GIC or even deny SYSTEM suspend.
These problems tilt the argument in favour of implementation in firmware. The primary concern of doing this in firmware was the memory cost for save and restoring several GIC Distributor registers. This can be overcome by allowing the platform to specify the memory for the save and restore (Possibly in a secure memory carve-out in DDR).
The text was updated successfully, but these errors were encountered: