diff --git a/include/libpv/macros.h b/include/libpv/macros.h index 4b9fe0fa..73c12dc8 100644 --- a/include/libpv/macros.h +++ b/include/libpv/macros.h @@ -10,7 +10,12 @@ #ifndef LIBPV_MACROS_H #define LIBPV_MACROS_H +#include + #define PV_NONNULL(...) #define DO_PRAGMA(x) _Pragma(#x) +/* Most significant bit */ +#define PV_MSB(idx) ((uint64_t)1 << (63 - (idx))) + #endif /* LIBPV_MACROS_H */ diff --git a/include/libpv/se-hdr.h b/include/libpv/se-hdr.h index 3d4219c1..f73372d5 100644 --- a/include/libpv/se-hdr.h +++ b/include/libpv/se-hdr.h @@ -15,6 +15,7 @@ #include "boot/s390.h" #include "libpv/crypto.h" +#include "libpv/macros.h" /* Magic number which is used to identify the file containing the PV * header @@ -22,20 +23,17 @@ #define PV_MAGIC_NUMBER 0x49424d5365634578ULL #define PV_VERSION_1 0x00000100U -/* Internal helper macro */ -#define __PV_BIT(nr) (1ULL << (63 - (nr))) - /* Plaintext control flags */ /* dumping of the configuration is allowed */ -#define PV_PCF_ALLOW_DUMPING __PV_BIT(34) +#define PV_PCF_ALLOW_DUMPING PV_MSB(34) /* prevent Ultravisor decryption during unpack operation */ -#define PV_PCF_NO_DECRYPTION __PV_BIT(35) +#define PV_PCF_NO_DECRYPTION PV_MSB(35) /* PCKMO encrypt-DEA/TDEA-key functions allowed */ -#define PV_PCF_PCKMO_DEA_TDEA __PV_BIT(56) +#define PV_PCF_PCKMO_DEA_TDEA PV_MSB(56) /* PCKMO encrypt-AES-key functions allowed */ -#define PV_PCF_PCKMO_AES __PV_BIT(57) +#define PV_PCF_PCKMO_AES PV_MSB(57) /* PCKMO encrypt-ECC-key functions allowed */ -#define PV_PCF_PCKM_ECC __PV_BIT(58) +#define PV_PCF_PCKM_ECC PV_MSB(58) /* maxima for the PV version 1 */ #define PV_V1_IPIB_MAX_SIZE PAGE_SIZE diff --git a/pvattest/src/arcb.h b/pvattest/src/arcb.h index b444011b..6791da33 100644 --- a/pvattest/src/arcb.h +++ b/pvattest/src/arcb.h @@ -15,6 +15,7 @@ #include "lib/zt_common.h" #include "libpv/crypto.h" +#include "libpv/macros.h" #include "types.h" @@ -28,18 +29,17 @@ #define ARCB_V1_IV_SIZE 12 #define ARCB_V1_PHKH_SIZE 32 -#define BIT(bit) ((uint64_t)1 << (63 - (bit))) /* Optional nonce in ARCB */ -#define ARCB_V1_PAF_NONCE BIT(1) +#define ARCB_V1_PAF_NONCE PV_MSB(1) /* Public host key hash used to unseal SE header added to additional data to be measured */ -#define ARCB_V1_PAF_AAD_PHKH_HEADER BIT(2) +#define ARCB_V1_PAF_AAD_PHKH_HEADER PV_MSB(2) /* Public host key hash used to unseal this attestation added to additional data to be measured */ -#define ARCB_V1_PAF_AAD_PHKH_ATTEST BIT(3) +#define ARCB_V1_PAF_AAD_PHKH_ATTEST PV_MSB(3) /* Temporary backup-host-key use allowed */ -#define ARCB_V1_PAF_TMP_BACKUP_ALLOWED BIT(62) +#define ARCB_V1_PAF_TMP_BACKUP_ALLOWED PV_MSB(62) /* Global not-host-specific key allowed */ -#define ARCB_V1_PAF_GLOBAL_NHS_KEY_ALLOWED BIT(63) +#define ARCB_V1_PAF_GLOBAL_NHS_KEY_ALLOWED PV_MSB(63) #define ARCB_V1_PAF_ALL \ (ARCB_V1_PAF_NONCE | ARCB_V1_PAF_AAD_PHKH_HEADER | ARCB_V1_PAF_AAD_PHKH_ATTEST | \