From patchwork Sun Jan 28 23:15:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 126132 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp1991426ljd; Sun, 28 Jan 2018 15:54:51 -0800 (PST) X-Google-Smtp-Source: AH8x224+8db44I0NYBIs5KmFluxtwT2EacC8blHtRgFswU/uxq4B5D9k8UCfCYrRlPjMNtG0nV9b X-Received: by 10.37.206.9 with SMTP id x9mr7482705ybe.314.1517183691738; Sun, 28 Jan 2018 15:54:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517183691; cv=none; d=google.com; s=arc-20160816; b=e/Ugzy/wf7Gxcd3Zav4UFFTqrEo2HX5nB1AdGivjhY8puyUIPIb7x8HUYpa0OlqlGT cw0MEZSzp6kdfkhnUZgNVkNYU+JLNe7PEzF9OuMyLvvctwCuRxMT6v3q/Q7VKLS4RzhG yayS71ibPeAPqOKL7DXV638WfyCfDBaERuqZKdFtrQnQ2PwSsH9cj4Ro6Auiq2NeFIxZ DFfrlnNsM+uTzIsZGHhzcYjpmyCbXWZbirU3tVnglvNAFpgTkOSD5jVTlkuUvsBsmOJ2 2gmyH7HuTLWIngafqBAyLR4/wx7smDm4nggvfnZ9+4XE+4zOfrpn+4CCCqu4UVxVK2/y S7qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=U7o7B2DzsMkCS0aqAyBfoJOeZETk6TvM1J6LL2I6Io4=; b=E9HXCy4rpHjXb2s7feoR35KM6cj2VZOv7Dq7rH0rg23BIB4uLtmUU04FvOoCWyKcfV xPKM6p2BvU6zTkEB00tXMbZlKgb7X/hdMPUIOKpu3SXLB9ZpA7NhqjH78OA8tY9eGIvz 3cNN8/pRUH4hnDfEGnd2AJc1UGi8yIZNDN+zqEkSp55jlYhSWuNoFwXFbmgeGMlUd72J gPRs51LAXtpk6p1yBJIKW5fjBq8z5qZhNPyVfmIvqLKWmgCQBMJ19Tz8R5T3OhE85Q/Y B9/TFHDSCz5RpH+1S7RE17xdXGneqNBK8bbeaHkiwelM+UgrXU74n9epekkCzQvnsdu/ SwWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KoBeu5Gq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n3si1867618ywl.207.2018.01.28.15.54.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 28 Jan 2018 15:54:51 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KoBeu5Gq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46025 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efwmg-0007fa-Vt for patch@linaro.org; Sun, 28 Jan 2018 18:54:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52490) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efwBj-0003Hg-Od for qemu-devel@nongnu.org; Sun, 28 Jan 2018 18:16:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1efwBi-0000pI-NW for qemu-devel@nongnu.org; Sun, 28 Jan 2018 18:16:39 -0500 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:45539) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1efwBi-0000nX-HV for qemu-devel@nongnu.org; Sun, 28 Jan 2018 18:16:38 -0500 Received: by mail-pf0-x244.google.com with SMTP id a88so3251746pfe.12 for ; Sun, 28 Jan 2018 15:16:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U7o7B2DzsMkCS0aqAyBfoJOeZETk6TvM1J6LL2I6Io4=; b=KoBeu5GqV616MY1LnjoZcvUbljGh8zcCWPCA4vtZNN/WzUyM/5kqKtXf65Q4bpXlix jAEjGRP6WjLnnSO8FCwUXjg1SQ+FefXigur8cxgiIw9kjsmE0RXENp2plEWnFu7hkUOT TEreG2sPt9X7UaltMHY2PvJ+lwb2Cuv4/qHqA= 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=U7o7B2DzsMkCS0aqAyBfoJOeZETk6TvM1J6LL2I6Io4=; b=r3rQKjQa3L9jL767jh3F8z/7B/Ghb7mwhVAGIW1HT+X1cFVuRJgd+15N9m8oe3SwOp RZnCF5ZMtSzeSjIdbEJoSiinXqnLopn3po1XHEmkbjeap07xdNUVtVl/E6qg8tCZGKE9 dy5/xvchz+VEExw8E5BP16BsJLEbTS6LNEoo2bQO4Z2+PyQD21qaQJ0Pv/5f8IDeiQkK NHSQ1V/+glrbtx7SFl1vqU/v3p/XJ56X5cyP/NaPJ0/6B7pFGUQ+eiGUoXi30ofs8oFP rMNaCSvp7znFyzBNl8ffR4ccZK3JrJoxjAIyzRXWKXx77eugU85ZX4cPPyw7WeGVGrZv 040Q== X-Gm-Message-State: AKwxytfXm71N8zrivPb7Hat4p+1kLT2Axb8n0NIPvvbQkGfKR2DmYmu2 ay+5vMXgPcbAX96A1ws/vOI2F7hXubA= X-Received: by 2002:a17:902:bb91:: with SMTP id m17-v6mr20270911pls.315.1517181397198; Sun, 28 Jan 2018 15:16:37 -0800 (PST) Received: from cloudburst.twiddle.net (174-21-6-47.tukw.qwest.net. [174.21.6.47]) by smtp.gmail.com with ESMTPSA id r27sm26949344pfj.75.2018.01.28.15.16.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Jan 2018 15:16:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 28 Jan 2018 15:15:28 -0800 Message-Id: <20180128231528.22719-44-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180128231528.22719-1-richard.henderson@linaro.org> References: <20180128231528.22719-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PULL v4 43/43] target/hppa: Implement PROBE for system 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/hppa/helper.h | 3 +-- target/hppa/op_helper.c | 34 +++++++++++++++++++++++----------- target/hppa/translate.c | 20 ++++++++++++++++---- 3 files changed, 40 insertions(+), 17 deletions(-) -- 2.14.3 diff --git a/target/hppa/helper.h b/target/hppa/helper.h index 31320740da..51dc3f8b09 100644 --- a/target/hppa/helper.h +++ b/target/hppa/helper.h @@ -17,8 +17,7 @@ DEF_HELPER_FLAGS_3(stby_b_parallel, TCG_CALL_NO_WG, void, env, tl, tr) DEF_HELPER_FLAGS_3(stby_e, TCG_CALL_NO_WG, void, env, tl, tr) DEF_HELPER_FLAGS_3(stby_e_parallel, TCG_CALL_NO_WG, void, env, tl, tr) -DEF_HELPER_FLAGS_1(probe_r, TCG_CALL_NO_RWG_SE, tr, tl) -DEF_HELPER_FLAGS_1(probe_w, TCG_CALL_NO_RWG_SE, tr, tl) +DEF_HELPER_FLAGS_4(probe, TCG_CALL_NO_WG, tr, env, tl, i32, i32) DEF_HELPER_FLAGS_1(loaded_fr0, TCG_CALL_NO_RWG, void, env) diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index 37160f0d91..4c00d15213 100644 --- a/target/hppa/op_helper.c +++ b/target/hppa/op_helper.c @@ -160,21 +160,33 @@ void HELPER(stby_e_parallel)(CPUHPPAState *env, target_ulong addr, do_stby_e(env, addr, val, true); } -target_ureg HELPER(probe_r)(target_ulong addr) +target_ureg HELPER(probe)(CPUHPPAState *env, target_ulong addr, + uint32_t level, uint32_t want) { #ifdef CONFIG_USER_ONLY - return page_check_range(addr, 1, PAGE_READ); + return page_check_range(addr, 1, want); #else - return 1; /* FIXME */ -#endif -} + int prot, excp; + hwaddr phys; -target_ureg HELPER(probe_w)(target_ulong addr) -{ -#ifdef CONFIG_USER_ONLY - return page_check_range(addr, 1, PAGE_WRITE); -#else - return 1; /* FIXME */ + /* Fail if the requested privilege level is higher than current. */ + if (level < (env->iaoq_f & 3)) { + return 0; + } + + excp = hppa_get_physical_address(env, addr, level, 0, &phys, &prot); + if (excp >= 0) { + if (env->psw & PSW_Q) { + /* ??? Needs tweaking for hppa64. */ + env->cr[CR_IOR] = addr; + env->cr[CR_ISR] = addr >> 32; + } + if (excp == EXCP_DTLB_MISS) { + excp = EXCP_NA_DTLB_MISS; + } + hppa_dynamic_excp(env, excp, GETPC()); + } + return (want & prot) != 0; #endif } diff --git a/target/hppa/translate.c b/target/hppa/translate.c index c62ee72615..7c45b1706c 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -2380,21 +2380,33 @@ static DisasJumpType trans_probe(DisasContext *ctx, uint32_t insn, { unsigned rt = extract32(insn, 0, 5); unsigned sp = extract32(insn, 14, 2); + unsigned rr = extract32(insn, 16, 5); unsigned rb = extract32(insn, 21, 5); unsigned is_write = extract32(insn, 6, 1); + unsigned is_imm = extract32(insn, 13, 1); TCGv_reg dest, ofs; + TCGv_i32 level, want; TCGv_tl addr; nullify_over(ctx); - /* ??? Do something with priv level operand. */ dest = dest_gpr(ctx, rt); form_gva(ctx, &addr, &ofs, rb, 0, 0, 0, sp, 0, false); - if (is_write) { - gen_helper_probe_w(dest, addr); + + if (is_imm) { + level = tcg_const_i32(extract32(insn, 16, 2)); } else { - gen_helper_probe_r(dest, addr); + level = tcg_temp_new_i32(); + tcg_gen_trunc_reg_i32(level, load_gpr(ctx, rr)); + tcg_gen_andi_i32(level, level, 3); } + want = tcg_const_i32(is_write ? PROT_WRITE : PROT_READ); + + gen_helper_probe(dest, cpu_env, addr, level, want); + + tcg_temp_free_i32(want); + tcg_temp_free_i32(level); + save_gpr(ctx, rt, dest); return nullify_end(ctx, DISAS_NEXT); }