mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-02 17:34:27 +00:00
hv: initial host reset implementation
- add the GUEST_FLAG_HIGHEST_SEVERITY flag to indicate that the guest has privilege to reboot the host system. - this flag is statically assigned to guest(s) in vm_configurations.c in different scenarios. - implement reset_host() function to reset the host. First try the ACPI reset register if available, then try the 0xcf9 PIO. Tracked-On: #3145 Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com> Signed-off-by: Zide Chen <zide.chen@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
committed by
ACRN System Integration
parent
321e4f1300
commit
5a23f7b664
@@ -111,6 +111,16 @@ bool is_rt_vm(const struct acrn_vm *vm)
|
||||
return ((vm_config->guest_flags & GUEST_FLAG_RT) != 0U);
|
||||
}
|
||||
|
||||
/**
|
||||
* @pre vm != NULL && vm_config != NULL && vm->vmid < CONFIG_MAX_VM_NUM
|
||||
*/
|
||||
bool is_highest_severity_vm(const struct acrn_vm *vm)
|
||||
{
|
||||
struct acrn_vm_config *vm_config = get_vm_config(vm->vm_id);
|
||||
|
||||
return ((vm_config->guest_flags & GUEST_FLAG_HIGHEST_SEVERITY) != 0U);
|
||||
}
|
||||
|
||||
/**
|
||||
* @pre vm != NULL && vm_config != NULL && vm->vmid < CONFIG_MAX_VM_NUM
|
||||
*/
|
||||
|
@@ -78,6 +78,45 @@ void triple_fault_shutdown_vm(struct acrn_vm *vm)
|
||||
}
|
||||
}
|
||||
|
||||
static void reset_host(void)
|
||||
{
|
||||
struct acpi_generic_address *gas = &(host_reset_reg.reg);
|
||||
|
||||
|
||||
/* TODO: gracefully shut down all guests before doing host reset. */
|
||||
|
||||
/*
|
||||
* UEFI more likely sets the reset value as 0x6 (not 0xe) for 0xcf9 port.
|
||||
* This asserts PLTRST# to reset devices on the platform, but not the
|
||||
* SLP_S3#/4#/5# signals, which power down the systems. This might not be
|
||||
* enough for us.
|
||||
*/
|
||||
if ((gas->space_id == SPACE_SYSTEM_IO) &&
|
||||
(gas->bit_width == 8U) && (gas->bit_offset == 0U) &&
|
||||
(gas->address != 0U) && (gas->address != 0xcf9U)) {
|
||||
pio_write8(host_reset_reg.val, (uint16_t)host_reset_reg.reg.address);
|
||||
}
|
||||
|
||||
/*
|
||||
* Fall back
|
||||
* making sure bit 2 (RST_CPU) is '0', when the reset command is issued.
|
||||
*/
|
||||
pio_write8(0x2U, 0xcf9U);
|
||||
pio_write8(0xeU, 0xcf9U);
|
||||
|
||||
/*
|
||||
* Fall back
|
||||
* keyboard controller might cause the INIT# being asserted,
|
||||
* and not power cycle the system.
|
||||
*/
|
||||
pio_write8(0xfeU, 0x64U);
|
||||
|
||||
pr_fatal("%s(): can't reset host.", __func__);
|
||||
while (1) {
|
||||
asm_pause();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @pre vcpu != NULL && vm != NULL
|
||||
*/
|
||||
@@ -108,7 +147,11 @@ static bool handle_common_reset_reg_write(struct acrn_vm *vm, bool reset)
|
||||
{
|
||||
bool ret = true;
|
||||
|
||||
if (is_postlaunched_vm(vm)) {
|
||||
if (is_highest_severity_vm(vm)) {
|
||||
if (reset) {
|
||||
reset_host();
|
||||
}
|
||||
} else if (is_postlaunched_vm(vm)) {
|
||||
/* re-inject to DM */
|
||||
ret = false;
|
||||
|
||||
@@ -155,7 +198,11 @@ static bool handle_reset_reg_write(__unused struct acrn_vm *vm, uint16_t addr, s
|
||||
{
|
||||
if (bytes == 1U) {
|
||||
if (val == host_reset_reg.val) {
|
||||
/* ignore reset request */
|
||||
if (is_highest_severity_vm(vm)) {
|
||||
reset_host();
|
||||
} else {
|
||||
/* ignore reset request */
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* ACPI defines the reset value but doesn't specify the meaning of other values.
|
||||
|
Reference in New Issue
Block a user