On Mon, 27 Jul 2026 at 14:53, Marcelo Manzo <[email protected]> wrote:
>
> Guards against the bug fixed in the previous commit: boots raspi4b's
> default 2 GiB configuration and checks that the guest actually sees
> close to that (>1.9M kB), not the ~921 MiB the bug left it capped at.
> Deliberately checks a threshold rather than the exact byte count of
> either figure, since the precise number depends on how this specific
> pinned kernel accounts for its own early reservations; the threshold
> is comfortably between the two (943524 kB broken, 1905824 kB fixed,
> confirmed by hand against this exact kernel/initrd).
>
> Signed-off-by: Marcelo Manzo <[email protected]>
> ---
>  tests/functional/aarch64/test_raspi4.py | 51 +++++++++++++++++++++++++
>  1 file changed, 51 insertions(+)
>
> diff --git a/tests/functional/aarch64/test_raspi4.py 
> b/tests/functional/aarch64/test_raspi4.py
> index 35ba6c24f7..55903e93d3 100755
> --- a/tests/functional/aarch64/test_raspi4.py
> +++ b/tests/functional/aarch64/test_raspi4.py
> @@ -154,6 +154,57 @@ def test_arm_raspi4_rng_thermal(self):
>          exec_command_and_wait_for_pattern(self, 'halt', 'reboot: System 
> halted')
>
>
> +    def test_arm_raspi4_full_ram(self):
> +        kernel_path = self.archive_extract(self.ASSET_KERNEL_20190215,
> +                                           member='boot/kernel8.img')
> +        dtb_path = self.archive_extract(self.ASSET_KERNEL_20190215,
> +                                        member='boot/bcm2711-rpi-4-b.dtb')
> +        initrd_path = self.uncompress(self.ASSET_INITRD)
> +
> +        self.set_machine('raspi4b')
> +        self.vm.set_console()
> +        kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
> +                               'earlycon=pl011,mmio32,0xfe201000 ' +
> +                               'console=ttyAMA0,115200 ' +
> +                               'panic=-1 noreboot ' +
> +                               'dwc_otg.fiq_fsm_enable=0')
> +        self.vm.add_args('-kernel', kernel_path,
> +                         '-dtb', dtb_path,
> +                         '-initrd', initrd_path,
> +                         '-append', kernel_command_line,
> +                         '-no-reboot')
> +        self.vm.launch()
> +        self.wait_for_console_pattern('Boot successful.')

This is an identical kernel/initrd boot to the existing
test_arm_raspi4_initrd() test, right? I think it would be
preferable to add the "check the RAM figure" to the existing
test, after e.g. the checks on cpuinfo and iomem. That way we
save the time it takes to do the full kernel boot. Our
functional test suite is already quite slow because of how
many "boot a guest" tests it needs to run, so I'm keen on
keeping the runtime down where we can do that.

> +        # raspi4b's default machine RAM is 2 GiB, but raspi4_modify_dtb()
> +        # used to compare the wrong field when deciding whether to add a
> +        # second memory node above the 1 GiB peripheral hole (it checked
> +        # the boot-loader's kernel/initrd-loading RAM budget, which is
> +        # itself always capped to at most 1 GiB, rather than the board's
> +        # actual total RAM) -- so that second node was never added for any
> +        # raspi4b configuration, and the guest never saw more than ~1 GiB
> +        # regardless of the machine's nominal RAM size. With the bug,
> +        # MemTotal here is 943524 kB; fixed, it is 1905824 kB. Guard
> +        # against a regression back to the ~1 GiB figure without hardcoding
> +        # the exact byte count of either, which depends on how this
> +        # specific pinned kernel accounts for its own reservations.

I think this comment is a bit more verbose than we need -- we can
just say that we used to get the RAM size wrong and we're guarding
against a regression; anybody interested in the exact details of the
old bug can look in the git history for it.

> +        mem_total_kb = None
> +        cmd_output = exec_command_and_wait_for_pattern(
> +            self, 'cat /proc/meminfo', 'MemAvailable')
> +        for line in cmd_output.decode('ascii', 
> errors='replace').splitlines():
> +            if line.startswith('MemTotal:'):
> +                mem_total_kb = int(line.split()[1])
> +                break
> +        self.assertIsNotNone(mem_total_kb, 'MemTotal line not found')
> +        self.assertGreater(mem_total_kb, 1900000,
> +                           'guest RAM (%d kB) is far below the ~1.9 GiB '
> +                           'expected for a 2 GiB raspi4b -- the second '
> +                           'memory node above the 1 GiB peripheral hole '
> +                           'is probably not being added' % mem_total_kb)
> +
> +        exec_command_and_wait_for_pattern(self, 'halt', 'reboot: System 
> halted')
> +
> +
>      def test_arm_raspi4_pcie(self):
>          kernel_path = self.archive_extract(self.ASSET_KERNEL_20190215,
>                                             member='boot/kernel8.img')

thanks
-- PMM

Reply via email to