Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4953683pxb; Tue, 5 Oct 2021 14:07:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuk70KY9WnGRjexYCZue1Q2ueRzK3HpoJuP+v0btV6BP7mxhFXPgnQuuK6ZfzDH+tmQKIS X-Received: by 2002:a50:9d4f:: with SMTP id j15mr29669442edk.68.1633468026140; Tue, 05 Oct 2021 14:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633468026; cv=none; d=google.com; s=arc-20160816; b=XNbYOPG/CTxWXcQQ7va9XutCxi5JEZbqOihmk6eLAazKez328sB2wuXAhp1mUDnwBU lratZi1bVkE472xVZvwjePcIc7s+b6XERoIRxFwE1YoR54FIhFtqmy2Ym2d7dtNCzL1W 5LQRU7m9RFLLvuBDk8ZD6N4KBbE0VdSnw4uwvjJCP2yFEDmem/2Bq2kp7VcfufZT6twD EZdp2uov1hvfzMVjk+mz8iv680+ByUozFIewQayUEWGiF7ozIzNOW0IgEYfGsOToQUgR Vp/lJ33K/VlwdD+6XSs/0i1w5eqZ+f6zw0Q4hgclUfjp16/PLEmqi/T3xU+u6mEYgTq6 UhUw== 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=qSi/EGCkMZaOb1CBlFluZpZE3DLb0hdQi2z1tMhFOGA=; b=UhAylLBkZv2GwmdTm/pqHOxqvwfFfM4sDuFVToWiBLUdUSg3lZgHOv53rdDWisPzpm Rm8/dQbIhuGTcx9EUzJa7mC1Osi4bKqAu9XpgVELkcSDbWkS8jIodbYjawD5aIATjrZj MLWECX1NcdSbrDRQlZ578TDp6QSaofn19+u8lwWFOO+Xwe1c8dvE0DcciLAc9NYE5XTy qu8Z2Y4XkmmYO3e9kg0upMEisPeiQPFBSvFlxWXlwm7l/j/0WZ5cpVLJGrEJbIljFm1j fiolbCCecUADBBEB6CZngbf9Ov0PzpBs20wq2yNv1zky9M2mREEn7kgyol9EI0/ahIGP QZAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OT8y6nHI; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 28si23225421ejh.738.2021.10.05.14.06.41; Tue, 05 Oct 2021 14:07:06 -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=@redhat.com header.s=mimecast20190719 header.b=OT8y6nHI; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236550AbhJEVGV (ORCPT + 99 others); Tue, 5 Oct 2021 17:06:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58993 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231322AbhJEVGU (ORCPT ); Tue, 5 Oct 2021 17:06:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633467869; 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: in-reply-to:in-reply-to:references:references; bh=qSi/EGCkMZaOb1CBlFluZpZE3DLb0hdQi2z1tMhFOGA=; b=OT8y6nHI8pLFxfRXJMzPrA89IDdLJe665sTwmAO9N0BCn5yzXSyGOB30+vEzY+LqF68hfy XHxMY97V1nRIGHv4hNbhtQ1AWBShb+AcWeOvU+5RVAj4wgeTjyyRl7g/M8gAILy/QAO/7r j0m/cSM9rPaMq+QPAr37sFBBjmXp2P8= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-341-Z8ws3IoWOhmxrGuuEfbXAA-1; Tue, 05 Oct 2021 17:04:28 -0400 X-MC-Unique: Z8ws3IoWOhmxrGuuEfbXAA-1 Received: by mail-qk1-f200.google.com with SMTP id s18-20020a05620a255200b00433885d4fa7so301541qko.4 for ; Tue, 05 Oct 2021 14:04:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=qSi/EGCkMZaOb1CBlFluZpZE3DLb0hdQi2z1tMhFOGA=; b=P70vAKq3/zirvUI6Z6+WkOVzKo04KIJZyhe6ju9uFQ0jHOszXG+HLxjSYwaz02Y2a5 8dIKniirq24Sk0XDAwIJQp91hQmHVfI0he8stcAEAmTqJaIXkoPVtDHl4RFKq2nTLnOX aTMuck7X/jnYM49aVOyOa4ZYSeMyPcIUR4CzIJuDxDhxcGPDDJRJYs93uBkC1N4T1Du7 85OaSVb812MMbKC81Fp0RinqDUyy5QqBTs2qqBAtM8VoRpOyODrXESDVFidRsjknrp+T VXbATAVpcFTEmsgCweHqGhAkPs2uf0tFcu+EBmDL7zJ5d+Hr0I1J1GDW+6GIb+nVXkXE J3kQ== X-Gm-Message-State: AOAM532qRvVuTKmnNLCEhSB1yfBva+5/n1RWcfZsTb586ooLq6nWXOpr rZttptTJNfpiVijbQgi1RYBAgY1Riv1aaC5MtE4ey3xKCq72EpAv3iJ1VJ5xs5K2Ree2gg0Qi1L 1L+9Ih8kd8bxNn3sjOpXVdCjH X-Received: by 2002:a37:63c2:: with SMTP id x185mr3094643qkb.223.1633467867955; Tue, 05 Oct 2021 14:04:27 -0700 (PDT) X-Received: by 2002:a37:63c2:: with SMTP id x185mr3094615qkb.223.1633467867684; Tue, 05 Oct 2021 14:04:27 -0700 (PDT) Received: from treble ([2600:1700:6e32:6c00::15]) by smtp.gmail.com with ESMTPSA id h5sm10360324qke.1.2021.10.05.14.04.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 14:04:27 -0700 (PDT) Date: Tue, 5 Oct 2021 14:04:23 -0700 From: Josh Poimboeuf To: Kuppuswamy Sathyanarayanan Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, Paolo Bonzini , David Hildenbrand , Andrea Arcangeli , Juergen Gross , Deep Shah , VMware Inc , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Peter H Anvin , Dave Hansen , Tony Luck , Dan Williams , Andi Kleen , Kirill Shutemov , Sean Christopherson , Kuppuswamy Sathyanarayanan , linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 03/11] x86/cpufeatures: Add TDX Guest CPU feature Message-ID: <20211005210423.yfftpxxmj3cjprtv@treble> References: <20211005025205.1784480-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20211005025205.1784480-4-sathyanarayanan.kuppuswamy@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20211005025205.1784480-4-sathyanarayanan.kuppuswamy@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 04, 2021 at 07:51:57PM -0700, Kuppuswamy Sathyanarayanan wrote: > @@ -495,6 +496,13 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data) > > copy_bootdata(__va(real_mode_data)); > > + /* > + * tdx_early_init() has dependency on command line parameters. > + * So the order of calling it should be after copy_bootdata() > + * (in which command line parameter is initialized). > + */ > + tdx_early_init(); Which cmdline parameters are those? > +/* > + * Allocate it in the data region to avoid zeroing it during > + * BSS initialization. It is mainly used in cc_platform_has() > + * call during early boot call. > + */ > +u64 __section(".data") is_tdx_guest = 0; Or you could just give it a -1 value here to avoid the section annotation. Not sure why it needs 64 bits, any reason it can't just be bool? > + > +static void __init is_tdx_guest_init(void) > +{ > + u32 eax, sig[3]; > + > + if (cpuid_eax(0) < TDX_CPUID_LEAF_ID) { > + is_tdx_guest = 0; > + return; > + } > + > + cpuid_count(TDX_CPUID_LEAF_ID, 0, &eax, &sig[0], &sig[2], &sig[1]); > + > + is_tdx_guest = !memcmp("IntelTDX ", sig, 12); > +} > + > +void __init tdx_early_init(void) > +{ > + is_tdx_guest_init(); > + > + if (!is_tdx_guest) > + return; > + > + setup_force_cpu_cap(X86_FEATURE_TDX_GUEST); > + > + pr_info("Guest initialized\n"); > +} What's the point of having both 'is_tdx_guest' and X86_FEATURE_TDX_GUEST? Are they not redundant? -- Josh