Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp715132lqo; Wed, 8 May 2024 12:28:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWXYWpfgl2mfLg/ObbJAf/mP0W11qwZkmGIrFlMa08oV9dMxzRdimhPJcM1pdbS8r8HPpKtnApfkgD0xEdLMOKKclLxl4UK7BKWNY00KA== X-Google-Smtp-Source: AGHT+IH1fBVl4qc15R+QUZGqhpdtgcV36qshgzzpyPp9nGJtrCBIqaCsVAWAg737B9XhrLqEj+iW X-Received: by 2002:a05:6a20:6f0e:b0:1aa:5ca9:c565 with SMTP id adf61e73a8af0-1afc8d1b1c7mr3424952637.8.1715196499158; Wed, 08 May 2024 12:28:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715196499; cv=pass; d=google.com; s=arc-20160816; b=hSHe8FZ49aTTfDeElUeeZF7ngD122A1KDnvhA0qxnciBxy6BLp9+D/Edkoy3rqV9GD b3glmkVJTaO6CkpeBied5TkMO2COesbPc2FyfQV3ByAB7yi5vJT+02I2Iz96h6tdCghA R60N6stjYhhEN1j8TANZLiLxmOGHDb8P39OBFUzRco2PQ7a2mFulOEp670b9CPsEZ/0j caIWZSIr9z+zirLhg8wVbjelRUurWB6OaYnAJnoFYPB8X7Y5BQBuC+NPr0B79mMOCYnO KDRTeV83tHUaDLRVeSWSBd3Fdn7wz+CGs48sVAWPhwHCZGdqaw6/9JO1IjZulYnvzdi6 xx7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=K1uKlYjMTe4xfHBkLhM4fwrAS4H0Wd2FQ2UyNN+YPgM=; fh=9ZcYtcY+RbTuefCMcZdBZYhMN89q1T/qR4HD6y6s8zY=; b=XdprgTEalYqwmLjT6DE9jp1gqUhZGJsV5olcMtidCTeQYzkcGQ+3emz9bAz1tFoPnY jKBlWWdlghql96nq74rM2CuXqnXk3HvicgM6w6bbC1YpERM6NgqXFWgqVRyH3dP6y7K0 nLoV5Hznvdx8yl+uF0mb65vDExpLfOLLXyTEWM+4+NZyebs2668ek0gVCVTmFaGEC4eA SeDWHFRQi4f3F0Sf9UGSP//F4ARrH+aUwGg8SpFEtTlMUeDb04gmgTlP0pdUlBS4fe/q MHil9+iSfSZpwgtLvNBHxrMnOMq+EM+Dkwc4y6ltPQWyG4fX0O+rmZweFdOsw7E16k4E y72g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="1/i2io5o"; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-173746-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173746-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id lp8-20020a056a003d4800b006f471eb11c7si8162073pfb.223.2024.05.08.12.28.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 12:28:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-173746-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="1/i2io5o"; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-173746-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173746-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 00AD9B24A31 for ; Wed, 8 May 2024 19:19:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D9539130A4D; Wed, 8 May 2024 19:19:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="1/i2io5o" Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E2A7130A43 for ; Wed, 8 May 2024 19:19:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715195976; cv=none; b=VGhoKt7Zp3hfktt+f+byynm/uFbGQJohB1cnkffXfeO8NQJVg4THX+T4gjeKAmBkTRcSLWUup7y1wIF8uHHV7hn89BzIrBKIbFEL6omMLQ/5FXiyyE1edM90h22l4D4nuFjgfbascKypPtSsupJyRsximkfrV7qFiKAoRvxg77A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715195976; c=relaxed/simple; bh=YIVNY41R8E3i0qyQzpYxu5vSIyMEkNoTli1SIL3s7xg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=B9YQmRc6eB7GMm9ekUa/tvk4wWcn93l42GQcLWLUZvNknduHpv5SAmgu9zjrr+mt1tVtjq+to+4d5hik3fv49wr17iJrn6GjgML5Dk3OL3fY6tEJsERzXVrmu/S9Kez+dToHaJqUYiubAMdzBugW5/YxGFAPGHQzFBIRo0y9Pls= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=1/i2io5o; arc=none smtp.client-ip=209.85.208.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2e3e18c24c1so1208361fa.1 for ; Wed, 08 May 2024 12:19:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1715195973; x=1715800773; 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=K1uKlYjMTe4xfHBkLhM4fwrAS4H0Wd2FQ2UyNN+YPgM=; b=1/i2io5o+yUAKNufrkNKnrlHRqEG7ucxRXgpH73zSfgZfkeMZg57mnB621KbEn7E9x LB12510yD8FiUHF+NU2xhSjYmUsksbihYzx49T5XdqR/M/9G5V4kHAlKwW5Nvu3nyX7H d+ttaO01uRO8Tm/DNxzWLYiFduch/OirW0ngKcpbTvYm4kHHdbLBQB1igrhdzp/+aJOd 72j3FRE7xSsVS6sOkyGs7OYiXlH2dF5eQ8/5nylLlDLjjk3ZCtvMxgCLE5mFqEvk0jzr yjT6PCxfvGN6tUEjZma4DuEwtXYHEzk5AlFVNTBUUhSKOeOMkvHmn5HkQzumj9ef1g0t 6tcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715195973; x=1715800773; 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=K1uKlYjMTe4xfHBkLhM4fwrAS4H0Wd2FQ2UyNN+YPgM=; b=FeBmi66/JorgJh/U9DM4q576OTda3+5Kue/kNo1XgkeBg5clrIZtEEQbcQuVn9hE0M 5RTMrm4ymE20mugwpPvw9ebRXMiHaaxWMMrxyVVn5WHYniPo89fa7u/RwiNz9uTkmvQU chmJ1jlefPdwSKiKjK9IwLOVH+AiESLMGVftEHAdQRsoBhmd50XvhDZ9NcqSPb/ETbaK VisevO5uz7/9Fo8rSG+hFZE5B4uReSBNyZLS9jPvKFGJjvXJh3EiJzcFrp+kZRJXvz/z rgAKpw0DmbSH3br2EViQm7Q6U0Cavm11Ji5XhAlIohjpSsojHK2aK4H09KxPYQsvWgyl C7wA== X-Forwarded-Encrypted: i=1; AJvYcCWsm0L+rX1W0TNTQgmLgsb6m5wVCu7dtz4jfj/O89Kw8qh3Bf4F6fXb/SeHLd8M7AaaIeGeQsDeLs0RwKn2XxqYLC5HfGtUF14MKIaZ X-Gm-Message-State: AOJu0Yx730tSETlTpOEuYNsN4hTvnsVKdAYPjfeYLeJ6mCyo9NBRC0AT BTwkdRrNT84cSSB7/ClT9Od9yIzwqt8MMILU8CKFuFldRkJh1N5rgqpUSZVr9AU= X-Received: by 2002:a2e:81a:0:b0:2e0:12f1:f827 with SMTP id 38308e7fff4ca-2e4479a2ca4mr23591601fa.43.1715195973157; Wed, 08 May 2024 12:19:33 -0700 (PDT) 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 5b1f17b1804b1-41f88110f3esm32622515e9.29.2024.05.08.12.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 12:19:32 -0700 (PDT) From: Alexandre Ghiti To: Ryan Roberts , Catalin Marinas , Will Deacon , Alexander Potapenko , Marco Elver , Dmitry Vyukov , Paul Walmsley , Palmer Dabbelt , Albert Ou , Ard Biesheuvel , Anup Patel , Atish Patra , Andrey Ryabinin , Andrey Konovalov , Vincenzo Frascino , Andrew Morton , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-riscv@lists.infradead.org, linux-efi@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-mm@kvack.org Cc: Alexandre Ghiti Subject: [PATCH 00/12] Make riscv use THP contpte support for arm64 Date: Wed, 8 May 2024 21:19:19 +0200 Message-Id: <20240508191931.46060-1-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This allows riscv to support napot (riscv equivalent to contpte) THPs by moving arm64 contpte support into mm, the previous series [1] only merging riscv and arm64 implementations of hugetlbfs contpte. riscv contpte specification allows for different contpte sizes, although only 64KB is supported for now. So in this patchset is implemented the support of multiple contpte sizes, which introduces a few arch specific helpers to determine what sizes are supported. Even though only one size is supported on riscv, the implementation of the multi size support is to show what it will look like when we support other sizes, and make sure it does not regress arm64. I tested arm64 using the cow kselftest and a kernel build with 4KB base page size and 64KB contpte. riscv was tested with the same tests on *all* contpte sizes that fit in the last page table level (support for PMD sizes is not present here). Both arch were only tested on qemu. Alexandre Ghiti (12): mm, arm64: Rename ARM64_CONTPTE to THP_CONTPTE mm, riscv, arm64: Use common ptep_get() function mm, riscv, arm64: Use common set_ptes() function mm, riscv, arm64: Use common ptep_get_lockless() function mm, riscv, arm64: Use common set_pte() function mm, riscv, arm64: Use common pte_clear() function mm, riscv, arm64: Use common ptep_get_and_clear() function mm, riscv, arm64: Use common ptep_test_and_clear_young() function mm, riscv, arm64: Use common ptep_clear_flush_young() function mm, riscv, arm64: Use common ptep_set_access_flags() function mm, riscv, arm64: Use common ptep_set_wrprotect()/wrprotect_ptes() functions mm, riscv, arm64: Use common get_and_clear_full_ptes()/clear_full_ptes() functions arch/arm64/Kconfig | 9 - arch/arm64/include/asm/pgtable.h | 318 +++++--------- arch/arm64/mm/Makefile | 1 - arch/arm64/mm/contpte.c | 408 ------------------ arch/arm64/mm/hugetlbpage.c | 6 +- arch/arm64/mm/mmu.c | 2 +- arch/riscv/include/asm/kfence.h | 4 +- arch/riscv/include/asm/pgtable.h | 206 +++++++++- arch/riscv/kernel/efi.c | 4 +- arch/riscv/kernel/hibernate.c | 2 +- arch/riscv/kvm/mmu.c | 26 +- arch/riscv/mm/fault.c | 2 +- arch/riscv/mm/init.c | 4 +- arch/riscv/mm/kasan_init.c | 16 +- arch/riscv/mm/pageattr.c | 8 +- arch/riscv/mm/pgtable.c | 6 +- include/linux/contpte.h | 37 ++ mm/Kconfig | 9 + mm/contpte.c | 685 ++++++++++++++++++++++++++++++- 19 files changed, 1056 insertions(+), 697 deletions(-) delete mode 100644 arch/arm64/mm/contpte.c create mode 100644 include/linux/contpte.h -- 2.39.2