Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp146529lqh; Wed, 27 Mar 2024 18:37:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXgkE8os3/rn6XZogjxf2Pz8c2VUE7cYrVf8jylpMMWRynwsoKISY3uw2T2O7Tm9IA0Aw9H1bPSdY/G/g0WkZ5GHO4tQfNtpwbaX+h52g== X-Google-Smtp-Source: AGHT+IHOj+REmQ/3I6uBPeVlX8C4pALmT0DKgJhVMsWMWkhRiQGXINyCdJu8gndJsnlAwTAuo7HS X-Received: by 2002:a05:6359:4c87:b0:17f:5c83:cddb with SMTP id kk7-20020a0563594c8700b0017f5c83cddbmr1231531rwc.5.1711589821789; Wed, 27 Mar 2024 18:37:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711589821; cv=pass; d=google.com; s=arc-20160816; b=GMPX5+ANfuWMVgQ+GIIAuKuE6c7SCqzPmFyB7a/okpbxRcm+q4qfgUDqviziGPumnk KaQ+0cPgwt5AVxTuAaj5PuSWzRY7NG8364bJ6Gr4x3gZPYUKPzb5K9oE1GFVUsfHrpRS b1jODMPS+w1xuuOq4Aine1IIptf/dQwys66w0oGzO/F9TyLTKO3BTdegdX95OXgpwqpi kK/OGKBzJ3f1ES72Y6Q7cvCyTX1l/h2GOqwmSlU5XdXzV0c2T7IRbDBsBmM/vKUGuyg0 pH7iEOtK8wVvsLNYBXe9PT5oqUzlsMFy/YPNIMzgIPkjPOlA1hf1D/TcvWOGqtTi5abf w9HQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=9jVloi2d6xSBItw/nt+xw382tFWOpVLXIaxU71WnRIs=; fh=fD19ZwJuD42o+Uq5LRevWX8MKJCJNj3/CskdrStN5aY=; b=yShqMWlM6wS0C80zAOcI6GWCb9BXEIu0eVD/bejcSf6BBSkpOtVGMhaf7aBN2+MqA7 Bzqgs1RAgMrNshe03KpuNS4GQUhf1trJGZ0xYGUCj0qkGmZeB4FCU3wkU6/GZM618Uur ZOzAFnXgRNiiqVwHkIKTND3Ov7kRrqhfi4pOl2Xd+JGmvDw95xoCEnNpPoUEyKLYw+oY sAZTCfE3HQHiZ+SH3a0yz3CvRrRVnhosEtxKqcId77/TRaB/Nb3uQI2D4H4KqE7Xm/GX SPTLDomDr0os57KUsamADF4apWA6P1aBknNANaz398HPUg+6C+oHD7HrtOCC4t8HQH9V Yl/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=g7zdxgAN; 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-122290-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122290-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id z7-20020a634c07000000b005f07f35d484si314419pga.755.2024.03.27.18.37.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 18:37:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122290-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=g7zdxgAN; 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-122290-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122290-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A51B1B222BF for ; Thu, 28 Mar 2024 01:37:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66A5D2943F; Thu, 28 Mar 2024 01:36:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="g7zdxgAN" 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 05505286AD; Thu, 28 Mar 2024 01:36:27 +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=1711589789; cv=none; b=IuaMjEHrMnCDgN8fzZdONzEICVArbh+uZ0crlOAV3isqUuAYElHh6VwDPmmWYEoki7tHcC5wIvmPHOeabZsm9c/Rq3AR+RmYpzxnMr7hvVAkKJhfOVOha+b3SzBu1Wndg/R9TsnM7v3ifWewd1Z7FEuaHIhu1OpDNYVqZRihv14= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711589789; c=relaxed/simple; bh=lhvQ3bL3zEzra6sPz4mYh3SCJYXmuoBa5F3CVmZ09oY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=fM+guDBdeXQyODTAm2u29ZhHiyNt3E/msywpkrX0IQvMpIJDgxTRRGLXp/RpG9P07EG8gwonSuQbmyfwktlfptM4NONCJiht3dd8gl2q1EAiEZIpvh1jinUjfx+OqQMoimesXmI4vYJNWH6yw3QHcX6gc3quj59a3n9rNeOYmDE= 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=g7zdxgAN; arc=none smtp.client-ip=192.198.163.16 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=1711589788; x=1743125788; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=lhvQ3bL3zEzra6sPz4mYh3SCJYXmuoBa5F3CVmZ09oY=; b=g7zdxgANnSweXA7Yt+5AvoDFy7DzpYSVF8yf0v+co1fuxTPnrS331CFA sn3AQT8KYGzsO8pZCGB5GWHE1Fj8PTlpO7DarFqSSvAH3UhYylGOmmHtm 6CkH4XliCgcXK5y4ajkI1tfgIXSaC5GGj8NvobDnWW9XGiVoIwU1m70Pb 1aBNtjLMLMDGG+KvvcqnwVezsXKez33of64R9tu/ihM2wXUudylKKEe6I 5iQ0S8OnaR3yDtQeaqj7+kNWbZsLeUksG5r4gb2qJLJw2hbKge5OMrLMC UShIVCA3wL9Qau0xkoN0b0QDgWPD4LEqfWkFz9sFCT/Csg/3GdDH/g7B9 g==; X-CSE-ConnectionGUID: LFX268AtRvewW9KbKX3XbA== X-CSE-MsgGUID: bhA4xmoFTRSYbywfoxBkMA== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="7325620" X-IronPort-AV: E=Sophos;i="6.07,160,1708416000"; d="scan'208";a="7325620" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 18:36:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,160,1708416000"; d="scan'208";a="20999108" Received: from xiaoyaol-hp-g830.ccr.corp.intel.com (HELO [10.124.224.7]) ([10.124.224.7]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 18:36:24 -0700 Message-ID: Date: Thu, 28 Mar 2024 09:36:21 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v19 039/130] KVM: TDX: initialize VM with TDX specific parameters To: "Edgecombe, Rick P" , "Gao, Chao" , "Yamahata, Isaku" Cc: "Zhang, Tina" , "isaku.yamahata@linux.intel.com" , "seanjc@google.com" , "Huang, Kai" , "sagis@google.com" , "Chen, Bo2" , "isaku.yamahata@gmail.com" , "Aktas, Erdem" , "kvm@vger.kernel.org" , "pbonzini@redhat.com" , "Yuan, Hang" , "linux-kernel@vger.kernel.org" References: <5eca97e6a3978cf4dcf1cff21be6ec8b639a66b9.1708933498.git.isaku.yamahata@intel.com> <20240321155513.GL1994522@ls.amr.corp.intel.com> <5470570d804b52dcf24b454d5fdfc2320f735e80.camel@intel.com> Content-Language: en-US From: Xiaoyao Li In-Reply-To: <5470570d804b52dcf24b454d5fdfc2320f735e80.camel@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 3/28/2024 9:12 AM, Edgecombe, Rick P wrote: > On Thu, 2024-03-21 at 08:55 -0700, Isaku Yamahata wrote: >> On Wed, Mar 20, 2024 at 02:12:49PM +0800, >> Chao Gao wrote: >> >>>> +static void setup_tdparams_cpuids(struct kvm_cpuid2 *cpuid, >>>> +                                 struct td_params *td_params) >>>> +{ >>>> +       int i; >>>> + >>>> +       /* >>>> +        * td_params.cpuid_values: The number and the order of cpuid_value must >>>> +        * be same to the one of struct tdsysinfo.{num_cpuid_config, cpuid_configs} >>>> +        * It's assumed that td_params was zeroed. >>>> +        */ >>>> +       for (i = 0; i < tdx_info->num_cpuid_config; i++) { >>>> +               const struct kvm_tdx_cpuid_config *c = &tdx_info->cpuid_configs[i]; >>>> +               /* KVM_TDX_CPUID_NO_SUBLEAF means index = 0. */ >>>> +               u32 index = c->sub_leaf == KVM_TDX_CPUID_NO_SUBLEAF ? 0 : c->sub_leaf; >>>> +               const struct kvm_cpuid_entry2 *entry = >>>> +                       kvm_find_cpuid_entry2(cpuid->entries, cpuid->nent, >>>> +                                             c->leaf, index); >>>> +               struct tdx_cpuid_value *value = &td_params->cpuid_values[i]; >>>> + >>>> +               if (!entry) >>>> +                       continue; >>>> + >>>> +               /* >>>> +                * tdsysinfo.cpuid_configs[].{eax, ebx, ecx, edx} >>>> +                * bit 1 means it can be configured to zero or one. >>>> +                * bit 0 means it must be zero. >>>> +                * Mask out non-configurable bits. >>>> +                */ >>>> +               value->eax = entry->eax & c->eax; >>>> +               value->ebx = entry->ebx & c->ebx; >>>> +               value->ecx = entry->ecx & c->ecx; >>>> +               value->edx = entry->edx & c->edx; >>> >>> Any reason to mask off non-configurable bits rather than return an error? this >>> is misleading to userspace because guest sees the values emulated by TDX module >>> instead of the values passed from userspace (i.e., the request from userspace >>> isn't done but there is no indication of that to userspace). >> >> Ok, I'll eliminate them.  If user space passes wrong cpuids, TDX module will >> return error. I'll leave the error check to the TDX module. > > I was just looking at this. Agreed. It breaks the selftests though. If all you prefer to go this direction, then please update the error handling of this specific SEAMCALL.