From patchwork Tue Feb 27 20:50:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Ghiti X-Patchwork-Id: 207419 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2958662dyb; Tue, 27 Feb 2024 12:53:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX6E2SqJJjPbZrTap51KIiFZEFXdDH+4sw0bfeitTwmuaxFwkXj1qo732/hyfqoAZtDw+S71bLDqrd4Shop9S+qIImgRw== X-Google-Smtp-Source: AGHT+IHNIBP1Gv1WwOpkI1uU3zypmIOKHfvsItVYkpjV4mHTPdYTDVYjBwoT85LqWri2Ka7fxYdf X-Received: by 2002:a17:902:9a08:b0:1dc:6b72:6467 with SMTP id v8-20020a1709029a0800b001dc6b726467mr12376153plp.38.1709067215543; Tue, 27 Feb 2024 12:53:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709067215; cv=pass; d=google.com; s=arc-20160816; b=cGL6qyIoLZMkNjvUIp41xW9fmfatHOZuGxL4/XvO6fu0xhw3LMabTz0SQDqEv+qsV/ Mwpj7UrBnOto3Sr6i5OYFg/zFY/r8VJIqpi5C22ze/bQPZbiK27HITeDW3hPS5HTqCk2 AwcwAXXY8cdJeuzhiw+yRJny8YjQyL1yT08IihKdTpPFs1eTdfPJ5iBfMi4vS7pUqn4V WWUruLcsB+PttCjGL9Fksc/KLL5ZwjFJ8X99UuzTEZsgjIwzhbOlEmENY8t1AoHrzJzu TIcSnAQ6Rml417gPpV8N+Gtstbt1vAb4YntubApW+hC2j9VwCyRO6kWzzhdsHqwRhEOj VnIg== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=wS3Fbtccf2xLgZAcGdUt297LbB3kw/tfByr2NgsnNkM=; fh=djimGIfd58XiU38oyPFO5Bxef2cXD4L8FHb9UNeupOw=; b=mDHCSLlibnJVVQ03fCBAANdMeNjL6+lV1A27tyMkfAMcHXv1qSpKpn85K4b8jCxW1o b9y9kvLH26uMQhmPaHpNa8DjvzMACDVxIctF7bkDJwDOsd1YzxvXSBl8EJ84gzs35jMe 2TBAAOUyHEZXA6l4+NO9QKNE4KUlszP2jCbRO5czbPmo+1Q++Sz3n4+dY47DJ7kXq3Xf mmzu5eF8CmvapUMGqK1OYok17s6wyDsmCJ3qKwk7q+3wJUAMxV1djDC/e8aohueD/iH8 UpJ1xS3Zvm4qCzj8TXWJhfGtK/ZDDMSDVcUyvHjn79zNNPezMja7IGHGp8mbz0/K6dPJ Ba9A==; 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=wymAGB67; 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-83995-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83995-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l4-20020a170902f68400b001dcad9c509csi1981516plg.538.2024.02.27.12.53.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 12:53:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83995-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=wymAGB67; 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-83995-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83995-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 56B35287CDD for ; Tue, 27 Feb 2024 20:53:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 199F2157E79; Tue, 27 Feb 2024 20:51:28 +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="wymAGB67" Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 D0E36156985 for ; Tue, 27 Feb 2024 20:51:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709067085; cv=none; b=oOUdZb6GNZQ+0cZRv7Mx1XkPfiJyfLhW6ZixCT3ZHkd0xGLeZbObvE5AaCuKFO4aqzKtZLzh29anBHZ6MjQtUZMwhW/1ghcRMArXeE29G8PbDgJRlfTASwQMa7uqcOdkGKJwqcUiEZmguMlVIOQxhu15JBt/kUuixr8646fjqaQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709067085; c=relaxed/simple; bh=YfetGUHw90TINhyDyoOkqomfVnThTiY+r2jyOXe193w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Z8KClKa5mYVIDOcylMj/U5GnMVfsHXT3HHDeAYaKLuDOwnKIbz9CeybZNQZwhMA33L0Am1iqgB7c349z+fwea7+tUfJMK5vgmCN9ZwUG2scwZhR0JVaWn6xoe7Oz+gXZjHm/3b0xFUGAb0DUe4T8iMYFgZonyHazDNeTZ0zsq3s= 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=wymAGB67; arc=none smtp.client-ip=209.85.221.44 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-wr1-f44.google.com with SMTP id ffacd0b85a97d-3392b045e0aso3870845f8f.2 for ; Tue, 27 Feb 2024 12:51:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1709067080; x=1709671880; 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=wS3Fbtccf2xLgZAcGdUt297LbB3kw/tfByr2NgsnNkM=; b=wymAGB67y2g14ZjVuSLbpsCPR3IiRxkjYIIop/swNmry9Cdle69shGKDDPYM4YrT0d cNT6vNiS+P+QR+ewVNcBAKFPCwAhaAOYok46pR8UOMBAaofD7zMW7YGsKrgXJhJsvCbT eiK74EpqG2TROivwhpcZMr7tvkKXiJYThwX8w4Tep5Dwa/X8BG1e86RiwAhn3VN6x+hP 4Ko/l9bdDqSdTYwA1kb2cXCDg60LyodN62UEGQE1yrJw4k+Hlddeyc4hwLclJxad8Sbf rHj5vbhA99lkhAAFq60FlH5z+TwLEtZtHZLrkAkf4w0rtQ+qyVotYaSWRXuNrTtj8AVf 1VtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709067080; x=1709671880; 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=wS3Fbtccf2xLgZAcGdUt297LbB3kw/tfByr2NgsnNkM=; b=n/2Xzyb9/nrtTOs0zHonTXqfv0sumFtu5407awct+cVPTucGEERS+MsoubibYzmmS+ RAymXAfzFu4O5mZiHK9qVVMdfeF5WIt26Dt9BxHoIf/wmYVQO7oVPBEoxjI4wir8IsPr Rxx6JI6YPW7N0gj3Kn53BVtLLgzUb1xyvqSVT6XqMH+LsQ0NJgXT1l7uXJcpuNmeEnJ6 UTCqPE9KeWXKERcwlrErnMbQUogDicVdQojvp1XXqYS7wAqa1Pgk3UaBHx1l70bWyYhL KcGwraiPo0lpr/EF2nAb9OABfk2VqNdO1EzfzJzKP+IbHxFJ8nFW8+N1FMgZKjCHADkJ J1SA== X-Forwarded-Encrypted: i=1; AJvYcCWHGfdip845Vuk1S4n/lo1MKFpPDxamKsvYQYNjvRb+daJGpGcE5it62WYRMIU8HaxjFclNm8WglP5Mve5xF61wRQLZBRpXsPCjO5vM X-Gm-Message-State: AOJu0YwKdd7VHIGJeuSU1jJnT5klSJhV84nTTHgZkUTsISW7K/hs2CJS yBCbgX6Ah+vhxj0aedFmcOC1ij1ob5extkB6CYjSEwBQp4NG2GQ6h+T8g8DWUEw= X-Received: by 2002:adf:e582:0:b0:33d:f3c9:a526 with SMTP id l2-20020adfe582000000b0033df3c9a526mr1830243wrm.67.1709067080216; Tue, 27 Feb 2024 12:51:20 -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 v26-20020adfa1da000000b0033dfd3a8cd3sm35135wrv.30.2024.02.27.12.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 12:51:19 -0800 (PST) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Jones , Conor Dooley , Qinglin Pan , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti Subject: [PATCH -fixes 1/2] Revert "riscv: mm: support Svnapot in huge vmap" Date: Tue, 27 Feb 2024 21:50:15 +0100 Message-Id: <20240227205016.121901-2-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240227205016.121901-1-alexghiti@rivosinc.com> References: <20240227205016.121901-1-alexghiti@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792086864546289726 X-GMAIL-MSGID: 1792086864546289726 This reverts commit ce173474cf19fe7fbe8f0fc74e3c81ec9c3d9807. We cannot correctly deal with NAPOT mappings in vmalloc/vmap because if some part of a NAPOT mapping is unmapped, the remaining mapping is not updated accordingly. For example: ptr = vmalloc_huge(64 * 1024, GFP_KERNEL); vunmap_range((unsigned long)(ptr + PAGE_SIZE), (unsigned long)(ptr + 64 * 1024)); leads to the following kernel page table dump: 0xffff8f8000ef0000-0xffff8f8000ef1000 0x00000001033c0000 4K PTE N .. .. D A G . . W R V Meaning the first entry which was not unmapped still has the N bit set, which, if accessed first and cached in the TLB, could allow access to the unmapped range. That's because the logic to break the NAPOT mapping does not exist and likely won't. Indeed, to break a NAPOT mapping, we first have to clear the whole mapping, flush the TLB and then set the new mapping ("break- before-make" equivalent). That works fine in userspace since we can handle any pagefault occurring on the remaining mapping but we can't handle a kernel pagefault on such mapping. So fix this by reverting the commit that introduced the vmap/vmalloc support. Fixes: ce173474cf19 ("riscv: mm: support Svnapot in huge vmap") Signed-off-by: Alexandre Ghiti --- arch/riscv/include/asm/vmalloc.h | 61 +------------------------------- 1 file changed, 1 insertion(+), 60 deletions(-) diff --git a/arch/riscv/include/asm/vmalloc.h b/arch/riscv/include/asm/vmalloc.h index 924d01b56c9a..51f6dfe19745 100644 --- a/arch/riscv/include/asm/vmalloc.h +++ b/arch/riscv/include/asm/vmalloc.h @@ -19,65 +19,6 @@ static inline bool arch_vmap_pmd_supported(pgprot_t prot) return true; } -#ifdef CONFIG_RISCV_ISA_SVNAPOT -#include +#endif -#define arch_vmap_pte_range_map_size arch_vmap_pte_range_map_size -static inline unsigned long arch_vmap_pte_range_map_size(unsigned long addr, unsigned long end, - u64 pfn, unsigned int max_page_shift) -{ - unsigned long map_size = PAGE_SIZE; - unsigned long size, order; - - if (!has_svnapot()) - return map_size; - - for_each_napot_order_rev(order) { - if (napot_cont_shift(order) > max_page_shift) - continue; - - size = napot_cont_size(order); - if (end - addr < size) - continue; - - if (!IS_ALIGNED(addr, size)) - continue; - - if (!IS_ALIGNED(PFN_PHYS(pfn), size)) - continue; - - map_size = size; - break; - } - - return map_size; -} - -#define arch_vmap_pte_supported_shift arch_vmap_pte_supported_shift -static inline int arch_vmap_pte_supported_shift(unsigned long size) -{ - int shift = PAGE_SHIFT; - unsigned long order; - - if (!has_svnapot()) - return shift; - - WARN_ON_ONCE(size >= PMD_SIZE); - - for_each_napot_order_rev(order) { - if (napot_cont_size(order) > size) - continue; - - if (!IS_ALIGNED(size, napot_cont_size(order))) - continue; - - shift = napot_cont_shift(order); - break; - } - - return shift; -} - -#endif /* CONFIG_RISCV_ISA_SVNAPOT */ -#endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */ #endif /* _ASM_RISCV_VMALLOC_H */ From patchwork Tue Feb 27 20:50:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Ghiti X-Patchwork-Id: 207420 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2958902dyb; Tue, 27 Feb 2024 12:54:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUzHvWccWMwcsjGS1QZQwSJ+tUGl2RMpEVd882H8cdgIGrVRWXMpOyBCetdGr+F4nV0eY8yA8u2ZBx8p9tO15jFGZ9noA== X-Google-Smtp-Source: AGHT+IFcw0oTkMnqnDrT5d9NsLNP7c8fHrSteABrPXXamI3E26adpNfFbWzBDAYPQ2sBaKptBeZf X-Received: by 2002:a17:906:241a:b0:a43:bb3b:3b53 with SMTP id z26-20020a170906241a00b00a43bb3b3b53mr1822801eja.47.1709067250305; Tue, 27 Feb 2024 12:54:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709067250; cv=pass; d=google.com; s=arc-20160816; b=en/dqcGBwk4YmUQBYWIVRHRN7J7oh7S6l3adccUJsDLDluUk9RT5/3yV1X2Mbg6OLa rXNL2M2nSa6paY3O2Y6PiQkOTE8PFRFBQMxK1ETDkWVBrKvXYh3/12E2cmFN5lqF/UZ5 CxXfs3fnsY8lcO/H8jyQBMyMl89s89UWmcZPXYw4puk3BChilqV2moeN8LGUZr+/FDRc qrT00Rs4a9PHWdtYLHmh9TNST2Ry2/CVH8gihFrrKzA0UkKzblCJk+yigvE6ngefVtmE G927WLLD5VRjJZRf+viXVVDcaRt2HNBh0zvhTfpmMwbbASbFDaLtBO+MOy94lDJweY7m 6Lxw== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=FzfPm4MGmy+twyI4zc1gm3KO2QTVwDkS4GmOlB/j8Xc=; fh=x6WOR7cr8gHJpklSnNDH3zF2d2nXCcgP04OzdW9k3Bo=; b=q5k/WgNqzuj+43wjrqNvjcYnGSDxVhIUxGvZP3osmRQmBz9rrj+Rbj0ysu0xG91YVu NgSxJViwX/0vjUY5ZxpCspLx+75qBBJArg8cUHc4niHiridAPXHzrO/jD0XqcgRrAXYh MfVs9cpuxEdkU3ibJ03lMyzm+fQ9my7tpNXDbWfspmZXYHuJIFaK8ZVGWx/OILWVU7rx O3j8AJbPzL8HNjyMvumUcdI6+e9ltBNkUK8muWH7PVPmNL157NBNgbS5GH5l5FUS8gER BEiwuGbw/ZmRTZaLB+THEAG8R/VHyMoOozCGXrmo/nYgsMaht+H2QtC1Ys19hTVKm0mW CH6A==; 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="O/ACh58K"; 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-83997-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83997-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gt32-20020a1709072da000b00a43ada8abbcsi929793ejc.612.2024.02.27.12.54.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 12:54:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83997-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="O/ACh58K"; 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-83997-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83997-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id BB1101F24517 for ; Tue, 27 Feb 2024 20:54:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B8C3A14F98F; Tue, 27 Feb 2024 20:52:26 +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="O/ACh58K" Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (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 A34AD48CFC for ; Tue, 27 Feb 2024 20:52:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709067144; cv=none; b=DWKvcl5SxisuxxR/bUZByUpw31EUt5rYo0MHA2sySCwiA6GZbsOhA8SJ23Isiaj0EKeZyx2hkoaxI3BgCGgA5MNV0eIp2yIo39WT3AIGFryxD6uf0alTvoICl4+vh7BAdjer3rB2GuTHdOJXT101YR6CaigeaDKHZiVvFV9K3Wo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709067144; c=relaxed/simple; bh=JsQ1nGdibb8WX0Sy1YuZgdzxR6vLTyCS9HB+mk8bneU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NJp+zN+flhBLTx0HnOzHK2y2ylUEfILdCGhKahQ3MgVXZgZkmov1CgTdjHmHHP5UBllpi/pfedM7C786E0odZHFFaqekvhdpPCiH2qv4hSNz9d3vNBQNmqGvhoNXLaeXyKgqOq/ZtkYIYqHhozR9siyU7y2iroJ/DTWiFKtJgng= 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=O/ACh58K; arc=none smtp.client-ip=209.85.221.46 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-wr1-f46.google.com with SMTP id ffacd0b85a97d-33d28468666so4111205f8f.0 for ; Tue, 27 Feb 2024 12:52:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1709067141; x=1709671941; 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=FzfPm4MGmy+twyI4zc1gm3KO2QTVwDkS4GmOlB/j8Xc=; b=O/ACh58KQp//yOLDqxJlq9hSIMjQauD04mbLhyKQa6Yuo++Kb2Iz9bK2PdzpbqFeJ0 6aAQ4FBDq3F2h5zDizfBfla9HkeW6+mDU2Ib9HcZOOxbgWsIMHl3sVZAhOou9cAKdjoi Z/7NS284XeCm2OMlg5XNAeFF6PpZI7+dTV7I18h8hK1dH7cw8COeGv6XxRNso0kq35V8 pL05BAka4XLOhQX/zgQyTvMuSQ4mejI2brh4HeAU2Al7DgbKx/7NJIgVycJaVcKHsKl6 6XxL07G1bMbUzzv/+5P4iBhqfUNnylxsfuhmyQtvXj7AwcDgkfVdbX7fguwjomyZVnlh GwMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709067141; x=1709671941; 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=FzfPm4MGmy+twyI4zc1gm3KO2QTVwDkS4GmOlB/j8Xc=; b=drNMlNIGnotrkoMUY5EzCODXu8J8mjcqePkEvFfZylbm4GDMSLcpSnvrAu/4DvUGMS gBiDw0vnWENEr9aBOKMhj7sv5cY8sTuyIjGMN1AsvareBlpD3fwIpFKc3NATjnoy7wXO nae5sxFnAo0FAmsxX9uUNm784I6yVGHnnxvCPw3a0f0lN0tvOpIJEbZStzMIXJBAjoJ7 GyLmdorZUwL0PPmYrBNqtmw23l77vDAAYyQdyL060vVQgQUVwbuTcEAJp57ARIZG9AS5 icvo5pIAQXYvaPkVraHhBR8/w4nfVwkbJkXdy6/R5u43yD03MWHHT3d2TDFXmUKxHEW8 r+Pg== X-Forwarded-Encrypted: i=1; AJvYcCW7JytsczSdVMjDIJFRg0t6+Xj/wF/HdAwQxGvC4XDachiuXSSFVptOo9yz+6WIrm0F/Dst7ptqT86vbDq0rzdsa9zzcG2M949/uQ88 X-Gm-Message-State: AOJu0Yz1GanSnoR0NQkfz2wXbw6sfNZxzNsBFUN1BZSRfU9KuwkcGqKC 39hKjo0Y474Mi8qx056PBdm87IdMPGJ6DKT7KgBMh+J9aeXdUdvVtrgO/yIqnS0= X-Received: by 2002:adf:f08d:0:b0:33d:1eea:4346 with SMTP id n13-20020adff08d000000b0033d1eea4346mr7362784wro.37.1709067141078; Tue, 27 Feb 2024 12:52:21 -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 bw1-20020a0560001f8100b0033af3a43e91sm12539544wrb.46.2024.02.27.12.52.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 12:52:20 -0800 (PST) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Jones , Conor Dooley , Qinglin Pan , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti Subject: [PATCH -fixes 2/2] riscv: Fix pte_leaf_size() for NAPOT Date: Tue, 27 Feb 2024 21:50:16 +0100 Message-Id: <20240227205016.121901-3-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240227205016.121901-1-alexghiti@rivosinc.com> References: <20240227205016.121901-1-alexghiti@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792086901118059763 X-GMAIL-MSGID: 1792086901118059763 pte_leaf_size() must be reimplemented to add support for NAPOT mappings. Fixes: 82a1a1f3bfb6 ("riscv: mm: support Svnapot in hugetlb page") Signed-off-by: Alexandre Ghiti --- arch/riscv/include/asm/pgtable.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 0c94260b5d0c..89f5f1bd6e46 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -439,6 +439,10 @@ static inline pte_t pte_mkhuge(pte_t pte) return pte; } +#define pte_leaf_size(pte) (pte_napot(pte) ? \ + napot_cont_size(napot_cont_order(pte)) :\ + PAGE_SIZE) + #ifdef CONFIG_NUMA_BALANCING /* * See the comment in include/asm-generic/pgtable.h