Skip to content

Commit

Permalink
CP-46264 deprecate host.bios_strings[hp-rombios] entry
Browse files Browse the repository at this point in the history
The host object maintains a map bios_strings that has an entry for the
"hp-rombios key. The value is based on a value read from dom0 memory
using /dev/mem. This is incompatible with secure boot and this patch
makes the value returned the empty string. The value is patched into a
guest's memory so we can't return anything else.

We might want to remove the key `hp-rembios` in the future.

Signed-off-by: Christian Lindig <[email protected]>
  • Loading branch information
Christian Lindig authored and lindig committed Jan 17, 2024
1 parent 954f3d3 commit d3f5af1
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions ocaml/xapi/bios_strings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -186,21 +186,13 @@ let get_oem_strings decode =
in
standard @ List.mapi convert values

(* Get the HP-specific ROMBIOS OEM string:
* 6 bytes from the memory starting at 0xfffea *)
let get_hp_rombios () =
let hp_rombios = Bytes.make 6 ' ' in
( try
let mem = Unix.openfile "/dev/mem" [Unix.O_RDONLY] 0 in
Xapi_stdext_pervasives.Pervasiveext.finally
(fun () ->
ignore (Unix.lseek mem 0xfffea Unix.SEEK_SET) ;
ignore (Unix.read mem hp_rombios 0 6)
)
(fun () -> Unix.close mem)
with _ -> ()
) ;
match Bytes.unsafe_to_string hp_rombios with "COMPAQ" -> "COMPAQ" | _ -> ""
(* CP-46264 - this used to read a string from /dev/mem but we can no
longer support this. It would either find "COMPAQ" and return it, or
return the empty string. We are now always returning the
"". The string is patched into a guest's memory - so it would not be
safe to return an arbitrary string. *)

let hp_rombios = [("hp-rombios", "")]

(* Get host bios strings *)
let get_host_bios_strings ~__context =
Expand All @@ -209,6 +201,4 @@ let get_host_bios_strings ~__context =
let system_strings = get_system_strings get_dmidecode_strings in
let baseboard_strings = get_baseboard_strings get_dmidecode_strings in
let oem_strings = get_oem_strings get_dmidecode_strings in
(* HP-specific ROMBIOS OEM string *)
let hp_rombios = [("hp-rombios", get_hp_rombios ())] in
bios_strings @ system_strings @ baseboard_strings @ oem_strings @ hp_rombios

0 comments on commit d3f5af1

Please sign in to comment.