All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64)
@ 2021-04-20  9:35 Mikhail B. WproxyM
  2021-04-26 20:56 ` Thomas Petazzoni
  2021-05-05  9:39 ` Fwd: " Mikhail B. WproxyM
  0 siblings, 2 replies; 16+ messages in thread
From: Mikhail B. WproxyM @ 2021-04-20  9:35 UTC (permalink / raw)
  To: buildroot

We are using binutils-2.35.2+ (later then 2.29.1), grub-2.04,
cross-compiling on recent buildroot under i386/i686 and getting error:

> lib/i386/relocator64.S:66: Error: unknown pseudo-op: `.code64'

So, the working patch is attached. Please add it to buildroot.

Sources:
1) https://debbugs.gnu.org/cgi/bugreport.cgi?bug=41982 (Jul 2020)
2)
http://archive.linuxfromscratch.org/mail-archives/lfs-support/2018-January/051723.html

--
Best regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20210420/a08994a2/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0150-grub-core-build-fixes-for-i386.patch
Type: text/x-patch
Size: 1722 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20210420/a08994a2/attachment.bin>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Buildroot] boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64)
  2021-04-20  9:35 [Buildroot] boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64) Mikhail B. WproxyM
@ 2021-04-26 20:56 ` Thomas Petazzoni
  2021-04-28  8:07   ` Mikhail B. WproxyM
  2021-05-05  9:39 ` Fwd: " Mikhail B. WproxyM
  1 sibling, 1 reply; 16+ messages in thread
From: Thomas Petazzoni @ 2021-04-26 20:56 UTC (permalink / raw)
  To: buildroot

Hello Mikhail,

On Tue, 20 Apr 2021 12:35:16 +0300
"Mikhail B. WproxyM" <w.proxy.m@gmail.com> wrote:

> We are using binutils-2.35.2+ (later then 2.29.1), grub-2.04,
> cross-compiling on recent buildroot under i386/i686 and getting error:
> 
> > lib/i386/relocator64.S:66: Error: unknown pseudo-op: `.code64'  
> 
> So, the working patch is attached. Please add it to buildroot.

Do you have some details on the conditions to reproduce this issue?
Indeed, I just tried to build grub2, with the following configuration:

BR2_x86_core2=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
# BR2_TARGET_ROOTFS_TAR is not set
BR2_TARGET_GRUB2=y
BR2_TARGET_GRUB2_I386_EFI=y

So it's using a i686 target system, with a toolchain that uses binutils
2.34 (i.e later than the 2.29 you're pointing). And it builds fine,
including relocator64.S, which gets built as part of the build process.

Note: I am building *from* an x86-64 system. But how can that matter,
as relocator64.S is built using the cross-compiler?

Also, why isn't this patch in upstream Grub ?

Thanks a lot for the additional details you could provide.

Best regards,

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Buildroot] boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64)
  2021-04-26 20:56 ` Thomas Petazzoni
@ 2021-04-28  8:07   ` Mikhail B. WproxyM
  2021-04-28 11:44     ` Thomas Petazzoni
  0 siblings, 1 reply; 16+ messages in thread
From: Mikhail B. WproxyM @ 2021-04-28  8:07 UTC (permalink / raw)
  To: buildroot

Hello, Thomas.

I have the build error, when building *from i686* to i686.

You do not have the build error, when building *from x86-64* to i686.
Looks like it is the reason.

Grub2 developers do not run build tests under i386/i686. Even you do
not run build tests under i686.

P.S.: Common build platform for most developers is x86-64, so I am not
surprised. It is too simple to lose compatibility by using too many
levels of assumptions, facades and abstractions.

--
Best regards

--
Best regards, Mikhail B.


