mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-25 15:02:13 +00:00
hv: fixup: a minor refine about tpm2_fixup
Check the return value of get_mod_by_tag before use it. Tracked-On: #6380 Signed-off-by: Fei Li <fei1.li@intel.com>
This commit is contained in:
parent
e5aa63b08e
commit
7dd877f8eb
@ -39,44 +39,48 @@ static void tpm2_fixup(uint16_t vm_id)
|
||||
struct abi_module *mod;
|
||||
|
||||
mod = get_mod_by_tag(abi, config->acpi_config.acpi_mod_tag);
|
||||
if (mod != NULL) {
|
||||
tpm2 = get_acpi_mod_entry(ACPI_SIG_TPM2, mod->start);
|
||||
native = get_acpi_tbl(ACPI_SIG_TPM2);
|
||||
|
||||
tpm2 = get_acpi_mod_entry(ACPI_SIG_TPM2, mod->start);
|
||||
native = get_acpi_tbl(ACPI_SIG_TPM2);
|
||||
if (config->pt_tpm2) {
|
||||
if ((tpm2 != NULL) && (native != NULL)) {
|
||||
/* Native has different start method */
|
||||
need_fix = tpm2->start_method != native->start_method;
|
||||
|
||||
if (config->pt_tpm2) {
|
||||
if ((tpm2 != NULL) && (native != NULL)) {
|
||||
/* Native has different start method */
|
||||
need_fix = tpm2->start_method != native->start_method;
|
||||
/* Native has event log */
|
||||
if (native->header.length ==
|
||||
sizeof(struct acpi_table_tpm2)) {
|
||||
need_fix |= tpm2->header.length == 0x34U;
|
||||
need_fix |= strncmp((char *)tpm2->start_method_spec_para,
|
||||
(char *)native->start_method_spec_para,
|
||||
sizeof(tpm2->start_method_spec_para)) != 0;
|
||||
need_fix |= tpm2->laml != native->laml;
|
||||
need_fix |= tpm2->lasa != native->lasa;
|
||||
}
|
||||
|
||||
/* Native has event log */
|
||||
if (native->header.length ==
|
||||
sizeof(struct acpi_table_tpm2)) {
|
||||
need_fix |= tpm2->header.length == 0x34U;
|
||||
need_fix |= strncmp((char *)tpm2->start_method_spec_para, (char *)native->start_method_spec_para,
|
||||
sizeof(tpm2->start_method_spec_para)) != 0;
|
||||
need_fix |= tpm2->laml != native->laml;
|
||||
need_fix |= tpm2->lasa != native->lasa;
|
||||
if (need_fix) {
|
||||
pr_err("%s tpm2 fix start method and event log field", __FUNCTION__);
|
||||
tpm2->start_method = native->start_method;
|
||||
tpm2->header.length = native->header.length;
|
||||
tpm2->header.revision = native->header.revision;
|
||||
memcpy_s(&tpm2->start_method_spec_para,
|
||||
sizeof(native->start_method_spec_para),
|
||||
&native->start_method_spec_para,
|
||||
sizeof(native->start_method_spec_para));
|
||||
tpm2->laml = native->laml;
|
||||
tpm2->lasa = config->mmiodevs[0].mmiores[1].base_gpa;
|
||||
|
||||
tpm2->header.checksum = 0;
|
||||
checksum = calculate_checksum8(tpm2, sizeof(struct acpi_table_tpm2));
|
||||
tpm2->header.checksum = checksum;
|
||||
|
||||
config->mmiodevs[0].mmiores[1].base_hpa = native->lasa;
|
||||
config->mmiodevs[0].mmiores[1].size = tpm2->laml;
|
||||
}
|
||||
} else {
|
||||
pr_err("VM or native can't find TPM2 ACPI table");
|
||||
}
|
||||
|
||||
if (need_fix) {
|
||||
pr_err("%s tpm2 fix start method and event log field", __FUNCTION__);
|
||||
tpm2->start_method = native->start_method;
|
||||
tpm2->header.length = native->header.length;
|
||||
tpm2->header.revision = native->header.revision;
|
||||
memcpy_s(&native->start_method_spec_para, sizeof(native->start_method_spec_para),
|
||||
&tpm2->start_method_spec_para, sizeof(native->start_method_spec_para));
|
||||
tpm2->laml = native->laml;
|
||||
tpm2->lasa = config->mmiodevs[0].mmiores[1].base_gpa;
|
||||
|
||||
tpm2->header.checksum = 0;
|
||||
checksum = calculate_checksum8(tpm2, sizeof(struct acpi_table_tpm2));
|
||||
tpm2->header.checksum = checksum;
|
||||
|
||||
config->mmiodevs[0].mmiores[1].base_hpa = native->lasa;
|
||||
config->mmiodevs[0].mmiores[1].size = tpm2->laml;
|
||||
}
|
||||
} else {
|
||||
pr_err("VM or native can't find TPM2 ACPI table");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user