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: 10195931 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6443F60362 for ; Thu, 1 Feb 2018 19:16:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 478DA28BEB for ; Thu, 1 Feb 2018 19:16:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 321BC28E65; Thu, 1 Feb 2018 19:16:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7654828C7E for ; Thu, 1 Feb 2018 19:08:42 +0000 (UTC) Received: from localhost ([::1]:55021 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehK9X-0004GG-Et for patchwork-qemu-devel@patchwork.kernel.org; Thu, 01 Feb 2018 14:04:07 -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-Google-Smtp-Source: AH8x22792kO2bFe3NFiJ+3ca5aNs3ltSWpB5lJCnZ55Ey6A50FrA8g5pjH2dJVBnFMQRy0kd7y++Tw== 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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() } };