Skip to contentSkip to conversation

Grub for ia64

DISCUSSION [email protected] 6 participants 22 messages Sep 28, 2006 – Oct 11, 2006

lore
Share & tools
lore
#0 lore raw

Hi

this is a port of grub2 to ia64. ia64 systems (itanium) are EFI based so this port reuse existing EFI infrastructure.

I have made 4 patches:

efi64.diffs: fix a 64 bits issue of efi/api.h
fat.diffs: fix 64bits issues and make filename match case insensitive.

[I think most 64 bits issues have already been reported recently and independently by the mail grub2 64bit system compatible]

ia64.diffs: ia64 specific files

modules.diffs:
currently the ia64 port cannot load modules. This patch makes slight changes so that grub can be completly prelinked without removing the dynamic loading feature.
I think it is worth for three reasons:
* it makes initial port easier.
* the current common code can't work on ia64 (on ia64 a function pointer is a descriptor and not the address of the first function instruction).
* grub-emu doesn't have dynamic modules and could reuse this work to remove most of #ifdef/#endif GRUB_UTIL

I have also written a few additionnal EFI specific commands I will post later.

Tristan.

#1 lore raw

It is great!!!, I will test on my IA64 box tommorrow. And I have few minor comments like this.
whether kern/ia64/efi/init.c can be common for all architectures of efi
platform, only grub_arch_sync_caches is different, this function can be placed on arch specific place. Function find_mmap_size can fit for all architectures.

why write different grub_efi_allocate_pages/grub_efi_free_boot_pages, we can
modify these two functions to fit for all architecture EFI platform.

thanks
bibo,mao

Quoted 37 lines · [email protected] wrote:

Hi

this is a port of grub2 to ia64. ia64 systems (itanium) are EFI based so this port reuse existing EFI infrastructure.

I have made 4 patches:

efi64.diffs: fix a 64 bits issue of efi/api.h
fat.diffs: fix 64bits issues and make filename match case insensitive.

[I think most 64 bits issues have already been reported recently and independently by the mail grub2 64bit system compatible]

ia64.diffs: ia64 specific files

modules.diffs:
currently the ia64 port cannot load modules. This patch makes slight changes so that grub can be completly prelinked without removing the dynamic loading feature.
I think it is worth for three reasons:
* it makes initial port easier.
* the current common code can't work on ia64 (on ia64 a function pointer is a descriptor and not the address of the first function instruction).
* grub-emu doesn't have dynamic modules and could reuse this work to remove most of #ifdef/#endif GRUB_UTIL

I have also written a few additionnal EFI specific commands I will post later.

Tristan.

------------------------------------------------------------------------

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

#2 lore raw

Quoting "bibo,mao" <[email protected]>:

Quoted 7 lines

It is great!!!, I will test on my IA64 box tommorrow. And I have few minor comments like this.
whether kern/ia64/efi/init.c can be common for all architectures of efi
platform, only grub_arch_sync_caches is different, this function can be placed
on arch specific place. Function find_mmap_size can fit for all architectures.

Correct.

Quoted 3 lines

why write different grub_efi_allocate_pages/grub_efi_free_boot_pages, we
can
modify these two functions to fit for all architecture EFI platform.

They are slightly different.
Pages allocated by grub_efi_allocate_boot_pages won't be freed at grub exit. This is very important to load linux/initrd/modules on pages which won't be touched!
These functions could be moved to kern/efi/mm.c.

Tristan.

#3 lore raw
In reply to [email protected]
Quoted 2 lines · [email protected] writes:

this is a port of grub2 to ia64. ia64 systems (itanium) are EFI based so this port reuse existing EFI infrastructure.

Thank you for offering this contribution.

First a few legal comments. I poked through the patches, and it seems that there are a few files that are copyrighted by Hewlett-Packard and David Mosberger-Tang. All developers of GNU GRUB has agreed to sign over their copyright to FSF, so brining non-FSF copyrighted code into the project is a problem (and likely a show-stopper).

There are also a few files that are released under LGPL. Maintainers, are there any problems with bringing such files into GNU GRUB?

It is not possible to find similar integer division code in glibc for example? And why is this code needed at all, doesn't IA64 have division? If it doesn't, my gut feeling tells me that this should be in libgcc.

There were also a few files without any copyright notice what so ever (trampoline.S being one). Please add a boilerplate.

I noticed that there were a generic fix for grub_strtoull in the fat patch; maybe you could send that, and other generic fixes as separate patches? Also, do not forget ChangeLog [1] entries for all your changes. If you are not familiar with writing ChangeLogs, we'll of course help you with that.

