Date   

Re: [RFC PATCH v2 1/2] hv: pci: use ECAM to access PCIe Configuration Space

Eddie Dong
 

With this patch, we removed support of legacy PIO based configuration space access. Did we test on all platforms we support?
Another way is to define 2 libraries: one with PIO, another one with MMIO.
I am fine with either choices as if we tested.

Thx Eddie

-----Original Message-----
From: Li, Fei1 <fei1.li@...>
Sent: Friday, December 6, 2019 11:26 PM
To: acrn-dev@...
Cc: Dong, Eddie <eddie.dong@...>; Zhang, Dongsheng X
<dongsheng.x.zhang@...>
Subject: [RFC PATCH v2 1/2] hv: pci: use ECAM to access PCIe Configuration
Space

Use Enhanced Configuration Access Mechanism (MMIO) instead of
PCI-compatible Configuration Mechanism (IO port) to access PCIe
Configuration Space

Tracked-On: #3475
Signed-off-by: Li Fei1 <fei1.li@...>
---
hypervisor/hw/pci.c | 50 ++++++++++++++++++++++++++-------------------
1 file changed, 29 insertions(+), 21 deletions(-)

diff --git a/hypervisor/hw/pci.c b/hypervisor/hw/pci.c index
ea301338..4bc230cd 100644
--- a/hypervisor/hw/pci.c
+++ b/hypervisor/hw/pci.c
@@ -34,6 +34,7 @@
#include <types.h>
#include <spinlock.h>
#include <io.h>
+#include <pgtable.h>
#include <pci.h>
#include <uart16550.h>
#include <logmsg.h>
@@ -86,67 +87,74 @@ uint32_t pci_lookup_drhd_for_pbdf(uint16_t pbdf)
return drhd_index;
}

-static uint32_t pci_pdev_calc_address(union pci_bdf bdf, uint32_t offset)
+/*
+ * @pre offset < 0x1000U
+ */
+static inline uint32_t pci_pdev_calc_address(union pci_bdf bdf,
+uint32_t offset)
{
- uint32_t addr = (uint32_t)bdf.value;
-
- addr <<= 8U;
- addr |= (offset | PCI_CFG_ENABLE);
- return addr;
+ return pci_mmcfg_base + (((uint32_t)bdf.value << 12U) | offset);
}

+/*
+ * @pre bytes == 1U || bytes == 2U || bytes == 4U */
uint32_t pci_pdev_read_cfg(union pci_bdf bdf, uint32_t offset, uint32_t
bytes) {
uint32_t addr;
uint32_t val;
+ void *mmcfg_base_hva;

addr = pci_pdev_calc_address(bdf, offset);
+ mmcfg_base_hva = hpa2hva(addr);

spinlock_obtain(&pci_device_lock);
+ stac();

- /* Write address to ADDRESS register */
- pio_write32(addr, (uint16_t)PCI_CONFIG_ADDR);
-
- /* Read result from DATA register */
switch (bytes) {
case 1U:
- val = (uint32_t)pio_read8((uint16_t)PCI_CONFIG_DATA +
((uint16_t)offset & 3U));
+ val = (uint32_t)mmio_read8(mmcfg_base_hva);
break;
case 2U:
- val = (uint32_t)pio_read16((uint16_t)PCI_CONFIG_DATA +
((uint16_t)offset & 2U));
+ val = (uint32_t)mmio_read16(mmcfg_base_hva);
break;
default:
- val = pio_read32((uint16_t)PCI_CONFIG_DATA);
+ val = mmio_read32(mmcfg_base_hva);
break;
}
+
+ clac();
spinlock_release(&pci_device_lock);

return val;
}

+/*
+ * @pre bytes == 1U || bytes == 2U || bytes == 4U */
void pci_pdev_write_cfg(union pci_bdf bdf, uint32_t offset, uint32_t bytes,
uint32_t val) {
uint32_t addr;
-
- spinlock_obtain(&pci_device_lock);
+ void *mmcfg_base_hva;

addr = pci_pdev_calc_address(bdf, offset);
+ mmcfg_base_hva = hpa2hva(addr);

- /* Write address to ADDRESS register */
- pio_write32(addr, (uint16_t)PCI_CONFIG_ADDR);
+ spinlock_obtain(&pci_device_lock);
+ stac();

- /* Write value to DATA register */
switch (bytes) {
case 1U:
- pio_write8((uint8_t)val, (uint16_t)PCI_CONFIG_DATA +
((uint16_t)offset & 3U));
+ mmio_write8((uint8_t)val, mmcfg_base_hva);
break;
case 2U:
- pio_write16((uint16_t)val, (uint16_t)PCI_CONFIG_DATA +
((uint16_t)offset & 2U));
+ mmio_write16((uint16_t)val, mmcfg_base_hva);
break;
default:
- pio_write32(val, (uint16_t)PCI_CONFIG_DATA);
+ mmio_write32(val, mmcfg_base_hva);
break;
}
+
+ clac();
spinlock_release(&pci_device_lock);
}

--
2.17.1


Re: [PATCH] HV: expose port 0x64 read for SOS VM

Eddie Dong
 

Fine to go PR...

-----Original Message-----
From: acrn-dev@... <acrn-dev@...> On
Behalf Of Victor Sun
Sent: Friday, December 6, 2019 10:12 PM
To: acrn-dev@...
Subject: [acrn-dev] [PATCH] HV: expose port 0x64 read for SOS VM

The port 0x64 is the status register of i8042 keyboard controller. When
i8042 is defined as ACPI PnP device in BIOS, enforce returning 0xff in read
handler would cause infinite loop when booting SOS VM, so expose the
physical port read in this case;

