Received: by 10.223.164.202 with SMTP id h10csp2255381wrb; Sun, 12 Nov 2017 05:15:59 -0800 (PST) X-Google-Smtp-Source: AGs4zMbSINoDFD61jxklM+iZlGw6COksEWb9oTiwO8WKTsSgI23Jb/TIwzJqLZ6gPxVx07UciDyz X-Received: by 10.99.175.80 with SMTP id s16mr6051320pgo.222.1510492559667; Sun, 12 Nov 2017 05:15:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510492559; cv=none; d=google.com; s=arc-20160816; b=YihteDl6Dt+HHnEVhQIcCSPWUjFRBJCHzowuz5FOf7nRvqAq4U2niapWo/lHbkvg1+ JmPJgprSxkbVoAV0/vNzYOQOhB8lGpCPmU115c/zQV0rWLXmmFnQ/jW2gxFuuj+7fzhb nYt6LzVCe7iQ196lZxFFqqL+4YJPabi1NELg4Zqp8P8ox8hTjpatKGJFbU04+WxNM+ib My3r89VThOB4cIS8n3vpMSndTWcbhnkn13O7LAdbfxwfC3ySvAR0d1M4sQNCy7msTar3 90uRQSsDKJ6f2irCKQH1G+IBH8ZO2/Uh1G4ux/1unDed/VjCEJvtmTjYpmY9S0Xl6Tnr /iEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :message-id:subject:cc:to:from:date:arc-authentication-results; bh=sXewzPw3FCEbXr2x6Lv6yX4ip3R1N4FnAvFfhX3UaKo=; b=I4IbaVrnHLGvBd1AbECFqr8njPPi1qTNaO5RrLySEm8/IY67qA9kXuM2ljg81M0qIM n31CHUJB88QAabkCZ0XYuNZgqYT/hmDUWMmLQbUJj07mVrjxi9e0BzTMrW9Ky1jjPeqn hdO4F+udSAJgSCmnIdAh1jGFWR2RNFggGdbNcG0IWHKmsNTi8c6anEBQlUYJDMDb/OPB Zg7Dz3+QxyWNGx1P7WkYA3OhYWozHcyUAtbrWOSMikmZ/Nt93KdPNIElmHGjvrY0X1kh /SlEzYA8gjWaeA8GAU8BtqsxkqSYtIA5lNzFPxjBX/RQh9HCPq3u8Qjb9rPJCd5pgbFc EcQw== 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=cmu.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6si12209148pgc.70.2017.11.12.05.15.46; Sun, 12 Nov 2017 05:15:59 -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=cmu.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751253AbdKLNNr (ORCPT + 87 others); Sun, 12 Nov 2017 08:13:47 -0500 Received: from SMTP.ANDREW.CMU.EDU ([128.2.105.203]:42077 "EHLO smtp.andrew.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750847AbdKLNNp (ORCPT ); Sun, 12 Nov 2017 08:13:45 -0500 Received: from hedwig.ini.cmu.edu (HEDWIG.INI.CMU.EDU [128.2.16.51]) (user=somlo mech=LOGIN (0 bits)) by smtp.andrew.cmu.edu (8.15.2/8.15.2) with ESMTPSA id vACChuOY089582 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 12 Nov 2017 07:43:58 -0500 Date: Sun, 12 Nov 2017 07:43:56 -0500 From: "Gabriel L. Somlo" To: =?iso-8859-1?Q?Marc-Andr=E9?= Lureau Cc: linux-kernel@vger.kernel.org, somlo@cmu.edu, qemu-devel@nongnu.org, mst@redhat.com Subject: Re: [PATCH v4 5/5] fw_cfg: write vmcoreinfo details Message-ID: <20171112124333.GF19857@hedwig.ini.cmu.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20171031151938.14982-6-marcandre.lureau@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.9.1 (2017-09-22) X-PMX-Version: 6.3.0.2556906, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2017.11.12.123017 X-SMTP-Spam-Clean: 8% ( MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_4000_4999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, FROM_EDU_TLD 0, IN_REP_TO 0, LEGITIMATE_SIGNS 0, MSG_THREAD 0, MULTIPLE_REAL_RCPTS 0, NO_URI_HTTPS 0, __ANY_URI 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CD 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __FORWARDED_MSG 0, __HAS_CC_HDR 0, __HAS_FROM 0, __HAS_MSGID 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __NO_HTML_TAG_RAW 0, __PHISH_SPEAR_STRUCTURE_1 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __SUBJ_ALPHA_NEGATE 0, __TO_MALFORMED_2 0, __TO_NAME 0, __TO_NAME_DIFF_FROM_ACC 0, __TO_REAL_NAMES 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0) X-SMTP-Spam-Score: 8% X-Scanned-By: MIMEDefang 2.78 on 128.2.105.203 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 31, 2017 at 04:19:38PM +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 Same two questions as for 3/5 earlier :) Thanks, --G > --- > 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 8ce5e49b7c62..ebd9bb134900 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 -EBUSY; Same question as before: why not e.g. 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(0, pos, FW_CFG_DMA_CTL_SKIP); NULL? > + 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; > + > + /* 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.rc0.40.gaefcc5f6f > From 1582787011476742189@xxx Tue Oct 31 15:22:01 +0000 2017 X-GM-THRID: 1582787011476742189 X-Gmail-Labels: Inbox,Category Forums