From nobody Mon Feb 9 00:36:45 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534874962851125.19877996578657; Tue, 21 Aug 2018 11:09:22 -0700 (PDT) Received: from localhost ([::1]:55305 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsB5l-00023t-ND for importer@patchew.org; Tue, 21 Aug 2018 14:09:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsA4o-0002IS-3A for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fsA4W-0006nw-5h for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:13 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:52672) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fsA4V-0006CM-3j for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:03:59 -0400 Received: by mail-wm0-x243.google.com with SMTP id y139-v6so853582wmc.2 for ; Tue, 21 Aug 2018 10:03:36 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id v6-v6sm2608955wmc.43.2018.08.21.10.03.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 10:03:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4o9J9yXlur8SlZPCIsmS3axKoMVepqGx1oLNlmXrQWg=; b=k+uDNPiQ7kvarGZx5jcuWn2T1FyI2NKzgERaw/N4ZAWBUIa599O36xFQWI0wg7pUdn hoQECYI17mKW8WRDBA8fC2TC+MiAe3zb8GHv5tZUttA33YOdS17OIyR1rENU9tBS/tbe 2FVAfBdgNr0tec2vZCNajBfcLe+2Eu9YvXtCtZyaytqPMKAthvwk/V9ztxAXqXMl5mcV VDWTyp9nqAbGaj5/Ze0NNgY6duwXhD2IwrPM2iiIecT5iPQLkFRR6+5+jJkDr+Y5Q/H7 T329aOKOKQ5Z3g6E+HfqUbCkTCGAFXQTZ9EusXXQhNwdcy9bRo6lP1Mq8lEvxHELeDKa lluQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=4o9J9yXlur8SlZPCIsmS3axKoMVepqGx1oLNlmXrQWg=; b=qi9tHNBKTCoWO/ZQ8F+tgbg+MkqlzEQIW3r2s1l2FUTNvZG/tWUtarMcEpbOHESVET AUhHZtgUjZbV4XSNqM3FOX7uBdhwluOcJE2GVmduWgOrN5owMrjPGN3HnhjoUk5a9ATI YRd7Nheh/jAPfP9eN4laeLchDoAkY4xbbUNIIOfakw0ZP0LlUPr9DHtUryhpHHP+n7gV JVbGBqJvj/VmqahZKfjkg6QqjRpkxb4OPu64XRrqV196H/mp0Wgyiu4+loBgdTdcibOG E9wjPB1us2K55AAExbytDS7S8eBGLie2oW7grT4H15GNUc8Pas7j85g19i9xQRkdiBSq 8X5g== X-Gm-Message-State: APzg51BUBa2blxaogL9w6GQNutxqR6YiCAZnTJXHlxiGKAiWgWHZlzHX G4+F4sPwEKIhizElgq52k8KsIe5H X-Google-Smtp-Source: ANB0VdbQrBSvYry/iPwGIuTz56u7aR50ggxeQYB2+RHyahbsMeHH0Iwvn/VCnETfCAT9nSlh1tb4ag== X-Received: by 2002:a1c:99c2:: with SMTP id b185-v6mr132246wme.15.1534871015075; Tue, 21 Aug 2018 10:03:35 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 21 Aug 2018 19:02:01 +0200 Message-Id: <1534870966-9287-30-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534870966-9287-1-git-send-email-pbonzini@redhat.com> References: <1534870966-9287-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PULL 29/74] fw_cfg: import & use linux/qemu_fw_cfg.h X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau Use kernel common header for fw_cfg. (unfortunately, optionrom.h must have its own define, since it's actually an assembler header) Signed-off-by: Marc-Andr=C3=83=C2=A9 Lureau Message-Id: <20180817155910.5722-2-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini Signed-off-by: Marc-Andr=C3=A9 Lureau --- dump.c | 2 +- hw/misc/vmcoreinfo.c | 6 +- include/hw/misc/vmcoreinfo.h | 12 +--- include/hw/nvram/fw_cfg.h | 18 +----- include/hw/nvram/fw_cfg_keys.h | 45 ------------- include/standard-headers/linux/qemu_fw_cfg.h | 97 ++++++++++++++++++++++++= ++++ pc-bios/optionrom/linuxboot_dma.c | 4 +- pc-bios/optionrom/optionrom.h | 15 ++++- tests/boot-order-test.c | 2 +- tests/fw_cfg-test.c | 2 +- tests/libqos/malloc-pc.c | 2 +- 11 files changed, 125 insertions(+), 80 deletions(-) delete mode 100644 include/hw/nvram/fw_cfg_keys.h create mode 100644 include/standard-headers/linux/qemu_fw_cfg.h diff --git a/dump.c b/dump.c index 04467b3..500b554 100644 --- a/dump.c +++ b/dump.c @@ -1742,7 +1742,7 @@ static void dump_init(DumpState *s, int fd, bool has_= format, warn_report("guest note is not present"); } else if (size < note_head_size || size > MAX_GUEST_NOTE_SIZE) { warn_report("guest note size is invalid: %" PRIu32, size); - } else if (format !=3D VMCOREINFO_FORMAT_ELF) { + } else if (format !=3D FW_CFG_VMCOREINFO_FORMAT_ELF) { warn_report("guest note format is unsupported: %" PRIu16, form= at); } else { s->guest_note =3D g_malloc(size + 1); /* +1 for adding \0 */ diff --git a/hw/misc/vmcoreinfo.c b/hw/misc/vmcoreinfo.c index a280552..304c628 100644 --- a/hw/misc/vmcoreinfo.c +++ b/hw/misc/vmcoreinfo.c @@ -19,7 +19,7 @@ static void fw_cfg_vmci_write(void *dev, off_t offset, si= ze_t len) VMCoreInfoState *s =3D VMCOREINFO(dev); =20 s->has_vmcoreinfo =3D offset =3D=3D 0 && len =3D=3D sizeof(s->vmcorein= fo) - && s->vmcoreinfo.guest_format !=3D VMCOREINFO_FORMAT_NONE; + && s->vmcoreinfo.guest_format !=3D FW_CFG_VMCOREINFO_FORMAT_NONE; } =20 static void vmcoreinfo_reset(void *dev) @@ -28,7 +28,7 @@ static void vmcoreinfo_reset(void *dev) =20 s->has_vmcoreinfo =3D false; memset(&s->vmcoreinfo, 0, sizeof(s->vmcoreinfo)); - s->vmcoreinfo.host_format =3D cpu_to_le16(VMCOREINFO_FORMAT_ELF); + s->vmcoreinfo.host_format =3D cpu_to_le16(FW_CFG_VMCOREINFO_FORMAT_ELF= ); } =20 static void vmcoreinfo_realize(DeviceState *dev, Error **errp) @@ -53,7 +53,7 @@ static void vmcoreinfo_realize(DeviceState *dev, Error **= errp) return; } =20 - fw_cfg_add_file_callback(fw_cfg, "etc/vmcoreinfo", + fw_cfg_add_file_callback(fw_cfg, FW_CFG_VMCOREINFO_FILENAME, NULL, fw_cfg_vmci_write, s, &s->vmcoreinfo, sizeof(s->vmcoreinfo), false); =20 diff --git a/include/hw/misc/vmcoreinfo.h b/include/hw/misc/vmcoreinfo.h index c3aa856..0d11578 100644 --- a/include/hw/misc/vmcoreinfo.h +++ b/include/hw/misc/vmcoreinfo.h @@ -13,20 +13,12 @@ #define VMCOREINFO_H =20 #include "hw/qdev.h" +#include "standard-headers/linux/qemu_fw_cfg.h" =20 #define VMCOREINFO_DEVICE "vmcoreinfo" #define VMCOREINFO(obj) OBJECT_CHECK(VMCoreInfoState, (obj), VMCOREINFO_DE= VICE) =20 -#define VMCOREINFO_FORMAT_NONE 0x0 -#define VMCOREINFO_FORMAT_ELF 0x1 - -/* all fields are little-endian */ -typedef struct FWCfgVMCoreInfo { - uint16_t host_format; /* set on reset */ - uint16_t guest_format; - uint32_t size; - uint64_t paddr; -} QEMU_PACKED FWCfgVMCoreInfo; +typedef struct fw_cfg_vmcoreinfo FWCfgVMCoreInfo; =20 typedef struct VMCoreInfoState { DeviceClass parent_obj; diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index b2259cc..f5a6895 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -2,7 +2,7 @@ #define FW_CFG_H =20 #include "exec/hwaddr.h" -#include "hw/nvram/fw_cfg_keys.h" +#include "standard-headers/linux/qemu_fw_cfg.h" #include "hw/sysbus.h" #include "sysemu/dma.h" =20 @@ -14,12 +14,7 @@ #define FW_CFG_IO(obj) OBJECT_CHECK(FWCfgIoState, (obj), TYPE_FW_CFG_IO) #define FW_CFG_MEM(obj) OBJECT_CHECK(FWCfgMemState, (obj), TYPE_FW_CFG_MEM) =20 -typedef struct FWCfgFile { - uint32_t size; /* file size */ - uint16_t select; /* write this to 0x510 to read it */ - uint16_t reserved; - char name[FW_CFG_MAX_FILE_PATH]; -} FWCfgFile; +typedef struct fw_cfg_file FWCfgFile; =20 #define FW_CFG_ORDER_OVERRIDE_VGA 70 #define FW_CFG_ORDER_OVERRIDE_NIC 80 @@ -34,14 +29,7 @@ typedef struct FWCfgFiles { FWCfgFile f[]; } FWCfgFiles; =20 -/* Control as first field allows for different structures selected by this - * field, which might be useful in the future - */ -typedef struct FWCfgDmaAccess { - uint32_t control; - uint32_t length; - uint64_t address; -} QEMU_PACKED FWCfgDmaAccess; +typedef struct fw_cfg_dma_access FWCfgDmaAccess; =20 typedef void (*FWCfgCallback)(void *opaque); typedef void (*FWCfgWriteCallback)(void *opaque, off_t start, size_t len); diff --git a/include/hw/nvram/fw_cfg_keys.h b/include/hw/nvram/fw_cfg_keys.h deleted file mode 100644 index b691945..0000000 --- a/include/hw/nvram/fw_cfg_keys.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef FW_CFG_KEYS_H -#define FW_CFG_KEYS_H - -#define FW_CFG_SIGNATURE 0x00 -#define FW_CFG_ID 0x01 -#define FW_CFG_UUID 0x02 -#define FW_CFG_RAM_SIZE 0x03 -#define FW_CFG_NOGRAPHIC 0x04 -#define FW_CFG_NB_CPUS 0x05 -#define FW_CFG_MACHINE_ID 0x06 -#define FW_CFG_KERNEL_ADDR 0x07 -#define FW_CFG_KERNEL_SIZE 0x08 -#define FW_CFG_KERNEL_CMDLINE 0x09 -#define FW_CFG_INITRD_ADDR 0x0a -#define FW_CFG_INITRD_SIZE 0x0b -#define FW_CFG_BOOT_DEVICE 0x0c -#define FW_CFG_NUMA 0x0d -#define FW_CFG_BOOT_MENU 0x0e -#define FW_CFG_MAX_CPUS 0x0f -#define FW_CFG_KERNEL_ENTRY 0x10 -#define FW_CFG_KERNEL_DATA 0x11 -#define FW_CFG_INITRD_DATA 0x12 -#define FW_CFG_CMDLINE_ADDR 0x13 -#define FW_CFG_CMDLINE_SIZE 0x14 -#define FW_CFG_CMDLINE_DATA 0x15 -#define FW_CFG_SETUP_ADDR 0x16 -#define FW_CFG_SETUP_SIZE 0x17 -#define FW_CFG_SETUP_DATA 0x18 -#define FW_CFG_FILE_DIR 0x19 - -#define FW_CFG_FILE_FIRST 0x20 -#define FW_CFG_FILE_SLOTS_MIN 0x10 - -#define FW_CFG_WRITE_CHANNEL 0x4000 -#define FW_CFG_ARCH_LOCAL 0x8000 -#define FW_CFG_ENTRY_MASK (~(FW_CFG_WRITE_CHANNEL | FW_CFG_ARCH_LOCA= L)) - -#define FW_CFG_INVALID 0xffff - -/* width in bytes of fw_cfg control register */ -#define FW_CFG_CTL_SIZE 0x02 - -#define FW_CFG_MAX_FILE_PATH 56 - -#endif diff --git a/include/standard-headers/linux/qemu_fw_cfg.h b/include/standar= d-headers/linux/qemu_fw_cfg.h new file mode 100644 index 0000000..cb93f66 --- /dev/null +++ b/include/standard-headers/linux/qemu_fw_cfg.h @@ -0,0 +1,97 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +#ifndef _LINUX_FW_CFG_H +#define _LINUX_FW_CFG_H + +#include "standard-headers/linux/types.h" + +#define FW_CFG_ACPI_DEVICE_ID "QEMU0002" + +/* selector key values for "well-known" fw_cfg entries */ +#define FW_CFG_SIGNATURE 0x00 +#define FW_CFG_ID 0x01 +#define FW_CFG_UUID 0x02 +#define FW_CFG_RAM_SIZE 0x03 +#define FW_CFG_NOGRAPHIC 0x04 +#define FW_CFG_NB_CPUS 0x05 +#define FW_CFG_MACHINE_ID 0x06 +#define FW_CFG_KERNEL_ADDR 0x07 +#define FW_CFG_KERNEL_SIZE 0x08 +#define FW_CFG_KERNEL_CMDLINE 0x09 +#define FW_CFG_INITRD_ADDR 0x0a +#define FW_CFG_INITRD_SIZE 0x0b +#define FW_CFG_BOOT_DEVICE 0x0c +#define FW_CFG_NUMA 0x0d +#define FW_CFG_BOOT_MENU 0x0e +#define FW_CFG_MAX_CPUS 0x0f +#define FW_CFG_KERNEL_ENTRY 0x10 +#define FW_CFG_KERNEL_DATA 0x11 +#define FW_CFG_INITRD_DATA 0x12 +#define FW_CFG_CMDLINE_ADDR 0x13 +#define FW_CFG_CMDLINE_SIZE 0x14 +#define FW_CFG_CMDLINE_DATA 0x15 +#define FW_CFG_SETUP_ADDR 0x16 +#define FW_CFG_SETUP_SIZE 0x17 +#define FW_CFG_SETUP_DATA 0x18 +#define FW_CFG_FILE_DIR 0x19 + +#define FW_CFG_FILE_FIRST 0x20 +#define FW_CFG_FILE_SLOTS_MIN 0x10 + +#define FW_CFG_WRITE_CHANNEL 0x4000 +#define FW_CFG_ARCH_LOCAL 0x8000 +#define FW_CFG_ENTRY_MASK (~(FW_CFG_WRITE_CHANNEL | FW_CFG_ARCH_LOCAL)) + +#define FW_CFG_INVALID 0xffff + +/* width in bytes of fw_cfg control register */ +#define FW_CFG_CTL_SIZE 0x02 + +/* fw_cfg "file name" is up to 56 characters (including terminating nul) */ +#define FW_CFG_MAX_FILE_PATH 56 + +/* size in bytes of fw_cfg signature */ +#define FW_CFG_SIG_SIZE 4 + +/* FW_CFG_ID bits */ +#define FW_CFG_VERSION 0x01 +#define FW_CFG_VERSION_DMA 0x02 + +/* fw_cfg file directory entry type */ +struct fw_cfg_file { + uint32_t size; + uint16_t select; + uint16_t reserved; + char name[FW_CFG_MAX_FILE_PATH]; +}; + +/* FW_CFG_DMA_CONTROL bits */ +#define FW_CFG_DMA_CTL_ERROR 0x01 +#define FW_CFG_DMA_CTL_READ 0x02 +#define FW_CFG_DMA_CTL_SKIP 0x04 +#define FW_CFG_DMA_CTL_SELECT 0x08 +#define FW_CFG_DMA_CTL_WRITE 0x10 + +#define FW_CFG_DMA_SIGNATURE 0x51454d5520434647ULL /* "QEMU CFG" */ + +/* Control as first field allows for different structures selected by this + * field, which might be useful in the future + */ +struct fw_cfg_dma_access { + uint32_t control; + uint32_t length; + uint64_t address; +}; + +#define FW_CFG_VMCOREINFO_FILENAME "etc/vmcoreinfo" + +#define FW_CFG_VMCOREINFO_FORMAT_NONE 0x0 +#define FW_CFG_VMCOREINFO_FORMAT_ELF 0x1 + +struct fw_cfg_vmcoreinfo { + uint16_t host_format; + uint16_t guest_format; + uint32_t size; + uint64_t paddr; +}; + +#endif diff --git a/pc-bios/optionrom/linuxboot_dma.c b/pc-bios/optionrom/linuxboo= t_dma.c index 4754282..d856d41 100644 --- a/pc-bios/optionrom/linuxboot_dma.c +++ b/pc-bios/optionrom/linuxboot_dma.c @@ -58,8 +58,6 @@ asm( " jmp load_kernel\n" ); =20 -#include "../../include/hw/nvram/fw_cfg_keys.h" - /* QEMU_CFG_DMA_CONTROL bits */ #define BIOS_CFG_DMA_CTL_ERROR 0x01 #define BIOS_CFG_DMA_CTL_READ 0x02 @@ -73,6 +71,8 @@ asm( #define uint32_t unsigned int #define uint16_t unsigned short =20 +#include "../../include/standard-headers/linux/qemu_fw_cfg.h" + #define barrier() asm("" : : : "memory") =20 typedef struct FWCfgDmaAccess { diff --git a/pc-bios/optionrom/optionrom.h b/pc-bios/optionrom/optionrom.h index 6c4c2c8..a2b612f 100644 --- a/pc-bios/optionrom/optionrom.h +++ b/pc-bios/optionrom/optionrom.h @@ -19,7 +19,20 @@ */ =20 =20 -#include "../../include/hw/nvram/fw_cfg_keys.h" +#define FW_CFG_KERNEL_ADDR 0x07 +#define FW_CFG_KERNEL_SIZE 0x08 +#define FW_CFG_KERNEL_CMDLINE 0x09 +#define FW_CFG_INITRD_ADDR 0x0a +#define FW_CFG_INITRD_SIZE 0x0b +#define FW_CFG_KERNEL_ENTRY 0x10 +#define FW_CFG_KERNEL_DATA 0x11 +#define FW_CFG_INITRD_DATA 0x12 +#define FW_CFG_CMDLINE_ADDR 0x13 +#define FW_CFG_CMDLINE_SIZE 0x14 +#define FW_CFG_CMDLINE_DATA 0x15 +#define FW_CFG_SETUP_ADDR 0x16 +#define FW_CFG_SETUP_SIZE 0x17 +#define FW_CFG_SETUP_DATA 0x18 =20 #define BIOS_CFG_IOPORT_CFG 0x510 #define BIOS_CFG_IOPORT_DATA 0x511 diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c index 9d98c48..c60ebcf 100644 --- a/tests/boot-order-test.c +++ b/tests/boot-order-test.c @@ -14,7 +14,7 @@ #include "libqos/fw_cfg.h" #include "libqtest.h" #include "qapi/qmp/qdict.h" -#include "hw/nvram/fw_cfg_keys.h" +#include "standard-headers/linux/qemu_fw_cfg.h" =20 /* TODO actually test the results and get rid of this */ #define qmp_discard_response(...) qobject_unref(qmp(__VA_ARGS__)) diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c index 1548bf1..1c5103f 100644 --- a/tests/fw_cfg-test.c +++ b/tests/fw_cfg-test.c @@ -13,7 +13,7 @@ #include "qemu/osdep.h" =20 #include "libqtest.h" -#include "hw/nvram/fw_cfg_keys.h" +#include "standard-headers/linux/qemu_fw_cfg.h" #include "libqos/fw_cfg.h" =20 static uint64_t ram_size =3D 128 << 20; diff --git a/tests/libqos/malloc-pc.c b/tests/libqos/malloc-pc.c index 634b9c2..b83cb8f 100644 --- a/tests/libqos/malloc-pc.c +++ b/tests/libqos/malloc-pc.c @@ -14,7 +14,7 @@ #include "libqos/malloc-pc.h" #include "libqos/fw_cfg.h" =20 -#include "hw/nvram/fw_cfg_keys.h" +#include "standard-headers/linux/qemu_fw_cfg.h" =20 #include "qemu-common.h" =20 --=20 1.8.3.1