Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3870049pxb; Tue, 19 Apr 2022 11:26:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzT/vgr6POQCDcPHbZYSag2JpC2TAuCJE6h17MerG6w+6JkikbGVnMANwRHFJLAEm+jT1X/ X-Received: by 2002:a63:c22:0:b0:39d:a9ed:ebc6 with SMTP id b34-20020a630c22000000b0039da9edebc6mr15980673pgl.350.1650392809816; Tue, 19 Apr 2022 11:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650392809; cv=none; d=google.com; s=arc-20160816; b=hl8CRIhHU+b8T9iPGqas2bQ5vyt5qWVIcU5WPrAGTMXq2u4UxJNLl8xtT2v4uiAEpt tMvC99FeEqMn3BfkqtT14iL2+Yf67Bt40la1Olcys6Mp3zEcRwcqFaZI0EIg8XOqavqY RypTPK3+T/BQi8EUIsrUTUeR8TbsdEi/iuVxn9ZdKj6Fk6DDMr0dzsb73+VgwMZhWSNk inshBlDw/zo9VilPtJWunvERYv6nQA2RDq8e53g+xkJE+QOEpJxv4tel3DFNfUq5R+sZ 3V19IM9wXJXp+OG7/CkgTXC2XmMsO9n8BLIGIV7QOA2DdifJQKbAVyuiufHbaWRkA4qQ CNvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=rD91uzCvDSspNfAkPwjjMGEMbYTspgKQlhhntg+kVMo=; b=HlodtNw/yZJkQpghrAdWMcYfIiPNQrGKZtgpAt5eEZFGmmgC+ixMv6dWt75qEDXA3R SE7dfo1w3py6NVK4dss4dbIoblg4mEGhJ5f+i1s/zE9QssXchVZ5jebR65H7y2ZPeKEd 1oiJtPvRoCG/u+0DpPRqkbpXjdFJXIShuhBnfrnTuP3oTkNUYBeOSHFgY54RjifGaLA5 tsaFtPxAa3ot1XJDc5dyqAbeJ8DDCdoa3s3Adn/qPP/ECqo3i6garugP2+NZGkI5jYut kEAF+SS83tn4h6eT5NRlIPtATRsOhb4NF4QcoDTagvC6t1SD7H/8Yl0mPSWfJ9w+trb0 CD4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RV3v7IwI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a170902f31100b00155d894798fsi10677311ple.362.2022.04.19.11.26.34; Tue, 19 Apr 2022 11:26:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RV3v7IwI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348157AbiDSDlc (ORCPT + 99 others); Mon, 18 Apr 2022 23:41:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231829AbiDSDl3 (ORCPT ); Mon, 18 Apr 2022 23:41:29 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DA37B1FA; Mon, 18 Apr 2022 20:38:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650339528; x=1681875528; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=TQyDAhIW68Som/ku3Jrd/qF0VCpteuvHqR0Y8MoNXvY=; b=RV3v7IwIAHi+ELmcPfPRCO2eB0gVjs7KEYDlif02wZJRDXpBUyksNAWN P22cK20zgEI+QckLFlR5VEOSJ263W/F9bTRLCTgZUkEnMZ9U+sQ939E6e UZO5N0UTyV99ma5dAtvE4daFaAWlQejjPf5JuUQtbmpEpwhB70DfRGU5W fadgDlZgD0u+ull9UjsLckkLHGiphmVF8Wi2AL6nyYspGUaeCJjAMdkL8 E7gqU2D1Ry/Qsjw96urCZXMd1OkVXzWoL4D+pTzzoB/RZO0TLAcx5JF9p ABje7BJ4dAnOQ6/devUiC1yPzW+d95FAligGhPNkA3K1mFfgEydysX+rx g==; X-IronPort-AV: E=McAfee;i="6400,9594,10321"; a="288760826" X-IronPort-AV: E=Sophos;i="5.90,271,1643702400"; d="scan'208";a="288760826" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2022 20:38:48 -0700 X-IronPort-AV: E=Sophos;i="5.90,271,1643702400"; d="scan'208";a="554524814" Received: from jaspuehl-mobl2.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.254.31.185]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2022 20:38:44 -0700 Message-ID: Subject: Re: [PATCH v3 01/21] x86/virt/tdx: Detect SEAM From: Kai Huang To: Sathyanarayanan Kuppuswamy , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, pbonzini@redhat.com, dave.hansen@intel.com, len.brown@intel.com, tony.luck@intel.com, rafael.j.wysocki@intel.com, reinette.chatre@intel.com, dan.j.williams@intel.com, peterz@infradead.org, ak@linux.intel.com, kirill.shutemov@linux.intel.com, isaku.yamahata@intel.com Date: Tue, 19 Apr 2022 15:38:42 +1200 In-Reply-To: <8e2269a7-3e71-5030-8d04-1e8e3fc4323f@linux.intel.com> References: <8e2269a7-3e71-5030-8d04-1e8e3fc4323f@linux.intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-1.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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 > > + > > +static void detect_seam(struct cpuinfo_x86 *c) > > +{ > > why not do this check directly in tdx_detect_cpu()? The second patch will detect TDX KeyID too. I suppose you are saying below is better? void tdx_detect_cpu(struct cpuinfo_x86 *c) { if (c == &boot_cpu_data) { detect_seam_bsp(c); detect_tdx_keyids_bsp(c); } else { detect_seam_ap(c); detect_tdx_keyids_ap(c); } } I personally don't see how above is better than the current way. Instead, I think having SEAM and TDX KeyID detection code in single function respectively is more flexible for future extension (if needed). > > > + if (c == &boot_cpu_data) > > + detect_seam_bsp(c); > > + else > > + detect_seam_ap(c); > > +} > > + > > +void tdx_detect_cpu(struct cpuinfo_x86 *c) > > +{ > > + detect_seam(c); > > +} >