From patchwork Wed Oct 19 08:22:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4549 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp204306wrs; Wed, 19 Oct 2022 01:45:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ywn0lTr1gr+3n/FwTGlcwHfqmu3ZbS5Qc2w7//zb40u1VHRx+iC1qgENV7+bCNOmk40E8 X-Received: by 2002:a63:8a4b:0:b0:460:7c54:1b2b with SMTP id y72-20020a638a4b000000b004607c541b2bmr6246765pgd.499.1666169146096; Wed, 19 Oct 2022 01:45:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666169146; cv=none; d=google.com; s=arc-20160816; b=n3EE4fikpH8/Bf2riilTyRaOKwztAMIlXUNuEy4li9+ty9knDhjXNmkc6PGuAhVW0d n3N9vQCRNUwwxqBVxXDNy0MAlVcf1gaVErypykg4+7ig95PF4PTF/BuyqrbQGBIrUyh5 dhft6Wke6aa3m95My0CKXSm+p9Oxh7Snpn+gWv0gpu0JjQrynVmtqaDOOpbORSGR7Q6H aI79FNZbBCg3AAnI4+mBhPzuX/jxm1o2cMdHrSCHs9+DN3BFWB6O/o/+Tcg4Ec2kbVRQ /2XZ3egPBP1zg1EP4y/tCcSUQafKdKnOOkk71Arrsenawc81RFlQcEIyu9IeGpQePIAI Xa1g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MpoxWs+4RU7KPgafbWDZ7saYeqOSfW9VdtPGVQPSOUU=; b=0kTOEfTbx5+Cv1ZS2XnizOcmG/6GW863s/OB+RaE/HcVwJDjEDkoZHamkM9uZsqugN CqXk4rChKvOsf+3zcuUtg1cCqelAIl+kKADoMHBbe1veQgUhln1le7osnovWaeKG6TtR 54Ayk2gZZEi4jkaK/QOLt14FxybjCqWHgfvdCgnHueDfvQaPMbshTmcbjzpTAwS507S0 oMrPczSH504ECIIlp6r6ps9MN0wocJXyTT1Q5rsFeldiDj2SXcS7BUckAHl2ZDwWDCCw N1V72g0GxIR2VjjnaQb93b7KeUa9Pg0V8z689T3Slxns7BapP4r2bHUoO4xzwKiRZT+c kFMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EsIoLqH7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t186-20020a6381c3000000b004624e24b4e9si17241062pgd.543.2022.10.19.01.45.31; Wed, 19 Oct 2022 01:45:46 -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=@linuxfoundation.org header.s=korg header.b=EsIoLqH7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231395AbiJSIpN (ORCPT + 99 others); Wed, 19 Oct 2022 04:45:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231315AbiJSIn5 (ORCPT ); Wed, 19 Oct 2022 04:43:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 150DF88DC3; Wed, 19 Oct 2022 01:41:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 45E2E617E4; Wed, 19 Oct 2022 08:40:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 376DBC433C1; Wed, 19 Oct 2022 08:40:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168820; bh=/2VWHXxCuruU2Yfpldt0LZ8uSfriJfdzL6Wr0+OwWB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EsIoLqH7fJ3Wx81UjXoOXSWOK9qPpPu2JEEBOoUO9U+lVGrFPs4yDXbn2Em8pnuwc mPpp7YtqYhco61AsUVbERHnvv0BP4AnYHDawelFUosMW+iZ7WXJ3BOj9qXR+gniUGW 3/2O22qccp5dy1RmNUqP2JwQezUAATW1a3eT2mDg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Atish Patra , Andrew Bresticker , Palmer Dabbelt Subject: [PATCH 6.0 063/862] riscv: Make VM_WRITE imply VM_READ Date: Wed, 19 Oct 2022 10:22:30 +0200 Message-Id: <20221019083252.727982018@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747104978409955259?= X-GMAIL-MSGID: =?utf-8?q?1747104978409955259?= From: Andrew Bresticker commit 7ab72c597356be1e7f0f3d856e54ce78527f43c8 upstream. 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") Reviewed-by: Atish Patra Signed-off-by: Andrew Bresticker Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220915193702.2201018-2-abrestic@rivosinc.com/ Signed-off-by: Palmer Dabbelt Signed-off-by: Greg Kroah-Hartman --- arch/riscv/mm/fault.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/arch/riscv/mm/fault.c +++ b/arch/riscv/mm/fault.c @@ -184,7 +184,8 @@ static inline bool access_error(unsigned } 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;