From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mx2.suse.de ([195.135.220.15]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1esuEv-0003Qx-0b for kexec@lists.infradead.org; Mon, 05 Mar 2018 17:49:34 +0000 Date: Mon, 5 Mar 2018 18:49:17 +0100 From: Michal =?UTF-8?B?U3VjaMOhbmVr?= Subject: Re: [PATCH 4/5] kexec: fallback to KEXEC_LOAD when KEXEC_FILE_LOAD is not supported. Message-ID: <20180305184917.53b7404b@kitsune.suse.cz> In-Reply-To: <20180302091706.GA15374@dhcp-128-65.nay.redhat.com> References: <20180302091706.GA15374@dhcp-128-65.nay.redhat.com> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: Dave Young Cc: Tony Jones , horms@verge.net.au, kexec@lists.infradead.org, Petr Tesarik On Fri, 2 Mar 2018 17:17:06 +0800 Dave Young wrote: > On 02/26/18 at 01:00pm, Michal Suchanek wrote: > > Not 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. > > > > Signed-off-by: Michal Suchanek > > --- > > kexec/kexec.c | 43 +++++++++++++++++++++++++++++++++++++++---- > > 1 file changed, 39 insertions(+), 4 deletions(-) > > > > diff --git a/kexec/kexec.c b/kexec/kexec.c > > index a95cfb473d6b..14f56e466a95 100644 > > --- a/kexec/kexec.c > > +++ b/kexec/kexec.c > > @@ -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: 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. > > + 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; > > 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. > I assumed only fallback in > case -ENOSYS which is not even listed. Thanks Michal _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec