Received: from eggs.gnu.org ([2001:4830:134:3::10]:43406) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anXog-0000ak-IO for qemu-devel@nongnu.org; Tue, 05 Apr 2016 16:43:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anXoc-0001vv-9s for qemu-devel@nongnu.org; Tue, 05 Apr 2016 16:43:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55558) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anXoc-0001vc-2O for qemu-devel@nongnu.org; Tue, 05 Apr 2016 16:43:10 -0400 Date: Tue, 5 Apr 2016 17:43:07 -0300 From: Eduardo Habkost Message-ID: <20160405204307.GF22665@thinpad.lan.raisama.net> References: <1459876288-1640-1-git-send-email-borneo.antonio@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1459876288-1640-1-git-send-email-borneo.antonio@gmail.com> Subject: Re: [Qemu-devel] [PATCH] hw/i386: add device tree support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Antonio Borneo Cc: Paolo Bonzini , Sebastian Andrzej Siewior , Richard Henderson , qemu-devel@nongnu.org, "Michael S. Tsirkin" On Tue, Apr 05, 2016 at 07:11:28PM +0200, Antonio Borneo wrote: > With "-dtb" on command-line: > - append the device tree blob to the kernel image; > - pass the blob's pointer to the kernel through setup_data, as > requested by upstream kernel commit da6b737b9ab7 ("x86: Add > device tree support"). > > The device tree blob is passed as-is to the guest; none of its > fields is modified nor updated. This is not an issue; the kernel > commit above uses the device tree only as an extension to the > traditional kernel configuration. > > To: "Michael S. Tsirkin" > To: Paolo Bonzini > To: Richard Henderson > To: Eduardo Habkost > Cc: qemu-devel@nongnu.org > Cc: Sebastian Andrzej Siewior > Signed-off-by: Antonio Borneo > --- > > Hi, > > I'm not expert on the x86 memory map at boot and during kernel > boot; I found easy to just append the dtb to the kernel image. > From my tests this patch is working fine. > If you have any hint for a different loading address for dtb, I > would be glad to modify this code. I was worried that changing FW_CFG_KERNEL_SIZE could break something, but this seems to be OK because: * The only user of FW_CFG_KERNEL_* seems to be read_fw_blob_addr32(), used by linuxboot.S and multiboot.S just for reading data from fw_cfg into RAM; * multiboot code already does something similar: it uses FW_CFG_KERNEL_SIZE not just for the kernel image size, but for the kernel image plus the extra data loaded after it. One small comment below: [...] > @@ -989,6 +1006,35 @@ static void load_linux(PCMachineState *pcms, > exit(1); > } > fclose(f); > + > + /* append dtb to kernel */ > + if (dtb_filename) { > + if (protocol < 0x209) { > + fprintf(stderr, "qemu: Linux kernel too old to load a dtb\n"); > + exit(1); > + } > + > + dtb_size = get_image_size(dtb_filename); > + if (dtb_size <= 0) { > + fprintf(stderr, "qemu: error reading dtb %s: %s\n", > + dtb_filename, strerror(errno)); > + exit(1); > + } > + > + setup_data_offset = QEMU_ALIGN_UP(kernel_size, 16); > + kernel_size = setup_data_offset + sizeof(struct setup_data) + dtb_size; > + kernel = g_realloc(kernel, kernel_size); > + > + stq_p(header+0x250, prot_addr + setup_data_offset); > + > + setup_data = (struct setup_data *)(kernel + setup_data_offset); > + setup_data->next = 0; > + setup_data->type = cpu_to_le32(SETUP_DTB); > + setup_data->len = cpu_to_le32(dtb_size); > + > + load_image(dtb_filename, setup_data->data); load_image() is deprecated, please use load_image_size(dtb_filename, setup_data->data, dtb_size) instead. > + } > + > memcpy(setup, header, MIN(sizeof(header), setup_size)); > > fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr); > -- > 2.8.0 > -- Eduardo