Received: by 10.223.164.202 with SMTP id h10csp1981145wrb; Thu, 16 Nov 2017 07:30:28 -0800 (PST) X-Google-Smtp-Source: AGs4zMYcq9L2O8PeMmTpoBoOfV6maiwFgCRh1PC+4wFgRjTMNFHFaTFDLMkOH3JCJEwjI+2g0i5X X-Received: by 10.84.204.136 with SMTP id b8mr989814ple.319.1510846228704; Thu, 16 Nov 2017 07:30:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510846228; cv=none; d=google.com; s=arc-20160816; b=IxJ7/xfX/e22tAttM5Gbbf8/1v/aXTegHxDrnX63Wh9eHDlLlCKk4vvhI5lfLutM9c 34q7Y8yhglkjZUr+Yy9MMe4rh7xve6AnSD8DGPNm0y0AaRLGsVLwCFq8KmLYRZ/7l3Ll QR83B/wEPrkhJx4ngMfj1wb4qN78jxw6+31PYEZDO5xhgLfZD9tOGSFvCCfgdJZvuPxG ngdz2CbZTixbz1/qy8XsFrNQj3TiB95XFd/MaGiIzNVtbE5xd79crsclKQZnrr4eA/Jk q8quNnUNLH88IcVWoVGnooBHpnaJyaxQPo5Kx4vsmAWQfqV52qDsW3NI5H+SQGurHdGe Aw3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:arc-authentication-results; bh=x61naeYiJQ+yjGYBu7m07XiOrHWisnPv1q2YUCbKbOk=; b=dYIjf7k3L2EeiNT3bM8aGwpLwp4OOhL4/hKsoXqRpgipnzq5LuKdLeph3/2Vd0+Jba CdpBb38BBFqtZ+7Hxja3QfKLqdRwZESTUEuxvdDEq6vBl3qwihzFCL6xOTgsxhWjyYw9 md9t+elSknD9UkprTQJgp784q0a8vh6mVFl2SMnJEhNGLp0O3K/bJ4Lcm9SYl19ObnAy JsYLk4+mrmwTDa6QCRUv6DhZjt9dlkOSZsqNjqx6Q3136vBo6Jxv5+7aLVd2ISI7VSFE qttCuLr+oRA8xmZ0KTKtK4ddusPnMKm+/mh0cTxT/IXdqWLQOSktLcvOcJHOe/HHMb06 N/7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l12si1042111plc.265.2017.11.16.07.30.16; Thu, 16 Nov 2017 07:30:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753928AbdKPNea convert rfc822-to-8bit (ORCPT + 91 others); Thu, 16 Nov 2017 08:34:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53414 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750738AbdKPNeX (ORCPT ); Thu, 16 Nov 2017 08:34:23 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D948E2DB714; Thu, 16 Nov 2017 13:34:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CDDF02D21D; Thu, 16 Nov 2017 13:34:23 +0000 (UTC) Received: from zmail17.collab.prod.int.phx2.redhat.com (zmail17.collab.prod.int.phx2.redhat.com [10.5.83.19]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BF0484BB79; Thu, 16 Nov 2017 13:34:23 +0000 (UTC) Date: Thu, 16 Nov 2017 08:34:23 -0500 (EST) From: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau To: "Michael S. Tsirkin" Cc: linux-kernel@vger.kernel.org, somlo@cmu.edu, qemu-devel@nongnu.org Message-ID: <183118826.40770917.1510839263526.JavaMail.zimbra@redhat.com> In-Reply-To: <20171116035606-mutt-send-email-mst@kernel.org> References: <20171113192958.22953-1-marcandre.lureau@redhat.com> <20171113192958.22953-6-marcandre.lureau@redhat.com> <20171116035606-mutt-send-email-mst@kernel.org> Subject: Re: [PATCH v6 5/5] fw_cfg: write vmcoreinfo details MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Originating-IP: [10.36.112.69, 10.4.195.6] Thread-Topic: fw_cfg: write vmcoreinfo details Thread-Index: qlohwerkNtNbxg0R7p/D9HisjeERzw== X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 16 Nov 2017 13:34:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi ----- Original Message ----- > On Mon, Nov 13, 2017 at 08:29:58PM +0100, Marc-André Lureau wrote: > > If the "etc/vmcoreinfo" fw_cfg file is present and we are not running > > the kdump kernel, write the addr/size of the vmcoreinfo ELF note. > > > > Signed-off-by: Marc-André Lureau > > Reviewed-by: Gabriel Somlo > > --- > > drivers/firmware/qemu_fw_cfg.c | 87 > > +++++++++++++++++++++++++++++++++++++++++- > > 1 file changed, 86 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/firmware/qemu_fw_cfg.c > > b/drivers/firmware/qemu_fw_cfg.c > > index 2ac4cd869fe6..7a70e7a549f6 100644 > > --- a/drivers/firmware/qemu_fw_cfg.c > > +++ b/drivers/firmware/qemu_fw_cfg.c > > @@ -35,6 +35,8 @@ > > #include > > #include > > #include > > +#include > > +#include > > > > MODULE_AUTHOR("Gabriel L. Somlo "); > > MODULE_DESCRIPTION("QEMU fw_cfg sysfs support"); > > @@ -59,6 +61,8 @@ MODULE_LICENSE("GPL"); > > /* fw_cfg "file name" is up to 56 characters (including terminating nul) > > */ > > #define FW_CFG_MAX_FILE_PATH 56 > > > > +#define VMCOREINFO_FORMAT_ELF 0x1 > > + > > /* platform device for dma mapping */ > > static struct device *dev; > > > > @@ -127,7 +131,8 @@ static ssize_t fw_cfg_dma_transfer(void *address, u32 > > length, u32 control) > > dma_addr_t dma; > > ssize_t ret = length; > > enum dma_data_direction dir = > > - (control & FW_CFG_DMA_CTL_READ ? DMA_FROM_DEVICE : 0); > > + (control & FW_CFG_DMA_CTL_READ ? DMA_FROM_DEVICE : 0) | > > + (control & FW_CFG_DMA_CTL_WRITE ? DMA_TO_DEVICE : 0); > > > > if (address && length) { > > dma_addr = dma_map_single(dev, address, length, dir); > > @@ -225,6 +230,48 @@ static ssize_t fw_cfg_read_blob(u16 key, > > return ret; > > } > > > > +#ifdef CONFIG_CRASH_CORE > > +/* write chunk of given fw_cfg blob (caller responsible for sanity-check) > > */ > > +static ssize_t fw_cfg_write_blob(u16 key, > > + void *buf, loff_t pos, size_t count) > > +{ > > + u32 glk = -1U; > > + acpi_status status; > > + ssize_t ret = count; > > + > > + /* If we have ACPI, ensure mutual exclusion against any potential > > + * device access by the firmware, e.g. via AML methods: > > + */ > > + status = acpi_acquire_global_lock(ACPI_WAIT_FOREVER, &glk); > > + if (ACPI_FAILURE(status) && status != AE_NOT_CONFIGURED) { > > + /* Should never get here */ > > + WARN(1, "%s: Failed to lock ACPI!\n", __func__); > > + memset(buf, 0, count); > > + return -EINVAL; > > + } > > + > > + mutex_lock(&fw_cfg_dev_lock); > > + if (pos == 0) { > > + ret = fw_cfg_dma_transfer(buf, count, key << 16 > > + | FW_CFG_DMA_CTL_SELECT > > + | FW_CFG_DMA_CTL_WRITE); > > + } else { > > + iowrite16(fw_cfg_sel_endianness(key), fw_cfg_reg_ctrl); > > + ret = fw_cfg_dma_transfer(NULL, pos, FW_CFG_DMA_CTL_SKIP); > > + if (ret < 0) > > + goto end; > > + ret = fw_cfg_dma_transfer(buf, count, FW_CFG_DMA_CTL_WRITE); > > + } > > + > > +end: > > + mutex_unlock(&fw_cfg_dev_lock); > > + > > + acpi_release_global_lock(glk); > > + > > + return ret; > > +} > > +#endif /* CONFIG_CRASH_CORE */ > > + > > /* clean up fw_cfg device i/o */ > > static void fw_cfg_io_cleanup(void) > > { > > @@ -343,6 +390,37 @@ struct fw_cfg_sysfs_entry { > > struct list_head list; > > }; > > > > +#ifdef CONFIG_CRASH_CORE > > +static ssize_t write_vmcoreinfo(const struct fw_cfg_file *f) > > +{ > > + struct vmci { > > + __le16 host_format; > > + __le16 guest_format; > > + __le32 size; > > + __le64 paddr; > > + } __packed; > > + struct vmci *data; > > + ssize_t ret; > > + > > + data = kmalloc(sizeof(struct vmci), GFP_KERNEL | GFP_DMA); > > + if (!data) > > + return -ENOMEM; > > It's a small bit of data - you can just keep it in a global variable, > this way failures won't be an issue. It would still need to be allocated with GFP_DMA. Since it's a one time thing, this is just moving the problem isn't it? > > > + > > + /* spare ourself reading host format support for now since we > > + * don't know what else to format - host may ignore ours > > + */ > > + *data = (struct vmci) { > > + .guest_format = cpu_to_le16(VMCOREINFO_FORMAT_ELF), > > + .size = cpu_to_le32(VMCOREINFO_NOTE_SIZE), > > + .paddr = cpu_to_le64(paddr_vmcoreinfo_note()) > > + }; > > + ret = fw_cfg_write_blob(f->select, data, 0, sizeof(struct vmci)); > > + > > + kfree(data); > > + return ret; > > +} > > +#endif /* CONFIG_CRASH_CORE */ > > + > > /* get fw_cfg_sysfs_entry from kobject member */ > > static inline struct fw_cfg_sysfs_entry *to_entry(struct kobject *kobj) > > { > > @@ -582,6 +660,13 @@ static int fw_cfg_register_file(const struct > > fw_cfg_file *f) > > int err; > > struct fw_cfg_sysfs_entry *entry; > > > > +#ifdef CONFIG_CRASH_CORE > > + if (strcmp(f->name, "etc/vmcoreinfo") == 0 && !is_kdump_kernel()) { > > + if (write_vmcoreinfo(f) < 0) > > + pr_warn("fw_cfg: failed to write vmcoreinfo"); > > + } > > +#endif > > + > > /* allocate new entry */ > > entry = kzalloc(sizeof(*entry), GFP_KERNEL); > > if (!entry) > > -- > > 2.15.0.125.g8f49766d64 > From 1584197461416977874@xxx Thu Nov 16 05:00:31 +0000 2017 X-GM-THRID: 1583980519600792907 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread