All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Nieuwenhuizen <janneke@gnu.org>
To: Daniel Kiper <dkiper@net-space.pl>
Cc: "Mikhail B. WproxyM" <w.proxy.m@gmail.com>,  grub-devel@gnu.org
Subject: Re: boot/grub2: grub-core-build-fixes-for-i386 (grub-2.04 + binutils-2.35.2 + pseudo-op .code64)
Date: Thu, 13 May 2021 12:35:25 +0200	[thread overview]
Message-ID: <87eeeaor9u.fsf@gnu.org> (raw)
In-Reply-To: <20210505163302.hkkti2ewr3iebht6@tomti.i.net-space.pl> (Daniel Kiper's message of "Wed, 5 May 2021 18:33:02 +0200")

[-- 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

  reply	other threads:[~2021-05-13 13:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=87eeeaor9u.fsf@gnu.org \
    --to=janneke@gnu.org \
    --cc=dkiper@net-space.pl \
    --cc=grub-devel@gnu.org \
    --cc=w.proxy.m@gmail.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.