crc generation fix for EXPORT_SYMBOL_GPL
RFC PATCH 1/1 crc generation fix for EXPORT_SYMBOL_GPL
Currently genksym does not take into account the GPLness of the exported symbol while generating the crc for the exported symbol. Any symbol changes from EXPORT_SYMBOL to EXPORT_SYMBOL_GPL would not reflect in the Module.symvers file. This patch fixes that problem.
With the patch one could find the changes in GPLness of the exported symbols between two releases of the kernel by diffing their Module.symvers file.
Signed-off-by Ram Pai ([email protected])
scripts/genksyms/genksyms.c | 4 +++- scripts/genksyms/genksyms.h | 2 +- scripts/genksyms/parse.c_shipped | 2 +- scripts/genksyms/parse.y | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-)
scripts/genksyms/genksyms.c +3 -1
@@ -426,11 +426,11 @@ expand_and_crc_list(struct string_list *return crc; }void -export_symbol (const char *name) +export_symbol (const char *name,const char *export_type) {struct symbol *sym; sym =find_symbol (name,SYM_NORMAL );if (!sym)
@@ -443,10 +443,12 @@ export_symbol(const char *name)fprintf (debugfile,"Export %s == <" , name); expansion_trail = (struct symbol *)-1L ; crc =expand_and_crc_list (sym->defn,0xffffffff ) ^0xffffffff ; +if (strncmp (export_type,"EXPORT_SYMBOL_GPL" ,17 ) ==0 ) + crc =partial_crc32 ("__gpl__" , crc); sym = expansion_trail;while (sym != (struct symbol *)-1L ) {struct symbol *n = sym->expansion_trail;
scripts/genksyms/genksyms.h +1 -1
@@ -65,11 +65,11 @@ extern struct string_list *current_list,struct symbol *find_symbol (const char *name,enum symbol_type ns);struct symbol *add_symbol (const char *name,enum symbol_type type,struct string_list *defn,int is_extern); -void export_symbol (const char *); +void export_symbol (const char *,const char *);struct string_list *reset_list (void );void free_list (struct string_list *s,struct string_list *e);void free_node (struct string_list *list);struct string_list *copy_node (struct string_list *);
scripts/genksyms/parse.c_shipped +1 -1
@@ -1341,11 +1341,11 @@ case 120: #line 453 "scripts/genksyms/parse.y" { yyval = NULL; ; break;} case 122: #line 459 "scripts/genksyms/parse.y" -{ export_symbol((*yyvsp[-2])->string); yyval = yyvsp[0]; ; +{ export_symbol((*yyvsp[-2])->string, (*yyvsp[-4])->string); yyval = yyvsp[0]; ; break;} } /* the action file gets copied in in place of this dollarsign */ #line 543 "/usr/lib/bison.simple"
scripts/genksyms/parse.y +1 -1
@@ -454,11 +454,11 @@ asm_phrase_opt: | ASM_PHRASE ; export_definition: EXPORT_SYMBOL_KEYW '(' IDENT ')' ';' - { export_symbol((*$3)->string); $$ = $5; } + { export_symbol((*$3)->string, (*$1)->string); $$ = $5; } ; %%
Quoted 4 lines · Ram Pai
Currently genksym does not take into account the GPLness of the exported symbol while generating the crc for the exported symbol. Any symbol changes from
EXPORT_SYMBOLtoEXPORT_SYMBOL_GPLwould not reflect in the Module.symvers file. This patch fixes that problem.
and this is a problem.. why?
Quoted 7 lines · Arjan van de Ven
Quoted 4 lines · Ram Pai
Currently genksym does not take into account the GPLness of the exported symbol while generating the crc for the exported symbol. Any symbol changes from
EXPORT_SYMBOLtoEXPORT_SYMBOL_GPLwould not reflect in the Module.symvers file. This patch fixes that problem.and this is a problem.. why?
Tools that depend on Module.symvers wont be able to detect the change in GPLness of the exported symbols.
Eventually we want to generate a tool that can report API changes across kernel releases and put it in some friendly(docbook) format.
Suggestions?
RP
Quoted 2 lines
Quoted 11 lines · Ram Pai
Quoted 7 lines · Arjan van de Ven
Quoted 4 lines · Ram Pai
Currently genksym does not take into account the GPLness of the exported symbol while generating the crc for the exported symbol. Any symbol changes from
EXPORT_SYMBOLtoEXPORT_SYMBOL_GPLwould not reflect in the Module.symvers file. This patch fixes that problem.and this is a problem.. why?
Tools that depend on Module.symvers wont be able to detect the change in GPLness of the exported symbols.
and that is relevant.. why?
Quoted 2 lines
Eventually we want to generate a tool that can report API changes across kernel releases and put it in some friendly(docbook) format.
but a _GPL change isn't an API change though... either a module is legal or it isn't. _GPL doesn't matter there...
Quoted 3 lines
Eventually we want to generate a tool that can report API changes across kernel releases and put it in some friendly(docbook) format.
the CRC's are only very lightly related to API though (or even ABI) so I suspect this isn't too useful a thing to persue in the first place (using CRC I mean, documenting real API changes I can see being useful)
Quoted 5 lines · Arjan van de Ven
Quoted 2 lines
Eventually we want to generate a tool that can report API changes across kernel releases and put it in some friendly(docbook) format.
the CRC's are only very lightly related to API though (or even ABI) so I suspect this isn't too useful a thing to persue in the first place
actually the CRC's capture a pretty good picture of the changes to API as well as ABI. The crc is run on the prototype of the exported symbol, recursively expanding each and every datastructure involved in the prototype.
Hence it mostly captures the ABI signature of the exported symbols. The only part it misses is, it does not capture the GPL'ness of the exported symbol. And that was what I was trying to fix, because changing the export nature of the symbol changes the ABI. With the fix one would be able to exactly detect API/ABI changes to exported symbols.
Do you think its a bad idea still? Its a good indication for out-of-tree modules that the ABI/API of some exported symbols they depend on, has changed.
Quoted 1 line
(using CRC I mean, documenting real API changes I can see being useful)
Sure. Nice to learn that this work will be of value. Also looking for ideas on what information would be useful to report and in what format.
Thanks,
RP