memuserkernel-r0drv-linux.c revision 0b53618bc8b692bf8ed1499ba786f5959295c633
/* $Id$ */
/** @file
* IPRT - User & Kernel Memory, Ring-0 Driver, Linux.
*/
/*
* Copyright (C) 2009 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "the-linux-kernel.h"
{
return VINF_SUCCESS;
return VERR_ACCESS_DENIED;
}
{
return VINF_SUCCESS;
return VERR_ACCESS_DENIED;
}
{
}
{
/* Couldn't find a straight forward way of doing this... */
#ifdef RT_ARCH_X86
# ifdef CONFIG_X86_HIGH_ENTRY
return true; /* ?? */
# else
# endif
#elif defined(RT_ARCH_AMD64)
/* Linux 2.6.0 ... 2.6.10 set PAGE_OFFSET to 0x0000010000000000.
* Linux 2.6.11 sets PAGE_OFFSET to 0xffff810000000000.
* Linux 2.6.33 sets PAGE_OFFSET to 0xffff880000000000. */
# else
/* Not correct (KERNEL_TEXT_START=0xffffffff80000000),
* VMALLOC_START (0xffffff0000000000) would be better */
# endif
#else
# error "PORT ME"
#endif
}
RTR0DECL(bool) RTR0MemAreKrnlAndUsrDifferent(void)
{
return false;
#else
return true;
#endif
}
/**
* Treats both source and destination as unsafe buffers.
*/
{
/* _ASM_EXTABLE was introduced in 2.6.25 from what I can tell. Using #ifndef
here since it has to be a macro and you never know what someone might have
backported to an earlier kernel release. */
# ifndef _ASM_EXTABLE
# if ARCH_BITS == 32
".section __ex_table,\"a\"\n" \
".balign 4\n" \
".previous\n"
# else
".section __ex_table,\"a\"\n" \
".balign 8\n" \
".previous\n"
# endif
# endif /* !_ASM_EXTABLE */
int rc;
if (!cb)
return VINF_SUCCESS;
"1:\n\t"
"rep; movsb\n"
"2:\n\t"
".section .fixup,\"ax\"\n"
"3:\n\t"
"movl %4, %0\n"
".previous\n"
: "=r" (rc),
"=D" (pvDst),
"=S" (pvSrc),
"=c" (cb)
: "i" (VERR_ACCESS_DENIED),
"0" (VINF_SUCCESS),
"1" (pvDst),
"2" (pvSrc),
"3" (cb)
: "memory");
return rc;
#else
return VERR_NOT_SUPPORTED;
#endif
}
{
}
{
}