static u64 rmp_cfg;
+static void *rmp_bookkeeping __ro_after_init;
+
/* Mask to apply to a PFN to get the first PFN of a 2MB page */
#define PFN_PMD_MASK GENMASK_ULL(63, PMD_SHIFT - PAGE_SHIFT)
}
}
-static bool __init clear_rmptable_bookkeeping(void)
-{
- void *bk;
-
- bk = memremap(probed_rmp_base, RMPTABLE_CPU_BOOKKEEPING_SZ, MEMREMAP_WB);
- if (!bk) {
- pr_err("Failed to map RMP bookkeeping area\n");
- return false;
- }
-
- memset(bk, 0, RMPTABLE_CPU_BOOKKEEPING_SZ);
-
- memunmap(bk);
-
- return true;
-}
-
static bool __init alloc_rmp_segment_desc(u64 segment_pa, u64 segment_size, u64 pa)
{
u64 rst_index, rmp_segment_size_max;
static bool __init setup_rmptable(void)
{
if (rmp_cfg & MSR_AMD64_SEG_RMP_ENABLED) {
- return setup_segmented_rmptable();
+ if (!setup_segmented_rmptable())
+ return false;
} else {
- return setup_contiguous_rmptable();
+ if (!setup_contiguous_rmptable())
+ return false;
}
+
+ rmp_bookkeeping = memremap(probed_rmp_base, RMPTABLE_CPU_BOOKKEEPING_SZ, MEMREMAP_WB);
+ if (!rmp_bookkeeping) {
+ pr_err("Failed to map RMP bookkeeping area\n");
+ free_rmp_segment_table();
+
+ return false;
+ }
+
+ return true;
}
/*
goto skip_enable;
/* Zero out the RMP bookkeeping area */
- if (!clear_rmptable_bookkeeping()) {
- free_rmp_segment_table();
- return -ENOSYS;
- }
+ memset(rmp_bookkeeping, 0, RMPTABLE_CPU_BOOKKEEPING_SZ);
/* Zero out the RMP entries */
for (i = 0; i < rst_max_index; i++) {