Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1294660rwn; Thu, 15 Sep 2022 13:27:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6kcZU2fse2S9ZtdJ+7gNlk0qYvBVQ+GjXxvnQ1NhwBAXdsnZdGaTnDSlR4gMoFWjoAe80S X-Received: by 2002:aa7:de91:0:b0:451:ecf8:e3b6 with SMTP id j17-20020aa7de91000000b00451ecf8e3b6mr1329992edv.402.1663273644673; Thu, 15 Sep 2022 13:27:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663273644; cv=none; d=google.com; s=arc-20160816; b=rQcpiFget51WNpNrPVCeNpEaxbgzeoj3NBnlOgc/sqIB/sxbu4sSt5RGRbXuO6wJ37 PUMXfrOmbOMU04TqPhwHEkT3GpU0J56BL8pXasS0eQmxAvzbHZjdW1FpfXDPo/gVaf8b 3+rTPnaKrjsdN+Z97dpUqYSiv3QghbtfMDx6VQSJlTGT+z4QDTq0dRqJYFBnlxdx498w gdEtS88xsv6mUv2HIlLin4TieaHuiWwP8Nqo8HHcr/8989AnA9mS82v+uqGCS6Hw8k7N RdNC21mrboxmuslE5D4z11mnVNisdrXKnVwemseMQO7+DILKVrni2ADvI/feDjRjxHvr uxwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VhWltIWQGr4otQw1ais9xJMa50uESeMiXqro3LvTwg8=; b=qcv7pvPjaBsvl2DHuxMeD3Wj5lb9znPYbz+XFTBAqcOt5ENirodcUMx+bzp7LXPviR u0NZzOs3XJqQhnZllL19u6M92RovoDWSRV59P1eJ0Ghpbc6wzkjmhO7ViGw0BY9E7Rvt iHHWdaBAUhvj+q3y0X1S3KYH5ejrIAq+3rFVF+Oppciqf10Uu7bC+yTDciO/zk8gbWrS SW0m7gBZgdrWhp4fRtouu2Fjjn3MZdfq1oMyaSJ1Gh4/KWPL6dPNjqa8C58aFxYoz9aB aXvlHuH6HLIHLj2pKCjnwbFyF6yr6YupoTj5peKPvJfCz1ejf0JdXjjTSXT1YuTAhoo8 x8RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=ZOzER003; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j23-20020a1709062a1700b0072e6774827asi13326183eje.915.2022.09.15.13.26.59; Thu, 15 Sep 2022 13:27:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=ZOzER003; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229471AbiIOTmC (ORCPT + 99 others); Thu, 15 Sep 2022 15:42:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229961AbiIOTlW (ORCPT ); Thu, 15 Sep 2022 15:41:22 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4806D9F777 for ; Thu, 15 Sep 2022 12:38:15 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id 3so13765121qka.5 for ; Thu, 15 Sep 2022 12:38:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=VhWltIWQGr4otQw1ais9xJMa50uESeMiXqro3LvTwg8=; b=ZOzER003YVUI0wX40DWwfYnP8PmDaWJ1GUNNHRfVg+RBqRnDWZhobIt10jbRXG8ikP 34RlHzRathp0u9FK7XGi0BLgao/yNkGHKjbQLgAQez8U/Fhwf9EYBjieRXyIlHh6xXY2 OevX6u1otUPcmldEFrNI5xLckhnjUCJ0SfDqAcm4iJwRkTv239iIvcgO2kRWb8jlWWs5 5j9nX8N+bM4li1mPoUvQv3damgywG3DWnKZ/rNZkmx3EnWm9jeo6MomLeWsIqSY88BrG D2mcSfMSddHnyLQjz6qPki3X548HVK9mZUvsHKjjIfayptk1JD4au5JFBBJkao5Oi76J ro+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=VhWltIWQGr4otQw1ais9xJMa50uESeMiXqro3LvTwg8=; b=B0w4x1aHVuJSi1N756XIaxmCSe51X7lS2eAVtzzDh1YQuRE1h633eq1XONyCbOBufA 8TShn38iIm6msqLTNhyb+Peu9te/90IoX1al6aeHwFvBUTjxC39CnWBCAznsmb2Buisa WkmnKoWDJOuMC2J+YJUYDEC9157KOGphts0sbih2Ot29ElIof8Z+w6OfClpKFn8pSHJ9 DK3wstH5KK9az6fCeO9NrFpOaPtFMrJ/L+dp0Qu1S53M2LAVuOW9FYAMAsX09P7dXWxs pOD6bBnqmZBq+LXILpllZANwIK9zyGipQk7hmiZogLleAwC/ARMYsJAtUUC3F7NfK8wR 3O3w== X-Gm-Message-State: ACrzQf0os7eFCpggmyCxTjqdjoKTBK9uWLE8x6E0U2gpgVo71dGtCw6e HEPThsYOxvB/LeNWSNhTWYagEg== X-Received: by 2002:a05:620a:40c6:b0:6bb:3d30:735 with SMTP id g6-20020a05620a40c600b006bb3d300735mr1394165qko.653.1663270635403; Thu, 15 Sep 2022 12:37:15 -0700 (PDT) Received: from abrestic-xps.ba.rivosinc.com (pool-71-105-112-35.nycmny.fios.verizon.net. [71.105.112.35]) by smtp.gmail.com with ESMTPSA id r1-20020ae9d601000000b006b872b606b1sm4596459qkk.128.2022.09.15.12.37.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 12:37:15 -0700 (PDT) From: Andrew Bresticker To: Palmer Dabbelt Cc: Paul Walmsley , Celeste Liu , dram , Ruizhe Pan , Conor.Dooley@microchip.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Bresticker , stable@vger.kernel.org, Atish Patra Subject: [PATCH v4 1/2] riscv: Make VM_WRITE imply VM_READ Date: Thu, 15 Sep 2022 15:37:01 -0400 Message-Id: <20220915193702.2201018-2-abrestic@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220915193702.2201018-1-abrestic@rivosinc.com> References: <20220915193702.2201018-1-abrestic@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: # v4.19+ Reviewed-by: Atish Patra Signed-off-by: Andrew Bresticker --- 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