On Mon, 23 Sep 2019 14:35:14 +0100 Alexandru Elisei <alexandru.elisei@xxxxxxx> wrote: > From: Julien Grall <julien.grall@xxxxxxx> > > RAM initialization is currently split between kvm__init_ram and > kvm__arch_init. Move all code related to RAM initialization to > kvm__init_ram. The diff is a bit confusing to read, but indeed this just moves the code from arch_init() to init_ram() (confirmed by moving the code and comparing). One thing to note is that this changes the order of initialisation slightly: the GIC is now created before the RAM (since we call arch_init() before init_ram()). Nevertheless: > Signed-off-by: Julien Grall <julien.grall@xxxxxxx> > Signed-off-by: Alexandru Elisei <alexandru.elisei@xxxxxxx> Reviewed-by: Andre Przywara <andre.przywara@xxxxxxx> Cheers, Andre. > --- > arm/kvm.c | 75 +++++++++++++++++++++++++++++++-------------------------------- > 1 file changed, 37 insertions(+), 38 deletions(-) > > diff --git a/arm/kvm.c b/arm/kvm.c > index 5decc138fd3e..3e49db7704aa 100644 > --- a/arm/kvm.c > +++ b/arm/kvm.c > @@ -29,44 +29,6 @@ void kvm__init_ram(struct kvm *kvm) > int err; > u64 phys_start, phys_size; > void *host_mem; > - > - phys_start = ARM_MEMORY_AREA; > - phys_size = kvm->ram_size; > - host_mem = kvm->ram_start; > - > - err = kvm__register_ram(kvm, phys_start, phys_size, host_mem); > - if (err) > - die("Failed to register %lld bytes of memory at physical " > - "address 0x%llx [err %d]", phys_size, phys_start, err); > - > - kvm->arch.memory_guest_start = phys_start; > -} > - > -void kvm__arch_delete_ram(struct kvm *kvm) > -{ > - munmap(kvm->arch.ram_alloc_start, kvm->arch.ram_alloc_size); > -} > - > -void kvm__arch_read_term(struct kvm *kvm) > -{ > - serial8250__update_consoles(kvm); > - virtio_console__inject_interrupt(kvm); > -} > - > -void kvm__arch_set_cmdline(char *cmdline, bool video) > -{ > -} > - > -void kvm__arch_sanitize_cfg(struct kvm_config *cfg) > -{ > - if (cfg->ram_size > ARM_MAX_MEMORY(cfg)) { > - cfg->ram_size = ARM_MAX_MEMORY(cfg); > - pr_warning("Capping memory to %lluMB", cfg->ram_size >> 20); > - } > -} > - > -void kvm__arch_init(struct kvm *kvm) > -{ > unsigned long alignment; > /* Convenience aliases */ > const char *hugetlbfs_path = kvm->cfg.hugetlbfs_path; > @@ -115,6 +77,43 @@ void kvm__arch_init(struct kvm *kvm) > madvise(kvm->arch.ram_alloc_start, kvm->arch.ram_alloc_size, > MADV_HUGEPAGE); > > + phys_start = ARM_MEMORY_AREA; > + phys_size = kvm->ram_size; > + host_mem = kvm->ram_start; > + > + err = kvm__register_ram(kvm, phys_start, phys_size, host_mem); > + if (err) > + die("Failed to register %lld bytes of memory at physical " > + "address 0x%llx [err %d]", phys_size, phys_start, err); > + > + kvm->arch.memory_guest_start = phys_start; > +} > + > +void kvm__arch_delete_ram(struct kvm *kvm) > +{ > + munmap(kvm->arch.ram_alloc_start, kvm->arch.ram_alloc_size); > +} > + > +void kvm__arch_read_term(struct kvm *kvm) > +{ > + serial8250__update_consoles(kvm); > + virtio_console__inject_interrupt(kvm); > +} > + > +void kvm__arch_set_cmdline(char *cmdline, bool video) > +{ > +} > + > +void kvm__arch_sanitize_cfg(struct kvm_config *cfg) > +{ > + if (cfg->ram_size > ARM_MAX_MEMORY(cfg)) { > + cfg->ram_size = ARM_MAX_MEMORY(cfg); > + pr_warning("Capping memory to %lluMB", cfg->ram_size >> 20); > + } > +} > + > +void kvm__arch_init(struct kvm *kvm) > +{ > /* Create the virtual GIC. */ > if (gic__create(kvm, kvm->cfg.arch.irqchip)) > die("Failed to create virtual GIC");