linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Bresticker <abrestic@rivosinc.com>
To: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>,
	Celeste Liu <coelacanthus@outlook.com>,
	dram <dramforever@live.com>, Ruizhe Pan <c141028@gmail.com>,
	Conor.Dooley@microchip.com, linux-riscv@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Andrew Bresticker <abrestic@rivosinc.com>,
	stable@vger.kernel.org, Atish Patra <atishp@rivosinc.com>
Subject: [PATCH v4 1/2] riscv: Make VM_WRITE imply VM_READ
Date: Thu, 15 Sep 2022 15:37:01 -0400	[thread overview]
Message-ID: <20220915193702.2201018-2-abrestic@rivosinc.com> (raw)
In-Reply-To: <20220915193702.2201018-1-abrestic@rivosinc.com>

RISC-V does not presently have write-only mappings as that PTE bit pattern
is considered reserved in the privileged spec, so allow handling of read
faults in VMAs that have VM_WRITE without VM_READ in order to be consistent
with other architectures that have similar limitations.

Fixes: 2139619bcad7 ("riscv: mmap with PROT_WRITE but no PROT_READ is invalid")
Cc: <stable@vger.kernel.org> # v4.19+
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Signed-off-by: Andrew Bresticker <abrestic@rivosinc.com>
---
new in v3
v3 -> v4: add Fixes tag
---
 arch/riscv/mm/fault.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
index f2fbd1400b7c..d86f7cebd4a7 100644
--- a/arch/riscv/mm/fault.c
+++ b/arch/riscv/mm/fault.c
@@ -184,7 +184,8 @@ static inline bool access_error(unsigned long cause, struct vm_area_struct *vma)
 		}
 		break;
 	case EXC_LOAD_PAGE_FAULT:
-		if (!(vma->vm_flags & VM_READ)) {
+		/* Write implies read */
+		if (!(vma->vm_flags & (VM_READ | VM_WRITE))) {
 			return true;
 		}
 		break;
-- 
2.25.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2022-09-15 19:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-15 19:37 [PATCH v4 0/2] Make mmap() with PROT_WRITE imply PROT_READ Andrew Bresticker
2022-09-15 19:37 ` Andrew Bresticker [this message]
2022-09-15 19:37 ` [PATCH v4 2/2] riscv: Allow PROT_WRITE-only mmap() Andrew Bresticker
2022-10-11 17:04 ` [PATCH v4 0/2] Make mmap() with PROT_WRITE imply PROT_READ Conor Dooley
2022-10-13 21:01 ` Palmer Dabbelt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220915193702.2201018-2-abrestic@rivosinc.com \
    --to=abrestic@rivosinc.com \
    --cc=Conor.Dooley@microchip.com \
    --cc=atishp@rivosinc.com \
    --cc=c141028@gmail.com \
    --cc=coelacanthus@outlook.com \
    --cc=dramforever@live.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).