Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp1008540lqp; Thu, 23 May 2024 06:44:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU9L3/G8+hcf040/mPrdFJUPyo6XVBE8HIO9Wl9owE95/yZuhicNX9RSlboqeHvuI8PqHoXqe+NuAz4MUuoehRByb+KLqa+q6li4aUxTQ== X-Google-Smtp-Source: AGHT+IHnU7ybMCWH2G51NUP6qmMIDDAuvq5XW2kkGy+311+XsC3UXGKPEK2Rx23zhIO2gG9Zmq86 X-Received: by 2002:a17:906:b145:b0:a5d:1079:ae43 with SMTP id a640c23a62f3a-a6228096506mr330477666b.46.1716471886516; Thu, 23 May 2024 06:44:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716471886; cv=pass; d=google.com; s=arc-20160816; b=XfvTw8NZNS2+QCe+bwlpVMLnl0e38YbJzkAzDKTegjHjY3O+l/W3ccokxlZAm2+ADr 11NlnUU859ftyT+zMeMotEVH5LWIsdX47Glyw/9drT13aB05b0voBOEpV5VfsiLholXX cHvWh4QZPR4tr8FiLInVqmduXjoPiUWNrVAygOG59O8lwis2rkezUFrs3xo0cpOjALpB FOu5iNupBlbDzmf12lDzuCW3Hy/dPSsTFiMT4yY9PcbECnDRR6TdNqsUnAdh6STHhH5x 8M/cYVR7DTlwitLELCT6XTC2EI/I74SUILD8NLV61i+tocL6ekcHP3lx+P4EZ66+Wiam i+Ag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:cc:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=iEjfN2LIeVmt2dzhJX/jvcwaoST0hxFaBbOTkz8kWzg=; fh=S1wo+dgkJfy/33Amumj/7lhiQ+pjh6vInOGd3w6wILQ=; b=BQhaFERa1QZRAmboZrib4UACPqIjVc4fP58DlADQJQzWTDCwgo6hN/E0v8XCxwfYu2 jrIW9apyX9ZXCt+HGVaT4NCQ7QM0qnHxKTvyT2js1hxDzF0oKMsQ3CDhQ6v0m428DwTO FnFxwrs8sCWRCmO/zG8002hc59jZfPdcPbhfmTaWJ3uoyV0wETB1kHAegekJkSFtfRib i2kox1zZ/zzZZVf9doKdYBwXGdGIHw0VP1985NNqriRdyBfpwLc8fdZ13qHYW4TbbwIw /5u/ZyLuehHk6ro6N2EZL6/CbSnUpGb0rJbPxZvjz/7WttwOBGLNf9QLZ5FJYPLURmPy H4LA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dEMshDrh; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-187594-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187594-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17ba2d80si1660043366b.519.2024.05.23.06.44.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 06:44:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187594-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dEMshDrh; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-187594-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187594-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 188411F238CF for ; Thu, 23 May 2024 13:44:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F091514A62A; Thu, 23 May 2024 13:44:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dEMshDrh" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D793D14A4D9 for ; Thu, 23 May 2024 13:44:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716471880; cv=none; b=nZd9yYRzMo+h7YIkrmCp89zyMWh1ISVCrdhVdM/zmP+q++bOPR8uwngMZm0j/wYyhNmYVqBDtOGh0qoIp13oGrT+ZachW7pEzZQ9ppwCWbOL9p1XWaArVC5tZwmBudjI/lOZKnJZO+tgqVLnFMcz0L87a6qYnq2XUvN0OmNHVg8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716471880; c=relaxed/simple; bh=vmS5DKfc2Mmr8SibsNeuvDmBmJX5E9bpBypBOCKOTMo=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=sGXG2rjx9D4WdQUF5h33gTShbmQ/sMLH2sCNZ4rV18b6xCmQwYK7doQD+QsOweDo4gomOD/pLYksnHzKLO/ahTeGfeLUrm7JfremmalXT+2HC75Bl/FB4/gMnGY9l2CS18H29bCyjNUu/IcPDDL4ChfuRsCInmxjjNfFyrkpiFM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=dEMshDrh; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716471879; x=1748007879; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=vmS5DKfc2Mmr8SibsNeuvDmBmJX5E9bpBypBOCKOTMo=; b=dEMshDrhBmOzLtg72AHCOmcNiOkSu0F+y8u3qP+J6SC0JMCrsrM9zHgQ 9iZD+Pv8GXs5tzekSGlrVuKWDfjVCzGyMpYuvOMYa9V1qZg0bbOuD/0W7 GwsDDxrEdQRkF5VYuImsuOgtI60Wq1rN+gFg+y2glCytNi29mBejunUlv sSuZKvqDdPzw6rOikXaTNTfiiyXHrjKbTxCE7cjiU4oKAJOGXGmJIcbqT 0w10Hd2zijkdBCHO9O41UeUwDjkCSI2Gs6me3w7o2yo5zT6lj15JHW/s5 qN5TGFPLMEq0AYHQdHR1uQfzAeJQ6hpMCaJrB5rX2LJplN7ctpx2O76Tz A==; X-CSE-ConnectionGUID: 4WdhsVtkTW66eDhGWZ+55g== X-CSE-MsgGUID: JJwt8Y3vQvW2xUAVUjC/OQ== X-IronPort-AV: E=McAfee;i="6600,9927,11081"; a="11661681" X-IronPort-AV: E=Sophos;i="6.08,182,1712646000"; d="scan'208";a="11661681" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2024 06:44:38 -0700 X-CSE-ConnectionGUID: qp+8+VJlTdybd6V3PCJHDA== X-CSE-MsgGUID: ni+y7hlzTU+m6uwwtJ9VWQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,182,1712646000"; d="scan'208";a="64882751" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.125.248.220]) ([10.125.248.220]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2024 06:44:36 -0700 Message-ID: Date: Thu, 23 May 2024 21:44:33 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: baolu.lu@linux.intel.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, David Woodhouse , Joerg Roedel , Will Deacon , Robin Murphy Subject: Re: [PATCH 2/3] iommu/vt-d: Use try_cmpxchg64() in intel_pasid_get_entry() To: Uros Bizjak References: <20240522082729.971123-1-ubizjak@gmail.com> <20240522082729.971123-2-ubizjak@gmail.com> Content-Language: en-US From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/5/23 21:34, Uros Bizjak wrote: >>> + if (!try_cmpxchg64(&dir[dir_index].val, &tmp, >>> + (u64)virt_to_phys(entries) | PASID_PTE_PRESENT)) { >> Above change will cause a dead loop during boot. It should be > No, it is correct as written: > > if (cmpxchg64(*ptr, 0, new)) > > can be written as: > > if (cmpxchg64(*ptr, 0, new) != 0) > > this is equivalent to: > > tmp = 0ULL; > if (!try_cmpxchg64(*ptr, &tmp, new)) The return value of both cmpxchg64() and try_cmpxchg64() is the old value that was loaded from the memory location, right? If so, if (cmpxchg64(*ptr, 0, new) != 0) is not equivalent to if (!try_cmpxchg64(*ptr, &tmp, new)) Best regards, baolu