From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 45A8CC61DF4 for ; Fri, 24 Nov 2023 10:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Q0niNzGLE6dbY3ah0MYiyZM9l7e/j792YaYFbUuINSg=; b=x4xPuW/CnRo3Q0nkil2WnIbCPp MBDblybCxfW+kX9aBempxdzaADxWJoK0qYfzKLmJGkB+14YLMemEAblxPU9INo/bs6rStfSA2kbzn Ei8rWynNIiufdVg7nu0i5FI2ryNI3R5BaCL2IilMABMCtVvkUyZPSulf6DmAfCYXF6LJ5ZGqZlWqL XRsBb34b4wENdjDxiXDgxleOll5HJvAn1YqkWPb/B0qMCYd65necp4L+lK7kYurZACTczmH+sfxus hCuWGq8fy8SYOJYjyjjOqxsEgX873ZjZs2wZGZcqbMbWqohmbNBUQ4PcsCOw9bNH+65mjijhfkfqR YPGvTbTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r6TIm-006ohF-0E; Fri, 24 Nov 2023 10:20:48 +0000 Received: from mail-wm1-x349.google.com ([2a00:1450:4864:20::349]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r6TIZ-006oaP-1z for linux-arm-kernel@lists.infradead.org; Fri, 24 Nov 2023 10:20:36 +0000 Received: by mail-wm1-x349.google.com with SMTP id 5b1f17b1804b1-40b3d4d6417so863545e9.0 for ; Fri, 24 Nov 2023 02:20:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700821234; x=1701426034; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=B+BEyFXzG6cg5GYg8KNy+ajGmyiq/MJQTumFJr+LLPA=; b=OkikygQPwa5wUKjOjbVQjUTAuECno6hOIqmEiDFhpip6Q95JlFl+IB7kz6B/MioufQ 6pFsoB2izzI4JweJNLTZiLgQ4Oc/jAmm6o4qm/ELb68D3mYEn95PqmZ7paGuR+o6WNd2 FFOcf6A96qf26amSG7Zk0FasiVwYSSej7ldcRhKXQm6uJS68Vy+zMmxnyBT7GphX7EQF /Wk0jKQeNHE2EDnwzQuKOAeAGG717ug1qmYj5HUvophE/xsqJiFBLZcr0YfhEtJiXeAA lxNkWSzulvht46Or7GKwjX/OtusxR2bdouAOWpRJXbcwnAff5YY5g5O/TA6V1/O0Qg63 bD5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700821234; x=1701426034; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=B+BEyFXzG6cg5GYg8KNy+ajGmyiq/MJQTumFJr+LLPA=; b=K9k4xaNMKYk8L9oHP5QYf6DkWzTt/CVAu5BHIlVAyQC9Sp1WSFLUouWhfyxDtWx9ij LCqhOv7yn7AyUR7Skt6hyqrLXBhNqWeh3/rMcLQfER0pTcW2BuFkmzjpOZalgG2+EP4p ZcauoPXq+ew89W2YEsTIkFKKzGFwBQXClszdLCyFZs795HKGalk+UQSWIjltCAR6z3CV v16yi0EpDP9oQFnKWMf+vBA88RI9D4OG/+Q8hOim97O56wIEIiUn8MVkKNAPnV4q3afk RzUasm9E/EegfBWpx5VlB0P764DlxYZA2mS/q+nSPOzY/Cg60OGjSjIQK/iyyHmD6rdc 44tw== X-Gm-Message-State: AOJu0YyxGuekZnjuPAJ3iYAtHbHO3USKYTUwoi0p9YhEgTyE98fm+/3I 39PSkv1HRi9wf/ga6tW3RGxyE5/JmC/mZkyGdxTUvLpj9TI+SuF7yhFK1glvbumJcDh+1dbN/eH 9aRljS+lFZNncA/BiUoYugwCFxs9mKPLeasLVS3dlET1NoEphlIt7EGTKFn+ZjNB82SY3SYGYCG c= X-Google-Smtp-Source: AGHT+IELRH4mS5fEGTbNwvQcnxYTfMufn0YZSVafXWjqZFr6XDwjflHFhVtghpKrZLH6Z3yj/WsF//wx X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a05:600c:5025:b0:40b:2ab2:b343 with SMTP id n37-20020a05600c502500b0040b2ab2b343mr45618wmr.2.1700821233820; Fri, 24 Nov 2023 02:20:33 -0800 (PST) Date: Fri, 24 Nov 2023 11:18:49 +0100 In-Reply-To: <20231124101840.944737-41-ardb@google.com> Mime-Version: 1.0 References: <20231124101840.944737-41-ardb@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=1794; i=ardb@kernel.org; h=from:subject; bh=83HVzL7EQSX7w4jk++s4dOJdvs3TCvaqo4xiMP29vyE=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JITWhoutkZdTePc93/1l7bFLn1E+tYp/C1/XpPNwgOif3Y Yv4hNZbHaUsDGIcDLJiiiwCs/++23l6olSt8yxZmDmsTCBDGLg4BWAiqxcxMvycVP8l8n2emNuM r7pnD/a90b3KMM//voOcjtDNuV5uJS6MDJum/VcrUbub+PfntAlz86xPqMjyh0xyX6Qeyt04Lce 2hRkA X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog Message-ID: <20231124101840.944737-50-ardb@google.com> Subject: [PATCH v5 09/39] arm64: mm: Reclaim unused vmemmap region for vmalloc use From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Catalin Marinas , Will Deacon , Marc Zyngier , Mark Rutland , Ryan Roberts , Anshuman Khandual , Kees Cook X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231124_022035_654248_5CDEC02E X-CRM114-Status: GOOD ( 14.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Ard Biesheuvel The vmemmap array is statically sized based on the maximum supported size of the virtual address space, but it is located inside the upper VA region, which is statically sized based on the *minimum* supported size of the VA space. This doesn't matter much when using 64k pages, which is the only configuration that currently supports 52-bit virtual addressing. However, upcoming LPA2 support will change this picture somewhat, as in that case, the vmemmap array will take up more than 25% of the upper VA region when using 4k pages. Given that most of this space is never used when running on a system that does not support 52-bit virtual addressing, let's reclaim the unused vmemmap area in that case. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/pgtable.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 8d30e2787b1f..5b5bedfa320e 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -18,11 +18,15 @@ * VMALLOC range. * * VMALLOC_START: beginning of the kernel vmalloc space - * VMALLOC_END: extends to the available space below vmemmap, PCI I/O space - * and fixed mappings + * VMALLOC_END: extends to the available space below vmemmap */ #define VMALLOC_START (MODULES_END) +#if VA_BITS == VA_BITS_MIN #define VMALLOC_END (VMEMMAP_START - SZ_8M) +#else +#define VMEMMAP_UNUSED_NPAGES ((_PAGE_OFFSET(vabits_actual) - PAGE_OFFSET) >> PAGE_SHIFT) +#define VMALLOC_END (VMEMMAP_START + VMEMMAP_UNUSED_NPAGES * sizeof(struct page) - SZ_8M) +#endif #define vmemmap ((struct page *)VMEMMAP_START - (memstart_addr >> PAGE_SHIFT)) -- 2.43.0.rc1.413.gea7ed67945-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel