linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/entry: add compatibility with IAS
@ 2020-07-13  1:24 Jian Cai
  2020-07-13  2:33 ` Brian Gerst
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Jian Cai @ 2020-07-13  1:24 UTC (permalink / raw)
  Cc: caij2003, jiancai, ndesaulniers, manojgupta, sedat.dilek,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
	H. Peter Anvin, Andy Lutomirski, Peter Zijlstra,
	Alexandre Chartre, linux-kernel, clang-built-linux

Clang's integrated assembler does not allow symbols with non-absolute
values to be reassigned. This patch allows the affected code to be
compatible with IAS.

Link: https://github.com/ClangBuiltLinux/linux/issues/1043
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Jian Cai <caij2003@gmail.com>
---
 arch/x86/include/asm/idtentry.h | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h
index f3d70830bf2a..77beed2cd6d9 100644
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -468,34 +468,32 @@ __visible noinstr void func(struct pt_regs *regs,			\
  */
 	.align 8
 SYM_CODE_START(irq_entries_start)
-    vector=FIRST_EXTERNAL_VECTOR
-    pos = .
+    i = 1
+    pos1 = .
     .rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR)
 	UNWIND_HINT_IRET_REGS
-	.byte	0x6a, vector
+	.byte	0x6a, FIRST_EXTERNAL_VECTOR + i - 1
 	jmp	asm_common_interrupt
 	nop
 	/* Ensure that the above is 8 bytes max */
-	. = pos + 8
-    pos=pos+8
-    vector=vector+1
+	. = pos1 + 8 * i
+	i = i + 1
     .endr
 SYM_CODE_END(irq_entries_start)
 
 #ifdef CONFIG_X86_LOCAL_APIC
 	.align 8
 SYM_CODE_START(spurious_entries_start)
-    vector=FIRST_SYSTEM_VECTOR
-    pos = .
+    i = 1
+    pos2 = .
     .rept (NR_VECTORS - FIRST_SYSTEM_VECTOR)
 	UNWIND_HINT_IRET_REGS
-	.byte	0x6a, vector
+	.byte	0x6a, FIRST_SYSTEM_VECTOR + i - 1
 	jmp	asm_spurious_interrupt
 	nop
 	/* Ensure that the above is 8 bytes max */
-	. = pos + 8
-    pos=pos+8
-    vector=vector+1
+	. = pos2 + 8 * i
+	i = i + 1
     .endr
 SYM_CODE_END(spurious_entries_start)
 #endif
-- 
2.27.0.383.g050319c2ae-goog


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] x86/entry: add compatibility with IAS
  2020-07-13  1:24 [PATCH] x86/entry: add compatibility with IAS Jian Cai
@ 2020-07-13  2:33 ` Brian Gerst
  2020-07-13  2:54 ` Arvind Sankar
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Brian Gerst @ 2020-07-13  2:33 UTC (permalink / raw)
  To: Jian Cai
  Cc: jiancai, Nick Desaulniers, manojgupta, Sedat Dilek,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	the arch/x86 maintainers, H. Peter Anvin, Andy Lutomirski,
	Peter Zijlstra, Alexandre Chartre, Linux Kernel Mailing List,
	clang-built-linux

On Sun, Jul 12, 2020 at 9:26 PM Jian Cai <caij2003@gmail.com> wrote:
>
> Clang's integrated assembler does not allow symbols with non-absolute
> values to be reassigned. This patch allows the affected code to be
> compatible with IAS.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/1043
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
> Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
> Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
> Signed-off-by: Jian Cai <caij2003@gmail.com>
> ---
>  arch/x86/include/asm/idtentry.h | 22 ++++++++++------------
>  1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h
> index f3d70830bf2a..77beed2cd6d9 100644
> --- a/arch/x86/include/asm/idtentry.h
> +++ b/arch/x86/include/asm/idtentry.h
> @@ -468,34 +468,32 @@ __visible noinstr void func(struct pt_regs *regs,                 \
>   */
>         .align 8
>  SYM_CODE_START(irq_entries_start)
> -    vector=FIRST_EXTERNAL_VECTOR
> -    pos = .
> +    i = 1

Start with index 0.

> +    pos1 = .

pos1 is unnecessary, as it's equal to irq_entries_start.

>      .rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR)
>         UNWIND_HINT_IRET_REGS
> -       .byte   0x6a, vector
> +       .byte   0x6a, FIRST_EXTERNAL_VECTOR + i - 1
>         jmp     asm_common_interrupt
>         nop
>         /* Ensure that the above is 8 bytes max */
> -       . = pos + 8
> -    pos=pos+8
> -    vector=vector+1
> +       . = pos1 + 8 * i
> +       i = i + 1

If you swap these two lines then the index will be correct for the
next stub if you start at 0..

>      .endr
>  SYM_CODE_END(irq_entries_start)
>
>  #ifdef CONFIG_X86_LOCAL_APIC
>         .align 8
>  SYM_CODE_START(spurious_entries_start)
> -    vector=FIRST_SYSTEM_VECTOR
> -    pos = .
> +    i = 1
> +    pos2 = .
>      .rept (NR_VECTORS - FIRST_SYSTEM_VECTOR)
>         UNWIND_HINT_IRET_REGS
> -       .byte   0x6a, vector
> +       .byte   0x6a, FIRST_SYSTEM_VECTOR + i - 1
>         jmp     asm_spurious_interrupt
>         nop
>         /* Ensure that the above is 8 bytes max */
> -       . = pos + 8
> -    pos=pos+8
> -    vector=vector+1
> +       . = pos2 + 8 * i
> +       i = i + 1
>      .endr
>  SYM_CODE_END(spurious_entries_start)
>  #endif

--
Brian Gerst

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] x86/entry: add compatibility with IAS
  2020-07-13  1:24 [PATCH] x86/entry: add compatibility with IAS Jian Cai
  2020-07-13  2:33 ` Brian Gerst