??, 26 ???. 2021 ?. ? 23:56, Thomas Petazzoni <thomas.petazzoni@bootlin.com>:
>
> Hello Mikhail,
>
> On Tue, 20 Apr 2021 12:35:16 +0300
> "Mikhail B. WproxyM" <w.proxy.m@gmail.com> wrote:
>
> > We are using binutils-2.35.2+ (later then 2.29.1), grub-2.04,
> > cross-compiling on recent buildroot under i386/i686 and getting error:
> >
> > > lib/i386/relocator64.S:66: Error: unknown pseudo-op: `.code64'
> >
> > So, the working patch is attached. Please add it to buildroot.
>
> Do you have some details on the conditions to reproduce this issue?
> Indeed, I just tried to build grub2, with the following configuration:
>
> BR2_x86_core2=y
> BR2_TOOLCHAIN_EXTERNAL=y
> BR2_INIT_NONE=y
> BR2_SYSTEM_BIN_SH_NONE=y
> # BR2_PACKAGE_BUSYBOX is not set
> # BR2_TARGET_ROOTFS_TAR is not set
> BR2_TARGET_GRUB2=y
> BR2_TARGET_GRUB2_I386_EFI=y
>
> So it's using a i686 target system, with a toolchain that uses binutils
> 2.34 (i.e later than the 2.29 you're pointing). And it builds fine,
> including relocator64.S, which gets built as part of the build process.
>
> Note: I am building *from* an x86-64 system. But how can that matter,
> as relocator64.S is built using the cross-compiler?
>
> Also, why isn't this patch in upstream Grub ?
>
> Thanks a lot for the additional details you could provide.
>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, co-owner and CEO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Buildroot] boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64)
  2021-04-28  8:07   ` Mikhail B. WproxyM
@ 2021-04-28 11:44     ` Thomas Petazzoni
  2021-04-28 13:23       ` Mikhail B. WproxyM
  0 siblings, 1 reply; 16+ messages in thread
From: Thomas Petazzoni @ 2021-04-28 11:44 UTC (permalink / raw)
  To: buildroot

Hello Mikhail,

On Wed, 28 Apr 2021 11:07:13 +0300
"Mikhail B. WproxyM" <w.proxy.m@gmail.com> wrote:

> I have the build error, when building *from i686* to i686.
> 
> You do not have the build error, when building *from x86-64* to i686.
> Looks like it is the reason.
> 
> Grub2 developers do not run build tests under i386/i686. Even you do
> not run build tests under i686.

I was worried the issue would be related from the difference of the
build machine architecture. In theory it shouldn't matter, as the file
being built is built with the cross-compiler, but it seems like there
is an actual difference.

What about having this patch submitted to upstream Grub ?

Best regards,

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Buildroot] boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64)
  2021-04-28 11:44     ` Thomas Petazzoni
@ 2021-04-28 13:23       ` Mikhail B. WproxyM
  2021-05-13  7:19           ` Mikhail B. WproxyM
  0 siblings, 1 reply; 16+ messages in thread
From: Mikhail B. WproxyM @ 2021-04-28 13:23 UTC (permalink / raw)
  To: buildroot

>What about having this patch submitted to upstream Grub ?

Idea is nice, but I am not sure that it will work.
The patch was already ignored some time before by grub2 developers,
because it is not included in upstream. I will try.

--
Best regards, Mikhail B.

??, 28 ???. 2021 ?. ? 14:44, Thomas Petazzoni <thomas.petazzoni@bootlin.com>:
>
> Hello Mikhail,
>
> On Wed, 28 Apr 2021 11:07:13 +0300
> "Mikhail B. WproxyM" <w.proxy.m@gmail.com> wrote:
>
> > I have the build error, when building *from i686* to i686.
> >
> > You do not have the build error, when building *from x86-64* to i686.
> > Looks like it is the reason.
> >
> > Grub2 developers do not run build tests under i386/i686. Even you do
> > not run build tests under i686.
>
> I was worried the issue would be related from the difference of the
> build machine architecture. In theory it shouldn't matter, as the file
> being built is built with the cross-compiler, but it seems like there
> is an actual difference.
>
> What about having this patch submitted to upstream Grub ?
>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, co-owner and CEO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Fwd: boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64)
  2021-04-20  9:35 [Buildroot] boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64) Mikhail B. WproxyM
  2021-04-26 20:56 ` Thomas Petazzoni
@ 2021-05-05  9:39 ` Mikhail B. WproxyM
  2021-05-05  9:44   ` Mikhail B. WproxyM
  2021-05-05 14:16   ` Fwd: " John Paul Adrian Glaubitz
  1 sibling, 2 replies; 16+ messages in thread
From: Mikhail B. WproxyM @ 2021-05-05  9:39 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 442 bytes --]

We are using binutils-2.35.2+ (later then 2.29.1), grub-2.04,
cross-compiling on recent buildroot under i386/i686 and getting error:

> lib/i386/relocator64.S:66: Error: unknown pseudo-op: `.code64'

So, the working patch is attached. Please add it to grub2.

Sources:
1) https://debbugs.gnu.org/cgi/bugreport.cgi?bug=41982 (Jul 2020)
2) http://archive.linuxfromscratch.org/mail-archives/lfs-support/2018-January/051723.html

--
Best regards

