All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Andi Kleen <ak@suse.de>
Cc: linux-kernel@vger.kernel.org,
	Chuck Ebbert <76306.1226@compuserve.com>,
	Zachary Amsden <zach@vmware.com>,
	Jan Beulich <jbeulich@novell.com>, Andrew Morton <akpm@osdl.org>
Subject: Re: [PATCH RFC 3/6] Use %gs as the PDA base-segment in the kernel.
Date: Sun, 27 Aug 2006 09:36:46 -0700	[thread overview]
Message-ID: <44F1CA1E.5010008@goop.org> (raw)
In-Reply-To: <200608271757.18621.ak@suse.de>

Andi Kleen wrote:
>>  
>> -	/* Clear %fs and %gs. */
>> -	asm volatile ("movl %0, %%fs; movl %0, %%gs" : : "r" (0));
>> +	/* Clear %fs. */
>> +	asm volatile ("mov %0, %%fs" : : "r" (0));
>> +
>> +	/* Set %gs for this CPU's PDA */
>> +	asm volatile ("mov %0, %%gs" : : "r" (__KERNEL_PDA));
>>     
>
> I would add memory clobbers here to make sure the dependency on read/write pda
> is right.
>   

Yep.  And the "m" args in the pda asm isn't quite right for rmw PDA ops 
(not that there are any at the moment).

>> +1:	movw GS(%esp), %gs
>>     
>
> movl is recommended in 32bit mode
>   

OK.  I thought the assembler objected to me about it.

>> --- a/arch/i386/kernel/signal.c
>> +++ b/arch/i386/kernel/signal.c
>> @@ -128,7 +128,7 @@ restore_sigcontext(struct pt_regs *regs,
>>  			 X86_EFLAGS_TF | X86_EFLAGS_SF | X86_EFLAGS_ZF | \
>>  			 X86_EFLAGS_AF | X86_EFLAGS_PF | X86_EFLAGS_CF)
>>  
>> -	GET_SEG(gs);
>> +	COPY_SEG(gs);
>>  	GET_SEG(fs);
>>  	COPY_SEG(es);
>>  	COPY_SEG(ds);
>> @@ -244,9 +244,7 @@ setup_sigcontext(struct sigcontext __use
>>  {
>>  	int tmp, err = 0;
>>  
>> -	tmp = 0;
>> -	savesegment(gs, tmp);
>> -	err |= __put_user(tmp, (unsigned int __user *)&sc->gs);
>> +	err |= __put_user(regs->xgs, (unsigned int __user *)&sc->gs);
>>  	savesegment(fs, tmp);
>>  	err |= __put_user(tmp, (unsigned int __user *)&sc->fs);
>>     
>
> Hmm, changing it for the sc looks a bit bogus. If everything 
> is right nothing should change for user space, but this changes something.
>   

The sigcontext contains the userspace register state at the time of the 
signal.  Since userspace %gs is stored in the on-stack pt_regs, that 
should be where it fetches it from to fill out the sigcontext, rather 
than the kernel's internal value of %gs - in other words, it should be 
the same as ds and es.  Or am I missing something?

>> @@ -306,7 +306,7 @@ static void do_sys_vm86(struct kernel_vm
>>  	tsk->thread.screen_bitmap = info->screen_bitmap;
>>  	if (info->flags & VM86_SCREEN_BITMAP)
>>  		mark_screen_rdonly(tsk->mm);
>> -	__asm__ __volatile__("xorl %eax,%eax; movl %eax,%fs; movl %eax,%gs\n\t");
>> +	__asm__ __volatile__("movl %0,%%fs\n\t" : : "r" (0));
>>     
>
> This is actually a useful bug fix on its own.
>   

Yep.  But there seems to be some other very dubious code in there as 
well (the asm("mov %%eax,%0" : "=r" (eax)) sequence).  I was wondering 
about what it all does...

    J

  reply	other threads:[~2006-08-27 16:36 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-27  8:44 [PATCH RFC 0/6] Implement per-processor data areas for i386 Jeremy Fitzhardinge
2006-08-27  8:44 ` [PATCH RFC 1/6] Basic definitions for i386-pda Jeremy Fitzhardinge
2006-08-27  8:44 ` [PATCH RFC 2/6] Initialize the per-CPU data area Jeremy Fitzhardinge
2006-08-27  8:44 ` [PATCH RFC 3/6] Use %gs as the PDA base-segment in the kernel Jeremy Fitzhardinge
2006-08-27  9:49   ` Keith Owens
2006-08-27 10:01     ` Jeremy Fitzhardinge
2006-08-27 15:57   ` Andi Kleen
2006-08-27 16:36     ` Jeremy Fitzhardinge [this message]
2006-08-27 17:20     ` Jeremy Fitzhardinge
2006-08-27 18:19       ` Andi Kleen
2006-08-27 20:03         ` Jan Engelhardt
2006-08-27 23:38         ` Jeremy Fitzhardinge
2006-08-28  9:51         ` Jan Beulich
2006-08-28 14:54           ` H. J. Lu
2006-08-28 17:24         ` H. Peter Anvin
2006-08-27  8:44 ` [PATCH RFC 4/6] Fix places where using %gs changes the usermode ABI Jeremy Fitzhardinge
2006-08-27 15:59   ` Andi Kleen
2006-08-27 16:37     ` Jeremy Fitzhardinge
2006-08-27  8:44 ` [PATCH RFC 5/6] Implement smp_processor_id() with the PDA Jeremy Fitzhardinge
2006-08-27  8:44 ` [PATCH RFC 6/6] Implement "current" " Jeremy Fitzhardinge
2006-08-27 16:01   ` Andi Kleen
2006-08-27 16:38     ` Jeremy Fitzhardinge
2006-08-27  9:47 ` [PATCH RFC 0/6] Implement per-processor data areas for i386 Arjan van de Ven
2006-08-27 16:46   ` Jeremy Fitzhardinge
2006-08-27 17:44     ` Arjan van de Ven
2006-08-27 18:07       ` Andi Kleen
2006-08-27 18:27         ` Jeremy Fitzhardinge
2006-08-27 16:01 ` Andi Kleen
2006-08-27 16:41   ` Jeremy Fitzhardinge
2006-08-27 17:21 ` Andreas Mohr
2006-08-27 17:34   ` Jeremy Fitzhardinge
2006-08-27 18:23     ` Andreas Mohr
2006-08-27 18:04   ` Andi Kleen
2006-08-27 18:27     ` Andreas Mohr
2006-08-27 18:35       ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44F1CA1E.5010008@goop.org \
    --to=jeremy@goop.org \
    --cc=76306.1226@compuserve.com \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=jbeulich@novell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zach@vmware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.