Fix to procfs read returns EIO
Refs: #1152 Change-Id: I48b330953fd7674ba1a3ac35744f9f50a5712730
This commit is contained in:
committed by
Masamichi Takagi
parent
1387c9687b
commit
14660a10c3
@@ -562,7 +562,6 @@ static void syscall_channel_send(struct ihk_ikc_channel_desc *c,
|
||||
}
|
||||
|
||||
extern unsigned long do_kill(struct thread *, int, int, int, struct siginfo *, int ptracecont);
|
||||
extern void process_procfs_request(struct ikc_scd_packet *rpacket);
|
||||
extern void terminate_host(int pid);
|
||||
extern void debug_log(long);
|
||||
|
||||
@@ -668,7 +667,13 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
||||
break;
|
||||
|
||||
case SCD_MSG_PROCFS_REQUEST:
|
||||
process_procfs_request(packet);
|
||||
pckt.msg = SCD_MSG_PROCFS_ANSWER;
|
||||
pckt.ref = packet->ref;
|
||||
pckt.arg = packet->arg;
|
||||
pckt.err = process_procfs_request(packet);
|
||||
pckt.reply = packet->reply;
|
||||
pckt.pid = packet->pid;
|
||||
syscall_channel_send(resp_channel, &pckt);
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
|
||||
@@ -383,7 +383,6 @@ struct procfs_read {
|
||||
int count; /* bytes to read (request) */
|
||||
int eof; /* if eof is detected, 1 otherwise 0. (answer)*/
|
||||
int ret; /* read bytes (answer) */
|
||||
int status; /* non-zero if done (answer) */
|
||||
int newcpu; /* migrated new cpu (answer) */
|
||||
int readwrite; /* 0:read, 1:write */
|
||||
char fname[PROCFS_NAME_MAX]; /* procfs filename (request) */
|
||||
@@ -395,6 +394,8 @@ struct procfs_file {
|
||||
char fname[PROCFS_NAME_MAX]; /* procfs filename (request) */
|
||||
};
|
||||
|
||||
int process_procfs_request(struct ikc_scd_packet *rpacket);
|
||||
|
||||
#define RUSAGE_SELF 0
|
||||
#define RUSAGE_CHILDREN -1
|
||||
#define RUSAGE_THREAD 1
|
||||
|
||||
@@ -75,7 +75,7 @@ procfs_delete_thread(struct thread *thread)
|
||||
*
|
||||
* \param rarg returned argument
|
||||
*/
|
||||
void process_procfs_request(struct ikc_scd_packet *rpacket)
|
||||
int process_procfs_request(struct ikc_scd_packet *rpacket)
|
||||
{
|
||||
unsigned long rarg = rpacket->arg;
|
||||
unsigned long parg, pbuf;
|
||||
@@ -83,28 +83,24 @@ void process_procfs_request(struct ikc_scd_packet *rpacket)
|
||||
struct process *proc = NULL;
|
||||
struct process_vm *vm = NULL;
|
||||
struct procfs_read *r;
|
||||
struct ikc_scd_packet packet;
|
||||
int osnum = ihk_mc_get_osnum();
|
||||
int rosnum, ret, pid, tid, ans = -EIO, eof = 0;
|
||||
char *buf, *p;
|
||||
struct ihk_ikc_channel_desc *syscall_channel;
|
||||
struct mcs_rwlock_node_irqsave lock;
|
||||
unsigned long offset;
|
||||
int count;
|
||||
int npages;
|
||||
int readwrite = 0;
|
||||
int err = -EIO;
|
||||
|
||||
dprintf("process_procfs_request: invoked.\n");
|
||||
|
||||
syscall_channel = get_cpu_local_var(0)->ikc2linux;
|
||||
|
||||
dprintf("rarg: %x\n", rarg);
|
||||
parg = ihk_mc_map_memory(NULL, rarg, sizeof(struct procfs_read));
|
||||
dprintf("parg: %x\n", parg);
|
||||
r = ihk_mc_map_virtual(parg, 1, PTATTR_WRITABLE | PTATTR_ACTIVE);
|
||||
if (r == NULL) {
|
||||
kprintf("ERROR: process_procfs_request: got a null procfs_read structure.\n");
|
||||
packet.err = -EIO;
|
||||
goto dataunavail;
|
||||
}
|
||||
dprintf("r: %p\n", r);
|
||||
@@ -118,7 +114,6 @@ void process_procfs_request(struct ikc_scd_packet *rpacket)
|
||||
dprintf("buf: %p\n", buf);
|
||||
if (buf == NULL) {
|
||||
kprintf("ERROR: process_procfs_request: got a null buffer.\n");
|
||||
packet.err = -EIO;
|
||||
goto bufunavail;
|
||||
}
|
||||
|
||||
@@ -695,28 +690,19 @@ end:
|
||||
dprintf("ret: %d, eof: %d\n", ans, eof);
|
||||
r->ret = ans;
|
||||
r->eof = eof;
|
||||
r->status = 1; /* done */
|
||||
packet.err = 0;
|
||||
err = 0;
|
||||
bufunavail:
|
||||
ihk_mc_unmap_memory(NULL, pbuf, r->count);
|
||||
ihk_mc_unmap_virtual(r, 1);
|
||||
dataunavail:
|
||||
ihk_mc_unmap_memory(NULL, parg, sizeof(struct procfs_read));
|
||||
|
||||
packet.msg = SCD_MSG_PROCFS_ANSWER;
|
||||
packet.arg = rarg;
|
||||
packet.pid = rpacket->pid;
|
||||
|
||||
ret = ihk_ikc_send(syscall_channel, &packet, 0);
|
||||
if (ret < 0) {
|
||||
kprintf("ERROR: sending IKC msg, ret: %d\n", ret);
|
||||
}
|
||||
if(proc)
|
||||
release_process(proc);
|
||||
if(thread)
|
||||
release_thread(thread);
|
||||
if(vm)
|
||||
release_process_vm(vm);
|
||||
return;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user