Re: [PATCH v2 08/25] x86/sgx: Expose SGX architectural definitions to the kernel

2021-03-14 Thread Kai Huang
On Fri, 12 Mar 2021 13:58:40 -0800 Sean Christopherson wrote:
> On Tue, Mar 09, 2021, Kai Huang wrote:
> > From: Sean Christopherson 
> > 
> > Expose SGX architectural structures, as KVM will use many of the
> > architectural constants and structs to virtualize SGX.
> > 
> > Name the new header file as asm/sgx.h, rather than asm/sgx_arch.h, to
> > have single header to provide SGX facilities to share with other kernel
> > componments.
> > 
> > Signed-off-by: Sean Christopherson 
> > Co-developed-by: Kai Huang 
> > Acked-by: Dave Hansen 
> 
> Same checkpatch warning.  Probably doesn't matter.

Will change order to make checkpatch happy for this whole series.

Thanks for pointing out.

> 
> > Signed-off-by: Kai Huang 
> > ---
> >  .../cpu/sgx/arch.h => include/asm/sgx.h}  | 20 ++-
> >  arch/x86/kernel/cpu/sgx/encl.c|  2 +-
> >  arch/x86/kernel/cpu/sgx/sgx.h |  2 +-
> >  tools/testing/selftests/sgx/defines.h |  2 +-
> >  4 files changed, 18 insertions(+), 8 deletions(-)
> >  rename arch/x86/{kernel/cpu/sgx/arch.h => include/asm/sgx.h} (95%)
> > 
> > diff --git a/arch/x86/kernel/cpu/sgx/arch.h b/arch/x86/include/asm/sgx.h
> > similarity index 95%
> > rename from arch/x86/kernel/cpu/sgx/arch.h
> > rename to arch/x86/include/asm/sgx.h
> > index abf99bb71fdc..d4ad35f6319a 100644
> > --- a/arch/x86/kernel/cpu/sgx/arch.h
> > +++ b/arch/x86/include/asm/sgx.h
> > @@ -2,15 +2,20 @@
> >  /**
> >   * Copyright(c) 2016-20 Intel Corporation.
> >   *
> > - * Contains data structures defined by the SGX architecture.  Data 
> > structures
> > - * defined by the Linux software stack should not be placed here.
> > + * Intel Software Guard Extensions (SGX) support.
> >   */
> > -#ifndef _ASM_X86_SGX_ARCH_H
> > -#define _ASM_X86_SGX_ARCH_H
> > +#ifndef _ASM_X86_SGX_H
> > +#define _ASM_X86_SGX_H
> >  
> >  #include 
> >  #include 
> >  
> > +/*
> > + * This file contains both data structures defined by SGX architecture and 
> > Linux
> > + * defined software data structures and functions.  The two should not be 
> > mixed
> > + * together for better readibility.  The architectural definitions come 
> > first.
> > + */
> > +
> >  /* The SGX specific CPUID function. */
> >  #define SGX_CPUID  0x12
> >  /* EPC enumeration. */
> > @@ -337,4 +342,9 @@ struct sgx_sigstruct {
> >  
> >  #define SGX_LAUNCH_TOKEN_SIZE 304
> >  
> > -#endif /* _ASM_X86_SGX_ARCH_H */
> > +/*
> > + * Do not put any hardware-defined SGX structure representations below this
> > + * line!
> 
> Heh, which line?  Yep, it's Friday afternoon...

Hmm.. I will change to below this comment. :)


Re: [PATCH v2 08/25] x86/sgx: Expose SGX architectural definitions to the kernel

2021-03-12 Thread Sean Christopherson
On Tue, Mar 09, 2021, Kai Huang wrote:
> From: Sean Christopherson 
> 
> Expose SGX architectural structures, as KVM will use many of the
> architectural constants and structs to virtualize SGX.
> 
> Name the new header file as asm/sgx.h, rather than asm/sgx_arch.h, to
> have single header to provide SGX facilities to share with other kernel
> componments.
> 
> Signed-off-by: Sean Christopherson 
> Co-developed-by: Kai Huang 
> Acked-by: Dave Hansen 

Same checkpatch warning.  Probably doesn't matter.

> Signed-off-by: Kai Huang 
> ---
>  .../cpu/sgx/arch.h => include/asm/sgx.h}  | 20 ++-
>  arch/x86/kernel/cpu/sgx/encl.c|  2 +-
>  arch/x86/kernel/cpu/sgx/sgx.h |  2 +-
>  tools/testing/selftests/sgx/defines.h |  2 +-
>  4 files changed, 18 insertions(+), 8 deletions(-)
>  rename arch/x86/{kernel/cpu/sgx/arch.h => include/asm/sgx.h} (95%)
> 
> diff --git a/arch/x86/kernel/cpu/sgx/arch.h b/arch/x86/include/asm/sgx.h
> similarity index 95%
> rename from arch/x86/kernel/cpu/sgx/arch.h
> rename to arch/x86/include/asm/sgx.h
> index abf99bb71fdc..d4ad35f6319a 100644
> --- a/arch/x86/kernel/cpu/sgx/arch.h
> +++ b/arch/x86/include/asm/sgx.h
> @@ -2,15 +2,20 @@
>  /**
>   * Copyright(c) 2016-20 Intel Corporation.
>   *
> - * Contains data structures defined by the SGX architecture.  Data structures
> - * defined by the Linux software stack should not be placed here.
> + * Intel Software Guard Extensions (SGX) support.
>   */
> -#ifndef _ASM_X86_SGX_ARCH_H
> -#define _ASM_X86_SGX_ARCH_H
> +#ifndef _ASM_X86_SGX_H
> +#define _ASM_X86_SGX_H
>  
>  #include 
>  #include 
>  
> +/*
> + * This file contains both data structures defined by SGX architecture and 
> Linux
> + * defined software data structures and functions.  The two should not be 
> mixed
> + * together for better readibility.  The architectural definitions come 
> first.
> + */
> +
>  /* The SGX specific CPUID function. */
>  #define SGX_CPUID0x12
>  /* EPC enumeration. */
> @@ -337,4 +342,9 @@ struct sgx_sigstruct {
>  
>  #define SGX_LAUNCH_TOKEN_SIZE 304
>  
> -#endif /* _ASM_X86_SGX_ARCH_H */
> +/*
> + * Do not put any hardware-defined SGX structure representations below this
> + * line!

Heh, which line?  Yep, it's Friday afternoon...

> + */


[PATCH v2 08/25] x86/sgx: Expose SGX architectural definitions to the kernel

2021-03-08 Thread Kai Huang
From: Sean Christopherson 

Expose SGX architectural structures, as KVM will use many of the
architectural constants and structs to virtualize SGX.

Name the new header file as asm/sgx.h, rather than asm/sgx_arch.h, to
have single header to provide SGX facilities to share with other kernel
componments.

Signed-off-by: Sean Christopherson 
Co-developed-by: Kai Huang 
Acked-by: Dave Hansen 
Signed-off-by: Kai Huang 
---
 .../cpu/sgx/arch.h => include/asm/sgx.h}  | 20 ++-
 arch/x86/kernel/cpu/sgx/encl.c|  2 +-
 arch/x86/kernel/cpu/sgx/sgx.h |  2 +-
 tools/testing/selftests/sgx/defines.h |  2 +-
 4 files changed, 18 insertions(+), 8 deletions(-)
 rename arch/x86/{kernel/cpu/sgx/arch.h => include/asm/sgx.h} (95%)

diff --git a/arch/x86/kernel/cpu/sgx/arch.h b/arch/x86/include/asm/sgx.h
similarity index 95%
rename from arch/x86/kernel/cpu/sgx/arch.h
rename to arch/x86/include/asm/sgx.h
index abf99bb71fdc..d4ad35f6319a 100644
--- a/arch/x86/kernel/cpu/sgx/arch.h
+++ b/arch/x86/include/asm/sgx.h
@@ -2,15 +2,20 @@
 /**
  * Copyright(c) 2016-20 Intel Corporation.
  *
- * Contains data structures defined by the SGX architecture.  Data structures
- * defined by the Linux software stack should not be placed here.
+ * Intel Software Guard Extensions (SGX) support.
  */
-#ifndef _ASM_X86_SGX_ARCH_H
-#define _ASM_X86_SGX_ARCH_H
+#ifndef _ASM_X86_SGX_H
+#define _ASM_X86_SGX_H
 
 #include 
 #include 
 
+/*
+ * This file contains both data structures defined by SGX architecture and 
Linux
+ * defined software data structures and functions.  The two should not be mixed
+ * together for better readibility.  The architectural definitions come first.
+ */
+
 /* The SGX specific CPUID function. */
 #define SGX_CPUID  0x12
 /* EPC enumeration. */
@@ -337,4 +342,9 @@ struct sgx_sigstruct {
 
 #define SGX_LAUNCH_TOKEN_SIZE 304
 
-#endif /* _ASM_X86_SGX_ARCH_H */
+/*
+ * Do not put any hardware-defined SGX structure representations below this
+ * line!
+ */
+
+#endif /* _ASM_X86_SGX_H */
diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c
index dcbcf840c522..130f6520438f 100644
--- a/arch/x86/kernel/cpu/sgx/encl.c
+++ b/arch/x86/kernel/cpu/sgx/encl.c
@@ -7,7 +7,7 @@
 #include 
 #include 
 #include 
-#include "arch.h"
+#include 
 #include "encl.h"
 #include "encls.h"
 #include "sgx.h"
diff --git a/arch/x86/kernel/cpu/sgx/sgx.h b/arch/x86/kernel/cpu/sgx/sgx.h
index 1bff93be7bf4..5d71c9c8644d 100644
--- a/arch/x86/kernel/cpu/sgx/sgx.h
+++ b/arch/x86/kernel/cpu/sgx/sgx.h
@@ -8,7 +8,7 @@
 #include 
 #include 
 #include 
-#include "arch.h"
+#include 
 
 #undef pr_fmt
 #define pr_fmt(fmt) "sgx: " fmt
diff --git a/tools/testing/selftests/sgx/defines.h 
b/tools/testing/selftests/sgx/defines.h
index 592c1ccf4576..0bd73428d2f3 100644
--- a/tools/testing/selftests/sgx/defines.h
+++ b/tools/testing/selftests/sgx/defines.h
@@ -14,7 +14,7 @@
 #define __aligned(x) __attribute__((__aligned__(x)))
 #define __packed __attribute__((packed))
 
-#include "../../../../arch/x86/kernel/cpu/sgx/arch.h"
+#include "../../../../arch/x86/include/asm/sgx.h"
 #include "../../../../arch/x86/include/asm/enclu.h"
 #include "../../../../arch/x86/include/uapi/asm/sgx.h"
 
-- 
2.29.2