Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5570040rdb; Wed, 13 Dec 2023 12:30:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IG5oC/OxgA5yVOToFsgtLzziHAxXTtxacnbBKxEEpuiDAQoxX5ngG9NKE/aWLkflH0Nchlw X-Received: by 2002:a17:902:7891:b0:1d3:5701:375a with SMTP id q17-20020a170902789100b001d35701375amr917935pll.36.1702499444559; Wed, 13 Dec 2023 12:30:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702499444; cv=none; d=google.com; s=arc-20160816; b=0aOLtbagQTAhsTOn08ANc0A+dzOzu5CPQ/6hHdUXkutVMoxKbCNE+WQ800xHkkbVL0 spAlX/bAab8rvDpvcSDprXdI9aE5gktsXTjYg8gALbOHYvhWmrkWSLkRMbMlmOy/M1Iw r/nkUgqYQABUttAchW2YRCdBBfASorRX7jOgFaz9vDMl+ml3EaZ/3qkDMDYdhm+lltGV KnFDJoPhZJxROiHHaBRPb5ydmUGN8el9YvCtTL3rAPffRjjOsOnJ9a9wci+O9isw5x+G U5RzutcnidQsRSZMhpESM1o+l1FkGDvji8PxXFnxfRdZiDV7RVC/yF5Hob2GLfoZqLgo UZAQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=i+467Loz3LrvYEdXAV5s12LMqcUY9odwCyEv1IdVOvU=; fh=IGropsY/f620dSTjnkF1U3l/yVuB1Ulli/O+nFZzzpw=; b=FvxKL3B2GO6+5b7bAdV2Bk5nkcqIjJMJKWsx2ToR6A7jsGbKitFl8JwiDEw8R8QkGj qr78zeBYAJLBxWDQPFjjKIRJV5X3VNPI1oSTCYT52Xu0KHXI8WquyuUGdIccJFttc1o7 3MgU4YwyjU1WivR0fNPOYR4K2/19lbRnB6SreAZyM/jXXg0CGI+TbWoHQ9ArlaGrgoMb FQ/a16VQiTh5XAnvI+uCpY6s9IRo29YluK3su6Ib4dl7sfbZTwxDgsNSIVCNOA66g5Bl ShwfO5NaS91Aab4k54gs/deVsWkH3PNiUeiyXjGry4XJbNK1I/ap1q7hZJwoH7LVAQ6q 7C9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=gZ68dQNw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id h14-20020a170902f54e00b001d00a56b03asi10305463plf.337.2023.12.13.12.30.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 12:30:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=gZ68dQNw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 86F4C80774A8; Wed, 13 Dec 2023 12:30:34 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442593AbjLMUaP (ORCPT + 99 others); Wed, 13 Dec 2023 15:30:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229671AbjLMUaN (ORCPT ); Wed, 13 Dec 2023 15:30:13 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8D97128 for ; Wed, 13 Dec 2023 12:30:18 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3333131e08dso7839290f8f.2 for ; Wed, 13 Dec 2023 12:30:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1702499417; x=1703104217; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=i+467Loz3LrvYEdXAV5s12LMqcUY9odwCyEv1IdVOvU=; b=gZ68dQNw/RKx0d/oICoetz555Ra/uNpzcF7W/+PXeUdEN8b28FE0zRdTMG7aZcvOd3 khRv3oWfsZ8UFA3eDrp8OWX0SgZQb4PHzky2v/sMMIgKbOJVVs4lY5FXM+RqFemkmXsu fV8tPbNPboESY07Bv6Bb5vQnFSCSDITsEyyLGf/D4TOiDiWLydRuU6PemOJMXrckW41Y 6ehCVKWYTa9883sRrWJzRXxEiPtzrv0hPQvjFyuEhVvxwXRrS285HsCrPyTrmEQt1JXg IVaGD8fJ0oQbSL3OpHtATR3by/loi94TtYmySiThArcC4hEQ4UMXNWEgLLPIqW56IoCk MKgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702499417; x=1703104217; 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=i+467Loz3LrvYEdXAV5s12LMqcUY9odwCyEv1IdVOvU=; b=tBDDylFX+FeyOyVuPMCBA8stSFGC6QR5rjUeqeBidQmU/cugAmLg1mzYfph88+/sed EqUK4Ztnxlk+1HjXp7qaiRnkcIxxN0UexM5nuY6mtUQtIp1ZQdgb/zOz8plJ2hbwLb/A bn6z8pIja4Ym6XTut5hTkDwZK1QIA3z78e6ZyYZW/j+SFrJiE+M92dRX059hFvZnBsA9 P1BMf6UN1xSkymtSJuRAY9Q+L5ZKH4wije3NfCqSFh80WoocgTduFL2lDgxFOgerH8K8 VeqFC3zPXhtjyWpfxM0jZE9h3ZZVqvy6SRop6LZeuhUfbc+7iNIMu0GifovraqAbDgnI 86+w== X-Gm-Message-State: AOJu0YxM/QMw6o+gfIfzqt5jTGCV8tpL8ABHpRRxXZOZ98upDH4gqosx k14U92OYkMTUBAhIB2pgG6woSQ== X-Received: by 2002:a05:6000:10c1:b0:336:38ef:1e91 with SMTP id b1-20020a05600010c100b0033638ef1e91mr917003wrx.128.1702499416911; Wed, 13 Dec 2023 12:30:16 -0800 (PST) Received: from alex-rivos.ba.rivosinc.com (amontpellier-656-1-456-62.w92-145.abo.wanadoo.fr. [92.145.124.62]) by smtp.gmail.com with ESMTPSA id x10-20020a5d444a000000b00336371fafe6sm2945256wrr.16.2023.12.13.12.30.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 12:30:16 -0800 (PST) From: Alexandre Ghiti To: Russell King , Ryan Roberts , Alexander Potapenko , Marco Elver , Dmitry Vyukov , Paul Walmsley , Palmer Dabbelt , Albert Ou , Anup Patel , Atish Patra , Ard Biesheuvel , Andrey Ryabinin , Andrey Konovalov , Vincenzo Frascino , kasan-dev@googlegroups.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-efi@vger.kernel.org, linux-mm@kvack.org Cc: Alexandre Ghiti Subject: [PATCH v2 0/4] riscv: Use READ_ONCE()/WRITE_ONCE() for pte accesses Date: Wed, 13 Dec 2023 21:29:57 +0100 Message-Id: <20231213203001.179237-1-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 13 Dec 2023 12:30:34 -0800 (PST) This series is a follow-up for riscv of a recent series from Ryan [1] which converts all direct dereferences of pte_t into a ptet_get() access. The goal here for riscv is to use READ_ONCE()/WRITE_ONCE() for all page table entries accesses to avoid any compiler transformation when the hardware can concurrently modify the page tables entries (A/D bits for example). I went a bit further and added pud/p4d/pgd_get() helpers as such concurrent modifications can happen too at those levels. [1] https://lore.kernel.org/all/20230612151545.3317766-1-ryan.roberts@arm.com/ Changes in v2: - Fix the kernel test report on arm32 - Remove the pte suffix patch - Fix pud_offset/p4d_offset which were missing the use of accessors - Rebase on top of 6.7-rc4 Alexandre Ghiti (4): riscv: Use WRITE_ONCE() when setting page table entries mm: Introduce pudp/p4dp/pgdp_get() functions riscv: mm: Only compile pgtable.c if MMU riscv: Use accessors to page table entries instead of direct dereference arch/arm/include/asm/pgtable.h | 2 ++ arch/riscv/include/asm/kfence.h | 4 +-- arch/riscv/include/asm/pgtable-64.h | 22 +++---------- arch/riscv/include/asm/pgtable.h | 33 +++++-------------- arch/riscv/kernel/efi.c | 2 +- arch/riscv/kvm/mmu.c | 22 ++++++------- arch/riscv/mm/Makefile | 3 +- arch/riscv/mm/fault.c | 16 ++++----- arch/riscv/mm/hugetlbpage.c | 12 +++---- arch/riscv/mm/kasan_init.c | 45 +++++++++++++------------ arch/riscv/mm/pageattr.c | 44 ++++++++++++------------- arch/riscv/mm/pgtable.c | 51 ++++++++++++++++++++++++++--- include/linux/pgtable.h | 21 ++++++++++++ 13 files changed, 157 insertions(+), 120 deletions(-) -- 2.39.2