From patchwork Wed Oct 2 09:59:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mathieu Othacehe X-Patchwork-Id: 15575 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 029BD1749F; Wed, 2 Oct 2019 11:02:32 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id A3C8E1749D for ; Wed, 2 Oct 2019 11:02:31 +0100 (BST) Received: from localhost ([::1]:53186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iFbSo-0005gd-8V for patchwork@mira.cbaines.net; Wed, 02 Oct 2019 06:02:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51245) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iFbQi-0003vb-Hy for guix-patches@gnu.org; Wed, 02 Oct 2019 06:00:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iFbQg-0000Hq-M7 for guix-patches@gnu.org; Wed, 02 Oct 2019 06:00:20 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:54931) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iFbQg-0000Hg-I8 for guix-patches@gnu.org; Wed, 02 Oct 2019 06:00:18 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iFbQg-0000bR-FH for guix-patches@gnu.org; Wed, 02 Oct 2019 06:00:18 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#36477] [PATCH v4 21/23] system: vm: Add arm64 support. Resent-From: Mathieu Othacehe Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 02 Oct 2019 10:00:18 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36477 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 36477@debbugs.gnu.org Cc: Mathieu Othacehe Received: via spool by 36477-submit@debbugs.gnu.org id=B36477.15700104052087 (code B ref 36477); Wed, 02 Oct 2019 10:00:18 +0000 Received: (at 36477) by debbugs.gnu.org; 2 Oct 2019 10:00:05 +0000 Received: from localhost ([127.0.0.1]:35494 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iFbQP-0000Wk-O0 for submit@debbugs.gnu.org; Wed, 02 Oct 2019 06:00:02 -0400 Received: from mail-wr1-f44.google.com ([209.85.221.44]:38495) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iFbQG-0000Uw-Ni for 36477@debbugs.gnu.org; Wed, 02 Oct 2019 05:59:53 -0400 Received: by mail-wr1-f44.google.com with SMTP id w12so18904367wro.5 for <36477@debbugs.gnu.org>; Wed, 02 Oct 2019 02:59:52 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=afuyksv9Cdb3+PcqCSw94KVmoYGR3A+lQiujjfQeOWc=; b=hlXxSgqBWXLnedLIX2PilbF41PwGH/WoropHlJg/iJJs5nqqzfH8kadQbgivXSgYIg 0O83bMI1OCcanRlERglXBs9LiO2wvBZ44b39JObuWmQCt2x1y9FvsSvqsJ5qtn4yauvR uwFmmrdd7gYy922vQnORICyUaPJ99W37Cmf0/BqCY73FkeFxDQjSMCrw1LMRE7RRuUBG BLrng3cxD44I2gSM+LPgkDUAlheWt0ee63a7H5NjJYPwcO1lJSKr3mWWVUs1u2yOm2Jm h+V4EUdGYJoloHoDtEWJgP0bRN1MCiuykknh8zWRTY0Tm2t4nKjr/yA1HODuwQ32VuIe WX5w== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=afuyksv9Cdb3+PcqCSw94KVmoYGR3A+lQiujjfQeOWc=; b=GRwgUS0GH1LEObn3WyXXchzGiu74657CdvktuHsr5Su4Ypxy6j/oPMVZBts2KjCbnt nA+Bi6yWspZsbaNEwpFTUiKiZcIFeu+oMhzVjHgIEKvdWvH8PHecl58p7vmNtAqv6WfB 3Ar8vKwsn1p6GxNc47/+sT9CEKMUm8bJnYKR7g/jDeOWyUDUiYVQl2vA9vCgnrzQVPd4 k1baejpgv4WDXPG8T14CzZI+YMxeSyJeWPKbV+ZoaGIjlYwAjzo+X63S+Kni14M9grOu f3jTYuTDNWNmZliBwAAst7gkAT3xwluIViTOJsDwnTxjBPSCp8W55RlujyVoiY9Lblok kCNw== X-Gm-Message-State: APjAAAXVQMmo+G+S31x+gPhSIEKGWZSV7lm++dEFuFRXHc4vuk1xtJBZ 2p3b+PTAnFENr9d/kvutihpr+pH1 X-Google-Smtp-Source: APXvYqwROISJTi4/lHeyjekLKtHSQN1FgV6TV/RGE1hhU/faFvlKLrQCTk71PbkAHwEKqanwSDWDPQ== X-Received: by 2002:adf:dc43:: with SMTP id m3mr1967958wrj.118.1570010386706; Wed, 02 Oct 2019 02:59:46 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:fa:a50:21e:67ff:fe5b:4283]) by smtp.gmail.com with ESMTPSA id w12sm29621318wrg.47.2019.10.02.02.59.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Oct 2019 02:59:45 -0700 (PDT) From: Mathieu Othacehe Date: Wed, 2 Oct 2019 11:59:02 +0200 Message-Id: <20191002095904.6325-22-m.othacehe@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191002095904.6325-1-m.othacehe@gmail.com> References: <20191002095904.6325-1-m.othacehe@gmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/build/vm.scm (load-in-linux-vm): Add target-arm64? argument and use it to pass correct arguments to qemu. * gnu/system/vm.scm (expression->derivation-in-linux-vm): Pass the new target-arm64? argument added above. Do not add ESP partition on all ARM targets. Do not pass grub-efi package to initialize-hard-disk on ARM targets. --- gnu/build/vm.scm | 19 +++++++++++++------ gnu/system/vm.scm | 15 +++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index b85398ed24..6f920aec9e 100644 --- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -82,6 +82,7 @@ make-disk-image? single-file-output? target-arm32? + target-aarch64? (disk-image-size (* 100 (expt 2 20))) (disk-image-format "qcow2") (references-graphs '())) @@ -97,10 +98,14 @@ access it via /dev/hda. REFERENCES-GRAPHS can specify a list of reference-graph files as produced by the #:references-graphs parameter of 'derivation'." + (define target-arm? (or target-arm32? target-aarch64?)) + (define arch-specific-flags `(;; On ARM, a machine has to be specified. Use "virt" machine to avoid ;; hardware limits imposed by other machines. - ,@(if target-arm32? '("-M" "virt") '()) + ,@(if target-arm? + '("-M" "virt") + '()) ;; On ARM32, if the kernel is built without LPAE support, ECAM conflicts ;; with VIRT_PCIE_MMIO causing PCI devices not to show up. Disable @@ -112,9 +117,9 @@ the #:references-graphs parameter of 'derivation'." ;; Only enable kvm if we see /dev/kvm exists. This allows users without ;; hardware virtualization to still use these commands. KVM support is - ;; still buggy on some ARM32 boards. Do not use it even if available. + ;; still buggy on some ARM boards. Do not use it even if available. ,@(if (and (file-exists? "/dev/kvm") - (not target-arm32?)) + (not target-arm?)) '("-enable-kvm") '()) @@ -125,11 +130,11 @@ the #:references-graphs parameter of 'derivation'." ;; The serial port name differs between emulated ;; architectures/machines. " console=" - (if target-arm32? "ttyAMA0" "ttyS0")) + (if target-arm? "ttyAMA0" "ttyS0")) ;; NIC is not supported on ARM "virt" machine, so use a user mode ;; network stack instead. - ,@(if target-arm32? + ,@(if target-arm? '("-device" "virtio-net-pci,netdev=mynet" "-netdev" "user,id=mynet") '("-net" "nic,model=virtio")))) @@ -153,7 +158,9 @@ the #:references-graphs parameter of 'derivation'." (_ #f)) (apply invoke qemu "-nographic" "-no-reboot" - "-smp" (number->string (parallel-job-count)) + ;; CPU "max" behaves as "host" when KVM is enabled, and like a system + ;; CPU with the maximum possible feature set otherwise. + "-cpu" "max" "-m" (number->string memory-size) "-object" "rng-random,filename=/dev/urandom,id=guixsd-vm-rng" "-device" "virtio-rng-pci,rng=guixsd-vm-rng" diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index ac6e4ded92..de20030848 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -235,10 +235,12 @@ made available under the /xchg CIFS share." #:memory-size #$memory-size #:make-disk-image? #$make-disk-image? #:single-file-output? #$single-file-output? - ;; FIXME: ‘target-arm32?’ may not operate on - ;; the right system/target values. Rewrite + ;; FIXME: ‘target-arm32?’ and + ;; ‘target-aarch64?’ may not operate on the + ;; right system/target values. Rewrite ;; using ‘let-system’ when available. #:target-arm32? #$(target-arm32?) + #:target-aarch64? #$(target-aarch64?) #:disk-image-format #$disk-image-format #:disk-image-size size #:references-graphs graphs)))))) @@ -452,10 +454,10 @@ system." ;; bootloaders if we are not targeting ARM because UEFI ;; support in U-Boot is experimental. ;; - ;; FIXME: ‘target-arm32?’ may be not operate on the right + ;; FIXME: ‘target-arm?’ may be not operate on the right ;; system/target values. Rewrite using ‘let-system’ when ;; available. - (if #$(target-arm32?) + (if #$(target-arm?) '() (list (partition ;; The standalone grub image is about 10MiB, but @@ -466,10 +468,11 @@ system." ;; when mounting. The actual FAT-ness is based ;; on file system size (16 in this case). (file-system "vfat") - (flags '(esp)))))))) + (flags '(esp))))))) + (grub-efi #$(and (not (target-arm?)) grub-efi))) (initialize-hard-disk "/dev/vda" #:partitions partitions - #:grub-efi #$grub-efi + #:grub-efi grub-efi #:bootloader-package #$(bootloader-package bootloader) #:bootcfg #$bootcfg-drv