Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp183641rdb; Thu, 16 Nov 2023 16:05:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IEEjTK9tb8wQA6kV0RRgHGeUZ72yFnSrGHdW2aXtEqqj4cVgf/SLqDghZimH3yMOIfIWqiy X-Received: by 2002:a05:6870:1494:b0:1e9:e605:279f with SMTP id k20-20020a056870149400b001e9e605279fmr22154020oab.13.1700179524587; Thu, 16 Nov 2023 16:05:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700179524; cv=none; d=google.com; s=arc-20160816; b=Jzco59vTLUxsP6ftwZotJ2H1X16QqV+HNCmf3zZaayQlSgePn6wpPd6KjcmP4f+pZ4 dNQbe5oIdqxrvAlb5gBH4rjDA7E5TMNFRNEltTJ04KtZG2+h10vu/UcFA/tcYJv1S+K8 SR6oI8aVV/yoT+YGOvlrvzd1gL+eUi7NAF+4507YyLr4jHYkD6iYpPLNoevDeJuZhjcN 8b4wYvEmLpU9B8vD7vX1k7H0Vwgy2KdFdoP3h625yZylBmuwKOLELKjgIz7V2Y0Gdd9a Zkh8nu2oWU7uvVS5SZZA1//fLEGXb3oLisFRU9PfwMu/cLKqizq7HlVK/6su/OrWaJL9 Mgqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BloSY8bMkkjidIYF8Nis7FeUgSif8gE/nzQnmEzfUN8=; fh=0lm6E2ZrG5dqHwlEuyVw8pKVvwxx5JbkCrxWMQgTbyI=; b=TIaQsobYOxUNomN2fsTxsE1vJ53TtGzxULzEJkEZjKncknvQ9ZfqiFKMCldA5k4KAZ zmp7z6289f29wJghsfUXagkqeT43lQy+28YxuOY1YD0q3friXxx0X2lyqWCnOkHfjPyW EK+mpS2iZiyoOfBm5XE5tXplUEGs0KK2kZLTpxLy3xBgcpyt9nycFjap1p1NgmJne9P+ Wl3jYN7ul86drRSpEBA8XARkyDGmzgejEQjE0j0iP4Mlpv/sOvjHe8Zo4d2X3Hgbbppp NWTResMXMix4pZSJoq5UvmNGIsduGwX+celygRYLTYALWaEu9PhfZPhLonWOx/F66URH tbBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Uh3ZDMaB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id ni16-20020a056871469000b001f4d404e43esi183858oab.23.2023.11.16.16.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 16:05:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Uh3ZDMaB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 30E3481EEBF9; Thu, 16 Nov 2023 16:05:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345585AbjKQAFE (ORCPT + 99 others); Thu, 16 Nov 2023 19:05:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbjKQAFD (ORCPT ); Thu, 16 Nov 2023 19:05:03 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BE89EA; Thu, 16 Nov 2023 16:05:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700179500; x=1731715500; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=vCpoMe2jdL8uHEa4QpYFjqifiicTJLTeMzgEjOKcuyQ=; b=Uh3ZDMaBZFfBL0YjdfoXjvpRL1ALDc4zpVwYiHkjPzkKGKkFVqyBL9Jp ZrJpj8L7fhTuu+aHHPIphX0JZp+BnEncQOC5OLdIRh2zi2jqXaAtDHsWn lBIWlnCeLhHotyysS6YNCK68gXoTfQ/X+fx1UbG1uoBCrmAZlK8Ie+7kO Z/YPQAbCTow+1kgRQ7X2AJoInAfEhUENKprVDnxKiZOU2rArUUeToc7oG GgOK3K55mwWX+vIG85MBRBiZRJh/8P8SVyoOFeFo/wdxg6M6gtF7dsBGQ V6SEtrCadFYg1UxA24A0SEqSytPIKuJVK2RkbX3nrFIeX+BLFNY/bkRBH w==; X-IronPort-AV: E=McAfee;i="6600,9927,10896"; a="390988321" X-IronPort-AV: E=Sophos;i="6.04,205,1695711600"; d="scan'208";a="390988321" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2023 16:05:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10896"; a="889073721" X-IronPort-AV: E=Sophos;i="6.04,205,1695711600"; d="scan'208";a="889073721" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2023 16:04:58 -0800 Date: Thu, 16 Nov 2023 16:04:58 -0800 From: Isaku Yamahata To: Binbin Wu Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , David Matlack , Kai Huang , Zhi Wang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, gkirkpatrick@google.com, isaku.yamahata@linux.intel.com Subject: Re: [PATCH v17 059/116] KVM: TDX: Create initial guest memory Message-ID: <20231117000458.GB1277973@ls.amr.corp.intel.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 16 Nov 2023 16:05:22 -0800 (PST) On Thu, Nov 16, 2023 at 02:35:33PM +0800, Binbin Wu wrote: > > > On 11/7/2023 10:56 PM, isaku.yamahata@intel.com wrote: > > From: Isaku Yamahata > > > > Because the guest memory is protected in TDX, the creation of the initial > > guest memory requires a dedicated TDX module API, tdh_mem_page_add, instead > > of directly copying the memory contents into the guest memory in the case > > of the default VM type. KVM MMU page fault handler callback, > > private_page_add, handles it. > > > > Define new subcommand, KVM_TDX_INIT_MEM_REGION, of VM-scoped > > KVM_MEMORY_ENCRYPT_OP. It assigns the guest page, copies the initial > > memory contents into the guest memory, encrypts the guest memory. At the > > same time, optionally it extends memory measurement of the TDX guest. It > > calls the KVM MMU page fault(EPT-violation) handler to trigger the > > callbacks for it. > > > > Reported-by: gkirkpatrick@google.com > > Signed-off-by: Isaku Yamahata > > > > --- > > v15 -> v16: > > - add check if nr_pages isn't large with > > (nr_page << PAGE_SHIFT) >> PAGE_SHIFT > > > > v14 -> v15: > > - add a check if TD is finalized or not to tdx_init_mem_region() > > - return -EAGAIN when partial population > > --- > > arch/x86/include/uapi/asm/kvm.h | 9 ++ > > arch/x86/kvm/mmu/mmu.c | 1 + > > arch/x86/kvm/vmx/tdx.c | 167 +++++++++++++++++++++++++- > > arch/x86/kvm/vmx/tdx.h | 2 + > > tools/arch/x86/include/uapi/asm/kvm.h | 9 ++ > > 5 files changed, 185 insertions(+), 3 deletions(-) > > > [...] > > +static int tdx_sept_page_add(struct kvm *kvm, gfn_t gfn, > > + enum pg_level level, kvm_pfn_t pfn) > > For me, the function name is a bit confusing. > I would relate it to a SEPT table page instead of a normal private page if > only by the function name. > > Similar to tdx_sept_page_aug(), though it's less confusing due to there is > no seam call to aug a sept table page. How about tdx_mem_page_{add, aug}()? -- Isaku Yamahata