From patchwork Tue Dec 7 09:34:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jin Guojie X-Patchwork-Id: 74499 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 76588B6EDF for ; Tue, 7 Dec 2010 20:39:31 +1100 (EST) Received: from localhost ([127.0.0.1]:33560 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPu1A-0006wA-0a for incoming@patchwork.ozlabs.org; Tue, 07 Dec 2010 04:39:28 -0500 Received: from [140.186.70.92] (port=50296 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPtwW-0005gl-4m for qemu-devel@nongnu.org; Tue, 07 Dec 2010 04:34:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PPtwV-000158-2m for qemu-devel@nongnu.org; Tue, 07 Dec 2010 04:34:39 -0500 Received: from mail-yx0-f173.google.com ([209.85.213.173]:49140) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PPtwV-00014t-0I for qemu-devel@nongnu.org; Tue, 07 Dec 2010 04:34:39 -0500 Received: by yxl31 with SMTP id 31so7124768yxl.4 for ; Tue, 07 Dec 2010 01:34:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=yPvQEC9PT0AXtQ+pLB4RntXewQh59zzplr8q1IumCcg=; b=eMOuslyHjRLXbMpDfLbpXIET4serQRNwHMSngBKaA9L5spdAj9Apt1XXOpdBjARd0e TM+vaAIQwzZVr7imGiMy2skCNiR/ZkbTZS1kfV1GZYNspNcd9Obm1+wtrpyhHioKKQkP xbAnzLyEicjwEvQhm4qgC9GZDDhHaBVRhOpYM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type; b=XZe2ddxr+uiSOaRgaon/B9KsMXVhERxUphMXcbNYVZNBK0+5c00oDaKgQrapJGaNpo FzCdFPhreRrQn3gNHbxOY+No5HtsUEk0wPMtvHfJpjxV8zdzggwi+VN4lMnwyiuyRmDi It3pTwDrAW910NlDiz5LWpc/t2okytdJ1hbLQ= MIME-Version: 1.0 Received: by 10.42.166.136 with SMTP id o8mr1831416icy.300.1291714477861; Tue, 07 Dec 2010 01:34:37 -0800 (PST) Received: by 10.42.219.135 with HTTP; Tue, 7 Dec 2010 01:34:37 -0800 (PST) Date: Tue, 7 Dec 2010 17:34:37 +0800 X-Google-Sender-Auth: cE4RhktOBbJ3ucbgKlzGDdJ5XVQ Message-ID: From: Jin Guojie To: Anthony Liguori X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: qemu-level Subject: [Qemu-devel] [PATCH] fix do_socket(): type conversion for all targets X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: "Jin Guojie" Signed-off-by: "Yin Yixiao" Reviewed-by: "Gao Xiang" A patch for do_socket() in Linux user mode. The original code only handles socket constants conversion for target MIPS. We encountered this problem when emulating X86 apps on MIPS machines. This patch extends the scope to all targets and fix the problem. For your review, any comment is strongly welcomed. Jin Guojie www.loongson.cn --- linux-user/socket.h | 10 ++++++++++ linux-user/syscall.c | 3 +-- 2 files changed, 11 insertions(+), 2 deletions(-) type = SOCK_DGRAM; @@ -1589,7 +1588,7 @@ static abi_long do_socket(int domain, int type, int protocol) type = SOCK_PACKET; break; } -#endif + if (domain == PF_NETLINK) return -EAFNOSUPPORT; /* do not NETLINK socket connections possible */ return get_errno(socket(domain, type, protocol)); diff --git a/linux-user/socket.h b/linux-user/socket.h index 93d4782..f24b44c 100644 --- a/linux-user/socket.h +++ b/linux-user/socket.h @@ -144,4 +144,14 @@ #define TARGET_SO_PEERSEC 31 + enum sock_type { + TARGET_SOCK_DGRAM = 2, + TARGET_SOCK_STREAM = 1, + TARGET_SOCK_RAW = 3, + TARGET_SOCK_RDM = 4, + TARGET_SOCK_SEQPACKET = 5, + TARGET_SOCK_DCCP = 6, + TARGET_SOCK_PACKET = 10, + }; + #endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c3e8706..544698a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1568,7 +1568,6 @@ static abi_long unlock_iovec(struct iovec *vec, abi_ulong target_addr, /* do_socket() Must return target values and target errnos. */ static abi_long do_socket(int domain, int type, int protocol) { -#if defined(TARGET_MIPS) switch(type) { case TARGET_SOCK_DGRAM: