From patchwork Thu Jun 7 22:24:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163691 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 85F21B6FA4 for ; Fri, 8 Jun 2012 09:18:13 +1000 (EST) Received: from localhost ([::1]:60728 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Scl9I-000481-Ia for incoming@patchwork.ozlabs.org; Thu, 07 Jun 2012 18:25:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Scl8L-0001V9-2c for qemu-devel@nongnu.org; Thu, 07 Jun 2012 18:24:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Scl8J-0006G8-6l for qemu-devel@nongnu.org; Thu, 07 Jun 2012 18:24:48 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:48169) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Scl8I-0006Db-Tq for qemu-devel@nongnu.org; Thu, 07 Jun 2012 18:24:47 -0400 Received: by mail-pb0-f45.google.com with SMTP id ro12so1843661pbb.4 for ; Thu, 07 Jun 2012 15:24:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=i5F642yUYQh0+Bsxk6U/tqynl09qsgbXYXBZjSnWuSs=; b=fPvEBg/4db5MZbOWlDV+MhvZMvcaDD4mbydrM8qh9V7K9UojZKP0RGFTdcm9BljjcP nduwK8J2B5VvEEnM4mhVWAu/VmHL2jd+ijQqUxkH4L3tkaLffWYdcilXFArU79OLQIqv W3k2wwM/eqGAw12Xc4ZDvb5vVNAHEAqnMTGXng1uhvEKVy35UxMBWJfQSOBDyJkmc3ZK cDciBEXt1447EfT0kAHrxCWGmOa5HBDCXXFXmjqSUTgWldvmxaxMSltuT5X8V/7oYKFx Y8RbY+Z/3E1pC4irKJz5LJ/9PCPxbqNsuDs73TW8pCCf+WNjjbLPQ3QRyUYciD5UoAE6 qmLg== Received: by 10.68.189.198 with SMTP id gk6mr12814000pbc.102.1339107885938; Thu, 07 Jun 2012 15:24:45 -0700 (PDT) Received: from anchor.twiddle.home ([173.160.232.49]) by mx.google.com with ESMTPS id u5sm5454817pbu.76.2012.06.07.15.24.44 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 07 Jun 2012 15:24:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 7 Jun 2012 15:24:31 -0700 Message-Id: <1339107871-4487-10-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1339107871-4487-1-git-send-email-rth@twiddle.net> References: <1339107871-4487-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: Riku Voipio Subject: [Qemu-devel] [PATCH 9/9] alpha-linux-user: Fix the getpriority syscall X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Alpha uses unbiased priority values in the syscall, with the a3 return value signaling error conditions. Therefore, properly interpret the libc getpriority as needed for the guest rather than passing the host value through unchanged. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index bc77b79..bc65c32 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -218,7 +218,6 @@ _syscall3(int, sys_getdents, uint, fd, struct linux_dirent *, dirp, uint, count) #if defined(TARGET_NR_getdents64) && defined(__NR_getdents64) _syscall3(int, sys_getdents64, uint, fd, struct linux_dirent64 *, dirp, uint, count); #endif -_syscall2(int, sys_getpriority, int, which, int, who); #if defined(TARGET_NR__llseek) && defined(__NR_llseek) _syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, loff_t *, res, uint, wh); @@ -6447,10 +6446,21 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; #endif case TARGET_NR_getpriority: - /* libc does special remapping of the return value of - * sys_getpriority() so it's just easiest to call - * sys_getpriority() directly rather than through libc. */ - ret = get_errno(sys_getpriority(arg1, arg2)); + /* Note that negative values are valid for getpriority, so we must + differentiate based on errno settings. */ + errno = 0; + ret = getpriority(arg1, arg2); + if (ret == -1 && errno != 0) { + ret = get_errno(errno); + break; + } +#ifdef TARGET_ALPHA + /* Return value is the unbiased priority. Signal no error. */ + ((CPUAlphaState *)cpu_env)->ir[IR_V0] = 0; +#else + /* Return value is a biased priority to avoid negative numbers. */ + ret = 20 - ret; +#endif break; case TARGET_NR_setpriority: ret = get_errno(setpriority(arg1, arg2, arg3));