[-- Attachment #2: 0150-grub-core-build-fixes-for-i386.patch --]
[-- Type: application/x-patch, Size: 1722 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64)
  2021-05-05  9:39 ` Fwd: " Mikhail B. WproxyM
@ 2021-05-05  9:44   ` Mikhail B. WproxyM
  2021-05-05 16:33     ` Daniel Kiper
  2021-05-05 14:16   ` Fwd: " John Paul Adrian Glaubitz
  1 sibling, 1 reply; 16+ messages in thread
From: Mikhail B. WproxyM @ 2021-05-05  9:44 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 442 bytes --]

We are using binutils-2.35.2+ (later then 2.29.1), grub-2.04,
cross-compiling on recent buildroot under i386/i686 and getting error:

> lib/i386/relocator64.S:66: Error: unknown pseudo-op: `.code64'

So, the working patch is attached. Please add it to grub2.

Sources:
1) https://debbugs.gnu.org/cgi/bugreport.cgi?bug=41982 (Jul 2020)
2) http://archive.linuxfromscratch.org/mail-archives/lfs-support/2018-January/051723.html

--
Best regards

[-- Attachment #2: 0150-grub-core-build-fixes-for-i386.patch --]
[-- Type: application/x-patch, Size: 1722 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Fwd: boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64)
  2021-05-05  9:39 ` Fwd: " Mikhail B. WproxyM
  2021-05-05  9:44   ` Mikhail B. WproxyM
@ 2021-05-05 14:16   ` John Paul Adrian Glaubitz
  1 sibling, 0 replies; 16+ messages in thread
From: John Paul Adrian Glaubitz @ 2021-05-05 14:16 UTC (permalink / raw)
  To: Mikhail B. WproxyM; +Cc: The development of GNU GRUB

Hello Mikhail!

On 5/5/21 11:39 AM, Mikhail B. WproxyM wrote:
> We are using binutils-2.35.2+ (later then 2.29.1), grub-2.04,
> cross-compiling on recent buildroot under i386/i686 and getting error:
> 
>> lib/i386/relocator64.S:66: Error: unknown pseudo-op: `.code64'
> 
> So, the working patch is attached. Please add it to grub2.

Please re-send your patch using git-send-email, see [1], for example.

Adrian

> [1] https://git-send-email.io/

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64)
  2021-05-05  9:44   ` Mikhail B. WproxyM
@ 2021-05-05 16:33     ` Daniel Kiper
  2021-05-13 10:35       ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 16+ messages in thread
From: Daniel Kiper @ 2021-05-05 16:33 UTC (permalink / raw)
  To: Mikhail B. WproxyM; +Cc: grub-devel, janneke

Hi,

Thank you for the report...

On Wed, May 05, 2021 at 12:44:07PM +0300, Mikhail B. WproxyM wrote:
> We are using binutils-2.35.2+ (later then 2.29.1), grub-2.04,
> cross-compiling on recent buildroot under i386/i686 and getting error:

May I ask you to try latest GRUB master git branch [1]? The GRUB 2.04
release is a few years old. We are going to release 2.06 soon.

> > lib/i386/relocator64.S:66: Error: unknown pseudo-op: `.code64'
>
> So, the working patch is attached. Please add it to grub2.

You can find a few comments below...

> From 270667540146f8ef9ea7a44258a71b3837a7af4a Mon Sep 17 00:00:00 2001
> From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
> Date: Sun, 21 Jun 2020 15:10:40 +0200
> Subject: [PATCH] grub-core: Build fixes for i386
>
> * grub-core/lib/i386/relocator64.S: Avoid x86_64 instructions on i386.

Please describe in the commit message why this patch is needed and how
the issue can be reproduced.

Please add your "Signed-off-by: ..." line at the end of commit message.
You can find good examples of commit messages in the GRUB git repository.

> ---
>  grub-core/lib/i386/relocator64.S | 26 +++++++++++++++++++++++++-
>  1 file changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/grub-core/lib/i386/relocator64.S b/grub-core/lib/i386/relocator64.S
> index 148f38adb..45fed9444 100644
> --- a/grub-core/lib/i386/relocator64.S
> +++ b/grub-core/lib/i386/relocator64.S
> @@ -63,7 +63,9 @@ VARIABLE(grub_relocator64_cr3)
>  	movq	%rax, %cr3
>  #endif
>
> +#ifdef __x86_64__
>  	.code64
> +#endif
>
>  	/* mov imm64, %rax */
>  	.byte 	0x48
> @@ -71,7 +73,14 @@ VARIABLE(grub_relocator64_cr3)
>  VARIABLE(grub_relocator64_rsp)
>  	.quad	0
>
> +#ifndef __x86_64__
> +	/* movq	%rax, %rsp */
> +	.byte 	0x48
> +	.byte	0x89
> +	.byte	0xc4
> +#else
>  	movq	%rax, %rsp
> +#endif

