From patchwork Wed Jan 11 20:19:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artyom Tarasenko X-Patchwork-Id: 9511463 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 52BAE606E1 for ; Wed, 11 Jan 2017 21:20:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42FD9286A2 for ; Wed, 11 Jan 2017 21:20:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34D26286A5; Wed, 11 Jan 2017 21:20:24 +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 CE68A286A2 for ; Wed, 11 Jan 2017 21:20:23 +0000 (UTC) Received: from localhost ([::1]:57209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRQJh-0001A0-Sz for patchwork-qemu-devel@patchwork.kernel.org; Wed, 11 Jan 2017 16:20:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRPOM-0006ky-Jr for qemu-devel@nongnu.org; Wed, 11 Jan 2017 15:21:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cRPOJ-00018j-Js for qemu-devel@nongnu.org; Wed, 11 Jan 2017 15:21:06 -0500 Received: from mail-wj0-x241.google.com ([2a00:1450:400c:c01::241]:35702) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cRPOJ-00017W-Dc for qemu-devel@nongnu.org; Wed, 11 Jan 2017 15:21:03 -0500 Received: by mail-wj0-x241.google.com with SMTP id ey1so13026716wjd.2 for ; Wed, 11 Jan 2017 12:21:03 -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 :in-reply-to:references; bh=9v4BKkJmTaIiGKvjYFE197qu6OWTStuAvtwGKIXprfk=; b=MJyn1peqh9Y3F9i+M01oRT/5PQnUCLqk1bOcxD6Yss6taNfRi6pcV6eoit/KKL50QU 1sK7TIy/F+wN6LQhQBIt0xI77+TFYUHsiXmrtQ7N1plexOgAIlUjtXt88HPXoMQHJdMo G4y8ZkopD86yVjfgLDhcw46q2ZlspEJlaMYvperLfRKpFOlhvDx50N/7+ZEwLu/p6A3I kXTo/6asuPAQgAukNOiDgjdqcOxbhRioxiETTEgF0/EIgepQP03KSGiYiIlZa4xtSUo9 8wVnEG1gAaedf/C3+oIKSDKldZaMQ+K6SJap76N0VKtasabUhsvpgNVaizUmgGs5v9q6 TZSA== 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:in-reply-to:references; bh=9v4BKkJmTaIiGKvjYFE197qu6OWTStuAvtwGKIXprfk=; b=RT/c3AzEF4ABJiptgOVm170LpLq+Iy4Fn+b73JTxtoGKfuCdZU4fFFBuOEHeolTwH2 AqBaiWF5TLi4ATz5q2rMM6dmmnaFx6nCleVXuGZXXJSStqrx1SXo4PSinlE7RA/zc2Rk WjtV/qM5SZAFngjoEjUpFnaRec6PofUw9+Yl4+bVEu1vj5ELbDk5kNVSdt+D6LmU08Hk VxxXLmGMPMDnAJUw7SMxk+IV7C7eaEERICVKMAYua3xIXHfENn8tM7yuRF+yR8K0gCxc 2CtrvFVgClw0+MOMBL6TEz2ZE+vSOABszCtnYt1LdgwWxQbwk1kNiJBToUBWuKvgG/m2 odLA== X-Gm-Message-State: AIkVDXJpIIzhwFCUPNx6cIL1NiY6Kkb+1R8VisElPeKxPBnEQ6DSxxuGRECD9pemvt1Qnw== X-Received: by 10.194.121.1 with SMTP id lg1mr6226983wjb.140.1484166062397; Wed, 11 Jan 2017 12:21:02 -0800 (PST) Received: from localhost (x55b4b54a.dyn.telefonica.de. [85.180.181.74]) by smtp.gmail.com with ESMTPSA id 203sm31443512wmf.21.2017.01.11.12.21.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jan 2017 12:21:01 -0800 (PST) From: Artyom Tarasenko To: qemu-devel@nongnu.org Date: Wed, 11 Jan 2017 21:19:47 +0100 Message-Id: <343d22b67790a08cd37bd66bfddeb1cad351ef43.1484165352.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:c01::241 Subject: [Qemu-devel] [PATCH v2 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);