NetBSD Problem Report #113

From gnats  Mon Feb  7 07:26:33 1994
Received: from helios.unl.edu (helios.unl.edu [129.93.33.11]) by sun-lamp.cs.berkeley.edu (8.6.5/8.6.5) with SMTP id HAA20520 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Mon, 7 Feb 1994 07:26:32 -0800
Message-Id: <m0pTXNE-000hSDC@sierra.weeville.com>
Date: Mon, 7 Feb 94 08:55 CST
From: randy%sierra%dsndata@tssi.com
Reply-To: randy%sierra%dsndata@tssi.com
To: dsndata!tssi!helios!sun-lamp.cs.berkeley.edu!gnats-bugs
Subject: mmap of /dev/vga returns EINVAL
X-Send-Pr-Version: 3.2

>Number:         113
>Category:       kern
>Synopsis:       mmapping /dev/vga returns EINVAL
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Feb 07 07:35:01 +0000 1994
>Closed-Date:    Thu Feb 24 01:17:09 +0000 1994
>Last-Modified:  Sun Mar 03 17:46:26 +0000 2013
>Originator:     Randy Terbush
>Release:        current-020494
>Organization:
zyzzyva
>Environment:
	486/66 VLB
	16MB RAM
	75MB Swap
	SCSI
	S3 928 Video
System: NetBSD sierra 0.9a SIERRABT#3 i386

>Description:
	Using mmap to map /dev/vga in XFree86 returns EINVAL
>How-To-Repeat:

#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/mman.h>


main()
{
    int fd;
    caddr_t base;

    if ((fd = open("/dev/vga", O_RDWR)) < 0)
    {
	printf("checkDevMem: warning: failed to open /dev/vga (%s)\n",
	       strerror(errno));
	printf("\tlinear fb access unavailable\n");

	return(fd);
    }

/* Try to map a page at the VGA address */
    printf("fd = %d\n", fd);

    base = (caddr_t)mmap((caddr_t)0, 4096, PROT_READ|PROT_WRITE,
			 MAP_FILE, fd, (off_t)0xA0000);

    printf("base = %d\n", base);

    close(fd);

    if (base == (caddr_t)-1)
    {
	printf("checkDevMem: warning: failed to mmap /dev/vga (%s)\n",
	       strerror(errno));
	printf("\tlinear fb access unavailable\n");

	return((int) base);
    }

    munmap((caddr_t)base, 4096);
    return;
}

ADDENDUM by cgd:
this mmap() is bogus.  historically, since 386BSD, you mmap()
/dev/vga at offset 0 to get the buffer.  this used to happen
automatically, becasue the device pager was broken, but now
that it's fixed, X's bug is exposed.

>Fix:

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback
State-Changed-By: cgd
State-Changed-When: Mon Feb 7 11:06:04 PST 1994
State-Changed-Why: 
it's a bug in X.
State-Changed-From-To: feedback->closed 
State-Changed-By: cgd 
State-Changed-When: Wed Feb 23 17:17:09 PST 1994 
State-Changed-Why:  
reported bug was due to: 
(1) bug in user's code 
(2) previous versions of the VM system ignoring that bug 

Unformatted:

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.