Re: [PATCH] Add static_key_feature_checks_initialized flag
From: Nicholas Miehlbradt <hidden>
Date: 2024-04-02 01:54:58
On 28/3/2024 2:20 am, Christophe Leroy wrote:
Le 27/03/2024 à 05:59, Nicholas Miehlbradt a écrit :quoted
JUMP_LABEL_FEATURE_CHECK_DEBUG used static_key_initialized to determine whether {cpu,mmu}_has_feature() was used before static keys were initialized. However, {cpu,mmu}_has_feature() should not be used before setup_feature_keys() is called. As static_key_initalized is set much earlier during boot there is a window in which JUMP_LABEL_FEATURE_CHECK_DEBUG will not report errors. Add a flag specifically to indicate when {cpu,mmu}_has_feature() is safe to use.What do you mean by "much earlier" ? As far as I can see, static_key_initialized is set by jump_label_init() as cpu_feature_keys_init() and mmu_feature_keys_init() are call immediately after. I don't think it is possible to do anything inbetween. Or maybe you mean the problem is the call to jump_label_init() in early_init_devtree() ? You should make it explicit in the message, and see if it wouldn't be better to call cpu_feature_keys_init() and mmu_feature_keys_init() as well in early_init_devtree() in that case ?
The jump_label_init() call in early_init_devtree() is exactly the issue. I don't think it's possible to move the call to mmu_feature_keys_init() earlier without significant refactoring since mmu features are being set as late as setup_kup(). I'll still sent a v2 with a better worded commit message. Nicholas
Christophe