qemu-arm
[Top][All Lists]
Advanced

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

Re: [PATCH v2] hw/loongarch/boot: Support Linux raw boot image


From: Richard Henderson
Subject: Re: [PATCH v2] hw/loongarch/boot: Support Linux raw boot image
Date: Tue, 24 Dec 2024 07:26:59 -0800
User-agent: Mozilla Thunderbird

On 12/24/24 07:06, Jiaxun Yang wrote:
+static int64_t load_loongarch_linux_image(const char *filename,
+                                          uint64_t *kernel_entry,
+                                          uint64_t *kernel_low,
+                                          uint64_t *kernel_high)
+{
+    gsize len;
+    int size;
+    uint8_t *buffer;
+    struct loongarch_linux_hdr *hdr;
+
+    /* Load as raw file otherwise */
+    if (!g_file_get_contents(filename, (char **)&buffer, &len, NULL)) {
+        return -1;
+    }
+    size = len;

This truncates from size_t to int, which will start to fail in odd ways at 2GB.

The code in load_aarch64_image has the same problem, so the best fix would be to change unpack_efi_zboot_image to take size_t.

+
+    /* Unpack the image if it is a EFI zboot image */
+    if (unpack_efi_zboot_image(&buffer, &size) < 0) {
+        g_free(buffer);
+        return -1;
+    }


r~



reply via email to

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