From patchwork Thu Feb 1 18:59:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 126587 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1980719ljc; Thu, 1 Feb 2018 11:02:58 -0800 (PST) X-Google-Smtp-Source: AH8x224Dao+DSHseM0oevPkBCrt2Olk3CSeUKBamj/evJsu6r5uug4bQVLWtjGYoCGwrvPf8kkTR X-Received: by 10.13.223.6 with SMTP id i6mr25430227ywe.503.1517511778418; Thu, 01 Feb 2018 11:02:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517511778; cv=none; d=google.com; s=arc-20160816; b=KW7yy/E5KE9a/f0DIRGmjcZfB9FSxb4KVzMfQBDxlpJeEz/2HXns+0HEu4fA+yiGPt FnSAWezc4WoiRzD+PrzrSAaihhGIleQgVxbumaWzfX2hT7N5WsMaTbKkn4xaekSJeLoC AKqk/C6VsENP20NzSuQqVixx1zOeFsH7riOUOOlOdpmDn70LTA7tW+pGimguxXoODILU ufCC5fvkw9nJqYPB9bSQ5XDr+ZkYed7Dj71wl7KgJ02mo10ajQe2gToxmt/SXBTl/McU ufz7Ou4ecz/r6hAdIpjGTqFk2XKW7D99cvAjJz/yEy8AxkLo+Am+WazL/gEgXBfaslZW qwVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=E9OFFWDo05OoEcAKguIO3xcoxGiLCZNemTeC/2Bk+b4=; b=Db9qxRGrGVlEbA3gMs8f4/ZedoTzzagB8LbU1ONd0ewwkLVQgd90NOecnaGVILHe27 1Oea/9b4t+79lqauZBv+AQ+Hqg2skBsjUpETjqi1SQyN4tKHszdqBMvDYd+VEmdGPRs7 oC6XUnGtNIyrJ88witsTe9jT/7z9AsNPF/aVH694dp5A3V2CAMjMiieYdveKmvexRr85 u3s2//6xc8YMIVq2g1XsGbppLHtt/xD4ph7BnJ+06A64PZgQkY5ZQG3jnVwUZfjH3rFv G8WalGtTvgXO8Ctxg0fTkFBxeKLnP/318+JxIqXVxrJyGP7dcY4ymLio2+fxI8aIdAPY de7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=kD5xnmZ2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j65si51678ywd.453.2018.02.01.11.02.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Feb 2018 11:02:58 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=kD5xnmZ2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:54977 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehK8P-0002ve-P7 for patch@linaro.org; Thu, 01 Feb 2018 14:02:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39137) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehK4q-0000J4-Ra for qemu-devel@nongnu.org; Thu, 01 Feb 2018 13:59:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehK4n-0001OA-Ky for qemu-devel@nongnu.org; Thu, 01 Feb 2018 13:59:16 -0500 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:41103) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ehK4n-0001NC-EM for qemu-devel@nongnu.org; Thu, 01 Feb 2018 13:59:13 -0500 Received: by mail-oi0-x241.google.com with SMTP id m83so14179228oik.8 for ; Thu, 01 Feb 2018 10:59:13 -0800 (PST) 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; bh=E9OFFWDo05OoEcAKguIO3xcoxGiLCZNemTeC/2Bk+b4=; b=kD5xnmZ29ebpOtxb9Mt0v7+uyYh0svyGh6uGtX7xka1JBSPkQMCObCz9Zr3hXE6MoM uAtwC5r1spEgYsMHRNlO7VGLO9qizTCfvYVPAcwCRuT0d6BYUAGUzlckwfU9PV+8TLe/ uFJA7irOdQINy+D3d0Snt9Adi2SctjY/yiJ5hbCPYttChDl9hvhuqNdsxyUUWqlqUFSZ JxU3d93efb/RI4rWf07fPL37RAIlNejvR02O/CkgOljsHLzD32yi/2E0pX4EDhOtsD0i S+k1yprZfb0bPLmdIBrI64kvAYv7GQc0RI/z8Mj+jzwpLytnDVTLyzurwFd3h3TyZe9I 1uPg== 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; bh=E9OFFWDo05OoEcAKguIO3xcoxGiLCZNemTeC/2Bk+b4=; b=K2pQStgz8frYt0TfgGR+huqpsEw04c8eNRwlAetEsmhmW6QU2fZtyuJdjUUzUB6seS VNvWnTfdrFmPWpvFhr/SWhzXnS0/R0UPWbiZOWOoiBWC0/KuQvOGakPMhfnjB/4ps9aM PFTUtOCu5ZLWeUFM+KOVOfNm0kcnJXLTmVjVrVOUFLstf9Kz1TU8SVll4KX/ta1E0QJE 2uxAhQ06kZ9ANo6DRLZmLoNj3L83VvFgtDUbh7xoxoscSoRxZXmlHOhfn9VzGQ3Mhc7y mCP/D6kLGWieRjg51RUm52Zh3zwczu/c0Ng0taDtK69tlM/rRHfmxbbCWHF03YBIWJCO EvCg== X-Gm-Message-State: AKwxytdtCbVRiYA5zTvI14c8xPb19o2QwwXYBfcr4oyROtjZWB6q7ELX xobmc2FqfOiw/QwL0uKaog== X-Received: by 10.202.245.201 with SMTP id t192mr13575917oih.295.1517511552446; Thu, 01 Feb 2018 10:59:12 -0800 (PST) Received: from serve.minyard.net ([47.184.168.85]) by smtp.gmail.com with ESMTPSA id h196sm118718oic.9.2018.02.01.10.59.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Feb 2018 10:59:10 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id DAA5C79A; Thu, 1 Feb 2018 12:59:09 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 1A48E3000A3; Thu, 1 Feb 2018 12:59:09 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 1 Feb 2018 12:59:06 -0600 Message-Id: <1517511547-10147-2-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517511547-10147-1-git-send-email-minyard@acm.org> References: <1517511547-10147-1-git-send-email-minyard@acm.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::241 Subject: [Qemu-devel] [PATCH 1/2] ipmi: Use proper struct reference for KCS vmstate 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: Corey Minyard Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard The vmstate for isa_ipmi_kcs was referencing into the kcs structure, instead create a kcs structure separate and use that. There was also some issues in the state transfer. The inlen field was not being transferred, so if a transaction was in process during the transfer it would be messed up. And the use_irq field was transferred, but that should come from the configuration. This also fixes those issues and is tested under heavy load. Signed-off-by: Corey Minyard --- hw/ipmi/isa_ipmi_kcs.c | 75 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 15 deletions(-) -- 2.7.4 diff --git a/hw/ipmi/isa_ipmi_kcs.c b/hw/ipmi/isa_ipmi_kcs.c index 689587b..3c942d6 100644 --- a/hw/ipmi/isa_ipmi_kcs.c +++ b/hw/ipmi/isa_ipmi_kcs.c @@ -422,24 +422,69 @@ static void ipmi_isa_realize(DeviceState *dev, Error **errp) isa_register_ioport(isadev, &iik->kcs.io, iik->kcs.io_base); } -const VMStateDescription vmstate_ISAIPMIKCSDevice = { - .name = TYPE_IPMI_INTERFACE, +static const VMStateDescription vmstate_IPMIKCS = { + .name = TYPE_IPMI_INTERFACE_PREFIX "kcs", .version_id = 1, .minimum_version_id = 1, .fields = (VMStateField[]) { - VMSTATE_BOOL(kcs.obf_irq_set, ISAIPMIKCSDevice), - VMSTATE_BOOL(kcs.atn_irq_set, ISAIPMIKCSDevice), - VMSTATE_BOOL(kcs.use_irq, ISAIPMIKCSDevice), - VMSTATE_BOOL(kcs.irqs_enabled, ISAIPMIKCSDevice), - VMSTATE_UINT32(kcs.outpos, ISAIPMIKCSDevice), - VMSTATE_UINT8_ARRAY(kcs.outmsg, ISAIPMIKCSDevice, MAX_IPMI_MSG_SIZE), - VMSTATE_UINT8_ARRAY(kcs.inmsg, ISAIPMIKCSDevice, MAX_IPMI_MSG_SIZE), - VMSTATE_BOOL(kcs.write_end, ISAIPMIKCSDevice), - VMSTATE_UINT8(kcs.status_reg, ISAIPMIKCSDevice), - VMSTATE_UINT8(kcs.data_out_reg, ISAIPMIKCSDevice), - VMSTATE_INT16(kcs.data_in_reg, ISAIPMIKCSDevice), - VMSTATE_INT16(kcs.cmd_reg, ISAIPMIKCSDevice), - VMSTATE_UINT8(kcs.waiting_rsp, ISAIPMIKCSDevice), + VMSTATE_BOOL(obf_irq_set, IPMIKCS), + VMSTATE_BOOL(atn_irq_set, IPMIKCS), + VMSTATE_BOOL(use_irq, IPMIKCS), + VMSTATE_BOOL(irqs_enabled, IPMIKCS), + VMSTATE_UINT32(outpos, IPMIKCS), + VMSTATE_UINT8_ARRAY(outmsg, IPMIKCS, MAX_IPMI_MSG_SIZE), + VMSTATE_UINT32(inlen, IPMIKCS), + VMSTATE_UINT8_ARRAY(inmsg, IPMIKCS, MAX_IPMI_MSG_SIZE), + VMSTATE_BOOL(write_end, IPMIKCS), + VMSTATE_UINT8(status_reg, IPMIKCS), + VMSTATE_UINT8(data_out_reg, IPMIKCS), + VMSTATE_INT16(data_in_reg, IPMIKCS), + VMSTATE_INT16(cmd_reg, IPMIKCS), + VMSTATE_UINT8(waiting_rsp, IPMIKCS), + VMSTATE_END_OF_LIST() + } +}; + +static int isa_ipmi_kcs_load_old(QEMUFile *f, void *opaque, int version_id) +{ + ISAIPMIKCSDevice *iik = opaque; + IPMIKCS *k = &iik->kcs; + unsigned int i; + + if (version_id != 1) { + return -EINVAL; + } + + k->obf_irq_set = qemu_get_byte(f); + k->atn_irq_set = qemu_get_byte(f); + qemu_get_byte(f); /* Used to be use_irq, but that's not a good idea. */ + k->irqs_enabled = qemu_get_byte(f); + k->outpos = qemu_get_be32(f); + for (i = 0; i < MAX_IPMI_MSG_SIZE; i++) { + k->outmsg[i] = qemu_get_byte(f); + } + k->inlen = 0; /* This was forgotten on version 1, just reset it. */ + for (i = 0; i < MAX_IPMI_MSG_SIZE; i++) { + k->inmsg[i] = qemu_get_byte(f); + } + k->write_end = qemu_get_byte(f); + k->status_reg = qemu_get_byte(f); + k->data_out_reg = qemu_get_byte(f); + k->data_in_reg = qemu_get_be16(f); + k->cmd_reg = qemu_get_be16(f); + k->waiting_rsp = qemu_get_byte(f); + + return 0; +} + +static const VMStateDescription vmstate_ISAIPMIKCSDevice = { + .name = TYPE_IPMI_INTERFACE_PREFIX "isa-kcs", + .version_id = 2, + .minimum_version_id = 2, + .minimum_version_id_old = 1, + .load_state_old = isa_ipmi_kcs_load_old, + .fields = (VMStateField[]) { + VMSTATE_STRUCT(kcs, ISAIPMIKCSDevice, 1, vmstate_IPMIKCS, IPMIKCS), VMSTATE_END_OF_LIST() } };