Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User mode is incomplete: lacks system calls to run bash #1

Open
kasperk81 opened this issue Jun 16, 2021 · 10 comments
Open

User mode is incomplete: lacks system calls to run bash #1

kasperk81 opened this issue Jun 16, 2021 · 10 comments

Comments

@kasperk81
Copy link
Contributor

kasperk81 commented Jun 16, 2021

On (very old) Debian 7 wheezy x64 (the last version before ia64 support was dropped from Deb), I built ski and created chroot using archive:

$ debootstrap --arch=ia64 wheezy /ia64 http://archive.debian.org/debian/

1. User mode

after that running bash from ia64 rootfs with user mode gives me errors like:

$ bski -forceuser -simroot /ia64 -noconsole /ia64/bin/bash
doSyscall: unimplemented system call 1293
doSyscall: unimplemented system call 1293
doSyscall: unimplemented system call 1293

root@debian $ uname -a
                    Ignoring unimplemented clone() system call
bash: fork: Function not implemented

root@debian $ apt-get --help
                                Ignoring unimplemented clone() system call
bash: fork: Function not implemented

2. System mode

and with system mode, I get:

$ bski -forcesystem -simroot /ia64 -noconsole /ia64/bin/bash
/ia64/bin/bash - PT_INTERP segment not allowed
bski: Could not open /ia64/bin/bash for reading

is there a way to fix either of these? I want to test build some library code on ia64 without an Itanium system.

@kasperk81
Copy link
Contributor Author

kasperk81 commented Jun 17, 2021

Same issue on buster.

Setup is:

$ docker run --privileged -it debian:buster
$ apt update && apt install debootstrap
# ignore unsupported architecture check
$ sed -i 's/1)      error 1 ARCHNOTEXEC/#1)      error 1 ARCHNOTEXEC/' $(command -v debootstrap)
$ debootstrap --verbose --no-check-gpg  --arch ia64 wheezy /ia64 http://archive.debian.org/debian/

# install dependencies and build ski
$ apt install -y debootstrap build-essential git libtool-bin autoconf automake libglade2-dev bison libelf-dev ncurses-dev gperf flex
$ git clone https://github.com/trofi/ski; cd ski
$ ./autogen.sh;./configure;make -j > logs 2>&1   # log file has 62K+ lines full of unused variable warnings!!!
# if it fails (due to concurrency issue; eparse.h is required before it is generated ...)
# just rerun `make -j`
$ echo $?  # should be zero now

# usage, both give same errors as noted in previous comment
$ /ski/src/bski -forceuser   -simroot /ia64 -noconsole /ia64/bin/bash
$ /ski/src/bski -forcesystem -simroot /ia64 -noconsole /ia64/bin/bash

@trofi
Copy link
Owner

trofi commented Jun 17, 2021

  1. User mode

We'll need to add more fresh syscalls to see how it goes. My expectation is that compatibility is weaker that of most qemu-user targets. But might work. I'll have a look.

  1. System mode

This one has higher chance to succeed. But also has quite a few caveats:

  1. system mode needs a block device to boot from
  2. system mode needs special hpsim build of kernel and boot loader to boot (was removed recently from linux kernel)
  3. system mode is expected to be 1000x slower than native. That might make any real-world building impractical.

A few years ago I booted 4.11 successfully: https://trofi.github.io/posts/199-ia64-machine-emulation.html

A few other options are:
a. build ia64-unknown-linux-gnu cross-compiler. In gentoo it's as easy as running crossdev -t ia64-unknown-linux-gnu.
b. ask for access to ia64 debian system on irc://oftc/#debian-ports

trofi pushed a commit that referenced this issue Jun 17, 2021
Reported-by: kasperk81
Bug: #1
Signed-off-by: Sergei Trofimovich <[email protected]>
@kasperk81
Copy link
Contributor Author

kasperk81 commented Jun 18, 2021

Thanks, latest kernel support for user+system modes would be great! After all ski is exclusively supporting ia64 emulation (other than a WIP for qemu ia64 in a fork). :)