Signed-off-by: Victor Sun <victor.sun@...>
---
hypervisor/arch/x86/guest/vm_reset.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/hypervisor/arch/x86/guest/vm_reset.c
b/hypervisor/arch/x86/guest/vm_reset.c
index 8730419..47e9f64 100644
--- a/hypervisor/arch/x86/guest/vm_reset.c
+++ b/hypervisor/arch/x86/guest/vm_reset.c
@@ -66,7 +66,6 @@ static bool handle_reset_reg_read(struct acrn_vcpu
*vcpu, __unused uint16_t addr
ret = false;
} else {
/*
- * - keyboard control/status register 0x64: ACRN doesn't expose
kbd controller to the guest.
* - reset control register 0xcf9: hide this from guests for now.
* - FADT reset register: the read behavior is not defined in spec,
keep it simple to return all '1'.
*/
@@ -114,6 +113,19 @@ static bool handle_kb_write(struct acrn_vcpu *vcpu,
__unused uint16_t addr, size
return handle_common_reset_reg_write(vcpu->vm, ((bytes == 1U) &&
(val == 0xfeU))); }

+static bool handle_kb_read(struct acrn_vcpu *vcpu, uint16_t addr,
+size_t bytes) {
+ if (is_sos_vm(vcpu->vm) && (bytes == 1U)) {
+ /* In case i8042 is defined as ACPI PNP device in BIOS, HV need
expose physical 0x64 port. */
+ vcpu->req.reqs.pio.value = pio_read8(addr);
+ } else {
+ /* ACRN will not expose kbd controller to the guest in this case. */
+ vcpu->req.reqs.pio.value = ~0U;
+ }
+ return true;
+}
+
+
/*
* Reset Control register at I/O port 0xcf9.
* Bit 1 - 0: "soft" reset. Force processor begin execution at power-on
reset vector.
@@ -176,7 +188,7 @@ void register_reset_port_handler(struct acrn_vm
*vm)
};

io_range.base = 0x64U;
- register_pio_emulation_handler(vm, KB_PIO_IDX, &io_range,
handle_reset_reg_read, handle_kb_write);
+ register_pio_emulation_handler(vm, KB_PIO_IDX, &io_range,
+handle_kb_read, handle_kb_write);

io_range.base = 0xcf9U;
register_pio_emulation_handler(vm, CF9_PIO_IDX, &io_range,
handle_reset_reg_read, handle_cf9_write);
--
2.7.4



[PATCH v2 2/6] acrn-config: add 'virtio-console' info in launch xmls

Liu, WeiX W
 

Some vm need mediator of 'virtio-console', so add 'console' item
into the launch config files that user could edit them from webUI.

Tracked-On: #4186
Signed-off-by: Wei Liu <weix.w.liu@...>
---
.../xmls/config-xmls/apl-mrb/sdc_launch_1uos_aaag.xml | 3 ++-
.../xmls/config-xmls/apl-mrb/sdc_launch_1uos_aliaag.xml | 3 ++-
.../xmls/config-xmls/apl-mrb/sdc_launch_1uos_laag.xml | 3 ++-
.../xmls/config-xmls/apl-up2-n3350/sdc_launch_1uos_laag.xml | 3 ++-
.../xmls/config-xmls/apl-up2/sdc_launch_1uos_aaag.xml | 3 ++-
.../xmls/config-xmls/apl-up2/sdc_launch_1uos_laag.xml | 3 ++-
.../xmls/config-xmls/generic/hybrid_launch_1uos.xml | 3 ++-
.../xmls/config-xmls/generic/industry_launch_1uos.xml | 3 ++-
.../xmls/config-xmls/generic/industry_launch_2uos.xml | 6 ++++--
.../xmls/config-xmls/generic/sdc_launch_1uos.xml | 3 ++-
.../config-xmls/nuc6cayh/industry_launch_1uos_hardrt.xml | 3 ++-
.../config-xmls/nuc6cayh/industry_launch_1uos_vxworks.xml | 3 ++-
.../xmls/config-xmls/nuc6cayh/industry_launch_1uos_waag.xml | 3 ++-
.../xmls/config-xmls/nuc6cayh/industry_launch_2uos.xml | 6 ++++--
.../xmls/config-xmls/nuc6cayh/sdc_launch_1uos_laag.xml | 3 ++-
.../xmls/config-xmls/nuc6cayh/sdc_launch_1uos_zephyr.xml | 3 ++-
.../config-xmls/nuc7i7dnb/industry_launch_1uos_hardrt.xml | 3 ++-
.../config-xmls/nuc7i7dnb/industry_launch_1uos_vxworks.xml | 3 ++-
.../config-xmls/nuc7i7dnb/industry_launch_1uos_waag.xml | 3 ++-
.../xmls/config-xmls/nuc7i7dnb/industry_launch_2uos.xml | 6 ++++--
.../xmls/config-xmls/nuc7i7dnb/sdc_launch_1uos_laag.xml | 3 ++-
.../xmls/config-xmls/nuc7i7dnb/sdc_launch_1uos_zephyr.xml | 3 ++-
.../config-xmls/whl-ipc-i5/industry_launch_1uos_hardrt.xml | 3 ++-
.../config-xmls/whl-ipc-i5/industry_launch_1uos_vxworks.xml | 3 ++-
.../config-xmls/whl-ipc-i5/industry_launch_1uos_waag.xml | 3 ++-
.../xmls/config-xmls/whl-ipc-i5/industry_launch_2uos.xml | 6 ++++--
.../xmls/config-xmls/whl-ipc-i5/sdc_launch_1uos_laag.xml | 3 ++-
.../xmls/config-xmls/whl-ipc-i5/sdc_launch_1uos_zephyr.xml | 3 ++-
.../config-xmls/whl-ipc-i7/industry_launch_1uos_hardrt.xml | 3 ++-
.../config-xmls/whl-ipc-i7/industry_launch_1uos_vxworks.xml | 3 ++-
.../config-xmls/whl-ipc-i7/industry_launch_1uos_waag.xml | 3 ++-
.../xmls/config-xmls/whl-ipc-i7/industry_launch_2uos.xml | 6 ++++--
.../xmls/config-xmls/whl-ipc-i7/sdc_launch_1uos_laag.xml | 3 ++-
.../xmls/config-xmls/whl-ipc-i7/sdc_launch_1uos_zephyr.xml | 3 ++-
34 files changed, 78 insertions(+), 39 deletions(-)

diff --git a/misc/acrn-config/xmls/config-xmls/apl-mrb/sdc_launch_1uos_aaag.xml b/misc/acrn-config/xmls/config-xmls/apl-mrb/sdc_launch_1uos_aaag.xml
index 76ca8edc7558..1d2fb13b49cc 100644
--- a/misc/acrn-config/xmls/config-xmls/apl-mrb/sdc_launch_1uos_aaag.xml
+++ b/misc/acrn-config/xmls/config-xmls/apl-mrb/sdc_launch_1uos_aaag.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">2048</mem_size>
<gvt_args desc="GVT argument for the vm">64 448 8</gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<poweroff_channel desc="the method of power off uos" readonly="true">
--pm_notify_channel ioc \
</poweroff_channel>
@@ -30,6 +30,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX].">AaaG</network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">/dev/mmcblk1p3:android/android.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/apl-mrb/sdc_launch_1uos_aliaag.xml b/misc/acrn-config/xmls/config-xmls/apl-mrb/sdc_launch_1uos_aliaag.xml
index a9f13a3c1a02..7dd07b445b7e 100644
--- a/misc/acrn-config/xmls/config-xmls/apl-mrb/sdc_launch_1uos_aliaag.xml
+++ b/misc/acrn-config/xmls/config-xmls/apl-mrb/sdc_launch_1uos_aliaag.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">2048</mem_size>
<gvt_args desc="GVT argument for the vm">64 448 8</gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<poweroff_channel desc="the method of power off uos" readonly="true">
--pm_notify_channel ioc \
</poweroff_channel>
@@ -30,6 +30,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX].">AliaaG</network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">/dev/mmcblk1p3:alios/alios.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/apl-mrb/sdc_launch_1uos_laag.xml b/misc/acrn-config/xmls/config-xmls/apl-mrb/sdc_launch_1uos_laag.xml
index ed7a3fe6067d..7d190f536543 100644
--- a/misc/acrn-config/xmls/config-xmls/apl-mrb/sdc_launch_1uos_laag.xml
+++ b/misc/acrn-config/xmls/config-xmls/apl-mrb/sdc_launch_1uos_laag.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">2048</mem_size>
<gvt_args desc="GVT argument for the vm">64 448 8</gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Enable</vuart0>
<poweroff_channel desc="the method of power off uos" readonly="true">
--pm_notify_channel ioc \
</poweroff_channel>
@@ -30,6 +30,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX].">LaaG</network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">/dev/mmcblk1p3:clearlinux/clearlinux.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@pty:pty_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/apl-up2-n3350/sdc_launch_1uos_laag.xml b/misc/acrn-config/xmls/config-xmls/apl-up2-n3350/sdc_launch_1uos_laag.xml
index b7f6ff8c020f..b88c5307485f 100644
--- a/misc/acrn-config/xmls/config-xmls/apl-up2-n3350/sdc_launch_1uos_laag.xml
+++ b/misc/acrn-config/xmls/config-xmls/apl-up2-n3350/sdc_launch_1uos_laag.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">2048</mem_size>
<gvt_args desc="GVT argument for the vm">64 448 8</gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Enable</vuart0>
<poweroff_channel desc="the method of power off uos" readonly="true">
--pm_notify_channel power_button \
</poweroff_channel>
@@ -30,6 +30,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX].">LaaG</network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">/dev/mmcblk0p1:clearlinux/clearlinux.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@pty:pty_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/apl-up2/sdc_launch_1uos_aaag.xml b/misc/acrn-config/xmls/config-xmls/apl-up2/sdc_launch_1uos_aaag.xml
index 306269d94249..1821d4b00e28 100644
--- a/misc/acrn-config/xmls/config-xmls/apl-up2/sdc_launch_1uos_aaag.xml
+++ b/misc/acrn-config/xmls/config-xmls/apl-up2/sdc_launch_1uos_aaag.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">2048</mem_size>
<gvt_args desc="GVT argument for the vm">64 448 8</gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<poweroff_channel desc="the method of power off uos" readonly="true">
--pm_notify_channel power_button \
</poweroff_channel>
@@ -30,6 +30,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX].">AaaG</network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">/dev/mmcblk0p1:android/android.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/apl-up2/sdc_launch_1uos_laag.xml b/misc/acrn-config/xmls/config-xmls/apl-up2/sdc_launch_1uos_laag.xml
index 5d3649187765..f38020d51c98 100644
--- a/misc/acrn-config/xmls/config-xmls/apl-up2/sdc_launch_1uos_laag.xml
+++ b/misc/acrn-config/xmls/config-xmls/apl-up2/sdc_launch_1uos_laag.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">2048</mem_size>
<gvt_args desc="GVT argument for the vm">64 448 8</gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Enable</vuart0>
<poweroff_channel desc="the method of power off uos" readonly="true">
--pm_notify_channel power_button \
</poweroff_channel>
@@ -30,6 +30,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX].">LaaG</network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">/dev/mmcblk0p1:clearlinux/clearlinux.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@pty:pty_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/generic/hybrid_launch_1uos.xml b/misc/acrn-config/xmls/config-xmls/generic/hybrid_launch_1uos.xml
index 26124f1da2c7..873642389eb3 100644
--- a/misc/acrn-config/xmls/config-xmls/generic/hybrid_launch_1uos.xml
+++ b/misc/acrn-config/xmls/config-xmls/generic/hybrid_launch_1uos.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte"></mem_size>
<gvt_args desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type"></console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<poweroff_channel desc="the method of power off uos">
</poweroff_channel>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>
@@ -29,6 +29,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img"></block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]"></console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/generic/industry_launch_1uos.xml b/misc/acrn-config/xmls/config-xmls/generic/industry_launch_1uos.xml
index 1118fba81f1e..61257ab8bbe9 100644
--- a/misc/acrn-config/xmls/config-xmls/generic/industry_launch_1uos.xml
+++ b/misc/acrn-config/xmls/config-xmls/generic/industry_launch_1uos.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte"></mem_size>
<gvt_args desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type"></console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<poweroff_channel desc="the method of power off uos">
</poweroff_channel>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>
@@ -29,6 +29,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img"></block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]"></console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/generic/industry_launch_2uos.xml b/misc/acrn-config/xmls/config-xmls/generic/industry_launch_2uos.xml
index 4dbb774d71bf..2ca56f286627 100644
--- a/misc/acrn-config/xmls/config-xmls/generic/industry_launch_2uos.xml
+++ b/misc/acrn-config/xmls/config-xmls/generic/industry_launch_2uos.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte"></mem_size>
<gvt_args desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type"></console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Enable</vuart0>
<poweroff_channel desc="the method of power off uos">
</poweroff_channel>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>
@@ -29,6 +29,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img"></block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]"></console>
</virtio_devices>
</uos>
<uos id="2">
@@ -37,7 +38,7 @@
<mem_size desc="UOS memory size in MByte"></mem_size>
<gvt_args desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type"></console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<poweroff_channel desc="the method of power off uos">
</poweroff_channel>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>
@@ -61,6 +62,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img"></block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]"></console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/generic/sdc_launch_1uos.xml b/misc/acrn-config/xmls/config-xmls/generic/sdc_launch_1uos.xml
index 76200d86ec05..b78cf4020fe0 100644
--- a/misc/acrn-config/xmls/config-xmls/generic/sdc_launch_1uos.xml
+++ b/misc/acrn-config/xmls/config-xmls/generic/sdc_launch_1uos.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte"></mem_size>
<gvt_args desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type"></console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<poweroff_channel desc="the method of power off uos">
</poweroff_channel>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>
@@ -29,6 +29,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img"></block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]"></console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/nuc6cayh/industry_launch_1uos_hardrt.xml b/misc/acrn-config/xmls/config-xmls/nuc6cayh/industry_launch_1uos_hardrt.xml
index c7fbfb38699f..255e54a7adf5 100644
--- a/misc/acrn-config/xmls/config-xmls/nuc6cayh/industry_launch_1uos_hardrt.xml
+++ b/misc/acrn-config/xmls/config-xmls/nuc6cayh/industry_launch_1uos_hardrt.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">1024</mem_size>
<gvt_args configurable="0" desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img"></block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/nuc6cayh/industry_launch_1uos_vxworks.xml b/misc/acrn-config/xmls/config-xmls/nuc6cayh/industry_launch_1uos_vxworks.xml
index 0c332ad6ac36..bcb57afb97ef 100644
--- a/misc/acrn-config/xmls/config-xmls/nuc6cayh/industry_launch_1uos_vxworks.xml
+++ b/misc/acrn-config/xmls/config-xmls/nuc6cayh/industry_launch_1uos_vxworks.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">2048</mem_size>
<gvt_args desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">./VxWorks.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/nuc6cayh/industry_launch_1uos_waag.xml b/misc/acrn-config/xmls/config-xmls/nuc6cayh/industry_launch_1uos_waag.xml
index 4f52ce570121..33d9a9d87592 100644
--- a/misc/acrn-config/xmls/config-xmls/nuc6cayh/industry_launch_1uos_waag.xml
+++ b/misc/acrn-config/xmls/config-xmls/nuc6cayh/industry_launch_1uos_waag.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">4096</mem_size>
<gvt_args desc="GVT argument for the vm">64 448 8</gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">com1(ttyS0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Enable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX].">WaaG</network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">./win10-ltsc.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]"></console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/nuc6cayh/industry_launch_2uos.xml b/misc/acrn-config/xmls/config-xmls/nuc6cayh/industry_launch_2uos.xml
index c21f822a5e62..d984871722f2 100644
--- a/misc/acrn-config/xmls/config-xmls/nuc6cayh/industry_launch_2uos.xml
+++ b/misc/acrn-config/xmls/config-xmls/nuc6cayh/industry_launch_2uos.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">4096</mem_size>
<gvt_args desc="GVT argument for the vm">64 448 8</gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">com1(ttyS0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Enable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX].">WaaG</network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">./win10-ltsc.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]"></console>
</virtio_devices>
</uos>

@@ -36,7 +37,7 @@
<mem_size desc="UOS memory size in MByte">1024</mem_size>
<gvt_args configurable="0" desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -58,6 +59,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img"></block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/nuc6cayh/sdc_launch_1uos_laag.xml b/misc/acrn-config/xmls/config-xmls/nuc6cayh/sdc_launch_1uos_laag.xml
index df0bfb5028be..afcb46c8b993 100644
--- a/misc/acrn-config/xmls/config-xmls/nuc6cayh/sdc_launch_1uos_laag.xml
+++ b/misc/acrn-config/xmls/config-xmls/nuc6cayh/sdc_launch_1uos_laag.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">2048</mem_size>
<gvt_args desc="GVT argument for the vm">64 448 8</gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<poweroff_channel desc="the method of power off uos" readonly="true">
--pm_notify_channel power_button \
</poweroff_channel>
@@ -30,6 +30,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX].">LaaG</network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">/home/clear/uos/uos.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/nuc6cayh/sdc_launch_1uos_zephyr.xml b/misc/acrn-config/xmls/config-xmls/nuc6cayh/sdc_launch_1uos_zephyr.xml
index 89c9431ec833..098bf9b99903 100644
--- a/misc/acrn-config/xmls/config-xmls/nuc6cayh/sdc_launch_1uos_zephyr.xml
+++ b/misc/acrn-config/xmls/config-xmls/nuc6cayh/sdc_launch_1uos_zephyr.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">128</mem_size>
<gvt_args desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">com1(ttyS0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Enable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">./zephyr.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@pty:pty_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/industry_launch_1uos_hardrt.xml b/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/industry_launch_1uos_hardrt.xml
index 895f294c456b..7dc32362a025 100644
--- a/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/industry_launch_1uos_hardrt.xml
+++ b/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/industry_launch_1uos_hardrt.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">1024</mem_size>
<gvt_args configurable="0" desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img"></block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/industry_launch_1uos_vxworks.xml b/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/industry_launch_1uos_vxworks.xml
index 2b89b8b81df9..951321b3860c 100644
--- a/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/industry_launch_1uos_vxworks.xml
+++ b/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/industry_launch_1uos_vxworks.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">2048</mem_size>
<gvt_args desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">./VxWorks.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/industry_launch_1uos_waag.xml b/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/industry_launch_1uos_waag.xml
index 2ea8bb642b7e..3a3792a625d0 100644
--- a/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/industry_launch_1uos_waag.xml
+++ b/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/industry_launch_1uos_waag.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">4096</mem_size>
<gvt_args desc="GVT argument for the vm">64 448 8</gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">com1(ttyS0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Enable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX].">WaaG</network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">./win10-ltsc.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]"></console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/industry_launch_2uos.xml b/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/industry_launch_2uos.xml
index 596dece2edc3..57e0560684c6 100644
--- a/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/industry_launch_2uos.xml
+++ b/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/industry_launch_2uos.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">4096</mem_size>
<gvt_args desc="GVT argument for the vm">64 448 8</gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">com1(ttyS0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Enable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX].">WaaG</network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">./win10-ltsc.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]"></console>
</virtio_devices>
</uos>

@@ -36,7 +37,7 @@
<mem_size desc="UOS memory size in MByte">1024</mem_size>
<gvt_args configurable="0" desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -58,6 +59,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img"></block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/sdc_launch_1uos_laag.xml b/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/sdc_launch_1uos_laag.xml
index 6dce9df19417..d2af73424335 100644
--- a/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/sdc_launch_1uos_laag.xml
+++ b/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/sdc_launch_1uos_laag.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">2048</mem_size>
<gvt_args desc="GVT argument for the vm">64 448 8</gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<poweroff_channel desc="the method of power off uos" readonly="true">
--pm_notify_channel power_button \
</poweroff_channel>
@@ -30,6 +30,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX].">LaaG</network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">/home/clear/uos/uos.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/sdc_launch_1uos_zephyr.xml b/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/sdc_launch_1uos_zephyr.xml
index dd3b4fa7379e..dbc9fd18cbce 100644
--- a/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/sdc_launch_1uos_zephyr.xml
+++ b/misc/acrn-config/xmls/config-xmls/nuc7i7dnb/sdc_launch_1uos_zephyr.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">128</mem_size>
<gvt_args desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">com1(ttyS0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Enable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">./zephyr.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@pty:pty_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_hardrt.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_hardrt.xml
index 04d07af3d02f..05c8da2f690e 100644
--- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_hardrt.xml
+++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_hardrt.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">1024</mem_size>
<gvt_args configurable="0" desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img"></block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_vxworks.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_vxworks.xml
index 791133e58c4d..a50cc0150f34 100644
--- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_vxworks.xml
+++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_vxworks.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">2048</mem_size>
<gvt_args desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">./VxWorks.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_waag.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_waag.xml
index 57a4d83cd6f5..0bddce49b91f 100644
--- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_waag.xml
+++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_waag.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">4096</mem_size>
<gvt_args desc="GVT argument for the vm">64 448 8</gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">com1(ttyS0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Enable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX].">WaaG</network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">./win10-ltsc.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]"></console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_2uos.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_2uos.xml
index 58e360be9c15..d921e39cfd33 100644
--- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_2uos.xml
+++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_2uos.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">4096</mem_size>
<gvt_args desc="GVT argument for the vm">64 448 8</gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">com1(ttyS0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Enable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX].">WaaG</network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">./win10-ltsc.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]"></console>
</virtio_devices>
</uos>

@@ -36,7 +37,7 @@
<mem_size desc="UOS memory size in MByte">1024</mem_size>
<gvt_args configurable="0" desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -58,6 +59,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img"></block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/sdc_launch_1uos_laag.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/sdc_launch_1uos_laag.xml
index 77111fb5a4ba..18a4b2b5b9e9 100644
--- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/sdc_launch_1uos_laag.xml
+++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/sdc_launch_1uos_laag.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">2048</mem_size>
<gvt_args desc="GVT argument for the vm">64 448 8</gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<poweroff_channel desc="the method of power off uos" readonly="true">
--pm_notify_channel power_button \
</poweroff_channel>
@@ -30,6 +30,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX].">LaaG</network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">/home/clear/uos/uos.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/sdc_launch_1uos_zephyr.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/sdc_launch_1uos_zephyr.xml
index e46f4e9f2fca..f686df95fe21 100644
--- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/sdc_launch_1uos_zephyr.xml
+++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/sdc_launch_1uos_zephyr.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">128</mem_size>
<gvt_args desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">com1(ttyS0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Enable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">./zephyr.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@pty:pty_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_hardrt.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_hardrt.xml
index 1767e83094b9..437ce0ae9e3d 100644
--- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_hardrt.xml
+++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_hardrt.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">1024</mem_size>
<gvt_args configurable="0" desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img"></block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_vxworks.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_vxworks.xml
index 08f9242308e5..fb50f9fda8f0 100644
--- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_vxworks.xml
+++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_vxworks.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">2048</mem_size>
<gvt_args desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">./VxWorks.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_waag.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_waag.xml
index 1134c554ffd4..2c7dcc3e08af 100644
--- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_waag.xml
+++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_waag.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">4096</mem_size>
<gvt_args desc="GVT argument for the vm">64 448 8</gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">com1(ttyS0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Enable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX].">WaaG</network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">./win10-ltsc.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]"></console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_2uos.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_2uos.xml
index ebacf0be7b27..1f20e41b4893 100644
--- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_2uos.xml
+++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_2uos.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">4096</mem_size>
<gvt_args desc="GVT argument for the vm">64 448 8</gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">com1(ttyS0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Enable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX].">WaaG</network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">./win10-ltsc.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]"></console>
</virtio_devices>
</uos>

@@ -36,7 +37,7 @@
<mem_size desc="UOS memory size in MByte">1024</mem_size>
<gvt_args configurable="0" desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -58,6 +59,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img"></block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/sdc_launch_1uos_laag.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/sdc_launch_1uos_laag.xml
index 6aaa1f355334..fc066444e882 100644
--- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/sdc_launch_1uos_laag.xml
+++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/sdc_launch_1uos_laag.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">2048</mem_size>
<gvt_args desc="GVT argument for the vm">64 448 8</gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">virtio-console(hvc0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Disable</vuart0>
<poweroff_channel desc="the method of power off uos" readonly="true">
--pm_notify_channel power_button \
</poweroff_channel>
@@ -30,6 +30,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX].">LaaG</network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">/home/clear/uos/uos.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@stdio:stdio_port</console>
</virtio_devices>
</uos>
</acrn-config>
diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/sdc_launch_1uos_zephyr.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/sdc_launch_1uos_zephyr.xml
index db96aadb0bf7..66b9fb8651e5 100644
--- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/sdc_launch_1uos_zephyr.xml
+++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/sdc_launch_1uos_zephyr.xml
@@ -5,7 +5,7 @@
<mem_size desc="UOS memory size in MByte">128</mem_size>
<gvt_args desc="GVT argument for the vm"></gvt_args>
<vbootloader desc="virtual bootloader method" readonly="true">ovmf</vbootloader>
- <console_type desc="UOS console type">com1(ttyS0)</console_type>
+ <vuart0 desc="vUART0 which emulated by device model">Enable</vuart0>
<usb_xhci desc="USB xHCI mediator configuration. input format: bus#-port#[:bus#-port#: ...]. e.g.: 1-2:2-4"></usb_xhci>

<passthrough_devices>
@@ -27,6 +27,7 @@
<network desc="virtio network devices setting. Input format: tap_name,[vhost],[mac=XX:XX:XX:XX:XX:XX]."></network>
<input desc="virtio input device"></input>
<block desc="virtio block device setting. format: [blk partition:][img path] e.g.: /dev/sda3:./a/b.img">./zephyr.img</block>
+ <console desc="virtio console device,input format: [@]stdio|tty|pty|sock:portname[=portpath][,[@]stdio|tty|pty:portname[=portpath]]">@pty:pty_port</console>
</virtio_devices>
</uos>
</acrn-config>
--
2.20.1


[PATCH v2 1/6] acrn-config: add 'virtio-console' mediator support for launch config

Liu, WeiX W
 

Add virtio-console mediator support to parse and get 'virtio-console' item value
from launch config files, these values are editable by user.

Tracked-On: #4186
Signed-off-by: Wei Liu <weix.w.liu@...>
---
misc/acrn-config/launch_config/com.py | 14 +++++++-------
misc/acrn-config/launch_config/launch_cfg_gen.py | 2 +-
misc/acrn-config/launch_config/launch_item.py | 5 +++--
misc/acrn-config/library/launch_cfg_lib.py | 7 +------
4 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/misc/acrn-config/launch_config/com.py b/misc/acrn-config/launch_config/com.py
index 3f789f10fab8..0fcf58f62780 100644
--- a/misc/acrn-config/launch_config/com.py
+++ b/misc/acrn-config/launch_config/com.py
@@ -465,6 +465,12 @@ def virtio_args_set(dm, virt_io, vmid, config):
net_name = net.split(',')[0]
print(" -s {},virtio-net,{} \\".format(launch_cfg_lib.virtual_dev_slot("virtio-net{}".format(net)), net_name), file=config)

+ # virtio-console set, the value type is a string
+ if virt_io['console'][vmid]:
+ print(" -s {},virtio-console,{} \\".format(
+ launch_cfg_lib.virtual_dev_slot("virtio-console"),
+ virt_io['console'][vmid]), file=config)
+

def dm_arg_set(names, sel, virt_io, dm, vmid, config):

@@ -545,15 +551,9 @@ def dm_arg_set(names, sel, virt_io, dm, vmid, config):
vboot_arg_set(dm, vmid, config)

# redirect console
- if dm['console_type'][vmid] == "com1(ttyS0)":
+ if dm['vuart0'][vmid] == "Enable":
print(" -s 1:0,lpc \\", file=config)
print(" -l com1,stdio \\", file=config)
- print(" -s {},{} \\".format(launch_cfg_lib.virtual_dev_slot("com1(ttyS0)"),
- launch_cfg_lib.RE_CONSOLE_MAP['com1(ttyS0)']), file=config)
- else:
- print(" -s {},{} \\".format(
- launch_cfg_lib.virtual_dev_slot("virtio-console(hvc0)"),
- launch_cfg_lib.RE_CONSOLE_MAP['virtio-console(hvc0)']), file=config)

if uos_type in ("CLEARLINUX", "ANDROID", "ALIOS"):
print(" -s {},virtio-hyper_dmabuf \\".format(launch_cfg_lib.virtual_dev_slot("virtio-hyper_dmabuf")), file=config)
diff --git a/misc/acrn-config/launch_config/launch_cfg_gen.py b/misc/acrn-config/launch_config/launch_cfg_gen.py
index d1ee1af64b0d..f71ed5743ee5 100644
--- a/misc/acrn-config/launch_config/launch_cfg_gen.py
+++ b/misc/acrn-config/launch_config/launch_cfg_gen.py
@@ -45,7 +45,7 @@ def get_launch_item_values(board_info):
launch_item_values["uos,rtos_type"] = launch_cfg_lib.RTOS_TYPE

launch_item_values["uos,vbootloader"] = launch_cfg_lib.BOOT_TYPE
- launch_item_values['uos,console_type'] = launch_cfg_lib.REDIRECT_CONSOLE
+ launch_item_values['uos,vuart0'] = launch_cfg_lib.DM_VUART0
launch_item_values['uos,gvt_args'] = launch_cfg_lib.GVT_ARGS

return launch_item_values
diff --git a/misc/acrn-config/launch_config/launch_item.py b/misc/acrn-config/launch_config/launch_item.py
index aa2fc1d74b57..6d428eee13c3 100644
--- a/misc/acrn-config/launch_config/launch_item.py
+++ b/misc/acrn-config/launch_config/launch_item.py
@@ -19,7 +19,7 @@ class AcrnDmArgs:
self.args["mem_size"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "mem_size")
self.args["gvt_args"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "gvt_args")
self.args["vbootloader"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "vbootloader")
- self.args["console_type"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "console_type")
+ self.args["vuart0"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "vuart0")
self.args["off_pcpus"] = launch_cfg_lib.get_leaf_tag_map(self.scenario_info, "vcpu_affinity", "pcpu_id")
self.args["xhci"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "usb_xhci")

@@ -30,7 +30,7 @@ class AcrnDmArgs:
launch_cfg_lib.mem_size_check(self.args["mem_size"], "mem_size")
launch_cfg_lib.args_aval_check(self.args["gvt_args"], "gvt_args", launch_cfg_lib.GVT_ARGS)
launch_cfg_lib.args_aval_check(self.args["vbootloader"], "vbootloader", launch_cfg_lib.BOOT_TYPE)
- launch_cfg_lib.args_aval_check(self.args["console_type"], "console_type", launch_cfg_lib.REDIRECT_CONSOLE)
+ launch_cfg_lib.args_aval_check(self.args["vuart0"], "vuart0", launch_cfg_lib.DM_VUART0)


class AvailablePthru():
@@ -152,3 +152,4 @@ class VirtioDeviceSelect():
self.dev["input"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "virtio_devices", "input")
self.dev["block"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "virtio_devices", "block")
self.dev["network"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "virtio_devices", "network")
+ self.dev["console"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "virtio_devices", "console")
diff --git a/misc/acrn-config/library/launch_cfg_lib.py b/misc/acrn-config/library/launch_cfg_lib.py
index 73c9d184bf10..9c1070b8443f 100644
--- a/misc/acrn-config/library/launch_cfg_lib.py
+++ b/misc/acrn-config/library/launch_cfg_lib.py
@@ -15,15 +15,10 @@ LAUNCH_INFO_FILE = ""
ERR_LIST = {}
BOOT_TYPE = ['no', 'vsbl', 'ovmf']
RTOS_TYPE = ['no', 'Soft RT', 'Hard RT']
-REDIRECT_CONSOLE = ['com1(ttyS0)', 'virtio-console(hvc0)']
+DM_VUART0 = ['Disable', 'Enable']
UOS_TYPES = ['CLEARLINUX', 'ANDROID', 'ALIOS', 'PREEMPT-RT LINUX', 'VXWORKS', 'WINDOWS', 'ZEPHYR', 'GENERIC LINUX']
GVT_ARGS = ['64 448 8']

-RE_CONSOLE_MAP = {
- "com1(ttyS0)":"virtio-console,@pty:pty_port",
- "virtio-console(hvc0)":"virtio-console,@stdio:stdio_port"
-}
-
PT_SUB_PCI = {}
PT_SUB_PCI['usb_xdci'] = ['USB controller']
PT_SUB_PCI['ipu'] = ['Multimedia controller']
--
2.20.1


Re: [PATCH v2 4/7] HV: ignore the NMI injection request for lapic-pt vCPUs

Yan, Like
 

On Mon, Dec 09, 2019 at 04:47:48PM +0000, Kaige Fu wrote:
NMI will be used as notification signal for lapic-pt vCPUs and
ACRN doesn't support vNMI for lapic-pt vCPUs. Because it is not
possible to distinguish between notification NMIs and external NMIs
for lapic-pt vCPUs in some corner cases, eg: we can use a magic number
as identifier of notification NMIs. If it is set when receiving a NMI,
this NMI is processed as notification NMI. Otherwise, it is a external
NMI for lapic-pt vCPUs. It works well most of the time. But it won't work
for some corner cases, eg:

1. The sender CPU sets the identifier.
2. An external NMI occurs on the target CPU and then the target CPU will
treat this NMI as notification NMI by mistake.
3. The sender CPU sends the NMI to target CPU.

So, this patch ignores the pending NMI request and EXCP with vector 2.

Signed-off-by: Kaige Fu <kaige.fu@...>
---
hypervisor/arch/x86/guest/virq.c | 55 ++++++++++++++++++++------------
1 file changed, 35 insertions(+), 20 deletions(-)

diff --git a/hypervisor/arch/x86/guest/virq.c b/hypervisor/arch/x86/guest/virq.c
index a0be3c3d..174c0fb3 100644
--- a/hypervisor/arch/x86/guest/virq.c
+++ b/hypervisor/arch/x86/guest/virq.c
@@ -212,26 +212,36 @@ int32_t vcpu_queue_exception(struct acrn_vcpu *vcpu, uint32_t vector_arg, uint32
static void vcpu_inject_exception(struct acrn_vcpu *vcpu, uint32_t vector)
{
if (bitmap_test_and_clear_lock(ACRN_REQUEST_EXCP, &vcpu->arch.pending_req)) {
-
- if ((exception_type[vector] & EXCEPTION_ERROR_CODE_VALID) != 0U) {
- exec_vmwrite32(VMX_ENTRY_EXCEPTION_ERROR_CODE,
- vcpu->arch.exception_info.error);
- }
+ if (is_lapic_pt_enabled(vcpu) && (vector == IDT_NMI)) {
The restriction is not support vNMI for RTVM, so I think we should use is_lapic_pt_configured() here.

+ /*
+ * NMI will be used as notification signal for lapic-pt vCPUs and we
+ * don't support vNMI yet. So, here we just ignore the NMI injection
+ * request.
+ */
+ pr_warn("Don't allow to inject NMI to lapic-pt vCPU%u. Ignore this request.", vcpu->vcpu_id);
+ vcpu->arch.exception_info.exception = VECTOR_INVALID;
+ } else {
+ if ((exception_type[vector] & EXCEPTION_ERROR_CODE_VALID) != 0U) {
+ exec_vmwrite32(VMX_ENTRY_EXCEPTION_ERROR_CODE,
+ vcpu->arch.exception_info.error);
+ }

- exec_vmwrite32(VMX_ENTRY_INT_INFO_FIELD, VMX_INT_INFO_VALID |
- (exception_type[vector] << 8U) | (vector & 0xFFU));
+ exec_vmwrite32(VMX_ENTRY_INT_INFO_FIELD, VMX_INT_INFO_VALID |
+ (exception_type[vector] << 8U) | (vector & 0xFFU));

- vcpu->arch.exception_info.exception = VECTOR_INVALID;
+ vcpu->arch.exception_info.exception = VECTOR_INVALID;

- /* retain rip for exception injection */
- vcpu_retain_rip(vcpu);
+ /* retain rip for exception injection */
+ vcpu_retain_rip(vcpu);

- /* SDM 17.3.1.1 For any fault-class exception except a debug exception generated in response to an
- * instruction breakpoint, the value pushed for RF is 1.
- * #DB is treated as Trap in get_exception_type, so RF will not be set for instruction breakpoint.
- */
- if (get_exception_type(vector) == EXCEPTION_FAULT) {
- vcpu_set_rflags(vcpu, vcpu_get_rflags(vcpu) | HV_ARCH_VCPU_RFLAGS_RF);
+ /* SDM 17.3.1.1 For any fault-class exception except a debug exception generated
+ * in response to an instruction breakpoint, the value pushed for RF is 1.
+ * #DB is treated as Trap in get_exception_type, so RF will not be set for
+ * instruction breakpoint.
+ */
+ if (get_exception_type(vector) == EXCEPTION_FAULT) {
+ vcpu_set_rflags(vcpu, vcpu_get_rflags(vcpu) | HV_ARCH_VCPU_RFLAGS_RF);
+ }
}
}
}
@@ -389,10 +399,15 @@ int32_t acrn_handle_pending_request(struct acrn_vcpu *vcpu)
if (!injected) {
/* inject NMI before maskable hardware interrupt */
if (bitmap_test_and_clear_lock(ACRN_REQUEST_NMI, pending_req_bits)) {
- /* Inject NMI vector = 2 */
- exec_vmwrite32(VMX_ENTRY_INT_INFO_FIELD,
- VMX_INT_INFO_VALID | (VMX_INT_TYPE_NMI << 8U) | IDT_NMI);
- injected = true;
+ if (!is_lapic_pt_enabled(vcpu)) {
Ditto

+ /* Inject NMI vector = 2 */
+ exec_vmwrite32(VMX_ENTRY_INT_INFO_FIELD,
+ VMX_INT_INFO_VALID | (VMX_INT_TYPE_NMI << 8U) | IDT_NMI);
+ injected = true;
+ } else {
+ pr_warn("Don't allow to inject NMI to lapic-pt vCPU%u. Ignore this request.",
+ vcpu->vcpu_id);
+ }
} else {
/* handling pending vector injection:
* there are many reason inject failed, we need re-inject again
--
2.20.0




Re: [PATCH v2 5/7] HV: Use NMI-window exiting to address req missing issue

Kaige Fu
 

On 12-09 Mon 14:23, Grandhi, Sainath wrote:


-----Original Message-----
From: acrn-dev@... <acrn-dev@...> On
Behalf Of Kaige Fu
Sent: Monday, December 09, 2019 8:48 AM
To: acrn-dev@...
Subject: [acrn-dev] [PATCH v2 5/7] HV: Use NMI-window exiting to address req
missing issue

There is a window where we may miss the current request in the notification
period when the work flow is as the following:

CPUx + + CPUr
| |
| +--+
| | | Handle pending req
| <--+
+--+ |
| | Set req flag |
<--+ |
+------------------>---+
| Send NMI | | Handle NMI
| <--+
| |
| |
| +--> vCPU enter
| |
+ +

So, this patch enables the NMI-window exiting to trigger the next vmexit once
there is no "virtual-NMI blocking" after vCPU enter into VMX non-root mode.
Then we can process the pending request on time.

Signed-off-by: Kaige Fu <kaige.fu@...>
---
hypervisor/arch/x86/guest/virq.c | 17 ++++++++++++++++
hypervisor/arch/x86/guest/vmcs.c | 2 +-
hypervisor/arch/x86/guest/vmexit.c | 2 +-
hypervisor/arch/x86/irq.c | 31 +++++++++++++++++++++++++++++-
hypervisor/include/arch/x86/irq.h | 1 +
5 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/hypervisor/arch/x86/guest/virq.c b/hypervisor/arch/x86/guest/virq.c
index 174c0fb3..a513a7da 100644
--- a/hypervisor/arch/x86/guest/virq.c
+++ b/hypervisor/arch/x86/guest/virq.c
@@ -533,3 +533,20 @@ int32_t exception_vmexit_handler(struct acrn_vcpu
*vcpu)

return status;
}
+
+int nmi_window_vmexit_handler(__unused struct acrn_vcpu *vcpu) {
+ uint32_t value32;
+
+ /*
+ * Disable NMI-window exiting here. We will process
+ * the pending request in acrn_handle_pending_request later
+ */
+ value32 = exec_vmread32(VMX_PROC_VM_EXEC_CONTROLS);
+ value32 &= ~VMX_PROCBASED_CTLS_NMI_WINEXIT;
+ exec_vmwrite32(VMX_PROC_VM_EXEC_CONTROLS, value32);
+
+ vcpu_retain_rip(vcpu);
+
+ return 0;
+}
diff --git a/hypervisor/arch/x86/guest/vmcs.c
b/hypervisor/arch/x86/guest/vmcs.c
index 1efa37db..7dd2d806 100644
--- a/hypervisor/arch/x86/guest/vmcs.c
+++ b/hypervisor/arch/x86/guest/vmcs.c
@@ -582,7 +582,7 @@ void switch_apicv_mode_x2apic(struct acrn_vcpu
*vcpu)
* directly without vmexit. So, here we enable NMI-exiting and
use NMI
* as notification signal after passthroughing the lapic to vCPU.
*/
- value32 |= VMX_PINBASED_CTLS_NMI_EXIT;
+ value32 |= VMX_PINBASED_CTLS_NMI_EXIT |
VMX_PINBASED_CTLS_VIRT_NMI;
exec_vmwrite32(VMX_PIN_VM_EXEC_CONTROLS, value32);

value32 = exec_vmread32(VMX_EXIT_CONTROLS); diff --git
a/hypervisor/arch/x86/guest/vmexit.c b/hypervisor/arch/x86/guest/vmexit.c
index 43c979f8..2c1a9d4b 100644
--- a/hypervisor/arch/x86/guest/vmexit.c
+++ b/hypervisor/arch/x86/guest/vmexit.c
@@ -51,7 +51,7 @@ static const struct vm_exit_dispatch
dispatch_table[NR_VMX_EXIT_REASONS] = {
[VMX_EXIT_REASON_INTERRUPT_WINDOW] = {
.handler = interrupt_window_vmexit_handler},
[VMX_EXIT_REASON_NMI_WINDOW] = {
- .handler = unhandled_vmexit_handler},
+ .handler = nmi_window_vmexit_handler},
[VMX_EXIT_REASON_TASK_SWITCH] = {
.handler = unhandled_vmexit_handler},
[VMX_EXIT_REASON_CPUID] = {
diff --git a/hypervisor/arch/x86/irq.c b/hypervisor/arch/x86/irq.c index
4460b44d..4a377239 100644
--- a/hypervisor/arch/x86/irq.c
+++ b/hypervisor/arch/x86/irq.c
@@ -18,6 +18,7 @@
#include <vboot.h>
#include <dump.h>
#include <logmsg.h>
+#include <vmx.h>

static spinlock_t exception_spinlock = { .head = 0U, .tail = 0U, }; static
spinlock_t irq_alloc_spinlock = { .head = 0U, .tail = 0U, }; @@ -368,9 +369,37
@@ void dispatch_interrupt(const struct intr_excp_ctx *ctx) void
dispatch_exception(struct intr_excp_ctx *ctx) {
uint16_t pcpu_id = get_pcpu_id();
+ uint32_t value32;

if (ctx->vector == IDT_NMI) {
- /* TODO: we will handle it later */
+ /*
+ * There is a window where we may miss the current request in
this
+ * notification period when the work flow is as the following:
+ *
+ * CPUx + + CPUr
+ * | |
+ * | +--+
+ * | | | Handle pending req
+ * | <--+
+ * +--+ |
+ * | | Set req flag |
+ * <--+ |
+ * +------------------>---+
+ * | Send NMI | | Handle NMI
+ * | <--+
+ * | |
+ * | |
+ * | +--> vCPU enter
+ * | |
+ * + +
+ *
+ * So, here we enable the NMI-window exiting to trigger the
next vmexit
+ * once there is no "virtual-NMI blocking" after vCPU enter into
VMX non-root
+ * mode. Then we can process the pending request on time.
+ */
+ value32 = exec_vmread32(VMX_PROC_VM_EXEC_CONTROLS);
+ value32 |= VMX_PROCBASED_CTLS_NMI_WINEXIT;
+ exec_vmwrite32(VMX_PROC_VM_EXEC_CONTROLS, value32);
Hi Kaige,
What if the reason of NMI is not due to hypervisor related notification? Can we check if there is a pending request against the vCPU running on this pCPU before opening "NMI window"
If the reason of NMI is not due to hypervisor related notification. There are no request bits set in pending request.
So, we will do nothing in next nmi-window exiting. It is harmless except for extra vmexit.

Yes. We can check the pending request against the vCPU running on this pCPU before opening "NMI window". But we don't
do like this for:
- Almost all the time, the NMI is triggered by hypervisor related notification.
- If we want to check the pending request in nmi_handler, we need to find the target vCPU according pCPU. It seems
weired to me that we touch the vCPU context in exception context and will introduce more complexity just to deal with
something that rarely happens.

} else {
/* Obtain lock to ensure exception dump doesn't get corrupted
*/
spinlock_obtain(&exception_spinlock);
diff --git a/hypervisor/include/arch/x86/irq.h
b/hypervisor/include/arch/x86/irq.h
index 8f8f3967..a5ed3aed 100644
--- a/hypervisor/include/arch/x86/irq.h
+++ b/hypervisor/include/arch/x86/irq.h
@@ -207,6 +207,7 @@ void vcpu_make_request(struct acrn_vcpu *vcpu,
uint16_t eventid);
* @pre vcpu != NULL
*/
int32_t exception_vmexit_handler(struct acrn_vcpu *vcpu);
+int32_t nmi_window_vmexit_handler(struct acrn_vcpu *vcpu);
int32_t interrupt_window_vmexit_handler(struct acrn_vcpu *vcpu); int32_t
external_interrupt_vmexit_handler(struct acrn_vcpu *vcpu); int32_t
acrn_handle_pending_request(struct acrn_vcpu *vcpu);
--
2.20.0





Re: [RFC PATCH v2 1/2] hv: pci: use ECAM to access PCIe Configuration Space

Dongsheng Zhang
 

LGTM

-----Original Message-----
From: Li, Fei1 <fei1.li@...>
Sent: Friday, December 6, 2019 7:26 AM
To: acrn-dev@...
Cc: Dong, Eddie <eddie.dong@...>; Zhang, Dongsheng X
<dongsheng.x.zhang@...>
Subject: [RFC PATCH v2 1/2] hv: pci: use ECAM to access PCIe Configuration
Space

Use Enhanced Configuration Access Mechanism (MMIO) instead of PCI-
compatible Configuration Mechanism (IO port) to access PCIe Configuration
Space

Tracked-On: #3475
Signed-off-by: Li Fei1 <fei1.li@...>
---
hypervisor/hw/pci.c | 50 ++++++++++++++++++++++++++-------------------
1 file changed, 29 insertions(+), 21 deletions(-)

diff --git a/hypervisor/hw/pci.c b/hypervisor/hw/pci.c index
ea301338..4bc230cd 100644
--- a/hypervisor/hw/pci.c
+++ b/hypervisor/hw/pci.c
@@ -34,6 +34,7 @@
#include <types.h>
#include <spinlock.h>
#include <io.h>
+#include <pgtable.h>
#include <pci.h>
#include <uart16550.h>
#include <logmsg.h>
@@ -86,67 +87,74 @@ uint32_t pci_lookup_drhd_for_pbdf(uint16_t pbdf)
return drhd_index;
}

-static uint32_t pci_pdev_calc_address(union pci_bdf bdf, uint32_t offset)
+/*
+ * @pre offset < 0x1000U
+ */
+static inline uint32_t pci_pdev_calc_address(union pci_bdf bdf,
+uint32_t offset)
{
- uint32_t addr = (uint32_t)bdf.value;
-
- addr <<= 8U;
- addr |= (offset | PCI_CFG_ENABLE);
- return addr;
+ return pci_mmcfg_base + (((uint32_t)bdf.value << 12U) | offset);
}

+/*
+ * @pre bytes == 1U || bytes == 2U || bytes == 4U */
uint32_t pci_pdev_read_cfg(union pci_bdf bdf, uint32_t offset, uint32_t
bytes) {
uint32_t addr;
uint32_t val;
+ void *mmcfg_base_hva;

addr = pci_pdev_calc_address(bdf, offset);
+ mmcfg_base_hva = hpa2hva(addr);

spinlock_obtain(&pci_device_lock);
+ stac();

- /* Write address to ADDRESS register */
- pio_write32(addr, (uint16_t)PCI_CONFIG_ADDR);
-
- /* Read result from DATA register */
switch (bytes) {
case 1U:
- val = (uint32_t)pio_read8((uint16_t)PCI_CONFIG_DATA +
((uint16_t)offset & 3U));
+ val = (uint32_t)mmio_read8(mmcfg_base_hva);
break;
case 2U:
- val = (uint32_t)pio_read16((uint16_t)PCI_CONFIG_DATA +
((uint16_t)offset & 2U));
+ val = (uint32_t)mmio_read16(mmcfg_base_hva);
break;
default:
- val = pio_read32((uint16_t)PCI_CONFIG_DATA);
+ val = mmio_read32(mmcfg_base_hva);
break;
}
+
+ clac();
spinlock_release(&pci_device_lock);

return val;
}

+/*
+ * @pre bytes == 1U || bytes == 2U || bytes == 4U */
void pci_pdev_write_cfg(union pci_bdf bdf, uint32_t offset, uint32_t bytes,
uint32_t val) {
uint32_t addr;
-
- spinlock_obtain(&pci_device_lock);
+ void *mmcfg_base_hva;

addr = pci_pdev_calc_address(bdf, offset);
+ mmcfg_base_hva = hpa2hva(addr);

- /* Write address to ADDRESS register */
- pio_write32(addr, (uint16_t)PCI_CONFIG_ADDR);
+ spinlock_obtain(&pci_device_lock);
+ stac();

- /* Write value to DATA register */
switch (bytes) {
case 1U:
- pio_write8((uint8_t)val, (uint16_t)PCI_CONFIG_DATA +
((uint16_t)offset & 3U));
+ mmio_write8((uint8_t)val, mmcfg_base_hva);
break;
case 2U:
- pio_write16((uint16_t)val, (uint16_t)PCI_CONFIG_DATA +
((uint16_t)offset & 2U));
+ mmio_write16((uint16_t)val, mmcfg_base_hva);
break;
default:
- pio_write32(val, (uint16_t)PCI_CONFIG_DATA);
+ mmio_write32(val, mmcfg_base_hva);
break;
}
+
+ clac();
spinlock_release(&pci_device_lock);
}

--
2.17.1


Re: [RFC PATCH v2 2/2] hv: vpci: trap PCIe ECAM access for SOS

Dongsheng Zhang
 

Looks PCI_CONFIG_SPACE_SIZE is not used by any code?

(Now pre-launched VM doesn't want to support PCI ECAM;
We can discuss and see if we can add mcfg table to vacpi.c's dsdt table so that we can
also trap PCIe ECAM access for pre-launched VM?


-----Original Message-----
From: Li, Fei1 <fei1.li@...>
Sent: Friday, December 6, 2019 7:26 AM
To: acrn-dev@...
Cc: Dong, Eddie <eddie.dong@...>; Zhang, Dongsheng X
<dongsheng.x.zhang@...>
Subject: [RFC PATCH v2 2/2] hv: vpci: trap PCIe ECAM access for SOS

SOS will use PCIe ECAM access PCIe external configuration space. HV should
trap this access for security(Now pre-launched VM doesn't want to support
PCI ECAM; post-launched VM trap PCIe ECAM access in DM).

Tracked-On: #3475
Signed-off-by: Li Fei1 <fei1.li@...>
---
hypervisor/dm/vpci/vpci.c | 43
+++++++++++++++++++++++++++++++++++-
hypervisor/include/dm/vpci.h | 7 +++--- hypervisor/include/hw/pci.h | 5
++++-
3 files changed, 50 insertions(+), 5 deletions(-)

diff --git a/hypervisor/dm/vpci/vpci.c b/hypervisor/dm/vpci/vpci.c index
78fa17cb..528bd93a 100644
--- a/hypervisor/dm/vpci/vpci.c
+++ b/hypervisor/dm/vpci/vpci.c
@@ -29,7 +29,9 @@

#include <vm.h>
#include <vtd.h>
+#include <io.h>
#include <mmu.h>
+#include <ept.h>
#include <logmsg.h>
#include "vpci_priv.h"
#include "pci_dev.h"
@@ -172,6 +174,38 @@ static bool pci_cfgdata_io_write(struct acrn_vcpu
*vcpu, uint16_t addr, size_t b
return true;
}

+/**
+ * @pre io_req != NULL && private_data != NULL */ static int32_t
+vpci_handle_mmconfig_access(struct io_request *io_req, void
+*private_data) {
+ struct mmio_request *mmio = &io_req->reqs.mmio;
+ struct acrn_vpci *vpci = (struct acrn_vpci *)private_data;
+ uint64_t pci_mmcofg_base = vpci->pci_mmcfg_base;
+ uint64_t address = mmio->address;
+ uint32_t reg_num = (uint32_t)(address & 0xfffUL);
+ union pci_bdf bdf;
+
+ /**
+ * Enhanced Configuration Address Mapping
+ * A[(20+n-1):20] Bus Number 1 ≤ n ≤ 8
+ * A[19:15] Device Number
+ * A[14:12] Function Number
+ * A[11:8] Extended Register Number
+ * A[7:2] Register Number
+ * A[1:0] Along with size of the access, used to generate Byte Enables
+ */
+ bdf.value = (uint16_t)((address - pci_mmcofg_base) >> 12U);
+
+ if (mmio->direction == REQUEST_READ) {
+ read_cfg(vpci, bdf, reg_num, mmio->size, (uint32_t
*)&mmio->value);
+ } else {
+ write_cfg(vpci, bdf, reg_num, mmio->size, (uint32_t)mmio-
value);
+ }
+
+ return 0;
+}
+
/**
* @pre vm != NULL
* @pre vm->vm_id < CONFIG_MAX_VM_NUM
@@ -189,6 +223,7 @@ void vpci_init(struct acrn_vm *vm)
};

struct acrn_vm_config *vm_config;
+ uint64_t pci_mmcfg_base;

vm->vpci.vm = vm;
vm->iommu = create_iommu_domain(vm->vm_id, hva2hpa(vm-
arch_vm.nworld_eptp), 48U); @@ -197,8 +232,14 @@ void vpci_init(struct
acrn_vm *vm)

vm_config = get_vm_config(vm->vm_id);
switch (vm_config->load_order) {
- case PRE_LAUNCHED_VM:
case SOS_VM:
+ pci_mmcfg_base = get_mmcfg_base();
+ vm->vpci.pci_mmcfg_base = pci_mmcfg_base;
+ register_mmio_emulation_handler(vm,
vpci_handle_mmconfig_access,
+ pci_mmcfg_base, pci_mmcfg_base +
PCI_MMCONFIG_SIZE, &vm->vpci);
+ ept_del_mr(vm, (uint64_t *)vm->arch_vm.nworld_eptp,
pci_mmcfg_base, PCI_MMCONFIG_SIZE);
+ /* falls through */
+ case PRE_LAUNCHED_VM:
/*
* SOS: intercept port CF8 only.
* UOS or pre-launched VM: register handler for CF8 only and
I/O requests to CF9/CFA/CFB are diff --git a/hypervisor/include/dm/vpci.h
b/hypervisor/include/dm/vpci.h index a5110755..c16aacbb 100644
--- a/hypervisor/include/dm/vpci.h
+++ b/hypervisor/include/dm/vpci.h
@@ -70,9 +70,9 @@ struct pci_msix {
};

union pci_cfgdata {
- uint8_t data_8[PCI_REGMAX + 1U];
- uint16_t data_16[(PCI_REGMAX + 1U) >> 1U];
- uint32_t data_32[(PCI_REGMAX + 1U) >> 2U];
+ uint8_t data_8[PCIE_CONFIG_SPACE_SIZE];
+ uint16_t data_16[PCIE_CONFIG_SPACE_SIZE >> 1U];
+ uint32_t data_32[PCIE_CONFIG_SPACE_SIZE >> 2U];
};

struct pci_vdev;
@@ -123,6 +123,7 @@ struct acrn_vpci {
spinlock_t lock;
struct acrn_vm *vm;
union pci_cfg_addr_reg addr;
+ uint64_t pci_mmcfg_base;
uint32_t pci_vdev_cnt;
struct pci_vdev pci_vdevs[CONFIG_MAX_PCI_DEV_NUM];
};
diff --git a/hypervisor/include/hw/pci.h b/hypervisor/include/hw/pci.h index
42fc3f9d..0dd98fbf 100644
--- a/hypervisor/include/hw/pci.h
+++ b/hypervisor/include/hw/pci.h
@@ -48,9 +48,12 @@
#define PCI_SLOTMAX 0x1FU
#define PCI_FUNCMAX 0x7U
#define PCI_BAR_COUNT 0x6U
-#define PCI_REGMAX 0xFFU
#define PCI_REGMASK 0xFCU

+#define PCI_CONFIG_SPACE_SIZE 0x100U
+#define PCIE_CONFIG_SPACE_SIZE 0x1000U
+#define PCI_MMCONFIG_SIZE 0x10000000U
+
/* I/O ports */
#define PCI_CONFIG_ADDR 0xCF8U
#define PCI_CONFIG_DATA 0xCFCU
--
2.17.1


[PATCH 2/2] acrn-config: support non-contiguous HPA for hybrid scenario

Vijay Dhanraj
 

The patch adds acrn-config tool support for adding
non-continguous HPA allocations for pre-launched VMs
in hybrid scenario.

Signed-off-by: Vijay Dhanraj <vijay.dhanraj@...>
---
misc/acrn-config/board_config/ve820_c.py | 9 +++++----
misc/acrn-config/scenario_config/vm_configurations_h.py | 4 ++--
misc/acrn-config/xmls/config-xmls/generic/hybrid.xml | 2 ++
3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/misc/acrn-config/board_config/ve820_c.py b/misc/acrn-config/board_config/ve820_c.py
index 17349d9f..e2bfa7f0 100644
--- a/misc/acrn-config/board_config/ve820_c.py
+++ b/misc/acrn-config/board_config/ve820_c.py
@@ -20,6 +20,7 @@ def ve820_per_launch(config, hpa_size, hpa2_size):
return err_dic

board_name = board_cfg_lib.undline_name(board_name)
+ pre_vm_cnt = board_cfg_lib.get_pre_launch_cnt(board_cfg_lib.SCENARIO_INFO_FILE)

low_mem_to_pci_hole_len = '0xA0000000'
low_mem_to_pci_hole = '0x20000000'
@@ -36,7 +37,7 @@ def ve820_per_launch(config, hpa_size, hpa2_size):
print("#include <vm.h>", file=config)
print("", file=config)

- for i in range(board_cfg_lib.VM_COUNT):
+ for i in range(pre_vm_cnt):
if (int(hpa_size[i], 16) <= 512 * 1024 * 1024):
low_mem_hpa_len.append(int(hpa_size[i], 16) - 1 * 1024 * 1024)
high_mem_hpa_len.append(0)
@@ -58,7 +59,7 @@ def ve820_per_launch(config, hpa_size, hpa2_size):
else:
print("#define VM{}_VE820_ENTRIES_{}\t{}U".format(i, board_name, 5), file=config)

- for i in range(board_cfg_lib.VM_COUNT):
+ for i in range(pre_vm_cnt):
print("static const struct e820_entry vm{}_ve820_entry[{}] = {{".format(
i, "VM{}_VE820_ENTRIES_{}".format(i, board_name)), file=config)
print("\t{\t/* usable RAM under 1MB */", file=config)
@@ -144,7 +145,7 @@ def ve820_per_launch(config, hpa_size, hpa2_size):
print("*/", file=config)
print("void create_prelaunched_vm_e820(struct acrn_vm *vm)", file=config)
print("{", file=config)
- for i in range(board_cfg_lib.VM_COUNT):
+ for i in range(pre_vm_cnt):
print("\tif (vm->vm_id == {}U)".format(hex(i)), file=config)
print("\t{", file=config)
print("\t\tvm->e820_entry_num = VM{}_VE820_ENTRIES_{};".format(i, board_name), file=config)
@@ -202,7 +203,7 @@ def generate_file(config):
return err_dic

# HPA size for both VMs should have valid length.
- for i in range(board_cfg_lib.VM_COUNT):
+ for i in range(pre_vm_cnt):
if hpa_size_list[i] == '0x0' or hpa_size_list[i] == '0X0':
board_cfg_lib.print_red("HPA size should not be zero", err=True)
err_dic['board config: generate ve820.c failed'] = "HPA size should not be zero"
diff --git a/misc/acrn-config/scenario_config/vm_configurations_h.py b/misc/acrn-config/scenario_config/vm_configurations_h.py
index 05ce22aa..68524921 100644
--- a/misc/acrn-config/scenario_config/vm_configurations_h.py
+++ b/misc/acrn-config/scenario_config/vm_configurations_h.py
@@ -176,7 +176,7 @@ def gen_logical_partition_header(vm_info, config):
i, vm_info.mem_info.mem_size[i]), file=config)
print("#define VM{0}_CONFIG_MEM_START_HPA2\t\t{1}UL".format(
i, vm_info.mem_info.mem_start_hpa2[i]), file=config)
- print("#define VM{0}_CONFIG_MEM_SIZE_HPA2\t\t\t{1}UL".format(
+ print("#define VM{0}_CONFIG_MEM_SIZE_HPA2\t\t{1}UL".format(
i, vm_info.mem_info.mem_size_hpa2[i]), file=config)
print('#define VM{0}_CONFIG_OS_BOOTARG_ROOT\t\t"root={1} "'.format(
i, vm_info.os_cfg.kern_root_dev[i]), file=config)
@@ -279,7 +279,7 @@ def gen_hybrid_header(vm_info, config):
print("#define VM0_CONFIG_MEM_SIZE\t\t{0}UL".format(vm_info.mem_info.mem_size[0]), file=config)
print("#define VM0_CONFIG_MEM_START_HPA2\t{0}UL".format(
vm_info.mem_info.mem_start_hpa2[0]), file=config)
- print("#define VM0_CONFIG_MEM_SIZE_HPA2\t\t{0}UL".format(vm_info.mem_info.mem_size_hpa2[0]), file=config)
+ print("#define VM0_CONFIG_MEM_SIZE_HPA2\t{0}UL".format(vm_info.mem_info.mem_size_hpa2[0]), file=config)
print("", file=config)
print("#define SOS_VM_BOOTARGS\t\t\tSOS_ROOTFS\t\\", file=config)
print('\t\t\t\t\t"rw rootwait "\t\\', file=config)
diff --git a/misc/acrn-config/xmls/config-xmls/generic/hybrid.xml b/misc/acrn-config/xmls/config-xmls/generic/hybrid.xml
index eb90b841..52cfc49e 100644
--- a/misc/acrn-config/xmls/config-xmls/generic/hybrid.xml
+++ b/misc/acrn-config/xmls/config-xmls/generic/hybrid.xml
@@ -17,6 +17,8 @@
<memory>
<start_hpa desc="The start physical address in host for the VM">0x100000000</start_hpa>
<size desc="The memory size in Bytes for the VM">0x20000000</size>
+ <start_hpa2 desc="The start physical address in host for the VM">0x0</start_hpa2>
+ <size_hpa2 desc="The memory size in Bytes for the VM">0x0</size_hpa2>
</memory>
<os_config>
<name desc="Specify the OS name of VM, currently it is not referenced by hypervisor code.">Zephyr</name>
--
2.17.2


[PATCH 1/2] HV: Extend non-contiguous HPA for hybrid scenario

Vijay Dhanraj
 

This patch extends non-contiguous HPA allocations for
pre-launched VMs in hybrid scenario.

Signed-off-by: Vijay Dhanraj <vijay.dhanraj@...>
---
hypervisor/arch/x86/guest/vm.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c
index c9fa2eaf..593e519b 100644
--- a/hypervisor/arch/x86/guest/vm.c
+++ b/hypervisor/arch/x86/guest/vm.c
@@ -321,6 +321,13 @@ static void create_sos_vm_e820(struct acrn_vm *vm)
filter_mem_from_sos_e820(vm, vm_config->memory.start_hpa,
vm_config->memory.start_hpa + vm_config->memory.size);
sos_vm_config->memory.size -= vm_config->memory.size;
+
+ /* if HPA2 is available, filter it out as well*/
+ if (vm_config->memory.size_hpa2 != 0UL) {
+ filter_mem_from_sos_e820(vm, vm_config->memory.start_hpa2,
+ vm_config->memory.start_hpa2 + vm_config->memory.size_hpa2);
+ sos_vm_config->memory.size -= vm_config->memory.size_hpa2;
+ }
}
}
}
--
2.17.2


[PATCH 0/2] Extend non-contiguos HPA for Hybrid mode

Vijay Dhanraj
 

These patches extend the non-contiguos HPA allocations to hybrid mode.

Vijay Dhanraj (2):
HV: Extend non-contiguous HPA for hybrid scenario
acrn-config: support non-contiguous HPA for hybrid scenario

hypervisor/arch/x86/guest/vm.c | 7 +++++++
misc/acrn-config/board_config/ve820_c.py | 9 +++++----
misc/acrn-config/scenario_config/vm_configurations_h.py | 4 ++--
misc/acrn-config/xmls/config-xmls/generic/hybrid.xml | 2 ++
4 files changed, 16 insertions(+), 6 deletions(-)

--
2.17.2


Re: [PATCH 0/7] Use NMI to nofity vCPUs with lapic-pt

Grandhi, Sainath
 

Thanks. That makes sense.

-----Original Message-----
From: acrn-dev@... <acrn-dev@...> On
Behalf Of Kaige Fu
Sent: Sunday, December 08, 2019 9:29 PM
To: acrn-dev@...
Subject: Re: [acrn-dev] [PATCH 0/7] Use NMI to nofity vCPUs with lapic-pt

Hi Sainath,

-----Original Message-----
From: acrn-dev@... <acrn-dev@...>
On Behalf Of Kaige Fu
Sent: Sunday, December 8, 2019 7:39 PM
To: acrn-dev@...
Subject: Re: [acrn-dev] [PATCH 0/7] Use NMI to nofity vCPUs with
lapic-pt

Hi Sainath,

Thanks for your review. Comment inline.

-----Original Message-----
From: acrn-dev@...
<acrn-dev@...> On Behalf Of Grandhi, Sainath
Sent: Friday, December 6, 2019 2:22 PM
To: acrn-dev@...
Subject: Re: [acrn-dev] [PATCH 0/7] Use NMI to nofity vCPUs with
lapic-pt



-----Original Message-----
From: acrn-dev@...
<acrn-dev@...> On Behalf Of Kaige Fu
Sent: Friday, December 06, 2019 5:48 AM
To: acrn-dev@...
Subject: [acrn-dev] [PATCH 0/7] Use NMI to nofity vCPUs with
lapic-pt

ACRN hypervisor needs to kick vCPU off VMX non-root mode to do
some operations in hypervisor, such as interrupt/exception
injection, EPT flush etc. For non lapic-pt vCPUs, we can use IPI
to do so. But, it doesn't work for lapic-pt vCPUs as the IPI will
be injected to VMs directly
without vmexit.

Consequently, there may be fatal errors triggered. 1). Certain
operation may not be carried out on time which may further lead to
fatal errors. Taking the EPT flush request as an example, once we
don't flush the EPT on time and the guest access the out-of-date
EPT, fatal error happens. 2). The IPI vector will be delivered to
VMs directly. If the guest can't handle it properly, further
interrupts might be
blocked which will cause the VMs hang.

The NMI can be used as the notification signal to kick the vCPU
off VMX non- root mode for lapic-pt vCPUs. This patchset does it
by enable NMI-exiting after passthroughing the lapic to vCPU.

TODOs:
- Filter out all NMI sources:
* Write ICR with deliver mode NMI
* Program the MSI data with deliver mode NMI
* Program the LVTs with deliver mode NMI
- Implement the smp_call for lapic-pt VMs to facilitate the
debug of lapic-pt VMs.

Kaige Fu (7):
HV: Push NMI vector on to the exception stack
HV: Add helper function send_single_nmi
HV: Use NMI to kick lapic-pt vCPU's thread
HV: ignore the NMI injection request for lapic-pt vCPUs
HV: Use NMI-window exiting to address req missing issue
Hi Kaige,
This patch " Use NMI-window exiting to address req missing issue"
has nothing to do LAPIC PT and "NMI being used for notification". Is
that
right?

When we use the NMI signal to kick the vCPU thread, there is such kind
of issue that we may miss the request in current notification period.
In this way, this patch has something to do with LAPIC PT and "NMI
being used for notification".

However, there may be the same issue when we use IPI for non lapic-pt
VMs to kick the vCPU thread.
I will investigate it and see if there is such kind of issue in current code.
I checked the current code. There is no such kind of issue for non lapic-pt VMs.
For non lapic-pt VMs, we use IPI to notify vCPU thread and the interrupts is
disabled between acrn_handle_pending_request and vmentry.

