Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
dd32e52
Improve devtools profile for FlashBox L2 (#129)
fkondej Apr 9, 2026
f777ec0
Shell scripts should use #!/usr/bin/env bash and flake.nix should add…
ameba23 Apr 13, 2026
d3c0227
Rm jq as it is already added as a system dependency
ameba23 Apr 14, 2026
eb1610a
Merge pull request #130 from flashbots/peg/nixos-friendly-flake
ameba23 Apr 14, 2026
49debcd
Bump lighthouse to v8.1.3 (#134)
pablin-10 Apr 16, 2026
cedd669
Update readme to remove integration messaging details
niccoloraspa Apr 17, 2026
ddae850
Merge pull request #135 from flashbots/docs/flashbox
niccoloraspa Apr 17, 2026
142a53d
chore: memory optimizations
MoeMahhouk Apr 27, 2026
b92c3e6
Allow installing apt packages in dev mode (#137)
alexhulbert Apr 29, 2026
5b3729c
Add Contrast BadAML sandbox kernel patch on GCP (#131)
ameba23 Apr 29, 2026
e76dcf9
Bump kernel to 6.19 + Debian snapshot 20260430 to fix CVE-2026-31431
MoeMahhouk Apr 30, 2026
c5bf67e
Merge pull request #136 from flashbots/moe/flashbox-l1-memory-headroom
niccoloraspa Apr 30, 2026
e6c662e
Merge pull request #138 from flashbots/moe/copy-fail-cve-2026-31431
niccoloraspa Apr 30, 2026
e667c69
Move needed network deps to shared module (#141)
alexhulbert Apr 30, 2026
ff5614f
Fixes for kernel build errors (#140)
alexhulbert Apr 30, 2026
63c4f20
Dynamically size ESP partition to support images > 512MB (#122)
alexhulbert Apr 30, 2026
769c37f
Log TDX measurements on boot (#143)
ameba23 May 7, 2026
b28706e
add security section
shashial May 8, 2026
07e5fb6
Merge pull request #147 from flashbots/add-security-section
shashial May 8, 2026
831883f
Add CODEOWNERS
niccoloraspa May 15, 2026
b169f8f
Merge pull request #149 from flashbots/feat/add-codeowners
niccoloraspa May 15, 2026
a182e67
Merge pull request #127 from flashbots/trunk/l2-builder-uni
0x416e746f6e May 25, 2026
676ed8c
Merge pull request #139 from flashbots/main
0x416e746f6e May 25, 2026
526af72
fix: use `systemd-repart` from nix
0x416e746f6e May 26, 2026
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
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# they will be requested for review when someone opens a pull request.
* @flashbots/devops @flashbots/andromeda
96 changes: 53 additions & 43 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,53 +44,56 @@
src = pkgs.fetchFromGitHub {
owner = "flashbots";
repo = "dstack-mr-gcp";
rev = "503e7c506f89f9d81be04025c90921778b26f0a4";
sha256 = "sha256-z6STTgcOXatiqA2rlpzwRyvAwnXrK30oNDCJqtIp7/8=";
rev = "ecf3284b72a507fd005de91d49f7372490cf6995";
sha256 = "sha256-1rcm9sIZuvCojNN2HMPrsECYn9sd8eVChsgwleo8nFY=";
};
vendorHash = "sha256-glOyRTrIF/zP78XGV+v58a1Bec6C3Fvc5c8G3PglzPM=";
};
mkosi = system: let
pkgsForSystem = import nixpkgs {inherit system;};
mkosi-unwrapped = (pkgsForSystem.mkosi.override {
extraDeps = with pkgsForSystem;
[
apt
dpkg
gnupg
debootstrap
squashfsTools
dosfstools
e2fsprogs
mtools
mustache-go
cryptsetup
gptfdisk
util-linux
zstd
which
qemu-utils
parted
unzip
jq
]
++ [reprepro];
}).overrideAttrs (old: {
src = pkgsForSystem.fetchFromGitHub {
owner = "systemd";
repo = "mkosi";
rev = "df51194bc2d890d4c267af644a1832d2d53339ac";
hash = "sha256-rGGzE9xIR8WvK07GBnaAmeLpmnM3Uy51wqyrmuHuWXo=";
};
# TODO: remove these patch hunks from upstream nixpkgs next time mkosi has a release
# The latest mkosi doesn't need them
patches = pkgs.lib.drop 2 old.patches;
postPatch = let fd = "${pkgs.patchutils}/bin/filterdiff"; in ''
{ ${fd} -x '*/run.py' --hunks=x2 ${builtins.elemAt old.patches 0}
${fd} -i '*/run.py' --hunks=x1-2 ${builtins.elemAt old.patches 0}
${fd} --hunks=x1 ${builtins.elemAt old.patches 1}
} | patch -p1
'';
});
mkosi-unwrapped =
(pkgsForSystem.mkosi.override {
extraDeps = with pkgsForSystem;
[
apt
dpkg
gnupg
debootstrap
squashfsTools
dosfstools
e2fsprogs
mtools
mustache-go
cryptsetup
gptfdisk
util-linux
zstd
which
qemu-utils
parted
unzip
jq
]
++ [reprepro];
}).overrideAttrs (old: {
src = pkgsForSystem.fetchFromGitHub {
owner = "systemd";
repo = "mkosi";
rev = "df51194bc2d890d4c267af644a1832d2d53339ac";
hash = "sha256-rGGzE9xIR8WvK07GBnaAmeLpmnM3Uy51wqyrmuHuWXo=";
};
# TODO: remove these patch hunks from upstream nixpkgs next time mkosi has a release
# The latest mkosi doesn't need them
patches = pkgs.lib.drop 2 old.patches;
postPatch = let
fd = "${pkgs.patchutils}/bin/filterdiff";
in ''
{ ${fd} -x '*/run.py' --hunks=x2 ${builtins.elemAt old.patches 0}
${fd} -i '*/run.py' --hunks=x1-2 ${builtins.elemAt old.patches 0}
${fd} --hunks=x1 ${builtins.elemAt old.patches 1}
} | patch -p1
'';
});
in
# Create a wrapper script that runs mkosi with unshare
# Unshare is needed to create files owned by multiple uids/gids
Expand All @@ -106,7 +109,14 @@
devShells = builtins.listToAttrs (map (system: {
name = system;
value.default = pkgs.mkShell {
nativeBuildInputs = [(mkosi system) measured-boot measured-boot-gcp];
nativeBuildInputs = with pkgs; [
(mkosi system)
measured-boot
measured-boot-gcp
bash
curl
git
];
shellHook = ''
mkdir -p mkosi.packages mkosi.cache mkosi.builddir ~/.cache/mkosi
touch mkosi.builddir/mkosi.sources
Expand Down
2 changes: 1 addition & 1 deletion images/flashbox-l1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Include=modules/flashbox/flashbox-l1/mkosi.conf
Profiles=azure,gcp

[Distribution]
Snapshot=20260301T083349Z
Snapshot=20260430T025253Z
2 changes: 1 addition & 1 deletion images/flashbox-l2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Include=modules/flashbox/flashbox-l2/mkosi.conf
Profiles=gcp

[Distribution]
Snapshot=20260301T083349Z
Snapshot=20260430T025253Z
2 changes: 1 addition & 1 deletion images/l2-simulator.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Profiles=gcp

[Distribution]
Snapshot=20260301T083349Z
Snapshot=20260430T025253Z

[Include]
Include=shared/mkosi.conf
Expand Down
2 changes: 1 addition & 1 deletion mkosi.profiles/azure/mkosi.postoutput
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -euxo pipefail

EFI_FILE="${OUTPUTDIR}/${IMAGE_ID}_${IMAGE_VERSION}.efi"
Expand Down
1 change: 1 addition & 0 deletions mkosi.profiles/devtools/mkosi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ExtraTrees=mkosi.extra
custom
PostInstallationScripts=custom.postinst.d/*.sh
CleanPackageMetadata=false

Packages=adjtimex
apt
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion mkosi.profiles/devtools/mkosi.postinst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -euxo pipefail

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Paul Meyer <katexochen0@gmail.com>
Date: Tue, 17 Feb 2026 10:47:28 +0100
Subject: [PATCH] drivers/acpi: add BadAML sandbox

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
---
drivers/acpi/acpica/exregion.c | 6 ++
drivers/acpi/acpica/sandbox.h | 139 +++++++++++++++++++++++++++++++++
2 files changed, 145 insertions(+)
create mode 100644 drivers/acpi/acpica/sandbox.h

diff --git a/drivers/acpi/acpica/exregion.c b/drivers/acpi/acpica/exregion.c
index a390a1c2b0abb01a7c8490b207ec377818120207..638323389e970500c004b7ccdd52a9e7455eaf67 100644
--- a/drivers/acpi/acpica/exregion.c
+++ b/drivers/acpi/acpica/exregion.c
@@ -14,6 +14,8 @@
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME("exregion")

+#include "sandbox.h"
+
/*******************************************************************************
*
* FUNCTION: acpi_ex_system_memory_space_handler
@@ -38,6 +40,7 @@ acpi_ex_system_memory_space_handler(u32 function,
u64 *value,
void *handler_context, void *region_context)
{
+ SANDBOX_SECT_START;
acpi_status status = AE_OK;
void *logical_addr_ptr = NULL;
struct acpi_mem_space_context *mem_info = region_context;
@@ -192,6 +195,7 @@ acpi_ex_system_memory_space_handler(u32 function,
case ACPI_READ:

*value = 0;
+ SANDBOX_READ_HOOK((u64)logical_addr_ptr, (u64)address);
switch (bit_width) {
case 8:

@@ -223,6 +227,7 @@ acpi_ex_system_memory_space_handler(u32 function,

case ACPI_WRITE:

+ SANDBOX_WRITE_HOOK((u64)logical_addr_ptr, (u64)address);
switch (bit_width) {
case 8:

@@ -258,6 +263,7 @@ acpi_ex_system_memory_space_handler(u32 function,
break;
}

+ SANDBOX_SECT_END;
return_ACPI_STATUS(status);
}

diff --git a/drivers/acpi/acpica/sandbox.h b/drivers/acpi/acpica/sandbox.h
new file mode 100644
index 0000000000000000000000000000000000000000..1d9d95a87698dde14429f2f33a0c375ad51774fe
--- /dev/null
+++ b/drivers/acpi/acpica/sandbox.h
@@ -0,0 +1,139 @@
+/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
+/* SPDX-FileCopyrightText: Satoru Takekoshi, Manami Mori, Takaaki Fukai,
+ * Takahiro Shinagawa */
+/* SPDX-FileCopyrightText: Edgeless Systems GmbH */
+#include <asm/coco.h>
+#include <linux/cc_platform.h>
+#include <linux/efi.h>
+#include <linux/mm.h>
+#include <linux/once.h>
+#include <linux/sched.h>
+
+#define SANDBOX_READ_HOOK(virt_addr, phys_addr) { if (!__sandbox_validate_memory_access(virt_addr, phys_addr, true)) break; }
+#define SANDBOX_WRITE_HOOK(virt_addr, phys_addr) { if (!__sandbox_validate_memory_access(virt_addr, phys_addr, false)) break; }
+#define SANDBOX_SECT_START { __sandbox_section_start(); }
+#define SANDBOX_SECT_END { __sandbox_section_end(); }
+
+static struct __sandbox_access_log {
+ bool is_read;
+ unsigned long phys_addr;
+ unsigned long virt_addr;
+ bool access_allowed;
+} __sandbox_access_log;
+
+static void __sandbox_log_enabled(void)
+{
+ DO_ONCE(pr_info, "SANDBOX: Enabled\n");
+}
+
+static unsigned long __sandbox_get_page_table_entry(unsigned long addr)
+{
+ pgd_t *pgd;
+ p4d_t *p4d;
+ pud_t *pud;
+ pmd_t *pmd;
+ pte_t *pte;
+
+ pgd = pgd_offset_k(addr);
+ if (pgd_none(*pgd)) {
+ return 0;
+ }
+
+ p4d = p4d_offset(pgd, addr);
+ if (p4d_none(*p4d)) {
+ return 0;
+ }
+
+ pud = pud_offset(p4d, addr);
+ if (pud_none(*pud)) {
+ return 0;
+ }
+
+ /* Check for 1GB huge page */
+ if (pud_leaf(*pud)) {
+ return pud_val(*pud);
+ }
+
+ pmd = pmd_offset(pud, addr);
+ if (pmd_none(*pmd)) {
+ return 0;
+ }
+
+ /* Check for 2MB huge page */
+ if (pmd_leaf(*pmd)) {
+ return pmd_val(*pmd);
+ }
+
+ pte = pte_offset_kernel(pmd, addr);
+ if (pte_none(*pte)) {
+ return 0;
+ }
+
+ return pte_val(*pte);
+}
+
+static bool __sandbox_is_encrypted_generic(unsigned long virt_addr)
+{
+ unsigned long val;
+
+ val = __sandbox_get_page_table_entry((unsigned long)(virt_addr));
+ if (val) {
+ return val == cc_mkenc(val);
+ } else {
+ ACPI_ERROR((AE_INFO, "SANDBOX: Page table walk failed"));
+ }
+
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "SANDBOX: Falling back to 'encrypted' state\n"));
+ return true;
+}
+
+static bool __sandbox_validate_memory_access(unsigned long virt_addr, unsigned long phys_addr, bool is_read)
+{
+ __sandbox_log_enabled();
+ __sandbox_access_log.is_read = is_read;
+ __sandbox_access_log.phys_addr = phys_addr;
+ __sandbox_access_log.virt_addr = virt_addr;
+ phys_addr &= PAGE_MASK;
+ virt_addr &= PAGE_MASK;
+
+ cond_resched();
+
+ bool encrypted = true;
+ if (cc_platform_has(CC_ATTR_MEM_ENCRYPT)) {
+ encrypted = __sandbox_is_encrypted_generic(virt_addr);
+ } else {
+ ACPI_ERROR((AE_INFO, "SANDBOX: Unknown platform"));
+ }
+
+ cond_resched();
+
+ if (!encrypted) {
+ return true;
+ }
+
+ __sandbox_access_log.access_allowed = false;
+ return false;
+}
+
+static void __sandbox_section_start(void)
+{
+ __sandbox_access_log.is_read = true;
+ __sandbox_access_log.phys_addr = 0xdeadbeefcafebabeuL;
+ __sandbox_access_log.virt_addr = 0xdeadbeefcafebabeuL;
+ __sandbox_access_log.access_allowed = true;
+}
+
+static void __sandbox_section_end(void)
+{
+ cond_resched();
+
+ ACPI_INFO((
+ "SANDBOX: ACCESS %s virt=%lx phys=%lx %s",
+ __sandbox_access_log.is_read ? "r" : "w",
+ (unsigned long)__sandbox_access_log.virt_addr,
+ (unsigned long)__sandbox_access_log.phys_addr,
+ __sandbox_access_log.access_allowed ? "allowed" : "denied"
+ ));
+
+ cond_resched();
+}
--
2.49.0
4 changes: 1 addition & 3 deletions mkosi.profiles/gcp/mkosi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@ Environment=KERNEL_CONFIG_SNIPPETS_GCP=mkosi.profiles/gcp/kernel/config.d
[Content]
ExtraTrees=mkosi.extra

Packages=udev
chrony
nvme-cli
Packages=nvme-cli
xxd
2 changes: 1 addition & 1 deletion mkosi.profiles/gcp/mkosi.postinst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -euxo pipefail

Expand Down
Loading