2023-06-06 03:53:41

by Kai Huang

[permalink] [raw]
Subject: [PATCH] x86/tdx: Explicitly include <linux/errno.h> in <asm/tdx.h>

Currently, in <asm/tdx.h> tdx_kvm_hypercall() simply returns -ENODEV
when TDX guest isn't enabled in the Kconfig w/o having <linux/errno.h>
header explicitly included. Although the current code doesn't have
build error, in general it is a good practice to explicitly include the
header to make sure any future patch which uses <asm/tdx.h> won't get
build error due to error code not being defined.

Fixes: cfb8ec7a31f2 ("x86/tdx: Wire up KVM hypercalls")
Suggested-by: Dave Hansen <[email protected]>
Cc: Kuppuswamy Sathyanarayanan <[email protected]>
Cc: Kirill A. Shutemov <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: Isaku Yamahata <[email protected]>
Signed-off-by: Kai Huang <[email protected]>
---
arch/x86/include/asm/tdx.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h
index 28d889c9aa16..0f303c9abee8 100644
--- a/arch/x86/include/asm/tdx.h
+++ b/arch/x86/include/asm/tdx.h
@@ -5,6 +5,7 @@

#include <linux/init.h>
#include <linux/bits.h>
+#include <linux/errno.h>
#include <asm/ptrace.h>
#include <asm/shared/tdx.h>


base-commit: 122333d6bd229af279cdb35d1b874b71b3b9ccfb
--
2.40.1



2023-06-06 09:33:58

by Kirill A. Shutemov

[permalink] [raw]
Subject: Re: [PATCH] x86/tdx: Explicitly include <linux/errno.h> in <asm/tdx.h>

On Tue, Jun 06, 2023 at 03:40:00PM +1200, Kai Huang wrote:
> Currently, in <asm/tdx.h> tdx_kvm_hypercall() simply returns -ENODEV
> when TDX guest isn't enabled in the Kconfig w/o having <linux/errno.h>
> header explicitly included. Although the current code doesn't have
> build error, in general it is a good practice to explicitly include the
> header to make sure any future patch which uses <asm/tdx.h> won't get
> build error due to error code not being defined.
>
> Fixes: cfb8ec7a31f2 ("x86/tdx: Wire up KVM hypercalls")
> Suggested-by: Dave Hansen <[email protected]>
> Cc: Kuppuswamy Sathyanarayanan <[email protected]>
> Cc: Kirill A. Shutemov <[email protected]>
> Cc: Dave Hansen <[email protected]>
> Cc: Isaku Yamahata <[email protected]>
> Signed-off-by: Kai Huang <[email protected]>

Acked-by: Kirill A. Shutemov <[email protected]>

--
Kiryl Shutsemau / Kirill A. Shutemov

Subject: Re: [PATCH] x86/tdx: Explicitly include <linux/errno.h> in <asm/tdx.h>



On 6/5/23 8:40 PM, Kai Huang wrote:
> Currently, in <asm/tdx.h> tdx_kvm_hypercall() simply returns -ENODEV
> when TDX guest isn't enabled in the Kconfig w/o having <linux/errno.h>

Maybe you can explicitly say "CONFIG_INTEL_TDX_GUEST is not enabled"


> header explicitly included. Although the current code doesn't have
> build error, in general it is a good practice to explicitly include the
> header to make sure any future patch which uses <asm/tdx.h> won't get
> build error due to error code not being defined.

Otherwise, it looks fine.

Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>

