From patchwork Mon Nov 7 08:08:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Feng" X-Patchwork-Id: 9414477 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A964D6022E for ; Mon, 7 Nov 2016 08:42:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99BCC28B04 for ; Mon, 7 Nov 2016 08:42:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E89F28C78; Mon, 7 Nov 2016 08:42:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 46EF028B04 for ; Mon, 7 Nov 2016 08:42:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c3fTr-0005bu-KR; Mon, 07 Nov 2016 08:40:39 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c3fTq-0005an-3G for xen-devel@lists.xen.org; Mon, 07 Nov 2016 08:40:38 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id 52/22-01148-40E30285; Mon, 07 Nov 2016 08:40:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrLLMWRWlGSWpSXmKPExsVywNykWJfFTiH C4MwsDoslHxezODB6HN39mymAMYo1My8pvyKBNWP5Y5+Cx4IVrScaWRoYb/F1MXJyCAlUSOw6 soARxJYQ4JU4smwGK4TtJ7HmSRd7FyMXUE0fo8SRy63MIAk2AUWJgxcPgRWJCEhLXPt8mRGki FlgAaNE48WjQEUcHMIC2hJ9OwxAalgEVCW+rvwH1ssr4Cix4PNZdogFchIbdv8HW8wp4CRx78 YEVoiDHCWu/J/PPIGRdwEjwypGjeLUorLUIl0jA72kosz0jJLcxMwcXUMDM73c1OLixPTUnMS kYr3k/NxNjMBgYACCHYy/lgUcYpTkYFIS5bW0UIgQ4kvKT6nMSCzOiC8qzUktPsQow8GhJMF7 ywYoJ1iUmp5akZaZAwxLmLQEB4+SCO8TkDRvcUFibnFmOkTqFKOilDivky1QQgAkkVGaB9cGi 4VLjLJSwryMQIcI8RSkFuVmlqDKv2IU52BUEuY9DTKeJzOvBG76K6DFTECL3UJkQBaXJCKkpB oYvb69cly5IzJu2kWdlucxjvcqzqr7/W9eYrX4p0Zst766y5HVMoH1uhPvv0o2qk36c2DxjgT FvNTPz0S3XJYRMToTPsF6kqHZtO9L9u6OkVK64sm2SW1GKVtWw0QWfiOX/f995edaPddTLFeq eWjmmS+UsKTcVL2FzeVJflrfpBXWOWHXVjgqsRRnJBpqMRcVJwIAX3Pmg4ACAAA= X-Env-Sender: feng.wu@intel.com X-Msg-Ref: server-12.tower-27.messagelabs.com!1478508024!69839345!6 X-Originating-IP: [192.55.52.115] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.0.13; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33960 invoked from network); 7 Nov 2016 08:40:35 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by server-12.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 7 Nov 2016 08:40:35 -0000 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP; 07 Nov 2016 00:40:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,605,1473145200"; d="scan'208";a="28337104" Received: from unknown (HELO feng-bdw-de-pi.bj.intel.com) ([10.238.154.57]) by orsmga005.jf.intel.com with ESMTP; 07 Nov 2016 00:40:33 -0800 From: Feng Wu To: xen-devel@lists.xen.org Date: Mon, 7 Nov 2016 16:08:02 +0800 Message-Id: <1478506083-14560-6-git-send-email-feng.wu@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1478506083-14560-1-git-send-email-feng.wu@intel.com> References: <1478506083-14560-1-git-send-email-feng.wu@intel.com> Cc: kevin.tian@intel.com, Feng Wu , george.dunlap@eu.citrix.com, andrew.cooper3@citrix.com, dario.faggioli@citrix.com, jbeulich@suse.com Subject: [Xen-devel] [PATCH v7 5/6] VT-d: Some cleanups X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use type-safe structure assignment instead of memcpy() Use sizeof(*iremap_entry). Signed-off-by: Feng Wu Reviewed-by: Konrad Rzeszutek Wilk --- v7: - Remove a useless cleanup v6: - More descripion about the patch xen/drivers/passthrough/vtd/intremap.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrough/vtd/intremap.c index 3f8c109..00a4bc1 100644 --- a/xen/drivers/passthrough/vtd/intremap.c +++ b/xen/drivers/passthrough/vtd/intremap.c @@ -183,8 +183,8 @@ static void free_remap_entry(struct iommu *iommu, int index) GET_IREMAP_ENTRY(ir_ctrl->iremap_maddr, index, iremap_entries, iremap_entry); - memset(iremap_entry, 0, sizeof(struct iremap_entry)); - iommu_flush_cache_entry(iremap_entry, sizeof(struct iremap_entry)); + memset(iremap_entry, 0, sizeof(*iremap_entry)); + iommu_flush_cache_entry(iremap_entry, sizeof(*iremap_entry)); iommu_flush_iec_index(iommu, 0, index); unmap_vtd_domain_page(iremap_entries); @@ -310,7 +310,7 @@ static int ioapic_rte_to_remap_entry(struct iommu *iommu, GET_IREMAP_ENTRY(ir_ctrl->iremap_maddr, index, iremap_entries, iremap_entry); - memcpy(&new_ire, iremap_entry, sizeof(struct iremap_entry)); + new_ire = *iremap_entry; if ( rte_upper ) { @@ -353,8 +353,8 @@ static int ioapic_rte_to_remap_entry(struct iommu *iommu, remap_rte->format = 1; /* indicate remap format */ } - memcpy(iremap_entry, &new_ire, sizeof(struct iremap_entry)); - iommu_flush_cache_entry(iremap_entry, sizeof(struct iremap_entry)); + *iremap_entry = new_ire; + iommu_flush_cache_entry(iremap_entry, sizeof(*iremap_entry)); iommu_flush_iec_index(iommu, 0, index); unmap_vtd_domain_page(iremap_entries); @@ -642,8 +642,8 @@ static int msi_msg_to_remap_entry( if ( iremap_entry->val != new_ire.val ) { - memcpy(iremap_entry, &new_ire, sizeof(struct iremap_entry)); - iommu_flush_cache_entry(iremap_entry, sizeof(struct iremap_entry)); + *iremap_entry = new_ire; + iommu_flush_cache_entry(iremap_entry, sizeof(*iremap_entry)); iommu_flush_iec_index(iommu, 0, index); }