Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp743424rdb; Fri, 22 Dec 2023 03:57:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IGxlSFy3kdOzb9dKOLwB3xJqUdNx1Hlq2AFMUuLBE7GtMenIjPTBV+WMk31i/1Sft6h8EVg X-Received: by 2002:ac8:5793:0:b0:427:7254:a029 with SMTP id v19-20020ac85793000000b004277254a029mr1941521qta.44.1703246260853; Fri, 22 Dec 2023 03:57:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703246260; cv=none; d=google.com; s=arc-20160816; b=z37cFf36Pt/bPmWxWdOe8XJ/M1hqKsaVU++o4c01oEUdaqx5udV+vhY0uajtPRPUa9 LGh0gcYN0T6DSwORsa4bE481ByScy69BCDRXEhhWLS90a8bo461dMyECDKOebFAlNcMX EaLQxzmZANoy2crbTRt/j9DJm4ydysRmeZ8oIt0b+3J14xLop5FAn5z7ipdqTyyagweC YO9MGq6wzdpeXs6GjemUceNu9m4IIWrakvD+Tsqjl52E9EBhGtQmIwu9LwRNGzN3BbCM OqtlMsMZKWwVPPAVpDzjrhcrFnoUEWCTKZnsXI33CN61K5dv0jO6NkLJKR2TSXMNB8Bj LlRg== 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=cA4wksJKldGt+LCgiLDGw2cF2dfjvj8srBypxzsUtSk=; fh=3YQLS1cPsLhMKuGGotL7Ux7rpkwBoh7ZT2nN27VXc5c=; b=fmc2r1vEh7qH2gPdDC1By4ntgdb1IN74yXIICFI0+SVSoCagMJs4AyHeYYqqEGB0Gr M5b9Q5nlqE/7SiNpB05DgWn2oPiPY7AzF2bSXATJG7zOCFEpsphkK8GE+34GHMeNCG5z W9Y+qnHainywHw63HTbYdM9hyZZVB8mbVPlExp/VbRPvGWQyqKZ6KEjZgXgg6wq3PzkK ScGV1MhICroj0lku286lZ2zyZCvO4bExWrxQ+ELLS3W5Tbk9S5uPBrtdmW9YWM7ciiM6 kEqbWnhaugz8dgMhHAVVhqtxJ6+3IpkI3UICI0Oj9Vp8Ig7S1N/C8d0qpuwkuQAshcx/ nwUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b9qp0VEO; spf=pass (google.com: domain of linux-kernel+bounces-9679-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9679-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id jd21-20020a05622a719500b0042391d5e4fdsi4354831qtb.803.2023.12.22.03.57.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 03:57:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9679-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b9qp0VEO; spf=pass (google.com: domain of linux-kernel+bounces-9679-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9679-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9A9411C24A93 for ; Fri, 22 Dec 2023 11:57:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3959418054; Fri, 22 Dec 2023 11:57:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="b9qp0VEO" 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 6451F17985; Fri, 22 Dec 2023 11:57:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A7F8C433C8; Fri, 22 Dec 2023 11:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703246245; bh=OMHoJ47sH8QL4h4TQhZ+b4gxch9yOK4WdYt6lzVlcv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b9qp0VEOGkrFAhxqIe4d6Y9gIs4x6sOfZwhGePIfwsqsVInwDYDn9xyPy0D6jHDf8 l80dp1DCIjiaIdq+5PnC7VMWBk1I1MVo2Kvz3lRX0lS+aStpiAEZpUTJ8a+nK6Cisq NPYiyqFkNnPd8iWk2opA3z9L0YWxKnMqBqifWtQZIoRcJt3hQZ5/8BdK20/JycOtV9 Vbu+Nf5bLXqImKx4F3uGjyRTiWakhBpnEd8OBDrR5Ky3U9rAjZcwI9w4n3wFEDlAUO JZQPQG3kpw5ZQVC2kAlMqOCLgqXJ97JXpA6tIzhx/yl2RMQQcSH9BYkEJx/5wHioZL HHbRAb8qWlz/w== 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 V3 1/4] riscv: mm: Fixup compat mode boot failure Date: Fri, 22 Dec 2023 06:57:00 -0500 Message-Id: <20231222115703.2404036-2-guoren@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231222115703.2404036-1-guoren@kernel.org> References: <20231222115703.2404036-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 DEFAULT_MAP_WINDOW (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 ... Increase the TASK_SIZE to cover STACK_TOP. 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