Re: [osv-dev] OSv boots and runs simple hello world on Firecracker ARM edition ... on Raspberry PI 4

2020-05-25 Thread Nadav Har'El
On Thu, May 21, 2020 at 11:58 PM Waldek Kozaczuk 
wrote:

>
> *ubuntu@ubuntu-rasp4*:*~*$ uname -a
>
> Linux ubuntu-rasp4 5.3.0-1025-raspi2 #27-Ubuntu SMP Fri May 8 08:32:04
> UTC 2020 aarch64 aarch64 aarch64 GNU/Linux
>
> *ubuntu@ubuntu-rasp4*:*~*$ ./firecracker-v0.21.1-aarch64 --no-api --config
> -file ./osv-config.json
>
> OSv v0.55.0-9-g840428ad
>
> PSCI: version 65536.0 detected.
>
> setup_arm_clock() ENTERED, lr=800d54e0
>
> arm_clock(): frequency read as 0337f980
>
> interrupt_table::interrupt_table() ENTERED, lr=800a8d1c
>
> gic_driver::init_cpu() ENTERED, lr=80201c80
>
> CPU interface enabled.
>
> gic_driver::init_dist() ENTERED, lr=80201c8c
>
> number of supported IRQs: 0080
>
> interrupt table: gic driver created.
>
> registered IRQ id=0004
>
> registered IRQ id=001b
>
> registered IRQ id=
>
> Premain complete!
>
> smp_launch ENTERED, lr=800d709c
>
> Booted up in 0.00 ms
>
> Cmdline: console=ttyS0 --verbose --nomount --maxnic=0 /tools/hello.so
> earlycon=uart,mmio,0x40001000
>
> faulting address 1001fea0
>
> faulting address 1328
>
> faulting address 1002
>
> faulting address 10050018
>
> faulting address 100301c8
>
> faulting address 1004fe00
>
> Hello from C code
>
> 2020-05-21T20:24:04.080765641 [anonymous-instance:ERROR:src/vmm/src/vstate
> .rs:951] Unexpected exit reason on vcpu run: SystemEvent
>
> In general it took me a bit of research as I am not really familiar with
> ARM architecture and even reading the assembly was a bit a challenge to say
> the least. And then debugging without debugger and any console (:-( .. so
> not debug() for long time. But all in all it was not too bad and the
> changes that I had to make to OSv are in my opinion much smaller and easier
> comparing to x86_64.
>

Very nice!

I'll try to review a few points below, but I'm even a less of an ARM expert
(and definitely firecracker expert) than you so I'm not sure how valuable
my review will be.
We just need to take care not to break what was already working in the
existing aarch64 code, because I don't know how it was tested, and how
various changes can break other arm variants and hypervisors.


>
> Below you will see the "hack-patch" showing what changes I had to make.
> Logically, following things had to be changed:
>
>- The most important thing was to move kernel from 0x4000 (1GB) to
>0x8000 (2GB) which required changing one line in Makefile (see below)
>and changing boot paging table to map the 2GB-3GB area of memory; only then
>I could actually start debugging :-) I wonder if it will also work on
>QEMU/KVM - possinly qemu boot loader will inspect ELF and place it
>accordingly in memory; firecracker does not read ELF and simply places it
>at 2GB
>- To get console working I guessed that that need to create equivalent
>class for isa_serial_console but communicating over mmio (see
>mmio_isa_serial_console.hh/cc) which in essence invokes mmio_set*/mmio_get*
>(it would be nice to extract common code somehow - suggestions welcome)
>
>
Perhaps you can have class class mmio_isa_serial_console inherit from
isa_serial_console, but change the implementation to use a method out()
instead of pci::outb() - and the new mmio_isa_serial_console will just
override the out() function (perhaps out() needs to be virtual for this to
work?).



>
>- Some more trivial changes - for now mostly disabling things - for
>now quite disorganized
>
>
> diff --git a/Makefile b/Makefile
> index db3c68cf..ffd570a5 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -354,6 +354,7 @@ tools := tools/mkfs/mkfs.so tools/cpiod/cpiod.so
>  $(out)/tools/%.o: COMMON += -fPIC
>
>  tools += tools/uush/uush.so
> +tools += tools/uush/hello.so
>  tools += tools/uush/ls.so
>  tools += tools/uush/mkdir.so
>
> @@ -451,8 +452,8 @@ endif # x64
>
>  ifeq ($(arch),aarch64)
>
> -kernel_base := 0x4008
> -kernel_vm_base := 0x4008
> +kernel_base := 0x8008
> +kernel_vm_base := 0x8008
>

I'm a bit worried about these magic numbers... I don't know if 0x4008
was important previously and things would break with a different number or
was it just picked randomly, and why 0x8008 is necessary now.


>  app_local_exec_tls_size := 0x0
>
>  include $(libfdt_base)/Makefile.libfdt
> @@ -816,6 +817,7 @@ drivers += drivers/xenplatform-pci.o
>  endif # x64
>
>  ifeq ($(arch),aarch64)
> +drivers += drivers/mmio-isa-serial.o
>  drivers += drivers/pl011.o
>  drivers += drivers/xenconsole.o
>  drivers += drivers/virtio.o
> diff --git a/arch/aarch64/arch-dtb.cc b/arch/aarch64/arch-dtb.cc
> index b59f1dcc..cd0719e8 100644
> --- a/arch/aarch64/arch-dtb.cc
> +++ b/arch/aarch64/arch-dtb.cc
> @@ -225,7 +225,8 @@ bool dtb_get_gic_v2(u64 *dist, size_t *dist_len, u64
> *cpu, size_t *cpu_len)
>  if (!dtb)
>  return false;
>
> -node = 

Re: [osv-dev] OSv boots and runs simple hello world on Firecracker ARM edition ... on Raspberry PI 4

2020-05-22 Thread Waldek Kozaczuk
I thing I forgot to mention is that currently OSv arm version only supports 
GIC 2 interrupt controller which is enough for RP 4. But we need GIC 3/4 to 
be able to run on Firecracker on "real"/non-toy hardware. I do not know how 
difficult it would be to support GIC 3/4.

On Friday, May 22, 2020 at 12:21:23 AM UTC-4, Roman Shaposhnik wrote:
>
> This is super awesome, Waldek! I'm now inspired to run OSv as a VM 
> backed by Firecracker on Project EVE/RPi! ;-) 
>
> Btw, can you share your osv-config.json and also details of what 
> version of Firecracker you used? 
>
 
