xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Weidong Han <weidong.han@intel.com>
To: Jan Beulich <JBeulich@novell.com>
Cc: Xen-devel <xen-devel@lists.xensource.com>,
	"Jiang, Yunhong" <yunhong.jiang@intel.com>,
	"Kay, Allen M" <allen.m.kay@intel.com>,
	Keir Fraser <keir.fraser@eu.citrix.com>
Subject: Re: [PATCH] Fixing ioapic write order in	 io_apic_write_remap_rte
Date: Mon, 09 Aug 2010 16:49:27 +0800	[thread overview]
Message-ID: <4C5FC117.2000508@intel.com> (raw)
In-Reply-To: <4C5FD7C1020000780000EC7F@vpn.id2.novell.com>

[-- Attachment #1: Type: text/plain, Size: 1637 bytes --]

Jan Beulich wrote:
>>>> On 09.08.10 at 05:18, "Han, Weidong" <weidong.han@intel.com> 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 <weidong.han@intel.com>

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;
     }
 

[-- Attachment #2: recover-mask-bit.patch --]
[-- Type: text/plain, Size: 607 bytes --]

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;
     }
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

      reply	other threads:[~2010-08-09  8:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-09  3:18 [PATCH] Fixing ioapic write order in io_apic_write_remap_rte Han, Weidong
2010-08-09  8:26 ` Jan Beulich
2010-08-09  8:49   ` Weidong Han [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C5FC117.2000508@intel.com \
    --to=weidong.han@intel.com \
    --cc=JBeulich@novell.com \
    --cc=allen.m.kay@intel.com \
    --cc=keir.fraser@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    --cc=yunhong.jiang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).