extern struct jump_entry __stop___jump_table[];
 
 extern void jump_label_init(void);
+extern void jump_label_init_ro(void);
 extern void jump_label_lock(void);
 extern void jump_label_unlock(void);
 extern void arch_jump_label_transform(struct jump_entry *entry,
        static_key_initialized = true;
 }
 
+static __always_inline void jump_label_init_ro(void) { }
+
 static __always_inline bool static_key_false(struct static_key *key)
 {
        if (unlikely_notrace(static_key_count(key) > 0))
 
        cpus_read_unlock();
 }
 
+static inline bool static_key_sealed(struct static_key *key)
+{
+       return (key->type & JUMP_TYPE_LINKED) && !(key->type & ~JUMP_TYPE_MASK);
+}
+
+static inline void static_key_seal(struct static_key *key)
+{
+       unsigned long type = key->type & JUMP_TYPE_TRUE;
+       key->type = JUMP_TYPE_LINKED | type;
+}
+
+void jump_label_init_ro(void)
+{
+       struct jump_entry *iter_start = __start___jump_table;
+       struct jump_entry *iter_stop = __stop___jump_table;
+       struct jump_entry *iter;
+
+       if (WARN_ON_ONCE(!static_key_initialized))
+               return;
+
+       cpus_read_lock();
+       jump_label_lock();
+
+       for (iter = iter_start; iter < iter_stop; iter++) {
+               struct static_key *iterk = jump_entry_key(iter);
+
+               if (!is_kernel_ro_after_init((unsigned long)iterk))
+                       continue;
+
+               if (static_key_sealed(iterk))
+                       continue;
+
+               static_key_seal(iterk);
+       }
+
+       jump_label_unlock();
+       cpus_read_unlock();
+}
+
 #ifdef CONFIG_MODULES
 
 enum jump_label_type jump_label_init_type(struct jump_entry *entry)
                        static_key_set_entries(key, iter);
                        continue;
                }
+
+               /*
+                * If the key was sealed at init, then there's no need to keep a
+                * reference to its module entries - just patch them now and be
+                * done with it.
+                */
+               if (static_key_sealed(key))
+                       goto do_poke;
+
                jlm = kzalloc(sizeof(struct static_key_mod), GFP_KERNEL);
                if (!jlm)
                        return -ENOMEM;
                static_key_set_linked(key);
 
                /* Only update if we've changed from our initial state */
+do_poke:
                if (jump_label_type(iter) != jump_label_init_type(iter))
                        __jump_label_update(key, iter, iter_stop, true);
        }
                if (within_module((unsigned long)key, mod))
                        continue;
 
+               /* No @jlm allocated because key was sealed at init. */
+               if (static_key_sealed(key))
+                       continue;
+
                /* No memory during module load */
                if (WARN_ON(!static_key_linked(key)))
                        continue;