This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH] x86: Apply standalone prefixes to the following instruction
- From: Jan Beulich <JBeulich at suse dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Fri, 19 Jul 2019 16:24:12 +0000
- Subject: Re: [PATCH] x86: Apply standalone prefixes to the following instruction
- Arc-authentication-results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=suse.com;dmarc=pass action=none header.from=suse.com;dkim=pass header.d=suse.com;arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=q5VfColzz/c/3xqLuiE0MzaXVy06VK17hGfVY6xdpSk=; b=R35Ff4jcUbHTeacIefY1IaKov5nHDZIg8hmpJ0JMlx+y2B1KAFoa7J/1o6l/bgwNNOOZa4zKyVtNoMc0vaK/BDfq33G8gCBxAHvfJfmdd5moNGsweUO+Q4kfk9eGN+CGd8UH01vhqz7RnQ5xGTrlShUpQM1A6PYbK09CKOAjtL6md5cRAM6ptUPxcZSlyCfr5p3OiFcjcL5v+1ek2shv2mkfO8RIB1HxLxPPmTNIenRggc621w6V7bJKj+BBieXFebRbCEFCZrvhbeTqiF2cnWBpeZy4SViKYuhnOzClC1jjwdxIBmIqbq7GWlY+kPoZTFO32Sf4FXueJ092jtfnxw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KB5HMgxjB4JJDXpeuJO0HJO6e1a6T2d7GblaTTCllqJ/ffuenSr5B8jp6VpJf7/Msxl1er3/x9UKxdqIpmlLbsLAByKapR8YD3Kko09Kzpyaw4QzidzBwoMVnp0FXsogsjNWaGncfqjtww3p/4QtMw40dc4euWLh50qY6pdj3G7O0i6aUG2Xno2CVbBU+e+2j+6KvRLzFlz7imNo/kdAE33NRr/bh2zuSopJSk1k38mRZh5LwD8eZw6K2gfPLC2BVsLcxa2SPtQlXriufOMqxKO4xJyhf/S2lcn/a7qJgFGWsh5xnLbJw6/qQGtWsR59FRv1GRRGhtma+R6beG/+0A==
- References: <CAMe9rOohqV49DVBVRr_kNTyT6ruNYJZgTCWkq4B-Bmh+VRAM=Q@mail.gmail.com> <email@example.com> <CAMe9rOrGn8yU_GbDdAxdD+-1uiPw+siKxf0xDZySLtQZ4_TgOA@mail.gmail.com>
On 19.07.2019 17:01, H.J. Lu wrote:
> On Fri, Jul 19, 2019 at 1:46 AM Jan Beulich <JBeulich@suse.com> wrote:
>> On 19.07.2019 00:26, H.J. Lu wrote:
>>> Standalone prefixes should be applied to the following instruction,
>>> instead of being treated as regular instructions. An error should be
>>> issued when a standalone prefix is at the end of source or isn't
>>> followed by an instruction in the same section.
>> Commenting here, because commenting on the actual code fragments is
>> not easily possible with the patch sent as attachment.
>> For one, I don't agree that errors should be issued when switching
>> sections. Clever assembly programming can easily result in the
>> actual section later getting resumed, and an appropriate insn being
> Yes, you will get an error which can be easily fixed.
For both this and ...
>> And then I'm getting the impression that the change here is going
>> to break things like
>> static inline unsigned int find_first_set_bit(unsigned long word)
>> asm ( "rep; bsf %1,%0" : "=r" (word) : "rm" (word) );
>> return (unsigned int)word;
> "rep; bsf" works like "rep bsf".
>> (quoted from Xen sources), being a backwards compatible
>> representation of tzcnt. Just like such have shown up in the past,
>> REP prefixes could easily obtain meaning for other insns going
>> forward, so tagging individual templates with RepPrefixOk is not
>> going to help. WBNOINVD is a pretty recent example.
> Since adding REP to random instructions may lead to different instructions,
> RepPrefixOk is used to prevent that. If one really wants different
> ".byte 0xf3" can be used.
... this you realize that breaking existing code is bad? It doesn't
matter how "easy" it is to fix such. Taking Xen (again) as the example,
older trees are supposed to not be touched anymore except for security
fixes. Now if people upgrade their underlying distros, builds of these
older trees will suddenly start to fail.
Furthermore, with your ".byte 0xf3" suggestion, what "protection" do
you achieve when disallowing "rep", but allowing ".byte 0xf3"? Plus
personally I consider the .byte variant quite a bit worse.
Finally, with a number of changes of mine (including the still pending
operand size default changes which I'm slowly making progress with)
you've been demanding that the Linux build not be broken. But just
like Xen, Linux too uses "rep; bsf".