misc: sanity check VM config for nested virtualization

- SOS does not allow LAPIC passthru unless nested virtualization is
  enabled on SOS.

- Currently nested virtualization requires LAPIC passthru, so if
  GUEST_FLAG_VMX_ENABLED is set, GUEST_FLAG_LAPIC_PASSTHROUGH must be
  set in same VM.

- Per VM GUEST_FLAG_VMX_ENABLED can be set only if CONFIG_VMX_ENABLED
  is set.

Tracked-On: #5923
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
This commit is contained in:
Zide Chen 2021-03-26 23:25:42 -07:00 committed by wenlingz
parent d013801daa
commit 873ed752d4
3 changed files with 17 additions and 3 deletions

View File

@ -60,6 +60,11 @@
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:assert test="count(guest_flag[text() = 'GUEST_FLAG_NVMX_ENABLED']) = 0 or count(guest_flag[text() = 'GUEST_FLAG_LAPIC_PASSTHROUGH']) > 0">
<xs:annotation>
<xs:documentation>If the GUEST_FLAG_NVMX_ENABLED is set, GUEST_FLAG_LAPIC_PASSTHROUGH must be set as well.</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:complexType>
<xs:complexType name="CPUAffinityConfiguration">

View File

@ -422,6 +422,12 @@ its ``id`` attribute. When it is enabled, specify which target VM's vUART the cu
<xs:element name="board_private" type="BoardPrivateConfiguration" minOccurs="0" />
</xs:all>
<xs:attribute name="id" type="xs:integer" />
<xs:assert test="vm_type != 'SOS_VM' or count(guest_flags[guest_flag = 'GUEST_FLAG_LAPIC_PASSTHROUGH']) = 0 or count(guest_flags[guest_flag = 'GUEST_FLAG_NVMX_ENABLED']) > 0">
<xs:annotation>
<xs:documentation>SOS cannot use LAPIC passthrough unless GUEST_FLAG_NVMX_ENABLED is set.</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:complexType>
<xs:complexType name="ACRNConfigType">
@ -445,6 +451,12 @@ to launch post-launched User VMs.</xs:documentation>
</xs:all>
<xs:attribute name="board" type="xs:string" use="required" />
<xs:attribute name="scenario" type="xs:string" use="required" />
<xs:assert test="count(//guest_flag[text() = 'GUEST_FLAG_NVMX_ENABLED']) = 0 or //NVMX_ENABLED = 'y'">
<xs:annotation>
<xs:documentation>Per VM GUEST_FLAG_NVMX_ENABLED can be set only if CONFIG_NVMX_ENABLED is set.</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:complexType>
<xs:element name="acrn-config" type="ACRNConfigType" />

View File

@ -140,9 +140,6 @@ bool sanitize_vm_config(void)
}
break;
case SOS_VM:
if ((vm_config->severity != (uint8_t)SEVERITY_SOS) || ((vm_config->guest_flags & GUEST_FLAG_LAPIC_PASSTHROUGH) != 0U)) {
ret = false;
}
break;
case POST_LAUNCHED_VM:
if ((vm_config->severity == (uint8_t)SEVERITY_SAFETY_VM) || (vm_config->severity == (uint8_t)SEVERITY_SOS)) {