Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1641987pxb; Fri, 20 Aug 2021 10:14:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkQVs5lD8b3ss1eVfdTymPY5Dyk8mPWuhlfh2euT5Ywd9XPSM1rGoal8p8fJ7EhfNWmpla X-Received: by 2002:a17:906:491a:: with SMTP id b26mr22949159ejq.25.1629479662276; Fri, 20 Aug 2021 10:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629479662; cv=none; d=google.com; s=arc-20160816; b=je0Uetwbs6oRlC4qyZocRSQWLWRVbiknJHH2gbLd1Vdw7XMbXpiEHCiipo+R7xPnKl F6HxbnsnkTAf2lNIHTYli5IhVPin/H9a8eWX9tFqstY/yM/olaaQmAwZx8bL/ZYZLTjX eozwb5S7fRGaWjfyLWmK7pj0kuMdoNYJEEysimkNgy2E3uWEftDcPdr8rk/0CYW184Sf b/vfCmDsnnG0lM/Ro9eC9soTIl/D7CJZZmtO5NybZF0reYj8DtBdPERTaC0YKGYGKpYT aYsyWDhPlXUYslYesXYbQ9G9yA6hCuuDjSOx4MScxpHmLmEdBdSHMOES7+bE2LKJcOM8 Oo2Q== 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=S4jTLQYXku/9jh4+L0ipAB4Go6isuVtIEWY084R3acs=; b=ZUEwWo8M0q58NtQGjV7C1aEDlqYcZamcqqHaNz1oSe3w1PwpOgMfxNQdBPOgS+oB75 Gqo6v1zHb1LEI4RjXiitQtxM9jMTZE2wYHs8vSxmWJlI1wGeieEmVi5n7TfcthdpMv3X nR0g+q0tRGYjr2oXWrzO1P9nxrilANQQuK4t4oCNsqgNAk3ikE+K19nikRsFiYg6D/Qm cUPZaUwYbu0S8wmVby8Puc/T6Zb9/FZcSAF1YxKuIewct6f43+2umsluiwvcgMtMvUFb nrAfXYfmHwo1rb9QXPMQH5e4gM5hym8e/QQ9tGSUxSS/eopsjZCW/kjaLo77XXLwnywF RgqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=m65S1MDu; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q9si7283415ejn.647.2021.08.20.10.13.58; Fri, 20 Aug 2021 10:14:22 -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=@alien8.de header.s=dkim header.b=m65S1MDu; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233028AbhHTRNI (ORCPT + 99 others); Fri, 20 Aug 2021 13:13:08 -0400 Received: from mail.skyhub.de ([5.9.137.197]:48062 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230052AbhHTRNH (ORCPT ); Fri, 20 Aug 2021 13:13:07 -0400 Received: from zn.tnic (p200300ec2f107b0070f9113f083a3500.dip0.t-ipconnect.de [IPv6:2003:ec:2f10:7b00:70f9:113f:83a:3500]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 41C4D1EC0589; Fri, 20 Aug 2021 19:12:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1629479544; 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:in-reply-to:in-reply-to: references:references; bh=S4jTLQYXku/9jh4+L0ipAB4Go6isuVtIEWY084R3acs=; b=m65S1MDuRHDhfyL4Lim7QkFQLc8a3FcTndsNB1G3hhVph0E1vSuCHzCCbk22W5a5VMKtEO 4RRrjhzwVOmUO2oeaFpJl+taxV+TMe1vjkEGGFPPC1oUXRZpzseNdAttbAMrfDWFTTai97 GfPZYtBQqrkNF2TnKK9OWNP0VnqbHAA= Date: Fri, 20 Aug 2021 19:13:03 +0200 From: Borislav Petkov To: Kuppuswamy Sathyanarayanan Cc: Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Andy Lutomirski , Peter H Anvin , Dave Hansen , Tony Luck , Dan Williams , Andi Kleen , Kirill Shutemov , Sean Christopherson , 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=utf-8 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 at 11:13:23AM -0700, Kuppuswamy Sathyanarayanan wrote: > From: "Kirill A. Shutemov" > > Per Guest-Host-Communication Interface (GHCI) for Intel Trust > Domain Extensions (Intel TDX) specification, sec 2.4.2, > TDCALL[TDINFO] provides basic TD execution environment information, not > provided by CPUID. > > Call TDINFO during early boot to be used for following system > initialization. > > The call provides info on which bit in pfn is used to indicate that the > page is shared with the host and attributes of the TD, such as debug. > > Information about the number of CPUs need not be saved because there are > no users so far for it. > > Signed-off-by: Kirill A. Shutemov > Reviewed-by: Andi Kleen > Reviewed-by: Tony Luck > Signed-off-by: Kuppuswamy Sathyanarayanan > --- > > Changes since v4: > * None > > Changes since v3: > * None > > arch/x86/kernel/tdx.c | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > 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; Where is that thing even used? I don't see it in the whole patchset. > + > /* > * 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) Also, what Sean said: "tdx_" please. Unless there's a real reason to have a different prefix - then state that reason. > +{ > + u64 ret; > + struct tdx_module_output out = {0}; The tip-tree preferred ordering of variable declarations at the beginning of a function is reverse fir tree order:: struct long_struct_name *descriptive_name; unsigned long foo, bar; unsigned int tmp; int ret; The above is faster to parse than the reverse ordering:: int ret; unsigned int tmp; unsigned long foo, bar; struct long_struct_name *descriptive_name; And even more so than random ordering:: unsigned long foo, bar; int ret; struct long_struct_name *descriptive_name; unsigned int tmp; > + > + ret = __tdx_module_call(TDINFO, 0, 0, 0, 0, &out); > + > + BUG_ON(ret); WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() #121: FILE: arch/x86/kernel/tdx.c:72: + BUG_ON(ret); Have I already told you about checkpatch? If not, here it is: Please integrate scripts/checkpatch.pl into your patch creation workflow. Some of the warnings/errors *actually* make sense. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette