1*a87892acSSong Liu#!/bin/bash 2*a87892acSSong Liu# SPDX-License-Identifier: GPL-2.0 3*a87892acSSong Liu# 4*a87892acSSong Liu# EXPORT_SYMBOL_FOR_MODULES() puts a vmlinux symbol in a "module:<names>" 5*a87892acSSong Liu# namespace, and the module loader grants access by matching the importing 6*a87892acSSong Liu# module's name against that list. A livepatch module is never on the list, so 7*a87892acSSong Liu# referencing such a symbol with a normal relocation fails modpost, and if that 8*a87892acSSong Liu# is silenced, fails to load with "Unknown symbol". It needs a klp relocation, 9*a87892acSSong Liu# the same as an unexported symbol. 10*a87892acSSong Liu# 11*a87892acSSong Liu# Ordinary namespaces are not affected: copy_import_ns() propagates the patched 12*a87892acSSong Liu# object's import tags to the patch module, so a normal relocation works. 13*a87892acSSong Liu 14*a87892acSSong Liu. "$(dirname "$0")/../lib.sh" 15*a87892acSSong Liu 16*a87892acSSong Liusetup 17*a87892acSSong Liubuild_pair cross_module.c 18*a87892acSSong Liu 19*a87892acSSong Liusym=other_mod_func 20*a87892acSSong Liu 21*a87892acSSong Liu# Plain vmlinux export: a normal relocation is what we want. 22*a87892acSSong Liuexport_syms "$sym" 23*a87892acSSong Liurun_diff 24*a87892acSSong Liuassert_no_klp_sym "$sym" 25*a87892acSSong Liu 26*a87892acSSong Liu# Ordinary namespace: still a normal relocation. 27*a87892acSSong Liuexport_syms 28*a87892acSSong Liuadd_exports_ns vmlinux MY_NS "$sym" 29*a87892acSSong Liurun_diff 30*a87892acSSong Liuassert_no_klp_sym "$sym" 31*a87892acSSong Liu 32*a87892acSSong Liu# module: namespace: has to become a klp relocation. 33*a87892acSSong Liuexport_syms 34*a87892acSSong Liuadd_exports_ns vmlinux module:kvm "$sym" 35*a87892acSSong Liurun_diff 36*a87892acSSong Liuassert_klp_sym "$sym" vmlinux 37*a87892acSSong Liuassert_section __klp_relocs.vmlinux 38*a87892acSSong Liu 39*a87892acSSong Liupass "EXPORT_SYMBOL_FOR_MODULES symbol referenced with a klp relocation" 40