Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1397034rdb; Mon, 2 Oct 2023 08:20:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGFcdqPFvuIlrKqMWdbNUmQrd33ulVtyUKEGB1apwVIultM3FYjyD9lJD3NErVnxuL08Oco X-Received: by 2002:a17:902:b58c:b0:1c3:3347:996e with SMTP id a12-20020a170902b58c00b001c33347996emr8879092pls.23.1696260053327; Mon, 02 Oct 2023 08:20:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696260053; cv=none; d=google.com; s=arc-20160816; b=RKwlOK0dCrzIYhUNjDIxFq84Hax9IRZ98L/E/+sK0S+XzcBxS4lE57pu31xOhTRAEA PAFqOSJlw42Y4MXebW13q8SEbp6A9z8ZAho4Rm3KWEB0unNfD6X9ML0HXBQCkc5hv+vR oNVyENQJjT+8/htl52OBaqixA4M1HqmnQ107ktetJhipSVtRuE5nP2YHBZCrDOnlbVYl eghwR+zVpJUn9e1DI7aHKHGMV4OG7ErJWg3b1IhMUqCu6Ab7FwbKgNNRBwmElGIGeuYc zQe2PTSiEgwomQqaKGlw/0SiLkt7rYQieK92T60ZBtMm4TgAsU/Ft/SkMSMNxhyOFwwu SI8g== 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=WAROWeuegt9axYlR2gFhUBC1uOuBg0VWiNfGep/WqRA=; fh=uXvJMJMnIF8WaKRrdgquas9RQiOXXOyuQb5203rEpB4=; b=jApkv9HS5SOaD5DaI8CO7ViesaDOlZTOp97Nmz5EZEMi0YV3hg+J3a4TpWWuhCE5UG 8Vn9TlwuEJ+grFLUTDLAB+tE/kwP8Z8PmFdZCTaLqqe/aVBQhM/KhzLmS+gg26y07Kog Z64GxRyerNfte3llMgS25W0NADMKB8IWf8xsvAhyetzd+Cmbffv2qg8cQnrESsc3O6KI heeK3qK202HI1JaxsfL9d3ccnJwy3ySx5rI6ACvt2JeeYAWi//c1cJd3dZgZ0RSlzy+f WsXfw1zsuQU7N275moO8Xa9NeZM9CEowm+Tw/rO5gue4HpSvmgultaj5RM+xbftsRa44 c9CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=aBt1BOFY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id k17-20020a170902c41100b001b9ffda162csi1983898plk.441.2023.10.02.08.20.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 08:20:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=aBt1BOFY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 7E6868070EDE; Mon, 2 Oct 2023 08:13:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237978AbjJBPMr (ORCPT + 99 others); Mon, 2 Oct 2023 11:12:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238024AbjJBPMp (ORCPT ); Mon, 2 Oct 2023 11:12:45 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4B56E3 for ; Mon, 2 Oct 2023 08:12:41 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40675f06f1fso5112115e9.1 for ; Mon, 02 Oct 2023 08:12:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1696259560; x=1696864360; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WAROWeuegt9axYlR2gFhUBC1uOuBg0VWiNfGep/WqRA=; b=aBt1BOFYLz2ZaBfzM6ZWaQOKieiR7xa/dQgV8zhD2OMupWx3kSjuovSNU3T7pR7P8h UUry+gkB1953S526Mq406JtxnbvTVM0ZmnoSecbdAIoSGzn5LYSTOVz/UCIyHWRlXClv EkkJp6733k9etHyRXeA81fWz72ktgNXOBEqtbSiz+uS+RkfiL2jxHUv393LYNmfYeepz x1rJ4y8O6J3qZDMjNEoLLAb3mbxESR4iIiELmOfe8fju27VeV4pIUuOmxf0tVWQrG4AS IROkos672qQpO2gKzCId7eC63UeVTQ8OzIsK9yNUFdspgreX8G94B1lb+VF/SybJ0lsO PFMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696259560; x=1696864360; 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:message-id:reply-to; bh=WAROWeuegt9axYlR2gFhUBC1uOuBg0VWiNfGep/WqRA=; b=cecKA84wBR87Acx3jqdd5EruopqjBfjsfv34PpTBsN+MPLcBCW4nUIaWKzVJks+h7S +hHrBFTjlMwEQh5lMvQIsYlV/8ETlKZru3kZ4koHoQ72ZAhFqSENV7PDODYpBeH2zh06 /U6N53kbnUl/zs2JR2zZf9Zgo1zBdN/N5lp9I7l0SyKqAdUxzBcJmzRHGnrz5gbmDxaL TiCuiQ6tQO0/hYt7nnipAMvoPSpIjYOi+FIZVg3pD9khPFq2SJ/th+wCd9OM9aDnnOLR 0P5Blha+CE+dnGfSdwZFUWf6FPQMxabqq3M5IQ/agumEz+guDa41Cg9rn1tggu9j/+oL IJAQ== X-Gm-Message-State: AOJu0YyUk7vJrYIn8I5jbvv1Bb0Uo8+XXmu86AgJscY8glFsCcUkSSNi la8Guxc/jpOWVS+x+eYvu66UzQ== X-Received: by 2002:a05:600c:5022:b0:405:3f06:d2ef with SMTP id n34-20020a05600c502200b004053f06d2efmr9800701wmr.4.1696259560252; Mon, 02 Oct 2023 08:12:40 -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 l5-20020a7bc445000000b003fbe791a0e8sm7507939wmi.0.2023.10.02.08.12.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 08:12:39 -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 2/5] mm: Introduce pudp/p4dp/pgdp_get() functions Date: Mon, 2 Oct 2023 17:10:28 +0200 Message-Id: <20231002151031.110551-3-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231002151031.110551-1-alexghiti@rivosinc.com> References: <20231002151031.110551-1-alexghiti@rivosinc.com> 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Mon, 02 Oct 2023 08:13:04 -0700 (PDT) Instead of directly dereferencing page tables entries, which can cause issues (see commit 20a004e7b017 ("arm64: mm: Use READ_ONCE/WRITE_ONCE when accessing page tables"), let's introduce new functions to get the pud/p4d/pgd entries (the pte and pmd versions already exist). Those new functions will be used in subsequent commits by the riscv architecture. Signed-off-by: Alexandre Ghiti --- include/linux/pgtable.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 1fba072b3dac..4ce68bcc201d 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -284,6 +284,27 @@ static inline pmd_t pmdp_get(pmd_t *pmdp) } #endif +#ifndef pudp_get +static inline pud_t pudp_get(pud_t *pudp) +{ + return READ_ONCE(*pudp); +} +#endif + +#ifndef p4dp_get +static inline p4d_t p4dp_get(p4d_t *p4dp) +{ + return READ_ONCE(*p4dp); +} +#endif + +#ifndef pgdp_get +static inline pgd_t pgdp_get(pgd_t *pgdp) +{ + return READ_ONCE(*pgdp); +} +#endif + #ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long address, -- 2.39.2