{
  "boot-source": {
"kernel_image_path": "/home/ubuntu/loader_with_console.img",
"boot_args": "console=ttyS0 --verbose --nomount --maxnic=0 
/tools/hello.so"
  },
  "drives": []
}
 

firecracker-v0.21.1-aarch64 - which I believe is the latest.


> Better yet -- if there's a github repo with all the bits and pieces 
> required to replicate your setup -- that'd be worthy of a gift of a 
> beer (post COVID tho!) ;-) 
>
There is a build-able branch (which is in essence current master + patch I 
have enclosed) - https://github.com/wkozaczuk/osv/tree/arm_on_firecracker2

./scripts/build image=empty arch=aarch64 fs=ramfs (it add simple hello 
world binary).

and then run

./firecracker-v0.21.1-aarch64 --no-api --config-file ./osv-config.json

>
> Thanks, 
> Roman. 
>
> On Thu, May 21, 2020 at 1:58 PM Waldek Kozaczuk  > wrote: 
> > 
> > 
> > ubuntu@ubuntu-rasp4:~$ uname -a 
> > 
> > Linux ubuntu-rasp4 5.3.0-1025-raspi2 #27-Ubuntu SMP Fri May 8 08:32:04 
> UTC 2020 aarch64 aarch64 aarch64 GNU/Linux 
> > 
> > ubuntu@ubuntu-rasp4:~$ ./firecracker-v0.21.1-aarch64 --no-api 
> --config-file ./osv-config.json 
> > 
> > OSv v0.55.0-9-g840428ad 
> > 
> > PSCI: version 65536.0 detected. 
> > 
> > setup_arm_clock() ENTERED, lr=800d54e0 
> > 
> > arm_clock(): frequency read as 0337f980 
> > 
> > interrupt_table::interrupt_table() ENTERED, lr=800a8d1c 
> > 
> > gic_driver::init_cpu() ENTERED, lr=80201c80 
> > 
> > CPU interface enabled. 
> > 
> > gic_driver::init_dist() ENTERED, lr=80201c8c 
> > 
> > number of supported IRQs: 0080 
> > 
> > interrupt table: gic driver created. 
> > 
> > registered IRQ id=0004 
> > 
> > registered IRQ id=001b 
> > 
> > registered IRQ id= 
> > 
> > Premain complete! 
> > 
> > smp_launch ENTERED, lr=800d709c 
> > 
> > Booted up in 0.00 ms 
> > 
> > Cmdline: console=ttyS0 --verbose --nomount --maxnic=0 /tools/hello.so 
> earlycon=uart,mmio,0x40001000 
> > 
> > faulting address 1001fea0 
> > 
> > faulting address 1328 
> > 
> > faulting address 1002 
> > 
> > faulting address 10050018 
> > 
> > faulting address 100301c8 
> > 
> > faulting address 1004fe00 
> > 
> > Hello from C code 
> > 
> > 2020-05-21T20:24:04.080765641 [anonymous-instance:ERROR:src/vmm/src/
> vstate.rs:951] Unexpected exit reason on vcpu run: SystemEvent 
> > 
> > 
> > In general it took me a bit of research as I am not really familiar with 
> ARM architecture and even reading the assembly was a bit a challenge to say 
> the least. And then debugging without debugger and any console (:-( .. so 
> not debug() for long time. But all in all it was not too bad and the 
> changes that I had to make to OSv are in my opinion much smaller and easier 
> comparing to x86_64. 
> > 
> > Below you will see the "hack-patch" showing what changes I had to make. 
> Logically, following things had to be changed: 
> > 
> > The most important thing was to move kernel from 0x4000 (1GB) to 
> 0x8000 (2GB) which required changing one line in Makefile (see below) 
> and changing boot paging table to map the 2GB-3GB area of memory; only then 
> I could actually start debugging :-) I wonder if it will also work on 
> QEMU/KVM - possinly qemu boot loader will inspect ELF and place it 
> accordingly in memory; firecracker does not read ELF and simply places it 
> at 2GB 
> > To get console working I guessed that that need to create equivalent 
> class for isa_serial_console but communicating over mmio (see 
> mmio_isa_serial_console.hh/cc) which in essence invokes mmio_set*/mmio_get* 
> (it would be nice to extract common code somehow - suggestions welcome) 
> > Some more trivial changes - for now mostly disabling things - for now 
> quite disorganized 
> > 
> > 
> > diff --git a/Makefile b/Makefile 
> > index db3c68cf..ffd570a5 100644 
> > --- a/Makefile 
> > +++ b/Makefile 
> > @@ -354,6 +354,7 @@ tools := tools/mkfs/mkfs.so tools/cpiod/cpiod.so 
> >  $(out)/tools/%.o: COMMON += -fPIC 
> > 
> >  tools += tools/uush/uush.so 
> > +tools += tools/uush/hello.so 
> >  tools += tools/uush/ls.so 
> >  tools += tools/uush/mkdir.so 
> > 
> > @@ -451,8 +452,8 @@ endif # x64 
> > 
> >  ifeq ($(arch),aarch64) 
> > 
> > -kernel_base := 0x4008 
> > -kernel_vm_base := 0x4008 
> > +kernel_base := 0x8008 
> > +kernel_vm_base 

Re: [osv-dev] OSv boots and runs simple hello world on Firecracker ARM edition ... on Raspberry PI 4

2020-05-21 Thread Roman Shaposhnik
This is super awesome, Waldek! I'm now inspired to run OSv as a VM
backed by Firecracker on Project EVE/RPi! ;-)

Btw, can you share your osv-config.json and also details of what
version of Firecracker you used?

Better yet -- if there's a github repo with all the bits and pieces
required to replicate your setup -- that'd be worthy of a gift of a
beer (post COVID tho!) ;-)

Thanks,
Roman.

On Thu, May 21, 2020 at 1:58 PM Waldek Kozaczuk  wrote:
>
>
> ubuntu@ubuntu-rasp4:~$ uname -a
>
> Linux ubuntu-rasp4 5.3.0-1025-raspi2 #27-Ubuntu SMP Fri May 8 08:32:04 UTC 
> 2020 aarch64 aarch64 aarch64 GNU/Linux
>
> ubuntu@ubuntu-rasp4:~$ ./firecracker-v0.21.1-aarch64 --no-api --config-file 
> ./osv-config.json
>
> OSv v0.55.0-9-g840428ad
>
> PSCI: version 65536.0 detected.
>
> setup_arm_clock() ENTERED, lr=800d54e0
>
> arm_clock(): frequency read as 0337f980
>
> interrupt_table::interrupt_table() ENTERED, lr=800a8d1c
>
> gic_driver::init_cpu() ENTERED, lr=80201c80
>
> CPU interface enabled.
>
> gic_driver::init_dist() ENTERED, lr=80201c8c
>
> number of supported IRQs: 0080
>
> interrupt table: gic driver created.
>
> registered IRQ id=0004
>
> registered IRQ id=001b
>
> registered IRQ id=
>
> Premain complete!
>
> smp_launch ENTERED, lr=800d709c
>
> Booted up in 0.00 ms
>
> Cmdline: console=ttyS0 --verbose --nomount --maxnic=0 /tools/hello.so 
> earlycon=uart,mmio,0x40001000
>
> faulting address 1001fea0
>
> faulting address 1328
>
> faulting address 1002
>
> faulting address 10050018
>
> faulting address 100301c8
>
> faulting address 1004fe00
>
> Hello from C code
>
> 2020-05-21T20:24:04.080765641 
> [anonymous-instance:ERROR:src/vmm/src/vstate.rs:951] Unexpected exit reason 
> on vcpu run: SystemEvent
>
>
> In general it took me a bit of research as I am not really familiar with ARM 
> architecture and even reading the assembly was a bit a challenge to say the 
> least. And then debugging without debugger and any console (:-( .. so not 
> debug() for long time. But all in all it was not too bad and the changes that 
> I had to make to OSv are in my opinion much smaller and easier comparing to 
> x86_64.
>
> Below you will see the "hack-patch" showing what changes I had to make. 
> Logically, following things had to be changed:
>
> The most important thing was to move kernel from 0x4000 (1GB) to 
> 0x8000 (2GB) which required changing one line in Makefile (see below) and 
> changing boot paging table to map the 2GB-3GB area of memory; only then I 
> could actually start debugging :-) I wonder if it will also work on QEMU/KVM 
> - possinly qemu boot loader will inspect ELF and place it accordingly in 
> memory; firecracker does not read ELF and simply places it at 2GB
> To get console working I guessed that that need to create equivalent class 
> for isa_serial_console but communicating over mmio (see 
> mmio_isa_serial_console.hh/cc) which in essence invokes mmio_set*/mmio_get* 
> (it would be nice to extract common code somehow - suggestions welcome)
> Some more trivial changes - for now mostly disabling things - for now quite 
> disorganized
>
>
> diff --git a/Makefile b/Makefile
> index db3c68cf..ffd570a5 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -354,6 +354,7 @@ tools := tools/mkfs/mkfs.so tools/cpiod/cpiod.so
>  $(out)/tools/%.o: COMMON += -fPIC
>
>  tools += tools/uush/uush.so
> +tools += tools/uush/hello.so
>  tools += tools/uush/ls.so
>  tools += tools/uush/mkdir.so
>
> @@ -451,8 +452,8 @@ endif # x64
>
>  ifeq ($(arch),aarch64)
>
> -kernel_base := 0x4008
> -kernel_vm_base := 0x4008
> +kernel_base := 0x8008
> +kernel_vm_base := 0x8008
>  app_local_exec_tls_size := 0x0
>
>  include $(libfdt_base)/Makefile.libfdt
> @@ -816,6 +817,7 @@ drivers += drivers/xenplatform-pci.o
>  endif # x64
>
>  ifeq ($(arch),aarch64)
> +drivers += drivers/mmio-isa-serial.o
>  drivers += drivers/pl011.o
>  drivers += drivers/xenconsole.o
>  drivers += drivers/virtio.o
> diff --git a/arch/aarch64/arch-dtb.cc b/arch/aarch64/arch-dtb.cc
> index b59f1dcc..cd0719e8 100644
> --- a/arch/aarch64/arch-dtb.cc
> +++ b/arch/aarch64/arch-dtb.cc
> @@ -225,7 +225,8 @@ bool dtb_get_gic_v2(u64 *dist, size_t *dist_len, u64 
> *cpu, size_t *cpu_len)
>  if (!dtb)
>  return false;
>
> -node = fdt_node_offset_by_compatible(dtb, -1, "arm,cortex-a15-gic");
> +//node = fdt_node_offset_by_compatible(dtb, -1, "arm,cortex-a15-gic");
> +node = fdt_node_offset_by_compatible(dtb, -1, "arm,gic-400");
>  if (node < 0)
>  return false;
>
> @@ -613,11 +614,13 @@ void  __attribute__((constructor(init_prio::dtb))) 
> dtb_setup()
>  abort("dtb_setup: failed to parse cpu mpid.\n");
>  }
>
> +//TODO: Parse PCI only if required and
> +// abort if missing only if required
>  dtb_timer_irq = dtb_parse_timer_irq();
>  

Re: [osv-dev] OSv boots and runs simple hello world on Firecracker ARM edition ... on Raspberry PI 4

2020-05-21 Thread Pekka Enberg
On Fri, May 22, 2020 at 12:26 AM Dor Laor  wrote:

> Kudos Waldek!
>

Indeed, nice work!

- Pekka

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/CAGUyND-vurn86y%3DNPu3e98nvnzO6B3aOACLdNpE49Ps2h%3DqCjg%40mail.gmail.com.


Re: [osv-dev] OSv boots and runs simple hello world on Firecracker ARM edition ... on Raspberry PI 4

2020-05-21 Thread Dor Laor
Kudos Waldek!

On Thu, May 21, 2020 at 1:58 PM Waldek Kozaczuk 
wrote:

>
> *ubuntu@ubuntu-rasp4*:*~*$ uname -a
>
> Linux ubuntu-rasp4 5.3.0-1025-raspi2 #27-Ubuntu SMP Fri May 8 08:32:04
> UTC 2020 aarch64 aarch64 aarch64 GNU/Linux
>
> *ubuntu@ubuntu-rasp4*:*~*$ ./firecracker-v0.21.1-aarch64 --no-api --config
> -file ./osv-config.json
>
> OSv v0.55.0-9-g840428ad
>
> PSCI: version 65536.0 detected.
>
> setup_arm_clock() ENTERED, lr=800d54e0
>
> arm_clock(): frequency read as 0337f980
>
> interrupt_table::interrupt_table() ENTERED, lr=800a8d1c
>
> gic_driver::init_cpu() ENTERED, lr=80201c80
>
> CPU interface enabled.
>
> gic_driver::init_dist() ENTERED, lr=80201c8c
>
> number of supported IRQs: 0080
>
> interrupt table: gic driver created.
>
> registered IRQ id=0004
>
> registered IRQ id=001b
>
> registered IRQ id=
>
> Premain complete!
>
> smp_launch ENTERED, lr=800d709c
>
> Booted up in 0.00 ms
>
> Cmdline: console=ttyS0 --verbose --nomount --maxnic=0 /tools/hello.so
> earlycon=uart,mmio,0x40001000
>
> faulting address 1001fea0
>
> faulting address 1328
>
> faulting address 1002
>
> faulting address 10050018
>
> faulting address 100301c8
>
> faulting address 1004fe00
>
> Hello from C code
>
> 2020-05-21T20:24:04.080765641 [anonymous-instance:ERROR:src/vmm/src/vstate
> .rs:951] Unexpected exit reason on vcpu run: SystemEvent
>
> In general it took me a bit of research as I am not really familiar with
> ARM architecture and even reading the assembly was a bit a challenge to say
> the least. And then debugging without debugger and any console (:-( .. so
> not debug() for long time. But all in all it was not too bad and the
> changes that I had to make to OSv are in my opinion much smaller and easier
> comparing to x86_64.
>
> Below you will see the "hack-patch" showing what changes I had to make.
> Logically, following things had to be changed:
>
>- The most important thing was to move kernel from 0x4000 (1GB) to
>0x8000 (2GB) which required changing one line in Makefile (see below)
>and changing boot paging table to map the 2GB-3GB area of memory; only then
>I could actually start debugging :-) I wonder if it will also work on
>QEMU/KVM - possinly qemu boot loader will inspect ELF and place it
>accordingly in memory; firecracker does not read ELF and simply places it
>at 2GB
>- To get console working I guessed that that need to create equivalent
>class for isa_serial_console but communicating over mmio (see
>mmio_isa_serial_console.hh/cc) which in essence invokes mmio_set*/mmio_get*
>(it would be nice to extract common code somehow - suggestions welcome)
>- Some more trivial changes - for now mostly disabling things - for
>now quite disorganized
>
>
> diff --git a/Makefile b/Makefile
> index db3c68cf..ffd570a5 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -354,6 +354,7 @@ tools := tools/mkfs/mkfs.so tools/cpiod/cpiod.so
>  $(out)/tools/%.o: COMMON += -fPIC
>
>  tools += tools/uush/uush.so
> +tools += tools/uush/hello.so
>  tools += tools/uush/ls.so
>  tools += tools/uush/mkdir.so
>
> @@ -451,8 +452,8 @@ endif # x64
>
>  ifeq ($(arch),aarch64)
>
> -kernel_base := 0x4008
> -kernel_vm_base := 0x4008
> +kernel_base := 0x8008
> +kernel_vm_base := 0x8008
>  app_local_exec_tls_size := 0x0
>
>  include $(libfdt_base)/Makefile.libfdt
> @@ -816,6 +817,7 @@ drivers += drivers/xenplatform-pci.o
>  endif # x64
>
>  ifeq ($(arch),aarch64)
> +drivers += drivers/mmio-isa-serial.o
>  drivers += drivers/pl011.o
>  drivers += drivers/xenconsole.o
>  drivers += drivers/virtio.o
> diff --git a/arch/aarch64/arch-dtb.cc b/arch/aarch64/arch-dtb.cc
> index b59f1dcc..cd0719e8 100644
> --- a/arch/aarch64/arch-dtb.cc
> +++ b/arch/aarch64/arch-dtb.cc
> @@ -225,7 +225,8 @@ bool dtb_get_gic_v2(u64 *dist, size_t *dist_len, u64
> *cpu, size_t *cpu_len)
>  if (!dtb)
>  return false;
>
> -node = fdt_node_offset_by_compatible(dtb, -1, "arm,cortex-a15-gic");
> +//node = fdt_node_offset_by_compatible(dtb, -1, "arm,cortex-a15-gic");
> +node = fdt_node_offset_by_compatible(dtb, -1, "arm,gic-400");
>  if (node < 0)
>  return false;
>
> @@ -613,11 +614,13 @@ void  __attribute__((constructor(init_prio::dtb)))
> dtb_setup()
>  abort("dtb_setup: failed to parse cpu mpid.\n");
>  }
>
> +//TODO: Parse PCI only if required and
> +// abort if missing only if required
>  dtb_timer_irq = dtb_parse_timer_irq();
>  dtb_pci_irqmask = dtb_parse_pci_irqmask();
>  dtb_pci_irqmap_count = dtb_parse_pci_irqmap_count();
>  if (!dtb_parse_pci_irqmap(dtb_pci_bdfs, dtb_pci_irq_ids,
> dtb_pci_irqmap_count)) {
> -abort("dtb_setup: failed to parse pci_irq_map.\n");
> +//abort("dtb_setup: failed to parse pci_irq_map.\n");
>  }
>
>  register u64 edata;

