kexec: Return -ENOSYS when kexec does not know how to call KEXEC_FILE_LOAD
Subsystems (2)
PATCH 1/5 kexec: Return -ENOSYS when kexec does not know how to call KEXEC_FILE_LOAD
When the kernel does not know a syscall number it returns -ENOSYS but when kexec does not know a syscall number it returns -1. Return -ENOSYS from kexec as well.
--- kexec/kexec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kexec/kexec.c +1 -1
@@ -1166,7 +1166,7 @@ static int do_kexec_file_load(int fileind, int argc, char **argv,if (!is_kexec_file_load_implemented ()) {fprintf (stderr,"syscall kexec_file_load not available.\n" ); -return -1 ; +return -ENOSYS ; }if (argc - fileind <=0 ) {
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 2/5 kexec: do not special-case the -s option
It is parsed separately to save a few CPU cycles when setting up other options but it just complicates the code. So fold it back and set up all flags both for KEXEC_LOAD and KEXEC_FILE_LOAD
--- kexec/kexec.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)
kexec/kexec.c +4 -21
@@ -1256,19 +1256,6 @@ int main(int argc, char *argv[]) };static const char short_options[] =KEXEC_ALL_OPT_STR ; -/* -* First check if --use-kexec-file-syscall is set. That changes lot of -* things -*/ -while ((opt =getopt_long (argc, argv, short_options, - options,0 )) !=-1 ) { -switch (opt) { -case OPT_KEXEC_FILE_SYSCALL : - do_kexec_file_syscall =1 ; -break ; - } - } -/* Reset getopt for the next pass. */ opterr =1 ; optind =1 ;
@@ -1310,8 +1297,7 @@ int main(int argc, char *argv[]) do_shutdown =0 ; do_sync =0 ; do_unload =1 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_UNLOAD ; + kexec_file_flags |=KEXEC_FILE_UNLOAD ;break ;case OPT_EXEC : do_load =0 ;
@@ -1354,11 +1340,8 @@ int main(int argc, char *argv[]) do_exec =0 ; do_shutdown =0 ; do_sync =0 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_ON_CRASH ; -else - kexec_flags =KEXEC_ON_CRASH ; -break ; + kexec_file_flags |=KEXEC_FILE_ON_CRASH ; + kexec_flags =KEXEC_ON_CRASH ;case OPT_MEM_MIN : mem_min =strtoul (optarg, &endptr,0 );if (*endptr) {
@@ -1383,7 +1366,7 @@ int main(int argc, char *argv[]) do_reuse_initrd =1 ;break ;case OPT_KEXEC_FILE_SYSCALL : -/* We already parsed it. Nothing to do. */ + do_kexec_file_syscall =1 ;break ;case OPT_STATUS : do_status =1 ;
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 2/5] kexec: do not special-case the -s option
Quoted 44 lines · Michal Suchanek
It is parsed separately to save a few CPU cycles when setting up other options but it just complicates the code. So fold it back and set up all flags both for
KEXEC_LOADandKEXEC_FILE_LOADSigned-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)kexec/kexec.c +1
-15@@ -1256,19 +1256,6 @@ int main(int argc, char *argv[]) };static const char short_options[] =KEXEC_ALL_OPT_STR ; -/* -* First check if --use-kexec-file-syscall is set. That changes lot of -* things -*/ -while ((opt =getopt_long (argc, argv, short_options, - options,0 )) !=-1 ) { -switch (opt) { -case OPT_KEXEC_FILE_SYSCALL : - do_kexec_file_syscall =1 ; -break ; - } - } -/* Reset getopt for the next pass. */ opterr =1 ; optind =1 ;@@ -1310,8 +1297,7 @@ int main(int argc, char *argv[]) do_shutdown =0 ; do_sync =0 ; do_unload =1 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_UNLOAD ; + kexec_file_flags |=KEXEC_FILE_UNLOAD ;break ;case OPT_EXEC : do_load =0 ;
kexec/kexec.c int main(int argc, char *argv[]) · line 1344
Quoted 10 lines
kexec/kexec.c +2
-5@@ -1354,11 +1340,8 @@ int main(int argc, char *argv[]) do_exec =0 ; do_shutdown =0 ; do_sync =0 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_ON_CRASH ; -else - kexec_flags =KEXEC_ON_CRASH ; -break ; + kexec_file_flags |=KEXEC_FILE_ON_CRASH ; + kexec_flags =KEXEC_ON_CRASH ;
This appears to change the logic of options parsing.
Quoted 15 lines
kexec/kexec.c +1
-1case OPT_MEM_MIN : mem_min =strtoul (optarg, &endptr,0 );if (*endptr) {@@ -1383,7 +1366,7 @@ int main(int argc, char *argv[]) do_reuse_initrd =1 ;break ;case OPT_KEXEC_FILE_SYSCALL : -/* We already parsed it. Nothing to do. */ + do_kexec_file_syscall =1 ;break ;case OPT_STATUS : do_status =1 ;Signature · 1 line
2.13.6
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 2/5] kexec: do not special-case the -s option
Quoted 52 lines · On Fri, 2 Mar 2018 13:36:16 +0100 Simon Horman <[email protected]> wrote:
Quoted 51 lines · Michal Suchanek
It is parsed separately to save a few CPU cycles when setting up other options but it just complicates the code. So fold it back and set up all flags both for
KEXEC_LOADandKEXEC_FILE_LOADSigned-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)kexec/kexec.c +0
-2@@ -1256,19 +1256,6 @@ int main(int argc, char *argv[]) };static const char short_options[] =KEXEC_ALL_OPT_STR ; -/* -* First check if --use-kexec-file-syscall is set. That changes lot of
kexec/kexec.c +1
-13-* things -*/ -while ((opt =getopt_long (argc, argv, short_options, - options,0 )) !=-1 ) { -switch (opt) { -case OPT_KEXEC_FILE_SYSCALL : - do_kexec_file_syscall =1 ; -break ; - } - } -/* Reset getopt for the next pass. */ opterr =1 ; optind =1 ;@@ -1310,8 +1297,7 @@ int main(int argc, char *argv[]) do_shutdown =0 ; do_sync =0 ; do_unload =1 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_UNLOAD ; + kexec_file_flags |=KEXEC_FILE_UNLOAD ;break ;case OPT_EXEC :kexec/kexec.c +0
-2do_load =0 ;@@ -1354,11 +1340,8 @@ int main(int argc, char *argv[]) do_exec =0 ; do_shutdown =0 ; do_sync =0 ; -if (do_kexec_file_syscall) - kexec_file_flags |=
Quoted 9 lines
kexec/kexec.c int main(int argc, char *argv[]) · line 1344
Quoted 6 lines
kexec/kexec.c +2
-3KEXEC_FILE_ON_CRASH ; - else - kexec_flags =KEXEC_ON_CRASH ; -break ; + kexec_file_flags |=KEXEC_FILE_ON_CRASH ; + kexec_flags =KEXEC_ON_CRASH ;This appears to change the logic of options parsing.
Care to share how exactly is the logic changed? I do not see it. To me it looks like we have separate flags for KEXEC_LOAD and KEXEC_FILE_LOAD so setting up both does not change anything. Whatever syscall is used it has the flags set up.
In the existing logic we decide which syscall to do beforehand and set up only flags for that syscall but that does not save much CPU cycles and makes the code more complex and fragile.
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 2/5] kexec: do not special-case the -s option
Quoted 65 lines · Michal Suchánek
Quoted 52 lines · On Fri, 2 Mar 2018 13:36:16 +0100 Simon Horman <[email protected]> wrote:
Quoted 51 lines · Michal Suchanek
It is parsed separately to save a few CPU cycles when setting up other options but it just complicates the code. So fold it back and set up all flags both for
KEXEC_LOADandKEXEC_FILE_LOADSigned-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)kexec/kexec.c +0
-2@@ -1256,19 +1256,6 @@ int main(int argc, char *argv[]) };static const char short_options[] =KEXEC_ALL_OPT_STR ; -/* -* First check if --use-kexec-file-syscall is set. That changes lot of
kexec/kexec.c +1
-13-* things -*/ -while ((opt =getopt_long (argc, argv, short_options, - options,0 )) !=-1 ) { -switch (opt) { -case OPT_KEXEC_FILE_SYSCALL : - do_kexec_file_syscall =1 ; -break ; - } - } -/* Reset getopt for the next pass. */ opterr =1 ; optind =1 ;@@ -1310,8 +1297,7 @@ int main(int argc, char *argv[]) do_shutdown =0 ; do_sync =0 ; do_unload =1 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_UNLOAD ; + kexec_file_flags |=KEXEC_FILE_UNLOAD ;break ;case OPT_EXEC :kexec/kexec.c +0
-2do_load =0 ;@@ -1354,11 +1340,8 @@ int main(int argc, char *argv[]) do_exec =0 ; do_shutdown =0 ; do_sync =0 ; -if (do_kexec_file_syscall) - kexec_file_flags |=Quoted 9 lines
kexec/kexec.c int main(int argc, char *argv[]) · line 1344
Quoted 6 lines
kexec/kexec.c +2
-3KEXEC_FILE_ON_CRASH ; - else - kexec_flags =KEXEC_ON_CRASH ; -break ; + kexec_file_flags |=KEXEC_FILE_ON_CRASH ; + kexec_flags =KEXEC_ON_CRASH ;This appears to change the logic of options parsing.
Quoted 8 lines
Care to share how exactly is the logic changed? I do not see it. To me it looks like we have separate flags for
KEXEC_LOADandKEXEC_FILE_LOADso setting up both does not change anything. Whatever syscall is used it has the flags set up.In the existing logic we decide which syscall to do beforehand and set up only flags for that syscall but that does not save much CPU cycles and makes the code more complex and fragile.
Thanks, the logic change that I was referring to is that kexec_file_flags and kexec_flags are both updated regardless of the value of do_kexec_file_syscall, which was not the case prior to this patch. If that has no effect on the overall execution of the program then this is of course fine but that was not at all obvious to me.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH 3/5 kexec: add option to revert -s
In reply to Michal SuchanekThe undocumented -s option selects KEXEC_FILE_LOAD syscall but there is no option to select KEXEC_LOAD syscall so add it. It is generally good idea and in followup patch the default will be changed so it will be needed to get KEXEC_LOAD functionality.
--- kexec/kexec.c | 3 +++ kexec/kexec.h | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-)
kexec/kexec.c +3 -0
@@ -1368,6 +1368,9 @@ int main(int argc, char *argv[])case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ;break ; +case OPT_KEXEC_SYSCALL : + do_kexec_file_syscall =0 ; +break ;case OPT_STATUS : do_status =1 ;break ;
kexec/kexec.h +3 -1
@@ -219,6 +219,7 @@ extern int file_types;#define OPT_TYPE 't'#define OPT_PANIC 'p'#define OPT_KEXEC_FILE_SYSCALL 's' +#define OPT_KEXEC_SYSCALL 'c'#define OPT_STATUS 'S'#define OPT_MEM_MIN 256#define OPT_MEM_MAX 257
@@ -246,11 +247,12 @@ extern int file_types; { "mem-max", 1, 0, OPT_MEM_MAX }, \ { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ + { "kexec-syscall", 0, 0, OPT_KEXEC_SYSCALL }, \ { "debug", 0, 0, OPT_DEBUG }, \ { "status", 0, 0, OPT_STATUS }, \ { "print-ckr-size", 0, 0, OPT_PRINT_CKR_SIZE }, \ -#define KEXEC_OPT_STR "h?vdfxyluet:psS" +#define KEXEC_OPT_STR "h?vdfxyluet:pscS" extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);extern void die (const char *fmt, ...)
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 4/5 kexec: fallback to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
In reply to Michal SuchanekNot all architectures implement KEXEC_FILE_LOAD. However, on some archiectures KEXEC_FILE_LOAD is required when secure boot is enabled in locked-down mode. Previously users had to select the KEXEC_FILE_LOAD syscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.
When no option is passed to select one syscall or the other try KEXEC_FILE_LOAD and fall back to KEXEC_LOAD when not suported.
--- kexec/kexec.c | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-)
kexec/kexec.c +39 -4
@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =1 ;int do_status =0 ;void *entry =0 ;char *type =0 ;
@@ -1367,9 +1368,11 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ;break ;case OPT_KEXEC_SYSCALL : do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ;break ;case OPT_STATUS : do_status =1 ;
@@ -1442,16 +1445,48 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification. +* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +case -ENOTSUPP : +/* +* By default reject or do nothing if +* succeded +*/ +default :break ; +/* +* Parsing image or other options failed +* The image may be invalid or image +* type may not supported by kernel so +* retry parsing in kexec-tools. +*/ +case -EINVAL : +case -ENOEXEC : + do_kexec_file_syscall =0 ; +break ; + } + } +if (!do_kexec_file_syscall) result =my_load (type, fileind, argc, argv, kexec_flags, entry); }
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 4/5] kexec: fallback to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
Quoted 20 lines · On Mon, 26 Feb 2018 13:00:37 +0100 Michal Suchanek <[email protected]> wrote:
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.When no option is passed to select one syscall or the other try
KEXEC_FILE_LOADand fall back toKEXEC_LOADwhen not suported.Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-)kexec/kexec.c +0
-0
kexec/kexec.c int main(int argc, char *argv[]) · line 1246
Quoted 4 lines
kexec/kexec.c +1
-0@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =1 ;
do_kexec_file_syscall should be also set to 1 for the fallback to be the default. Or we need the fallback option to set do_kexec_fallback separately.
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 4/5] kexec: fallback to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
In reply to Michal SuchanekQuoted 75 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.When no option is passed to select one syscall or the other try
KEXEC_FILE_LOADand fall back toKEXEC_LOADwhen not suported.Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-)kexec/kexec.c +26
-4@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =1 ;int do_status =0 ;void *entry =0 ;char *type =0 ;@@ -1367,9 +1368,11 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ;break ;case OPT_KEXEC_SYSCALL : do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ;break ;case OPT_STATUS : do_status =1 ;@@ -1442,16 +1445,48 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification. +* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +case -ENOTSUPP : +/* +* By default reject or do nothing if +* succeded +*/ +default :break ;
kexec/kexec.c int main(int argc, char *argv[]) · line 1486
Quoted 10 lines
kexec/kexec.c +10
-0+/* +* Parsing image or other options failed +* The image may be invalid or image +* type may not supported by kernel so +* retry parsing in kexec-tools. +*/ +case -EINVAL : +case -ENOEXEC : + do_kexec_file_syscall =0 ; +break ;
Why do we need checking so many errno, I assumed only fallback in case -ENOSYS
Quoted 14 lines
kexec/kexec.c +3
-0+ } + } +if (!do_kexec_file_syscall) result =my_load (type, fileind, argc, argv, kexec_flags, entry); }Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 4/5] kexec: fallback to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
Quoted 66 lines · On Fri, 2 Mar 2018 17:17:06 +0800 Dave Young <[email protected]> wrote:
Quoted 65 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.When no option is passed to select one syscall or the other try
KEXEC_FILE_LOADand fall back toKEXEC_LOADwhen not suported.Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-)kexec/kexec.c +12
-4@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =1 ;int do_status =0 ;void *entry =0 ;char *type =0 ;@@ -1367,9 +1368,11 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ;break ;case OPT_KEXEC_SYSCALL : do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ;break ;case OPT_STATUS : do_status =1 ;@@ -1442,16 +1445,48 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification.
Quoted 8 lines
kexec/kexec.c int main(int argc, char *argv[]) · line 1470
Quoted 8 lines
kexec/kexec.c +8
-0+* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE :
The above do not need to be listed. These are the return values expected when checking signature fails. This lists is for documentation purposes only.
Quoted 15 lines
Quoted 15 lines
kexec/kexec.c +3
-0+case -ENOTSUPP : +/* +* By default reject or do nothing if
kexec/kexec.c +5
-0+* succeded +*/ +default :break ; +/* +* Parsing image or other options failed
kexec/kexec.c +1
-0+* The image may be invalid or image
kexec/kexec.c +1
-0+* type may not supported by kernel so
kexec/kexec.c +1
-0+* retry parsing in
Quoted 8 lines
kexec/kexec.c int main(int argc, char *argv[]) · line 1486
Quoted 6 lines
kexec-tools.
kexec/kexec.c +5
-0+*/ +case -EINVAL : +case -ENOEXEC : + do_kexec_file_syscall =0 ; +break ;Why do we need checking so many errno,
Linux returns these when it does not understand the image format. Because some formats are not supported by KEXEC_LOAD_FILE it makes sense to try parsing the image in kexec-tools.
Quoted 2 lines
I assumed only fallback in
case-ENOSYS
which is not even listed.
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v4 1/5 kexec: Return -ENOSYS when kexec does not know how to call KEXEC_FILE_LOAD
In reply to Dave YoungWhen the kernel does not know a syscall number it returns -ENOSYS but when kexec does not know a syscall number it returns -1. Return -ENOSYS from kexec as well.
--- kexec/kexec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kexec/kexec.c +1 -1
@@ -1166,7 +1166,7 @@ static int do_kexec_file_load(int fileind, int argc, char **argv,if (!is_kexec_file_load_implemented ()) {fprintf (stderr,"syscall kexec_file_load not available.\n" ); -return -1 ; +return -ENOSYS ; }if (argc - fileind <=0 ) {
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v4 2/5 kexec: do not special-case the -s option
It is parsed separately to save a few CPU cycles when setting up other options but it just complicates the code. So fold it back and set up all flags both for KEXEC_LOAD and KEXEC_FILE_LOAD
--- kexec/kexec.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)
kexec/kexec.c +4 -21
@@ -1256,19 +1256,6 @@ int main(int argc, char *argv[]) };static const char short_options[] =KEXEC_ALL_OPT_STR ; -/* -* First check if --use-kexec-file-syscall is set. That changes lot of -* things -*/ -while ((opt =getopt_long (argc, argv, short_options, - options,0 )) !=-1 ) { -switch (opt) { -case OPT_KEXEC_FILE_SYSCALL : - do_kexec_file_syscall =1 ; -break ; - } - } -/* Reset getopt for the next pass. */ opterr =1 ; optind =1 ;
@@ -1310,8 +1297,7 @@ int main(int argc, char *argv[]) do_shutdown =0 ; do_sync =0 ; do_unload =1 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_UNLOAD ; + kexec_file_flags |=KEXEC_FILE_UNLOAD ;break ;case OPT_EXEC : do_load =0 ;
@@ -1354,11 +1340,8 @@ int main(int argc, char *argv[]) do_exec =0 ; do_shutdown =0 ; do_sync =0 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_ON_CRASH ; -else - kexec_flags =KEXEC_ON_CRASH ; -break ; + kexec_file_flags |=KEXEC_FILE_ON_CRASH ; + kexec_flags =KEXEC_ON_CRASH ;case OPT_MEM_MIN : mem_min =strtoul (optarg, &endptr,0 );if (*endptr) {
@@ -1383,7 +1366,7 @@ int main(int argc, char *argv[]) do_reuse_initrd =1 ;break ;case OPT_KEXEC_FILE_SYSCALL : -/* We already parsed it. Nothing to do. */ + do_kexec_file_syscall =1 ;break ;case OPT_STATUS : do_status =1 ;
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 2/5] kexec: do not special-case the -s option
Quoted 34 lines · Michal Suchanek
It is parsed separately to save a few CPU cycles when setting up other options but it just complicates the code. So fold it back and set up all flags both for
KEXEC_LOADandKEXEC_FILE_LOADSigned-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)kexec/kexec.c +0
-13@@ -1256,19 +1256,6 @@ int main(int argc, char *argv[]) };static const char short_options[] =KEXEC_ALL_OPT_STR ; -/* -* First check if --use-kexec-file-syscall is set. That changes lot of -* things -*/ -while ((opt =getopt_long (argc, argv, short_options, - options,0 )) !=-1 ) { -switch (opt) { -case OPT_KEXEC_FILE_SYSCALL : - do_kexec_file_syscall =1 ; -break ; - } - } -/* Reset getopt for the next pass. */ opterr =1 ; optind =1 ;
kexec/kexec.c int main(int argc, char *argv[]) · line 1303
Quoted 9 lines
kexec/kexec.c +1
-2@@ -1310,8 +1297,7 @@ int main(int argc, char *argv[]) do_shutdown =0 ; do_sync =0 ; do_unload =1 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_UNLOAD ; + kexec_file_flags |=KEXEC_FILE_UNLOAD ;break ;case OPT_EXEC : do_load =0 ;
@@ -1354,11 +1340,8 @@ int main(int argc, char *argv[])
The existing code has the following above the context shown in the patch:
do_load = 1;
kexec/kexec.c int main(int argc, char *argv[]) · line 1344
Quoted 10 lines
kexec/kexec.c +2
-5do_exec =0 ; do_shutdown =0 ; do_sync =0 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_ON_CRASH ; -else - kexec_flags =KEXEC_ON_CRASH ; -break ; + kexec_file_flags |=KEXEC_FILE_ON_CRASH ; + kexec_flags =KEXEC_ON_CRASH ;
kexec_flags is now set regardless of the value of do_kexec_file_syscall, which was not the case prior to this patch. That seems to affect the following which appears later in the function. Is that ok?
if (do_load && (kexec_flags & KEXEC_ON_CRASH) &&
!is_crashkernel_mem_reserved()) {
die("Memory for crashkernel is not reserved\n"
"Please reserve memory by passing"
"\"crashkernel=X@Y\" parameter to kernel\n"
"Then try to loading kdump kernel\n");
}
...
if ((result == 0) && do_load_jump_back_helper) {
result = my_load_jump_back_helper(kexec_flags, entry);
}Quoted 15 lines
kexec/kexec.c +1
-1case OPT_MEM_MIN : mem_min =strtoul (optarg, &endptr,0 );if (*endptr) {@@ -1383,7 +1366,7 @@ int main(int argc, char *argv[]) do_reuse_initrd =1 ;break ;case OPT_KEXEC_FILE_SYSCALL : -/* We already parsed it. Nothing to do. */ + do_kexec_file_syscall =1 ;break ;case OPT_STATUS : do_status =1 ;Signature · 1 line
2.13.6
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 2/5] kexec: do not special-case the -s option
Quoted 72 lines · On Thu, 15 Mar 2018 11:38:30 +0100 Simon Horman <[email protected]> wrote:
Quoted 44 lines · Michal Suchanek
It is parsed separately to save a few CPU cycles when setting up other options but it just complicates the code. So fold it back and set up all flags both for
KEXEC_LOADandKEXEC_FILE_LOADSigned-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)kexec/kexec.c +0
-2@@ -1256,19 +1256,6 @@ int main(int argc, char *argv[]) };static const char short_options[] =KEXEC_ALL_OPT_STR ; -/* -* First check if --use-kexec-file-syscall is set. That changes lot of
kexec/kexec.c +1
-13-* things -*/ -while ((opt =getopt_long (argc, argv, short_options, - options,0 )) !=-1 ) { -switch (opt) { -case OPT_KEXEC_FILE_SYSCALL : - do_kexec_file_syscall =1 ; -break ; - } - } -/* Reset getopt for the next pass. */ opterr =1 ; optind =1 ;@@ -1310,8 +1297,7 @@ int main(int argc, char *argv[]) do_shutdown =0 ; do_sync =0 ; do_unload =1 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_UNLOAD ; + kexec_file_flags |=KEXEC_FILE_UNLOAD ;break ;case OPT_EXEC :Quoted 1 line
do_load= 0;@@ -1354,11 +1340,8 @@ int
main(int argc, char *argv[])The existing code has the following above the context shown in the
patch:do_load = 1;kexec/kexec.c int main(int argc, char *argv[]) · line 1344
Quoted 11 lines
kexec/kexec.c +0
-2do_exec =0 ; do_shutdown =0 ; do_sync =0 ; -if (do_kexec_file_syscall) - kexec_file_flags |=
KEXEC_FILE_ON_CRASH;kexec/kexec.c +2
-3-else - kexec_flags =KEXEC_ON_CRASH ; -break ; + kexec_file_flags |=KEXEC_FILE_ON_CRASH ; + kexec_flags =KEXEC_ON_CRASH ;
kexec_flagsis now set regardless of the value ofdo_kexec_file_syscall, which was not the case prior to this patch. That seems to affect the following which appears later in the function. Is that ok?
Quoted 7 lines
if (do_load && (kexec_flags & KEXEC_ON_CRASH) &&
!is_crashkernel_mem_reserved()) {
die("Memory for crashkernel is not reserved\n"
"Please reserve memory by passing"
"\"crashkernel=X@Y\" parameter to kernel\n"
"Then try to loading kdump kernel\n");
}Do you not need memory for kexec -s? This looks broken to start with.
Quoted 4 lines
...
if ((result == 0) && do_load_jump_back_helper) {And yes, this should not be allowed with -s
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 2/5] kexec: do not special-case the -s option
Quoted 83 lines · Michal Suchánek
Quoted 72 lines · On Thu, 15 Mar 2018 11:38:30 +0100 Simon Horman <[email protected]> wrote:
Quoted 44 lines · Michal Suchanek
It is parsed separately to save a few CPU cycles when setting up other options but it just complicates the code. So fold it back and set up all flags both for
KEXEC_LOADandKEXEC_FILE_LOADSigned-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)kexec/kexec.c +0
-2@@ -1256,19 +1256,6 @@ int main(int argc, char *argv[]) };static const char short_options[] =KEXEC_ALL_OPT_STR ; -/* -* First check if --use-kexec-file-syscall is set. That changes lot of
kexec/kexec.c +1
-13-* things -*/ -while ((opt =getopt_long (argc, argv, short_options, - options,0 )) !=-1 ) { -switch (opt) { -case OPT_KEXEC_FILE_SYSCALL : - do_kexec_file_syscall =1 ; -break ; - } - } -/* Reset getopt for the next pass. */ opterr =1 ; optind =1 ;@@ -1310,8 +1297,7 @@ int main(int argc, char *argv[]) do_shutdown =0 ; do_sync =0 ; do_unload =1 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_UNLOAD ; + kexec_file_flags |=KEXEC_FILE_UNLOAD ;break ;case OPT_EXEC :Quoted 1 line
do_load= 0;@@ -1354,11 +1340,8 @@ int
main(int argc, char *argv[])The existing code has the following above the context shown in the
patch:do_load = 1;kexec/kexec.c int main(int argc, char *argv[]) · line 1344
Quoted 11 lines
kexec/kexec.c +0
-2do_exec =0 ; do_shutdown =0 ; do_sync =0 ; -if (do_kexec_file_syscall) - kexec_file_flags |=
KEXEC_FILE_ON_CRASH;kexec/kexec.c +2
-3-else - kexec_flags =KEXEC_ON_CRASH ; -break ; + kexec_file_flags |=KEXEC_FILE_ON_CRASH ; + kexec_flags =KEXEC_ON_CRASH ;
kexec_flagsis now set regardless of the value ofdo_kexec_file_syscall, which was not the case prior to this patch. That seems to affect the following which appears later in the function. Is that ok?Quoted 7 lines
if (do_load && (kexec_flags & KEXEC_ON_CRASH) && !is_crashkernel_mem_reserved()) { die("Memory for crashkernel is not reserved\n" "Please reserve memory by passing" "\"crashkernel=X@Y\" parameter to kernel\n" "Then try to loading kdump kernel\n"); }
Quoted 1 line
Do you not need memory for kexec -s? This looks broken to start with.
Could you propose a fix? I realise your patchset may not introduce this problem. But it seems to me that it makes things slightly worse or at the very least perpetuates the notion that the above is correct.
Quoted 5 lines
Quoted 3 lines
... if ((result == 0) && do_load_jump_back_helper) {And yes, this should not be allowed with -s
Is the simple fix here for your patch to add an extra condition to the if statement above?
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 2/5] kexec: do not special-case the -s option
Quoted 14 lines · On Fri, 16 Mar 2018 12:20:25 +0100 Simon Horman <[email protected]> wrote:
Quoted 13 lines · Michal Suchánek
Quoted 9 lines · On Thu, 15 Mar 2018 11:38:30 +0100 Simon Horman <[email protected]> wrote:
if (do_load && (kexec_flags & KEXEC_ON_CRASH) && !is_crashkernel_mem_reserved()) { die("Memory for crashkernel is not reserved\n" "Please reserve memory by passing" "\"crashkernel=X@Y\" parameter to kernel\n" "Then try to loading kdump kernel\n"); }
Quoted 6 lines
Quoted 2 lines
Do you not need memory for kexec -s? This looks broken to start with.
Could you propose a fix? I realise your patchset may not introduce this problem. But it seems to me that it makes things slightly worse or at the very least perpetuates the notion that the above is correct.
Yes, it makes sense to fix the condition.
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
... if ((result == 0) && do_load_jump_back_helper) {And yes, this should not be allowed with -s
Is the simple fix here for your patch to add an extra condition to the if statement above?
This is not supported with -s but nothing prevents setting the flag. So a test for kexec_load should be added I guess.
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 2/5] kexec: do not special-case the -s option
Quoted 17 lines · Michal Suchánek
Quoted 14 lines · On Fri, 16 Mar 2018 12:20:25 +0100 Simon Horman <[email protected]> wrote:
Quoted 13 lines · Michal Suchánek
Quoted 9 lines · On Thu, 15 Mar 2018 11:38:30 +0100 Simon Horman <[email protected]> wrote:
if (do_load && (kexec_flags & KEXEC_ON_CRASH) && !is_crashkernel_mem_reserved()) { die("Memory for crashkernel is not reserved\n" "Please reserve memory by passing" "\"crashkernel=X@Y\" parameter to kernel\n" "Then try to loading kdump kernel\n"); }
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Do you not need memory for kexec -s? This looks broken to start with.
Could you propose a fix? I realise your patchset may not introduce this problem. But it seems to me that it makes things slightly worse or at the very least perpetuates the notion that the above is correct.
Yes, it makes sense to fix the condition.
Thanks.
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
... if ((result == 0) && do_load_jump_back_helper) {And yes, this should not be allowed with -s
Is the simple fix here for your patch to add an extra condition to the if statement above?
This is not supported with -s but nothing prevents setting the flag. So a test for
kexec_loadshould be added I guess.
That is what I was thinking too.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v5 1/5 kexec: Return -ENOSYS when kexec does not know how to call KEXEC_FILE_LOAD
When the kernel does not know a syscall number it returns -ENOSYS but when kexec does not know a syscall number it returns -1. Return -ENOSYS from kexec as well.
--- kexec/kexec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kexec/kexec.c +1 -1
@@ -1166,7 +1166,7 @@ static int do_kexec_file_load(int fileind, int argc, char **argv,if (!is_kexec_file_load_implemented ()) {fprintf (stderr,"syscall kexec_file_load not available.\n" ); -return -1 ; +return -ENOSYS ; }if (argc - fileind <=0 ) {
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v5 2/5 kexec: Fix option checks to take KEXEC_FILE_LOAD into account
When kexec_file_load support was added some sanity checks were not updated.
Some options are set only in the kexec_load flags so cannot be supported wiht kexec_file_load. On the other hand, reserved memory is needed for kdump with both kexec_load and kexec_file_load.
--- kexec/kexec.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
kexec/kexec.c +9 -1
@@ -1415,7 +1415,9 @@ int main(int argc, char *argv[]) do_load_jump_back_helper =0 ; } -if (do_load && (kexec_flags &KEXEC_ON_CRASH ) && +if (do_load && + ((kexec_flags &KEXEC_ON_CRASH ) || + (kexec_file_flags &KEXEC_FILE_ON_CRASH )) && !is_crashkernel_mem_reserved ()) {die ("Memory for crashkernel is not reserved\n" "Please reserve memory by passing"
@@ -1447,6 +1449,12 @@ int main(int argc, char *argv[]) } } } +if (do_kexec_file_syscall) { +if (do_load_jump_back_helper) +die ("--load-jump-back-helper not supported with kexec_file_load\n" ); +if (kexec_flags &KEXEC_PRESERVE_CONTEXT ) +die ("--load-preserve-context not supported with kexec_file_load\n" ); + }if (do_reuse_initrd){check_reuse_initrd ();
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v5 3/5 kexec: Do not special-case the -s option
In reply to Michal SuchanekIt is parsed separately to save a few CPU cycles when setting up other options but it just complicates the code. So fold it back and set up all flags both for KEXEC_LOAD and KEXEC_FILE_LOAD
--- kexec/kexec.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)
kexec/kexec.c +4 -21
@@ -1256,19 +1256,6 @@ int main(int argc, char *argv[]) };static const char short_options[] =KEXEC_ALL_OPT_STR ; -/* -* First check if --use-kexec-file-syscall is set. That changes lot of -* things -*/ -while ((opt =getopt_long (argc, argv, short_options, - options,0 )) !=-1 ) { -switch (opt) { -case OPT_KEXEC_FILE_SYSCALL : - do_kexec_file_syscall =1 ; -break ; - } - } -/* Reset getopt for the next pass. */ opterr =1 ; optind =1 ;
@@ -1310,8 +1297,7 @@ int main(int argc, char *argv[]) do_shutdown =0 ; do_sync =0 ; do_unload =1 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_UNLOAD ; + kexec_file_flags |=KEXEC_FILE_UNLOAD ;break ;case OPT_EXEC : do_load =0 ;
@@ -1354,11 +1340,8 @@ int main(int argc, char *argv[]) do_exec =0 ; do_shutdown =0 ; do_sync =0 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_ON_CRASH ; -else - kexec_flags =KEXEC_ON_CRASH ; -break ; + kexec_file_flags |=KEXEC_FILE_ON_CRASH ; + kexec_flags =KEXEC_ON_CRASH ;case OPT_MEM_MIN : mem_min =strtoul (optarg, &endptr,0 );if (*endptr) {
@@ -1383,7 +1366,7 @@ int main(int argc, char *argv[]) do_reuse_initrd =1 ;break ;case OPT_KEXEC_FILE_SYSCALL : -/* We already parsed it. Nothing to do. */ + do_kexec_file_syscall =1 ;break ;case OPT_STATUS : do_status =1 ;
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v5 4/5 kexec: Add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported
In reply to Michal SuchanekNot all architectures implement KEXEC_FILE_LOAD. However, on some archiectures KEXEC_FILE_LOAD is required when secure boot is enabled in locked-down mode. Previously users had to select the KEXEC_FILE_LOAD syscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.
So add an -a option that tries KEXEC_FILE_LOAD and when it is not supported tries KEXEC_LOAD.
---
v3: instead of changing the deafult add extra option
v4: actually check -ENOSYS as well
v5: add missing break
--- kexec/kexec.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- kexec/kexec.h | 6 +++++- 2 files changed, 58 insertions(+), 6 deletions(-)
kexec/kexec.c +53 -5
@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =0 ;int do_status =0 ;void *entry =0 ;char *type =0 ;
@@ -1367,6 +1368,15 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ; +break ; +case OPT_KEXEC_SYSCALL : + do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ; +break ; +case OPT_KEXEC_SYSCALL_AUTO : + do_kexec_file_syscall =1 ; + do_kexec_fallback =1 ;break ;case OPT_STATUS : do_status =1 ;
@@ -1433,7 +1443,7 @@ int main(int argc, char *argv[]) } }if (do_kexec_file_syscall) { -if (do_load_jump_back_helper) +if (do_load_jump_back_helper && !do_kexec_fallback)die ("--load-jump-back-helper not supported with kexec_file_load\n" );if (kexec_flags &KEXEC_PRESERVE_CONTEXT )die ("--load-preserve-context not supported with kexec_file_load\n" );
@@ -1447,16 +1457,54 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification. +* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +/* +* By default reject or do nothing if +* succeded +*/ +default :break ; +case -ENOSYS :/* not implemented */ +/* +* Parsing image or other options failed +* The image may be invalid or image +* type may not supported by kernel so +* retry parsing in kexec-tools. +*/ +case -EINVAL : +case -ENOEXEC : +/* +* ENOTSUPP can be unsupported image +* type or unsupported PE signature +* wrapper type, duh +*/ +case -ENOTSUP : + do_kexec_file_syscall =0 ; +break ; + } + } +if (!do_kexec_file_syscall) result =my_load (type, fileind, argc, argv, kexec_flags, entry); }
kexec/kexec.h +5 -1
@@ -219,6 +219,8 @@ extern int file_types;#define OPT_TYPE 't'#define OPT_PANIC 'p'#define OPT_KEXEC_FILE_SYSCALL 's' +#define OPT_KEXEC_SYSCALL 'c' +#define OPT_KEXEC_SYSCALL_AUTO 'a'#define OPT_STATUS 'S'#define OPT_MEM_MIN 256#define OPT_MEM_MAX 257
@@ -246,11 +248,13 @@ extern int file_types; { "mem-max", 1, 0, OPT_MEM_MAX }, \ { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ + { "kexec-syscall", 0, 0, OPT_KEXEC_SYSCALL }, \ + { "kexec-syscall-auto", 0, 0, OPT_KEXEC_SYSCALL_AUTO }, \ { "debug", 0, 0, OPT_DEBUG }, \ { "status", 0, 0, OPT_STATUS }, \ { "print-ckr-size", 0, 0, OPT_PRINT_CKR_SIZE }, \ -#define KEXEC_OPT_STR "h?vdfxyluet:psS" +#define KEXEC_OPT_STR "h?vdfxyluet:pscaS" extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);extern void die (const char *fmt, ...)
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 4/5] kexec: Add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported
Quoted 97 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.So add an -a option that tries
KEXEC_FILE_LOADand when it is not supported triesKEXEC_LOAD.Signed-off-by Michal Suchanek <[email protected]>---
v3: instead of changing the deafult add extra option
v4: actually check-ENOSYSas well
v5: add missing break--- kexec/kexec.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- kexec/kexec.h | 6 +++++- 2 files changed, 58 insertions(+), 6 deletions(-)kexec/kexec.c +38
-5@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =0 ;int do_status =0 ;void *entry =0 ;char *type =0 ;@@ -1367,6 +1368,15 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ; +break ; +case OPT_KEXEC_SYSCALL : + do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ; +break ; +case OPT_KEXEC_SYSCALL_AUTO : + do_kexec_file_syscall =1 ; + do_kexec_fallback =1 ;break ;case OPT_STATUS : do_status =1 ;@@ -1433,7 +1443,7 @@ int main(int argc, char *argv[]) } }if (do_kexec_file_syscall) { -if (do_load_jump_back_helper) +if (do_load_jump_back_helper && !do_kexec_fallback)die ("--load-jump-back-helper not supported with kexec_file_load\n" );if (kexec_flags &KEXEC_PRESERVE_CONTEXT )die ("--load-preserve-context not supported with kexec_file_load\n" );@@ -1447,16 +1457,54 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification. +* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +/* +* By default reject or do nothing if +* succeded +*/ +default :break ; +case -ENOSYS :/* not implemented */ +/* +* Parsing image or other options failed +* The image may be invalid or image +* type may not supported by kernel so
kexec/kexec.c int main(int argc, char *argv[]) · line 1502
Quoted 10 lines
kexec/kexec.c +10
-0+* retry parsing in kexec-tools. +*/ +case -EINVAL : +case -ENOEXEC : +/* +* ENOTSUPP can be unsupported image +* type or unsupported PE signature +* wrapper type, duh +*/ +case -ENOTSUP :
Hmm, this is still used in latest version. kernel does not return such error number, I might not say clearly previously. Please check the kernel code, the only one place I know is because no kdump support in power kexec_file:arch/powerpc/kernel/machine_kexec_file_64.c
/* We don't support crash kernels yet. */
if (image->type == KEXEC_TYPE_CRASH)
return -ENOTSUPP;So I suggest not checking this as well since -ENOTSUPP is not populated in userspace headers, and -ENOTSUP is not used at all.
Also as I mentioned in another reply -EINVAL and -ENOEXEC is also not ncessary.
For -ENOTSUP, maybe someone can submit a patch to switch to -ENOTSUPP so that userspace can check it.
Ccing Thiago and Hari for the -ENOTSUPP errno issue.
Quoted 44 lines
kexec/kexec.c +5
-0+ do_kexec_file_syscall =0 ; +break ; + } + } +if (!do_kexec_file_syscall) result =my_load (type, fileind, argc, argv, kexec_flags, entry); }kexec/kexec.h +5
-1@@ -219,6 +219,8 @@ extern int file_types;#define OPT_TYPE 't'#define OPT_PANIC 'p'#define OPT_KEXEC_FILE_SYSCALL 's' +#define OPT_KEXEC_SYSCALL 'c' +#define OPT_KEXEC_SYSCALL_AUTO 'a'#define OPT_STATUS 'S'#define OPT_MEM_MIN 256#define OPT_MEM_MAX 257@@ -246,11 +248,13 @@ extern int file_types; { "mem-max", 1, 0, OPT_MEM_MAX }, \ { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ + { "kexec-syscall", 0, 0, OPT_KEXEC_SYSCALL }, \ + { "kexec-syscall-auto", 0, 0, OPT_KEXEC_SYSCALL_AUTO }, \ { "debug", 0, 0, OPT_DEBUG }, \ { "status", 0, 0, OPT_STATUS }, \ { "print-ckr-size", 0, 0, OPT_PRINT_CKR_SIZE }, \ -#define KEXEC_OPT_STR "h?vdfxyluet:psS" +#define KEXEC_OPT_STR "h?vdfxyluet:pscaS" extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);extern void die (const char *fmt, ...)Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 4/5] kexec: Add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported
Quoted 122 lines · Dave Young
Quoted 97 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.So add an -a option that tries
KEXEC_FILE_LOADand when it is not supported triesKEXEC_LOAD.Signed-off-by Michal Suchanek <[email protected]>---
v3: instead of changing the deafult add extra option
v4: actually check-ENOSYSas well
v5: add missing break--- kexec/kexec.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- kexec/kexec.h | 6 +++++- 2 files changed, 58 insertions(+), 6 deletions(-)kexec/kexec.c +38
-5@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =0 ;int do_status =0 ;void *entry =0 ;char *type =0 ;@@ -1367,6 +1368,15 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ; +break ; +case OPT_KEXEC_SYSCALL : + do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ; +break ; +case OPT_KEXEC_SYSCALL_AUTO : + do_kexec_file_syscall =1 ; + do_kexec_fallback =1 ;break ;case OPT_STATUS : do_status =1 ;@@ -1433,7 +1443,7 @@ int main(int argc, char *argv[]) } }if (do_kexec_file_syscall) { -if (do_load_jump_back_helper) +if (do_load_jump_back_helper && !do_kexec_fallback)die ("--load-jump-back-helper not supported with kexec_file_load\n" );if (kexec_flags &KEXEC_PRESERVE_CONTEXT )die ("--load-preserve-context not supported with kexec_file_load\n" );@@ -1447,16 +1457,54 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification. +* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +/* +* By default reject or do nothing if +* succeded +*/ +default :break ; +case -ENOSYS :/* not implemented */ +/* +* Parsing image or other options failed +* The image may be invalid or image +* type may not supported by kernel so kexec/kexec.c int main(int argc, char *argv[]) · line 1502
Quoted 10 lines
kexec/kexec.c +10
-0+* retry parsing in kexec-tools. +*/ +case -EINVAL : +case -ENOEXEC : +/* +* ENOTSUPP can be unsupported image +* type or unsupported PE signature +* wrapper type, duh +*/ +case -ENOTSUP :Hmm, this is still used in latest version. kernel does not return such error number, I might not say clearly previously. Please check the kernel code, the only one place I know is because no kdump support in power
kexec_file:arch/powerpc/kernel/machine_kexec_file_64.c/* We don't support crash kernels yet. */ if (image->type == KEXEC_TYPE_CRASH) return -ENOTSUPP;So I suggest not checking this as well since
-ENOTSUPPis not populated in userspace headers, and-ENOTSUPis not used at all.
Quoted 6 lines
Also as I mentioned in another reply
-EINVALand-ENOEXECis also not ncessary.For
-ENOTSUP, maybe someone can submit a patch to switch to-ENOTSUPPso that userspace can check it.
Ccing Thiago and Hari for the-ENOTSUPPerrno issue.
Oops for the hurry reply, I means -ENOTSUPP might be able to replaced with -EOPNOTSUPP, a similar change like this:
https://patchwork.kernel.org/patch/8490791/
Quoted 41 lines
Quoted 41 lines
kexec/kexec.c +5
-0+ do_kexec_file_syscall =0 ; +break ; + } + } +if (!do_kexec_file_syscall) result =my_load (type, fileind, argc, argv, kexec_flags, entry); }kexec/kexec.h +5
-1@@ -219,6 +219,8 @@ extern int file_types;#define OPT_TYPE 't'#define OPT_PANIC 'p'#define OPT_KEXEC_FILE_SYSCALL 's' +#define OPT_KEXEC_SYSCALL 'c' +#define OPT_KEXEC_SYSCALL_AUTO 'a'#define OPT_STATUS 'S'#define OPT_MEM_MIN 256#define OPT_MEM_MAX 257@@ -246,11 +248,13 @@ extern int file_types; { "mem-max", 1, 0, OPT_MEM_MAX }, \ { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ + { "kexec-syscall", 0, 0, OPT_KEXEC_SYSCALL }, \ + { "kexec-syscall-auto", 0, 0, OPT_KEXEC_SYSCALL_AUTO }, \ { "debug", 0, 0, OPT_DEBUG }, \ { "status", 0, 0, OPT_STATUS }, \ { "print-ckr-size", 0, 0, OPT_PRINT_CKR_SIZE }, \ -#define KEXEC_OPT_STR "h?vdfxyluet:psS" +#define KEXEC_OPT_STR "h?vdfxyluet:pscaS" extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);extern void die (const char *fmt, ...)Signature · 1 line
2.13.6
Quoted 7 lines
Quoted 4 lines
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexecThanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 4/5] kexec: Add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported
Quoted 139 lines · On Mon, 26 Mar 2018 17:12:10 +0800 Dave Young <[email protected]> wrote:
Quoted 138 lines · Dave Young
Quoted 117 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.So add an -a option that tries
KEXEC_FILE_LOADand when it is not supported triesKEXEC_LOAD.Signed-off-by Michal Suchanek <[email protected]>---
v3: instead of changing the deafult add extra option
v4: actually check-ENOSYSas well
v5: add missing break--- kexec/kexec.c | 58+++++++++++++++++++++++++++++++++++++++++++++++++++++-----
kexec/kexec.h| 6 +++++- 2 files changed, 58 insertions(+), 6 deletions(-)kexec/kexec.c +11
-1@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =0 ;int do_status =0 ;void *entry =0 ;char *type =0 ;@@ -1367,6 +1368,15 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ; +break ; +case OPT_KEXEC_SYSCALL : + do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ; +break ; +case OPT_KEXEC_SYSCALL_AUTO : + do_kexec_file_syscall =1 ; + do_kexec_fallback =1 ;break ;case OPT_STATUS : do_status =1 ;@@ -1433,7 +1443,7 @@ int main(int argc, char *argv[]) } }if (do_kexec_file_syscall) { -if (do_load_jump_back_helper) + if (do_load_jump_back_helper&& !do_kexec_fallback)
die("--load-jump-back-helper not supported with kexec_file_load\n"); if (kexec_flags&KEXEC_PRESERVE_CONTEXT)die("--load-preserve-context not supported with kexec_file_load\n"); @@ -1447,16 +1457,54 @@ intmain(int argc, char *argv[])result =k_status(kexec_flags);kexec/kexec.c +1
-1}if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =
kexec_file_unload(kexec_file_flags);kexec/kexec.c +1
-1-else + if ((result == -ENOSYS) &&
do_kexec_fallback)kexec/kexec.c +4
-1+ do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result = do_kexec_file_load(fileind,argc, argv,
kexec_file_flags);kexec/kexec.c +3
-1-else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification.
kexec/kexec.c +10
-0+* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +/* +* By default reject or do nothing if
kexec/kexec.c +4
-0+* succeded +*/ +default :break ; +case -ENOSYS :/* not implemented */
kexec/kexec.c +2
-0+/* +* Parsing image or other options failed
kexec/kexec.c +1
-0+* The image may be invalid or image
kexec/kexec.c +1
-0+* type may not supported by kernel so
kexec/kexec.c +1
-0+* retry parsing in kexec-tools.
kexec/kexec.c +5
-0+*/ +case -EINVAL : +case -ENOEXEC : +/* +* ENOTSUPP can be unsupported image
kexec/kexec.c +1
-0+* type or unsupported PE signature
kexec/kexec.c int main(int argc, char *argv[]) · line 1502
Quoted 3 lines
kexec/kexec.c +3
-0+* wrapper type, duh +*/ +case -ENOTSUP :Hmm, this is still used in latest version. kernel does not return such error number, I might not say clearly previously. Please check the kernel code, the only one place I know is because no kdump support in power
kexec_file:arch/powerpc/kernel/machine_kexec_file_64.c/* We don't support crash kernels yet. */ if (image->type == KEXEC_TYPE_CRASH) return -ENOTSUPP;So I suggest not checking this as well since
-ENOTSUPPis not populated in userspace headers, and-ENOTSUPis not used at all.Also as I mentioned in another reply
-EINVALand-ENOEXECis also not ncessary.
Quoted 7 lines
Quoted 3 lines
For
-ENOTSUP, maybe someone can submit a patch to switch to-ENOTSUPPso that userspace can check it.
Ccing Thiago and Hari for the-ENOTSUPPerrno issue.Oops for the hurry reply, I means
-ENOTSUPPmight be able to replaced with-EOPNOTSUPP, a similar change like this:
https://patchwork.kernel.org/patch/8490791/
Thanks for catching this. In Linux ENOTSUPP with extra P is different from EOPNOTSUPP and ENOTSUP (single P). Since we are talking to the kernel and it returns the double P ENOTSUPP we need to define it in kexec as well. And we should check ENOTSUP with single P in case somebody some day thinks that returning undefined error codes to userspace is not nice like in the patch above.
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 4/5] kexec: Add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported
Quoted 150 lines · Michal Suchánek
Quoted 139 lines · On Mon, 26 Mar 2018 17:12:10 +0800 Dave Young <[email protected]> wrote:
Quoted 138 lines · Dave Young
Quoted 117 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.So add an -a option that tries
KEXEC_FILE_LOADand when it is not supported triesKEXEC_LOAD.Signed-off-by Michal Suchanek <[email protected]>---
v3: instead of changing the deafult add extra option
v4: actually check-ENOSYSas well
v5: add missing break--- kexec/kexec.c | 58+++++++++++++++++++++++++++++++++++++++++++++++++++++-----
kexec/kexec.h| 6 +++++- 2 files changed, 58 insertions(+), 6 deletions(-)kexec/kexec.c +11
-1@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =0 ;int do_status =0 ;void *entry =0 ;char *type =0 ;@@ -1367,6 +1368,15 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ; +break ; +case OPT_KEXEC_SYSCALL : + do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ; +break ; +case OPT_KEXEC_SYSCALL_AUTO : + do_kexec_file_syscall =1 ; + do_kexec_fallback =1 ;break ;case OPT_STATUS : do_status =1 ;@@ -1433,7 +1443,7 @@ int main(int argc, char *argv[]) } }if (do_kexec_file_syscall) { -if (do_load_jump_back_helper) + if (do_load_jump_back_helper&& !do_kexec_fallback)
die("--load-jump-back-helper not supported with kexec_file_load\n"); if (kexec_flags&KEXEC_PRESERVE_CONTEXT)die("--load-preserve-context not supported with kexec_file_load\n"); @@ -1447,16 +1457,54 @@ intmain(int argc, char *argv[])result =k_status(kexec_flags);kexec/kexec.c +1
-1}if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =
kexec_file_unload(kexec_file_flags);kexec/kexec.c +1
-1-else + if ((result == -ENOSYS) &&
do_kexec_fallback)kexec/kexec.c +4
-1+ do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result = do_kexec_file_load(fileind,argc, argv,
kexec_file_flags);kexec/kexec.c +3
-1-else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification.
kexec/kexec.c +10
-0+* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +/* +* By default reject or do nothing if
kexec/kexec.c +4
-0+* succeded +*/ +default :break ; +case -ENOSYS :/* not implemented */
kexec/kexec.c +2
-0+/* +* Parsing image or other options failed
kexec/kexec.c +1
-0+* The image may be invalid or image
kexec/kexec.c +1
-0+* type may not supported by kernel so
kexec/kexec.c +1
-0+* retry parsing in kexec-tools.
kexec/kexec.c +5
-0+*/ +case -EINVAL : +case -ENOEXEC : +/* +* ENOTSUPP can be unsupported image
kexec/kexec.c +1
-0+* type or unsupported PE signature
kexec/kexec.c int main(int argc, char *argv[]) · line 1502
Quoted 3 lines
kexec/kexec.c +3
-0+* wrapper type, duh +*/ +case -ENOTSUP :Hmm, this is still used in latest version. kernel does not return such error number, I might not say clearly previously. Please check the kernel code, the only one place I know is because no kdump support in power
kexec_file:arch/powerpc/kernel/machine_kexec_file_64.c/* We don't support crash kernels yet. */ if (image->type == KEXEC_TYPE_CRASH) return -ENOTSUPP;So I suggest not checking this as well since
-ENOTSUPPis not populated in userspace headers, and-ENOTSUPis not used at all.Also as I mentioned in another reply
-EINVALand-ENOEXECis also not ncessary.Quoted 7 lines
Quoted 3 lines
For
-ENOTSUP, maybe someone can submit a patch to switch to-ENOTSUPPso that userspace can check it.
Ccing Thiago and Hari for the-ENOTSUPPerrno issue.Oops for the hurry reply, I means
-ENOTSUPPmight be able to replaced with-EOPNOTSUPP, a similar change like this:
https://patchwork.kernel.org/patch/8490791/
Quoted 6 lines
Thanks for catching this. In Linux ENOTSUPP with extra P is different from EOPNOTSUPP and ENOTSUP (single P). Since we are talking to the kernel and it returns the double P ENOTSUPP we need to define it in kexec as well. And we should check ENOTSUP with single P in case somebody some day thinks that returning undefined error codes to userspace is not nice like in the patch above.
I wasn't aware that ENOTSUPP was an in-kernel only errno. Should I submit a patch for the kernel so that powerpc returns -EOPNOTSUPP in case of trying to load kdump kernel with kexec_file_load()?
Signature · 8 lines
Thiago Jung Bauermann IBM Linux Technology Center _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 4/5] kexec: Add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported
Quoted 21 lines · On Mon, 26 Mar 2018 15:52:39 -0300 Thiago Jung Bauermann…
Quoted 19 lines · Michal Suchánek
Quoted 16 lines · On Mon, 26 Mar 2018 17:12:10 +0800 Dave Young <[email protected]> wrote:
Quoted 15 lines · Dave Young
On 03/20/18 at 04:56pm, Michal Suchanek wrote:
Hmm, this is still used in latest version. kernel does not return such error number, I might not say clearly previously. Please check the kernel code, the only one place I know is because no kdump support in power
kexec_file:arch/powerpc/kernel/machine_kexec_file_64.c/* We don't support crash kernels yet. */ if (image->type == KEXEC_TYPE_CRASH) return -ENOTSUPP;So I suggest not checking this as well since
-ENOTSUPPis not populated in userspace headers, and-ENOTSUPis not used at all.
...
Quoted 15 lines
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
For
-ENOTSUP, maybe someone can submit a patch to switch to-ENOTSUPPso that userspace can check it.
Ccing Thiago and Hari for the-ENOTSUPPerrno issue.Oops for the hurry reply, I means
-ENOTSUPPmight be able to replaced with-EOPNOTSUPP, a similar change like this:
https://patchwork.kernel.org/patch/8490791/Quoted 6 lines
Thanks for catching this. In Linux ENOTSUPP with extra P is different from EOPNOTSUPP and ENOTSUP (single P). Since we are talking to the kernel and it returns the double P ENOTSUPP we need to define it in kexec as well. And we should check ENOTSUP with single P in case somebody some day thinks that returning undefined error codes to userspace is not nice like in the patch above.
Quoted 4 lines
I wasn't aware that ENOTSUPP was an in-kernel only errno. Should I submit a patch for the kernel so that powerpc returns
-EOPNOTSUPPin case of trying to load kdump kernel withkexec_file_load()?
It does not help us much because we need to support kernels without the patch as well. In the long run it might be nice to eliminate the return value in user-facing functions. But it's difficult to tell which functions are user-facing. The return value can be forwarded quite a few times before it reaches the user.
This is far from the only place returning this error code to userspace. I wonder what was the reason for introducing this error code in the first place.
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 4/5] kexec: Add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported
In reply to Thiago Jung BauermannQuoted 160 lines · Thiago Jung Bauermann
Quoted 150 lines · Michal Suchánek
Quoted 139 lines · On Mon, 26 Mar 2018 17:12:10 +0800 Dave Young <[email protected]> wrote:
Quoted 138 lines · Dave Young
Quoted 117 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.So add an -a option that tries
KEXEC_FILE_LOADand when it is not supported triesKEXEC_LOAD.Signed-off-by Michal Suchanek <[email protected]>---
v3: instead of changing the deafult add extra option
v4: actually check-ENOSYSas well
v5: add missing break--- kexec/kexec.c | 58+++++++++++++++++++++++++++++++++++++++++++++++++++++-----
kexec/kexec.h| 6 +++++- 2 files changed, 58 insertions(+), 6 deletions(-)kexec/kexec.c +11
-1@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =0 ;int do_status =0 ;void *entry =0 ;char *type =0 ;@@ -1367,6 +1368,15 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ; +break ; +case OPT_KEXEC_SYSCALL : + do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ; +break ; +case OPT_KEXEC_SYSCALL_AUTO : + do_kexec_file_syscall =1 ; + do_kexec_fallback =1 ;break ;case OPT_STATUS : do_status =1 ;@@ -1433,7 +1443,7 @@ int main(int argc, char *argv[]) } }if (do_kexec_file_syscall) { -if (do_load_jump_back_helper) + if (do_load_jump_back_helper&& !do_kexec_fallback)
die("--load-jump-back-helper not supported with kexec_file_load\n"); if (kexec_flags&KEXEC_PRESERVE_CONTEXT)die("--load-preserve-context not supported with kexec_file_load\n"); @@ -1447,16 +1457,54 @@ intmain(int argc, char *argv[])result =k_status(kexec_flags);kexec/kexec.c +1
-1}if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =
kexec_file_unload(kexec_file_flags);kexec/kexec.c +1
-1-else + if ((result == -ENOSYS) &&
do_kexec_fallback)kexec/kexec.c +4
-1+ do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result = do_kexec_file_load(fileind,argc, argv,
kexec_file_flags);kexec/kexec.c +3
-1-else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification.
kexec/kexec.c +10
-0+* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +/* +* By default reject or do nothing if
kexec/kexec.c +4
-0+* succeded +*/ +default :break ; +case -ENOSYS :/* not implemented */
kexec/kexec.c +2
-0+/* +* Parsing image or other options failed
kexec/kexec.c +1
-0+* The image may be invalid or image
kexec/kexec.c +1
-0+* type may not supported by kernel so
kexec/kexec.c +1
-0+* retry parsing in kexec-tools.
kexec/kexec.c +5
-0+*/ +case -EINVAL : +case -ENOEXEC : +/* +* ENOTSUPP can be unsupported image
kexec/kexec.c +1
-0+* type or unsupported PE signature
kexec/kexec.c int main(int argc, char *argv[]) · line 1502
Quoted 3 lines
kexec/kexec.c +3
-0+* wrapper type, duh +*/ +case -ENOTSUP :Hmm, this is still used in latest version. kernel does not return such error number, I might not say clearly previously. Please check the kernel code, the only one place I know is because no kdump support in power
kexec_file:arch/powerpc/kernel/machine_kexec_file_64.c/* We don't support crash kernels yet. */ if (image->type == KEXEC_TYPE_CRASH) return -ENOTSUPP;So I suggest not checking this as well since
-ENOTSUPPis not populated in userspace headers, and-ENOTSUPis not used at all.Also as I mentioned in another reply
-EINVALand-ENOEXECis also not ncessary.Quoted 7 lines
Quoted 3 lines
For
-ENOTSUP, maybe someone can submit a patch to switch to-ENOTSUPPso that userspace can check it.
Ccing Thiago and Hari for the-ENOTSUPPerrno issue.Oops for the hurry reply, I means
-ENOTSUPPmight be able to replaced with-EOPNOTSUPP, a similar change like this:
https://patchwork.kernel.org/patch/8490791/Quoted 6 lines
Thanks for catching this. In Linux ENOTSUPP with extra P is different from EOPNOTSUPP and ENOTSUP (single P). Since we are talking to the kernel and it returns the double P ENOTSUPP we need to define it in kexec as well. And we should check ENOTSUP with single P in case somebody some day thinks that returning undefined error codes to userspace is not nice like in the patch above.
Quoted 3 lines
I wasn't aware that ENOTSUPP was an in-kernel only errno. Should I submit a patch for the kernel so that powerpc returns
-EOPNOTSUPPin case of trying to load kdump kernel withkexec_file_load()?
This should be the easiest way and worth a try since userspace check it now.
Quoted 5 lines
Signature · 3 lines
-- Thiago Jung Bauermann IBM Linux Technology Center
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v6 1/5 kexec: Return -ENOSYS when kexec does not know how to call KEXEC_FILE_LOAD
When the kernel does not know a syscall number it returns -ENOSYS but when kexec does not know a syscall number it returns -1. Return -ENOSYS from kexec as well.
--- kexec/kexec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kexec/kexec.c +1 -1
@@ -1166,7 +1166,7 @@ static int do_kexec_file_load(int fileind, int argc, char **argv,if (!is_kexec_file_load_implemented ()) {fprintf (stderr,"syscall kexec_file_load not available.\n" ); -return -1 ; +return -ENOSYS ; }if (argc - fileind <=0 ) {
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v6 2/5 kexec: Fix option checks to take KEXEC_FILE_LOAD into account
When kexec_file_load support was added some sanity checks were not updated.
Some options are set only in the kexec_load flags so cannot be supported wiht kexec_file_load. On the other hand, reserved memory is needed for kdump with both kexec_load and kexec_file_load.
---
Added in v5
--- kexec/kexec.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
kexec/kexec.c +9 -1
@@ -1415,7 +1415,9 @@ int main(int argc, char *argv[]) do_load_jump_back_helper =0 ; } -if (do_load && (kexec_flags &KEXEC_ON_CRASH ) && +if (do_load && + ((kexec_flags &KEXEC_ON_CRASH ) || + (kexec_file_flags &KEXEC_FILE_ON_CRASH )) && !is_crashkernel_mem_reserved ()) {die ("Memory for crashkernel is not reserved\n" "Please reserve memory by passing"
@@ -1447,6 +1449,12 @@ int main(int argc, char *argv[]) } } } +if (do_kexec_file_syscall) { +if (do_load_jump_back_helper) +die ("--load-jump-back-helper not supported with kexec_file_load\n" ); +if (kexec_flags &KEXEC_PRESERVE_CONTEXT ) +die ("--load-preserve-context not supported with kexec_file_load\n" ); + }if (do_reuse_initrd){check_reuse_initrd ();
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v6 3/5 kexec: Do not special-case the -s option
In reply to Michal SuchanekIt is parsed separately to save a few CPU cycles when setting up other options but it just complicates the code. So fold it back and set up all flags for both KEXEC_LOAD and KEXEC_FILE_LOAD
--- kexec/kexec.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)
kexec/kexec.c +4 -21
@@ -1256,19 +1256,6 @@ int main(int argc, char *argv[]) };static const char short_options[] =KEXEC_ALL_OPT_STR ; -/* -* First check if --use-kexec-file-syscall is set. That changes lot of -* things -*/ -while ((opt =getopt_long (argc, argv, short_options, - options,0 )) !=-1 ) { -switch (opt) { -case OPT_KEXEC_FILE_SYSCALL : - do_kexec_file_syscall =1 ; -break ; - } - } -/* Reset getopt for the next pass. */ opterr =1 ; optind =1 ;
@@ -1310,8 +1297,7 @@ int main(int argc, char *argv[]) do_shutdown =0 ; do_sync =0 ; do_unload =1 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_UNLOAD ; + kexec_file_flags |=KEXEC_FILE_UNLOAD ;break ;case OPT_EXEC : do_load =0 ;
@@ -1354,11 +1340,8 @@ int main(int argc, char *argv[]) do_exec =0 ; do_shutdown =0 ; do_sync =0 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_ON_CRASH ; -else - kexec_flags =KEXEC_ON_CRASH ; -break ; + kexec_file_flags |=KEXEC_FILE_ON_CRASH ; + kexec_flags =KEXEC_ON_CRASH ;case OPT_MEM_MIN : mem_min =strtoul (optarg, &endptr,0 );if (*endptr) {
@@ -1383,7 +1366,7 @@ int main(int argc, char *argv[]) do_reuse_initrd =1 ;break ;case OPT_KEXEC_FILE_SYSCALL : -/* We already parsed it. Nothing to do. */ + do_kexec_file_syscall =1 ;break ;case OPT_STATUS : do_status =1 ;
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v6 3/5] kexec: Do not special-case the -s option
Quoted 15 lines · On Wed, 28 Mar 2018 15:15:16 +0200 Michal Suchanek <[email protected]> wrote:
It is parsed separately to save a few CPU cycles when setting up other options but it just complicates the code. So fold it back and set up all flags for both
KEXEC_LOADandKEXEC_FILE_LOADSigned-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)kexec/kexec.c +0
-0
kexec/kexec.c int main(int argc, char *argv[]) · line 1361
Quoted 8 lines
kexec/kexec.c +0
-5@@ -1354,11 +1340,8 @@ int main(int argc, char *argv[]) do_exec =0 ; do_shutdown =0 ; do_sync =0 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_ON_CRASH ; -else - kexec_flags =KEXEC_ON_CRASH ; -break ;
Argh. This break was rather important. "kexec -p" now segfaults on me, as it falls through to parsing non-existent optarg. :-(
Petr T
Quoted 6 lines
kexec/kexec.c +2
-0+ kexec_file_flags |=KEXEC_FILE_ON_CRASH ; + kexec_flags =KEXEC_ON_CRASH ;case OPT_MEM_MIN : mem_min =strtoul (optarg, &endptr,0 );if (*endptr) {
kexec/kexec.c int main(int argc, char *argv[]) · line 1372
Quoted 8 lines
kexec/kexec.c +1
-1@@ -1383,7 +1366,7 @@ int main(int argc, char *argv[]) do_reuse_initrd =1 ;break ;case OPT_KEXEC_FILE_SYSCALL : -/* We already parsed it. Nothing to do. */ + do_kexec_file_syscall =1 ;break ;case OPT_STATUS : do_status =1 ;
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v6 3/5] kexec: Do not special-case the -s option
Quoted 21 lines · Petr Tesarik
Quoted 18 lines · On Wed, 28 Mar 2018 15:15:16 +0200 Michal Suchanek <[email protected]> wrote:
It is parsed separately to save a few CPU cycles when setting up other options but it just complicates the code. So fold it back and set up all flags for both
KEXEC_LOADandKEXEC_FILE_LOADSigned-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)kexec/kexec.c +0
-0@@ -1354,11 +1340,8 @@ int main(int argc, char *argv[]) do_exec =0 ; do_shutdown =0 ; do_sync =0 ;
Quoted 9 lines
kexec/kexec.c int main(int argc, char *argv[]) · line 1361
Quoted 5 lines
kexec/kexec.c +0
-5-if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_ON_CRASH ; -else - kexec_flags =KEXEC_ON_CRASH ; -break ;Argh. This break was rather important. "kexec -p" now segfaults on me, as it falls through to parsing non-existent optarg. :-(
Sigh. Seems 'kexec -p' was never tested with properly with this patchset. This is one of the problems I see with this patchset, so we definitely would like to get rid of this segmentation fault.
Petr, I am going to share my Tested-by for the patch you shared for fixing this issue in the separate thread.
I would request the fix to be picked up earlier into kexec-tools as 'kexec -p' is currently broken in upstream kexec-tools.
Regards,
Bhupesh
Quoted 13 lines
Quoted 13 lines
kexec/kexec.c +3
-1+ kexec_file_flags |=KEXEC_FILE_ON_CRASH ; + kexec_flags =KEXEC_ON_CRASH ;case OPT_MEM_MIN : mem_min =strtoul (optarg, &endptr,0 );if (*endptr) {@@ -1383,7 +1366,7 @@ int main(int argc, char *argv[]) do_reuse_initrd =1 ;break ;case OPT_KEXEC_FILE_SYSCALL : -/* We already parsed it. Nothing to do. */ + do_kexec_file_syscall =1 ;break ;
Quoted 9 lines
kexec/kexec.c int main(int argc, char *argv[]) · line 1372
Quoted 2 lines
kexec/kexec.c +0
-0case OPT_STATUS : do_status =1 ;_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v6 4/5 kexec: Add option to revert -s
In reply to Michal SuchanekThe undocumented -s option selects KEXEC_FILE_LOAD syscall but there is no option to select KEXEC_LOAD syscall. Add it so -s can be reverted.
---
v6: add description to help text
--- kexec/kexec.c | 5 +++++ kexec/kexec.h | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-)
kexec/kexec.c +5 -0
@@ -1005,6 +1005,8 @@ void usage(void)" preserve context)\n" " to original kernel.\n" " -s, --kexec-file-syscall Use file based syscall for kexec operation\n" +" -c, --kexec-syscall Use the kexec_load syscall for for compatibility\n" +" with systems that don't support -s (default)\n" " -d, --debug Enable debugging to help spot a failure.\n" " -S, --status Return 0 if the type (by default crash) is loaded.\n" "\n"
@@ -1368,6 +1370,9 @@ int main(int argc, char *argv[])case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ;break ; +case OPT_KEXEC_SYSCALL : + do_kexec_file_syscall =0 ; +break ;case OPT_STATUS : do_status =1 ;break ;
kexec/kexec.h +3 -1
@@ -219,6 +219,7 @@ extern int file_types;#define OPT_TYPE 't'#define OPT_PANIC 'p'#define OPT_KEXEC_FILE_SYSCALL 's' +#define OPT_KEXEC_SYSCALL 'c'#define OPT_STATUS 'S'#define OPT_MEM_MIN 256#define OPT_MEM_MAX 257
@@ -246,11 +247,12 @@ extern int file_types; { "mem-max", 1, 0, OPT_MEM_MAX }, \ { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ + { "kexec-syscall", 0, 0, OPT_KEXEC_SYSCALL }, \ { "debug", 0, 0, OPT_DEBUG }, \ { "status", 0, 0, OPT_STATUS }, \ { "print-ckr-size", 0, 0, OPT_PRINT_CKR_SIZE }, \ -#define KEXEC_OPT_STR "h?vdfxyluet:psS" +#define KEXEC_OPT_STR "h?vdfxyluet:pscS" extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);extern void die (const char *fmt, ...)
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v6 5/5 kexec: Add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported
In reply to Michal SuchanekNot all architectures implement KEXEC_FILE_LOAD. However, on some archiectures KEXEC_FILE_LOAD is required when secure boot is enabled in locked-down mode. Previously users had to select the KEXEC_FILE_LOAD syscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.
So add an -a option that tries KEXEC_FILE_LOAD and when it is not supported tries KEXEC_LOAD.
---
v3: instead of changing the deafult add extra option
v4: actually check -ENOSYS as well
v5: add missing break
v6:
- add note about ENOTSUPP
- add description to help text
--- kexec/kexec.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- kexec/kexec.h | 4 +++- 2 files changed, 63 insertions(+), 6 deletions(-)
kexec/kexec.c +60 -5
@@ -1007,6 +1007,10 @@ void usage(void)" -s, --kexec-file-syscall Use file based syscall for kexec operation\n" " -c, --kexec-syscall Use the kexec_load syscall for for compatibility\n" " with systems that don't support -s (default)\n" +" -a, --kexec-syscall-auto Use file based syscall for kexec and fall\n" +" back to the compatibility syscall when file based\n" +" syscall is not supported or the kernel did not\n" +" understand the image\n" " -d, --debug Enable debugging to help spot a failure.\n" " -S, --status Return 0 if the type (by default crash) is loaded.\n" "\n"
@@ -1245,6 +1249,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =0 ;int do_status =0 ;void *entry =0 ;char *type =0 ;
@@ -1369,9 +1374,15 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ;break ;case OPT_KEXEC_SYSCALL : do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ; +break ; +case OPT_KEXEC_SYSCALL_AUTO : + do_kexec_file_syscall =1 ; + do_kexec_fallback =1 ;break ;case OPT_STATUS : do_status =1 ;
@@ -1438,7 +1449,7 @@ int main(int argc, char *argv[]) } }if (do_kexec_file_syscall) { -if (do_load_jump_back_helper) +if (do_load_jump_back_helper && !do_kexec_fallback)die ("--load-jump-back-helper not supported with kexec_file_load\n" );if (kexec_flags &KEXEC_PRESERVE_CONTEXT )die ("--load-preserve-context not supported with kexec_file_load\n" );
@@ -1452,16 +1463,60 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification. +* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +/* +* By default reject or do nothing if +* succeded +*/ +default :break ; +case -ENOSYS :/* not implemented */ +/* +* Parsing image or other options failed +* The image may be invalid or image +* type may not supported by kernel so +* retry parsing in kexec-tools. +*/ +case -EINVAL : +case -ENOEXEC : +/* +* ENOTSUP can be unsupported image +* type or unsupported PE signature +* wrapper type, duh +* +* The kernel sometimes wrongly +* returns ENOTSUPP (524) - ignore +* that. It is not supposed to be seen +* by userspace so seeing it is a +* kernel bug +*/ +case -ENOTSUP : + do_kexec_file_syscall =0 ; +break ; + } + } +if (!do_kexec_file_syscall) result =my_load (type, fileind, argc, argv, kexec_flags, entry); }
kexec/kexec.h +3 -1
@@ -220,6 +220,7 @@ extern int file_types;#define OPT_PANIC 'p'#define OPT_KEXEC_FILE_SYSCALL 's'#define OPT_KEXEC_SYSCALL 'c' +#define OPT_KEXEC_SYSCALL_AUTO 'a'#define OPT_STATUS 'S'#define OPT_MEM_MIN 256#define OPT_MEM_MAX 257
@@ -248,11 +249,12 @@ extern int file_types; { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ { "kexec-syscall", 0, 0, OPT_KEXEC_SYSCALL }, \ + { "kexec-syscall-auto", 0, 0, OPT_KEXEC_SYSCALL_AUTO }, \ { "debug", 0, 0, OPT_DEBUG }, \ { "status", 0, 0, OPT_STATUS }, \ { "print-ckr-size", 0, 0, OPT_PRINT_CKR_SIZE }, \ -#define KEXEC_OPT_STR "h?vdfxyluet:pscS" +#define KEXEC_OPT_STR "h?vdfxyluet:pscaS" extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);extern void die (const char *fmt, ...)
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 6/6 kexec: Document -s, -c and -a options in the man page
In reply to Michal Suchanek---
v5: document that KEXEC_LOAD may be disabled
v6: document that fallback happens in case the kernel does not understand the image
--- kexec/kexec.8 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
kexec/kexec.8 +20 -0
@@ -144,6 +144,26 @@ Load the new kernel for use on panic. Specify that the new kernel is of this .I type. .TP +.BI \-s\ (\-\-kexec-file-syscall) +Specify that the new KEXEC_FILE_LOAD syscall should be used exclusively. +.TP +.BI \-c\ (\-\-kexec-syscall) +Specify that the old KEXEC_LOAD syscall should be used exclusively (the default). +.TP +.BI \-a\ (\-\-kexec-syscall-auto) +Try the new KEXEC_FILE_LOAD syscall first and when it is not supported or the +kernel does not understand the supplied image fall back to the old KEXEC_LOAD +interface. + +There is no one single interface that always works. + +KEXEC_FILE_LOAD is required on systems that use locked-down secure boot to +verify the kernel signature. KEXEC_LOAD may be also disabled in the kernel +configuration. + +KEXEC_LOAD is required for some kernel image formats and on architectures that +do not implement KEXEC_FILE_LOAD. +.TP .B \-u\ (\-\-unload) Unload the current .B kexec
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Hi again Dave,
would you care to review v6?
Quoted 25 lines · Michal Suchanek
When the kernel does not know a syscall number it returns
-ENOSYSbut when kexec does not know a syscall number it returns -1. Return-ENOSYSfrom kexec as well.Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kexec/kexec.c +1
-1@@ -1166,7 +1166,7 @@ static int do_kexec_file_load(int fileind, int argc, char **argv,if (!is_kexec_file_load_implemented ()) {fprintf (stderr,"syscall kexec_file_load not available.\n" ); -return -1 ; +return -ENOSYS ; }if (argc - fileind <=0 ) {Signature · 1 line
2.13.6
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi Simon,
Quoted 3 lines · Simon Horman
Hi again Dave,
would you care to review v6?
I have no more comments for v6. Overall looks good to me.
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Simon Horman
AppliedQuoted 8 lines · Dave Young
Hi Simon,
Quoted 3 lines · Simon Horman
Hi again Dave,
would you care to review v6?
I have no more comments for v6. Overall looks good to me.
Thanks, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 4/5] kexec: Add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported
In reply to Michal SuchánekQuoted 150 lines · Michal Suchánek
Quoted 139 lines · On Mon, 26 Mar 2018 17:12:10 +0800 Dave Young <[email protected]> wrote:
Quoted 138 lines · Dave Young
Quoted 117 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.So add an -a option that tries
KEXEC_FILE_LOADand when it is not supported triesKEXEC_LOAD.Signed-off-by Michal Suchanek <[email protected]>---
v3: instead of changing the deafult add extra option
v4: actually check-ENOSYSas well
v5: add missing break--- kexec/kexec.c | 58+++++++++++++++++++++++++++++++++++++++++++++++++++++-----
kexec/kexec.h| 6 +++++- 2 files changed, 58 insertions(+), 6 deletions(-)kexec/kexec.c +11
-1@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =0 ;int do_status =0 ;void *entry =0 ;char *type =0 ;@@ -1367,6 +1368,15 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ; +break ; +case OPT_KEXEC_SYSCALL : + do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ; +break ; +case OPT_KEXEC_SYSCALL_AUTO : + do_kexec_file_syscall =1 ; + do_kexec_fallback =1 ;break ;case OPT_STATUS : do_status =1 ;@@ -1433,7 +1443,7 @@ int main(int argc, char *argv[]) } }if (do_kexec_file_syscall) { -if (do_load_jump_back_helper) + if (do_load_jump_back_helper&& !do_kexec_fallback)
die("--load-jump-back-helper not supported with kexec_file_load\n"); if (kexec_flags&KEXEC_PRESERVE_CONTEXT)die("--load-preserve-context not supported with kexec_file_load\n"); @@ -1447,16 +1457,54 @@ intmain(int argc, char *argv[])result =k_status(kexec_flags);kexec/kexec.c +1
-1}if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =
kexec_file_unload(kexec_file_flags);kexec/kexec.c +1
-1-else + if ((result == -ENOSYS) &&
do_kexec_fallback)kexec/kexec.c +4
-1+ do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result = do_kexec_file_load(fileind,argc, argv,
kexec_file_flags);kexec/kexec.c +3
-1-else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification.
kexec/kexec.c +10
-0+* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +/* +* By default reject or do nothing if
kexec/kexec.c +4
-0+* succeded +*/ +default :break ; +case -ENOSYS :/* not implemented */
kexec/kexec.c +2
-0+/* +* Parsing image or other options failed
kexec/kexec.c +1
-0+* The image may be invalid or image
kexec/kexec.c +1
-0+* type may not supported by kernel so
kexec/kexec.c +1
-0+* retry parsing in kexec-tools.
kexec/kexec.c +5
-0+*/ +case -EINVAL : +case -ENOEXEC : +/* +* ENOTSUPP can be unsupported image
kexec/kexec.c +1
-0+* type or unsupported PE signature
kexec/kexec.c int main(int argc, char *argv[]) · line 1502
Quoted 3 lines
kexec/kexec.c +3
-0+* wrapper type, duh +*/ +case -ENOTSUP :Hmm, this is still used in latest version. kernel does not return such error number, I might not say clearly previously. Please check the kernel code, the only one place I know is because no kdump support in power
kexec_file:arch/powerpc/kernel/machine_kexec_file_64.c/* We don't support crash kernels yet. */ if (image->type == KEXEC_TYPE_CRASH) return -ENOTSUPP;So I suggest not checking this as well since
-ENOTSUPPis not populated in userspace headers, and-ENOTSUPis not used at all.Also as I mentioned in another reply
-EINVALand-ENOEXECis also not ncessary.Quoted 7 lines
Quoted 3 lines
For
-ENOTSUP, maybe someone can submit a patch to switch to-ENOTSUPPso that userspace can check it.
Ccing Thiago and Hari for the-ENOTSUPPerrno issue.Oops for the hurry reply, I means
-ENOTSUPPmight be able to replaced with-EOPNOTSUPP, a similar change like this:
https://patchwork.kernel.org/patch/8490791/
Quoted 6 lines
Thanks for catching this. In Linux ENOTSUPP with extra P is different from EOPNOTSUPP and ENOTSUP (single P). Since we are talking to the kernel and it returns the double P ENOTSUPP we need to define it in kexec as well. And we should check ENOTSUP with single P in case somebody some day thinks that returning undefined error codes to userspace is not nice like in the patch above.
I'm not sure if we can define it in kexec-tools since they are used in kernel only..
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 4/5] kexec: Add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported
Quoted 38 lines · On Tue, 27 Mar 2018 18:06:19 +0800 Dave Young <[email protected]> wrote:
Quoted 30 lines · Michal Suchánek
Quoted 19 lines · On Mon, 26 Mar 2018 17:12:10 +0800 Dave Young <[email protected]> wrote:
Quoted 18 lines · Dave Young
On 03/20/18 at 04:56pm, Michal Suchanek wrote:
Hmm, this is still used in latest version. kernel does not return such error number, I might not say clearly previously. Please check the kernel code, the only one place I know is because no kdump support in power
kexec_file:arch/powerpc/kernel/machine_kexec_file_64.c/* We don't support crash kernels yet. */ if (image->type == KEXEC_TYPE_CRASH) return -ENOTSUPP;So I suggest not checking this as well since
-ENOTSUPPis not populated in userspace headers, and-ENOTSUPis not used at all.Also as I mentioned in another reply
-EINVALand-ENOEXECis also not ncessary.Quoted 7 lines
Quoted 3 lines
For
-ENOTSUP, maybe someone can submit a patch to switch to-ENOTSUPPso that userspace can check it.
Ccing Thiago and Hari for the-ENOTSUPPerrno issue.Oops for the hurry reply, I means
-ENOTSUPPmight be able to replaced with-EOPNOTSUPP, a similar change like this:
https://patchwork.kernel.org/patch/8490791/Quoted 6 lines
Thanks for catching this. In Linux ENOTSUPP with extra P is different from EOPNOTSUPP and ENOTSUP (single P). Since we are talking to the kernel and it returns the double P ENOTSUPP we need to define it in kexec as well. And we should check ENOTSUP with single P in case somebody some day thinks that returning undefined error codes to userspace is not nice like in the patch above.
Quoted 2 lines
I'm not sure if we can define it in kexec-tools since they are used in kernel only..
We define the KEXEC_FILE_LOAD syscall numbers so why not ENOTSUPP?
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 4/5] kexec: Add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported
Quoted 41 lines · On Tue, 27 Mar 2018 13:01:29 +0200 Michal Suchánek <[email protected]> wrote:
Quoted 38 lines · On Tue, 27 Mar 2018 18:06:19 +0800 Dave Young <[email protected]> wrote:
Quoted 36 lines · Michal Suchánek
Quoted 19 lines · On Mon, 26 Mar 2018 17:12:10 +0800 Dave Young <[email protected]> wrote:
Quoted 18 lines · Dave Young
On 03/20/18 at 04:56pm, Michal Suchanek wrote:
Hmm, this is still used in latest version. kernel does not return such error number, I might not say clearly previously. Please check the kernel code, the only one place I know is because no kdump support in power
kexec_file:arch/powerpc/kernel/machine_kexec_file_64.c/* We don't support crash kernels yet. */ if (image->type == KEXEC_TYPE_CRASH) return -ENOTSUPP;So I suggest not checking this as well since
-ENOTSUPPis not populated in userspace headers, and-ENOTSUPis not used at all.Also as I mentioned in another reply
-EINVALand-ENOEXECis also not ncessary.Quoted 7 lines
Quoted 3 lines
For
-ENOTSUP, maybe someone can submit a patch to switch to-ENOTSUPPso that userspace can check it.
Ccing Thiago and Hari for the-ENOTSUPPerrno issue.Oops for the hurry reply, I means
-ENOTSUPPmight be able to replaced with-EOPNOTSUPP, a similar change like this:
https://patchwork.kernel.org/patch/8490791/Thanks for catching this. In Linux ENOTSUPP with extra P is different from EOPNOTSUPP and ENOTSUP (single P). Since we are talking to the kernel and it returns the double P ENOTSUPP we need to define it in kexec as well. And we should check ENOTSUP with single P in case somebody some day thinks that returning undefined error codes to userspace is not nice like in the patch above.
Quoted 4 lines
Quoted 2 lines
I'm not sure if we can define it in kexec-tools since they are used in kernel only..
We define the
KEXEC_FILE_LOADsyscall numbers so why not ENOTSUPP?
Essentially, because syscall numbers will be added to Linux uapi sooner or later, but ENOTSUPP is meant to stay kernel-internal. It is declared in include/linux/errno.h, which says:
* These should never be seen by user programs.
In other words, it is already a kernel bug that these error codes can are currently returned to user space.
Petr T
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 4/5] kexec: Add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported
In reply to Michal SuchánekQuoted 41 lines · Michal Suchánek
Quoted 38 lines · On Tue, 27 Mar 2018 18:06:19 +0800 Dave Young <[email protected]> wrote:
Quoted 36 lines · Michal Suchánek
Quoted 19 lines · On Mon, 26 Mar 2018 17:12:10 +0800 Dave Young <[email protected]> wrote:
Quoted 18 lines · Dave Young
On 03/20/18 at 04:56pm, Michal Suchanek wrote:
Hmm, this is still used in latest version. kernel does not return such error number, I might not say clearly previously. Please check the kernel code, the only one place I know is because no kdump support in power
kexec_file:arch/powerpc/kernel/machine_kexec_file_64.c/* We don't support crash kernels yet. */ if (image->type == KEXEC_TYPE_CRASH) return -ENOTSUPP;So I suggest not checking this as well since
-ENOTSUPPis not populated in userspace headers, and-ENOTSUPis not used at all.Also as I mentioned in another reply
-EINVALand-ENOEXECis also not ncessary.Quoted 7 lines
Quoted 3 lines
For
-ENOTSUP, maybe someone can submit a patch to switch to-ENOTSUPPso that userspace can check it.
Ccing Thiago and Hari for the-ENOTSUPPerrno issue.Oops for the hurry reply, I means
-ENOTSUPPmight be able to replaced with-EOPNOTSUPP, a similar change like this:
https://patchwork.kernel.org/patch/8490791/Thanks for catching this. In Linux ENOTSUPP with extra P is different from EOPNOTSUPP and ENOTSUP (single P). Since we are talking to the kernel and it returns the double P ENOTSUPP we need to define it in kexec as well. And we should check ENOTSUP with single P in case somebody some day thinks that returning undefined error codes to userspace is not nice like in the patch above.
Quoted 4 lines
Quoted 2 lines
I'm not sure if we can define it in kexec-tools since they are used in kernel only..
We define the
KEXEC_FILE_LOADsyscall numbers so why not ENOTSUPP?
They are different syscall number is persistent but internal errnos are not supposed to be so.
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 4/5] kexec: Add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported
Quoted 42 lines · Dave Young
Quoted 41 lines · Michal Suchánek
Quoted 38 lines · On Tue, 27 Mar 2018 18:06:19 +0800 Dave Young <[email protected]> wrote:
Quoted 36 lines · Michal Suchánek
Quoted 19 lines · On Mon, 26 Mar 2018 17:12:10 +0800 Dave Young <[email protected]> wrote:
Quoted 18 lines · Dave Young
On 03/20/18 at 04:56pm, Michal Suchanek wrote:
Hmm, this is still used in latest version. kernel does not return such error number, I might not say clearly previously. Please check the kernel code, the only one place I know is because no kdump support in power
kexec_file:arch/powerpc/kernel/machine_kexec_file_64.c/* We don't support crash kernels yet. */ if (image->type == KEXEC_TYPE_CRASH) return -ENOTSUPP;So I suggest not checking this as well since
-ENOTSUPPis not populated in userspace headers, and-ENOTSUPis not used at all.Also as I mentioned in another reply
-EINVALand-ENOEXECis also not ncessary.Quoted 7 lines
Quoted 3 lines
For
-ENOTSUP, maybe someone can submit a patch to switch to-ENOTSUPPso that userspace can check it.
Ccing Thiago and Hari for the-ENOTSUPPerrno issue.Oops for the hurry reply, I means
-ENOTSUPPmight be able to replaced with-EOPNOTSUPP, a similar change like this:
https://patchwork.kernel.org/patch/8490791/Thanks for catching this. In Linux ENOTSUPP with extra P is different from EOPNOTSUPP and ENOTSUP (single P). Since we are talking to the kernel and it returns the double P ENOTSUPP we need to define it in kexec as well. And we should check ENOTSUP with single P in case somebody some day thinks that returning undefined error codes to userspace is not nice like in the patch above.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
I'm not sure if we can define it in kexec-tools since they are used in kernel only..
We define the
KEXEC_FILE_LOADsyscall numbers so why not ENOTSUPP?They are different syscall number is persistent but internal errnos are not supposed to be so.
It sounds to me that the kernel needs to be updated and that upstream kexec-tools can't support ENOTSUPP.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v5 5/5 kexec: Document -s, -c and -a options
In reply to Michal Suchanek--- kexec/kexec.8 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
kexec/kexec.8 +19 -0
@@ -144,6 +144,25 @@ Load the new kernel for use on panic. Specify that the new kernel is of this .I type. .TP +.BI \-s\ (\-\-kexec-file-syscall) +Specify that the new KEXEC_FILE_LOAD syscall should be used exclusively. +.TP +.BI \-c\ (\-\-kexec-syscall) +Specify that the old KEXEC_LOAD syscall should be used exclusively (the default). +.TP +.BI \-a\ (\-\-kexec-syscall-auto) +Try the new KEXEC_FILE_LOAD syscall first and if it is not supported fall back +to the old KEXEC_LOAD interface. + +There is no one single interface that always works. + +KEXEC_FILE_LOAD is required on systems that use locked-down secure boot to +verify the kernel signature. KEXEC_LOAD may be also disabled in the kernel +configuration. + +KEXEC_LOAD is required for some kernel image formats and on architectures that +do not implement KEXEC_FILE_LOAD. +.TP .B \-u\ (\-\-unload) Unload the current .B kexec
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Hi Michal, thanks for the updated patches.
Dave, are you planning to review this series?
Quoted 25 lines · Michal Suchanek
When the kernel does not know a syscall number it returns
-ENOSYSbut when kexec does not know a syscall number it returns -1. Return-ENOSYSfrom kexec as well.Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kexec/kexec.c +1
-1@@ -1166,7 +1166,7 @@ static int do_kexec_file_load(int fileind, int argc, char **argv,if (!is_kexec_file_load_implemented ()) {fprintf (stderr,"syscall kexec_file_load not available.\n" ); -return -1 ; +return -ENOSYS ; }if (argc - fileind <=0 ) {Signature · 1 line
2.13.6
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi Simon
Quoted 4 lines · Simon Horman
Hi Michal, thanks for the updated patches.
Dave, are you planning to review this series?
I have same concern as I commented in last versioni, but seems we can not convince each other with Michal.
For example for -EINVAL/-ENOEXEC, since it can be some misc error checking in kernel code, it is not equal to an unsupported syscall. I'm not keen to think broken kernel file (include the case for unsupported kernel format, but not limit to that) is equal as an unsupported syscall
Also seems the new options are not showing in kexec -h although added in the man page.
So I think I will leave to you and do not object it if you are fine.
Quoted 22 lines · Michal Suchanek
Quoted 21 lines
When the kernel does not know a syscall number it returns
-ENOSYSbut when kexec does not know a syscall number it returns -1. Return-ENOSYSfrom kexec as well.Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kexec/kexec.c +1
-1@@ -1166,7 +1166,7 @@ static int do_kexec_file_load(int fileind, int argc, char **argv,if (!is_kexec_file_load_implemented ()) {fprintf (stderr,"syscall kexec_file_load not available.\n" ); -return -1 ; +return -ENOSYS ; }
Quoted 9 lines
Quoted 4 lines
kexec/kexec.c +0
-0if (argc - fileind <=0 ) {Signature · 1 line
2.13.6_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 7 lines · On Mon, 26 Mar 2018 15:53:24 +0800 Dave Young <[email protected]> wrote:
Hi Simon
Quoted 4 lines · Simon Horman
Hi Michal, thanks for the updated patches.
Dave, are you planning to review this series?
Quoted 8 lines
I have same concern as I commented in last versioni, but seems we can not convince each other with Michal.
For example for -EINVAL/-ENOEXEC, since it can be some misc error checking in kernel code, it is not equal to an unsupported syscall. I'm not keen to think broken kernel file (include the case for unsupported kernel format, but not limit to that) is equal as an unsupported syscall
I do not say it is equal to unsupported syscall. However, the kernel cannot really tell if the image is complete garbage or if it is in format it does not understand. The only way to check that is trying to load in the old way. I don't see any way around that if we want an --auto option which is of any use.
Quoted 3 lines
Also seems the new options are not showing in
kexec -halthough added in the man page.
Yes, that's another place where the description should be added.
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 19 lines · Michal Suchánek
Quoted 7 lines · On Mon, 26 Mar 2018 15:53:24 +0800 Dave Young <[email protected]> wrote:
Hi Simon
Quoted 4 lines · Simon Horman
Hi Michal, thanks for the updated patches.
Dave, are you planning to review this series?
Quoted 8 lines
I have same concern as I commented in last versioni, but seems we can not convince each other with Michal.
For example for -EINVAL/-ENOEXEC, since it can be some misc error checking in kernel code, it is not equal to an unsupported syscall. I'm not keen to think broken kernel file (include the case for unsupported kernel format, but not limit to that) is equal as an unsupported syscall
Quoted 5 lines
I do not say it is equal to unsupported syscall. However, the kernel cannot really tell if the image is complete garbage or if it is in format it does not understand. The only way to check that is trying to load in the old way. I don't see any way around that if we want an --auto option which is of any use.
Maybe it is some personal taste, I tend to only checking syscall supported so that it can be simpler. And maybe from the beginning I understand the "supported" as only for the syscall itself..
Anyway as having said before let's see how Simon think about this.
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v4 3/5 kexec: add option to revert -s
In reply to Michal SuchanekThe undocumented -s option selects KEXEC_FILE_LOAD syscall but there is no option to select KEXEC_LOAD syscall so add it. It is generally good idea and in followup patch the default will be changed so it will be needed to get KEXEC_LOAD functionality.
--- kexec/kexec.c | 3 +++ kexec/kexec.h | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-)
kexec/kexec.c +3 -0
@@ -1368,6 +1368,9 @@ int main(int argc, char *argv[])case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ;break ; +case OPT_KEXEC_SYSCALL : + do_kexec_file_syscall =0 ; +break ;case OPT_STATUS : do_status =1 ;break ;
kexec/kexec.h +3 -1
@@ -219,6 +219,7 @@ extern int file_types;#define OPT_TYPE 't'#define OPT_PANIC 'p'#define OPT_KEXEC_FILE_SYSCALL 's' +#define OPT_KEXEC_SYSCALL 'c'#define OPT_STATUS 'S'#define OPT_MEM_MIN 256#define OPT_MEM_MAX 257
@@ -246,11 +247,12 @@ extern int file_types; { "mem-max", 1, 0, OPT_MEM_MAX }, \ { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ + { "kexec-syscall", 0, 0, OPT_KEXEC_SYSCALL }, \ { "debug", 0, 0, OPT_DEBUG }, \ { "status", 0, 0, OPT_STATUS }, \ { "print-ckr-size", 0, 0, OPT_PRINT_CKR_SIZE }, \ -#define KEXEC_OPT_STR "h?vdfxyluet:psS" +#define KEXEC_OPT_STR "h?vdfxyluet:pscS" extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);extern void die (const char *fmt, ...)
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v4 4/5 kexec: add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
In reply to Michal SuchanekNot all architectures implement KEXEC_FILE_LOAD. However, on some archiectures KEXEC_FILE_LOAD is required when secure boot is enabled in locked-down mode. Previously users had to select the KEXEC_FILE_LOAD syscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.
So add an -a option that tries KEXEC_FILE_LOAD and when it is not supported tries KEXEC_LOAD.
---
v3: instead of changing the deafult add extra option
v4: actually check -ENOSYS as well
--- kexec/kexec.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++---- kexec/kexec.h | 4 +++- 2 files changed, 51 insertions(+), 5 deletions(-)
kexec/kexec.c +48 -4
@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =0 ;int do_status =0 ;void *entry =0 ;char *type =0 ;
@@ -1367,10 +1368,15 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ;break ;case OPT_KEXEC_SYSCALL : do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ;break ; +case OPT_KEXEC_SYSCALL_AUTO : + do_kexec_file_syscall =1 ; + do_kexec_fallback =1 ;case OPT_STATUS : do_status =1 ;break ;
@@ -1442,16 +1448,54 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification. +* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +/* +* By default reject or do nothing if +* succeded +*/ +default :break ; +case -ENOSYS :/* not implemented */ +/* +* Parsing image or other options failed +* The image may be invalid or image +* type may not supported by kernel so +* retry parsing in kexec-tools. +*/ +case -EINVAL : +case -ENOEXEC : +/* +* ENOTSUPP can be unsupported image +* type or unsupported PE signature +* wrapper type, duh +*/ +case -ENOTSUP : + do_kexec_file_syscall =0 ; +break ; + } + } +if (!do_kexec_file_syscall) result =my_load (type, fileind, argc, argv, kexec_flags, entry); }
kexec/kexec.h +3 -1
@@ -220,6 +220,7 @@ extern int file_types;#define OPT_PANIC 'p'#define OPT_KEXEC_FILE_SYSCALL 's'#define OPT_KEXEC_SYSCALL 'c' +#define OPT_KEXEC_SYSCALL_AUTO 'a'#define OPT_STATUS 'S'#define OPT_MEM_MIN 256#define OPT_MEM_MAX 257
@@ -248,11 +249,12 @@ extern int file_types; { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ { "kexec-syscall", 0, 0, OPT_KEXEC_SYSCALL }, \ + { "kexec-syscall-auto", 0, 0, OPT_KEXEC_SYSCALL_AUTO }, \ { "debug", 0, 0, OPT_DEBUG }, \ { "status", 0, 0, OPT_STATUS }, \ { "print-ckr-size", 0, 0, OPT_PRINT_CKR_SIZE }, \ -#define KEXEC_OPT_STR "h?vdfxyluet:pscS" +#define KEXEC_OPT_STR "h?vdfxyluet:pscaS" extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);extern void die (const char *fmt, ...)
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 4/5] kexec: add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
Quoted 10 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.So add an -a option that tries
KEXEC_FILE_LOADand when it is not supported triesKEXEC_LOAD.Signed-off-by Michal Suchanek <[email protected]>
David, Simon.
Is there any feedback on v4 of this patchset? Adding a new option for fallback rather than changing the existing behavior was the v3 feedback on March 2nd.
Cheers!
Tony
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 4/5] kexec: add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
Quoted 7 lines · Tony Jones
Quoted 6 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.
Quoted 9 lines
Quoted 4 lines
So add an -a option that tries
KEXEC_FILE_LOADand when it is not supported triesKEXEC_LOAD.Signed-off-by Michal Suchanek <[email protected]>David, Simon.
Is there any feedback on v4 of this patchset? Adding a new option for fallback rather than changing the existing behavior was the v3 feedback on March 2nd.
Tony, sure, I just replied with several comments, but still need Simon to review in case I may miss something.
Quoted 3 lines
Cheers!
Tony
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 4/5] kexec: add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
In reply to Michal SuchanekQuoted 33 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.So add an -a option that tries
KEXEC_FILE_LOADand when it is not supported triesKEXEC_LOAD.Signed-off-by Michal Suchanek <[email protected]>---
v3: instead of changing the deafult add extra option
v4: actually check-ENOSYSas well--- kexec/kexec.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++---- kexec/kexec.h | 4 +++- 2 files changed, 51 insertions(+), 5 deletions(-)kexec/kexec.c +1
-0@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =0 ;int do_status =0 ;void *entry =0 ;char *type =0 ;@@ -1367,10 +1368,15 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL :
kexec/kexec.c int main(int argc, char *argv[]) · line 1379
Quoted 10 lines
kexec/kexec.c +5
-0do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ;break ;case OPT_KEXEC_SYSCALL : do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ;break ; +case OPT_KEXEC_SYSCALL_AUTO : + do_kexec_file_syscall =1 ; + do_kexec_fallback =1 ;
need a break here
Quoted 46 lines
kexec/kexec.c +29
-4case OPT_STATUS : do_status =1 ;break ;@@ -1442,16 +1448,54 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification. +* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +/* +* By default reject or do nothing if +* succeded +*/ +default :break ; +case -ENOSYS :/* not implemented */ +/* +* Parsing image or other options failed +* The image may be invalid or image +* type may not supported by kernel so +* retry parsing in kexec-tools. +*/
kexec/kexec.c int main(int argc, char *argv[]) · line 1495
Quoted 10 lines
kexec/kexec.c +10
-0+case -EINVAL : +case -ENOEXEC : +/* +* ENOTSUPP can be unsupported image +* type or unsupported PE signature +* wrapper type, duh +*/ +case -ENOTSUP : + do_kexec_file_syscall =0 ; +break ;
It looks to me it is enough only checking -ENOSYS maybe also -ENOTSUPP and then set do_kexec_file_syscall = 0;
EINVAL and ENOEXEC are real errors, I do not understand why still fallback. Also thos signature verification errors are not needed in this code as well.
Quoted 40 lines
kexec/kexec.c +3
-0+ } + } +if (!do_kexec_file_syscall) result =my_load (type, fileind, argc, argv, kexec_flags, entry); }kexec/kexec.h +3
-1@@ -220,6 +220,7 @@ extern int file_types;#define OPT_PANIC 'p'#define OPT_KEXEC_FILE_SYSCALL 's'#define OPT_KEXEC_SYSCALL 'c' +#define OPT_KEXEC_SYSCALL_AUTO 'a'#define OPT_STATUS 'S'#define OPT_MEM_MIN 256#define OPT_MEM_MAX 257@@ -248,11 +249,12 @@ extern int file_types; { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ { "kexec-syscall", 0, 0, OPT_KEXEC_SYSCALL }, \ + { "kexec-syscall-auto", 0, 0, OPT_KEXEC_SYSCALL_AUTO }, \ { "debug", 0, 0, OPT_DEBUG }, \ { "status", 0, 0, OPT_STATUS }, \ { "print-ckr-size", 0, 0, OPT_PRINT_CKR_SIZE }, \ -#define KEXEC_OPT_STR "h?vdfxyluet:pscS" +#define KEXEC_OPT_STR "h?vdfxyluet:pscaS" extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);extern void die (const char *fmt, ...)Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 4/5] kexec: add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
Quoted 39 lines · On Wed, 14 Mar 2018 11:21:59 +0800 Dave Young <[email protected]> wrote:
Quoted 38 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.So add an -a option that tries
KEXEC_FILE_LOADand when it is not supported triesKEXEC_LOAD.Signed-off-by Michal Suchanek <[email protected]>---
v3: instead of changing the deafult add extra option
v4: actually check-ENOSYSas well--- kexec/kexec.c | 52++++++++++++++++++++++++++++++++++++++++++++++++----
kexec/kexec.h| 4 +++- 2 files changed, 51 insertions(+), 5 deletions(-)kexec/kexec.c +2
-0@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =0 ;int do_status =0 ;void *entry =0 ;char *type =0 ;@@ -1367,10 +1368,15 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ;break ;case OPT_KEXEC_SYSCALL :
Quoted 8 lines
kexec/kexec.c int main(int argc, char *argv[]) · line 1379
Quoted 6 lines
kexec/kexec.c +4
-0do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ;break ; +case OPT_KEXEC_SYSCALL_AUTO : + do_kexec_file_syscall =1 ; + do_kexec_fallback =1 ;need a break here
Indeed
Quoted 71 lines
Quoted 62 lines
kexec/kexec.c +9
-4case OPT_STATUS : do_status =1 ;break ;@@ -1442,16 +1448,54 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification.
kexec/kexec.c +10
-0+* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +/* +* By default reject or do nothing if
kexec/kexec.c +6
-0+* succeded +*/ +default :break ; +case -ENOSYS :/* not implemented */ +/* +* Parsing image or other options failed
kexec/kexec.c +1
-0+* The image may be invalid or image
kexec/kexec.c +1
-0+* type may not supported by kernel so
kexec/kexec.c +1
-0+* retry parsing in kexec-tools.
kexec/kexec.c +5
-0+*/ +case -EINVAL : +case -ENOEXEC : +/* +* ENOTSUPP can be unsupported image
kexec/kexec.c +1
-0+* type or unsupported PE signature
kexec/kexec.c int main(int argc, char *argv[]) · line 1495
Quoted 5 lines
kexec/kexec.c +5
-0+* wrapper type, duh +*/ +case -ENOTSUP : + do_kexec_file_syscall =0 ; +break ;It looks to me it is enough only checking
-ENOSYSmaybe also-ENOTSUPPand then setdo_kexec_file_syscall= 0;
Quoted 2 lines
EINVAL and ENOEXEC are real errors, I do not understand why still fallback.
If you pass an image type that the kernel does not understand (eg. multiboot or uImage) then the kernel will return a real error because it does not understand the image. However, kexec-tools should still be able to load it, automatically. That's what the -auto stands for.
Quoted 2 lines
Also thos signature verification errors are not needed in this code as well.
Yes, they are not needed. They are here so it's obvious which errors are signature verification errors.
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 4/5] kexec: add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
Quoted 124 lines · Michal Suchánek
Quoted 39 lines · On Wed, 14 Mar 2018 11:21:59 +0800 Dave Young <[email protected]> wrote:
Quoted 38 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.So add an -a option that tries
KEXEC_FILE_LOADand when it is not supported triesKEXEC_LOAD.Signed-off-by Michal Suchanek <[email protected]>---
v3: instead of changing the deafult add extra option
v4: actually check-ENOSYSas well--- kexec/kexec.c | 52++++++++++++++++++++++++++++++++++++++++++++++++----
kexec/kexec.h| 4 +++- 2 files changed, 51 insertions(+), 5 deletions(-)kexec/kexec.c +2
-0@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =0 ;int do_status =0 ;void *entry =0 ;char *type =0 ;@@ -1367,10 +1368,15 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ;break ;case OPT_KEXEC_SYSCALL :Quoted 8 lines
kexec/kexec.c int main(int argc, char *argv[]) · line 1379
Quoted 6 lines
kexec/kexec.c +4
-0do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ;break ; +case OPT_KEXEC_SYSCALL_AUTO : + do_kexec_file_syscall =1 ; + do_kexec_fallback =1 ;need a break here
Indeed
Quoted 71 lines
Quoted 62 lines
kexec/kexec.c +9
-4case OPT_STATUS : do_status =1 ;break ;@@ -1442,16 +1448,54 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification.
kexec/kexec.c +10
-0+* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +/* +* By default reject or do nothing if
kexec/kexec.c +6
-0+* succeded +*/ +default :break ; +case -ENOSYS :/* not implemented */ +/* +* Parsing image or other options failed
kexec/kexec.c +1
-0+* The image may be invalid or image
kexec/kexec.c +1
-0+* type may not supported by kernel so
kexec/kexec.c +1
-0+* retry parsing in kexec-tools.
kexec/kexec.c +5
-0+*/ +case -EINVAL : +case -ENOEXEC : +/* +* ENOTSUPP can be unsupported image
kexec/kexec.c +1
-0+* type or unsupported PE signature
kexec/kexec.c int main(int argc, char *argv[]) · line 1495
Quoted 5 lines
kexec/kexec.c +5
-0+* wrapper type, duh +*/ +case -ENOTSUP : + do_kexec_file_syscall =0 ; +break ;It looks to me it is enough only checking
-ENOSYSmaybe also-ENOTSUPPand then setdo_kexec_file_syscall= 0;
Quoted 7 lines
Quoted 2 lines
EINVAL and ENOEXEC are real errors, I do not understand why still fallback.
If you pass an image type that the kernel does not understand (eg. multiboot or uImage) then the kernel will return a real error because it does not understand the image. However, kexec-tools should still be able to load it, automatically. That's what the -auto stands for.
This semes over engineering, the initial purpose is to fallback when kexec_file_load is not supported, so I would suggest not to do more than that.
Quoted 10 lines
Quoted 3 lines
Also thos signature verification errors are not needed in this code as well.
Yes, they are not needed. They are here so it's obvious which errors are signature verification errors.
Thanks
Michal
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 4/5] kexec: add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
Quoted 16 lines · On Fri, 16 Mar 2018 14:45:02 +0800 Dave Young <[email protected]> wrote:
Quoted 6 lines · Michal Suchánek
Quoted 3 lines · On Wed, 14 Mar 2018 11:21:59 +0800 Dave Young <[email protected]> wrote:
It looks to me it is enough only checking
-ENOSYSmaybe also-ENOTSUPPand then setdo_kexec_file_syscall= 0;Quoted 8 lines
Quoted 2 lines
EINVAL and ENOEXEC are real errors, I do not understand why still fallback.
If you pass an image type that the kernel does not understand (eg. multiboot or uImage) then the kernel will return a real error because it does not understand the image. However, kexec-tools should still be able to load it, automatically. That's what the -auto stands for.
Quoted 3 lines
This semes over engineering, the initial purpose is to fallback when
kexec_file_loadis not supported, so I would suggest not to do more than that.
The initial purpose is for users to not need to specify any flag to select a syscall to use. Since this is not acceptable because it might make kexec work out of the box on systems where it was previously broken or whatever this new flag is supposed to achieve that: when specified kexec tries hard to do the best thing possible with the image it received.
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 4/5] kexec: add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
In reply to Michal SuchanekQuoted 87 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.So add an -a option that tries
KEXEC_FILE_LOADand when it is not supported triesKEXEC_LOAD.Signed-off-by Michal Suchanek <[email protected]>---
v3: instead of changing the deafult add extra option
v4: actually check-ENOSYSas well--- kexec/kexec.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++---- kexec/kexec.h | 4 +++- 2 files changed, 51 insertions(+), 5 deletions(-)kexec/kexec.c +33
-4@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =0 ;int do_status =0 ;void *entry =0 ;char *type =0 ;@@ -1367,10 +1368,15 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ;break ;case OPT_KEXEC_SYSCALL : do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ;break ; +case OPT_KEXEC_SYSCALL_AUTO : + do_kexec_file_syscall =1 ; + do_kexec_fallback =1 ;case OPT_STATUS : do_status =1 ;break ;@@ -1442,16 +1448,54 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification. +* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +/* +* By default reject or do nothing if +* succeded +*/ +default :break ; +case -ENOSYS :/* not implemented */ +/* +* Parsing image or other options failed +* The image may be invalid or image +* type may not supported by kernel so
kexec/kexec.c int main(int argc, char *argv[]) · line 1493
Quoted 10 lines
kexec/kexec.c +10
-0+* retry parsing in kexec-tools. +*/ +case -EINVAL : +case -ENOEXEC : +/* +* ENOTSUPP can be unsupported image +* type or unsupported PE signature +* wrapper type, duh +*/ +case -ENOTSUP :
Shouldn't this be -ENOTSUPP ?
Quoted 42 lines
kexec/kexec.c +5
-0+ do_kexec_file_syscall =0 ; +break ; + } + } +if (!do_kexec_file_syscall) result =my_load (type, fileind, argc, argv, kexec_flags, entry); }kexec/kexec.h +3
-1@@ -220,6 +220,7 @@ extern int file_types;#define OPT_PANIC 'p'#define OPT_KEXEC_FILE_SYSCALL 's'#define OPT_KEXEC_SYSCALL 'c' +#define OPT_KEXEC_SYSCALL_AUTO 'a'#define OPT_STATUS 'S'#define OPT_MEM_MIN 256#define OPT_MEM_MAX 257@@ -248,11 +249,12 @@ extern int file_types; { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ { "kexec-syscall", 0, 0, OPT_KEXEC_SYSCALL }, \ + { "kexec-syscall-auto", 0, 0, OPT_KEXEC_SYSCALL_AUTO }, \ { "debug", 0, 0, OPT_DEBUG }, \ { "status", 0, 0, OPT_STATUS }, \ { "print-ckr-size", 0, 0, OPT_PRINT_CKR_SIZE }, \ -#define KEXEC_OPT_STR "h?vdfxyluet:pscS" +#define KEXEC_OPT_STR "h?vdfxyluet:pscaS" extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);extern void die (const char *fmt, ...)Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 4/5] kexec: add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
Quoted 103 lines · On Wed, 14 Mar 2018 11:22:40 +0800 Dave Young <[email protected]> wrote:
Quoted 102 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.So add an -a option that tries
KEXEC_FILE_LOADand when it is not supported triesKEXEC_LOAD.Signed-off-by Michal Suchanek <[email protected]>---
v3: instead of changing the deafult add extra option
v4: actually check-ENOSYSas well--- kexec/kexec.c | 52++++++++++++++++++++++++++++++++++++++++++++++++----
kexec/kexec.h| 4 +++- 2 files changed, 51 insertions(+), 5 deletions(-)kexec/kexec.c +15
-4@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =0 ;int do_status =0 ;void *entry =0 ;char *type =0 ;@@ -1367,10 +1368,15 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ;break ;case OPT_KEXEC_SYSCALL : do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ;break ; +case OPT_KEXEC_SYSCALL_AUTO : + do_kexec_file_syscall =1 ; + do_kexec_fallback =1 ;case OPT_STATUS : do_status =1 ;break ;@@ -1442,16 +1448,54 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification.
kexec/kexec.c +10
-0+* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +/* +* By default reject or do nothing if
kexec/kexec.c +6
-0+* succeded +*/ +default :break ; +case -ENOSYS :/* not implemented */ +/* +* Parsing image or other options failed
kexec/kexec.c +1
-0+* The image may be invalid or image
kexec/kexec.c +1
-0+* type may not supported by kernel so
kexec/kexec.c +1
-0+* retry parsing in kexec-tools.
kexec/kexec.c +5
-0+*/ +case -EINVAL : +case -ENOEXEC : +/* +* ENOTSUPP can be
Quoted 8 lines
kexec/kexec.c int main(int argc, char *argv[]) · line 1493
Quoted 6 lines
unsupported image
kexec/kexec.c +1
-0+* type or unsupported PE signature
kexec/kexec.c +3
-0+* wrapper type, duh +*/ +case -ENOTSUP :Shouldn't this be
-ENOTSUPP?
No, ENOTSUP and EOPNOTSUPP is defined. The latter is for socket operations.
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 4/5] kexec: add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
Quoted 115 lines · Michal Suchánek
Quoted 103 lines · On Wed, 14 Mar 2018 11:22:40 +0800 Dave Young <[email protected]> wrote:
Quoted 102 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.So add an -a option that tries
KEXEC_FILE_LOADand when it is not supported triesKEXEC_LOAD.Signed-off-by Michal Suchanek <[email protected]>---
v3: instead of changing the deafult add extra option
v4: actually check-ENOSYSas well--- kexec/kexec.c | 52++++++++++++++++++++++++++++++++++++++++++++++++----
kexec/kexec.h| 4 +++- 2 files changed, 51 insertions(+), 5 deletions(-)kexec/kexec.c +15
-4@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =0 ;int do_status =0 ;void *entry =0 ;char *type =0 ;@@ -1367,10 +1368,15 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ;break ;case OPT_KEXEC_SYSCALL : do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ;break ; +case OPT_KEXEC_SYSCALL_AUTO : + do_kexec_file_syscall =1 ; + do_kexec_fallback =1 ;case OPT_STATUS : do_status =1 ;break ;@@ -1442,16 +1448,54 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification.
kexec/kexec.c +10
-0+* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +/* +* By default reject or do nothing if
kexec/kexec.c +6
-0+* succeded +*/ +default :break ; +case -ENOSYS :/* not implemented */ +/* +* Parsing image or other options failed
kexec/kexec.c +1
-0+* The image may be invalid or image
kexec/kexec.c +1
-0+* type may not supported by kernel so
kexec/kexec.c +1
-0+* retry parsing in kexec-tools.
kexec/kexec.c +5
-0+*/ +case -EINVAL : +case -ENOEXEC : +/* +* ENOTSUPP can be Quoted 8 lines
kexec/kexec.c int main(int argc, char *argv[]) · line 1493
Quoted 6 lines
unsupported image
kexec/kexec.c +1
-0+* type or unsupported PE signature
kexec/kexec.c +3
-0+* wrapper type, duh +*/ +case -ENOTSUP :Shouldn't this be
-ENOTSUPP?
Quoted 2 lines
No, ENOTSUP and EOPNOTSUPP is defined. The latter is for socket operations.
Your code comment "ENOTSUPP can be unsupported image", but your
code use ENOTSUP, ENOTSUP != ENOTSUPP here.
Quoted 4 lines
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v4 5/5 kexec: document -s, -c and -a options.
In reply to Michal Suchanek--- kexec/kexec.8 | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
kexec/kexec.8 +15 -0
@@ -144,6 +144,21 @@ Load the new kernel for use on panic. Specify that the new kernel is of this .I type. .TP +.BI \-s\ (\-\-kexec-file-syscall) +Specify that the new KEXEC_FILE_LOAD syscall should be used exclusively. +.TP +.BI \-c\ (\-\-kexec-syscall) +Specify that the old KEXEC_LOAD syscall should be used exclusively (the default). +.TP +.BI \-a\ (\-\-kexec-syscall-auto) +Try the new simpler KEXEC_FILE_LOAD syscall first and if it is not supported +fall back to the old KEXEC_LOAD interface. + +There is no one single interface that always works. KEXEC_FILE_LOAD is required +on systems that use locked-down secure boot to verify the kernel signature. +KEXEC_LOAD is required for some kernel image formats and on architectures that +do not support KEXEC_FILE_LOAD. +.TP .B \-u\ (\-\-unload) Unload the current .B kexec
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 5/5] kexec: document -s, -c and -a options.
Quoted 10 lines · Michal Suchanek
Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.8 | 15 +++++++++++++++ 1 file changed, 15 insertions(+)kexec/kexec.8 +0
-0
kexec/kexec.8 Load the new kernel for use on panic. · line 148
Quoted 5 lines
kexec/kexec.8 +2
-0@@ -144,6 +144,21 @@ Load the new kernel for use on panic. Specify that the new kernel is of this .I type. .TP +.BI \-s\ (\-\-kexec-file-syscall) +Specify that the new KEXEC_FILE_LOAD syscall should be used exclusively.
Maybe better to be simple like below:
"Use kexec_file_load syscall to load the new kernel."
kexec/kexec.8 Load the new kernel for use on panic. · line 151
Quoted 3 lines
kexec/kexec.8 +3
-0+.TP +.BI \-c\ (\-\-kexec-syscall) +Specify that the old KEXEC_LOAD syscall should be used exclusively (the default).
similarly:
"Use kexec_load syscall to load the new kernel."
kexec/kexec.8 Load the new kernel for use on panic. · line 160
Quoted 9 lines
kexec/kexec.8 +9
-0+.TP +.BI \-a\ (\-\-kexec-syscall-auto) +Try the new simpler KEXEC_FILE_LOAD syscall first and if it is not supported +fall back to the old KEXEC_LOAD interface. + +There is no one single interface that always works. KEXEC_FILE_LOAD is required +on systems that use locked-down secure boot to verify the kernel signature. +KEXEC_LOAD is required for some kernel image formats and on architectures that +do not support KEXEC_FILE_LOAD.
It seems not good to say kexec_file_load is simpler and newer. Also it is not a must for Secure Boot and locked down kernel only. So it would be better to just simplify and use the first paragraph:
"Try kexec_file_load syscall first and if it is not supported fall back to the kexec_load syscall"
Quoted 7 lines
kexec/kexec.8 +1
-0+.TP .B \-u\ (\-\-unload) Unload the current .B kexecSignature · 1 line
2.13.6
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 5/5] kexec: document -s, -c and -a options.
Quoted 45 lines · On Wed, 14 Mar 2018 11:41:30 +0800 Dave Young <[email protected]> wrote:
Quoted 15 lines · Michal Suchanek
Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.8 | 15 +++++++++++++++ 1 file changed, 15 insertions(+)kexec/kexec.8 +2
-0@@ -144,6 +144,21 @@ Load the new kernel for use on panic. Specify that the new kernel is of this .I type. .TP +.BI \-s\ (\-\-kexec-file-syscall) +Specify that the new KEXEC_FILE_LOAD syscall should be usedQuoted 1 line
exclusively.
Maybe better to be simple like below:
"Usekexec_file_loadsyscall to load the new kernel."Quoted 4 lines
+.TP
+.BI \-c\ (\-\-kexec-syscall)
+Specify that the oldKEXEC_LOADsyscall should be used exclusively (the default).similarly:
"Usekexec_loadsyscall to load the new kernel."Quoted 10 lines
+.TP
+.BI \-a\ (\-\-kexec-syscall-auto)
+Try the new simplerKEXEC_FILE_LOADsyscall first and if it is not supported +fall back to the oldKEXEC_LOADinterface.kexec/kexec.8 +2
-0+ +There is no one single interface that always works.
KEXEC_FILE_LOADis required +on systems that use locked-down secure boot to verify the kernel signature. +KEXEC_LOAD is required for some kernel image formats and on architectures that +do not supportKEXEC_FILE_LOAD.It seems not good to say
kexec_file_loadis simpler and newer. Also it is not a must for Secure Boot and locked down kernel only. So it would be better to just simplify and use the first paragraph:
Quoted 2 lines
"Try
kexec_file_loadsyscall first and if it is not supported fall back to thekexec_loadsyscall"
There was a request for explanation so just the first paragraph will not do. What is it required for other than secure boot?
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 5/5] kexec: document -s, -c and -a options.
Quoted 48 lines · Michal Suchánek
Quoted 45 lines · On Wed, 14 Mar 2018 11:41:30 +0800 Dave Young <[email protected]> wrote:
Quoted 15 lines · Michal Suchanek
Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.8 | 15 +++++++++++++++ 1 file changed, 15 insertions(+)kexec/kexec.8 +2
-0@@ -144,6 +144,21 @@ Load the new kernel for use on panic. Specify that the new kernel is of this .I type. .TP +.BI \-s\ (\-\-kexec-file-syscall) +Specify that the new KEXEC_FILE_LOAD syscall should be usedQuoted 1 line
exclusively.
Maybe better to be simple like below:
"Usekexec_file_loadsyscall to load the new kernel."Quoted 4 lines
+.TP
+.BI \-c\ (\-\-kexec-syscall)
+Specify that the oldKEXEC_LOADsyscall should be used exclusively (the default).similarly:
"Usekexec_loadsyscall to load the new kernel."Quoted 10 lines
+.TP
+.BI \-a\ (\-\-kexec-syscall-auto)
+Try the new simplerKEXEC_FILE_LOADsyscall first and if it is not supported +fall back to the oldKEXEC_LOADinterface.kexec/kexec.8 +2
-0+ +There is no one single interface that always works.
KEXEC_FILE_LOADis required +on systems that use locked-down secure boot to verify the kernel signature. +KEXEC_LOAD is required for some kernel image formats and on architectures that +do not supportKEXEC_FILE_LOAD.It seems not good to say
kexec_file_loadis simpler and newer. Also it is not a must for Secure Boot and locked down kernel only. So it would be better to just simplify and use the first paragraph:
Quoted 5 lines
Quoted 2 lines
"Try
kexec_file_loadsyscall first and if it is not supported fall back to thekexec_loadsyscall"There was a request for explanation so just the first paragraph will not do. What is it required for other than secure boot?
People can use kexec -s to load a signed kernel but not necessary to boot with Secure Boot enabled.
There is no Secure Boot in powerpc, arm64 now.
Quoted 4 lines
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 5/5] kexec: document -s, -c and -a options.
Quoted 50 lines · On Wed, 14 Mar 2018 15:50:31 +0800 Dave Young <[email protected]> wrote:
Quoted 49 lines · Michal Suchánek
Quoted 46 lines · On Wed, 14 Mar 2018 11:41:30 +0800 Dave Young <[email protected]> wrote:
Quoted 15 lines · Michal Suchanek
Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.8 | 15 +++++++++++++++ 1 file changed, 15 insertions(+)kexec/kexec.8 +2
-0@@ -144,6 +144,21 @@ Load the new kernel for use on panic. Specify that the new kernel is of this .I type. .TP +.BI \-s\ (\-\-kexec-file-syscall) +Specify that the new KEXEC_FILE_LOAD syscall should be usedQuoted 1 line
exclusively.
Maybe better to be simple like below:
"Usekexec_file_loadsyscall to load the new kernel."Quoted 4 lines
+.TP
+.BI \-c\ (\-\-kexec-syscall)
+Specify that the oldKEXEC_LOADsyscall should be used exclusively (the default).similarly:
"Usekexec_loadsyscall to load the new kernel."Quoted 10 lines
+.TP
+.BI \-a\ (\-\-kexec-syscall-auto)
+Try the new simplerKEXEC_FILE_LOADsyscall first and if it is not supported +fall back to the oldKEXEC_LOADinterface.kexec/kexec.8 +2
-0+ +There is no one single interface that always works.
KEXEC_FILE_LOADis required +on systems that use locked-down secure boot to verify the kernel signature. +KEXEC_LOAD is required for some kernel image formats and on architectures that +do not supportKEXEC_FILE_LOAD.It seems not good to say
kexec_file_loadis simpler and newer. Also it is not a must for Secure Boot and locked down kernel only. So it would be better to just simplify and use the first paragraph:
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
"Try
kexec_file_loadsyscall first and if it is not supported fall back to thekexec_loadsyscall"There was a request for explanation so just the first paragraph will not do. What is it required for other than secure boot?
People can use kexec -s to load a signed kernel but not necessary to boot with Secure Boot enabled.
Is booting signed kernel without -s not supported? If so I would consider it kexec-tools bug. And it should documented then as well I guess.
Quoted 2 lines
There is no Secure Boot in powerpc, arm64 now.
Is there not yet? Anyway, the intent is to support it which is probably the reason we have the syscall in the first place.
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 5/5] kexec: document -s, -c and -a options.
Quoted 59 lines · Michal Suchánek
Quoted 56 lines · On Wed, 14 Mar 2018 15:50:31 +0800 Dave Young <[email protected]> wrote:
Quoted 54 lines · Michal Suchánek
Quoted 46 lines · On Wed, 14 Mar 2018 11:41:30 +0800 Dave Young <[email protected]> wrote:
Quoted 15 lines · Michal Suchanek
Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.8 | 15 +++++++++++++++ 1 file changed, 15 insertions(+)kexec/kexec.8 +2
-0@@ -144,6 +144,21 @@ Load the new kernel for use on panic. Specify that the new kernel is of this .I type. .TP +.BI \-s\ (\-\-kexec-file-syscall) +Specify that the new KEXEC_FILE_LOAD syscall should be usedQuoted 1 line
exclusively.
Maybe better to be simple like below:
"Usekexec_file_loadsyscall to load the new kernel."Quoted 4 lines
+.TP
+.BI \-c\ (\-\-kexec-syscall)
+Specify that the oldKEXEC_LOADsyscall should be used exclusively (the default).similarly:
"Usekexec_loadsyscall to load the new kernel."Quoted 10 lines
+.TP
+.BI \-a\ (\-\-kexec-syscall-auto)
+Try the new simplerKEXEC_FILE_LOADsyscall first and if it is not supported +fall back to the oldKEXEC_LOADinterface.kexec/kexec.8 +2
-0+ +There is no one single interface that always works.
KEXEC_FILE_LOADis required +on systems that use locked-down secure boot to verify the kernel signature. +KEXEC_LOAD is required for some kernel image formats and on architectures that +do not supportKEXEC_FILE_LOAD.It seems not good to say
kexec_file_loadis simpler and newer. Also it is not a must for Secure Boot and locked down kernel only. So it would be better to just simplify and use the first paragraph:Quoted 2 lines
"Try
kexec_file_loadsyscall first and if it is not supported fall back to thekexec_loadsyscall"There was a request for explanation so just the first paragraph will not do. What is it required for other than secure boot?
Quoted 6 lines
Quoted 2 lines
People can use kexec -s to load a signed kernel but not necessary to boot with Secure Boot enabled.
Is booting signed kernel without -s not supported? If so I would consider it kexec-tools bug. And it should documented then as well I guess.
I'm not sure I understand the question. In kernel we splitted kexec and kexec_file they can be enabled as kernel config options separately. If one want to a secured kexec (not UEFI Secure Boot, only signed kernel loading) then one can only enable CONFIG_KEXEC_FILE but disable CONFIG_KEXEC. In this case without '-s' load will fail. But if one enabled both CONFIG_KEXEC_FILE and CONFIG_KEXEC then kexec load without '-s' still works.
Quoted 6 lines
Quoted 3 lines
There is no Secure Boot in powerpc, arm64 now.
Is there not yet? Anyway, the intent is to support it which is probably the reason we have the syscall in the first place.
Secure Boot is UEFI only, AFAIK powerpc does not have UEFI, arm64 has UEFI but I do not see Secure Boot.
Also powerpc version kexec_file_load does not have signature verification.
Quoted 4 lines
Thanks
Michal
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 5/5] kexec: document -s, -c and -a options.
Quoted 67 lines · On Fri, 16 Mar 2018 14:51:14 +0800 Dave Young <[email protected]> wrote:
Quoted 59 lines · Michal Suchánek
Quoted 56 lines · On Wed, 14 Mar 2018 15:50:31 +0800 Dave Young <[email protected]> wrote:
Quoted 54 lines · Michal Suchánek
Quoted 46 lines · On Wed, 14 Mar 2018 11:41:30 +0800 Dave Young <[email protected]> wrote:
Quoted 15 lines · Michal Suchanek
Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.8 | 15 +++++++++++++++ 1 file changed, 15 insertions(+)kexec/kexec.8 +2
-0@@ -144,6 +144,21 @@ Load the new kernel for use on panic. Specify that the new kernel is of this .I type. .TP +.BI \-s\ (\-\-kexec-file-syscall) +Specify that the new KEXEC_FILE_LOAD syscall should be usedQuoted 1 line
exclusively.
Maybe better to be simple like below:
"Usekexec_file_loadsyscall to load the new kernel."Quoted 4 lines
+.TP
+.BI \-c\ (\-\-kexec-syscall)
+Specify that the oldKEXEC_LOADsyscall should be used exclusively (the default).similarly:
"Usekexec_loadsyscall to load the new kernel."Quoted 10 lines
+.TP
+.BI \-a\ (\-\-kexec-syscall-auto)
+Try the new simplerKEXEC_FILE_LOADsyscall first and if it is not supported +fall back to the oldKEXEC_LOADinterface. +
+There is no one single interface that always works.KEXEC_FILE_LOADis required +on systems that use locked-down secure boot to verify the kernel signature. +KEXEC_LOAD is required for some kernel image formats and on architectures that +do not supportKEXEC_FILE_LOAD.It seems not good to say
kexec_file_loadis simpler and newer. Also it is not a must for Secure Boot and locked down kernel only. So it would be better to just simplify and use the first paragraph:Quoted 2 lines
"Try
kexec_file_loadsyscall first and if it is not supported fall back to thekexec_loadsyscall"There was a request for explanation so just the first paragraph will not do. What is it required for other than secure boot?
Quoted 6 lines
Quoted 2 lines
People can use kexec -s to load a signed kernel but not necessary to boot with Secure Boot enabled.
Is booting signed kernel without -s not supported? If so I would consider it kexec-tools bug. And it should documented then as well I guess.
Quoted 7 lines
I'm not sure I understand the question. In kernel we splitted kexec and
kexec_filethey can be enabled as kernel config options separately. If one want to a secured kexec (not UEFI Secure Boot, only signed kernel loading) then one can only enableCONFIG_KEXEC_FILEbut disableCONFIG_KEXEC. In this case without '-s' load will fail. But if one enabled bothCONFIG_KEXEC_FILEandCONFIG_KEXECthen kexec load without '-s' still works.
This is currently not supported by kexec-tools. Status does not use KEXEC_FILE
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 5/5] kexec: document -s, -c and -a options.
In reply to Michal SuchanekQuoted 34 lines · Michal Suchanek
Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.8 | 15 +++++++++++++++ 1 file changed, 15 insertions(+)kexec/kexec.8 +15
-0@@ -144,6 +144,21 @@ Load the new kernel for use on panic. Specify that the new kernel is of this .I type. .TP +.BI \-s\ (\-\-kexec-file-syscall) +Specify that the new KEXEC_FILE_LOAD syscall should be used exclusively. +.TP +.BI \-c\ (\-\-kexec-syscall) +Specify that the old KEXEC_LOAD syscall should be used exclusively (the default). +.TP +.BI \-a\ (\-\-kexec-syscall-auto) +Try the new simpler KEXEC_FILE_LOAD syscall first and if it is not supported +fall back to the old KEXEC_LOAD interface. + +There is no one single interface that always works. KEXEC_FILE_LOAD is required +on systems that use locked-down secure boot to verify the kernel signature. +KEXEC_LOAD is required for some kernel image formats and on architectures that +do not support KEXEC_FILE_LOAD. +.TP .B \-u\ (\-\-unload) Unload the current .B kexecSignature · 1 line
2.13.6
Actually while I replied this mail, I tried 'kexec -c -a' system immediately rebooted. Also as I noted in patch 4 a 'break' is missing so does it work on your side?
I think it need more testing.
Another question I have is not sure if '-c' is a good option letter, but I do not have suggestion as well..
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v4 5/5] kexec: document -s, -c and -a options.
Quoted 31 lines · On Wed, 14 Mar 2018 11:43:55 +0800 Dave Young <[email protected]> wrote:
Quoted 30 lines · Michal Suchanek
Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.8 | 15 +++++++++++++++ 1 file changed, 15 insertions(+)kexec/kexec.8 +2
-0@@ -144,6 +144,21 @@ Load the new kernel for use on panic. Specify that the new kernel is of this .I type. .TP +.BI \-s\ (\-\-kexec-file-syscall) +Specify that the new KEXEC_FILE_LOAD syscall should be usedexclusively. +.TP
+.BI \-c\ (\-\-kexec-syscall)
+Specify that the oldKEXEC_LOADsyscall should be used exclusively (the default). +.TP
+.BI \-a\ (\-\-kexec-syscall-auto)
+Try the new simplerKEXEC_FILE_LOADsyscall first and if it is not supported +fall back to the oldKEXEC_LOADinterface.kexec/kexec.8 +2
-0+ +There is no one single interface that always works.
KEXEC_FILE_LOADis required +on systems that use locked-down secure boot to verify the kernel signature. +KEXEC_LOAD is required for some kernel image formats and on architectures that +do not supportKEXEC_FILE_LOAD. +.TP
.B \-u\ (\-\-unload)
Unload the current
Quoted 8 lines
Quoted 4 lines
.B kexec
Signature · 1 line
2.13.6Actually while I replied this mail, I tried 'kexec -c -a' system immediately rebooted. Also as I noted in patch 4 a 'break' is missing so does it work on your side?
Right, the original single-patch code had a bug which is now fixed but new one crept in. Since we still don't agree how it *should* behave it is too early to say it deviates from expectation.
If we agree what it should do but it turns out to be broken it can be fixed after the fact, too.
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 4/5] kexec: fallback to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
In reply to Michal SuchanekQuoted 8 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.When no option is passed to select one syscall or the other try
KEXEC_FILE_LOADand fall back toKEXEC_LOADwhen not suported.
Again, IMHO the default behavior should not be changed..
Quoted 91 lines
Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-)kexec/kexec.c +39
-4@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =1 ;int do_status =0 ;void *entry =0 ;char *type =0 ;@@ -1367,9 +1368,11 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ;break ;case OPT_KEXEC_SYSCALL : do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ;break ;case OPT_STATUS : do_status =1 ;@@ -1442,16 +1445,48 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification. +* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +case -ENOTSUPP : +/* +* By default reject or do nothing if +* succeded +*/ +default :break ; +/* +* Parsing image or other options failed +* The image may be invalid or image +* type may not supported by kernel so +* retry parsing in kexec-tools. +*/ +case -EINVAL : +case -ENOEXEC : + do_kexec_file_syscall =0 ; +break ; + } + } +if (!do_kexec_file_syscall) result =my_load (type, fileind, argc, argv, kexec_flags, entry); }Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 4/5] kexec: fallback to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
Quoted 8 lines · On Fri, 2 Mar 2018 17:24:19 +0800 Dave Young <[email protected]> wrote:
Quoted 7 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.
Quoted 4 lines
Quoted 2 lines
When no option is passed to select one syscall or the other try
KEXEC_FILE_LOADand fall back toKEXEC_LOADwhen not suported.Again, IMHO the default behavior should not be changed..
So adding a new option to enable the fallback would be ok?
Thanks
Michal
Quoted 96 lines
Quoted 96 lines
Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-)kexec/kexec.c +12
-4@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =1 ;int do_status =0 ;void *entry =0 ;char *type =0 ;@@ -1367,9 +1368,11 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ;break ;case OPT_KEXEC_SYSCALL : do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ;break ;case OPT_STATUS : do_status =1 ;@@ -1442,16 +1445,48 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification.
kexec/kexec.c +11
-0+* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +case -ENOTSUPP : +/* +* By default reject or do nothing if
kexec/kexec.c +5
-0+* succeded +*/ +default :break ; +/* +* Parsing image or other options failed
kexec/kexec.c +1
-0+* The image may be invalid or image
kexec/kexec.c +1
-0+* type may not supported by kernel so
kexec/kexec.c +1
-0+* retry parsing in kexec-tools.
kexec/kexec.c +8
-0+*/ +case -EINVAL : +case -ENOEXEC : + do_kexec_file_syscall =0 ; +break ; + } + } +if (!do_kexec_file_syscall) result = my_load(type, fileind, argc, argv, kexec_flags,entry); }
Signature · 1 line
2.13.6
Quoted 7 lines
Quoted 4 lines
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexecThanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 4/5] kexec: fallback to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
Quoted 11 lines · Michal Suchánek
Quoted 8 lines · On Fri, 2 Mar 2018 17:24:19 +0800 Dave Young <[email protected]> wrote:
Quoted 7 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
When no option is passed to select one syscall or the other try
KEXEC_FILE_LOADand fall back toKEXEC_LOADwhen not suported.Again, IMHO the default behavior should not be changed..
So adding a new option to enable the fallback would be ok?
I am also wary of changing the default behaviour and I think a new fallback option would be better.
Dave?
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 4/5] kexec: fallback to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
Quoted 16 lines · On Fri, 2 Mar 2018 13:46:10 +0100 Simon Horman <[email protected]> wrote:
Quoted 15 lines · Michal Suchánek
Quoted 12 lines · On Fri, 2 Mar 2018 17:24:19 +0800 Dave Young <[email protected]> wrote:
Quoted 10 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.When no option is passed to select one syscall or the other try
KEXEC_FILE_LOADand fall back toKEXEC_LOADwhen not suported.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Again, IMHO the default behavior should not be changed..
So adding a new option to enable the fallback would be ok?
I am also wary of changing the default behaviour and I think a new fallback option would be better.
Dave?
Ok, I will resend with a separate fallback option.
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v3 1/5 kexec: Return -ENOSYS when kexec does not know how to call KEXEC_FILE_LOAD
In reply to Simon HormanWhen the kernel does not know a syscall number it returns -ENOSYS but when kexec does not know a syscall number it returns -1. Return -ENOSYS from kexec as well.
--- kexec/kexec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kexec/kexec.c +1 -1
@@ -1166,7 +1166,7 @@ static int do_kexec_file_load(int fileind, int argc, char **argv,if (!is_kexec_file_load_implemented ()) {fprintf (stderr,"syscall kexec_file_load not available.\n" ); -return -1 ; +return -ENOSYS ; }if (argc - fileind <=0 ) {
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v3 2/5 kexec: do not special-case the -s option
It is parsed separately to save a few CPU cycles when setting up other options but it just complicates the code. So fold it back and set up all flags both for KEXEC_LOAD and KEXEC_FILE_LOAD
--- kexec/kexec.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)
kexec/kexec.c +4 -21
@@ -1256,19 +1256,6 @@ int main(int argc, char *argv[]) };static const char short_options[] =KEXEC_ALL_OPT_STR ; -/* -* First check if --use-kexec-file-syscall is set. That changes lot of -* things -*/ -while ((opt =getopt_long (argc, argv, short_options, - options,0 )) !=-1 ) { -switch (opt) { -case OPT_KEXEC_FILE_SYSCALL : - do_kexec_file_syscall =1 ; -break ; - } - } -/* Reset getopt for the next pass. */ opterr =1 ; optind =1 ;
@@ -1310,8 +1297,7 @@ int main(int argc, char *argv[]) do_shutdown =0 ; do_sync =0 ; do_unload =1 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_UNLOAD ; + kexec_file_flags |=KEXEC_FILE_UNLOAD ;break ;case OPT_EXEC : do_load =0 ;
@@ -1354,11 +1340,8 @@ int main(int argc, char *argv[]) do_exec =0 ; do_shutdown =0 ; do_sync =0 ; -if (do_kexec_file_syscall) - kexec_file_flags |=KEXEC_FILE_ON_CRASH ; -else - kexec_flags =KEXEC_ON_CRASH ; -break ; + kexec_file_flags |=KEXEC_FILE_ON_CRASH ; + kexec_flags =KEXEC_ON_CRASH ;case OPT_MEM_MIN : mem_min =strtoul (optarg, &endptr,0 );if (*endptr) {
@@ -1383,7 +1366,7 @@ int main(int argc, char *argv[]) do_reuse_initrd =1 ;break ;case OPT_KEXEC_FILE_SYSCALL : -/* We already parsed it. Nothing to do. */ + do_kexec_file_syscall =1 ;break ;case OPT_STATUS : do_status =1 ;
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v3 3/5 kexec: add option to revert -s
In reply to Michal SuchanekThe undocumented -s option selects KEXEC_FILE_LOAD syscall but there is no option to select KEXEC_LOAD syscall so add it. It is generally good idea and in followup patch the default will be changed so it will be needed to get KEXEC_LOAD functionality.
--- kexec/kexec.c | 3 +++ kexec/kexec.h | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-)
kexec/kexec.c +3 -0
@@ -1368,6 +1368,9 @@ int main(int argc, char *argv[])case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ;break ; +case OPT_KEXEC_SYSCALL : + do_kexec_file_syscall =0 ; +break ;case OPT_STATUS : do_status =1 ;break ;
kexec/kexec.h +3 -1
@@ -219,6 +219,7 @@ extern int file_types;#define OPT_TYPE 't'#define OPT_PANIC 'p'#define OPT_KEXEC_FILE_SYSCALL 's' +#define OPT_KEXEC_SYSCALL 'c'#define OPT_STATUS 'S'#define OPT_MEM_MIN 256#define OPT_MEM_MAX 257
@@ -246,11 +247,12 @@ extern int file_types; { "mem-max", 1, 0, OPT_MEM_MAX }, \ { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ + { "kexec-syscall", 0, 0, OPT_KEXEC_SYSCALL }, \ { "debug", 0, 0, OPT_DEBUG }, \ { "status", 0, 0, OPT_STATUS }, \ { "print-ckr-size", 0, 0, OPT_PRINT_CKR_SIZE }, \ -#define KEXEC_OPT_STR "h?vdfxyluet:psS" +#define KEXEC_OPT_STR "h?vdfxyluet:pscS" extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);extern void die (const char *fmt, ...)
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v3 4/5 kexec: fallback to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
In reply to Michal SuchanekNot all architectures implement KEXEC_FILE_LOAD. However, on some archiectures KEXEC_FILE_LOAD is required when secure boot is enabled in locked-down mode. Previously users had to select the KEXEC_FILE_LOAD syscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.
When no option is passed to select one syscall or the other try KEXEC_FILE_LOAD and fall back to KEXEC_LOAD when not suported.
--- kexec/kexec.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- kexec/kexec.h | 4 +++- 2 files changed, 50 insertions(+), 5 deletions(-)
kexec/kexec.c +47 -4
@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =0 ;int do_status =0 ;void *entry =0 ;char *type =0 ;
@@ -1367,10 +1368,15 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ;break ;case OPT_KEXEC_SYSCALL : do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ;break ; +case OPT_KEXEC_SYSCALL_AUTO : + do_kexec_file_syscall =1 ; + do_kexec_fallback =1 ;case OPT_STATUS : do_status =1 ;break ;
@@ -1442,16 +1448,53 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification. +* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +/* +* By default reject or do nothing if +* succeded +*/ +default :break ; +/* +* Parsing image or other options failed +* The image may be invalid or image +* type may not supported by kernel so +* retry parsing in kexec-tools. +*/ +case -EINVAL : +case -ENOEXEC : +/* +* ENOTSUPP can be unsupported image +* type or unsupported PE signature +* wrapper type, duh +*/ +case -ENOTSUP : + do_kexec_file_syscall =0 ; +break ; + } + } +if (!do_kexec_file_syscall) result =my_load (type, fileind, argc, argv, kexec_flags, entry); }
kexec/kexec.h +3 -1
@@ -220,6 +220,7 @@ extern int file_types;#define OPT_PANIC 'p'#define OPT_KEXEC_FILE_SYSCALL 's'#define OPT_KEXEC_SYSCALL 'c' +#define OPT_KEXEC_SYSCALL_AUTO 'a'#define OPT_STATUS 'S'#define OPT_MEM_MIN 256#define OPT_MEM_MAX 257
@@ -248,11 +249,12 @@ extern int file_types; { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ { "kexec-syscall", 0, 0, OPT_KEXEC_SYSCALL }, \ + { "kexec-syscall-auto", 0, 0, OPT_KEXEC_SYSCALL_AUTO }, \ { "debug", 0, 0, OPT_DEBUG }, \ { "status", 0, 0, OPT_STATUS }, \ { "print-ckr-size", 0, 0, OPT_PRINT_CKR_SIZE }, \ -#define KEXEC_OPT_STR "h?vdfxyluet:pscS" +#define KEXEC_OPT_STR "h?vdfxyluet:pscaS" extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);extern void die (const char *fmt, ...)
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v3 4/5] kexec: fallback to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
Quoted 9 lines · On Fri, 2 Mar 2018 14:33:02 +0100 Michal Suchanek <[email protected]> wrote:
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.When no option is passed to select one syscall or the other try
KEXEC_FILE_LOADand fall back toKEXEC_LOADwhen not suported.
I forgot to update the description. meh
Quoted 127 lines
Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 51+++++++++++++++++++++++++++++++++++++++++++++++----
kexec/kexec.h| 4 +++- 2 files changed, 50 insertions(+), 5 deletions(-)kexec/kexec.c +15
-4@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =0 ;int do_status =0 ;void *entry =0 ;char *type =0 ;@@ -1367,10 +1368,15 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ;break ;case OPT_KEXEC_SYSCALL : do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ;break ; +case OPT_KEXEC_SYSCALL_AUTO : + do_kexec_file_syscall =1 ; + do_kexec_fallback =1 ;case OPT_STATUS : do_status =1 ;break ;@@ -1442,16 +1448,53 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification.
kexec/kexec.c +10
-0+* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +/* +* By default reject or do nothing if
kexec/kexec.c +5
-0+* succeded +*/ +default :break ; +/* +* Parsing image or other options failed
kexec/kexec.c +1
-0+* The image may be invalid or image
kexec/kexec.c +1
-0+* type may not supported by kernel so
kexec/kexec.c +1
-0+* retry parsing in kexec-tools.
kexec/kexec.c +5
-0+*/ +case -EINVAL : +case -ENOEXEC : +/* +* ENOTSUPP can be unsupported image
kexec/kexec.c +1
-0+* type or unsupported PE signature
kexec/kexec.c +8
-0+* wrapper type, duh +*/ +case -ENOTSUP : + do_kexec_file_syscall =0 ; +break ; + } + } +if (!do_kexec_file_syscall) result =my_load (type, fileind, argc, argv, kexec_flags, entry); }kexec/kexec.h +3
-1@@ -220,6 +220,7 @@ extern int file_types;#define OPT_PANIC 'p'#define OPT_KEXEC_FILE_SYSCALL 's'#define OPT_KEXEC_SYSCALL 'c' +#define OPT_KEXEC_SYSCALL_AUTO 'a'#define OPT_STATUS 'S'#define OPT_MEM_MIN 256#define OPT_MEM_MAX 257@@ -248,11 +249,12 @@ extern int file_types; { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ { "kexec-syscall", 0, 0, OPT_KEXEC_SYSCALL }, \ + { "kexec-syscall-auto", 0, 0, OPT_KEXEC_SYSCALL_AUTO }, \ { "debug", 0, 0, OPT_DEBUG }, \ { "status", 0, 0, OPT_STATUS }, \ { "print-ckr-size", 0, 0, OPT_PRINT_CKR_SIZE }, \ -#define KEXEC_OPT_STR "h?vdfxyluet:pscS" +#define KEXEC_OPT_STR "h?vdfxyluet:pscaS" extern void dbgprint_mem_range(const char *prefix, struct
Quoted 1 line
memory_range*mr, intnr_mr); extern voiddie(const char *fmt, ...)
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH 1/1 kexec: add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
In reply to Michal SuchanekNot all architectures implement KEXEC_FILE_LOAD. However, on some archiectures KEXEC_FILE_LOAD is required when secure boot is enabled in locked-down mode. Previously users had to select the KEXEC_FILE_LOAD syscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.
So add an -a option that tries KEXEC_FILE_LOAD and when it is not supported tries KEXEC_LOAD.
--- kexec/kexec.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- kexec/kexec.h | 4 +++- 2 files changed, 50 insertions(+), 5 deletions(-)
kexec/kexec.c +47 -4
@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =0 ;int do_status =0 ;void *entry =0 ;char *type =0 ;
@@ -1367,10 +1368,15 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ;break ;case OPT_KEXEC_SYSCALL : do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ;break ; +case OPT_KEXEC_SYSCALL_AUTO : + do_kexec_file_syscall =1 ; + do_kexec_fallback =1 ;case OPT_STATUS : do_status =1 ;break ;
@@ -1442,16 +1448,53 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification. +* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +/* +* By default reject or do nothing if +* succeded +*/ +default :break ; +/* +* Parsing image or other options failed +* The image may be invalid or image +* type may not supported by kernel so +* retry parsing in kexec-tools. +*/ +case -EINVAL : +case -ENOEXEC : +/* +* ENOTSUPP can be unsupported image +* type or unsupported PE signature +* wrapper type, duh +*/ +case -ENOTSUP : + do_kexec_file_syscall =0 ; +break ; + } + } +if (!do_kexec_file_syscall) result =my_load (type, fileind, argc, argv, kexec_flags, entry); }
kexec/kexec.h +3 -1
@@ -220,6 +220,7 @@ extern int file_types;#define OPT_PANIC 'p'#define OPT_KEXEC_FILE_SYSCALL 's'#define OPT_KEXEC_SYSCALL 'c' +#define OPT_KEXEC_SYSCALL_AUTO 'a'#define OPT_STATUS 'S'#define OPT_MEM_MIN 256#define OPT_MEM_MAX 257
@@ -248,11 +249,12 @@ extern int file_types; { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ { "kexec-syscall", 0, 0, OPT_KEXEC_SYSCALL }, \ + { "kexec-syscall-auto", 0, 0, OPT_KEXEC_SYSCALL_AUTO }, \ { "debug", 0, 0, OPT_DEBUG }, \ { "status", 0, 0, OPT_STATUS }, \ { "print-ckr-size", 0, 0, OPT_PRINT_CKR_SIZE }, \ -#define KEXEC_OPT_STR "h?vdfxyluet:pscS" +#define KEXEC_OPT_STR "h?vdfxyluet:pscaS" extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);extern void die (const char *fmt, ...)
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v3 5/5 kexec: document -s, -c and -a options.
In reply to Michal Suchanek--- kexec/kexec.8 | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
kexec/kexec.8 +15 -0
@@ -144,6 +144,21 @@ Load the new kernel for use on panic. Specify that the new kernel is of this .I type. .TP +.BI \-s\ (\-\-kexec-file-syscall) +Specify that the new KEXEC_FILE_LOAD syscall should be used exclusively. +.TP +.BI \-c\ (\-\-kexec-syscall) +Specify that the old KEXEC_LOAD syscall should be used exclusively (the default). +.TP +.BI \-a\ (\-\-kexec-syscall-auto) +Try the new simpler KEXEC_FILE_LOAD syscall first and if it is not supported +fall back to the old KEXEC_LOAD interface. + +There is no one single interface that always works. KEXEC_FILE_LOAD is required +on systems that use locked-down secure boot to verify the kernel signature. +KEXEC_LOAD is required for some kernel image formats and on architectures that +do not support KEXEC_FILE_LOAD. +.TP .B \-u\ (\-\-unload) Unload the current .B kexec
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 4/5] kexec: fallback to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
In reply to Simon HormanQuoted 15 lines · Simon Horman
Quoted 14 lines · Michal Suchánek
Quoted 11 lines · On Fri, 2 Mar 2018 17:24:19 +0800 Dave Young <[email protected]> wrote:
Quoted 9 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.When no option is passed to select one syscall or the other try
KEXEC_FILE_LOADand fall back toKEXEC_LOADwhen not suported.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Again, IMHO the default behavior should not be changed..
So adding a new option to enable the fallback would be ok?
I am also wary of changing the default behaviour and I think a new fallback option would be better.
Dave?
Simon, I have same feeling, and a new option looks good to me as well
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 4/5] kexec: fallback to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
In reply to Michal SuchanekQuoted 8 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.When no option is passed to select one syscall or the other try
KEXEC_FILE_LOADand fall back toKEXEC_LOADwhen not suported.
Has there been a release of kexec-tools with things arranged they way they currently are?
Can we document this behaviour and the related undocumented options?
Quoted 69 lines
Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-)kexec/kexec.c +29
-4@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])int do_unload =0 ;int do_reuse_initrd =0 ;int do_kexec_file_syscall =0 ; +int do_kexec_fallback =1 ;int do_status =0 ;void *entry =0 ;char *type =0 ;@@ -1367,9 +1368,11 @@ int main(int argc, char *argv[])break ;case OPT_KEXEC_FILE_SYSCALL : do_kexec_file_syscall =1 ; + do_kexec_fallback =0 ;break ;case OPT_KEXEC_SYSCALL : do_kexec_file_syscall =0 ; + do_kexec_fallback =0 ;break ;case OPT_STATUS : do_status =1 ;@@ -1442,16 +1445,48 @@ int main(int argc, char *argv[]) result =k_status (kexec_flags); }if (do_unload) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =kexec_file_unload (kexec_file_flags); -else +if ((result == -ENOSYS ) && do_kexec_fallback) + do_kexec_file_syscall =0 ; + } +if (!do_kexec_file_syscall) result =k_unload (kexec_flags); }if (do_load && (result ==0 )) { -if (do_kexec_file_syscall) +if (do_kexec_file_syscall) { result =do_kexec_file_load (fileind, argc, argv, kexec_file_flags); -else +if (do_kexec_fallback)switch (result) { +/* +* Something failed with signature verification. +* Reject the image. +*/ +case -ELIBBAD : +case -EKEYREJECTED : +case -ENOPKG : +case -ENOKEY : +case -EBADMSG : +case -EMSGSIZE : +case -ENOTSUPP : +/* +* By default reject or do nothing if +* succeded +*/ +default :break ; +/* +* Parsing image or other options failed +* The image may be invalid or image
kexec/kexec.c int main(int argc, char *argv[]) · line 1489
Quoted 10 lines
kexec/kexec.c +10
-0+* type may not supported by kernel so +* retry parsing in kexec-tools. +*/ +case -EINVAL : +case -ENOEXEC : + do_kexec_file_syscall =0 ; +break ; + } + } +if (!do_kexec_file_syscall)
How about:
if (do_kexec_file_syscall) {
result = ...;
/* Comment */
if (do_kexec_fallback &&
(result == -EINVAL || result == -ENOEXEC))
do_kexec_file_syscall = 0;
}
if (!do_kexec_file_syscall)
result = ...;Quoted 6 lines
kexec/kexec.c +0
-0result =my_load (type, fileind, argc, argv, kexec_flags, entry); }Signature · 1 line
2.13.6
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 4/5] kexec: fallback to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported.
Quoted 8 lines · On Fri, 2 Mar 2018 13:44:58 +0100 Simon Horman <[email protected]> wrote:
Quoted 7 lines · Michal Suchanek
Not all architectures implement
KEXEC_FILE_LOAD. However, on some archiecturesKEXEC_FILE_LOADis required when secure boot is enabled in locked-down mode. Previously users had to select theKEXEC_FILE_LOADsyscall with undocumented -s option. However, if they did pass the option kexec would fail on architectures that do not support it.
Quoted 5 lines
Quoted 2 lines
When no option is passed to select one syscall or the other try
KEXEC_FILE_LOADand fall back toKEXEC_LOADwhen not suported.Has there been a release of kexec-tools with things arranged they way they currently are?
$ git tag --contains 046d1755d2bd723a11a180c265e61a884990712e v2.0.10 v2.0.10-rc1 v2.0.11 v2.0.11-rc1 v2.0.12 v2.0.12-rc1 v2.0.13 v2.0.13-rc1 v2.0.14 v2.0.14-rc1 v2.0.15 v2.0.15-rc1 v2.0.16-rc1 v2.0.8 v2.0.8-rc1 v2.0.9 v2.0.9-rc1
Quoted 2 lines
Can we document this behaviour and the related undocumented options?
It's done in a followup patch.
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH 5/5 kexec: document -s and -c options.
In reply to Michal Suchanek--- kexec/kexec.8 | 7 +++++++ 1 file changed, 7 insertions(+)
kexec/kexec.8 +7 -0
@@ -144,6 +144,13 @@ Load the new kernel for use on panic. Specify that the new kernel is of this .I type. .TP +.BI \-s\ (\-\-kexec-file-syscall) +Specify that the new KEXEC_FILE_LOAD syscall should be used exclusively. +Otherwise KEXEC_FILE_LOAD is tried and when not supported KEXEC_LOAD is used. +.TP +.BI \-c\ (\-\-kexec-syscall) +Specify that the old KEXEC_LOAD syscall should be used exclusively. +.TP .B \-u\ (\-\-unload) Unload the current .B kexec
Signature · 7 lines
2.13.6 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Quoted 14 lines · Michal Suchanek
When the kernel does not know a syscall number it returns
-ENOSYSbut when kexec does not know a syscall number it returns -1. Return-ENOSYSfrom kexec as well.Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kexec/kexec.c +0
-0
kexec/kexec.c static int do_kexec_file_load(int fileind, int argc, char **argv, · line 1169
Quoted 5 lines
kexec/kexec.c +1
-1@@ -1166,7 +1166,7 @@ static int do_kexec_file_load(int fileind, int argc, char **argv,if (!is_kexec_file_load_implemented ()) {fprintf (stderr,"syscall kexec_file_load not available.\n" ); -return -1 ; +return -ENOSYS ;
It seems to me that the current with do_kexec_file_load() returning 0 for success and -1 for error. I think any change to that scheme would need to be more comprehensive than this.
Quoted 6 lines
kexec/kexec.c +0
-0}if (argc - fileind <=0 ) {Signature · 1 line
2.13.6
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 10 lines · On Fri, 2 Mar 2018 13:34:45 +0100 Simon Horman <[email protected]> wrote:
Quoted 9 lines · Michal Suchanek
When the kernel does not know a syscall number it returns
-ENOSYSbut when kexec does not know a syscall number it returns -1. Return-ENOSYSfrom kexec as well.Signed-off-by Michal Suchanek <[email protected]>--- kexec/kexec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
kexec/kexec.c static int do_kexec_file_load(int fileind, · line 1170
Quoted 11 lines
kexec/kexec.c +1
-1@@ -1166,7 +1166,7 @@ static int do_kexec_file_load(int fileind, int argc, char **argv, if (!is_kexec_file_load_implemented()) { fprintf(stderr, "syscall kexec_file_load not available.\n"); -return -1 ; +return -ENOSYS ;It seems to me that the current with
do_kexec_file_load()returning 0 for success and -1 for error. I think any change to that scheme would need to be more comprehensive than this.
It looks to me that the return value from the actual syscall is passed through as the return value of kexec, at least for kexec_file_load. So this only fixes that one occasion when -ENOSYS can originate from kexec itself. Sure, there are more return values that could be made more sensible.
Thanks
Michal
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec