Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2869159lqp; Mon, 25 Mar 2024 11:30:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXafl3VSrdRrLLs9B4K9xYbth6dmg9fQAwm4IV7cQOEhRE9JQ5XWaScLlBtNCE5zPpz7+i/vCmIPbf4jYcTCjL8HnWrvFH6Wa5I19wRqg== X-Google-Smtp-Source: AGHT+IFYzaKSxIor8UZSjP+0bm3fK1ss4n7IN6HmYlv4t+ujckR3BinPUtnMEtFG8/kRqJQn6Gjl X-Received: by 2002:ac8:5d86:0:b0:431:108e:cd1 with SMTP id d6-20020ac85d86000000b00431108e0cd1mr8932956qtx.57.1711391440946; Mon, 25 Mar 2024 11:30:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711391440; cv=pass; d=google.com; s=arc-20160816; b=Z44q3gMH9NbLk9pVkqMwSXf/mnLAcZGNRj7iOnEb8qpdqop+KGnLCD7G8bvrLi2qi6 5qZEuWXqQ5Pqht36podXXASJnsKM6DK5wAjzuMe2uwIQ2pSv3jOThGlgUqA9hR7M9r8M qCsn6MsAQTrYVq98ZaUaUDoceqtzRqST4g8wkDNDsoEm4EODTNiFfyhPkUSH1XQFyGrj pFwKXPpAwErT6kfXOk9D3A04V4m1Xal75WcKfPMyHwBMSr2K64SlrbFWS16ah8bPdUlp Blp+Qfs6cSKAYw9cGugxCpKtY9bTzTht5JGa7CDbN6TcWSJKfWtQxs+qkBlIKL6QmOkl NDSw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:cc:to:from:date:references:in-reply-to:message-id :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:feedback-id:dkim-signature:dkim-signature; bh=MZ8i+Gw+8UGRptvTYhnegZ3s5XeZTdAEd0vXFYyBJzU=; fh=e+RjrWMvCVEy0QU3DqTr1CUr+yX70FF4seCHDpM5jbM=; b=mh9AsG1OWaxoEUidDYS/hsUwvJmY8Sdk6bqz6K/dQSPV3JaSiXLWt+KU+USitd/jEu O+kJC8+0nFKu+CXK5ydieK+tc88ahvJ+8uRR5I5EvYYCRwXtUDzaAub5wexPHsJGQiwj wbZ1pUegGIZW9pS7e1Y6iuCQPeSESCKNpAbq4AUFEyjVUDQnNnDqoIbk/lGy16QzBSaa wj9ezyCCtKhTlNQc3rGbzuqnHyfOUAo2ulzXHRTo24gPTcF7a4qh8Fhy+6ob50WDHAFa E1oZ4I08GiYHiVJR02MeJOenY+sGGAxaMAjBUjPh25VUaG5HzBxhrcE8NjyfuBMqiToI qlnw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b="VEbwH/ZO"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="DuwM5x/R"; arc=pass (i=1 spf=pass spfdomain=arndb.de dkim=pass dkdomain=arndb.de dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=arndb.de); spf=pass (google.com: domain of linux-kernel+bounces-117672-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117672-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id e12-20020a05622a110c00b004313d2cde19si5856529qty.251.2024.03.25.11.30.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 11:30:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117672-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=@arndb.de header.s=fm1 header.b="VEbwH/ZO"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="DuwM5x/R"; arc=pass (i=1 spf=pass spfdomain=arndb.de dkim=pass dkdomain=arndb.de dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=arndb.de); spf=pass (google.com: domain of linux-kernel+bounces-117672-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117672-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de 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 A7E591C60522 for ; Mon, 25 Mar 2024 18:30:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 50F695490D; Mon, 25 Mar 2024 18:02:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b="VEbwH/ZO"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="DuwM5x/R" Received: from wfhigh6-smtp.messagingengine.com (wfhigh6-smtp.messagingengine.com [64.147.123.157]) (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 21B6660ED0 for ; Mon, 25 Mar 2024 18:02:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.157 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711389760; cv=none; b=R4A1362hhS6c1WnqDoT7zkbdwZhcBoDczbOc5UAz2bsrFnwkPZZtM3u/Hp04ZE7tx7+YhM2ZJXVV8hZkOtGTlCCZoWHTG6z/mXKfq6KKk9z4oC48D7dluj7GzcQS/mYm17H1X2b1b7xmEyNW2gJpj+/399K9Dh3px4X6k6Jwzd8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711389760; c=relaxed/simple; bh=9Kc4RxYAxHuTl3CFSV/d0BgxGhfm6+wZgv60jU0R42Q=; h=MIME-Version:Message-Id:In-Reply-To:References:Date:From:To:Cc: Subject:Content-Type; b=qrh70x3nMvJBQCwjxSD4kV2mDQrUEcTX2jzW/3AF6f0NNClqv+DJsHgbgPY/udNVuOkgV0+5sPoFMKi8s0mfHtglBCawCx55sLeOKC37euyGx8MHVj+s4idBSAbNYl0905JZrae8B4epbpezCNIHpLttRfBU4pZ3WGu091Iwcdc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de; spf=pass smtp.mailfrom=arndb.de; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b=VEbwH/ZO; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=DuwM5x/R; arc=none smtp.client-ip=64.147.123.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arndb.de Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfhigh.west.internal (Postfix) with ESMTP id 67A5D18000B3; Mon, 25 Mar 2024 14:02:36 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute5.internal (MEProxy); Mon, 25 Mar 2024 14:02:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1711389755; x=1711476155; bh=MZ8i+Gw+8U GRptvTYhnegZ3s5XeZTdAEd0vXFYyBJzU=; b=VEbwH/ZOjXX+6S7+y28Yyc+vWh Ca3MEk4YxNwb4JxA0pyWCeXBL3vAle5gi06OoeGki82Ie7LQdXk9n5GK2GW55mql nLmqXwC4hshhdsEGA/K1nk+h6K4AODag0IvFFzhl4aQ9BJOME6U/e1fZj1tp4EBG sD00QoVswMY6HvkZjafP+T8piL2yAFjVEoQBudVHuoWEMb+Lmbp0wyrN8SzDjh+P BE7Bk0sAbbqrQcm8RSeVzxFzabGwYZhWMHazr3NyMddCg67R04fJNfFrnShZaI6F WNoPquXpDSHD8xSYetuhQ/rc9A7Jf3nkfy9eEqnp6ZP0Cja2z9qsQxaK2VtQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1711389755; x=1711476155; bh=MZ8i+Gw+8UGRptvTYhnegZ3s5XeZ TdAEd0vXFYyBJzU=; b=DuwM5x/Rn+rxyTOAQOoNhmPfZJ4KGAm63mFOUDozt+Ob g9Ro3gpszcmkCZ+ZW7UQtWxZLo9gxE8dL3WyM7zDNFynjxGeURELyiI3V7oocqJ0 BEG59jkhks0VzPAbX2Ca9Ygb1rUsX2GGI46jVOeSV94gMw2gSyUsZA98P/NmQSvj p7aWN7aO4IzJG0Lx9b35xnOL+WFgPj10LtBAmgOG6/VDxe4qZHB7mHNFpLLBFM8+ TWWd+Bp/V3VtiOF/6JcAtlFXboYIrhP4xGpD7Tnr4pFwWiRQVFc4xzxmrOr9PDcw F7In0ielSZEvfnoysg5q9vZRv+StTODJVsCRepSAlg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudduuddggeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedftehr nhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrdguvgeqnecuggftrfgrth htvghrnhepffehueegteeihfegtefhjefgtdeugfegjeelheejueethfefgeeghfektdek teffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hrnhgusegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 03979B6008D; Mon, 25 Mar 2024 14:02:34 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-332-gdeb4194079-fm-20240319.002-gdeb41940 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: In-Reply-To: References: <20240313180010.295747-1-samuel.holland@sifive.com> <88de4a1a-047e-4be9-b5b0-3e53434dc022@sifive.com> Date: Mon, 25 Mar 2024 19:02:13 +0100 From: "Arnd Bergmann" To: "Mark Rutland" , "Alexandre Ghiti" Cc: "David Laight" , "Samuel Holland" , "Alexandre Ghiti" , "Palmer Dabbelt" , "linux-riscv@lists.infradead.org" , "Albert Ou" , "Andrew Morton" , "Charlie Jenkins" , guoren , "Jisheng Zhang" , "Kemeng Shi" , "Matthew Wilcox" , "Mike Rapoport" , "Paul Walmsley" , "Xiao W Wang" , "Yangyu Chen" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] riscv: Define TASK_SIZE_MAX for __access_ok() Content-Type: text/plain On Mon, Mar 25, 2024, at 17:39, Mark Rutland wrote: > Using a compile-time constant TASK_SIZE_MAX allows the compiler to generate > much better code for access_ok(), and on arm64 we use a compile-time constant > even when our page table depth can change at runtime (and when native/compat > task sizes differ). The only abosolute boundary that needs to be maintained is > that access_ok() fails for kernel addresses. As I understand, this works on arm64 and x86 because the kernel mapping starts on negative 64-bit addresses, so the highest user address (TASK_SIZE = 0x000fffffffffffff) is still smaller than the lowest kernel address (PAGE_OFFSET = 0xfff0000000000000). If an architecture ignores all the top bits of a virtual address, the largest TASK_SIZE would be higher than the smallest (positive, unsigned) PAGE_OFFSET, so you need TASK_SIZE_MAX to be dynamic. It doesn't look like this is the case on riscv, but I'm not sure about this part. Arnd