hv: add ACPI support for pre-launched VMs

Statically define the per vm RSDP/XSDT/MADT ACPI template tables in vacpi.c,
RSDP/XSDT tables are copied to guest physical memory after checksum is
calculated. For MADT table, first fix up process id/lapic id in its lapic
subtable, then the MADT table's checksum is calculated before it is copies to
guest physical memory.

Add 8-bit checksum function in util.h

Tracked-On: #3601
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
dongshen
2019-08-21 19:37:33 -07:00
committed by wenlingz
parent 96b422ce9d
commit b447ce3d86
7 changed files with 191 additions and 4 deletions

View File

@@ -0,0 +1,63 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/************************************************************************
*
* FILE NAME
*
* vacpi.h
*
* DESCRIPTION
*
* This file defines API and extern variable for virtual ACPI
*
************************************************************************/
/**********************************/
/* EXTERNAL VARIABLES */
/**********************************/
#ifndef VACPI_H
#define VACPI_H
#include <acpi.h>
/*
*
* Create the minimal set of ACPI tables required to boot pre-launched VM
*
* The tables are placed in the guest's ROM area just below 1MB physical,
* above the MPTable.
*
* Layout
* ------
* RSDP -> 0xf2400 (36 bytes fixed)
* XSDT -> 0xf2480 (36 bytes + 8*7 table addrs, 4 used)
* MADT -> 0xf2500 (depends on #CPUs)
*/
#define ACPI_BASE 0xf2400U
#define ACPI_RSDP_ADDR (ACPI_BASE + 0x0U)
#define ACPI_XSDT_ADDR (ACPI_BASE + 0x080U)
#define ACPI_MADT_ADDR (ACPI_BASE + 0x100U)
#define ACPI_OEM_ID "ACRN "
#define ACPI_ASL_COMPILER_ID "INTL"
#define ACPI_ASL_COMPILER_VERSION 0x20190802U
struct acpi_table_info {
struct acpi_table_rsdp rsdp;
struct acpi_table_xsdt xsdt;
struct {
struct acpi_table_madt madt;
struct acpi_madt_local_apic_nmi lapic_nmi;
struct acpi_madt_local_apic lapic_array[CONFIG_MAX_PCPU_NUM];
} __packed;
};
void build_vacpi(struct acrn_vm *vm);
#endif /* VACPI_H */