From patchwork Fri Nov 4 20:50:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artyom Tarasenko X-Patchwork-Id: 9413231 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 2A36B60573 for ; Fri, 4 Nov 2016 21:09:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19B632AF51 for ; Fri, 4 Nov 2016 21:09:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B39B2AF79; Fri, 4 Nov 2016 21:09:39 +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 A1A1E2AF51 for ; Fri, 4 Nov 2016 21:09:38 +0000 (UTC) Received: from localhost ([::1]:40792 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c2lk1-0007cE-Ga for patchwork-qemu-devel@patchwork.kernel.org; Fri, 04 Nov 2016 17:09:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55661) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c2lSd-00010s-GI for qemu-devel@nongnu.org; Fri, 04 Nov 2016 16:51:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c2lSc-0004Ba-4N for qemu-devel@nongnu.org; Fri, 04 Nov 2016 16:51:39 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:33528) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c2lSb-0004AQ-Tv for qemu-devel@nongnu.org; Fri, 04 Nov 2016 16:51:38 -0400 Received: by mail-wm0-x242.google.com with SMTP id u144so5628485wmu.0 for ; Fri, 04 Nov 2016 13:51:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=eevOtEXVJRtyB9iJ8VYY6C9f2mw89W/7SpWpTVBkq6k=; b=qZ5AwzsmRdZwsUV4TUX1evu3LF/FTQuM4zGasEGHz/chbFjtJfZbyJ1mhMKilQk/sl 967tHuYCOsXuCnBcLNO6HU5EyXJ3wtFHBujbleT8S5z0RWjK2uLjqitXCMm/yLeHhZiN gmKhYL43Mo7LQYsB0v3gcXWazZw6KnH9DwkVRTwpwj4KzEXKRzzk6SSv7q6VxwjzoiGq 8xRKbLJqzfaya+SSR+dVQsVyFER/LR72YVB1ZeiWeFZMciSkuq7tWzww8yJYjzirNG8f dC/N+VXbtz22ICG5xgwWQzT7dTInd2oTQTZvocifM3gyNrP7dF0rvzSmVMJDtA/Txvmg t4tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=eevOtEXVJRtyB9iJ8VYY6C9f2mw89W/7SpWpTVBkq6k=; b=YN7B+xJmFVbFX+MDa+WMszBwxAoAjjjIHDo90tbqXy6inFXi5I+E5QspEwDfH5+tQF a1EIXfLu+Gn+nspfEnVzwfy26GmICjb+OdzmVf6C5Mzm+Ovbvx8Tq9GJGXemcWJsjs7i 5XxSBRNy5HrqVfWhUsoFX/3Df2ztUL95eaHpgAWQkKj0sw9eU9eNuJx86mTEWeT4114i /JvLcVofTsP1DGjH7qgb3Y7lY6Nw5oG9q0jXmS6jZ9gvjrhqECoiVj28TV7xTMURTngX owYYAFlb3fm8jE9gRYowk1fIBvWn7RMYB/vtn/kwi3aBSD7NAhLPaZSwbr1PBp/lx9Do md8Q== X-Gm-Message-State: ABUngve9jOATrK4+9m0tnWHMJT24+/kdn0MxRKvdPTu246I0YkbcqSZMamhF7mOuA6mwXA== X-Received: by 10.28.51.141 with SMTP id z135mr178804wmz.109.1478292696810; Fri, 04 Nov 2016 13:51:36 -0700 (PDT) Received: from localhost (x55b4b5cf.dyn.telefonica.de. [85.180.181.207]) by smtp.gmail.com with ESMTPSA id jg6sm16139528wjb.22.2016.11.04.13.51.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Nov 2016 13:51:36 -0700 (PDT) From: Artyom Tarasenko To: qemu-devel@nongnu.org Date: Fri, 4 Nov 2016 21:50:17 +0100 Message-Id: <3c352fc282481ba83da0296b2f302b11b97fe46c.1478291230.git.atar4qemu@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: 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] [PATCH v1 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 , Artyom Tarasenko , Richard Henderson 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 | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/target-sparc/ldst_helper.c b/target-sparc/ldst_helper.c index 387732d..301616b 100644 --- a/target-sparc/ldst_helper.c +++ b/target-sparc/ldst_helper.c @@ -293,6 +293,20 @@ static inline target_ulong asi_address_mask(CPUSPARCState *env, } return addr; } + +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 static void do_check_align(CPUSPARCState *env, target_ulong addr, @@ -1118,13 +1132,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 +1431,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);