HV: Use NMI to replace INIT signal for lapic-pt VMs S5
HV: Remove INIT signal notification related code

hypervisor/arch/x86/guest/virq.c | 76 ++++++++++++++++++++--------
hypervisor/arch/x86/guest/vmcs.c | 18 +++++--
hypervisor/arch/x86/guest/vmexit.c | 23 +--------
hypervisor/arch/x86/idt.S | 6 +--
hypervisor/arch/x86/irq.c | 55 ++++++++++++++++----
hypervisor/arch/x86/lapic.c | 9 +---
hypervisor/common/schedule.c | 24 ++++++---
hypervisor/include/arch/x86/irq.h | 1 +
hypervisor/include/arch/x86/lapic.h | 4 +-
hypervisor/include/common/schedule.h | 4 +-
10 files changed, 146 insertions(+), 74 deletions(-)

--
2.20.0






Re: [PATCH v2 5/7] HV: Use NMI-window exiting to address req missing issue

Grandhi, Sainath
 

-----Original Message-----
From: acrn-dev@... <acrn-dev@...> On
Behalf Of Kaige Fu
Sent: Monday, December 09, 2019 8:48 AM
To: acrn-dev@...
Subject: [acrn-dev] [PATCH v2 5/7] HV: Use NMI-window exiting to address req
missing issue

