From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E4B6C7EE2A for ; Tue, 24 Jun 2025 05:27:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D70E86B00A8; Tue, 24 Jun 2025 01:27:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D21736B00A9; Tue, 24 Jun 2025 01:27:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C0FDB6B00AC; Tue, 24 Jun 2025 01:27:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id AFD786B00A8 for ; Tue, 24 Jun 2025 01:27:53 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2E00F5FDAC for ; Tue, 24 Jun 2025 05:27:53 +0000 (UTC) X-FDA: 83589162426.22.3BC0420 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf04.hostedemail.com (Postfix) with ESMTP id 0E3AA40005 for ; Tue, 24 Jun 2025 05:27:50 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf04.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750742871; a=rsa-sha256; cv=none; b=16zApYyhdEMSs5zQUDzy/9H+W034r0RZx0MdNhQdec0tEMNVQbIJsZimBjCpQ3Eq53IJiG HUiY8uXoVtujcw94Y+DhTkA2Ucah8C8m7oY18XblgYxmxcN/39+vJ0OhElpjLDruX0Bj8T BMwj0RzRVT0ihTWHhsgDkcoUW32lsos= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf04.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750742871; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EO1qbStgarmOW9mGDSDoweBf/E2w4Qp1gXtmbRU0lGY=; b=zZhjnJSvLdq60cfJVLB9xYU6Z9mYV7ZehW+xpkD1KVlQ7bkFjagFo5tuRGNYcU3JA8gXU2 dXi1kqfSExeXf3iYRHgohNs9v5hO8hIV25jrBDmnxyf+/29uoQ56kCqzswOyKKLzAXFquN eV7gvRpi9TPjQNUPOE/yZ6gQgQBmrzI= Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4bRD450pqCz9sHR; Tue, 24 Jun 2025 07:27:49 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TQwRk1sPy-Tu; Tue, 24 Jun 2025 07:27:48 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4bRD446pFmz9sFT; Tue, 24 Jun 2025 07:27:48 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id DB3938B768; Tue, 24 Jun 2025 07:27:48 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id SZzaiK0op1Va; Tue, 24 Jun 2025 07:27:48 +0200 (CEST) Received: from [192.168.235.99] (unknown [192.168.235.99]) by messagerie.si.c-s.fr (Postfix) with ESMTP id F03358B767; Tue, 24 Jun 2025 07:27:47 +0200 (CEST) Message-ID: Date: Tue, 24 Jun 2025 07:27:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 0/5] powerpc: Implement masked user access To: David Laight Cc: Michael Ellerman , Nicholas Piggin , Naveen N Rao , Madhavan Srinivasan , Alexander Viro , Christian Brauner , Jan Kara , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Darren Hart , Davidlohr Bueso , Andre Almeida , Andrew Morton , Dave Hansen , Linus Torvalds , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org References: <20250622172043.3fb0e54c@pumpkin> Content-Language: fr-FR From: Christophe Leroy In-Reply-To: <20250622172043.3fb0e54c@pumpkin> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Stat-Signature: orm188q7gfbaxd31wksemq9nsdtf9i1k X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 0E3AA40005 X-Rspam-User: X-HE-Tag: 1750742870-616638 X-HE-Meta: U2FsdGVkX1+9gITxkdx5l0/xoIQ4U38ligEkrwt8Ej/9JxCH6PaLfblHB983nTu77NlsqcOvlMRDzfCo4W4dwq90VYoddKFasu9XnaIw23X13SoLu7yXt60K5bSMVq5uVGewDi1lUehmOb4nuyekNJu7b6ZsDkuPNygbJUfNet9sk9xuHo4fm0ow+nYJ1uLDzusH+ZGsNcCBfJNomBxCOU7WfAuDBIBBkPUBG72Sz5Mv2t7/LOQsi86uf2SiWfqSmrSdmEmY4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ilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Le 22/06/2025 à 18:20, David Laight a écrit : > On Sun, 22 Jun 2025 11:52:38 +0200 > Christophe Leroy wrote: > >> Masked user access avoids the address/size verification by access_ok(). >> Allthough its main purpose is to skip the speculation in the >> verification of user address and size hence avoid the need of spec >> mitigation, it also has the advantage to reduce the amount of >> instructions needed so it also benefits to platforms that don't >> need speculation mitigation, especially when the size of the copy is >> not know at build time. > > It also removes a conditional branch that is quite likely to be > statically predicted 'the wrong way'. But include/asm-generic/access_ok.h defines access_ok() as: #define access_ok(addr, size) likely(__access_ok(addr, size)) So GCC uses the 'unlikely' variant of the branch instruction to force the correct prediction, doesn't it ? > >> Unlike x86_64 which masks the address to 'all bits set' when the >> user address is invalid, here the address is set to an address in >> the gap. It avoids relying on the zero page to catch offseted >> accesses. On book3s/32 it makes sure the opening remains on user >> segment. The overcost is a single instruction in the masking. > > That isn't true (any more). > Linus changed the check to (approx): > if (uaddr > TASK_SIZE) > uaddr = TASK_SIZE; > (Implemented with a conditional move) Ah ok, I overlooked that, I didn't know the cmove instruction, seem similar to the isel instruction on powerpc e500. Christophe