[PATCH] treewide: avoid the ponter addition with NULL pointer

2021-02-22 Thread sz18665958617
From: "dean.yang_cp" 

Signed-off-by: dean.yang_cp 
---
 arch/arc/kernel/unwind.c | 27 ++-
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/arch/arc/kernel/unwind.c b/arch/arc/kernel/unwind.c
index 74ad425..47bab67 100644
--- a/arch/arc/kernel/unwind.c
+++ b/arch/arc/kernel/unwind.c
@@ -187,25 +187,26 @@ static void init_unwind_table(struct unwind_table *table, 
const char *name,
  const void *table_start, unsigned long table_size,
  const u8 *header_start, unsigned long header_size)
 {
-   const u8 *ptr = header_start + 4;
-   const u8 *end = header_start + header_size;
-
table->core.pc = (unsigned long)core_start;
table->core.range = core_size;
table->init.pc = (unsigned long)init_start;
table->init.range = init_size;
table->address = table_start;
table->size = table_size;
-
-   /* See if the linker provided table looks valid. */
-   if (header_size <= 4
-   || header_start[0] != 1
-   || (void *)read_pointer(&ptr, end, header_start[1]) != table_start
-   || header_start[2] == DW_EH_PE_omit
-   || read_pointer(&ptr, end, header_start[2]) <= 0
-   || header_start[3] == DW_EH_PE_omit)
-   header_start = NULL;
-
+   /* To avoid the pointer addition with NULL pointer.*/
+   if (header_start != NULL) {
+   const u8 *ptr = header_start + 4;
+   const u8 *end = header_start + header_size;
+   /* See if the linker provided table looks valid. */
+   if (header_size <= 4
+   || header_start[0] != 1
+   || (void *)read_pointer(&ptr, end, header_start[1])
+   != table_start
+   || header_start[2] == DW_EH_PE_omit
+   || read_pointer(&ptr, end, header_start[2]) <= 0
+   || header_start[3] == DW_EH_PE_omit)
+   header_start = NULL;
+   }
table->hdrsz = header_size;
smp_wmb();
table->header = header_start;
-- 
1.9.1



___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH] ARC: Enable automatic support for newer ARC ISA variants (ARCv3)

2021-02-22 Thread Vineet Gupta
The syscall TRAP instruction used to be 4 bytes on legacy ARCompact
based ARC700 cores. Since then ARCv2 (circa 2014) and the upcoming ARCv3
use the same 2-byte TRAP_S instruction.

To ease porting of software to new ISA, special case ARC700.

This is the only change needed to get strace working on 64-bit ARCv3
cores (kudos to strace for making porting so easy)

Signed-off-by: Vineet Gupta 
---
 src/linux/arc/raw_syscall.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/linux/arc/raw_syscall.h b/src/linux/arc/raw_syscall.h
index 6e60a6112b31..f54fe06f33df 100644
--- a/src/linux/arc/raw_syscall.h
+++ b/src/linux/arc/raw_syscall.h
@@ -21,10 +21,8 @@ raw_syscall_0(const kernel_ulong_t nr, kernel_ulong_t *err)
 
 # ifdef __A7__
 #  define ARC_TRAP_INSN "trap0"
-# elif defined __HS__
-#  define ARC_TRAP_INSN "trap_s 0 "
 # else
-#  error unrecognized arc
+#  define ARC_TRAP_INSN "trap_s 0 "
 # endif
 
__asm__ __volatile__(ARC_TRAP_INSN
-- 
2.25.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] treewide: avoid the ponter addition with NULL pointer

2021-02-22 Thread Vineet Gupta
On 2/22/21 6:00 PM, sz18665958...@163.com wrote:
> From: "dean.yang_cp" 
>
> Signed-off-by: dean.yang_cp 

LGTM.

Acked-by: Vineet Gupta 

Thx,
-Vineet

> ---
>   arch/arc/kernel/unwind.c | 27 ++-
>   1 file changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/arch/arc/kernel/unwind.c b/arch/arc/kernel/unwind.c
> index 74ad425..47bab67 100644
> --- a/arch/arc/kernel/unwind.c
> +++ b/arch/arc/kernel/unwind.c
> @@ -187,25 +187,26 @@ static void init_unwind_table(struct unwind_table 
> *table, const char *name,
> const void *table_start, unsigned long table_size,
> const u8 *header_start, unsigned long header_size)
>   {
> - const u8 *ptr = header_start + 4;
> - const u8 *end = header_start + header_size;
> -
>   table->core.pc = (unsigned long)core_start;
>   table->core.range = core_size;
>   table->init.pc = (unsigned long)init_start;
>   table->init.range = init_size;
>   table->address = table_start;
>   table->size = table_size;
> -
> - /* See if the linker provided table looks valid. */
> - if (header_size <= 4
> - || header_start[0] != 1
> - || (void *)read_pointer(&ptr, end, header_start[1]) != table_start
> - || header_start[2] == DW_EH_PE_omit
> - || read_pointer(&ptr, end, header_start[2]) <= 0
> - || header_start[3] == DW_EH_PE_omit)
> - header_start = NULL;
> -
> + /* To avoid the pointer addition with NULL pointer.*/
> + if (header_start != NULL) {
> + const u8 *ptr = header_start + 4;
> + const u8 *end = header_start + header_size;
> + /* See if the linker provided table looks valid. */
> + if (header_size <= 4
> + || header_start[0] != 1
> + || (void *)read_pointer(&ptr, end, header_start[1])
> + != table_start
> + || header_start[2] == DW_EH_PE_omit
> + || read_pointer(&ptr, end, header_start[2]) <= 0
> + || header_start[3] == DW_EH_PE_omit)
> + header_start = NULL;
> + }
>   table->hdrsz = header_size;
>   smp_wmb();
>   table->header = header_start;

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc