Re: [x86] do_arch_prctl - bug?

From: Jeremy Fitzhardinge
Date: Tue Nov 18 2008 - 20:07:40 EST


Eric Lacombe wrote:
I look at the Intel docs (vol. 3A) again, and see that in 64 bits mode the hidden field gs.base are physically mapped to the MSR, so it seems that in order to load gs.base we don't need to load gs (like in 32 bits mode), but rather we only need to load the MSR.

So I don't understand the purpose of load_gs_index in that context :

if (doit) {
load_gs_index(0);
ret = checking_wrmsrl(MSR_KERNEL_GS_BASE, addr);
}

Why don't we only load the MSR ?
What is the purpose of calling load_gs_index with 0 as parameter ?

Because %gs of 0 means "base too large, go to MSR". If you have a 32-bit base, then loading it into the gdt and loading %gs with the right selector is faster. wrmsr/rdmsr are slow instructions.

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