From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E639C3858D34; Wed, 17 Jun 2020 05:43:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E639C3858D34 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592372632; bh=b/b866df3NCRCxq46TBQwZm/7l/Ac/yX9vzYpdni00A=; h=From:To:Subject:Date:In-Reply-To:References:From; b=wvZ7cj81VaVHTycVWkamN9L9zJpWNY3sBRVbWohWADEwkTXYu8eilh1LD3rcYDbpZ 0gq1wTSilPoPYcK08HioKYp2PqAwouqKE4bQXJW4RHArg9O0ZrQSi8ZrpuIlEaIYY1 Azyam0HUW2exQ6nHUkxdFPrgNf9ryqI6cSdoWCRM= From: "markalle at us dot ibm.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug inline-asm/95692] PPC64, suspicious store in front of inline assembly section Date: Wed, 17 Jun 2020 05:43:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: inline-asm X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: markalle at us dot ibm.com X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jun 2020 05:43:53 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95692 --- Comment #2 from Mark Allen --- Hi, thanks for the input. I was figuring gcc should see the inline assembly modifying r2 and any function call out of intercept_munmap() would be doing the logical equivalent of saving the current r2, calling something where a different r2 might be used, then upon return restoring r2 to whatever it was when it left intercept_munmap(). But it sounds like you're saying gcc should be the exclusive manager of r2. And I get that the activity of making a function call isn't always going to be as linear as "save current r2, set r2 for whatever new context it's calling into, restore r2". I'm open to other solutions. For most alternatives I can think of, I can at least imagine potential gcc behavior that would conflict with us hacking r2, which I expect is why you're suggesting doing nothing but our own assembly from intercept_munmap() downward. That would be rough though, we'd definitely like to be able to call other functions from intercept_munmap(). The problem starts when we turn munmap into a branch into intercept_munmap. At that point r2 would have been set up as valid for munmap() but then we branched into intercept_munmap() which presumably needs its own r2. So far the best hack I can see is to put it all in the initial branch. Eg overwrite munmap not just with a branch to intercept_munmap, but replace r2 at that level (rather than at the start of intercept_munmap). That essentially puts both of the things that hack the state into the same location, after which the state is consistent for gcc to continue doing whatever it wants. I'm getting the impression this isn't going to receive a blessing as a "good" solution though. Any other ideas for a "least bad" solution if we want to be able to make function calls into other gcc-compiled functions from inside intercept_munmap()?=