From patchwork Sat Oct 22 07:18:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7181 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1088845wrr; Sat, 22 Oct 2022 00:41:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4XVq4B86twtujcO37oiumqpliiXKVjyu4Wa5Blnn1gwzFwI1SC6/F4kPkV2/QeaJHF3reE X-Received: by 2002:a17:902:d590:b0:185:4875:ae29 with SMTP id k16-20020a170902d59000b001854875ae29mr23456676plh.27.1666424485512; Sat, 22 Oct 2022 00:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424485; cv=none; d=google.com; s=arc-20160816; b=mPn973QEVb3OQJYV7SW9OUzriiylQF7bcjZ7o3hPYE9fyQ5WgFZ4xyap4x6tEpeT0L pycMNqrHJKWGciundkaS6hkHR7OJMKGCslRzndMxHm9sBJ8TFn5tBxWS6DLBX1cpgUeZ Nng8/ojRqMAl3goGEM1xUuJP1Aa6uP9l2P0V/10d6fWWFUzpsbKv6Nyd427Gw5W2cx6m TMoDfwPM3AxVZLD8JJ+T5qMofSMEcSfvWaHLb8PffUqhVoEM0F9ZVp4ib4SNZgdw7bXM GjW4ue8Pnz11t1eFUaM9e8FbUxYvZ7p8TROOoLYbiQLmxGZNs5OkYdnZAnUmtmaeDLtj th6w== 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=DaVM4Oa9mS4wpaJ27y4vhKtHkLT5ZFjoakObOq53NliKUflaW1QDFAM74pXfj47WKv bUvtCAXksT/jkbySXCcW19qMnKESSS775/vDLJKM5uyCMZkSr2zvfxM4E/BgwvQWzH36 qk/buqJMwo9FpQvgl7Dh+VhrxxC8aIjXnAimQa5ZB8sHnqLf4sBtMr2OzhZlORbBtH9R xm99JBtXRdE0tdLdkWmnGnNEaQKMU70AzRTpOTvhWH6WPf6kszqbNyqb5F6vai3ZnA3m aIzWb5HhwOUGVk27eV/B8a9cZwnIlXFFsUzk66lS5MbYS608TjxrFwHwel4qQs1VVIzf RKxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AWvwpMjv; 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 cj7-20020a056a00298700b0053b9c18617esi24239308pfb.300.2022.10.22.00.41.13; Sat, 22 Oct 2022 00:41:25 -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=AWvwpMjv; 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 S230466AbiJVHkc (ORCPT + 99 others); Sat, 22 Oct 2022 03:40:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230522AbiJVHjb (ORCPT ); Sat, 22 Oct 2022 03:39:31 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 336112B3AD1; Sat, 22 Oct 2022 00:36:54 -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 sin.source.kernel.org (Postfix) with ESMTPS id CB5D4CE2C9F; Sat, 22 Oct 2022 07:36:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2379C433C1; Sat, 22 Oct 2022 07:36:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424195; bh=/2VWHXxCuruU2Yfpldt0LZ8uSfriJfdzL6Wr0+OwWB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AWvwpMjv8oTrbDFqZN7+egBDOF5kbGVZIuYiyYcjssImf/milucUZTdGZZfWlRcB4 MRG5K6v/MX4kHAsjPEJgw3fYAKUR0hZVy3p3AUJLJP3KDLFNVnsTf5ZLZo6z3KMeLd x6fh6TknIncW8UezyLa95EmYwrAgOWjRqKmzmegU= 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 5.19 057/717] riscv: Make VM_WRITE imply VM_READ Date: Sat, 22 Oct 2022 09:18:56 +0200 Message-Id: <20221022072425.164960595@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747372721699473952?= X-GMAIL-MSGID: =?utf-8?q?1747372721699473952?= 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;