Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp942112pxb; Wed, 6 Apr 2022 04:57:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGWxOKlzxT2zc5JEY6lu5AbIcxoSEh/8QMji+Eojj4Mkwf4teZazy8rkpN8lP13h8FqTuR X-Received: by 2002:a17:903:1208:b0:151:93fd:d868 with SMTP id l8-20020a170903120800b0015193fdd868mr8212816plh.121.1649246273399; Wed, 06 Apr 2022 04:57:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649246273; cv=none; d=google.com; s=arc-20160816; b=c8WWZGQ+4obZX5DghhSEZC2GyZ8rZWbXgeGeg9YLEF/eVoJTl8XUwlaDy/pCtM6G7k i6YjsyVsjrcjhNURkJRqb4MSCsQ53sdGLIkK+KoGB/PI+qGTin42/bT76na1eM4TBiNy Zq0zXA5LuS4TCOLIQVbrAo52+IV7ktCaVW4cEV5JEFWo8L+Lj/fCSRPKiUaGOrPfhu/W ZS9h9buz1txrhg9nJEZxqgPLtTnSkd+BBrqH4Bs+F5Eg6phAMpPsFypqMLAl0UxfcbdL tq6tAdSBnfjfA8KlkdEWSN8WygytrVj3UKPm8Rqj9tB3XHG/KWTq9eomi71wp9gsMo3H 12tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=I7YDzc0txooe4wDXjoZKV+HdiLgjGSAsT9wsXDKfsIc=; b=MMJnuI5eDeP/Q87iF+YrvSRcc+HrhFcMLvb3HA0KaaRdd74P7tMC2NYX0nsWIkQKeO Zk3TPDv97iGyyk8zECSbaT9XeevB4VEXAeKSsHzyyjgjufT1idD7AgeGU54tWo9JFabc s2FUMo6DX3/TmC399bTy6Dj0Q/Esc/zBFsWu0l6ntlEYdC87g6tlwzoRz8wwqz5BDTFR bhSztSHTiOYQS3Sp2gMg+zmr8GI7lh/pQmVR3YqX8hGcUguimYmMkxQyi3l1h/z2G9Jg G7SihpPzT2EB/TV47yVbX464X7VI7UNL2cFgiCqt5Yk0gfRW7elrTW4APQR/K9N7cM0g gtnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="FKCw3Ti/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x6-20020a63cc06000000b003987eaf156csi15216783pgf.641.2022.04.06.04.57.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 04:57:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="FKCw3Ti/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D1C866564D5; Wed, 6 Apr 2022 03:20:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1842238AbiDFBaO (ORCPT + 99 others); Tue, 5 Apr 2022 21:30:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344110AbiDEOF5 (ORCPT ); Tue, 5 Apr 2022 10:05:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C26B01557F6 for ; Tue, 5 Apr 2022 05:58:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649163490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I7YDzc0txooe4wDXjoZKV+HdiLgjGSAsT9wsXDKfsIc=; b=FKCw3Ti/+ORFFLtV7Tm8IUe5bp3acUYA1EXqpzxN3iRUr53lZTW/6WUTmkReqBvcof880l nYAr6po6kjbbJIFH3pac94g2YH0Q+dT9tK3B74QVliuIBALsLjKVdm3lDeGfC42FV4qV/Q zBfERp1jE8MyihcLzcpl4gote1tUzrU= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-669-k7qXx2a9MtyUJ_rIkDzG8A-1; Tue, 05 Apr 2022 08:58:08 -0400 X-MC-Unique: k7qXx2a9MtyUJ_rIkDzG8A-1 Received: by mail-wm1-f69.google.com with SMTP id z16-20020a05600c0a1000b0038bebbd8548so1314277wmp.3 for ; Tue, 05 Apr 2022 05:58:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=I7YDzc0txooe4wDXjoZKV+HdiLgjGSAsT9wsXDKfsIc=; b=318g+CFF7i7tEZz7irbT+DZNn5/+iizwTgX4341R9NtSmpeH/t+krxiQVbnnEuHaMe noKjObDx39YQz9p1u+2JBUAoOnu+wFvAl74g4PqnBScRQgaEz53tUh/E1fiqqurnuUvX ckblhylWH2yXpy/H0s5E1KLY55nMBMTV2mohNgb+Xn7Wxs6J0BBIEzD7+8ekuZ+FQ2iK WWAoY2H0GuzMHUOuEt1f6FJDUBsHEFOIGj5syMBMNsDu0MIDS+pGHOVvtE7a9EH81Bie fqDNkOT5IE2mCh62Xp+ZBeMQJGRthvdosWVle/wecjru/30SJ+deVWMsnjqPnynB+vEM a/mg== X-Gm-Message-State: AOAM530ABlKDzgnDtApKar6tZUOxd63qQQ++rbXg/PG7rMX+jTEQLY21 1QNj17Ijk/x2wGK2TfCw0QmY+CfwuejPPra9S+nklD9NuzWgghY86Cu4TBtnPVGjVOZomOAgruy AuczdcuQrOvwBKoIfEAgSX2Ws X-Received: by 2002:a7b:c347:0:b0:37e:68e6:d85c with SMTP id l7-20020a7bc347000000b0037e68e6d85cmr3142058wmj.176.1649163487130; Tue, 05 Apr 2022 05:58:07 -0700 (PDT) X-Received: by 2002:a7b:c347:0:b0:37e:68e6:d85c with SMTP id l7-20020a7bc347000000b0037e68e6d85cmr3142030wmj.176.1649163486869; Tue, 05 Apr 2022 05:58:06 -0700 (PDT) Received: from [10.32.181.87] (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.googlemail.com with ESMTPSA id r4-20020a05600c35c400b0038cbd8c41e9sm2096679wmq.12.2022.04.05.05.58.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Apr 2022 05:58:05 -0700 (PDT) Message-ID: Date: Tue, 5 Apr 2022 14:58:04 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [RFC PATCH v5 027/104] KVM: TDX: initialize VM with TDX specific parameters Content-Language: en-US To: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@gmail.com, Jim Mattson , erdemaktas@google.com, Connor Kuehl , Sean Christopherson References: From: Paolo Bonzini In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/4/22 20:48, isaku.yamahata@intel.com wrote: > + td_params->attributes = init_vm->attributes; > + if (td_params->attributes & TDX_TD_ATTRIBUTE_PERFMON) { > + pr_warn("TD doesn't support perfmon. KVM needs to save/restore " > + "host perf registers properly.\n"); > + return -EOPNOTSUPP; > + } Why does KVM have to hardcode this (and LBR/AMX below)? Is the level of hardware support available from tdx_caps, for example through the CPUID configs (0xA for this one, 0xD for LBR and AMX)? > + /* PT can be exposed to TD guest regardless of KVM's XSS support */ > + guest_supported_xss &= (supported_xss | XFEATURE_MASK_PT); > + td_params->xfam = guest_supported_xcr0 | guest_supported_xss; > + if (td_params->xfam & TDX_TD_XFAM_LBR) { > + pr_warn("TD doesn't support LBR. KVM needs to save/restore " > + "IA32_LBR_DEPTH properly.\n"); > + return -EOPNOTSUPP; > + } > + > + if (td_params->xfam & TDX_TD_XFAM_AMX) { > + pr_warn("TD doesn't support AMX. KVM needs to save/restore " > + "IA32_XFD, IA32_XFD_ERR properly.\n"); > + return -EOPNOTSUPP; > + } > > + if (init_vm->tsc_khz) > + guest_tsc_khz = init_vm->tsc_khz; > + else > + guest_tsc_khz = max_tsc_khz; You can just use kvm->arch.default_tsc_khz in the latest kvm/queue. > +#define BUILD_BUG_ON_MEMCPY(dst, src) \ > + do { \ > + BUILD_BUG_ON(sizeof(dst) != sizeof(src)); \ > + memcpy((dst), (src), sizeof(dst)); \ > + } while (0) > + > + BUILD_BUG_ON_MEMCPY(td_params->mrconfigid, init_vm->mrconfigid); > + BUILD_BUG_ON_MEMCPY(td_params->mrowner, init_vm->mrowner); > + BUILD_BUG_ON_MEMCPY(td_params->mrownerconfig, init_vm->mrownerconfig); > + Please rename to MEMCPY_SAME_SIZE. Thanks, Paolo