Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1484617lqp; Fri, 22 Mar 2024 17:29:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXCVA4tK4nwyKvknlya05Z325lGk+ZODnSus6RR2AZiIHpMT+8+x6pS/k+l+Oeu1JJVe37G8Fiy4tUCk4WL/fIJ+41voGQ3fQnWby55kA== X-Google-Smtp-Source: AGHT+IHiumC6fFZeaHs1ipzCjSWaUL93+MzlJEEQDDGajbEndF4aKXDlLhL/S4/FHZxpQdKXFzOv X-Received: by 2002:a05:6214:20e7:b0:690:e5ac:c775 with SMTP id 7-20020a05621420e700b00690e5acc775mr844951qvk.46.1711153739703; Fri, 22 Mar 2024 17:28:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711153739; cv=pass; d=google.com; s=arc-20160816; b=gXShl1Y8EkMi5RV65CCF1Fd4CwXnCK2iOvx1neLOJMEWkboKzTCKzspOpxSxuFW8FV lGAtL+N5c1SJZ21hV5L81idARfZAUwHarHsAT8DkvF67zbZCvMlvDj4+VN/xcoI/SdLx AOPkdmxzmujPFCaSZj7YxWdsR8J3H6Qz075IULflfauCMOhwcRDWfUpVqUtoGE6Ki/zh gwOz4v2RtpW0BpyzaY64r400a76rJvwweMd1vRTWwwwd7yU1MsB8JNKEy0R8WTeca0IM 7EBi1YclZ7E7jrhtIA4exZn6WcncWHdw/CSo62G4OejR92HicZup7WABcIqdEAq9DUjA EwEA== 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=3YNhilKr/fv40nCYmc6iyZz7yAXpnVxvVHPFZTCOr1w=; fh=go+TtFjibR1uT8GqWJETZBnc+De4cwEtCPu7WIb71qc=; b=jpXIzvihwwM2fqGC2ylUzSe6kmW4jiFxwLPMRXVjPFbcx7tNi2V7QHSkrIrmy15De1 6B+dkKrJPWb0cNbC2cs+XZKpCXLeO2Y40MzcJOtL0SD+H2D0+2IMt2GZyw+AnFt8973e SYii+/h9HKXqdGzxW6DwhqAbXCc5qB7MQzxmUeJ9V3ppRSmZSAdkEgVLBCdbm8BoIJqR ynZU4H9H+MZHJUd1zrbSbXua8OXg6ODMI2tDgKIXD1OqnFUkRyevsQXCRJ0RE2VK54wk ZWQvjs5CKXfaTRE5f8w7ysOFht3A1txsxpX1YgLWQi0q6eAoNRttLOadTVN5BZh9xdqT idvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=N9t3qxJm; 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-112135-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112135-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c7-20020a056214224700b0068ff1888580si3351797qvc.97.2024.03.22.17.28.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 17:28:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112135-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=N9t3qxJm; 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-112135-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112135-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 65B721C216B1 for ; Sat, 23 Mar 2024 00:28:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D4CA8A20; Sat, 23 Mar 2024 00:28:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="N9t3qxJm" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 42D877F; Sat, 23 Mar 2024 00:28:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711153731; cv=none; b=pZZBSCIBioxV13zEzjpNrL65x/5Eqk49zSfvpWlEr7OexCvTjygpZ5Rx7w+sfWKj6GGoja9VM44aFjsI2FHgDGW218+AdarvFbF/Lzq/d7O75P1IW8XK4XwzU0pIGfCYU42zU9Isl8cNyJ5UR2T8HUYjXyHz4VFO9njxjYYd3O8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711153731; c=relaxed/simple; bh=jVb5GT+16h3jDNU+od6bEZSrMw4FvOmODglDBfW0RcY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SAlYzHJxW+vl6/lBSXjdeyAfugPtqOS7sk5jgC6pYpZncx7TIcyf64Fg6UNQMQ9Sjgbj3HcOFxKHQJ1RwYmFzb1mdoK/X/nUbKtdvTriHCrST2u2u2AzXJRfrTBIKa0qT0pS/iodWzpRIstCBRkT1+5falowMuINrbzQvXtS5Ys= 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=N9t3qxJm; arc=none smtp.client-ip=192.198.163.8 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=1711153729; x=1742689729; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=jVb5GT+16h3jDNU+od6bEZSrMw4FvOmODglDBfW0RcY=; b=N9t3qxJmZ7qncCF9nok5ngGE3QLyWNzeG+nZM3tRjfnj06EcIRVQ0w80 Quuav+aeJw4XOJ8M5FHfML6BPtPD17eMaIzPP5cYB/G9jOXgOHXRg8cX7 kLUYIIeuO1h9cmYA/NhLs7J6V1r3WQE0c6/vRPpyf3XCC8z5Jvwc5AuJQ Z3kuArgtZOvNX6C1dEDoLmEBKVc6x4i6ttE0YccrjJVUIdA6rRsnuhmiw aY41Car/Swk0/85olTaYvttuvOLHf+O0CDQOUAebDevfVDqVoC0Q341rP R8vgoOvUrULpI20ttwglt8C/VXMi7RPE3k8WtYYFk1uxzLH98boBd/bYE g==; X-IronPort-AV: E=McAfee;i="6600,9927,11021"; a="23712454" X-IronPort-AV: E=Sophos;i="6.07,147,1708416000"; d="scan'208";a="23712454" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2024 17:28:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,147,1708416000"; d="scan'208";a="14981765" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2024 17:28:48 -0700 Date: Fri, 22 Mar 2024 17:28:47 -0700 From: Isaku Yamahata To: "Huang, Kai" Cc: "Yamahata, Isaku" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "isaku.yamahata@gmail.com" , Paolo Bonzini , "Aktas, Erdem" , Sean Christopherson , Sagi Shahar , "Chen, Bo2" , "Yuan, Hang" , "Zhang, Tina" , Sean Christopherson , isaku.yamahata@linux.intel.com Subject: Re: [PATCH v19 036/130] KVM: TDX: x86: Add ioctl to get TDX systemwide parameters Message-ID: <20240323002847.GB2357401@ls.amr.corp.intel.com> References: <167f8f7e9b19154d30c7fe8f733f947592eb244c.1708933498.git.isaku.yamahata@intel.com> <838fe705-4ebe-43f1-9193-4696baa05aad@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: <838fe705-4ebe-43f1-9193-4696baa05aad@intel.com> On Fri, Mar 22, 2024 at 11:26:17AM +1300, "Huang, Kai" wrote: > > diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h > > index 9ea46d143bef..e28189c81691 100644 > > --- a/arch/x86/include/uapi/asm/kvm.h > > +++ b/arch/x86/include/uapi/asm/kvm.h > > @@ -604,4 +604,21 @@ struct kvm_tdx_cpuid_config { > > __u32 edx; > > }; > > +/* supported_gpaw */ > > +#define TDX_CAP_GPAW_48 (1 << 0) > > +#define TDX_CAP_GPAW_52 (1 << 1) > > + > > +struct kvm_tdx_capabilities { > > + __u64 attrs_fixed0; > > + __u64 attrs_fixed1; > > + __u64 xfam_fixed0; > > + __u64 xfam_fixed1; > > + __u32 supported_gpaw; > > + __u32 padding; > > + __u64 reserved[251]; > > + > > + __u32 nr_cpuid_configs; > > + struct kvm_tdx_cpuid_config cpuid_configs[]; > > +}; > > + > > I think you should use __DECLARE_FLEX_ARRAY(). > > It's already used in existing KVM UAPI header: > > struct kvm_nested_state { > ... > union { > __DECLARE_FLEX_ARRAY(struct kvm_vmx_nested_state_data, > vmx); > __DECLARE_FLEX_ARRAY(struct kvm_svm_nested_state_data, > svm); > } data; > } Yes, will use it. > > + if (copy_to_user(user_caps->cpuid_configs, &tdx_info->cpuid_configs, > > + tdx_info->num_cpuid_config * > > + sizeof(tdx_info->cpuid_configs[0]))) { > > + ret = -EFAULT; > > + } > > I think the '{ }' is needed here. Unnecessary? Will remove braces. > > + > > +out: > > + /* kfree() accepts NULL. */ > > + kfree(caps); > > + return ret; > > +} > > + > > int tdx_vm_ioctl(struct kvm *kvm, void __user *argp) > > { > > struct kvm_tdx_cmd tdx_cmd; > > @@ -68,6 +121,9 @@ int tdx_vm_ioctl(struct kvm *kvm, void __user *argp) > > mutex_lock(&kvm->lock); > > switch (tdx_cmd.id) { > > + case KVM_TDX_CAPABILITIES: > > + r = tdx_get_capabilities(&tdx_cmd); > > + break; > > default: > > r = -EINVAL; > > goto out; > > diff --git a/arch/x86/kvm/vmx/tdx.h b/arch/x86/kvm/vmx/tdx.h > > index 473013265bd8..22c0b57f69ca 100644 > > --- a/arch/x86/kvm/vmx/tdx.h > > +++ b/arch/x86/kvm/vmx/tdx.h > > @@ -3,6 +3,9 @@ > > #define __KVM_X86_TDX_H > > #ifdef CONFIG_INTEL_TDX_HOST > > + > > +#include "tdx_ops.h" > > + > > It appears "tdx_ops.h" is used for making SEAMCALLs. > > I don't see this patch uses any SEAMCALL so I am wondering whether this > chunk is needed here? Will remove it to move it to an appropriate patch -- Isaku Yamahata