All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] powerpc/signal: Add helper function to fetch quad word aligned pointer
@ 2015-07-20  2:58 Anshuman Khandual
  2015-07-21  1:37 ` [V2] " Michael Ellerman
  2015-07-22  9:44 ` Michael Ellerman
  0 siblings, 2 replies; 4+ messages in thread
From: Anshuman Khandual @ 2015-07-20  2:58 UTC (permalink / raw
  To: linuxppc-dev; +Cc: mikey, mpe

This patch adds one helper function 'sigcontext_vmx_regs' which computes
quad word aligned pointer for 'vmx_reserve' array element in sigcontext
structure making the code more readable.

Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
- Fixed some indentation problems
- Changed function name from 'vmx_reserve_addr' to 'sigcontext_vmx_regs'
- Added some documentation before the function

 arch/powerpc/kernel/signal_64.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index c7c24d2..bb9c939 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -74,6 +74,16 @@ static const char fmt64[] = KERN_INFO \
 	"%s[%d]: bad frame in %s: %016lx nip %016lx lr %016lx\n";
 
 /*
+ * This computes quad word aligned pointer for 'vmx_reserve' array element
+ * which is used primarily in assigning to the preceding pointer 'v_regs'
+ * in sigcontext structure.
+ */
+static elf_vrreg_t __user *sigcontext_vmx_regs(struct sigcontext __user *sc)
+{
+	return (elf_vrreg_t __user *) (((unsigned long)sc->vmx_reserve + 15) & ~0xful);
+}
+
+/*
  * Set up the sigcontext for the signal frame.
  */
 
@@ -90,7 +100,7 @@ static long setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
 	 * v_regs pointer or not
 	 */
 #ifdef CONFIG_ALTIVEC
-	elf_vrreg_t __user *v_regs = (elf_vrreg_t __user *)(((unsigned long)sc->vmx_reserve + 15) & ~0xful);
+	elf_vrreg_t __user *v_regs = sigcontext_vmx_regs(sc);
 #endif
 	unsigned long msr = regs->msr;
 	long err = 0;
@@ -181,10 +191,8 @@ static long setup_tm_sigcontexts(struct sigcontext __user *sc,
 	 * v_regs pointer or not.
 	 */
 #ifdef CONFIG_ALTIVEC
-	elf_vrreg_t __user *v_regs = (elf_vrreg_t __user *)
-		(((unsigned long)sc->vmx_reserve + 15) & ~0xful);
-	elf_vrreg_t __user *tm_v_regs = (elf_vrreg_t __user *)
-		(((unsigned long)tm_sc->vmx_reserve + 15) & ~0xful);
+	elf_vrreg_t __user *v_regs = sigcontext_vmx_regs(sc);
+	elf_vrreg_t __user *tm_v_regs = sigcontext_vmx_regs(tm_sc);
 #endif
 	unsigned long msr = regs->msr;
 	long err = 0;
-- 
2.1.0

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

* Re: [V2] powerpc/signal: Add helper function to fetch quad word aligned pointer
  2015-07-20  2:58 [PATCH V2] powerpc/signal: Add helper function to fetch quad word aligned pointer Anshuman Khandual
@ 2015-07-21  1:37 ` Michael Ellerman
  2015-07-21  5:04   ` Anshuman Khandual
  2015-07-22  9:44 ` Michael Ellerman
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Ellerman @ 2015-07-21  1:37 UTC (permalink / raw
  To: Anshuman Khandual, linuxppc-dev; +Cc: mikey

On Mon, 2015-20-07 at 02:58:43 UTC, Anshuman Khandual wrote:
> This patch adds one helper function 'sigcontext_vmx_regs' which computes
> quad word aligned pointer for 'vmx_reserve' array element in sigcontext
> structure making the code more readable.
> 
> diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
> index c7c24d2..bb9c939 100644
> --- a/arch/powerpc/kernel/signal_64.c
> +++ b/arch/powerpc/kernel/signal_64.c
> @@ -74,6 +74,16 @@ static const char fmt64[] = KERN_INFO \
>  	"%s[%d]: bad frame in %s: %016lx nip %016lx lr %016lx\n";
>  
>  /*
> + * This computes quad word aligned pointer for 'vmx_reserve' array element
> + * which is used primarily in assigning to the preceding pointer 'v_regs'
> + * in sigcontext structure.

How about:

  * This computes a quad word aligned pointer inside the vmx_reserve array
  * element. For historical reasons sigcontext might not be quad word aligned,
  * but the location we write the VMX regs to must be. See the comment in
  * sigcontext for more detail.


> + */
> +static elf_vrreg_t __user *sigcontext_vmx_regs(struct sigcontext __user *sc)
> +{
> +	return (elf_vrreg_t __user *) (((unsigned long)sc->vmx_reserve + 15) & ~0xful);
> +}

This doesn't build for ppc64e_defconfig:

  arch/powerpc/kernel/signal_64.c:82:28: error: 'sigcontext_vmx_regs' defined but not used [-Werror=unused-function]
   static elf_vrreg_t __user *sigcontext_vmx_regs(struct sigcontext __user *sc)
                            ^

For now I'll just #ifdef it.

Please do a test build of ppc64e_defconfig in future.

cheers

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

* Re: [V2] powerpc/signal: Add helper function to fetch quad word aligned pointer
  2015-07-21  1:37 ` [V2] " Michael Ellerman
@ 2015-07-21  5:04   ` Anshuman Khandual
  0 siblings, 0 replies; 4+ messages in thread
From: Anshuman Khandual @ 2015-07-21  5:04 UTC (permalink / raw
  To: Michael Ellerman, linuxppc-dev; +Cc: mikey

On 07/21/2015 07:07 AM, Michael Ellerman wrote:
> On Mon, 2015-20-07 at 02:58:43 UTC, Anshuman Khandual wrote:
>> This patch adds one helper function 'sigcontext_vmx_regs' which computes
>> quad word aligned pointer for 'vmx_reserve' array element in sigcontext
>> structure making the code more readable.
>>
>> diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
>> index c7c24d2..bb9c939 100644
>> --- a/arch/powerpc/kernel/signal_64.c
>> +++ b/arch/powerpc/kernel/signal_64.c
>> @@ -74,6 +74,16 @@ static const char fmt64[] = KERN_INFO \
>>  	"%s[%d]: bad frame in %s: %016lx nip %016lx lr %016lx\n";
>>  
>>  /*
>> + * This computes quad word aligned pointer for 'vmx_reserve' array element
>> + * which is used primarily in assigning to the preceding pointer 'v_regs'
>> + * in sigcontext structure.
> 
> How about:
> 
>   * This computes a quad word aligned pointer inside the vmx_reserve array
>   * element. For historical reasons sigcontext might not be quad word aligned,
>   * but the location we write the VMX regs to must be. See the comment in
>   * sigcontext for more detail.

Yeah, its way better. Thanks !

> 
> 
>> + */
>> +static elf_vrreg_t __user *sigcontext_vmx_regs(struct sigcontext __user *sc)
>> +{
>> +	return (elf_vrreg_t __user *) (((unsigned long)sc->vmx_reserve + 15) & ~0xful);
>> +}
> 
> This doesn't build for ppc64e_defconfig:

This time, I did build test for some of the configs but not the entire
comprehensive list. Sorry, missed this one though, will take care next
time around.

> 
>   arch/powerpc/kernel/signal_64.c:82:28: error: 'sigcontext_vmx_regs' defined but not used [-Werror=unused-function]
>    static elf_vrreg_t __user *sigcontext_vmx_regs(struct sigcontext __user *sc)
>                             ^
> 
> For now I'll just #ifdef it.
> 
> Please do a test build of ppc64e_defconfig in future.

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

* Re: [V2] powerpc/signal: Add helper function to fetch quad word aligned pointer
  2015-07-20  2:58 [PATCH V2] powerpc/signal: Add helper function to fetch quad word aligned pointer Anshuman Khandual
  2015-07-21  1:37 ` [V2] " Michael Ellerman
@ 2015-07-22  9:44 ` Michael Ellerman
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2015-07-22  9:44 UTC (permalink / raw
  To: Anshuman Khandual, linuxppc-dev; +Cc: mikey

On Mon, 2015-20-07 at 02:58:43 UTC, Anshuman Khandual wrote:
> This patch adds one helper function 'sigcontext_vmx_regs' which computes
> quad word aligned pointer for 'vmx_reserve' array element in sigcontext
> structure making the code more readable.
> 
> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/2476c09f391eddb546a7

cheers

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

end of thread, other threads:[~2015-07-22  9:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-20  2:58 [PATCH V2] powerpc/signal: Add helper function to fetch quad word aligned pointer Anshuman Khandual
2015-07-21  1:37 ` [V2] " Michael Ellerman
2015-07-21  5:04   ` Anshuman Khandual
2015-07-22  9:44 ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.