Huacai Chen <chenhuacai@xxxxxxxxxx> 于2023年12月5日周二 14:18写道: > > On Tue, Dec 5, 2023 at 2:16 PM Ainux Wang <ainux.wang@xxxxxxxxx> wrote: > > > > Huacai Chen <chenhuacai@xxxxxxxxxx> 于2023年12月5日周二 14:09写道: > > > > > > Why send a test patch? > > > > > > > Confirm the accuracy of the testing method > > Don't use maillist to do this. Sorry, I don't know about this :-( > > > > > > On Tue, Dec 5, 2023 at 2:04 PM <wangyao@xxxxxxxxxx> wrote: > > > > > > > > From: Wang Yao <wangyao@xxxxxxxxxx> > > > > > > > > This is a test patch for PIE kernel that load address is not equal to > > > > link address. > > > > > > > > Signed-off-by: Wang Yao <wangyao@xxxxxxxxxx> > > > > --- > > > > drivers/firmware/efi/libstub/loongarch-stub.c | 12 +++++++++++- > > > > 1 file changed, 11 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/firmware/efi/libstub/loongarch-stub.c b/drivers/firmware/efi/libstub/loongarch-stub.c > > > > index d6ec5d4b8dbe..c13c022d18cf 100644 > > > > --- a/drivers/firmware/efi/libstub/loongarch-stub.c > > > > +++ b/drivers/firmware/efi/libstub/loongarch-stub.c > > > > @@ -22,12 +22,22 @@ efi_status_t handle_kernel_image(unsigned long *image_addr, > > > > efi_handle_t image_handle) > > > > { > > > > efi_status_t status; > > > > - unsigned long kernel_addr = 0; > > > > + unsigned long kernel_addr = 0, tmp_addr = 0; > > > > > > > > kernel_addr = (unsigned long)&kernel_offset - kernel_offset; > > > > > > > > + /* > > > > + * Allocate 2M space at 0x200000(EFI_KIMG_PREFERRED_ADDRESS) for > > > > + * test, this will lead to the kernel be loaded at 0x4000000. > > > > + */ > > > > + status = efi_relocate_kernel(&tmp_addr, 0x100000, 0x200000, > > > > + EFI_KIMG_PREFERRED_ADDRESS, efi_get_kimg_min_align(), 0x0); > > > > + efi_info("@@@[%s] tmp_addr: 0x%lx\n", __func__, tmp_addr); > > > > + > > > > + /* kernel_addr == 0x400000 */ > > > > status = efi_relocate_kernel(&kernel_addr, kernel_fsize, kernel_asize, > > > > EFI_KIMG_PREFERRED_ADDRESS, efi_get_kimg_min_align(), 0x0); > > > > + efi_info("@@@[%s] kernel_addr: 0x%lx\n", __func__, kernel_addr); > > > > > > > > *image_addr = kernel_addr; > > > > *image_size = kernel_asize; > > > > -- > > > > 2.27.0 > > > >