PPC problem

View: New views
4 Messages — Rating Filter:   Alert me  

PPC problem

by Eli Barzilay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

There was a PPC problem that we've just fixed, and I'm forwarding it
here in case it's not fixed in the lightning repository:

(Quoting Matthew Flatt)

The problem was a bug in lightning's icache-flushing code (used by the
JIT) It could walk one word past the end of an allocated page onto an
unallocated page. The bug was exposed by yesterday's change to the way
that memory is allocated to hold JIT-generated native code.

The fix is in "lightning/ppc/funcs.h": subtract 1 from `end' here:

     end -= ((long) end - 1) & (cache_line_size - 1);

--
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


_______________________________________________
Lightning mailing list
Lightning@...
http://lists.gnu.org/mailman/listinfo/lightning

Re: PPC problem

by Paolo Bonzini-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Eli Barzilay wrote:

> There was a PPC problem that we've just fixed, and I'm forwarding it
> here in case it's not fixed in the lightning repository:
>
> (Quoting Matthew Flatt)
>
> The problem was a bug in lightning's icache-flushing code (used by the
> JIT) It could walk one word past the end of an allocated page onto an
> unallocated page. The bug was exposed by yesterday's change to the way
> that memory is allocated to hold JIT-generated native code.
>
> The fix is in "lightning/ppc/funcs.h": subtract 1 from `end' here:
>
>      end -= ((long) end - 1) & (cache_line_size - 1);

Thanks, here's what I applied:

diff --git a/lightning/ppc/funcs.h b/lightning/ppc/funcs.h
index 9f3df90..ae9301f 100644
--- a/lightning/ppc/funcs.h
+++ b/lightning/ppc/funcs.h
@@ -67,6 +67,9 @@ jit_flush_code(void *start, void *end)
         break;
   }

+  /* Point end to the last byte being flushed.  */
+  end   =(void*)( (long)(end - 1));
+
   start =(void*)( (long)start - (((long) start) & (cache_line_size - 1)));
   end   =(void*)( (long)end   - (((long) end) & (cache_line_size - 1)));

Paolo


_______________________________________________
Lightning mailing list
Lightning@...
http://lists.gnu.org/mailman/listinfo/lightning

Re: PPC problem

by Eli Barzilay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Oct  9, Paolo Bonzini wrote:

> Eli Barzilay wrote:
> >
> > The fix is in "lightning/ppc/funcs.h": subtract 1 from `end' here:
> >
> >      end -= ((long) end - 1) & (cache_line_size - 1);
>
> Thanks, here's what I applied:
>
> diff --git a/lightning/ppc/funcs.h b/lightning/ppc/funcs.h
> index 9f3df90..ae9301f 100644
> --- a/lightning/ppc/funcs.h
> +++ b/lightning/ppc/funcs.h
> @@ -67,6 +67,9 @@ jit_flush_code(void *start, void *end)
>          break;
>    }
>
> +  /* Point end to the last byte being flushed.  */
> +  end   =(void*)( (long)(end - 1));
> +
>    start =(void*)( (long)start - (((long) start) & (cache_line_size - 1)));
>    end   =(void*)( (long)end   - (((long) end) & (cache_line_size - 1)));

Hmm, we have:

  start -= ((long) start) & (cache_line_size - 1);
  end -= ((long) end - 1) & (cache_line_size - 1);

which is different.  (I'm not too familiar with this code, so I'm
CCing Matthew too, in case there is something wrong in our version of
the file.)

--
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


_______________________________________________
Lightning mailing list
Lightning@...
http://lists.gnu.org/mailman/listinfo/lightning

Re: PPC problem

by Paolo Bonzini-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> Hmm, we have:
>
>   start -= ((long) start) & (cache_line_size - 1);
>   end -= ((long) end - 1) & (cache_line_size - 1);
>
> which is different.  (I'm not too familiar with this code, so I'm
> CCing Matthew too, in case there is something wrong in our version of
> the file.)

No, it was this change:

2008-07-02  Laurent Michel  <ldm@...>

        * lightning/ppc/funcs.h (jit_flush_code): modified the computation
        of start/end. The pointer arithmetic was done without casting. It
        prevented compilation with recent gcc versions.

If you have time, I think syncing MzScheme's lightning now would not be
a bad idea.

Paolo


_______________________________________________
Lightning mailing list
Lightning@...
http://lists.gnu.org/mailman/listinfo/lightning