Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1624214pxy; Mon, 2 Aug 2021 06:29:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8IXvgtSFY6r91O+5oV2RaEwiZZNb0Jdsguc6skxjlkz7VTc4rYXcRVil4cxi9ExOe0hvf X-Received: by 2002:a17:906:32cf:: with SMTP id k15mr15823918ejk.68.1627910951892; Mon, 02 Aug 2021 06:29:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627910951; cv=none; d=google.com; s=arc-20160816; b=mToL6VmTcHYFTLqbJt97oMal6E0tiv7MaWqh70GxCdSapVZMc8EBv8mYKROJHW7vO9 Kto/mdeqqRFUeWI4hO4aFrDX9l+aryFlS9Ni/FnGuZ8DdXLmTylSh4p9Vfo66YJyRGhP 7fp/mTVqThnsIGJVQNVnbkDMCEMYLp4SmpKPn1mL4S0xCz1tV4ASK7u17VEwMCGG+kSU DvelvPnRwnWemclj9xzvtDqVN4iHS4Q5hw5k3EzCOMbR3zOq8OR4US65Iq2yx8lL2xTC sSyxRIJt+UPJ0wIg4yMSs+drF8E9SJSb0OpOWyXj2dV0kzjNmc7XZjQBAqTunQqf+rpT PRXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=I5l0/ovtKnwZJAUfRBuoc3aeSF4fIQVskM/tYHfIPYI=; b=dO650Nvc27PyX4J+vNXhhQSVLXIoX50NeYXPVJ6QUFjFj8OADqxxsGWIjTvswVH/vQ KkPTgfP+zQwlQ0+cZxOMCcYMz5TEqT9a8qIrDaX14eeK9biM8gsXUkoqykEtrNaOTiPc jNZDyQJ9uM+VVFhZJkOqzrRDfke+3VtKzpAz2UOTvhDepQ8xOBPxmUaNzmiC0Y9Fe0fK mEZegEPvqZb3DdJ8gcP4225UijWAjc5v03DrdE8bPwj5MpwymJeKrEwNZ6YEsS5RFnY8 iwGUgQtvXU70PTHHv0THE/LZRDZKWF9ot+vRfNYVlNqYUaJFkMIxox1KWY/IDAEF5/aa E5AQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o20si10124616ejm.682.2021.08.02.06.28.24; Mon, 02 Aug 2021 06:29:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233886AbhHBN0C (ORCPT + 99 others); Mon, 2 Aug 2021 09:26:02 -0400 Received: from mga17.intel.com ([192.55.52.151]:55701 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233818AbhHBN0A (ORCPT ); Mon, 2 Aug 2021 09:26:00 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10063"; a="193736130" X-IronPort-AV: E=Sophos;i="5.84,289,1620716400"; d="scan'208";a="193736130" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2021 06:25:50 -0700 X-IronPort-AV: E=Sophos;i="5.84,289,1620716400"; d="scan'208";a="520564738" Received: from xiaoyaol-mobl.ccr.corp.intel.com (HELO [10.249.168.136]) ([10.249.168.136]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2021 06:25:46 -0700 Subject: Re: [RFC PATCH v2 05/69] KVM: TDX: Add architectural definitions for structures and values To: Erdem Aktas , "Yamahata, Isaku" Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Connor Kuehl , Sean Christopherson , x86 , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, isaku.yamahata@gmail.com, Sean Christopherson , Kai Huang , Chao Gao References: From: Xiaoyao Li Message-ID: <1057bbfe-c73e-a182-7696-afc59a4786d8@intel.com> Date: Mon, 2 Aug 2021 21:25:44 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/31/2021 9:04 AM, Erdem Aktas wrote: > On Fri, Jul 2, 2021 at 3:05 PM wrote: >> +/* Management class fields */ >> +enum tdx_guest_management { >> + TD_VCPU_PEND_NMI = 11, >> +}; >> + >> +/* @field is any of enum tdx_guest_management */ >> +#define TDVPS_MANAGEMENT(field) BUILD_TDX_FIELD(32, (field)) > > I am a little confused with this. According to the spec, PEND_NMI has > a field code of 0x200000000000000B > I can understand that 0x20 is the class code and the PEND_NMI field code is 0xB. > On the other hand, for the LAST_EXIT_TSC the field code is 0xA00000000000000A. > Based on your code and the table in the spec, I can see that there is > an additional mask (1ULL<<63) for readonly fields No. bit 63 is not for readonly fields, but for non_arch fields. Please see 18.7.1 General definition > Is this information correct and is this included in the spec? I tried > to find it but somehow I do not see it clearly defined. > >> +#define TDX1_NR_TDCX_PAGES 4 >> +#define TDX1_NR_TDVPX_PAGES 5 >> + >> +#define TDX1_MAX_NR_CPUID_CONFIGS 6 > Why is this just 6? I am looking at the CPUID table in the spec and > there are already more than 6 CPUID leaves there. This is the number of CPUID config reported by TDH.SYS.INFO. Current KVM only reports 6 leaves. >> +#define TDX1_MAX_NR_CMRS 32 >> +#define TDX1_MAX_NR_TDMRS 64 >> +#define TDX1_MAX_NR_RSVD_AREAS 16 >> +#define TDX1_PAMT_ENTRY_SIZE 16 >> +#define TDX1_EXTENDMR_CHUNKSIZE 256 > > I believe all of the defined variables above need to be enumerated > with TDH.SYS.INFO. No. Only TDX1_MAX_NR_TDMRS, TDX1_MAX_NR_RSVD_AREAS and TDX1_PAMT_ENTRY_SIZE can be enumerated from TDH.SYS.INFO. - TDX1_MAX_NR_CMRS is described in 18.6.3 CMR_INFO, which tells TDH.SYS.INFO leaf function returns a MAX_CMRS(32) entry array of CMR_INFO entries. - TDX1_EXTENDMR_CHUNKSIZE is describe in 20.2.23 TDH.MR.EXTEND >> +#define TDX_TDMR_ADDR_ALIGNMENT 512 > Is TDX_TDMR_ADDR_ALIGNMENT used anywhere or is it just for completeness? It's the leftover during rebase. We will clean it up. >> +#define TDX_TDMR_INFO_ALIGNMENT 512 > Why do we have alignment of 512, I am assuming to make it cache line > size aligned for efficiency? It should be leftover too. SEAMCALL TDH.SYS.INFO requires each cmr info in CMR_INFO_ARRAY to be 512B aligned > >> +#define TDX_TDSYSINFO_STRUCT_ALIGNEMNT 1024 > > typo: ALIGNEMNT -> ALIGNMENT > > -Erdem >