From patchwork Tue Apr 13 02:41:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 12199147 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 23F41C433B4 for ; Tue, 13 Apr 2021 02:44:14 +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 D6033611CE for ; Tue, 13 Apr 2021 02:44:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6033611CE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lW92C-0008Us-Vy for qemu-devel@archiver.kernel.org; Mon, 12 Apr 2021 22:44:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lW90G-0005xe-TN; Mon, 12 Apr 2021 22:42:12 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:19807) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lW90E-0007w1-SS; Mon, 12 Apr 2021 22:42:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1618281736; x=1649817736; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/Ok+tcjiS+FZn/FXu1Fpq+gKJ8dmBUMypcJItbhVtUk=; b=mecVyWQaA+YNP2iQtsHmwxMyfuv6TDxYNuq+nf9kUZHo5aWccMpq6VY9 K69w62YzPhGJGiNdAHFr/l2ai94Qup+tDDI7neFyVx5QgdNmkVtilWwnq 8Zka2n6fVv2V5PDZcSaTXral+rXkXjFhglXXc0AKWwgFxzY8yHJr3SwlP /Rp/i0MAMngxrir1AYDGruvIYC1/AsEYEz4Z42AZlXEo2lmFXhWd6c+nc sQCHVYFexhs85uuE5chil5odHqLxO/p5MH/aOlwzXV8lA+p3XFrG59gkQ uWjV9C+eQnJkFTTuMG9EwEkBudjARe5rfUiVG+eg/iDal1k4iymOWaqsE Q==; IronPort-SDR: V266+8jq/jrlOirTRuJs7TGih+jupAn/iR6kN14XD39hav4Iry/RyeIPyr2hZhRP4zA7lkPlkC GRwmC4FmLYn7mUrXNeI6Pj49idb5te87QZIjn9fWlFAi5+hhh5fB5ObQnan55unIajW8WVajmv Tc79OaMEhhNZRQi7NRhyltHJUr48yrv3uyay/4ldYV6U8YL24jd3mYiLjanwbhOoirVfjPSwGW 2MRbMOZPhxneZtvxM/r1Naxq22UjUg9kZQ8nHoRCJvj3k1P/5MZt+7bUlHfJovHjM+fJvAGsH4 xZU= X-IronPort-AV: E=Sophos;i="5.82,216,1613404800"; d="scan'208";a="268800698" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 13 Apr 2021 10:41:57 +0800 IronPort-SDR: UMMmOXmpBY3kVmI/qF4eTAt9qksWhGUXum9b+E/cjQ5uVYjNwCq9xMI6V3CAOjuIMnn7JU1peF sxtaYZEaGEOfk2Bd/30zTFSJh190P/zbH0w3HeKdkxolw18zdT76xYLv+Yay5tTFYWy1tRC7P9 YB9Y+MrsjDSJnqBEizqeg7iU+NRHE3khjNYqFv5FcHUwOyAS3MeFzXVOQpBc7eo1mpq7jWkfrH mqD2CCew4GCGAUUNM/ANENjkBOfPzGnEo6s02yKIT70hO9oIYk2TQmw1eSmmlEsO9qBeqpybn/ SM2KqbKFZDISScl2SzzkLN17 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2021 19:21:20 -0700 IronPort-SDR: 4ROzS0BIe6NtWejGR4AiAoa7gUPRPpjLO+qj5UCcsMdQ+ZHny1kFGlCwqyN6xHzzH3TWW+i6WQ jugYaXrQy2g+b3kWtrAq8YnZfwALDykPtdZx/CV5PvUc7yqrV+Cmdf6rAPTRfOyflkouG0j80l Tag27yQIU5lspOseiGLCOvwzwYWcyCR0pme2CSzuEberwIVPSn0VDwjZit26WIvdvlqTqkabgS ib9r3+JCuKLx1MDDyHS4LLe69EOh1pNFdgbWHT3ZXozWbdKkRhgrR8jS3IN+ojg0kgK35+8NkR DR0= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.16]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Apr 2021 19:41:50 -0700 From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v3 1/8] target/riscv: Fix the PMP is locked check when using TOR Date: Tue, 13 Apr 2021 12:41:43 +1000 Message-Id: <358acc99b748a2099f460fb01d7f0727bdf1432e.1618281655.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=730c0c5bd=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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: alistair.francis@wdc.com, bmeng.cn@gmail.com, palmer@dabbelt.com, alistair23@gmail.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The RISC-V spec says: if PMP entry i is locked and pmpicfg.A is set to TOR, writes to pmpaddri-1 are ignored. The current QEMU code ignores accesses to pmpaddri-1 and pmpcfgi-1 which is incorrect. Update the pmp_is_locked() function to not check the supporting fields and instead enforce the lock functionality in the pmpaddr write operation. Signed-off-by: Alistair Francis Reviewed-by: Bin Meng --- target/riscv/pmp.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index cff020122a..a3b253bb15 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -59,16 +59,6 @@ static inline int pmp_is_locked(CPURISCVState *env, uint32_t pmp_index) return 0; } - /* In TOR mode, need to check the lock bit of the next pmp - * (if there is a next) - */ - const uint8_t a_field = - pmp_get_a_field(env->pmp_state.pmp[pmp_index + 1].cfg_reg); - if ((env->pmp_state.pmp[pmp_index + 1u].cfg_reg & PMP_LOCK) && - (PMP_AMATCH_TOR == a_field)) { - return 1; - } - return 0; } @@ -380,7 +370,23 @@ void pmpaddr_csr_write(CPURISCVState *env, uint32_t addr_index, target_ulong val) { trace_pmpaddr_csr_write(env->mhartid, addr_index, val); + if (addr_index < MAX_RISCV_PMPS) { + /* + * In TOR mode, need to check the lock bit of the next pmp + * (if there is a next). + */ + if (addr_index + 1 < MAX_RISCV_PMPS) { + uint8_t pmp_cfg = env->pmp_state.pmp[addr_index + 1].cfg_reg; + + if (pmp_cfg & PMP_LOCK && + PMP_AMATCH_TOR == pmp_get_a_field(pmp_cfg)) { + qemu_log_mask(LOG_GUEST_ERROR, + "ignoring pmpaddr write - pmpcfg + 1 locked\n"); + return; + } + } + if (!pmp_is_locked(env, addr_index)) { env->pmp_state.pmp[addr_index].addr_reg = val; pmp_update_rule(env, addr_index); From patchwork Tue Apr 13 02:41:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 12199149 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 2D86EC433B4 for ; Tue, 13 Apr 2021 02:46:05 +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 D346960232 for ; Tue, 13 Apr 2021 02:46:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D346960232 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lW93z-0001oB-W1 for qemu-devel@archiver.kernel.org; Mon, 12 Apr 2021 22:46:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lW90N-00064G-GR; Mon, 12 Apr 2021 22:42:19 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:62296) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lW90L-00080J-RO; Mon, 12 Apr 2021 22:42:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1618281737; x=1649817737; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6Pem7nn+Ai8i7C1vw/hr6N5V118h5TJ3Ltyh7wyBDJY=; b=GqcDKDIPU6tBEfIthYxL3jofElYZ7hrlvtb4J49iVYFU2flz2L15U1Fw iieP1RLkVwnGrZrp0Qi+pd3dqVlZ2fGa8cESjpelKcCjJKmGiXXHEeMoP CDq3beINXx6xVGER8t5bPBrGNFijPJpzI9ma6Yv9bp6kOELb3qsp/SV1Q s+PmTyuCtArijoJ3qJWL85TOboxN9+8nUcSeJzF/6DkVLguYNgFqnfiuX Ty3xaJSVihYi98f9zcVeS5VYRp5UkFrvvFDsirgpCgwfke78r4fORGnKN g0lrjYSezN5lX56mFR/UjOjWTY50QVwZLQxbvooTtME+TmyjBfm3EAqwW g==; IronPort-SDR: ngHH1njyr/ZzbugCbSOVm914JHtwd9w0ulB5AvvzvUUyMTdD0zK6gJUUA0z775ZzxBEx1FqK+8 F0KjLMY5iapseF0RcRL2nQHBzBvFmr5xNZcTEybP7D9k8BfcYAcKV36tR/rS3G6rD1ihHBAqVq 2NKMsdExNSQsFi4+3GiGBWtzOJANy/OFRBQ128G427i2PWbRBVz3l0u5owJJD4+Yg+0GN4lzqt 4wWvbvUGYV0TDvYLq/OCUREkjiuUz+PehQ5w1J3hT7xRDcX4MZTpujrhrVBYE3Q6QOt6ZnhCtP L88= X-IronPort-AV: E=Sophos;i="5.82,216,1613404800"; d="scan'208";a="164190716" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 13 Apr 2021 10:42:09 +0800 IronPort-SDR: 7TLNaThtfZoWdktZJmwnpU869Kk1YRyNCFPhKIaalGC/wX9bauBIMOSn9CoqESaVUvlXLtcJIV DI7RqcdCUA0Rdf/l0TxRtbjMHLBkOKs038FDw3zQRigG/00MbKU1hlJL9w5O4aiZQ8rm4jNmno m2qMR2oGsXNSH4tP4BLjZKxknunBhoeCEMyOjbUqL+jaaRcR8VCY3LwwAhvKR0dcOm0kRvYNnb fh0QbiuKnsgsAiBu4cljT2dJd8aX9cV+vb0elcm6lHoZw0XwuPsOEWpHcx9Xy4c9K4e/YbHQ9c +pq/v7LFi1TOwfaAkMzMucza Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2021 19:21:35 -0700 IronPort-SDR: Jf+nuujwPxdHBhrE+j2hmFQJM9v8fN/wL1FP4gTbOvd5R8yEGpENIODXkzUz97fqfZppyQKG74 CRhRUyxlWB1gfL6wph2yt48Jbl96JxIEiRAGs7pxjSAKrFjS2hP387jC55MM5E2XWs4gUM7u3w VdKV3v2qeWVQpDtsLGSlabIgz/WBf16v9bhO5+XiDksVq2vYSxsguBWPICa9y8q+XzNBzuh1QM VlKnBfkDuQG925+02l8YaNTJVDZy5WPLVawnykWu8Ktu51IwsUhapSQxSuq19kmdcMKk2xkDt0 kuk= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.16]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Apr 2021 19:42:05 -0700 From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v3 2/8] target/riscv: Define ePMP mseccfg Date: Tue, 13 Apr 2021 12:41:55 +1000 Message-Id: <919a4f45cbfd039545efadd4cfb0cd9ada8cfdb9.1618281655.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=730c0c5bd=alistair.francis@wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_PASS=-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: alistair.francis@wdc.com, bmeng.cn@gmail.com, palmer@dabbelt.com, alistair23@gmail.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Hou Weiying Use address 0x390 and 0x391 for the ePMP CSRs. Signed-off-by: Hongzheng-Li Signed-off-by: Hou Weiying Signed-off-by: Myriad-Dreamin Reviewed-by: Alistair Francis Message-Id: [ Changes by AF: - Tidy up commit message ] Signed-off-by: Alistair Francis Reviewed-by: Bin Meng --- target/riscv/cpu_bits.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 8549d77b4f..24d89939a0 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -220,6 +220,9 @@ #define CSR_MTINST 0x34a #define CSR_MTVAL2 0x34b +/* Enhanced Physical Memory Protection (ePMP) */ +#define CSR_MSECCFG 0x390 +#define CSR_MSECCFGH 0x391 /* Physical Memory Protection */ #define CSR_PMPCFG0 0x3a0 #define CSR_PMPCFG1 0x3a1 From patchwork Tue Apr 13 02:42:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 12199151 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 A4C3AC433ED for ; Tue, 13 Apr 2021 02:47:24 +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 0B4B660232 for ; Tue, 13 Apr 2021 02:47:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B4B660232 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lW95G-0002t8-Ub for qemu-devel@archiver.kernel.org; Mon, 12 Apr 2021 22:47:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lW90g-0006SN-JI; Mon, 12 Apr 2021 22:42:38 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:62315) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lW90e-0008BX-Q2; Mon, 12 Apr 2021 22:42:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1618281756; x=1649817756; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AEdLUUCBoQL5rEE7QdTBd0JifO8NvjBpCTUmr7NrzuA=; b=WEXs5WTgm2bvIyNo3v02VpP5LY3+Q1v1AU8x1FLxWMwotDKASL20jmbh Fy8Mx/zNt69FD+gB3QusKMlZsXX6rQz+an2Z6cLJfROMj+1v/+B4ZqwI4 UwJkhSIt/HYq23XQpLaXMNJHgO5kZgszywaNsbmyhUh20W0ZEmWZP89Yo te75wPP1dP32n55fRmzlL11yKkg3OuQ2/dw5QLtZTrOQO+HI9NAxmv7zF Pj4njabSA5kIgiuxAfZSAWLNKJXEwe9bc4JzOZSgLhoeWoc7Z03E3BSYd mP9E3pmnBZNeipMbz//Ls8bZHa2yP2sLfDGJEexyDVHuruAIJsU5htjpY g==; IronPort-SDR: 1S5vBJ+MwQcL570pcM62J44T66tzedzx50hQu91QuJcz40rwL7CDkXLR3HYO6+QYX5JZ190rX+ ErSwClwOjfMHyIO35M28lbFB0igCEqp3Oqr2LbKw2Xp+3eDT2vhfjaFijzmYGgY0wqGlmcmlgU 0OD9txBLC1vIU91JFOd6I3OIcHMrSl8OpA3JRmkW6fWg9F23novy9Bk0Qmfgb/lV5UpQRsyVgD EWVZUb3jwYNVoaiiWKMaijXef/cGiBCpJ1x5RmyRxGXdqhq6O3ZEBx/PkVaKHhm/4c3MGCaism csw= X-IronPort-AV: E=Sophos;i="5.82,216,1613404800"; d="scan'208";a="164190738" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Apr 2021 10:42:23 +0800 IronPort-SDR: SYgiMQQd6PSxYSv9iNp8QEAHuNSZM1DW3u82hJz9Hm/AoqCg232RDPgFJ2eOjHek6LfnW4r5fB AUOpAsK50T23+eT9V1tEsFDqyjO5w+iFNJX7sZco3BC9C3FL7at3rVwdnflW/lQ8E8mOxYkUmC 2D7MZPle1QskVTRygTmWTYiDfXMNXRrVK2HLLOnK9gkO7Hmrh0UzuB+ACstIen4To7/iWDbrka Hwa352OALjtqjes1z6Aav2HIgQ9d5yb0NvBMQtH1yzJ8Db4aXDp/isVTJ1rLKMX+8CySmuOVOJ z77yBe+pKHtJA6F8mDlb/MDC Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2021 19:23:24 -0700 IronPort-SDR: 4cy/XtgGsOlvE2oddCxjE7SGVFqTX81AVLVEkYJM0Sh0+4blMoj8LF+QWevkkQiYLzeUnao0r+ wQJYA/mLUIE1A2Mp40PgJz5GO4wz7UfSz9MRwTR1Yv50MAJLrxKwCkA8k4lPq98XJix2HpjeTq JKjwIYcM4y92spjKFjhOTetUw0DLiRxQF+nCCHDhwxKUS+QxH3ZHjXj3DtDgYFEGy6ac5FyhHn tztUkCZ0Uf7bVr0ULnnCW3r3+E7OIb5Pr6fXDHOQ62c8TkdCQ23aPLc4SphwT2rRf5UtB+NFPQ ptM= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.16]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Apr 2021 19:42:18 -0700 From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v3 3/8] target/riscv: Add the ePMP feature Date: Tue, 13 Apr 2021 12:42:09 +1000 Message-Id: <3a2615d3f1433a025c7035673f66e4b72cb22878.1618281655.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=730c0c5bd=alistair.francis@wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_PASS=-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: alistair.francis@wdc.com, bmeng.cn@gmail.com, palmer@dabbelt.com, alistair23@gmail.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The spec is avaliable at: https://docs.google.com/document/d/1Mh_aiHYxemL0umN3GTTw8vsbmzHZ_nxZXgjgOUzbvc8 Signed-off-by: Alistair Francis Reviewed-by: Bin Meng --- target/riscv/cpu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 842d3ab810..13a08b86f6 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -81,6 +81,7 @@ enum { RISCV_FEATURE_MMU, RISCV_FEATURE_PMP, + RISCV_FEATURE_EPMP, RISCV_FEATURE_MISA }; From patchwork Tue Apr 13 02:42:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 12199143 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 639F6C433ED for ; Tue, 13 Apr 2021 02:43: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 DBBAE60232 for ; Tue, 13 Apr 2021 02:43:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DBBAE60232 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lW91e-0007Wm-Vc for qemu-devel@archiver.kernel.org; Mon, 12 Apr 2021 22:43:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lW90d-0006O0-K0; Mon, 12 Apr 2021 22:42:35 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:43511) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lW90a-00088n-8W; Mon, 12 Apr 2021 22:42:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1618281752; x=1649817752; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BeGxDstgSVmAKMR32zQD2g9vyfnlWWfmmbhPOYG0QOo=; b=ZdBWrvyH8flq5fgHRw3YtdDdXFyzVrVH9QYZEChyxLnZS3AzzrKqvfLx ihXfMXC2lG+8+/QgoISA74ybOVQjPidRa895pOOShi3sUgWUeUE4tkSn6 DQvN0gs9uPA2M1FiF/e9WRqpmByVXJTlu84LtxMJqouTZ93N52buRJRj0 RDGnD1vF7UAuMmdzNBj4aMdL5Si+bntbusFGgWrgKJLV2hIugXoo19wmb w7Mr4bxJfC2laRdMge4esLRoAa3t8ww5BfSm9vA19GMbsOSEV49biNSeY 2n4gKLESOI9x1AfMa0JEd10E68osshcyswUKlrlMboGe8YvFVZOlijnNy A==; IronPort-SDR: 8rrlo3sAX5t7GAGPkTiFpJ9H8V1afhz6rg6jVADHRfBeQKMVJIwJdQVB5qPqAKXboT3mkiSYQe kGb8mQ6wTRMQ1Q3IrBuKdXLEUAig0bjUByGcesl+4Po5HEDqWpMmnzu++jcGE2DtQIPz6gUYCc ChsofMYPezMXJf/yS/BqrV2lCXPqGrrLsYwnLkFG44SjAKOUle647dm4KHUVqhi6sd112Oru0i ljNvul2vKTsXiuS3zNMKiClXc+/PKJFMWw4godVrsIf73ZaouSBNVTVmgls4cwoewlQbAPIs8/ Vd8= X-IronPort-AV: E=Sophos;i="5.82,216,1613404800"; d="scan'208";a="169070139" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 13 Apr 2021 10:42:29 +0800 IronPort-SDR: jcj2owI6coloN1o94S57TtTjtixtDQPcc9A3c+mpazoLXE13iBehjHHmkKdrSCL7M3ZfvofNPe quJlQ1kqRPAbTbqUPsJUhZ0lV9LvvFu0zjFnQWxktk9Lhftsrz1YtzJ2ngg4ONTpDgXt4zcWDw hZMp16/kob7uvi9JIgF7Ts/n/EQmg6DB3b65Cd3lCELdiyw/YAMhGuAcYBQs06IcEPZ7c3uoAP BwB7FPw+WBe7fS2GxoDg1sD29jGgq+qTm8y8Us3rb/6NjXfWfn7Q9Idc2hHZUfnW77PUcows3f lGRVVJZ8BkvfcUX9J9DbqJx4 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2021 19:21:58 -0700 IronPort-SDR: TxIPsBiI59tPPAkTY7MwRdJSbjbI5ehbytqd+3DBbpLJC3qLSGfM5DfV2nlZrRPXGJoWOX0LFg Ow1xCv6k1ndwwUxj+AtaQ6aA0efJQ8vZIGM6111+J7EJ7ZMRPRdSOyvunsPGm6rOa2uCsq4ro5 9K2iiasNhmkYAhD6Y6oR7RMnICk7R6tc2yd3CXUOL1CVl2yZYMStt9Kq1Qxi/Z0A+ESxtR2lbx aaa0wGi5pRovCV8NEP/l0hkr3Ap87ycCaX0aTgFkSvjVVzQU6x5QouyIbrT4ZrKz8Kfvd5TxQQ R30= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.16]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Apr 2021 19:42:25 -0700 From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v3 4/8] target/riscv: Add ePMP CSR access functions Date: Tue, 13 Apr 2021 12:42:23 +1000 Message-Id: <19e68047049b7390801464bf9986500777c4ab68.1618281655.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=730c0c5bd=alistair.francis@wdc.com; helo=esa3.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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: alistair.francis@wdc.com, bmeng.cn@gmail.com, palmer@dabbelt.com, alistair23@gmail.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Hou Weiying Signed-off-by: Hongzheng-Li Signed-off-by: Hou Weiying Signed-off-by: Myriad-Dreamin Message-Id: [ Changes by AF: - Rebase on master - Fix build errors - Fix some style issues ] Signed-off-by: Alistair Francis Reviewed-by: Bin Meng --- target/riscv/cpu.h | 1 + target/riscv/pmp.h | 14 ++++++++++++++ target/riscv/csr.c | 24 ++++++++++++++++++++++++ target/riscv/pmp.c | 34 ++++++++++++++++++++++++++++++++++ target/riscv/trace-events | 3 +++ 5 files changed, 76 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 13a08b86f6..83b315e0b2 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -230,6 +230,7 @@ struct CPURISCVState { /* physical memory protection */ pmp_table_t pmp_state; + target_ulong mseccfg; /* machine specific rdtime callback */ uint64_t (*rdtime_fn)(uint32_t); diff --git a/target/riscv/pmp.h b/target/riscv/pmp.h index b82a30f0d5..a9a0b363a7 100644 --- a/target/riscv/pmp.h +++ b/target/riscv/pmp.h @@ -36,6 +36,12 @@ typedef enum { PMP_AMATCH_NAPOT /* Naturally aligned power-of-two region */ } pmp_am_t; +typedef enum { + MSECCFG_MML = 1 << 0, + MSECCFG_MMWP = 1 << 1, + MSECCFG_RLB = 1 << 2 +} mseccfg_field_t; + typedef struct { target_ulong addr_reg; uint8_t cfg_reg; @@ -55,6 +61,10 @@ typedef struct { void pmpcfg_csr_write(CPURISCVState *env, uint32_t reg_index, target_ulong val); target_ulong pmpcfg_csr_read(CPURISCVState *env, uint32_t reg_index); + +void mseccfg_csr_write(CPURISCVState *env, target_ulong val); +target_ulong mseccfg_csr_read(CPURISCVState *env); + void pmpaddr_csr_write(CPURISCVState *env, uint32_t addr_index, target_ulong val); target_ulong pmpaddr_csr_read(CPURISCVState *env, uint32_t addr_index); @@ -68,4 +78,8 @@ void pmp_update_rule_nums(CPURISCVState *env); uint32_t pmp_get_num_rules(CPURISCVState *env); int pmp_priv_to_page_prot(pmp_priv_t pmp_priv); +#define MSECCFG_MML_ISSET(env) get_field(env->mseccfg, MSECCFG_MML) +#define MSECCFG_MMWP_ISSET(env) get_field(env->mseccfg, MSECCFG_MMWP) +#define MSECCFG_RLB_ISSET(env) get_field(env->mseccfg, MSECCFG_RLB) + #endif diff --git a/target/riscv/csr.c b/target/riscv/csr.c index f0a74f0eb8..97ceff718f 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -200,6 +200,15 @@ static RISCVException pmp(CPURISCVState *env, int csrno) return RISCV_EXCP_ILLEGAL_INST; } + +static RISCVException epmp(CPURISCVState *env, int csrno) +{ + if (env->priv == PRV_M && riscv_feature(env, RISCV_FEATURE_EPMP)) { + return RISCV_EXCP_NONE; + } + + return RISCV_EXCP_ILLEGAL_INST; +} #endif /* User Floating-Point CSRs */ @@ -1343,6 +1352,20 @@ static RISCVException write_mtinst(CPURISCVState *env, int csrno, } /* Physical Memory Protection */ +static RISCVException read_mseccfg(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val = mseccfg_csr_read(env); + return RISCV_EXCP_NONE; +} + +static RISCVException write_mseccfg(CPURISCVState *env, int csrno, + target_ulong val) +{ + mseccfg_csr_write(env, val); + return RISCV_EXCP_NONE; +} + static RISCVException read_pmpcfg(CPURISCVState *env, int csrno, target_ulong *val) { @@ -1581,6 +1604,7 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { [CSR_MTINST] = { "mtinst", hmode, read_mtinst, write_mtinst }, /* Physical Memory Protection */ + [CSR_MSECCFG] = { "mseccfg", epmp, read_mseccfg, write_mseccfg }, [CSR_PMPCFG0] = { "pmpcfg0", pmp, read_pmpcfg, write_pmpcfg }, [CSR_PMPCFG1] = { "pmpcfg1", pmp, read_pmpcfg, write_pmpcfg }, [CSR_PMPCFG2] = { "pmpcfg2", pmp, read_pmpcfg, write_pmpcfg }, diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index a3b253bb15..e35988eec2 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -419,6 +419,40 @@ target_ulong pmpaddr_csr_read(CPURISCVState *env, uint32_t addr_index) return val; } +/* + * Handle a write to a mseccfg CSR + */ +void mseccfg_csr_write(CPURISCVState *env, target_ulong val) +{ + int i; + + trace_mseccfg_csr_write(env->mhartid, val); + + /* RLB cannot be enabled if it's already 0 and if any regions are locked */ + if (!MSECCFG_RLB_ISSET(env)) { + for (i = 0; i < MAX_RISCV_PMPS; i++) { + if (pmp_is_locked(env, i)) { + val &= ~MSECCFG_RLB; + break; + } + } + } + + /* Sticky bits */ + val |= (env->mseccfg & (MSECCFG_MMWP | MSECCFG_MML)); + + env->mseccfg = val; +} + +/* + * Handle a read from a mseccfg CSR + */ +target_ulong mseccfg_csr_read(CPURISCVState *env) +{ + trace_mseccfg_csr_read(env->mhartid, env->mseccfg); + return env->mseccfg; +} + /* * Calculate the TLB size if the start address or the end address of * PMP entry is presented in thie TLB page. diff --git a/target/riscv/trace-events b/target/riscv/trace-events index b7e371ee97..49ec4d3b7d 100644 --- a/target/riscv/trace-events +++ b/target/riscv/trace-events @@ -6,3 +6,6 @@ pmpcfg_csr_read(uint64_t mhartid, uint32_t reg_index, uint64_t val) "hart %" PRI pmpcfg_csr_write(uint64_t mhartid, uint32_t reg_index, uint64_t val) "hart %" PRIu64 ": write reg%" PRIu32", val: 0x%" PRIx64 pmpaddr_csr_read(uint64_t mhartid, uint32_t addr_index, uint64_t val) "hart %" PRIu64 ": read addr%" PRIu32", val: 0x%" PRIx64 pmpaddr_csr_write(uint64_t mhartid, uint32_t addr_index, uint64_t val) "hart %" PRIu64 ": write addr%" PRIu32", val: 0x%" PRIx64 + +mseccfg_csr_read(uint64_t mhartid, uint64_t val) "hart %" PRIu64 ": read mseccfg, val: 0x%" PRIx64 +mseccfg_csr_write(uint64_t mhartid, uint64_t val) "hart %" PRIu64 ": write mseccfg, val: 0x%" PRIx64 From patchwork Tue Apr 13 02:42:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 12199155 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 049C6C433ED for ; Tue, 13 Apr 2021 02:48:46 +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 7F6F761222 for ; Tue, 13 Apr 2021 02:48:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F6F761222 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lW96a-0004T8-MN for qemu-devel@archiver.kernel.org; Mon, 12 Apr 2021 22:48:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lW90o-0006gy-4e; Mon, 12 Apr 2021 22:42:46 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:43522) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lW90l-0008FY-PO; Mon, 12 Apr 2021 22:42:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1618281763; x=1649817763; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Xl1m/1iKNeJ0A7+JnK6xpXTeZOowjbzrcn2KLoPCgTA=; b=eVuLTDOE4pxn6QOskLR9JwZ5tG7lOOC3sUVlqkSmZVM6xZcXE1zOKgPE zOGDw3MuEhYvFC58c9nEj81CBNygDeFG6ocWDC9uUCPXpu873YqG+xVQM wJDnEXdEM6LkfljyHWxq/9spwu/jhN+Bde6bzZOOIvk6y9T9uCJs/vpTi kqBvwtQBd4thZqydLDZekhHMF3i0zdPIclEdnc7c5VbpieA08NTwEy37D xMCM2H48Gqzebv1OZHDI/EPbm9ue1rtiQayVMDh71w/vOTOSkZRKxW17o NO7i1POzfGL/an+P3+ajeJ6Deqn55mWNTxUdbcROmCdXUHB+I2bNmS09i A==; IronPort-SDR: ZqXXCfSDyVdv2tJQ/TukklBeyIywjv26MqCVljZeEzOoR9dcpYApyB7o/dBsmTz5eJoGeBUJda RePCAg4X56CbLS8MxpB89BvmLBTh4XP4Qwf6AcLWuk3oDf52k0dvJ6DgZducL4yd95uJvzjgcD hfkMunxGJHnk/jKE/LG3ecZnzg2fahYPodA+b3YGzcqtLT/jnq88tphO4JjlkQsW9p4/bvZeID tlwiivjQC9uw9Pn/nczXS3NK8mCDz2MQv6nsF59hn3k5i+UcEZM0Vlcahi9blQ8kKQULSiYQko N/0= X-IronPort-AV: E=Sophos;i="5.82,216,1613404800"; d="scan'208";a="169070147" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 13 Apr 2021 10:42:41 +0800 IronPort-SDR: pofKK9fHLjW6Ff9cZCse/SvWaZaRGRrqvmIn8iPumDlEnfSvsXN8c928jOCSVsIwgZPxP1E24U o4nZEdw3SxzJxw9r13i6xHanmwe4J9IrHnWihi2jLiWx42mrELplLM33TFhzbpIGsHElGf85+C haK/jo8WgDd02G0hV5uHwrHAQQWcgWnlrIaMFIxApgMhxLzl5UUZe4r22nIK9beQju0OFWbgbG jwShZXzX2+6Ru/gqFxbU4c4IR/9dwzyFJevHKcQMpeHSzdZGmWlP60mztInl73AE2Sn7jrE8HZ 5WEBSZ3LkN/3G+K4+s/MhtgX Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2021 19:22:09 -0700 IronPort-SDR: UxvY0BrZRNRz4cK1JNGqCePoUhcnpULGeH7MBrc4fXYdlSPaA82eozyyYLhXwmCVw0qspritqv BAIhACNgFiixfQxRUjd+rePDoZZYEpU3PS7HpJWQDOa76o3ofpYefITPnITaR7wRLnsK7konPO Pf1WTs61uLOQtVdvLkpRdfgiJtlrXm96rKikMnum30wiwy18+M0jLOqE82hK8eyYKgFcxvQrcb 07ipl6zhU/RIJASqwrS45c1e130fhQ1fTgfINtcJCrZzV/kBedhwvSSB3gAC6JSyMUyOrCwqHF txw= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.16]) by uls-op-cesaip02.wdc.com with ESMTP; 12 Apr 2021 19:42:39 -0700 From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v3 5/8] target/riscv: Implementation of enhanced PMP (ePMP) Date: Tue, 13 Apr 2021 12:42:32 +1000 Message-Id: <616cef68b75ec06b77847203efaca16f7efaaf18.1618281655.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=730c0c5bd=alistair.francis@wdc.com; helo=esa3.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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: alistair.francis@wdc.com, bmeng.cn@gmail.com, palmer@dabbelt.com, alistair23@gmail.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Hou Weiying This commit adds support for ePMP v0.9.1. The ePMP spec can be found in: https://docs.google.com/document/d/1Mh_aiHYxemL0umN3GTTw8vsbmzHZ_nxZXgjgOUzbvc8 Signed-off-by: Hongzheng-Li Signed-off-by: Hou Weiying Signed-off-by: Myriad-Dreamin Message-Id: [ Changes by AF: - Rebase on master - Update to latest spec - Use a switch case to handle ePMP MML permissions - Fix a few bugs ] Signed-off-by: Alistair Francis --- target/riscv/pmp.c | 164 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 152 insertions(+), 12 deletions(-) diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index e35988eec2..00f91d074f 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -90,11 +90,42 @@ static inline uint8_t pmp_read_cfg(CPURISCVState *env, uint32_t pmp_index) static void pmp_write_cfg(CPURISCVState *env, uint32_t pmp_index, uint8_t val) { if (pmp_index < MAX_RISCV_PMPS) { - if (!pmp_is_locked(env, pmp_index)) { - env->pmp_state.pmp[pmp_index].cfg_reg = val; - pmp_update_rule(env, pmp_index); + bool locked = true; + + if (riscv_feature(env, RISCV_FEATURE_EPMP)) { + /* mseccfg.RLB is set */ + if (MSECCFG_RLB_ISSET(env)) { + locked = false; + } + + /* mseccfg.MML is not set */ + if (!MSECCFG_MML_ISSET(env) && !pmp_is_locked(env, pmp_index)) { + locked = false; + } + + /* mseccfg.MML is set */ + if (MSECCFG_MML_ISSET(env)) { + /* not adding execute bit */ + if ((val & PMP_LOCK) != 0 && (val & PMP_EXEC) != PMP_EXEC) { + locked = false; + } + /* shared region and not adding X bit */ + if ((val & PMP_LOCK) != PMP_LOCK && + (val & 0x7) != (PMP_WRITE | PMP_EXEC)) { + locked = false; + } + } } else { + if (!pmp_is_locked(env, pmp_index)) { + locked = false; + } + } + + if (locked) { qemu_log_mask(LOG_GUEST_ERROR, "ignoring pmpcfg write - locked\n"); + } else { + env->pmp_state.pmp[pmp_index].cfg_reg = val; + pmp_update_rule(env, pmp_index); } } else { qemu_log_mask(LOG_GUEST_ERROR, @@ -217,6 +248,32 @@ static bool pmp_hart_has_privs_default(CPURISCVState *env, target_ulong addr, { bool ret; + if (riscv_feature(env, RISCV_FEATURE_EPMP)) { + if (MSECCFG_MMWP_ISSET(env)) { + /* + * The Machine Mode Whitelist Policy (mseccfg.MMWP) is set + * so we default to deny all, even for M-mode. + */ + *allowed_privs = 0; + return false; + } else if (MSECCFG_MML_ISSET(env)) { + /* + * The Machine Mode Lockdown (mseccfg.MML) bit is set + * so we can only execute code in M-mode with an applicable + * rule. Other modes are disabled. + */ + if (mode == PRV_M && !(privs & PMP_EXEC)) { + ret = true; + *allowed_privs = PMP_READ | PMP_WRITE; + } else { + ret = false; + *allowed_privs = 0; + } + + return ret; + } + } + if ((!riscv_feature(env, RISCV_FEATURE_PMP)) || (mode == PRV_M)) { /* * Privileged spec v1.10 states if HW doesn't implement any PMP entry @@ -294,13 +351,94 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr, pmp_get_a_field(env->pmp_state.pmp[i].cfg_reg); /* - * If the PMP entry is not off and the address is in range, do the priv - * check + * Convert the PMP permissions to match the truth table in the + * ePMP spec. */ + const uint8_t epmp_operation = + ((env->pmp_state.pmp[i].cfg_reg & PMP_LOCK) >> 4) | + ((env->pmp_state.pmp[i].cfg_reg & PMP_READ) << 2) | + (env->pmp_state.pmp[i].cfg_reg & PMP_WRITE) | + ((env->pmp_state.pmp[i].cfg_reg & PMP_EXEC) >> 2); + if (((s + e) == 2) && (PMP_AMATCH_OFF != a_field)) { - *allowed_privs = PMP_READ | PMP_WRITE | PMP_EXEC; - if ((mode != PRV_M) || pmp_is_locked(env, i)) { - *allowed_privs &= env->pmp_state.pmp[i].cfg_reg; + /* + * If the PMP entry is not off and the address is in range, + * do the priv check + */ + if (!MSECCFG_MML_ISSET(env)) { + /* + * If mseccfg.MML Bit is not set, do pmp priv check + * This will always apply to regular PMP. + */ + *allowed_privs = PMP_READ | PMP_WRITE | PMP_EXEC; + if ((mode != PRV_M) || pmp_is_locked(env, i)) { + *allowed_privs &= env->pmp_state.pmp[i].cfg_reg; + } + } else { + /* + * If mseccfg.MML Bit set, do the enhanced pmp priv check + */ + if (mode == PRV_M) { + switch (epmp_operation) { + case 0: + case 1: + case 4: + case 5: + case 6: + case 7: + case 8: + *allowed_privs = 0; + break; + case 2: + case 3: + case 14: + *allowed_privs = PMP_READ | PMP_WRITE; + break; + case 9: + case 10: + *allowed_privs = PMP_EXEC; + break; + case 11: + case 13: + *allowed_privs = PMP_READ | PMP_EXEC; + break; + case 12: + case 15: + *allowed_privs = PMP_READ; + break; + } + } else { + switch (epmp_operation) { + case 0: + case 8: + case 9: + case 12: + case 13: + case 14: + *allowed_privs = 0; + break; + case 1: + case 10: + case 11: + *allowed_privs = PMP_EXEC; + break; + case 2: + case 4: + case 15: + *allowed_privs = PMP_READ; + break; + case 3: + case 6: + *allowed_privs = PMP_READ | PMP_WRITE; + break; + case 5: + *allowed_privs = PMP_READ | PMP_EXEC; + break; + case 7: + *allowed_privs = PMP_READ | PMP_WRITE | PMP_EXEC; + break; + } + } } ret = ((privs & *allowed_privs) == privs); @@ -328,10 +466,12 @@ void pmpcfg_csr_write(CPURISCVState *env, uint32_t reg_index, trace_pmpcfg_csr_write(env->mhartid, reg_index, val); - if ((reg_index & 1) && (sizeof(target_ulong) == 8)) { - qemu_log_mask(LOG_GUEST_ERROR, - "ignoring pmpcfg write - incorrect address\n"); - return; + if (!riscv_feature(env, RISCV_FEATURE_EPMP) || !MSECCFG_RLB_ISSET(env)) { + if ((reg_index & 1) && (sizeof(target_ulong) == 8)) { + qemu_log_mask(LOG_GUEST_ERROR, + "ignoring pmpcfg write - PMP config is locked\n"); + return; + } } for (i = 0; i < sizeof(target_ulong); i++) { From patchwork Tue Apr 13 02:42:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 12199145 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 09EE0C433ED for ; Tue, 13 Apr 2021 02:44:00 +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 8DCFA60232 for ; Tue, 13 Apr 2021 02:43:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DCFA60232 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lW91y-00089k-O1 for qemu-devel@archiver.kernel.org; Mon, 12 Apr 2021 22:43:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lW914-0006vd-46; Mon, 12 Apr 2021 22:43:02 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:43553) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lW90y-0008Mn-HZ; Mon, 12 Apr 2021 22:43:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1618281776; x=1649817776; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KQtAdV5LP9iEiyOwP2HFZ15i0V8DACTLNBdpl+Fu7po=; b=EpqUv20TtY1SdNxSAe6wljf4+b4t8Jm/g3hWFx+smJXpoewQl1q7kWwG VvHIL5X7Sv94SFt4ukluADP3SA1NHnNhyTI249LfixqqNIG8/+GCM7onW VkeVTqGJNSkkDHVz8XUuauRThoJezIH9UAhoZ8uR1gwzSBUipz6J8yu6s 26XZ6dpLQ/79YUgUOkLIcTScxRgi6hjjGib2aq2oCjkLMasPM0AXRvJb7 IAYqJ1MzAui2OJUeYG6DUuafT3x8xTWlGJEPhw5Qy9q7sL4J6GrbGNGw8 Z2bubK/v6Ur94bmNudEpmZkodfzKmTBHHLAvE9vy8l4o4UWQgc7GVf3Rn A==; IronPort-SDR: gzMdB1tpBX5FXNGjRkkXpBEI1ZdkZt2I6bwYT/B8Tnt3+qhJm7Y6Y5da/tcYYJqaCigWJPiuy/ ZsPm8zhk9HVbWpHBkI+X2GGrcQMeWaZFMXqbVA6KOAKCEEMfelV7IduBviyn/8ZVnIr5/3KN3i L6ocTuRg6KIG6x993rP8asIlvl7kQUHaf95Rss0OKTHBS5fjSIKjjmI6Z0cPm1J12jTXA5nt4h ARGtY4p4HBCuSCS2Jxxw+l0crXVAC/H9FoMlhEqzdr63vQqjeMMkFNW6DldHCMirplvVw8s9Zv lmc= X-IronPort-AV: E=Sophos;i="5.82,216,1613404800"; d="scan'208";a="169070162" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 13 Apr 2021 10:42:54 +0800 IronPort-SDR: 1jlhDkytw8HfMpmYfWYyYchsfF/X6aqAJ0pO5/3tC4iK7Ub+RGO4rO95QUVK0H/PCqk56oyfBJ kY706KjndNG4AzG0nOe6zama1UWPo0djtWeQFQwmG12m8b3WMLNv5UyF2MD4TJbtq+3fjGjDMr E/3IXHmCzDfPcb1P3aaVff4rTWGTW825AX7anLne/Q7shzL4sSfCrPpFh3s0Ok4jWxl/CLaDGN z5OcfnKy0JZgcdrDs9GmL+ryPEjn7txOldvg3jTDEidMt4MP9d9Qf0riZI9k9jidVq/3Xq8wPx s4EaNjzpCersAPj9VJvmp4ze Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2021 19:22:22 -0700 IronPort-SDR: R1s/IVr91SSDEe9xUP1qEBtqeVeVSHlvqzkK3Y4JQFKwLV92MnCtuCD4jK06/IVlFZdFt8Bsqx LevDuo4nZT6YiSIgPGIUpJnJy0j7KcFWiQIW2M8t8PD3bdi992dqEQ0rEBSRm7kjo1hXuUsDfT 0ztP3I2lBIWneC2AhjX1CHXLkbXTsDl3qnaPV4QEtj7COS44KXVwypcRnRYOaHRCRidMgUkFH4 TEQq2yXSch+d9tKc2pyJ3/5lXPAwE/cV1Dw62CrA6FamBN+OCjauIAH7HMkCuGGywA9m2PwbIQ xRA= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.16]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Apr 2021 19:42:52 -0700 From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v3 6/8] target/riscv: Add a config option for ePMP Date: Tue, 13 Apr 2021 12:42:44 +1000 Message-Id: <5369dff9ce1abd04874dc71dd1bae4d3e6428a25.1618281655.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=730c0c5bd=alistair.francis@wdc.com; helo=esa3.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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: alistair.francis@wdc.com, bmeng.cn@gmail.com, palmer@dabbelt.com, alistair23@gmail.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Hou Weiying Add a config option to enable experimental support for ePMP. This is disabled by default and can be enabled with 'x-epmp=true'. Signed-off-by: Hongzheng-Li Signed-off-by: Hou Weiying Signed-off-by: Myriad-Dreamin Message-Id: Signed-off-by: Alistair Francis Reviewed-by: Bin Meng --- target/riscv/cpu.h | 1 + target/riscv/cpu.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 83b315e0b2..add734bbbd 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -304,6 +304,7 @@ struct RISCVCPU { uint16_t elen; bool mmu; bool pmp; + bool epmp; uint64_t resetvec; } cfg; }; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index e530df9385..66787d019c 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -412,6 +412,14 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) if (cpu->cfg.pmp) { set_feature(env, RISCV_FEATURE_PMP); + + /* + * Enhanced PMP should only be available + * on harts with PMP support + */ + if (cpu->cfg.epmp) { + set_feature(env, RISCV_FEATURE_EPMP); + } } set_resetvec(env, cpu->cfg.resetvec); @@ -554,6 +562,8 @@ static Property riscv_cpu_properties[] = { DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64), DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true), DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), + DEFINE_PROP_BOOL("x-epmp", RISCVCPU, cfg.epmp, false), + DEFINE_PROP_UINT64("resetvec", RISCVCPU, cfg.resetvec, DEFAULT_RSTVEC), DEFINE_PROP_END_OF_LIST(), }; From patchwork Tue Apr 13 02:42:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 12199157 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 5E236C433B4 for ; Tue, 13 Apr 2021 02:50:45 +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 7D84E61222 for ; Tue, 13 Apr 2021 02:50:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D84E61222 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lW98V-0006Cq-I8 for qemu-devel@archiver.kernel.org; Mon, 12 Apr 2021 22:50:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lW91J-0007ET-QE; Mon, 12 Apr 2021 22:43:17 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:62364) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lW91H-00005a-Vy; Mon, 12 Apr 2021 22:43:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1618281795; x=1649817795; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xa/AfaCnaXGcqbPu6T/WSIkls/DVmFNgca5PZOzM57o=; b=TAQSNdFAXx36WTtDjw1Z7BjxYod5UrKe8xgwkW4/QzBQbjuR9m0rk6LF 6zQiIrWj3H/ddibl20tDNf0O8CNECP7P5qH5951TwUd8QbzxsHQXq+2p3 jdTs5i8ZFX9NUwVvN8MU1r4RGasin4OmjmyeW38zwzLxje4GoXziODHN0 kt4j08AD/dN4vThXczktUry8AGUtLlDiUyO4leuEkOEy8Iap8rZptIJDI M6qw1pMhenxTtGimNlWqz1+HP0tJeAEeucIysWfAZaCdHxfzqg4+vMoqj LndjV8ldp04HlnAy7xMTsLdhJf1CU7sA8yvKUxLlgugPu7hpFAPsrDdph Q==; IronPort-SDR: gQfPWEWAOfhpBSGY3BgNMo1Tbc1GD5qTMG96AH3jZHHgGSHZEiEPut8p2ZgonugF3g/DI4SgVM adB6Y9jVkt4n1xjbKpSMO/AOxGPAdXfK/6D26p+lRvCClqNW2gYrWT9wXlwt8rHhYOuTu1r+pX ao9JBYWchdCeOqmQgATYojR5TnPolYWwfxInjrUWflhTeSnrHEnzV6w23grA/J9LlNO6EXTGfz q4JJYCn+mXZC8ozy8plEHswQAfKPTSK1n23qjoDgZqgISMh9AadP2ZDjsC0mVy5wBadbx4//SQ OEg= X-IronPort-AV: E=Sophos;i="5.82,216,1613404800"; d="scan'208";a="164190777" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Apr 2021 10:43:08 +0800 IronPort-SDR: tJjUTFUaZtvsDsSzUXaSi5+/47g6MaBKMOwxyEmf0j/hiYx1aPLW6wlIN7QZM3nOQRU7KoFv7w RdchI4XMJGbieuYiy7+Yvb90w8E3SjY+C8E+eM3tzJA+D53OmpeiZl1SYTkf3GRCn396SMYg55 AVpxU9bB011DlbGkIptIZKAjlom+DC1wRQcXDDjAcA8NS/Z+xFgGTlJw1JmC+vpA5HByvGLQgM RRrrfehSlUchjBJt9DzroK919lPO6clLaPa1pHLuYkgFuSLSBKFrMXP5zNULdqDoP7MMcQfOB6 KumDNez4FsI5h3nI0pUNyTOL Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2021 19:24:10 -0700 IronPort-SDR: o+THx8Iihq1UAAr+Pe9D5Jc6oIclxKQSq+0Ls47/qofz/5xDbRgO/S9wv/f3om7LY7VxpEfLVn rPly1ExR+k2qJiH+cnPs6wJOUt80c639in6lX/dvueUY6ouIQXsHt/zssY39oz0v7u6nTieibA pYWGgmlRmoyjviOL6wrPkj6hc+PPkq190VjrSck6IEJIsjE7G8XQFS3B2A40x41FCP/Ca0TfpP jl0e/08rra4GlgLloeLJmusIt1TX9Qqm/h5PbfGO2vaLg4cOQW5AfYn7Vl3Z6ztALTcsCJWJt0 DFE= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.16]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Apr 2021 19:43:04 -0700 From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v3 7/8] target/riscv/pmp: Remove outdated comment Date: Tue, 13 Apr 2021 12:42:57 +1000 Message-Id: <433d23e16bd941b209d433263aa8020b9efbf669.1618281655.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=730c0c5bd=alistair.francis@wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_PASS=-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: alistair.francis@wdc.com, bmeng.cn@gmail.com, palmer@dabbelt.com, alistair23@gmail.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alistair Francis Reviewed-by: Bin Meng --- target/riscv/pmp.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index 00f91d074f..68be893e16 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -19,10 +19,6 @@ * this program. If not, see . */ -/* - * PMP (Physical Memory Protection) is as-of-yet unused and needs testing. - */ - #include "qemu/osdep.h" #include "qemu/log.h" #include "qapi/error.h" From patchwork Tue Apr 13 02:43:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 12199153 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 BC3CAC433ED for ; Tue, 13 Apr 2021 02:48:27 +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 6C56661222 for ; Tue, 13 Apr 2021 02:48:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C56661222 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lW96I-000404-Ec for qemu-devel@archiver.kernel.org; Mon, 12 Apr 2021 22:48:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lW95U-00037f-CE; Mon, 12 Apr 2021 22:47:38 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:21351) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lW95N-0002cF-II; Mon, 12 Apr 2021 22:47:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1618282049; x=1649818049; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bAxzhW2heL1O/qeLTh6rWsqzlTWl7MNh1NZ6zHObLQU=; b=bYRhUdICmdr8DUyuq92OMR0P8EuJ4sM4mCaMWFwsBe6R/GuSi0wXPHP5 HwO+3K0hmw2lbnJbseMN89fWauZDHr7vAR8c76foNIQI46dQnY1tRfs/6 ZAUfqpBNWCiiUhbFr+eoG3FcisvXCYM+EGHd6iBSio+IYwt8cHI047OKr pfSQy4NX5IjlwkUqF8cU2svpBAi07g/t53NybxLBKX1Uzfd0CJxFpcFb8 L7kyshqt/i2Qi9CA+5e3SihSbBc+m6Rol1bgIWU0YGa1J+p5D3Jc30Ngi x4RpvlM2IvYzhaiLvWvZR3FGA9FlHMhfJbphL1soU7BCAiZ5fVxVQRD3l Q==; IronPort-SDR: AH4QSFH42CH/1Xysp5/jB/co/WoKxig+BotTClbVAm33I9HfGfssye1J7SwCl7VMN93PEvcgy+ LkrP9gqhwppOXGsq40WSrVpPpkr3PqOHj14DST/WNfwENQ/nTJVJwQpQRApzeliKe9+Evl6K8P YzEBuW60k8hscT/74bOR6JZ9pCbTtMD6sC/YR0tOCDrHOV/bZdXayhTe4xrpPgKOnkZ8VbleHB JWM5IWqJL28Vk/s1qCuZe5SY4Z66XS2fS568p3Pv6hLWxdMMblRL1Wf+PxS/nGrOHzyyQzxo7e 08g= X-IronPort-AV: E=Sophos;i="5.82,216,1613404800"; d="scan'208";a="164557096" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Apr 2021 10:43:21 +0800 IronPort-SDR: u28QQ3kcW/F0oCB+Wo9qsZS6GthcxvEqM8V5yl0dM537SrBfTlLYFOFwArFYd8EbFCiUjFfYqN R5qhrlTuPTC0emPz/ejA+bVRIV3DvbELYLnIwj6DCUfENPpUASlWnI/Pq36JqVaEhCFaiEOrJM X9sG/jDBkbO/YJADDU8wv4EwJtxiz9DNiBtRjcO9tT3sNSNpK6zgiUbXw5s5CTEmzhoW3Mf474 PyMxEowgltEIi+xGAbJ4w7UFNIjvznAfnQEml6yZSKWyMIDr62B/F2Cqw8YiHIp7cMRTI2l5gR tKu3qZ8fVDCld0ooJT/xeUI+ Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2021 19:24:23 -0700 IronPort-SDR: fPQQwefFuXXUiewmv/K5LlmpihJJJ0Uqzw2s7P42TtAHG3cgWU1EO5KJDrWxvrkujs+F1lv1bB Vo9SD16gRIZpqqQS3no2M53sBmFau9H5ZOjtAuO5zNlikvV6JBaaYHUpELSoMaERZ9VUiAkACC oUIRj1VAgRjArl440suZ4bSAu3HxROxDeDPgrFa8iKwSByUvDUB0fO9Bx9IoPwksLAhrpv5lA+ J6W3gB9jnzIUh1x/Q3XkXQyb8QoJp87haKJ/sWOnt2ihCbzzmRUfxvZLWyuWusG20SOSqG6pIb 2ZQ= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.16]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Apr 2021 19:43:16 -0700 From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v3 8/8] target/riscv: Add ePMP support for the Ibex CPU Date: Tue, 13 Apr 2021 12:43:08 +1000 Message-Id: <01a14ca289ed6ceb87fdaae61e4689937244518f.1618281655.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=730c0c5bd=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-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: alistair.francis@wdc.com, bmeng.cn@gmail.com, palmer@dabbelt.com, alistair23@gmail.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The physical Ibex CPU has ePMP support and it's enabled for the OpenTitan machine so let's enable ePMP support for the Ibex CPU in QEMU. Signed-off-by: Alistair Francis Reviewed-by: Bin Meng --- target/riscv/cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 66787d019c..4bf6a00636 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -202,6 +202,7 @@ static void rv32_ibex_cpu_init(Object *obj) set_misa(env, RV32 | RVI | RVM | RVC | RVU); set_priv_version(env, PRIV_VERSION_1_10_0); qdev_prop_set_bit(DEVICE(obj), "mmu", false); + qdev_prop_set_bit(DEVICE(obj), "x-epmp", true); } static void rv32_imafcu_nommu_cpu_init(Object *obj)