diff --git a/misc/acrn-config/acpi_gen/acpi_const.py b/misc/acrn-config/acpi_gen/acpi_const.py index bd3de9840..fd51c8f4f 100644 --- a/misc/acrn-config/acpi_gen/acpi_const.py +++ b/misc/acrn-config/acpi_gen/acpi_const.py @@ -15,7 +15,7 @@ TEMPLATE_ACPI_PATH = os.path.join(VM_CONFIGS_PATH, 'acpi', 'template') ACPI_TABLE_LIST = [('rsdp.asl', 'rsdp.aml'), ('xsdt.asl', 'xsdt.aml'), ('facp.asl', 'facp.aml'), ('mcfg.asl', 'mcfg.aml'), ('apic.asl', 'apic.aml'), ('tpm2.asl', 'tpm2.aml'), - ('dsdt.asl', 'dsdt.aml')] + ('dsdt.asl', 'dsdt.aml'), ('PTCT', 'ptct.aml')] ACPI_BASE = 0x7ff00000 @@ -25,6 +25,7 @@ ACPI_FADT_ADDR_OFFSET = 0x100 # (244 bytes) ACPI_DSDT_ADDR_OFFSET = 0x200 # (variable) ACPI_MCFG_ADDR_OFFSET = 0x400 # (60 bytes) ACPI_MADT_ADDR_OFFSET = 0x440 # (depends on #CPUs) +ACPI_PTCT_ADDR_OFFSET = 0xF00 ACPI_TPM2_ADDR_OFFSET = 0x1100 # (52 bytes) ACPI_RSDP_ADDR = (ACPI_BASE + ACPI_RSDP_ADDR_OFFSET) @@ -34,6 +35,7 @@ ACPI_MCFG_ADDR = (ACPI_BASE + ACPI_MCFG_ADDR_OFFSET) ACPI_MADT_ADDR = (ACPI_BASE + ACPI_MADT_ADDR_OFFSET) ACPI_TPM2_ADDR = (ACPI_BASE + ACPI_TPM2_ADDR_OFFSET) ACPI_DSDT_ADDR = (ACPI_BASE + ACPI_DSDT_ADDR_OFFSET) +ACPI_PTCT_ADDR = (ACPI_BASE + ACPI_PTCT_ADDR_OFFSET) ACPI_FACS_ADDR = 0x0 PM1A_EVN_LEN = 0x4 @@ -51,3 +53,5 @@ ACPI_MADT_TYPE_LOCAL_APIC_NMI = 4 TSN_DEVICE_LIST = ['8086:4ba0', '8086:4bb0', '8086:4b32'] + +PTCT = 'PTCT' diff --git a/misc/acrn-config/acpi_gen/asl_gen.py b/misc/acrn-config/acpi_gen/asl_gen.py index 9da3b128e..4ad665ef5 100644 --- a/misc/acrn-config/acpi_gen/asl_gen.py +++ b/misc/acrn-config/acpi_gen/asl_gen.py @@ -50,6 +50,7 @@ def gen_xsdt(dest_vm_acpi_path, passthru_devices): p_mcfg_addr = r'ACPI Table Address 1 : ([0-9a-fA-F]{16})' p_madt_addr = r'ACPI Table Address 2 : ([0-9a-fA-F]{16})' p_tpm2_addr = r'ACPI Table Address 3 : ([0-9a-fA-F]{16})' + p_ptct_addr = r'ACPI Table Address 4 : ([0-9a-fA-F]{16})' with open(os.path.join(dest_vm_acpi_path, xsdt_asl), 'w') as dest: lines = [] @@ -64,6 +65,9 @@ def gen_xsdt(dest_vm_acpi_path, passthru_devices): elif re.search(p_tpm2_addr, line): if 'TPM2' in passthru_devices: lines.append(re.sub(p_tpm2_addr, 'ACPI Table Address 3 : {0:016X}'.format(ACPI_TPM2_ADDR), line)) + elif re.search(p_ptct_addr, line): + if 'PTCT' in passthru_devices: + lines.append(re.sub(p_ptct_addr, 'ACPI Table Address 4 : {0:016X}'.format(ACPI_PTCT_ADDR), line)) else: lines.append(line) @@ -454,11 +458,29 @@ def main(args): if pcpu_id is not None and pcpu_id.text.strip() in pcpu_list: dict_vcpu_list[vm_id].append(pcpu_id) + PASSTHROUGH_PTCT = False + PRELAUNCHED_RTVM_ID = None + try: + if scenario_root.find('hv/FEATURES/PSRAM/PSRAM_ENABLED').text.strip() == 'y' \ + and scenario_root.find('hv/FEATURES/PSRAM/PSRAM_PASSTHROUGH_PRE_RTVM').text.strip() == 'y': + PASSTHROUGH_PTCT = True + for vm in scenario_root.findall('vm'): + vm_id = vm.attrib['id'] + vm_type_node = vm.find('vm_type') + if (vm_type_node is not None) and (vm_type_node.text in ['PRE_RT_VM']): + PRELAUNCHED_RTVM_ID = vm_id + break + except: + PASSTHROUGH_PTCT = False + for vm_id, passthru_devices in dict_passthru_devices.items(): print('start to generate ACPI ASL code for VM{}'.format(vm_id)) dest_vm_acpi_path = os.path.join(DEST_ACPI_PATH, 'VM'+vm_id) if not os.path.isdir(dest_vm_acpi_path): os.makedirs(dest_vm_acpi_path) + if PASSTHROUGH_PTCT is True and vm_id == PRELAUNCHED_RTVM_ID: + passthru_devices.append(PTCT) + shutil.copy(os.path.join(VM_CONFIGS_PATH, 'acpi', board_type, PTCT), dest_vm_acpi_path) gen_rsdp(dest_vm_acpi_path) gen_xsdt(dest_vm_acpi_path, passthru_devices) gen_fadt(dest_vm_acpi_path, board_root) diff --git a/misc/acrn-config/acpi_gen/bin_gen.py b/misc/acrn-config/acpi_gen/bin_gen.py index e4154a173..4099b7342 100644 --- a/misc/acrn-config/acpi_gen/bin_gen.py +++ b/misc/acrn-config/acpi_gen/bin_gen.py @@ -33,6 +33,10 @@ def asl_to_aml(dest_vm_acpi_path, dest_vm_acpi_bin_path): os.remove(os.path.join(dest_vm_acpi_path, acpi_table[1])) rmsg = 'failed to compile {}'.format(acpi_table[0]) break + elif acpi_table[0] == PTCT: + if PTCT in os.listdir(dest_vm_acpi_path): + shutil.copyfile(os.path.join(dest_vm_acpi_path, acpi_table[0]), + os.path.join(dest_vm_acpi_bin_path, acpi_table[1])) else: rc = exec_command('iasl {}'.format(acpi_table[0])) if rc == 0 and os.path.isfile(os.path.join(dest_vm_acpi_path, acpi_table[1])): @@ -92,6 +96,11 @@ def aml_to_bin(dest_vm_acpi_path, dest_vm_acpi_bin_path, acpi_bin_name): with open(os.path.join(dest_vm_acpi_bin_path, ACPI_TABLE_LIST[6][1]), 'rb') as asl: acpi_bin.write(asl.read()) + if PTCT in os.listdir(dest_vm_acpi_path): + acpi_bin.seek(ACPI_PTCT_ADDR_OFFSET) + with open(os.path.join(dest_vm_acpi_bin_path, ACPI_TABLE_LIST[7][1]), 'rb') as asl: + acpi_bin.write(asl.read()) + acpi_bin.seek(0xfffff) acpi_bin.write(b'\0') shutil.move(acpi_bin_file, os.path.join(dest_vm_acpi_bin_path, '..', acpi_bin_name)) diff --git a/misc/vm_configs/acpi/template/xsdt.asl b/misc/vm_configs/acpi/template/xsdt.asl index 90e35a6a5..552cb77a7 100644 --- a/misc/vm_configs/acpi/template/xsdt.asl +++ b/misc/vm_configs/acpi/template/xsdt.asl @@ -22,3 +22,4 @@ [0008] ACPI Table Address 1 : 00000000000F2640 [0008] ACPI Table Address 2 : 00000000000F2680 [0008] ACPI Table Address 3 : 00000000000F2800 +[0008] ACPI Table Address 4 : 00000000000F3300 diff --git a/misc/vm_configs/acpi/tgl-rvp/PTCT b/misc/vm_configs/acpi/tgl-rvp/PTCT new file mode 100644 index 000000000..cd2ee449a Binary files /dev/null and b/misc/vm_configs/acpi/tgl-rvp/PTCT differ