From mboxrd@z Thu Jan 1 00:00:00 1970 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 B99542367B5; Mon, 27 Oct 2025 09:01:59 +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=1761555721; cv=none; b=ToIYA1dHLJaKehb0kGImLcxOV1/lHII7/QUwVU9/2ZrwiKdbjKLX6wU5UmiSl7I9tcxdznS3CDf4xQm1PTzrZjR2/jtzpDRaAApZZU0CGneQbJ7rwMbl0FJKCGEvbK4q4NEX5Z1Nip6IqsSQVYQY1fbU/zsr26vIc6s+CnGTOvY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761555721; c=relaxed/simple; bh=275YkRCyZVfjEDUsCr12iYfs5/SgTlKkXm5iRoBP66c=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=JTkWiickBbDcYj9HVArT/uulGYaZ++47UmmfbjA2K8KotCu5VUZ+tplcnYm+9HNDq86GsOeUdWqQPWn1cT134EhT0fqEHl+mDPeSKZ9WYkJoBK8uHBOdBASn6J2W3isESOOpJF9rYAhD2Tjpj/2+31E/WN2HNt3QFJGpgiex7Ko= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=WJdInWqP; 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=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.b="WJdInWqP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761555719; x=1793091719; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=275YkRCyZVfjEDUsCr12iYfs5/SgTlKkXm5iRoBP66c=; b=WJdInWqPl+KAkREVwMfyH9a958lpsrnBmyvCHhCsQXNjUJ+fj9KiOgCv 1kSNYue2GmE1d4mQdk7hfeZs5MatZ26nRWkvBerb4pjJiV9Inmn+3/34g kXrUbKZS0mCfIqpXN/iIoAhkcuCJbtzgDWlo/JP19qedPSmiQXClLjrb7 zpmAM/e00e2LmyAsK+zzGwSgUb4KeYa+XjC1AlmHrkP6nIU4SEAlH0R4u fkYKYiFG4tRVIbiwn3MZOGTGLHs0HyfXjZoEm9rvHa219qVkJDxTS78jE 1C6QqBsOpJUNSHM1XJNlW+Scp7TfkBqFGBKMTXDDHyxUOhNh6Oj1LSJ8Z A==; X-CSE-ConnectionGUID: QupBOUrlRGCeefTEJjVJYA== X-CSE-MsgGUID: vSfZFS6YTxWp0E6m/QNcVQ== X-IronPort-AV: E=McAfee;i="6800,10657,11586"; a="51206713" X-IronPort-AV: E=Sophos;i="6.19,258,1754982000"; d="scan'208";a="51206713" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2025 02:01:59 -0700 X-CSE-ConnectionGUID: iCVeVDcZSguedVPvO1GnIg== X-CSE-MsgGUID: rPVV21LWTqG3HlsE3kXlFw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,258,1754982000"; d="scan'208";a="184892900" Received: from yinghaoj-desk.ccr.corp.intel.com (HELO [10.238.1.225]) ([10.238.1.225]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2025 02:01:51 -0700 Message-ID: <59ae9957-88a8-4777-9bd2-196e8b4eb8ac@linux.intel.com> Date: Mon, 27 Oct 2025 17:01:49 +0800 Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 13/25] KVM: TDX: Fold tdx_mem_page_record_premap_cnt() into its sole caller To: Sean Christopherson Cc: Marc Zyngier , Oliver Upton , Tianrui Zhao , Bibo Mao , Huacai Chen , Madhavan Srinivasan , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Paolo Bonzini , "Kirill A. Shutemov" , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, x86@kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, Ira Weiny , Kai Huang , Michael Roth , Yan Zhao , Vishal Annapurve , Rick Edgecombe , Ackerley Tng References: <20251017003244.186495-1-seanjc@google.com> <20251017003244.186495-14-seanjc@google.com> <5dea4a3d-c7b7-48f0-b2d5-7597e0cd5f00@linux.intel.com> Content-Language: en-US From: Binbin Wu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 10/25/2025 12:33 AM, Sean Christopherson wrote: > On Fri, Oct 24, 2025, Binbin Wu wrote: >> >> On 10/17/2025 8:32 AM, Sean Christopherson wrote: >>> Fold tdx_mem_page_record_premap_cnt() into tdx_sept_set_private_spte() as >>> providing a one-off helper for effectively three lines of code is at best a >>> wash, and splitting the code makes the comment for smp_rmb() _extremely_ >>> confusing as the comment talks about reading kvm->arch.pre_fault_allowed >>> before kvm_tdx->state, but the immediately visible code does the exact >>> opposite. >>> >>> Opportunistically rewrite the comments to more explicitly explain who is >>> checking what, as well as _why_ the ordering matters. >>> >>> No functional change intended. >>> >>> Reviewed-by: Rick Edgecombe >>> Signed-off-by: Sean Christopherson >> Reviewed-by: Binbin Wu >> >> One nit below. >> >> [...] >>> + /* >>> + * If the TD isn't finalized/runnable, then userspace is initializing >>> + * the VM image via KVM_TDX_INIT_MEM_REGION. Increment the number of >>> + * pages that need to be mapped and initialized via TDH.MEM.PAGE.ADD. >>> + * KVM_TDX_FINALIZE_VM checks the counter to ensure all mapped pages >>                                                                    ^ >>                                                 Nit: Is pre-mapped better? > Yeah, updated (and then it gets deleted a few commits later :-) ). Oh, right, nr_premapped will be dropped later. Since the whole nr_premapped will be dropped, do we still need a cleanup patch like patch 12 which will be dropped finally?