public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i386-pda updates
@ 2006-09-09  8:15 Jeremy Fitzhardinge
  2006-09-09 15:52 ` Andi Kleen
  0 siblings, 1 reply; 5+ messages in thread
From: Jeremy Fitzhardinge @ 2006-09-09  8:15 UTC (permalink / raw)
  To: Andi Kleen, Andrew Morton; +Cc: Linux Kernel Mailing List

Updates to i386-pda:

- fix typo
- add a self-pointer to the PDA, so that finding its
  linear address is easy
- add type checking to PDA write operations
- add byte-sized read/writes to the PDA

Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>

---
 arch/i386/kernel/cpu/common.c |    4 +++-
 include/asm-i386/pda.h        |   19 +++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff -r 69614542c834 arch/i386/kernel/cpu/common.c
--- a/arch/i386/kernel/cpu/common.c	Fri Sep 08 16:53:26 2006 -0700
+++ b/arch/i386/kernel/cpu/common.c	Sat Sep 09 00:19:48 2006 -0700
@@ -588,7 +588,7 @@ void __init early_cpu_init(void)
 #endif
 }
 
-/* Make sure %gs it initialized properly in idle threads */
+/* Make sure %gs is initialized properly in idle threads */
 struct pt_regs * __devinit idle_regs(struct pt_regs *regs)
 {
 	memset(regs, 0, sizeof(struct pt_regs));
@@ -648,6 +648,8 @@ static __cpuinit void pda_init(int cpu, 
 
 	memset(pda, 0, sizeof(*pda));
 
+	pda->_pda = pda;
+
 	pda->cpu_number = cpu;
 	pda->pcurrent = curr;
 
diff -r 69614542c834 include/asm-i386/pda.h
--- a/include/asm-i386/pda.h	Fri Sep 08 16:53:26 2006 -0700
+++ b/include/asm-i386/pda.h	Sat Sep 09 00:19:48 2006 -0700
@@ -3,6 +3,8 @@
 
 struct i386_pda
 {
+	struct i386_pda *_pda;		/* pointer to self */
+
 	struct task_struct *pcurrent;	/* current process */
 	int cpu_number;
 };
@@ -20,7 +22,14 @@ extern struct i386_pda _proxy_pda;
 #define pda_to_op(op,field,val)						\
 	do {								\
 		typedef typeof(_proxy_pda.field) T__;			\
+		if (0) { T__ tmp__; tmp__ = (val); }			\
 		switch (sizeof(_proxy_pda.field)) {			\
+		case 1:							\
+			asm(op "b %1,%%gs:%c2"				\
+			    : "+m" (_proxy_pda.field)			\
+			    :"ri" ((T__)val),				\
+			     "i"(pda_offset(field)));			\
+			break;						\
 		case 2:							\
 			asm(op "w %1,%%gs:%c2"				\
 			    : "+m" (_proxy_pda.field)			\
@@ -41,6 +50,12 @@ extern struct i386_pda _proxy_pda;
 	({								\
 		typeof(_proxy_pda.field) ret__;				\
 		switch (sizeof(_proxy_pda.field)) {			\
+		case 1:							\
+			asm(op "b %%gs:%c1,%0"				\
+			    : "=r" (ret__)				\
+			    : "i" (pda_offset(field)),			\
+			      "m" (_proxy_pda.field));			\
+			break;						\
 		case 2:							\
 			asm(op "w %%gs:%c1,%0"				\
 			    : "=r" (ret__)				\
@@ -57,6 +72,10 @@ extern struct i386_pda _proxy_pda;
 		}							\
 		ret__; })
 
+/* Return a pointer to a pda field */
+#define pda_addr(field)							\
+	((typeof(_proxy_pda.field) *)((unsigned char *)read_pda(_pda) + \
+				      pda_offset(field)))
 
 #define read_pda(field) pda_from_op("mov",field)
 #define write_pda(field,val) pda_to_op("mov",field,val)


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

* Re: [PATCH] i386-pda updates
  2006-09-09  8:15 [PATCH] i386-pda updates Jeremy Fitzhardinge
@ 2006-09-09 15:52 ` Andi Kleen
  2006-09-09 23:07   ` Jeremy Fitzhardinge
  2006-09-09 23:30   ` Jeremy Fitzhardinge
  0 siblings, 2 replies; 5+ messages in thread
From: Andi Kleen @ 2006-09-09 15:52 UTC (permalink / raw)
  To: Jeremy Fitzhardinge; +Cc: Andrew Morton, Linux Kernel Mailing List

On Sat, Sep 09, 2006 at 01:15:30AM -0700, Jeremy Fitzhardinge wrote:
> 
> -/* Make sure %gs it initialized properly in idle threads */
> +/* Make sure %gs is initialized properly in idle threads */

Merged

