From mboxrd@z Thu Jan 1 00:00:00 1970 From: Weidong Han Subject: Re: [PATCH] Fixing ioapic write order in io_apic_write_remap_rte Date: Mon, 09 Aug 2010 16:49:27 +0800 Message-ID: <4C5FC117.2000508@intel.com> References: <1A42CE6F5F474C41B63392A5F80372B22903A75C@shsmsx501.ccr.corp.intel.com> <4C5FD7C1020000780000EC7F@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060106010307070303060709" Return-path: In-Reply-To: <4C5FD7C1020000780000EC7F@vpn.id2.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jan Beulich Cc: Xen-devel , "Jiang, Yunhong" , "Kay, Allen M" , Keir Fraser List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------060106010307070303060709 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Jan Beulich wrote: >>>> On 09.08.10 at 05:18, "Han, Weidong" wrote: >>>> >> At the end of io_apic_write_remap_rte, it writes new entry (remapped >> interrupt) to ioapic. But it writes low 32 bits before high 32 bits, it >> unmasks interrupt before writing high 32 bits if 'mask' bit in low 32 bits is >> cleared. Thus it may result in issues. This patch fixes this issue by writing >> high 32 bits before low 32 bits. >> > > While I fully agree with this change, isn't there another problem in the > error handling path in that the mask bit would not get cleared again > if the write is to the upper half of the RTE? > > Jan > > Yes, it's a problem. Good catch. Below patch should fix it. When ioapic_rte_to_remap_entry fails, currently it just writes value to ioapic. But the 'mask' bit may be changed if it writes to the upper half of RTE. This patch ensures to recover the original value of 'mask' bit in this case. Signed-off-by: Weidong Han diff -r aceb28f902ec xen/drivers/passthrough/vtd/intremap.c --- a/xen/drivers/passthrough/vtd/intremap.c Fri Aug 06 11:47:46 2010 -0400 +++ b/xen/drivers/passthrough/vtd/intremap.c Mon Aug 09 12:34:43 2010 -0400 @@ -440,6 +440,13 @@ void io_apic_write_remap_rte( { *IO_APIC_BASE(apic) = rte_upper ? (reg + 1) : reg; *(IO_APIC_BASE(apic)+4) = value; + + /* Recover the original value of 'mask' bit */ + if ( rte_upper ) + { + *IO_APIC_BASE(apic) = reg; + *(IO_APIC_BASE(apic)+4) = *(((u32 *)&old_rte)+0); + } return; } --------------060106010307070303060709 Content-Type: text/plain; name="recover-mask-bit.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="recover-mask-bit.patch" diff -r aceb28f902ec xen/drivers/passthrough/vtd/intremap.c --- a/xen/drivers/passthrough/vtd/intremap.c Fri Aug 06 11:47:46 2010 -0400 +++ b/xen/drivers/passthrough/vtd/intremap.c Mon Aug 09 12:34:43 2010 -0400 @@ -440,6 +440,13 @@ void io_apic_write_remap_rte( { *IO_APIC_BASE(apic) = rte_upper ? (reg + 1) : reg; *(IO_APIC_BASE(apic)+4) = value; + + /* Recover the original value of 'mask' bit */ + if ( rte_upper ) + { + *IO_APIC_BASE(apic) = reg; + *(IO_APIC_BASE(apic)+4) = *(((u32 *)&old_rte)+0); + } return; } --------------060106010307070303060709 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------060106010307070303060709--