From patchwork Wed Mar 29 05:11:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Gao X-Patchwork-Id: 9651457 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 8CBCA60350 for ; Wed, 29 Mar 2017 12:17:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B6F527C0B for ; Wed, 29 Mar 2017 12:17:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 701D228354; Wed, 29 Mar 2017 12:17:05 +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=-2.0 required=2.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIM_SIGNED, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 3EB0A27C0B for ; Wed, 29 Mar 2017 12:17:04 +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 1ctCUq-0003yc-2J; Wed, 29 Mar 2017 12:14:40 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctCUp-0003y0-8P for xen-devel@lists.xen.org; Wed, 29 Mar 2017 12:14:39 +0000 Received: from [193.109.254.147] by server-6.bemta-6.messagelabs.com id E1/05-03430-E25ABD85; Wed, 29 Mar 2017 12:14:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDLMWRWlGSWpSXmKPExsVywNwkQldv6e0 Ig31zWSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oyjR7tZC3aLVFz4/4exgXGWYBcjFweLwC0m iedbN7GBOEIC0xglfuw9xdzFyMkhIcArcWTZDFYI209izvGnTCC2kEC5xJyrs8HibALKEhe/9 rKB2CIC0hLXPl9mBBnELPCUSaLpUSdYQlhAR6Jj3Q8wm0VAVaJlzTR2EJtXwFFi8r7v7BALFC SmPHwPtphTwEni/K4zzBDLHCXWrXjIMoGRbwEjwypGjeLUorLUIl0jC72kosz0jJLcxMwcXUM DM73c1OLixPTUnMSkYr3k/NxNjMBQYQCCHYzn1wYeYpTkYFIS5T1heDtCiC8pP6UyI7E4I76o NCe1+BCjDAeHkgSvyhKgnGBRanpqRVpmDjBoYdISHDxKIrwWi4HSvMUFibnFmekQqVOMilLiv L9BEgIgiYzSPLg2WKRcYpSVEuZlBDpEiKcgtSg3swRV/hWjOAejkjDvX5ApPJl5JXDTXwEtZg JaLG5zC2RxSSJCSqqB0ebAmUu3LadKbVPfm3LkNPNq24fJ1v/rNFZ4iXSaMax/K8M851KKeM4 RmT27rnxdLv+rQyJobvl+R9YJsT+Ws2/SeV6QVu5UeuW1hMLLHeH/3SrkHOU7CiepdT3a11NQ mJp0PO2W5tGjD3+pblg4qXxzy33fmXVhPnK3ZkW9mbf90YbfTR5//iixFGckGmoxFxUnAgBFT 5jfjwIAAA== X-Env-Sender: chao.gao@intel.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1490789671!94414712!4 X-Originating-IP: [192.55.52.88] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTkyLjU1LjUyLjg4ID0+IDM3NDcyNQ==\n X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 20485 invoked from network); 29 Mar 2017 12:14:37 -0000 Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by server-9.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 29 Mar 2017 12:14:37 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490789677; x=1522325677; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=QC19GIJ1G0U2/e7BHEHXgsVICA8BgUJfbR+MmnMCLUU=; b=x/bbWfA1QpqAEIQtzETOJHC0TMsJ8fvGAnjLzEutHz48ha/TideTS2ei j+Mo8qD5BjqB2Jl4f091DzH0E2ypJQ==; Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Mar 2017 05:14:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,241,1486454400"; d="scan'208";a="80557032" Received: from skl-2s3.sh.intel.com ([10.239.48.35]) by orsmga005.jf.intel.com with ESMTP; 29 Mar 2017 05:14:35 -0700 From: Chao Gao To: xen-devel@lists.xen.org Date: Wed, 29 Mar 2017 13:11:52 +0800 Message-Id: <1490764315-7162-4-git-send-email-chao.gao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1490764315-7162-1-git-send-email-chao.gao@intel.com> References: <1490764315-7162-1-git-send-email-chao.gao@intel.com> Cc: Kevin Tian , Feng Wu , Jun Nakajima , George Dunlap , Andrew Cooper , Dario Faggioli , Jan Beulich , Chao Gao Subject: [Xen-devel] [PATCH v11 3/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 From: Feng Wu Use type-safe structure assignment instead of memcpy() Use sizeof(*iremap_entry). Signed-off-by: Feng Wu Signed-off-by: Chao Gao Reviewed-by: Konrad Rzeszutek Wilk Acked-by: Kevin Tian --- v10: - Added several lines for patch [1/6] has been reworked. v9: - Delete several lines for patch [5/8] has been reworked. 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 9bbf0f6..b992f23 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); @@ -639,8 +639,8 @@ static int msi_msg_to_remap_entry( remap_rte->address_hi = 0; remap_rte->data = index - i; - 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);