From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,58e01463bf74882a,start X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1993-10-12 12:36:53 PST Newsgroups: comp.sys.dec Path: gmd.de!xlink.net!howland.reston.ans.net!sol.ctr.columbia.edu!destroyer!nntp.cs.ubc.ca!uw-beaver!news From: pardo@cs.washington.edu (David Keppel) Subject: More Alpha/AXP I cache flushing questions Message-ID: <1993Oct12.181743.10010@beaver.cs.washington.edu> Sender: news@beaver.cs.washington.edu (USENET News System) Organization: Computer Science & Engineering, U. of Washington, Seattle Date: Tue, 12 Oct 93 18:17:43 GMT I asked recently about where to find the constant used in the Alpha's CALL_PAL assembler used to flush the I cache. Thanks to those who responded, the answer is that it's in . For my next Alpha question, I get SEGV's (I'm running OSF/1 1.3) when I try to `malloc' a region and use it for writing and executing code. For example: h = malloc (...) memcpy (h, ...); routine_to_imb(); (*h)(); /* SEGV on first instruction. */ I have experimented and found h = malloc (...) mprotect (h&pagemask, ..., PROT_READ|PROT_WRITE|PROT_EXEC); memcpy (h, ...); routine_to_imb(); (*h)(); memcpy (h, ...); /* SEGV on first byte changed. */ (Yes, I'm checking the return value from `mprotect'). If I add another `mprotect', it all works: h = malloc (...) mprotect (h&pagemask, ..., PROT_READ|PROT_WRITE|PROT_EXEC); memcpy (h, ...); routine_to_imb(); (*h)(); mprotect (h&pagemask, ..., PROT_READ|PROT_WRITE|PROT_EXEC); memcpy (h, ...); routine_to_imb(); (*h)(); I don't have any explanation for why I'm using `mprotect', except that when it SEGV'd in the first case, I assumed ``oh, the page isn't executable'' and started adding calls to `mprotect'. I have since discovered that although some cases will SEGV reliably on my machine (without the `mprotect' calls), there are other cases that will work reliably without the call (but they also omit the IMB, so they execute both old and new instructions and thus produce incorrect results). Does anybody have good ideas about what is going on? It almost feels like the OS is playing games with the page protections, but the fact that *some* attempts to muck things don't SEGV tells me this probably isn't the case. Thus, I suspect my use of `mprotect' is just a red herring, but I'm not sure what else to do. Thanks in advance. ;-D on ( Paying my protection ) Pardo