From 14a3abcce0dfebf8c0c65fafd83c412a34e01752 Mon Sep 17 00:00:00 2001 From: dongshen Date: Wed, 9 Sep 2020 13:05:45 -0700 Subject: [PATCH] acrn-config: always generate pt_tpm2 boilerplate code in vm_configurations.c so that vm_configurations.h/vm_configurations.c are consistent for different boards The boilerplate code is protected by #ifdef VM0_PASSTHROUGH_TPM/#endif, so it will not hurt if we always produce related code. Define a new macro VM0_TPM_BUFFER_BASE_ADDR_GPA to define the allocated gpa for VM0_TPM_BUFFER_BASE_ADDR to make the code more flexible. Tracked-On: #5229 Signed-off-by: dongshen --- misc/acrn-config/board_config/misc_cfg_h.py | 2 ++ misc/acrn-config/scenario_config/vm_configurations_c.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/misc/acrn-config/board_config/misc_cfg_h.py b/misc/acrn-config/board_config/misc_cfg_h.py index 4aa3f09b8..589a66b98 100644 --- a/misc/acrn-config/board_config/misc_cfg_h.py +++ b/misc/acrn-config/board_config/misc_cfg_h.py @@ -391,6 +391,8 @@ def generate_file(config): if vm0_pre_launch and board_cfg_lib.is_tpm_passthru(): print("#define VM0_PASSTHROUGH_TPM", file=config) print("#define VM0_TPM_BUFFER_BASE_ADDR 0xFED40000UL", file=config) + gpa = common.hpa2gpa(0, 0xFED40000, 0x5000) + print("#define VM0_TPM_BUFFER_BASE_ADDR_GPA 0x{:X}UL".format(gpa), file=config) print("#define VM0_TPM_BUFFER_SIZE 0x5000UL", file=config) print("", file=config) diff --git a/misc/acrn-config/scenario_config/vm_configurations_c.py b/misc/acrn-config/scenario_config/vm_configurations_c.py index a7903c25b..57bd824d2 100644 --- a/misc/acrn-config/scenario_config/vm_configurations_c.py +++ b/misc/acrn-config/scenario_config/vm_configurations_c.py @@ -327,11 +327,11 @@ def gen_pre_launch_vm(vm_type, vm_i, scenario_items, config): print("\t\t.pci_dev_num = VM{}_CONFIG_PCI_DEV_NUM,".format(vm_i), file=config) print("\t\t.pci_devs = vm{}_pci_devs,".format(vm_i), file=config) - if vm_i == 0 and board_cfg_lib.is_tpm_passthru(): + if vm_i == 0: print("#ifdef VM0_PASSTHROUGH_TPM", file=config) print("\t\t.pt_tpm2 = true,", file=config) print("\t\t.mmiodevs[0] = {", file=config) - print("\t\t\t.base_gpa = 0xFED40000UL,", file=config) + print("\t\t\t.base_gpa = VM0_TPM_BUFFER_BASE_ADDR_GPA,", file=config) print("\t\t\t.base_hpa = VM0_TPM_BUFFER_BASE_ADDR,", file=config) print("\t\t\t.size = VM0_TPM_BUFFER_SIZE,", file=config) print("\t\t},", file=config)