I tried the cross compiler option on gentoo meanwhile, and got errors. Here is what I did:

$ docker run -it --privileged gentoo/stage3

$ emerge-webrsync
$ emerge sys-devel/crossdev app-eselect/eselect-repository
$ mkdir -p /etc/portage/repos.conf/
$ eselect repository create localrepo
$ crossdev -t ia64-unknown-linux-gnu
...
 * Emerging cross-gcc-stage1 ...

 * error: gcc failed :(
 *
 * If you file a bug, please attach the following logfiles:
 * /var/log/portage/cross-ia64-unknown-linux-gnu-info.log
 * /var/log/portage/cross-ia64-unknown-linux-gnu-gcc-stage1.log.xz
 * /var/tmp/portage/cross-ia64-unknown-linux-gnu/gcc*/temp/gcc-config.logs.tar.xz

# strip ANSI colors from logs and upload
$ cat /var/log/portage/cross-ia64-unknown-linux-gnu-gcc-stage1.log \
    | sed 's/\x1B[@A-Z\\\]^_]\|\x1B\[[0-9:;<=>?]*[-!"#$%&'"'"'()*+,.\/]*[][\\@A-Z^_`a-z{|}~]//g' \
    | curl -F"sprunge=<-" http://sprunge.us

logs: http://sprunge.us/gXNYGu

@trofi
Copy link
Owner

trofi commented Jun 20, 2021

/var/tmp/portage/cross-ia64-unknown-linux-gnu/gcc-11.1.0-r1/work/gcc-11.1.0/libgcc/config/ia64/fde-glibc.c:33:10: fatal error: stdlib.h: No such file or directory
33 | #include <stdlib.h>
| ^~~~~~~~~~

Oh, that was recently fixed in https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=bcedb8deeb2e08b91db7b6f5c31623d2a777cb8b

As a workaround you can enable it explicitly: crossdev -t ia64-unknown-linux-gnu --with-headers

@kasperk81
Copy link
Contributor Author

Thanks @trofi! crossdev solution worked. :)

@trofi
Copy link
Owner

trofi commented Jul 11, 2022

https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=cef03728234644b1a9ad5bd8e94daeac8650a71b should fix --without-headers build upstream as well.

@trofi
Copy link
Owner

trofi commented Aug 20, 2022

Added basic HOWTO on how to get both user and system modes to run: 4206523.

Released 1.4.0 with minor tweak to make ski built on modern environments: https://github.com/trofi/ski/releases/tag/v1.4.0

Let's rename this report into incomplete support of user mode.

@trofi trofi changed the title Both user and system modes broken? User more is incomplete: lacks system calls to run bash Aug 20, 2022
@trofi
Copy link
Owner

trofi commented Aug 20, 2022

Current bash status:

$ LANG=C bskinc ./bash-ia64/bin/bash
doSyscall: unimplemented system call 1298
doSyscall: unimplemented system call 1325
doSyscall: unimplemented system call 1254
Ignoring unimplemented sysinfo() system call
doSyscall: unimplemented system call 1254
doSyscall: unimplemented system call 1254
doSyscall: unimplemented system call 1325
doSyscall: unimplemented system call 1325
doSyscall: unimplemented system call 1317
bash: cannot make pipe for command substitution: Function not implemented
doSyscall: unimplemented system call 1317
bash: cannot make pipe for command substitution: Function not implemented
doSyscall: unimplemented system call 1254
doSyscall: unimplemented system call 1254

@sskras
Copy link

sskras commented Oct 31, 2023

That's interesting. I wonder if running a simpler thing, some Borne-like shell (like Dash or PDksh) would be more successful.

@kasperk81 kasperk81 changed the title User more is incomplete: lacks system calls to run bash User mode is incomplete: lacks system calls to run bash Oct 31, 2023
@trofi
Copy link
Owner

trofi commented Nov 1, 2023

My guess would be that most of these syscalls come from modern glibc and are not very specific to the shell code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants