From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DCE273F1064 for ; Mon, 7 Sep 2026 03:51:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788753082; cv=none; b=BJ3n769rqqpBdIAaFSxkHsbhZH3utQWboK9sUjOMS2NnlA1JMXzZ7aEeE/GGr01KeL4VAO0rLRN6+rFGu6ENXtT/DYAcKTodmW3OPZ2o3+jKEoLizCVJzDNSmpdA99OXBO7hwAQ9tsgwlyaDvuUfUcnXVDLTJ2slv5Rpii2Lz4s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788753082; c=relaxed/simple; bh=Qb+7E8NXipxvoAEHwL2Au3g/XDt1GmXueAfBnPSqsJs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tsfHBiXjnZlk7F191/wIfTTlmx6E2rhkZjuScEiw/BBZ9r33Nrq/4yyYU3TL8JATkX4+hTnPN/LSw34+uZcBpkhc2XJ6AgIw5FjlYkDI5tuuWGMNo4ihWVXsKejZj6etiWN76ZGcpI/5Eikj9hTfZiQCfHXtd9wcPK3d+XefqCg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=lKEnAII+; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="lKEnAII+" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A16E41BA8; Sun, 6 Sep 2026 20:51:16 -0700 (PDT) Received: from localhost (a085714.arm.com [10.164.19.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9999D3F7B4; Sun, 6 Sep 2026 20:51:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1788753080; bh=Qb+7E8NXipxvoAEHwL2Au3g/XDt1GmXueAfBnPSqsJs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lKEnAII+5BcNq0/1T2NrvYL3H4zsr6jbJe17vY4vHbGtC5Ka7nzO99iXt8eHS5Maf DUh3npYqcQW/MG/QV9gj8aGR+OWVu2/7LIT0nnrpnjXk7rBdDRVbBdyr+CQYOu3SFr xyxdDNO5/m6NQtaItwuz7F+PRbFHlpCj5q5LgVLM= From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org Cc: Anshuman Khandual , Catalin Marinas , Will Deacon , Ryan Roberts , Mark Rutland , Lorenzo Stoakes , Andrew Morton , David Hildenbrand , Mike Rapoport , Linu Cherian , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , kasan-dev@googlegroups.com Subject: [PATCH V2 12/14] arm64/mm: Relax KASAN shadow alignment for FEAT_D128 Date: Mon, 7 Sep 2026 09:20:27 +0530 Message-ID: <20260907035030.2839978-13-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907035030.2839978-1-anshuman.khandual@arm.com> References: <20260907035030.2839978-1-anshuman.khandual@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit D128 reduces the number of descriptors in each translation table, causing some VA size and page granule combinations that use two page table levels with D64 to now require three levels. For three-level page tables, the PUD level is folded while the PMD level remains a real translation level. Hence, PUD_SIZE represents a root-level span. With D128, some configurations have a KASAN shadow region smaller than this span, making it impossible for both KASAN shadow boundaries to satisfy the existing PUD_SIZE alignment requirement. The KASAN initialization code on arm64 already supports shadow boundaries which are not root-level aligned, by installing or cloning the next-level table as required. Similarly for three level D128 page tables, relax SHADOW_ALIGN to PMD_SIZE, which corresponds to the first non-folded level below the root level. Keep the existing alignment requirements unchanged for all other configurations. Cc: Andrey Ryabinin Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland Cc: kasan-dev@googlegroups.com Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/arm64/mm/kasan_init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c index f61f5bc09467..e12abea6ad15 100644 --- a/arch/arm64/mm/kasan_init.c +++ b/arch/arm64/mm/kasan_init.c @@ -178,7 +178,9 @@ static void __init kasan_pgd_populate(unsigned long addr, unsigned long end, } while (pgdp++, addr = next, addr != end); } -#if defined(CONFIG_ARM64_64K_PAGES) || CONFIG_PGTABLE_LEVELS > 4 +#if defined(CONFIG_ARM64_D128) && CONFIG_PGTABLE_LEVELS == 3 +#define SHADOW_ALIGN PMD_SIZE +#elif defined(CONFIG_ARM64_64K_PAGES) || CONFIG_PGTABLE_LEVELS > 4 #define SHADOW_ALIGN P4D_SIZE #else #define SHADOW_ALIGN PUD_SIZE -- 2.43.0