From: Simon Horman <horms@kernel.org>
To: Pingfan Liu <piliu@redhat.com>
Cc: kexec@lists.infradead.org, horms@verge.net.au, ardb@kernel.org,
jeremy.linton@arm.com
Subject: Re: [PATCHv2 1/6] kexec: Change the image probe's prototype
Date: Wed, 24 May 2023 13:52:57 +0200 [thread overview]
Message-ID: <ZG36mQerUGDHAgcQ@kernel.org> (raw)
In-Reply-To: <20230516073124.23531-2-piliu@redhat.com>
On Tue, May 16, 2023 at 03:31:19PM +0800, Pingfan Liu wrote:
> As more complicated kernel format occurs such as zboot, where the
> compressed kernel is stored as a payload. The straight forward
> decompression can not meet the demand.
>
> A new image probe method is expected to read in the kernel file and decide
> how to unfold the content by itself.
>
> This patch aims to change the image probe's prototype from
> typedef int (probe_t)(const char *kernel_buf, off_t kernel_size);
> to
> typedef int (probe_t)(const char *kernel_buf, off_t kernel_size, struct kexec_info *info);
>
> Later, info can be used to return both the file descriptor and the
> parsed kernel buffer.
>
> In case your are curious, the remaing part of the log describes the
> process of the substitution of the new prototype, which can be divided
> into three groups.
>
> 1. change function pointer and its callsites:
> sed -i 's/(probe_t)(const char \*kernel_buf, off_t kernel_size);/(probe_t)(const char \*kernel, off_t kernel_size, struct kexec_info \*info);/g' kexec/kexec.h
> sed -i 's/\.probe(\([^,]*\), \([^)]*\))/\.probe(\1, \2, NULL)/g' kexec/kexec.c
>
> 2. change the function declaration and definition of each 'probe'
> instance by coccinelle because they may cross lines
>
> The cocci file looks like:
>
> @ rule1 @
> identifier fn =~ "_probe";
> identifier buf, size;
> typedef off_t;
> @@
>
> -int fn(const char *buf, off_t size)
> +int fn(const char *buf, off_t size, struct kexec_info *info)
> {
> ...
> }
>
> @ rule2 @
> identifier fn =~ "_probe";
> identifier buf, size;
> typedef off_t;
> @@
>
> +int fn(const char *buf, off_t size, struct kexec_info *info);
> -int fn(const char *buf, off_t size);
>
> Then running the command
> spatch --sp-file cocci/define.cocci --dir kexec --include-headers > ../define.patch
> git apply --directory=kexec ../define.patch
>
> 3. change the direct calls to the probe instances
>
> Originally I planned to achieve this by coccinelle, but failed similar
> to [1]. I have tried using "-I and --include" option for coccinelle, but it
> still did not work.
>
> Checking the direct callsite by "git grep "_probe(" | grep -v const"
> Fortunatelly, it turns out that only a few direct callsites exist, which
> lies in i386, and easy to be amended manually.
>
> Anyway, just FYI, the cocci file looks like:
> @ rule1 @
> identifier fn =~ "_probe";
> identifier buf, size;
> identifier info;
> typedef off_t;
> @@
>
> int fn(const char *buf, off_t size, struct kexec_info *info);
>
> /* change the direct callsite of any probe */
> @ rule2 @
> identifier rule1.fn;
> expression E1, E2;
> @@
>
> fn(E1, E2
> + ,NULL
> )
>
> Then running the command:
> spatch --sp-file cocci/direct.cocci --dir kexec --include-headers
>
> [1]: https://lore.kernel.org/all/alpine.DEB.2.22.394.2202280705080.3112@hadrien/T/
>
> Signed-off-by: Pingfan Liu <piliu@redhat.com>
> To: kexec@lists.infradead.org
> Cc: horms@verge.net.au
> Cc: ardb@kernel.org
> Cc: jeremy.linton@arm.com
Unfortunately I am seeing a build failure on (at least) sh4 with this change:
../../kexec/arch/sh/kexec-zImage-sh.c:54:5: error: conflicting types for ‘zImage_sh_probe’
54 | int zImage_sh_probe(const char *buf, off_t UNUSED(len))
| ^~~~~~~~~~~~~~~
In file included from ../../kexec/arch/sh/kexec-zImage-sh.c:27:
../../kexec/arch/sh/kexec-sh.h:11:5: note: previous declaration of ‘zImage_sh_probe’ was here
11 | int zImage_sh_probe(const char *buf, off_t len, struct kexec_info *info);
| ^~~~~~~~~~~~~~~
../../kexec/arch/sh/kexec-zImage-sh.c:29:18: warning: ‘probe_debug’ defined but not used [-Wunused-const-variable=]
29 | static const int probe_debug = 0;
| ^~~~~~~~~~~
make[1]: *** [Makefile:124: kexec/arch/sh/kexec-zImage-sh.o] Error 1
make[1]: *** Waiting for unfinished jobs....
../../kexec/arch/sh/kexec-netbsd-sh.c:28:18: warning: ‘probe_debug’ defined but not used [-Wunused-const-variable=]
28 | static const int probe_debug = 0;
| ^~~~~~~~~~~
Link: https://github.com/horms/kexec-tools/actions/runs/5068250493/jobs/9100319093#step:5:215
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2023-05-24 11:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 7:31 [PATCHv2 0/6] arm64: zboot support Pingfan Liu
2023-05-16 7:31 ` [PATCHv2 1/6] kexec: Change the image probe's prototype Pingfan Liu
2023-05-24 11:52 ` Simon Horman [this message]
2023-05-25 3:32 ` Pingfan Liu
2023-06-01 1:45 ` Pingfan Liu
2023-06-29 3:57 ` Pingfan Liu
2023-05-16 7:31 ` [PATCHv2 2/6] arm64: Fix some issues with zImage _probe() Pingfan Liu
2023-05-16 7:31 ` [PATCHv2 3/6] arm64: Scatter the logic of reading of kernel file into each probe Pingfan Liu
2023-05-16 7:31 ` [PATCHv2 4/6] kexec/zboot: Add arch independent zboot support Pingfan Liu
2023-05-16 7:31 ` [PATCHv2 5/6] arm64: Add ZBOOT PE containing compressed image support Pingfan Liu
2023-05-16 7:31 ` [PATCHv2 6/6] arm64: Hook up the ZBOOT support as vmlinuz Pingfan Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZG36mQerUGDHAgcQ@kernel.org \
--to=horms@kernel.org \
--cc=ardb@kernel.org \
--cc=horms@verge.net.au \
--cc=jeremy.linton@arm.com \
--cc=kexec@lists.infradead.org \
--cc=piliu@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.