Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1156722imm; Thu, 6 Sep 2018 16:49:26 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYC0cNKqj80CQF68mFtQHiUd5Za1hl/ZtLZpCY+sXvoKHz8insh0t76nclLjw4SPyTs0UvP X-Received: by 2002:a63:ac54:: with SMTP id z20-v6mr5233260pgn.74.1536277766114; Thu, 06 Sep 2018 16:49:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536277766; cv=none; d=google.com; s=arc-20160816; b=fUGGbuNNp7l7+AqnR2w3hdoPJxg9KlZJrzhEB69re5kifMei9UpeCamGzKTnlrVt1f liCax6PU8EAXV+MwUc9OsG4DnxqxPwJ8NIEX25g28mTz8OR0mmOpHjbHSfBc2539pWe9 uJExC/ClgYcuI557+TPUPSU5NPM/wqmo1GUmoXQ7lKeO7t97w7JSwZjYMluSxvGYPcZu +PDZ4MJGvWhH8gz51t7hcRSQgU0xmiLmROx5fDri4n1Jgc+Fp3pxfi9RZyUjAzPyd5V5 Jb5HobU+hz/sLOVhGuxymrlBWKvE8jwWpZkvanGj/TH8GWE3/8V6LHnkw0zk22SHc5UF eYpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=EzPG2dLaxOsSZt29FE/TdVGE2oFQImR1XRbKlyV+TMo=; b=wr4pmNVfl/PAXRqBR5OSomdNQh5s5rhvuRC8z+dHzY/51qegg61ew5Sx7zOH1dvQf5 mlB7cEae08rDO+rx717KE+fjIniSUoNjERBKV9RYo9MsijyySmCnhpDeVeBTfKWHTSGw S7nFDhuAxeVeDDZ8DmAfDRn6UlZNb29rU5fUS1oxwwnlRLzh+cYd6cpP6SjVD52MnEIj oOAdv32JU+N54lXX+6iXAineZnoleJXxbdYnGmszOoPOwh97JPvLeX0ev8e67NwBVSP8 k1sXZF7MTIxe5xNj+IjjU4ebnMH/InDntNHCT3l9Ho9DXGYkwZOW/k2lcxe/2k3HrYd+ yVZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y15-v6si6591592pff.117.2018.09.06.16.49.10; Thu, 06 Sep 2018 16:49:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727686AbeIGETN (ORCPT + 99 others); Fri, 7 Sep 2018 00:19:13 -0400 Received: from mga18.intel.com ([134.134.136.126]:8981 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725926AbeIGETN (ORCPT ); Fri, 7 Sep 2018 00:19:13 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Sep 2018 16:41:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,340,1531810800"; d="scan'208";a="89648597" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by orsmga002.jf.intel.com with ESMTP; 06 Sep 2018 16:41:17 -0700 Date: Thu, 6 Sep 2018 16:43:17 -0700 From: Jacob Pan To: Lu Baolu Cc: "Tian, Kevin" , Joerg Roedel , David Woodhouse , "Raj, Ashok" , "Kumar, Sanjay K" , "Liu, Yi L" , "Sun, Yi Y" , "peterx@redhat.com" , Jean-Philippe Brucker , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , Jacob Pan , jacob.jun.pan@intel.com Subject: Re: [PATCH v2 02/12] iommu/vt-d: Manage scalalble mode PASID tables Message-ID: <20180906164317.786bbdda@jacob-builder> In-Reply-To: <44298d5c-5720-a382-07d1-a90a072ff24b@linux.intel.com> References: <20180830013524.28743-1-baolu.lu@linux.intel.com> <20180830013524.28743-3-baolu.lu@linux.intel.com> <44298d5c-5720-a382-07d1-a90a072ff24b@linux.intel.com> Organization: OTC X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 6 Sep 2018 10:46:03 +0800 Lu Baolu wrote: > >> @@ -224,7 +271,14 @@ struct pasid_entry > >> *intel_pasid_get_entry(struct device *dev, int pasid) > >> */ > >> static inline void pasid_clear_entry(struct pasid_entry *pe) > >> { > >> - WRITE_ONCE(pe->val, 0); > >> + WRITE_ONCE(pe->val[0], 0); > >> + WRITE_ONCE(pe->val[1], 0); > >> + WRITE_ONCE(pe->val[2], 0); > >> + WRITE_ONCE(pe->val[3], 0); > >> + WRITE_ONCE(pe->val[4], 0); > >> + WRITE_ONCE(pe->val[5], 0); > >> + WRITE_ONCE(pe->val[6], 0); > >> + WRITE_ONCE(pe->val[7], 0); > > > > memset? > > The order is important here. Otherwise, the PRESENT bit of this pasid > entry might still set while other fields contains invalid values. WRITE_ONCE/READ_ONCE will switch to __builtin_memcpy() in if the size exceeds word size, ie. 64bit in this case. I don;t think compiler will reorder built-in function. Beside, we only need to clear present and FDP bit, right?