2006-02-12 23:26:27

by Marko Euth

[permalink] [raw]
Subject: How getting a pointer on the per-cpu struct tss_struct??


Hello,

may anyone tell me where I'm wrong???


What I thought to have found:

I want to access the per-cpu IO Permission Bitmap. Therefore, I try to
get a pointer on the per-cpu struct tss_struct. I found an array of typ
'struct tss_struct' named 'init_tss' (declared in asm/processor.h with
'DECLARE_PER_CPU(struct tss_struct, init_tss);').

So I should be able to get a pointer on the struct tss_struct of the
current cpu, by using the following code:

int cpu = get_cpu();
struct tss_struct * t = &per_cpu(init_tss, cpu);

But when I try to compile this, I get the warning:

*** Warning: "per_cpu__init_tss" [/home/..../module.ko]
undefined!

and according to this warning an error, when I try to load the module:

insmod: error inserting 'module.ko': -1 Unknown symbol in module


(I'm using gcc4.0.2 and kernel 2.6.14.2)


Where's my problem??

Thanks,



Marko Euth


2006-02-12 23:53:55

by Zwane Mwaikambo

[permalink] [raw]
Subject: Re: How getting a pointer on the per-cpu struct tss_struct??

On Mon, 13 Feb 2006, Marko wrote:

> But when I try to compile this, I get the warning:
>
> *** Warning: "per_cpu__init_tss" [/home/..../module.ko]
> undefined!
>
> and according to this warning an error, when I try to load the module:
>
> insmod: error inserting 'module.ko': -1 Unknown symbol in module

init_tss isn't exported, you would need to do
EXPORT_PER_CPU_SYMBOL(init_tss).

Also a suggestion, you should use __get_cpu_var instead of per_cpu e.g.

struct tss_struct *t;
/* if you don't need cpu variable just preempt_disable */
int cpu = get_cpu();
t = __get_cpu_var(init_tss);
...
put_cpu();

2006-02-13 00:13:34

by Marko Euth

[permalink] [raw]
Subject: Re: How getting a pointer on the per-cpu struct tss_struct??


Thanks for answering.

So when I don't want to change the kernel, the only way to get
a pointer on the IO Permission Bitmap is using the TSS entry in
the GDT??

Or is there another way to access the current structure tss_struct??


Marko Euth




On Sun, 12 Feb 2006 15:58:31 -0800 (PST)
Zwane Mwaikambo <[email protected]> wrote:

> On Mon, 13 Feb 2006, Marko wrote:
>
> > But when I try to compile this, I get the warning:
> >
> > *** Warning: "per_cpu__init_tss" [/home/..../module.ko]
> > undefined!
> >
> > and according to this warning an error, when I try to load the module:
> >
> > insmod: error inserting 'module.ko': -1 Unknown symbol in module
>
> init_tss isn't exported, you would need to do
> EXPORT_PER_CPU_SYMBOL(init_tss).
>
> Also a suggestion, you should use __get_cpu_var instead of per_cpu e.g.
>
> struct tss_struct *t;
> /* if you don't need cpu variable just preempt_disable */
> int cpu = get_cpu();
> t = __get_cpu_var(init_tss);
> ...
> put_cpu();
>

2006-02-13 06:08:55

by Zwane Mwaikambo

[permalink] [raw]
Subject: Re: How getting a pointer on the per-cpu struct tss_struct??

On Mon, 13 Feb 2006, Marko wrote:

> Thanks for answering.
>
> So when I don't want to change the kernel, the only way to get
> a pointer on the IO Permission Bitmap is using the TSS entry in
> the GDT??
>
> Or is there another way to access the current structure tss_struct??

How about saving the GDT and then fetching the TSS from there?

2006-02-13 07:29:45

by Arjan van de Ven

[permalink] [raw]
Subject: Re: How getting a pointer on the per-cpu struct tss_struct??

On Mon, 2006-02-13 at 01:14 +0100, Marko wrote:
> Thanks for answering.
>
> So when I don't want to change the kernel, the only way to get
> a pointer on the IO Permission Bitmap is using the TSS entry in
> the GDT??
>
> Or is there another way to access the current structure tss_struct??


what on earth are you trying to do????

(and why can't you change the kernel?)