From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754742AbcGEH6j (ORCPT ); Tue, 5 Jul 2016 03:58:39 -0400 Received: from mail-pf0-f179.google.com ([209.85.192.179]:33423 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751704AbcGEH6f (ORCPT ); Tue, 5 Jul 2016 03:58:35 -0400 Date: Tue, 5 Jul 2016 17:03:57 +0900 From: AKASHI Takahiro To: Dave Young Cc: Thiago Jung Bauermann , kexec@lists.infradead.org, ebiederm@xmission.com, bhe@redhat.com, vgoyal@redhat.com, will.deacon@arm.com, catalin.marinas@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [RFC] arm64: kexec_file_load support Message-ID: <20160705080355.GQ20774@linaro.org> Mail-Followup-To: AKASHI Takahiro , Dave Young , Thiago Jung Bauermann , kexec@lists.infradead.org, ebiederm@xmission.com, bhe@redhat.com, vgoyal@redhat.com, will.deacon@arm.com, catalin.marinas@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org References: <20160701051111.GL20774@linaro.org> <3300473.zhbeG65qgA@hactar> <20160704065814.GO20774@linaro.org> <20160705012556.GC8190@dhcp-128-65.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-2022-jp Content-Disposition: inline In-Reply-To: <20160705012556.GC8190@dhcp-128-65.nay.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dave, On Tue, Jul 05, 2016 at 09:25:56AM +0800, Dave Young wrote: > On 07/04/16 at 03:58pm, AKASHI Takahiro wrote: > > Hi, > > > > On Fri, Jul 01, 2016 at 12:46:31PM -0300, Thiago Jung Bauermann wrote: > > > Am Freitag, 01 Juli 2016, 14:11:12 schrieb AKASHI Takahiro: > > > > I'm not sure whether there is any demand for kexec_file_load > > > > support on arm64, but anyhow I'm working on this and now > > > > my early prototype code does work fine. > > > > > > It is necessary if you want to support loading only signed kernels, and also > > > if you want IMA to measure the kernel in its event log. > > > > > > > There is, however, one essential issue: > > > > While arm64 kernel requires a device tree blob to be set up > > > > correctly at boot time, the current system call API doesn't > > > > have this parameter. > > > > int kexec_file_load(int kernel_fd, int initrd_fd, > > > > unsigned long cmdline_len, const char > > > > *cmdline_ptr, unsigned long flags); > > > > > > > > Should we invent a new system call, like kexec_file_load2, > > > > and, if so, what kind of interface would be desired? > > > > > > I'm facing the same issue on powerpc. What I'm doing is taking the device > > > tree that was used to boot the current kernel and modifying it as necessary > > > to pass it to the next kernel. > > > > That is exactly what I do. > > > > > I agree that it would be better if we could have a system call where a > > > custom device tree could be passed. One suggestion is: > > > > For powerpc, you might be able to use dtbImage instead of Image > > without changing the kernel interfaces. > > > > > > kexec_file_load2(int fds[], int fd_types[], int nr_fds, > > > unsigned long cmdline_len, const char *cmdline_ptr, > > > unsigned long flags); > > > > You don't want to simply add one more argument, i.e. dtb_fd, don't you. > > > > I prefer a slightly-simpler interface: > > struct kexec_file_fd { > > enum kexec_file_type; > > int fd; > > } > > > > int kexec_file_load2(struct kexec_file_fd[], int nr_fds, int flags); > > > > Or if you want to keep the compatibility with the existing system call, > > > > int kexec_file_load(int kernel_fd, int initrd_fd, > > unsigned long cmdline_len, const char *cmdline_ptr, > > unsigned long flags, > > int struct kexec_file_fd[], int nr_fds); > > > > Here SYSCALL_DEFINE7() have to be defined, and I'm not sure that we will not > > have a problem in adding a system call with more than 6 arguments. > > > > > Where fds is an array with nr_fds file descriptors and fd_types is an array > > > specifying what each fd in fds is. So for example, if fds[i] is the kernel, > > > then fd_types[i] would have the value KEXEC_FILE_KERNEL_FD. If fds[i] is the > > > device tree blob, fd_types[i], would have the value KEXEC_FILE_DTB and so > > > on. That way, the syscall can be extended for an arbitrary number and types > > > of segments that have to be loaded, just like kexec_load. > > > > > > Another option is to have a struct: > > > > > > kexec_file_load2(struct kexec_file_params *params, unsigned long params_sz); > > > > Wow, we can add any number of new parameters with this interface. > > > > Thanks, > > -Takahiro AKASHI > > > > > Where: > > > > > > struct kexec_file_params { > > > int version; /* allows struct to be extended in the future */ > > > int fds[]; > > > int fd_types[]; > > > int nr_fds; > > > unsigned long cmdline_len; > > > const char *cmdline_ptr; > > > unsigned long flags; > > > }; > > > > > > This is even more flexible. > > I would like to vote for this one, and use kexec_file_fd fds[] in the struct If we take this approach, we'd better take "flags" out of struct, and my preference would be: enum kexec_file_type { KEXEC_FILE_TYPE_KERNEL; KEXEC_FILE_TYPE_INITRD; KEXEC_FILE_TYPE_DTB; } struct kexec_file_fd { enum kexec_file_type; int fd; } sturct kexec_file_params { int version; unsigned char *cmdline; unsigned long cmdline_len; int nr_fds; struct kexec_file_fd fds[0]; } int kexec_file_load2(int kernel_fd, unsigned long flags, sturct kexec_file_params extra); So we don't have to retrieve extra if KEXEC_FILE_UNLOAD (or kernel_fd < 0?), and only once retrieve extra if extra != NULL && nr_fds == 0. Thanks, -Takahiro AKASHI > Thanks > Dave From mboxrd@z Thu Jan 1 00:00:00 1970 From: takahiro.akashi@linaro.org (AKASHI Takahiro) Date: Tue, 5 Jul 2016 17:03:57 +0900 Subject: [RFC] arm64: kexec_file_load support In-Reply-To: <20160705012556.GC8190@dhcp-128-65.nay.redhat.com> References: <20160701051111.GL20774@linaro.org> <3300473.zhbeG65qgA@hactar> <20160704065814.GO20774@linaro.org> <20160705012556.GC8190@dhcp-128-65.nay.redhat.com> Message-ID: <20160705080355.GQ20774@linaro.org> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi Dave, On Tue, Jul 05, 2016 at 09:25:56AM +0800, Dave Young wrote: > On 07/04/16 at 03:58pm, AKASHI Takahiro wrote: > > Hi, > > > > On Fri, Jul 01, 2016 at 12:46:31PM -0300, Thiago Jung Bauermann wrote: > > > Am Freitag, 01 Juli 2016, 14:11:12 schrieb AKASHI Takahiro: > > > > I'm not sure whether there is any demand for kexec_file_load > > > > support on arm64, but anyhow I'm working on this and now > > > > my early prototype code does work fine. > > > > > > It is necessary if you want to support loading only signed kernels, and also > > > if you want IMA to measure the kernel in its event log. > > > > > > > There is, however, one essential issue: > > > > While arm64 kernel requires a device tree blob to be set up > > > > correctly at boot time, the current system call API doesn't > > > > have this parameter. > > > > int kexec_file_load(int kernel_fd, int initrd_fd, > > > > unsigned long cmdline_len, const char > > > > *cmdline_ptr, unsigned long flags); > > > > > > > > Should we invent a new system call, like kexec_file_load2, > > > > and, if so, what kind of interface would be desired? > > > > > > I'm facing the same issue on powerpc. What I'm doing is taking the device > > > tree that was used to boot the current kernel and modifying it as necessary > > > to pass it to the next kernel. > > > > That is exactly what I do. > > > > > I agree that it would be better if we could have a system call where a > > > custom device tree could be passed. One suggestion is: > > > > For powerpc, you might be able to use dtbImage instead of Image > > without changing the kernel interfaces. > > > > > > kexec_file_load2(int fds[], int fd_types[], int nr_fds, > > > unsigned long cmdline_len, const char *cmdline_ptr, > > > unsigned long flags); > > > > You don't want to simply add one more argument, i.e. dtb_fd, don't you. > > > > I prefer a slightly-simpler interface: > > struct kexec_file_fd { > > enum kexec_file_type; > > int fd; > > } > > > > int kexec_file_load2(struct kexec_file_fd[], int nr_fds, int flags); > > > > Or if you want to keep the compatibility with the existing system call, > > > > int kexec_file_load(int kernel_fd, int initrd_fd, > > unsigned long cmdline_len, const char *cmdline_ptr, > > unsigned long flags, > > int struct kexec_file_fd[], int nr_fds); > > > > Here SYSCALL_DEFINE7() have to be defined, and I'm not sure that we will not > > have a problem in adding a system call with more than 6 arguments. > > > > > Where fds is an array with nr_fds file descriptors and fd_types is an array > > > specifying what each fd in fds is. So for example, if fds[i] is the kernel, > > > then fd_types[i] would have the value KEXEC_FILE_KERNEL_FD. If fds[i] is the > > > device tree blob, fd_types[i], would have the value KEXEC_FILE_DTB and so > > > on. That way, the syscall can be extended for an arbitrary number and types > > > of segments that have to be loaded, just like kexec_load. > > > > > > Another option is to have a struct: > > > > > > kexec_file_load2(struct kexec_file_params *params, unsigned long params_sz); > > > > Wow, we can add any number of new parameters with this interface. > > > > Thanks, > > -Takahiro AKASHI > > > > > Where: > > > > > > struct kexec_file_params { > > > int version; /* allows struct to be extended in the future */ > > > int fds[]; > > > int fd_types[]; > > > int nr_fds; > > > unsigned long cmdline_len; > > > const char *cmdline_ptr; > > > unsigned long flags; > > > }; > > > > > > This is even more flexible. > > I would like to vote for this one, and use kexec_file_fd fds[] in the struct If we take this approach, we'd better take "flags" out of struct, and my preference would be: enum kexec_file_type { KEXEC_FILE_TYPE_KERNEL; KEXEC_FILE_TYPE_INITRD; KEXEC_FILE_TYPE_DTB; } struct kexec_file_fd { enum kexec_file_type; int fd; } sturct kexec_file_params { int version; unsigned char *cmdline; unsigned long cmdline_len; int nr_fds; struct kexec_file_fd fds[0]; } int kexec_file_load2(int kernel_fd, unsigned long flags, sturct kexec_file_params extra); So we don't have to retrieve extra if KEXEC_FILE_UNLOAD (or kernel_fd < 0?), and only once retrieve extra if extra != NULL && nr_fds == 0. Thanks, -Takahiro AKASHI > Thanks > Dave From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-pf0-x22a.google.com ([2607:f8b0:400e:c00::22a]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bKLFv-0000ql-QQ for kexec@lists.infradead.org; Tue, 05 Jul 2016 07:58:57 +0000 Received: by mail-pf0-x22a.google.com with SMTP id i123so67915880pfg.0 for ; Tue, 05 Jul 2016 00:58:35 -0700 (PDT) Date: Tue, 5 Jul 2016 17:03:57 +0900 From: AKASHI Takahiro Subject: Re: [RFC] arm64: kexec_file_load support Message-ID: <20160705080355.GQ20774@linaro.org> References: <20160701051111.GL20774@linaro.org> <3300473.zhbeG65qgA@hactar> <20160704065814.GO20774@linaro.org> <20160705012556.GC8190@dhcp-128-65.nay.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160705012556.GC8190@dhcp-128-65.nay.redhat.com> 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: linux-arm-kernel@lists.infradead.org, bhe@redhat.com, kexec@lists.infradead.org, will.deacon@arm.com, linux-kernel@vger.kernel.org, ebiederm@xmission.com, catalin.marinas@arm.com, Thiago Jung Bauermann , linuxppc-dev@lists.ozlabs.org, vgoyal@redhat.com Hi Dave, On Tue, Jul 05, 2016 at 09:25:56AM +0800, Dave Young wrote: > On 07/04/16 at 03:58pm, AKASHI Takahiro wrote: > > Hi, > > > > On Fri, Jul 01, 2016 at 12:46:31PM -0300, Thiago Jung Bauermann wrote: > > > Am Freitag, 01 Juli 2016, 14:11:12 schrieb AKASHI Takahiro: > > > > I'm not sure whether there is any demand for kexec_file_load > > > > support on arm64, but anyhow I'm working on this and now > > > > my early prototype code does work fine. > > > > > > It is necessary if you want to support loading only signed kernels, and also > > > if you want IMA to measure the kernel in its event log. > > > > > > > There is, however, one essential issue: > > > > While arm64 kernel requires a device tree blob to be set up > > > > correctly at boot time, the current system call API doesn't > > > > have this parameter. > > > > int kexec_file_load(int kernel_fd, int initrd_fd, > > > > unsigned long cmdline_len, const char > > > > *cmdline_ptr, unsigned long flags); > > > > > > > > Should we invent a new system call, like kexec_file_load2, > > > > and, if so, what kind of interface would be desired? > > > > > > I'm facing the same issue on powerpc. What I'm doing is taking the device > > > tree that was used to boot the current kernel and modifying it as necessary > > > to pass it to the next kernel. > > > > That is exactly what I do. > > > > > I agree that it would be better if we could have a system call where a > > > custom device tree could be passed. One suggestion is: > > > > For powerpc, you might be able to use dtbImage instead of Image > > without changing the kernel interfaces. > > > > > > kexec_file_load2(int fds[], int fd_types[], int nr_fds, > > > unsigned long cmdline_len, const char *cmdline_ptr, > > > unsigned long flags); > > > > You don't want to simply add one more argument, i.e. dtb_fd, don't you. > > > > I prefer a slightly-simpler interface: > > struct kexec_file_fd { > > enum kexec_file_type; > > int fd; > > } > > > > int kexec_file_load2(struct kexec_file_fd[], int nr_fds, int flags); > > > > Or if you want to keep the compatibility with the existing system call, > > > > int kexec_file_load(int kernel_fd, int initrd_fd, > > unsigned long cmdline_len, const char *cmdline_ptr, > > unsigned long flags, > > int struct kexec_file_fd[], int nr_fds); > > > > Here SYSCALL_DEFINE7() have to be defined, and I'm not sure that we will not > > have a problem in adding a system call with more than 6 arguments. > > > > > Where fds is an array with nr_fds file descriptors and fd_types is an array > > > specifying what each fd in fds is. So for example, if fds[i] is the kernel, > > > then fd_types[i] would have the value KEXEC_FILE_KERNEL_FD. If fds[i] is the > > > device tree blob, fd_types[i], would have the value KEXEC_FILE_DTB and so > > > on. That way, the syscall can be extended for an arbitrary number and types > > > of segments that have to be loaded, just like kexec_load. > > > > > > Another option is to have a struct: > > > > > > kexec_file_load2(struct kexec_file_params *params, unsigned long params_sz); > > > > Wow, we can add any number of new parameters with this interface. > > > > Thanks, > > -Takahiro AKASHI > > > > > Where: > > > > > > struct kexec_file_params { > > > int version; /* allows struct to be extended in the future */ > > > int fds[]; > > > int fd_types[]; > > > int nr_fds; > > > unsigned long cmdline_len; > > > const char *cmdline_ptr; > > > unsigned long flags; > > > }; > > > > > > This is even more flexible. > > I would like to vote for this one, and use kexec_file_fd fds[] in the struct If we take this approach, we'd better take "flags" out of struct, and my preference would be: enum kexec_file_type { KEXEC_FILE_TYPE_KERNEL; KEXEC_FILE_TYPE_INITRD; KEXEC_FILE_TYPE_DTB; } struct kexec_file_fd { enum kexec_file_type; int fd; } sturct kexec_file_params { int version; unsigned char *cmdline; unsigned long cmdline_len; int nr_fds; struct kexec_file_fd fds[0]; } int kexec_file_load2(int kernel_fd, unsigned long flags, sturct kexec_file_params extra); So we don't have to retrieve extra if KEXEC_FILE_UNLOAD (or kernel_fd < 0?), and only once retrieve extra if extra != NULL && nr_fds == 0. Thanks, -Takahiro AKASHI > Thanks > Dave _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec