[ofa-general] Re: [PATCH] installer: update kernel symbol versions

Yosef Etigin yosefe at voltaire.com
Thu Apr 19 02:17:23 PDT 2007


Michael S. Tsirkin wrote:
>>Quoting Yosef Etigin <yosefe at voltaire.com>:
>>Subject: Re: [PATCH] installer: update kernel symbol versions
>>
>>Michael S. Tsirkin wrote:
>>
>>>>1. Taking another Module.symvers, and even knowing that this is what causes the 
>>>>  module loading errors, is not as straightforward as finding the headers.
>>>
>>>
>>>It isn't? Why isn't it?
>>>As I see it, this is a problem that needs to be solved once
>>>when external module is packaged.
>>>
>>
>>OK, but this solution should be part of OFED, and available for all kernels.
>>From what 
>>I have tested (and correct me if i'm wrong) on older kernels one must edit the original
>>.symvers anyway to get the right versions.
>>
>>So why shouldn't the installation do that?
> 
> 
> Because, these are part of another package, touching them is wrong.
> External modules will have to solve it in some other way.  It should be possible
> - it's all just scripts, for the most part.  For example, for all I care, build
> script for external module can catenate ofed and kernel symvers, build and then
> split them back. Already better than OFED doing permanent changes.
> 

The problem is that this is not applicable for old kernels.
Anyone using rhas4 must change his version anyway.

Another method:
The kernel-ib-devel will provide a patch that a user can apply to his
Module.symvers, to update it with the new versions.

Signed-off-by: Yosef Etigin <yosefe at voltaire.com>
--

diff -urN ofed_1_2.orig/ofed_scripts/ofa_kernel.spec ofed_1_2.new/ofed_scripts/ofa_kernel.spec
--- ofed_1_2.orig/ofed_scripts/ofa_kernel.spec	2007-04-19 12:13:58.000000000 +0300
+++ ofed_1_2.new/ofed_scripts/ofa_kernel.spec	2007-04-19 12:15:30.000000000 +0300
@@ -162,13 +162,57 @@
 %if %{build_kernel_ib}
 make kernel # MODULES_DIR=/lib/modules/%{KVERSION} DESTDIR=$RPM_BUILD_ROOT
 make install_kernel MODULES_DIR=%{LIB_MOD_DIR} DESTDIR=$RPM_BUILD_ROOT
-modsyms=`find $RPM_BUILD_DIR/%{_name}-%{_version} -name Module.symvers -o -name Modules.symvers`
-for modsym in $modsyms
+
+# Create module symbols patch
+MOD_SYMVERS_TMP=$RPM_BUILD_ROOT/%{_prefix}/src/%{_name}/Module.symvers
+MOD_SYMVERS_OFA=$RPM_BUILD_ROOT/%{_prefix}/src/%{_name}/Modules.symvers
+IB_MODULES_ROOT=$RPM_BUILD_DIR/%{_name}-%{_version}
+MOD_SYMVERS_ORIG=%{KSRC}/Module.symvers
+
+cp ${MOD_SYMVERS_ORIG} ${MOD_SYMVERS_TMP}
+
+# Go silent - don't display the symbol string
+set +x
+
+# Find the new symbols that IB modules export
+# list them all in a file,crc,symbol fashion
+SYM_RECS=""
+for mod in $(find ${IB_MODULES_ROOT} -name '*.ko')
 do
-        cat $modsym >> $RPM_BUILD_ROOT/%{_prefix}/src/%{_name}/Module.symvers
+        # break down the list to file name crc and symbol
+        group=$(nm -o ${mod} |
+            sed -ne s#${IB_MODULES_ROOT}'/*\(.*\)\.ko:0\{8\}\(\w\{8\}\) . __crc_\(.*\)$#\2,\3,\1#p')
+        SYM_RECS=${SYM_RECS}' '${group}
+        for rec in ${group}
+        do
+                [ -z "${rec}" ] && continue
+                sym=$(echo ${rec} | cut -d, -f2)
+                SYMS=${SYMS}"/${sym}/d;"
+        done
+done
+
+# Remove old symbols from Module.symvers
+touch ${MOD_SYMVERS_TMP}
+sed -i ${MOD_SYMVERS_TMP} -e "${SYMS}"
+
+# Add our symbols
+rm -f ${MOD_SYMVERS_OFA}
+touch ${MOD_SYMVERS_OFA}
+for rec in ${SYM_RECS}; do
+        echo 0x${rec} | sed -e 's/,/\t/g' >> ${MOD_SYMVERS_OFA}
 done
+cat ${MOD_SYMVERS_OFA} >> ${MOD_SYMVERS_TMP}
+
+# Go verbose
+set -x
+
+# create patch
+MODULES_PATCH_FILE=$RPM_BUILD_ROOT/%{_prefix}/src/%{_name}/ofed_kernel_syms.patch
+diff -uN  ${MOD_SYMVERS_ORIG} ${MOD_SYMVERS_TMP} >> ${MODULES_PATCH_FILE} || true
+rm -f ${MOD_SYMVERS_TMP}
+
 %endif
-	
+
 ################################## Handle kernel modules ##################################
 
     # Fix kernel modules path in case that modules were installed under 'extra' directory





More information about the general mailing list