Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3796392rwi; Fri, 21 Oct 2022 23:50:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM58TRFs6Sj6w0+n/L6aChN7Wibtb+tX8zuzqeMFVLfEw+7srEJhWPDxEXTWRxP6UjSTP9SJ X-Received: by 2002:a17:90b:3804:b0:20d:4e77:373a with SMTP id mq4-20020a17090b380400b0020d4e77373amr62460403pjb.212.1666421413407; Fri, 21 Oct 2022 23:50:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666421413; cv=none; d=google.com; s=arc-20160816; b=C/iq9Lya+KoiOtT3AJ2UzMOIe2eu9IhyQl2hXake92ZOaNlqz6gAGoYq6TajUz8W39 EUWOrQi3LqlkdG135M3k7GbRpsbUH4iESX+H6mzv987IOde9tjaoWM+idp8/EdamxcEx XjonM+zFyLDTVVwSJHrrUw0oUKEPp7plYAAVlvgwHnMJFS6q58bYrUFSc3EqFb0kiL+A 2OVGL3QE1sGjz7pvrs3QsYZaOb9ugDBoHvs76VGURmvS/9MneWG564SnNj5ZUeg6S7Rr JS6pseUZ9EAzuSNWsKW1U7ipBQHz6IMx1gqqpCz65g3W9riA1+lm5cupw1+uLVWUra/T 0foQ== 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=/WBhMo5JPj8t4Y0M8wKL+2HqUZEdhz8IJBvw90kKQyY=; b=wYoPMW3H8+Gr9egARraDsNMmCOIIq5RfUDp2naJIVTjuqSWdT26NSgd9mnXIZ41wWe 0YGlebG+aFr3/ReYhJ00ZIEqw2iYPFNzbHwqh8CDGAhI6yNZCrY730/+q2uVKt/ou9WX weM1orCqZASW+mLN10K450mWigVKA/YK5Mmuz81jI1Ztl6igo+LDqBkyapQQBY4ZT95n TzakQVneqKDGlk5vwqjp7meyGbHYCVXEcxK9Eqn6tF0t3rT/+ciXBGqbh+jE7+ATyxCI uzN+5u/kObijqyUsKPqHZ5XKaTg/YRaYYf4LKwoPSL76OK5CFHVbzvYz+6ArdSekJTLb ygXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LLBwCPBC; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s9-20020a170902b18900b0016dc27fb9fbsi25656596plr.117.2022.10.21.23.49.52; Fri, 21 Oct 2022 23:50:13 -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=@linuxfoundation.org header.s=korg header.b=LLBwCPBC; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229865AbiJVGEe (ORCPT + 99 others); Sat, 22 Oct 2022 02:04:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbiJVGEc (ORCPT ); Sat, 22 Oct 2022 02:04:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFD352BD1; Fri, 21 Oct 2022 23:04:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 12A92601C6; Sat, 22 Oct 2022 06:04:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3FA1C433D6; Sat, 22 Oct 2022 06:04:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666418668; bh=Juz5LjJbSCNynnLDYD7GXdYfa161RW8vLJD4JA2tHS0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LLBwCPBC927P7PqXScUSO95lyXe13Iior2iKmUfeh/0S8b28HUBRC9vsN9D7r4NbF aR/fuvZamZwjZA+ZGfdwdhtNWe8HImdVYsJvYkrhqqhCcepXvLYee0jlYfM03UbpCz QqR5aSH7MyEeDGcr1FgTQAoJnzKX+K8Y6sbA0etQ= Date: Sat, 22 Oct 2022 08:05:18 +0200 From: Greg Kroah-Hartman To: Sathyanarayanan Kuppuswamy Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Shuah Khan , Jonathan Corbet , "H . Peter Anvin" , "Kirill A . Shutemov" , Tony Luck , Kai Huang , Wander Lairson Costa , Isaku Yamahata , marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH v15 2/3] virt: Add TDX guest driver Message-ID: References: <20221020045828.2354731-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20221020045828.2354731-3-sathyanarayanan.kuppuswamy@linux.intel.com> <34ef18d6-69f8-853a-d1ba-7023822e17ff@linux.intel.com> <13adfc8d-8118-2fd7-3a66-98dfbf8037a9@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <13adfc8d-8118-2fd7-3a66-98dfbf8037a9@linux.intel.com> X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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, Oct 21, 2022 at 04:51:34PM -0700, Sathyanarayanan Kuppuswamy wrote: > Hi Greg, > > On 10/20/22 9:39 PM, Greg Kroah-Hartman wrote: > >>>> +#ifdef MODULE > >>>> +static const struct x86_cpu_id tdx_guest_ids[] = { > >>>> + X86_MATCH_FEATURE(X86_FEATURE_TDX_GUEST, NULL), > >>>> + {} > >>>> +}; > >>>> +MODULE_DEVICE_TABLE(x86cpu, tdx_guest_ids); > >>>> +#endif > >>> Why the #ifdef? Should not be needed, right? > >> I have added it to fix the following warning reported by 0-day. > >> > >> https://lore.kernel.org/lkml/202209211607.tCtTWKbV-lkp@intel.com/ > >> > >> It is related to nullifying the MODULE_DEVICE_TABLE in #ifndef MODULE > >> case in linux/module.h. > > Then fix it properly, by correctly using that structure no matter what. > > You don't do that here... > > I think we can use __maybe_unused attribute to fix this warning like > mentioned below. Are you fine with it? > > --- a/drivers/virt/coco/tdx-guest/tdx-guest.c > +++ b/drivers/virt/coco/tdx-guest/tdx-guest.c > @@ -118,13 +118,11 @@ static void __exit tdx_guest_exit(void) > } > module_exit(tdx_guest_exit); > > -#ifdef MODULE > -static const struct x86_cpu_id tdx_guest_ids[] = { > +static const struct x86_cpu_id __maybe_unused tdx_guest_ids[] = { > X86_MATCH_FEATURE(X86_FEATURE_TDX_GUEST, NULL), > {} > }; > MODULE_DEVICE_TABLE(x86cpu, tdx_guest_ids); > -#endif > > Solution 2: > ----------- > > We can also modify the code to use this structure in all cases like > below. But it requires me to use slower x86_match_cpu() in place of > cpu_feature_enabled() which I think is unnecessary. > > --- a/drivers/virt/coco/tdx-guest/tdx-guest.c > +++ b/drivers/virt/coco/tdx-guest/tdx-guest.c > @@ -103,9 +103,15 @@ static struct miscdevice tdx_misc_dev = { > .fops = &tdx_guest_fops, > }; > > +static const struct x86_cpu_id tdx_guest_ids[] = { > + X86_MATCH_FEATURE(X86_FEATURE_TDX_GUEST, NULL), > + {} > +}; > +MODULE_DEVICE_TABLE(x86cpu, tdx_guest_ids); > + > static int __init tdx_guest_init(void) > { > - if (!cpu_feature_enabled(X86_FEATURE_TDX_GUEST)) > + if (!x86_match_cpu(tdx_guest_ids)) Please use this as it's what all other users of the x86cpu module device table code uses, right? And what is the "speed" difference here? Is is measurable and where does it matter? thanks, greg k-h