Skip to content

Commit ca07557

Browse files
committed
Modify Makefile for Azure, refactor code in main.rs
Revert changes to do_measurements Refactor modified: sh_script/Azure/Makefile modified: sh_script/fuzzing.sh modified: src/migtd/src/bin/migtd/main.rs Add formatting. modified: sh_script/Azure/Makefile modified: sh_script/fuzzing.sh modified: src/migtd/src/bin/migtd/main.rs Increase timeout for build_AzCVMEmu_policy_and_test.sh to complete. modified: .github/workflows/integration-emu.yml modified: sh_script/Azure/Makefile modified: sh_script/fuzzing.sh modified: src/migtd/src/bin/migtd/main.rs
1 parent 4e19941 commit ca07557

File tree

4 files changed

+63
-18
lines changed

4 files changed

+63
-18
lines changed

.github/workflows/integration-emu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ jobs:
241241
242242
# Run the script with timeout
243243
set +e
244-
timeout 600 ./sh_script/build_AzCVMEmu_policy_and_test.sh --mock-report
244+
timeout 900 ./sh_script/build_AzCVMEmu_policy_and_test.sh --mock-report
245245
EXIT_CODE=$?
246246
set -e
247247

sh_script/Azure/Makefile

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ IGVM_MANIFEST ?= config/Azure/servtd_info.json
1515
.PHONY: pre-build build-igvm generate-hash build-igvm-all
1616
.PHONY: build-igvm-reject build-igvm-reject-all
1717
.PHONY: generate-hash-verbose generate-hash-accept-verbose
18+
.PHONY: build-igvm-get-quote build-igvm-get-quote-all generate-hash-get-quote
1819

1920
.DEFAULT_GOAL := build-igvm-all
2021

2122
help:
2223
@echo "Available targets:"
2324
@echo " build-igvm-all - Build IGVM"
2425
@echo " build-igvm-accept-all - Build IGVM with disabled RA and accept all policy with TLS"
25-
@echo " build-igvm-reject - Build IGVM with v1 policy which will be rejected because on empty quote generation."
26+
@echo " build-igvm-reject-all - Build IGVM with v1 policy which will be rejected because on empty quote generation."
27+
@echo " build-igvm-get-quote-all - Build IGVM with v2 policy which will call getquote durining initialization."
2628

2729
pre-build:
2830
@if ! command -v rustc >/dev/null 2>&1 || ! rustc --version | grep -q "1.83.0"; then \
@@ -43,28 +45,45 @@ pre-build:
4345
cd ../../ && ./sh_script/preparation.sh
4446

4547
build-igvm-accept:
46-
cd ../../ && cargo image --no-default-features --features $(IGVM_FEATURES_DISABLE_RA_AND_ACCEPT_ALL) --log-level $(LOG_LEVEL) --image-format igvm --output $(IGVM_FILE) --debug
48+
cd ../../ && cargo image --no-default-features --features $(IGVM_FEATURES_DISABLE_RA_AND_ACCEPT_ALL) \
49+
--log-level $(LOG_LEVEL) --image-format igvm --output $(IGVM_FILE) --debug
4750

4851
generate-hash-accept:
49-
cd ../../ && cargo run -p migtd-hash -- --image $(IGVM_FILE) --test-disable-ra-and-accept-all --manifest $(IGVM_MANIFEST)
52+
cd ../../ && cargo run -p migtd-hash -- --image $(IGVM_FILE) --test-disable-ra-and-accept-all \
53+
--manifest $(IGVM_MANIFEST)
5054

5155
generate-hash-accept-verbose:
52-
cd ../../ && cargo run -p migtd-hash -- --image $(IGVM_FILE) --test-disable-ra-and-accept-all --verbose
56+
cd ../../ && cargo run -p migtd-hash -- --image $(IGVM_FILE) --test-disable-ra-and-accept-all \
57+
--verbose
5358

5459
build-igvm-accept-all: pre-build build-igvm-accept generate-hash-accept
5560

5661
generate-hash:
5762
cd ../../ && cargo run -p migtd-hash -- --image $(IGVM_FILE) --manifest $(IGVM_MANIFEST)
5863

5964
build-igvm:
60-
cd ../../ && cargo image --no-default-features --features $(IGVM_FEATURES_BASE) --log-level $(LOG_LEVEL) --image-format igvm --output $(IGVM_FILE)
65+
cd ../../ && cargo image --no-default-features --features $(IGVM_FEATURES_BASE) --log-level $(LOG_LEVEL) \
66+
--image-format igvm --output $(IGVM_FILE)
6167

6268
build-igvm-all: pre-build build-igvm generate-hash
6369

