Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1604474rdb; Mon, 2 Oct 2023 15:11:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFmbU4KmhfliIyLQ/ca8VTic5ctgWpQORv0Z8Fj4GpaE1n9/JTHbs3//lzCydAj5OHFHEA X-Received: by 2002:a05:6808:1524:b0:3a7:b4e8:563e with SMTP id u36-20020a056808152400b003a7b4e8563emr18215547oiw.38.1696284676088; Mon, 02 Oct 2023 15:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696284676; cv=none; d=google.com; s=arc-20160816; b=V53aNAcFvi5XUSsc/rOtEHQ2SEBEZ/r3E0a2o6w0CfVejapZhvUiD7axImIw++/Jse DYTGJ1k2OrgMOrOMXsWVKjL7mYRUGmJrNqo6VvUBoZGfh86VaRDj/V6cDjLeMdtesNFl Ju2Imu13vnzoc6JoHqiC+l+QFK/DG1kvO8dFt34XnCzzW2BpW//IOf33X1MtjYiqEzbF /mwqDMPFI4hJrjcvWmKOcXRNYv2xhPb2ZeWpDSAT2j+E69mED8dpTgnamlLL1brO7lmA QpB/k8gqqKugA7HRp1j4987zbCs8ozwUABvvi7PfiSKovWd7FZY61lIng5PLCeVLsXRb xNkg== 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=BviuOqu94hunsSO/3Ul5WhMTTjDvZpGvaCCYOAqyBa0=; fh=uXvJMJMnIF8WaKRrdgquas9RQiOXXOyuQb5203rEpB4=; b=ICJAuQM9WZCwrzzvOL8IxXygWff32Q9uYv2baLCx5pa1zP/Z9dth8E9Dx37zWg2Hir vPuce1sLgzhMDcbLJ8PGqQWk1oucTdg/86wCXy8kfI+uMLnwunZOnDlYS8jd2chQ6Bax BhnekKsabzKNCor9TYfwP9qGNgdHY4Hm+S5rAD8k7vjexc6NMfkyB1FexePdv+OHZrLE 1d0MwlS+U4SOzi0PXcztRQMimDssjuh33Lj9qHsFtwU/LgOVZgmXM6WSBYlRByZioH2d IDG3uza1a+JF+ckYbiWvY21mjm4uTJse5H/ZgwpMAl4BcrrCTFhPaBifhiJz2BUGj7iF LKXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=bU8XSnAy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id lw2-20020a17090b180200b002792c288cc2si9231448pjb.170.2023.10.02.15.11.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 15:11:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=bU8XSnAy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id E60DB80756C2; Mon, 2 Oct 2023 08:10:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237962AbjJBPKn (ORCPT + 99 others); Mon, 2 Oct 2023 11:10:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237950AbjJBPKk (ORCPT ); Mon, 2 Oct 2023 11:10:40 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A694583 for ; Mon, 2 Oct 2023 08:10:37 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3231d6504e1so12623631f8f.2 for ; Mon, 02 Oct 2023 08:10:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1696259436; x=1696864236; 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=BviuOqu94hunsSO/3Ul5WhMTTjDvZpGvaCCYOAqyBa0=; b=bU8XSnAyHcGPOJvJzjWf35Sj21egS4oTZnBl/V+y4kfUOo6aTkGD/4q7Fnn4jnGp/2 c7U/1vdLd7odd/NILraXy6xfFl+mojvHCjARfLqr6vmLSY1o1ZnBGYoYKwsUm257tWaR 4PqPngiRYDboNRY9oTTdSef6pO60zGyyEonP+5993kfYlXcuGeIXIpv05RSSR9YKMVYI irVhDRDoQgfoFfG4cmS1XeS8g0abGtQ/sBAwqqv/ao7un7UiFzrEjjV6Hp+10EJEn6W1 5CZ9j3iyvUCPHGRXAQUn9MGht0b8l4UwIFP8n8WxO0XBnJuq7PAUmrP9QA4yOismJX0K jq+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696259436; x=1696864236; 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=BviuOqu94hunsSO/3Ul5WhMTTjDvZpGvaCCYOAqyBa0=; b=LxzKVY2BmI9lEJYSnvRV7Dn9EhikemOvRzZ43GhltDyzpBGlryd5d7qoGWWriTtoWZ 4wy/5Nnkt8jfD+p1H+aVmPyRQbkI0KOEvrgcEbMuhKfqWcECJz4hH3fywVx12+cmduJM hb04ENgKJmXQx+d0m1p/iiqlNGLZPXAnGkN0BKYcpq1nXcMi8A7buSlf7qjW+2O9qUAG KiEZUAk+o5Gj/qY622Nx2XC9/hgHyql4ZVQEM1js77RXVhcIZHH8sxg9Ng2eNf6cmR5Y EX4a9SxgMib1PFhn/71ID79EXDtIInjoUfa6HlJ/sufCnony9b1cxFACj/298C0Ag0Ru dO0w== X-Gm-Message-State: AOJu0YwdtFen50S3fzMLqaheWKNf1LyURsDNiPxmZIqkasxRwS7oUb8r Hw5oGwNrFIDQEQKpdawGKOve1A== X-Received: by 2002:adf:ea8f:0:b0:320:1c6:628c with SMTP id s15-20020adfea8f000000b0032001c6628cmr11378844wrm.65.1696259436015; Mon, 02 Oct 2023 08:10:36 -0700 (PDT) Received: from alex-rivos.home (amontpellier-656-1-456-62.w92-145.abo.wanadoo.fr. [92.145.124.62]) by smtp.gmail.com with ESMTPSA id b16-20020a5d4d90000000b0031fba0a746bsm8493981wru.9.2023.10.02.08.10.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 08:10:35 -0700 (PDT) From: Alexandre Ghiti To: 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 0/5] riscv: Use READ_ONCE()/WRITE_ONCE() for pte accesses Date: Mon, 2 Oct 2023 17:10:26 +0200 Message-Id: <20231002151031.110551-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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 02 Oct 2023 08:10:46 -0700 (PDT) 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/ Alexandre Ghiti (5): 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: Suffix all page table entry pointers with 'p' riscv: Use accessors to page table entries instead of direct dereference arch/riscv/include/asm/kfence.h | 6 +- arch/riscv/include/asm/kvm_host.h | 2 +- arch/riscv/include/asm/pgalloc.h | 86 ++++++++++---------- arch/riscv/include/asm/pgtable-64.h | 26 +++--- arch/riscv/include/asm/pgtable.h | 33 ++------ arch/riscv/kernel/efi.c | 2 +- arch/riscv/kvm/mmu.c | 44 +++++----- arch/riscv/mm/Makefile | 3 +- arch/riscv/mm/fault.c | 38 ++++----- arch/riscv/mm/hugetlbpage.c | 80 +++++++++---------- arch/riscv/mm/init.c | 30 +++---- arch/riscv/mm/kasan_init.c | 119 ++++++++++++++-------------- arch/riscv/mm/pageattr.c | 74 +++++++++-------- arch/riscv/mm/pgtable.c | 71 +++++++++++------ include/linux/pgtable.h | 21 +++++ 15 files changed, 334 insertions(+), 301 deletions(-) -- 2.39.2