Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp836565iob; Fri, 13 May 2022 14:03:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqq4cY3ReOS8g3MriSUY7sbarCSXgyroAvLZKduwzAKN9FPM+wjqqxOZEH5jkbHBcXzr9C X-Received: by 2002:a17:906:7684:b0:6e8:5d05:196b with SMTP id o4-20020a170906768400b006e85d05196bmr6043357ejm.209.1652475779860; Fri, 13 May 2022 14:02:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652475779; cv=none; d=google.com; s=arc-20160816; b=BujEc34h7Qo3HI5JAc6mPY1Tn2FQwCl8IPJeytenY4NrIpAvHNXqUT6DLwBOBDzO// Kd7icR7O9g1uXn+fwE/3wXmBms4KBJOq2GKB4gtU1TGj8gt+Xd5hTXEFZJj/RNhhyqy1 gWjnVV3/F/lmXf6cv9XWDt7nPRVBodeE/GuNtmEOMKTrNGehs0WH8NIHAvvHsZa3weWX P2Te7Qrzvd180QFNXl2iS1IFpw1Svk+CQ8fJPm3QqQ/QdHRFOoipewko96JVzBxljFal smQP6XdvlNzq0+H5zCunVj/wtdiDJxMrZeH7WOqOvT+/E4hF0Wcnyr7gDzqhVoEJWqC1 NIEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=nNnx/MfkCvw0H1RR97MczNVLGMV82iA4NGI1MdYophQ=; b=LtNlRWHXx30IqQKIe9M1DONIR2ddxiBHaj+WWTjrcFClyVN8pOlDzqtTRtHIwxKElS ZT05SV0xRvVoxA1Ldkq5Vl+14FkAS+5lXeZDKBqLY5sbnuxbvfNVv/PkeocBN1eXbyeI FkYHE4zakMA87sig7a3nCtD0mXOaBhT4if+YlNHH1xTxbvetTPYh4MaRur86c0RaZ9K1 PZFk/4CJMxWWQyxnCHpCJ6OPW+WKVctGiWVtOXtWgCagDgTMhMLlGqH1Z8nHxBTGvOpY gJ/7JAYBiMJhQGbFPB/094E4QrKDnqWj8GF6ildZUa9Y8Gnp8/XfCK3xHTslnnGcpKKe nDaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RoWmQ6iw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dr12-20020a170907720c00b006df76385e8fsi3275568ejc.815.2022.05.13.14.02.30; Fri, 13 May 2022 14:02:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RoWmQ6iw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380411AbiEMMfM (ORCPT + 99 others); Fri, 13 May 2022 08:35:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380386AbiEMMfB (ORCPT ); Fri, 13 May 2022 08:35:01 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04F9469498; Fri, 13 May 2022 05:35:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652445301; x=1683981301; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=Zv7Qi86HPneMHTnZpf40yaE9hmnJYLH+m3BORrPBcec=; b=RoWmQ6iwVOTB8MQ+8HMUo1kgPbBvVVKr0rrJbk6oskwi7rIaCAksbgZQ azZqXoVSy7gU1bkLlXUymZoRnIFOO01bLUT2wmiUMSsZ8ylLKhL8rgDmq kZoss0zZnSia9fiKra2UlkpFNTf50VFbbyq5a5ue7D93rNJdAo8cXpmRg x/V7umKa6WSL5mBXVRspY93Er4LYY30iSxGC2OAS1xFVXz98C/quJex/t umpgMyNB8B+StndAG3z0Vm7qEfPMGWKBh+weKbOVWyRP9QT199Gr+btyx KdXBlc5JuCdMN83sDRY+X+0ASwp8s642UxNrMGmLNhXqBpucbn5HDvPPN Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10345"; a="356721676" X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="356721676" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 05:35:00 -0700 X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="521405157" Received: from apamu-mobl.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.254.33.218]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 05:34:58 -0700 Message-ID: Subject: Re: [RFC PATCH v6 025/104] KVM: TDX: initialize VM with TDX specific parameters From: Kai Huang To: Isaku Yamahata , Xiaoyao Li Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar Date: Sat, 14 May 2022 00:34:55 +1200 In-Reply-To: <20220509151829.GC2789321@ls.amr.corp.intel.com> References: <20220509151829.GC2789321@ls.amr.corp.intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2022-05-09 at 08:18 -0700, Isaku Yamahata wrote: > > > +struct kvm_tdx_init_vm { > > > + __u64 attributes; > > > + __u32 max_vcpus; > > > + __u32 tsc_khz; > > > + __u64 mrconfigid[6]; /* sha384 digest */ > > > + __u64 mrowner[6]; /* sha384 digest */ > > > + __u64 mrownerconfig[6]; /* sha348 digest */ > > > + union { > > > + /* > > > + * KVM_TDX_INIT_VM is called before vcpu creation, thus > > > before > > > + * KVM_SET_CPUID2.  CPUID configurations needs to be > > > passed. > > > + * > > > + * This configuration supersedes KVM_SET_CPUID{,2}. > > > + * The user space VMM, e.g. qemu, should make them > > > consistent > > > + * with this values. > > > + * sizeof(struct kvm_cpuid_entry2) * > > > KVM_MAX_CPUID_ENTRIES(256) > > > + * = 8KB. > > > + */ > > > + struct { > > > + struct kvm_cpuid2 cpuid; > > > + /* 8KB with KVM_MAX_CPUID_ENTRIES. */ > > > + struct kvm_cpuid_entry2 entries[]; > > > + }; > > > + /* > > > + * For future extensibility. > > > + * The size(struct kvm_tdx_init_vm) = 16KB. > > > + * This should be enough given sizeof(TD_PARAMS) = 1024 > > > + */ > > > + __u64 reserved[2028]; > > > > I don't think it's a good idea to put the CPUID configs at the end of this > > structure and put it into a union. > > > > 1. The union makes the Array of Length zero entries[] pointless. > > 2. It wastes memory that when new field to be added in the future, it has to > > be put after union instead of inside union. > > Hmm, I checked this as there was a suggestion to do so. > I have to admit that it's ugly for future reserved area.  The options I can > think of are > > A. add a pointer to struct kvm_cpuid2 (previous v5 patch) > B. this patch. Why can't we just use kvm_cpuid2 here to replace the union? We can add additional reserved space before kvm_cpuid2 for future extension. Is there any problem? I don't see there's fundamental difference between putting kvm_cpuid2 directly here vs putting a 'cpuid' pointer here. My personal feeling is the former is clearer than the latter. -- Thanks, -Kai