Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump QEMU #150

Merged
merged 8 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/sel4-kernel-loader/src/plat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sel4_cfg_if! {
} else if #[sel4_cfg(all(any(ARCH_AARCH64, ARCH_AARCH32), PLAT_BCM2711))] {
#[path = "bcm2711/mod.rs"]
mod imp;
} else if #[sel4_cfg(all(any(ARCH_RISCV64, ARCH_RISCV32), any(PLAT_SPIKE, PLAT_QEMU_RISCV_VIRT)))] {
} else if #[sel4_cfg(all(any(ARCH_RISCV64, ARCH_RISCV32), any(PLAT_SPIKE, PLAT_QEMU_RISCV_VIRT, PLAT_HIFIVE)))] {
#[path = "riscv_generic/mod.rs"]
mod imp;
}
Expand Down
42 changes: 2 additions & 40 deletions hacking/nix/scope/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -261,45 +261,7 @@ superCallPackage ../rust-utils {} self //

opensbi = callPackage ./opensbi.nix {};

qemuForSeL4 = (qemu.override {
hostCpuTargets = [
"arm-softmmu"
"aarch64-softmmu"
"riscv32-softmmu"
"riscv64-softmmu"
"i386-softmmu"
"x86_64-softmmu"
];
guestAgentSupport = false;
numaSupport = false;
seccompSupport = false;
alsaSupport = false;
pulseSupport = false;
sdlSupport = false;
jackSupport = false;
gtkSupport = false;
vncSupport = false;
smartcardSupport = false;
spiceSupport = false;
ncursesSupport = false;
usbredirSupport = false;
libiscsiSupport = false;
tpmSupport = false;
uringSupport = false;
}).overrideDerivation (attrs: {
# patches from https://github.com/coliasgroup/qemu
patches = attrs.patches ++ [
# nspin/arm-virt-sp804
(fetchurl {
url = "https://github.com/coliasgroup/qemu/commit/79310d4cd22230a0dfca55697729670fe7e952fa.patch";
sha256 = "sha256-6CMhLFo7B6tGrOfvIqfT+ZtJz7A7WBfHazeAYECDWbE=";
})
# nspin/opensbi-fw-payload-use-elf-entry-point
(fetchurl {
url = "https://github.com/coliasgroup/qemu/commit/4b0e8e5be4cdcdd9aeb387f949bbc8a1dbfe9299.patch";
sha256 = "sha256-CoEnu5Ijy+khO7Jqq8NaKzJ1E4lLdaKDFF1ZC/I1C6k=";
})
];
});
qemuForSeL4 = callPackage ./qemu {};
qemuForSeL4Xilinx = callPackage ./qemu/xilinx.nix {};

})
2 changes: 2 additions & 0 deletions hacking/nix/scope/opensbi.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ stdenv.mkDerivation rec {
hash = "sha256-JNkPvmKYd5xbGB2lsZKWrpI6rBIckWbkLYu98bw7+QY=";
};

hardeningDisable = [ "all" ];

postPatch = ''
patchShebangs ./scripts
'';
Expand Down
5 changes: 5 additions & 0 deletions hacking/nix/scope/plat-utils/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@
{
qemu = callPackage ./qemu {};
rpi4 = callPackage ./rpi4 {};

composeInstanceForPlatformAttrs = a: b: {
attrs = a.attrs // b.attrs;
links = a.links ++ b.links;
};
}
21 changes: 19 additions & 2 deletions hacking/nix/scope/plat-utils/rpi4/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
#

{ lib, hostPlatform, callPackage
, pkgsBuildBuild
, runCommand, writeText
, fetchFromGitHub
, ubootTools

, fetchzip
, stdenvNoCC, mtools, utillinux

, platUtils
}:

