On Thu, Dec 20, 2018 at 03:21:25PM +0000, Julien Grall wrote: > Currently, the RAM will always be contiguous and start 2GB. This patch > is giving the possibility to the user to specificy multiple RAM region > and > > Note that at the moment it is not possible to place any RAM region below > 2GB as the MMIO region is still static. > > The implementation for multi memory regions is fairly straight-forward, > althought it the following points are worth to be mention: > - The banks are sorted by base address, so it is easier to fetch the > lowest bank later on and do sanity checking > - If the user does not specify the address of the first bank, the > old behavior is kept. > > Signed-off-by: Julien Grall <julien.grall@xxxxxxx> > > --- > Changes in v2: > - Check whether memory banks overlap with the MMIO area > --- > arm/aarch32/include/kvm/kvm-arch.h | 2 +- > arm/aarch64/include/kvm/kvm-arch.h | 4 +- > arm/fdt.c | 19 ++++-- > arm/include/arm-common/kvm-arch.h | 24 +++++-- > arm/kvm.c | 129 +++++++++++++++++++++++++++++-------- > 5 files changed, 133 insertions(+), 45 deletions(-) > > diff --git a/arm/aarch32/include/kvm/kvm-arch.h b/arm/aarch32/include/kvm/kvm-arch.h > index cd31e72..2ee0cb1 100644 > --- a/arm/aarch32/include/kvm/kvm-arch.h > +++ b/arm/aarch32/include/kvm/kvm-arch.h > @@ -3,7 +3,7 @@ > > #define ARM_KERN_OFFSET(...) 0x8000 > > -#define ARM_MAX_MEMORY(...) ARM_LOMAP_MAX_MEMORY > +#define ARM_MAX_PHYS_SHIFT(...) 32 > > #include "arm-common/kvm-arch.h" > > diff --git a/arm/aarch64/include/kvm/kvm-arch.h b/arm/aarch64/include/kvm/kvm-arch.h > index 1b3d0a5..53ac20f 100644 > --- a/arm/aarch64/include/kvm/kvm-arch.h > +++ b/arm/aarch64/include/kvm/kvm-arch.h > @@ -5,9 +5,7 @@ > 0x8000 : \ > 0x80000) > > -#define ARM_MAX_MEMORY(cfg) ((cfg)->arch.aarch32_guest ? \ > - ARM_LOMAP_MAX_MEMORY : \ > - ARM_HIMAP_MAX_MEMORY) > +#define ARM_MAX_PHYS_SHIFT(cfg) ((cfg)->arch.aarch32_guest ? 32 : 40) We should probably have some #defines instead of open-coding the '32' and '40'. > > #include "arm-common/kvm-arch.h" > > diff --git a/arm/fdt.c b/arm/fdt.c > index 6ac0b33..2a010c7 100644 > --- a/arm/fdt.c > +++ b/arm/fdt.c > @@ -29,7 +29,7 @@ static void dump_fdt(const char *dtb_file, void *fdt) > int count, fd; > > fd = open(dtb_file, O_CREAT | O_TRUNC | O_RDWR, 0666); > - if (fd < 0) > + > die("Failed to write dtb to %s", dtb_file); This looks dodgy. Will