Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2827682pxb; Thu, 3 Feb 2022 15:44:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJx542f7haDOWZLxEGigmUpa+oAJmtjYD0vFm5JY2dxX8RU2IFIG2HRKjAij4ZAuXcZQh4Nw X-Received: by 2002:a17:90a:694d:: with SMTP id j13mr153269pjm.10.1643931847067; Thu, 03 Feb 2022 15:44:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643931847; cv=none; d=google.com; s=arc-20160816; b=oGtH5Ajsp59S5LifwU6Od2zchWi7X8bWf9c8yenAMWc/gHNgBmBR5/P+KrTDWK1uHj rNU2BtPtHUzENRWhv0/7q2TZOPR6iJ2lAmQjJunDvd42fHTOluJtY7ZhC4HpmugqJwRq 6zY71M45A456KYBzzd8Us9XxDsHXI2toBfX2kRD52oSEQRmlbmOhzbbz5VdCk63vKMVj kI4uUxZoSHHLlA+ihTXLNkG4xv5MrjEuHQBoDflY07NZe1tSaZzNPrUT9qIqz0PxdfAP wNH15L9kmAnYrXtPWGiu17K7bPVnKrcG+iLoHG3DB+66BWak4G0kGL9lMQD9OglQYnLo W7nw== 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 :dkim-signature; bh=VeOgX34HqBQD1om5QEHqlWGb0XmwFUjfaUn6e7z0Y00=; b=J4UrilN9d2uNTs/+Fgge0qaAPcGY0bovRpAj+ZAkHnveu9g7peqOT1x62hUBnOF6jF zX29GzEnxvDOqc8/f51EK+acIz6DpNKjJhS4avvSxtshATUrG/7PaPoS8N/KG4lMRfuy dOZzui4b6pSQ7qhNM568usiTZa2Q7j8rmDUiBnrpwXZC4wtxy9Gkp0bPDjQ/9JosMVKO 7wDvbwguyRiPgSlJSzG28iwlc53fQzze0dxLPJQuunXa1v+UBuHrm2PDUqzU9Yz0hv32 JKr/PiWH/xzwhrvuLbF7+RUVMfO9hpMqoeC8jjWOiFr5b7kDe3rPcaSjlWxOa3YtAL+g tBAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="R/OC8wFv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lk3si11572096pjb.103.2022.02.03.15.43.55; Thu, 03 Feb 2022 15:44:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="R/OC8wFv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239982AbiBAPHO (ORCPT + 99 others); Tue, 1 Feb 2022 10:07:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239921AbiBAPHF (ORCPT ); Tue, 1 Feb 2022 10:07:05 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5DEAC06173B; Tue, 1 Feb 2022 07:07:05 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 82042B82E98; Tue, 1 Feb 2022 15:07:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 370ECC340EF; Tue, 1 Feb 2022 15:06:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643728023; bh=a1sC80QEMsJ1SgwAfWEJYAxYwB7cBGeGznoe8NpsNfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R/OC8wFvI3f02Iycn2k2srEKbrGNKSg2nuFurmauT/lCNJf7lYC8hE/FTUE0PPSyI IT89j4G7Lo2vKWpygW0h8HE3osNKssXR5I/ALlmGKFXNreY9GTWDDVD34neYRRHw3/ e2EcBXiNbcT/bNtn70v+YxIdTplb5AB17tca1ct869D2iF4J53MYVp4AAeWLA8Yzqu Iv/GOSGWYxB1EEL0iOdxre9NKG62AtNDD64hEXQxe8gijJCmxxpijsqffSJyFBzg3P BdLygsTeaTIWE59+Ank+TlmjedYUCX0rbr6pMIOFN9OaIt0yBqECO75YAaKnIaf4Jl jvK5Z8q2gbKbA== From: guoren@kernel.org To: guoren@kernel.org, palmer@dabbelt.com, arnd@arndb.de, anup@brainfault.org, gregkh@linuxfoundation.org, liush@allwinnertech.com, wefu@redhat.com, drew@beagleboard.org, wangjunqiang@iscas.ac.cn, hch@lst.de Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-csky@vger.kernel.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-parisc@vger.kernel.org, linux-mips@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, Guo Ren Subject: [PATCH V5 10/21] riscv: compat: Re-implement TASK_SIZE for COMPAT_32BIT Date: Tue, 1 Feb 2022 23:05:34 +0800 Message-Id: <20220201150545.1512822-11-guoren@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220201150545.1512822-1-guoren@kernel.org> References: <20220201150545.1512822-1-guoren@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guo Ren Make TASK_SIZE from const to dynamic detect TIF_32BIT flag function. Refer to arm64 to implement DEFAULT_MAP_WINDOW_64 for efi-stub. Limit 32-bit compatible process in 0-2GB virtual address range (which is enough for real scenarios), because it could avoid address sign extend problem when 32-bit enter 64-bit and ease software design. The standard 32-bit TASK_SIZE is 0x9dc00000:FIXADDR_START, and compared to a compatible 32-bit, it increases 476MB for the application's virtual address. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Reviewed-by: Arnd Bergmann --- arch/riscv/include/asm/pgtable.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 7e949f25c933..f0d125ea3ceb 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -704,8 +704,17 @@ static inline pmd_t pmdp_establish(struct vm_area_struct *vma, * 63–48 all equal to bit 47, or else a page-fault exception will occur." */ #ifdef CONFIG_64BIT -#define TASK_SIZE (PGDIR_SIZE * PTRS_PER_PGD / 2) -#define TASK_SIZE_MIN (PGDIR_SIZE_L3 * PTRS_PER_PGD / 2) +#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) - PAGE_SIZE) +#define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \ + TASK_SIZE_32 : TASK_SIZE_64) +#else +#define TASK_SIZE TASK_SIZE_64 +#endif + #else #define TASK_SIZE FIXADDR_START #define TASK_SIZE_MIN TASK_SIZE -- 2.25.1