@ 2020-07-13  2:54 ` Arvind Sankar
  2020-07-13  3:57   ` Arvind Sankar
  2020-07-13 21:38 ` Jian Cai
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Arvind Sankar @ 2020-07-13  2:54 UTC (permalink / raw)
  To: Jian Cai
  Cc: jiancai, ndesaulniers, manojgupta, sedat.dilek, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, x86, H. Peter Anvin,
	Andy Lutomirski, Peter Zijlstra, Alexandre Chartre, linux-kernel,
	clang-built-linux

On Sun, Jul 12, 2020 at 06:24:22PM -0700, Jian Cai wrote:
> Clang's integrated assembler does not allow symbols with non-absolute
> values to be reassigned. This patch allows the affected code to be
> compatible with IAS.
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/1043
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
> Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
> Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
> Signed-off-by: Jian Cai <caij2003@gmail.com>
> ---
>  arch/x86/include/asm/idtentry.h | 22 ++++++++++------------
>  1 file changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h
> index f3d70830bf2a..77beed2cd6d9 100644
> --- a/arch/x86/include/asm/idtentry.h
> +++ b/arch/x86/include/asm/idtentry.h
> @@ -468,34 +468,32 @@ __visible noinstr void func(struct pt_regs *regs,			\
>   */
>  	.align 8
>  SYM_CODE_START(irq_entries_start)
> -    vector=FIRST_EXTERNAL_VECTOR
> -    pos = .
> +    i = 1
> +    pos1 = .
>      .rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR)
>  	UNWIND_HINT_IRET_REGS
> -	.byte	0x6a, vector
> +	.byte	0x6a, FIRST_EXTERNAL_VECTOR + i - 1
>  	jmp	asm_common_interrupt
>  	nop
>  	/* Ensure that the above is 8 bytes max */
> -	. = pos + 8
> -    pos=pos+8
> -    vector=vector+1
> +	. = pos1 + 8 * i
> +	i = i + 1
>      .endr
>  SYM_CODE_END(irq_entries_start)

I think it would be a little cleaner to initialize i to 0, and drop pos.
i.e. couldn't we do
	i = 0
	...
	.byte	0x6a, FIRST_EXTERNAL_VECTOR + i
	...
	i = i + 1
	. = irq_entries_start + 8 * i

>  
>  #ifdef CONFIG_X86_LOCAL_APIC
>  	.align 8
>  SYM_CODE_START(spurious_entries_start)
> -    vector=FIRST_SYSTEM_VECTOR
> -    pos = .
> +    i = 1
> +    pos2 = .
>      .rept (NR_VECTORS - FIRST_SYSTEM_VECTOR)
>  	UNWIND_HINT_IRET_REGS
> -	.byte	0x6a, vector
> +	.byte	0x6a, FIRST_SYSTEM_VECTOR + i - 1
>  	jmp	asm_spurious_interrupt
>  	nop
>  	/* Ensure that the above is 8 bytes max */
> -	. = pos + 8
> -    pos=pos+8
> -    vector=vector+1
> +	. = pos2 + 8 * i
> +	i = i + 1
>      .endr
>  SYM_CODE_END(spurious_entries_start)
>  #endif
> -- 
> 2.27.0.383.g050319c2ae-goog
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] x86/entry: add compatibility with IAS
  2020-07-13  2:54 ` Arvind Sankar
