From patchwork Tue Aug 21 17:02:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 144775 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp5575244ljj; Tue, 21 Aug 2018 11:00:34 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYSex6LEhMMXH5yuJ/IvphXjRUKElZFawVtat+rqvj0HvjDenn4rqqQgfMDN2kWC0dL3CCh X-Received: by 2002:aed:25b4:: with SMTP id x49-v6mr6290230qtc.228.1534874434583; Tue, 21 Aug 2018 11:00:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534874434; cv=none; d=google.com; s=arc-20160816; b=ml0345gTXJK/9nmUXCFRx6Y482+ofQIpVXcWgP08Q9Tx7bUtKgNGNDt8S5wbtITwx/ PjcvEM7QFX9/7gM5yPL53i5q4CBSvFbsnZV6tLm9qA/jy1zKk3opI94YR7gL6kuyhuX6 x8tZsdUxooiTNlQngx8zwwJEgNGQc9msF/R+SyRZ6mdQ/N+xQvfzEW/GC0nUr5+ZGv5A pB9U3jKwl1p7ghOZDi3ac53+ubcdV1ivQ1lfCC3K3D3LjUJXcoPkxeA3LhnnH7wMnuGr vr9tDCeJ1mS/sRnwbJ8a2Ijf9L8cLdQ1BcTLgYGA+bHkBhe5csoLcq3cDR8HQaThvGex yyew== 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=XzdQb4myVIoMb9NuZHlHUKoiT3KZg77zsB0wbJSpUZA=; b=ZUWZFLF621Gy/Ux8gr+SvI5q9ZeugF8bKtfyUQnVPmO6xD0qJ+zTjtrPw7TJVJ3dWz CkjCw11gfu96d247PdG8yY4qOxcP3/3JzXlrbyuU7Zq7J3Kk3NBFJD15MV8hbxJlC5rq qNk4MYisn3uZEuHl3Z9m/KwdH6bxiNl2yuFP0aZWKPhyHPXFs8lnzGyIcn/7uyXYJzaj bkcLKllQ5fhESPVU/nBl4r7hd9cJE6AiXBdKfin6JJomCJ98ZqyKnNie1MOt7B+qXo3Z 5mS5ejApSPFsa9m9TqcYJWM8dSZlP/EGdvF2XnPcbHlS0U2zZjPcQYq5oCX3TptO525+ ynGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=JPIAALmX; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e102-v6si4661417qkh.4.2018.08.21.11.00.34 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 21 Aug 2018 11:00:34 -0700 (PDT) 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=JPIAALmX; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:55250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsAxG-0002JY-2X for patch@linaro.org; Tue, 21 Aug 2018 14:00:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsA51-0002UW-T4 for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fsA4n-0007A8-LZ for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:25 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:43888) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fsA4b-0006vg-Cj for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:08 -0400 Received: by mail-wr1-x42f.google.com with SMTP id k5-v6so4944662wre.10 for ; Tue, 21 Aug 2018 10:04:05 -0700 (PDT) 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=XzdQb4myVIoMb9NuZHlHUKoiT3KZg77zsB0wbJSpUZA=; b=JPIAALmXGQwub/qbNQ3MdFHJQXZPkJTHvUd+loPG+nCnYZzppch9KkWlC87tP+svC5 GOsDnd10Ao/Z3W6bkI0MORsxzT0V5fDMDZY8Llj8E8wsUdVgsmPsErsAtsR5InS/tU6S IKz4du7YNWdzU8zEiXOFIkoyBMXe8uknacx+aBQ+5zC2UOWijSl8WolBXpfpECd4s29H UTmLECUnKZ12/28qZeKjagYbZPemRm09NqDNJg+4VIF2DbhcC5YqVk4DMDgpX6Q4AWzg 1TLjZDC7DjiZoGs0EOmaNPVm1PSgb2QLzddCOvBIQNWx9he3lAQJlNDffb45l8uTlFoz rcaA== 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=XzdQb4myVIoMb9NuZHlHUKoiT3KZg77zsB0wbJSpUZA=; b=VBqnk4iOfk37XeAPu1j38oAqcf+gvSf37jVx8CFKKxzjyCOUSPwccuhboIpT3YcTLI YnclE3Xr846/URYXqPOEGR/5EQZRhYWB3x4h4rp7uKmscPThyLELINxPuASzCTVP/C3y DU+n9FWFDUPT8SxKZhz+m5sE3ZHgBG3o+/Jq2MgX5/r1FGcyXHOWXO2lnkOGjIdPuSFV c0mexs0rxmg4fmmxiiahYBo3wmQuivcZW56a2LuGkryCRNn91pzdIS0ZJIk3uNB6I7N9 j6cWuFv4fdgRNAHhFz0xMr+kJmI7ThCUAIQG8E6ZV/PKpvGpQW+JDGyN1w7DFUkuW1uP ESfA== X-Gm-Message-State: AOUpUlGOuXbUZJJ+wtmV/+KQ+m+Lk7skUh7dWzryPPwRaMGisgkOG77e Sc7LxoBnav5vs2rfgmm+bTM5zJxx X-Received: by 2002:adf:9d46:: with SMTP id o6-v6mr32436629wre.51.1534871043980; Tue, 21 Aug 2018 10:04:03 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id v6-v6sm2608955wmc.43.2018.08.21.10.04.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 10:04:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 21 Aug 2018 19:02:29 +0200 Message-Id: <1534870966-9287-58-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534870966-9287-1-git-send-email-pbonzini@redhat.com> References: <1534870966-9287-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42f Subject: [Qemu-devel] [PULL 57/74] ipmi: Use proper struct reference for BT 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_bt was referencing into the bt structure, instead create a bt structure separate and use that. The version 1 of the BT transfer was fairly broken, if a migration occured during an IPMI operation, it is likely the migration would be corrupted because I misunderstood the VMSTATE_VBUFFER_UINT32() handling, I thought it handled transferring the length field, too. So I just remove support for that. I doubt anyone is using it at this point. This also removes the transfer of use_irq, since that should come from configuration. Signed-off-by: Corey Minyard Reviewed-by: Dr. David Alan Gilbert Message-Id: <1534798644-13587-1-git-send-email-minyard@acm.org> Signed-off-by: Paolo Bonzini --- hw/ipmi/isa_ipmi_bt.c | 68 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 13 deletions(-) -- 1.8.3.1 diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c index e946030..8bbb1fa 100644 --- a/hw/ipmi/isa_ipmi_bt.c +++ b/hw/ipmi/isa_ipmi_bt.c @@ -22,6 +22,7 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" +#include "qemu/log.h" #include "qapi/error.h" #include "hw/hw.h" #include "hw/ipmi/ipmi.h" @@ -450,22 +451,63 @@ static void isa_ipmi_bt_realize(DeviceState *dev, Error **errp) isa_register_ioport(isadev, &iib->bt.io, iib->bt.io_base); } -static const VMStateDescription vmstate_ISAIPMIBTDevice = { - .name = TYPE_IPMI_INTERFACE, +static int ipmi_bt_vmstate_post_load(void *opaque, int version) +{ + IPMIBT *ib = opaque; + + /* Make sure all the values are sane. */ + if (ib->outpos >= MAX_IPMI_MSG_SIZE || ib->outlen >= MAX_IPMI_MSG_SIZE || + ib->outpos >= ib->outlen) { + qemu_log_mask(LOG_GUEST_ERROR, + "ipmi:bt: vmstate transfer received bad out values: %d %d\n", + ib->outpos, ib->outlen); + ib->outpos = 0; + ib->outlen = 0; + } + + if (ib->inlen >= MAX_IPMI_MSG_SIZE) { + qemu_log_mask(LOG_GUEST_ERROR, + "ipmi:bt: vmstate transfer received bad in value: %d\n", + ib->inlen); + ib->inlen = 0; + } + + return 0; +} + +const VMStateDescription vmstate_IPMIBT = { + .name = TYPE_IPMI_INTERFACE_PREFIX "bt", .version_id = 1, .minimum_version_id = 1, + .post_load = ipmi_bt_vmstate_post_load, + .fields = (VMStateField[]) { + VMSTATE_BOOL(obf_irq_set, IPMIBT), + VMSTATE_BOOL(atn_irq_set, IPMIBT), + VMSTATE_BOOL(irqs_enabled, IPMIBT), + VMSTATE_UINT32(outpos, IPMIBT), + VMSTATE_UINT32(outlen, IPMIBT), + VMSTATE_UINT8_ARRAY(outmsg, IPMIBT, MAX_IPMI_MSG_SIZE), + VMSTATE_UINT32(inlen, IPMIBT), + VMSTATE_UINT8_ARRAY(inmsg, IPMIBT, MAX_IPMI_MSG_SIZE), + VMSTATE_UINT8(control_reg, IPMIBT), + VMSTATE_UINT8(mask_reg, IPMIBT), + VMSTATE_UINT8(waiting_rsp, IPMIBT), + VMSTATE_UINT8(waiting_seq, IPMIBT), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_ISAIPMIBTDevice = { + .name = TYPE_IPMI_INTERFACE_PREFIX "isa-bt", + .version_id = 2, + .minimum_version_id = 2, + /* + * Version 1 had messed up the array transfer, it's not even usable + * because it used VMSTATE_VBUFFER_UINT32, but it did not transfer + * the buffer length, so random things would happen. + */ .fields = (VMStateField[]) { - VMSTATE_BOOL(bt.obf_irq_set, ISAIPMIBTDevice), - VMSTATE_BOOL(bt.atn_irq_set, ISAIPMIBTDevice), - VMSTATE_BOOL(bt.use_irq, ISAIPMIBTDevice), - VMSTATE_BOOL(bt.irqs_enabled, ISAIPMIBTDevice), - VMSTATE_UINT32(bt.outpos, ISAIPMIBTDevice), - VMSTATE_VBUFFER_UINT32(bt.outmsg, ISAIPMIBTDevice, 1, NULL, bt.outlen), - VMSTATE_VBUFFER_UINT32(bt.inmsg, ISAIPMIBTDevice, 1, NULL, bt.inlen), - VMSTATE_UINT8(bt.control_reg, ISAIPMIBTDevice), - VMSTATE_UINT8(bt.mask_reg, ISAIPMIBTDevice), - VMSTATE_UINT8(bt.waiting_rsp, ISAIPMIBTDevice), - VMSTATE_UINT8(bt.waiting_seq, ISAIPMIBTDevice), + VMSTATE_STRUCT(bt, ISAIPMIBTDevice, 1, vmstate_IPMIBT, IPMIBT), VMSTATE_END_OF_LIST() } };