Have you signed over copyright to FSF for your work on GNU GRUB? In other words, have you sent in an assignment record to FSF? If not, let us know and we'll send you a request record.

Anyhow, when I get a few more minutes over I'll try to review your patches more in depth.

I do not know if there is a policy for how to contribute code to GRUB, but please send unified diffs (-u) instead of context diffs (-c). I at least find them easier to read.

~j

[1] http://www.gnu.org/prep/standards/html_node/Change-Logs.html

#4 lore raw
Quoted 5 lines · Johan Rydberg

First a few legal comments. I poked through the patches, and it seems that there are a few files that are copyrighted by Hewlett-Packard and David Mosberger-Tang. All developers of GNU GRUB has agreed to sign over their copyright to FSF, so brining non-FSF copyrighted code into the project is a problem (and likely a show-stopper).

If code from third parties is used it will be a show stopper, especially in such cases.

Quoted 2 lines

There are also a few files that are released under LGPL. Maintainers, are there any problems with bringing such files into GNU GRUB?

What do you mean by that? Code written for the IA64 port or brought in from elsewhere?

Quoted 3 lines

Have you signed over copyright to FSF for your work on GNU GRUB? In other words, have you sent in an assignment record to FSF? If not, let us know and we'll send you a request record.

Okuji or me will talk to contributors off-list usually about such issues, so that won't be a problem.

Quoted 2 lines

Anyhow, when I get a few more minutes over I'll try to review your patches more in depth.

Thanks a lot for doing this!

Quoted 3 lines

I do not know if there is a policy for how to contribute code to GRUB, but please send unified diffs (-u) instead of context diffs (-c). I at least find them easier to read.

Like mentioned in the other emails, I want unified diffs (diff -up) inlined in the email with a Changelog entry. This is correctly picked up in the patch in the other thread so I am confident it will work out fine for the port as well. :-)

--
Marco

#5 lore raw
In reply to Johan Rydberg

Quoting Johan Rydberg <[email protected]>:

Quoted 6 lines
Quoted 2 lines · [email protected] writes:

this is a port of grub2 to ia64. ia64 systems (itanium) are EFI based so this port reuse existing EFI infrastructure.

Thank you for offering this contribution.

You're welcome!

Quoted 5 lines

First a few legal comments. I poked through the patches, and it seems that there are a few files that are copyrighted by Hewlett-Packard and David Mosberger-Tang. All developers of GNU GRUB has agreed to sign over their copyright to FSF, so brining non-FSF copyrighted code into the project is a problem (and likely a show-stopper).

I was not aware of this policy.

Quoted 6 lines

There are also a few files that are released under LGPL. Maintainers, are there any problems with bringing such files into GNU GRUB?

It is not possible to find similar integer division code in glibc for example? And why is this code needed at all, doesn't IA64 have division?

No, it doesn't have integer division.

Quoted 2 lines

If it doesn't, my gut feeling tells me that this should be
in libgcc.

Yes, most should be either in glibc or libgcc.

Quoted 2 lines

There were also a few files without any copyright notice what so ever (trampoline.S being one). Please add a boilerplate.

Ok.

Quoted 5 lines

I noticed that there were a generic fix for grub_strtoull in the fat patch; maybe you could send that, and other generic fixes as separate patches? Also, do not forget ChangeLog [1] entries for all your changes. If you are not familiar with writing ChangeLogs, we'll of course help you with that.

Ok.

Quoted 3 lines

Have you signed over copyright to FSF for your work on GNU GRUB? In other words, have you sent in an assignment record to FSF? If not, let us know and we'll send you a request record.

NO. Please send me the request record. Note: this work currently belongs to my employer (Bull SAS).

Quoted 6 lines

Anyhow, when I get a few more minutes over I'll try to review your patches more in depth.

I do not know if there is a policy for how to contribute code to GRUB, but please send unified diffs (-u) instead of context diffs (-c). I at least find them easier to read.

Oops, sorry.

Tristan.

#6 lore raw
Quoted 8 lines · [email protected] writes:
Quoted 3 lines

It is not possible to find similar integer division code in glibc for example? And why is this code needed at all, doesn't IA64 have division?

No, it doesn't have integer division.

Quoted 2 lines

If it doesn't, my gut feeling tells me that this should be
in libgcc.

Yes, most should be either in glibc or libgcc.

I have not verified this completely, but it seems as libgcc has all these routines at hand. GCC also has the following IA-64 options that might be usefull;

`-minline-int-divide-min-latency'
Generate code for inline divides of integer values using the minimum latency algorithm.

`-minline-int-divide-max-throughput'
Generate code for inline divides of integer values using the maximum throughput algorithm.

