Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1204563rdh; Fri, 27 Oct 2023 07:34:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHrvM6DxF1rpeNyvGHjXcj7QwJ10L2GjAPra+IzaR5GXV520b2u48bpZX3zWgJoZldCEtr/ X-Received: by 2002:a05:6102:290d:b0:455:f04d:7b64 with SMTP id cz13-20020a056102290d00b00455f04d7b64mr3773740vsb.8.1698417284469; Fri, 27 Oct 2023 07:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698417284; cv=none; d=google.com; s=arc-20160816; b=fwOMddDSpMPovJEh6kMq8BS4BwiYinkqIAzncCkIOgYSwlW9xa9QT2Ax6wKxHbHShn KD9LdhGk4NLwgjCK7Q85r3iyKXkmVJ2HVWEcr2lh+vgtPRsd2AJFD2zZ2iuTiX46bEpj gI7P8TwhuPvbwGwHMxlwMgJPbrvj0H8SIrEL9O0t5waIfFdFKH7LIG+tgaQbcfOJIXTU Au2cKFxEtjxjURVwWhsfFGcI1dVN0oQQE52fOJ7mpahHgQY3XVm1+Vtpuso3Jgwq1O4F YJL9SBjM0JMsO2kNkfVscQcEXK+RbQPM2OYo6xSnD1cR7AUesrx0NK7qfzdS3tOBygUA fiuA== 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=hEPgDTMpIXvshpOSSpINtGH8/u8zbO38mo5vAWcHcCQ=; fh=0YNXORI2f1g3k8QaEEzBwjs/kwDlkOiTK/vvbTQGF20=; b=At883xDclcs+yoLiqsFrEgXtOTRQyKHyyAbxeVIBL+1KK5bALe9W2uokHpxI7fumF9 uxhiuI6zhDtsjBFVYxDhNUpTqPZfwJ1mpKZmk0rxT8dLgVSt+lPG2q/1aDYsfCcY3m7p VQtHre0dWC6m5jqThV39qmeFeCe9SRIslIb7DFAlQTvTsQVV+MqfMrHZ+riIHicYIX30 7bMjkf3xOYAtFyeqsPEJbnsLlYXa8R7hsBHYybCXNq62llLfXQTpyozXnMc7i9DfKGxt 6Acm1SdX0lD5FyQFkKVZenpgYnDD0AJm0ELdIHt79G5+qS8W6y5hfH7e4YdkGOf3LSqq a21w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=H18pUSVj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id ei29-20020a056102471d00b004546c1b91e0si227802vsb.391.2023.10.27.07.34.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 07:34:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=H18pUSVj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 83F8885202EC; Fri, 27 Oct 2023 07:34:41 -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 S1346059AbjJ0Oec (ORCPT + 99 others); Fri, 27 Oct 2023 10:34:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345952AbjJ0Oeb (ORCPT ); Fri, 27 Oct 2023 10:34:31 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC62DC4 for ; Fri, 27 Oct 2023 07:34:28 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4083f61312eso16781045e9.3 for ; Fri, 27 Oct 2023 07:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1698417267; x=1699022067; 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=hEPgDTMpIXvshpOSSpINtGH8/u8zbO38mo5vAWcHcCQ=; b=H18pUSVj/grz+Rh752v5d+wojcXm2kkbTVewsVY06pyHeReHXkvMreUxlTFeBTQfjv 8XSTZAPK43/ZrpERlV7oKnTcBn7CWVF6Jh7O4ghraMtK+vz1UmtYWsx40+JFOursBju3 pjkdqSq139hIKPYp8dcTzIP5i1gEFAC1D+jBynePL4wO45MepRaOqegle0zgbMKDdwt3 TIJLMmfjM6BJeMPctOVkTr5wGdg86td0tGBAJupZvxOsrW8YkyZm+EYpyYl2X7yciWn3 k/w/eKxT/1mhal6ChBfHDwsZ5L4XAThym0+ta+c8Oh6IiXMPLXejMh1k4vOKPVvVbxyz En/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698417267; x=1699022067; 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=hEPgDTMpIXvshpOSSpINtGH8/u8zbO38mo5vAWcHcCQ=; b=VBPd24rL6tq3L7rPQB5IJfaN9rqxhDBZZv2bQsRNER0nDlLR7oVFPueZm2n6cHZbAo Hkf/USWm4L8Hi2ysxleYMWmiAFDrcvtDD7UyXlSsEfbPKFf9CAovefmWU/gBR7yh8g+C X3Kd2gvrpBafogbiy36N177+TGcQtaG2HRP0t2hSjRjL4R4hGJczX6sEysw6YXYlfyCI A6iZnWnut272g38RvGz900yqRuEQSFhnKl2Qt3TYX1A3c5KWeEk81SNXraAhx+Qj65tn +8IdPLl0SAhEKpf4kGcy62Er2MZIcVrmMLS5c7wJrMyiUEY6Meb51nzyeTPLMssmYljI 1JFQ== X-Gm-Message-State: AOJu0YzResH8YsCu6YDVcPyS5qIxgvecsQTcp+GPIl/ic2p0b23SeUxM lPMybK/pAG+xxiiMe5LHtL8AnQ== X-Received: by 2002:a05:600c:45ca:b0:408:4f5d:eeb2 with SMTP id s10-20020a05600c45ca00b004084f5deeb2mr2609822wmo.20.1698417267289; Fri, 27 Oct 2023 07:34:27 -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 p9-20020a05600c468900b004090798d29csm1784097wmo.15.2023.10.27.07.34.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 07:34:27 -0700 (PDT) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Mike Rapoport , linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti Subject: [PATCH v2 1/2] riscv: Don't use PGD entries for the linear mapping Date: Fri, 27 Oct 2023 16:32:21 +0200 Message-Id: <20231027143222.115588-2-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231027143222.115588-1-alexghiti@rivosinc.com> References: <20231027143222.115588-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]); Fri, 27 Oct 2023 07:34:41 -0700 (PDT) Propagating changes at this level is cumbersome as we need to go through all the page tables when that happens (either when changing the permissions or when splitting the mapping). Note that this prevents the use of 4MB mapping for sv32 and 1GB mapping for sv39 in the linear mapping. Signed-off-by: Alexandre Ghiti --- arch/riscv/mm/init.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 0798bd861dcb..6dc61d3c392f 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -664,16 +664,16 @@ void __init create_pgd_mapping(pgd_t *pgdp, static uintptr_t __init best_map_size(phys_addr_t pa, uintptr_t va, phys_addr_t size) { - if (!(pa & (PGDIR_SIZE - 1)) && !(va & (PGDIR_SIZE - 1)) && size >= PGDIR_SIZE) - return PGDIR_SIZE; - - if (!(pa & (P4D_SIZE - 1)) && !(va & (P4D_SIZE - 1)) && size >= P4D_SIZE) + if (pgtable_l5_enabled && + !(pa & (P4D_SIZE - 1)) && !(va & (P4D_SIZE - 1)) && size >= P4D_SIZE) return P4D_SIZE; - if (!(pa & (PUD_SIZE - 1)) && !(va & (PUD_SIZE - 1)) && size >= PUD_SIZE) + if (pgtable_l4_enabled && + !(pa & (PUD_SIZE - 1)) && !(va & (PUD_SIZE - 1)) && size >= PUD_SIZE) return PUD_SIZE; - if (!(pa & (PMD_SIZE - 1)) && !(va & (PMD_SIZE - 1)) && size >= PMD_SIZE) + if (IS_ENABLED(CONFIG_64BIT) && + !(pa & (PMD_SIZE - 1)) && !(va & (PMD_SIZE - 1)) && size >= PMD_SIZE) return PMD_SIZE; return PAGE_SIZE; -- 2.39.2