From patchwork Wed Nov 14 13:37:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Markovic X-Patchwork-Id: 997747 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rt-rk.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42w5Gd25D0z9s3C for ; Thu, 15 Nov 2018 00:40:25 +1100 (AEDT) Received: from localhost ([::1]:60377 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMvP4-0001PQ-Ok for incoming@patchwork.ozlabs.org; Wed, 14 Nov 2018 08:40:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMvMh-000820-EH for qemu-devel@nongnu.org; Wed, 14 Nov 2018 08:37:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMvMd-0007xb-Or for qemu-devel@nongnu.org; Wed, 14 Nov 2018 08:37:55 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:45359 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gMvMd-0006uR-4D for qemu-devel@nongnu.org; Wed, 14 Nov 2018 08:37:51 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 6D3DE1A45D9; Wed, 14 Nov 2018 14:36:46 +0100 (CET) X-Virus-Scanned: amavisd-new at rt-rk.com Received: from smarkovic.mipstec.com (smarkovic.domain.local [10.10.13.57]) by mail.rt-rk.com (Postfix) with ESMTPSA id 31ECA1A2444; Wed, 14 Nov 2018 14:36:46 +0100 (CET) From: Stefan Markovic To: qemu-devel@nongnu.org Date: Wed, 14 Nov 2018 14:37:08 +0100 Message-Id: <1542202628-6538-1-git-send-email-stefan.markovic@rt-rk.com> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH] linux-user: Update MIPS specific prctl() implementation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: smarkovic@wavecomp.com, riku.voipio@iki.fi, laurent@vivier.eu, amarkovic@wavecomp.com, pjovanovic@wavecomp.com, aurelien@aurel32.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Stefan Markovic Perform needed checks before actual prctl() PR_SET_FP_MODE and PR_GET_FP_MODE work based on kernel implementation. Also, update necessary hflags. Signed-off-by: Stefan Markovic Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 810a58b..10db8b7 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9544,9 +9544,25 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, { CPUMIPSState *env = ((CPUMIPSState *)cpu_env); bool old_fr = env->CP0_Status & (1 << CP0St_FR); + bool old_fre = env->CP0_Config5 & (1 << CP0C5_FRE); bool new_fr = arg2 & TARGET_PR_FP_MODE_FR; bool new_fre = arg2 & TARGET_PR_FP_MODE_FRE; + const unsigned int known_bits = TARGET_PR_FP_MODE_FR | + TARGET_PR_FP_MODE_FRE; + + /* If nothing to change, return right away, successfully. */ + if (old_fr == new_fr && old_fre == new_fre) { + return 0; + } + /* Check the value is valid */ + if (arg2 & ~known_bits) { + return -TARGET_EOPNOTSUPP; + } + /* Setting FRE without FR is not supported. */ + if (new_fre && !new_fr) { + return -TARGET_EOPNOTSUPP; + } if (new_fr && !(env->active_fpu.fcr0 & (1 << FCR0_F64))) { /* FR1 is not supported */ return -TARGET_EOPNOTSUPP; @@ -9576,6 +9592,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, env->hflags |= MIPS_HFLAG_F64; } else { env->CP0_Status &= ~(1 << CP0St_FR); + env->hflags &= ~MIPS_HFLAG_F64; } if (new_fre) { env->CP0_Config5 |= (1 << CP0C5_FRE); @@ -9584,6 +9601,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } else { env->CP0_Config5 &= ~(1 << CP0C5_FRE); + env->hflags &= ~MIPS_HFLAG_FRE; } return 0;