Message ID | 20231219111701.1886903-1-guoren@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-5062-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1863014dyi; Tue, 19 Dec 2023 03:17:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZ12hT7xcYAhkx5IDTCW7OAMxWjErNnxATPqAxxE2REWN367rW84iCb6DIEbmu6lp/y3fT X-Received: by 2002:a05:6808:1454:b0:3b9:dc8e:1fe4 with SMTP id x20-20020a056808145400b003b9dc8e1fe4mr21510779oiv.73.1702984646137; Tue, 19 Dec 2023 03:17:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702984646; cv=none; d=google.com; s=arc-20160816; b=YVjLbxyIer0BI0sRXuqVMj/vOPSq8S8PW6xiDDa0bBCg2B/ggQLwUG8jEKTFsJtKA6 Ou8eBS5EmaDNbyuLgFz41g1wgP8L3Bf/rjiTsw7bIJ2JjKI681EmbXI7vOJs2cbxFe2U wBIt7xrEBx2X/MobmTruE5UJiuCANpKbjzl2Dy3K4ux5SrZXCOO/qNQpXJyyU8WncxUb 7gHSWGzsick1L1gNZwoBrVN5mLWoK2Kz50pz69IeN5YBorqP4kTx9zGjiMFGJ8/xddpb DnDAbsLxgjOKMGLMCQj+hWRAUGOp8b9QCCh0eyMOERRjHj4xuM3sqFzbtAhJHlbh37ud md/A== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=2IVa735C3qqTzqU9dNU/lNGLcedISK3OK+VKtsK+zW0=; fh=Fao+ItUfkTUgT4n1D1brbH/vgva30eAHGIp8mDFEIFE=; b=F+QqfAN4DVAF0l3v/FpKy6c/VbzWnIx+xDa3WHtY8Cy3On1OCFPYv8+JxmwN61U98N CXmtIz6IYxdkgPckI4U/oEy5krC4cKchh45iO4cQ4s5nXpwkMVcqIWjQvZWeRPFQkZIW LUw+CYRWSgxA3rxbA8OjuRMumYi+2uCy9U1Q/XwhBzQkfa56fdVSz7FDOjCzqsRH1e/6 43K5QTZQvH5CZUi2pCFPAIAuQci1z1YOVWbPCUlc/RCBWsMZSdmIPjiTovSA+j1lJFj3 g9YTPzOOwgDD/fTr39LAyFsC9c+x4UZ5k1D+aOktXQ9lQFUgiMKvQbdexPVRiO1Dg6Ij s9lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=H1WI21Fj; spf=pass (google.com: domain of linux-kernel+bounces-5062-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5062-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u17-20020a0cb691000000b0067f02e301f1si2474512qvd.423.2023.12.19.03.17.25 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 03:17:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5062-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=H1WI21Fj; spf=pass (google.com: domain of linux-kernel+bounces-5062-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5062-ouuuleilei=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 DE1A61C239FF for <ouuuleilei@gmail.com>; Tue, 19 Dec 2023 11:17:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7A14154AD; Tue, 19 Dec 2023 11:17:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H1WI21Fj" 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 16D97168BD for <linux-kernel@vger.kernel.org>; Tue, 19 Dec 2023 11:17:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3FAAC433C8; Tue, 19 Dec 2023 11:17:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702984627; bh=wJ8SoxQvEXo8YD/Otob+P1IPztgR2u77NuTz+L6AVU4=; h=From:To:Cc:Subject:Date:From; b=H1WI21FjhrRQqg3E1c+b9XLaLpRQ5UnHHpqgayieRpRt9ZtZquOYuPtjRP86oKQxF QmYVT4SUNPFdKdWfcAwGru47rzFe7efebbzWOM8kfA3uyFYYLvHYi42lKwzyV4BMaX 8DMf1hrc2dPsEPN0ETih338m/ZAI1oyIa5mARhVFR1xxSk3DrQ7B4Dq5qiNUk/qD+X 1Y5PALy2PRFxmxFY+nzUVwaF9WxzI4CDb9/WJfBdQd0Gtyg0i+HgJ2xOddraG6Ui/K osw9FWJ9Kq620lSDCNPxU1xUPMOmddLjeNuF9JbrOJIs2lcOkDzhu1N6hkAWj50lVU IpO1d51vxt2TA== 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 Cc: linux-riscv@lists.infradead.org, Guo Ren <guoren@linux.alibaba.com> Subject: [PATCH] riscv: mm: Fixup compat mode boot failure Date: Tue, 19 Dec 2023 06:17:01 -0500 Message-Id: <20231219111701.1886903-1-guoren@kernel.org> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785708827853633477 X-GMAIL-MSGID: 1785708827853633477 |
Series |
riscv: mm: Fixup compat mode boot failure
|
|
Commit Message
Guo Ren
Dec. 19, 2023, 11:17 a.m. UTC
From: Guo Ren <guoren@linux.alibaba.com> 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 ... Fixes: add2cc6b6515 ("RISC-V: mm: Restrict address space for sv39,sv48,sv57") Signed-off-by: Guo Ren <guoren@linux.alibaba.com> Signed-off-by: Guo Ren <guoren@kernel.org> --- arch/riscv/include/asm/pgtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Tue, Dec 19, 2023 at 06:17:01AM -0500, guoren@kernel.org wrote: > From: Guo Ren <guoren@linux.alibaba.com> > > 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 > ... > > Fixes: add2cc6b6515 ("RISC-V: mm: Restrict address space for sv39,sv48,sv57") > Signed-off-by: Guo Ren <guoren@linux.alibaba.com> > Signed-off-by: Guo Ren <guoren@kernel.org> Abandon this patch, and here is the v2: https://lore.kernel.org/linux-riscv/20231221154702.2267684-1-guoren@kernel.org/ > --- > 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..d2ec5e6fa331 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 (UL(1) << (MMAP_VA_BITS - 1)) > #define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \ > TASK_SIZE_32 : TASK_SIZE_64) > #else > -- > 2.40.1 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv >
diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index ab00235b018f..d2ec5e6fa331 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 (UL(1) << (MMAP_VA_BITS - 1)) #define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \ TASK_SIZE_32 : TASK_SIZE_64) #else