From patchwork Sun Oct 21 16:55:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 987399 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="J9sswpsJ"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42dQmd1WGXz9sCQ for ; Mon, 22 Oct 2018 03:57:03 +1100 (AEDT) Received: from localhost ([::1]:59665 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEH2C-0002if-EX for incoming@patchwork.ozlabs.org; Sun, 21 Oct 2018 12:57:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35150) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEH1q-0002h7-1T for qemu-devel@nongnu.org; Sun, 21 Oct 2018 12:56:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEH1o-0004tE-7Z for qemu-devel@nongnu.org; Sun, 21 Oct 2018 12:56:37 -0400 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]:35997) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEH1n-0004sj-Oo for qemu-devel@nongnu.org; Sun, 21 Oct 2018 12:56:36 -0400 Received: by mail-lf1-x144.google.com with SMTP id l1-v6so8784638lfc.3 for ; Sun, 21 Oct 2018 09:56:35 -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=lD2rcuGkY11c1aaXBbh6MwojHE+mw/f+4FePYJ572Lo=; b=J9sswpsJSlApUY42embxBAFcPTDf7D/4JFk1pxpGd/024doMN2leClrlG85l3AMRFV yMVIBmr9evnnM+U9bkTMDbXQIHP1exuthcJ8bWy1JoVac8pJn/83B9G34pIAsHxMsgxI VwsK8yt12cJOKI/Pz8liqgdjFnYpIVnYyQNm4zy656OidFVY/qeb1qlkMi48RKF0YHVb gZzvj9tiRFDacroPRXQlq2WynHv74iQrhEaejgHTIuFlmx7YtzczcyPXEDdUyTiLUAkK dENTJWQJ/jj/ktoYkdnE4OYrfMUtW22plbEnvSHAiK0pPw1572t/tK3LuUh2awC0y618 WLIQ== 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=lD2rcuGkY11c1aaXBbh6MwojHE+mw/f+4FePYJ572Lo=; b=Er7UcYkmf8wDfcD9z47PlSUz2YJdwJbctkYHsGPKUao46JNS1HMvUtLFynLfHJ7pb9 9YBxDA7MSd4bNL4rD5nJ0suWjZj0/Xc+8QZplH6T92OfnPyrHr5Hmb86ItNrgk4MUN71 RrAFv+ycnREOZkAL/7MXM9p9o0EDLGBMM6j2b4CyZHREaZlAd4hxTQwbHp3SOVLFGhBF oZtpfLqji7i40qijcwprydBaRYbrld0/YNqws5f5QPCioRSEmuwKjgkvS0HCs/GV+GkG VILsqURtCR9/l7hp2YEcJfRog4wlB5TIVfMWFJJn3qPkbkW2nQaoZ4yjnkG2SS26aOka DD7g== X-Gm-Message-State: ABuFfohdtX5T1jBpwQtGSz58VBr3QaVo3Uvfw6cqfzVYq8j385zOaDCC kwYliEgaDeJM3aHn68Z5NGEObKpoRN4= X-Google-Smtp-Source: ACcGV62Tg5VBT78G3Qg70BQjGZNbSfle1UaMq01DpLYlX+mcWUjXx1SG0MvR/9IM4/Vnwu3S2buVhQ== X-Received: by 2002:a19:5a05:: with SMTP id o5mr7746295lfb.140.1540140994021; Sun, 21 Oct 2018 09:56:34 -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 s69-v6sm1683555lfs.92.2018.10.21.09.56.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:56:33 -0700 (PDT) From: Max Filippov To: qemu-devel@nongnu.org Date: Sun, 21 Oct 2018 09:55:42 -0700 Message-Id: <20181021165542.8692-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::144 Subject: [Qemu-devel] [PATCH v3] scripts/qemu-binfmt-conf.sh: add bFLT 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 , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- Changes v2->v3: - fix bFLT in the patch subject Changes v1->v2: - drop unintended changes to dtc; scripts/qemu-binfmt-conf.sh | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) 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 ;;