dm: get lapic id from madt

The GET_PLATFORM_INFO will be removed from hypervisor. The acrn-dm can
only refer to Service VM's resources from now, all the resources out of
Service VM are not awared by acrn-dm. The original info got from
GET_PLATFORM_INFO needs to changed to Service VM's perspective like lapic id.

The pcpu_id is the index of lapic instance in MADT table. This patch
parses the Service VM's MADT table to convert the pcpu_id to lapic_id instead
of GET_PLATFORM_INFO.

Tracked-On: #6690
Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@linux.intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
Yuanyuan Zhao
2021-10-27 20:41:28 +08:00
committed by acrnsi-robot
parent 6d49f0f26a
commit c5537ec4d4
6 changed files with 194 additions and 8 deletions

View File

@@ -41,6 +41,11 @@
#define IO_PMTMR 0x0 /* PM Timer is disabled in ACPI */
#define ACPI_MADT_TYPE_LOCAL_APIC 0U
#define ACPI_MADT_TYPE_IOAPIC 1U
#define ACPI_MADT_ENABLED 1U
#define ACPI_MADT_TYPE_LOCAL_APIC_NMI 4U
struct acpi_table_hdr {
/* ASCII table signature */
char signature[4];
@@ -62,6 +67,29 @@ struct acpi_table_hdr {
uint32_t asl_compiler_revision;
} __attribute__((packed));
struct acpi_table_madt {
/* Common ACPI table header */
struct acpi_table_hdr header;
/* Physical address of local APIC */
uint32_t address;
uint32_t flags;
} __packed;
struct acpi_subtable_header {
uint8_t type;
uint8_t length;
} __packed;
struct acpi_madt_local_apic {
struct acpi_subtable_header header;
/* ACPI processor id */
uint8_t processor_id;
/* Processor's local APIC id */
uint8_t id;
uint32_t lapic_flags;
} __packed;
/* All dynamic table entry no. */
#define NHLT_ENTRY_NO 8
@@ -89,6 +117,8 @@ void power_button_init(struct vmctx *ctx);
void power_button_deinit(struct vmctx *ctx);
int pcpuid_from_vcpuid(uint64_t guest_pcpu_bitmask, int vcpu_id);
int lapicid_from_pcpuid(struct acrn_platform_info *plat_info, int pcpu_id);
int lapicid_from_pcpuid(int pcpu_id);
int lapic_to_pcpu(int lapic);
int parse_madt(void);
#endif /* _ACPI_H_ */