I would do it other way around to increase readability...

#ifdef __x86_64__
     movq    %rax, %rsp
#else
     /* movq %rax, %rsp */
     .byte   0x48
     ...

>  #ifdef GRUB_MACHINE_EFI
>  	jmp	LOCAL(skip_efi_stack_align)
> @@ -95,8 +104,15 @@ LOCAL(skip_efi_stack_align):
>  VARIABLE(grub_relocator64_rsi)
>  	.quad	0
>
> +#ifndef	__x86_64__
> +	/* movq	%rax, %rsi */
> +	.byte 	0x48
> +	.byte	0x89
> +	.byte 	0xc6
> +#else
>  	movq	%rax, %rsi
> -
> +#endif

Ditto...

>  	/* mov imm64, %rax */
>  	.byte 	0x48
>  	.byte	0xb8
> @@ -128,6 +144,14 @@ VARIABLE(grub_relocator64_rdx)
>  #ifdef __APPLE__
>  	.byte 0xff, 0x25
>  	.quad 0
> +#elif !defined (__x86_64__)
> +	/* jmp *LOCAL(jump_addr) (%rip) */
> +	.byte 0xff
> +        .byte 0x25
> +	.byte 0
> +	.byte 0
> +	.byte 0
> +	.byte 0
>  #else
>  	jmp *LOCAL(jump_addr) (%rip)
>  #endif

#if defined(__APPLE__) || !defined (__x86_64__)
     .byte 0xff, 0x25
     .quad 0
#else
     jmp *LOCAL(jump_addr) (%rip)
#endif

A patch should be prepared on top of latest GRUB master git branch [1].
And please use "git-send-email" to send the patch as Adrian said...

Daniel

[1] https://git.savannah.gnu.org/gitweb/?p=grub.git&view=view+git+repository


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Buildroot] boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64)
  2021-04-28 13:23       ` Mikhail B. WproxyM
@ 2021-05-13  7:19           ` Mikhail B. WproxyM
  0 siblings, 0 replies; 16+ messages in thread
From: Mikhail B. WproxyM @ 2021-05-13  7:19 UTC (permalink / raw)
  To: buildroot

As expected, they do not want to include fix patch, because "The GRUB 2.04
release is a few years old."

--
Best regards, Mikhail B.


??, 28 ???. 2021 ?. ? 16:23, Mikhail B. WproxyM <w.proxy.m@gmail.com>:

