Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4241555pxv; Tue, 29 Jun 2021 02:19:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxo9MvqkmIBi2NROqtXsEJYWIq1MkOM61rxeXFzmqMAHwIQOKg2dLsIAsoDVJtOr1QBT1n5 X-Received: by 2002:a05:6402:204:: with SMTP id t4mr38684218edv.34.1624958357467; Tue, 29 Jun 2021 02:19:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624958357; cv=none; d=google.com; s=arc-20160816; b=vD/dwX7ckTa7VyW342WwEtNj6G0DvbBk4VMILTSnKlaKKQm2jrGBEzMFjeWTGTTL5y 2n0McdhDxNXnJFQDrqP8ydK/5aFc+n2gOIx1U4bEQ8Igrk3Hg1HdNTaWMIwzTrEKdMvo zTYYilYJ7A/r/jUPMaK6kqm03e6xfkjbJJ/JapT+Eoaq949y29wg7FUi1yuqW7NLOVuF F578k5COYiCWBvatGqQVLROGUKw8i3j+6etlB1Y9KTqT6p0WWQ7sJ7BOXuq3+b5KE05h mw/5kNQITxLY0okQBO5jhnsFVGIU/0k4hKc+3TIc8asJ9/egSW8EdH3OCdmvAYulPr6w PmvA== 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; bh=MkIz2jZE4NSyNntKVkZjv5PjawSqmQBcZi0lF1I0X28=; b=qu4ytff96otqPXQNGJxTam5LEX/G7J8Cg4RYOrnrOjD8MIy6nqsGN+c0wmZtSTVE2t ufmug//WYOGGogIVZ2LMquYKesYAwATw+NzvCl9zhzQETNLZJ+Yh665e8Q/I0J9e/YmV y8Al+D8cd0Onn8VyVyXZGGQsyCoRC9bcETu746W2sIrvYA5TT9/KfKC8Grn1T3QNe0i+ 1xbEnMQNzsYhrTWqGqhremjvC+MmYxm3l3wwkKPOQdrB1AaVRsbv6m+ADEJ4xECnCw3r Y+0h68PzxBh0LL2RFkICvyBIKEGBeX/4GfpkE7H2zd6KZNYvUfSiZvPx3lPh6kJwGJ7p /q5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bo20si3276697edb.17.2021.06.29.02.18.53; Tue, 29 Jun 2021 02:19:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232679AbhF2JRb (ORCPT + 99 others); Tue, 29 Jun 2021 05:17:31 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:46655 "EHLO relay4-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232470AbhF2JR3 (ORCPT ); Tue, 29 Jun 2021 05:17:29 -0400 Received: (Authenticated sender: alex@ghiti.fr) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 94BB6E0002; Tue, 29 Jun 2021 09:14:59 +0000 (UTC) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Kefeng Wang , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti Subject: [PATCH 2/3] riscv: Make sure the linear mapping does not use the kernel mapping Date: Tue, 29 Jun 2021 11:13:47 +0200 Message-Id: <20210629091349.3802690-2-alex@ghiti.fr> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210629091349.3802690-1-alex@ghiti.fr> References: <20210629091349.3802690-1-alex@ghiti.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For 64-bit kernel, the end of the address space is occupied by the kernel mapping and currently, the functions to populate the kernel page tables (i.e. create_p*d_mapping) do not override existing mapping so we must make sure the linear mapping does not map memory in the kernel mapping by clipping the memory above the memory limit. Signed-off-by: Alexandre Ghiti --- arch/riscv/mm/init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 04a5db3a9788..a1a0c4afa80f 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -742,6 +742,8 @@ static void __init setup_vm_final(void) if (start <= __pa(PAGE_OFFSET) && __pa(PAGE_OFFSET) < end) start = __pa(PAGE_OFFSET); + if (end >= __pa(PAGE_OFFSET) + memory_limit) + end = __pa(PAGE_OFFSET) + memory_limit; map_size = best_map_size(start, end - start); for (pa = start; pa < end; pa += map_size) { -- 2.30.2