From patchwork Mon Aug 31 16:06:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 248820 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp3463507ilg; Mon, 31 Aug 2020 09:36:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz58CqLDDmO/rK902BeSqoQn2nhK7M70OZj9VL5Kcaa+h3LJ195PAENKIMYtSOL+KZIxOXg X-Received: by 2002:a25:e80e:: with SMTP id k14mr3799522ybd.16.1598891806336; Mon, 31 Aug 2020 09:36:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598891806; cv=none; d=google.com; s=arc-20160816; b=Lsv9c2vp/oNGY9Coxr6sdye2aVD2o8whYR3UouK7vMMs380zV4+Grkrdydr+Fd+l1n AcGGQRBym8ssCKRmBcwrMSJKjHEoETBYKPzPPG4Sw9AFbocKlh2hKWFun4u/kmLgJB/l 4/dlPa5dRGiAf3DOQUaIuPoRv5WW/e0jLcXEhgZ5M1DLtpZqwOD+3ABrGqVSjZ34L3iJ gpJ/69yUqvGzQFtyWuTbfxHOHNd/z5FEVHHKZpmMnTQsSQk67+f2oPdiAfVDo1ffKpvX aKcpy5d8v9F+rYn975RkfV/KudBRi9t+AWPQhBmTHSeTfi0UYkMiBMj7J7ivEdyHbE4S YbXg== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=1WdUOJWGCdcV9QIGGOS0y70LT85NGsncqmvGoqTi8AE=; b=JwxjJFaZTxdoU7LGa6qAprwy9aAGvIdELScH/B5VesrOzdzwrHAy6bW7KqrAHIHG3w cJQ3HBCs8H109nnp3awVGUyiPW3XJyUph+YzIcaFfOmI+g4h67CZiVk3nHOzV9UtW1BP Rpo4kpTMlaHgxPWTKOdEQZz79f2YQXLKirLLDl0d0cVFmwFsvSXEnovc0/O5lTHruR/k vopN2wgby3sL8loeTcLdBLb6MY9oEXyUv8o8ihwTHYj6lLSBF8C3p5yRrAhDx+6UF2Y6 UMSRaRVYiG0/zI0lNe7GQD3NvNNKvsuSpeg+hGKLJjGpZvfbL4hwH9osET8bfPFTy7Ty l3+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=e69b8CsJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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. [209.51.188.17]) by mx.google.com with ESMTPS id t4si993865ybi.422.2020.08.31.09.36.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 31 Aug 2020 09:36:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=e69b8CsJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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]:36728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCmnV-0007PF-Q5 for patch@linaro.org; Mon, 31 Aug 2020 12:36:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCmLW-00072n-Mx for qemu-devel@nongnu.org; Mon, 31 Aug 2020 12:07:50 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:34142) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kCmLU-0006CK-OU for qemu-devel@nongnu.org; Mon, 31 Aug 2020 12:07:50 -0400 Received: by mail-pg1-x544.google.com with SMTP id i10so846115pgk.1 for ; Mon, 31 Aug 2020 09:07:48 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=1WdUOJWGCdcV9QIGGOS0y70LT85NGsncqmvGoqTi8AE=; b=e69b8CsJeYkWnBKvekJVHEOqMk9y1E4fM/sL+A12hFC5kyXMEE4NYTB9HkSwooL6Z1 tuIJCTBcW9Fn6CF1UGzNux4+Q/kpIcCjBW0025jOvaepFCcRdpnuDsh8/asu0GrEj+Zx CjW6ji916SXGhWbeHNjoQLdICCwiNcSRVrI7WJmtJeOb8/yeKu0V8EeRTlX2fRv/aU3P GjC4kfEMqWK/f/reTysvW86vO1n7PJ0sLRUGOdzCppqiLBWZRbYR2lSB7GYvxurAqKQ4 IYWCWsI2YI+QesbKQkCRdiV4g3u3vPdWJqignyDN9nCS0jYrNiBYoWpzl4882ji7bDkS G+XQ== 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:mime-version:content-transfer-encoding; bh=1WdUOJWGCdcV9QIGGOS0y70LT85NGsncqmvGoqTi8AE=; b=OoDKvVwxZt5PukGYZMMWA7E0RI16UHW4swXM+VovC2pHcOQNxGIYoIIAXOPjsDPwfq fMGerLys+PvZ7Bv3Ao3qcraMvHkV66HzDDQcyW5btw6IYzfRNBIJ8uG57vKh5oHVGG8r gxFXAj4rixH/zJ/5ZDduCpnAqDfJ4WeLcSCM/mLaAzc6XMKpZ0NdQdMrE2uIv0Q7NuHN sThQ8CG5K8pFj9y+yLvumFr/CvILSDsFyhFht4chUH4jvIEOqnBMsOoxPaNeCsAvMv/n t6ssf/DMF/uLTCSUcpYCC8tGLnV/LGYR8AX9iMdKP3kaovJoko77Dy3XX8Gwy1tQtT90 eMjA== X-Gm-Message-State: AOAM532lPc5eQgWuXdmCx8reWTLbRaTH54jBY3pK4K43uh/FV3wJL3O4 pRYYNqHW+lb+//xKc+x7XtWtYzcHWGXGxA== X-Received: by 2002:a65:6882:: with SMTP id e2mr1803507pgt.290.1598890065867; Mon, 31 Aug 2020 09:07:45 -0700 (PDT) Received: from localhost.localdomain ([71.212.141.89]) by smtp.gmail.com with ESMTPSA id gt13sm17218pjb.43.2020.08.31.09.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2020 09:07:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 76/76] target/microblaze: Reduce linux-user address space to 32-bit Date: Mon, 31 Aug 2020 09:06:01 -0700 Message-Id: <20200831160601.833692-77-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200831160601.833692-1-richard.henderson@linaro.org> References: <20200831160601.833692-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::544; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x544.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Edgar E . Iglesias" , peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" User-space programs cannot use the 64-bit lwea/swea instructions. We can improve code generation and runtime by restricting the user-only address space to 32-bit. Tested-by: Edgar E. Iglesias Reviewed-by: Edgar E. Iglesias Signed-off-by: Richard Henderson --- target/microblaze/cpu-param.h | 15 +++++++++++++++ target/microblaze/cpu.h | 2 +- target/microblaze/helper.c | 4 ++-- target/microblaze/translate.c | 28 +++++++++++++++++++++++++++- 4 files changed, 45 insertions(+), 4 deletions(-) -- 2.25.1 diff --git a/target/microblaze/cpu-param.h b/target/microblaze/cpu-param.h index 4abbc62d50..4d8297fa94 100644 --- a/target/microblaze/cpu-param.h +++ b/target/microblaze/cpu-param.h @@ -8,9 +8,24 @@ #ifndef MICROBLAZE_CPU_PARAM_H #define MICROBLAZE_CPU_PARAM_H 1 +/* + * While system mode can address up to 64 bits of address space, + * this is done via the lea/sea instructions, which are system-only + * (as they also bypass the mmu). + * + * We can improve the user-only experience by only exposing 32 bits + * of address space. + */ +#ifdef CONFIG_USER_ONLY +#define TARGET_LONG_BITS 32 +#define TARGET_PHYS_ADDR_SPACE_BITS 32 +#define TARGET_VIRT_ADDR_SPACE_BITS 32 +#else #define TARGET_LONG_BITS 64 #define TARGET_PHYS_ADDR_SPACE_BITS 64 #define TARGET_VIRT_ADDR_SPACE_BITS 64 +#endif + /* FIXME: MB uses variable pages down to 1K but linux only uses 4k. */ #define TARGET_PAGE_BITS 12 #define NB_MMU_MODES 3 diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h index 4298f242a6..d11b6fa995 100644 --- a/target/microblaze/cpu.h +++ b/target/microblaze/cpu.h @@ -242,7 +242,7 @@ struct CPUMBState { uint32_t pc; uint32_t msr; /* All bits of MSR except MSR[C] and MSR[CC] */ uint32_t msr_c; /* MSR[C], in low bit; other bits must be 0 */ - uint64_t ear; + target_ulong ear; uint32_t esr; uint32_t fsr; uint32_t btr; diff --git a/target/microblaze/helper.c b/target/microblaze/helper.c index 1667822fb7..48547385b0 100644 --- a/target/microblaze/helper.c +++ b/target/microblaze/helper.c @@ -303,8 +303,8 @@ void mb_cpu_do_unaligned_access(CPUState *cs, vaddr addr, iflags = cpu->env.iflags; qemu_log_mask(CPU_LOG_INT, - "Unaligned access addr=" TARGET_FMT_lx - " pc=%x iflags=%x\n", addr, cpu->env.pc, iflags); + "Unaligned access addr=" TARGET_FMT_lx " pc=%x iflags=%x\n", + (target_ulong)addr, cpu->env.pc, iflags); esr = ESR_EC_UNALIGNED_DATA; if (likely(iflags & ESR_ESS_FLAG)) { diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 8c287457a9..a377818b5e 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -687,6 +687,7 @@ static TCGv compute_ldst_addr_typeb(DisasContext *dc, int ra, int imm) return ret; } +#ifndef CONFIG_USER_ONLY static TCGv compute_ldst_addr_ea(DisasContext *dc, int ra, int rb) { int addr_size = dc->cpu->cfg.addr_size; @@ -712,6 +713,7 @@ static TCGv compute_ldst_addr_ea(DisasContext *dc, int ra, int rb) } return ret; } +#endif static void record_unaligned_ess(DisasContext *dc, int rd, MemOp size, bool store) @@ -776,8 +778,12 @@ static bool trans_lbuea(DisasContext *dc, arg_typea *arg) if (trap_userspace(dc, true)) { return true; } +#ifdef CONFIG_USER_ONLY + return true; +#else TCGv addr = compute_ldst_addr_ea(dc, arg->ra, arg->rb); return do_load(dc, arg->rd, addr, MO_UB, MMU_NOMMU_IDX, false); +#endif } static bool trans_lbui(DisasContext *dc, arg_typeb *arg) @@ -803,8 +809,12 @@ static bool trans_lhuea(DisasContext *dc, arg_typea *arg) if (trap_userspace(dc, true)) { return true; } +#ifdef CONFIG_USER_ONLY + return true; +#else TCGv addr = compute_ldst_addr_ea(dc, arg->ra, arg->rb); return do_load(dc, arg->rd, addr, MO_TEUW, MMU_NOMMU_IDX, false); +#endif } static bool trans_lhui(DisasContext *dc, arg_typeb *arg) @@ -830,8 +840,12 @@ static bool trans_lwea(DisasContext *dc, arg_typea *arg) if (trap_userspace(dc, true)) { return true; } +#ifdef CONFIG_USER_ONLY + return true; +#else TCGv addr = compute_ldst_addr_ea(dc, arg->ra, arg->rb); return do_load(dc, arg->rd, addr, MO_TEUL, MMU_NOMMU_IDX, false); +#endif } static bool trans_lwi(DisasContext *dc, arg_typeb *arg) @@ -910,8 +924,12 @@ static bool trans_sbea(DisasContext *dc, arg_typea *arg) if (trap_userspace(dc, true)) { return true; } +#ifdef CONFIG_USER_ONLY + return true; +#else TCGv addr = compute_ldst_addr_ea(dc, arg->ra, arg->rb); return do_store(dc, arg->rd, addr, MO_UB, MMU_NOMMU_IDX, false); +#endif } static bool trans_sbi(DisasContext *dc, arg_typeb *arg) @@ -937,8 +955,12 @@ static bool trans_shea(DisasContext *dc, arg_typea *arg) if (trap_userspace(dc, true)) { return true; } +#ifdef CONFIG_USER_ONLY + return true; +#else TCGv addr = compute_ldst_addr_ea(dc, arg->ra, arg->rb); return do_store(dc, arg->rd, addr, MO_TEUW, MMU_NOMMU_IDX, false); +#endif } static bool trans_shi(DisasContext *dc, arg_typeb *arg) @@ -964,8 +986,12 @@ static bool trans_swea(DisasContext *dc, arg_typea *arg) if (trap_userspace(dc, true)) { return true; } +#ifdef CONFIG_USER_ONLY + return true; +#else TCGv addr = compute_ldst_addr_ea(dc, arg->ra, arg->rb); return do_store(dc, arg->rd, addr, MO_TEUL, MMU_NOMMU_IDX, false); +#endif } static bool trans_swi(DisasContext *dc, arg_typeb *arg) @@ -1818,7 +1844,7 @@ void mb_cpu_dump_state(CPUState *cs, FILE *f, int flags) } qemu_fprintf(f, "\nesr=0x%04x fsr=0x%02x btr=0x%08x edr=0x%x\n" - "ear=0x%016" PRIx64 " slr=0x%x shr=0x%x\n", + "ear=0x" TARGET_FMT_lx " slr=0x%x shr=0x%x\n", env->esr, env->fsr, env->btr, env->edr, env->ear, env->slr, env->shr);