> >What about having this patch submitted to upstream Grub ?
>
> Idea is nice, but I am not sure that it will work.
> The patch was already ignored some time before by grub2 developers,
> because it is not included in upstream. I will try.
>
> --
> Best regards, Mikhail B.
>
> ??, 28 ???. 2021 ?. ? 14:44, Thomas Petazzoni <
> thomas.petazzoni at bootlin.com>:
> >
> > Hello Mikhail,
> >
> > On Wed, 28 Apr 2021 11:07:13 +0300
> > "Mikhail B. WproxyM" <w.proxy.m@gmail.com> wrote:
> >
> > > I have the build error, when building *from i686* to i686.
> > >
> > > You do not have the build error, when building *from x86-64* to i686.
> > > Looks like it is the reason.
> > >
> > > Grub2 developers do not run build tests under i386/i686. Even you do
> > > not run build tests under i686.
> >
> > I was worried the issue would be related from the difference of the
> > build machine architecture. In theory it shouldn't matter, as the file
> > being built is built with the cross-compiler, but it seems like there
> > is an actual difference.
> >
> > What about having this patch submitted to upstream Grub ?
> >
> > Best regards,
> >
> > Thomas
> > --
> > Thomas Petazzoni, co-owner and CEO, Bootlin
> > Embedded Linux and Kernel engineering
> > https://bootlin.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20210513/0e749c49/attachment.html>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Buildroot] boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64)
@ 2021-05-13  7:19           ` Mikhail B. WproxyM
  0 siblings, 0 replies; 16+ messages in thread
From: Mikhail B. WproxyM @ 2021-05-13  7:19 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: buildroot, grub-devel, janneke

[-- Attachment #1: Type: text/plain, Size: 1534 bytes --]

As expected, they do not want to include fix patch, because "The GRUB 2.04
release is a few years old."

--
Best regards, Mikhail B.


ср, 28 апр. 2021 г. в 16:23, Mikhail B. WproxyM <w.proxy.m@gmail.com>:

> >What about having this patch submitted to upstream Grub ?
>
> Idea is nice, but I am not sure that it will work.
> The patch was already ignored some time before by grub2 developers,
> because it is not included in upstream. I will try.
>
> --
> Best regards, Mikhail B.
>
> ср, 28 апр. 2021 г. в 14:44, Thomas Petazzoni <
> thomas.petazzoni@bootlin.com>:
> >
> > Hello Mikhail,
> >
> > On Wed, 28 Apr 2021 11:07:13 +0300
> > "Mikhail B. WproxyM" <w.proxy.m@gmail.com> wrote:
> >
> > > I have the build error, when building *from i686* to i686.
> > >
> > > You do not have the build error, when building *from x86-64* to i686.
> > > Looks like it is the reason.
> > >
> > > Grub2 developers do not run build tests under i386/i686. Even you do
> > > not run build tests under i686.
> >
> > I was worried the issue would be related from the difference of the
> > build machine architecture. In theory it shouldn't matter, as the file
> > being built is built with the cross-compiler, but it seems like there
> > is an actual difference.
> >
> > What about having this patch submitted to upstream Grub ?
> >
> > Best regards,
> >
> > Thomas
> > --
> > Thomas Petazzoni, co-owner and CEO, Bootlin
> > Embedded Linux and Kernel engineering
> > https://bootlin.com
>

[-- Attachment #2: Type: text/html, Size: 2541 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Buildroot] boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64)
  2021-05-13  7:19           ` Mikhail B. WproxyM
  (?)
@ 2021-05-13  7:28           ` John Paul Adrian Glaubitz
  -1 siblings, 0 replies; 16+ messages in thread
From: John Paul Adrian Glaubitz @ 2021-05-13  7:28 UTC (permalink / raw)
  To: The development of GNU GRUB, Mikhail B. WproxyM, Thomas Petazzoni
  Cc: buildroot, janneke

Hello Mikhail!

On 5/13/21 9:19 AM, Mikhail B. WproxyM wrote:
> As expected, they do not want to include fix patch, because "The GRUB 2.04
> release is a few years old."

Since GRUB 2.06 will hopefully be released within the next weeks, you should
be able to upgrade to the new upstream release, aren't you?

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64)
  2021-05-05 16:33     ` Daniel Kiper
@ 2021-05-13 10:35       ` Jan Nieuwenhuizen
  2021-05-17 16:49         ` Daniel Kiper
  0 siblings, 1 reply; 16+ messages in thread
From: Jan Nieuwenhuizen @ 2021-05-13 10:35 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: Mikhail B. WproxyM, grub-devel

