Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp363604lqb; Tue, 28 May 2024 19:20:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXLpddYr9toV/9hkNMHU1gI2tyQ5L+8t/yUjG94y4QanK3K9Q/hdddJG1zppzwBbePimlasZVTDXwy3TE/9rsia3/rtbon/uzeSvqmWQg== X-Google-Smtp-Source: AGHT+IHy2NNQvyr5q9ktXwZn7uh5lNWvcsx0ofXgxguFKyxnlRpgKgszYO9LxfEcKXXvFne6Rb4H X-Received: by 2002:a05:6214:3101:b0:6a9:d318:48c3 with SMTP id 6a1803df08f44-6abcd0fbbafmr170992606d6.52.1716949214103; Tue, 28 May 2024 19:20:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716949214; cv=pass; d=google.com; s=arc-20160816; b=jhkM89Xa1mHWNmGdJS9e7JFZlOaihXXskqKyXUnB72r/YRMz8uUVz/ZUvsJuHcAQuh BhOLi2h/EaJNTf2LyzfKpglz6HQLo3yRu/2zR4nbwiHGJh1/pZMAph4CHRUQAHEyhIBg NFEbBxdgl8RLfKsDBE8O0ocLmRo+4DOPhmB6VbdkA4GV0HX1Fro+6nBryS3DfkAky6Cq SjjIjuR9oxl8KoffsAq39uHDCkQlRLEB0Kqi3HC8QNjqh91IovCOTQeLu3cXPiFZlzHx N9I00KfcYp8xRJyi5SE/kcTxBl7dyHJJZ7cDkfDteDYsAETx0CSmVqQFAwssxqFLRzNt b/EA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2wS4lxWuxoU4namp1s26aa6Uu+NCtoXuccmHcJaSvvw=; fh=D3M4ZmR/Mc6cCxGVFXFTomLVoBc8fld6nt/jkSU51Hs=; b=wqIKTZW1/Z/iMPEzHsohaEiRn4LKL9A0+gke5nUj2T1SeQph3a7MktnCf9EfGCUgjP HusnkxRPeRvTDGGIqiQRHQYSU6Tp+DCKUza1DswCwX7E7xRkAo3XZ/9wVyUJqQXJFRS3 YF3HqzxsirUPB0NCifb165I09m4N1N7HiXCa3wwSxitOnb3bDSzrkanC93C532es5mja X0HAzAWx8AelurTqMMu2S/OdgV7IOmsqKnDv6xU78SYFvQ4nrjcdlX2otKM2IC0wLqAd TBkBuTwBb8VjXVjD41qkWk9aw1Q5xcKNngAC4MYHXsus8EPwuzIMdqg2TJJbhAyIenLO vzYA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WQj2hlY+; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-193358-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193358-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6ac06f4f2c6si119305706d6.39.2024.05.28.19.20.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 19:20:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193358-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WQj2hlY+; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-193358-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193358-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C47071C23511 for ; Wed, 29 May 2024 02:20:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9246115B0E4; Wed, 29 May 2024 02:20:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WQj2hlY+" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 52F4D4DA08; Wed, 29 May 2024 02:20:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716949206; cv=none; b=fyxWLght3+Z63s81RiQp3ziMQid+r/+++wXmEcKjzItyXpf7e7Vj6GoZvaf2/1mEtNhAxtjb6xwLWdNUYmueLjw79ZHp9BJWOrZkdh6WkNMu30XQGIuBDBZfa3YpoY4Y+mZkYY8wPdQwOJZqH4mmjQGKdRzAieFkoQhu/tuoCBE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716949206; c=relaxed/simple; bh=1Lxina2QR/i/PAe6wbyp4MvFOW2Mak7+iWIwuFEcXBk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gKrETO2vLkOoyTKeLsTR1ZASnz1X1r4ilOASFuyrfzGvGG9AVuoFRtztRGSXJ1sf4mhA4/3h7XdTTuB9ptU2ZtEeCUzkJVZrJB/Z9Yo8GcCJp2dlVhIekphfgw+2OBTBMMJ6CczXbzcfJuV75pGUzj3+CylL8Tq1WC7p9rvad9I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=WQj2hlY+; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716949206; x=1748485206; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=1Lxina2QR/i/PAe6wbyp4MvFOW2Mak7+iWIwuFEcXBk=; b=WQj2hlY+9YYjf9LTip0Rp+7MTJZZNuXRIv7Nevnge0IUStWgvTsm56x8 OdHmh+rJ6VkctcaigndH30yz4J1e+FJk0kbrfYu6fDNAfN7Z2T43IHEhb LSLBeITlKjsqKZSZjqbNo0ljBXQcfhHb8f9vaiZRd4FR3g8X6JxsABzaL eFhRXRWPCujPzkGLsqlQavH73BHJEM3A3CUopn2IVU5LUQjcnFadzsNAo phhgOGgPLrj2cgdgeOzUsKwPfXUjC3PU68KDm6x6XHX3f2yhEbmu0omFi 2Iw9VLcf+HswxBBcHBd3lanay7Zm4h4aRYZ069D0Q6YgChSbB6PJAX+g+ w==; X-CSE-ConnectionGUID: 8E2uLc1IRb2eb3aaDM93XA== X-CSE-MsgGUID: Pt2cMSCkTZOrKCWFEOfUSg== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13170257" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13170257" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 19:20:05 -0700 X-CSE-ConnectionGUID: eAAshPejSTO9bYY/tgY3Bg== X-CSE-MsgGUID: ElrHQ9duQUq+ev6u3ztCWg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="66465436" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.54]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 19:20:04 -0700 Date: Tue, 28 May 2024 19:20:03 -0700 From: Isaku Yamahata To: "Edgecombe, Rick P" Cc: "Yamahata, Isaku" , "dmatlack@google.com" , "seanjc@google.com" , "sagis@google.com" , "linux-kernel@vger.kernel.org" , "Zhao, Yan Y" , "Aktas, Erdem" , "kvm@vger.kernel.org" , "pbonzini@redhat.com" , "isaku.yamahata@gmail.com" , isaku.yamahata@linux.intel.com Subject: Re: [PATCH 10/16] KVM: x86/tdp_mmu: Support TDX private mapping for TDP MMU Message-ID: <20240529022003.GG386318@ls.amr.corp.intel.com> References: <20240515005952.3410568-1-rick.p.edgecombe@intel.com> <20240515005952.3410568-11-rick.p.edgecombe@intel.com> <6273a3de68722ddbb453cab83fe8f155eff7009a.camel@intel.com> <20240524082006.GG212599@ls.amr.corp.intel.com> <20240529011609.GD386318@ls.amr.corp.intel.com> <2b3fec05250a4ec993b17ab8c90403428ca5c957.camel@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2b3fec05250a4ec993b17ab8c90403428ca5c957.camel@intel.com> On Wed, May 29, 2024 at 01:50:05AM +0000, "Edgecombe, Rick P" wrote: > On Tue, 2024-05-28 at 18:16 -0700, Isaku Yamahata wrote: > > > Looking at how to create some more explainable code here, I'm also wondering > > > about the tdx_track() call in tdx_sept_remove_private_spte(). I didn't > > > realize > > > it will send IPIs to each vcpu for *each* page getting zapped. Another one > > > in > > > the "to optimize later" bucket I guess. And I guess it won't happen very > > > often. > > > > We need it. Without tracking (or TLB shoot down), we'll hit > > TDX_TLB_TRACKING_NOT_DONE.  The TDX module has to guarantee that there is no > > remaining TLB entries for pages freed by TDH.MEM.PAGE.REMOVE(). > > It can't be removed without other changes, but the TDX module doesn't enforce > that you have to zap and shootdown a page at at time, right? Like it could be > batched. Right. TDX module doesn't enforce it. If we want to batch zapping, it requires to track the SPTE state, zapped, not TLB shoot down yet, and not removed yet. It's simpler to issue TLB shoot per page for now. It would be future optimization. At runtime, the zapping happens when memory conversion(private -> shared) or memslot deletion. Because it's not often, we don't have to care. For vm destruction, it's simpler to skip tlb shoot down by deleting HKID first than to track SPTE state for batching TLB shoot down. -- Isaku Yamahata