Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/815483/?format=api
{ "id": 815483, "url": "http://patchwork.ozlabs.org/api/patches/815483/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170919115814.14724-4-marcandre.lureau@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170919115814.14724-4-marcandre.lureau@redhat.com>", "list_archive_url": null, "date": "2017-09-19T11:58:13", "name": "[v2,3/4] fw_cfg: write vmcoreinfo details", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "dcd9a2fd33b45264c8b6fe86d92037a53840cec1", "submitter": { "id": 66774, "url": "http://patchwork.ozlabs.org/api/people/66774/?format=api", "name": "Marc-André Lureau", "email": "marcandre.lureau@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170919115814.14724-4-marcandre.lureau@redhat.com/mbox/", "series": [ { "id": 3856, "url": "http://patchwork.ozlabs.org/api/series/3856/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=3856", "date": "2017-09-19T11:58:10", "name": "fw_cfg: add DMA operations & etc/vmcoreinfo support", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/3856/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/815483/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/815483/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)", "ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com", "ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=marcandre.lureau@redhat.com" ], "Received": [ "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxLzm3jNXz9s4q\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 19 Sep 2017 22:00:36 +1000 (AEST)", "from localhost ([::1]:42001 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1duHCc-0008Ru-Ie\n\tfor incoming@patchwork.ozlabs.org; Tue, 19 Sep 2017 08:00:34 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:40682)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <marcandre.lureau@redhat.com>) id 1duHAh-0007Pj-SE\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 07:58:37 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <marcandre.lureau@redhat.com>) id 1duHAf-00022V-Ig\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 07:58:35 -0400", "from mx1.redhat.com ([209.132.183.28]:49926)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <marcandre.lureau@redhat.com>)\n\tid 1duHAf-000222-Ax\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 07:58:33 -0400", "from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 5B8B0C047B7F;\n\tTue, 19 Sep 2017 11:58:32 +0000 (UTC)", "from localhost (ovpn-112-56.ams2.redhat.com [10.36.112.56])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id B3EF15C541;\n\tTue, 19 Sep 2017 11:58:31 +0000 (UTC)" ], "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com 5B8B0C047B7F", "From": "marcandre.lureau@redhat.com", "To": "linux-kernel@vger.kernel.org", "Date": "Tue, 19 Sep 2017 13:58:13 +0200", "Message-Id": "<20170919115814.14724-4-marcandre.lureau@redhat.com>", "In-Reply-To": "<20170919115814.14724-1-marcandre.lureau@redhat.com>", "References": "<20170919115814.14724-1-marcandre.lureau@redhat.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.16", "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.31]);\n\tTue, 19 Sep 2017 11:58:32 +0000 (UTC)", "Content-Transfer-Encoding": "quoted-printable", "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]", "X-Received-From": "209.132.183.28", "Subject": "[Qemu-devel] [PATCH v2 3/4] fw_cfg: write vmcoreinfo details", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.21", "Precedence": "list", "List-Id": "<qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Cc": "=?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>,\n\tsomlo@cmu.edu, qemu-devel@nongnu.org, mst@redhat.com", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>" }, "content": "From: Marc-André Lureau <marcandre.lureau@redhat.com>\n\nIf the \"etc/vmcoreinfo\" file is present, write the addr/size of the\nvmcoreinfo ELF note.\n\nSigned-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>\n---\n drivers/firmware/qemu_fw_cfg.c | 80 +++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 79 insertions(+), 1 deletion(-)", "diff": "diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c\nindex a0e24fdf3ae5..26152bfc7805 100644\n--- a/drivers/firmware/qemu_fw_cfg.c\n+++ b/drivers/firmware/qemu_fw_cfg.c\n@@ -34,6 +34,7 @@\n #include <linux/io.h>\n #include <linux/ioport.h>\n #include <linux/dma-mapping.h>\n+#include <linux/crash_core.h>\n \n MODULE_AUTHOR(\"Gabriel L. Somlo <somlo@cmu.edu>\");\n MODULE_DESCRIPTION(\"QEMU fw_cfg sysfs support\");\n@@ -57,6 +58,8 @@ MODULE_LICENSE(\"GPL\");\n /* fw_cfg \"file name\" is up to 56 characters (including terminating nul) */\n #define FW_CFG_MAX_FILE_PATH 56\n \n+#define VMCOREINFO_FORMAT_ELF 0x1\n+\n /* platform device for dma mapping */\n static struct device *dev;\n \n@@ -107,7 +110,8 @@ static ssize_t fw_cfg_dma_transfer(void *address, u32 length, u32 control)\n \tdma_addr_t dma;\n \tssize_t ret = length;\n \tenum dma_data_direction dir =\n-\t\t(control & FW_CFG_DMA_CTL_READ ? DMA_FROM_DEVICE : 0);\n+\t\t(control & FW_CFG_DMA_CTL_READ ? DMA_FROM_DEVICE : 0) |\n+\t\t(control & FW_CFG_DMA_CTL_WRITE ? DMA_TO_DEVICE : 0);\n \n \tif (address && length) {\n \t\tdma_addr = dma_map_single(dev, address, length, dir);\n@@ -203,6 +207,46 @@ static ssize_t fw_cfg_read_blob(u16 key,\n \treturn ret;\n }\n \n+/* write chunk of given fw_cfg blob (caller responsible for sanity-check) */\n+static ssize_t fw_cfg_write_blob(u16 key,\n+\t\t\t\t void *buf, loff_t pos, size_t count)\n+{\n+\tu32 glk = -1U;\n+\tacpi_status status;\n+\tssize_t ret = count;\n+\n+\t/* If we have ACPI, ensure mutual exclusion against any potential\n+\t * device access by the firmware, e.g. via AML methods:\n+\t */\n+\tstatus = acpi_acquire_global_lock(ACPI_WAIT_FOREVER, &glk);\n+\tif (ACPI_FAILURE(status) && status != AE_NOT_CONFIGURED) {\n+\t\t/* Should never get here */\n+\t\tWARN(1, \"%s: Failed to lock ACPI!\\n\", __func__);\n+\t\tmemset(buf, 0, count);\n+\t\treturn -EBUSY;\n+\t}\n+\n+\tmutex_lock(&fw_cfg_dev_lock);\n+\tif (pos == 0) {\n+\t\tret = fw_cfg_dma_transfer(buf, count, key << 16\n+\t\t\t\t\t | FW_CFG_DMA_CTL_SELECT\n+\t\t\t\t\t | FW_CFG_DMA_CTL_WRITE);\n+\t} else {\n+\t\tiowrite16(fw_cfg_sel_endianness(key), fw_cfg_reg_ctrl);\n+\t\tret = fw_cfg_dma_transfer(0, pos, FW_CFG_DMA_CTL_SKIP);\n+\t\tif (ret < 0)\n+\t\t\tgoto end;\n+\t\tret = fw_cfg_dma_transfer(buf, count, FW_CFG_DMA_CTL_WRITE);\n+\t}\n+\n+end:\n+\tmutex_unlock(&fw_cfg_dev_lock);\n+\n+\tacpi_release_global_lock(glk);\n+\n+\treturn ret;\n+}\n+\n /* clean up fw_cfg device i/o */\n static void fw_cfg_io_cleanup(void)\n {\n@@ -321,6 +365,35 @@ struct fw_cfg_sysfs_entry {\n \tstruct list_head list;\n };\n \n+static ssize_t write_vmcoreinfo(const struct fw_cfg_file *f)\n+{\n+\tstruct vmci {\n+\t\t__le16 host_format;\n+\t\t__le16 guest_format;\n+\t\t__le32 size;\n+\t\t__le64 paddr;\n+\t} __packed;\n+\tstruct vmci *data;\n+\tssize_t ret;\n+\n+\tdata = kmalloc(sizeof(struct vmci), GFP_KERNEL | GFP_DMA);\n+\tif (!data)\n+\t\treturn -ENOMEM;\n+\n+\t/* spare ourself reading host format support for now since we\n+\t * don't know what else to format - host may ignore ours\n+\t */\n+\t*data = (struct vmci) {\n+\t\t.guest_format = cpu_to_le16(VMCOREINFO_FORMAT_ELF),\n+\t\t.size = cpu_to_le32(VMCOREINFO_NOTE_SIZE),\n+\t\t.paddr = cpu_to_le64(paddr_vmcoreinfo_note())\n+\t};\n+\tret = fw_cfg_write_blob(f->select, data, 0, sizeof(struct vmci));\n+\n+\tkfree(data);\n+\treturn ret;\n+}\n+\n /* get fw_cfg_sysfs_entry from kobject member */\n static inline struct fw_cfg_sysfs_entry *to_entry(struct kobject *kobj)\n {\n@@ -560,6 +633,11 @@ static int fw_cfg_register_file(const struct fw_cfg_file *f)\n \tint err;\n \tstruct fw_cfg_sysfs_entry *entry;\n \n+\tif (strcmp(f->name, \"etc/vmcoreinfo\") == 0) {\n+\t\tif (write_vmcoreinfo(f) < 0)\n+\t\t\tpr_warn(\"fw_cfg: failed to write vmcoreinfo\");\n+\t}\n+\n \t/* allocate new entry */\n \tentry = kzalloc(sizeof(*entry), GFP_KERNEL);\n \tif (!entry)\n", "prefixes": [ "v2", "3/4" ] }