Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: ralf@uni-koblenz.de
To: "William J. Earl" <wje@fir.engr.sgi.com>
Cc: linux@cthulhu.engr.sgi.com
Subject: Re: VCE exceptions
Date: Fri, 3 Apr 1998 13:52:45 +0200	[thread overview]
Message-ID: <19980403135245.23593@uni-koblenz.de> (raw)
In-Reply-To: <199804022315.PAA01986@fir.engr.sgi.com>; from William J. Earl on Thu, Apr 02, 1998 at 03:15:03PM -0800

[-- Attachment #1: Type: text/plain, Size: 1602 bytes --]

On Thu, Apr 02, 1998 at 03:15:03PM -0800, William J. Earl wrote:

> At MIPS, with the Magnum 4000PC under RISC/os, and at SGI, with the
> Indy R4000PC (and later R4600 and R5000), I modified RISC/os and IRIX to
> control virtual aliasing, but only for those platforms without hardware
> VCE detection (in order to minimize time to market).  

VCE's don't look too difficult to tackle under Linux.

>     Note that taking a K0SEG address for a physical page which is also mapped
> to user space can easily cause a VCE, since there is a good chance that
> the K0SEG virtual index differs from the user space virtual index, unless
> you match physical page color to virtual page color when allocating pages.
> Note that you have to do that for any pages which must be accessible in
> the general exception handler, since you cannot handle a VCE in the
> exception handler.

The VCE bug is actually worse than I thought before.  I was in the assumption
that we'd handle all cases were VC might hit us because the MIPS ABI takes
care of by it's restrictions of the virtual addresses for mmaping.  Well,
I was wrong.  Writing via write(2) to a file that is also mmap(2)ed may
result in virtual coherency problems.

Another problem is that under Linux one cannot simply allocate a page of
a desired colour - which would of course be the prefered solution.  Luckily
a vce exceptionhandler will not run into the problem under Linux.

A small test program for the mmap/write problem attached.  If may be
necessary to start it several times in order to make it print the ``Big
trouble, man ...'' message.

  Ralf

[-- Attachment #2: mmap.c --]
[-- Type: text/plain, Size: 1139 bytes --]

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>

#define TESTFILE "hurz"

static char zero[4096];
static char one[4096];

int main(int argc, char *argv[])
{
	int fd, res, i;
	char *addr;
	volatile char *p;

	memset(zero, 0, 4096);
	memset(one, 1, 4096);

	fd = open(TESTFILE, O_RDWR | O_CREAT, 664);
	unlink(TESTFILE);
	if(fd < 0) {
		perror("Opening testfile failed");
		exit(EXIT_FAILURE);
	}

	res =write(fd, one, 4096);
	if (res < 0) {
		perror("Write failed");
		exit(EXIT_FAILURE);
	}

	addr = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
	if (addr == MAP_FAILED) {
		perror("Mapping /dev/zero failed");
	}

	p = addr;
	for (i=0;i<4096;i++) {
		*(p++);
	}

	res = lseek(fd, SEEK_SET, 0);
	if (res < 0) {
		perror("Seek failed");
		exit(EXIT_FAILURE);
	}

	res =write(fd, zero, 4096);
	if (res < 0) {
		perror("Write failed");
		exit(EXIT_FAILURE);
	}

	p = addr;
	res = 0;
	for (i=0;i<4096;i++) {
		res |= *(p++);
	}

	if (res) {
		fprintf(stderr, "Big trouble, man ...\n");
	}

	exit(EXIT_SUCCESS);
}

  reply	other threads:[~1998-04-03 12:07 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-02 20:53 VCE exceptions ralf
1998-04-02 21:41 ` William J. Earl
1998-04-02 22:36   ` ralf
1998-04-02 23:15     ` William J. Earl
1998-04-03 11:52       ` ralf [this message]
1998-04-03 19:11         ` William J. Earl
1998-04-03 19:17           ` Alan Cox
1998-04-03 19:17             ` Alan Cox
1998-04-03 21:02             ` ralf
1998-04-03 21:00               ` Alan Cox
1998-04-03 23:13             ` Olivier Galibert
1998-04-03 23:15               ` Alan Cox
1998-04-03 23:15                 ` Alan Cox
1998-04-03 23:47               ` William J. Earl
1998-04-03 21:27           ` ralf
1998-04-03 22:07             ` William J. Earl
  -- strict thread matches above, loose matches on Subject: below --
1998-04-23  5:01 Brendan Black

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19980403135245.23593@uni-koblenz.de \
    --to=ralf@uni-koblenz.de \
    --cc=linux@cthulhu.engr.sgi.com \
    --cc=wje@fir.engr.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox