public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Arun Sharma <arun.sharma@intel.com>
To: linux-ia64@vger.kernel.org
Subject: epoll support for ia32 applications
Date: Fri, 08 Aug 2003 00:35:13 +0000	[thread overview]
Message-ID: <marc-linux-ia64-106030302724904@msgid-missing> (raw)

[-- Attachment #1: Type: text/plain, Size: 186 bytes --]


The patch was created by Matt Helsley <matthltc at us.ibm.com> for 2.4 and has been changed slightly to match 2.6.

The implementation compromises performance for correctness.

	-Arun


[-- Attachment #2: epoll-2.5.patch --]
[-- Type: text/plain, Size: 3699 bytes --]

Index: arch/ia64/ia32/ia32_entry.S
===================================================================
--- arch/ia64/ia32/ia32_entry.S	(revision 12202)
+++ arch/ia64/ia32/ia32_entry.S	(working copy)
@@ -440,12 +440,12 @@
 	data8 sys_ni_syscall
 	data8 sys_ni_syscall
 	data8 sys_ni_syscall
+	data8 sys_epoll_create
+	data8 sys32_epoll_ctl	/* 255 */
+	data8 sys32_epoll_wait
 	data8 sys_ni_syscall
-	data8 sys_ni_syscall	/*255*/
 	data8 sys_ni_syscall
 	data8 sys_ni_syscall
-	data8 sys_ni_syscall
-	data8 sys_ni_syscall
 	data8 sys_ni_syscall	/* 260 */
 	data8 sys_ni_syscall
 	data8 sys_ni_syscall
Index: arch/ia64/ia32/sys_ia32.c
===================================================================
--- arch/ia64/ia32/sys_ia32.c	(revision 12202)
+++ arch/ia64/ia32/sys_ia32.c	(working copy)
@@ -43,6 +43,7 @@
 #include <linux/nfsd/xdr.h>
 #include <linux/nfsd/syscall.h>
 #include <linux/poll.h>
+#include <linux/eventpoll.h>
 #include <linux/personality.h>
 #include <linux/ptrace.h>
 #include <linux/stat.h>
@@ -2704,6 +2705,95 @@
 	goto out;
 }
 
+/* Structure for ia32 emulation on ia64 */
+struct epoll_event32 
+{
+	u32 events;
+	u64 data;
+} __attribute__((packed));
+
+asmlinkage long 
+sys32_epoll_ctl(int epfd, int op, int fd, struct epoll_event32 *event)
+{
+	mm_segment_t old_fs = get_fs();
+	struct epoll_event event64;
+	int error = -EFAULT;
+	u32 data_halfword;
+  
+	if ((error = verify_area(VERIFY_READ, event,
+				 sizeof(struct epoll_event32))))
+		return error;
+  
+	__get_user(event64.events, &event->events);
+	__get_user(data_halfword, (u32*)(&event->data));
+	event64.data = data_halfword;
+	__get_user(data_halfword, ((u32*)(&event->data) + 1));
+ 	event64.data |= ((u64)data_halfword) << 32; 
+
+	set_fs(KERNEL_DS);
+	error = sys_epoll_ctl(epfd, op, fd, &event64);
+	set_fs(old_fs);
+
+	return error;
+}
+
+asmlinkage long
+sys32_epoll_wait(int epfd, struct epoll_event32 *events, int maxevents,
+		 int timeout)
+{
+	struct epoll_event *events64 = NULL;
+	mm_segment_t old_fs = get_fs();
+	int error;
+	int evt_idx;
+  
+	if (maxevents <= 0) {
+		return -EINVAL;
+	}
+
+	/* Verify that the area passed by the user is writeable */
+	if ((error = verify_area(VERIFY_WRITE, events,
+				 maxevents * sizeof(struct epoll_event32))))
+		return error;
+
+	/* Allocate the space needed for the intermediate copy */
+	events64 = kmalloc(maxevents * sizeof(struct epoll_event), GFP_KERNEL);
+	if (events64 == NULL) {
+		return -ENOMEM;
+	}
+  
+	/* Expand the 32-bit structures into the 64-bit structures */
+	for (evt_idx = 0; evt_idx < maxevents; evt_idx++) {
+		u32 data_halfword;
+		__get_user(events64[evt_idx].events, &events[evt_idx].events);
+		__get_user(data_halfword, (u32*)(&events[evt_idx].data));
+		events64[evt_idx].data = data_halfword;
+		__get_user(data_halfword, ((u32*)(&events[evt_idx].data) + 1));
+		events64[evt_idx].data |= ((u64)data_halfword) << 32;
+	}
+  
+	/* Do the system call */
+	set_fs(KERNEL_DS); /* copy_to/from_user should work on kernel mem*/
+	error = sys_epoll_wait(epfd, events64, maxevents, timeout);
+	set_fs(old_fs);
+
+	/* Don't modify userspace memory if we're returning an error */ 
+	if (!error) {
+		/* Translate the 64-bit structures back into the 32-bit 
+		   structures */
+		for (evt_idx = 0; evt_idx < maxevents; evt_idx++) {
+			__put_user(events64[evt_idx].events, 
+				   &events[evt_idx].events);
+			__put_user((u32)(events64[evt_idx].data),
+				   (u32*)(&events[evt_idx].data));
+			__put_user((u32)(events64[evt_idx].data >> 32),
+				   ((u32*)(&events[evt_idx].data) + 1));
+		}
+	}
+
+	kfree(events64);
+	return error;
+}
+
 #ifdef	NOTYET  /* UNTESTED FOR IA64 FROM HERE DOWN */
 
 struct ncp_mount_data32 {

             reply	other threads:[~2003-08-08  0:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-08  0:35 Arun Sharma [this message]
2003-08-08  6:31 ` epoll support for ia32 applications David Mosberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=marc-linux-ia64-106030302724904@msgid-missing \
    --to=arun.sharma@intel.com \
    --cc=linux-ia64@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox