Re: [PATCH] arm64: setup return path for el1_undef

2014-12-23 Thread Min-Hua Chen
On Tue, Dec 23, 2014 at 11:57 PM, Catalin Marinas
 wrote:
> On Tue, Dec 23, 2014 at 03:15:10PM +, Min-Hua Chen wrote:
>> Setup return path for el1_undef since el1_undef may
>> be handled by handlers.
>
> Did you find a real issue or it was just code inspection.

Thanks for your reply. It was just a code inspection.

Min-Hua

>
>> asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
>> {
>> siginfo_t info;
>> void __user *pc = (void __user *)instruction_pointer(regs);
>>
>> /* check for AArch32 breakpoint instructions */
>> if (!aarch32_break_handler(regs))
>> return;
>>
>> if (call_undef_hook(regs) == 0)
>> return;
>>
>> ...
>> }
>> Signed-off-by: Min-Hua Chen 
>> ---
>>  arch/arm64/kernel/entry.S |3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
>> index fd4fa37..86ebec5 100644
>> --- a/arch/arm64/kernel/entry.S
>> +++ b/arch/arm64/kernel/entry.S
>> @@ -313,7 +313,8 @@ el1_undef:
>>   */
>>  enable_dbg
>>  movx0, sp
>> -bdo_undefinstr
>> +bldo_undefinstr
>> +kernel_exit 1
>>  el1_dbg:
>>  /*
>>   * Debug exception handling
>
> I don't think this is needed. The code is pretty convoluted but for an
> EL1 undefined exception we should never return from do_undefinstr(). The
> call_undef_hook() function returns 1 if !user_mode(regs) and this should
> cause a kernel panic. Basically we do not allow any kind of undefined
> instructions in the arm64 kernel.
>
> --
> Catalin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] arm64: setup return path for el1_undef

2014-12-23 Thread Catalin Marinas
On Tue, Dec 23, 2014 at 03:15:10PM +, Min-Hua Chen wrote:
> Setup return path for el1_undef since el1_undef may
> be handled by handlers.

Did you find a real issue or it was just code inspection.

> asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
> {
> siginfo_t info;
> void __user *pc = (void __user *)instruction_pointer(regs);
> 
> /* check for AArch32 breakpoint instructions */
> if (!aarch32_break_handler(regs))
> return;
> 
> if (call_undef_hook(regs) == 0)
> return;
> 
> ...
> }
> Signed-off-by: Min-Hua Chen 
> ---
>  arch/arm64/kernel/entry.S |3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
> index fd4fa37..86ebec5 100644
> --- a/arch/arm64/kernel/entry.S
> +++ b/arch/arm64/kernel/entry.S
> @@ -313,7 +313,8 @@ el1_undef:
>   */
>  enable_dbg
>  movx0, sp
> -bdo_undefinstr
> +bldo_undefinstr
> +kernel_exit 1
>  el1_dbg:
>  /*
>   * Debug exception handling

I don't think this is needed. The code is pretty convoluted but for an
EL1 undefined exception we should never return from do_undefinstr(). The
call_undef_hook() function returns 1 if !user_mode(regs) and this should
cause a kernel panic. Basically we do not allow any kind of undefined
instructions in the arm64 kernel.

-- 
Catalin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] arm64: setup return path for el1_undef

2014-12-23 Thread Min-Hua Chen
Setup return path for el1_undef since el1_undef may
be handled by handlers.

asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
{
siginfo_t info;
void __user *pc = (void __user *)instruction_pointer(regs);

/* check for AArch32 breakpoint instructions */
if (!aarch32_break_handler(regs))
return;

if (call_undef_hook(regs) == 0)
return;

...
}

Signed-off-by: Min-Hua Chen 
---
 arch/arm64/kernel/entry.S |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index fd4fa37..86ebec5 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -313,7 +313,8 @@ el1_undef:
  */
 enable_dbg
 movx0, sp
