From patchwork Sun Jan 28 23:15:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 126105 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp1981191ljd; Sun, 28 Jan 2018 15:30:36 -0800 (PST) X-Google-Smtp-Source: AH8x226UHQapzi3Q9DLD8fW25z7ZfYcQVQ/0PAm6q3KKnMeZBLiZKSrWst2JP1agdodyGhiJicoZ X-Received: by 10.37.22.195 with SMTP id 186mr15766346ybw.300.1517182236026; Sun, 28 Jan 2018 15:30:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517182236; cv=none; d=google.com; s=arc-20160816; b=dDx7UqnDWan5oBALi3ncxihZdP6x72x5wlLHbMfVabwdFSDJiRbcu5vR6mmkjSdEm6 riyFEkdweDNmvc2vo7gycI54hEmRK2D+aDuehho2FOClRM0iu7x9jnxKjeHix4aOu3H8 On3scJBw1WStxF+wd73Dw+CYkhIuU0ElpDXDSJmvTx5OWJqkQpeGhbMtn8CrKHrPYtu0 D1YMrcGSQZf9iDgbUUc9EjQ+yLL+/325CnVAw9hGyl7DyeexLytjYiI7bBNDQwNf484/ r441vVv4H5u7Fer9gBLI55EfbVJatJnCkiH2NMkYwb/Ne0y8TqddAlS9ZSsZKqEoTh0n /3Iw== 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=uRSridC6lGQHsnPszcui7oa0KrUirpIsSP8OmInKgJQ=; b=E3WJmJ8UTf8dHdcqF8MaFAd3QpwxYpWfnqqod85KIfaGF5E579PaxVdzL47rtwVDLo 32ONvF7bHjDGhg0WczxrRXtEBDC3EgpW3oX+feufO35RVF126SlgIALPozZUgctvjF1s zDYCXZvUQgLrT/DzH52RShrG9yGLWYa+bCNwO565nx0coTBCjBXw6gXQhf+Y7zDZsQHz 7qtZDq8fHyzqSlXfWqHPQLnlGLn8V+ap+4QRXwYEdPWejD6tNLKvQQhQXVewSEFvcqmK v18PembFVn883OzjjUIBBwF3PF9363/V4UM3fEXX1Bx9lDKq+GR2kmcVX/3/u0QdtBXS 7kNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WtHmQBSh; 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 w3si1828675ywl.507.2018.01.28.15.30.35 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 28 Jan 2018 15:30:36 -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=WtHmQBSh; 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]:45000 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efwPD-000597-9M for patch@linaro.org; Sun, 28 Jan 2018 18:30:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52204) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1efwBI-0002xZ-2x for qemu-devel@nongnu.org; Sun, 28 Jan 2018 18:16:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1efwBG-000094-11 for qemu-devel@nongnu.org; Sun, 28 Jan 2018 18:16:12 -0500 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:40456) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1efwBF-00008U-Oh for qemu-devel@nongnu.org; Sun, 28 Jan 2018 18:16:09 -0500 Received: by mail-pg0-x242.google.com with SMTP id g16so3004332pgn.7 for ; Sun, 28 Jan 2018 15:16:09 -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=uRSridC6lGQHsnPszcui7oa0KrUirpIsSP8OmInKgJQ=; b=WtHmQBSh66IlYYSWOA+Ta7n8+fqOT7BdrN/ASO2te4dWgUQX4fULVbdC1K1F3I1wl/ hAzLKZedNt58F8ecMAXUs/mENGWfIt4qeYPANjdW/vqZqh/u3VucPwsDvkU4BqMptF1N uUQlzgyyl6MBtQIrEPl5lecou3Ft/4VcVO5g4= 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=uRSridC6lGQHsnPszcui7oa0KrUirpIsSP8OmInKgJQ=; b=EMu0NGnQBGzlPAAAnNZReQb7h1EKmbkM2H0FaSH0UcnGpeRoHO9flvfFkjCCu/1mLk k+ygDonEQn2PtPn4AXC3yfZ7rxuL1gD9E29Uln+DNzZwSkcgnMBL5Y7qOEBeW4dXz5k3 92XnTv0XpzBINcwq75vTw73rldS+6nyJb5j2KH94s4kGImNG7jn9K82hx1Uw9ZyGeY4G 4MTt3BVf2W6PKZVwPM/1wYDGDg9SOvdpqj9lQAo/9lky4n1kytJdd4esSe067/NLpafE DgmgFK56pCu3lOV+cVIOPTYpFphmJW3QUgdQ194kIeVbZhl25ZMstpGyWSob8QByhzr+ fOBQ== X-Gm-Message-State: AKwxytfwvyfN7jyEbCzD9FTonExfNSen6WqnwyM/h7B5uyogMwl5REzw VOY/bj9RTdnToMfEmAqDybISoZNL720= X-Received: by 10.98.174.8 with SMTP id q8mr25041352pff.109.1517181368493; Sun, 28 Jan 2018 15:16:08 -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.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Jan 2018 15:16:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 28 Jan 2018 15:15:09 -0800 Message-Id: <20180128231528.22719-25-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:c05::242 Subject: [Qemu-devel] [PULL v4 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 | 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 3782e1d834..54f11d4e18 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -345,5 +345,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 df245533e4..c2b2705869 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -314,4 +314,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, 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 phys; +} #endif /* CONFIG_USER_ONLY */ diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index 8c546f4882..ef2951386c 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 };