urw.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
#include <vm/seg_kmem.h>
static int
{
struct segvn_data *svd;
/*
* Fail if the page doesn't map to a page in the underlying
* mapped file, if an underlying mapped file exists.
*/
return (0);
}
/*
* Fail if this is an ISM shared segment and the address is
* not within the real size of the spt segment that backs it.
*/
return (0);
/*
* The key is that the mapping comes from segdev and the
* type is neither MAP_SHARED nor MAP_PRIVATE.
*/
return (0);
/*
* Fail if the page is a MAP_NORESERVE page that has
* not actually materialized.
* We cheat by knowing that segvn is the only segment
* driver that supports MAP_NORESERVE.
*/
/*
* Guilty knowledge here. We know that
* segvn_incore returns more than just the
* low-order bit that indicates the page is
* actually in memory. If any bits are set,
* then there is backing store for the page.
*/
char incore = 0;
if (incore == 0)
return (0);
}
return (1);
}
/*
* Map address "addr" in address space "as" into a kernel virtual address.
* The memory is guaranteed to be resident and locked down.
*/
static caddr_t
{
/*
* NB: Because of past mistakes, we have bits being returned
* by getpfnum that are actually the page type bits of the pte.
* When the object we are trying to map is a memory page with
* a page structure everything is ok and we can use the optimal
* method, ppmapin. Otherwise, we have to do something special.
*/
if (pf_is_memory(pfnum)) {
(caddr_t)-1);
}
}
/*
* Oh well, we didn't have a page struct for the object we were
* trying to map in; ppmapin doesn't handle devices, but allocating a
* heap address allows ppmapout to free virutal space when done.
*/
}
/*ARGSUSED*/
static void
{
}
/*
* Perform I/O to a given process. This will return EIO if we dectect
* corrupt memory and ENXIO if there is no such mapped address in the
* user process's address space.
*/
static int
{
int error = 0;
int err = 0;
int protchanged;
int retrycnt;
/*
* Locate segment containing address of interest.
*/
retrycnt = 0;
return (ENXIO);
}
protchanged = 0;
protchanged = 1;
protchanged = 0;
retrycnt++;
goto retry;
}
if (err != 0) {
return (ENXIO);
}
}
/*
* segvn may do a copy-on-write for F_SOFTLOCK/S_READ case to break
* sharing to avoid a copy on write of a softlocked page by another
* thread. But since we locked the address space as a writer no other
* thread can cause a copy on write. S_READ_NOCOW is passed as the
* access type to tell segvn that it's ok not to do a copy-on-write
* for this SOFTLOCK fault.
*/
if (writing)
rw = S_READ_NOCOW;
else
if (protchanged)
return (ENXIO);
}
/*
* Make sure we're not trying to read or write off the end of the page.
*/
/*
* Map in the locked page, copy to our local buffer,
* then map the page out and unlock it.
*/
/*
* Since we are copying memory on behalf of the user process,
* protect against memory error correction faults.
*/
/*
* Device memory can behave strangely; invoke
* a segdev-specific copy operation instead.
*/
if (writing) {
} else {
}
} else {
if (writing)
else
}
} else {
}
no_trap();
/*
* If we're writing to an executable page, we may need to sychronize
* the I$ with the modifications we made through the D$.
*/
if (rw == S_READ_NOCOW)
if (protchanged)
return (error);
}
int
{
}
int
{
}