qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH V2 1/4] hw/pc: extract reserved memory end compu


From: Igor Mammedov
Subject: Re: [Qemu-devel] [PATCH V2 1/4] hw/pc: extract reserved memory end computation to a standalone function
Date: Mon, 16 May 2016 10:13:18 +0200

On Sun, 15 May 2016 22:23:31 +0300
Marcel Apfelbaum <address@hidden> wrote:

> This code will be reused when calculating 64-bit MMIO hotplug ranges.
> 
> Signed-off-by: Marcel Apfelbaum <address@hidden>
Reviewed-by: Igor Mammedov <address@hidden>

> ---
>  hw/i386/pc.c         | 29 +++++++++++++++++++++--------
>  include/hw/i386/pc.h |  1 +
>  2 files changed, 22 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 99437e0..a7791e3 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -1280,6 +1280,7 @@ void pc_memory_init(PCMachineState *pcms,
>      FWCfgState *fw_cfg;
>      MachineState *machine = MACHINE(pcms);
>      PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
> +    uint64_t res_mem_end;
>  
>      assert(machine->ram_size == pcms->below_4g_mem_size +
>                                  pcms->above_4g_mem_size);
> @@ -1375,15 +1376,10 @@ void pc_memory_init(PCMachineState *pcms,
>  
>      rom_set_fw(fw_cfg);
>  
> -    if (pcmc->has_reserved_memory && pcms->hotplug_memory.base) {
> +    res_mem_end = pc_machine_get_reserved_memory_end(pcms);
> +    if (res_mem_end) {
>          uint64_t *val = g_malloc(sizeof(*val));
> -        PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
> -        uint64_t res_mem_end = pcms->hotplug_memory.base;
> -
> -        if (!pcmc->broken_reserved_end) {
> -            res_mem_end += memory_region_size(&pcms->hotplug_memory.mr);
> -        }
> -        *val = cpu_to_le64(ROUND_UP(res_mem_end, 0x1ULL << 30));
> +        *val = cpu_to_le64(res_mem_end);
>          fw_cfg_add_file(fw_cfg, "etc/reserved-memory-end", val, 
> sizeof(*val));
>      }
>  
> @@ -1853,6 +1849,23 @@ bool pc_machine_is_smm_enabled(PCMachineState *pcms)
>      return false;
>  }
>  
> +uint64_t pc_machine_get_reserved_memory_end(PCMachineState *pcms)
> +{
> +    PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
> +    uint64_t res_mem_end = 0;
> +
> +    if (pcmc->has_reserved_memory && pcms->hotplug_memory.base) {
> +        res_mem_end = pcms->hotplug_memory.base;
> +
> +        if (!pcmc->broken_reserved_end) {
> +            res_mem_end += memory_region_size(&pcms->hotplug_memory.mr);
> +        }
> +        res_mem_end = ROUND_UP(res_mem_end, 0x1ULL << 30);
> +    }
> +
> +    return res_mem_end;
> +}
> +
>  static void pc_machine_get_smm(Object *obj, Visitor *v, const char *name,
>                                 void *opaque, Error **errp)
>  {
> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> index 96f0b66..7c25814 100644
> --- a/include/hw/i386/pc.h
> +++ b/include/hw/i386/pc.h
> @@ -223,6 +223,7 @@ void i8042_setup_a20_line(ISADevice *dev, qemu_irq 
> *a20_out);
>  extern int fd_bootchk;
>  
>  bool pc_machine_is_smm_enabled(PCMachineState *pcms);
> +uint64_t pc_machine_get_reserved_memory_end(PCMachineState *pcms);
>  void pc_register_ferr_irq(qemu_irq irq);
>  void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
>  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]