[-- Attachment #1: Type: text/plain, Size: 6127 bytes --]

Daniel Kiper writes:

Hello Daniel,

> May I ask you to try latest GRUB master git branch [1]? The GRUB 2.04
> release is a few years old. We are going to release 2.06 soon.

Sure.  The bug is still there (see attached patch to reproduce using
Guix):

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix build --system=i686-linux --target=i586-pc-gnu grub 
starting phase `unpack'
grub-2.06~rc1/
[..]
starting phase `configure'
source directory: "/tmp/guix-build-grub-2.06-rc1.drv-0/grub-2.06~rc1" (relative from build: ".")
build directory: "/tmp/guix-build-grub-2.06-rc1.drv-0/grub-2.06~rc1"
configure flags: ("CC_FOR_BUILD=gcc" "CONFIG_SHELL=/gnu/store/v1g7f3p4f0851mywrla8qmr9hb8jgfjr-bash-minimal-5.0.16/bin/bash" "SHELL=/gnu/store/v1g7f3p4f0851mywrla8qmr9hb8jgfjr-bash-minimal-5.0.16/bin/bash" "--prefix=/gnu/store/753q8z0xa9ijap3p3phpsvns7287c7sn-grub-2.06-rc1" "--enable-fast-install" "--build=i686-unknown-linux-gnu" "--host=i586-pc-gnu" "PYTHON=true")
[..]
starting phase `build'
[..]
i586-pc-gnu-gcc -DHAVE_CONFIG_H -I. -I..  -Wall -W  -DGRUB_MACHINE_PCBIOS=1 -DGRUB_MACHINE=I386_PC -m32 -nostdinc -isystem /gnu/store/q8af3pvwsknn132pl1nzrb5281i4pgij-gcc-cross-i586-pc-gnu-7.5.0-lib/lib/gcc/i586-pc-gnu/7.5.0/include -I../include -I../include -DGRUB_FILE=\"lib/i386/relocator.c\" -I. -I. -I.. -I.. -I../include -I../include -I../grub-core/lib/libgcrypt-grub/src/    -D_FILE_OFFSET_BITS=64 -std=gnu99 -Os -m32 -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value  -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations  -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -march=i386 -mrtd -mregparm=3 -falign-jumps=1 -falign-loops=1 -falign-functions=1 -freg-struct-return -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow -msoft-float -fno-dwarf2-cfi-asm -mno-stack-arg-probe -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-ident -fno-stack-protector -Wtrampolines -Werror   -ffreestanding   -MT lib/i386/relocator_module-relocator.o -MD -MP -MF lib/i386/.deps-core/relocator_module-relocator.Tpo -c -o lib/i386/relocator_module-relocator.o `test -f 'lib/i386/relocator.c' || echo './'`lib/i386/relocator.c
lib/i386/relocator64.S: Assembler messages:
lib/i386/relocator64.S:66: Error: unknown pseudo-op: `.code64'
lib/i386/relocator64.S:74: Error: bad register name `%rax'
lib/i386/relocator64.S:98: Error: bad register name `%rax'
lib/i386/relocator64.S:132: Error: bad register name `%rip)'
--8<---------------cut here---------------end--------------->8---

>> > lib/i386/relocator64.S:66: Error: unknown pseudo-op: `.code64'
>>
>> So, the working patch is attached. Please add it to grub2.
>
> You can find a few comments below...

Thanks!

>> From 270667540146f8ef9ea7a44258a71b3837a7af4a Mon Sep 17 00:00:00 2001
>> From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
>> Date: Sun, 21 Jun 2020 15:10:40 +0200
>> Subject: [PATCH] grub-core: Build fixes for i386
>>
>> * grub-core/lib/i386/relocator64.S: Avoid x86_64 instructions on i386.
>
> Please describe in the commit message why this patch is needed and how
> the issue can be reproduced.

I have added:

--8<---------------cut here---------------start------------->8---
This fixes cross-compiling to x86 (e.g., the Hurd) from x86-linux.

To reproduce, update the Grub source description in your local Guix
archive and run

   ./pre-inst-env guix build --system=i686-linux --target=i586-pc-gnu grub 

or install an x86 cross-build environment on x86-linux (32bit!) and
configure to cross build and make, e.g., do something like

    ./configure \
       CC_FOR_BUILD=gcc \
       --build=i686-unknown-linux-gnu
       --host=i586-pc-gnu
    make
--8<---------------cut here---------------end--------------->8---

>> diff --git a/grub-core/lib/i386/relocator64.S b/grub-core/lib/i386/relocator64.S
>> index 148f38adb..45fed9444 100644
[..]
>> +#ifndef __x86_64__
>> +	/* movq	%rax, %rsp */
>> +	.byte 	0x48
>> +	.byte	0x89
>> +	.byte	0xc4
>> +#else
>>  	movq	%rax, %rsp
>> +#endif
>
> I would do it other way around to increase readability...
>
> #ifdef __x86_64__
>      movq    %rax, %rsp
> #else
>      /* movq %rax, %rsp */
>      .byte   0x48
>      ...

Done.

>> +#ifndef	__x86_64__
>> +	/* movq	%rax, %rsi */
>> +	.byte 	0x48
>> +	.byte	0x89
>> +	.byte 	0xc6
>> +#else
>>  	movq	%rax, %rsi
>> -
>> +#endif
>
> Ditto...

Ok.

>>  #ifdef __APPLE__
>>  	.byte 0xff, 0x25
>>  	.quad 0
>> +#elif !defined (__x86_64__)
>> +	/* jmp *LOCAL(jump_addr) (%rip) */
>> +	.byte 0xff
>> +        .byte 0x25
>> +	.byte 0
>> +	.byte 0
>> +	.byte 0
>> +	.byte 0
>>  #else
>>  	jmp *LOCAL(jump_addr) (%rip)
>>  #endif
>
> #if defined(__APPLE__) || !defined (__x86_64__)
>      .byte 0xff, 0x25
>      .quad 0
> #else
>      jmp *LOCAL(jump_addr) (%rip)
> #endif

Ah, yes; that's better.  Also updated.

> A patch should be prepared on top of latest GRUB master git branch [1].

Sure, but well..

    https://lists.gnu.org/archive/html/bug-grub/2020-06/msg00013.html

it was when I sent the report ;)

