From: Chao Gao <chao.gao@intel.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Kevin Tian <kevin.tian@intel.com>,
George Dunlap <George.Dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Dario Faggioli <dario.faggioli@citrix.com>,
xen-devel@lists.xen.org, Jun Nakajima <jun.nakajima@intel.com>
Subject: Re: [PATCH v10 4/6] VT-d: introduce update_irte to update irte safely
Date: Fri, 17 Mar 2017 09:52:36 +0800 [thread overview]
Message-ID: <20170317015236.GA31295@skl-2s3.sh.intel.com> (raw)
In-Reply-To: <58CA77190200007800143ABB@prv-mh.provo.novell.com>
On Thu, Mar 16, 2017 at 04:29:29AM -0600, Jan Beulich wrote:
>>>> On 15.03.17 at 23:39, <chao.gao@intel.com> wrote:
>> On Wed, Mar 15, 2017 at 10:48:25AM -0600, Jan Beulich wrote:
>>>>>> On 15.03.17 at 06:11, <chao.gao@intel.com> wrote:
>>>> + /*
>>>> + * The following method to update IRTE is safe on condition that
>>>> + * only the high qword or the low qword is to be updated.
>>>> + * If entire IRTE is to be updated, callers should make sure the
>>>> + * IRTE is not in use.
>>>> + */
>>>> + entry->lo = new_ire->lo;
>>>> + entry->hi = new_ire->hi;
>>>
>>>How is this any better than structure assignment? Furthermore
>>
>> Indeed, not better. when using structure assignment, the assembly code is
>> 48 8b 06 mov (%rsi),%rax
>> 48 8b 56 08 mov 0x8(%rsi),%rdx
>> 48 89 07 mov %rax,(%rdi)
>> 48 89 57 08 mov %rdx,0x8(%rdi)
>> Using the code above, the assembly code is
>> 48 8b 06 mov (%rsi),%rax
>> 48 89 07 mov %rax,(%rdi)
>> 48 8b 46 08 mov 0x8(%rsi),%rax
>> 48 89 47 08 mov %rax,0x8(%rdi)
>>
>> I thought structure assignment maybe ultilize memcpy considering structure
>> of a big size, so I made this change. I will change this back. Although
>> that, this patch is trying to make the change safer when cmpxchg16() is
>> supported.
>
>Perhaps you've really meant to use write_atomic()?
I don't understand what you mean. But I think write_atomic may be not related
to the problem how to update a 16 byte memory atomically if cmpxchg16() is not
supported.
>
>>>the comment here partially contradicts the commit message. I
>>
>> Yes.
>>
>>>guess callers need to be given a way (another function parameter?)
>>>to signal the function whether the unsafe variant is okay to use.
>>
>> This means we need to add the new parameter to iommu ops for only
>> IOAPIC/MSI know the entry they want to change is masked. Is there
>> any another reasonable and correct solution?
>
>Well, users you convert in this patch must be okay to use the
>non-atomic variant. The PI user(s) know(s) that cmpxchg16b is
>available, so could always request the safe variant. No need for
>a new parameter higher up in the call trees afaics.
>
>> How about...
>>
>>>You should then add a suitable BUG_ON() in the else path here.
>>
>> just add a BUG_ON() like this
>> BUG_ON( (entry->hi != new_ire->hi) && (entry->lo != new_ire->lo) );
>> Adding this BUG_ON() means update_irte() can't be used for initializing
>> or clearing IRTE which are not bugs.
>
>Yes, that's an option too, albeit then I'd suggest (pseudo code)
>
> if ( high_up_to_date )
> update_low;
> else if ( low_up_to_date )
> update_high;
> else
> BUG();
>
>But you'll want to have the okay from Kevin as the maintainer for
>something like this.
ok. I will wait for comments of Kevin.
Thank,
Chao
>
>Jan
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-03-17 1:52 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-15 5:11 [PATCH v10 0/6] VMX: Properly handle pi descriptor and per-cpu blocking list Chao Gao
2017-03-15 5:11 ` [PATCH v10 1/6] VT-d: Introduce new fields in msi_desc to track binding with guest interrupt Chao Gao
2017-03-15 16:41 ` Jan Beulich
2017-03-15 21:21 ` Chao Gao
2017-03-16 10:24 ` Jan Beulich
2017-03-22 5:59 ` Tian, Kevin
2017-03-22 0:18 ` Chao Gao
2017-03-22 8:32 ` Tian, Kevin
2017-03-15 5:11 ` [PATCH v10 2/6] VT-d: Some cleanups Chao Gao
2017-03-15 5:11 ` [PATCH v10 3/6] VMX: Fixup PI descriptor when cpu is offline Chao Gao
2017-03-15 5:11 ` [PATCH v10 4/6] VT-d: introduce update_irte to update irte safely Chao Gao
2017-03-15 16:48 ` Jan Beulich
2017-03-15 22:39 ` Chao Gao
2017-03-16 10:29 ` Jan Beulich
2017-03-17 1:52 ` Chao Gao [this message]
2017-03-17 9:08 ` Jan Beulich
2017-03-22 6:26 ` Tian, Kevin
2017-03-24 8:44 ` Tian, Kevin
2017-03-15 5:11 ` [PATCH v10 5/6] passthrough/io: don't migrate pirq when it is delivered through VT-d PI Chao Gao
2017-03-17 10:43 ` Jan Beulich
2017-03-20 1:59 ` Chao Gao
2017-03-20 9:18 ` Jan Beulich
2017-03-20 2:38 ` Chao Gao
2017-03-20 10:26 ` Jan Beulich
2017-03-20 5:22 ` Chao Gao
2017-03-20 12:50 ` Jan Beulich
2017-03-20 6:11 ` Chao Gao
2017-03-15 5:11 ` [PATCH v10 6/6] passthrough/io: Fall back to remapping interrupt when we can't use " Chao Gao
2017-03-17 10:48 ` Jan Beulich
2017-03-22 6:34 ` Tian, Kevin
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=20170317015236.GA31295@skl-2s3.sh.intel.com \
--to=chao.gao@intel.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=dario.faggioli@citrix.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=xen-devel@lists.xen.org \
/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).