From patchwork Sun Sep 16 15:04:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fredrik Noring X-Patchwork-Id: 970342 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=nocrew.org 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 42CymB3cTrz9sBJ for ; Mon, 17 Sep 2018 04:42:18 +1000 (AEST) Received: from localhost ([::1]:59901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1bzs-0004aq-3n for incoming@patchwork.ozlabs.org; Sun, 16 Sep 2018 14:42:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1bwh-0002Z0-6i for qemu-devel@nongnu.org; Sun, 16 Sep 2018 14:38:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g1bwg-00057p-Fo for qemu-devel@nongnu.org; Sun, 16 Sep 2018 14:38:59 -0400 Received: from ste-pvt-msa2.bahnhof.se ([213.80.101.71]:41305) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g1bwg-000542-5x for qemu-devel@nongnu.org; Sun, 16 Sep 2018 14:38:58 -0400 Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 375073F67D; Sun, 16 Sep 2018 20:38:52 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Amavis-Alert: BAD HEADER SECTION, Non-encoded 8-bit data (char C3 hex): Cc: ....maydell@linaro.org>, \n \tJ\303\203\302\274rgen Urban In-Reply-To: References: <4b72263c848ecf76a06f973294cc5b5b67fe4080.1537122775.git.noring@nocrew.org> From: Fredrik Noring Date: Sun, 16 Sep 2018 17:04:12 +0200 To: Aleksandar Markovic , "Maciej W. Rozycki" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 213.80.101.71 Subject: [Qemu-devel] [PATCH v4 4/8] target/mips: Add function to signal RI exception unless user only 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: Peter Maydell , Richard Henderson , qemu-devel@nongnu.org, J??rgen Urban , Petar Jovanovic , Aurelien Jarno Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The Linux kernel traps and emulates certain instructions. For user only, QEMU is the kernel, so we emulate those traps by simply emulating the instructions directly. Signed-off-by: Fredrik Noring Reviewed-by: Philippe Mathieu-Daudé --- target/mips/translate.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/target/mips/translate.c b/target/mips/translate.c index c35be0053b..77d678353e 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -1887,6 +1887,20 @@ static inline void check_insn_opc_removed(DisasContext *ctx, int flags) } } +/* + * Unless user only, when the kernel emulates the code, a "reserved + * instruction" exception is generated if the CPU has corresponding + * flag set which indicates that the instruction has been removed. + */ +static inline void check_insn_opc_user_only(DisasContext *ctx, int flags) +{ +#ifndef CONFIG_USER_ONLY + if (unlikely(ctx->insn_flags & flags)) { + generate_exception_end(ctx, EXCP_RI); + } +#endif +} + /* This code generates a "reserved instruction" exception if the CPU does not support 64-bit paired-single (PS) floating point data type */ static inline void check_ps(DisasContext *ctx)