> };
> @@ -20,7 +22,14 @@ extern struct i386_pda _proxy_pda;
> #define pda_to_op(op,field,val)					 \
> 	do {								\
> 		typedef typeof(_proxy_pda.field) T__;			\
> +		if (0) { T__ tmp__; tmp__ = (val); }			\

Merged into original patch

> 		switch (sizeof(_proxy_pda.field)) {			\
> +		case 1:							\
> +			asm(op "b %1,%%gs:%c2"				\
> +			    : "+m" (_proxy_pda.field)			\
> +			    :"ri" ((T__)val),				\
> +			     "i"(pda_offset(field)));			\
> +			break;						\
> 		case 2:							\
> 			asm(op "w %1,%%gs:%c2"				\
> 			    : "+m" (_proxy_pda.field)			\
> @@ -41,6 +50,12 @@ extern struct i386_pda _proxy_pda;
> 	({								\
> 		typeof(_proxy_pda.field) ret__;				\
> 		switch (sizeof(_proxy_pda.field)) {			\
> +		case 1:							\
> +			asm(op "b %%gs:%c1,%0"				\
> +			    : "=r" (ret__)				\
> +			    : "i" (pda_offset(field)),			\
> +			      "m" (_proxy_pda.field));			\
> +			break;						\
> 		case 2:							\
> 			asm(op "w %%gs:%c1,%0"				\
> 			    : "=r" (ret__)				\
> @@ -57,6 +72,10 @@ extern struct i386_pda _proxy_pda;
> 		}							\
> 		ret__; })
> 
> +/* Return a pointer to a pda field */
> +#define pda_addr(field)						 \
> +	((typeof(_proxy_pda.field) *)((unsigned char *)read_pda(_pda) + \
> +				      pda_offset(field)))

I think i would prefer to merge that and the 1 byte one only
with actual users (x86-64 hasn't needed either for a long time)

-Andi

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

* Re: [PATCH] i386-pda updates
  2006-09-09 15:52 ` Andi Kleen
@ 2006-09-09 23:07   ` Jeremy Fitzhardinge
  2006-09-09 23:30   ` Jeremy Fitzhardinge
  1 sibling, 0 replies; 5+ messages in thread
From: Jeremy Fitzhardinge @ 2006-09-09 23:07 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Andrew Morton, Linux Kernel Mailing List

Andi Kleen wrote:
> I think i would prefer to merge that and the 1 byte one only
> with actual users (x86-64 hasn't needed either for a long time)

Taking the address of a PDA field is pretty useful.  And it is going to 
be important for a subsequent patch.

    J


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

* Re: [PATCH] i386-pda updates
  2006-09-09 15:52 ` Andi Kleen
  2006-09-09 23:07   ` Jeremy Fitzhardinge
@ 2006-09-09 23:30   ` Jeremy Fitzhardinge
  2006-09-10  6:18     ` Andi Kleen
  1 sibling, 1 reply; 5+ messages in thread
From: Jeremy Fitzhardinge @ 2006-09-09 23:30 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Andrew Morton, Linux Kernel Mailing List

Andi Kleen wrote:
>> @@ -20,7 +22,14 @@ extern struct i386_pda _proxy_pda;
>> #define pda_to_op(op,field,val)					 \
>> 	do {								\
>> 		typedef typeof(_proxy_pda.field) T__;			\
>> +		if (0) { T__ tmp__; tmp__ = (val); }			\
>>     
>
> Merged into original patch
>   
BTW, do you mean you already had this in i386, or that you folded it 
into the existing patch?  I don't think I had sent out my version of 
this before.

    J

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

* Re: [PATCH] i386-pda updates
  2006-09-09 23:30   ` Jeremy Fitzhardinge
@ 2006-09-10  6:18     ` Andi Kleen
  0 siblings, 0 replies; 5+ messages in thread
From: Andi Kleen @ 2006-09-10  6:18 UTC (permalink / raw)
  To: Jeremy Fitzhardinge; +Cc: Andrew Morton, Linux Kernel Mailing List

On Sat, Sep 09, 2006 at 04:30:31PM -0700, Jeremy Fitzhardinge wrote:
> Andi Kleen wrote:
> >>@@ -20,7 +22,14 @@ extern struct i386_pda _proxy_pda;
> >>#define pda_to_op(op,field,val)					 \
> >>	do {								\
> >>		typedef typeof(_proxy_pda.field) T__;			\
> >>+		if (0) { T__ tmp__; tmp__ = (val); }			\
> >>    
> >
> >Merged into original patch
> >  
> BTW, do you mean you already had this in i386, or that you folded it 
> into the existing patch?  I don't think I had sent out my version of 
> this before.

I folded it into the existing patch.

-Andi

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

end of thread, other threads:[~2006-09-10  6:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-09  8:15 [PATCH] i386-pda updates Jeremy Fitzhardinge
2006-09-09 15:52 ` Andi Kleen
2006-09-09 23:07   ` Jeremy Fitzhardinge
2006-09-09 23:30   ` Jeremy Fitzhardinge
2006-09-10  6:18     ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox