From patchwork Tue Oct 11 00:57:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Feng" X-Patchwork-Id: 9370043 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 053C160865 for ; Tue, 11 Oct 2016 01:30:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F106828CB1 for ; Tue, 11 Oct 2016 01:30:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4C5D28CB3; Tue, 11 Oct 2016 01:30:56 +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 8D75128D2F for ; Tue, 11 Oct 2016 01:30:56 +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 1btlsE-0005yp-LO; Tue, 11 Oct 2016 01:28:54 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btlsD-0005x7-BM for xen-devel@lists.xen.org; Tue, 11 Oct 2016 01:28:53 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id E8/D2-29563-4504CF75; Tue, 11 Oct 2016 01:28:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNLMWRWlGSWpSXmKPExsVywNxEWzfE4U+ 4wZbXzBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aOowdYCnaIVPQ0n2RsYHwu0MXIySEkUCnx fV0DG4gtIcArcWTZDFYI21/iRNsnFoiaeonXW7ewg9hsAooSBy8eAqsREZCWuPb5MmMXIxcHs 8ACRonGi0eZuxg5OIQFtCV+/uEDqWERUJW4d6WFGcTmFXCUOP2ojxFivpzEht3/wWxOASeJyW +nsoG0CgHVdOxnn8DIu4CRYRWjenFqUVlqka6pXlJRZnpGSW5iZo6uoYGZXm5qcXFiempOYlK xXnJ+7iZGYCAwAMEOxumX/Q8xSnIwKYnyFhn9CRfiS8pPqcxILM6ILyrNSS0+xCjDwaEkwatn D5QTLEpNT61Iy8wBhiRMWoKDR0mENx8kzVtckJhbnJkOkTrFqCglzssJkhAASWSU5sG1weLgE qOslDAvI9AhQjwFqUW5mSWo8q8YxTkYlYR5TUCm8GTmlcBNfwW0mAloMcviHyCLSxIRUlINjN OeTTj8bs6D2zF3dBjtMh36Dr7/vqhZWmyXo7D95ZKzPosiLn1fPLtx1tn/M+9O3DjDp3aFyO+ UlbELlBqYJqxeO2vRacMlh3Wam5wafpzy9JjLd+7r9KX77RcLTvma+Gau4UT1DSv2mTe+zLzi 8/zMh6mJNt8LD34WzXZK5tHoeX5p+XbTpRp3lFiKMxINtZiLihMBVVwjYX4CAAA= X-Env-Sender: feng.wu@intel.com X-Msg-Ref: server-10.tower-21.messagelabs.com!1476149320!30791318!7 X-Originating-IP: [192.55.52.43] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54703 invoked from network); 11 Oct 2016 01:28:51 -0000 Received: from mga05.intel.com (HELO mga05.intel.com) (192.55.52.43) by server-10.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 11 Oct 2016 01:28:51 -0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP; 10 Oct 2016 18:28:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,327,1473145200"; d="scan'208";a="178535737" Received: from feng-bdw-de-pi.bj.intel.com ([10.238.154.57]) by fmsmga004.fm.intel.com with ESMTP; 10 Oct 2016 18:28:50 -0700 From: Feng Wu To: xen-devel@lists.xen.org Date: Tue, 11 Oct 2016 08:57:52 +0800 Message-Id: <1476147473-30970-7-git-send-email-feng.wu@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1476147473-30970-1-git-send-email-feng.wu@intel.com> References: <1476147473-30970-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 v5 6/7] 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 --- xen/drivers/passthrough/vtd/intremap.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrough/vtd/intremap.c index 8dd0373..b6f8d3d 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); @@ -638,7 +638,8 @@ static int msi_msg_to_remap_entry( GET_IREMAP_ENTRY(ir_ctrl->iremap_maddr, index, iremap_entries, iremap_entry); - memcpy(&new_ire, iremap_entry, sizeof(struct iremap_entry)); + if ( iremap_entry->remap.p ) + new_ire.remap.im = iremap_entry->remap.im; /* Set interrupt remapping table entry */ new_ire.remap.fpd = 0; @@ -682,8 +683,8 @@ static int msi_msg_to_remap_entry( if ( !pi_can_suppress_irte_update(&new_ire, iremap_entry) ) { - 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); }