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 109FD3C8197 for ; Fri, 22 May 2026 09:56:56 +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=1779443817; cv=none; b=nmVnfNN78JlORsAKWYUks+hKBSW6kGbJyVZefYOcw95p3Yfur4cHZwSHkFj9W+MJtOwbdWaS8v+RVKfLx58Ma12qtphObuOU/S21TyMcABhxrPyc0JvPTY7NJMMM2rKo13n9a+JUcHMpb1mNO6QUcBbmmpC/NzDeSnD/2fjc3wo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779443817; c=relaxed/simple; bh=XuOAOSYDASIkE8k1DcwiObr6/h55lx5h+RiNNYy8aAY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NVE74bLAO0Mls5F0s8k0pbEM8fAV4HAesK2uCLfTTv+Qz4HuJJGHwpBTFIlQw99zQAeU++wFArZ7nhfBSxBgx+cyLNWn7/jjJ9cmMHGFgwZX3mKMUnuXRFfxWGEwuwBLPFU01/49wLNpsk7v83cmRii8gUG4QXmW68msLU17taU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FPWVhxS6; 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="FPWVhxS6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A0141F000E9; Fri, 22 May 2026 09:56:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779443815; bh=KetQGnpihDD2vxXf7LRusXJw3y8BnoktxOIVo1JkiuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FPWVhxS6abEj6Wk6gFOxmmr6UOrr890+s7heZe8/fOUS5UVOBRFX97dsWRpgb7YaK rnMYA0kQylA8upBWX0FZvF1tdr8ONj8sJ+ginfH1TRkAfkmnYc2X4wnlMLpcf07R1f 3DTfbM24AXKjQ6FoYLsxFPLlgzyyzgQ1Pt+wJv+CO1agEntrgLhgfHwDouGe/pwk6G /E5S7iUP/VXGkGAE1/4m72Yhps6wh+PYkLpHm6Y6FeLniPes3Zesk0K5OatPEX70Io iZkKfq6ylDva5sT2HLA2em2ubKAOcESOa6S/VeKXS8PhvqWTQF+4F4XGgrOJ1DZwfy uLzHNsBIsiruw== 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 v1 7/8] powerpc/uaccess: Add unsafe_clear_user() Date: Fri, 22 May 2026 11:56:07 +0200 Message-ID: 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=owGbwMvMwCV2d0KB2p7V54MZT6slMWQJaNjvkJjaz3Dv4lZeb6npj7TCjacndbLNDT2ltjlL2 8MsYGN7RykLgxgXg6yYIsvx/9y7ZnR9Sc2fuksfZg4rE8gQBi5OAZjIWmZGhjPiVwo4Nm99mie/ o+5Dz9dm27sMs17pzNPbkvIq+/mWviJGhoblz8xW5Zs5Ke1ZOD97ysaP1tob1d7/TulLC+ovrPt hyQ4A 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