Luckily it still applied cleanly to current master.

> And please use "git-send-email" to send the patch as Adrian said...

Sure, sent separately to bug-grub.

Greetings,
Janneke


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: grub-hurd-cross-build-reproducer.patch --]
[-- Type: text/x-patch, Size: 1185 bytes --]

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 56bef57cb7..78923e4303 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -88,18 +88,15 @@
 (define-public grub
   (package
     (name "grub")
-    (version "2.04")
+    (version "2.06-rc1")
     (source (origin
              (method url-fetch)
-             (uri (string-append "mirror://gnu/grub/grub-" version ".tar.xz"))
+             (uri (string-append "https://alpha.gnu.org/pub/gnu/grub/"
+                                 "grub-2.06~rc1" ".tar.xz"))
+             (file-name (string-append "grub-" version ".tar.xz"))
              (sha256
               (base32
-               "0zgp5m3hmc9jh8wpjx6czzkh5id2y8n1k823x2mjvm2sk6b28ag5"))
-             (patches (search-patches
-                       "grub-efi-fat-serial-number.patch"
-                       "grub-setup-root.patch"
-                       "grub-verifiers-Blocklist-fallout-cleanup.patch"
-                       "grub-cross-system-i686.patch"))))
+               "112l2isb0rgdz4zz4ssmf5hklv0viz0674fdwr1h1d9a3vrg31rc"))))
     (build-system gnu-build-system)
     (arguments
      `(#:configure-flags

[-- Attachment #3: Type: text/plain, Size: 152 bytes --]


-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64)
  2021-05-13 10:35       ` Jan Nieuwenhuizen
@ 2021-05-17 16:49         ` Daniel Kiper
  2021-05-18  5:05           ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 16+ messages in thread
From: Daniel Kiper @ 2021-05-17 16:49 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: Mikhail B. WproxyM, grub-devel

Hi Jan,

On Thu, May 13, 2021 at 12:35:25PM +0200, Jan Nieuwenhuizen wrote:
> Daniel Kiper writes:
>
> Hello Daniel,
>
> > May I ask you to try latest GRUB master git branch [1]? The GRUB 2.04
> > release is a few years old. We are going to release 2.06 soon.
>
> Sure.  The bug is still there (see attached patch to reproduce using
> Guix):
>
> --8<---------------cut here---------------start------------->8---
> $ ./pre-inst-env guix build --system=i686-linux --target=i586-pc-gnu grub
> starting phase `unpack'
> grub-2.06~rc1/
> [..]
> starting phase `configure'
> source directory: "/tmp/guix-build-grub-2.06-rc1.drv-0/grub-2.06~rc1" (relative from build: ".")
> build directory: "/tmp/guix-build-grub-2.06-rc1.drv-0/grub-2.06~rc1"
> configure flags: ("CC_FOR_BUILD=gcc" "CONFIG_SHELL=/gnu/store/v1g7f3p4f0851mywrla8qmr9hb8jgfjr-bash-minimal-5.0.16/bin/bash" "SHELL=/gnu/store/v1g7f3p4f0851mywrla8qmr9hb8jgfjr-bash-minimal-5.0.16/bin/bash" "--prefix=/gnu/store/753q8z0xa9ijap3p3phpsvns7287c7sn-grub-2.06-rc1" "--enable-fast-install" "--build=i686-unknown-linux-gnu" "--host=i586-pc-gnu" "PYTHON=true")
> [..]
> starting phase `build'
> [..]
> i586-pc-gnu-gcc -DHAVE_CONFIG_H -I. -I..  -Wall -W  -DGRUB_MACHINE_PCBIOS=1 -DGRUB_MACHINE=I386_PC -m32 -nostdinc -isystem /gnu/store/q8af3pvwsknn132pl1nzrb5281i4pgij-gcc-cross-i586-pc-gnu-7.5.0-lib/lib/gcc/i586-pc-gnu/7.5.0/include -I../include -I../include -DGRUB_FILE=\"lib/i386/relocator.c\" -I. -I. -I.. -I.. -I../include -I../include -I../grub-core/lib/libgcrypt-grub/src/    -D_FILE_OFFSET_BITS=64 -std=gnu99 -Os -m32 -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value  -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations  -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -march=i386 -mrtd -mregparm=3 -falign-jumps=1 -falign-loops=1 -falign-functions=1 -freg-struct-return -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow -msoft-float -fno-dwarf2-cfi-asm -mno-stack-arg-probe -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-ident -fno-stack-protector -Wtrampolines -Werror   -ffreestanding   -MT lib/i386/relocator_module-relocator.o -MD -MP -MF lib/i386/.deps-core/relocator_module-relocator.Tpo -c -o lib/i386/relocator_module-relocator.o `test -f 'lib/i386/relocator.c' || echo './'`lib/i386/relocator.c
> lib/i386/relocator64.S: Assembler messages:
> lib/i386/relocator64.S:66: Error: unknown pseudo-op: `.code64'
> lib/i386/relocator64.S:74: Error: bad register name `%rax'
> lib/i386/relocator64.S:98: Error: bad register name `%rax'
> lib/i386/relocator64.S:132: Error: bad register name `%rip)'
> --8<---------------cut here---------------end--------------->8---