@ 2020-07-13  3:57   ` Arvind Sankar
  0 siblings, 0 replies; 11+ messages in thread
From: Arvind Sankar @ 2020-07-13  3:57 UTC (permalink / raw)
  To: Arvind Sankar
  Cc: Jian Cai, jiancai, ndesaulniers, manojgupta, sedat.dilek,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
	H. Peter Anvin, Andy Lutomirski, Peter Zijlstra,
	Alexandre Chartre, linux-kernel, clang-built-linux

On Sun, Jul 12, 2020 at 10:54:29PM -0400, Arvind Sankar wrote:
> On Sun, Jul 12, 2020 at 06:24:22PM -0700, Jian Cai wrote:
> > Clang's integrated assembler does not allow symbols with non-absolute
> > values to be reassigned. This patch allows the affected code to be
> > compatible with IAS.
> > 
> > Link: https://github.com/ClangBuiltLinux/linux/issues/1043
> > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> > Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
> > Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
> > Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
> > Signed-off-by: Jian Cai <caij2003@gmail.com>
> > ---
> >  arch/x86/include/asm/idtentry.h | 22 ++++++++++------------
> >  1 file changed, 10 insertions(+), 12 deletions(-)
> > 
> > diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h
> > index f3d70830bf2a..77beed2cd6d9 100644
> > --- a/arch/x86/include/asm/idtentry.h
> > +++ b/arch/x86/include/asm/idtentry.h
> > @@ -468,34 +468,32 @@ __visible noinstr void func(struct pt_regs *regs,			\
> >   */
> >  	.align 8
> >  SYM_CODE_START(irq_entries_start)
> > -    vector=FIRST_EXTERNAL_VECTOR
> > -    pos = .
> > +    i = 1
> > +    pos1 = .
> >      .rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR)
> >  	UNWIND_HINT_IRET_REGS
> > -	.byte	0x6a, vector
> > +	.byte	0x6a, FIRST_EXTERNAL_VECTOR + i - 1
> >  	jmp	asm_common_interrupt
> >  	nop
> >  	/* Ensure that the above is 8 bytes max */
> > -	. = pos + 8
> > -    pos=pos+8
> > -    vector=vector+1
> > +	. = pos1 + 8 * i
> > +	i = i + 1
> >      .endr
> >  SYM_CODE_END(irq_entries_start)
> 
> I think it would be a little cleaner to initialize i to 0, and drop pos.
> i.e. couldn't we do
> 	i = 0
> 	...
> 	.byte	0x6a, FIRST_EXTERNAL_VECTOR + i
> 	...
> 	i = i + 1
> 	. = irq_entries_start + 8 * i
> 

Or maybe just:

diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h
index eeac6dc2adaa..c774039d130b 100644
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -469,15 +469,14 @@ __visible noinstr void func(struct pt_regs *regs,			\
 	.align 8
 SYM_CODE_START(irq_entries_start)
     vector=FIRST_EXTERNAL_VECTOR
-    pos = .
     .rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR)
+    0:
 	UNWIND_HINT_IRET_REGS
 	.byte	0x6a, vector
 	jmp	asm_common_interrupt
 	nop
 	/* Ensure that the above is 8 bytes max */
-	. = pos + 8
-    pos=pos+8
+	. = 0b + 8
     vector=vector+1
     .endr
 SYM_CODE_END(irq_entries_start)
@@ -486,15 +485,14 @@ SYM_CODE_END(irq_entries_start)
 	.align 8
 SYM_CODE_START(spurious_entries_start)
     vector=FIRST_SYSTEM_VECTOR
-    pos = .
     .rept (NR_VECTORS - FIRST_SYSTEM_VECTOR)
+    0:
 	UNWIND_HINT_IRET_REGS
 	.byte	0x6a, vector
 	jmp	asm_spurious_interrupt
 	nop
 	/* Ensure that the above is 8 bytes max */
-	. = pos + 8
-    pos=pos+8
+	. = 0b + 8
     vector=vector+1
     .endr
 SYM_CODE_END(spurious_entries_start)

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH] x86/entry: add compatibility with IAS
  2020-07-13  1:24 [PATCH] x86/entry: add compatibility with IAS Jian Cai
  2020-07-13  2:33 ` Brian Gerst
  2020-07-13  2:54 ` Arvind Sankar
@ 2020-07-13 21:38 ` Jian Cai
  2020-07-13 22:17   ` Arvind Sankar
  2020-07-13 22:40 ` Jian Cai
  2020-07-14 23:30 ` [PATCH v2] " Jian Cai
  4 siblings, 1 reply; 11+ messages in thread
From: Jian Cai @ 2020-07-13 21:38 UTC (permalink / raw)
  Cc: caij2003, jiancai, ndesaulniers, manojgupta, sedat.dilek,
	Brian Gerst, Arvind Sankar, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, x86, H. Peter Anvin, Andy Lutomirski,
	Peter Zijlstra, Alexandre Chartre, linux-kernel,
	clang-built-linux

Clang's integrated assembler does not allow symbols with non-absolute
values to be reassigned. This patch allows the affected code to be
compatible with IAS.

Link: https://github.com/ClangBuiltLinux/linux/issues/1043
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Suggested-by: Brian Gerst <brgerst@gmail.com>
Suggested-by: Arvind Sankar <nivedita@alum.mit.edu>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Jian Cai <caij2003@gmail.com>
---
 arch/x86/include/asm/idtentry.h | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h
index f3d70830bf2a..7d22684eafdf 100644
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -469,16 +469,15 @@ __visible noinstr void func(struct pt_regs *regs,			\
 	.align 8
 SYM_CODE_START(irq_entries_start)
     vector=FIRST_EXTERNAL_VECTOR
-    pos = .
     .rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR)
+0 :
 	UNWIND_HINT_IRET_REGS
 	.byte	0x6a, vector
 	jmp	asm_common_interrupt
 	nop
 	/* Ensure that the above is 8 bytes max */
-	. = pos + 8
-    pos=pos+8
-    vector=vector+1
+	. = 0b + 8
+	vector = vector+1
     .endr
 SYM_CODE_END(irq_entries_start)
 
@@ -486,16 +485,15 @@ SYM_CODE_END(irq_entries_start)
 	.align 8
 SYM_CODE_START(spurious_entries_start)
     vector=FIRST_SYSTEM_VECTOR
-    pos = .
     .rept (NR_VECTORS - FIRST_SYSTEM_VECTOR)
+0 :
 	UNWIND_HINT_IRET_REGS
-	.byte	0x6a, vector
+	.byte	0x6a, FIRST_SYSTEM_VECTOR + i
 	jmp	asm_spurious_interrupt
 	nop
 	/* Ensure that the above is 8 bytes max */
-	. = pos + 8
-    pos=pos+8
-    vector=vector+1
+	. = 0b + 8
+	vector = vector+1
     .endr
 SYM_CODE_END(spurious_entries_start)
 #endif
-- 
2.27.0.383.g050319c2ae-goog


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] x86/entry: add compatibility with IAS
  2020-07-13 21:38 ` Jian Cai
@ 2020-07-13 22:17   ` Arvind Sankar
  0 siblings, 0 replies; 11+ messages in thread
From: Arvind Sankar @ 2020-07-13 22:17 UTC (permalink / raw)
  To: Jian Cai
  Cc: jiancai, ndesaulniers, manojgupta, sedat.dilek, Brian Gerst,
	Arvind Sankar, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	x86, H. Peter Anvin, Andy Lutomirski, Peter Zijlstra,
	Alexandre Chartre, linux-kernel, clang-built-linux

On Mon, Jul 13, 2020 at 02:38:01PM -0700, Jian Cai wrote:
> Clang's integrated assembler does not allow symbols with non-absolute
> values to be reassigned. This patch allows the affected code to be
> compatible with IAS.
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/1043
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
> Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
> Suggested-by: Brian Gerst <brgerst@gmail.com>
> Suggested-by: Arvind Sankar <nivedita@alum.mit.edu>
> Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
> Signed-off-by: Jian Cai <caij2003@gmail.com>
> ---
>  arch/x86/include/asm/idtentry.h | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h
> index f3d70830bf2a..7d22684eafdf 100644
> --- a/arch/x86/include/asm/idtentry.h
> +++ b/arch/x86/include/asm/idtentry.h
> @@ -469,16 +469,15 @@ __visible noinstr void func(struct pt_regs *regs,			\
>  	.align 8
>  SYM_CODE_START(irq_entries_start)
>      vector=FIRST_EXTERNAL_VECTOR
> -    pos = .
>      .rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR)
> +0 :
>  	UNWIND_HINT_IRET_REGS

I know I had it this way, but I think it may be slightly safer to put
the label immediately after UNWIND_HINT_IRET_REGS instead of before,
just in case anyone adds a 0: inside that macro.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH] x86/entry: add compatibility with IAS
  2020-07-13  1:24 [PATCH] x86/entry: add compatibility with IAS Jian Cai
                   ` (2 preceding siblings ...)
  2020-07-13 21:38 ` Jian Cai
@ 2020-07-13 22:40 ` Jian Cai
  2020-07-14  9:34   ` Sedat Dilek
  2020-07-14 23:30 ` [PATCH v2] " Jian Cai
  4 siblings, 1 reply; 11+ messages in thread
