mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-26 15:31:35 +00:00
dm: rpmb: Support RPMB mode config from launch.sh
physical RPMB is accessed if "phisycal_rpmb" is specified in launch.sh. Also it reserves some RPMB area with a fixed size(32KB) for AttKB and future usage, which is RO for UOS. Tracked-On: #1544 Signed-off-by: Huang, Yang <yang.huang@intel.com> Acked-by: Zhu Bing <bing.zhu@intel.com>
This commit is contained in:
parent
107eaa3ab0
commit
bd97e5cbe2
@ -57,6 +57,7 @@
|
|||||||
#define VIRTIO_RPMB_MAXSEGS 5
|
#define VIRTIO_RPMB_MAXSEGS 5
|
||||||
#define ADDR_NOT_PRESENT -2
|
#define ADDR_NOT_PRESENT -2
|
||||||
|
|
||||||
|
static const char PHYSICAL_RPMB_STR[] = "physical_rpmb";
|
||||||
static int virtio_rpmb_debug = 1;
|
static int virtio_rpmb_debug = 1;
|
||||||
#define DPRINTF(params) do { if (virtio_rpmb_debug) printf params; } while (0)
|
#define DPRINTF(params) do { if (virtio_rpmb_debug) printf params; } while (0)
|
||||||
#define WPRINTF(params) (printf params)
|
#define WPRINTF(params) (printf params)
|
||||||
@ -538,20 +539,14 @@ virtio_rpmb_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: keep it for self-adaption rpmb mode
|
|
||||||
/*rc = rpmb_get_counter(RPMB_PHY_MODE, key, &rpmb_counter, &rpmb_result);
|
|
||||||
if (rc) {
|
|
||||||
DPRINTF(("rpmb_get_counter failed\n"));
|
|
||||||
goto out;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
memset(key, 0, RPMB_KEY_32_LEN);
|
memset(key, 0, RPMB_KEY_32_LEN);
|
||||||
/*TODO: hardcode rpmb mode to RPMB_SIM_MODE*/
|
|
||||||
rpmb_result = RPMB_RES_GENERAL_FAILURE;
|
if (opts && !strncmp(opts, PHYSICAL_RPMB_STR, sizeof(PHYSICAL_RPMB_STR))) {
|
||||||
if (rpmb_result == RPMB_RES_OK) {
|
DPRINTF(("RPMB in physical mode!\n"));
|
||||||
rpmb_mode_init(RPMB_PHY_MODE);
|
rpmb_mode_init(RPMB_PHY_MODE);
|
||||||
rpmb_block_count = rpmb_search_size(RPMB_PHY_MODE, key, 0);
|
rpmb_block_count = rpmb_search_size(RPMB_PHY_MODE, key, 0);
|
||||||
} else {
|
} else {
|
||||||
|
DPRINTF(("RPMB in simulated mode!\n"));
|
||||||
rc = rpmb_sim_key_init(key);
|
rc = rpmb_sim_key_init(key);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
DPRINTF(("rpmb_sim_key_init failed!\n"));
|
DPRINTF(("rpmb_sim_key_init failed!\n"));
|
||||||
@ -565,7 +560,6 @@ virtio_rpmb_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rpmb_mode_init(RPMB_SIM_MODE);
|
rpmb_mode_init(RPMB_SIM_MODE);
|
||||||
|
|
||||||
rpmb_block_count = rpmb_search_size(RPMB_SIM_MODE, key, 0);
|
rpmb_block_count = rpmb_search_size(RPMB_SIM_MODE, key, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,15 +64,16 @@ static uint16_t get_rpmb_blocks(void)
|
|||||||
return rpmb_get_blocks();
|
return rpmb_get_blocks();
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: hardcode keybox size. It will be read from keybox header from RPMB.
|
/* Common area of RPMB refers to the start area of RPMB
|
||||||
|
* shared among all UOS with RO access.
|
||||||
|
* It's predefined to 32KB in size which contains:
|
||||||
|
* AttKB(up to 16KB), RPMB info header (256B)
|
||||||
|
* and the remaining size for future uasge.
|
||||||
|
*/
|
||||||
static uint16_t get_common_blocks(void)
|
static uint16_t get_common_blocks(void)
|
||||||
{
|
{
|
||||||
uint16_t kb_blocks;
|
uint16_t common_size = 32 * 1024;
|
||||||
uint32_t kb_size = 15872;
|
return common_size / RPMB_BLOCK_SIZE;
|
||||||
|
|
||||||
kb_blocks = (kb_size + (RPMB_BLOCK_SIZE -1)) / RPMB_BLOCK_SIZE;
|
|
||||||
//reserve for simulated rpmb + KBox header + padding
|
|
||||||
return kb_blocks + 1 + 1 + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t get_accessible_blocks(void)
|
static uint16_t get_accessible_blocks(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user