There is a window where we may miss the current request in the notification
period when the work flow is as the following:

CPUx + + CPUr
| |
| +--+
| | | Handle pending req
| <--+
+--+ |
| | Set req flag |
<--+ |
+------------------>---+
| Send NMI | | Handle NMI
| <--+
| |
| |
| +--> vCPU enter
| |
+ +

So, this patch enables the NMI-window exiting to trigger the next vmexit once
there is no "virtual-NMI blocking" after vCPU enter into VMX non-root mode.
Then we can process the pending request on time.

Signed-off-by: Kaige Fu <kaige.fu@...>
---
hypervisor/arch/x86/guest/virq.c | 17 ++++++++++++++++
hypervisor/arch/x86/guest/vmcs.c | 2 +-
hypervisor/arch/x86/guest/vmexit.c | 2 +-
hypervisor/arch/x86/irq.c | 31 +++++++++++++++++++++++++++++-
hypervisor/include/arch/x86/irq.h | 1 +
5 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/hypervisor/arch/x86/guest/virq.c b/hypervisor/arch/x86/guest/virq.c
index 174c0fb3..a513a7da 100644
--- a/hypervisor/arch/x86/guest/virq.c
+++ b/hypervisor/arch/x86/guest/virq.c
@@ -533,3 +533,20 @@ int32_t exception_vmexit_handler(struct acrn_vcpu
*vcpu)

