Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3649021iob; Sat, 7 May 2022 10:47:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+5D/uotXp4+2NH7NF9yEWh5SeAyRnQyvkxQAfYem+vEbuLp5cnCtPNpgmDge+V+4/3sU5 X-Received: by 2002:a17:902:c14a:b0:15b:9c29:935a with SMTP id 10-20020a170902c14a00b0015b9c29935amr9010502plj.2.1651945644609; Sat, 07 May 2022 10:47:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651945644; cv=none; d=google.com; s=arc-20160816; b=NXAtQYSLujmbzvWs0dEjjkoTju8/F97vJA4EWJ5r7rYy0NfOT6IAYsGEMJLjvZGbyn wa5BG5M+xT7qtcFEJ9zrzOEmcRYLcMvxKJvEn9QxXuTaOkvUaTghi1LCFCVDtzLR82Z9 I2dFp3ZWgY9lVGrD9JdUa8hjZ83E8fudyoNNkE2Ren08dpwNzShnsV0L7gxBuwG2xcAs 5NcBRefsiBZdZAjx1djY/fIvz1GKHy0kEem3gDqnMjxGyhBXQfymlZ261TE3Yqp4sjRf uMlFaTNjJZnHimCesbnHOLhxsYGhMqFG7lW2oCjGKs1F7m42JnDUdUG5fCNyRHYCQQi5 fHuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=6qT9B79QXkLWw17UF4jXkgLnzsIOvLk4zlsmk1fzfpA=; b=q0KLGOQ3fJUDQE0rJcMEuQlidA38YN4//OdlYN7or0cYl4ydQLl3192VxGdZfzp6OU vC7lLbtSxH/gwLAloVm1xJr4eXzsN/n9ZpwShz+zcxAwK/jEAte2D95jCRrrAK5XL4kv GZg5n2OVfUN+yioNjutCcjNhKpxT4jUbm3bNObwRzJwLxwsqVus2kJB53K87tP0s8ac9 X1DCtvhJ1qEmgYOcQ+ZC4pxeyX5CIC+wG2TnZQEv1sFiflxUc/dL07kI2PJVOidlsq1J ZqwAviTJRyS+VGgGmgQlqKmbiCWU+cIKZ4f9u7HmB8z1aCAPlGm1nyo7941O1jiWbOxf ZY3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GvND7ulv; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o18-20020a63fb12000000b003c1d90dd51csi8233097pgh.291.2022.05.07.10.46.31; Sat, 07 May 2022 10:47:24 -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=@gmail.com header.s=20210112 header.b=GvND7ulv; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444477AbiEFVdT (ORCPT + 99 others); Fri, 6 May 2022 17:33:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444464AbiEFVdQ (ORCPT ); Fri, 6 May 2022 17:33:16 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1F7D6F4AB; Fri, 6 May 2022 14:29:32 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id c9so7930569plh.2; Fri, 06 May 2022 14:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=6qT9B79QXkLWw17UF4jXkgLnzsIOvLk4zlsmk1fzfpA=; b=GvND7ulvJ0NlO8EOj5vYXO3AtWWcVqs0iZMXTw0tKe5MktIsJXcjT9wDj+TMCSW9Li RBPsDcKG4kR1+fAkhLTmfqFxdFFxxI/GywIqM3uqDHktjpW3N4l55OExoVNeu0vYDmy1 XUzIVOq+ghsC7rX3iE3RJTcmDbce9Lhb4vHntWS7Ty8WXzUtymUNgjdXBycqV2t7Qa1W jk4wz36U1WMeXLLKjcJoz3kblEc1opFCk0ZtMxiX3KbvxDooJXRhb86ZCw4ovGBx5Y/a iRKW2QJLnCLCUIN6CHzM3CUTtzgeQ1igX0UoYIMXbSXDUyY3QvqecA7WDNbLHS69r8Df DuGw== 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:user-agent; bh=6qT9B79QXkLWw17UF4jXkgLnzsIOvLk4zlsmk1fzfpA=; b=2v5h8H02tB9Xmc4yMgMvFSsWLR4Yaf+khTw99HhVLMSjKtnHuXiFvUZvY0oaM3crjn 2OiXsDFbGa9O1nANZ92sKGoOJiDOM0dJWBOndsCjDAFmkMWwcdp2fpMC0iee1uxQliYl ofJqhdHBjshgiX1U/sQGynqg2WxVOBT2DXMDBxTC1vF3LFDU4XXgJzussPDnZsup4PQq oF3tBYKUuKoNSIhobYaUaZE8e1y4rF3TacPuSIGk6iaAsec6NqPTpCGUNPEnj3T0bxMQ ZvQ/s3Jjcy72xKmoe5OH1OAB95w7tC8eW+fY5tcL8LyhvKHvDK3flqrTquAhoyVEubk2 M92g== X-Gm-Message-State: AOAM5312T5XyssIht7o4E54+3sXGHg3ktR68dxDOGM3SYBeILy9LijHG 9VWfhBLV331sAs+p+Yb8BDW9KfJb0n0= X-Received: by 2002:a17:902:7104:b0:15e:ddb8:199 with SMTP id a4-20020a170902710400b0015eddb80199mr5728782pll.80.1651872571978; Fri, 06 May 2022 14:29:31 -0700 (PDT) Received: from localhost (c-107-3-154-88.hsd1.ca.comcast.net. [107.3.154.88]) by smtp.gmail.com with ESMTPSA id s66-20020a637745000000b003c25a7581d9sm3739161pgc.52.2022.05.06.14.29.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 14:29:31 -0700 (PDT) Date: Fri, 6 May 2022 14:29:30 -0700 From: Isaku Yamahata To: Xiaoyao Li Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar Subject: Re: [RFC PATCH v6 011/104] KVM: TDX: Initialize TDX module when loading kvm_intel.ko Message-ID: <20220506212930.GA2145958@private.email.ne.jp> References: <752bc449e13cb3e6874ba2d82f790f6f6018813c.1651774250.git.isaku.yamahata@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 On Fri, May 06, 2022 at 09:57:09PM +0800, Xiaoyao Li wrote: > On 5/6/2022 2:14 AM, isaku.yamahata@intel.com wrote: > > +int __init tdx_module_setup(void) > > +{ > > + const struct tdsysinfo_struct *tdsysinfo; > > + int ret = 0; > > + > > + BUILD_BUG_ON(sizeof(*tdsysinfo) != 1024); > > + BUILD_BUG_ON(TDX_MAX_NR_CPUID_CONFIGS != 37); > > + > > + ret = tdx_detect(); > > + if (ret) { > > + pr_info("Failed to detect TDX module.\n"); > > + return ret; > > + } > > + > > + ret = tdx_init(); > > + if (ret) { > > + pr_info("Failed to initialize TDX module.\n"); > > + return ret; > > + } > > + > > + tdsysinfo = tdx_get_sysinfo(); > > + if (tdx_caps.nr_cpuid_configs > TDX_MAX_NR_CPUID_CONFIGS) > > + return -EIO; > > It needs to check tdsysinfo->num_cpuid_config against > TDX_MAX_NR_CPUID_CONFIG > > or move the check down after tdx_caps is initialized. Thanks for catching it. I'll replace it with tdsysinfo->num_cpuid_config. -- Isaku Yamahata