~j

#7 lore raw
In reply to Johan Rydberg
Quoted 2 lines · Johan Rydberg

Anyhow, when I get a few more minutes over I'll try to review your patches more in depth.

A few comments;

* Would it be possible for you to rewrite kern/ia64/efi/startup.S, so that you hold the copyright for it?

* Same goes for kern/ia64/efi/reloc_ia64.S.

(Or maybe it is possible to find similar code in for example GNU libc,
that is already copyrighted to FSF.)

* Most of the math functions in kern/ia64 should be available in libgcc. Could you try to link it against "gcc -print-libgcc-file-name"?

~j

#8 lore raw
Quoted 11 lines · Johan Rydberg
Quoted 2 lines · Johan Rydberg

Anyhow, when I get a few more minutes over I'll try to review your patches more in depth.

A few comments;

* Would it be possible for you to rewrite kern/ia64/efi/startup.S, so that you hold the copyright for it?

* Same goes for kern/ia64/efi/reloc_ia64.S.

Who holds the copyright now? If it's folks at HP, we can probably get a disclaimer for it.

Tks,
Jeff Bailey

Signature · 3 lines
I do not agree with a word you say, but I will defend to the death your
right to say it. 
 - Voltaire
#9 lore raw
Quoted 5 lines · Jeff Bailey
Quoted 5 lines
Quoted 2 lines

Anyhow, when I get a few more minutes over I'll try to review your patches more in depth.

A few comments;

Quoted 7 lines
Quoted 4 lines

* Would it be possible for you to rewrite kern/ia64/efi/startup.S, so that you hold the copyright for it?

* Same goes for kern/ia64/efi/reloc_ia64.S.

Who holds the copyright now? If it's folks at HP, we can probably get a disclaimer for it.

Some files are both copyrighted by both HP and Mosberger-Tang:

+ * Copyright (C) 2000 Hewlett-Packard Co
+ * Copyright (C) 2000 David Mosberger-Tang <[email protected]>

Files that are from the GNU EFI package seem to be just copyrighted by HP:

+ Copyright (C) 1999 Hewlett-Packard Co.
+ Contributed by David Mosberger <[email protected]>.

How would one go about to get a disclaimer for them?

~j

#10 lore raw
In reply to Johan Rydberg
Quoted 7 lines · Johan Rydberg
Quoted 2 lines · Johan Rydberg

Anyhow, when I get a few more minutes over I'll try to review your patches more in depth.

A few comments;

Quoted 7 lines

* Would it be possible for you to rewrite kern/ia64/efi/startup.S, so that you hold the copyright for it?

* Same goes for kern/ia64/efi/reloc_ia64.S.

(Or maybe it is possible to find similar code in for example GNU libc,
that is already copyrighted to FSF.)

Unfortunatly there is no similar code.
Rewritting startup.S should be rather quick. reloc_ia64.S may be rewritten in C.

Quoted 3 lines

* Most of the math functions in kern/ia64 should be available in libgcc. Could you try to link it against "gcc -print-libgcc-file-name"?

Yes, it should work.

Tristan.

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

#11 lore raw
In reply to [email protected]

[email protected] writes:

Hi,

Quoted 2 lines

this is a port of grub2 to ia64. ia64 systems (itanium) are EFI based so this port reuse existing EFI infrastructure.

This is truly great, thanks a lot for doing this! :-)

First of all, the same comment as for your other emails. Please use diff -up and inline the patches and write changelog entries. I like that you split up the patches so they can be reviewed and separately.

Next week or weeks I will be quite busy and won't have time for GRUB hacking or to review patches. But I will try to do so ASAP, or hopefully Okuji will have the time to do so. I hope you will be patient, I want this in ASAP. :)

Quoted 1 line

fat.diffs: fix 64bits issues and make filename match case insensitive.

Can you please explain why you want this in detail? I know there are issues with EFI to determine the prefix. My guess is that is why you want to change this. But I am afraid this might not be a generic solution so I hope we can discuss the problem first.

Quoted 3 lines

[I think most 64 bits issues have already been reported recently and independently by the mail grub2 64bit system compatible]

Cool. I assume these patches are in CVS now?

Quoted 6 lines

modules.diffs:
currently the ia64 port cannot load modules. This patch makes slight changes so that grub can be completly prelinked without removing the dynamic loading feature.
I think it is worth for three reasons:
* it makes initial port easier.

Right, we had that with the PPC port too. I will have a look if it doesn't break anything for other archs.

