From: "Jan Beulich" Subject: Re: [RFC v1 07/15] vt-d: Add API to update IRTE when VT-d PI is used Date: Fri, 27 Mar 2015 10:02:17 +0000 Message-ID: <551538B9020000780006E6B3@mail.emea.novell.com> References: <1427286717-4093-1-git-send-email-feng.wu@intel.com> <1427286717-4093-8-git-send-email-feng.wu@intel.com> <55145B46.2020907@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Feng Wu Cc: Yang Z Zhang , Andrew Cooper , Kevin Tian , "keir@xen.org" , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org >>> On 27.03.15 at 03:13, wrote: >> From: Andrew Cooper [mailto:andrew.cooper3@citrix.com] >> Sent: Friday, March 27, 2015 3:17 AM >> On 25/03/15 12:31, Feng Wu wrote: >> > + >> > + new_ire.lo_intpost.res_1 = 0; >> > + new_ire.lo_intpost.res_2 = 0; >> > + new_ire.lo_intpost.res_3 = 0; >> > + new_ire.hi_intpost.res_1 = 0; >> > + >> > + new_ire.lo_intpost.im = 1; >> > + >> > + memcpy(p, &new_ire, sizeof(struct iremap_entry)); >> > + iommu_flush_cache_entry(p, sizeof(struct iremap_entry)); >> >> Same here regarding sizeof. >> >> Furthermore, is the memcpy() safe to update the live descriptor? >> >> If it is, why do you not update the descriptor in place using p-> rather >> than copying it to the stack and back? > > There are some example in the current code of updating IRTE, such as > in ioapic_rte_to_remap_entry(), I try to follow it here. Doing things the same way as existing code does should always be done with spending some extra thought on "is the original code correct" and "does my use case have the same constraints as the original one". Blindly copying code means blindly spreading mistakes. Jan