Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3488466pxp; Mon, 14 Mar 2022 22:15:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxpTJFUcSim0EbJ1e+X5v3bm7u7F92cwjrPyQbLB48+19X3eiGqibcFr/TmeQx1kns7UwH X-Received: by 2002:a05:6402:27ce:b0:416:9d78:9f1f with SMTP id c14-20020a05640227ce00b004169d789f1fmr23390827ede.356.1647321332394; Mon, 14 Mar 2022 22:15:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647321332; cv=none; d=google.com; s=arc-20160816; b=IX17Pww1ZGJl0n/qK2EdteawbkeQxS5kM6s+IsW2F+BK+o3+FsmrOJALfpax2cmanC zFwFQmw+7OZQ0j2Q+0VWvPtbyM+5hYXiVCS+njBUdAhUbc2dzf7TX49f26LUbhJtJHP4 CD6hABiEUgv/vwj7kVzVs5hyR+PRSB8mBfBXa9M7E1KGE4xcpQ7o9dQh/R0ZdcTC81qb YO7t5FmZmUhwrp4tWi3HVM3pNTvEKgY6dvnPlZ7/umnRpG/V5u4HkA8pqh4vKRyJxGFZ 7hGTGGVBOXMlnj7condLGbqRYcSG6eNX1923aX/zU/2EEPXBJROlnEYszqmAkDB4+MRu UzoQ== 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=CTRcPEvohEbkBJBhxX5YwvL7VuGghtI6YMapSuVpqPw=; b=YELZp8rbNg2oGoTuw9DxnpprU+m7BzbNnILbmCO9aWXWGZpoMWl93LLQdjl7StOyVo n2uIDb37jNzT2s3VahYHsXINwPVhPfXUJ9E36+RJUiMybLEx0V6neTC7axeYOBroU5m/ kuJIiysjSIxaMakuqs4y0B8MjCwulBe4YMGdJYmo2AgBC3kwTTv4Yv3V6y6tHqyAwCpe Oqtt4zMgqMl+epAwk7O20kudtyiJ97vGoOSAjF4I/TkA2nsRJMvePUhYBrbBzV5ZhnBM nEnW9GJwByLHJt/FrnlaXAcf8TUSSHYP1CyD9QP4BMcCGB6mjnXp41hJpMfj6n0xOr8P 2ByQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VinnD8Jg; 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 e20-20020aa7d7d4000000b00415f18b8e50si10766847eds.123.2022.03.14.22.15.07; Mon, 14 Mar 2022 22:15:32 -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=VinnD8Jg; 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 S243891AbiCNSgO (ORCPT + 99 others); Mon, 14 Mar 2022 14:36:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235005AbiCNSgN (ORCPT ); Mon, 14 Mar 2022 14:36:13 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A91D3E0EC; Mon, 14 Mar 2022 11:35:02 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id mr24-20020a17090b239800b001bf0a375440so66614pjb.4; Mon, 14 Mar 2022 11:35:02 -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; bh=CTRcPEvohEbkBJBhxX5YwvL7VuGghtI6YMapSuVpqPw=; b=VinnD8Jg80xGV8LsRbx1iP3bZvs5Lp7/9ZRAP6d+uSEnGALRihy8zJ6imCP2Mp+SRK L4JV7OvTOQ4otZb4TiUustePMczBp6npjPhP78X3nUSe0jEUgxzFNchItUF12gO8cEVj Axe8IIXctJxNsoS4tqZkpu4P4ZYB5pNXhFZkauLTWh9lK0gj8Cq14tx0StgFgr9NlFK/ p6qdVQNHToE8pCNMWtDkvupqwGaVUacqEAUOKFBh5V3rwYy1w5KjryNHfMscq/QDVe0R y7rVeRUgIVpLHMyPr1NlVcusN5QdKza4TYVQNlkzsx9mnBHsOfRzxIeQMsjV0N8vDaMB qemw== 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=CTRcPEvohEbkBJBhxX5YwvL7VuGghtI6YMapSuVpqPw=; b=oGHCPFVbqkiZHWKMjxwCLTCfZaeaG3EGVhfWfyngZ1A8yDhh4zaWm2ddfeeJC0wJ0u by5dlECfOY+ufm1P9/C3RQt2DrK0aBJ+pScJnCwNWtHFlHswzc3oVQht7JWTds2C/QKg bAggNu5IxAMHVWKeryc3Tw0YMkSm0pOD0jkTIs0KjOjKev3c1QDm5LIINqm0VVWLeZEj c+gcA/WxTRIvbpeCGDUrdU4hdaUI3LBWfnQC/m4Uwlfl6Ko1ybPteB0wobfMKdo3/nBr 9IeRgJHnk3qa06/kqFW9wv0HBoDo93gJxcYhY64xHjUXvgjIve1sghdxbji0kYZ4vuPP CPNQ== X-Gm-Message-State: AOAM531lYSRQ5Yk7pgQJ1ucVkgoR0kwvFs+3XoVBRuGoqIU2YFHZI9gT hLYuuFET7kPjCzlUEhDXEfM= X-Received: by 2002:a17:902:b597:b0:151:e24e:a61e with SMTP id a23-20020a170902b59700b00151e24ea61emr24932081pls.66.1647282902015; Mon, 14 Mar 2022 11:35:02 -0700 (PDT) Received: from localhost ([192.55.54.52]) by smtp.gmail.com with ESMTPSA id u10-20020a63b54a000000b00380ea901cd2sm13747236pgo.6.2022.03.14.11.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Mar 2022 11:35:01 -0700 (PDT) Date: Mon, 14 Mar 2022 11:34:59 -0700 From: Isaku Yamahata To: Paolo Bonzini Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Jim Mattson , erdemaktas@google.com, Connor Kuehl , Sean Christopherson Subject: Re: [RFC PATCH v5 003/104] KVM: TDX: Detect CPU feature on kernel module initialization Message-ID: <20220314183459.GB1964605@ls.amr.corp.intel.com> References: <70201fd686c6cc6e03f5af8a9f59af67bdc81194.1646422845.git.isaku.yamahata@intel.com> <3443ca75-0b64-1b6b-1d1d-1cbca34d14cb@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3443ca75-0b64-1b6b-1d1d-1cbca34d14cb@redhat.com> 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 Thanks for comment. On Sun, Mar 13, 2022 at 02:49:51PM +0100, Paolo Bonzini wrote: > On 3/4/22 20:48, isaku.yamahata@intel.com wrote: > > From: Isaku Yamahata > > +static int __init __tdx_hardware_setup(struct kvm_x86_ops *x86_ops) > > +{ > > + u32 max_pa; > > + > > + if (!enable_ept) { > > + pr_warn("Cannot enable TDX with EPT disabled\n"); > > + return -EINVAL; > > + } > > + > > + if (!platform_has_tdx()) { > > + pr_warn("Cannot enable TDX with SEAMRR disabled\n"); > > + return -ENODEV; > > + } > > This will cause a pr_warn in the logs on all machines that don't have TDX. > Perhaps you can restrict the pr_warn() to machines that have > __seamrr_enabled() == true? Makes sense. I'll include the following change. diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h index 73bb472bd515..aa02c98afd11 100644 --- a/arch/x86/include/asm/tdx.h +++ b/arch/x86/include/asm/tdx.h @@ -134,6 +134,7 @@ struct tdsysinfo_struct { }; } __packed __aligned(TDSYSINFO_STRUCT_ALIGNMENT); +bool __seamrr_enabled(void); void tdx_detect_cpu(struct cpuinfo_x86 *c); int tdx_detect(void); int tdx_init(void); @@ -143,6 +144,7 @@ u32 tdx_get_global_keyid(void); int tdx_keyid_alloc(void); void tdx_keyid_free(int keyid); #else +static inline bool __seamrr_enabled(void) { return false; } static inline void tdx_detect_cpu(struct cpuinfo_x86 *c) { } static inline int tdx_detect(void) { return -ENODEV; } static inline int tdx_init(void) { return -ENODEV; } diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c index 66dffe815e63..880d8291b380 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -2625,7 +2625,8 @@ static int __init __tdx_hardware_setup(struct kvm_x86_ops *x86_ops) } if (!platform_has_tdx()) { - pr_warn("Cannot enable TDX with SEAMRR disabled\n"); + if (__seamrr_enabled()) + pr_warn("Cannot enable TDX with SEAMRR disabled\n"); return -ENODEV; } diff --git a/arch/x86/virt/vmx/tdx.c b/arch/x86/virt/vmx/tdx.c index d99961b7cb02..bb578a72b2da 100644 --- a/arch/x86/virt/vmx/tdx.c +++ b/arch/x86/virt/vmx/tdx.c @@ -186,10 +186,11 @@ static const struct kernel_param_ops tdx_trace_ops = { module_param_cb(tdx_trace_level, &tdx_trace_ops, &tdx_trace_level, 0644); MODULE_PARM_DESC(tdx_trace_level, "TDX module trace level"); -static bool __seamrr_enabled(void) +bool __seamrr_enabled(void) { return (seamrr_mask & SEAMRR_ENABLED_BITS) == SEAMRR_ENABLED_BITS; } +EXPORT_SYMBOL_GPL(__seamrr_enabled); static void detect_seam_bsp(struct cpuinfo_x86 *c) { -- Isaku Yamahata