Re: Update on wip-arm-bootstrap

2021-02-21 Thread Jan Nieuwenhuizen
Danny Milosavljevic writes:

Hello Danny,

> Nice!
>
> Patch review:
>
>>+#if __ARM_EABI__
>>+#define CLEAR_CACHE(BEG,END) \
>>+{\
>>+  register unsigned long _beg __asm ("a1") = (unsigned long)(BEG);   \
>>+  register unsigned long _end __asm ("a2") = (unsigned long)(END);   \
>>+  register unsigned long _flg __asm ("a3") = 0;  
>>\
>>+  __asm __volatile ("mov r7, 0x9f0002\n\t"   \
>
> should be mov r7, 0xf0002 in EABI.
> (SWI #(0x90 + syscallnr) is for OABI syscalls only)

Ok, great; that could help!

>>* sysdeps/unix/sysv/linux/arm/brk.c (__brk): Likewise.Likewise.
>
> Duplicate "Likewise".
>
> Otherwise LGTM!

Thanks.  Testing a fixup now (currently only on my branch @gitlab).

>>But something like puts or printf segfaults "Illegal
>>instruction" in strlen:
>
>>--8<---cut here---start->8---
>>(gdb) disas /r
>>Dump of assembler code for function strlen:
>>   0xd160 <+0>:   03 10 c0 e3 bic r1, r0, #3
>>=> 0xd164 <+4>:   04 20 91 e4 ldr r2, [r1], #4  
>>--8<---cut here---end--->8---
>
> Hmm... looks good to me?  Weird.

Yes...

> I'm building it right now and will have a look.

Great, thanks!
Janneke

-- 
Jan Nieuwenhuizen  | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com



Re: Update on wip-arm-bootstrap

2021-02-21 Thread Jan Nieuwenhuizen
Danny Milosavljevic writes:

> Hi Janneke,
>
> I get
>
> gcc-mesboot.sh: line 20:  9438 Illegal instruction (core dumped) ./a.out
>
> │   0x276b8 <__writev+32>   svc 0x0014
>  │
> │  >0x276bc <__writev+36>   mov r4, r0
>  │
>
> The actual problem is at the first line above--the svc with argument != 0.
>
> #0  0x000276bc in __writev (fd=2, vector=0xbebc54c0, count=10)
> at ../sysdeps/unix/sysv/linux/writev.c:51
>
> glibc 2.2.5:sysdeps/unix/sysv/linux/writev.c:51
>
>>  bytes_written = INLINE_SYSCALL (writev, 3, fd, CHECK_N (vector, count), 
>> count);
>
> Err hmm?!

Hmm, I'm not seeing this (I did see something like this before).  You
*are* on

e44b6b7eed squash! commencement: binutils-mesboot0: Support ARM.

right?

> You *are* patching INLINE_SYSCALL body--

Yes

> so I'd guess that __ARM_EABI__ for some reason is not being defined.
>
> I'd suggest to #error (or at least #warning) if !__ARM_EABI__.

That's a good suggestion; I'm setting it in the glibc-mesboot0 recipe

,(if (equal? triplet "arm-unknown-linux-gnu")
 " -D __ARM_EABI__=1"
 "")))

and it "looks like" that's being used in every compilation...

Weird,
Janneke

-- 
Jan Nieuwenhuizen  | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com



Re: Gnome Boxes

2021-02-21 Thread Evan Rowley
FreeBSD also provides .iso.xz. Some examples here:
http://ftp-archive.freebsd.org/pub/FreeBSD/releases/amd64/amd64/ISO-IMAGES/13.0/

On Thu, Feb 18, 2021 at 4:23 PM Julien Lepiller  wrote:

> Sorry, a compressed .iso is probably common, a .iso.xz is very uncommon
> :). We even have had some reports of people trying to copy that directly to
> an installation media.
>
> Le 18 février 2021 14:56:44 GMT-05:00, Tobias Geerinckx-Rice 
> a écrit :
>>
>> Julien Lepiller 写道:
>>
>>> Usually compression is provided by the webserver, but maybe ours
>>> is not configured to do that.  I think we're the only distro to
>>> provide compressed isos.
>>>
>>
>> Really?  Most distribution ISOs use squashfs or similar with
>> XZ/LZMA compression.  It doesn't make sense to compress that over
>> the wire.
>>
>> That said: XZ compression currently saves 27% (559M -> 405M).
>> Transparently serving pre-compressed ISOs with nginx (gzip level
>> 9) would save about 25% (559M -> 415M), which is surprisingly
>> similar.
>>
>> Kind regards,
>>
>> T G-R
>>
>>

