Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1979368rdb; Tue, 3 Oct 2023 07:02:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYOgWisdY18V+iKZVBTc6o+3NMH5OmlWxvHxvkYP+ewtgN6x70n4rJPg9PqmSE8LmVGKO7 X-Received: by 2002:a17:90b:fc7:b0:274:735c:e2d3 with SMTP id gd7-20020a17090b0fc700b00274735ce2d3mr12450184pjb.8.1696341728896; Tue, 03 Oct 2023 07:02:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696341728; cv=none; d=google.com; s=arc-20160816; b=0RyX6DYm6/fGuGoQjyw3aRlNWThRqrjutXbhK2GqvPMWMr0i8P6mP1KEadJLKzDJc9 UgkDH97w5dbHyUtL71ed/sHL+27DBJg1zQsUJ6+Ad1g7pc+SPE48+ZSIbwme4n7OzjRG DyV84tK76fMwZ+4YJ+KbqWLb1Rgm3n1xuqr2gt0FuIfAEmi4VuN9d8V+QhDmG82h7/Nc hEDmr+7fJndNkVwmk7yc50Dz6X8WB/FbF/+/vlr+Zjs1erXRORu0FWBWwyHiBLlYjy0m aXy7XrYKPX7rv3lpXvOao44L2c6TrVYsnNLOJs5rDD2HeStKeFnCc5utpS3NMRY8pEy2 vqqA== 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=8eV2+NeWF5FzykjZVWHwkCZ/5723LLxVkpUrQH4j+1c=; fh=dQrk9DQ0Wt2fTyYUg2QWhPlnvyNRjmRd3gE8NwNoY+4=; b=TlmRo6w8dI7jthTH0EC5Clb5C8wLOX93tMd8if890T7nV06SSTtObIIYz4YdSYDz2y h4Tkq1YViGt5jYBSM4iXf4I3u1nji6LyxBFAfyv/kuPxDozbbE5GHvWBFEjxbEmPsTC4 C8cDKfIxYwq3erfK1pddMIGj3BAYWeTEb5Td26IrquybsoZX1CQ52tkA4Mn/DLRSv8SY Nj0Xop5hf5LooeWbITjH7zVRLI+YYwGqmyDvuucl8tUgu9h0MxkejwD5WylwgWUYorrp WmCXUf2xPbZKzZHszztehYbgWQ/gXLsNXzBPq3fQlLBVxolnpZ3X/RGVNvThIjbTTsB+ nhjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=D6MiQroa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id l14-20020a17090a660e00b00277387ac962si10205453pjj.2.2023.10.03.07.02.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 07:02:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=D6MiQroa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 622928022C3F; Tue, 3 Oct 2023 07:02:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237880AbjJCOBu (ORCPT + 99 others); Tue, 3 Oct 2023 10:01:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230468AbjJCOBt (ORCPT ); Tue, 3 Oct 2023 10:01:49 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9608DA3 for ; Tue, 3 Oct 2023 07:01:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696341704; x=1727877704; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=uePwa7VPltT+jw5/W9K9jgZRk0qXIMPCBgYp21qPHok=; b=D6MiQroaQ51XgqdSu5EmjYser4f9tJLmQE1XI2UGAVYnJajZtimd7ddk wVIwcwqQcdSOnU6rvlWRRCJJhgHbpxh1/xBQMHjeR/Y9sVxHjFxNfEmRr TaoQd7Y9a+RxF9oMjoh7B7fOENhgLFeo99wUq7Kh/eYJd08+ijYSg3Jgn 44cFyYoaYCVF/uzA7CRVmnkxiN0F1IGpjabqnuIgMpuFEOE5y2cynjBMZ rXoOUJQ1Py7OKG/XBApYc9N/KdwbQHERqH0vJSPP1Wq+6TwsBJ5IQc8wY +v5zdh6v4u77dXbJgJJvYZHfdmaBQW7RNT/L65BA4HTtvohkzw2zIAfes g==; X-IronPort-AV: E=McAfee;i="6600,9927,10852"; a="1475228" X-IronPort-AV: E=Sophos;i="6.03,197,1694761200"; d="scan'208";a="1475228" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Oct 2023 07:01:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10852"; a="780303304" X-IronPort-AV: E=Sophos;i="6.03,197,1694761200"; d="scan'208";a="780303304" Received: from sknagara-mobl2.amr.corp.intel.com (HELO [10.209.121.241]) ([10.209.121.241]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Oct 2023 07:01:42 -0700 Message-ID: <1019158c-a854-4e29-b9ec-961fb878bab3@linux.intel.com> Date: Tue, 3 Oct 2023 07:01:44 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] x86/tdx: Dump TDX version During the TD Bootup Content-Language: en-US To: Yi Sun Cc: kirill.shutemov@linux.intel.com, linux-kernel@vger.kernel.org, heng.su@intel.com, yi.sun@linux.intel.com, Dongcheng Yan References: <20230930161110.3251107-1-yi.sun@intel.com> <483ee0eb-cc14-44a4-9c3b-77a6d0860359@linux.intel.com> From: Kuppuswamy Sathyanarayanan In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 03 Oct 2023 07:02:04 -0700 (PDT) On 10/3/2023 6:56 AM, Yi Sun wrote: > On 03.10.2023 06:26, Kuppuswamy Sathyanarayanan wrote: >> >> >> On 9/30/2023 9:11 AM, Yi Sun wrote: >>> +static int tdg_get_sysinfo(struct tdg_sys_info *td_sys) >>> +{ >>> +    struct tdx_module_output out; >>> +    u64 ret; >>> + >>> +    if (!td_sys) >>> +        return -EINVAL; >>> + >>> +    ret = __tdx_module_call(TDX_SYS_RD, 0, TDX_SYS_VENDOR_ID_FID, 0, 0, >>> +                &out); >>> +    if (TDCALL_RETURN_CODE(ret) == TDCALL_INVALID_OPERAND) >>> +        goto version_1_0; >>> +    else if (ret) >>> +        return ret; >> >> For this failure case, do you want to reset tdg_sys_info to some value like zero >> or some constants to specify unknown? > Yes, that would be better for this case. > >>> + >>> +    td_sys->vendor_id = (u32)out.r8; >>> + >>> +    ret = __tdx_module_call(TDX_SYS_RD, 0, TDX_SYS_MAJOR_FID, 0, 0, &out); >>> +    if (ret) >>> +        return ret; >>> + >>> +    td_sys->major_version = (u16)out.r8; >>> + >>> +    ret = __tdx_module_call(TDX_SYS_RD, 0, TDX_SYS_MINOR_FID, 0, 0, &out); >>> +    if (ret) >>> +        return ret; >>> + >>> +    td_sys->minor_version = (u16)out.r8; >>> + >>> +    return 0; >>> + >>> +    /* TDX 1.0 does not have the TDCALL TDG.SYS.RD */ >>> +version_1_0: >>> +    td_sys->vendor_id = TDX_VENDOR_INTEL; >>> +    td_sys->major_version = 1; >>> +    td_sys->minor_version = 0; >>> + >>> +    return 0; >>> +} >>> + >>>  void __init tdx_early_init(void) >>>  { >>>      u64 cc_mask; >>>      u32 eax, sig[3]; >>> +    struct tdg_sys_info td_sys_info; >>> >>>      cpuid_count(TDX_CPUID_LEAF_ID, 0, &eax, &sig[0], &sig[2],  &sig[1]); >>> >>> @@ -820,5 +882,9 @@ void __init tdx_early_init(void) >>>       */ >>>      x86_cpuinit.parallel_bringup = false; >>> >>> -    pr_info("Guest detected\n"); >>> +    tdg_get_sysinfo(&td_sys_info); >> >> Why not check the return value before dumping the info? >> > I overlooked that. I will add it in the next version. > Thanks Sathya for your comments. if you plan to zero out the td_sys_info value in error case, I think it is better to make the tdg_get_sysinfo as void > > Thanks >      --Yi Sun -- Sathyanarayanan Kuppuswamy Linux Kernel Developer