From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.zytor.com (terminus.zytor.com [198.137.202.136]) (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 7C7D35394 for ; Fri, 18 Mar 2022 23:03:33 +0000 (UTC) Received: from [IPv6:::1] ([IPv6:2601:646:8600:40c1:8f0c:2533:51ff:d719]) (authenticated bits=0) by mail.zytor.com (8.17.1/8.15.2) with ESMTPSA id 22IN36PG1022936 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Fri, 18 Mar 2022 16:03:07 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 22IN36PG1022936 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2022030301; t=1647644587; bh=svb/lgQXEzjEPgFnj7j1DJy4Iq5vz9ytaGKdBRZvYko=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=bTlBuu+sxs0JshNvGQ3E+y9m/Xuz8dwiLyY+4q3DXXgPM+fnIbGU+MrR3G+OaRy/f bx0IiUAGeRjEQdVq/J5bCDkEudRK4+mlTQO15QkG+smtmr4QeUpncwoGZ5UPk8D6n0 ioY5oZG34neIzvJJgJ+3XC+z8wcnI2N3X9ze6yeUd5MZzM7zkkNS0oOqWKU9aGJ+9a 4gqt5VAmjtWwVfFf1Z+SrsJzYDuGPg8t82hbTOijcDGbdTXnMobW1CJvFz2r+pCAzL w0+tk1JlrNSvoxPleYrkG9U+tBYksKJu3vc/Po7R+SLx2Hs1jodCuoPsXgwlz7zDOz GjFceMUiJgd5g== Date: Fri, 18 Mar 2022 16:03:01 -0700 From: "H. Peter Anvin" To: David Laight , "'Linus Torvalds'" , Andy Lutomirski CC: Andrew Cooper , Nick Desaulniers , Bill Wendling , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Nathan Chancellor , Juergen Gross , Peter Zijlstra , "llvm@lists.linux.dev" , LKML , linux-toolchains Subject: RE: [PATCH v5] x86: use builtins to read eflags User-Agent: K-9 Mail for Android In-Reply-To: <5794cceec50a4f1ebca069d5a31afcdf@AcuMS.aculab.com> References: <20220210223134.233757-1-morbo@google.com> <20220301201903.4113977-1-morbo@google.com> <83b33afc-8502-0065-60bc-3a91528632d8@kernel.org> <5794cceec50a4f1ebca069d5a31afcdf@AcuMS.aculab.com> Message-ID: <8B69D1BF-8369-42EC-B0ED-DED038966FC9@zytor.com> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On March 18, 2022 3:43:13 PM PDT, David Laight wrote: >From: Linus Torvalds >> Sent: 18 March 2022 18:19 >>=20 >> On Fri, Mar 18, 2022 at 10:59 AM Andy Lutomirski wr= ote: >> > >> > I generally agree=2E In this particular case, though, I will keep us= ing >> > the builtin in tools/testing/selftests/x86/helpers=2Eh unless we actu= ally >> > hit breakage=2E This is because this is *user* code, it is compiled = with >> > the redzone enabled, and the asm code to do the right thing when the >> > redzone is enabled is too hairy for me to want to deal with it=2E >>=20 >> Yeah, redzoning is a problem for "pushf"=2E >>=20 >> Or rather, it's not the redzoning itself, but the fact that the >> compiler might use the word under the stack for random other things, >> and the pushf will then corrupt some local variable storage=2E >>=20 >> I think it would be lovely to solve that in inline asm itself some way >> - by marking the stack pointer clobbered or something=2E > >Something that generates: > mov %rax,-8(%rsp) > pushf > xchg %rax,0(%rsp) > add %rsp,8 >should work with or without a redzone=2E >Will be a bit slower :-( > > David > >- >Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1= 1PT, UK >Registration No: 1397386 (Wales) > *Much* slower (XCHG is implicitly locked, for hysterical raisins) and you = are using the redzone between the mov and the push, so it seems like you ju= st made things worse for no reason=2E