[<prev] [next>] [day] [month] [year] [list]
Message-Id: <200811181835.11365.goretux@gmail.com>
Date: Tue, 18 Nov 2008 18:35:10 +0100
From: Eric Lacombe <goretux@...il.com>
To: Arjan van de Ven <arjan@...radead.org>
Cc: Ingo Molnar <mingo@...e.hu>, linux-kernel@...r.kernel.org
Subject: Re: [x86] do_arch_prctl - bug?
In fact, if what I thought from that function was ok, we will have in fact the
order of the two following lines inversed :
...
load_gs_index(0);
ret = checking_wrmsrl(MSR_KERNEL_GS_BASE, addr);
...
So that we would have :
...
ret = checking_wrmsrl(MSR_KERNEL_GS_BASE, addr);
load_gs_index(0);
...
Regards,
Eric
Le mardi 18 novembre 2008 18:20:03 Eric Lacombe, vous avez écrit :
> Le mardi 18 novembre 2008 15:45:56, vous avez écrit :
> > On Tue, 18 Nov 2008 15:33:32 +0100
> >
> > Eric Lacombe <goretux@...il.com> wrote:
> > > Hello,
> > >
> > > I would like to know why the ARCH_SET_GS action of sys_arch_prctl,
> > > write the MSR MSR_KERNEL_GS_BASE and not the MSR MSR_GS_BASE when the
> > > variable "doit" equals 1? Is that a bug?
> >
> > I don't think it is.
> > The trick is that we use "swapgs" on entering/leaving the kernel, and
> > that will "swap" gs with the MSR, so when we return to userspace, GS
> > gets loaded from the MSR_KERNEL_GS_BASE ...
>
> Yeah when we enter the kernel swapgs is used, so the MSR_GS_BASE is
> switched with the MSR_KERNEL_GS_BASE.
>
> In fact, what I certainly misunderstand is why load_gs_index use swapgs
> inside.
> From that function, I trust that only when gs is loaded, its hidden part is
> loaded with the MSR_GS_BASE.
>
> ENTRY(native_load_gs_index)
> CFI_STARTPROC
> pushf
> CFI_ADJUST_CFA_OFFSET 8
> DISABLE_INTERRUPTS(CLBR_ANY | ~(CLBR_RDI))
> SWAPGS
> gs_change:
> movl %edi,%gs
> 2: mfence /* workaround */
> SWAPGS
> popf
> CFI_ADJUST_CFA_OFFSET -8
> ret
> CFI_ENDPROC
> ENDPROC(native_load_gs_index)
>
> Regards,
>
> Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists