On 17.08.20 19:17, Jakub Luzny wrote:
> Add the required memory regions to support 2G, 4G and 8G RAM variants
> of the Raspberry Pi 4. Tested on all the bigger variants, not on 1G, as I 
> don't
> have one on hand and it's not available anymore.
> 
> Also moved the memory used by Jailhouse for the hypervisor and cells from
> 0x30000000 to 0x20000000 to avoid conflict with GPU memory. That is fine for
> gpu_mem setting of up to 256. The memory is supposed to be reserved using
> reserved-memory node in the device tree. To support variants with >2G RAM,
> another region for PCI MMIO space has to be also reserved.
> ---
>  configs/arm64/rpi4-inmate-demo.c | 22 ++++++------
>  configs/arm64/rpi4-linux-demo.c  | 28 +++++++--------
>  configs/arm64/rpi4.c             | 62 +++++++++++++++++++++++---------
>  3 files changed, 71 insertions(+), 41 deletions(-)
> 
> diff --git a/configs/arm64/rpi4-inmate-demo.c 
> b/configs/arm64/rpi4-inmate-demo.c
> index 62442e7c..09dfc1f0 100644
> --- a/configs/arm64/rpi4-inmate-demo.c
> +++ b/configs/arm64/rpi4-inmate-demo.c
> @@ -51,34 +51,34 @@ struct {
>       .mem_regions = {
>               /* IVSHMEM shared memory regions (demo) */
>               {
> -                     .phys_start = 0x3faf0000,
> -                     .virt_start = 0x3faf0000,
> +                     .phys_start = 0x2faf0000,
> +                     .virt_start = 0x2faf0000,
>                       .size = 0x1000,
>                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED,
>               },
>               {
> -                     .phys_start = 0x3faf1000,
> -                     .virt_start = 0x3faf1000,
> +                     .phys_start = 0x2faf1000,
> +                     .virt_start = 0x2faf1000,
>                       .size = 0x9000,
>                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
>                               JAILHOUSE_MEM_ROOTSHARED,
>               },
>               {
> -                     .phys_start = 0x3fafa000,
> -                     .virt_start = 0x3fafa000,
> +                     .phys_start = 0x2fafa000,
> +                     .virt_start = 0x2fafa000,
>                       .size = 0x2000,
>                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED,
>               },
>               {
> -                     .phys_start = 0x3fafc000,
> -                     .virt_start = 0x3fafc000,
> +                     .phys_start = 0x2fafc000,
> +                     .virt_start = 0x2fafc000,
>                       .size = 0x2000,
>                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
>                               JAILHOUSE_MEM_ROOTSHARED,
>               },
>               {
> -                     .phys_start = 0x3fafe000,
> -                     .virt_start = 0x3fafe000,
> +                     .phys_start = 0x2fafe000,
> +                     .virt_start = 0x2fafe000,
>                       .size = 0x2000,
>                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED,
>               },
> @@ -91,7 +91,7 @@ struct {
>                               JAILHOUSE_MEM_IO_32 | JAILHOUSE_MEM_ROOTSHARED,
>               },
>               /* RAM */ {
> -                     .phys_start = 0x3fa00000,
> +                     .phys_start = 0x2fa00000,
>                       .virt_start = 0,
>                       .size = 0x00010000,
>                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
> diff --git a/configs/arm64/rpi4-linux-demo.c b/configs/arm64/rpi4-linux-demo.c
> index 9e7fad26..cf36fa22 100644
> --- a/configs/arm64/rpi4-linux-demo.c
> +++ b/configs/arm64/rpi4-linux-demo.c
> @@ -52,39 +52,39 @@ struct {
>       .mem_regions = {
>               /* IVSHMEM shared memory regions (demo) */
>               {
> -                     .phys_start = 0x3faf0000,
> -                     .virt_start = 0x3faf0000,
> +                     .phys_start = 0x2faf0000,
> +                     .virt_start = 0x2faf0000,
>                       .size = 0x1000,
>                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED,
>               },
>               {
> -                     .phys_start = 0x3faf1000,
> -                     .virt_start = 0x3faf1000,
> +                     .phys_start = 0x2faf1000,
> +                     .virt_start = 0x2faf1000,
>                       .size = 0x9000,
>                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
>                               JAILHOUSE_MEM_ROOTSHARED,
>               },
>               {
> -                     .phys_start = 0x3fafa000,
> -                     .virt_start = 0x3fafa000,
> +                     .phys_start = 0x2fafa000,
> +                     .virt_start = 0x2fafa000,
>                       .size = 0x2000,
>                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED,
>               },
>               {
> -                     .phys_start = 0x3fafc000,
> -                     .virt_start = 0x3fafc000,
> +                     .phys_start = 0x2fafc000,
> +                     .virt_start = 0x2fafc000,
>                       .size = 0x2000,
>                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED,
>               },
>               {
> -                     .phys_start = 0x3fafe000,
> -                     .virt_start = 0x3fafe000,
> +                     .phys_start = 0x2fafe000,
> +                     .virt_start = 0x2fafe000,
>                       .size = 0x2000,
>                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
>                               JAILHOUSE_MEM_ROOTSHARED,
>               },
>               /* IVSHMEM shared memory region */
> -             JAILHOUSE_SHMEM_NET_REGIONS(0x3fb00000, 1),
> +             JAILHOUSE_SHMEM_NET_REGIONS(0x2fb00000, 1),
>               /* UART */ {
>                       .phys_start = 0xfe215040,
>                       .virt_start = 0xfe215040,
> @@ -94,15 +94,15 @@ struct {
>                               JAILHOUSE_MEM_IO_32 | JAILHOUSE_MEM_ROOTSHARED,
>               },
>               /* RAM */ {
> -                     .phys_start = 0x3f900000,
> +                     .phys_start = 0x2f900000,
>                       .virt_start = 0,
>                       .size = 0x10000,
>                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
>                               JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_LOADABLE,
>               },
>               /* RAM */ {
> -                     .phys_start = 0x30000000,
> -                     .virt_start = 0x30000000,
> +                     .phys_start = 0x20000000,
> +                     .virt_start = 0x20000000,
>                       .size = 0x8000000,
>                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
>                               JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
> diff --git a/configs/arm64/rpi4.c b/configs/arm64/rpi4.c
> index 92463184..c25bd8d2 100644
> --- a/configs/arm64/rpi4.c
> +++ b/configs/arm64/rpi4.c
> @@ -1,7 +1,7 @@
>  /*
>   * Jailhouse, a Linux-based partitioning hypervisor
>   *
> - * Test configuration for Raspberry Pi 4 (32-bit, quad-core Cortex-A72, 1GB 
> RAM)
> + * Test configuration for Raspberry Pi 4 (32-bit, quad-core Cortex-A72, 1GB, 
> 2GB, 4GB or 8GB RAM)

Not sure anymore what I meant with "32-bit", that can be removed.

>   *
>   * Copyright (c) Siemens AG, 2020
>   *
> @@ -10,6 +10,9 @@
>   *
>   * This work is licensed under the terms of the GNU GPL, version 2.  See
>   * the COPYING file in the top-level directory.
> + *
> + * Reservation via device tree: reg = <0x0 0x20000000 0x10000000>;
> + *                              reg = <0x0 0xe0000000 0x200000>;

Why this split-up into two regions?

This will also mean I need to add a patch to [1] so that the DT will
carry the carve out. And drop the mem= from [2]. Or can we rearrange the
reservation to keep that mem= cut-off, at the price of wasting memory on
larger RPi variants?

>   */
>  
>  #include <jailhouse/types.h>
> @@ -18,7 +21,7 @@
>  struct {
>       struct jailhouse_system header;
>       __u64 cpus[1];
> -     struct jailhouse_memory mem_regions[12];
> +     struct jailhouse_memory mem_regions[15];
>       struct jailhouse_irqchip irqchips[2];
>       struct jailhouse_pci_device pci_devices[2];
>  } __attribute__((packed)) config = {
> @@ -27,7 +30,7 @@ struct {
>               .revision = JAILHOUSE_CONFIG_REVISION,
>               .flags = JAILHOUSE_SYS_VIRTUAL_DEBUG_CONSOLE,
>               .hypervisor_memory = {
> -                     .phys_start = 0x3fc00000,
> +                     .phys_start = 0x2fc00000,
>                       .size       = 0x00400000,
>               },
>               .debug_console = {
> @@ -70,37 +73,37 @@ struct {
>       .mem_regions = {
>               /* IVSHMEM shared memory regions for 00:00.0 (demo) */
>               {
> -                     .phys_start = 0x3faf0000,
> -                     .virt_start = 0x3faf0000,
> +                     .phys_start = 0x2faf0000,
> +                     .virt_start = 0x2faf0000,
>                       .size = 0x1000,
>                       .flags = JAILHOUSE_MEM_READ,
>               },
>               {
> -                     .phys_start = 0x3faf1000,
> -                     .virt_start = 0x3faf1000,
> +                     .phys_start = 0x2faf1000,
> +                     .virt_start = 0x2faf1000,
>                       .size = 0x9000,
>                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
>               },
>               {
> -                     .phys_start = 0x3fafa000,
> -                     .virt_start = 0x3fafa000,
> +                     .phys_start = 0x2fafa000,
> +                     .virt_start = 0x2fafa000,
>                       .size = 0x2000,
>                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
>               },
>               {
> -                     .phys_start = 0x3fafc000,
> -                     .virt_start = 0x3fafc000,
> +                     .phys_start = 0x2fafc000,
> +                     .virt_start = 0x2fafc000,
>                       .size = 0x2000,
>                       .flags = JAILHOUSE_MEM_READ,
>               },
>               {
> -                     .phys_start = 0x3fafe000,
> -                     .virt_start = 0x3fafe000,
> +                     .phys_start = 0x2fafe000,
> +                     .virt_start = 0x2fafe000,
>                       .size = 0x2000,
>                       .flags = JAILHOUSE_MEM_READ,
>               },
>               /* IVSHMEM shared memory regions for 00:01.0 (networking) */
> -             JAILHOUSE_SHMEM_NET_REGIONS(0x3fb00000, 0),
> +             JAILHOUSE_SHMEM_NET_REGIONS(0x2fb00000, 0),
>               /* MMIO 1 (permissive) */ {
>                       .phys_start = 0xfd500000,
>                       .virt_start = 0xfd500000,
> @@ -115,10 +118,37 @@ struct {
>                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
>                               JAILHOUSE_MEM_IO,
>               },
> -             /* RAM */ {
> +             /* RAM (0M-~762M) */ {
>                       .phys_start = 0x0,
>                       .virt_start = 0x0,
> -                     .size = 0x3fa10000,
> +                     .size = 0x2fa10000,
> +                     .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
> +                             JAILHOUSE_MEM_EXECUTE,
> +             },
> +
> +             /* ~6M reserved for the hypervisor and the shared memory 
> regions */
> +
> +             /* RAM (768M-3584M) */ {
> +                     .phys_start = 0x30000000,
> +                     .virt_start = 0x30000000,
> +                     .size = 0xb0000000,
> +                     .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
> +                             JAILHOUSE_MEM_EXECUTE,
> +             },
> +
> +        /* 2M reserved for PCI MMIO space */
> +
> +        /* RAM (3586M-4032M) */ {
> +                     .phys_start = 0xe0200000,
> +                     .virt_start = 0xe0200000,
> +                     .size = 0x1be00000,
> +                     .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
> +                             JAILHOUSE_MEM_EXECUTE,
> +             },
> +             /* RAM (4096M-8192M) */ {
> +                     .phys_start = 0x100000000,
> +                     .virt_start = 0x100000000,
> +                     .size = 0x100000000,
>                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
>                               JAILHOUSE_MEM_EXECUTE,
>               },
> 

Thanks,
Jan

[1] https://github.com/siemens/linux/commits/jailhouse-enabling/5.4-rpi
[2]
https://github.com/siemens/jailhouse-images/blob/master/recipes-bsp/rpi-firmware/files/cmdline.txt

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/57c67012-fee7-d7f1-1201-25415e39034a%40siemens.com.

Reply via email to