[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] shmat(): use mmap_find_vma to find free memory area
From: |
Kirill A. Shutemov |
Subject: |
[Qemu-devel] [PATCH] shmat(): use mmap_find_vma to find free memory area |
Date: |
Mon, 13 Oct 2008 13:10:40 +0300 |
Signed-off-by: Kirill A. Shutemov <address@hidden>
---
linux-user/syscall.c | 28 ++++++++++++++++++++--------
1 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 3fa205f..db3538b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2267,25 +2267,37 @@ static inline abi_long do_shmctl(int shmid, int cmd,
abi_long buf)
static inline abi_long do_shmat(int shmid, abi_ulong shmaddr, int shmflg,
unsigned long *raddr)
{
+ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size);
abi_long ret;
struct shmid_ds shm_info;
int i;
- /* SHM_* flags are the same on all linux platforms */
- *raddr = (unsigned long) shmat(shmid, g2h(shmaddr), shmflg);
-
- if (*raddr == -1) {
- return get_errno(*raddr);
- }
-
/* find out the length of the shared memory segment */
ret = get_errno(shmctl(shmid, IPC_STAT, &shm_info));
if (is_error(ret)) {
/* can't get length, bail out */
- shmdt((void *) *raddr);
return get_errno(ret);
}
+ if (shmaddr)
+ *raddr = (unsigned long) shmat(shmid, g2h(shmaddr), shmflg);
+ else {
+ abi_ulong mmap_start;
+
+ mmap_start = mmap_find_vma(0, shm_info.shm_segsz);
+
+ if (mmap_start == -1) {
+ errno = ENOMEM;
+ *raddr = -1;
+ } else
+ *raddr = (unsigned long) shmat(shmid, g2h(mmap_start),
+ shmflg | SHM_REMAP);
+ }
+
+ if (*raddr == -1) {
+ return get_errno(*raddr);
+ }
+
page_set_flags(h2g(*raddr), h2g(*raddr) + shm_info.shm_segsz,
PAGE_VALID | PAGE_READ |
((shmflg & SHM_RDONLY)? 0 : PAGE_WRITE));
--
1.5.6.5.GIT
- [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling, (continued)
- [Qemu-devel] [PATCH] Fix and cleanup IPCOP_msg* ipc calls handling, Kirill A. Shutemov, 2008/10/13
- [Qemu-devel] [PATCH] Implement msg* syscalls, Kirill A. Shutemov, 2008/10/13
- [Qemu-devel] [PATCH] Fix and cleanup IPCOP_sem* ipc calls handling, Kirill A. Shutemov, 2008/10/13
- [Qemu-devel] [PATCH] Implement sem* syscalls, Kirill A. Shutemov, 2008/10/13
- [Qemu-devel] [PATCH] Fix and cleanup IPCOP_shm* ipc calls handling, Kirill A. Shutemov, 2008/10/13
- [Qemu-devel] [PATCH] Implement shm* syscalls, Kirill A. Shutemov, 2008/10/13
- [Qemu-devel] [PATCH] Fix fstatat64()/newfstatat() syscall implementation, Kirill A. Shutemov, 2008/10/13
- [Qemu-devel] [PATCH] Introduce --enable-binfmt-misc configure option, Kirill A. Shutemov, 2008/10/13
- [Qemu-devel] [PATCH] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets, Kirill A. Shutemov, 2008/10/13
- [Qemu-devel] [PATCH] mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly, Kirill A. Shutemov, 2008/10/13
- [Qemu-devel] [PATCH] shmat(): use mmap_find_vma to find free memory area,
Kirill A. Shutemov <=
- [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space, Kirill A. Shutemov, 2008/10/17
- [Qemu-devel] [PATCH] linux-user, x86: use target_mmap() to allocate idt, gdt and ldt tables, Kirill A. Shutemov, 2008/10/17
- Re: [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space, andrzej zaborowski, 2008/10/27
- Re: [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space, Kirill A. Shutemov, 2008/10/27
- Re: [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space, Andreas Schwab, 2008/10/27
- Re: [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space, Kirill A. Shutemov, 2008/10/27
- Re: [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space, andrzej zaborowski, 2008/10/27
- Re: [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space, Kirill A. Shutemov, 2008/10/27
- [Qemu-devel] [PATCH, v2] mmap: add check if requested memory area fits target address space, Kirill A. Shutemov, 2008/10/27
- Re: [Qemu-devel] [PATCH] mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly, Vince Weaver, 2008/10/14