From: Jian Cai @ 2020-07-13 22:40 UTC (permalink / raw)
  Cc: caij2003, jiancai, ndesaulniers, manojgupta, sedat.dilek,
	Brian Gerst, Arvind Sankar, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, x86, H. Peter Anvin, Andy Lutomirski,
	Peter Zijlstra, Alexandre Chartre, linux-kernel,
	clang-built-linux

Clang's integrated assembler does not allow symbols with non-absolute
values to be reassigned. This patch allows the affected code to be
compatible with IAS.

Link: https://github.com/ClangBuiltLinux/linux/issues/1043
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Suggested-by: Brian Gerst <brgerst@gmail.com>
Suggested-by: Arvind Sankar <nivedita@alum.mit.edu>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Jian Cai <caij2003@gmail.com>
---
 arch/x86/include/asm/idtentry.h | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h
index f3d70830bf2a..5efaaed34eda 100644
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -469,16 +469,15 @@ __visible noinstr void func(struct pt_regs *regs,			\
 	.align 8
 SYM_CODE_START(irq_entries_start)
     vector=FIRST_EXTERNAL_VECTOR
-    pos = .
     .rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR)
 	UNWIND_HINT_IRET_REGS
+0 :
 	.byte	0x6a, vector
 	jmp	asm_common_interrupt
 	nop
 	/* Ensure that the above is 8 bytes max */
-	. = pos + 8
-    pos=pos+8
-    vector=vector+1
+	. = 0b + 8
+	vector = vector+1
     .endr
 SYM_CODE_END(irq_entries_start)
 
@@ -486,16 +485,15 @@ SYM_CODE_END(irq_entries_start)
 	.align 8
 SYM_CODE_START(spurious_entries_start)
     vector=FIRST_SYSTEM_VECTOR
-    pos = .
     .rept (NR_VECTORS - FIRST_SYSTEM_VECTOR)
 	UNWIND_HINT_IRET_REGS
+0 :
 	.byte	0x6a, vector
 	jmp	asm_spurious_interrupt
 	nop
 	/* Ensure that the above is 8 bytes max */
-	. = pos + 8
-    pos=pos+8
-    vector=vector+1
+	. = 0b + 8
+	vector = vector+1
     .endr
 SYM_CODE_END(spurious_entries_start)
 #endif
