Message ID | 1456327988-31568-4-git-send-email-andre.przywara@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, Feb 24, 2016 at 03:33:07PM +0000, Andre Przywara wrote: > Currently the pre_init support is provided only for x86_64. Since > having 32-bit x86 supported as well is not far off, just add an > implementation using i386 assembly instructions and the respective > syscall ABI. > > Signed-off-by: Andre Przywara <andre.przywara@arm.com> > --- > Makefile | 1 + > x86/init32.S | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 51 insertions(+) > create mode 100644 x86/init32.S Did you manage to test this? Will -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Will, On 02/03/16 02:57, Will Deacon wrote: > On Wed, Feb 24, 2016 at 03:33:07PM +0000, Andre Przywara wrote: >> Currently the pre_init support is provided only for x86_64. Since >> having 32-bit x86 supported as well is not far off, just add an >> implementation using i386 assembly instructions and the respective >> syscall ABI. >> >> Signed-off-by: Andre Przywara <andre.przywara@arm.com> >> --- >> Makefile | 1 + >> x86/init32.S | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ >> 2 files changed, 51 insertions(+) >> create mode 100644 x86/init32.S > > Did you manage to test this? Yes, I think I tested it back when I originally wrote this, but I just redid the testing using a 32-bit Ubuntu-Core i386 chroot (and deleting the .lkvm/default directory before testing to make sure you don't get an older version of init). It works fine and apart from the size of the binary I can't tell a difference between booting with or without the patch. Cheers, Andre. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/Makefile b/Makefile index e26afa3..54bdd31 100644 --- a/Makefile +++ b/Makefile @@ -106,6 +106,7 @@ ARCH ?= $(shell uname -m | sed -e s/i.86/i386/ -e s/ppc.*/powerpc/ \ ifeq ($(ARCH),i386) ARCH := x86 DEFINES += -DCONFIG_X86_32 + ARCH_PRE_INIT = x86/init32.S endif ifeq ($(ARCH),x86_64) ARCH := x86 diff --git a/x86/init32.S b/x86/init32.S new file mode 100644 index 0000000..8937deb --- /dev/null +++ b/x86/init32.S @@ -0,0 +1,50 @@ +/* + * #!/bin/sh + * mount -t 9p -o trans=virtio,version=9p2000.L hostfs /host + * /virt/init $* + */ + +#include <asm/unistd.h> +.text +.globl _start +_start: + +# Linux syscall ABI +# i386/int 0x80: nr = eax, args: ebx ecx edx esi edi ebp +# x86_64/syscall: nr = rax, args: rdi rsi rdx r10 r8 r9 + + mov $__NR_mount, %eax + mov $.m_dev, %ebx + mov $.m_dir, %ecx + mov $.m_typ, %edx + mov $1, %esi # MS_RDONLY + mov $.m_opt, %edi + int $0x80 + + mov $__NR_execve, %eax + mov $.e_nam, %ebx # filename: "/virt/init" + lea 4(%esp), %ecx # pass through argv + mov %ebx, (%ecx) # overwrite argv[0] with "/virt/init" + mov (%esp), %edx # read argc + inc %edx + lea (%ecx,%edx,4), %edx # envp = argv + argc + 1 + int $0x80 + + mov $__NR_exit, %eax + mov $1, %ebx + int $0x80 # panic + +loop: hlt + jmp loop + +.m_dev: +.string "hostfs" +.m_dir: +.string "/host" +.m_typ: +.string "9p" +.m_opt: +.string "trans=virtio,version=9p2000.L" + +.e_nam: +.string "/virt/init"
Currently the pre_init support is provided only for x86_64. Since having 32-bit x86 supported as well is not far off, just add an implementation using i386 assembly instructions and the respective syscall ABI. Signed-off-by: Andre Przywara <andre.przywara@arm.com> --- Makefile | 1 + x86/init32.S | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 x86/init32.S