From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.13 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796200154; b=n2gpwKHMgivhEtum/kqBUVuiGKbCPiilOKzBRXqiSaEkVx+yQuiQY3nqb0ONTtQAAZdj MPKhRToy3/+/W7h3vfh9NcdsMp71MBU2mmExsvgsgA21H41WdUNKc1k6XSgPH9gRxYO5s rg3/EhGTGkM4XwqGknCfyxzaVpTOxcNmyB5D38DDtj2f9orEvGiXDKQqW0xBi46kEvh2a V062Z/oeutwYrQ1yww3+Mj9OZ/GvDyb9WTcQ0MLKRdf0b8Sk4ERMDu6BNsUhXGu31Yvc8 Ya2gC9oEXF0BiJk+hK4qHh/ETnaWxCC5gZpN7J4Zq+HcbAvD1vKdbQFkUZCzibx5eWg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796200154; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Message-ID:Date: MIME-Version:User-Agent:Cc:Subject:To:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=Rnf1jvPVlIYhyA5r09+ZcQdl/pdp6DyQbx9/meX6PJU=; b=dc8GZThNueW28gmgqxM8KATPRLIIln2NWkeX8DRjc8iBvFks5M0VeBnq2CGUiLa7v43f uoqnXEtfrbMdtktUs9M8j90EXASMLr+yZwnTZDqy/mqph8uF1+NrS7P9KDszsWyUoBWMp QchC+ZUcm6OiiTWud+Xn/kum0z0QLq0A8BFRzsUlHaeY0sPXDEQKlZDy500UPxTnlv4mL AI/ZbZHH9FkIWQEsdhnweB0/o2dyTekQgDy79DT1XS30icKiZ9NeGXMxHS4ybZqICGXiV Pys/eF0s7Y9wzyPN53FTMa9V+NDd4KSN/IOHaSGCaf9umSonnu6/+EBOgMuddC0brUw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=BnhszO9i; arc=none smtp.remote-ip=198.175.65.13 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC872606A31A; Wed, 2 Dec 2026 08:29:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AC872606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=BnhszO9i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796200154; x=1827736154; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=Rnf1jvPVlIYhyA5r09+ZcQdl/pdp6DyQbx9/meX6PJU=; b=BnhszO9iyMfs1E0quZ3xibll2WEV0jhdU5LurAUwB9ScTXfNmxr/f+zc 5l8FyD9BvcdML9EcSlvX+W6DJ9lSaFz+ysfQh6kRVVJVCTCgXN6aJh631 w2LfnD8IjDZ5KDsm12u4accd6bgsJAp/lmtdrgYNiIZNkxsEG7DoacgeY zPmlnHm7ye+HXxhZ+efM18q38dtFvINuHfsUtT+Rysel+Vo1egIrOXP6a mPSBe8DJVsG0GjkZYvL4v3gy+VSayL/foFzfaPhs0PNQWR3G0hGNWNyik SfMcXIno4XAU+M2JK/OB06Sx/opnFh7fgqXjACkio0P/z0t5EJ8/fKPPH A==; X-CSE-ConnectionGUID: gBPWNCGyTLmp8oFC/yYOfw== X-CSE-MsgGUID: +ryEOjvlQ/+82FRWN/Bg3A== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="5019059" X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="5019059" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 00:29:13 -0800 X-CSE-ConnectionGUID: fiTJerIPR4iJ8+0dJ6+5Pw== X-CSE-MsgGUID: xC2pqmQeQdaGGWhB1fylog== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="13305506" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.124.249.52]) ([10.124.249.52]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 00:29:10 -0800 Message-ID: <28dc9218-bf0b-4c9c-bde0-419c710200bb@linux.intel.com> Date: Wed, 2 Dec 2026 16:29:07 +0800 X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: baolu.lu@linux.intel.com, Jason Gunthorpe , Kiryl Shutsemau , "Edgecombe, Rick P" , "yilun.xu@linux.intel.com" , "Li, Xiaoyao" , "Gao, Chao" , Binbin Wu , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v3 5/9] iommu/vt-d: Block GCMD and ECMD while acquired by the TDX module To: "Tian, Kevin" , "iommu@lists.linux.dev" , "x86@kernel.org" , "linux-coco@lists.linux.dev" , "kvm@vger.kernel.org" References: <20261112043054.2664857-1-baolu.lu@linux.intel.com> <20261112043054.2664857-6-baolu.lu@linux.intel.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 12/2/2026 12:57 PM, Tian, Kevin wrote: >> From: Baolu Lu >> Sent: Thursday, November 26, 2026 10:11 AM >> >> On 11/25/2026 11:49 AM, Tian, Kevin wrote: >>>> From: Lu Baolu >>>> Sent: Thursday, November 12, 2026 12:31 PM >>>> >>>> + * context (e.g. perf pmu::start/stop), so don't sleep; just reject >>>> + * the request. >>>> + */ >>>> + if (iommu->tdxc_acquired) { >>>> + ret = -EBUSY; >>>> + goto err; >>>> + } >>>> + >>> iommu_pmu_stop() doesn't check the return value of this. It's a void >>> function. So returning error here still breaks the perf feature. >>> >>> we may need a way to disable iommu perf completely in the acquire >>> function. >> Good catch. Returning an error there leaves events that look like >> they're running but never count, or that can't be stopped. >> >> I'll make perf events and TDX mode mutually exclusive instead: >> >> - The iommu pmu counts its live events under register_lock. >> - event_init() fails with -EBUSY while the IOMMU is acquired. >> - acquire() fails with -EBUSY while any event exists. >> >> Something like the following(compiled but not tested). Does this work >> for you? > we could simply unregister iommu pmu at acquisition time? that makes > the entire capability disappeared when tdx is acquired, clearer than > presenting a capability w/o any usable counters... Good idea. It's simpler, and it also means an open perf session can no longer block TDX acquisition. perf_pmu_unregister() now detaches live events instead of failing, so dmar_tdx_acquire() can tear the pmu down unconditionally: ret = dmar_tdx_reserve_did(iommu); if (ret) return ret; /* * Perf issues enhanced commands from callbacks that can't fail, and * TDX mode blocks them. */ iommu_pmu_unregister(iommu); free_iommu_pmu(iommu); dmar_tdx_set_acquired(iommu, true); Thanks, baolu