mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
linux(4): Deduplicate mmap2
To help porting the Linux emulation layer to a new platforms start using Linux names for conditional builds instead of architecture-specific ifdefs. MFC after: 1 week (cherry picked from commit 2a1cf1b6b55c8326bbe85d0fdf17b0f2fb9b34ce)
This commit is contained in:
parent
4d17239617
commit
a321b17b8e
7 changed files with 23 additions and 45 deletions
|
|
@ -69,7 +69,6 @@
|
|||
#include <amd64/linux/linux_proto.h>
|
||||
#include <compat/linux/linux_fork.h>
|
||||
#include <compat/linux/linux_misc.h>
|
||||
#include <compat/linux/linux_mmap.h>
|
||||
#include <compat/linux/linux_util.h>
|
||||
|
||||
#define LINUX_ARCH_AMD64 0xc000003e
|
||||
|
|
@ -89,14 +88,6 @@ linux_set_upcall(struct thread *td, register_t stack)
|
|||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
linux_mmap2(struct thread *td, struct linux_mmap2_args *args)
|
||||
{
|
||||
|
||||
return (linux_mmap_common(td, args->addr, args->len, args->prot,
|
||||
args->flags, args->fd, args->pgoff));
|
||||
}
|
||||
|
||||
int
|
||||
linux_iopl(struct thread *td, struct linux_iopl_args *args)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -46,6 +46,10 @@
|
|||
#define LINUX32_MAXSSIZ (64 * 1024 * 1024) /* 64MB */
|
||||
#define LINUX32_MAXVMEM 0 /* Unlimited */
|
||||
|
||||
#define LINUX_ARCHWANT_MMAP2PGOFF 1 /* 32-bit off_t want offset
|
||||
* represented in multiples
|
||||
* of page size. */
|
||||
|
||||
/*
|
||||
* Provide a separate set of types for the Linux types.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -320,15 +320,6 @@ linux_set_upcall(struct thread *td, register_t stack)
|
|||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
linux_mmap2(struct thread *td, struct linux_mmap2_args *args)
|
||||
{
|
||||
|
||||
return (linux_mmap_common(td, PTROUT(args->addr), args->len, args->prot,
|
||||
args->flags, args->fd, (uint64_t)(uint32_t)args->pgoff *
|
||||
PAGE_SIZE));
|
||||
}
|
||||
|
||||
int
|
||||
linux_mmap(struct thread *td, struct linux_mmap_args *args)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,25 +32,17 @@
|
|||
#include <sys/proc.h>
|
||||
#include <sys/ptrace.h>
|
||||
#include <sys/reg.h>
|
||||
#include <sys/sdt.h>
|
||||
|
||||
#include <vm/vm_param.h>
|
||||
|
||||
#include <arm64/linux/linux.h>
|
||||
#include <arm64/linux/linux_proto.h>
|
||||
#include <compat/linux/linux_dtrace.h>
|
||||
#include <compat/linux/linux_fork.h>
|
||||
#include <compat/linux/linux_misc.h>
|
||||
#include <compat/linux/linux_mmap.h>
|
||||
#include <compat/linux/linux_util.h>
|
||||
|
||||
#define LINUX_ARCH_AARCH64 0xc00000b7
|
||||
|
||||
/* DTrace init */
|
||||
LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE);
|
||||
|
||||
/* DTrace probes */
|
||||
LIN_SDT_PROBE_DEFINE0(machdep, linux_mmap2, todo);
|
||||
|
||||
int
|
||||
linux_set_upcall(struct thread *td, register_t stack)
|
||||
|
|
@ -67,16 +59,6 @@ linux_set_upcall(struct thread *td, register_t stack)
|
|||
return (0);
|
||||
}
|
||||
|
||||
/* LINUXTODO: deduplicate arm64 linux_mmap2 */
|
||||
int
|
||||
linux_mmap2(struct thread *td, struct linux_mmap2_args *uap)
|
||||
{
|
||||
|
||||
LIN_SDT_PROBE0(machdep, linux_mmap2, todo);
|
||||
return (linux_mmap_common(td, PTROUT(uap->addr), uap->len, uap->prot,
|
||||
uap->flags, uap->fd, uap->pgoff));
|
||||
}
|
||||
|
||||
int
|
||||
linux_set_cloned_tls(struct thread *td, void *desc)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -365,6 +365,23 @@ linux_madvise(struct thread *td, struct linux_madvise_args *uap)
|
|||
uap->behav));
|
||||
}
|
||||
|
||||
int
|
||||
linux_mmap2(struct thread *td, struct linux_mmap2_args *uap)
|
||||
{
|
||||
#if defined(LINUX_ARCHWANT_MMAP2PGOFF)
|
||||
/*
|
||||
* For architectures with sizeof (off_t) < sizeof (loff_t) mmap is
|
||||
* implemented with mmap2 syscall and the offset is represented in
|
||||
* multiples of page size.
|
||||
*/
|
||||
return (linux_mmap_common(td, PTROUT(uap->addr), uap->len, uap->prot,
|
||||
uap->flags, uap->fd, (uint64_t)(uint32_t)uap->pgoff * PAGE_SIZE));
|
||||
#else
|
||||
return (linux_mmap_common(td, PTROUT(uap->addr), uap->len, uap->prot,
|
||||
uap->flags, uap->fd, uap->pgoff));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef LINUX_LEGACY_SYSCALLS
|
||||
int
|
||||
linux_time(struct thread *td, struct linux_time_args *args)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@
|
|||
|
||||
#define LINUX_DTRACE linuxulator
|
||||
|
||||
#define LINUX_ARCHWANT_MMAP2PGOFF 1
|
||||
|
||||
/*
|
||||
* Provide a separate set of types for the Linux types.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -308,15 +308,6 @@ linux_set_upcall(struct thread *td, register_t stack)
|
|||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
linux_mmap2(struct thread *td, struct linux_mmap2_args *args)
|
||||
{
|
||||
|
||||
return (linux_mmap_common(td, args->addr, args->len, args->prot,
|
||||
args->flags, args->fd, (uint64_t)(uint32_t)args->pgoff *
|
||||
PAGE_SIZE));
|
||||
}
|
||||
|
||||
int
|
||||
linux_mmap(struct thread *td, struct linux_mmap_args *args)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue