WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

Re: [Xen-ia64-devel] Mini-OS registers and libgcc

Hello,

Dietmar Hahn, le Wed 13 Feb 2008 11:53:59 +0100, a écrit :
> Am Dienstag, 12. Februar 2008 schrieb Samuel Thibault:
> > Is there a reason for using -mfixed-range=f2-f5,f12-f15,f32-f127
> > when compiling Mini-OS?  Is it really needed since it doesn't
> > have a user-land? (though I guess some support would be needed in
> > switch_context for instance)
> 
> To handle this in a clean way the trap_frame has to be expanded and some fp 
> registers have to stored/restored in trap handling.

Ok. Would this be needed in order to be able to use libgcc.a?

> > Then, are there other reasons for using __*div/di*.S instead of just
> > linking with libgcc?
> 
> It's possible to use libgcc.a but the flag -mconstant-gp has to be removed 
> from the mini-os makefiles and a clean way to add libgcc.a is needed.

Something like the attached patch?

Actually I'm asking because for other purpose, I would need __divdi on
x86_32, and using libgcc.a is a really simple solution.

> By the way current mini-os crashed with Unaligned Reference. 
> A small change is needed:
>  static void maybe_split(struct xmalloc_hdr *hdr, size_t size, size_t block)
>  {
>      struct xmalloc_hdr *extra;
> -    size_t leftover = block - size;
> +    size_t leftover;
> +#if defined(__ia64__)
> +    size = (size +7 ) & ~7;  /* alignment needed on 8 byte boundary. */
> +#endif
> +    leftover = block - size;

Does the following patch work?

diff -r 3cc84775d725 extras/mini-os/lib/xmalloc.c
--- a/extras/mini-os/lib/xmalloc.c      Tue Feb 12 17:04:32 2008 +0000
+++ b/extras/mini-os/lib/xmalloc.c      Wed Feb 13 12:03:52 2008 +0000
@@ -62,10 +62,19 @@ struct xmalloc_pad
     size_t hdr_size;
 };
 
+/* Return size, increased to alignment with align. */
+static inline size_t align_up(size_t size, size_t align)
+{
+    return (size + align - 1) & ~(align - 1);
+}
+
 static void maybe_split(struct xmalloc_hdr *hdr, size_t size, size_t block)
 {
     struct xmalloc_hdr *extra;
-    size_t leftover = block - size;
+    size_t leftover;
+    size = align_up(size, __alignof__(struct xmalloc_hdr));
+    size = align_up(size, __alignof__(struct xmalloc_pad));
+    leftover = block - size;
 
     /* If enough is left to make a block, put it on free list. */
     if ( leftover >= (2 * (sizeof(struct xmalloc_hdr) + sizeof(struct 
xmalloc_pad))) )
@@ -98,12 +107,6 @@ static struct xmalloc_hdr *xmalloc_new_p
     maybe_split(hdr, size, PAGE_SIZE);
 
     return hdr;
-}
-
-/* Return size, increased to alignment with align. */
-static inline size_t align_up(size_t size, size_t align)
-{
-    return (size + align - 1) & ~(align - 1);
 }
 
 /* Big object?  Just use the page allocator. */

Samuel

Attachment: patch
Description: Text document

_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel
<Prev in Thread] Current Thread [Next in Thread>