-- 
2.27.0.383.g050319c2ae-goog


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] x86/entry: add compatibility with IAS
  2020-07-13 22:40 ` Jian Cai
@ 2020-07-14  9:34   ` Sedat Dilek
  2020-07-14 10:48     ` Sedat Dilek
  0 siblings, 1 reply; 11+ messages in thread
From: Sedat Dilek @ 2020-07-14  9:34 UTC (permalink / raw)
  To: Jian Cai
  Cc: jiancai, Nick Desaulniers, manojgupta, Brian Gerst,
	Arvind Sankar, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	x86, H. Peter Anvin, Andy Lutomirski, Peter Zijlstra,
	Alexandre Chartre, linux-kernel, Clang-Built-Linux ML

On Tue, Jul 14, 2020 at 12:40 AM Jian Cai <caij2003@gmail.com> wrote:
>
> Clang's integrated assembler does not allow symbols with non-absolute
> values to be reassigned. This patch allows the affected code to be
> compatible with IAS.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/1043
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
> Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
> Suggested-by: Brian Gerst <brgerst@gmail.com>
> Suggested-by: Arvind Sankar <nivedita@alum.mit.edu>
> Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
> Signed-off-by: Jian Cai <caij2003@gmail.com>

Hi Jian,

thanks for the update!

I am glad to see that some Linux/x86 assembler "monsters" jumped on the train.

So, your patch with reviewer's comment got several iterations?
Not sure if you are aware of the process of submitting patches (see [1])?

It is common to add a ChangeLog below commit-message-body and diffstat
means add below "--".
Something like:
--
Changes v1 -> v2:
- I did some cool stuff to improve this

While at it... Please add your version-of-patch to the subject-line:
You can do this via "git format-patch --signoff --subject-prefix="PATCH v2".
There might be other cool git tricks I do not know.

Hope I was no "Uberlehrer".

- Sedat -

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst

> ---
>  arch/x86/include/asm/idtentry.h | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h
> index f3d70830bf2a..5efaaed34eda 100644
> --- a/arch/x86/include/asm/idtentry.h
> +++ b/arch/x86/include/asm/idtentry.h
> @@ -469,16 +469,15 @@ __visible noinstr void func(struct pt_regs *regs,                 \
>         .align 8
>  SYM_CODE_START(irq_entries_start)
>      vector=FIRST_EXTERNAL_VECTOR
> -    pos = .
>      .rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR)
>         UNWIND_HINT_IRET_REGS
> +0 :
>         .byte   0x6a, vector
>         jmp     asm_common_interrupt
>         nop
>         /* Ensure that the above is 8 bytes max */
> -       . = pos + 8
> -    pos=pos+8
> -    vector=vector+1
> +       . = 0b + 8
> +       vector = vector+1
>      .endr
>  SYM_CODE_END(irq_entries_start)
>
> @@ -486,16 +485,15 @@ SYM_CODE_END(irq_entries_start)
>         .align 8
>  SYM_CODE_START(spurious_entries_start)
>      vector=FIRST_SYSTEM_VECTOR
> -    pos = .
>      .rept (NR_VECTORS - FIRST_SYSTEM_VECTOR)
>         UNWIND_HINT_IRET_REGS
> +0 :
>         .byte   0x6a, vector
>         jmp     asm_spurious_interrupt
>         nop
>         /* Ensure that the above is 8 bytes max */
> -       . = pos + 8
> -    pos=pos+8
> -    vector=vector+1
> +       . = 0b + 8
> +       vector = vector+1
>      .endr
>  SYM_CODE_END(spurious_entries_start)
>  #endif
> --
> 2.27.0.383.g050319c2ae-goog
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] x86/entry: add compatibility with IAS
  2020-07-14  9:34   ` Sedat Dilek
