Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2970569lqp; Mon, 25 Mar 2024 15:05:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWjyQNv9Da76O97XcK326jWFT+hyr9xKnQ/2jO21KZ9KMlPAAQmCP0Uc33mCvEW/I9IKJf9l4qTzdL717jI90kVKFTadhejF+xxVFdEwg== X-Google-Smtp-Source: AGHT+IG7X4Wyrl0C9H+/fYkD/YeOa8bhekmD4M1XCLj6jSdBERb786CqLOm34/ULtxioBXOVWWnw X-Received: by 2002:a50:cd93:0:b0:568:b71a:5954 with SMTP id p19-20020a50cd93000000b00568b71a5954mr6564121edi.10.1711404312501; Mon, 25 Mar 2024 15:05:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711404312; cv=pass; d=google.com; s=arc-20160816; b=A2FaTIbeC5QhKQ8OKLG9teRBMqsvWUoOOaBFWtuEbkdSxnb7BHy5DZwyqyKAELP7Lq R3dDsAKLS/Nfqe/Vg7/qjRLNMMk/FyJLXI/fKLn82l2QH2DZoGCUji2LHBHSjisAfVir ZcWhje+q6k+45Z9Q3TaqrBzhJccdUIwclv1/M+M9uAz2Edvger9i2NV51spzTvGwEdQa tIgIjzW3QGFs1ySRl8G1SsAIMNIXsx3nAc0UpykAeQPGSz4ktyLOig6aYtv4F2Iiv96f Y1yW5SV2+zsPlBGj95FV1DEM2EGSw7lw1dqCAMcVOpzmxkqFLiEwXoMF4iBWby2bqEzc +guA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wWbR9U2Bgoh2BbmCJtMEdGhDSk4TdVAMUZB6RJk5ATQ=; fh=X5dQp0IpjhvrsNuRg9mXougGGYazjH+MLudbyheJ26U=; b=l88ztHQznUdnQcyUhctIm3tlum3uUbO+4BNRyOxhxnnl0qP1j8BVyIPC9Een16h1U+ eNA4jDPLpVbQe5BKQFE5UZbCrHgH7xUsfu+bIm2M5qlQp2pEjhaX43xOMjgBQ77iFGm+ DYl2sKQuZMe5dWa7osIosfpBh8nu0UoAkbmru73UW5FOxS+iLJZuWLApguL+rp6ozO8P DDjTJSBzswy6oRWkBGN3Zmg/KxRSihHx6/fun2vs0FP6Wfd7zfprNv8aN8n1pJiM3n8W 1zKAhMgo7qh7tUKU5es0+g/PlTVjK6DsUx8m2XwnpqRiszTCopz4YaJG8xEjlbU4YP5r 1bvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZyX6lYvU; 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-118079-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118079-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ev25-20020a056402541900b0056c0b91605fsi1595818edb.99.2024.03.25.15.05.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 15:05:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118079-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZyX6lYvU; 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-118079-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118079-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 401BB1F64A77 for ; Mon, 25 Mar 2024 22:05:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E1D237175E; Mon, 25 Mar 2024 22:05:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZyX6lYvU" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 187F56D1C8; Mon, 25 Mar 2024 22:04:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711404301; cv=none; b=KDgQSqid7tIrG+gNlp1zT2jjZj9pL3eVH7PU/8t+lfN2hngcKa8M/mCA8lMAw5NgwnvudBycBTXrjY+aXfy2LV9E3+sXp0Yi6AAfmwC9/BcHIFCJaKF6KblZQ0WWnVWainT0wZOJSgBt3Dwt/crU3GxrBLWhZL3OA2yxNqToDbk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711404301; c=relaxed/simple; bh=+ovNKGBLi1gXj1YmUYOIgIN0QJaeJZCivM4A+DNQztk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=npuioVY/Z9gyVgcl0uHGkTgkEZpjmJ2Xkf80k7L3nwjSmyR6MWpC16d8alImk3qNaltwOiFG0OxFHzZkORC6YYBrhp2uHxKl70nlU9bLjCjKX6vbeWk3ZOVrJaL5SKpK/OJbwTcBhMZX3zu6LksPL8/Z0lfPwLigjKjlGXNHn0Y= 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=ZyX6lYvU; arc=none smtp.client-ip=198.175.65.18 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=1711404299; x=1742940299; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=+ovNKGBLi1gXj1YmUYOIgIN0QJaeJZCivM4A+DNQztk=; b=ZyX6lYvUjE851fFzzkwZAqpTAhonAWVuvhjXJ4OjFtyMD5tIlXwbb9Uw M4ISFQL8RuEjzLXIFAuJybNAjV+y30jdV0v3USn4tmmU3OlpmOOYqwU73 4Vcr5o1xNpJrJFAj62iRXdCxymFo7Fo7HgBwQXG7c+TMEM2NXNvsKpv+n 7LPge4M60oY1N20B/j6rBYrga1D+0Odo9DsCcJeXYR0xovh5Ni+o4/3ch zjgVO7e0N69uqlKxzDnXeEUsUrmX0VjNFpxWY7lzciE/52IdB1kSC9XeM QcAfB7+2OuB2Mwb77ugJD4pBOdnuIxu1X1Y/dPka3THRg3pjDd1rEin9U g==; X-IronPort-AV: E=McAfee;i="6600,9927,11024"; a="6561311" X-IronPort-AV: E=Sophos;i="6.07,154,1708416000"; d="scan'208";a="6561311" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2024 15:04:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,154,1708416000"; d="scan'208";a="20222690" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2024 15:04:58 -0700 Date: Mon, 25 Mar 2024 15:04:57 -0700 From: Isaku Yamahata To: "Huang, Kai" Cc: "Yamahata, Isaku" , "Zhang, Tina" , "seanjc@google.com" , "Yuan, Hang" , "Chen, Bo2" , "sagis@google.com" , "isaku.yamahata@gmail.com" , "linux-kernel@vger.kernel.org" , "Aktas, Erdem" , "kvm@vger.kernel.org" , "pbonzini@redhat.com" , "Li, Xiaoyao" , "isaku.yamahata@linux.intel.com" Subject: Re: [PATCH v19 039/130] KVM: TDX: initialize VM with TDX specific parameters Message-ID: <20240325220457.GN2357401@ls.amr.corp.intel.com> References: <5eca97e6a3978cf4dcf1cff21be6ec8b639a66b9.1708933498.git.isaku.yamahata@intel.com> <5f0c798cf242bafe9810556f711b703e9efec304.camel@intel.com> <20240323012224.GD2357401@ls.amr.corp.intel.com> <59fbe690d1765337b4b1785b4cef900415bd5df2.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 In-Reply-To: <59fbe690d1765337b4b1785b4cef900415bd5df2.camel@intel.com> On Mon, Mar 25, 2024 at 10:39:10AM +0000, "Huang, Kai" wrote: > On Fri, 2024-03-22 at 18:22 -0700, Yamahata, Isaku wrote: > > On Fri, Mar 22, 2024 at 11:20:01AM +0000, > > "Huang, Kai" wrote: > > > > > On Mon, 2024-02-26 at 00:25 -0800, isaku.yamahata@intel.com wrote: > > > > +struct kvm_tdx_init_vm { > > > > + __u64 attributes; > > > > + __u64 mrconfigid[6]; /* sha384 digest */ > > > > + __u64 mrowner[6]; /* sha384 digest */ > > > > + __u64 mrownerconfig[6]; /* sha384 digest */ > > > > + /* > > > > + * For future extensibility to make sizeof(struct kvm_tdx_init_vm) = 8KB. > > > > + * This should be enough given sizeof(TD_PARAMS) = 1024. > > > > + * 8KB was chosen given because > > > > + * sizeof(struct kvm_cpuid_entry2) * KVM_MAX_CPUID_ENTRIES(=256) = 8KB. > > > > + */ > > > > + __u64 reserved[1004]; > > > > > > This is insane. > > > > > > You said you want to reserve 8K for CPUID entries, but how can these 1004 * 8 > > > bytes be used for CPUID entries since ... > > > > I tried to overestimate it. It's too much, how about to make it > > 1024, reserved[109]? > > > > I am not sure why we need 1024B either. > > IIUC, the inputs here in 'kvm_tdx_init_vm' should be a subset of the members in > TD_PARAMS. This IOCTL() isn't intended to carry any additional input besides > these defined in TD_PARAMS, right? > > If so, then it seems to me you "at most" only need to reserve the space for the > members excluding the CPUID entries, because for the CPUID entries we will > always pass them as a flexible array at the end of the structure. > > Based on the spec, the "non-CPUID-entry" part only occupies 256 bytes. To me it > seems we have no reason to reserve more space than 256 bytes. Ok, I'll make it 256 bytes. The alternative is to use key-value. The user space loops to set all necessary parameters. Something like as follows. KVM_TDX_SET_VM_PARAM struct kvm_tdx_vm_param { /* TDCS metadata field. */ __u64 field_id; /* * value for attributes or data less or qeual to __u64. * pointer for sha384, cpuid, or data larger than __u64. */ __u64 value_or_ptr; }; -- Isaku Yamahata