-bdo_undefinstr
+bldo_undefinstr
+kernel_exit 1
 el1_dbg:
 /*
  * Debug exception handling
-- 
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] arm64: setup return path for el1_undef

2014-12-23 Thread Min-Hua Chen
Setup return path for el1_undef since el1_undef may
be handled by handlers.

asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
{
siginfo_t info;
void __user *pc = (void __user *)instruction_pointer(regs);

/* check for AArch32 breakpoint instructions */
if (!aarch32_break_handler(regs))
return;

if (call_undef_hook(regs) == 0)
return;

...
}

Signed-off-by: Min-Hua Chen orca.c...@gmail.com
---
 arch/arm64/kernel/entry.S |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index fd4fa37..86ebec5 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -313,7 +313,8 @@ el1_undef:
  */
 enable_dbg
 movx0, sp
-bdo_undefinstr
+bldo_undefinstr
+kernel_exit 1
 el1_dbg:
 /*
  * Debug exception handling
-- 
1.7.10.4
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] arm64: setup return path for el1_undef

2014-12-23 Thread Catalin Marinas
On Tue, Dec 23, 2014 at 03:15:10PM +, Min-Hua Chen wrote:
 Setup return path for el1_undef since el1_undef may
 be handled by handlers.

Did you find a real issue or it was just code inspection.

 asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
 {
 siginfo_t info;
 void __user *pc = (void __user *)instruction_pointer(regs);
 
 /* check for AArch32 breakpoint instructions */
 if (!aarch32_break_handler(regs))
 return;
 
 if (call_undef_hook(regs) == 0)
 return;
 
 ...
 }
 Signed-off-by: Min-Hua Chen orca.c...@gmail.com
 ---
  arch/arm64/kernel/entry.S |3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
 index fd4fa37..86ebec5 100644
 --- a/arch/arm64/kernel/entry.S
 +++ b/arch/arm64/kernel/entry.S
 @@ -313,7 +313,8 @@ el1_undef:
   */
  enable_dbg
  movx0, sp
 -bdo_undefinstr
 +bldo_undefinstr
 +kernel_exit 1
  el1_dbg:
  /*
   * Debug exception handling

I don't think this is needed. The code is pretty convoluted but for an
EL1 undefined exception we should never return from do_undefinstr(). The
call_undef_hook() function returns 1 if !user_mode(regs) and this should
cause a kernel panic. Basically we do not allow any kind of undefined
instructions in the arm64 kernel.

-- 
Catalin
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] arm64: setup return path for el1_undef

2014-12-23 Thread Min-Hua Chen
On Tue, Dec 23, 2014 at 11:57 PM, Catalin Marinas
catalin.mari...@arm.com wrote:
 On Tue, Dec 23, 2014 at 03:15:10PM +, Min-Hua Chen wrote:
 Setup return path for el1_undef since el1_undef may
 be handled by handlers.

 Did you find a real issue or it was just code inspection.

Thanks for your reply. It was just a code inspection.

Min-Hua


 asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
 {
 siginfo_t info;
 void __user *pc = (void __user *)instruction_pointer(regs);

 /* check for AArch32 breakpoint instructions */
 if (!aarch32_break_handler(regs))
 return;

 if (call_undef_hook(regs) == 0)
 return;

 ...
 }
 Signed-off-by: Min-Hua Chen orca.c...@gmail.com
 ---
  arch/arm64/kernel/entry.S |3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

 diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
 index fd4fa37..86ebec5 100644
 --- a/arch/arm64/kernel/entry.S
 +++ b/arch/arm64/kernel/entry.S
 @@ -313,7 +313,8 @@ el1_undef:
   */
  enable_dbg
  movx0, sp
 -bdo_undefinstr
 +bldo_undefinstr
 +kernel_exit 1
  el1_dbg:
  /*
   * Debug exception handling

 I don't think this is needed. The code is pretty convoluted but for an
 EL1 undefined exception we should never return from do_undefinstr(). The
 call_undef_hook() function returns 1 if !user_mode(regs) and this should
 cause a kernel panic. Basically we do not allow any kind of undefined
 instructions in the arm64 kernel.

 --
 Catalin
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/