@ 2020-07-14 10:48     ` Sedat Dilek
  0 siblings, 0 replies; 11+ messages in thread
From: Sedat Dilek @ 2020-07-14 10:48 UTC (permalink / raw)
  To: Jian Cai
  Cc: jiancai, Nick Desaulniers, manojgupta, Brian Gerst,
	Arvind Sankar, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	x86, H. Peter Anvin, Andy Lutomirski, Peter Zijlstra,
	Alexandre Chartre, linux-kernel, Clang-Built-Linux ML

On Tue, Jul 14, 2020 at 11:34 AM Sedat Dilek <sedat.dilek@gmail.com> wrote:
>
> On Tue, Jul 14, 2020 at 12:40 AM Jian Cai <caij2003@gmail.com> wrote:
> >
> > Clang's integrated assembler does not allow symbols with non-absolute
> > values to be reassigned. This patch allows the affected code to be
> > compatible with IAS.
> >
> > Link: https://github.com/ClangBuiltLinux/linux/issues/1043
> > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> > Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
> > Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
> > Suggested-by: Brian Gerst <brgerst@gmail.com>
> > Suggested-by: Arvind Sankar <nivedita@alum.mit.edu>
> > Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
> > Signed-off-by: Jian Cai <caij2003@gmail.com>
>
> Hi Jian,
>
> thanks for the update!
>
> I am glad to see that some Linux/x86 assembler "monsters" jumped on the train.
>
> So, your patch with reviewer's comment got several iterations?
> Not sure if you are aware of the process of submitting patches (see [1])?
>
> It is common to add a ChangeLog below commit-message-body and diffstat
> means add below "--".
> Something like:
> --
> Changes v1 -> v2:
> - I did some cool stuff to improve this
>
> While at it... Please add your version-of-patch to the subject-line:
> You can do this via "git format-patch --signoff --subject-prefix="PATCH v2".
> There might be other cool git tricks I do not know.
>
> Hope I was no "Uberlehrer".
>
> - Sedat -
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst
>
> > ---
> >  arch/x86/include/asm/idtentry.h | 14 ++++++--------
> >  1 file changed, 6 insertions(+), 8 deletions(-)
> >
> > diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h
> > index f3d70830bf2a..5efaaed34eda 100644
> > --- a/arch/x86/include/asm/idtentry.h
> > +++ b/arch/x86/include/asm/idtentry.h
> > @@ -469,16 +469,15 @@ __visible noinstr void func(struct pt_regs *regs,                 \
> >         .align 8
> >  SYM_CODE_START(irq_entries_start)
> >      vector=FIRST_EXTERNAL_VECTOR
> > -    pos = .
> >      .rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR)
> >         UNWIND_HINT_IRET_REGS
> > +0 :
> >         .byte   0x6a, vector
> >         jmp     asm_common_interrupt
> >         nop
> >         /* Ensure that the above is 8 bytes max */
> > -       . = pos + 8
> > -    pos=pos+8
> > -    vector=vector+1
> > +       . = 0b + 8
> > +       vector = vector+1
> >      .endr
> >  SYM_CODE_END(irq_entries_start)
> >
> > @@ -486,16 +485,15 @@ SYM_CODE_END(irq_entries_start)
> >         .align 8
> >  SYM_CODE_START(spurious_entries_start)
> >      vector=FIRST_SYSTEM_VECTOR
> > -    pos = .
> >      .rept (NR_VECTORS - FIRST_SYSTEM_VECTOR)
> >         UNWIND_HINT_IRET_REGS
> > +0 :
> >         .byte   0x6a, vector
> >         jmp     asm_spurious_interrupt
> >         nop
> >         /* Ensure that the above is 8 bytes max */
> > -       . = pos + 8
> > -    pos=pos+8
> > -    vector=vector+1
> > +       . = 0b + 8
> > +       vector = vector+1
> >      .endr
> >  SYM_CODE_END(spurious_entries_start)
> >  #endif
> > --
> > 2.27.0.383.g050319c2ae-goog
> >

Stolen the patch from [1].

Tested-by: Sedat Dilek <sedat.dilek@gmail.com> #
Compile-/Assemble-tested against Linux v5.8-rc5 with LLVM/Clang
v11.0.0-git

- Sedat -

[1] https://lore.kernel.org/patchwork/patch/1272115/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2] x86/entry: add compatibility with IAS
  2020-07-13  1:24 [PATCH] x86/entry: add compatibility with IAS Jian Cai
                   ` (3 preceding siblings ...)
  2020-07-13 22:40 ` Jian Cai
@ 2020-07-14 23:30 ` Jian Cai
  2020-07-16 15:30   ` [tip: x86/urgent] x86/entry: Add " tip-bot2 for Jian Cai
  4 siblings, 1 reply; 11+ messages in thread
From: Jian Cai @ 2020-07-14 23:30 UTC (permalink / raw)
  Cc: caij2003, jiancai, ndesaulniers, manojgupta, sedat.dilek,
	Brian Gerst, Arvind Sankar, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, x86, H. Peter Anvin, Andy Lutomirski,
	Peter Zijlstra, Alexandre Chartre, linux-kernel,
	clang-built-linux

Clang's integrated assembler does not allow symbols with non-absolute
values to be reassigned. This patch allows the affected code to be
compatible with IAS.

Link: https://github.com/ClangBuiltLinux/linux/issues/1043
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Suggested-by: Brian Gerst <brgerst@gmail.com>
Suggested-by: Arvind Sankar <nivedita@alum.mit.edu>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com> #
Compile-/Assemble-tested against Linux v5.8-rc5 with LLVM/Clang
v11.0.0-git
Signed-off-by: Jian Cai <caij2003@gmail.com>
---

Thanks Nick and Sedat for explaining the process of submitting patches.
Include the changelog as follows,

Changes v1 -> v2:
 Update the patch based on Arvind Sankar <nivedita@alum.mit.edu>'s
 comments. Also include addtional information in the Tested-by tag.

 arch/x86/include/asm/idtentry.h | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h
index f3d70830bf2a..5efaaed34eda 100644
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -469,16 +469,15 @@ __visible noinstr void func(struct pt_regs *regs,			\
 	.align 8
 SYM_CODE_START(irq_entries_start)
     vector=FIRST_EXTERNAL_VECTOR
-    pos = .
     .rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR)
 	UNWIND_HINT_IRET_REGS
+0 :
 	.byte	0x6a, vector
 	jmp	asm_common_interrupt
 	nop
 	/* Ensure that the above is 8 bytes max */
-	. = pos + 8
-    pos=pos+8
-    vector=vector+1
+	. = 0b + 8
+	vector = vector+1
     .endr
 SYM_CODE_END(irq_entries_start)
 
@@ -486,16 +485,15 @@ SYM_CODE_END(irq_entries_start)
 	.align 8
 SYM_CODE_START(spurious_entries_start)
     vector=FIRST_SYSTEM_VECTOR
-    pos = .
     .rept (NR_VECTORS - FIRST_SYSTEM_VECTOR)
 	UNWIND_HINT_IRET_REGS
+0 :
 	.byte	0x6a, vector
 	jmp	asm_spurious_interrupt
 	nop
 	/* Ensure that the above is 8 bytes max */
-	. = pos + 8
-    pos=pos+8
-    vector=vector+1
+	. = 0b + 8
+	vector = vector+1
     .endr
 SYM_CODE_END(spurious_entries_start)
 #endif
-- 
2.27.0.389.gc38d7665816-goog


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [tip: x86/urgent] x86/entry: Add compatibility with IAS
  2020-07-14 23:30 ` [PATCH v2] " Jian Cai
