From patchwork Sun Oct 21 02:45:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10650707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B4BD91508 for ; Sun, 21 Oct 2018 02:48:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9443E2853C for ; Sun, 21 Oct 2018 02:48:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8631D285EC; Sun, 21 Oct 2018 02:48:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,FROM_LOCAL_NOVOWEL,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 470E72853C for ; Sun, 21 Oct 2018 02:48:55 +0000 (UTC) Received: from localhost ([::1]:57239 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gE3nS-00084V-6X for patchwork-qemu-devel@patchwork.kernel.org; Sat, 20 Oct 2018 22:48:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59392) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gE3mB-0006UF-RA for qemu-devel@nongnu.org; Sat, 20 Oct 2018 22:47:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gE3kZ-00033u-4c for qemu-devel@nongnu.org; Sat, 20 Oct 2018 22:45:55 -0400 Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]:41456) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gE3kY-00033g-SX for qemu-devel@nongnu.org; Sat, 20 Oct 2018 22:45:55 -0400 Received: by mail-lf1-x143.google.com with SMTP id q39-v6so27840769lfi.8 for ; Sat, 20 Oct 2018 19:45:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=NYA/23YlGbYUhPSxptFBkgJ6DSccdgqsWlT7fVItgak=; b=XtZQwNIaImXI5fZ3UdbnqlfrCMauBBQKTLD2ahQPl89JpJsRMb8QpMRzbwPCW4V6Qw iV8P0v1651rTdBs8xE2oa36a/WI45StH40DFvCjvgh15GI9Vzyj4/PQBB9cjs+uPCgHR w9DHuqsVr7TCLvV4haojZn3SsRfG9lJxATGIfIMGlflLxD5UZW5OlBvcYqtsOPxf/z8T ygTw4MzmwAwq7m+s9VjMMHtG7XLlszXKtByf1SXHwW/y17QfJ+oh2HFKJCL/yHrqKmWn WVZE6JnB0S4KCDY+9rolgS/fLB1G4semYP1q2M0PRqBrpL1SPxamVC46zfyzf/NEcV6i EtWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=NYA/23YlGbYUhPSxptFBkgJ6DSccdgqsWlT7fVItgak=; b=AEf8lr4yx417HWDbHGEgbq14DFq0otWXmAoJJVnwQswRSdPdGKd0TXZ6g8Cljthju2 F3emLSJV+ilbHtvcNpDh6ii5W6VKTjzBs3Vt7D/mvVBbfCOo9vz0E4hL0Q5CIA5tRMrp UunM3aIxcNZw2mCItZ55XOz22Zm2BBPIe92PfXKJ6sEjU1DARetdYy/lEeiTLhv5XX+N jsUQQIJHapU6jtcmA1pz1OZhNRGnokE5DLZbFiiT9bTylyP4mupTTlDqY0fSK4gc6Fs+ f8b5zn8PfREqpTYkStF9Y2/pY7JXASZN/5RXx7eCJq8SqcFMvvvgcC+MwAcmbitIQ1Gu BfVw== X-Gm-Message-State: ABuFfojGuUxP5+WTubCS2ZkMSNlb5UUXPqaRpoQmeaAVmkGY3iMCRiRe hgaZR9o5GcSKS0dByaIUdq3sJfID X-Google-Smtp-Source: ACcGV61TpBzLy5oM4UuMQM02bwNjOzoLLCgL2iFrJx8gi45T3Yiv9mqcoupok0cgh31BUbf2e+5wBQ== X-Received: by 2002:a19:111b:: with SMTP id g27mr6682902lfi.135.1540089952917; Sat, 20 Oct 2018 19:45:52 -0700 (PDT) Received: from octofox.hsd1.ca.comcast.net. (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id l67-v6sm5950823lfg.45.2018.10.20.19.45.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 20 Oct 2018 19:45:51 -0700 (PDT) From: Max Filippov To: qemu-devel@nongnu.org Date: Sat, 20 Oct 2018 19:45:36 -0700 Message-Id: <20181021024536.9748-1-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::143 Subject: [Qemu-devel] [PATCH] scripts/qemu-binfmt-conf.sh: add bFL handler registration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Filippov , Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP bFLT format header doesn't have enough information to register a handler for a specific architecture. Add switch -f / --flat that registers one of the qemu binaries as a handler for bFLT executable images. Signed-off-by: Max Filippov --- dtc | 2 +- scripts/qemu-binfmt-conf.sh | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/dtc b/dtc index 88f18909db73..e54388015af1 160000 --- a/dtc +++ b/dtc @@ -1 +1 @@ -Subproject commit 88f18909db731a627456f26d779445f84e449536 +Subproject commit e54388015af1fb4bf04d0bca99caba1074d9cc42 diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index b5a16742a149..39f61065c698 100755 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -132,6 +132,9 @@ or1k_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\ or1k_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' or1k_family=or1k +flat_magic='bFLT\x00\x00\x00\x04' +flat_mask='\xff\xff\xff\xff\xff\xff\xff\xff' + qemu_get_family() { cpu=${HOST_ARCH:-$(uname -m)} case "$cpu" in @@ -170,6 +173,7 @@ usage() { Usage: qemu-binfmt-conf.sh [--qemu-path PATH][--debian][--systemd CPU] [--help][--credential yes|no][--exportdir PATH] [--persistent yes|no][--qemu-suffix SUFFIX] + [--flat CPU] Configure binfmt_misc to use qemu interpreter @@ -188,7 +192,9 @@ Usage: qemu-binfmt-conf.sh [--qemu-path PATH][--debian][--systemd CPU] calculated according to the binary to interpret --persistent: if yes, the interpreter is loaded when binfmt is configured and remains in memory. All future uses - are cloned from the open file. + are cloned from the open file + --flat: register QEMU for this CPU architecture as a handler + for the bFLT executable format. To import templates with update-binfmts, use : @@ -311,6 +317,13 @@ qemu_set_binfmts() { $BINFMT_SET fi done + if [ -n "$QEMU_FLAT" ] ; then + cpu="${QEMU_FLAT}_bflt" + qemu="$QEMU_PATH/qemu-$QEMU_FLAT" + magic=$flat_magic + mask=$flat_mask + $BINFMT_SET + fi } CHECK=qemu_check_bintfmt_misc @@ -324,7 +337,7 @@ CREDENTIAL=no PERSISTENT=no QEMU_SUFFIX="" -options=$(getopt -o ds:Q:S:e:hc:p: -l debian,systemd:,qemu-path:,qemu-suffix:,exportdir:,help,credential:,persistent: -- "$@") +options=$(getopt -o ds:Q:S:e:hc:p:f: -l debian,systemd:,qemu-path:,qemu-suffix:,exportdir:,help,credential:,persistent:,flat: -- "$@") eval set -- "$options" while true ; do @@ -380,6 +393,21 @@ while true ; do shift PERSISTENT="$1" ;; + -f|--flat) + shift + QEMU_FLAT="$1" + for cpu in ${qemu_target_list} ; do + if [ "$cpu" = "$1" ] ; then + break + fi + done + + if [ "$cpu" != "$1" ] ; then + echo "ERROR: unknown CPU \"$1\"" 1>&2 + usage + exit 1 + fi + ;; *) break ;;