From patchwork Wed Jan 24 23:26:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 125726 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp735033ljf; Wed, 24 Jan 2018 15:35:56 -0800 (PST) X-Google-Smtp-Source: AH8x225TyLRY7s1HsKmNL72ngf2SrS6uOPzxOJrhG6s+hiekJUGw5ynJ6hC9M5W1N7TAo3FxmUPr X-Received: by 10.129.80.10 with SMTP id e10mr6795233ywb.429.1516836956494; Wed, 24 Jan 2018 15:35:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516836956; cv=none; d=google.com; s=arc-20160816; b=sl5RGLJAzS51C7tN+reOOrpx9MJXbhe7fQivaGf8eFeCIVqKv7/WAPXPgL3khOQ82J /IFCqcvvpW7Ysg0qOvCKcKAMXtTXhDXXrSaneMH4k9FlU7tX223XFjXPdjEHs8aLkiD2 mNZLYJ13c2wCT0DBuWFxQl2ax0sTYRPxJhCSdSnW2CYz1qH17LJ/EeFOwfA7RrrW5kDo ADj9uPzkCrM6F2/yFGUuBFkDF+a/Qw0KRPaH6N4j7enyQ39gSUGy8tX4EV94b5Ut8K3b 2OwHDWH0IIyl7A4lLe2CAyetOgEHDl7T2XIuVeq9lWCmN4EzK6lxHaOFyzzeUy55hME8 8XTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=l90A/DY5v8SNLXxNLjiu4jsgTj01n2M44ta48kw+zYE=; b=EK7RoQrNN4cSYKn1n+vFkmAnsWtIdKUz1/8Ge6TEoTsLWGk4HqfLb2sucPBEOyMj91 qKFB+GQTPHJ2XzubaEbkD2yzaBDXbH/00u5ef10H9fkN5GtPIyDCN7W+/BNlN3WX2yG1 pxZk1qpuFGAlIsY6exNKGxUf8v0eIwMXY35qoBmQjU4ZK8RYAZ6mcznRAaF/yg2iyeUU FLC0uwyllT1kX6t4HhRUPKF+XrQEAz1hpVhwsgbl9+JyCWyk5heYtLJR3FnwbuEDX37A flse1CWXmVEAwPGOpPwGuICsDVZcOVFkCFZzydTJUGFODr7Rr7fz4rqJgWCQ/OQzygRM zKEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UchfsvBq; 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 v124si234514ywf.321.2018.01.24.15.35.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 Jan 2018 15:35:56 -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=UchfsvBq; 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]:54505 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeUaB-00036X-Ql for patch@linaro.org; Wed, 24 Jan 2018 18:35:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeURg-0004qt-7Z for qemu-devel@nongnu.org; Wed, 24 Jan 2018 18:27:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eeURe-0001xu-RQ for qemu-devel@nongnu.org; Wed, 24 Jan 2018 18:27:08 -0500 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:42674) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eeURe-0001xd-Iw for qemu-devel@nongnu.org; Wed, 24 Jan 2018 18:27:06 -0500 Received: by mail-pg0-x244.google.com with SMTP id q67so3809276pga.9 for ; Wed, 24 Jan 2018 15:27:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=l90A/DY5v8SNLXxNLjiu4jsgTj01n2M44ta48kw+zYE=; b=UchfsvBqej7XmP1Uj4dsEX+OBvdelsZWAA8alJibtJvDSnCRLZTOwke3WhTCAowZJ1 ZbZsUtk/g7+uIWbZaoF7PjFGRXJqMjkk1uIa4xgqIcECZokcMMA4b4PtyHPeOnkB0rRG E13VUkY5BgpAM7e9jijdWZTByDAhPKGLSv8R4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=l90A/DY5v8SNLXxNLjiu4jsgTj01n2M44ta48kw+zYE=; b=DAFr7cwysWBG6277kwAdwH7YwPIrB13GN3WM0UPGqBFKI2zD8F3v2D6h0LTcezt0tB o+5aFqh48rIqv5MtIz/hrp5yDhjT/ygBRlI/xxHPCtoc+0GzM2EJs9/hgOTYR1gVjfPV 6IH0xQl+puhfxHFqn2F7kTXSaquc8/lE2HzhhGQXeqKcJp824OM6rcEhCtTC04pjsrbJ adqZpyLN42N7kYNvN00uXGnijHvqDtmpAJVIgLTE+5RlzO++QgIp/7pgFL1W1OJgUK01 rPqssuAX+k2P1/m5ji0CTwIjriQ5AJwK+IzQXLHgHXiLn8v1zcLLHKggGbWAo5yGIRUH MpPg== X-Gm-Message-State: AKwxytfB9lo+AYtg8+QAFfxGbKnKszXfHWiEDeOtQQMN/6HvlhOukgHW L9UB6o++e+VXq5Zq99rtRW1KayxjaUQ= X-Received: by 2002:a17:902:62:: with SMTP id 89-v6mr9284626pla.284.1516836425305; Wed, 24 Jan 2018 15:27:05 -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 z19sm9760028pfh.185.2018.01.24.15.27.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Jan 2018 15:27:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 24 Jan 2018 15:26:04 -0800 Message-Id: <20180124232625.30105-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180124232625.30105-1-richard.henderson@linaro.org> References: <20180124232625.30105-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:c05::244 Subject: [Qemu-devel] [PATCH v3 24/45] target/hppa: Implement LPA 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/hppa/cpu.h | 1 + target/hppa/helper.h | 1 + target/hppa/mem_helper.c | 21 +++++++++++++++++++++ target/hppa/op_helper.c | 10 +++++----- target/hppa/translate.c | 30 ++++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 5 deletions(-) -- 2.14.3 diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 31a3702684..a6e4091b6a 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -344,5 +344,6 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, extern const MemoryRegionOps hppa_io_eir_ops; void hppa_cpu_alarm_timer(void *); #endif +void QEMU_NORETURN hppa_dynamic_excp(CPUHPPAState *env, int excp, uintptr_t ra); #endif /* HPPA_CPU_H */ diff --git a/target/hppa/helper.h b/target/hppa/helper.h index f059ddf3b9..1e733b7926 100644 --- a/target/hppa/helper.h +++ b/target/hppa/helper.h @@ -90,4 +90,5 @@ DEF_HELPER_FLAGS_3(itlba, TCG_CALL_NO_RWG, void, env, tl, tr) DEF_HELPER_FLAGS_3(itlbp, TCG_CALL_NO_RWG, void, env, tl, tr) DEF_HELPER_FLAGS_2(ptlb, TCG_CALL_NO_RWG, void, env, tl) DEF_HELPER_FLAGS_1(ptlbe, TCG_CALL_NO_RWG, void, env) +DEF_HELPER_FLAGS_2(lpa, TCG_CALL_NO_WG, tr, env, tl) #endif diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index 2835d890f2..fbe2e19d5d 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -307,4 +307,25 @@ void HELPER(ptlbe)(CPUHPPAState *env) memset(env->tlb, 0, sizeof(env->tlb)); tlb_flush_by_mmuidx(src, 0xf); } + +target_ureg HELPER(lpa)(CPUHPPAState *env, target_ulong addr) +{ + hwaddr phys; + int prot, excp; + + excp = hppa_get_physical_address(env, addr, MMU_KERNEL_IDX, + MMU_DATA_LOAD, &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 phys; +} #endif /* CONFIG_USER_ONLY */ diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index 6d19cab6c9..d270f94e31 100644 --- a/target/hppa/op_helper.c +++ b/target/hppa/op_helper.c @@ -34,7 +34,7 @@ void QEMU_NORETURN HELPER(excp)(CPUHPPAState *env, int excp) cpu_loop_exit(cs); } -static void QEMU_NORETURN dynexcp(CPUHPPAState *env, int excp, uintptr_t ra) +void QEMU_NORETURN hppa_dynamic_excp(CPUHPPAState *env, int excp, uintptr_t ra) { HPPACPU *cpu = hppa_env_get_cpu(env); CPUState *cs = CPU(cpu); @@ -46,14 +46,14 @@ static void QEMU_NORETURN dynexcp(CPUHPPAState *env, int excp, uintptr_t ra) void HELPER(tsv)(CPUHPPAState *env, target_ureg cond) { if (unlikely((target_sreg)cond < 0)) { - dynexcp(env, EXCP_OVERFLOW, GETPC()); + hppa_dynamic_excp(env, EXCP_OVERFLOW, GETPC()); } } void HELPER(tcond)(CPUHPPAState *env, target_ureg cond) { if (unlikely(cond)) { - dynexcp(env, EXCP_COND, GETPC()); + hppa_dynamic_excp(env, EXCP_COND, GETPC()); } } @@ -237,7 +237,7 @@ static void update_fr0_op(CPUHPPAState *env, uintptr_t ra) env->fr[0] = (uint64_t)shadow << 32; if (hard_exp & shadow) { - dynexcp(env, EXCP_ASSIST, ra); + hppa_dynamic_excp(env, EXCP_ASSIST, ra); } } @@ -645,7 +645,7 @@ target_ureg HELPER(swap_system_mask)(CPUHPPAState *env, target_ureg nsm) /* ??? On second reading this condition simply seems to be undefined rather than a diagnosed trap. */ if (nsm & ~psw & PSW_Q) { - dynexcp(env, EXCP_ILL, GETPC()); + hppa_dynamic_excp(env, EXCP_ILL, GETPC()); } env->psw = (psw & ~PSW_SM) | (nsm & PSW_SM); return psw & PSW_SM; diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 3d441ef4ac..082221f450 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -2433,6 +2433,35 @@ static DisasJumpType trans_pxtlbx(DisasContext *ctx, uint32_t insn, return nullify_end(ctx, !is_data && (ctx->base.tb->flags & PSW_C) ? DISAS_IAQ_N_STALE : DISAS_NEXT); } + +static DisasJumpType trans_lpa(DisasContext *ctx, uint32_t insn, + const DisasInsn *di) +{ + unsigned rt = extract32(insn, 0, 5); + unsigned m = extract32(insn, 5, 1); + unsigned sp = extract32(insn, 14, 2); + unsigned rx = extract32(insn, 16, 5); + unsigned rb = extract32(insn, 21, 5); + TCGv_tl vaddr; + TCGv_reg ofs, paddr; + + CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR); + nullify_over(ctx); + + form_gva(ctx, &vaddr, &ofs, rb, rx, 0, 0, sp, m, false); + + paddr = tcg_temp_new(); + gen_helper_lpa(paddr, cpu_env, vaddr); + + /* Note that physical address result overrides base modification. */ + if (m) { + save_gpr(ctx, rb, ofs); + } + save_gpr(ctx, rt, paddr); + tcg_temp_free(paddr); + + return nullify_end(ctx, DISAS_NEXT); +} #endif /* !CONFIG_USER_ONLY */ static const DisasInsn table_mem_mgmt[] = { @@ -2460,6 +2489,7 @@ static const DisasInsn table_mem_mgmt[] = { { 0x04000240u, 0xfc001fdfu, trans_pxtlbx }, /* pitlbe */ { 0x04001200u, 0xfc001fdfu, trans_pxtlbx }, /* pdtlb */ { 0x04001240u, 0xfc001fdfu, trans_pxtlbx }, /* pdtlbe */ + { 0x04001340u, 0xfc003fc0u, trans_lpa }, #endif };