@ 2020-07-16 15:30   ` tip-bot2 for Jian Cai
  0 siblings, 0 replies; 11+ messages in thread
From: tip-bot2 for Jian Cai @ 2020-07-16 15:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Nick Desaulniers, Sedat Dilek, Brian Gerst, Arvind Sankar,
	Jian Cai, Thomas Gleixner, x86, LKML

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     6ee93f8df09c470da1a4af11e394c52d7b62418c
Gitweb:        https://git.kernel.org/tip/6ee93f8df09c470da1a4af11e394c52d7b62418c
Author:        Jian Cai <caij2003@gmail.com>
AuthorDate:    Tue, 14 Jul 2020 16:30:21 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Thu, 16 Jul 2020 17:25:09 +02:00

x86/entry: Add compatibility with IAS

Clang's integrated assembler does not allow symbols with non-absolute
values to be reassigned. Modify the interrupt entry loop macro to be
compatible with IAS by using a label and an offset.

Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Suggested-by: Brian Gerst <brgerst@gmail.com>
Suggested-by: Arvind Sankar <nivedita@alum.mit.edu>
Signed-off-by: Jian Cai <caij2003@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com> #
Link: https://github.com/ClangBuiltLinux/linux/issues/1043
Link: https://lkml.kernel.org/r/20200714233024.1789985-1-caij2003@gmail.com
---
 arch/x86/include/asm/idtentry.h | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h
index f3d7083..5efaaed 100644
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -469,16 +469,15 @@ __visible noinstr void func(struct pt_regs *regs,			\
 	.align 8
 SYM_CODE_START(irq_entries_start)
     vector=FIRST_EXTERNAL_VECTOR
-    pos = .
     .rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR)
 	UNWIND_HINT_IRET_REGS
+0 :
 	.byte	0x6a, vector
 	jmp	asm_common_interrupt
 	nop
 	/* Ensure that the above is 8 bytes max */
-	. = pos + 8
-    pos=pos+8
-    vector=vector+1
+	. = 0b + 8
+	vector = vector+1
     .endr
 SYM_CODE_END(irq_entries_start)
 
@@ -486,16 +485,15 @@ SYM_CODE_END(irq_entries_start)
 	.align 8
 SYM_CODE_START(spurious_entries_start)
     vector=FIRST_SYSTEM_VECTOR
-    pos = .
     .rept (NR_VECTORS - FIRST_SYSTEM_VECTOR)
 	UNWIND_HINT_IRET_REGS
+0 :
 	.byte	0x6a, vector
 	jmp	asm_spurious_interrupt
 	nop
 	/* Ensure that the above is 8 bytes max */
-	. = pos + 8
-    pos=pos+8
-    vector=vector+1
+	. = 0b + 8
+	vector = vector+1
     .endr
 SYM_CODE_END(spurious_entries_start)
 #endif

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-07-16 15:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-13  1:24 [PATCH] x86/entry: add compatibility with IAS Jian Cai
2020-07-13  2:33 ` Brian Gerst
2020-07-13  2:54 ` Arvind Sankar
2020-07-13  3:57   ` Arvind Sankar
2020-07-13 21:38 ` Jian Cai
2020-07-13 22:17   ` Arvind Sankar
2020-07-13 22:40 ` Jian Cai
2020-07-14  9:34   ` Sedat Dilek
2020-07-14 10:48     ` Sedat Dilek
2020-07-14 23:30 ` [PATCH v2] " Jian Cai
2020-07-16 15:30   ` [tip: x86/urgent] x86/entry: Add " tip-bot2 for Jian Cai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).