6470
build-igvm-reject:
65-
cd ../../ && cargo image --no-default-features --features $(IGVM_FEATURES_BASE) --log-level debug --image-format igvm --output $(IGVM_FILE) --debug
71+
cd ../../ && cargo image --no-default-features --features $(IGVM_FEATURES_BASE) --log-level $(LOG_LEVEL) \
72+
--image-format igvm --output $(IGVM_FILE) --debug
6673

6774
build-igvm-reject-all: pre-build build-igvm-reject generate-hash
6875

6976
generate-hash-verbose:
70-
cd ../../ && cargo run -p migtd-hash -- --image $(IGVM_FILE) --verbose --manifest $(IGVM_MANIFEST)
77+
cd ../../ && cargo run -p migtd-hash -- --image $(IGVM_FILE) --verbose --manifest $(IGVM_MANIFEST)
78+
79+
build-igvm-get-quote:
80+
cd ../../ && cargo image --no-default-features --features $(IGVM_FEATURES_BASE) --log-level $(LOG_LEVEL) \
81+
--image-format igvm --output $(IGVM_FILE) --debug \
82+
--policy-v2 --policy config/templates/policy_v2_signed.json \
83+
--policy-issuer-chain config/templates/policy_issuer_chain.pem \
84+
--root-ca config/Intel_SGX_Provisioning_Certification_RootCA_preproduction.cer
85+
86+
generate-hash-get-quote:
87+
cd ../../ && cargo run -p migtd-hash -- --image $(IGVM_FILE) --manifest $(IGVM_MANIFEST) --policy-v2
88+
89+
build-igvm-get-quote-all: pre-build build-igvm-get-quote generate-hash-get-quote

sh_script/fuzzing.sh

100644100755
File mode changed.

src/migtd/src/bin/migtd/main.rs

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ fn basic_info() {
139139
info!("MigTD Version - {}\n", MIGTD_VERSION);
140140
}
141141

142+
#[cfg(not(feature = "policy_v2"))]
142143
fn do_measurements() {
143144
// Get the event log recorded by firmware
144145
let event_log = event_log::get_event_log_mut().expect("Failed to get the event log");
@@ -147,18 +148,29 @@ fn do_measurements() {
147148
measure_test_feature(event_log);
148149
return;
149150
}
150-
151-
#[cfg(feature = "policy_v2")]
152-
get_policy_issuer_chain_and_measure(event_log);
153-
154151
// Get migration td policy from CFV and measure it into RMTR
155152
get_policy_and_measure(event_log);
156153

157154
// Get root certificate from CFV and measure it into RMTR
158-
#[cfg(not(feature = "policy_v2"))]
159155
get_ca_and_measure(event_log);
160156
}
161157

158+
#[cfg(feature = "policy_v2")]
159+
fn do_measurements() {
160+
// Get the event log recorded by firmware
161+
let event_log = event_log::get_event_log_mut().expect("Failed to get the event log");
162+
163+
if cfg!(feature = "test_disable_ra_and_accept_all") {
164+
measure_test_feature(event_log);
165+
return;
166+
}
167+
168+
get_policy_issuer_chain_and_measure(event_log);
169+
170+
// Get migration td policy from CFV and measure it into RMTR
171+
get_policy_and_measure(event_log);
172+
}
173+
162174
fn measure_test_feature(event_log: &mut [u8]) {
163175
// Measure and extend the migtd test feature to RTMR
164176
event_log::write_tagged_event_log(
@@ -171,19 +183,33 @@ fn measure_test_feature(event_log: &mut [u8]) {
171183
.expect("Failed to log migtd test feature");
172184
}
173185

186+
#[cfg(not(feature = "policy_v2"))]
187+
fn get_policy_and_measure(event_log: &mut [u8]) {
188+
// Read migration policy from CFV
189+
let policy = config::get_policy().expect("Fail to get policy from CFV\n");
190+
191+
let event_data = policy;
192+
193+
// Measure and extend the migration policy to RTMR
194+
event_log::write_tagged_event_log(
195+
event_log,
196+
MR_INDEX_POLICY,
197+
policy,
198+
TAGGED_EVENT_ID_POLICY,
199+
event_data,
200+
)
201+
.expect("Failed to log migration policy");
202+
}
203+
204+
#[cfg(feature = "policy_v2")]
174205
fn get_policy_and_measure(event_log: &mut [u8]) {
175206
// Read migration policy from CFV
176207
let policy = config::get_policy().expect("Fail to get policy from CFV\n");
177208

178-
#[cfg(feature = "policy_v2")]
179209
let version = initialize_policy();
180210

181-
#[cfg(feature = "policy_v2")]
182211
let event_data = version.as_bytes();
183212

184-
#[cfg(not(feature = "policy_v2"))]
185-
let event_data = policy;
186-
187213
// Measure and extend the migration policy to RTMR
188214
event_log::write_tagged_event_log(
189215
event_log,

0 commit comments

Comments
 (0)