Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4408865pxb; Mon, 21 Feb 2022 20:38:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+8oqgkehETM9gPmpA/rDIs+9zBxl/wtEeoRKBzgVVtvA5jYy/yNgPEEuUIGgRt1ys4uNG X-Received: by 2002:a63:6201:0:b0:372:d3d1:a684 with SMTP id w1-20020a636201000000b00372d3d1a684mr18423032pgb.523.1645504703555; Mon, 21 Feb 2022 20:38:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645504703; cv=none; d=google.com; s=arc-20160816; b=lmuQqePNfozFt4tCTtjSODXaQ0FTAUZr0K9Ztw71HsD+LQ1HPgOhFloJnH07S/9VYX sqnHUKEOcKHVrwKIwWXI/MWces+4dBMjNzta2a6zQsoceJPURB35cvwmz5RiaKWVoDDc FVYli2AcvP1vpZZyyUyB5dNtTAF+mn+FjCkwKLPR+uoiHIhDHLbbR0w16KnnKahCujJY M70gjK69f8/1cTK1ulgg0joHTpOdSbONb/RC6JzXO7XA70ujv53HPC8pQeTp03yKZRyq VnaoAvCve+JjpIalkiaYjnA7fvUoK/+7jeiQ9nLvFPBnihtJN1iTZwzhk0x/3stnPO8+ 4tuQ== 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=l3l7QPOBiZegguSKl75l8EIKwXsvCfeQMTqIqX4BHG8=; b=mSl0lh1/zNwDH8RbnYW8MGY9L3Gxa9PtTP3HODAlOSuBw7866PMrdaLizqhQ1Awkoc pLMiSKHHA4jThJbHC3wjVSebZjlMbiOxftNIJrsLfhHrpOBK/KjsxWwvH457JyTfFvzu 6ILMHsff3k9B05CQrty5bFKsKJk0u7mzx71Gr8Itca/9p7O8d8rfTliuEwwZVteVx7j5 2XpTX4OVJSvLTSJCXN3nK0qWvJzGAz2LgYKQHTbFpB9Ud5yy5GG1FBVFMZG0e2an8L6i 3qao1XiepUCKglkckBfzRCWFNdjTOZq/BpcAqprbSCCmBRofgioeIuSPq7Xd3hBI5lpy bypA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=epajSyEC; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id p2si7394797plp.303.2022.02.21.20.38.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 20:38:23 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=epajSyEC; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 482019EB8A; Mon, 21 Feb 2022 20:26:22 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376730AbiBUNx5 (ORCPT + 99 others); Mon, 21 Feb 2022 08:53:57 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376788AbiBUNxs (ORCPT ); Mon, 21 Feb 2022 08:53:48 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BB9FDE9E for ; Mon, 21 Feb 2022 05:53:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645451605; x=1676987605; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=ErfHXPfkw5Ja9S/Lcj6RYf+Mflg/caQz6cN0PzobeDU=; b=epajSyECE+nmk4J9PUVUlwidiHWg6YfypkWY1+Dfjfjs//nPJsgODVG2 EpwFR3C9NDjtDnnRfkfZJsdStpNAzOkXw4DoniItUYXozROBSZRbxhOAg 3HeCTHV8GPlatjzII8rhZSCQqiA2EltmG+ZYJzBvTPbc2uiefb5WFisgw iI1NdatzjzrD/Pr5Z8dg9JVH6tUpE35bppKHGa/zp0doTycHNqSesla0s QdIZ02GzEg9ycUfjsUq4WX9wd3aj3VCodiaObzEDd0l0JYRrIf3hY9ipG 1SL80EDX5qUM8EGzTh5wS6/Ds9uEyluFQyYRgXc1WU5rtKTedBw/j1q9T w==; X-IronPort-AV: E=McAfee;i="6200,9189,10264"; a="337942288" X-IronPort-AV: E=Sophos;i="5.88,385,1635231600"; d="scan'208";a="337942288" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2022 05:53:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,385,1635231600"; d="scan'208";a="505082386" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 21 Feb 2022 05:53:18 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 13737161; Mon, 21 Feb 2022 15:53:34 +0200 (EET) Date: Mon, 21 Feb 2022 16:53:34 +0300 From: "Kirill A. Shutemov" To: Cyrill Gorcunov Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@intel.com, luto@kernel.org, peterz@infradead.org, sathyanarayanan.kuppuswamy@linux.intel.com, aarcange@redhat.com, ak@linux.intel.com, dan.j.williams@intel.com, david@redhat.com, hpa@zytor.com, jgross@suse.com, jmattson@google.com, joro@8bytes.org, jpoimboe@redhat.com, knsathya@kernel.org, pbonzini@redhat.com, sdeep@vmware.com, seanjc@google.com, tony.luck@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv3 13/32] x86/tdx: Detect TDX at early kernel decompression time Message-ID: <20220221135334.zzcozxu6vyskxjzo@black.fi.intel.com> References: <20220218161718.67148-1-kirill.shutemov@linux.intel.com> <20220218161718.67148-14-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Mon, Feb 21, 2022 at 02:37:29PM +0300, Cyrill Gorcunov wrote: > On Fri, Feb 18, 2022 at 07:16:59PM +0300, Kirill A. Shutemov wrote: > ... > > > > + > > +void early_tdx_detect(void) > > +{ > > + u32 eax, sig[3]; > > + > > + cpuid_count(TDX_CPUID_LEAF_ID, 0, &eax, &sig[0], &sig[2], &sig[1]); > > + > > + if (memcmp(TDX_IDENT, sig, 12)) > > + return; > > Maybe worth to guard ourself, like > > BUILD_BUG_ON(sizeof(sig) != (sizeof(TDX_IDENT)-1)); > if (memcmp(TDX_IDENT, sig, sizeof(sig)) > return; Sure. Will do. -- Kirill A. Shutemov