From nobody Sat Feb 7 23:01:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1694694911; cv=none; d=zohomail.com; s=zohoarc; b=LwcyP7c2/8vxCsV0si2xQqhd5FcgXCvpHA3tR6OOOgrPw1cwN/14TH5LphQHCubPbGdzGWMKRtimiHoPvktTqV17WF1S4UUPbwuLB64v+LiME/bxs5WZmk5zyPTvUfDLx482DnEeGUGbqANTXYL6nlruCIfJRzAPLARS5jOPfFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694694911; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=2i5iORmaPcRV7ieGSCV0tofWjzs027VAkkmm8l6mIu4=; b=hhKHibJvP4ckE6ackkUoywljAbD9EackGYUkeWqmVHR2iob8xQ81+EjG9M/wQwYEWnW6yuzuzrFQIZdtj/GtZ8FEgJguaQBbUS/yhYvPNriD0RSfeAg3zPByw0eufGSRj4/IIurRRNJjhtu1uh4hEgLbQ4qiw8n/vfZPvy8rSMM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694694911930653.4819179811911; Thu, 14 Sep 2023 05:35:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qglY7-0002ts-Gy; Thu, 14 Sep 2023 08:34:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qglXW-0002O3-Ol for qemu-devel@nongnu.org; Thu, 14 Sep 2023 08:33:47 -0400 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qglXV-0008Eo-45 for qemu-devel@nongnu.org; Thu, 14 Sep 2023 08:33:46 -0400 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-271c700efb2so704165a91.0 for ; Thu, 14 Sep 2023 05:33:43 -0700 (PDT) Received: from mchitale-vm.. ([103.97.165.210]) by smtp.googlemail.com with ESMTPSA id 19-20020a17090a001300b00263f5ac814esm3311275pja.38.2023.09.14.05.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 05:33:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694694821; x=1695299621; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=2i5iORmaPcRV7ieGSCV0tofWjzs027VAkkmm8l6mIu4=; b=QZpd9GPNdta0IF3O/YHqqZZzaJJswotyKWJ/FHYQ59tuSc0/TzCk0JH792RybEmP4e xy3lJ31M5luDSNtGUZrEr1cSMAjBRehs0b2LI0OC3/ZrlbFFpNt/EBfGBGwcOHieJOw2 wTG3mW1KXu6qFTWoKGn2lF3+RmbBtAPP56XyMEOkaJ59BqWRxZOsijDnx2Rf19MepiGP yzi4H7BHt3vnjtSzMWIKCcUv8yHYz4yQgOlh2G7O+E/frPN456oiOgXRTz931VkW/PJD jupyzuWRKhjQXmkWcIxaG9lPm2AZPPVxcRM4AS7dwpNpLGfoHK26dpuU+q8+298efV5P i0Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694694821; x=1695299621; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2i5iORmaPcRV7ieGSCV0tofWjzs027VAkkmm8l6mIu4=; b=i1V5KZ1OJDLuh8unJ3cDh2rnJjSGton9E2Iu9DdfWahR/LNKN6DhHyeajccGTqpOoe iq39IO/mM3B1bxqOWGg90ERw7GyjgNy8V7tFS6RVgeuh5PsKyQBg1I9nMWI2p6cJrMKa QamIb6uhb/dl5ZNOQ3Zx/napWvsctu+0oanL+4ldaiwIXvoQvFhIKw6fWAPyMWklNPDa Y2BAlpDq4qWCLjfqaMynVhpDllKUQwLz69XED0QRqBsBMnUb2jtPA87IiUtq4hc4tJar uhG6jCXDL6NIhEaQ+jNEiuhbQmwekA6g+zN3ORjIm30oDHs+gdSFwxmiEadvWzXO32Ig MRBQ== X-Gm-Message-State: AOJu0YxyfdYo7c7SjRlI5mKiZyTGewRMSkhWVq8It0VyGyxODg6j8nce BN6hgUA2gAsyNaLVNRAVrMb9JfadNU1S+ZHe8TwoTg== X-Google-Smtp-Source: AGHT+IFlDiP+shAuXCGwOWWpk937o0m9ZHYJpzhq6Vi/xBPPCzOGN/ZZpvwt6xOJ9HLD5HUH+BxBjA== X-Received: by 2002:a17:90a:2ce2:b0:271:9c5f:fc42 with SMTP id n89-20020a17090a2ce200b002719c5ffc42mr5028784pjd.31.1694694821567; Thu, 14 Sep 2023 05:33:41 -0700 (PDT) From: Mayuresh Chitale To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Mayuresh Chitale , alistair.francis@wdc.com Subject: [PATCH] target/riscv: pmp: Ignore writes when RW=01 Date: Thu, 14 Sep 2023 15:47:51 +0530 Message-Id: <20230914101751.772576-1-mchitale@ventanamicro.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=mchitale@ventanamicro.com; helo=mail-pj1-x102f.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1694694912685100001 Content-Type: text/plain; charset="utf-8" As per the Priv spec: "The R, W, and X fields form a collective WARL field for which the combinations with R=3D0 and W=3D1 are reserved." However currently such writes are not ignored as ought to be. The combinations with RW=3D01 are allowed only when the Smepmp extension is enabled and mseccfg.MML is set. Signed-off-by: Mayuresh Chitale --- target/riscv/pmp.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index f3eb6e6585..5b430be18c 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -119,6 +119,14 @@ static bool pmp_write_cfg(CPURISCVState *env, uint32_t= pmp_index, uint8_t val) if (locked) { qemu_log_mask(LOG_GUEST_ERROR, "ignoring pmpcfg write - locked= \n"); } else if (env->pmp_state.pmp[pmp_index].cfg_reg !=3D val) { + /* If !mseccfg.MML then ignore writes with encoding RW=3D01 */ + if ((val & PMP_WRITE) && !(val & PMP_READ) && + (!riscv_cpu_cfg(env)->ext_smepmp || + !MSECCFG_MML_ISSET(env))) { + val &=3D ~(PMP_WRITE | PMP_READ); + val |=3D env->pmp_state.pmp[pmp_index].cfg_reg & + (PMP_WRITE | PMP_READ); + } env->pmp_state.pmp[pmp_index].cfg_reg =3D val; pmp_update_rule_addr(env, pmp_index); return true; --=20 2.34.1