From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 35A2736E489 for ; Tue, 2 Jun 2026 08:47:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780390028; cv=none; b=X0/CZ9URVZqZtSttZIiKftW+95Ic074sLHN5Pz6XtOknUyPKaXfJdhWSxcgegB4fZkENRTUM0PsHZ9HmwkLuzUyhyvQ5vh1kONg/s6x/M+RNEmPPMU3HXLbjnBGYNVR0cCtDLIGO24F6y10O8xB34kd2bcWg7mU+0om8ihRv7jQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780390028; c=relaxed/simple; bh=XuOAOSYDASIkE8k1DcwiObr6/h55lx5h+RiNNYy8aAY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Np37UkuIOA/xV628oCnXJt4boIiVgLqKJRxn1SbYSTvpMN8tT1TS1tqjhaHtovgjFqFLUirMD3jhNP5DzEdaiDtPDMAgA+cZ20XMBN/B0zIUBM0sdAszuqwKBx5jyBTPJrAzeRYc0DzyqtpGpK+eiKRlDE75d5xpc3vl6zPJmko= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LuD2k+yR; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LuD2k+yR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 111B71F00893; Tue, 2 Jun 2026 08:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780390026; bh=KetQGnpihDD2vxXf7LRusXJw3y8BnoktxOIVo1JkiuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LuD2k+yRlJPZt8nXdTJbqG6KC2W+Dke3s/q3g84fgMAsgCHOlv/HHiDB548ujh1xr 3rVpsuk0GvyWAWOk1iOYj530GpfzudRL9onsjLw10+vrV9bwuUGx6tFgPETvwm16l6 J6LwCmDwQmP377adwJWaHunJr4CJ2NIEODTWTLhi0WyCZJQO4HZdUZs64Ecp0LUZIG X/RhL0fNJLePJuEj+zb46h38tCqD1bdbvgxyKalD3XIm+3nGDPrwGLSr24k4zxMR7z ooxRsfSyqGlhWUg22EusR7oTkymzzs/wjfkXcNziWdi54hYfg7zG/T8U6cHr1+yC5Z WnLksJM5+C+qA== From: "Christophe Leroy (CS GROUP)" To: Michael Ellerman , Nicholas Piggin , Madhavan Srinivasan Cc: "Christophe Leroy (CS GROUP)" , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v2 7/8] powerpc/uaccess: Add unsafe_clear_user() Date: Tue, 2 Jun 2026 10:46:36 +0200 Message-ID: <1a4f0e7ef4d1c6b794fb95cb88c4ce65c1fd5f6a.1780389863.git.chleroy@kernel.org> X-Mailer: git-send-email 2.54.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 X-Developer-Signature: v=1; a=openpgp-sha256; l=1532; i=chleroy@kernel.org; h=from:subject:message-id; bh=XuOAOSYDASIkE8k1DcwiObr6/h55lx5h+RiNNYy8aAY=; b=owGbwMvMwCV2d0KB2p7V54MZT6slMWTJzcgLSU9+9t018cOqeqtNJtpPW3UPbtAzu1qw7Vj9M +kX69pSO0pZGMS4GGTFFFmO/+feNaPrS2r+1F36MHNYmUCGMHBxCsBEYlwYGeac+/MiTS3z7rvz Zf2RareFL1vxLLJyOFLGL7khyNxpbQ0jQ//UIxXxF3vYIjd+ehxR9uDMry93Jt9okBH1Y1hw+2j VFQ4A X-Developer-Key: i=chleroy@kernel.org; a=openpgp; fpr=10FFE6F8B390DE17ACC2632368A92FEB01B8DD78 Content-Transfer-Encoding: 8bit Implement unsafe_clear_user() for powerpc. It's a copy/paste of unsafe_copy_to_user() with value 0 as source. It may be improved in a later patch by using 'dcbz' instruction to zeroize full cache lines at once. Signed-off-by: Christophe Leroy (CS GROUP) --- arch/powerpc/include/asm/uaccess.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h index e98c628e3899..ef6711d1278b 100644 --- a/arch/powerpc/include/asm/uaccess.h +++ b/arch/powerpc/include/asm/uaccess.h @@ -588,6 +588,26 @@ do { \ unsafe_put_user(*(u8*)(_src + _i), (u8 __user *)(_dst + _i), e); \ } while (0) +#define unsafe_clear_user(d, l, e) \ +do { \ + u8 __user *_dst = (u8 __user *)(d); \ + size_t _len = (l); \ + int _i; \ + \ + for (_i = 0; _i < (_len & ~(sizeof(u64) - 1)); _i += sizeof(u64)) \ + unsafe_put_user(0, (u64 __user *)(_dst + _i), e); \ + if (_len & 4) { \ + unsafe_put_user(0, (u32 __user *)(_dst + _i), e); \ + _i += 4; \ + } \ + if (_len & 2) { \ + unsafe_put_user(0, (u16 __user *)(_dst + _i), e); \ + _i += 2; \ + } \ + if (_len & 1) \ + unsafe_put_user(0, (u8 __user *)(_dst + _i), e); \ +} while (0) + #define arch_get_kernel_nofault(dst, src, type, err_label) \ __get_user_size_goto(*((type *)(dst)), \ (__force type __user *)(src), sizeof(type), err_label) -- 2.54.0