From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) (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 92339ECA for ; Tue, 19 Apr 2022 09:17:11 +0000 (UTC) Received: from zn.tnic (p200300ea971b58fe329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:971b:58fe:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id A9F2F1EC0426; Tue, 19 Apr 2022 11:17:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1650359823; h=from:from: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:in-reply-to:in-reply-to: references:references; bh=IpUcxK1+aTl3dEfdBYBEfx4dIywUQ3Ulo1xvFLO5pfQ=; b=m6EKFizfaEKMQ8/FoV/wzQyw+m/nH+T/i6ZYFMp/On5sVMohISCvYd1t7rKxwUrqs1KRHZ MuxuTVr35O0B+kdtlZxWn8Zf0/6WqE1RbLQis3tRq9id/Q0jHUBgNi33N56YfpjJJufgtq yfaK9g5cQyAj8X+50o3k1UeuK16auAo= Date: Tue, 19 Apr 2022 11:17:00 +0200 From: Borislav Petkov To: Linus Torvalds Cc: Mark Hemment , Andrew Morton , the arch/x86 maintainers , Peter Zijlstra , patrice.chotard@foss.st.com, Mikulas Patocka , Lukas Czerner , Christoph Hellwig , "Darrick J. Wong" , Chuck Lever , Hugh Dickins , patches@lists.linux.dev, Linux-MM , mm-commits@vger.kernel.org Subject: Re: [patch 02/14] tmpfs: fix regressions from wider use of ZERO_PAGE Message-ID: References: <29b9ef95-1226-73b4-b4d1-6e8d164fb17d@gmail.com> Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Mon, Apr 18, 2022 at 10:10:42AM -0700, Linus Torvalds wrote: > Ugh. If you do this, you need to have a big comment about how that > %rcx value gets fixed up with EX_TYPE_UCOPY_LEN (which basically ends > up doing "%rcx = %rcx*8+%rax" in ex_handler_ucopy_len() for the > exception case). Yap, and I reused your text and expanded it. You made me look at that crazy DEFINE_EXTABLE_TYPE_REG macro finally so that I know what it does in detail. So I have the below now, it boots in the guest so it must be perfect. --- /* * Default clear user-space. * Input: * rdi destination * rcx count * * Output: * rcx uncopied bytes or 0 if successful. */ SYM_FUNC_START(clear_user_original) mov %rcx,%rax shr $3,%rcx # qwords and $7,%rax # rest bytes test %rcx,%rcx jz 1f # do the qwords first .p2align 4 0: movq $0,(%rdi) lea 8(%rdi),%rdi dec %rcx jnz 0b 1: test %rax,%rax jz 3f # now do the rest bytes 2: movb $0,(%rdi) inc %rdi decl %eax jnz 2b 3: xorl %eax,%eax RET _ASM_EXTABLE_UA(0b, 3b) /* * The %rcx value gets fixed up with EX_TYPE_UCOPY_LEN (which basically ends * up doing "%rcx = %rcx*8 + %rax" in ex_handler_ucopy_len() for the exception * case). That is, we use %rax above at label 2: for simpler asm but the number * of uncleared bytes will land in %rcx, as expected by the caller. * * %rax at label 3: still needs to be cleared in the exception case because this * is called from inline asm and the compiler expects %rax to be zero when exiting * the inline asm, in case it might reuse it somewhere. */ _ASM_EXTABLE_TYPE_REG(2b, 3b, EX_TYPE_UCOPY_LEN8, %rax) SYM_FUNC_END(clear_user_original) EXPORT_SYMBOL(clear_user_original) -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette