From patchwork Mon Jan 22 03:41:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 125316 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp949409ljf; Sun, 21 Jan 2018 20:04:43 -0800 (PST) X-Google-Smtp-Source: AH8x224OcWCOma54fR473ARFC2qKIXh9/dv/7juqBMd82KTaUpPuJGPwQDpj8NcarWJDCSDVGiCs X-Received: by 10.37.184.20 with SMTP id v20mr6085197ybj.139.1516593883832; Sun, 21 Jan 2018 20:04:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516593883; cv=none; d=google.com; s=arc-20160816; b=Be2kjZHbMMj9IU2K9o/kaZJ+vvUI0H5bFUFbm1Fc021SrrgQC4gHrV9j87xar3BMit PFNFD8qVTbEHAqlDptpoSYuA++AnEe5DAfdxSEUyzrVBv/uEaLlEB3DyCm4RzuYlDObQ o9VumBIGiiRE1T2dwvKo13B7lMCFD8CrEGfbW/wf92CBL9CfIf4DAmd8ylHPuILE0Qkk Qh7Rl+c7Y9ZrI6TM73G+gff/3cp8St6WRuL7Lwv8zt9lJmIvoAKEUiOsRVgdISi5D0RJ Hp0aGdcGcnEeFamvGbyEMOHbHfNh+5TuVcasoEDwLb7ZwAz3zBfSKa4palg4K+z6zrAl T4mg== 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=xE/Zv2DUrJBEt+P7UQ3XeDRFqVWiz2CLnQgNWEowR+U=; b=LR1Xu53ExYznR9jjzh0PSq/X3qqL9p+Sp9tkVbcqYyrwPAOKU1Gh7I4j7WTe+ZpRRS i5yPR9s5PHlV2vY+3ZCzRepYD5p4Oc8Ft0OQjYyleq8vzYJ1RCoRAKQFYhKSdoUqKpN5 Z4/FlDDkohKw+UUk6xICLdPLYwGBM3FIN3b/bKpDHSP8xe3UaBWONFRtpCeJkMRPmGRV 5lmWJWuAjt4NcL2Rrraqh1Zc099fa5iDXueIrK079/RjMcvG9cwp6blHHBHmuOeaMok/ BaXYz5k7WXT+s4MdtmB6IBMP1yZaMDsnDhl6Y+k6pJC1IvIgACNzr/abl8pMItp/dhjI XRmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VeeBgLjI; 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 i138si3423947ywc.180.2018.01.21.20.04.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 21 Jan 2018 20:04:43 -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=VeeBgLjI; 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]:41760 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edTLf-0005Bt-72 for patch@linaro.org; Sun, 21 Jan 2018 23:04:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edT0e-0005lr-Qs for qemu-devel@nongnu.org; Sun, 21 Jan 2018 22:43:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1edT0a-0006cO-6t for qemu-devel@nongnu.org; Sun, 21 Jan 2018 22:43:00 -0500 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:35398) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1edT0Z-0006by-V4 for qemu-devel@nongnu.org; Sun, 21 Jan 2018 22:42:56 -0500 Received: by mail-pf0-x243.google.com with SMTP id t12so6084412pfg.2 for ; Sun, 21 Jan 2018 19:42:55 -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=xE/Zv2DUrJBEt+P7UQ3XeDRFqVWiz2CLnQgNWEowR+U=; b=VeeBgLjITKUpI3p1rEAhwp0N5ZMnfZZ5wysixxu9e0EUn3gjSVdcdHQW+EBQP8qpen cKKNxFZJjAwYGbRYdk4z/7LGwADYaEfykvgFruqUF1uq4cLHG6x5a0C6tsWXHW7mJLFu Y8lu6AH21ohsBdc7YYvtXx5VyvyGE8HvXNznw= 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=xE/Zv2DUrJBEt+P7UQ3XeDRFqVWiz2CLnQgNWEowR+U=; b=DXqmC5yiR8YSZmNqSzVBqZfvDSAgxGba6niSWcnyG72fP8TQAyyy2kqLQAGAHrkvxL S1sEr2BfCGd/bTGOoLLlynA4ztlrvtW2x0GMrFowLDnzXrAXq8/98U3G4meM+/hbkN/2 LYOdhudmTJMlalHRry00kAF4PfxLwaWuceBJ26P2ScWK9KpuwwtqDcgCQ75DSNshMxKI YMdC+srSEJdPMII41WeRy7uGt4fIFnxhoqOo8Ntpv2UCyUDjiILGbC9pC1qeVlC1oXoo e1osuOKrJ/xNLp1Bu4eBJOwFEEAGW8hcr2UeQ5mKpaplTChOLTMXRJqYoRr9ViS5ksuA HYFw== X-Gm-Message-State: AKwxyteO33oBK+vGqM43UC768FpE+22ZfDV00IpMTBr0hKuq+LBo9Y0m aj4w03l1SvN/7SlyygfV7xvCQaAmpXI= X-Received: by 10.101.86.201 with SMTP id w9mr6046439pgs.434.1516592574669; Sun, 21 Jan 2018 19:42:54 -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 z125sm182023pfz.27.2018.01.21.19.42.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 21 Jan 2018 19:42:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 21 Jan 2018 19:41:58 -0800 Message-Id: <20180122034217.19593-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180122034217.19593-1-richard.henderson@linaro.org> References: <20180122034217.19593-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::243 Subject: [Qemu-devel] [PULL 24/43] 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: , 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/cpu.h | 1 + target/hppa/helper.h | 1 + target/hppa/mem_helper.c | 13 +++++++++++++ target/hppa/op_helper.c | 10 +++++----- target/hppa/translate.c | 30 ++++++++++++++++++++++++++++++ 5 files changed, 50 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 b5e2e35908..9d93894019 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -305,4 +305,17 @@ 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 == EXCP_DTLB_MISS) { + hppa_dynamic_excp(env, EXCP_NA_DTLB_MISS, 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 5b49cc5332..bbef2f0d7f 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -2422,6 +2422,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[] = { @@ -2449,6 +2478,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 };