From patchwork Sun Jan 7 06:30:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 185711 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp418148dyq; Sat, 6 Jan 2024 22:31:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IFsPhDVztq/duK8ULTVWKqheI7zAOodZEgWAPa/9FdS8z3aYyspxKiIol2mkmLBbqpN+71v X-Received: by 2002:a50:950b:0:b0:553:6a5b:c61f with SMTP id u11-20020a50950b000000b005536a5bc61fmr888885eda.0.1704609069596; Sat, 06 Jan 2024 22:31:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704609069; cv=none; d=google.com; s=arc-20160816; b=yGVlLn5ysCtnBL8npN37NrYpEXl8GCBwMuWwdoX3fkHfGxGUXW7oCkbeq2SgggChQU gr+dHNdQbDJMgL/1JjmnYoQ4r1ztAj5dH3hqY4PiawjYTIke8uJ+BvmxNNaUDPp+wJp8 nl2cl3jVEm2QfhYf5kU7dJQIrnGB2sHJkl3mGzwwWcKJBsZwsnF/NnucycV0/AoJE303 jCgIH5Na22FxUCPdFO7+mvxdwLbNXw8LiGMZI6exw9J6Yw5BQr11akef1271x4RSvsh1 ue7RGL3ZJ4PlrDCflFwZ0ONeurEiKtZ89yFab/qVq+oXT892uCOLqR9vFBRDHAXULrKX 8OQw== 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=yivtmjIxjxBk5vZZ7Itp2G4z4IxdJHmSXuDySeahfag=; fh=/lYCltQoICvZOiEykQDkdAMUBJcCrz5GO5CAiInM168=; b=qhRgXEs7R3gq72I5jft4utD2SlWdGiPlbzVe3YJddY3pIcJS+uAIVxCKLBN2HvJHi6 ZVyk1pZDn3QcPM/lkVs81xVD8uj59Ue8JMgnVcSSaAxyybBFpuc/bkLvPxd7/+L9SnKG dYukDDz7D9w3Pld11MJ1cMkrQVR1hVW1wsqjpHuDYARuanUf6z/onBn/zuId803w/RLk U8ED93EwwFkqh/mobQD2PiPkO7/AAUchERNYOZo8iMizE+eVzBdQ2QyKPJtaIm3Zg18r 7RgTXjT/hWDcdToB84X/XSn9OPNtNOKvB9EWBPsC6k1onJEyq3e75bsHwonub2SYzKEn s54w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Mn3TOmiv; spf=pass (google.com: domain of linux-kernel+bounces-18800-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18800-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q4-20020a50aa84000000b0055753dcad8esi1189617edc.48.2024.01.06.22.31.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 22:31:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18800-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Mn3TOmiv; spf=pass (google.com: domain of linux-kernel+bounces-18800-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18800-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 360C81F21C80 for ; Sun, 7 Jan 2024 06:31:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C01212E46; Sun, 7 Jan 2024 06:30:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Mn3TOmiv" 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 7568712B92; Sun, 7 Jan 2024 06:30:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB07AC433C9; Sun, 7 Jan 2024 06:30:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704609040; bh=umVU6nCEokwPLk3HrZTDkXejHPDj2htP73GTdyKh3eo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mn3TOmivgPCO/CP1FPDa6+UeC0fG+YnB1vlkpqGB06WykzQhSPZgfEWRjWSnOLOyA vMv2q9+q2So6X8m3t5rWgEmAeIzV70HxK/hLtzArezOr1DDRxdqK57bJxRZ9A2UZVt en517NGqSEQ4HCxaEi4MWz4wELJfFmGewjf/sZeuFmANs6890megy/uRZa6AkhAhVF gs3uALG2rQfQyz9hK92vN8lQ+4zCiJxZW8JyJWF7kNE6ZZxxZpg6su2usEZEr4lw4V CiABSujfXFQHpYjkSPuLmB9DMaSM4+RCGMYYHjxyal5c2Q2HJ46XoLt/5O6ZcWx10y 0wNlHmlwdEJiw== From: guoren@kernel.org To: paul.walmsley@sifive.com, palmer@dabbelt.com, alexghiti@rivosinc.com, charlie@rivosinc.com, guoren@kernel.org, panqinglin2020@iscas.ac.cn, bjorn@rivosinc.com, conor.dooley@microchip.com, leobras@redhat.com, cleger@rivosinc.com, willy@infradead.org Cc: linux-kernel@vger.kernel.org, Guo Ren , stable@vger.kernel.org Subject: [PATCH V4 1/4] riscv: mm: Fixup compat mode boot failure Date: Sun, 7 Jan 2024 01:30:22 -0500 Message-Id: <20240107063025.1628475-2-guoren@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240107063025.1628475-1-guoren@kernel.org> References: <20240107063025.1628475-1-guoren@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787412159908842046 X-GMAIL-MSGID: 1787412159908842046 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") Reviewed-by: Leonardo Bras Reviewed-by: Charlie Jenkins 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 From patchwork Sun Jan 7 06:30:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 185712 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp418237dyq; Sat, 6 Jan 2024 22:31:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdGovDu28SSyRksjxOoTRlN4VXwf0NMCGJejjB9Tg6tfIH86TA2pQ5Ssd+ZZdFlf1VUCjA X-Received: by 2002:a17:90a:6384:b0:28c:a2ff:9970 with SMTP id f4-20020a17090a638400b0028ca2ff9970mr480877pjj.35.1704609094171; Sat, 06 Jan 2024 22:31:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704609094; cv=none; d=google.com; s=arc-20160816; b=zyR/7ADu3LNPt5MPShOmE4cVtNHRu2K9mEmsLi/63BecLOBkJOKpqeO62k//4++ygw SAYt0QVBqX6uhtCF+6qhTW2S/dVJRvgDblCLVp7jW6ENhQbXCYl0d9s4rNVNR6PD8HAn kJNGL2JuNMZh+Bx6opS/bVUsdr8WZ+gtsWhWP7EQ5CTip9Ur4xJgmofofEIQ6V48vMZb JXS6YCQqgs8iEOMY2iwcc9QjfeQM+9jBRznZTbNPWN+YeDfZDD2vAe2sW2igPpztYBIw vLd05cJBJKO0zPJI9nGublnuiX65UkeCVdTjENMt6lKPjbQbwuQMMNvF0l9lmuOx91cI RqwQ== 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=3WWPCnsD0bkNsqM6rw3TZ82B+qTOIBc7aespK5GY4VM=; fh=/lYCltQoICvZOiEykQDkdAMUBJcCrz5GO5CAiInM168=; b=gcVP90mat9MQZ5Hyp4Rp9GZwDmumb/H3o1pBebWsPCF8sbLII+sVGiq/23bmcu+ziM rAMez/fms4HycpjccvRDyoEy0g+UfxUVvPjy1n+R8EyqkeHDFkmJnZhzWFetNQCPKkKt X0+VDMGGPkIu8y4rUrPalhRqtcjFP2SW5vclOaTz0AScygHOt1NQ2qozw7FJR5MOWcAu /Cjw0ZeG82dBta8BCDSNbqonXbqus0MojB0kXjhZRL2lHpBTJ2dNGmNgL8wvyrOx9suw APIzY17mZZ7pAzKnxuAV3S5RkYudH9fdchVJsI+lHkY1AgF8FbCCEOhHnm5JdFUjNOuW OOJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BEErWvmR; spf=pass (google.com: domain of linux-kernel+bounces-18801-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18801-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id j8-20020a17090a738800b0028ce6523925si3604804pjg.76.2024.01.06.22.31.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 22:31:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18801-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BEErWvmR; spf=pass (google.com: domain of linux-kernel+bounces-18801-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18801-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id CEBE5B217DC for ; Sun, 7 Jan 2024 06:31:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E8149134A3; Sun, 7 Jan 2024 06:30:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BEErWvmR" 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 5977B12B66; Sun, 7 Jan 2024 06:30:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0E87C433C9; Sun, 7 Jan 2024 06:30:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704609044; bh=YilEYSeqr0j5pZzspgrqRl75oKMAwPW5xtHbgWvnWkc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BEErWvmRP+NHy/jjchNvIRuWxKTcy8/+6eKXBfdkbcPp5RmlvdvpJZuSYRAfADUyH iwPowOPa0uFKC+9F1I8BFIflxTZw6YrSRjNZpLZc+1JJEd+GKJ4dyCr/Fh9UVosHLz rJseGwNuDC9/0AeWgpkfUPYjZobEHfURx2QM8sF1FmuEjeKf/90d6qRWdNTjyf8ALM HrItqTfrXlLb6Fx4RqUVRWTmnVbvKzpJgtkSWcoyi++ommxiewPcQX+/Kg4mdSC4Gk WrLRAAR2WXpCT6BV2mOsx2YIHnwAEX7S01SJD1fzII4sx+LPxFjgNk6aScaNdcLdZs H724z8mQTXM5g== From: guoren@kernel.org To: paul.walmsley@sifive.com, palmer@dabbelt.com, alexghiti@rivosinc.com, charlie@rivosinc.com, guoren@kernel.org, panqinglin2020@iscas.ac.cn, bjorn@rivosinc.com, conor.dooley@microchip.com, leobras@redhat.com, cleger@rivosinc.com, willy@infradead.org Cc: linux-kernel@vger.kernel.org, Guo Ren , stable@vger.kernel.org Subject: [PATCH V4 2/4] riscv: mm: Fixup compat arch_get_mmap_end Date: Sun, 7 Jan 2024 01:30:23 -0500 Message-Id: <20240107063025.1628475-3-guoren@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240107063025.1628475-1-guoren@kernel.org> References: <20240107063025.1628475-1-guoren@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787412185688037867 X-GMAIL-MSGID: 1787412185688037867 From: Guo Ren When the task is in COMPAT mode, the arch_get_mmap_end should be 2GB, not TASK_SIZE_64. The TASK_SIZE has contained is_compat_mode() detection, so change the definition of STACK_TOP_MAX to TASK_SIZE directly. Cc: stable@vger.kernel.org Fixes: add2cc6b6515 ("RISC-V: mm: Restrict address space for sv39,sv48,sv57") Reviewed-by: Leonardo Bras Reviewed-by: Charlie Jenkins Signed-off-by: Guo Ren Signed-off-by: Guo Ren --- arch/riscv/include/asm/processor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h index f19f861cda54..e1944ff0757a 100644 --- a/arch/riscv/include/asm/processor.h +++ b/arch/riscv/include/asm/processor.h @@ -16,7 +16,7 @@ #ifdef CONFIG_64BIT #define DEFAULT_MAP_WINDOW (UL(1) << (MMAP_VA_BITS - 1)) -#define STACK_TOP_MAX TASK_SIZE_64 +#define STACK_TOP_MAX TASK_SIZE #define arch_get_mmap_end(addr, len, flags) \ ({ \ From patchwork Sun Jan 7 06:30:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 185713 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp418270dyq; Sat, 6 Jan 2024 22:31:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqeLLKc+K3DfvQDNq4hsQ6c7IBlF6pPrmCMcXgNDD4YqtJMiy4hgMYXXBDQ+2sJHUYjNdh X-Received: by 2002:a05:6a20:a104:b0:199:a053:385a with SMTP id q4-20020a056a20a10400b00199a053385amr25902pzk.55.1704609107955; Sat, 06 Jan 2024 22:31:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704609107; cv=none; d=google.com; s=arc-20160816; b=0moC+VxCdvFKcK1moAbkH2LR46M1TxvRdDh/lclb00kaaSR1p4MG6qWZRMPi4IezYr b3+Dl0tQIyk2uw9VS8D+qUZ2r/rB9sHpCUH531TYg3a/SAU1UYGavd6SgEiqbl4BbQZA vAgkfUY1yChPXBajAT7Dw6iqRsWSwvPuR2ZrvOIMiYpyOJ4g4thlB7iNIHYlg+2B59OQ w6cXRTbPyNVLnfH7AbG/Iy90ZIwfixlahlzGrb6RN5h3fEOl9AFbq/ggslF3r5Dho+H8 rD6VF4FjWDozRcpS8AS9A/krABg5E/bS5Wd5803aiRaO+yYE0pkj8EvhtzTkiqibE2nu BumQ== 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=51cR+iiFTSeuQGXrjyfcONIKJ3brzFQxfBINGcHw8C4=; fh=yhmNvk3uep6UOKkj3Qx0qRxJTOOYElfRY/Q5awrrhME=; b=m6vPSWDbO4yBOj8QuA1SKkqF4/OtOMXV8kc4etB8cQY2SM/EZiUncSttnvZh3C/kur Gogb3usoFv76LtlEwt48YnNuClrcpIx4CxtUCbYS5R3Gq55GRbu19VoAaPb6Xt7Vsq2w aB9hA68G/XJUW0GSfnWlNCQrNiYebgKyHoF9wRdbrl6W93lpDrVQxP26B4xdrTFoY87i CiympD6IOcJAQrQTrBJjKYAHJsblRvrPBexlvjXmD7WlT3Yufx19a5xsAsVfUHhAXxf+ uAHDMgoEojMiTRlUmvSy/fv5bA9XA1uz1XMOOAwZvF+ATo+07WqqPXk6+Ku5pfKzoVeP 3vXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=G3HfLCNV; spf=pass (google.com: domain of linux-kernel+bounces-18802-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18802-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q63-20020a632a42000000b005cdfdfcd033si4123858pgq.180.2024.01.06.22.31.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 22:31:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18802-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=G3HfLCNV; spf=pass (google.com: domain of linux-kernel+bounces-18802-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18802-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E243CB21C27 for ; Sun, 7 Jan 2024 06:31:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5E2BD12B74; Sun, 7 Jan 2024 06:30:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="G3HfLCNV" 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 C63AF134AB for ; Sun, 7 Jan 2024 06:30:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D09CC433CA; Sun, 7 Jan 2024 06:30:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704609049; bh=vzAUwHIH1r+/fUC34Yyxdlm+3Xgnktg3iqTJcmMW334=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G3HfLCNVX2P6JME1CRwoKlII+8fekB61j+wxGk8SBt44Z+PfP5xWipdBEl9SxyI9Y JgxqN1nqfT4weGIevxsCwJfRZPerhMFS+oG5jbTx/vZuhAnfMu12xrhRCeIG/06IwF Bk8QKbobbXzKmmotNNZNuDEivbp/qqUTEjT9as7W3FFlow/6A8Dlf6bQ+7Lv79Xj29 qI3yqZu1Co4UPztVZ/4IB6kUle6SbZ0cZnzACHAADsQ+kx8jhSA2MQD62USMr6VF8n C8SbqZ3VnLGwKPRpcYLP68+Gvb7UX/pK6Z0V/zF4xaR5q4yBaZ7hJTKsLIxyrUABmP vleOZdLP7cfzw== From: guoren@kernel.org To: paul.walmsley@sifive.com, palmer@dabbelt.com, alexghiti@rivosinc.com, charlie@rivosinc.com, guoren@kernel.org, panqinglin2020@iscas.ac.cn, bjorn@rivosinc.com, conor.dooley@microchip.com, leobras@redhat.com, cleger@rivosinc.com, willy@infradead.org Cc: linux-kernel@vger.kernel.org, Guo Ren Subject: [PATCH V4 3/4] riscv: mm: Remove unused TASK_SIZE_MIN Date: Sun, 7 Jan 2024 01:30:24 -0500 Message-Id: <20240107063025.1628475-4-guoren@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240107063025.1628475-1-guoren@kernel.org> References: <20240107063025.1628475-1-guoren@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787412199632564057 X-GMAIL-MSGID: 1787412199632564057 From: Guo Ren Remove TASK_SIZE_MIN because it's not used anymore. Reviewed-by: Leonardo Bras Signed-off-by: Guo Ren Signed-off-by: Guo Ren --- arch/riscv/include/asm/pgtable.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 74ffb2178f54..e415582276ec 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -878,7 +878,6 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte) */ #ifdef CONFIG_64BIT #define TASK_SIZE_64 (PGDIR_SIZE * PTRS_PER_PGD / 2) -#define TASK_SIZE_MIN (PGDIR_SIZE_L3 * PTRS_PER_PGD / 2) #ifdef CONFIG_COMPAT #define TASK_SIZE_32 (_AC(0x80000000, UL)) @@ -890,7 +889,6 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte) #else #define TASK_SIZE FIXADDR_START -#define TASK_SIZE_MIN TASK_SIZE #endif #else /* CONFIG_MMU */ From patchwork Sun Jan 7 06:30:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 185714 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp418310dyq; Sat, 6 Jan 2024 22:32:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IE44zF1TBYgAGGOHnKeaUPQNIXkbg7hQqNwhXOB/69CBQTX5RCVwTBsSF4nOey1gx76tsPa X-Received: by 2002:a17:902:7c8c:b0:1d4:477c:4753 with SMTP id y12-20020a1709027c8c00b001d4477c4753mr1963258pll.42.1704609123110; Sat, 06 Jan 2024 22:32:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704609123; cv=none; d=google.com; s=arc-20160816; b=JhOXgBB/b4T9wfokfKAK1BkH0kQ5V+oyxBKBM/bZWxN1W16iyIA+ON/fb/UG5/OWx3 RokxLsqzASvTVZm0L+0uTpyn67HnhYKGNi0xsEoEu9OlxZ6xFosDqebF7tOkQmgxweay F28jC3xTCD5BXAOlNAKkMof4BBg2Zps8ghPvqMG7oHjpF+NhIGiA2ObKltX1vyW5AqQD AhZ2DHyf8boNpAHUSfBt3sL04rl+5WSFE4yPUc1uVY5Qt/ZiuNyScYER8ehzMcxsG8Te RizHhDhjvG6i1bvlEn6zAcWkRGix40MnteNjDgXLU+3999inONf3qWYp1YbGshjUh2VZ H1sw== 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=oOZZs3PpDAkDeF0MOjYrzS4GP5LC1t8VKDdE5SDt6qw=; fh=yhmNvk3uep6UOKkj3Qx0qRxJTOOYElfRY/Q5awrrhME=; b=0ZMqKIFahw/Im5MdVAWIlhXBuikNqqJCRGzXHG86v14YopJpiDpULEld+Pc1g9/qgP Ki+8HfeA8JfDGhNzUnH616+gYkCB7WsbGXrwZFcdQWDGqkwZtQVhblXuF6dJqmQD4F9P HVFJEnoP329cl9vLCN/m9ArhZasPXdC9PklNElxEmBd3HZso8pl8wfJS4icyCpu+1/iR Zwh6qSCZtORwIlxgafeKAGF7g6UW2xjtaUyS/xkA+CLXifsTssdRNlUib9jiEPTCwYKj LqWhyDhHPrOrddtS3f5Ak/fXhHtUF4u4MLo82KqJQhYwbL0y583312TWM8NXHM08gd0F rpbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="agAcaV/N"; spf=pass (google.com: domain of linux-kernel+bounces-18803-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18803-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d16-20020a170903231000b001d40595144bsi4010063plh.282.2024.01.06.22.32.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 22:32:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18803-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="agAcaV/N"; spf=pass (google.com: domain of linux-kernel+bounces-18803-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18803-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id B67F6B217D3 for ; Sun, 7 Jan 2024 06:31:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5A2D8826; Sun, 7 Jan 2024 06:30:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="agAcaV/N" 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 4C2A612B83 for ; Sun, 7 Jan 2024 06:30:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E65CDC433C7; Sun, 7 Jan 2024 06:30:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704609053; bh=Bpr3cN4ZdKoHQcirLqVi0ln0qEuA20LN4TwxV/9UyIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=agAcaV/NvLQp39pnbxq5D6E3FwE2Kwp0XpWaz5aMDV3I4idAjyymK1ctu+sf4nhWS KryA/Rv1bnzYa+sqzTyoCklXBMwfcoByx13WuGYsH7hOdoeC65nTGu1jvoU2atK2rW 9dKKWkvCl7wL1uw/b64Aov6lca1OdzHYKTYA8XNFMKhMY8rksmoWPRHEO+Iy75Wq0c K1WPlv/dFlIWmbIWHvuVJPr+DEKOTQi4hjBfifT38XFMsF9ZDsFzrkeRauqlhLsyN1 L7IkKLk97GgFAkFu0zFiekkJDLVgUj1jln47xCpWyWHAiGGk8arh1tKhbYWLKsRSWs jinIrjKHkMGsA== From: guoren@kernel.org To: paul.walmsley@sifive.com, palmer@dabbelt.com, alexghiti@rivosinc.com, charlie@rivosinc.com, guoren@kernel.org, panqinglin2020@iscas.ac.cn, bjorn@rivosinc.com, conor.dooley@microchip.com, leobras@redhat.com, cleger@rivosinc.com, willy@infradead.org Cc: linux-kernel@vger.kernel.org, Guo Ren Subject: [PATCH V4 4/4] riscv: mm: Optimize TASK_SIZE definition Date: Sun, 7 Jan 2024 01:30:25 -0500 Message-Id: <20240107063025.1628475-5-guoren@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240107063025.1628475-1-guoren@kernel.org> References: <20240107063025.1628475-1-guoren@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787412215950135210 X-GMAIL-MSGID: 1787412215950135210 From: Guo Ren Unify the TASK_SIZE definition with VA_BITS for better readability. Add COMPAT mode user address space info in the comment. Reviewed-by: Leonardo Bras Signed-off-by: Guo Ren Signed-off-by: Guo Ren --- arch/riscv/include/asm/pgtable.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index e415582276ec..271565e1956f 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -866,6 +866,7 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte) * Note that PGDIR_SIZE must evenly divide TASK_SIZE. * Task size is: * - 0x9fc00000 (~2.5GB) for RV32. + * - 0x80000000 ( 2GB) for RV64 compat mode * - 0x4000000000 ( 256GB) for RV64 using SV39 mmu * - 0x800000000000 ( 128TB) for RV64 using SV48 mmu * - 0x100000000000000 ( 64PB) for RV64 using SV57 mmu @@ -877,10 +878,10 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte) * Similarly for SV57, bits 63–57 must be equal to bit 56. */ #ifdef CONFIG_64BIT -#define TASK_SIZE_64 (PGDIR_SIZE * PTRS_PER_PGD / 2) +#define TASK_SIZE_64 (UL(1) << (VA_BITS - 1)) #ifdef CONFIG_COMPAT -#define TASK_SIZE_32 (_AC(0x80000000, UL)) +#define TASK_SIZE_32 (UL(1) << (VA_BITS_SV32 - 1)) #define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \ TASK_SIZE_32 : TASK_SIZE_64) #else