[osv-dev] OSv boots and runs simple hello world on Firecracker ARM edition ... on Raspberry PI 4

2020-05-21 Thread Waldek Kozaczuk


*ubuntu@ubuntu-rasp4*:*~*$ uname -a

Linux ubuntu-rasp4 5.3.0-1025-raspi2 #27-Ubuntu SMP Fri May 8 08:32:04 UTC 
2020 aarch64 aarch64 aarch64 GNU/Linux

*ubuntu@ubuntu-rasp4*:*~*$ ./firecracker-v0.21.1-aarch64 --no-api --config-file 
./osv-config.json

OSv v0.55.0-9-g840428ad

PSCI: version 65536.0 detected.

setup_arm_clock() ENTERED, lr=800d54e0

arm_clock(): frequency read as 0337f980

interrupt_table::interrupt_table() ENTERED, lr=800a8d1c

gic_driver::init_cpu() ENTERED, lr=80201c80

CPU interface enabled.

gic_driver::init_dist() ENTERED, lr=80201c8c

number of supported IRQs: 0080

interrupt table: gic driver created.

registered IRQ id=0004

registered IRQ id=001b

registered IRQ id=

Premain complete!

smp_launch ENTERED, lr=800d709c

Booted up in 0.00 ms

Cmdline: console=ttyS0 --verbose --nomount --maxnic=0 /tools/hello.so 
earlycon=uart,mmio,0x40001000

faulting address 1001fea0

faulting address 1328

faulting address 1002

faulting address 10050018

faulting address 100301c8

faulting address 1004fe00

Hello from C code

2020-05-21T20:24:04.080765641 [anonymous-instance:ERROR:src/vmm/src/vstate.
rs:951] Unexpected exit reason on vcpu run: SystemEvent

In general it took me a bit of research as I am not really familiar with 
ARM architecture and even reading the assembly was a bit a challenge to say 
the least. And then debugging without debugger and any console (:-( .. so 
not debug() for long time. But all in all it was not too bad and the 
changes that I had to make to OSv are in my opinion much smaller and easier 
comparing to x86_64.

Below you will see the "hack-patch" showing what changes I had to make. 
Logically, following things had to be changed:

   - The most important thing was to move kernel from 0x4000 (1GB) to 
   0x8000 (2GB) which required changing one line in Makefile (see below) 
   and changing boot paging table to map the 2GB-3GB area of memory; only then 
   I could actually start debugging :-) I wonder if it will also work on 
   QEMU/KVM - possinly qemu boot loader will inspect ELF and place it 
   accordingly in memory; firecracker does not read ELF and simply places it 
   at 2GB
   - To get console working I guessed that that need to create equivalent 
   class for isa_serial_console but communicating over mmio (see 
   mmio_isa_serial_console.hh/cc) which in essence invokes mmio_set*/mmio_get* 
   (it would be nice to extract common code somehow - suggestions welcome)
   - Some more trivial changes - for now mostly disabling things - for now 
   quite disorganized


diff --git a/Makefile b/Makefile
index db3c68cf..ffd570a5 100644
--- a/Makefile
+++ b/Makefile
@@ -354,6 +354,7 @@ tools := tools/mkfs/mkfs.so tools/cpiod/cpiod.so
 $(out)/tools/%.o: COMMON += -fPIC
 
 tools += tools/uush/uush.so
+tools += tools/uush/hello.so
 tools += tools/uush/ls.so
 tools += tools/uush/mkdir.so
 
@@ -451,8 +452,8 @@ endif # x64
 
 ifeq ($(arch),aarch64)
 
-kernel_base := 0x4008
-kernel_vm_base := 0x4008
+kernel_base := 0x8008
+kernel_vm_base := 0x8008
 app_local_exec_tls_size := 0x0
 
 include $(libfdt_base)/Makefile.libfdt
@@ -816,6 +817,7 @@ drivers += drivers/xenplatform-pci.o
 endif # x64
 
 ifeq ($(arch),aarch64)
+drivers += drivers/mmio-isa-serial.o
 drivers += drivers/pl011.o
 drivers += drivers/xenconsole.o
 drivers += drivers/virtio.o
diff --git a/arch/aarch64/arch-dtb.cc b/arch/aarch64/arch-dtb.cc
index b59f1dcc..cd0719e8 100644
--- a/arch/aarch64/arch-dtb.cc
+++ b/arch/aarch64/arch-dtb.cc
@@ -225,7 +225,8 @@ bool dtb_get_gic_v2(u64 *dist, size_t *dist_len, u64 
*cpu, size_t *cpu_len)
 if (!dtb)
 return false;
 
-node = fdt_node_offset_by_compatible(dtb, -1, "arm,cortex-a15-gic");
+//node = fdt_node_offset_by_compatible(dtb, -1, "arm,cortex-a15-gic");
+node = fdt_node_offset_by_compatible(dtb, -1, "arm,gic-400");
 if (node < 0)
 return false;
 
@@ -613,11 +614,13 @@ void  __attribute__((constructor(init_prio::dtb))) 
dtb_setup()
 abort("dtb_setup: failed to parse cpu mpid.\n");
 }
 
+//TODO: Parse PCI only if required and
+// abort if missing only if required
 dtb_timer_irq = dtb_parse_timer_irq();
 dtb_pci_irqmask = dtb_parse_pci_irqmask();
 dtb_pci_irqmap_count = dtb_parse_pci_irqmap_count();
 if (!dtb_parse_pci_irqmap(dtb_pci_bdfs, dtb_pci_irq_ids, 
dtb_pci_irqmap_count)) {
-abort("dtb_setup: failed to parse pci_irq_map.\n");
+//abort("dtb_setup: failed to parse pci_irq_map.\n");
 }
 
 register u64 edata;
diff --git a/arch/aarch64/arch-setup.cc b/arch/aarch64/arch-setup.cc
index bdbb1266..b12546ae 100644
--- a/arch/aarch64/arch-setup.cc
+++ b/arch/aarch64/arch-setup.cc
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "arch-mmu.hh"
 #include "arch-dtb.hh"
@@ -25,6 +26,7