CAAM RNG activation causes a kernel oops on iMx8MM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CAAM RNG activation causes a kernel oops on iMx8MM

1,098 Views
MAbdulfattah
Contributor I

Hello NXP, 

We are running linux-imx 6.6.36 on our custom hardware. The kernel throws the following bug at boot up : 
11.037497] caam algorithms registered in /proc/crypto
[ 11.043580] caam 30900000.crypto: caam pkc algorithms registered in /proc/crypto
[ 11.051276] caam 30900000.crypto: rng crypto API alg registered prng-caam
[ 11.058214] caam 30900000.crypto: registering rng-caam
[ 11.063516] caam_jr 30902000.jr: job ring error: irqstate: 00000103
[ 11.069865] ------------[ cut here ]------------
[ 11.074488] kernel BUG at /drivers/crypto/caam/jr.c:286!
[ 11.079803] Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP
[ 11.086593] Modules linked in: caam_jr(+) caamkeyblob_desc caamhash_desc caamalg_desc crypto_engine authenc libdes crct10dif_ce polyval_ce polyval_generic snd_soc_imx_card secvio caam error snd_soc_fsl_sai snd_soc_fsl_utils imx_pcm_dma imx_sdma leds_gpio overlay snd_usb_audio snd_hwdep snd_usbmidi_lib snd_ump

When we disable the CAAM RNG (by un-setting CONFIG_CRYPTO_DEV_FSL_CAAM_RNG_API) the kernel boots up normally. 
We are using the original imx8_v8_defconfig with no further modifications. We also made sure that JR1 security setting is the same as what is set at IMX-ATF by reading address : 

0x30900018 and the value is 0x00000001 
We are using imx scarthgap release https://github.com/nxp-imx/imx-manifest/blob/imx-linux-scarthgap/imx-6.6.36-2.1.0.xml 
And no changes were made to imx ATF nor the crypto/CAAM related nodes in the imx8mm.dtsi header. 
We also know that the CAAM registers are proprietary, so we can not even know which regs to check. 
Any idea? 

 



0 Kudos
Reply
4 Replies

443 Views
marcocavallini
Contributor V

Same issue here using Yocto scarthgap release with i.MX8MM and we need CAAM functionality to be fully activated with no issues.

Any clue?

 

Starting kernel ...
[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] Linux version 6.6.52-lts-next-g4fb516caac5f-dirty (oe-user@oe-host) (aarch64-poky-linux-gcc (GCC) 13.3.0, GNU ld (GNU Binutils) 2.42.0.20240723) #1 SMP PREEMPT Fri Nov 14 12:43:43 UTC 2025
...
[ 7.977664] caam algorithms registered in /proc/crypto
[ 7.986745] caam 30900000.crypto: caam pkc algorithms registered in /proc/crypto
[ 8.008003] caam 30900000.crypto: rng crypto API alg registered prng-caam
[ OK ] Stopped 8.015193] caam 30900000.crypto: registering rng-caam
;39mVirtual Console Setup.
[ 8.023446] caam_jr 30902000.jr: job ring error: irqstate: 00000103
[ 8.032264] ------------[ cut here ]------------
[ 8.036884] kernel BUG at /drivers/crypto/caam/jr.c:286!
[ 8.042199] Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP
[ 8.048990] Modules linked in: caam_jr(+) caamkeyblob_desc caamhash_desc caamalg_desc crypto_engine authenc libdes crct10dif_ce polyval_ce polyval_generic at24 caam secvio error fuse
[ 8.065294] CPU: 0 PID: 211 Comm: systemd-random- Not tainted 6.6.52-lts-next-g4fb516caac5f-dirty #1

 

0 Kudos
Reply

235 Views
marcocavallini
Contributor V

The solution for this issue is documented in u-boot documentation file mx8m_secure_boot.txt 

1.4.1 Avoiding Kernel crash in closed devices
----------------------------------------------

For devices prior to HAB v4.4.0, the HAB code locks the Job Ring and DECO
master ID registers in closed configuration. In case the user specific
application requires any changes in CAAM MID registers it's necessary to
add the "Unlock CAAM MID" command in CSF file.

The current NXP BSP implementation expects the CAAM registers to be unlocked
when configuring CAAM to operate in non-secure TrustZone world.

