From nobody Thu May 2 20:50:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500193832532776.9681406594449; Sun, 16 Jul 2017 01:30:32 -0700 (PDT) Received: from localhost ([::1]:44479 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWewd-000078-Ss for importer@patchew.org; Sun, 16 Jul 2017 04:30:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWevh-000897-L4 for qemu-devel@nongnu.org; Sun, 16 Jul 2017 04:29:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dWeve-0008Mj-Fc for qemu-devel@nongnu.org; Sun, 16 Jul 2017 04:29:29 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:35072) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dWeve-0008LC-7K for qemu-devel@nongnu.org; Sun, 16 Jul 2017 04:29:26 -0400 Received: by mail-wm0-x244.google.com with SMTP id u23so17828634wma.2 for ; Sun, 16 Jul 2017 01:29:24 -0700 (PDT) Received: from bark.daynix ([141.226.163.173]) by smtp.gmail.com with ESMTPSA id n189sm7397426wmd.0.2017.07.16.01.29.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Jul 2017 01:29:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=xDq2F7j/X8s9+PEAiTrhUgxQvBzALi1zpYCgUA1MB+8=; b=1jDtSvglNR6BpFbbtw4P69Jtsh1olE4fqV+srcFFbGD0DWsGKEfU5IeX15oDAD0eXI j53VYEeAoPQ/B58NTQ31SV1NzHNv22K+taAbugOrCU9v9BM1RONrgRT6WkO65/oLmIfK smb33SUH+yPwR1qfUOb5sGKCAkl7LmVTpvxR0EAQAA/0hZrjs++EfDvyCsV61kPAeQAm Cs0QFfhjIYpYkBoKSUIozs6HT+8KRXK9pSSH8Se6OffNQkJT4dsNvp6QZcyaFDlq+VZf w5Ee3osK5ocpWpm4+WPJBk/aJXFWkaBvAoxL0ejYT/p4rUFBkdrdeNt231zfBvfpslI2 +IEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xDq2F7j/X8s9+PEAiTrhUgxQvBzALi1zpYCgUA1MB+8=; b=g6KnV6Xw7USneq4C1008JhFPi8qwiPqGApO0V74RJkLcxt/+E/XWu+cHHBP8MB3hSu KJG+CNBnChsYEn7LD9DUxodaVcS6FBXkBY4dPo4WPVCEv8gB5ys1aIYYhc1l/ZPAjPb5 i3Q3uJBAgQu0Y6Ta0YoPI/RXk20YzyW4S27ypsQF2JXKHG2eSoEB39UPOIefizutppBc 6RyP8t/28eCYWy+bF3URcyYoJGdeXl0vyXoGac+iPuaLdstUGMqwkfivIkZN0dgP8I7a TAmqTHz85A8apfEJNPHCBcIS94mURwld5hnkHw9TlmhzzvWR9PwUqZBVf+U8DI3/0JgM FsPA== X-Gm-Message-State: AIVw113jbLBp0nkzBQhtAFODaInvbOt19QuLeAF8yWhwzQ1JSsXFHIQg v8SW4joWTBDlFv+WtAE= X-Received: by 10.28.180.70 with SMTP id d67mr927444wmf.121.1500193763309; Sun, 16 Jul 2017 01:29:23 -0700 (PDT) From: Dmitry Fleytman To: qemu-devel@nongnu.org Date: Sun, 16 Jul 2017 11:29:17 +0300 Message-Id: <20170716082917.720-1-dmitry@daynix.com> X-Mailer: git-send-email 2.9.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PATCH] pci: honor PCI_COMMAND_MEMORY 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: Marcel Apfelbaum , Sameeh Jubran , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" According to PCI spec. bit 1 of command register (PCI_COMMAND_MEMORY) controls a device's response to memory space accesses. A value of 0 disables the device response. A value of 1 allows the device to respond to memory space accesses. Current behavior introduced by commit commit 1c380f9460522f32c8dd2577b2a53d518ec91c6d Author: Avi Kivity Date: Wed Oct 3 17:42:58 2012 +0200 pci: honor PCI_COMMAND_MASTER is to ignore device memory space accesses unless bit 2 (PCI_COMMAND_MASTER) is set. Aforementioned commit introduced regression of Windows hibernation (S4) functionality support because on resume Windows kernel sets bits 0 and 1 (PCI_COMMAND_MEMORY | PCI_COMMAND_IO) of boot device's (piix3-ide in our specific case) command register and tries to work with the device. Since PCI_COMMAND_MASTER bit is not set, device does not answer and Windows fails to resume from hibernation. As a result following BSOD happens: BugCheck A0, {10e, a, aa00, 418} Probably caused by : ntkrnlmp.exe ( nt!PopHiberChecksumHiberFileData+b346= ) Followup: MachineOwner --------- 0: kd> !analyze -v *************************************************************************= ****** * = * * Bugcheck Analysis = * * = * *************************************************************************= ****** INTERNAL_POWER_ERROR (a0) The power policy manager experienced a fatal error. Arguments: Arg1: 000000000000010e, The disk subsystem returned corrupt data while re= ading from the hibernation file. Arg2: 000000000000000a Arg3: 000000000000aa00, Incorrect checksum Arg4: 0000000000000418, Previous disk read's checksum According to our tests this problem happens at least on Windows 8/8.1/2012/2012R2/10/2016. This patch solves https://bugzilla.redhat.com/show_bug.cgi?id=3D988351 Signed-off-by: Dmitry Fleytman --- hw/pci/pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 0c6f74a..10af82f 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -480,7 +480,7 @@ static int get_pci_config_device(QEMUFile *f, void *pv,= size_t size, =20 memory_region_set_enabled(&s->bus_master_enable_region, pci_get_word(s->config + PCI_COMMAND) - & PCI_COMMAND_MASTER); + & (PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY)); =20 g_free(config); return 0; @@ -1356,7 +1356,7 @@ void pci_default_write_config(PCIDevice *d, uint32_t = addr, uint32_t val_in, int pci_update_irq_disabled(d, was_irq_disabled); memory_region_set_enabled(&d->bus_master_enable_region, pci_get_word(d->config + PCI_COMMAND) - & PCI_COMMAND_MASTER); + & (PCI_COMMAND_MASTER | PCI_COMMAND_MEMO= RY)); } =20 msi_write_config(d, addr, val_in, l); --=20 2.9.4