Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp234709rdb; Thu, 21 Dec 2023 07:47:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHiRdWYdh6A44RmzsN0aC40Wpghf5+49ak663j6q/eIdmifTg9nvSLGlnWViQzv/0wnU+jT X-Received: by 2002:a17:902:6b05:b0:1d3:a13a:e2b2 with SMTP id o5-20020a1709026b0500b001d3a13ae2b2mr4204004plk.135.1703173652246; Thu, 21 Dec 2023 07:47:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703173652; cv=none; d=google.com; s=arc-20160816; b=JLuo1Of9u2Lbmhe7/e3WT19tG5xJXWApPdluHb4zz10DckEvYlwopzbPoezJTG7qqo ZtTxtfjQzgXM7cNJjcS8SfrLhSTnwgOvbf4hsf5wnplIDmCopfRqHE6GanyyAJwfjXdE 13il5JUBlsw3M/4hlXcguySITTiNCEzQx/2F9I5iSSwqyalA4Yni+TcIaUpiwG7h0bHh Zn61pJ6Tq3w/tebhGAh10q7Byg3KKYsi022NO4vPO+LIU2HubSNsMa3d301DMWkmHvDk uKdZ3mPQxvvncTPFi9v0A4q5kmYnR4+jzNBvmkN1TkSlJxcHZFSWsgkeYN8Ffn0tNw0H Z/fg== ARC-Message-Signature: i=1; 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=R7v7KRN5kF3f6T8ivYjW/QyKlDyLwS+koztQTaV2Ui0=; fh=3YQLS1cPsLhMKuGGotL7Ux7rpkwBoh7ZT2nN27VXc5c=; b=CVm7LDiNp5nBkLjWvLhyMSNFUnwdrGjND3255Iai1DhhfPsKKwr7dIodVMmmB5+Xlx QTI/i69CQ3LSWU6i/1tJmm2Fsi3Nl2/gPBn/v8FKhTxFb4/bbwhGg7sZPfjWhIL/uBM3 yROto85QBJzGPMfvC4qnwAPhELBqYN1UQkO/fc/18xgiFl5v7zFR4I5hl3zLX7RAEYRp glW+YQ+DpWjLOQVE/fN6NoALY6GqDgDAyEPEaIxEIzqolrlyiIKg1aIL/dRe4xTqtEi3 +7GGhFNkpCz0tzA01QYdBgLs3ysPZhbuvx767RXDrlFaB9PD75sAwoxv1YuAxoUnqfHX 5lgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=foMQzB4V; spf=pass (google.com: domain of linux-kernel+bounces-8703-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8703-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id jb2-20020a170903258200b001d344ac944esi1664797plb.0.2023.12.21.07.47.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 07:47:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8703-linux.lists.archive=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=@kernel.org header.s=k20201202 header.b=foMQzB4V; spf=pass (google.com: domain of linux-kernel+bounces-8703-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8703-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 B6656284340 for ; Thu, 21 Dec 2023 15:47:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F16655E5A; Thu, 21 Dec 2023 15:47:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="foMQzB4V" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D40EE55E41; Thu, 21 Dec 2023 15:47:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 028E0C433C9; Thu, 21 Dec 2023 15:47:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703173634; bh=1VkNb9SSj6ijZ3M72NIaFsxAoNnYaBQ2VS47upbIECw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=foMQzB4VeCSYCK//dcfGdemiuC7dKk0zuG1BDQxCkZdTqaRrEwvgQCiJ0pXugK9Qa LlUugpTV6s3JWWoRtIg3kD00AvVPEJP5ILsdBTWtHMZDygSEHTpeduzLfOCjCD3mUD K3IOHDR4zp4rOF+qKjzuLt5nVJFScnxaGbvVMet34PxjkKCWbSg2cZHqJJI/e/AMc/ /UaclkeRKp4EkIdtq18KfuTuwxLqSAFS+T4dthVtNZ1Tyl0Nwfu6r4+m9FZkW4q9rG X7uiwUiXnuQy4VWUUAkrbx6BAI1wIIVJ2ppeNoQPmqW7SH+zUe85KzXJjgyMQMwOfw FmXjWEdP3pzJQ== From: guoren@kernel.org To: linux-kernel@vger.kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, alexghiti@rivosinc.com, charlie@rivosinc.com, xiao.w.wang@intel.com, guoren@kernel.org, david@redhat.com, panqinglin2020@iscas.ac.cn, rick.p.edgecombe@intel.com, willy@infradead.org, bjorn@rivosinc.com, conor.dooley@microchip.com, cleger@rivosinc.com, leobras@redhat.com Cc: linux-riscv@lists.infradead.org, Guo Ren , stable@vger.kernel.org Subject: [PATCH V2 1/4] riscv: mm: Fixup compat mode boot failure Date: Thu, 21 Dec 2023 10:46:58 -0500 Message-Id: <20231221154702.2267684-2-guoren@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231221154702.2267684-1-guoren@kernel.org> References: <20231221154702.2267684-1-guoren@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Guo Ren In COMPAT mode, the STACK_TOP is 0x80000000, but the TASK_SIZE is 0x7fff000. When the user stack is upon 0x7fff000, it will cause a user segment fault. Sometimes, it would cause boot failure when the whole rootfs is rv32. Freeing unused kernel image (initmem) memory: 2236K Run /sbin/init as init process Starting init: /sbin/init exists but couldn't execute it (error -14) Run /etc/init as init process ... Cc: stable@vger.kernel.org Fixes: add2cc6b6515 ("RISC-V: mm: Restrict address space for sv39,sv48,sv57") Signed-off-by: Guo Ren Signed-off-by: Guo Ren --- arch/riscv/include/asm/pgtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index ab00235b018f..74ffb2178f54 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -881,7 +881,7 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte) #define TASK_SIZE_MIN (PGDIR_SIZE_L3 * PTRS_PER_PGD / 2) #ifdef CONFIG_COMPAT -#define TASK_SIZE_32 (_AC(0x80000000, UL) - PAGE_SIZE) +#define TASK_SIZE_32 (_AC(0x80000000, UL)) #define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \ TASK_SIZE_32 : TASK_SIZE_64) #else -- 2.40.1