From: Deborah Brouwer <[email protected]> The firmware binary must have a shared section for communicating with the MCU. Check for this section after parsing and fail with -EINVAL if it is missing.
Signed-off-by: Deborah Brouwer <[email protected]> Signed-off-by: Laura Nao <[email protected]> --- drivers/gpu/drm/tyr/fw/parser.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/gpu/drm/tyr/fw/parser.rs b/drivers/gpu/drm/tyr/fw/parser.rs index c4d0ad1d7899..8bddaa1f0aa2 100644 --- a/drivers/gpu/drm/tyr/fw/parser.rs +++ b/drivers/gpu/drm/tyr/fw/parser.rs @@ -197,6 +197,20 @@ pub(super) fn parse(&mut self) -> Result<KVec<ParsedSection>> { return Err(EINVAL); } + // Validate that the firmware contains the required shared memory section. + let has_shared_section = parsed_sections + .iter() + .any(|section| section.va.start == super::CSF_MCU_SHARED_REGION_START); + + if !has_shared_section { + dev_err!( + self.cursor.dev, + "No shared section found at 0x{:08x} in firmware\n", + super::CSF_MCU_SHARED_REGION_START + ); + return Err(EINVAL); + } + Ok(parsed_sections) } -- 2.39.5