[...]

> > A patch should be prepared on top of latest GRUB master git branch [1].
>
> Sure, but well..
>
>     https://lists.gnu.org/archive/html/bug-grub/2020-06/msg00013.html
>
> it was when I sent the report ;)

Sorry, I missed it...

> Luckily it still applied cleanly to current master.

Great!

> > And please use "git-send-email" to send the patch as Adrian said...
>
> Sure, sent separately to bug-grub.

I cannot find your updated patch. May I ask you to send it using
"git-send-email" to grub-devel@gnu.org?

Daniel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64)
  2021-05-17 16:49         ` Daniel Kiper
@ 2021-05-18  5:05           ` Jan Nieuwenhuizen
  2021-05-18  7:02             ` John Paul Adrian Glaubitz
  0 siblings, 1 reply; 16+ messages in thread
From: Jan Nieuwenhuizen @ 2021-05-18  5:05 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: Mikhail B. WproxyM, grub-devel

Daniel Kiper writes:

Hello Daniel,

[..]

>> Sure, sent separately to bug-grub.
>
> I cannot find your updated patch.

It's here:

    https://lists.gnu.org/archive/html/bug-grub/2021-05/msg00009.html

> May I ask you to send it using "git-send-email" to grub-devel@gnu.org?

(waiting with this for a bit, please ping if needed :)

Greetings,
Janneke

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64)
  2021-05-18  5:05           ` Jan Nieuwenhuizen
@ 2021-05-18  7:02             ` John Paul Adrian Glaubitz
  0 siblings, 0 replies; 16+ messages in thread
From: John Paul Adrian Glaubitz @ 2021-05-18  7:02 UTC (permalink / raw)
  To: The development of GNU GRUB, Jan Nieuwenhuizen, Daniel Kiper
  Cc: Mikhail B. WproxyM

Hello Jan!

On 5/18/21 7:05 AM, Jan Nieuwenhuizen wrote:
>>> Sure, sent separately to bug-grub.
>>
>> I cannot find your updated patch.
> 
> It's here:
> 
>     https://lists.gnu.org/archive/html/bug-grub/2021-05/msg00009.html
> 
>> May I ask you to send it using "git-send-email" to grub-devel@gnu.org?
> 
> (waiting with this for a bit, please ping if needed :)

I think you should post the patch to this mailing list so it can be reviewed
here. Reviewing the patch when it's located in the archives of a different
mailing list is a bit awkward.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-05-18  7:03 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20  9:35 [Buildroot] boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64) Mikhail B. WproxyM
2021-04-26 20:56 ` Thomas Petazzoni
2021-04-28  8:07   ` Mikhail B. WproxyM
2021-04-28 11:44     ` Thomas Petazzoni
2021-04-28 13:23       ` Mikhail B. WproxyM
2021-05-13  7:19         ` Mikhail B. WproxyM
2021-05-13  7:19           ` Mikhail B. WproxyM
2021-05-13  7:28           ` John Paul Adrian Glaubitz
2021-05-05  9:39 ` Fwd: " Mikhail B. WproxyM
2021-05-05  9:44   ` Mikhail B. WproxyM
2021-05-05 16:33     ` Daniel Kiper
2021-05-13 10:35       ` Jan Nieuwenhuizen
2021-05-17 16:49         ` Daniel Kiper
2021-05-18  5:05           ` Jan Nieuwenhuizen
2021-05-18  7:02             ` John Paul Adrian Glaubitz
2021-05-05 14:16   ` Fwd: " John Paul Adrian Glaubitz

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.