let
Expand Down Expand Up @@ -96,7 +99,21 @@ let
image = loader;
};
bootCopied = mkBootCopied boot;
in rec {
qemu = platUtils.qemu.mkMkInstanceForPlatform {
mkQemuCmd = loader: [
"${pkgsBuildBuild.this.qemuForSeL4}/bin/qemu-system-${if hostPlatform.is32bit then "arm" else "aarch64"}"
"-smp" "4"
"-m" "size=2048"
"-machine" "raspi4b"
"-nographic"
"-serial" "null"
"-serial" "mon:stdio"
"-kernel" loader
];
} {
inherit loader rootTask;
};
in platUtils.composeInstanceForPlatformAttrs qemu (rec {
attrs = {
inherit boot bootCopied;
};
Expand All @@ -105,7 +122,7 @@ let
path = boot;
}
];
};
});

in {
inherit
Expand Down
105 changes: 105 additions & 0 deletions hacking/nix/scope/qemu/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#
# Copyright 2024, Colias Group, LLC
#
# SPDX-License-Identifier: BSD-2-Clause
#

{ lib, stdenv
, buildPackages
, fetchurl, fetchpatch, fetchFromGitHub, fetchFromGitLab
, python3Packages
, pkg-config, ninja, meson, perl
, zlib, lzo, glib
, bison, flex, dtc
, pixman, vde2
, texinfo
, snappy, libaio, libtasn1, gnutls, nettle, curl
, attr, libcap, libcap_ng, libslirp

, hostCpuTargets ? [
"arm-softmmu"
"aarch64-softmmu"
"riscv32-softmmu"
"riscv64-softmmu"
"i386-softmmu"
"x86_64-softmmu"
]
}:

stdenv.mkDerivation (finalAttrs: with finalAttrs; {
pname = "qemu";
version = "9.0.0";

src = fetchurl {
url = "https://download.qemu.org/qemu-${version}.tar.xz";
hash = "sha256-MnCKxmww2MiSYz6paMdxwcdtWX1w3erSGg0izPOG2mk=";
};

depsBuildBuild = [
buildPackages.stdenv.cc
];

nativeBuildInputs = [
pkg-config meson ninja
bison flex dtc
perl

# Don't change this to python3 and python3.pkgs.*, breaks cross-compilation
python3Packages.python
python3Packages.sphinx
python3Packages.sphinx-rtd-theme
];

buildInputs = [
dtc zlib lzo glib pixman vde2 texinfo
snappy libtasn1 gnutls nettle curl libslirp
libaio libcap_ng libcap attr
];

dontUseMesonConfigure = true; # meson's configurePhase isn't compatible with qemu build

patches = [
# nspin/arm-virt-sp804
(fetchurl {
url = "https://github.com/coliasgroup/qemu/commit/7994b0d17da7dbf1cf2da3e6555914e23559b23e.patch";
sha256 = "sha256-o5Z1LYF6pwqBGrP4AYOIXmhSg75w7mIRuxvj2ZCO+HY=";
})
# nspin/opensbi-fw-payload-use-elf-entry-point
(fetchurl {
url = "https://github.com/coliasgroup/qemu/commit/db69d0a7dc0af9d8130328347fdd81ab5fa9e352.patch";
sha256 = "sha256-12uGZRO6T1uWYvblAx5/FdRsuZZ1B1iWT9ZxpN3Qga0=";
})
];

postPatch = ''
# Otherwise tries to ensure /var/run exists.
sed -i "/install_emptydir(get_option('localstatedir') \/ 'run')/d" \
qga/meson.build
'';

preConfigure = ''
unset CPP # intereferes with dependency calculation
# this script isn't marked as executable b/c it's indirectly used by meson. Needed to patch its shebang
chmod +x ./scripts/shaderinclude.py
patchShebangs .
# avoid conflicts with libc++ include for <version>
mv VERSION QEMU_VERSION
substituteInPlace configure \
--replace '$source_path/VERSION' '$source_path/QEMU_VERSION'
substituteInPlace meson.build \
--replace "'VERSION'" "'QEMU_VERSION'"
'';

configureFlags = [
"--localstatedir=/var"
"--sysconfdir=/etc"
"--enable-linux-aio"
"--enable-slirp"
"--cross-prefix=${stdenv.cc.targetPrefix}"
"--target-list=${lib.concatStringsSep "," hostCpuTargets}"
];

preBuild = ''
cd build
'';
})
89 changes: 89 additions & 0 deletions hacking/nix/scope/qemu/xilinx.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#
# Copyright 2024, Colias Group, LLC
#
# SPDX-License-Identifier: BSD-2-Clause
#

{ lib, stdenv
, fetchFromGitHub, fetchFromGitLab
, python3, dtc
, qemuForSeL4
}:

let
version = "xilinx_v2024.1";

src = fetchFromGitHub {
owner = "Xilinx";
repo = "qemu";
rev = version;
hash = "sha256-FKaoTRTftaIId+VkjMqKzcdO48ngQirymH4XLzMm+t8=";
};

keycodemapdb = fetchFromGitLab {
owner = "qemu-project";
repo = "keycodemapdb";
rev = "f5772a62ec52591ff6870b7e8ef32482371f22c6";
hash = "sha256-GbZ5mrUYLXMi0IX4IZzles0Oyc095ij2xAsiLNJwfKQ=";
};

berkeley-softfloat-3 = fetchFromGitLab {
owner = "qemu-project";
repo = "berkeley-softfloat-3";
rev = "b64af41c3276f97f0e181920400ee056b9c88037";
hash = "sha256-Yflpx+mjU8mD5biClNpdmon24EHg4aWBZszbOur5VEA=";
};

berkeley-testfloat-3 = fetchFromGitLab {
owner = "qemu-project";
repo = "berkeley-testfloat-3";
rev = "40619cbb3bf32872df8c53cc457039229428a263";
hash = "sha256-EBz1uYnjehCtJqrSFzERH23N5ELZU3gGM26JnsGFcWg=";
};

devicetrees = stdenv.mkDerivation {
name = "devicetrees";
src = fetchFromGitHub {
owner = "Xilinx";
repo = "qemu-devicetrees";
rev = version;
hash = "sha256-FYNo/2XVq/viWIB+yFDwzY5eaosC5omQZ3LyypMu2bM=";
};
nativeBuildInputs = [
python3
dtc
];
dontConfigure = true;
dontFixup = true;
installPhase = ''
mv LATEST $out
'';
};

in

(qemuForSeL4.override {
hostCpuTargets = [
"aarch64-softmmu"
];
}).overrideAttrs (finalAttrs: previousAttrs: {
inherit version src;

postPatch = (previousAttrs.postPatch or "") + ''
pushd subprojects
ln -sf ${keycodemapdb} keycodemapdb

d=berkeley-softfloat-3
cp -r --no-preserve=owner,mode ${berkeley-softfloat-3} $d
cp -r packagefiles/$d/* $d

d=berkeley-testfloat-3
cp -r --no-preserve=owner,mode ${berkeley-testfloat-3} $d
cp -r packagefiles/$d/* $d
popd
'';

passthru = (previousAttrs.passthru or {}) // {
inherit devicetrees;
};
})
4 changes: 2 additions & 2 deletions hacking/nix/scope/sources.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ in rec {
seL4 = {
rust = fetchGit {
url = "https://github.com/coliasgroup/seL4.git";
rev = "80eaac9ee68b2b24249e1acda116dfc4bf56cdd8"; # branch "rust-testing"
rev = "a57464ad2c4e269dfb5e5bd87bf7d6b81417a2ed"; # branch "rust-testing"
local = localRoot + "/seL4";
};

Expand All @@ -62,7 +62,7 @@ in rec {

microkit = fetchGit {
url = "https://github.com/coliasgroup/microkit.git";
rev = "9ed293c8908de78ccf7925c6e670093adfba59d4"; # branch "rust-nix"
rev = "de0f7c3066ae7828d52302cbf7e2acd8fb5e7023"; # branch "rust-nix"
local = localRoot + "/microkit";
};

Expand Down
Loading
Loading