From patchwork Wed Nov 24 11:12:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quirin Gylstorff X-Patchwork-Id: 12636645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E686C43217 for ; Wed, 24 Nov 2021 11:12:26 +0000 (UTC) Received: from thoth.sbs.de (thoth.sbs.de [192.35.17.2]) by mx.groups.io with SMTP id smtpd.web09.4852.1637752344782059102 for ; Wed, 24 Nov 2021 03:12:25 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: siemens.com, ip: 192.35.17.2, mailfrom: quirin.gylstorff@siemens.com) Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id 1AOBCMB0009586 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 24 Nov 2021 12:12:22 +0100 Received: from md2dvrtc.fritz.box ([139.22.38.174]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 1AOBCLdw009575; Wed, 24 Nov 2021 12:12:21 +0100 From: "Q. Gylstorff" To: jan.kiszka@siemens.com, cip-dev@lists.cip-project.org Subject: [cip-dev][isar-cip-core][PATCH 1/3] start-qemu.sh: set bootindex for SECURE_BOOT Date: Wed, 24 Nov 2021 12:12:19 +0100 Message-Id: <20211124111221.300917-2-Quirin.Gylstorff@siemens.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211124111221.300917-1-Quirin.Gylstorff@siemens.com> References: <20211124111221.300917-1-Quirin.Gylstorff@siemens.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 24 Nov 2021 11:12:26 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/6989 From: Quirin Gylstorff Set the bootindex to avoid booting into the default uefi shell. An if-clause is used to avoid the following error message for non-secure-boot images: ``` qemu-system-x86_64: -device ide-hd,drive=disk,bootindex=0: The bootindex 0 has already been used ``` Signed-off-by: Quirin Gylstorff --- start-qemu.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/start-qemu.sh b/start-qemu.sh index 3f62257..2c0a751 100755 --- a/start-qemu.sh +++ b/start-qemu.sh @@ -39,8 +39,14 @@ case "$1" in -cpu qemu64 \ -smp 4 \ -machine q35,accel=kvm:tcg \ - -device ide-hd,drive=disk \ -device virtio-net-pci,netdev=net" + if [ -n "${SECURE_BOOT}" ]; then + QEMU_EXTRA_ARGS=" \ + ${QEMU_EXTRA_ARGS} -device ide-hd,drive=disk,bootindex=0" + else + QEMU_EXTRA_ARGS=" \ + ${QEMU_EXTRA_ARGS} -device ide-hd,drive=disk" + fi KERNEL_CMDLINE=" \ root=/dev/sda" ;; From patchwork Wed Nov 24 11:12:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quirin Gylstorff X-Patchwork-Id: 12636647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63567C4332F for ; Wed, 24 Nov 2021 11:12:26 +0000 (UTC) Received: from lizzard.sbs.de (lizzard.sbs.de [194.138.37.39]) by mx.groups.io with SMTP id smtpd.web11.4896.1637752344824730410 for ; Wed, 24 Nov 2021 03:12:25 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: siemens.com, ip: 194.138.37.39, mailfrom: quirin.gylstorff@siemens.com) Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by lizzard.sbs.de (8.15.2/8.15.2) with ESMTPS id 1AOBCM5S023533 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 24 Nov 2021 12:12:22 +0100 Received: from md2dvrtc.fritz.box ([139.22.38.174]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 1AOBCLdx009575; Wed, 24 Nov 2021 12:12:22 +0100 From: "Q. Gylstorff" To: jan.kiszka@siemens.com, cip-dev@lists.cip-project.org Subject: [cip-dev][isar-cip-core][PATCH 2/3] start-qemu.sh: parse .config.yaml for ease of use Date: Wed, 24 Nov 2021 12:12:20 +0100 Message-Id: <20211124111221.300917-3-Quirin.Gylstorff@siemens.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211124111221.300917-1-Quirin.Gylstorff@siemens.com> References: <20211124111221.300917-1-Quirin.Gylstorff@siemens.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 24 Nov 2021 11:12:26 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/6990 From: Quirin Gylstorff Suggested-by: Jan Kiszka Signed-off-by: Quirin Gylstorff --- start-qemu.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/start-qemu.sh b/start-qemu.sh index 2c0a751..21b303a 100755 --- a/start-qemu.sh +++ b/start-qemu.sh @@ -20,13 +20,24 @@ usage() exit 1 } +if grep -s -q "IMAGE_SECURE_BOOT: true" .config.yaml; then + SECURE_BOOT="true" +fi + if [ -n "${QEMU_PATH}" ]; then QEMU_PATH="${QEMU_PATH}/" fi if [ -z "${DISTRO_RELEASE}" ]; then - DISTRO_RELEASE="buster" + if grep -s -q "DEBIAN_BULLSEYE: true" .config.yaml; then + DISTRO_RELEASE="bullseye" + elif grep -s -q "DEBIAN_STRETCH: true" .config.yaml; then + DISTRO_RELEASE="stretch" + else + DISTRO_RELEASE="buster" + fi fi + if [ -z "${TARGET_IMAGE}" ];then TARGET_IMAGE="cip-core-image" fi From patchwork Wed Nov 24 11:12:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quirin Gylstorff X-Patchwork-Id: 12636643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0D98C433FE for ; Wed, 24 Nov 2021 11:12:25 +0000 (UTC) Received: from goliath.siemens.de (goliath.siemens.de [192.35.17.28]) by mx.groups.io with SMTP id smtpd.web11.4895.1637752344472975077 for ; Wed, 24 Nov 2021 03:12:25 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: siemens.com, ip: 192.35.17.28, mailfrom: quirin.gylstorff@siemens.com) Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id 1AOBCMZd007266 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 24 Nov 2021 12:12:22 +0100 Received: from md2dvrtc.fritz.box ([139.22.38.174]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 1AOBCLe0009575; Wed, 24 Nov 2021 12:12:22 +0100 From: "Q. Gylstorff" To: jan.kiszka@siemens.com, cip-dev@lists.cip-project.org Subject: [cip-dev][isar-cip-core][PATCH 3/3] start-qemu.sh: Simplify qemu call Date: Wed, 24 Nov 2021 12:12:21 +0100 Message-Id: <20211124111221.300917-4-Quirin.Gylstorff@siemens.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211124111221.300917-1-Quirin.Gylstorff@siemens.com> References: <20211124111221.300917-1-Quirin.Gylstorff@siemens.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 24 Nov 2021 11:12:25 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/6988 From: Quirin Gylstorff Move qemu call out of if clause to avoid code duplications and use the same behavior for secure boot and non secure boot images. Signed-off-by: Quirin Gylstorff --- start-qemu.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/start-qemu.sh b/start-qemu.sh index 21b303a..4817790 100755 --- a/start-qemu.sh +++ b/start-qemu.sh @@ -120,18 +120,16 @@ if [ -n "${SECURE_BOOT}" ]; then BOOT_FILES="-drive if=pflash,format=raw,unit=0,readonly=on,file=${ovmf_code} \ -drive if=pflash,format=raw,file=${ovmf_vars} \ -drive file=${IMAGE_PREFIX}.wic.img,discard=unmap,if=none,id=disk,format=raw" - ${QEMU_PATH}${QEMU} \ - -m 1G -serial mon:stdio -netdev user,id=net \ - ${BOOT_FILES} ${QEMU_EXTRA_ARGS} "$@" else IMAGE_FILE=$(ls ${IMAGE_PREFIX}.ext4.img) KERNEL_FILE=$(ls ${IMAGE_PREFIX}-vmlinu* | tail -1) INITRD_FILE=$(ls ${IMAGE_PREFIX}-initrd.img* | tail -1) - ${QEMU_PATH}${QEMU} \ - -m 1G -serial mon:stdio -netdev user,id=net \ - -drive file=${IMAGE_FILE},discard=unmap,if=none,id=disk,format=raw \ + BOOT_FILES="-drive file=${IMAGE_FILE},discard=unmap,if=none,id=disk,format=raw \ -kernel ${KERNEL_FILE} -append "${KERNEL_CMDLINE}" \ - -initrd ${INITRD_FILE} ${QEMU_EXTRA_ARGS} "$@" + -initrd ${INITRD_FILE}" fi +${QEMU_PATH}${QEMU} \ + -m 1G -serial mon:stdio -netdev user,id=net \ + ${BOOT_FILES} ${QEMU_EXTRA_ARGS} "$@"