>
> Fixes: cfb8ec7a31f2 ("x86/tdx: Wire up KVM hypercalls")
> Suggested-by: Dave Hansen <[email protected]>
> Cc: Kuppuswamy Sathyanarayanan <[email protected]>
> Cc: Kirill A. Shutemov <[email protected]>
> Cc: Dave Hansen <[email protected]>
> Cc: Isaku Yamahata <[email protected]>
> Signed-off-by: Kai Huang <[email protected]>
> ---
> arch/x86/include/asm/tdx.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h
> index 28d889c9aa16..0f303c9abee8 100644
> --- a/arch/x86/include/asm/tdx.h
> +++ b/arch/x86/include/asm/tdx.h
> @@ -5,6 +5,7 @@
>
> #include <linux/init.h>
> #include <linux/bits.h>
> +#include <linux/errno.h>
> #include <asm/ptrace.h>
> #include <asm/shared/tdx.h>
>
>
> base-commit: 122333d6bd229af279cdb35d1b874b71b3b9ccfb

--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer

2023-06-06 22:52:19

by Kai Huang

[permalink] [raw]
Subject: Re: [PATCH] x86/tdx: Explicitly include <linux/errno.h> in <asm/tdx.h>

On Tue, 2023-06-06 at 06:10 -0700, Sathyanarayanan Kuppuswamy wrote:
>
> On 6/5/23 8:40 PM, Kai Huang wrote:
> > Currently, in <asm/tdx.h> tdx_kvm_hypercall() simply returns -ENODEV
> > when TDX guest isn't enabled in the Kconfig w/o having <linux/errno.h>
>
> Maybe you can explicitly say "CONFIG_INTEL_TDX_GUEST is not enabled"

It also can be disabled by !CONFIG_KVM_GUEST.


2023-06-06 23:17:47

by Kai Huang

[permalink] [raw]
Subject: Re: [PATCH] x86/tdx: Explicitly include <linux/errno.h> in <asm/tdx.h>

On Wed, 2023-06-07 at 01:45 +0300, Kirill A. Shutemov wrote:
> On Tue, Jun 06, 2023 at 10:17:53PM +0000, Huang, Kai wrote:
> > On Tue, 2023-06-06 at 06:10 -0700, Sathyanarayanan Kuppuswamy wrote:
> > >
> > > On 6/5/23 8:40 PM, Kai Huang wrote:
> > > > Currently, in <asm/tdx.h> tdx_kvm_hypercall() simply returns -ENODEV
> > > > when TDX guest isn't enabled in the Kconfig w/o having <linux/errno.h>
> > >
> > > Maybe you can explicitly say "CONFIG_INTEL_TDX_GUEST is not enabled"
> >
> > It also can be disabled by !CONFIG_KVM_GUEST.
>
> Borislav has already fixed it during unaccepted memory patchset
> application. He used <asm/errno.h>, not <linux/errno.h>.
>
> See [1] and [2].
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=75d090fd167acab4d7eda7e2b65729e877c0fd64
> [2] https://lore.kernel.org/all/20230606161606.GDZH9bxhrGnFkaLl2A@fat_crate.local
>

Wonderful, then we can drop this one :)

2023-06-06 23:18:45

by Kirill A. Shutemov

[permalink] [raw]
Subject: Re: [PATCH] x86/tdx: Explicitly include <linux/errno.h> in <asm/tdx.h>

On Tue, Jun 06, 2023 at 10:17:53PM +0000, Huang, Kai wrote:
> On Tue, 2023-06-06 at 06:10 -0700, Sathyanarayanan Kuppuswamy wrote:
> >
> > On 6/5/23 8:40 PM, Kai Huang wrote:
> > > Currently, in <asm/tdx.h> tdx_kvm_hypercall() simply returns -ENODEV
> > > when TDX guest isn't enabled in the Kconfig w/o having <linux/errno.h>
> >
> > Maybe you can explicitly say "CONFIG_INTEL_TDX_GUEST is not enabled"
>
> It also can be disabled by !CONFIG_KVM_GUEST.

Borislav has already fixed it during unaccepted memory patchset
application. He used <asm/errno.h>, not <linux/errno.h>.

See [1] and [2].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=75d090fd167acab4d7eda7e2b65729e877c0fd64
[2] https://lore.kernel.org/all/20230606161606.GDZH9bxhrGnFkaLl2A@fat_crate.local

--
Kiryl Shutsemau / Kirill A. Shutemov