I hope you are willing to implement whatever is required for module loading for IA64. Module loading is an essential part of the GRUB 2 design and I prefer having the same behavior for every port.

Quoted 2 lines

* the current common code can't work on ia64 (on ia64 a function pointer is a descriptor and not the address of the first function instruction).

Can you give some examples by using code? Certainly we would have to aim for module loading at some point in time. :)

Quoted 2 lines

* grub-emu doesn't have dynamic modules and could reuse this work to remove most of #ifdef/#endif GRUB_UTIL

*Please* do not mess around too much with grub-emu. I can perfectly understand why people want all kind of things changed in grub-emu and I would certainly like to have module support there (IIRC there were patches sent in, some of which I still have to review, etc :-/).

It's important to know why I wrote grub-emu. It is mainly a debugging tool. For example you don't want to implement a filesystem or work on the commandline interface without such tool. Having module loading only is just annoying so GRUB_UTIL can't and won't be removed.

Actually, it is technically almost impossible to do modules loading in every case on every processor. For example take the PPC, some relocations are almost impossible or very hard to implement in userspace.

Quoted 1 line

I have also written a few additionnal EFI specific commands I will post later.

I am looking forwards to your patches.

Thanks,
Marco

#12 lore raw

Quoting Marco Gerards <[email protected]>:

Quoted 19 lines

[email protected] writes:

Hi,

Quoted 1 line

this is a port of grub2 to ia64. ia64 systems (itanium) are EFI based so

this

Quoted 1 line

port reuse existing EFI infrastructure.

This is truly great, thanks a lot for doing this! :-)

First of all, the same comment as for your other emails. Please use diff -up and inline the patches and write changelog entries. I like that you split up the patches so they can be reviewed and separately.

Next week or weeks I will be quite busy and won't have time for GRUB hacking or to review patches. But I will try to do so ASAP, or hopefully Okuji will have the time to do so. I hope you will be patient, I want this in ASAP. :)

Quoted 5 lines
Quoted 1 line

fat.diffs: fix 64bits issues and make filename match case insensitive.

Can you please explain why you want this in detail? I know there are issues with EFI to determine the prefix. My guess is that is why you want to change this.

Yes.

Quoted 2 lines

But I am afraid this might not be a generic
solution so I hope we can discuss the problem first.

I suppose you can't use mixed case filename currently for FAT fs. This patch fixes that.

Quoted 4 lines
Quoted 2 lines

[I think most 64 bits issues have already been reported recently and independently by the mail grub2 64bit system compatible]

Cool. I assume these patches are in CVS now?

AFAIK not yet integrated.

Quoted 9 lines
Quoted 2 lines

modules.diffs:
currently the ia64 port cannot load modules. This patch makes slight

changes

Quoted 1 line

so that grub can be completly prelinked without removing the dynamic

loading

Quoted 3 lines

feature.
I think it is worth for three reasons:
* it makes initial port easier.

Quoted 6 lines

Right, we had that with the PPC port too. I will have a look if it doesn't break anything for other archs.

I hope you are willing to implement whatever is required for module loading for IA64. Module loading is an essential part of the GRUB 2 design and I prefer having the same behavior for every port.

Sure.

Quoted 6 lines
Quoted 1 line

* the current common code can't work on ia64 (on ia64 a function pointer is

a

Quoted 1 line

descriptor and not the address of the first function instruction).

Can you give some examples by using code? Certainly we would have to aim for module loading at some point in time. :)

Yes, cf kern/dl.c:

	  if (grub_strcmp (name, "grub_mod_init") == 0)
	    mod->init = (void (*) (grub_dl_t)) sym->st_value;

This won't work on ia64 AFAIK.

Quoted 8 lines
Quoted 2 lines

* grub-emu doesn't have dynamic modules and could reuse this work to remove most of #ifdef/#endif GRUB_UTIL

*Please* do not mess around too much with grub-emu. I can perfectly understand why people want all kind of things changed in grub-emu and I would certainly like to have module support there (IIRC there were patches sent in, some of which I still have to review, etc :-/).

Quoted 4 lines

It's important to know why I wrote grub-emu. It is mainly a debugging tool. For example you don't want to implement a filesystem or work on the commandline interface without such tool. Having module loading only is just annoying so GRUB_UTIL can't and won't be removed.

From my point of view, GRUB_UTIL could be removed without adding modules to grub-emu. This would be slightly cleaner.

Quoted 4 lines

Actually, it is technically almost impossible to do modules loading in every case on every processor. For example take the PPC, some relocations are almost impossible or very hard to implement in userspace.

Looks strange. How does ld.so works on these systems ?

Quoted 4 lines
Quoted 1 line

I have also written a few additionnal EFI specific commands I will post

later.

I am looking forwards to your patches.

Ok.

Thanks,
Tristan.

#13 lore raw
Quoted 4 lines · [email protected] writes:
Quoted 3 lines

Can you please explain why you want this in detail? I know there are issues with EFI to determine the prefix. My guess is that is why you want to change this.

Yes.

Please elaborate.

Quoted 4 lines
Quoted 2 lines

But I am afraid this might not be a generic
solution so I hope we can discuss the problem first.

I suppose you can't use mixed case filename currently for FAT fs. This patch fixes that.

Well, I am afraid the same problem will show up when using HFS+, ext2 or whatever. So that is why I would like a detailed description of this problem (I just know there is a problem, but never received a detailed report).

Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

[I think most 64 bits issues have already been reported recently and independently by the mail grub2 64bit system compatible]

Cool. I assume these patches are in CVS now?

AFAIK not yet integrated.

Ok. Your patch relies on that? so would those have to go in first?

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

* the current common code can't work on ia64 (on ia64 a function pointer is a descriptor and not the address of the first function instruction).

Quoted 8 lines
Quoted 2 lines

Can you give some examples by using code? Certainly we would have to aim for module loading at some point in time. :)

Yes, cf kern/dl.c:

	  if (grub_strcmp (name, "grub_mod_init") == 0)
	    mod->init = (void (*) (grub_dl_t)) sym->st_value;

This won't work on ia64 AFAIK.

Why not? In the internal working of filesystems there are also function pointer being used. Same for almost every other part of GRUB 2. So I am wondering what makes this different.

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

* grub-emu doesn't have dynamic modules and could reuse this work to remove most of #ifdef/#endif GRUB_UTIL

*Please* do not mess around too much with grub-emu. I can perfectly understand why people want all kind of things changed in grub-emu and I would certainly like to have module support there (IIRC there were patches sent in, some of which I still have to review, etc :-/).

Quoted 4 lines
Quoted 4 lines

It's important to know why I wrote grub-emu. It is mainly a debugging tool. For example you don't want to implement a filesystem or work on the commandline interface without such tool. Having module loading only is just annoying so GRUB_UTIL can't and won't be removed.

From my point of view, GRUB_UTIL could be removed without adding

Quoted 1 line

modules to grub-emu. This would be slightly cleaner.

Well, it's use can certainly be brought back or changed. But adding a module loader is not the way to go. If it bothers a lot of people I could change functions like grub_dl_ref into a macro which does the #ifdef.

Quoted 5 lines
Quoted 4 lines

Actually, it is technically almost impossible to do modules loading in every case on every processor. For example take the PPC, some relocations are almost impossible or very hard to implement in userspace.

Looks strange. How does ld.so works on these systems ?

For the PPC I once wrote a module loader (userspace). Some relocations expect the symbols you point to from the relocated code, to be within 4MB. The dynamic loader on the PPC perhaps has no problems with that because it can load code about everywhere and perhaps those relocations are normally not used, but I can be wrong.

--
Marco

#14 lore raw

Quoting Marco Gerards <[email protected]>:

Quoted 8 lines
Quoted 4 lines · [email protected] writes:
Quoted 3 lines

Can you please explain why you want this in detail? I know there are issues with EFI to determine the prefix. My guess is that is why you want to change this.

Yes.

Please elaborate.

The prefix is determined from an EFI file path. This file path may have some components in upper case. However grub can't match a mixed file name with a FAT directory entry.
We could either fix this by lowering the EFI file path or fixing the fat fs.

Quoted 10 lines
Quoted 4 lines
Quoted 2 lines

But I am afraid this might not be a generic
solution so I hope we can discuss the problem first.

I suppose you can't use mixed case filename currently for FAT fs. This patch fixes that.

Well, I am afraid the same problem will show up when using HFS+, ext2 or whatever. So that is why I would like a detailed description of this problem (I just know there is a problem, but never received a detailed report).

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

[I think most 64 bits issues have already been reported recently and independently by the mail grub2 64bit system compatible]

Cool. I assume these patches are in CVS now?

AFAIK not yet integrated.

Ok. Your patch relies on that? so would those have to go in first?

No, No. Completly independant.

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

* the current common code can't work on ia64 (on ia64 a function pointer is a descriptor and not the address of the first function instruction).

Can you give some examples by using code? Certainly we would have to aim for module loading at some point in time. :)

Yes, cf kern/dl.c:

Quoted 8 lines
Quoted 4 lines
	  if (grub_strcmp (name, "grub_mod_init") == 0)
	    mod->init = (void (*) (grub_dl_t)) sym->st_value;

