This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] ppc32 dl-machine.c


Resubmitted with separate "for loops" for dcbst and icbi per Geoff Keating.

Back in July, Anton Blanchard reported a bug in dl-machine.c
(__elf_machine_runtime_setup) asserting that the loader must "icbi"
(Instruction Cache Block Invalidate) the entire PLT range after it is
initialized. 

http://sources.redhat.com/ml/libc-alpha/2002-07/msg00166.html

Anton and Geoff Keating debated this back and forth for a while but I believe
the conclusion was that this is required based on the rationale in:

http://sources.redhat.com/ml/libc-alpha/2002-07/msg00180.html

I believe the discussion ended with Geoff expecting a patch from Anton.
But on examination of the the current CVS it seems Anton forgot. I discussed
this with Anton and offered to create the patch myself which is attached. 

If this patch is accepted it should be considered for glibc-2-2-branch as 
well as 2.3.

2002-09-24  Steven Munroe  <sjmunroe@us.ibm.com>

	* sysdeps/powerpc/powerpc32/dl-machine.c: Declare __cache_line_size as
	weak extern.
	(__elf_machine_runtime_setup): Invalidate the instruction cache over the 
	whole range of the PLT.


diff -rupPN -xCVS -x*orig -xmanual libc23-cvstip-20020923/sysdeps/powerpc/powerpc32/dl-machine.c libc23/sysdeps/powerpc/powerpc32/dl-machine.c
--- libc23-cvstip-20020923/sysdeps/powerpc/powerpc32/dl-machine.c	Thu Sep  5 03:24:12 2002
+++ libc23/sysdeps/powerpc/powerpc32/dl-machine.c	Wed Sep 25 14:00:28 2002
@@ -26,6 +26,11 @@
 #include <dl-machine.h>
 #include <stdio-common/_itoa.h>
 
+/* The value __cache_line_size is defined in memset.S and is initialised
+   by _dl_sysdep_start via DL_PLATFORM_INIT.  */
+extern int __cache_line_size;
+weak_extern (__cache_line_size)
+
 /* Because ld.so is now versioned, these functions can be in their own file;
    no relocations need to be done to call them.
    Of course, if ld.so is not versioned...  */
@@ -214,6 +219,8 @@ __elf_machine_runtime_setup (struct link
       Elf32_Word rel_offset_words = PLT_DATA_START_WORDS (num_plt_entries);
       Elf32_Word data_words = (Elf32_Word) (plt + rel_offset_words);
       Elf32_Word size_modified;
+      int *line_size_ptr = & __cache_line_size;
+      int line_size_words;
 
       extern void _dl_runtime_resolve (void);
       extern void _dl_prof_resolve (void);
@@ -304,14 +311,26 @@ __elf_machine_runtime_setup (struct link
 	 there may be a little overlap at the start and the end.
 
 	 Assumes that dcbst and icbi apply to lines of 16 bytes or
-	 more.  Current known line sizes are 16, 32, and 128 bytes.  */
+	 more.  Current known line sizes are 16, 32, and 128 bytes.  
+	 The following gets the __cache_line_size, when available.  */
 
+      line_size_words = 4;/* Default minimum 4 words per cache line.  */
+      if (lazy) /* Don't try this until ld.so has relocated itself!  */
+        if (line_size_ptr != NULL)
+          { /*  Verify that __cache_line_size is defined and set.  */
+            if (*line_size_ptr != 0)  
+	            /* Convert bytes to words.  */
+              line_size_words = *line_size_ptr >> 2;	    
+          }
+	
       size_modified = lazy ? rel_offset_words : 6;
-      for (i = 0; i < size_modified; i += 4)
-	PPC_DCBST (plt + i);
+      for (i = 0; i < size_modified; i += line_size_words)
+        PPC_DCBST (plt + i);
       PPC_DCBST (plt + size_modified - 1);
       PPC_SYNC;
-      PPC_ICBI (plt);
+      
+      for (i = 0; i < size_modified; i += line_size_words)
+        PPC_ICBI (plt + i);
       PPC_ICBI (plt + size_modified - 1);
       PPC_ISYNC;
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]