From owner-svn-src-stable-12@freebsd.org Tue May 26 19:34:06 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 172622F255B; Tue, 26 May 2020 19:34:06 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49Wkfj6vwkz3Xp2; Tue, 26 May 2020 19:34:05 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E866A8AA3; Tue, 26 May 2020 19:34:05 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 04QJY5G7013261; Tue, 26 May 2020 19:34:05 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04QJY5Oh013260; Tue, 26 May 2020 19:34:05 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202005261934.04QJY5Oh013260@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 26 May 2020 19:34:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r361538 - in stable: 11/stand/common 12/stand/common X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/stand/common 12/stand/common X-SVN-Commit-Revision: 361538 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 May 2020 19:34:06 -0000 Author: kevans Date: Tue May 26 19:34:05 2020 New Revision: 361538 URL: https://svnweb.freebsd.org/changeset/base/361538 Log: loader: fix userboot's ability to detect a guest's interpreter Some time after r338418, I believe with -Os/-Oz -ffunction-sections -fdata-sections, the bootprog_interp variable that held our "$Interpreter:" marker started getting strip from all loaders, with exception to userboot since it used bootprog_interp to determine what flavor of userboot it was. At some point, it had been brought to my attention that this was no longer working and I had worked up some potential solutions to use the variable that involved printing it out. My vague recollection is that this was rejected, and I forgot to explore the alternatives; I cannot find records of this discussion anymore. Fast forward to present day, Andrew reported that it was non-functional and offered (effectively) this patch (sans comment) to stop the compiler from optimizing it out by assigning it to a volatile variable. This removes concerns about user-facing change while retaining the interpreter marker. Furthermore, it could certainly be uglier. Modified: stable/12/stand/common/interp.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/stand/common/interp.c Directory Properties: stable/11/ (props changed) Modified: stable/12/stand/common/interp.c ============================================================================== --- stable/12/stand/common/interp.c Tue May 26 19:22:46 2020 (r361537) +++ stable/12/stand/common/interp.c Tue May 26 19:34:05 2020 (r361538) @@ -45,8 +45,17 @@ __FBSDID("$FreeBSD$"); void interact(void) { - static char input[256]; /* big enough? */ + static char input[256]; /* big enough? */ + const char * volatile interp_identifier; + /* + * Because interp_identifier is volatile, it cannot be optimized out by + * the compiler as it's considered an externally observable event. This + * prevents the compiler from optimizing out our carefully placed + * $Interpreter:4th string that userboot may use to determine that + * we need to switch interpreters. + */ + interp_identifier = bootprog_interp; interp_init(); printf("\n");