This won't work on ia64 AFAIK.

Why not? In the internal working of filesystems there are also function pointer being used. Same for almost every other part of GRUB 2. So I am wondering what makes this different.

Function pointers works on ia64 (of course!) But you can't convert an address to a function pointer. This cast is not valid on ia64 (and violates the C standard).

Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

* grub-emu doesn't have dynamic modules and could reuse this work to

remove

Quoted 11 lines
Quoted 11 lines
Quoted 1 line

most of #ifdef/#endif GRUB_UTIL

*Please* do not mess around too much with grub-emu. I can perfectly understand why people want all kind of things changed in grub-emu and I would certainly like to have module support there (IIRC there were patches sent in, some of which I still have to review, etc :-/).

It's important to know why I wrote grub-emu. It is mainly a debugging tool. For example you don't want to implement a filesystem or work on the commandline interface without such tool. Having module loading only is just annoying so GRUB_UTIL can't and won't be removed.

Quoted 7 lines
Quoted 2 lines

From my point of view, GRUB_UTIL could be removed without adding modules to grub-emu. This would be slightly cleaner.

Well, it's use can certainly be brought back or changed. But adding a module loader is not the way to go. If it bothers a lot of people I could change functions like grub_dl_ref into a macro which does the #ifdef.

I have never suggested to add module loader to grub-emu!

Quoted 11 lines
Quoted 5 lines
Quoted 4 lines

Actually, it is technically almost impossible to do modules loading in every case on every processor. For example take the PPC, some relocations are almost impossible or very hard to implement in userspace.

Looks strange. How does ld.so works on these systems ?

For the PPC I once wrote a module loader (userspace). Some relocations expect the symbols you point to from the relocated code, to be within 4MB. The dynamic loader on the PPC perhaps has no problems with that because it can load code about everywhere and perhaps those relocations are normally not used, but I can be wrong.

These problems are very common.
You should compile with -fpic!

Tristan.

#15 lore raw

Re: Grub for ia64 - function descriptors

In reply to [email protected]
Quoted 5 lines · On Thu, 2006-09-28 at 15:45 +0200, [email protected] wrote:
          if (grub_strcmp (name, "grub_mod_init") == 0)
            mod->init = (void (*) (grub_dl_t)) sym->st_value;

This won't work on ia64 AFAIK.

Can't this problem be solved with an architecture-specific macro?

FWIW, 64-bit PowerPC also uses function descriptors. They look something like:
long code_address
long table_of_contents
long unused

The table_of_contents (TOC) value needs to be placed into r2 when jumping at code_address (and of course the old one needs to be restored when returning). I assume IA64 is similar here, and given that, a module_jump function implemented in assembly by each architecture would solve this problem.

(Generally speaking, the TOC on ppc64 only varies across separately linked modules.)

(This issue does not apply to GRUB on ppc64 systems, since those systems still use 32-bit firmware and thus 32-bit GRUB.)

-Hollis

#16 lore raw

Re: Grub for ia64 - function descriptors

Quoting Hollis Blanchard <[email protected]>:

Quoted 15 lines · On Thu, 2006-09-28 at 15:45 +0200, [email protected] wrote:
Quoted 5 lines
          if (grub_strcmp (name, "grub_mod_init") == 0)
            mod->init = (void (*) (grub_dl_t)) sym->st_value;

This won't work on ia64 AFAIK.

Can't this problem be solved with an architecture-specific macro?

FWIW, 64-bit PowerPC also uses function descriptors. They look something like:
long code_address
long table_of_contents
long unused

Quoted 3 lines

The table_of_contents (TOC) value needs to be placed into r2 when jumping at code_address (and of course the old one needs to be restored when returning).

Indeed, same issue.

Quoted 3 lines

I assume IA64 is similar here, and given that, a
module_jump function implemented in assembly by each architecture would solve this problem.

I'd prefer modules to export pointers. Seems to be easier to deal.

Tristan.

#17 lore raw

Re: Grub for ia64 - function descriptors

Quoted 20 lines · On Fri, 2006-09-29 at 08:59 +0200, [email protected] wrote:

Quoting Hollis Blanchard <[email protected]>:

Quoted 15 lines · On Thu, 2006-09-28 at 15:45 +0200, [email protected] wrote:
Quoted 5 lines
          if (grub_strcmp (name, "grub_mod_init") == 0)
            mod->init = (void (*) (grub_dl_t)) sym->st_value;

This won't work on ia64 AFAIK.

Can't this problem be solved with an architecture-specific macro?

