Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Service VM to supervisor role #8630

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions devicemodel/core/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,7 @@ vm_loop(struct vmctx *ctx)
break;
}

/* RTVM can't be reset */
if ((VM_SUSPEND_SYSTEM_RESET == vm_get_suspend_mode()) && (!is_rtvm)) {
if (VM_SUSPEND_SYSTEM_RESET == vm_get_suspend_mode()) {
vm_system_reset(ctx);
}

Expand Down
2 changes: 1 addition & 1 deletion devicemodel/core/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ static void handle_stop(struct mngr_msg *msg, int client_fd, void *param)
ack.msgid = msg->msgid;
ack.timestamp = msg->timestamp;

if (msg->data.acrnd_stop.force && !is_rtvm) {
if (msg->data.acrnd_stop.force) {
pr_info("%s: setting VM state to %s\n", __func__, vm_state_to_str(VM_SUSPEND_POWEROFF));
vm_set_suspend_mode(VM_SUSPEND_POWEROFF);
ack.data.err = 0;
Expand Down
11 changes: 4 additions & 7 deletions devicemodel/hw/pci/passthrough.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,13 +980,10 @@ passthru_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
pciaccess_cleanup();
free(ptdev);

if (!is_rtvm) {
/* Let the HV to deassign the pt device for RTVM, In this case, the RTVM
* could still be alive if DM died.
*/
vm_deassign_pcidev(ctx, &pcidev);
}
if (!is_rtvm && phys_bdf) {
/*Let device model to deassign pt device for all VMs, including RTVM if the Service VM plays
*supervisor role.*/
vm_deassign_pcidev(ctx, &pcidev);
if (phys_bdf) {
memset(reset_path, 0, sizeof(reset_path));
snprintf(reset_path, 40,
"/sys/bus/pci/devices/0000:%02x:%02x.%x/reset",
Expand Down
5 changes: 2 additions & 3 deletions hypervisor/arch/x86/guest/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1048,9 +1048,8 @@ void pause_vm(struct acrn_vm *vm)
uint16_t i;
struct acrn_vcpu *vcpu = NULL;

/* For RTVM, we can only pause its vCPUs when it is powering off by itself */
if (((!is_rt_vm(vm)) && (vm->state == VM_RUNNING)) ||
((is_rt_vm(vm)) && (vm->state == VM_READY_TO_POWEROFF)) ||
if (((is_severity_pass(vm->vm_id)) && (vm->state == VM_RUNNING)) ||
(vm->state == VM_READY_TO_POWEROFF) ||
(vm->state == VM_CREATED)) {
foreach_vcpu(i, vm, vcpu) {
zombie_vcpu(vcpu, VCPU_ZOMBIE);
Expand Down
6 changes: 1 addition & 5 deletions hypervisor/common/hypercall.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <asm/lapic.h>
#include <asm/guest/assign.h>
#include <asm/guest/ept.h>
#include <asm/guest/vm.h>
#include <asm/mmu.h>
#include <hypercall.h>
#include <errno.h>
Expand Down Expand Up @@ -69,11 +70,6 @@ bool is_hypercall_from_ring0(void)
return ret;
}

inline static bool is_severity_pass(uint16_t target_vmid)
{
return SEVERITY_SERVICE_VM >= get_vm_severity(target_vmid);
}

/**
* @brief offline vcpu from Service VM
*
Expand Down
5 changes: 5 additions & 0 deletions hypervisor/include/arch/x86/asm/guest/vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ static inline uint16_t vmid_2_rel_vmid(uint16_t service_vmid, uint16_t vmid) {
return (vmid - service_vmid);
}

static inline bool is_severity_pass(uint16_t target_vmid)
{
return SEVERITY_SERVICE_VM >= get_vm_severity(target_vmid);
}

void make_shutdown_vm_request(uint16_t pcpu_id);
bool need_shutdown_vm(uint16_t pcpu_id);
int32_t shutdown_vm(struct acrn_vm *vm);
Expand Down
2 changes: 1 addition & 1 deletion hypervisor/include/arch/x86/asm/vm_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
/* ACRN guest severity */
enum acrn_vm_severity {
SEVERITY_SAFETY_VM = 0x40U,
SEVERITY_RTVM = 0x30U,
SEVERITY_RTVM = RTVM_SEVERITY_LEVEL,
SEVERITY_SERVICE_VM = 0x20U,
SEVERITY_STANDARD_VM = 0x10U,
};
Expand Down
5 changes: 5 additions & 0 deletions misc/config_tools/schema/config.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
<xs:documentation>Enable multiboot2 protocol support (with multiboot1 downward compatibility). If multiboot1 meets your requirements, disable this feature to reduce hypervisor code size.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="SERVICE_VM_SUPERVISOR_ENABLED" type="Boolean" default="n">
<xs:annotation acrn:title="Enable Service VM supervisor role" acrn:views="advanced">
<xs:documentation>Enable Service VM to play the supervisor role. If Enabled, the severity level of Service VM is higher than RTVM.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="SPLIT_LOCK_DETECTION_ENABLED" type="Boolean" default="n">
<xs:annotation acrn:title="Enable split lock detection" acrn:views="advanced">
<xs:documentation>Enable detection of split locks. A split lock can negatively affect an application's real-time performance. If a lock is detected, an alignment check exception #AC occurs.</xs:documentation>
Expand Down
4 changes: 4 additions & 0 deletions misc/config_tools/xforms/config_common.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
<xsl:with-param name="value" select="'y'" />
</xsl:call-template>

<xsl:call-template name="boolean-by-key">
<xsl:with-param name="key" select="'SERVICE_VM_SUPERVISOR_ENABLED'" />
</xsl:call-template>

<xsl:call-template name="boolean-by-key">
<xsl:with-param name="key" select="'SPLIT_LOCK_DETECTION_ENABLED'" />
</xsl:call-template>
Expand Down
12 changes: 12 additions & 0 deletions misc/config_tools/xforms/misc_cfg.h.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<xsl:call-template name="cpu_affinity" />
<xsl:call-template name="rdt" />
<xsl:call-template name="vm0_passthrough_tpm" />
<xsl:call-template name="service_vm_super_role" />
<xsl:call-template name="vm_config_pci_dev_num" />
<xsl:call-template name="vm_boot_args" />
</xsl:template>
Expand Down Expand Up @@ -172,6 +173,17 @@
</xsl:if>
</xsl:template>

<xsl:template name="service_vm_super_role">
<xsl:choose>
<xsl:when test="//SERVICE_VM_SUPERVISOR_ENABLED = 'y'">
<xsl:value-of select="acrn:define('RTVM_SEVERITY_LEVEL', '0x10', 'U')" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="acrn:define('RTVM_SEVERITY_LEVEL', '0x30', 'U')" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="vm_config_pci_dev_num">
<xsl:for-each select="vm">
<xsl:if test="acrn:pci-dev-num(@id)">
Expand Down