From patchwork Wed Mar 15 05:11:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Gao X-Patchwork-Id: 9625477 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 8A1DC60424 for ; Wed, 15 Mar 2017 12:16:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 801B72860B for ; Wed, 15 Mar 2017 12:16:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73A8F28616; Wed, 15 Mar 2017 12:16:28 +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.5 required=2.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIM_SIGNED, RCVD_IN_DNSWL_MED, 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 A566A2860B for ; Wed, 15 Mar 2017 12:16:26 +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 1co7oT-00049y-TR; Wed, 15 Mar 2017 12:13:57 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1co7oS-00049q-M3 for xen-devel@lists.xen.org; Wed, 15 Mar 2017 12:13:56 +0000 Received: from [85.158.139.211] by server-4.bemta-5.messagelabs.com id C5/2A-13971-30039C85; Wed, 15 Mar 2017 12:13:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRWlGSWpSXmKPExsXS1tbhqMtscDL C4NtuUYslHxezODB6HN39mymAMYo1My8pvyKBNWN5+xzWgt0iFZO7r7A3MM4S7GLk5GARuMUk 8XObQRcjF4eQwDRGieaOBSwgCQkBXokjy2awQtgBEheutTCD2EIC5RKzL60Hs9kElCUufu1lA 7FFBKQlrn2+zAgyiFngKZNE06NOsISwgI7E1JmTWSG2qUr8absAtoBXwFFi3qb7zBALFCSmPH wPZHNwcAo4SWx4Wwexy1Fi194ZrBMY+RYwMqxiVC9OLSpLLdI11EsqykzPKMlNzMzRNTQw1ct NLS5OTE/NSUwq1kvOz93ECAySegYGxh2MTb3OhxglOZiURHlVBE9ECPEl5adUZiQWZ8QXleak Fh9ilOHgUJLgfXoIKCdYlJqeWpGWmQMMV5i0BAePkghvEUiat7ggMbc4Mx0idYpRUUqcNwskI QCSyCjNg2uDxcglRlkpYV5GBgYGIZ6C1KLczBJU+VeM4hyMSsK81SBTeDLzSuCmvwJazAS0OP HnEZDFJYkIKakGxpAKw7XvT/cU3Lr1sO9TkfLq1E8unILJFRHZRxR2/v3BpvEs44ziEnX+hmN q25WURf7NXzZh1TorqQbvVP6p7dYT8oUcPu/Pe2uw7eZ7tSXnFeuunrhyWT70P+e67MfRcbd+ TVu5/VDLb+bqLo/OBJ/Ow0W5dTr2SU/VeJqDKqc75s+3KOdKUWIpzkg01GIuKk4EAJJvJKeMA gAA X-Env-Sender: chao.gao@intel.com X-Msg-Ref: server-13.tower-206.messagelabs.com!1489580028!74059212!3 X-Originating-IP: [134.134.136.65] X-SpamReason: No, hits=0.8 required=7.0 tests=DATE_IN_PAST_06_12 X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13603 invoked from network); 15 Mar 2017 12:13:55 -0000 Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by server-13.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 15 Mar 2017 12:13:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489580035; x=1521116035; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=enoIe2ntj8B8LXiBMdHNvPlnJ6/biY5wEZ+FRdSjat0=; b=okSW9gCKKN4IMC21ovPvHw2O6l5f1A5r+LAuv/EUyokWlh64KxbjL5F/ +e2yVY3DY6SF2rJqd71DgMErBLAHRg==; Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Mar 2017 05:13:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.36,168,1486454400"; d="scan'208"; a="1108706719" Received: from skl-2s3.sh.intel.com ([10.239.48.35]) by orsmga001.jf.intel.com with ESMTP; 15 Mar 2017 05:13:52 -0700 From: Chao Gao To: xen-devel@lists.xen.org Date: Wed, 15 Mar 2017 13:11:18 +0800 Message-Id: <1489554682-6126-3-git-send-email-chao.gao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1489554682-6126-1-git-send-email-chao.gao@intel.com> References: <1489554682-6126-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 v10 2/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 6202ece..7d4c7e1 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); @@ -640,8 +640,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);