FWIW, 64-bit PowerPC also uses function descriptors. They look something like:
long code_address
long table_of_contents
long unused

Quoted 3 lines

The table_of_contents (TOC) value needs to be placed into r2 when jumping at code_address (and of course the old one needs to be restored when returning).

Quoted 6 lines

Indeed, same issue.

Quoted 3 lines

I assume IA64 is similar here, and given that, a
module_jump function implemented in assembly by each architecture would solve this problem.

I'd prefer modules to export pointers. Seems to be easier to deal.

I don't know what you mean; please elaborate (with pseudo-code if possible).

-Hollis

#18 lore raw

Re: Grub for ia64 - function descriptors

Quoting Hollis Blanchard <[email protected]>:

Quoted 23 lines · On Fri, 2006-09-29 at 08:59 +0200, [email protected] wrote:
Quoted 22 lines

Quoting Hollis Blanchard <[email protected]>:

Quoted 15 lines · On Thu, 2006-09-28 at 15:45 +0200, [email protected] wrote:
Quoted 5 lines
          if (grub_strcmp (name, "grub_mod_init") == 0)
            mod->init = (void (*) (grub_dl_t)) sym->st_value;

This won't work on ia64 AFAIK.

Can't this problem be solved with an architecture-specific macro?

FWIW, 64-bit PowerPC also uses function descriptors. They look something like:
long code_address
long table_of_contents
long unused

Quoted 3 lines

The table_of_contents (TOC) value needs to be placed into r2 when jumping at code_address (and of course the old one needs to be restored when returning).

Indeed, same issue.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

I assume IA64 is similar here, and given that, a
module_jump function implemented in assembly by each architecture would solve this problem.

I'd prefer modules to export pointers. Seems to be easier to deal.

I don't know what you mean; please elaborate (with pseudo-code if possible).

I'd propose modules export struct grub_dl. This struct contains init and fini functions pointers.
Getting the address of a data structure is much more portable. Dealing with function pointers would be a matter of the relocator.

Tristan.

#19 lore raw

Re: Grub for ia64 - function descriptors

Quoted 30 lines · On Mon, 02 Oct 2006 08:31:10 +0200, [email protected] said:

Quoting Hollis Blanchard <[email protected]>:

Quoted 28 lines · On Fri, 2006-09-29 at 08:59 +0200, [email protected] wrote:
Quoted 26 lines

Quoting Hollis Blanchard <[email protected]>:

Quoted 15 lines · On Thu, 2006-09-28 at 15:45 +0200, [email protected] wrote:
Quoted 5 lines
          if (grub_strcmp (name, "grub_mod_init") == 0)
            mod->init = (void (*) (grub_dl_t)) sym->st_value;

This won't work on ia64 AFAIK.

Can't this problem be solved with an architecture-specific macro?

FWIW, 64-bit PowerPC also uses function descriptors. They look something like:
long code_address
long table_of_contents
long unused

Quoted 3 lines

The table_of_contents (TOC) value needs to be placed into r2 when jumping at code_address (and of course the old one needs to be restored when returning).

Indeed, same issue.

Quoted 3 lines

I assume IA64 is similar here, and given that, a
module_jump function implemented in assembly by each architecture would solve this problem.

I'd prefer modules to export pointers. Seems to be easier to deal.

Quoted 8 lines
Quoted 2 lines

I don't know what you mean; please elaborate (with pseudo-code if possible).

I'd propose modules export struct grub_dl. This struct contains init and fini
functions pointers.
Getting the address of a data structure is much more portable. Dealing with function pointers would be a matter of the relocator.

It looks like this is only done twice in the current code: mod->init and mod->fini. Wouldn't it be easy to do this:

dl.c 3 Oct 2006 02:15:51 -0000 renamed from dl.c 28 May 2006 23:01:43 -0000 1.12 +2 -2
@@ -380,9 +380,9 @@ grub_dl_resolve_symbols (grub_dl_t mod,
              return grub_errno;
 
          if (grub_strcmp (name, "grub_mod_init") == 0)
-           mod->init = (void (*) (grub_dl_t)) sym->st_value;
+           mod->init = grub_dl_arch_func (sym->st_value);
          else if (grub_strcmp (name, "grub_mod_fini") == 0)
-           mod->fini = (void (*) (void)) sym->st_value;
+           mod->fini = grub_dl_arch_func (sym->st_value);
          break;
 
        case STT_SECTION:

-Hollis

#20 lore raw

Re: Grub for ia64 - function descriptors

Selon Hollis Blanchard <[email protected]>:

Quoted 3 lines · On Mon, 02 Oct 2006 08:31:10 +0200, [email protected] said:
Quoted 1 line

Quoting Hollis Blanchard <[email protected]>:

[...]

Quoted 21 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I assume IA64 is similar here, and given that, a module_jump function implemented in assembly by each architecture

would

Quoted 11 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line

solve this problem.

I'd prefer modules to export pointers. Seems to be easier to deal.

I don't know what you mean; please elaborate (with pseudo-code if possible).

I'd propose modules export struct grub_dl. This struct contains init and fini
functions pointers.
Getting the address of a data structure is much more portable. Dealing with function pointers would be a matter of the relocator.

It looks like this is only done twice in the current code: mod->init and mod->fini. Wouldn't it be easy to do this:

dl.c 3 Oct 2006 02:15:51 -0000 renamed from dl.c 28 May 2006 23:01:43 -0000 1.12 +0 -0
@@ -380,9 +380,9 @@ grub_dl_resolve_symbols (grub_dl_t mod,
              return grub_errno;

dl.c 3 Oct 2006 02:15:51 -0000 grub_dl_resolve_symbols (grub_dl_t mod, · line 388

Quoted 10 lines
dl.c 3 Oct 2006 02:15:51 -0000 renamed from dl.c 28 May 2006 23:01:43 -0000 1.12 +2 -2
 
          if (grub_strcmp (name, "grub_mod_init") == 0)
-           mod->init = (void (*) (grub_dl_t)) sym->st_value;
+           mod->init = grub_dl_arch_func (sym->st_value);
          else if (grub_strcmp (name, "grub_mod_fini") == 0)
-           mod->fini = (void (*) (void)) sym->st_value;
+           mod->fini = grub_dl_arch_func (sym->st_value);
          break;
 
        case STT_SECTION:

To create descriptor, grub_dl_arch_func have to grub_malloc memory. How to free it ?

I always prefer to use static memory when I can do that: code is smaller and safer. That's the reason why I'd prefer to have struct grub_dl declared static. Of course this is just my opinion.

Tristan.

#21 lore raw

Re: Grub for ia64 - function descriptors

Quoted 36 lines · On Tue, 2006-10-03 at 06:04 +0200, [email protected] wrote:

Selon Hollis Blanchard <[email protected]>:

Quoted 3 lines · On Mon, 02 Oct 2006 08:31:10 +0200, [email protected] said:
Quoted 1 line

Quoting Hollis Blanchard <[email protected]>:

[...]

Quoted 30 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I assume IA64 is similar here, and given that, a module_jump function implemented in assembly by each architecture

would

Quoted 11 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line

solve this problem.

I'd prefer modules to export pointers. Seems to be easier to deal.

I don't know what you mean; please elaborate (with pseudo-code if possible).

I'd propose modules export struct grub_dl. This struct contains init and fini
functions pointers.
Getting the address of a data structure is much more portable. Dealing with function pointers would be a matter of the relocator.

It looks like this is only done twice in the current code: mod->init and mod->fini. Wouldn't it be easy to do this:

dl.c 3 Oct 2006 02:15:51 -0000 renamed from dl.c 28 May 2006 23:01:43 -0000 1.12 +2 -2
@@ -380,9 +380,9 @@ grub_dl_resolve_symbols (grub_dl_t mod,
              return grub_errno;
 
          if (grub_strcmp (name, "grub_mod_init") == 0)
-           mod->init = (void (*) (grub_dl_t)) sym->st_value;
+           mod->init = grub_dl_arch_func (sym->st_value);
          else if (grub_strcmp (name, "grub_mod_fini") == 0)
-           mod->fini = (void (*) (void)) sym->st_value;
+           mod->fini = grub_dl_arch_func (sym->st_value);
          break;
 
Quoted 3 lines

dl.c 3 Oct 2006 02:15:51 -0000 grub_dl_resolve_symbols (grub_dl_t mod, · line 388

Quoted 1 line
dl.c 3 Oct 2006 02:15:51 -0000 renamed from dl.c 28 May 2006 23:01:43 -0000 1.12 +0 -0
        case STT_SECTION:

To create descriptor, grub_dl_arch_func have to grub_malloc memory. How to free it ?

What about this:

        grub_dl_arch_func(&mod->init, sym->st_value);
Quoted 3 lines

I always prefer to use static memory when I can do that: code is smaller and safer. That's the reason why I'd prefer to have struct grub_dl declared static. Of course this is just my opinion.

Sure, and I'm not really opposed to exporting a struct grub_dl from modules; I'm just trying to make sure we don't overcomplicate what could be a simple change. Do you have a patch illustrating your idea?

-Hollis