All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Sathyanarayanan Kuppuswamy  <sathyanarayanan.kuppuswamy@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, Shuah Khan <shuah@kernel.org>,
	Jonathan Corbet <corbet@lwn.net>,
	"H . Peter Anvin" <hpa@zytor.com>,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	Tony Luck <tony.luck@intel.com>, Kai Huang <kai.huang@intel.com>,
	Wander Lairson Costa <wander@redhat.com>,
	Isaku Yamahata <isaku.yamahata@gmail.com>,
	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
Date: Sat, 22 Oct 2022 08:05:18 +0200	[thread overview]
Message-ID: <Y1OIHjFp2r58fDPI@kroah.com> (raw)
In-Reply-To: <13adfc8d-8118-2fd7-3a66-98dfbf8037a9@linux.intel.com>

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

  reply	other threads:[~2022-10-22  6:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20  4:58 [PATCH v15 0/3]] Add TDX Guest Attestation support Kuppuswamy Sathyanarayanan
2022-10-20  4:58 ` [PATCH v15 1/3] x86/tdx: Add a wrapper to get TDREPORT from the TDX Module Kuppuswamy Sathyanarayanan
2022-10-20  4:58 ` [PATCH v15 2/3] virt: Add TDX guest driver Kuppuswamy Sathyanarayanan
2022-10-20  5:38   ` Greg Kroah-Hartman
2022-10-21  0:00     ` Sathyanarayanan Kuppuswamy
2022-10-21  4:39       ` Greg Kroah-Hartman
2022-10-21 23:51         ` Sathyanarayanan Kuppuswamy
2022-10-22  6:05           ` Greg Kroah-Hartman [this message]
2022-10-22  6:42             ` Sathyanarayanan Kuppuswamy
2022-10-23 16:13         ` Sathyanarayanan Kuppuswamy
2022-10-24 12:57           ` Wander Lairson Costa
2022-10-24 13:54             ` Greg Kroah-Hartman
2022-10-24 23:59               ` Sathyanarayanan Kuppuswamy
2022-10-24 14:17           ` Dave Hansen
2022-10-25  0:20             ` Sathyanarayanan Kuppuswamy
2022-10-20  4:58 ` [PATCH v15 3/3] selftests: tdx: Test TDX attestation GetReport support Kuppuswamy Sathyanarayanan
2022-10-20 17:08 ` [PATCH v15 0/3]] Add TDX Guest Attestation support Dave Hansen
2022-10-23 16:09   ` Sathyanarayanan Kuppuswamy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y1OIHjFp2r58fDPI@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=bp@alien8.de \
    --cc=corbet@lwn.net \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=isaku.yamahata@gmail.com \
    --cc=kai.huang@intel.com \
    --cc=khalid.elmously@canonical.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=marcelo.cerri@canonical.com \
    --cc=mingo@redhat.com \
    --cc=philip.cox@canonical.com \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=shuah@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tim.gardner@canonical.com \
    --cc=tony.luck@intel.com \
    --cc=wander@redhat.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.