Skip to content

Commit

Permalink
Support CoVE local attestation by reserving memory in the kernel imag…
Browse files Browse the repository at this point in the history
…e for TVM Attestation

Payload (TAP). Pass the physical address of the TAP when requesting to be promoted to a
TVM.

Signed-off-by: Wojciech Ozga <woz@zurich.ibm.com>
  • Loading branch information
wojciechozga committed Oct 7, 2024
1 parent c1fffab commit 998239d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion arch/riscv/cove/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <asm/cove.h>
#include <linux/mm.h>

extern char __cove_tap_start[];

static bool is_tvm;

bool is_cove_guest(void)
Expand Down Expand Up @@ -47,7 +49,7 @@ int promote_to_cove_guest()

if (strstr(boot_command_line, "promote_to_cove_guest")) {
ret = sbi_ecall(SBI_EXT_COVH, SBI_EXT_COVH_PROMOTE_TO_TVM, dtb_early_pa,
0, 0, 0, 0, 0);
__pa(__cove_tap_start), 0, 0, 0, 0);
if (ret.error) {
rc = sbi_err_map_linux_errno(ret.error);
goto done;
Expand Down
11 changes: 11 additions & 0 deletions arch/riscv/kernel/vmlinux-xip.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ SECTIONS
}
_exiprom = .; /* End of XIP ROM area */

#ifdef CONFIG_RISCV_COVE_GUEST
. = ALIGN(4096);
.cove_tvm_attestation_payload : {
__cove_tap_start = .;
LONG(0xace0ace0)
SHORT(0x0FFA)
FILL(0x00)
. += 4090;
__cove_tap_end = .;
}
#endif

/*
* From this point, stuff is considered writable and will be copied to RAM
Expand Down
12 changes: 12 additions & 0 deletions arch/riscv/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ SECTIONS
}
__init_end = .;

#ifdef CONFIG_RISCV_COVE_GUEST
. = ALIGN(4096);
.cove_tvm_attestation_payload : {
__cove_tap_start = .;
LONG(0xace0ace0)
SHORT(0x0FFA)
FILL(0x00)
. += 4090;
__cove_tap_end = .;
}
#endif

/* Start of data section */
_sdata = .;
RO_DATA(SECTION_ALIGN)
Expand Down
2 changes: 2 additions & 0 deletions drivers/of/fdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,7 @@ int __init early_init_dt_scan_chosen(char *cmdline)
early_init_dt_check_for_initrd(node);
early_init_dt_check_for_elfcorehdr(node);

#ifndef CONFIG_RISCV_COVE_GUEST
rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l);
if (rng_seed && l > 0) {
add_bootloader_randomness(rng_seed, l);
Expand All @@ -1178,6 +1179,7 @@ int __init early_init_dt_scan_chosen(char *cmdline)
of_fdt_crc32 = crc32_be(~0, initial_boot_params,
fdt_totalsize(initial_boot_params));
}
#endif

/* Retrieve command line */
p = of_get_flat_dt_prop(node, "bootargs", &l);
Expand Down

0 comments on commit 998239d

Please sign in to comment.