Skip to content

Commit a243096

Browse files
committed
fmt
1 parent 8527c25 commit a243096

File tree

6 files changed

+57
-52
lines changed

6 files changed

+57
-52
lines changed

include/ccf/pal/attestation_sev_snp.h

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "ccf/pal/attestation_sev_snp_endorsements.h"
77
#include "ccf/pal/measurement.h"
88
#include "ccf/pal/report_data.h"
9-
#include "ccf/pal/hardware_info.h"
109

1110
#include <array>
1211
#include <map>
@@ -297,11 +296,13 @@ QPHfbkH0CyPfhl1jWhJFZasCAwEAAQ==
297296
};
298297
#pragma pack(pop)
299298
DECLARE_JSON_TYPE(CPUID);
300-
DECLARE_JSON_REQUIRED_FIELDS(CPUID, stepping, base_model, base_family, extended_model, extended_family);
299+
DECLARE_JSON_REQUIRED_FIELDS(
300+
CPUID, stepping, base_model, base_family, extended_model, extended_family);
301301
static_assert(
302302
sizeof(CPUID) == sizeof(uint32_t), "Can't cast CPUID to uint32_t");
303303

304-
union UnionedCPUID{
304+
union UnionedCPUID
305+
{
305306
uint32_t eax;
306307
CPUID cpuid;
307308
};
@@ -310,10 +311,7 @@ QPHfbkH0CyPfhl1jWhJFZasCAwEAAQ==
310311
{
311312
UnionedCPUID cpuid_eax;
312313
cpuid_eax.eax = 0;
313-
asm volatile(
314-
"cpuid"
315-
: "=a"(cpuid_eax.eax)
316-
: "a"(1));
314+
asm volatile("cpuid" : "=a"(cpuid_eax.eax) : "a"(1));
317315
return cpuid_eax.cpuid;
318316
}
319317
}
@@ -325,15 +323,13 @@ namespace ccf::kv::serialisers
325323
template <>
326324
struct BlitSerialiser<ccf::pal::snp::CPUID>
327325
{
328-
static SerialisedEntry to_serialised(
329-
const ccf::pal::snp::CPUID& chip)
326+
static SerialisedEntry to_serialised(const ccf::pal::snp::CPUID& chip)
330327
{
331328
auto hex_str = chip.hex_str();
332329
return SerialisedEntry(hex_str.begin(), hex_str.end());
333330
}
334331

335-
static ccf::pal::snp::CPUID from_serialised(
336-
const SerialisedEntry& data)
332+
static ccf::pal::snp::CPUID from_serialised(const SerialisedEntry& data)
337333
{
338334
ccf::pal::snp::CPUID ret;
339335
auto buf_ptr = reinterpret_cast<uint8_t*>(&ret);

include/ccf/service/tables/tcb_verification.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
namespace ccf
1010
{
11-
using SnpTcbVersionMap =
12-
ServiceMap<pal::snp::CPUID, pal::snp::TcbVersion>;
11+
using SnpTcbVersionMap = ServiceMap<pal::snp::CPUID, pal::snp::TcbVersion>;
1312

1413
namespace Tables
1514
{

src/node/quote.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,19 @@ namespace ccf
276276
}
277277

278278
std::optional<pal::snp::TcbVersion> min_tcb_opt = std::nullopt;
279-
279+
280280
auto h = tx.ro<SnpTcbVersionMap>(Tables::SNP_TCB_VERSIONS);
281-
// expensive but there should not be many entries in this table only one per cpu
282-
h->foreach([&min_tcb_opt, &attestation](const pal::snp::CPUID& cpuid, const pal::snp::TcbVersion& v) {
283-
if (cpuid.get_family_id() == attestation.cpuid_fam_id &&
284-
cpuid.get_model_id() == attestation.cpuid_mod_id &&
285-
cpuid.stepping == attestation.cpuid_step) {
281+
// expensive but there should not be many entries
282+
h->foreach([&min_tcb_opt, &attestation](
283+
const pal::snp::CPUID& cpuid, const pal::snp::TcbVersion& v) {
284+
if (
285+
cpuid.get_family_id() == attestation.cpuid_fam_id &&
286+
cpuid.get_model_id() == attestation.cpuid_mod_id &&
287+
cpuid.stepping == attestation.cpuid_step)
288+
{
286289
min_tcb_opt = v;
287290
return false;
288-
}
291+
}
289292
return true;
290293
});
291294

src/node/rpc/node_frontend.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,6 @@ namespace ccf
16401640
break;
16411641

16421642
InternalTablesAccess::trust_static_snp_tcb_version(ctx.tx);
1643-
16441643
}
16451644

16461645
case QuoteFormat::amd_sev_snp_v1:

src/pal/quote_generation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#pragma once
44

55
#include "ccf/crypto/hash_provider.h"
6-
#include "ds/files.h"
76
#include "ccf/pal/attestation.h"
7+
#include "ds/files.h"
88

99
#include <nlohmann/json.hpp>
1010
#include <string>

src/service/internal_tables_access.h

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -827,13 +827,14 @@ namespace ccf
827827
{
828828
auto h = tx.wo<ccf::SnpTcbVersionMap>(Tables::SNP_TCB_VERSIONS);
829829

830-
constexpr pal::snp::CPUID milan_chip_id {.stepping = 0x1,
831-
.base_model = 0x1,
832-
.base_family = 0xF,
833-
.reserved = 0,
834-
.extended_model = 0x0,
835-
.extended_family = 0x0A,
836-
.reserved2 = 0};
830+
constexpr pal::snp::CPUID milan_chip_id{
831+
.stepping = 0x1,
832+
.base_model = 0x1,
833+
.base_family = 0xF,
834+
.reserved = 0,
835+
.extended_model = 0x0,
836+
.extended_family = 0x0A,
837+
.reserved2 = 0};
837838
constexpr pal::snp::TcbVersion milan_tcb_version = {
838839
.boot_loader = 0,
839840
.tee = 0,
@@ -842,13 +843,14 @@ namespace ccf
842843
.microcode = 0xDB};
843844
h->put(milan_chip_id, milan_tcb_version);
844845

845-
constexpr pal::snp::CPUID milan_x_chip_id {.stepping = 0x2,
846-
.base_model = 0x1,
847-
.base_family = 0xF,
848-
.reserved = 0,
849-
.extended_model = 0x0,
850-
.extended_family = 0x0A,
851-
.reserved2 = 0};
846+
constexpr pal::snp::CPUID milan_x_chip_id{
847+
.stepping = 0x2,
848+
.base_model = 0x1,
849+
.base_family = 0xF,
850+
.reserved = 0,
851+
.extended_model = 0x0,
852+
.extended_family = 0x0A,
853+
.reserved2 = 0};
852854
constexpr pal::snp::TcbVersion milan_x_tcb_version = {
853855
.boot_loader = 0,
854856
.tee = 0,
@@ -857,13 +859,14 @@ namespace ccf
857859
.microcode = 0x44};
858860
h->put(milan_x_chip_id, milan_x_tcb_version);
859861

860-
constexpr pal::snp::CPUID genoa_chip_id {.stepping = 0x1,
861-
.base_model = 0x1,
862-
.base_family = 0xF,
863-
.reserved = 0,
864-
.extended_model = 0x1,
865-
.extended_family = 0x0A,
866-
.reserved2 = 0};
862+
constexpr pal::snp::CPUID genoa_chip_id{
863+
.stepping = 0x1,
864+
.base_model = 0x1,
865+
.base_family = 0xF,
866+
.reserved = 0,
867+
.extended_model = 0x1,
868+
.extended_family = 0x0A,
869+
.reserved2 = 0};
867870
constexpr pal::snp::TcbVersion genoa_tcb_version = {
868871
.boot_loader = 0,
869872
.tee = 0,
@@ -872,13 +875,14 @@ namespace ccf
872875
.microcode = 0x54};
873876
h->put(genoa_chip_id, genoa_tcb_version);
874877

875-
constexpr pal::snp::CPUID genoa_x_chip_id {.stepping = 0x2,
876-
.base_model = 0x1,
877-
.base_family = 0xF,
878-
.reserved = 0,
879-
.extended_model = 0x1,
880-
.extended_family = 0x0A,
881-
.reserved2 = 0};
878+
constexpr pal::snp::CPUID genoa_x_chip_id{
879+
.stepping = 0x2,
880+
.base_model = 0x1,
881+
.base_family = 0xF,
882+
.reserved = 0,
883+
.extended_model = 0x1,
884+
.extended_family = 0x0A,
885+
.reserved2 = 0};
882886
constexpr pal::snp::TcbVersion genoa_x_tcb_version = {
883887
.boot_loader = 0,
884888
.tee = 0,
@@ -891,7 +895,7 @@ namespace ccf
891895
static void trust_node_snp_tcb_version(
892896
ccf::kv::Tx& tx, pal::snp::Attestation& attestation)
893897
{
894-
// Fall back to statically configured tcb versions
898+
// Fall back to statically configured tcb versions
895899
auto cpuid = pal::snp::get_cpuid();
896900
if (attestation.version < pal::snp::MIN_TCB_VERIF_VERSION)
897901
{
@@ -906,7 +910,11 @@ namespace ccf
906910
cpuid->stepping != attestation.cpuid_step)
907911
{
908912
LOG_FAIL_FMT(
909-
"Snp cpuid does not match attestation cpuid ({} != {}, {}, {})", cpuid->hex_str(), attestation.cpuid_fam_id, attestation.cpuid_mod_id, attestation.cpuid_step);
913+
"Snp cpuid does not match attestation cpuid ({} != {}, {}, {})",
914+
cpuid->hex_str(),
915+
attestation.cpuid_fam_id,
916+
attestation.cpuid_mod_id,
917+
attestation.cpuid_step);
910918
trust_static_snp_tcb_version(tx);
911919
return;
912920
}

0 commit comments

Comments
 (0)