From mboxrd@z Thu Jan 1 00:00:00 1970 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 4729F21730E for ; Thu, 24 Oct 2024 19:09:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729796945; cv=none; b=kbhq4rSb2rKy1BTpUoQiZZz38vVyqVsJG0jICho+kDS6vLu4bMu2xsWQJDYEyfI+f292K0+qMEM0zqaOxgbgfOmxdFiA2qYp+lcN7ayQGmhdreAUVJgl5J2aqxvQPw9bj3H5oBaw6olS6rtHAoEYytaSloy6EjmlrQWOnoowduw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729796945; c=relaxed/simple; bh=2eA9EOl3HC9/GnzLC7POscomQwnN5i9LKrBbdl1GkII=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hVCyFIV1FR6oR92kfN0ywP39XU85EP6524LwJLYGPuH8uBCyUwdE2886vPO0doO8V60mxU9rUb7jXjOIg9xxfzW2cHDCeOpwhCx6MKEP/2at+RCsG6LfQ+ijXXfxElJmM726oOKDxNPbVpeU2N7w4WOfXLy1qjH9GgL/0rc28q4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U4iVuj03; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="U4iVuj03" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AAF0C4CEC7; Thu, 24 Oct 2024 19:09:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729796944; bh=2eA9EOl3HC9/GnzLC7POscomQwnN5i9LKrBbdl1GkII=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=U4iVuj03Sfl8R0t80flJPI8fUKTTsseDJbwPscuW9LSMtWAE1Au4hYlWfVu9xIeXl uEB6RizCcEeOKzYE7qMVmBtnLbnfZYDNiBZCVaGz5/+8aCDwUPviDtXCOVbBlTxdnf xWnY18d8e9Y/Y7ZzInq11gOaBS3+0/xw0O3xdeVTve6kQsj0AniTSM2IgSqoOIDk4Q 5qjKrzPBE+sJuPe/UTU5Mtrna99lWx1lVMdELwmxKjXJ2oUrP1snnvn7Xx8Jz8dTRx co72Tu7n5LrRX125k/yNLdI1RMIxsspDESynsGIcH94X9TTl4dw7KAeYWWIS6ZaAHr y/VPLYj+oLVBQ== Date: Thu, 24 Oct 2024 12:09:03 -0700 From: Josh Poimboeuf To: Linus Torvalds Cc: Borislav Petkov , Linux Kernel Mailing List , x86@kernel.org, Andrew Cooper Subject: Re: [PATCH] x86: fix user address masking non-canonical speculation issue Message-ID: <20241024190903.qlmfegs4y7rxl6q5@treble.attlocal.net> References: <20241024013214.129639-1-torvalds@linux-foundation.org> <20241024110822.GBZxoqppmxp0xxG7ew@fat_crate.local> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Thu, Oct 24, 2024 at 11:13:35AM -0700, Linus Torvalds wrote: > It does result in a few more casts on the C side, since you can't just > do bitwise 'or' on a pointer, but I think it's still the right thing > to do. So that thing becomes > > static inline void __user *mask_user_address(const void __user *ptr) > { > unsigned long mask; > asm("cmp %1,%0\n\t" > "sbb %0,%0" > :"=r" (mask) > :"r" (ptr), > "0" (runtime_const_ptr(USER_PTR_MAX))); > return (__force void __user *)(mask | (__force unsigned long)ptr); > } On a non-related note, doesn't the inline asm need a "cc" clobber? -- Josh