From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH v2] kvm: Disable MSI/MSI-X in assigned device reset path Date: Mon, 16 Apr 2012 21:55:07 -0300 Message-ID: <20120417005507.GE3987@amt.cnet> References: <20120405033450.25661.68810.stgit@bling.home> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, jan.kiszka@siemens.com, mst@redhat.com, jbaron@redhat.com To: Alex Williamson Return-path: Received: from mx1.redhat.com ([209.132.183.28]:49855 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753353Ab2DQDFz (ORCPT ); Mon, 16 Apr 2012 23:05:55 -0400 Content-Disposition: inline In-Reply-To: <20120405033450.25661.68810.stgit@bling.home> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Apr 04, 2012 at 09:42:32PM -0600, Alex Williamson wrote: > We've hit a kernel host panic, when issuing a 'system_reset' with an > 82576 nic assigned and a Windows guest. Host system is a PowerEdge R815. > > [Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 32993 > [Hardware Error]: APEI generic hardware error status > [Hardware Error]: severity: 1, fatal > [Hardware Error]: section: 0, severity: 1, fatal > [Hardware Error]: flags: 0x01 > [Hardware Error]: primary > [Hardware Error]: section_type: PCIe error > [Hardware Error]: port_type: 0, PCIe end point > [Hardware Error]: version: 1.0 > [Hardware Error]: command: 0x0000, status: 0x0010 > [Hardware Error]: device_id: 0000:08:00.0 > [Hardware Error]: slot: 1 > [Hardware Error]: secondary_bus: 0x00 > [Hardware Error]: vendor_id: 0x8086, device_id: 0x10c9 > [Hardware Error]: class_code: 000002 > [Hardware Error]: aer_status: 0x00100000, aer_mask: 0x00018000 > [Hardware Error]: Unsupported Request > [Hardware Error]: aer_layer=Transaction Layer, aer_agent=Requester ID > [Hardware Error]: aer_uncor_severity: 0x00067011 > [Hardware Error]: aer_tlp_header: 40001001 0020000f edbf800c 01000000 > [Hardware Error]: section: 1, severity: 1, fatal > [Hardware Error]: flags: 0x01 > [Hardware Error]: primary > [Hardware Error]: section_type: PCIe error > [Hardware Error]: port_type: 0, PCIe end point > [Hardware Error]: version: 1.0 > [Hardware Error]: command: 0x0000, status: 0x0010 > [Hardware Error]: device_id: 0000:08:00.0 > [Hardware Error]: slot: 1 > [Hardware Error]: secondary_bus: 0x00 > [Hardware Error]: vendor_id: 0x8086, device_id: 0x10c9 > [Hardware Error]: class_code: 000002 > [Hardware Error]: aer_status: 0x00100000, aer_mask: 0x00018000 > [Hardware Error]: Unsupported Request > [Hardware Error]: aer_layer=Transaction Layer, aer_agent=Requester ID > [Hardware Error]: aer_uncor_severity: 0x00067011 > [Hardware Error]: aer_tlp_header: 40001001 0020000f edbf800c 01000000 > Kernel panic - not syncing: Fatal hardware error! > Pid: 0, comm: swapper Not tainted 2.6.32-242.el6.x86_64 #1 > Call Trace: > [] ? panic+0xa0/0x168 > [] ? ghes_notify_nmi+0x17c/0x180 > [] ? notifier_call_chain+0x55/0x80 > [] ? atomic_notifier_call_chain+0x1a/0x20 > [] ? notify_die+0x2e/0x30 > [] ? do_nmi+0x1a1/0x2b0 > [] ? nmi+0x20/0x30 > [] ? native_safe_halt+0xb/0x10 > <> [] ? default_idle+0x4d/0xb0 > [] ? cpu_idle+0xb6/0x110 > [] ? rest_init+0x7a/0x80 > [] ? start_kernel+0x424/0x430 > [] ? x86_64_start_reservations+0x125/0x129 > [] ? x86_64_start_kernel+0xfa/0x109 > > The root cause of the problem is that the 'reset_assigned_device()' code > first writes a 0 to the command register. Then, when qemu subsequently does > a kvm_deassign_irq() (called by assign_irq(), in the system_reset path), > the kernel ends up calling '__msix_mask_irq()', which performs a write to > the memory mapped msi vector space. Since, we've explicitly told the device > to disallow mmio access (via the 0 write to the command register), we end > up with the above 'Unsupported Request'. > > The fix here is to first disable MSI-X, before doing the reset. We also > disable MSI, leaving the device in INTx mode. In this way, the device is > a known state after reset, and we avoid touching msi memory mapped space > on any subsequent 'kvm_deassign_irq()'. > > Thanks to Michael S. Tsirkin for help in understanding what was going on > here and Jason Baron, the original debugger of this problem. > > Signed-off-by: Alex Williamson Applied, thanks.