The Unlock command is already included by default in the signed HDMI and
DisplayPort firmwares. On i.MX8MM, i.MX8MN and i.MX8MP devices or in case the
HDMI or DisplayPort controllers are disabled in i.MX8M, users must ensure this
command is included in SPL CSF.

- Add Unlock MID command in csf_spl.txt:

  [Unlock]
      Engine = CAAM
      Features = MID

 

Tags (4)
0 Kudos
Reply

1,044 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello,

A kernel oops in Linux is triggered when the kernel detects an internal error, such as an invalid memory access. It's a non-fatal error that can lead to an unstable system and potentially a kernel panic if not addressed. 

 

Regards

0 Kudos
Reply

1,041 Views
MAbdulfattah
Contributor I

Hello @Bio_TICFSL , 

I know it is not a fatal error. However, we are using the manifest as provided by NXP and we expect the CAAM functionality to be fully activated with no issues. We want to use the TRNG of the CAAM. 
Any idea what the issue might be? 


0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2090985%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ECAAM%20RNG%20activation%20causes%20a%20kernel%20oops%20on%20iMx8MM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2090985%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20NXP%2C%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EWe%20are%20running%20linux-imx%26nbsp%3B6.6.36%20on%20our%20custom%20hardware.%20The%20kernel%20throws%20the%20following%20bug%20at%20boot%20up%20%3A%26nbsp%3B%3CBR%20%2F%3E11.037497%5D%20caam%20algorithms%20registered%20in%20%2Fproc%2Fcrypto%3CBR%20%2F%3E%5B%2011.043580%5D%20caam%2030900000.crypto%3A%20caam%20pkc%20algorithms%20registered%20in%20%2Fproc%2Fcrypto%3CBR%20%2F%3E%5B%2011.051276%5D%20caam%2030900000.crypto%3A%20rng%20crypto%20API%20alg%20registered%20prng-caam%3CBR%20%2F%3E%5B%2011.058214%5D%20caam%2030900000.crypto%3A%20registering%20rng-caam%3CBR%20%2F%3E%5B%2011.063516%5D%20caam_jr%2030902000.jr%3A%20job%20ring%20error%3A%20irqstate%3A%2000000103%3CBR%20%2F%3E%5B%2011.069865%5D%20------------%5B%20cut%20here%20%5D------------%3CBR%20%2F%3E%5B%2011.074488%5D%20kernel%20BUG%20at%20%2Fdrivers%2Fcrypto%2Fcaam%2Fjr.c%3A286!%3CBR%20%2F%3E%5B%2011.079803%5D%20Internal%20error%3A%20Oops%20-%20BUG%3A%2000000000f2000800%20%5B%231%5D%20PREEMPT%20SMP%3CBR%20%2F%3E%5B%2011.086593%5D%20Modules%20linked%20in%3A%20caam_jr(%2B)%20caamkeyblob_desc%20caamhash_desc%20caamalg_desc%20crypto_engine%20authenc%20libdes%20crct10dif_ce%20polyval_ce%20polyval_generic%20snd_soc_imx_card%20secvio%20caam%20error%20snd_soc_fsl_sai%20snd_soc_fsl_utils%20imx_pcm_dma%20imx_sdma%20leds_gpio%20overlay%20snd_usb_audio%20snd_hwdep%20snd_usbmidi_lib%20snd_ump%3CBR%20%2F%3E%3CBR%20%2F%3EWhen%20we%20disable%20the%20CAAM%20RNG%20(by%20un-setting%26nbsp%3B%3CSPAN%3ECONFIG_CRYPTO_DEV_FSL_CAAM_RNG_API)%20the%20kernel%20boots%20up%20normally.%26nbsp%3B%3CBR%20%2F%3EWe%20are%20using%20the%20original%20imx8_v8_defconfig%20with%20no%20further%20modifications.%20We%20also%20made%20sure%20that%20JR1%20security%20setting%20is%20the%20same%20as%20what%20is%20set%20at%20IMX-ATF%20by%20reading%20address%20%3A%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CDIV%3E0x30900018%20and%20the%20value%20is%200x00000001%26nbsp%3B%3CBR%20%2F%3EWe%20are%20using%20imx%20scarthgap%20release%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fnxp-imx%2Fimx-manifest%2Fblob%2Fimx-linux-scarthgap%2Fimx-6.6.36-2.1.0.xml%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fnxp-imx%2Fimx-manifest%2Fblob%2Fimx-linux-scarthgap%2Fimx-6.6.36-2.1.0.xml%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3EAnd%20no%20changes%20were%20made%20to%20imx%20ATF%20nor%20the%20crypto%2FCAAM%20related%20nodes%20in%20the%20imx8mm.dtsi%20header.%26nbsp%3B%3CBR%20%2F%3EWe%20also%20know%20that%20the%20CAAM%20registers%20are%20proprietary%2C%20so%20we%20can%20not%20even%20know%20which%20regs%20to%20check.%26nbsp%3B%3CBR%20%2F%3EAny%20idea%3F%26nbsp%3B%3C%2FDIV%3E%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2205287%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20CAAM%20RNG%20activation%20causes%20a%20kernel%20oops%20on%20iMx8MM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2205287%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3ESame%20issue%20here%26nbsp%3Busing%20%3CSTRONG%3EYocto%20scarthgap%3C%2FSTRONG%3E%20release%20with%20%3CSTRONG%3Ei.MX8MM%3C%2FSTRONG%3E%20and%20we%20need%26nbsp%3B%3CSTRONG%3ECAAM%3C%2FSTRONG%3E%20functionality%20to%20be%20fully%20activated%20with%20no%20issues.%3C%2FP%3E%3CP%3EAny%20clue%3F%3C%2FP%3E%3CBR%20%2F%3E%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3EStarting%20kernel%20...%0A%5B%20%20%20%200.000000%5D%20Booting%20Linux%20on%20physical%20CPU%200x0000000000%20%5B0x410fd034%5D%0A%5B%20%20%20%200.000000%5D%20Linux%20version%206.6.52-lts-next-g4fb516caac5f-dirty%20(oe-user%40oe-host)%20(aarch64-poky-linux-gcc%20(GCC)%2013.3.0%2C%20GNU%20ld%20(GNU%20Binutils)%202.42.0.20240723)%20%231%20SMP%20PREEMPT%20Fri%20Nov%2014%2012%3A43%3A43%20UTC%202025%0A...%0A%5B%207.977664%5D%20caam%20algorithms%20registered%20in%20%2Fproc%2Fcrypto%0A%5B%207.986745%5D%20caam%2030900000.crypto%3A%20caam%20pkc%20algorithms%20registered%20in%20%2Fproc%2Fcrypto%0A%5B%208.008003%5D%20caam%2030900000.crypto%3A%20rng%20crypto%20API%20alg%20registered%20prng-caam%0A%5B%20OK%20%5D%20Stopped%208.015193%5D%20caam%2030900000.crypto%3A%20registering%20rng-caam%0A%3B39mVirtual%20Console%20Setup.%0A%5B%208.023446%5D%20caam_jr%2030902000.jr%3A%20job%20ring%20error%3A%20irqstate%3A%2000000103%0A%5B%208.032264%5D%20------------%5B%20cut%20here%20%5D------------%0A%5B%208.036884%5D%20kernel%20BUG%20at%20%2Fdrivers%2Fcrypto%2Fcaam%2Fjr.c%3A286!%0A%5B%208.042199%5D%20Internal%20error%3A%20Oops%20-%20BUG%3A%2000000000f2000800%20%5B%231%5D%20PREEMPT%20SMP%0A%5B%208.048990%5D%20Modules%20linked%20in%3A%20caam_jr(%2B)%20caamkeyblob_desc%20caamhash_desc%20caamalg_desc%20crypto_engine%20authenc%20libdes%20crct10dif_ce%20polyval_ce%20polyval_generic%20at24%20caam%20secvio%20error%20fuse%0A%5B%208.065294%5D%20CPU%3A%200%20PID%3A%20211%20Comm%3A%20systemd-random-%20Not%20tainted%206.6.52-lts-next-g4fb516caac5f-dirty%20%231%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2093714%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20CAAM%20RNG%20activation%20causes%20a%20kernel%20oops%20on%20iMx8MM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2093714%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F34846%22%20target%3D%22_blank%22%3E%40Bio_TICFSL%3C%2FA%3E%26nbsp%3B%2C%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EI%20know%20it%20is%20not%20a%20fatal%20error.%20However%2C%20we%20are%20using%20the%20manifest%20as%20provided%20by%20NXP%20and%20we%20expect%20the%20CAAM%20functionality%20to%20be%20fully%20activated%20with%20no%20issues.%20We%20want%20to%20use%20the%20TRNG%20of%20the%20CAAM.%26nbsp%3B%3CBR%20%2F%3EAny%20idea%20what%20the%20issue%20might%20be%3F%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2093708%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20CAAM%20RNG%20activation%20causes%20a%20kernel%20oops%20on%20iMx8MM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2093708%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-huuid%3D%22690400883816089229%22%3EA%20kernel%20oops%20in%20Linux%20is%20triggered%20%3CMARK%20class%3D%22QVRyCf%22%3Ewhen%20the%20kernel%20detects%20an%20internal%20error%2C%20such%20as%20an%20invalid%20memory%20access%3C%2FMARK%3E.%20%3C%2FSPAN%3E%3CSPAN%20data-huuid%3D%22690400883816089156%22%3EIt's%20a%20non-fatal%20error%20that%20can%20lead%20to%20an%20unstable%20system%20and%20potentially%20a%20kernel%20panic%20if%20not%20addressed.%3CSPAN%20class%3D%22pjBG2e%22%20data-cid%3D%22b744ba15-7fc9-430c-aa5b-2c1c86f29414%22%3E%3CSPAN%20class%3D%22UV3uM%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20class%3D%22NPrrbc%22%20data-cid%3D%22b744ba15-7fc9-430c-aa5b-2c1c86f29414%22%20data-uuids%3D%22690400883816089229%2C690400883816089156%22%3E%0A%3CDIV%20class%3D%22BMebGe%20btku5b%20fCrZyc%20LwdV0e%20FR7ZSc%20OJeuxf%22%20tabindex%3D%220%22%20role%3D%22button%22%20aria-label%3D%22Ver%20v%C3%ADnculos%20relacionados%22%20data-hveid%3D%22CAQQAQ%22%20data-ved%3D%222ahUKEwiBt72hiJSNAxW0_rsIHYyPInEQ3fYKegQIBBAB%22%3E%0A%3CDIV%20class%3D%22niO4u%22%3E%0A%3CDIV%20class%3D%22kHtcsd%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3E%3CLI-WRAPPER%3E%3C%2FLI-WRAPPER%3ERegards%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2256111%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20CAAM%20RNG%20activation%20causes%20a%20kernel%20oops%20on%20iMx8MM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2256111%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThe%20solution%20for%20this%20issue%20is%20documented%20in%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fnxp-imx%2Fuboot-imx%2Fblob%2Flf_v2024.04%2Fdoc%2Fimx%2Fhabv4%2Fguides%2Fmx8m_secure_boot.txt%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Eu-boot%20documentation%20file%20mx8m_secure_boot.txt%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E1.4.1%20Avoiding%20Kernel%20crash%20in%20closed%20devices%0A----------------------------------------------%0A%0AFor%20devices%20prior%20to%20HAB%20v4.4.0%2C%20the%20HAB%20code%20locks%20the%20Job%20Ring%20and%20DECO%0Amaster%20ID%20registers%20in%20closed%20configuration.%20In%20case%20the%20user%20specific%0Aapplication%20requires%20any%20changes%20in%20CAAM%20MID%20registers%20it's%20necessary%20to%0Aadd%20the%20%22Unlock%20CAAM%20MID%22%20command%20in%20CSF%20file.%0A%0AThe%20current%20NXP%20BSP%20implementation%20expects%20the%20CAAM%20registers%20to%20be%20unlocked%0Awhen%20configuring%20CAAM%20to%20operate%20in%20non-secure%20TrustZone%20world.%0A%0AThe%20Unlock%20command%20is%20already%20included%20by%20default%20in%20the%20signed%20HDMI%20and%0ADisplayPort%20firmwares.%20On%20i.MX8MM%2C%20i.MX8MN%20and%20i.MX8MP%20devices%20or%20in%20case%20the%0AHDMI%20or%20DisplayPort%20controllers%20are%20disabled%20in%20i.MX8M%2C%20users%20must%20ensure%20this%0Acommand%20is%20included%20in%20SPL%20CSF.%0A%0A-%20Add%20Unlock%20MID%20command%20in%20csf_spl.txt%3A%0A%0A%20%20%5BUnlock%5D%0A%20%20%20%20%20%20Engine%20%3D%20CAAM%0A%20%20%20%20%20%20Features%20%3D%20MID%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E