From nobody Mon Nov 25 09:35:24 2024 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 E84F218E764 for ; Tue, 29 Oct 2024 01:56:40 +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=1730167001; cv=none; b=H2mStgPZT1TAMP0FGy50VZ8J4BczVS5mvxhLIHNjsIQY/PJpaPrEDQb0UhTsBUq50AEiKmbyj4L5MfznKPrSiLQ7kkppTsm1nR1HJi0MUnuviCQw2YFYLvbVOpxYbxN9Yo2mPQGRV1Mec6JQk4JeruJBuukmViboz2khGc8ahNk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730167001; c=relaxed/simple; bh=IE8lVpfvQw2PdSSBXAG4ZavNEB/AEx7acTSv9OtsKdU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q7vEX9dOK0EAkhSDMMka+j8AdJWQHN4QwAYbS14RO/NVkvV6RQ/vB0quBQdDVaVW+F9Ljqzhxejy2GMM5yyDQjigjaVxdg1Kym5P3GtUeDDT4Sme/GZXJSIOaopdaEwBn48zJexm58SHQnfAmLliH80HdPSx0s9aShLhQm2BRwM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vP6NtVLO; 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="vP6NtVLO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D7E1C4CEE9; Tue, 29 Oct 2024 01:56:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730167000; bh=IE8lVpfvQw2PdSSBXAG4ZavNEB/AEx7acTSv9OtsKdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vP6NtVLOF5MSVKXfLbiGaQ7rBrz+nwyn8OXmIPidSHqN94Ang0Ey0IFWTqlQK1Y0v V1YUzspWLwVcW+caX08qDq9t+paQGzRtumCwpcxsaU4+P0U+u7Q5y5Phy8Q3imUW8m zxIW5wlVIcBdkGg52Rk3zm/U6tVT4iD9LMDOtGItWX+1MBjIT9VgEkGjLW6DajtVe/ 7xXxdQ78h4plFwmfB1nMdTs/1fryGbDiMkZ3EduhzgoHB5FruTbTRfgGGFQgm946dh 0dsmcqJ37mPTRF42IIebnKYp8XbTcyzaWb882nZlhGRmM0OHPvG0B59kJVNh/rqpK7 1tYWuy5PrYXRg== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Borislav Petkov , Peter Zijlstra , Pawan Gupta , Waiman Long , Dave Hansen , Ingo Molnar , Linus Torvalds , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Andrew Cooper , Mark Rutland , "Kirill A . Shutemov" Subject: [PATCH v3 5/6] x86/uaccess: Avoid barrier_nospec() in 32-bit __get_user() Date: Mon, 28 Oct 2024 18:56:18 -0700 Message-ID: <967768924bd5295c231b6bfd37e3cbf85dad3cb2.1730166635.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The barrier_nospec() in 34-bit __get_user() is slow. Instead use pointer masking to force the user pointer to all 1's if the access_ok() mispredicted true for an invalid address. Signed-off-by: Josh Poimboeuf --- arch/x86/lib/getuser.S | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S index 5bce27670baa..7da4fc75eba9 100644 --- a/arch/x86/lib/getuser.S +++ b/arch/x86/lib/getuser.S @@ -35,8 +35,6 @@ #include #include =20 -#define ASM_BARRIER_NOSPEC ALTERNATIVE "", "lfence", X86_FEATURE_LFENCE_RD= TSC - .macro mask_user_address size:req .if IS_ENABLED(CONFIG_X86_64) movq $0x0123456789abcdef,%rdx @@ -107,11 +105,7 @@ EXPORT_SYMBOL(__get_user_8) =20 /* .. and the same for __get_user, just without the range checks */ SYM_FUNC_START(__get_user_nocheck_1) -#ifdef CONFIG_X86_64 mask_user_address size=3D1 -#else - ASM_BARRIER_NOSPEC -#endif ASM_STAC UACCESS movzbl (%_ASM_AX),%edx xor %eax,%eax @@ -121,11 +115,7 @@ SYM_FUNC_END(__get_user_nocheck_1) EXPORT_SYMBOL(__get_user_nocheck_1) =20 SYM_FUNC_START(__get_user_nocheck_2) -#ifdef CONFIG_X86_64 mask_user_address size=3D2 -#else - ASM_BARRIER_NOSPEC -#endif ASM_STAC UACCESS movzwl (%_ASM_AX),%edx xor %eax,%eax @@ -135,11 +125,7 @@ SYM_FUNC_END(__get_user_nocheck_2) EXPORT_SYMBOL(__get_user_nocheck_2) =20 SYM_FUNC_START(__get_user_nocheck_4) -#ifdef CONFIG_X86_64 mask_user_address size=3D4 -#else - ASM_BARRIER_NOSPEC -#endif ASM_STAC UACCESS movl (%_ASM_AX),%edx xor %eax,%eax @@ -149,11 +135,7 @@ SYM_FUNC_END(__get_user_nocheck_4) EXPORT_SYMBOL(__get_user_nocheck_4) =20 SYM_FUNC_START(__get_user_nocheck_8) -#ifdef CONFIG_X86_64 mask_user_address size=3D8 -#else - ASM_BARRIER_NOSPEC -#endif ASM_STAC #ifdef CONFIG_X86_64 UACCESS movq (%_ASM_AX),%rdx --=20 2.47.0