From patchwork Wed Jan 18 22:38:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artyom Tarasenko X-Patchwork-Id: 9524927 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 544DF6043A for ; Wed, 18 Jan 2017 23:07:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47FA5284D5 for ; Wed, 18 Jan 2017 23:07:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BF9428564; Wed, 18 Jan 2017 23:07:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D162A284D5 for ; Wed, 18 Jan 2017 23:07:31 +0000 (UTC) Received: from localhost ([::1]:44939 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cTzKE-0004oI-9h for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Jan 2017 18:07:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cTytG-0006ex-5E for qemu-devel@nongnu.org; Wed, 18 Jan 2017 17:39:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cTytF-0002qL-CG for qemu-devel@nongnu.org; Wed, 18 Jan 2017 17:39:38 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:33220) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cTytF-0002pv-60 for qemu-devel@nongnu.org; Wed, 18 Jan 2017 17:39:37 -0500 Received: by mail-wm0-x242.google.com with SMTP id r144so7568333wme.0 for ; Wed, 18 Jan 2017 14:39:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=O0AkdvfVja/LbHvzMhC6jgm2zsmDmgDo6abCjej+e9M=; b=ByLjOsnHIKe+/mskfgqKOf+O+gDxcAm2d/oFuLAZr/8bA/kxwROX9LGaNHGTIT7Dqu 1XD2OiMu5fdjTTo0r2Ab67/Ytw03NBVYCgDa2pC6mqDpBu6UC1Qpjn4tsd8PfZbk2GDC lVKcLUmN7em2cRbsSjgb0qd/5PaV+Z30rZusxzlFq4rltrCjIYeAbSsYM9QZglvqDovz 5xz2FZZUb7M0atqdL/Mi0EqJvaJW4cyytRm06ABV/GKwaxHqxaHCOR5w8e8tmducn6VB Z58qFjjEA6iAQA55e8Ak3gUfPr9idZxW2CRx6azNnwQmiV9RXqeZowIDMDK8phLrtGiq 5lAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=O0AkdvfVja/LbHvzMhC6jgm2zsmDmgDo6abCjej+e9M=; b=AMcoLLX72Se+xPyc8FgnXApMlDr0T9mU9X3R38Z4HzXmchaIW3Qt2wPatt2q2kTMpx F8lXuIfnN0ZWXHzStfCbr+cIeIRrtwPBaiAuzz1V1C3aEiErnJLSzGPhwcwKFccZxNXE QCjVjoTS8L7y30WXb/VDa9ftCcnhEdHWpYmT8Nowgqg3M6KPuTasZAWcmnXTKgf32t9l 9IHzNBIa2PQIFZ7acyu1pPLQlCEjAZmHbgalpASGsSbUDLIDNkUIjMEJvvi2TEA5uLO3 gYJp/zpnmFdAxSYxikLbmzxhWU5yZnaqEWERc6OB9dDhm6kg2gguAgdmkBQJz/SWQihE WIOg== X-Gm-Message-State: AIkVDXLPre2bf6to6BI7Ie/cOJAJJ20bUFFG0itEgRnr1xRPwF6iTEoxTrwyD5T3kNIN3Q== X-Received: by 10.28.90.65 with SMTP id o62mr4309009wmb.80.1484779176137; Wed, 18 Jan 2017 14:39:36 -0800 (PST) Received: from localhost (x4e33e2b8.dyn.telefonica.de. [78.51.226.184]) by smtp.gmail.com with ESMTPSA id y145sm48363805wmc.17.2017.01.18.14.39.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jan 2017 14:39:35 -0800 (PST) From: Artyom Tarasenko To: peter.maydell@linaro.org Date: Wed, 18 Jan 2017 23:38:29 +0100 Message-Id: <1484779123-18968-17-git-send-email-atar4qemu@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1484779123-18968-1-git-send-email-atar4qemu@gmail.com> References: <1484779123-18968-1-git-send-email-atar4qemu@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 16/30] target-sparc: allow priveleged ASIs in hyperprivileged mode 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: mark.cave-ayland@ilande.co.uk, qemu-devel@nongnu.org, Artyom Tarasenko , rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Artyom Tarasenko --- target/sparc/ldst_helper.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c index 2e6439a..ade4fb0 100644 --- a/target/sparc/ldst_helper.c +++ b/target/sparc/ldst_helper.c @@ -293,6 +293,22 @@ static inline target_ulong asi_address_mask(CPUSPARCState *env, } return addr; } + +#ifndef CONFIG_USER_ONLY +static inline void do_check_asi(CPUSPARCState *env, int asi, uintptr_t ra) +{ + /* ASIs >= 0x80 are user mode. + * ASIs >= 0x30 are hyper mode (or super if hyper is not available). + * ASIs <= 0x2f are super mode. + */ + if (asi < 0x80 + && !cpu_hypervisor_mode(env) + && (!cpu_supervisor_mode(env) + || (asi >= 0x30 && cpu_has_hypervisor(env)))) { + cpu_raise_exception_ra(env, TT_PRIV_ACT, ra); + } +} +#endif /* !CONFIG_USER_ONLY */ #endif static void do_check_align(CPUSPARCState *env, target_ulong addr, @@ -1118,13 +1134,7 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, asi &= 0xff; - if ((asi < 0x80 && (env->pstate & PS_PRIV) == 0) - || (cpu_has_hypervisor(env) - && asi >= 0x30 && asi < 0x80 - && !(env->hpstate & HS_PRIV))) { - cpu_raise_exception_ra(env, TT_PRIV_ACT, GETPC()); - } - + do_check_asi(env, asi, GETPC()); do_check_align(env, addr, size - 1, GETPC()); addr = asi_address_mask(env, asi, addr); @@ -1423,13 +1433,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, asi &= 0xff; - if ((asi < 0x80 && (env->pstate & PS_PRIV) == 0) - || (cpu_has_hypervisor(env) - && asi >= 0x30 && asi < 0x80 - && !(env->hpstate & HS_PRIV))) { - cpu_raise_exception_ra(env, TT_PRIV_ACT, GETPC()); - } - + do_check_asi(env, asi, GETPC()); do_check_align(env, addr, size - 1, GETPC()); addr = asi_address_mask(env, asi, addr);