Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp66338pxt; Wed, 4 Aug 2021 16:00:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHPyb61+y8NYeM44vVkOwsWXh+TFoQMLtHBhWwBZgGg4Gc33MEsAO1CEzGQvRKlaUWgPoK X-Received: by 2002:a17:907:3e0d:: with SMTP id hp13mr1442445ejc.372.1628118031487; Wed, 04 Aug 2021 16:00:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628118031; cv=none; d=google.com; s=arc-20160816; b=yMj4ShY86bHm78dtd+Vyz6BE8nzGddSZboVtlAxzfdLdFwCOJm71nb93U4fLgYJHJy VZzebtF8BBSujb7waBguNwiP/HvAZrZjsnqvqVjinp/hmpluDqU4LScrPwhgEFRMKJgW 4GE4j6/vWrp8H6e4KhgEWMrkeJdUUibx7FZigNMgwLtMuqNoPO2bFl99M9onO9yq/7Dq 0tUvWw6TDVqexih78EYaTwLBgl1AWonvQQhvzTzpsV+lFuXgM5i3kmFmrtiHVBZoHxDf sKtVqpq0DewQgytJFwf+j0qh+OiGcGVPORrDGJFXnhiPuSuKFqPeZ0WKeg6bkR23Dry7 b9iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=aVyHYA4wWqGiHay7mEaNY+3DhCOe05sArbi0hivwJ5Y=; b=gV9QsEckkSnGY9ymN2YRbNnZg1syOw5+aV/HGy+FjgtiacI/o1fNBcAhXvjm15cfdb HB7quwul/zyJLq6j2GkBVnSww3DEw/18pjVutbLfLyxSy4IkKX/soCqGW9hSVy9H6ZAv C48LxP610jeGie5mABqiMko+xH1oIIe7Vx6n814fS3t0pVuULfnW8wdJfa3606a+XIN2 ftuegDzuSECTOi8JSwuKJsbQxl8kTD3OTCMZzcn4XcZzASbCE9qNCILKjNCjnNfVacHa oZK+PjYSxpIKwgzpeBjVPskSa2MqUpf8TAY5bSICBKaBGpb7hZgr1O8XM924AaP/aU9E UZ1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bQHh6iZo; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e10si3328179ejy.33.2021.08.04.16.00.05; Wed, 04 Aug 2021 16:00:31 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=bQHh6iZo; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231506AbhHDWi7 (ORCPT + 99 others); Wed, 4 Aug 2021 18:38:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229611AbhHDWi6 (ORCPT ); Wed, 4 Aug 2021 18:38:58 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2E54C0613D5 for ; Wed, 4 Aug 2021 15:38:45 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id i10so4730636pla.3 for ; Wed, 04 Aug 2021 15:38:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=aVyHYA4wWqGiHay7mEaNY+3DhCOe05sArbi0hivwJ5Y=; b=bQHh6iZoHgv3of+vKoqb4SE9Dqb+7J9TZIYjRdNb11jGshOmj+T9wfEAZ+umwzQqUm HmX+pyIFlNF/OtxMkfoHRzYm6kNua6Z+7+wJnSPcIUnyKkIRipatDWnG6G5m85tyN9LG 1T+FXeZDHYkN13NRdnT3VLZSD2inTZPd6nRfAF1EPJ4yBL2f2zgd5jHbXb5xjjnlA1s+ PePT9ctxmj2wVFaKMuOxLdtsT9odHaIBEUxsGij60389zdsM5ZVrIjwRJjosBWela1VD 5YDPfdrorcM/6nWWhb+Y0xmVX4X6f18cDJ4NTbsMyIZRbvQavbBdtS9keKoqWkc4LQWv 73Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=aVyHYA4wWqGiHay7mEaNY+3DhCOe05sArbi0hivwJ5Y=; b=b1h1IHAbOQUzHNgv8Vn5rdNiyXA6SzeowS5K/4s29FmhqaKh/jo8RMwC7u5mUkaBc5 KWZdaaIIk2rtpO68auQbSuw1Z1WpyPI0VDD+JDVaDGsF5+vHfKkY1MsSZsZGh+vLhR4F QU1awz6MlxJdZllAkq/SjpL43yKtFAt0jIePR22dLZ/+yCPdY2eZ8dgPp60rGHqVPelE bEJ3PCymdQJCsZsOavclJR26ylfNyPBv2NJmO9vE3Q5SNsM3okd4rOfdF/Imy6Yl21CP Kdf9+xmzJT/qUjK8WKmdHMYF1RG1BBX1kQjWeJoSooAg5POngqOqstEHUHse//QAxZlv HqPA== X-Gm-Message-State: AOAM530YkAkCdKMG0rxyUWXY6aqIa6WQHMha5x648ZqCSDVPS7PFbhIm R8FoQV4WTxt4EktbplIXuU6byw== X-Received: by 2002:a65:428b:: with SMTP id j11mr11402pgp.301.1628116725269; Wed, 04 Aug 2021 15:38:45 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id j15sm3968550pfh.194.2021.08.04.15.38.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Aug 2021 15:38:44 -0700 (PDT) Date: Wed, 4 Aug 2021 22:38:40 +0000 From: Sean Christopherson To: Kuppuswamy Sathyanarayanan Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Andy Lutomirski , Peter H Anvin , Dave Hansen , Tony Luck , Dan Williams , Andi Kleen , Kirill Shutemov , Kuppuswamy Sathyanarayanan , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 06/12] x86/tdx: Get TD execution environment information via TDINFO Message-ID: References: <20210804181329.2899708-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20210804181329.2899708-7-sathyanarayanan.kuppuswamy@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210804181329.2899708-7-sathyanarayanan.kuppuswamy@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 04, 2021, Kuppuswamy Sathyanarayanan wrote: > diff --git a/arch/x86/kernel/tdx.c b/arch/x86/kernel/tdx.c > index 287564990f21..3973e81751ba 100644 > --- a/arch/x86/kernel/tdx.c > +++ b/arch/x86/kernel/tdx.c > @@ -8,6 +8,14 @@ > > #include > > +/* TDX Module call Leaf IDs */ > +#define TDINFO 1 > + > +static struct { > + unsigned int gpa_width; > + unsigned long attributes; > +} td_info __ro_after_init; > + > /* > * Wrapper for standard use of __tdx_hypercall with BUG_ON() check > * for TDCALL error. > @@ -54,6 +62,19 @@ bool tdx_prot_guest_has(unsigned long flag) > } > EXPORT_SYMBOL_GPL(tdx_prot_guest_has); > > +static void tdg_get_info(void) I've already made my dislike of "tdg" abundantly clear, but I will keep on complaining so long as y'all keep sending patches with "tdx" and "tdg" interspersed without any obvious method to the madness. Also, a function with "get" in the name that returns a void and fills in a global struct that's is a bit misleading. > +{ > + u64 ret; > + struct tdx_module_output out = {0}; > + > + ret = __tdx_module_call(TDINFO, 0, 0, 0, 0, &out); > + > + BUG_ON(ret); > + > + td_info.gpa_width = out.rcx & GENMASK(5, 0); > + td_info.attributes = out.rdx; > +} > + > void __init tdx_early_init(void) > { > if (!cpuid_has_tdx_guest()) > @@ -61,5 +82,7 @@ void __init tdx_early_init(void) > > setup_force_cpu_cap(X86_FEATURE_TDX_GUEST); > > + tdg_get_info(); > + > pr_info("Guest initialized\n"); > } > -- > 2.25.1 >