From patchwork Thu Apr 6 00:30:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Gao X-Patchwork-Id: 9666235 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 90C9F60364 for ; Thu, 6 Apr 2017 07:35:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 815E226530 for ; Thu, 6 Apr 2017 07:35:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7585327F9F; Thu, 6 Apr 2017 07:35:27 +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 F08EB26530 for ; Thu, 6 Apr 2017 07:35: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 1cw1uw-0003ZS-U4; Thu, 06 Apr 2017 07:33:18 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cw1uv-0003Xw-Hq for xen-devel@lists.xen.org; Thu, 06 Apr 2017 07:33:17 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id 86/19-03420-C3FE5E85; Thu, 06 Apr 2017 07:33:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRWlGSWpSXmKPExsXS1tYhomvz/mm EwaVZKhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8a9mRuZCnaLVPz6tY6lgXGWYBcjFweLwC0m ib6f21lBHCGB6YwSG+7+Z+9i5OSQEOCVOLJsBiuEHSBxYvZFZhBbSKBcovnzXDCbTUBZ4uLXX jYQW0RAWuLa58uMIIOYBZ4ySTQ96gRLCAvoSKz6s4gFxGYRUJV497SHEcTmFXCSONe4mA1igY LElIfvgYZycHAKOEvcepMNsctJYsPDj2wTGPkWMDKsYlQvTi0qSy3SNdRLKspMzyjJTczM0TU 0MNPLTS0uTkxPzUlMKtZLzs/dxAgMEwYg2MG487nTIUZJDiYlUV4FnycRQnxJ+SmVGYnFGfFF pTmpxYcYZTg4lCR4md49jRASLEpNT61Iy8wBBixMWoKDR0mENx8kzVtckJhbnJkOkTrFqCglz isJkhAASWSU5sG1waLkEqOslDAvI9AhQjwFqUW5mSWo8q8YxTkYlYR5y0Gm8GTmlcBNfwW0mA losc8tsMUliQgpqQZG7ncqtjc76y6XJsRN8eRIOzBV4NTjmX+sBJdsPGtkJ3HvoqUMM1eF+ZF YP7nm7gc2OcF108LEV1xbbfTUqTTrvdy3DVtbXuwt0I7J3vNpx+3aLUZeDCXueys9pwbN6+Cs Er/bGn2me5vF5sTny62nF879O1tA/p65QF7vm2KPhYVJk3evNLisxFKckWioxVxUnAgAbZzHK o0CAAA= X-Env-Sender: chao.gao@intel.com X-Msg-Ref: server-2.tower-21.messagelabs.com!1491463986!48563541!5 X-Originating-IP: [134.134.136.20] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjAgPT4gMzU1MzU4\n X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9503 invoked from network); 6 Apr 2017 07:33:16 -0000 Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by server-2.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 6 Apr 2017 07:33:16 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491463996; x=1522999996; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=NaJ0A2iIm2J92wYr4a0A0G0e29jVKY7VT6tuoHcI5Rc=; b=uBXZkUoZL/Z7+QyUkZnAGviDfLCSVonBBWQobAOtBJmipN9jMe2IzfL8 XyGkSoKsS4T/NzuUnCcG7um4eb8BwQ==; Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Apr 2017 00:33:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.37,283,1488873600"; d="scan'208"; a="1151803806" Received: from skl-2s3.sh.intel.com ([10.239.48.35]) by fmsmga002.fm.intel.com with ESMTP; 06 Apr 2017 00:33:13 -0700 From: Chao Gao To: xen-devel@lists.xen.org Date: Thu, 6 Apr 2017 08:30:24 +0800 Message-Id: <1491438627-10456-5-git-send-email-chao.gao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1491438627-10456-1-git-send-email-chao.gao@intel.com> References: <1491438627-10456-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 v12 4/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 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 6314cbf..a18717b 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);