[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 6/9] hw/i386/pc: Initialize ram_memory variable directly
From: |
Bernhard Beschow |
Subject: |
Re: [PATCH v4 6/9] hw/i386/pc: Initialize ram_memory variable directly |
Date: |
Wed, 22 Feb 2023 08:21:16 +0000 |
Am 22. Februar 2023 02:38:04 UTC schrieb Xiaoyao Li <xiaoyao.li@intel.com>:
>On 2/14/2023 12:20 AM, Bernhard Beschow wrote:
>> Going through pc_memory_init() seems quite complicated for a simple
>> assignment.
>>
>
>...
>
>> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
>> index 5bde4533cc..00ba725656 100644
>> --- a/hw/i386/pc_piix.c
>> +++ b/hw/i386/pc_piix.c
>> @@ -143,6 +143,7 @@ static void pc_init1(MachineState *machine,
>> if (xen_enabled()) {
>> xen_hvm_init_pc(pcms, &ram_memory);
In Xen mode, ram_memory is initialized here and machine->ram isn't used at all.
>> } else {
>> + ram_memory = machine->ram;
The idea of moving the assignment here is to make the code more symmetric to
Xen and to establish the invariant of ram_memory being initialized after this
if-else block. IOW one shouldn't need to use machine->ram directly after this
point.
>> if (!pcms->max_ram_below_4g) {
>> pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */
>> }
>> @@ -205,8 +206,7 @@ static void pc_init1(MachineState *machine,
>> /* allocate ram and load rom/bios */
>> if (!xen_enabled()) {
>> - pc_memory_init(pcms, system_memory,
>> - rom_memory, &ram_memory, hole64_size);
>
>IMHO, it seems more proper to put
>
>+ ram_memory = machine->ram;
>
>here rather than above.
This patch allowed for further cleanup (establishing above invariant) which I
inlined for simplicity.
Do you still see issues here?
Thanks,
Bernhard
>
>> + pc_memory_init(pcms, system_memory, rom_memory, hole64_size);
>> } else {
>> pc_system_flash_cleanup_unused(pcms);
>> if (machine->kernel_filename != NULL) {
>
- [PATCH v4 0/9] PC cleanups, Bernhard Beschow, 2023/02/13
- [PATCH v4 1/9] hw/pci-host/i440fx: Inline sysbus_add_io(), Bernhard Beschow, 2023/02/13
- [PATCH v4 2/9] hw/pci-host/q35: Inline sysbus_add_io(), Bernhard Beschow, 2023/02/13
- [PATCH v4 3/9] hw/i386/pc_q35: Reuse machine parameter, Bernhard Beschow, 2023/02/13
- [PATCH v4 4/9] hw/i386/pc_{q35, piix}: Reuse MachineClass::desc as SMB product name, Bernhard Beschow, 2023/02/13
- [PATCH v4 5/9] hw/i386/pc_{q35, piix}: Minimize usage of get_system_memory(), Bernhard Beschow, 2023/02/13
- [PATCH v4 6/9] hw/i386/pc: Initialize ram_memory variable directly, Bernhard Beschow, 2023/02/13
- [PATCH v4 7/9] hw/pci-host/pam: Make init_pam() usage more readable, Bernhard Beschow, 2023/02/13
- [PATCH v4 9/9] target/i386/tcg/sysemu/tcg-cpu: Avoid own opinion about smram size, Bernhard Beschow, 2023/02/13
- [PATCH v4 8/9] hw/i386/x86: Make TYPE_X86_MACHINE the owner of smram, Bernhard Beschow, 2023/02/13
- Re: [PATCH v4 0/9] PC cleanups, Bernhard Beschow, 2023/02/13
- Re: [PATCH v4 0/9] PC cleanups, Bernhard Beschow, 2023/02/21