return status;
}
+
+int nmi_window_vmexit_handler(__unused struct acrn_vcpu *vcpu) {
+ uint32_t value32;
+
+ /*
+ * Disable NMI-window exiting here. We will process
+ * the pending request in acrn_handle_pending_request later
+ */
+ value32 = exec_vmread32(VMX_PROC_VM_EXEC_CONTROLS);
+ value32 &= ~VMX_PROCBASED_CTLS_NMI_WINEXIT;
+ exec_vmwrite32(VMX_PROC_VM_EXEC_CONTROLS, value32);
+
+ vcpu_retain_rip(vcpu);
+
+ return 0;
+}
diff --git a/hypervisor/arch/x86/guest/vmcs.c
b/hypervisor/arch/x86/guest/vmcs.c
index 1efa37db..7dd2d806 100644
--- a/hypervisor/arch/x86/guest/vmcs.c
+++ b/hypervisor/arch/x86/guest/vmcs.c
@@ -582,7 +582,7 @@ void switch_apicv_mode_x2apic(struct acrn_vcpu
*vcpu)
* directly without vmexit. So, here we enable NMI-exiting and
use NMI
* as notification signal after passthroughing the lapic to vCPU.
*/
- value32 |= VMX_PINBASED_CTLS_NMI_EXIT;
+ value32 |= VMX_PINBASED_CTLS_NMI_EXIT |
VMX_PINBASED_CTLS_VIRT_NMI;
exec_vmwrite32(VMX_PIN_VM_EXEC_CONTROLS, value32);