-- 
 - EJR


Re: Update on wip-arm-bootstrap

2021-02-21 Thread Danny Milosavljevic
Hi Janneke,

I get

gcc-mesboot.sh: line 20:  9438 Illegal instruction (core dumped) ./a.out

│   0x276b8 <__writev+32>   svc 0x0014 │
│  >0x276bc <__writev+36>   mov r4, r0 │

The actual problem is at the first line above--the svc with argument != 0.

#0  0x000276bc in __writev (fd=2, vector=0xbebc54c0, count=10)
at ../sysdeps/unix/sysv/linux/writev.c:51

glibc 2.2.5:sysdeps/unix/sysv/linux/writev.c:51

>  bytes_written = INLINE_SYSCALL (writev, 3, fd, CHECK_N (vector, count), 
> count);

Err hmm?!

You *are* patching INLINE_SYSCALL body--so I'd guess that __ARM_EABI__ for
some reason is not being defined.

I'd suggest to #error (or at least #warning) if !__ARM_EABI__.


pgpJ1qm1DXq5_.pgp
Description: OpenPGP digital signature


Re: Update on wip-arm-bootstrap

2021-02-21 Thread Danny Milosavljevic
Hi Janneke,

Nice!

Patch review:

>+#if __ARM_EABI__
>+#define CLEAR_CACHE(BEG,END)  \
>+{ \
>+  register unsigned long _beg __asm ("a1") = (unsigned long)(BEG);\
>+  register unsigned long _end __asm ("a2") = (unsigned long)(END);\
>+  register unsigned long _flg __asm ("a3") = 0;   
>\
>+  __asm __volatile ("mov r7, 0x9f0002\n\t"\

should be mov r7, 0xf0002 in EABI.
(SWI #(0x90 + syscallnr) is for OABI syscalls only)

>* sysdeps/unix/sysv/linux/arm/brk.c (__brk): Likewise.Likewise.

Duplicate "Likewise".

Otherwise LGTM!

>But something like puts or printf segfaults "Illegal
>instruction" in strlen:

>--8<---cut here---start->8---
>(gdb) disas /r
>Dump of assembler code for function strlen:
>   0xd160 <+0>:03 10 c0 e3 bic r1, r0, #3
>=> 0xd164 <+4>:04 20 91 e4 ldr r2, [r1], #4  
>--8<---cut here---end--->8---

Hmm... looks good to me?  Weird.

I'm building it right now and will have a look.


pgpheWF3N5kjV.pgp
Description: OpenPGP digital signature


Re: Update on wip-arm-bootstrap

2021-02-21 Thread Danny Milosavljevic
> > Does that mean there are no old reference binaries known to work on
> > Novena?  
> 
> Not if they are binaries from before Lenny (2009), unless we compile the
> kernel with OABI support, which as I understand from Danny, is a bad
> idea.  Weird.

It backdoors https://en.wikipedia.org/wiki/Seccomp if you enable the kernel
option CONFIG_OABI_COMPAT (it also breaks syscall auditing).

And it's very easy to just change the syscall facility in glibc to emit EABI
syscalls (load one new register with constant, and the swi number is different).

Also, binaries compiled with gcc already [say they] are EABI (while using
OABI syscalls :P).

So I think just using EABI syscalls is easier than figuring out how to get
gcc to emit OABI executables--which otherwise are an obsolete format.

GNU Mes for ARM does not use OABI for its own system calls either.

I mean as a test we could totally enable that kernel option and see
whether the bootstrap works.  But it's of limited long-term use.  If we want
regular people to be able to build our bootstrap binaries, we probably
shouldn't rely on them enabling obscure kernel options where the kernel docs
say you shouldn't enable those.


pgpmm7f7GOl5F.pgp
Description: OpenPGP digital signature


Re: Update on wip-arm-bootstrap

2021-02-21 Thread Jan Nieuwenhuizen
Jan Nieuwenhuizen writes:

Hi Danny!

>> On Thu, 18 Feb 2021 22:52:57 +0100
>> Jan Nieuwenhuizen  wrote:
>> Since this only affects the syscall interface and since also our
>> ELF headers specify EABI, I would just change the syscalls to EABI:
>> Just put the syscall number into r7 and use svc 0.
>
> Oh, if that's all we should be able to find and fix it?

I took a stab at it and created the attached patch, also on
wip-arm-bootstrap now.  This allows creating simple binaries using
gcc-core-mesboot0 and glibc-mesboot0 that run, like "return 42" and even
"exit (42)".  But something like puts or printf segfaults "Illegal
instruction" in strlen:

--8<---cut here---start->8---
(gdb) disas /r
Dump of assembler code for function strlen:
   0xd160 <+0>: 03 10 c0 e3 bic r1, r0, #3
=> 0xd164 <+4>: 04 20 91 e4 ldr r2, [r1], #4
--8<---cut here---end--->8---

makes no sens to me?  So, trying to build the first glibc-based gcc

--8<---cut here---start->8---
./pre-inst-env guix build -e '(@@ (gnu packages commencement) gcc-mesboot0)'
--8<---cut here---end--->8---

still fails during configure.  Seems like I'm stuck here again,
hopefully you can spot some silly mistake in my patch or have another
helpful insight :-)

Greetings,
Janneke

>From dda9f6d081d68848a1d602c375e0d7a8871e4ae4 Mon Sep 17 00:00:00 2001
From: "Jan (janneke) Nieuwenhuizen" 
Date: Sat, 20 Feb 2021 15:32:53 +0100
Subject: [PATCH 8/8] bootstrappable: arm: Support EABI system calls.
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8

* sysdeps/unix/sysv/linux/arm/sysdep.h (DO_CALL,INLINE_SYSCALL)
[__ARM_EABI__]: Use eabi calling convention for syscalls.
* sysdeps/arm/dl-machine.h (CLEAR_CACHE): Likewise.
* sysdeps/unix/sysv/linux/arm/brk.c (__brk): Likewise.Likewise.
* sysdeps/unix/sysv/linux/arm/clone.S: Likewise.
* sysdeps/unix/sysv/linux/arm/mmap.S: Likewise.
* sysdeps/unix/sysv/linux/arm/mmap64.S: Likewise.
* sysdeps/unix/sysv/linux/arm/sigrestorer.S: Likewise.
* sysdeps/unix/sysv/linux/arm/socket.S: Likewise.
* sysdeps/unix/sysv/linux/arm/vfork.S: Likewise.
---
 sysdeps/arm/dl-machine.h  | 14 ++
 sysdeps/unix/sysv/linux/arm/brk.c | 10 +
 sysdeps/unix/sysv/linux/arm/clone.S   |  7 +++
 sysdeps/unix/sysv/linux/arm/mmap.S|  7 +++
 sysdeps/unix/sysv/linux/arm/mmap64.S  |  7 +++
 sysdeps/unix/sysv/linux/arm/sigrestorer.S | 14 ++
 sysdeps/unix/sysv/linux/arm/socket.S  |  7 +++
 sysdeps/unix/sysv/linux/arm/sysdep.h  | 54 +++
 sysdeps/unix/sysv/linux/arm/vfork.S   | 14 ++
 9 files changed, 134 insertions(+)

diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h
index 2d802b7..02c48bd 100644
--- a/sysdeps/arm/dl-machine.h
+++ b/sysdeps/arm/dl-machine.h
@@ -32,6 +32,19 @@
   && VALID_ELF_OSABI (hdr[EI_OSABI]) \
   && VALID_ELF_ABIVERSION (hdr[EI_ABIVERSION])
 
+#if __ARM_EABI__
+#define CLEAR_CACHE(BEG,END)		\
+{	\
+  register unsigned long _beg __asm ("a1") = (unsigned long)(BEG);	\
+  register unsigned long _end __asm ("a2") = (unsigned long)(END);	\
+  register unsigned long _flg __asm ("a3") = 0;\
+  __asm __volatile ("mov r7, 0x9f0002\n\t"\
+		"swi 0x0		@ sys_cacheflush"		\
+		: /* no outputs */	\
+		: /* no inputs */	\
+		: "a1","r7");	\
+}
+#else // !__ARM_EABI__
 #define CLEAR_CACHE(BEG,END)		\
 {	\
   register unsigned long _beg __asm ("a1") = (unsigned long)(BEG);	\
@@ -42,6 +55,7 @@
 		: /* no inputs */	\
 		: "a1");		\
 }
+#endif // !__ARM_EABI__
 
 /* Return nonzero iff ELF header is compatible with the running host.  */
 static inline int __attribute__ ((unused))
diff --git a/sysdeps/unix/sysv/linux/arm/brk.c b/sysdeps/unix/sysv/linux/arm/brk.c
index 153d893..d5d0904 100644
--- a/sysdeps/unix/sysv/linux/arm/brk.c
+++ b/sysdeps/unix/sysv/linux/arm/brk.c
@@ -29,12 +29,22 @@ __brk (void *addr)
 {
   void *newbrk;
 
+#if __ARM_EABI__
+  asm ("mov a1, %1\n"	/* save the argment in r0 */
+   "mov r7, %2\n"	/* system call nr in r7 */
+   "swi 0x0\n"	/* do the system call */
+   "mov %0, a1;"	/* keep the return value */
+   : "=r"(newbrk)
+   : "r"(addr), "i" (SYS_ify (brk))
+   : "a1","r7");
+#else // !__ARM_EABI__
   asm ("mov a1, %1\n"	/* save the argment in r0 */
"swi %2\n"	/* do the system call */
"mov %0, a1;"	/* keep the return value */
: "=r"(newbrk) 
: "r"(addr), "i" (SYS_ify (brk))
: "a1");
+#endif // !__ARM_EABI__
 
   __curbrk = newbrk;
 
diff --git a/sysdeps/unix/sysv/linux/arm/clone.S b/sysdeps/unix/sysv/linux/arm/clone.S
index c9a1ec2..bd088b4 100644
--- a/sysdeps/unix/sysv/linux/arm/clone.S
+++ b/sysdeps/unix/sysv/linux/arm/clone.S
@@ -44,7 +44,14 @@ ENTRY(__clone)
 	@ get flags
 	mov	r0, r2
 	@ new sp is 

Re: Update on wip-arm-bootstrap

2021-02-21 Thread Jan Nieuwenhuizen
Ludovic Courtès writes:

Hello,

> I read the story, which I found rather fun and full of suspense, but I
> admit I was disappointed by the ending.  :-)
>
> Jan Nieuwenhuizen  skribis:
>
>> ...pretty familiar.  So, what's going on here?  Do the "woody"
>> binaries not run on novena?
>
> Does that mean there are no old reference binaries known to work on
> Novena?

Not if they are binaries from before Lenny (2009), unless we compile the
kernel with OABI support, which as I understand from Danny, is a bad
idea.  Weird.

Janneke

-- 
Jan Nieuwenhuizen  | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com



Confusing error messages from guix when loading a user scheme file that fails to load another file

2021-02-21 Thread Rovanion Luckey
Hi,
Today I encountered an issue with Guix's user interface. I was trying to
load a Scheme file defining a development environment with `guix
environment --ad-hoc --load=file.scm`, but Guix kept telling me that the
file did not exist even though I could swear it did:

> $ head -n 1 development-environment.scm
> (use-modules (gnu packages)
> $ guix environment --ad-hoc --load=development-environment.scm
> guix environment: error: failed to load 'development-environment.scm': No
such file or directory

After pulling my hair out for a while and then turning to `strace` I
figured out that it was not actually that the file
`development-environment.scm` did not exist, the issue was that the Scheme
code in that file tried to load a file that did not exist.

I set up a couple of different test cases to see if all errors were
reported equally and to understand the issue better. Running a file that
contains a syntax error indicates that there is an error in the file itself

> $ guix environment --ad-hoc --load=syntax-error.scm
> syntax-error.scm:2:1: missing closing parenthesis


The same goes for when the code in the file being run throws an exception:

> $ guix environment --ad-hoc --load=throw-exception.scm
> guix environment: error: failed to load 'throw-exception.scm':
> throw-exception.scm:1:0: banana


But when the code in turn tries to load another file which does not exist
it is reported as if the file itself is missing:

> $ guix environment --ad-hoc --load=load-non-existing-file.scm
> guix environment: error: failed to load 'load-non-existing-file.scm': No
such file or directory


I was able to find the source of the error message in `guix/ui.scm:378` and
patched it to output the following message that makes more sense in this
failure case:

> $ ./pre-inst-env guix environment --ad-hoc
--load=load-non-existing-file.scm
> guix environment: error: failed to evaluate 'load-non-existing-file.scm',
it raised the error: No such file or directory


So here comes my questions:

1. Why is the file and line number not reported when the user provided
scheme file fails to load another file?
2. Is it possible to modify guix so that it is?
3. If not, is the code path that I patched also used for other failures
making the modification I demonstrated above a bad idea?
4. If so, is there a better way?

I have attached the three small Scheme source code files used in the above
examples.
(use-modules (ice-9 rdelim))

(with-input-from-file "non-existant" read-string)
(error "banana")
(