Skip to content

Commit 58e1a5c

Browse files
authored
build_igvm: Separate release configuration from build profile (#1867)
This PR adds a new flag to local invocations of `xflowey build-igvm`, `--release-cfg`. This flag controls various bits of configuration around how the final IGVM file is produced, such as the json file used and the features compiled in. This separates these configuration pieces from `--release`, which now only control the build profile. This allows for building an optimized binary with debug options still available. It also allows for building an unoptimized output without debug options, but this is weird, so it outputs a warning if you ask for it. This PR then removes the debug configurations from the cvm-release json. This means that running `xflowey build-igvm x64-cvm --release` locally will still produce an optimized binary with the debug bits set, but it means the binaries we ship to the OS will now have the debug bit unset by default, as the publishing step is effectively running with `--release --release-cfg`.
1 parent b9a2abc commit 58e1a5c

9 files changed

+58
-43
lines changed

flowey/flowey_hvlite/src/pipelines/build_igvm.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,18 @@ where
5050
/// into a VTL2 initrd, what `igvmfilegen` manifest is being used, etc...
5151
pub recipe: Recipe,
5252

53-
/// Build using release variants of all constituent components.
53+
/// Build using release variants of all constituent binary components.
5454
///
5555
/// Uses --profile=boot-release for openhcl_boot, --profile=openhcl-ship
56-
/// when building openvmm_hcl, `--min-interactive` vtl2 initrd
57-
/// configuration, `-release.json` manifest variant, etc...
56+
/// when building openvmm_hcl, etc...
5857
#[clap(long)]
5958
pub release: bool,
6059

60+
/// Configure the IGVM file with the appropriate `-release.json`
61+
/// manifest variant, and disable debug-only features.
62+
#[clap(long)]
63+
pub release_cfg: bool,
64+
6165
/// pass `--verbose` to cargo
6266
#[clap(long)]
6367
pub verbose: bool,
@@ -230,6 +234,7 @@ impl IntoPipeline for BuildIgvmCli {
230234
let Self {
231235
recipe,
232236
release,
237+
release_cfg,
233238
verbose,
234239
locked,
235240
install_missing_deps,
@@ -257,11 +262,7 @@ impl IntoPipeline for BuildIgvmCli {
257262
} = self;
258263

259264
if with_perf_tools {
260-
custom_extra_rootfs.push(
261-
crate::repo_root()
262-
.join("openhcl/perftoolsfs.config")
263-
.clone(),
264-
);
265+
custom_extra_rootfs.push(crate::repo_root().join("openhcl/perftoolsfs.config"));
265266
}
266267

267268
let mut pipeline = Pipeline::new();
@@ -309,6 +310,7 @@ impl IntoPipeline for BuildIgvmCli {
309310
OpenhclRecipeCli::Aarch64Devkern => OpenhclIgvmRecipe::Aarch64Devkern,
310311
},
311312
release,
313+
release_cfg,
312314

313315
customizations: flowey_lib_hvlite::_jobs::local_build_igvm::Customizations {
314316
build_label,

flowey/flowey_lib_hvlite/src/_jobs/build_and_publish_openhcl_igvm_from_recipe.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,13 @@ impl SimpleFlowNode for Node {
7070
let (read_built_sidecar, built_sidecar) = ctx.new_var();
7171
ctx.req(crate::build_openhcl_igvm_from_recipe::Request {
7272
custom_target,
73-
profile,
73+
build_profile: profile,
74+
release_cfg: match profile {
75+
OpenvmmHclBuildProfile::Debug => false,
76+
OpenvmmHclBuildProfile::Release | OpenvmmHclBuildProfile::OpenvmmHclShip => {
77+
true
78+
}
79+
},
7480
recipe: recipe.clone(),
7581
built_openvmm_hcl,
7682
built_openhcl_boot,

flowey/flowey_lib_hvlite/src/_jobs/build_and_publish_openvmm_hcl_baseline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl SimpleFlowNode for Node {
3636
target: CommonTriple::X86_64_LINUX_MUSL,
3737
profile: OpenvmmHclBuildProfile::OpenvmmHclShip,
3838
features: (OpenhclIgvmRecipe::X64)
39-
.recipe_details(OpenvmmHclBuildProfile::OpenvmmHclShip)
39+
.recipe_details(true)
4040
.openvmm_hcl_features,
4141
no_split_dbg_info: false,
4242
},

flowey/flowey_lib_hvlite/src/_jobs/check_openvmm_hcl_size.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl SimpleFlowNode for Node {
6060
target: target.clone(),
6161
profile: OpenvmmHclShip,
6262
features: (OpenhclIgvmRecipe::X64)
63-
.recipe_details(OpenvmmHclShip)
63+
.recipe_details(true)
6464
.openvmm_hcl_features,
6565
no_split_dbg_info: false,
6666
},

flowey/flowey_lib_hvlite/src/_jobs/local_build_and_run_nextest_vmm_tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,8 @@ impl SimpleFlowNode for Node {
393393
let (read_built_openhcl_boot, built_openhcl_boot) = ctx.new_var();
394394
let (read_built_sidecar, built_sidecar) = ctx.new_var();
395395
ctx.req(crate::build_openhcl_igvm_from_recipe::Request {
396-
profile: openvmm_hcl_profile,
396+
build_profile: openvmm_hcl_profile,
397+
release_cfg: release,
397398
recipe: recipe.clone(),
398399
custom_target: None,
399400
built_openvmm_hcl,

flowey/flowey_lib_hvlite/src/_jobs/local_build_igvm.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ flowey_request! {
4949

5050
pub base_recipe: OpenhclIgvmRecipe,
5151
pub release: bool,
52+
pub release_cfg: bool,
5253

5354
pub customizations: Customizations,
5455
}
@@ -70,6 +71,7 @@ impl SimpleFlowNode for Node {
7071

7172
base_recipe,
7273
release,
74+
release_cfg,
7375

7476
customizations,
7577
} = request;
@@ -97,13 +99,20 @@ impl SimpleFlowNode for Node {
9799
custom_extra_rootfs,
98100
} = customizations;
99101

100-
let profile = if release {
102+
if release_cfg && !release {
103+
log::warn!(
104+
"You are building a debug binary with a release configuration.\n\
105+
The produced binary likely will not function properly due to memory restrictions."
106+
)
107+
}
108+
109+
let build_profile = if release {
101110
OpenvmmHclBuildProfile::OpenvmmHclShip
102111
} else {
103112
OpenvmmHclBuildProfile::Debug
104113
};
114+
let mut recipe_details = base_recipe.recipe_details(release_cfg);
105115

106-
let mut recipe_details = base_recipe.recipe_details(profile);
107116
{
108117
let OpenhclIgvmRecipeDetails {
109118
local_only,
@@ -125,8 +134,8 @@ impl SimpleFlowNode for Node {
125134
*with_sidecar_details = true;
126135
}
127136

128-
// Debug builds include --interactive by default, for busybox, gdbserver, and perf.
129-
*with_interactive = matches!(profile, OpenvmmHclBuildProfile::Debug) || with_perf_tools;
137+
// Debug configurations include --interactive by default, for busybox, gdbserver, and perf.
138+
*with_interactive = !release_cfg || with_perf_tools;
130139

131140
assert!(local_only.is_none());
132141
*local_only = Some(OpenhclIgvmRecipeDetailsLocalOnly {
@@ -212,8 +221,9 @@ impl SimpleFlowNode for Node {
212221
let (built_sidecar, write_built_sidecar) = ctx.new_var();
213222

214223
ctx.req(crate::build_openhcl_igvm_from_recipe::Request {
215-
profile,
216-
recipe: OpenhclIgvmRecipe::LocalOnlyCustom(recipe_details.clone()),
224+
build_profile,
225+
release_cfg,
226+
recipe: OpenhclIgvmRecipe::LocalOnlyCustom(recipe_details),
217227
custom_target: None,
218228
built_openvmm_hcl: write_built_openvmm_hcl,
219229
built_openhcl_boot: write_built_openhcl_boot,
@@ -231,7 +241,7 @@ impl SimpleFlowNode for Node {
231241
move |rt| {
232242
let output_dir = rt
233243
.read(artifact_dir)
234-
.join(match profile {
244+
.join(match build_profile {
235245
OpenvmmHclBuildProfile::Debug => "debug",
236246
OpenvmmHclBuildProfile::Release => "release",
237247
OpenvmmHclBuildProfile::OpenvmmHclShip => "ship",

flowey/flowey_lib_hvlite/src/build_openhcl_igvm_from_recipe.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,29 +95,29 @@ pub enum OpenhclIgvmRecipe {
9595
}
9696

9797
impl OpenhclIgvmRecipe {
98-
pub fn recipe_details(&self, profile: OpenvmmHclBuildProfile) -> OpenhclIgvmRecipeDetails {
98+
pub fn recipe_details(&self, release_cfg: bool) -> OpenhclIgvmRecipeDetails {
9999
let base_openvmm_hcl_features = || {
100100
let mut m = BTreeSet::new();
101101

102102
m.insert(OpenvmmHclFeature::Tpm);
103103

104-
if matches!(profile, OpenvmmHclBuildProfile::Debug) {
104+
if !release_cfg {
105105
m.insert(OpenvmmHclFeature::Gdb);
106106
}
107107

108108
m
109109
};
110110

111111
let in_repo_template = |debug_manifest: &'static str, release_manifest: &'static str| {
112-
IgvmManifestPath::InTree(if matches!(profile, OpenvmmHclBuildProfile::Debug) {
113-
debug_manifest.into()
114-
} else {
112+
IgvmManifestPath::InTree(if release_cfg {
115113
release_manifest.into()
114+
} else {
115+
debug_manifest.into()
116116
})
117117
};
118118

119-
// Debug builds include --interactive by default, for busybox, gdbserver, and perf.
120-
let with_interactive = matches!(profile, OpenvmmHclBuildProfile::Debug);
119+
// Debug configurations include --interactive by default, for busybox, gdbserver, and perf.
120+
let with_interactive = !release_cfg;
121121

122122
match self {
123123
Self::LocalOnlyCustom(details) => details.clone(),
@@ -229,16 +229,12 @@ impl OpenhclIgvmRecipe {
229229
},
230230
}
231231
}
232-
233-
pub fn to_custom_mut(&mut self, profile: OpenvmmHclBuildProfile) {
234-
let details = self.recipe_details(profile);
235-
*self = Self::LocalOnlyCustom(details);
236-
}
237232
}
238233

239234
flowey_request! {
240235
pub struct Request {
241-
pub profile: OpenvmmHclBuildProfile,
236+
pub build_profile: OpenvmmHclBuildProfile,
237+
pub release_cfg: bool,
242238
pub recipe: OpenhclIgvmRecipe,
243239
pub custom_target: Option<CommonTriple>,
244240

@@ -270,7 +266,8 @@ impl SimpleFlowNode for Node {
270266

271267
fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
272268
let Request {
273-
profile,
269+
build_profile,
270+
release_cfg,
274271
recipe,
275272
custom_target,
276273
built_openvmm_hcl,
@@ -289,7 +286,7 @@ impl SimpleFlowNode for Node {
289286
with_uefi,
290287
with_interactive,
291288
with_sidecar,
292-
} = recipe.recipe_details(profile);
289+
} = recipe.recipe_details(release_cfg);
293290

294291
let OpenhclIgvmRecipeDetailsLocalOnly {
295292
openvmm_hcl_no_strip,
@@ -423,7 +420,7 @@ impl SimpleFlowNode for Node {
423420
ctx.reqv(|v| crate::build_sidecar::Request {
424421
build_params: crate::build_sidecar::SidecarBuildParams {
425422
arch,
426-
profile: match profile {
423+
profile: match build_profile {
427424
OpenvmmHclBuildProfile::Debug => {
428425
crate::build_sidecar::SidecarBuildProfile::Debug
429426
}
@@ -448,7 +445,7 @@ impl SimpleFlowNode for Node {
448445
crate::build_openvmm_hcl::Request {
449446
build_params: crate::build_openvmm_hcl::OpenvmmHclBuildParams {
450447
target: target.clone(),
451-
profile,
448+
profile: build_profile,
452449
features: openvmm_hcl_features,
453450
// manually strip later, depending on provided igvm flags
454451
no_split_dbg_info: true,
@@ -492,7 +489,7 @@ impl SimpleFlowNode for Node {
492489
ctx.reqv(|v| crate::build_openhcl_boot::Request {
493490
build_params: crate::build_openhcl_boot::OpenhclBootBuildParams {
494491
arch,
495-
profile: match profile {
492+
profile: match build_profile {
496493
OpenvmmHclBuildProfile::Debug => {
497494
crate::build_openhcl_boot::OpenhclBootBuildProfile::Debug
498495
}

vm/loader/manifests/openhcl-x64-cvm-release.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
"snp": {
99
"shared_gpa_boundary_bits": 46,
1010
"policy": 196639,
11-
"enable_debug": true,
11+
"enable_debug": false,
1212
"injection_type": "normal"
1313
}
1414
},
1515
"image": {
1616
"openhcl": {
17-
"command_line": "OPENHCL_CONFIDENTIAL_DEBUG=1",
17+
"command_line": "",
1818
"memory_page_count": 163840,
1919
"memory_page_base": 32768,
2020
"uefi": true
@@ -26,7 +26,7 @@
2626
"max_vtl": 2,
2727
"isolation_type": {
2828
"tdx": {
29-
"enable_debug": true,
29+
"enable_debug": false,
3030
"sept_ve_disable": true
3131
}
3232
},
@@ -44,12 +44,12 @@
4444
"max_vtl": 2,
4545
"isolation_type": {
4646
"vbs": {
47-
"enable_debug": true
47+
"enable_debug": false
4848
}
4949
},
5050
"image": {
5151
"openhcl": {
52-
"command_line": "OPENHCL_CONFIDENTIAL_DEBUG=1",
52+
"command_line": "",
5353
"memory_page_count": 32768,
5454
"memory_page_base": 32768,
5555
"uefi": true

vm/loader/manifests/openhcl-x64-release.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"isolation_type": "none",
88
"image": {
99
"openhcl": {
10-
"initrd_path": "./underhill.cpio.gz",
1110
"command_line": "",
1211
"memory_page_count": 17920,
1312
"uefi": true

0 commit comments

Comments
 (0)