value32 = exec_vmread32(VMX_EXIT_CONTROLS); diff --git
a/hypervisor/arch/x86/guest/vmexit.c b/hypervisor/arch/x86/guest/vmexit.c
index 43c979f8..2c1a9d4b 100644
--- a/hypervisor/arch/x86/guest/vmexit.c
+++ b/hypervisor/arch/x86/guest/vmexit.c
@@ -51,7 +51,7 @@ static const struct vm_exit_dispatch
dispatch_table[NR_VMX_EXIT_REASONS] = {
[VMX_EXIT_REASON_INTERRUPT_WINDOW] = {
.handler = interrupt_window_vmexit_handler},
[VMX_EXIT_REASON_NMI_WINDOW] = {
- .handler = unhandled_vmexit_handler},
+ .handler = nmi_window_vmexit_handler},
[VMX_EXIT_REASON_TASK_SWITCH] = {
.handler = unhandled_vmexit_handler},
[VMX_EXIT_REASON_CPUID] = {
diff --git a/hypervisor/arch/x86/irq.c b/hypervisor/arch/x86/irq.c index
4460b44d..4a377239 100644
--- a/hypervisor/arch/x86/irq.c
+++ b/hypervisor/arch/x86/irq.c
@@ -18,6 +18,7 @@
#include <vboot.h>
#include <dump.h>
#include <logmsg.h>
+#include <vmx.h>

static spinlock_t exception_spinlock = { .head = 0U, .tail = 0U, }; static
spinlock_t irq_alloc_spinlock = { .head = 0U, .tail = 0U, }; @@ -368,9 +369,37
@@ void dispatch_interrupt(const struct intr_excp_ctx *ctx) void
dispatch_exception(struct intr_excp_ctx *ctx) {
uint16_t pcpu_id = get_pcpu_id();
+ uint32_t value32;

if (ctx->vector == IDT_NMI) {
- /* TODO: we will handle it later */
+ /*
+ * There is a window where we may miss the current request in
this
+ * notification period when the work flow is as the following:
+ *
+ * CPUx + + CPUr
+ * | |
+ * | +--+
+ * | | | Handle pending req
+ * | <--+
+ * +--+ |
+ * | | Set req flag |
+ * <--+ |
+ * +------------------>---+
+ * | Send NMI | | Handle NMI
+ * | <--+
+ * | |
+ * | |
+ * | +--> vCPU enter
+ * | |
+ * + +
+ *
+ * So, here we enable the NMI-window exiting to trigger the
next vmexit
+ * once there is no "virtual-NMI blocking" after vCPU enter into
VMX non-root
+ * mode. Then we can process the pending request on time.
+ */
+ value32 = exec_vmread32(VMX_PROC_VM_EXEC_CONTROLS);
+ value32 |= VMX_PROCBASED_CTLS_NMI_WINEXIT;
+ exec_vmwrite32(VMX_PROC_VM_EXEC_CONTROLS, value32);
Hi Kaige,
What if the reason of NMI is not due to hypervisor related notification? Can we check if there is a pending request against the vCPU running on this pCPU before opening "NMI window"?
} else {
/* Obtain lock to ensure exception dump doesn't get corrupted
*/
spinlock_obtain(&exception_spinlock);
diff --git a/hypervisor/include/arch/x86/irq.h
b/hypervisor/include/arch/x86/irq.h
index 8f8f3967..a5ed3aed 100644
--- a/hypervisor/include/arch/x86/irq.h
+++ b/hypervisor/include/arch/x86/irq.h
@@ -207,6 +207,7 @@ void vcpu_make_request(struct acrn_vcpu *vcpu,
uint16_t eventid);
* @pre vcpu != NULL
*/
int32_t exception_vmexit_handler(struct acrn_vcpu *vcpu);
+int32_t nmi_window_vmexit_handler(struct acrn_vcpu *vcpu);
int32_t interrupt_window_vmexit_handler(struct acrn_vcpu *vcpu); int32_t
external_interrupt_vmexit_handler(struct acrn_vcpu *vcpu); int32_t
acrn_handle_pending_request(struct acrn_vcpu *vcpu);
--
2.20.0



Re: [PATCH] acrn-config: UI supports virtio input devices edited by multi-lines.

Victor Sun
 

Reviewed-by: Victor Sun <victor.sun@...>

On 12/9/2019 5:18 PM, Zheng, Shuang wrote:
This is to make acrn config UI support to edit virtio input devices
by multi-lines.

Tracked-On: #4163
Signed-off-by: Shuang Zheng <shuang.zheng@...>
---
misc/acrn-config/config_app/static/main.js | 3 ++-
misc/acrn-config/config_app/templates/launch.html | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/misc/acrn-config/config_app/static/main.js b/misc/acrn-config/config_app/static/main.js
index 63ee8503..0e7cc6a5 100644
--- a/misc/acrn-config/config_app/static/main.js
+++ b/misc/acrn-config/config_app/static/main.js
@@ -511,7 +511,8 @@ function save_launch(generator=null) {
var id = $(this).attr('id');
var value = $(this).val();
- if(id.indexOf('virtio_devices,network')>=0 || id.indexOf('virtio_devices,block')>=0) {
+ if(id.indexOf('virtio_devices,network')>=0 || id.indexOf('virtio_devices,block')>=0
+ || id.indexOf('virtio_devices,input')>=0) {
if(id in launch_config) {
launch_config[id].push(value);
} else {
diff --git a/misc/acrn-config/config_app/templates/launch.html b/misc/acrn-config/config_app/templates/launch.html
index 18ff2146..d7bc681a 100644
--- a/misc/acrn-config/config_app/templates/launch.html
+++ b/misc/acrn-config/config_app/templates/launch.html
@@ -157,7 +157,7 @@
{% elif elem.getchildren() != [] %}
{% if 'multiselect' not in elem.attrib or elem.attrib['multiselect'] != 'true' %}
{% set first_child = [] %}
- {% set first_multi_child = {'block': 0, 'network': 0} %}
+ {% set first_multi_child = {'block': 0, 'network': 0, 'input': 0} %}
{% for sub_elem in elem.getchildren() %}
{% set sub_elem_text = '' if sub_elem.text == None else sub_elem.text %}
{% if 'configurable' not in sub_elem.attrib or sub_elem.attrib['configurable'] != '0' %}
@@ -191,7 +191,7 @@
{% endif %}
</div>
- {% if elem.tag in ['virtio_devices'] and sub_elem.tag in ['block', 'network'] %}
+ {% if elem.tag in ['virtio_devices'] and sub_elem.tag in ['block', 'network', 'input'] %}
<div class="col-sm-1">
<button type="button" class="btn" id="add_virtio_{{sub_elem.tag}}_{{first_multi_child[sub_elem.tag]}}">+</button>
{% if first_multi_child[sub_elem.tag] == 0 %}


[PATCH] acrn-config: UI supports virtio input devices edited by multi-lines.

Zheng, Shuang
 

This is to make acrn config UI support to edit virtio input devices
by multi-lines.

Tracked-On: #4163
Signed-off-by: Shuang Zheng <shuang.zheng@...>
---
misc/acrn-config/config_app/static/main.js | 3 ++-
misc/acrn-config/config_app/templates/launch.html | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/misc/acrn-config/config_app/static/main.js b/misc/acrn-config/config_app/static/main.js
index 63ee8503..0e7cc6a5 100644
--- a/misc/acrn-config/config_app/static/main.js
+++ b/misc/acrn-config/config_app/static/main.js
@@ -511,7 +511,8 @@ function save_launch(generator=null) {
var id = $(this).attr('id');
var value = $(this).val();

- if(id.indexOf('virtio_devices,network')>=0 || id.indexOf('virtio_devices,block')>=0) {
+ if(id.indexOf('virtio_devices,network')>=0 || id.indexOf('virtio_devices,block')>=0
+ || id.indexOf('virtio_devices,input')>=0) {
if(id in launch_config) {
launch_config[id].push(value);
} else {
diff --git a/misc/acrn-config/config_app/templates/launch.html b/misc/acrn-config/config_app/templates/launch.html
index 18ff2146..d7bc681a 100644
--- a/misc/acrn-config/config_app/templates/launch.html
+++ b/misc/acrn-config/config_app/templates/launch.html
@@ -157,7 +157,7 @@
{% elif elem.getchildren() != [] %}
{% if 'multiselect' not in elem.attrib or elem.attrib['multiselect'] != 'true' %}
{% set first_child = [] %}
- {% set first_multi_child = {'block': 0, 'network': 0} %}
+ {% set first_multi_child = {'block': 0, 'network': 0, 'input': 0} %}
{% for sub_elem in elem.getchildren() %}
{% set sub_elem_text = '' if sub_elem.text == None else sub_elem.text %}
{% if 'configurable' not in sub_elem.attrib or sub_elem.attrib['configurable'] != '0' %}
@@ -191,7 +191,7 @@
{% endif %}
</div>

- {% if elem.tag in ['virtio_devices'] and sub_elem.tag in ['block', 'network'] %}
+ {% if elem.tag in ['virtio_devices'] and sub_elem.tag in ['block', 'network', 'input'] %}
<div class="col-sm-1">
<button type="button" class="btn" id="add_virtio_{{sub_elem.tag}}_{{first_multi_child[sub_elem.tag]}}">+</button>
{% if first_multi_child[sub_elem.tag] == 0 %}
--
2.23.0


[PATCH v2 7/7] HV: Remove INIT signal notification related code

Kaige Fu
 

We don't use INIT signal notification method now. This patch
removes them.

Signed-off-by: Kaige Fu <kaige.fu@...>
---
hypervisor/arch/x86/guest/vmexit.c | 21 +--------------------
hypervisor/arch/x86/lapic.c | 20 --------------------
hypervisor/common/schedule.c | 5 +----
hypervisor/include/arch/x86/lapic.h | 9 ---------
hypervisor/include/common/schedule.h | 4 +---
5 files changed, 3 insertions(+), 56 deletions(-)

diff --git a/hypervisor/arch/x86/guest/vmexit.c b/hypervisor/arch/x86/guest/vmexit.c
index 2c1a9d4b..1ab69835 100644
--- a/hypervisor/arch/x86/guest/vmexit.c
+++ b/hypervisor/arch/x86/guest/vmexit.c
@@ -30,7 +30,6 @@ static int32_t unhandled_vmexit_handler(struct acrn_vcpu *vcpu);
static int32_t xsetbv_vmexit_handler(struct acrn_vcpu *vcpu);
static int32_t wbinvd_vmexit_handler(struct acrn_vcpu *vcpu);
static int32_t undefined_vmexit_handler(struct acrn_vcpu *vcpu);
-static int32_t init_signal_vmexit_handler(__unused struct acrn_vcpu *vcpu);

/* VM Dispatch table for Exit condition handling */
static const struct vm_exit_dispatch dispatch_table[NR_VMX_EXIT_REASONS] = {
@@ -41,7 +40,7 @@ static const struct vm_exit_dispatch dispatch_table[NR_VMX_EXIT_REASONS] = {
[VMX_EXIT_REASON_TRIPLE_FAULT] = {
.handler = triple_fault_vmexit_handler},
[VMX_EXIT_REASON_INIT_SIGNAL] = {
- .handler = init_signal_vmexit_handler},
+ .handler = undefined_vmexit_handler},
[VMX_EXIT_REASON_STARTUP_IPI] = {
.handler = unhandled_vmexit_handler},
[VMX_EXIT_REASON_IO_SMI] = {
@@ -372,21 +371,3 @@ static int32_t undefined_vmexit_handler(struct acrn_vcpu *vcpu)
vcpu_inject_ud(vcpu);
return 0;
}
-
-/*
- * This handler is only triggered by INIT signal when poweroff from inside of RTVM
- */
-static int32_t init_signal_vmexit_handler(__unused struct acrn_vcpu *vcpu)
-{
- /*
- * Intel SDM Volume 3, 25.2:
- * INIT signals. INIT signals cause VM exits. A logical processer performs none
- * of the operations normally associated with these events. Such exits do not modify
- * register state or clear pending events as they would outside of VMX operation (If
- * a logical processor is the wait-for-SIPI state, INIT signals are blocked. They do
- * not cause VM exits in this case).
- *
- * So, it is safe to ignore the signal and reture here.
- */
- return 0;
-}
diff --git a/hypervisor/arch/x86/lapic.c b/hypervisor/arch/x86/lapic.c
index a54cb067..498a7972 100644
--- a/hypervisor/arch/x86/lapic.c
+++ b/hypervisor/arch/x86/lapic.c
@@ -269,26 +269,6 @@ void send_single_ipi(uint16_t pcpu_id, uint32_t vector)
}
}

-/**
- * @pre pcpu_id < CONFIG_MAX_PCPU_NUM
- *
- * @return None
- */
-void send_single_init(uint16_t pcpu_id)
-{
- union apic_icr icr;
-
- /*
- * Intel SDM Vol3 23.8:
- * The INIT signal is blocked whenever a logical processor is in VMX root operation.
- * It is not blocked in VMX nonroot operation. Instead, INITs cause VM exits
- */
- icr.value_32.hi_32 = per_cpu(lapic_id, pcpu_id);
- icr.value_32.lo_32 = (INTR_LAPIC_ICR_PHYSICAL << 11U) | (INTR_LAPIC_ICR_INIT << 8U);
-
- msr_write(MSR_IA32_EXT_APIC_ICR, icr.value);
-}
-
/**
* @pre pcpu_id < CONFIG_MAX_PCPU_NUM
*
diff --git a/hypervisor/common/schedule.c b/hypervisor/common/schedule.c
index b846863d..e5714c36 100644
--- a/hypervisor/common/schedule.c
+++ b/hypervisor/common/schedule.c
@@ -118,7 +118,7 @@ struct thread_object *sched_get_current(uint16_t pcpu_id)
}

/**
- * @pre delmode == DEL_MODE_IPI || delmode == DEL_MODE_INIT || delmode == DEL_MODE_NMI
+ * @pre delmode == DEL_MODE_IPI || delmode == DEL_MODE_NMI
*/
void make_reschedule_request(uint16_t pcpu_id, uint16_t delmode)
{
@@ -130,9 +130,6 @@ void make_reschedule_request(uint16_t pcpu_id, uint16_t delmode)
case DEL_MODE_IPI:
send_single_ipi(pcpu_id, VECTOR_NOTIFY_VCPU);
break;
- case DEL_MODE_INIT:
- send_single_init(pcpu_id);
- break;
case DEL_MODE_NMI:
send_single_nmi(pcpu_id);
break;
diff --git a/hypervisor/include/arch/x86/lapic.h b/hypervisor/include/arch/x86/lapic.h
index 9b59c21d..b345ff6b 100644
--- a/hypervisor/include/arch/x86/lapic.h
+++ b/hypervisor/include/arch/x86/lapic.h
@@ -174,15 +174,6 @@ void send_single_ipi(uint16_t pcpu_id, uint32_t vector);
*/
/* End of ipi_ext_apis */

-/**
- * @brief Send an INIT signal to a single pCPU
- *
- * @param[in] pcpu_id The id of destination physical cpu
- *
- * @return None
- */
-void send_single_init(uint16_t pcpu_id);
-
/**
* @brief Send an NMI signal to a single pCPU
*
diff --git a/hypervisor/include/common/schedule.h b/hypervisor/include/common/schedule.h
index 27aa4db7..473aff56 100644
--- a/hypervisor/include/common/schedule.h
+++ b/hypervisor/include/common/schedule.h
@@ -10,9 +10,8 @@

#define NEED_RESCHEDULE (1U)

-#define DEL_MODE_INIT (1U)
+#define DEL_MODE_NMI (1U)
#define DEL_MODE_IPI (2U)
-#define DEL_MODE_NMI (3U)

#define THREAD_DATA_SIZE (256U)

@@ -23,7 +22,6 @@ enum thread_object_state {
};

enum sched_notify_mode {
- SCHED_NOTIFY_INIT,
SCHED_NOTIFY_NMI,
SCHED_NOTIFY_IPI
};
--
2.20.0


[PATCH v2 6/7] HV: Use NMI to replace INIT signal for lapic-pt VMs S5

Kaige Fu
 

We have implemented a new notification method using NMI.
So replace the INIT notification method with the NMI one.
Then we can remove INIT notification related code later.

Signed-off-by: Kaige Fu <kaige.fu@...>
---
hypervisor/arch/x86/guest/vmcs.c | 7 ++++---
hypervisor/common/schedule.c | 4 ++--
hypervisor/include/common/schedule.h | 1 +
3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/hypervisor/arch/x86/guest/vmcs.c b/hypervisor/arch/x86/guest/vmcs.c
index 7dd2d806..a125e2de 100644
--- a/hypervisor/arch/x86/guest/vmcs.c
+++ b/hypervisor/arch/x86/guest/vmcs.c
@@ -606,10 +606,11 @@ void switch_apicv_mode_x2apic(struct acrn_vcpu *vcpu)
update_msr_bitmap_x2apic_passthru(vcpu);

/*
- * After passthroughing lapic to guest, we should use INIT signal to
- * notify vcpu thread instead of IPI
+ * After passthroughing lapic to guest, we should use NMI signal to
+ * notify vcpu thread instead of IPI. Because the IPI will be delivered
+ * the guest directly without vmexit.
*/
- vcpu->thread_obj.notify_mode = SCHED_NOTIFY_INIT;
+ vcpu->thread_obj.notify_mode = SCHED_NOTIFY_NMI;
} else {
value32 = exec_vmread32(VMX_PROC_VM_EXEC_CONTROLS2);
value32 &= ~VMX_PROCBASED_CTLS2_VAPIC;
diff --git a/hypervisor/common/schedule.c b/hypervisor/common/schedule.c
index 327d4cc6..b846863d 100644
--- a/hypervisor/common/schedule.c
+++ b/hypervisor/common/schedule.c
@@ -197,8 +197,8 @@ void sleep_thread(struct thread_object *obj)
scheduler->sleep(obj);
}
if (is_running(obj)) {
- if (obj->notify_mode == SCHED_NOTIFY_INIT) {
- make_reschedule_request(pcpu_id, DEL_MODE_INIT);
+ if (obj->notify_mode == SCHED_NOTIFY_NMI) {
+ make_reschedule_request(pcpu_id, DEL_MODE_NMI);
} else {
make_reschedule_request(pcpu_id, DEL_MODE_IPI);
}
diff --git a/hypervisor/include/common/schedule.h b/hypervisor/include/common/schedule.h
index 0a407fb1..27aa4db7 100644
--- a/hypervisor/include/common/schedule.h
+++ b/hypervisor/include/common/schedule.h
@@ -24,6 +24,7 @@ enum thread_object_state {

enum sched_notify_mode {
SCHED_NOTIFY_INIT,
+ SCHED_NOTIFY_NMI,
SCHED_NOTIFY_IPI
};

--
2.20.0


[PATCH v2 5/7] HV: Use NMI-window exiting to address req missing issue

Kaige Fu
 

There is a window where we may miss the current request in the
notification period when the work flow is as the following:

CPUx + + CPUr
| |
| +--+
| | | Handle pending req
| <--+
+--+ |
| | Set req flag |
<--+ |
+------------------>---+
| Send NMI | | Handle NMI
| <--+
| |
| |
| +--> vCPU enter
| |
+ +

So, this patch enables the NMI-window exiting to trigger the next vmexit
once there is no "virtual-NMI blocking" after vCPU enter into VMX non-root
mode. Then we can process the pending request on time.

Signed-off-by: Kaige Fu <kaige.fu@...>
---
hypervisor/arch/x86/guest/virq.c | 17 ++++++++++++++++
hypervisor/arch/x86/guest/vmcs.c | 2 +-
hypervisor/arch/x86/guest/vmexit.c | 2 +-
hypervisor/arch/x86/irq.c | 31 +++++++++++++++++++++++++++++-
hypervisor/include/arch/x86/irq.h | 1 +
5 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/hypervisor/arch/x86/guest/virq.c b/hypervisor/arch/x86/guest/virq.c
index 174c0fb3..a513a7da 100644
--- a/hypervisor/arch/x86/guest/virq.c
+++ b/hypervisor/arch/x86/guest/virq.c
@@ -533,3 +533,20 @@ int32_t exception_vmexit_handler(struct acrn_vcpu *vcpu)

return status;
}
+
+int nmi_window_vmexit_handler(__unused struct acrn_vcpu *vcpu)
+{
+ uint32_t value32;
+
+ /*
+ * Disable NMI-window exiting here. We will process
+ * the pending request in acrn_handle_pending_request later
+ */
+ value32 = exec_vmread32(VMX_PROC_VM_EXEC_CONTROLS);
+ value32 &= ~VMX_PROCBASED_CTLS_NMI_WINEXIT;
+ exec_vmwrite32(VMX_PROC_VM_EXEC_CONTROLS, value32);
+
+ vcpu_retain_rip(vcpu);
+
+ return 0;
+}
diff --git a/hypervisor/arch/x86/guest/vmcs.c b/hypervisor/arch/x86/guest/vmcs.c
index 1efa37db..7dd2d806 100644
--- a/hypervisor/arch/x86/guest/vmcs.c
+++ b/hypervisor/arch/x86/guest/vmcs.c
@@ -582,7 +582,7 @@ void switch_apicv_mode_x2apic(struct acrn_vcpu *vcpu)
* directly without vmexit. So, here we enable NMI-exiting and use NMI
* as notification signal after passthroughing the lapic to vCPU.
*/
- value32 |= VMX_PINBASED_CTLS_NMI_EXIT;
+ value32 |= VMX_PINBASED_CTLS_NMI_EXIT | VMX_PINBASED_CTLS_VIRT_NMI;
exec_vmwrite32(VMX_PIN_VM_EXEC_CONTROLS, value32);

value32 = exec_vmread32(VMX_EXIT_CONTROLS);
diff --git a/hypervisor/arch/x86/guest/vmexit.c b/hypervisor/arch/x86/guest/vmexit.c
index 43c979f8..2c1a9d4b 100644
--- a/hypervisor/arch/x86/guest/vmexit.c
+++ b/hypervisor/arch/x86/guest/vmexit.c
@@ -51,7 +51,7 @@ static const struct vm_exit_dispatch dispatch_table[NR_VMX_EXIT_REASONS] = {
[VMX_EXIT_REASON_INTERRUPT_WINDOW] = {
.handler = interrupt_window_vmexit_handler},
[VMX_EXIT_REASON_NMI_WINDOW] = {
- .handler = unhandled_vmexit_handler},
+ .handler = nmi_window_vmexit_handler},
[VMX_EXIT_REASON_TASK_SWITCH] = {
.handler = unhandled_vmexit_handler},
[VMX_EXIT_REASON_CPUID] = {
diff --git a/hypervisor/arch/x86/irq.c b/hypervisor/arch/x86/irq.c
index 4460b44d..4a377239 100644
--- a/hypervisor/arch/x86/irq.c
+++ b/hypervisor/arch/x86/irq.c
@@ -18,6 +18,7 @@
#include <vboot.h>
#include <dump.h>
#include <logmsg.h>
+#include <vmx.h>

static spinlock_t exception_spinlock = { .head = 0U, .tail = 0U, };
static spinlock_t irq_alloc_spinlock = { .head = 0U, .tail = 0U, };
@@ -368,9 +369,37 @@ void dispatch_interrupt(const struct intr_excp_ctx *ctx)
void dispatch_exception(struct intr_excp_ctx *ctx)
{
uint16_t pcpu_id = get_pcpu_id();
+ uint32_t value32;

if (ctx->vector == IDT_NMI) {
- /* TODO: we will handle it later */
+ /*
+ * There is a window where we may miss the current request in this
+ * notification period when the work flow is as the following:
+ *
+ * CPUx + + CPUr
+ * | |
+ * | +--+
+ * | | | Handle pending req
+ * | <--+
+ * +--+ |
+ * | | Set req flag |
+ * <--+ |
+ * +------------------>---+
+ * | Send NMI | | Handle NMI
+ * | <--+
+ * | |
+ * | |
+ * | +--> vCPU enter
+ * | |
+ * + +
+ *
+ * So, here we enable the NMI-window exiting to trigger the next vmexit
+ * once there is no "virtual-NMI blocking" after vCPU enter into VMX non-root
+ * mode. Then we can process the pending request on time.
+ */
+ value32 = exec_vmread32(VMX_PROC_VM_EXEC_CONTROLS);
+ value32 |= VMX_PROCBASED_CTLS_NMI_WINEXIT;
+ exec_vmwrite32(VMX_PROC_VM_EXEC_CONTROLS, value32);
} else {
/* Obtain lock to ensure exception dump doesn't get corrupted */
spinlock_obtain(&exception_spinlock);
diff --git a/hypervisor/include/arch/x86/irq.h b/hypervisor/include/arch/x86/irq.h
index 8f8f3967..a5ed3aed 100644
--- a/hypervisor/include/arch/x86/irq.h
+++ b/hypervisor/include/arch/x86/irq.h
@@ -207,6 +207,7 @@ void vcpu_make_request(struct acrn_vcpu *vcpu, uint16_t eventid);
* @pre vcpu != NULL
*/
int32_t exception_vmexit_handler(struct acrn_vcpu *vcpu);
+int32_t nmi_window_vmexit_handler(struct acrn_vcpu *vcpu);
int32_t interrupt_window_vmexit_handler(struct acrn_vcpu *vcpu);
int32_t external_interrupt_vmexit_handler(struct acrn_vcpu *vcpu);
int32_t acrn_handle_pending_request(struct acrn_vcpu *vcpu);
--
2.20.0


[PATCH v2 4/7] HV: ignore the NMI injection request for lapic-pt vCPUs

Kaige Fu
 

NMI will be used as notification signal for lapic-pt vCPUs and
ACRN doesn't support vNMI for lapic-pt vCPUs. Because it is not
possible to distinguish between notification NMIs and external NMIs
for lapic-pt vCPUs in some corner cases, eg: we can use a magic number
as identifier of notification NMIs. If it is set when receiving a NMI,
this NMI is processed as notification NMI. Otherwise, it is a external
NMI for lapic-pt vCPUs. It works well most of the time. But it won't work
for some corner cases, eg:

1. The sender CPU sets the identifier.
2. An external NMI occurs on the target CPU and then the target CPU will
treat this NMI as notification NMI by mistake.
3. The sender CPU sends the NMI to target CPU.

So, this patch ignores the pending NMI request and EXCP with vector 2.

Signed-off-by: Kaige Fu <kaige.fu@...>
---
hypervisor/arch/x86/guest/virq.c | 55 ++++++++++++++++++++------------
1 file changed, 35 insertions(+), 20 deletions(-)

diff --git a/hypervisor/arch/x86/guest/virq.c b/hypervisor/arch/x86/guest/virq.c
index a0be3c3d..174c0fb3 100644
--- a/hypervisor/arch/x86/guest/virq.c
+++ b/hypervisor/arch/x86/guest/virq.c
@@ -212,26 +212,36 @@ int32_t vcpu_queue_exception(struct acrn_vcpu *vcpu, uint32_t vector_arg, uint32
static void vcpu_inject_exception(struct acrn_vcpu *vcpu, uint32_t vector)
{
if (bitmap_test_and_clear_lock(ACRN_REQUEST_EXCP, &vcpu->arch.pending_req)) {
-
- if ((exception_type[vector] & EXCEPTION_ERROR_CODE_VALID) != 0U) {
- exec_vmwrite32(VMX_ENTRY_EXCEPTION_ERROR_CODE,
- vcpu->arch.exception_info.error);
- }
+ if (is_lapic_pt_enabled(vcpu) && (vector == IDT_NMI)) {
+ /*
+ * NMI will be used as notification signal for lapic-pt vCPUs and we
+ * don't support vNMI yet. So, here we just ignore the NMI injection
+ * request.
+ */
+ pr_warn("Don't allow to inject NMI to lapic-pt vCPU%u. Ignore this request.", vcpu->vcpu_id);
+ vcpu->arch.exception_info.exception = VECTOR_INVALID;
+ } else {
+ if ((exception_type[vector] & EXCEPTION_ERROR_CODE_VALID) != 0U) {
+ exec_vmwrite32(VMX_ENTRY_EXCEPTION_ERROR_CODE,
+ vcpu->arch.exception_info.error);
+ }

- exec_vmwrite32(VMX_ENTRY_INT_INFO_FIELD, VMX_INT_INFO_VALID |
- (exception_type[vector] << 8U) | (vector & 0xFFU));
+ exec_vmwrite32(VMX_ENTRY_INT_INFO_FIELD, VMX_INT_INFO_VALID |
+ (exception_type[vector] << 8U) | (vector & 0xFFU));

- vcpu->arch.exception_info.exception = VECTOR_INVALID;
+ vcpu->arch.exception_info.exception = VECTOR_INVALID;

- /* retain rip for exception injection */
- vcpu_retain_rip(vcpu);
+ /* retain rip for exception injection */
+ vcpu_retain_rip(vcpu);

- /* SDM 17.3.1.1 For any fault-class exception except a debug exception generated in response to an
- * instruction breakpoint, the value pushed for RF is 1.
- * #DB is treated as Trap in get_exception_type, so RF will not be set for instruction breakpoint.
- */
- if (get_exception_type(vector) == EXCEPTION_FAULT) {
- vcpu_set_rflags(vcpu, vcpu_get_rflags(vcpu) | HV_ARCH_VCPU_RFLAGS_RF);
+ /* SDM 17.3.1.1 For any fault-class exception except a debug exception generated
+ * in response to an instruction breakpoint, the value pushed for RF is 1.
+ * #DB is treated as Trap in get_exception_type, so RF will not be set for
+ * instruction breakpoint.
+ */
+ if (get_exception_type(vector) == EXCEPTION_FAULT) {
+ vcpu_set_rflags(vcpu, vcpu_get_rflags(vcpu) | HV_ARCH_VCPU_RFLAGS_RF);
+ }
}
}
}
@@ -389,10 +399,15 @@ int32_t acrn_handle_pending_request(struct acrn_vcpu *vcpu)
if (!injected) {
/* inject NMI before maskable hardware interrupt */
if (bitmap_test_and_clear_lock(ACRN_REQUEST_NMI, pending_req_bits)) {
- /* Inject NMI vector = 2 */
- exec_vmwrite32(VMX_ENTRY_INT_INFO_FIELD,
- VMX_INT_INFO_VALID | (VMX_INT_TYPE_NMI << 8U) | IDT_NMI);
- injected = true;
+ if (!is_lapic_pt_enabled(vcpu)) {
+ /* Inject NMI vector = 2 */
+ exec_vmwrite32(VMX_ENTRY_INT_INFO_FIELD,
+ VMX_INT_INFO_VALID | (VMX_INT_TYPE_NMI << 8U) | IDT_NMI);
+ injected = true;
+ } else {
+ pr_warn("Don't allow to inject NMI to lapic-pt vCPU%u. Ignore this request.",
+ vcpu->vcpu_id);
+ }
} else {
/* handling pending vector injection:
* there are many reason inject failed, we need re-inject again
--
2.20.0


[PATCH v2 3/7] HV: Use NMI to kick lapic-pt vCPU's thread

Kaige Fu
 

ACRN hypervisor needs to kick vCPU off VMX non-root mode to do some
operations in hypervisor, such as interrupt/exception injection, EPT
flush etc. For non lapic-pt vCPUs, we can use IPI to do so. But, it
doesn't work for lapic-pt vCPUs as the IPI will be injected to VMs
directly without vmexit.

There may be fatal errors triggered. 1). Certain operation may not be
carried out on time which may further lead to fatal errors. Taking the
EPT flush request as an example, once we don't flush the EPT on time and
the guest access the out-of-date EPT, fatal error happens. 2). The IPI
vector will be delivered to VMs directly. If the guest can't handle it
properly, further interrupts might be blocked which will cause the VMs
hang.

The NMI can be used as the notification signal to kick the vCPU off VMX
non-root mode for lapic-pt vCPUs. This patch does it by enable NMI-exiting
after passthroughing the lapic to vCPU.

Signed-off-by: Kaige Fu <kaige.fu@...>
---
hypervisor/arch/x86/guest/vmcs.c | 11 +++++++++++
hypervisor/arch/x86/irq.c | 20 ++++++++++++--------
hypervisor/common/schedule.c | 19 ++++++++++++++++---
hypervisor/include/common/schedule.h | 1 +
4 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/hypervisor/arch/x86/guest/vmcs.c b/hypervisor/arch/x86/guest/vmcs.c
index 6e2d7669..1efa37db 100644
--- a/hypervisor/arch/x86/guest/vmcs.c
+++ b/hypervisor/arch/x86/guest/vmcs.c
@@ -562,6 +562,7 @@ void switch_apicv_mode_x2apic(struct acrn_vcpu *vcpu)
* Disable posted interrupt processing
* update x2apic msr bitmap for pass-thru
* enable inteception only for ICR
+ * enable NMI exit as we will use NMI to kick vCPU thread
* disable pre-emption for TSC DEADLINE MSR
* Disable Register Virtualization and virtual interrupt delivery
* Disable "use TPR shadow"
@@ -572,6 +573,16 @@ void switch_apicv_mode_x2apic(struct acrn_vcpu *vcpu)
if (is_apicv_advanced_feature_supported()) {
value32 &= ~VMX_PINBASED_CTLS_POST_IRQ;
}
+
+ /*
+ * ACRN hypervisor needs to kick vCPU off VMX non-root mode to do some
+ * operations in hypervisor, such as interrupt/exception injection, EPT
+ * flush etc. For non lapic-pt vCPUs, we can use IPI to do so. But, it
+ * doesn't work for lapic-pt vCPUs as the IPI will be injected to VMs
+ * directly without vmexit. So, here we enable NMI-exiting and use NMI
+ * as notification signal after passthroughing the lapic to vCPU.
+ */
+ value32 |= VMX_PINBASED_CTLS_NMI_EXIT;
exec_vmwrite32(VMX_PIN_VM_EXEC_CONTROLS, value32);

value32 = exec_vmread32(VMX_EXIT_CONTROLS);
diff --git a/hypervisor/arch/x86/irq.c b/hypervisor/arch/x86/irq.c
index 6a55418c..4460b44d 100644
--- a/hypervisor/arch/x86/irq.c
+++ b/hypervisor/arch/x86/irq.c
@@ -369,17 +369,21 @@ void dispatch_exception(struct intr_excp_ctx *ctx)
{
uint16_t pcpu_id = get_pcpu_id();

- /* Obtain lock to ensure exception dump doesn't get corrupted */
- spinlock_obtain(&exception_spinlock);
+ if (ctx->vector == IDT_NMI) {
+ /* TODO: we will handle it later */
+ } else {
+ /* Obtain lock to ensure exception dump doesn't get corrupted */
+ spinlock_obtain(&exception_spinlock);

- /* Dump exception context */
- dump_exception(ctx, pcpu_id);
+ /* Dump exception context */
+ dump_exception(ctx, pcpu_id);

- /* Release lock to let other CPUs handle exception */
- spinlock_release(&exception_spinlock);
+ /* Release lock to let other CPUs handle exception */
+ spinlock_release(&exception_spinlock);

- /* Halt the CPU */
- cpu_dead();
+ /* Halt the CPU */
+ cpu_dead();
+ }
}

static void init_irq_descs(void)
diff --git a/hypervisor/common/schedule.c b/hypervisor/common/schedule.c
index 847bafd0..327d4cc6 100644
--- a/hypervisor/common/schedule.c
+++ b/hypervisor/common/schedule.c
@@ -118,7 +118,7 @@ struct thread_object *sched_get_current(uint16_t pcpu_id)
}

/**
- * @pre delmode == DEL_MODE_IPI || delmode == DEL_MODE_INIT
+ * @pre delmode == DEL_MODE_IPI || delmode == DEL_MODE_INIT || delmode == DEL_MODE_NMI
*/
void make_reschedule_request(uint16_t pcpu_id, uint16_t delmode)
{
@@ -133,6 +133,9 @@ void make_reschedule_request(uint16_t pcpu_id, uint16_t delmode)
case DEL_MODE_INIT:
send_single_init(pcpu_id);
break;
+ case DEL_MODE_NMI:
+ send_single_nmi(pcpu_id);
+ break;
default:
ASSERT(false, "Unknown delivery mode %u for pCPU%u", delmode, pcpu_id);
break;
@@ -230,10 +233,20 @@ void kick_thread(const struct thread_object *obj)
obtain_schedule_lock(pcpu_id, &rflag);
if (is_running(obj)) {
if (get_pcpu_id() != pcpu_id) {
- send_single_ipi(pcpu_id, VECTOR_NOTIFY_VCPU);
+ if (obj->notify_mode == SCHED_NOTIFY_IPI) {
+ send_single_ipi(pcpu_id, VECTOR_NOTIFY_VCPU);
+ } else {
+ /* For lapic-pt vCPUs */
+ send_single_nmi(pcpu_id);
+ }
}
} else if (is_runnable(obj)) {
- make_reschedule_request(pcpu_id, DEL_MODE_IPI);
+ if (obj->notify_mode == SCHED_NOTIFY_IPI) {
+ make_reschedule_request(pcpu_id, DEL_MODE_IPI);
+ } else {
+ /* For lapic-pt vCPUs */
+ make_reschedule_request(pcpu_id, DEL_MODE_NMI);
+ }
} else {
/* do nothing */
}
diff --git a/hypervisor/include/common/schedule.h b/hypervisor/include/common/schedule.h
index 808beacc..0a407fb1 100644
--- a/hypervisor/include/common/schedule.h
+++ b/hypervisor/include/common/schedule.h
@@ -12,6 +12,7 @@

#define DEL_MODE_INIT (1U)
#define DEL_MODE_IPI (2U)
+#define DEL_MODE_NMI (3U)

#define THREAD_DATA_SIZE (256U)

--
2.20.0

11121 - 11140 of 37094