From patchwork Tue Apr 27 22:06:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Baturo X-Patchwork-Id: 12227631 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30EE4C433B4 for ; Tue, 27 Apr 2021 22:08:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 97ABF613BC for ; Tue, 27 Apr 2021 22:08:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 97ABF613BC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lbVsd-0007pg-Jj for qemu-devel@archiver.kernel.org; Tue, 27 Apr 2021 18:08:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57132) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbVqc-0006CK-P2; Tue, 27 Apr 2021 18:06:26 -0400 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]:45650) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lbVqa-0002fo-Tt; Tue, 27 Apr 2021 18:06:26 -0400 Received: by mail-ej1-x634.google.com with SMTP id u3so12942801eja.12; Tue, 27 Apr 2021 15:06:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5NCSBeXLLnQxRcsQBmTOFrJe1uMeKwEpgQvj+fl82v4=; b=T7kheJnPdbKDifHgaaQzgvOqGLXk85WkeUWZJhwG/efnfcoIy+8qZNpcuXD9a+y9ig 0frhqhEbBu9ThXRbkFVx+3MGoCCKV5wpfdqLfnKL0u9B2duJ4vBbtXmH+LfoWSbF2inm 9/MXMrsGDL7tj8drg6wBWT4YLLfAD+JQD5FDsyYvWGxv2lbYrVZU6RyJDUs0xfBKyA5I PABOQFvEB/52WXQ2r7MHXj7HSP/7Q10H7DeflfZnF/ZBQP0grxrqlh6gT4SYDKhyMSMq COmyBVCEu6NBh9mde2L757ZID1aIGcHloCyvf/9XoJ8temt3RzbTe5tm9NiTCpBo7lIE j04g== 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=5NCSBeXLLnQxRcsQBmTOFrJe1uMeKwEpgQvj+fl82v4=; b=QDvCKzraoAqPjlL3B6YVE6tlywDrGl4n6h6PHO3buyh0raRBWavYs4YAq4X7AgnlhE VJGl8687Fa9bttlUXmjfqGp1KgtH3Sek6bypF9dIUWgCxHgg3xx2ciEUsfsML4LGtYf5 szubmnbppCFUN6SGLJ7gIQmrhq6zvhV3VHq6/Xm5FtfjhduynsAnrXoErZUZeL43QCtf CjpbAb3en9ZjtRqa3f8HHRg8Q/QRdIhwdedKud4BkQ++To8lzK/y76AQOuvIQ7ydGu1H Q8CbNaSBbH5OK7lnGuCMGRNL3ksxmZ0PhlxWPdkKC0njEyzx0R6ExQFcfd5HG9sHpWcE AUyg== X-Gm-Message-State: AOAM53263TqxG2NnOt3pPS2/X+iZtUg+UXYQCplCsJKKTV0JOd/S1CGn de6fIEjVzpMCR7QqO9Qyus0= X-Google-Smtp-Source: ABdhPJzdXCNd/+mJpq6azZaoTiXfNFjKiVVVhR+yDMH7izvMi6ICOjaqUW/8fX8IoXa6dZP3S8Z5Lw== X-Received: by 2002:a17:907:397:: with SMTP id ss23mr8255581ejb.298.1619561182391; Tue, 27 Apr 2021 15:06:22 -0700 (PDT) Received: from neptune.lab ([46.39.228.82]) by smtp.googlemail.com with ESMTPSA id r10sm640049ejd.112.2021.04.27.15.06.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 15:06:22 -0700 (PDT) From: Alexey Baturo X-Google-Original-From: Alexey Baturo To: Subject: [PATCH v8 1/6] [RISCV_PM] Add J-extension into RISC-V Date: Wed, 28 Apr 2021 01:06:10 +0300 Message-Id: <20210427220615.12763-2-space.monkey.delivers@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210427220615.12763-1-space.monkey.delivers@gmail.com> References: <20210427220615.12763-1-space.monkey.delivers@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=baturo.alexey@gmail.com; helo=mail-ej1-x634.google.com 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, FREEMAIL_FROM=0.001, 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: baturo.alexey@gmail.com, qemu-riscv@nongnu.org, sagark@eecs.berkeley.edu, kbastian@mail.uni-paderborn.de, richard.henderson@linaro.org, qemu-devel@nongnu.org, space.monkey.delivers@gmail.com, Alistair Francis , kupokupokupopo@gmail.com, palmer@dabbelt.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alexey Baturo Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- target/riscv/cpu.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 0a33d387ba..0ea9fc65c8 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -72,6 +72,7 @@ #define RVS RV('S') #define RVU RV('U') #define RVH RV('H') +#define RVJ RV('J') /* S extension denotes that Supervisor mode exists, however it is possible to have a core that support S mode but does not have an MMU and there @@ -291,6 +292,7 @@ struct RISCVCPU { bool ext_s; bool ext_u; bool ext_h; + bool ext_j; bool ext_v; bool ext_counters; bool ext_ifencei; From patchwork Tue Apr 27 22:06:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Baturo X-Patchwork-Id: 12227643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E827C433ED for ; Tue, 27 Apr 2021 22:13:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A57C661059 for ; Tue, 27 Apr 2021 22:13:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A57C661059 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lbVxZ-0004NN-RQ for qemu-devel@archiver.kernel.org; Tue, 27 Apr 2021 18:13:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57172) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbVqf-0006ES-81; Tue, 27 Apr 2021 18:06:29 -0400 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]:41539) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lbVqb-0002fz-44; Tue, 27 Apr 2021 18:06:28 -0400 Received: by mail-ej1-x630.google.com with SMTP id zg3so10018362ejb.8; Tue, 27 Apr 2021 15:06:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JwQyQ3gZyShSB1dmjFj5bxruG1VO4p2x3DRdXWSoaLs=; b=WSPFc4tWBbu3NidHNhGqbfjn1rCwKTXoa+SbzSA8bOyxcL8pbAsM6R6Gt+VoI6HMl8 sxJlp5RmMAQ43iNi/6QSLc7tPlKo/Su29lMtQi/EdFeNUYZuHxamRvtbkF8DPcGyVN8B T2rYMUPQLgh/qCuBt1a0AxZFi7FYamnAFF+Jep7QI/rq1hBed2K0TKOdX6Wos6X452ok e62W2X/nke9hIOPAHll53DLzlrHIPNcSMlfmCo7+ujOMAyaduFgIurNf9VfL1vT5HB+7 sSOmmO0dgsMzvMP7yQ4auiNhsQ1ay0fRsshX7Mx254p+sm+fOdqQ+KKiSANs/SYjS/p2 LCPQ== 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=JwQyQ3gZyShSB1dmjFj5bxruG1VO4p2x3DRdXWSoaLs=; b=oj5AGSKwOd+2o63cAlL4xjdpcmimwRAHgKb5icaEgffRMgxVsnIYNbLCy5CuuPBbUc gWalXMW/Ay6V6UiPG/b0xSVAxt7sCU4oPhkuWl7uSLzkcZXt0nzuwONTtVt/QcMX4c+l oVk4YN0ytowaq+nfIy5jViNgwdVFCZhBvdA5LBsoe7f7Sv4z2w3tqCHvItzm6y8p/qdI lHWJS6l958VwZ96GHjlSQqr0Gb97YyhjfpIv/MydnS5Z0pHJc1njlrxZ2AoYN7oVCIQO iXCwdIkAf3SlDwB6at2Soo+zz1zT8kEn9RhT1mcSpTNJ4G06PODLZXmrdmuObzROkpci OLWg== X-Gm-Message-State: AOAM533ER7uKLu+8Aany4OsVDGz8Xjhx0uXEf36NEL3F4gqUQCzZY4s6 WJu4uX/YUO/YkPzsgu7sshU= X-Google-Smtp-Source: ABdhPJxEBzv3shbrUyFfYCgAmyZI8ZDaJ/uxnn3rOPR2TqUK4sa4hTaA6Wj7JtwHDwZpEhdPl7WIpg== X-Received: by 2002:a17:906:1114:: with SMTP id h20mr25999832eja.453.1619561183422; Tue, 27 Apr 2021 15:06:23 -0700 (PDT) Received: from neptune.lab ([46.39.228.82]) by smtp.googlemail.com with ESMTPSA id r10sm640049ejd.112.2021.04.27.15.06.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 15:06:23 -0700 (PDT) From: Alexey Baturo X-Google-Original-From: Alexey Baturo To: Subject: [PATCH v8 2/6] [RISCV_PM] Support CSRs required for RISC-V PM extension except for the h-mode Date: Wed, 28 Apr 2021 01:06:11 +0300 Message-Id: <20210427220615.12763-3-space.monkey.delivers@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210427220615.12763-1-space.monkey.delivers@gmail.com> References: <20210427220615.12763-1-space.monkey.delivers@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::630; envelope-from=baturo.alexey@gmail.com; helo=mail-ej1-x630.google.com 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, FREEMAIL_FROM=0.001, 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: baturo.alexey@gmail.com, qemu-riscv@nongnu.org, sagark@eecs.berkeley.edu, kbastian@mail.uni-paderborn.de, richard.henderson@linaro.org, qemu-devel@nongnu.org, space.monkey.delivers@gmail.com, Alistair.Francis@wdc.com, kupokupokupopo@gmail.com, palmer@dabbelt.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alexey Baturo --- target/riscv/cpu.c | 5 + target/riscv/cpu.h | 12 ++ target/riscv/cpu_bits.h | 66 +++++++++++ target/riscv/csr.c | 239 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 322 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 7d6ed80f6b..c04911ec05 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -473,6 +473,11 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) if (cpu->cfg.ext_h) { target_misa |= RVH; } + if (cpu->cfg.ext_j) { +#ifndef CONFIG_USER_ONLY + env->mmte |= PM_EXT_INITIAL; +#endif + } if (cpu->cfg.ext_v) { target_misa |= RVV; if (!is_power_of_2(cpu->cfg.vlen)) { diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 0ea9fc65c8..19aa3b4769 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -238,6 +238,18 @@ struct CPURISCVState { /* True if in debugger mode. */ bool debugger; + + /* + * CSRs for PM + * TODO: move these csr to appropriate groups + */ + target_ulong mmte; + target_ulong mpmmask; + target_ulong mpmbase; + target_ulong spmmask; + target_ulong spmbase; + target_ulong upmmask; + target_ulong upmbase; #endif float_status fp_status; diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index caf4599207..f8e7cdb99b 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -354,6 +354,21 @@ #define CSR_MHPMCOUNTER30H 0xb9e #define CSR_MHPMCOUNTER31H 0xb9f +/* Custom user register */ +#define CSR_UMTE 0x8c0 +#define CSR_UPMMASK 0x8c1 +#define CSR_UPMBASE 0x8c2 + +/* Custom machine register */ +#define CSR_MMTE 0x7c0 +#define CSR_MPMMASK 0x7c1 +#define CSR_MPMBASE 0x7c2 + +/* Custom supervisor register */ +#define CSR_SMTE 0x9c0 +#define CSR_SPMMASK 0x9c1 +#define CSR_SPMBASE 0x9c2 + /* Legacy Machine Protection and Translation (priv v1.9.1) */ #define CSR_MBASE 0x380 #define CSR_MBOUND 0x381 @@ -592,4 +607,55 @@ #define MIE_UTIE (1 << IRQ_U_TIMER) #define MIE_SSIE (1 << IRQ_S_SOFT) #define MIE_USIE (1 << IRQ_U_SOFT) + +/* general mte CSR bits*/ +#define PM_ENABLE 0x00000001ULL +#define PM_CURRENT 0x00000002ULL +#define PM_XS_MASK 0x00000003ULL + +/* PM XS bits values */ +#define PM_EXT_DISABLE 0x00000000ULL +#define PM_EXT_INITIAL 0x00000001ULL +#define PM_EXT_CLEAN 0x00000002ULL +#define PM_EXT_DIRTY 0x00000003ULL + +/* offsets for every pair of control bits per each priv level */ +#define XS_OFFSET 0ULL +#define U_OFFSET 2ULL +#define S_OFFSET 4ULL +#define M_OFFSET 6ULL + +#define PM_XS_BITS (PM_XS_MASK << XS_OFFSET) +#define U_PM_ENABLE (PM_ENABLE << U_OFFSET) +#define U_PM_CURRENT (PM_CURRENT << U_OFFSET) +#define S_PM_ENABLE (PM_ENABLE << S_OFFSET) +#define S_PM_CURRENT (PM_CURRENT << S_OFFSET) +#define M_PM_ENABLE (PM_ENABLE << M_OFFSET) + +/* mmte CSR bits */ +#define MMTE_PM_XS_BITS PM_XS_BITS +#define MMTE_U_PM_ENABLE U_PM_ENABLE +#define MMTE_U_PM_CURRENT U_PM_CURRENT +#define MMTE_S_PM_ENABLE S_PM_ENABLE +#define MMTE_S_PM_CURRENT S_PM_CURRENT +#define MMTE_M_PM_ENABLE M_PM_ENABLE +#define MMTE_MASK (MMTE_U_PM_ENABLE | MMTE_U_PM_CURRENT | \ + MMTE_S_PM_ENABLE | MMTE_S_PM_CURRENT | \ + MMTE_M_PM_ENABLE | MMTE_PM_XS_BITS) + +/* smte CSR bits */ +#define SMTE_PM_XS_BITS PM_XS_BITS +#define SMTE_U_PM_ENABLE U_PM_ENABLE +#define SMTE_U_PM_CURRENT U_PM_CURRENT +#define SMTE_S_PM_ENABLE S_PM_ENABLE +#define SMTE_S_PM_CURRENT S_PM_CURRENT +#define SMTE_MASK (SMTE_U_PM_ENABLE | SMTE_U_PM_CURRENT | \ + SMTE_S_PM_ENABLE | SMTE_S_PM_CURRENT | \ + SMTE_PM_XS_BITS) + +/* umte CSR bits */ +#define UMTE_U_PM_ENABLE U_PM_ENABLE +#define UMTE_U_PM_CURRENT U_PM_CURRENT +#define UMTE_MASK (UMTE_U_PM_ENABLE | MMTE_U_PM_CURRENT) + #endif diff --git a/target/riscv/csr.c b/target/riscv/csr.c index d2585395bf..829e043ef9 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -184,6 +184,38 @@ static int hmode32(CPURISCVState *env, int csrno) } +static int umode(CPURISCVState *env, int csrno) +{ + return -!riscv_has_ext(env, RVU); +} + +/* Checks if PointerMasking registers could be accessed */ +static int pointer_masking(CPURISCVState *env, int csrno) { + /* Check if j-ext is present */ + int j_check = -!riscv_has_ext(env, RVJ); + int mode_check = 0; + int csr_priv = get_field(csrno, 0x300); + /* check if particular mode is present */ + switch (csr_priv) { + case PRV_M: + mode_check = any(env, csrno); + break; + case PRV_S: + mode_check = smode(env, csrno); + break; + case PRV_U: + mode_check = umode(env, csrno); + break; + default: + g_assert_not_reached(); + } + /* raise fault if no j-ext or particular mode are present */ + if (j_check < 0) { + return -RISCV_EXCP_ILLEGAL_INST; + } + return mode_check; +} + static int pmp(CPURISCVState *env, int csrno) { return -!riscv_feature(env, RISCV_FEATURE_PMP); @@ -1263,6 +1295,200 @@ static int write_pmpaddr(CPURISCVState *env, int csrno, target_ulong val) return 0; } +/* + * Functions to access Pointer Masking feature registers + * We have to check if current priv lvl could modify + * csr in given mode + */ +static int check_pm_current_disabled(CPURISCVState *env, int csrno) +{ + int csr_priv = get_field(csrno, 0x300); + /* + * If priv lvls differ that means we're accessing csr from higher priv lvl, + * so allow the access + */ + if (env->priv != csr_priv) { + return 0; + } + int cur_bit_pos; + switch (env->priv) { + case PRV_M: + /* m-mode is always allowed to modify registers, so allow */ + return 0; + case PRV_S: + cur_bit_pos = S_PM_CURRENT; + break; + case PRV_U: + cur_bit_pos = U_PM_CURRENT; + break; + default: + g_assert_not_reached(); + } + int pm_current = get_field(env->mmte, cur_bit_pos); + /* It's same priv lvl, so we allow to modify csr only if pm_current==1 */ + return !pm_current; +} + +static int read_mmte(CPURISCVState *env, int csrno, target_ulong *val) +{ + *val = env->mmte & MMTE_MASK; + return 0; +} + +static int write_mmte(CPURISCVState *env, int csrno, target_ulong val) +{ + target_ulong wpri_val = val & MMTE_MASK; + if (val != wpri_val) { + qemu_log_mask(LOG_GUEST_ERROR, + "MMTE: WPRI violation written 0x%lx vs expected 0x%lx\n", + val, wpri_val); + } + env->mmte = val; + env->mstatus |= MSTATUS_XS | MSTATUS_SD; + env->mmte |= PM_EXT_DIRTY; + return 0; +} + +static int read_smte(CPURISCVState *env, int csrno, target_ulong *val) +{ + *val = env->mmte & SMTE_MASK; + return 0; +} + +static int write_smte(CPURISCVState *env, int csrno, target_ulong val) +{ + target_ulong wpri_val = val & SMTE_MASK; + if (val != wpri_val) { + qemu_log_mask(LOG_GUEST_ERROR, + "SMTE: WPRI violation written 0x%lx vs expected 0x%lx\n", + val, wpri_val); + } + if (check_pm_current_disabled(env, csrno)) { + return 0; + } + target_ulong new_val = val | (env->mmte & ~SMTE_MASK); + write_mmte(env, csrno, new_val); + return 0; +} + +static int read_umte(CPURISCVState *env, int csrno, target_ulong *val) +{ + *val = env->mmte & UMTE_MASK; + return 0; +} + +static int write_umte(CPURISCVState *env, int csrno, target_ulong val) +{ + target_ulong wpri_val = val & UMTE_MASK; + if (val != wpri_val) { + qemu_log_mask(LOG_GUEST_ERROR, + "UMTE: WPRI violation written 0x%lx vs expected 0x%lx\n", + val, wpri_val); + } + if (check_pm_current_disabled(env, csrno)) { + return 0; + } + target_ulong new_val = val | (env->mmte & ~UMTE_MASK); + write_mmte(env, csrno, new_val); + return 0; +} + +static int read_mpmmask(CPURISCVState *env, int csrno, target_ulong *val) +{ + *val = env->mpmmask; + return 0; +} + +static int write_mpmmask(CPURISCVState *env, int csrno, target_ulong val) +{ + env->mpmmask = val; + env->mstatus |= MSTATUS_XS | MSTATUS_SD; + env->mmte |= PM_EXT_DIRTY; + return 0; +} + +static int read_spmmask(CPURISCVState *env, int csrno, target_ulong *val) +{ + *val = env->spmmask; + return 0; +} + +static int write_spmmask(CPURISCVState *env, int csrno, target_ulong val) +{ + if (check_pm_current_disabled(env, csrno)) { + return 0; + } + env->spmmask = val; + env->mstatus |= MSTATUS_XS | MSTATUS_SD; + env->mmte |= PM_EXT_DIRTY; + return 0; +} + +static int read_upmmask(CPURISCVState *env, int csrno, target_ulong *val) +{ + *val = env->upmmask; + return 0; +} + +static int write_upmmask(CPURISCVState *env, int csrno, target_ulong val) +{ + if (check_pm_current_disabled(env, csrno)) { + return 0; + } + env->upmmask = val; + env->mstatus |= MSTATUS_XS | MSTATUS_SD; + env->mmte |= PM_EXT_DIRTY; + return 0; +} + +static int read_mpmbase(CPURISCVState *env, int csrno, target_ulong *val) +{ + *val = env->mpmbase; + return 0; +} + +static int write_mpmbase(CPURISCVState *env, int csrno, target_ulong val) +{ + env->mpmbase = val; + env->mstatus |= MSTATUS_XS | MSTATUS_SD; + env->mmte |= PM_EXT_DIRTY; + return 0; +} + +static int read_spmbase(CPURISCVState *env, int csrno, target_ulong *val) +{ + *val = env->spmbase; + return 0; +} + +static int write_spmbase(CPURISCVState *env, int csrno, target_ulong val) +{ + if (check_pm_current_disabled(env, csrno)) { + return 0; + } + env->spmbase = val; + env->mstatus |= MSTATUS_XS | MSTATUS_SD; + env->mmte |= PM_EXT_DIRTY; + return 0; +} + +static int read_upmbase(CPURISCVState *env, int csrno, target_ulong *val) +{ + *val = env->upmbase; + return 0; +} + +static int write_upmbase(CPURISCVState *env, int csrno, target_ulong val) +{ + if (check_pm_current_disabled(env, csrno)) { + return 0; + } + env->upmbase = val; + env->mstatus |= MSTATUS_XS | MSTATUS_SD; + env->mmte |= PM_EXT_DIRTY; + return 0; +} + #endif /* @@ -1494,6 +1720,19 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { [CSR_PMPADDR14] = { "pmpaddr14", pmp, read_pmpaddr, write_pmpaddr }, [CSR_PMPADDR15] = { "pmpaddr15", pmp, read_pmpaddr, write_pmpaddr }, + /* User Pointer Masking */ + [CSR_UMTE] = { "umte", pointer_masking, read_umte, write_umte }, + [CSR_UPMMASK] = { "upmmask", pointer_masking, read_upmmask, write_upmmask }, + [CSR_UPMBASE] = { "upmbase", pointer_masking, read_upmbase, write_upmbase }, + /* Machine Pointer Masking */ + [CSR_MMTE] = { "mmte", pointer_masking, read_mmte, write_mmte }, + [CSR_MPMMASK] = { "mpmmask", pointer_masking, read_mpmmask, write_mpmmask }, + [CSR_MPMBASE] = { "mpmbase", pointer_masking, read_mpmbase, write_mpmbase }, + /* Supervisor Pointer Masking */ + [CSR_SMTE] = { "smte", pointer_masking, read_smte, write_smte }, + [CSR_SPMMASK] = { "spmmask", pointer_masking, read_spmmask, write_spmmask }, + [CSR_SPMBASE] = { "spmbase", pointer_masking, read_spmbase, write_spmbase }, + /* Performance Counters */ [CSR_HPMCOUNTER3] = { "hpmcounter3", ctr, read_zero }, [CSR_HPMCOUNTER4] = { "hpmcounter4", ctr, read_zero }, From patchwork Tue Apr 27 22:06:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Baturo X-Patchwork-Id: 12227633 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1B49C433ED for ; Tue, 27 Apr 2021 22:08:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2394B613B4 for ; Tue, 27 Apr 2021 22:08:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2394B613B4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lbVsk-0007wm-4s for qemu-devel@archiver.kernel.org; Tue, 27 Apr 2021 18:08:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57160) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbVqe-0006Cj-5G; Tue, 27 Apr 2021 18:06:28 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]:33709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lbVqc-0002gm-6H; Tue, 27 Apr 2021 18:06:27 -0400 Received: by mail-ej1-x62d.google.com with SMTP id t4so8338843ejo.0; Tue, 27 Apr 2021 15:06:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I5tnfyh15+1Hzqs2BbpAsHKgrqdCLD3z3hF5NAd03tM=; b=S2Wx8WWW2OAr9xcdhR3wtjLBzqLk5RmrIOCYwtG7YP2jwcbHyGKp9sNBSQUcBwkwQh AZ5VXm8Sy+BuKqqeUcFTqDTUk234X09am8WO3aJrf8TdXfM8mlQ3OHsWF+hxKH2ZCeQl pzuVlxbf/OgZzchyfoTB6s1MH+Hr5e+9a7q75E65Ndmu3FO+WY9ze5aLOJBC1X0rPUgB snccrh0okxsstYrky0XmiVPL/6Ft89TtCT4+XcJaXzPLOh0Q6+yVFlsj41CuJTy/OQD2 Zq32f74hKhbNAMOqkJcv7ptYlRop0Zcb3sLfQopgB3Xw28BAZ6gaak8kgeRvC4ic7pW8 mfCg== 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=I5tnfyh15+1Hzqs2BbpAsHKgrqdCLD3z3hF5NAd03tM=; b=gy5kjhAelE8Bo6q4itrlevROEI/obNH5U1mZwsvQ+xIFZ7sf77Ikp+agqcAD2gsOZ4 FAGOb48OfXzl+onQweKDO0AFUgBm9jDri7ELw/bnI03DG/H+4fceHGxArhxQzhICBsXF YXpIlnOkor/xxJX55xqiIYz2devWqh4R57F14FJ0s59qpk2CaP+GUPBCMmvEf2O4y8SN u+z+ta4J77tl7s0mzOc3CrEngX+hSex3KxvXkYefscH+woi/wRtlnyv57fWb19XSaZra IJmvwwLMI3oAdATM4LCHJgHVRqI55o5OWvw+L4v3eUQVTjw1EhL0lvGVnKr4XZov5MZh keog== X-Gm-Message-State: AOAM531xI+/3VNQSl3Abgkub4p0XIJgv7LvizC9gpjFjAERwiRgZnwbq Hnshuy4ecJmg6WSwLoAqx29vNFoo+FRz74Y8aDMlRYhP X-Google-Smtp-Source: ABdhPJxeAr6TqoD2k48/VRSr1na7NS4HI+t4uI2eEGG4jYWgVFWV7nH6jD62G02I3MinZVLWnVARng== X-Received: by 2002:a17:906:4d02:: with SMTP id r2mr13725591eju.464.1619561184587; Tue, 27 Apr 2021 15:06:24 -0700 (PDT) Received: from neptune.lab ([46.39.228.82]) by smtp.googlemail.com with ESMTPSA id r10sm640049ejd.112.2021.04.27.15.06.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 15:06:24 -0700 (PDT) From: Alexey Baturo X-Google-Original-From: Alexey Baturo To: Subject: [PATCH v8 3/6] [RISCV_PM] Print new PM CSRs in QEMU logs Date: Wed, 28 Apr 2021 01:06:12 +0300 Message-Id: <20210427220615.12763-4-space.monkey.delivers@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210427220615.12763-1-space.monkey.delivers@gmail.com> References: <20210427220615.12763-1-space.monkey.delivers@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=baturo.alexey@gmail.com; helo=mail-ej1-x62d.google.com 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, FREEMAIL_FROM=0.001, 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: baturo.alexey@gmail.com, qemu-riscv@nongnu.org, sagark@eecs.berkeley.edu, kbastian@mail.uni-paderborn.de, richard.henderson@linaro.org, qemu-devel@nongnu.org, space.monkey.delivers@gmail.com, Alistair Francis , kupokupokupopo@gmail.com, palmer@dabbelt.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alexey Baturo Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index c04911ec05..0682410f5d 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -287,6 +287,31 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags) qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "htval ", env->htval); qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval2 ", env->mtval2); } + if (riscv_has_ext(env, RVJ)) { + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mmte ", env->mmte); + switch (env->priv) { + case PRV_U: + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "upmbase ", + env->upmbase); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "upmmask ", + env->upmmask); + break; + case PRV_S: + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "spmbase ", + env->spmbase); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "spmmask ", + env->spmmask); + break; + case PRV_M: + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mpmbase ", + env->mpmbase); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mpmmask ", + env->mpmmask); + break; + default: + g_assert_not_reached(); + } + } #endif for (i = 0; i < 32; i++) { From patchwork Tue Apr 27 22:06:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Baturo X-Patchwork-Id: 12227635 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.4 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,GAPPY_SUBJECT,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F729C433B4 for ; Tue, 27 Apr 2021 22:08:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8649361026 for ; Tue, 27 Apr 2021 22:08:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8649361026 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lbVsk-0007xa-D1 for qemu-devel@archiver.kernel.org; Tue, 27 Apr 2021 18:08:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbVqf-0006Eo-CI; Tue, 27 Apr 2021 18:06:29 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]:36442) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lbVqd-0002iB-Ad; Tue, 27 Apr 2021 18:06:29 -0400 Received: by mail-ej1-x62d.google.com with SMTP id r9so91646476ejj.3; Tue, 27 Apr 2021 15:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GLUHIJt3ywEiGCbZr3kPOmm2DXUUFc44cAU14asvpAg=; b=sVk2EqgArSDnYvwr25XkBTK3V8ayrRhLDrBNkV/Vv0gpDw+iw3NjV8iyt2RFgg3Ihw TxCp3JXrbKFQhtqX6uUBtuG8RI0Zbd9eBkCxble33n8VbH3HVs7dqzG4Ab/vjGnrI0mG OrVpyAeYPCAmC3jcEWdV2vIHMZAB2VtE7WH6kTGKUSia8rfZOkczPOO16ugqxcUUpe4P krW5KSrBGkUacUJgjuMojpFNNq+Z49YnXUTBHSo+tkPDrcP2ts1TiEYlVHWefoFKiB/D O+8YDwRq+bB0FCQc0OYuAOpUwAW7TfazshgM/eG+IAc0WNUqTexQFjg2ViVfIwyWsacG fAsA== 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=GLUHIJt3ywEiGCbZr3kPOmm2DXUUFc44cAU14asvpAg=; b=EOdtkiS0EDXsSEhR2fKwGAyVe/+tXVk2tu1Qa9s0ehmbSbY/6PTVYdHdBl+XRYPCH0 xFEU5VGaLOXvj3A51J/UCGFJFUPRqBmbAg2A9I38KGOIbSdjDz0WkaWKADD6Zn31KQML nQFaz6xIlLLIPvugH5Hf3seNm9GnzQ7TsPKIqJE74+Ei1cE2QCMan1CsWt1R9tMpMWge QWUsoM3BoDfXGoo/1fserVDX99/V752oaMUx+X3Tud6PIjcnbHtRkAwZueXx8mj+4CLv NnmrJ0q2juinyIGODLb8ghHgK8rS5NYFLmmlCoyOsaoND17oa5KprS8WX6kLgl16df/T ttNw== X-Gm-Message-State: AOAM532lHFywmeyyTKhGtxDmHbjJM1D3b1KAyF+DFb418OzRDKxGZnKO czHF4nvBfY1wc6STES0zo2M= X-Google-Smtp-Source: ABdhPJwH4+JTuviocPdhk0xQLbSwHFd/OXoudtl80Ze+96Fuj3foSCd3BfZ8hqfqjOv6Axn2iU4aYg== X-Received: by 2002:a17:906:f1d0:: with SMTP id gx16mr25830094ejb.340.1619561185692; Tue, 27 Apr 2021 15:06:25 -0700 (PDT) Received: from neptune.lab ([46.39.228.82]) by smtp.googlemail.com with ESMTPSA id r10sm640049ejd.112.2021.04.27.15.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 15:06:25 -0700 (PDT) From: Alexey Baturo X-Google-Original-From: Alexey Baturo To: Subject: [PATCH v8 4/6] [RISCV_PM] Support pointer masking for RISC-V for i/c/f/d/a types of instructions Date: Wed, 28 Apr 2021 01:06:13 +0300 Message-Id: <20210427220615.12763-5-space.monkey.delivers@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210427220615.12763-1-space.monkey.delivers@gmail.com> References: <20210427220615.12763-1-space.monkey.delivers@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=baturo.alexey@gmail.com; helo=mail-ej1-x62d.google.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 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, FREEMAIL_FROM=0.001, GAPPY_SUBJECT=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: baturo.alexey@gmail.com, qemu-riscv@nongnu.org, sagark@eecs.berkeley.edu, kbastian@mail.uni-paderborn.de, richard.henderson@linaro.org, qemu-devel@nongnu.org, space.monkey.delivers@gmail.com, Alistair Francis , kupokupokupopo@gmail.com, palmer@dabbelt.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alexey Baturo Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- target/riscv/insn_trans/trans_rva.c.inc | 3 +++ target/riscv/insn_trans/trans_rvd.c.inc | 2 ++ target/riscv/insn_trans/trans_rvf.c.inc | 2 ++ target/riscv/insn_trans/trans_rvi.c.inc | 2 ++ target/riscv/translate.c | 10 ++++++++++ 5 files changed, 19 insertions(+) diff --git a/target/riscv/insn_trans/trans_rva.c.inc b/target/riscv/insn_trans/trans_rva.c.inc index be8a9f06dd..5559e347ba 100644 --- a/target/riscv/insn_trans/trans_rva.c.inc +++ b/target/riscv/insn_trans/trans_rva.c.inc @@ -26,6 +26,7 @@ static inline bool gen_lr(DisasContext *ctx, arg_atomic *a, MemOp mop) if (a->rl) { tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); } + gen_pm_adjust_address(ctx, src1, src1); tcg_gen_qemu_ld_tl(load_val, src1, ctx->mem_idx, mop); if (a->aq) { tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); @@ -46,6 +47,7 @@ static inline bool gen_sc(DisasContext *ctx, arg_atomic *a, MemOp mop) TCGLabel *l2 = gen_new_label(); gen_get_gpr(src1, a->rs1); + gen_pm_adjust_address(ctx, src1, src1); tcg_gen_brcond_tl(TCG_COND_NE, load_res, src1, l1); gen_get_gpr(src2, a->rs2); @@ -91,6 +93,7 @@ static bool gen_amo(DisasContext *ctx, arg_atomic *a, gen_get_gpr(src1, a->rs1); gen_get_gpr(src2, a->rs2); + gen_pm_adjust_address(ctx, src1, src1); (*func)(src2, src1, src2, ctx->mem_idx, mop); gen_set_gpr(a->rd, src2); diff --git a/target/riscv/insn_trans/trans_rvd.c.inc b/target/riscv/insn_trans/trans_rvd.c.inc index 4f832637fa..935342f66d 100644 --- a/target/riscv/insn_trans/trans_rvd.c.inc +++ b/target/riscv/insn_trans/trans_rvd.c.inc @@ -25,6 +25,7 @@ static bool trans_fld(DisasContext *ctx, arg_fld *a) TCGv t0 = tcg_temp_new(); gen_get_gpr(t0, a->rs1); tcg_gen_addi_tl(t0, t0, a->imm); + gen_pm_adjust_address(ctx, t0, t0); tcg_gen_qemu_ld_i64(cpu_fpr[a->rd], t0, ctx->mem_idx, MO_TEQ); @@ -40,6 +41,7 @@ static bool trans_fsd(DisasContext *ctx, arg_fsd *a) TCGv t0 = tcg_temp_new(); gen_get_gpr(t0, a->rs1); tcg_gen_addi_tl(t0, t0, a->imm); + gen_pm_adjust_address(ctx, t0, t0); tcg_gen_qemu_st_i64(cpu_fpr[a->rs2], t0, ctx->mem_idx, MO_TEQ); diff --git a/target/riscv/insn_trans/trans_rvf.c.inc b/target/riscv/insn_trans/trans_rvf.c.inc index 3dfec8211d..04b3c3eb3d 100644 --- a/target/riscv/insn_trans/trans_rvf.c.inc +++ b/target/riscv/insn_trans/trans_rvf.c.inc @@ -30,6 +30,7 @@ static bool trans_flw(DisasContext *ctx, arg_flw *a) TCGv t0 = tcg_temp_new(); gen_get_gpr(t0, a->rs1); tcg_gen_addi_tl(t0, t0, a->imm); + gen_pm_adjust_address(ctx, t0, t0); tcg_gen_qemu_ld_i64(cpu_fpr[a->rd], t0, ctx->mem_idx, MO_TEUL); gen_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rd]); @@ -47,6 +48,7 @@ static bool trans_fsw(DisasContext *ctx, arg_fsw *a) gen_get_gpr(t0, a->rs1); tcg_gen_addi_tl(t0, t0, a->imm); + gen_pm_adjust_address(ctx, t0, t0); tcg_gen_qemu_st_i64(cpu_fpr[a->rs2], t0, ctx->mem_idx, MO_TEUL); diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc index d04ca0394c..bee7f6be46 100644 --- a/target/riscv/insn_trans/trans_rvi.c.inc +++ b/target/riscv/insn_trans/trans_rvi.c.inc @@ -141,6 +141,7 @@ static bool gen_load(DisasContext *ctx, arg_lb *a, MemOp memop) TCGv t1 = tcg_temp_new(); gen_get_gpr(t0, a->rs1); tcg_gen_addi_tl(t0, t0, a->imm); + gen_pm_adjust_address(ctx, t0, t0); tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, memop); gen_set_gpr(a->rd, t1); @@ -180,6 +181,7 @@ static bool gen_store(DisasContext *ctx, arg_sb *a, MemOp memop) TCGv dat = tcg_temp_new(); gen_get_gpr(t0, a->rs1); tcg_gen_addi_tl(t0, t0, a->imm); + gen_pm_adjust_address(ctx, t0, t0); gen_get_gpr(dat, a->rs2); tcg_gen_qemu_st_tl(dat, t0, ctx->mem_idx, memop); diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 2f9f5ccc62..2e815a5912 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -89,6 +89,16 @@ static void gen_nanbox_s(TCGv_i64 out, TCGv_i64 in) tcg_gen_ori_i64(out, in, MAKE_64BIT_MASK(32, 32)); } +/* + * Temp stub: generates address adjustment for PointerMasking + */ +static void gen_pm_adjust_address(DisasContext *s, + TCGv_i64 dst, + TCGv_i64 src) +{ + tcg_gen_mov_i64(dst, src); +} + /* * A narrow n-bit operation, where n < FLEN, checks that input operands * are correctly Nan-boxed, i.e., all upper FLEN - n bits are 1. From patchwork Tue Apr 27 22:06:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Baturo X-Patchwork-Id: 12227637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7A9BC433ED for ; Tue, 27 Apr 2021 22:08:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 61F3C613C5 for ; Tue, 27 Apr 2021 22:08:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 61F3C613C5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lbVsx-0008US-EM for qemu-devel@archiver.kernel.org; Tue, 27 Apr 2021 18:08:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbVqg-0006GO-CS; Tue, 27 Apr 2021 18:06:30 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]:44728) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lbVqe-0002iN-AT; Tue, 27 Apr 2021 18:06:30 -0400 Received: by mail-ej1-x636.google.com with SMTP id r20so41894013ejo.11; Tue, 27 Apr 2021 15:06:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oZo0boHEvBRhG0tdDLSUtrJ+iJiWD/rcMwo8xjj1KII=; b=u0ZB5pCrS5EcsProiJwe6jyGTSg8aqdaQvRRv4Q5KjkOwULrwn0R4SdyBVqyjo3lez WcJxc2r1MSDCeL26+/GwDG9C4P7fdzkbJFP8GVWzOCGj+zOfcjPbAMTizt6386d4Zo3B B5tutHQLllahDt4060tF0KYBPI6EYk1gIkyoBs7OvSFYmsLanOfN4NsbAtFCK+IlYna/ 0sCYm+OvrvOGBiaJrJn7mqRYdG7NgvHtM9qbcPJlgNqJ1yT0VX5oyDkauzf0uX/kbYZu jkETBhfzh3JdJRxhpdIpG7T2hUyUKNbHyvt3KwXyX6POp8DNpdrb8Lu1hcXmYBboOMc5 9tkA== 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=oZo0boHEvBRhG0tdDLSUtrJ+iJiWD/rcMwo8xjj1KII=; b=EON4294C3Mte4PkRy+B9Cdo5ArVsJr3zHTdQOmUO5JJ3ngYGn9rHuHEh+pXP0PPD9x JPRAI4nu+Hwr6fImOKdKZwP1IQZ3D2MeXgO5xLspobapdMeT/p7aM45aXqEVFN094GZl dDuucyhfdWtuvn54JoshSMIKdLPJeOrlHwA86HWF8z+O3Yx4MnePB/rrIFCBkfsHq+Pi G2gV/USxCTuKPBbuRI4Hs5Jr4cgYtr9xmL5ct52z3vHS2PA5CnR3SvIyzTfEmuJH4IO3 53HPaSJQpGC37Y455UtoaXH3dtpe3B+Wa6MWnXKEtj7LRXWHRhnxZ731mAzU4tgyY8Kq NfiQ== X-Gm-Message-State: AOAM532lnDUibiC8grEY8UaqkYxZGFvtOCJi/UKEOhxAGPeJX5wEB+27 KNGiXZfM89KGfzVJnLUWo/w= X-Google-Smtp-Source: ABdhPJzNUPHXTgadDLWuxsPF1+PEOtcprE4eo/H2Kd2Qh8+jULaBAYtUZ+8qiccH1lQlGeQGiTsyyg== X-Received: by 2002:a17:906:9a02:: with SMTP id ai2mr4307253ejc.279.1619561186738; Tue, 27 Apr 2021 15:06:26 -0700 (PDT) Received: from neptune.lab ([46.39.228.82]) by smtp.googlemail.com with ESMTPSA id r10sm640049ejd.112.2021.04.27.15.06.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 15:06:26 -0700 (PDT) From: Alexey Baturo X-Google-Original-From: Alexey Baturo To: Subject: [PATCH v8 5/6] [RISCV_PM] Implement address masking functions required for RISC-V Pointer Masking extension Date: Wed, 28 Apr 2021 01:06:14 +0300 Message-Id: <20210427220615.12763-6-space.monkey.delivers@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210427220615.12763-1-space.monkey.delivers@gmail.com> References: <20210427220615.12763-1-space.monkey.delivers@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=baturo.alexey@gmail.com; helo=mail-ej1-x636.google.com 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, FREEMAIL_FROM=0.001, 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: baturo.alexey@gmail.com, qemu-riscv@nongnu.org, sagark@eecs.berkeley.edu, kbastian@mail.uni-paderborn.de, richard.henderson@linaro.org, qemu-devel@nongnu.org, space.monkey.delivers@gmail.com, Alistair.Francis@wdc.com, kupokupokupopo@gmail.com, palmer@dabbelt.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Anatoly Parshintsev Signed-off-by: Anatoly Parshintsev Reviewed-by: Richard Henderson --- target/riscv/cpu.h | 20 ++++++++++++++++++++ target/riscv/translate.c | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 19aa3b4769..2edfc59712 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -407,6 +407,8 @@ FIELD(TB_FLAGS, SEW, 5, 3) FIELD(TB_FLAGS, VILL, 8, 1) /* Is a Hypervisor instruction load/store allowed? */ FIELD(TB_FLAGS, HLSX, 9, 1) +/* If PointerMasking should be applied */ +FIELD(TB_FLAGS, PM_ENABLED, 10, 1) bool riscv_cpu_is_32bit(CPURISCVState *env); @@ -464,6 +466,24 @@ static inline void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc, flags = FIELD_DP32(flags, TB_FLAGS, HLSX, 1); } } + if (riscv_has_ext(env, RVJ)) { + int priv = cpu_mmu_index(env, false); + bool pm_enabled = false; + switch (priv) { + case PRV_U: + pm_enabled = env->mmte & U_PM_ENABLE; + break; + case PRV_S: + pm_enabled = env->mmte & S_PM_ENABLE; + break; + case PRV_M: + pm_enabled = env->mmte & M_PM_ENABLE; + break; + default: + g_assert_not_reached(); + } + flags = FIELD_DP32(flags, TB_FLAGS, PM_ENABLED, pm_enabled); + } #endif *pflags = flags; diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 2e815a5912..37706d56d5 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -36,6 +36,9 @@ static TCGv cpu_gpr[32], cpu_pc, cpu_vl; static TCGv_i64 cpu_fpr[32]; /* assume F and D extensions */ static TCGv load_res; static TCGv load_val; +/* globals for PM CSRs */ +static TCGv pm_mask[4]; +static TCGv pm_base[4]; #include "exec/gen-icount.h" @@ -64,6 +67,10 @@ typedef struct DisasContext { uint16_t vlen; uint16_t mlen; bool vl_eq_vlmax; + /* PointerMasking extension */ + bool pm_enabled; + TCGv pm_mask; + TCGv pm_base; CPUState *cs; } DisasContext; @@ -90,13 +97,19 @@ static void gen_nanbox_s(TCGv_i64 out, TCGv_i64 in) } /* - * Temp stub: generates address adjustment for PointerMasking + * Generates address adjustment for PointerMasking */ static void gen_pm_adjust_address(DisasContext *s, TCGv_i64 dst, TCGv_i64 src) { - tcg_gen_mov_i64(dst, src); + if (!s->pm_enabled) { + /* Load unmodified address */ + tcg_gen_mov_i64(dst, src); + } else { + tcg_gen_andc_i64(dst, src, s->pm_mask); + tcg_gen_or_i64(dst, dst, s->pm_base); + } } /* @@ -657,6 +670,10 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->lmul = FIELD_EX32(tb_flags, TB_FLAGS, LMUL); ctx->mlen = 1 << (ctx->sew + 3 - ctx->lmul); ctx->vl_eq_vlmax = FIELD_EX32(tb_flags, TB_FLAGS, VL_EQ_VLMAX); + ctx->pm_enabled = FIELD_EX32(tb_flags, TB_FLAGS, PM_ENABLED); + int priv = cpu_mmu_index(env, false) & TB_FLAGS_PRIV_MMU_MASK; + ctx->pm_mask = pm_mask[priv]; + ctx->pm_base = pm_base[priv]; ctx->cs = cs; } @@ -777,4 +794,19 @@ void riscv_translate_init(void) "load_res"); load_val = tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, load_val), "load_val"); +#ifndef CONFIG_USER_ONLY + /* Assign PM CSRs to tcg globals */ + pm_mask[PRV_U] = + tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, upmmask), "upmmask"); + pm_base[PRV_U] = + tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, upmbase), "upmbase"); + pm_mask[PRV_S] = + tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, spmmask), "spmmask"); + pm_base[PRV_S] = + tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, spmbase), "spmbase"); + pm_mask[PRV_M] = + tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, mpmmask), "mpmmask"); + pm_base[PRV_M] = + tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, mpmbase), "mpmbase"); +#endif } From patchwork Tue Apr 27 22:06:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Baturo X-Patchwork-Id: 12227641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D450C433ED for ; Tue, 27 Apr 2021 22:11:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 03D8561007 for ; Tue, 27 Apr 2021 22:11:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 03D8561007 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lbVvf-0002aR-VB for qemu-devel@archiver.kernel.org; Tue, 27 Apr 2021 18:11:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbVqh-0006IY-51; Tue, 27 Apr 2021 18:06:31 -0400 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]:38901) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lbVqf-0002jf-GG; Tue, 27 Apr 2021 18:06:30 -0400 Received: by mail-ed1-x529.google.com with SMTP id y3so35521938eds.5; Tue, 27 Apr 2021 15:06:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0cBG/vn+Mouc2f2rVusu430afCyfWYcUQo1i/pxUkWk=; b=QARGwzuhI2sHHICFMvR49bz2qgPU7VlY+DRx5JRELUBr/m+UDd3JpNeHJs3jcrTFgh j4x+hpGiZ9zGeilFNiTJc5e1+eik7ocE0JNmMzgFVYtFXkqj+R23ToKccsWemxvLnZJb 42ise5rpBVLNekKs2ChT4Jw0N9WxNWZ2kF5izpkoex34gvJY2jc/+HSGbj9om33DUcmP RGjgP0O2oza7NC12q9r0hz2vVYz6ZJTq3bFDNakc/48fMnTzCyKT9B1MofZaaAV7CQ4U /5EWSzhl/Qe+c9Jnywmn3bfheRk2Eum8W5K6DYqXCYlMni3fwFs/gJn4poM3gaG3w1r+ QH+A== 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=0cBG/vn+Mouc2f2rVusu430afCyfWYcUQo1i/pxUkWk=; b=Hf73cnSNijAEd6wtIddNCUdpYkcoZnLACcErQ3RIxz65ysZHDpyyqtWC8IrDDuBRn2 A5TwAbzMNOuQpl+TA63rzHhJEVTRUFsIv+8kbbICC6qO9xPUtNix/pNERRzASRW6pWFU KkhhYRnOAnbEbqukjgdc2RKors8M+v3mClxSLcoKZFtNX2MWS4jYMK1f1Dx1v71Rv2ke oPfAh13IhMZ0KGzZPnLWUsjvEGjvKkBTKc6yeozLm+frYb8BEmyLhu7hYuMjdUhtbhjh hDjwKmamYyNHXbdS650frH7sBPHL2mAycz4M2lK8xGoxkxE4zVjlaOkQWZDajqGlwNKO VwOQ== X-Gm-Message-State: AOAM532gmB3CJPYmKugOZ4mlgwGspyLpWG5fTTeo9idBLAZMSc0Zn8FW SHAU5E7NVpfGcBXavYPwkIw= X-Google-Smtp-Source: ABdhPJxFgiZ8PdBRsz2ArMh7VCCBexta6ipErli5pxXo+jN9R1zXwX6Tb+SyJUh617R+7K4IwPMDYg== X-Received: by 2002:a05:6402:270a:: with SMTP id y10mr7014007edd.387.1619561187776; Tue, 27 Apr 2021 15:06:27 -0700 (PDT) Received: from neptune.lab ([46.39.228.82]) by smtp.googlemail.com with ESMTPSA id r10sm640049ejd.112.2021.04.27.15.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 15:06:27 -0700 (PDT) From: Alexey Baturo X-Google-Original-From: Alexey Baturo To: Subject: [PATCH v8 6/6] [RISCV_PM] Allow experimental J-ext to be turned on Date: Wed, 28 Apr 2021 01:06:15 +0300 Message-Id: <20210427220615.12763-7-space.monkey.delivers@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210427220615.12763-1-space.monkey.delivers@gmail.com> References: <20210427220615.12763-1-space.monkey.delivers@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=baturo.alexey@gmail.com; helo=mail-ed1-x529.google.com 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, FREEMAIL_FROM=0.001, 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: baturo.alexey@gmail.com, qemu-riscv@nongnu.org, sagark@eecs.berkeley.edu, kbastian@mail.uni-paderborn.de, richard.henderson@linaro.org, qemu-devel@nongnu.org, space.monkey.delivers@gmail.com, Alistair Francis , kupokupokupopo@gmail.com, palmer@dabbelt.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alexey Baturo Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 0682410f5d..fecc64d7ba 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -502,6 +502,7 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) #ifndef CONFIG_USER_ONLY env->mmte |= PM_EXT_INITIAL; #endif + target_misa |= RVJ; } if (cpu->cfg.ext_v) { target_misa |= RVV; @@ -574,6 +575,7 @@ static Property riscv_cpu_properties[] = { DEFINE_PROP_BOOL("u", RISCVCPU, cfg.ext_u, true), /* This is experimental so mark with 'x-' */ DEFINE_PROP_BOOL("x-h", RISCVCPU, cfg.ext_h, false), + DEFINE_PROP_BOOL("x-j", RISCVCPU, cfg.ext_j, false), DEFINE_PROP_BOOL("x-v", RISCVCPU, cfg.ext_v, false), DEFINE_PROP_BOOL("Counters", RISCVCPU, cfg.ext_counters, true), DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true),