Date   

Re: [PATCH 2/2] hv: move the define of MAX_IR_ENTRIES to offline tool

chenli.wei
 

On 5/14/2022 1:13 AM, Eddie Dong wrote:
Once you removed this, you can also remove ROUND2/4/8 MACROs.
OK

-----Original Message-----
From: acrn-dev@... <acrn-dev@...> On
Behalf Of chenli.wei
Sent: Friday, May 13, 2022 3:29 AM
To: Mao, Junjie <junjie.mao@...>; Li, Fei1 <fei1.li@...>; acrn-
dev@...
Cc: Wei, Chenli <chenli.wei@...>
Subject: [acrn-dev] [PATCH 2/2] hv: move the define of MAX_IR_ENTRIES to
offline tool

There is an issue of calculate 2^n roundup of CONFIG_MAX_PT_IRQ_ENTRIE,
and the code style is very ugly when we use macro to fix it.

So this patch move MAX_IR_ENTRIE to offline tool which could do align
check and calculate it automatically.

Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/include/arch/x86/asm/vtd.h | 7 -------
1 file changed, 7 deletions(-)

diff --git a/hypervisor/include/arch/x86/asm/vtd.h
b/hypervisor/include/arch/x86/asm/vtd.h
index 4d3518286..284fc62db 100644
--- a/hypervisor/include/arch/x86/asm/vtd.h
+++ b/hypervisor/include/arch/x86/asm/vtd.h
@@ -42,13 +42,6 @@
#define DMAR_ICS_REG 0x9cU /* Invalidation complete status register
*/
#define DMAR_IRTA_REG 0xb8U /* Interrupt remapping table addr
register */

-/* Make sure all PT IRQs work w/ interrupt remapping or post interrupt */ -
#if (CONFIG_MAX_PT_IRQ_ENTRIES <= 256) -#define MAX_IR_ENTRIES 256 -
#else -#define MAX_IR_ENTRIES
powerof2_roundup(CONFIG_MAX_PT_IRQ_ENTRIES)
-#endif
-
/* Values for entry_type in ACPI_DMAR_DEVICE_SCOPE - device types */
enum acpi_dmar_scope_type {
ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0,
--
2.17.1







Re: [PATCH 2/2] hv: move the define of MAX_IR_ENTRIES to offline tool

Eddie Dong
 

Once you removed this, you can also remove ROUND2/4/8 MACROs.

-----Original Message-----
From: acrn-dev@... <acrn-dev@...> On
Behalf Of chenli.wei
Sent: Friday, May 13, 2022 3:29 AM
To: Mao, Junjie <junjie.mao@...>; Li, Fei1 <fei1.li@...>; acrn-
dev@...
Cc: Wei, Chenli <chenli.wei@...>
Subject: [acrn-dev] [PATCH 2/2] hv: move the define of MAX_IR_ENTRIES to
offline tool

There is an issue of calculate 2^n roundup of CONFIG_MAX_PT_IRQ_ENTRIE,
and the code style is very ugly when we use macro to fix it.

So this patch move MAX_IR_ENTRIE to offline tool which could do align
check and calculate it automatically.

Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/include/arch/x86/asm/vtd.h | 7 -------
1 file changed, 7 deletions(-)

diff --git a/hypervisor/include/arch/x86/asm/vtd.h
b/hypervisor/include/arch/x86/asm/vtd.h
index 4d3518286..284fc62db 100644
--- a/hypervisor/include/arch/x86/asm/vtd.h
+++ b/hypervisor/include/arch/x86/asm/vtd.h
@@ -42,13 +42,6 @@
#define DMAR_ICS_REG 0x9cU /* Invalidation complete status register
*/
#define DMAR_IRTA_REG 0xb8U /* Interrupt remapping table addr
register */

-/* Make sure all PT IRQs work w/ interrupt remapping or post interrupt */ -
#if (CONFIG_MAX_PT_IRQ_ENTRIES <= 256) -#define MAX_IR_ENTRIES 256 -
#else -#define MAX_IR_ENTRIES
powerof2_roundup(CONFIG_MAX_PT_IRQ_ENTRIES)
-#endif
-
/* Values for entry_type in ACPI_DMAR_DEVICE_SCOPE - device types */
enum acpi_dmar_scope_type {
ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0,
--
2.17.1





Re: [PATCH 1/2] misc: add the define of MAX_IR_ENTRIES

chenli.wei
 

On 5/13/2022 8:34 PM, Geoffroy Van Cutsem wrote:
Here too, fix the typo _ENTRIE -> _ENTRIES (and throughout the patch series)
ok

-----Original Message-----
From: acrn-dev@... <acrn-dev@...> On
Behalf Of chenli.wei
Sent: Friday, May 13, 2022 12:29 pm
To: Mao, Junjie <junjie.mao@...>; Li, Fei1 <fei1.li@...>; acrn-
dev@...
Cc: Wei, Chenli <chenli.wei@...>
Subject: [acrn-dev] [PATCH 1/2] misc: add the define of MAX_IR_ENTRIES

The current code align MAX_IR_ENTRIE with the
CONFIG_MAX_PT_IRQ_ENTRIE roundup to 2^n, there is an issue of the
powerof2_roundup to calculate the macro, and the code style is very ugly
when we use macro to fix it.

So this patch move the calculate and define of MAX_IR_ENTRIE to offline
tool.

Signed-off-by: Chenli Wei <chenli.wei@...>
---
.../static_allocators/board_capability.py | 17 +++++++++++++++++
.../config_tools/xforms/vm_configurations.h.xsl | 5 +++++
2 files changed, 22 insertions(+)

diff --git a/misc/config_tools/static_allocators/board_capability.py
b/misc/config_tools/static_allocators/board_capability.py
index 5a98f472d..75f72afc2 100644
--- a/misc/config_tools/static_allocators/board_capability.py
+++ b/misc/config_tools/static_allocators/board_capability.py
@@ -7,6 +7,23 @@

import common

+def powerof2_roundup(value):
+ result = value
+ for i in [1, 2, 4, 8, 16]:
+ result = result | result >> i
+ return result + 1
+
+# Make sure all PT IRQs work w/ interrupt remapping or post interrupt
+def create_max_ir_entries(scenario_etree, allocation_etree):
+ pt_irq_entries = common.get_node(f"//MAX_PT_IRQ_ENTRIES/text()",
scenario_etree)
+ if (pt_irq_entries is not None) and (int(pt_irq_entries) > 256):
+ ir_entries = powerof2_roundup(int(pt_irq_entries) - 1)
+ else:
+ ir_entries = 256
+
+ common.append_node("/acrn-config/hv/MAX_IR_ENTRIES", ir_entries,
+ allocation_etree)
+
def fn(board_etree, scenario_etree, allocation_etree):
pci_bus_nums = board_etree.xpath("//bus[@type='pci']/@address")
common.append_node("/acrn-config/platform/MAX_PCI_BUS_NUM",
hex(max(map(lambda x: int(x, 16), pci_bus_nums)) + 1), allocation_etree)
+ create_max_ir_entries(scenario_etree, allocation_etree)
diff --git a/misc/config_tools/xforms/vm_configurations.h.xsl
b/misc/config_tools/xforms/vm_configurations.h.xsl
index f91c2720c..215a17fdd 100644
--- a/misc/config_tools/xforms/vm_configurations.h.xsl
+++ b/misc/config_tools/xforms/vm_configurations.h.xsl
@@ -34,6 +34,7 @@
<xsl:call-template name="vm_count" />
<xsl:call-template name="sos_vm_bootarges" />
<xsl:call-template name="vm_vuart_num" />
+ <xsl:call-template name="ir_entries" />
</xsl:template>

<xsl:template name ="vm_vuart_num">
@@ -50,6 +51,10 @@
<xsl:value-of select = "acrn:define('MAX_VUART_NUM_PER_VM',
math:max(str:split($vuart_nums, ',')), 'U')" />
</xsl:template>

+ <xsl:template name="ir_entries">
+ <xsl:value-of select = "acrn:define('MAX_IR_ENTRIES',
+ //MAX_IR_ENTRIES, 'U')" /> </xsl:template>
+
<xsl:template name ="vm_count">
<xsl:value-of select="acrn:comment('SERVICE_VM_NUM can only be 0 or
1; When SERVICE_VM_NUM is 1, MAX_POST_VM_NUM must be 0 too.')" />
<xsl:value-of select="$newline" />
--
2.17.1







Re: [PATCH 2/2] hv: move the define of MAX_IR_ENTRIES to offline tool

chenli.wei
 

On 5/13/2022 8:34 PM, Geoffroy Van Cutsem wrote:

-----Original Message-----
From: acrn-dev@... <acrn-dev@...> On
Behalf Of chenli.wei
Sent: Friday, May 13, 2022 12:29 pm
To: Mao, Junjie <junjie.mao@...>; Li, Fei1 <fei1.li@...>; acrn-
dev@...
Cc: Wei, Chenli <chenli.wei@...>
Subject: [acrn-dev] [PATCH 2/2] hv: move the define of MAX_IR_ENTRIES to
offline tool

There is an issue of calculate 2^n roundup of CONFIG_MAX_PT_IRQ_ENTRIE,
CONFIG_MAX_PT_IRQ_ENTRIE -> CONFIG_MAX_PT_IRQ_ENTRIES
OK

and the code style is very ugly when we use macro to fix it.

So this patch move MAX_IR_ENTRIE to offline tool which could do align check
MAX_IR_ENTRIE -> MAX_IR_ENTRIES
Done, thanks

and calculate it automatically.

Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/include/arch/x86/asm/vtd.h | 7 -------
1 file changed, 7 deletions(-)

diff --git a/hypervisor/include/arch/x86/asm/vtd.h
b/hypervisor/include/arch/x86/asm/vtd.h
index 4d3518286..284fc62db 100644
--- a/hypervisor/include/arch/x86/asm/vtd.h
+++ b/hypervisor/include/arch/x86/asm/vtd.h
@@ -42,13 +42,6 @@
#define DMAR_ICS_REG 0x9cU /* Invalidation complete status register */
#define DMAR_IRTA_REG 0xb8U /* Interrupt remapping table addr
register */

-/* Make sure all PT IRQs work w/ interrupt remapping or post interrupt */ -
#if (CONFIG_MAX_PT_IRQ_ENTRIES <= 256) -#define MAX_IR_ENTRIES 256 -
#else -#define MAX_IR_ENTRIES
powerof2_roundup(CONFIG_MAX_PT_IRQ_ENTRIES)
-#endif
-
/* Values for entry_type in ACPI_DMAR_DEVICE_SCOPE - device types */
enum acpi_dmar_scope_type {
ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0,
--
2.17.1







Re: [PATCH 1/2] misc: add the define of MAX_IR_ENTRIES

Geoffroy Van Cutsem
 

Here too, fix the typo _ENTRIE -> _ENTRIES (and throughout the patch series)

-----Original Message-----
From: acrn-dev@... <acrn-dev@...> On
Behalf Of chenli.wei
Sent: Friday, May 13, 2022 12:29 pm
To: Mao, Junjie <junjie.mao@...>; Li, Fei1 <fei1.li@...>; acrn-
dev@...
Cc: Wei, Chenli <chenli.wei@...>
Subject: [acrn-dev] [PATCH 1/2] misc: add the define of MAX_IR_ENTRIES

The current code align MAX_IR_ENTRIE with the
CONFIG_MAX_PT_IRQ_ENTRIE roundup to 2^n, there is an issue of the
powerof2_roundup to calculate the macro, and the code style is very ugly
when we use macro to fix it.

So this patch move the calculate and define of MAX_IR_ENTRIE to offline
tool.

Signed-off-by: Chenli Wei <chenli.wei@...>
---
.../static_allocators/board_capability.py | 17 +++++++++++++++++
.../config_tools/xforms/vm_configurations.h.xsl | 5 +++++
2 files changed, 22 insertions(+)

diff --git a/misc/config_tools/static_allocators/board_capability.py
b/misc/config_tools/static_allocators/board_capability.py
index 5a98f472d..75f72afc2 100644
--- a/misc/config_tools/static_allocators/board_capability.py
+++ b/misc/config_tools/static_allocators/board_capability.py
@@ -7,6 +7,23 @@

import common

+def powerof2_roundup(value):
+ result = value
+ for i in [1, 2, 4, 8, 16]:
+ result = result | result >> i
+ return result + 1
+
+# Make sure all PT IRQs work w/ interrupt remapping or post interrupt
+def create_max_ir_entries(scenario_etree, allocation_etree):
+ pt_irq_entries = common.get_node(f"//MAX_PT_IRQ_ENTRIES/text()",
scenario_etree)
+ if (pt_irq_entries is not None) and (int(pt_irq_entries) > 256):
+ ir_entries = powerof2_roundup(int(pt_irq_entries) - 1)
+ else:
+ ir_entries = 256
+
+ common.append_node("/acrn-config/hv/MAX_IR_ENTRIES", ir_entries,
+ allocation_etree)
+
def fn(board_etree, scenario_etree, allocation_etree):
pci_bus_nums = board_etree.xpath("//bus[@type='pci']/@address")
common.append_node("/acrn-config/platform/MAX_PCI_BUS_NUM",
hex(max(map(lambda x: int(x, 16), pci_bus_nums)) + 1), allocation_etree)
+ create_max_ir_entries(scenario_etree, allocation_etree)
diff --git a/misc/config_tools/xforms/vm_configurations.h.xsl
b/misc/config_tools/xforms/vm_configurations.h.xsl
index f91c2720c..215a17fdd 100644
--- a/misc/config_tools/xforms/vm_configurations.h.xsl
+++ b/misc/config_tools/xforms/vm_configurations.h.xsl
@@ -34,6 +34,7 @@
<xsl:call-template name="vm_count" />
<xsl:call-template name="sos_vm_bootarges" />
<xsl:call-template name="vm_vuart_num" />
+ <xsl:call-template name="ir_entries" />
</xsl:template>

<xsl:template name ="vm_vuart_num">
@@ -50,6 +51,10 @@
<xsl:value-of select = "acrn:define('MAX_VUART_NUM_PER_VM',
math:max(str:split($vuart_nums, ',')), 'U')" />
</xsl:template>

+ <xsl:template name="ir_entries">
+ <xsl:value-of select = "acrn:define('MAX_IR_ENTRIES',
+ //MAX_IR_ENTRIES, 'U')" /> </xsl:template>
+
<xsl:template name ="vm_count">
<xsl:value-of select="acrn:comment('SERVICE_VM_NUM can only be 0 or
1; When SERVICE_VM_NUM is 1, MAX_POST_VM_NUM must be 0 too.')" />
<xsl:value-of select="$newline" />
--
2.17.1





Re: [PATCH 2/2] hv: move the define of MAX_IR_ENTRIES to offline tool

Geoffroy Van Cutsem
 

-----Original Message-----
From: acrn-dev@... <acrn-dev@...> On
Behalf Of chenli.wei
Sent: Friday, May 13, 2022 12:29 pm
To: Mao, Junjie <junjie.mao@...>; Li, Fei1 <fei1.li@...>; acrn-
dev@...
Cc: Wei, Chenli <chenli.wei@...>
Subject: [acrn-dev] [PATCH 2/2] hv: move the define of MAX_IR_ENTRIES to
offline tool

There is an issue of calculate 2^n roundup of CONFIG_MAX_PT_IRQ_ENTRIE,
CONFIG_MAX_PT_IRQ_ENTRIE -> CONFIG_MAX_PT_IRQ_ENTRIES

and the code style is very ugly when we use macro to fix it.

So this patch move MAX_IR_ENTRIE to offline tool which could do align check
MAX_IR_ENTRIE -> MAX_IR_ENTRIES

and calculate it automatically.

Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/include/arch/x86/asm/vtd.h | 7 -------
1 file changed, 7 deletions(-)

diff --git a/hypervisor/include/arch/x86/asm/vtd.h
b/hypervisor/include/arch/x86/asm/vtd.h
index 4d3518286..284fc62db 100644
--- a/hypervisor/include/arch/x86/asm/vtd.h
+++ b/hypervisor/include/arch/x86/asm/vtd.h
@@ -42,13 +42,6 @@
#define DMAR_ICS_REG 0x9cU /* Invalidation complete status register */
#define DMAR_IRTA_REG 0xb8U /* Interrupt remapping table addr
register */

-/* Make sure all PT IRQs work w/ interrupt remapping or post interrupt */ -
#if (CONFIG_MAX_PT_IRQ_ENTRIES <= 256) -#define MAX_IR_ENTRIES 256 -
#else -#define MAX_IR_ENTRIES
powerof2_roundup(CONFIG_MAX_PT_IRQ_ENTRIES)
-#endif
-
/* Values for entry_type in ACPI_DMAR_DEVICE_SCOPE - device types */
enum acpi_dmar_scope_type {
ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0,
--
2.17.1





[PATCH 2/2] hv: move the define of MAX_IR_ENTRIES to offline tool

chenli.wei
 

There is an issue of calculate 2^n roundup of CONFIG_MAX_PT_IRQ_ENTRIE,
and the code style is very ugly when we use macro to fix it.

So this patch move MAX_IR_ENTRIE to offline tool which could do align
check and calculate it automatically.

Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/include/arch/x86/asm/vtd.h | 7 -------
1 file changed, 7 deletions(-)

diff --git a/hypervisor/include/arch/x86/asm/vtd.h b/hypervisor/include/arch/x86/asm/vtd.h
index 4d3518286..284fc62db 100644
--- a/hypervisor/include/arch/x86/asm/vtd.h
+++ b/hypervisor/include/arch/x86/asm/vtd.h
@@ -42,13 +42,6 @@
#define DMAR_ICS_REG 0x9cU /* Invalidation complete status register */
#define DMAR_IRTA_REG 0xb8U /* Interrupt remapping table addr register */

-/* Make sure all PT IRQs work w/ interrupt remapping or post interrupt */
-#if (CONFIG_MAX_PT_IRQ_ENTRIES <= 256)
-#define MAX_IR_ENTRIES 256
-#else
-#define MAX_IR_ENTRIES powerof2_roundup(CONFIG_MAX_PT_IRQ_ENTRIES)
-#endif
-
/* Values for entry_type in ACPI_DMAR_DEVICE_SCOPE - device types */
enum acpi_dmar_scope_type {
ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0,
--
2.17.1


[PATCH 1/2] misc: add the define of MAX_IR_ENTRIES

chenli.wei
 

The current code align MAX_IR_ENTRIE with the CONFIG_MAX_PT_IRQ_ENTRIE
roundup to 2^n, there is an issue of the powerof2_roundup to calculate
the macro, and the code style is very ugly when we use macro to fix it.

So this patch move the calculate and define of MAX_IR_ENTRIE to offline
tool.

Signed-off-by: Chenli Wei <chenli.wei@...>
---
.../static_allocators/board_capability.py | 17 +++++++++++++++++
.../config_tools/xforms/vm_configurations.h.xsl | 5 +++++
2 files changed, 22 insertions(+)

diff --git a/misc/config_tools/static_allocators/board_capability.py b/misc/config_tools/static_allocators/board_capability.py
index 5a98f472d..75f72afc2 100644
--- a/misc/config_tools/static_allocators/board_capability.py
+++ b/misc/config_tools/static_allocators/board_capability.py
@@ -7,6 +7,23 @@

import common

+def powerof2_roundup(value):
+ result = value
+ for i in [1, 2, 4, 8, 16]:
+ result = result | result >> i
+ return result + 1
+
+# Make sure all PT IRQs work w/ interrupt remapping or post interrupt
+def create_max_ir_entries(scenario_etree, allocation_etree):
+ pt_irq_entries = common.get_node(f"//MAX_PT_IRQ_ENTRIES/text()", scenario_etree)
+ if (pt_irq_entries is not None) and (int(pt_irq_entries) > 256):
+ ir_entries = powerof2_roundup(int(pt_irq_entries) - 1)
+ else:
+ ir_entries = 256
+
+ common.append_node("/acrn-config/hv/MAX_IR_ENTRIES", ir_entries, allocation_etree)
+
def fn(board_etree, scenario_etree, allocation_etree):
pci_bus_nums = board_etree.xpath("//bus[@type='pci']/@address")
common.append_node("/acrn-config/platform/MAX_PCI_BUS_NUM", hex(max(map(lambda x: int(x, 16), pci_bus_nums)) + 1), allocation_etree)
+ create_max_ir_entries(scenario_etree, allocation_etree)
diff --git a/misc/config_tools/xforms/vm_configurations.h.xsl b/misc/config_tools/xforms/vm_configurations.h.xsl
index f91c2720c..215a17fdd 100644
--- a/misc/config_tools/xforms/vm_configurations.h.xsl
+++ b/misc/config_tools/xforms/vm_configurations.h.xsl
@@ -34,6 +34,7 @@
<xsl:call-template name="vm_count" />
<xsl:call-template name="sos_vm_bootarges" />
<xsl:call-template name="vm_vuart_num" />
+ <xsl:call-template name="ir_entries" />
</xsl:template>

<xsl:template name ="vm_vuart_num">
@@ -50,6 +51,10 @@
<xsl:value-of select = "acrn:define('MAX_VUART_NUM_PER_VM', math:max(str:split($vuart_nums, ',')), 'U')" />
</xsl:template>

+ <xsl:template name="ir_entries">
+ <xsl:value-of select = "acrn:define('MAX_IR_ENTRIES', //MAX_IR_ENTRIES, 'U')" />
+ </xsl:template>
+
<xsl:template name ="vm_count">
<xsl:value-of select="acrn:comment('SERVICE_VM_NUM can only be 0 or 1; When SERVICE_VM_NUM is 1, MAX_POST_VM_NUM must be 0 too.')" />
<xsl:value-of select="$newline" />
--
2.17.1


[PATCH 0/2] Move the define of MAX_IR_ENTRIES to offline tool

chenli.wei
 

There is an issue of calculate 2^n roundup of CONFIG_MAX_PT_IRQ_ENTRIE,
and the code style is very ugly when we use macro to fix it.

So this series move MAX_IR_ENTRIE to offline tool to fix the issue and
clear HV code.

Chenli Wei (2):
misc: add the define of MAX_IR_ENTRIES
hv: move the define of MAX_IR_ENTRIES to offline tool

hypervisor/include/arch/x86/asm/vtd.h | 7 -------
.../static_allocators/board_capability.py | 17 +++++++++++++++++
.../config_tools/xforms/vm_configurations.h.xsl | 5 +++++
3 files changed, 22 insertions(+), 7 deletions(-)

--
2.17.1


[PATCH] config_tools: add placeholders in input widgets

Junjie Mao
 

The configurator today shows "Please Input" as the placeholder of input
widgets, which is far from informative.

This patch specifies element or type specific placeholders in the XML
schema by reusing the `acrn:widget-options` annotation mechanism. For
manually-designed widgets such as ivshmem or vUART the placeholders are
added in the corresponding vue directly.

Tracked-On: #6691
Signed-off-by: Junjie Mao <junjie.mao@...>
---
doc/scripts/configdoc.xsl | 7 +++-
.../CustomWidget/IVSHMEM_REGION.vue | 4 +--
.../Config/ConfigForm/CustomWidget/VUART.vue | 8 ++---
.../scenario_config/jsonschema/converter.py | 16 +++++----
misc/config_tools/schema/VMtypes.xsd | 36 ++++++++++---------
misc/config_tools/schema/config.xsd | 25 ++++++-------
misc/config_tools/schema/types.xsd | 6 ++--
7 files changed, 53 insertions(+), 49 deletions(-)

diff --git a/doc/scripts/configdoc.xsl b/doc/scripts/configdoc.xsl
index 5f393f911..2e1fbdf3d 100644
--- a/doc/scripts/configdoc.xsl
+++ b/doc/scripts/configdoc.xsl
@@ -5,7 +5,7 @@
<xsl:variable name="section_adornment" select="'#*=-%+@`'"/>
<xsl:variable name="vLower" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="vUpper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
- <!-- xslt script to autogenerate config option documentation -->
+ <!-- xslt script to autogenerate config option documentation -->
<!-- Get things started with the ACRNConfigType element -->
<xsl:template match="/xs:schema">
<xsl:apply-templates select="xs:complexType[@name='ACRNConfigType']">
@@ -204,6 +204,11 @@
<xsl:with-param name="indent" select="' '"/>
</xsl:call-template>
</xsl:when>
+ <xsl:when test="starts-with(xs:restriction/@base, 'xs:')">
+ <xsl:variable name="ty" select="xs:restriction/@base"/>
+ <xsl:value-of select="concat(translate(substring($ty, 4,1), $vLower, $vUpper), substring($ty,5),' value')"/>
+ <xsl:value-of select="$newline"/>
+ </xsl:when>
<xsl:otherwise>
<xsl:text>No type annotation found</xsl:text>
<xsl:value-of select="$newline"/>
diff --git a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/IVSHMEM_REGION.vue b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/IVSHMEM_REGION.vue
index 938acc481..2103269c4 100644
--- a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/IVSHMEM_REGION.vue
+++ b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/IVSHMEM_REGION.vue
@@ -9,7 +9,7 @@
<label>Region name: </label>
</b-col>
<b-col md="4">
- <b-form-input v-model="IVSHMEM_VMO.NAME"/>
+ <b-form-input v-model="IVSHMEM_VMO.NAME" placeholder="Any string with no white spaces."/>
</b-col>
</b-row>

@@ -48,7 +48,7 @@
<b-form-select v-model="IVSHMEM_VM.VM_NAME" :options="vmNames"></b-form-select>
</b-col>
<b-col sm="3">
- <b-form-input v-model="IVSHMEM_VM.VBDF"/>
+ <b-form-input v-model="IVSHMEM_VM.VBDF" placeholder="00:[device].[function], e.g. 00:0c.0. All fields are in hexadecimal."/>
</b-col>
<b-col sm="3">
<div class="ToolSet">
diff --git a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/VUART.vue b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/VUART.vue
index e15404b37..3fe4c536a 100644
--- a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/VUART.vue
+++ b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/VUART.vue
@@ -50,15 +50,15 @@
<b-row class="justify-content-sm-start align-items-center">
<b-col sm="4"> Connection_{{ index }}-{{ VUARTConn.endpoint[0].vm_name }} </b-col>
<b-col sm="4">
- <b-form-input v-model="VUARTConn.endpoint[0].io_port" v-if="VUARTConn.type === 'legacy'"/>
- <b-form-input v-model="VUARTConn.endpoint[0].vbdf" v-else-if="VUARTConn.type === 'pci'"/>
+ <b-form-input v-model="VUARTConn.endpoint[0].io_port" v-if="VUARTConn.type === 'legacy'" placeholder="An address in hexadecimal, e.g. 0x4000"/>
+ <b-form-input v-model="VUARTConn.endpoint[0].vbdf" v-else-if="VUARTConn.type === 'pci'" placeholder="00:[device].[function], e.g. 00:1c.0. All fields are in hexadecimal."/>
</b-col>
</b-row>
<b-row class="justify-content-sm-start align-items-center">
<b-col sm="4"> Connection_{{ index }}-{{ VUARTConn.endpoint[1].vm_name }} </b-col>
<b-col sm="4">
- <b-form-input v-model="VUARTConn.endpoint[1].io_port" v-if="VUARTConn.type === 'legacy'"/>
- <b-form-input v-model="VUARTConn.endpoint[1].vbdf" v-else-if="VUARTConn.type === 'pci'"/>
+ <b-form-input v-model="VUARTConn.endpoint[1].io_port" v-if="VUARTConn.type === 'legacy'" placeholder="An address in hexadecimal, e.g. 0x4000"/>
+ <b-form-input v-model="VUARTConn.endpoint[1].vbdf" v-else-if="VUARTConn.type === 'pci'" placeholder="00:[device].[function], e.g. 00:1c.0. All fields are in hexadecimal."/>
</b-col>
</b-row>
</div>
diff --git a/misc/config_tools/scenario_config/jsonschema/converter.py b/misc/config_tools/scenario_config/jsonschema/converter.py
index 15d32bb04..cabbe4bea 100644
--- a/misc/config_tools/scenario_config/jsonschema/converter.py
+++ b/misc/config_tools/scenario_config/jsonschema/converter.py
@@ -148,8 +148,8 @@ class XS2JS:
def convert_widget_config(self, annotation, js_ele):
if '@acrn:widget' in annotation:
js_ele['ui:widget'] = annotation['@acrn:widget']
- if '@acrn:widget-options' in annotation:
- js_ele['ui:options'] = {eval(k): eval(v) for k, v in [kv.split('=') for kv in annotation['@acrn:widget-options'].split(',')]}
+ if '@acrn:widget-options' in annotation:
+ js_ele['ui:options'] = eval(f"{{{annotation['@acrn:widget-options']}}}")

def xst2jst(self, type_name) -> str:
"""convert xml schema type name to json schema type name"""
@@ -195,9 +195,9 @@ class XS2JS:
enum_names.append(enum_name)
js_st["enumNames"] = enum_names

- # widget and its options
- if 'xs:annotation' in obj:
- self.convert_widget_config(obj['xs:annotation'], js_st)
+ # widget and its options
+ if 'xs:annotation' in obj:
+ self.convert_widget_config(obj['xs:annotation'], js_st)

js_st.update(self.xsa2jsa(restriction))
return js_st
@@ -297,12 +297,14 @@ class XS2JS:
required.append(name)

if '@maxOccurs' in element:
- possible_keys = ['type', '$ref', 'oneOf']
+ # ui:options seen at this moment are copied from the annotation of the type.
+ possible_keys = ['type', '$ref', 'oneOf', 'ui:options']
convert_to_items_success = False
+ js_ele['items'] = {}
for possible_key in possible_keys:
if possible_key not in js_ele:
continue
- js_ele['items'] = {possible_key: js_ele[possible_key]}
+ js_ele['items'][possible_key] = js_ele[possible_key]
del js_ele[possible_key]
convert_to_items_success = True

diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd
index 0701f00db..a61237bc0 100644
--- a/misc/config_tools/schema/VMtypes.xsd
+++ b/misc/config_tools/schema/VMtypes.xsd
@@ -147,17 +147,20 @@ The size is a subset of the VM's total memory size specified on the Basic tab.</
</xs:annotation>
</xs:element>
<xs:element name="kern_mod" type="xs:string" minOccurs="0">
- <xs:annotation acrn:title="Kernel module tag">
+ <xs:annotation acrn:title="Kernel module tag"
+ acrn:widget-options="'placeholder': 'An arbitrary string without white spaces. The same string shall be appended, in grub.conf, to the GRUB module containing the OS kernel.'">
<xs:documentation>Specify the tag for the kernel image that is used as a multiboot module. The tag's spelling must exactly match the module tag in the GRUB multiboot cmdline.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="ramdisk_mod" type="xs:string" minOccurs="0">
- <xs:annotation acrn:title="RAMdisk module tag">
+ <xs:annotation acrn:title="RAMdisk module tag"
+ acrn:widget-options="'placeholder': '(Optional) An arbitrary string without white spaces. The same string shall be appended, in grub.conf, to the GRUB module containing the OS ramdisk or initrd.'">
<xs:documentation>Specify the tag for the RAMdisk image that is used as a multiboot module. The tag's spelling must exactly match the module tag in the GRUB multiboot cmdline.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="bootargs" type="xs:string" minOccurs="0">
- <xs:annotation acrn:title="Kernel command-line parameters">
+ <xs:annotation acrn:title="Kernel command-line parameters"
+ acrn:widget-options="'placeholder': '(Optional) The command line options to be passed to the OS kernel.'">
<xs:documentation>Specify the command-line parameters that will be used to boot the kernel for this VM. See `Linux documentation &lt;https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html>;`__ for a list of parameters.</xs:documentation>
</xs:annotation>
</xs:element>
@@ -276,8 +279,7 @@ The size is a subset of the VM's total memory size specified on the Basic tab.</
<xs:complexType name="PCIDevsConfiguration">
<xs:sequence>
<xs:element name="pci_dev" type="xs:string" minOccurs="0" maxOccurs="unbounded">
- <xs:annotation acrn:title="PCI device assignment"
- acrn:options="//device[class]/@description" acrn:options-sorted-by="lambda s: (s.split(' ', maxsplit=1)[-1].split(':')[0], s.split(' ')[0])">
+ <xs:annotation acrn:options="//device[class]/@description" acrn:options-sorted-by="lambda s: (s.split(' ', maxsplit=1)[-1].split(':')[0], s.split(' ')[0])">
<xs:documentation>Select the PCI devices you want to assign to this virtual machine.</xs:documentation>
</xs:annotation>
</xs:element>
@@ -314,13 +316,13 @@ The size is a subset of the VM's total memory size specified on the Basic tab.</
</xs:annotation>
</xs:element>
<xs:element name="interface_name" minOccurs="0">
- <xs:annotation acrn:title="Network interface name">
+ <xs:annotation acrn:title="Network interface name" acrn:widget-options="'placeholder': 'An arbitrary-long string with letters, digits, underscores or dashes.'">
<xs:documentation>Specify the network interface name that will appear in the Service VM. Use the `ip a` command in the Service VM to display the network interface names.</xs:documentation>
</xs:annotation>
<xs:simpleType>
- <xs:annotation>
- <xs:documentation>A string of letters, digits, ``_``, or ``-``.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>A string of letters, digits, ``_``, or ``-``.</xs:documentation>
+ </xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="[a-zA-Z0-9_\-]+" />
</xs:restriction>
@@ -372,18 +374,18 @@ device file when user config it as virtio serial port, which can be read and wri
<xs:documentation>Specify backend device type in service VM.</xs:documentation>
</xs:annotation>
</xs:element>
- <xs:element name="output_file_path" type="xs:string" minOccurs="0" maxOccurs="1">
- <xs:annotation acrn:title="Output file path">
+ <xs:element name="output_file_path" type="xs:string" minOccurs="0">
+ <xs:annotation acrn:title="Output file path" acrn:widget-options="'placeholder': '/home/user/path/to/console_output.txt, needed only when backend type is file.'">
<xs:documentation>The output file path for the file backend type.</xs:documentation>
</xs:annotation>
</xs:element>
- <xs:element name="sock_file_path" type="xs:string" minOccurs="0" maxOccurs="1">
- <xs:annotation acrn:title="Sock file path">
+ <xs:element name="sock_file_path" type="xs:string" minOccurs="0">
+ <xs:annotation acrn:title="Sock file path" acrn:widget-options="'placeholder': '/path/to/file.sock, needed only when backend type is sock client or server.'">
<xs:documentation>The sock file path for the sock server or client backend type.</xs:documentation>
</xs:annotation>
</xs:element>
- <xs:element name="tty_device_path" type="xs:string" minOccurs="0" maxOccurs="1">
- <xs:annotation acrn:title="TTY device path">
+ <xs:element name="tty_device_path" type="xs:string" minOccurs="0">
+ <xs:annotation acrn:title="TTY device path" acrn:widget-options="'placeholder': '/dev/ttyX, needed only when backend type is tty.'">
<xs:documentation>The device path for the tty backend type.</xs:documentation>
</xs:annotation>
</xs:element>
@@ -393,12 +395,12 @@ device file when user config it as virtio serial port, which can be read and wri
<xs:complexType name="VirtioInputConfiguration">
<xs:sequence>
<xs:element name="backend_device_file" type="xs:string" minOccurs="0">
- <xs:annotation acrn:title="Backend device file">
+ <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'">
<xs:documentation>Specifying backend device in service vm with device description.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="id" minOccurs="0">
- <xs:annotation acrn:title="Guest virtio input device unique identifier">
+ <xs:annotation acrn:title="Guest virtio input device unique identifier" acrn:widget-options="'placeholder': 'An arbitrary-long string with letters, digits, underscores or dashes.'">
<xs:documentation>Specifying unique identifier to distinguish same devices in guest.</xs:documentation>
</xs:annotation>
<xs:simpleType>
diff --git a/misc/config_tools/schema/config.xsd b/misc/config_tools/schema/config.xsd
index 9c5917b61..a65114d9a 100644
--- a/misc/config_tools/schema/config.xsd
+++ b/misc/config_tools/schema/config.xsd
@@ -286,7 +286,7 @@ These settings can only be changed at build time.</xs:documentation>
Refer to :ref:`vuart_config` for detailed vUART settings.</xs:documentation>
</xs:annotation>
</xs:element>
- <xs:element name="CACHE_REGION" type="CacheRegionType" minOccurs="0" maxOccurs="1">
+ <xs:element name="CACHE_REGION" type="CacheRegionType" minOccurs="0">
<xs:annotation>
<xs:documentation>Specify the cache setting.</xs:documentation>
</xs:annotation>
@@ -306,20 +306,10 @@ Refer to :ref:`vuart_config` for detailed vUART settings.</xs:documentation>
<xs:documentation>Select the VM type. A standard VM (``STANDARD_VM``) is for general-purpose applications, such as human-machine interface (HMI). A real-time VM (``RTVM``) offers special features for time-sensitive applications.</xs:documentation>
</xs:annotation>
</xs:element>
- <xs:element name="name">
+ <xs:element name="name" type="VMNameType">
<xs:annotation acrn:title="VM name" acrn:views="basic">
<xs:documentation>Specify the name used to identify this VM. The VM name will be shown in the hypervisor console vm_list command.</xs:documentation>
</xs:annotation>
- <xs:simpleType>
- <xs:annotation>
- <xs:documentation>A string from 1 to 32 characters long (with no spaces).</xs:documentation>
- </xs:annotation>
- <xs:restriction base="xs:string">
- <xs:minLength value="1" />
- <xs:maxLength value="15" />
- <xs:pattern value="\S+" />
- </xs:restriction>
- </xs:simpleType>
</xs:element>
<xs:element name="lapic_passthrough" type="Boolean" default="n" minOccurs="0">
<xs:annotation acrn:title="LAPIC passthrough" acrn:applicable-vms="pre-launched, post-launched" acrn:views="advanced">
@@ -404,7 +394,7 @@ argument and memory.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="mmio_resources" type="MMIOResourcesConfiguration" minOccurs="0">
- <xs:annotation acrn:applicable-vms="pre-launched" acrn:views="basic">
+ <xs:annotation acrn:title="MMIO Resources" acrn:applicable-vms="pre-launched" acrn:views="basic">
<xs:documentation>MMIO resources to passthrough.</xs:documentation>
</xs:annotation>
</xs:element>
@@ -470,13 +460,18 @@ is the virtio network driver, simulating the virtual NIC. The backend could be:
mouse, and tablet. It sends Linux input layer events over virtio.</xs:documentation>
</xs:annotation>
</xs:element>
- <xs:element name="block" type="xs:string" minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="block" minOccurs="0" maxOccurs="unbounded">
<xs:annotation acrn:title="Virtio block device" acrn:views="basic">
<xs:documentation>The virtio-blk device presents a block device to the VM. Each virtio-blk device appears as a disk inside the VM.</xs:documentation>
</xs:annotation>
+ <xs:simpleType>
+ <xs:annotation acrn:widget-options="'placeholder': '/home/user/path/to/disk.image'" />
+ <xs:restriction base="xs:string" />
+ </xs:simpleType>
</xs:element>
<xs:element name="gpu" type="xs:string" minOccurs="0">
- <xs:annotation acrn:title="Virtio GPU device" acrn:views="basic">
+ <xs:annotation acrn:title="Virtio GPU device" acrn:views="basic"
+ acrn:widget-options="'placeholder': 'fullscreen or geometry=[width]x[height]+[x offset]+[y offset], e.g. geometry=1280x720+0+0 specifies a 1280 x 720 pixels region at the top left corner of the screan'">
<xs:documentation>The virtio GPU device presents a GPU device to the VM.
This feature enables you to view the VM's GPU output in the Service VM.</xs:documentation>
</xs:annotation>
diff --git a/misc/config_tools/schema/types.xsd b/misc/config_tools/schema/types.xsd
index b48feef6b..b80cfaff1 100644
--- a/misc/config_tools/schema/types.xsd
+++ b/misc/config_tools/schema/types.xsd
@@ -4,7 +4,7 @@
xmlns:acrn="https://projectacrn.org">

<xs:simpleType name="Boolean">
- <xs:annotation acrn:widget="b-form-checkbox" acrn:widget-options="'value' = 'y', 'unchecked-value' = 'n'">
+ <xs:annotation acrn:widget="b-form-checkbox" acrn:widget-options="'value': 'y', 'unchecked-value': 'n'">
<xs:documentation>A Boolean value, written as ``y`` or ``n``.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
@@ -24,7 +24,7 @@
</xs:simpleType>

<xs:simpleType name="HexFormat">
- <xs:annotation>
+ <xs:annotation acrn:widget-options="'placeholder': 'A hexadecimal number with a leading 0x, e.g. 0x1000.'">
<xs:documentation>An Integer value in hexadecimal format (with a leading ``0x``).</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
@@ -184,7 +184,7 @@ Read more about the available scheduling options in :ref:`cpu_sharing`.</xs:docu
</xs:simpleType>

<xs:simpleType name="VMNameType">
- <xs:annotation>
+ <xs:annotation acrn:widget-options="'placeholder': 'A string with at most 15 non-space characters, e.g. Linux-VM-1.'">
<xs:documentation>A string of up to 15 letters, digits, ``_``, or ``-``.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
--
2.30.2


Re: [PATCH v6 3/4] hv: move the MAX_VUART_NUM_PER_VM to offline tool

chenli.wei
 

On 5/13/2022 2:57 AM, Eddie Dong wrote:
I am fine with this. Once you get +1 for the misc patches, please PR.
OK.

I have send to PR.


-----Original Message-----
From: acrn-dev@... <acrn-dev@...> On
Behalf Of chenli.wei
Sent: Thursday, May 12, 2022 1:16 AM
To: Mao, Junjie <junjie.mao@...>; acrn-dev@...
Cc: Wei, Chenli <chenli.wei@...>
Subject: [acrn-dev] [PATCH v6 3/4] hv: move the
MAX_VUART_NUM_PER_VM to offline tool

Current code limit the MAX vUART number to 8 which is not enough for
Service VM which should config S5 UART for each user VM.

We could count how many vUARTs we need by offline tool, so remove the
define of MAX_VUART_NUM_PER_VM to offline tool is a simple and
accurate way to allocate vUARTs.

v1-->v2:
1.move the define of MAX_VUART_NUM_PER_VM to offline tool

Tracked-On: #8782
Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/include/arch/x86/asm/vm_config.h | 1 -
1 file changed, 1 deletion(-)

diff --git a/hypervisor/include/arch/x86/asm/vm_config.h
b/hypervisor/include/arch/x86/asm/vm_config.h
index d985d7081..7e58a88b5 100644
--- a/hypervisor/include/arch/x86/asm/vm_config.h
+++ b/hypervisor/include/arch/x86/asm/vm_config.h
@@ -18,7 +18,6 @@

#define AFFINITY_CPU(n) (1UL << (n))
#define MAX_VCPUS_PER_VM MAX_PCPU_NUM
-#define MAX_VUART_NUM_PER_VM 8U
#define MAX_VM_OS_NAME_LEN 32U
#define MAX_MOD_TAG_LEN 32U

--
2.17.1







Re: [PATCH v6 4/4] hv: refine the define of *PIO_IDX

chenli.wei
 

On 5/13/2022 2:56 AM, Eddie Dong wrote:
A reminder: using enumeration constants as integers is prohibited by ACRN
coding guideline.
Aaa, If this is the case, we have to drop this patch.
OK.

I have drop this patch and send others to PR.


In this case the enumeration above is not exhaustive (due to the variable
number of UARTs) and will eventually trigger enum to integer conversions
somewhere in the code.

--
Best Regards
Junjie Mao

/**
* @brief The handler of VM exits on I/O instructions
*




Re: [PATCH v6 3/4] hv: move the MAX_VUART_NUM_PER_VM to offline tool

Eddie Dong
 

I am fine with this. Once you get +1 for the misc patches, please PR.

-----Original Message-----
From: acrn-dev@... <acrn-dev@...> On
Behalf Of chenli.wei
Sent: Thursday, May 12, 2022 1:16 AM
To: Mao, Junjie <junjie.mao@...>; acrn-dev@...
Cc: Wei, Chenli <chenli.wei@...>
Subject: [acrn-dev] [PATCH v6 3/4] hv: move the
MAX_VUART_NUM_PER_VM to offline tool

Current code limit the MAX vUART number to 8 which is not enough for
Service VM which should config S5 UART for each user VM.

We could count how many vUARTs we need by offline tool, so remove the
define of MAX_VUART_NUM_PER_VM to offline tool is a simple and
accurate way to allocate vUARTs.

v1-->v2:
1.move the define of MAX_VUART_NUM_PER_VM to offline tool

Tracked-On: #8782
Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/include/arch/x86/asm/vm_config.h | 1 -
1 file changed, 1 deletion(-)

diff --git a/hypervisor/include/arch/x86/asm/vm_config.h
b/hypervisor/include/arch/x86/asm/vm_config.h
index d985d7081..7e58a88b5 100644
--- a/hypervisor/include/arch/x86/asm/vm_config.h
+++ b/hypervisor/include/arch/x86/asm/vm_config.h
@@ -18,7 +18,6 @@

#define AFFINITY_CPU(n) (1UL << (n))
#define MAX_VCPUS_PER_VM MAX_PCPU_NUM
-#define MAX_VUART_NUM_PER_VM 8U
#define MAX_VM_OS_NAME_LEN 32U
#define MAX_MOD_TAG_LEN 32U

--
2.17.1





Re: [PATCH v6 4/4] hv: refine the define of *PIO_IDX

Eddie Dong
 


A reminder: using enumeration constants as integers is prohibited by ACRN
coding guideline.
Aaa, If this is the case, we have to drop this patch.


In this case the enumeration above is not exhaustive (due to the variable
number of UARTs) and will eventually trigger enum to integer conversions
somewhere in the code.

--
Best Regards
Junjie Mao

/**
* @brief The handler of VM exits on I/O instructions
*



Re: [PATCH v6 4/4] hv: refine the define of *PIO_IDX

Eddie Dong
 

-----Original Message-----
From: acrn-dev@... <acrn-dev@...> On
Behalf Of chenli.wei
Sent: Thursday, May 12, 2022 1:16 AM
To: Mao, Junjie <junjie.mao@...>; acrn-dev@...
Cc: Wei, Chenli <chenli.wei@...>
Subject: [acrn-dev] [PATCH v6 4/4] hv: refine the define of *PIO_IDX

The current code define *PIO_IDX by macro, it's not a good style and the
UART PIO was in the middle of these macro which should move to the end to
conveniently modify.

This patch change these macro to enum and move the UART PIO to the end
of these PIO_IDX list.

v5-->v6:
1.code format

Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/arch/x86/guest/pm.c | 2 +-
hypervisor/dm/io_req.c | 2 +-
.../include/arch/x86/asm/guest/vmx_io.h | 38 ++++++++++---------
3 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/hypervisor/arch/x86/guest/pm.c
b/hypervisor/arch/x86/guest/pm.c index 2af0dd259..a7f71fca7 100644
--- a/hypervisor/arch/x86/guest/pm.c
+++ b/hypervisor/arch/x86/guest/pm.c
@@ -249,7 +249,7 @@ static bool pm1ab_io_write(struct acrn_vcpu *vcpu,
uint16_t addr, size_t width,
return true;
}

-static void register_gas_io_handler(struct acrn_vm *vm, uint32_t pio_idx,
const struct acrn_acpi_generic_address *gas)
+static void register_gas_io_handler(struct acrn_vm *vm, enum
+port_io_index pio_idx, const struct acrn_acpi_generic_address *gas)
{
uint8_t io_len[5] = {0U, 1U, 2U, 4U, 8U};
struct vm_io_range gas_io;
diff --git a/hypervisor/dm/io_req.c b/hypervisor/dm/io_req.c index
b68a66cab..fbc38cf46 100644
--- a/hypervisor/dm/io_req.c
+++ b/hypervisor/dm/io_req.c
@@ -597,7 +597,7 @@ emulate_io(struct acrn_vcpu *vcpu, struct
io_request *io_req)
* @param io_write_fn_ptr The handler for emulating writes to the given
range
* @pre pio_idx < EMUL_PIO_IDX_MAX
*/
-void register_pio_emulation_handler(struct acrn_vm *vm, uint32_t pio_idx,
+void register_pio_emulation_handler(struct acrn_vm *vm, enum
+port_io_index pio_idx,
const struct vm_io_range *range, io_read_fn_t
io_read_fn_ptr, io_write_fn_t io_write_fn_ptr) {
if (is_service_vm(vm)) {
diff --git a/hypervisor/include/arch/x86/asm/guest/vmx_io.h
b/hypervisor/include/arch/x86/asm/guest/vmx_io.h
index 5c41b4d4c..3ddb46fee 100644
--- a/hypervisor/include/arch/x86/asm/guest/vmx_io.h
+++ b/hypervisor/include/arch/x86/asm/guest/vmx_io.h
@@ -9,25 +9,27 @@

#include <types.h>

+enum port_io_index {
/* Define emulated port IO index */
-#define PIC_PRIMARY_PIO_IDX 0U
-#define PIC_SECONDARY_PIO_IDX (PIC_PRIMARY_PIO_IDX +
1U)
-#define PIC_ELC_PIO_IDX (PIC_SECONDARY_PIO_IDX
+ 1U)
-#define PCI_CFGADDR_PIO_IDX (PIC_ELC_PIO_IDX + 1U)
-#define PCI_CFGDATA_PIO_IDX (PCI_CFGADDR_PIO_IDX + 1U)
-/* MAX_VUART_NUM_PER_VM is 8, so allocate
UART_PIO_IDX0~UART_PIO_IDX0 + 7 for 8 vuart */
-#define UART_PIO_IDX0 (PCI_CFGDATA_PIO_IDX +
1U)
-#define PM1A_EVT_PIO_IDX (UART_PIO_IDX0 +
MAX_VUART_NUM_PER_VM)
-#define PM1A_CNT_PIO_IDX (PM1A_EVT_PIO_IDX + 1U)
-#define PM1B_EVT_PIO_IDX (PM1A_CNT_PIO_IDX + 1U)
-#define PM1B_CNT_PIO_IDX (PM1B_EVT_PIO_IDX + 1U)
-#define RTC_PIO_IDX (PM1B_CNT_PIO_IDX + 1U)
-#define VIRTUAL_PM1A_CNT_PIO_IDX (RTC_PIO_IDX + 1U)
-#define KB_PIO_IDX (VIRTUAL_PM1A_CNT_PIO_IDX +
1U)
-#define CF9_PIO_IDX (KB_PIO_IDX + 1U)
-#define PIO_RESET_REG_IDX (CF9_PIO_IDX + 1U)
-#define SLEEP_CTL_PIO_IDX (PIO_RESET_REG_IDX + 1U)
-#define EMUL_PIO_IDX_MAX (SLEEP_CTL_PIO_IDX + 1U)
+ PIC_PRIMARY_PIO_IDX,
Should we add "=0" for the 1st element?

The rest is fine. Please PR with my ack.

+ PIC_SECONDARY_PIO_IDX,
+ PIC_ELC_PIO_IDX,
+ PCI_CFGADDR_PIO_IDX,
+ PCI_CFGDATA_PIO_IDX,
+ PM1A_EVT_PIO_IDX,
+ PM1A_CNT_PIO_IDX,
+ PM1B_EVT_PIO_IDX,
+ PM1B_CNT_PIO_IDX,
+ RTC_PIO_IDX,
+ VIRTUAL_PM1A_CNT_PIO_IDX,
+ KB_PIO_IDX,
+ CF9_PIO_IDX,
+ PIO_RESET_REG_IDX,
+ SLEEP_CTL_PIO_IDX,
+ UART_PIO_IDX0,
+ EMUL_PIO_IDX_MAX = (UART_PIO_IDX0 +
MAX_VUART_NUM_PER_VM), };
+
/**
* @brief The handler of VM exits on I/O instructions
*
--
2.17.1





Re: [PATCH v6 4/4] hv: refine the define of *PIO_IDX

chenli.wei
 

On 5/12/2022 5:01 PM, Junjie Mao wrote:
Chenli Wei <chenli.wei@...> writes:

The current code define *PIO_IDX by macro, it's not a good style and
the UART PIO was in the middle of these macro which should move to the
end to conveniently modify.

This patch change these macro to enum and move the UART PIO to the end
of these PIO_IDX list.

v5-->v6:
1.code format

Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/arch/x86/guest/pm.c | 2 +-
hypervisor/dm/io_req.c | 2 +-
.../include/arch/x86/asm/guest/vmx_io.h | 38 ++++++++++---------
3 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/hypervisor/arch/x86/guest/pm.c b/hypervisor/arch/x86/guest/pm.c
index 2af0dd259..a7f71fca7 100644
--- a/hypervisor/arch/x86/guest/pm.c
+++ b/hypervisor/arch/x86/guest/pm.c
@@ -249,7 +249,7 @@ static bool pm1ab_io_write(struct acrn_vcpu *vcpu, uint16_t addr, size_t width,
return true;
}
-static void register_gas_io_handler(struct acrn_vm *vm, uint32_t pio_idx, const struct acrn_acpi_generic_address *gas)
+static void register_gas_io_handler(struct acrn_vm *vm, enum port_io_index pio_idx, const struct acrn_acpi_generic_address *gas)
{
uint8_t io_len[5] = {0U, 1U, 2U, 4U, 8U};
struct vm_io_range gas_io;
diff --git a/hypervisor/dm/io_req.c b/hypervisor/dm/io_req.c
index b68a66cab..fbc38cf46 100644
--- a/hypervisor/dm/io_req.c
+++ b/hypervisor/dm/io_req.c
@@ -597,7 +597,7 @@ emulate_io(struct acrn_vcpu *vcpu, struct io_request *io_req)
* @param io_write_fn_ptr The handler for emulating writes to the given range
* @pre pio_idx < EMUL_PIO_IDX_MAX
*/
-void register_pio_emulation_handler(struct acrn_vm *vm, uint32_t pio_idx,
+void register_pio_emulation_handler(struct acrn_vm *vm, enum port_io_index pio_idx,
const struct vm_io_range *range, io_read_fn_t io_read_fn_ptr, io_write_fn_t io_write_fn_ptr)
{
if (is_service_vm(vm)) {
diff --git a/hypervisor/include/arch/x86/asm/guest/vmx_io.h b/hypervisor/include/arch/x86/asm/guest/vmx_io.h
index 5c41b4d4c..3ddb46fee 100644
--- a/hypervisor/include/arch/x86/asm/guest/vmx_io.h
+++ b/hypervisor/include/arch/x86/asm/guest/vmx_io.h
@@ -9,25 +9,27 @@
#include <types.h>
+enum port_io_index {
/* Define emulated port IO index */
-#define PIC_PRIMARY_PIO_IDX 0U
-#define PIC_SECONDARY_PIO_IDX (PIC_PRIMARY_PIO_IDX + 1U)
-#define PIC_ELC_PIO_IDX (PIC_SECONDARY_PIO_IDX + 1U)
-#define PCI_CFGADDR_PIO_IDX (PIC_ELC_PIO_IDX + 1U)
-#define PCI_CFGDATA_PIO_IDX (PCI_CFGADDR_PIO_IDX + 1U)
-/* MAX_VUART_NUM_PER_VM is 8, so allocate UART_PIO_IDX0~UART_PIO_IDX0 + 7 for 8 vuart */
-#define UART_PIO_IDX0 (PCI_CFGDATA_PIO_IDX + 1U)
-#define PM1A_EVT_PIO_IDX (UART_PIO_IDX0 + MAX_VUART_NUM_PER_VM)
-#define PM1A_CNT_PIO_IDX (PM1A_EVT_PIO_IDX + 1U)
-#define PM1B_EVT_PIO_IDX (PM1A_CNT_PIO_IDX + 1U)
-#define PM1B_CNT_PIO_IDX (PM1B_EVT_PIO_IDX + 1U)
-#define RTC_PIO_IDX (PM1B_CNT_PIO_IDX + 1U)
-#define VIRTUAL_PM1A_CNT_PIO_IDX (RTC_PIO_IDX + 1U)
-#define KB_PIO_IDX (VIRTUAL_PM1A_CNT_PIO_IDX + 1U)
-#define CF9_PIO_IDX (KB_PIO_IDX + 1U)
-#define PIO_RESET_REG_IDX (CF9_PIO_IDX + 1U)
-#define SLEEP_CTL_PIO_IDX (PIO_RESET_REG_IDX + 1U)
-#define EMUL_PIO_IDX_MAX (SLEEP_CTL_PIO_IDX + 1U)
+ PIC_PRIMARY_PIO_IDX,
+ PIC_SECONDARY_PIO_IDX,
+ PIC_ELC_PIO_IDX,
+ PCI_CFGADDR_PIO_IDX,
+ PCI_CFGDATA_PIO_IDX,
+ PM1A_EVT_PIO_IDX,
+ PM1A_CNT_PIO_IDX,
+ PM1B_EVT_PIO_IDX,
+ PM1B_CNT_PIO_IDX,
+ RTC_PIO_IDX,
+ VIRTUAL_PM1A_CNT_PIO_IDX,
+ KB_PIO_IDX,
+ CF9_PIO_IDX,
+ PIO_RESET_REG_IDX,
+ SLEEP_CTL_PIO_IDX,
+ UART_PIO_IDX0,
+ EMUL_PIO_IDX_MAX = (UART_PIO_IDX0 + MAX_VUART_NUM_PER_VM),
+};
+
A reminder: using enumeration constants as integers is prohibited by
ACRN coding guideline.

In this case the enumeration above is not exhaustive (due to the
variable number of UARTs) and will eventually trigger enum to integer
conversions somewhere in the code.
It seems we should confirm this patch again.

I will pause this patch and send others of this series to PR.


Re: [PATCH v6 2/4] misc: define the MAX_VUART_NUM_PER_VM by offline tool

chenli.wei
 

On 5/12/2022 4:51 PM, Junjie Mao wrote:
Chenli Wei <chenli.wei@...> writes:

The current code define MAX_VUART_NUM_PER_VM for all VM and it's a hard
code which can't match our vUART logic which need dynamic setting.

This patch move the define of MAX_VUART_NUM_PER_VM to offline tool and
calculate it automatically.

v5-->v6:
1.collect the number of vUART controllers of each VMs and calculate
the MAX to define MAX_VUART_NUM_PER_VM

Signed-off-by: Chenli Wei <chenli.wei@...>
Reviewed-by: Junjie Mao <junjie.mao@...>

One minor comment below.

---
misc/config_tools/xforms/vm_configurations.h.xsl | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/misc/config_tools/xforms/vm_configurations.h.xsl b/misc/config_tools/xforms/vm_configurations.h.xsl
index b596ef692..0758ff42f 100644
--- a/misc/config_tools/xforms/vm_configurations.h.xsl
+++ b/misc/config_tools/xforms/vm_configurations.h.xsl
@@ -9,6 +9,7 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dyn="http://exslt.org/dynamic"
xmlns:math="http://exslt.org/math"
+ xmlns:str="http://exslt.org/strings"
xmlns:acrn="http://projectacrn.org">
<xsl:include href="lib.xsl" />
<xsl:output method="text" />
@@ -32,6 +33,21 @@
<xsl:template match="config-data/acrn-config">
<xsl:call-template name="vm_count" />
<xsl:call-template name="sos_vm_bootarges" />
+ <xsl:call-template name="vm_vuart_num" />
+ </xsl:template>
+
+ <xsl:template name ="vm_vuart_num">
+ <xsl:variable name="vuart_nums">
+ <xsl:for-each select = "//config-data//vm">
+ <xsl:variable name = "vm_name" select = "./name/text()" />
+ <xsl:variable name = "vuart_num" select = "count(//endpoint[vm_name = $vm_name]) + 1" />
+ <xsl:value-of select = "$vuart_num" />
+ <xsl:if test = "position() != last()">
+ <xsl:value-of select = "concat(',', ' ')" />
Why do you need `concat` here? A single ',' should do the trick.
OK, I will change it.


Re: [PATCH v6 4/4] hv: refine the define of *PIO_IDX

Junjie Mao
 

Chenli Wei <chenli.wei@...> writes:

The current code define *PIO_IDX by macro, it's not a good style and
the UART PIO was in the middle of these macro which should move to the
end to conveniently modify.

This patch change these macro to enum and move the UART PIO to the end
of these PIO_IDX list.

v5-->v6:
1.code format

Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/arch/x86/guest/pm.c | 2 +-
hypervisor/dm/io_req.c | 2 +-
.../include/arch/x86/asm/guest/vmx_io.h | 38 ++++++++++---------
3 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/hypervisor/arch/x86/guest/pm.c b/hypervisor/arch/x86/guest/pm.c
index 2af0dd259..a7f71fca7 100644
--- a/hypervisor/arch/x86/guest/pm.c
+++ b/hypervisor/arch/x86/guest/pm.c
@@ -249,7 +249,7 @@ static bool pm1ab_io_write(struct acrn_vcpu *vcpu, uint16_t addr, size_t width,
return true;
}

-static void register_gas_io_handler(struct acrn_vm *vm, uint32_t pio_idx, const struct acrn_acpi_generic_address *gas)
+static void register_gas_io_handler(struct acrn_vm *vm, enum port_io_index pio_idx, const struct acrn_acpi_generic_address *gas)
{
uint8_t io_len[5] = {0U, 1U, 2U, 4U, 8U};
struct vm_io_range gas_io;
diff --git a/hypervisor/dm/io_req.c b/hypervisor/dm/io_req.c
index b68a66cab..fbc38cf46 100644
--- a/hypervisor/dm/io_req.c
+++ b/hypervisor/dm/io_req.c
@@ -597,7 +597,7 @@ emulate_io(struct acrn_vcpu *vcpu, struct io_request *io_req)
* @param io_write_fn_ptr The handler for emulating writes to the given range
* @pre pio_idx < EMUL_PIO_IDX_MAX
*/
-void register_pio_emulation_handler(struct acrn_vm *vm, uint32_t pio_idx,
+void register_pio_emulation_handler(struct acrn_vm *vm, enum port_io_index pio_idx,
const struct vm_io_range *range, io_read_fn_t io_read_fn_ptr, io_write_fn_t io_write_fn_ptr)
{
if (is_service_vm(vm)) {
diff --git a/hypervisor/include/arch/x86/asm/guest/vmx_io.h b/hypervisor/include/arch/x86/asm/guest/vmx_io.h
index 5c41b4d4c..3ddb46fee 100644
--- a/hypervisor/include/arch/x86/asm/guest/vmx_io.h
+++ b/hypervisor/include/arch/x86/asm/guest/vmx_io.h
@@ -9,25 +9,27 @@

#include <types.h>

+enum port_io_index {
/* Define emulated port IO index */
-#define PIC_PRIMARY_PIO_IDX 0U
-#define PIC_SECONDARY_PIO_IDX (PIC_PRIMARY_PIO_IDX + 1U)
-#define PIC_ELC_PIO_IDX (PIC_SECONDARY_PIO_IDX + 1U)
-#define PCI_CFGADDR_PIO_IDX (PIC_ELC_PIO_IDX + 1U)
-#define PCI_CFGDATA_PIO_IDX (PCI_CFGADDR_PIO_IDX + 1U)
-/* MAX_VUART_NUM_PER_VM is 8, so allocate UART_PIO_IDX0~UART_PIO_IDX0 + 7 for 8 vuart */
-#define UART_PIO_IDX0 (PCI_CFGDATA_PIO_IDX + 1U)
-#define PM1A_EVT_PIO_IDX (UART_PIO_IDX0 + MAX_VUART_NUM_PER_VM)
-#define PM1A_CNT_PIO_IDX (PM1A_EVT_PIO_IDX + 1U)
-#define PM1B_EVT_PIO_IDX (PM1A_CNT_PIO_IDX + 1U)
-#define PM1B_CNT_PIO_IDX (PM1B_EVT_PIO_IDX + 1U)
-#define RTC_PIO_IDX (PM1B_CNT_PIO_IDX + 1U)
-#define VIRTUAL_PM1A_CNT_PIO_IDX (RTC_PIO_IDX + 1U)
-#define KB_PIO_IDX (VIRTUAL_PM1A_CNT_PIO_IDX + 1U)
-#define CF9_PIO_IDX (KB_PIO_IDX + 1U)
-#define PIO_RESET_REG_IDX (CF9_PIO_IDX + 1U)
-#define SLEEP_CTL_PIO_IDX (PIO_RESET_REG_IDX + 1U)
-#define EMUL_PIO_IDX_MAX (SLEEP_CTL_PIO_IDX + 1U)
+ PIC_PRIMARY_PIO_IDX,
+ PIC_SECONDARY_PIO_IDX,
+ PIC_ELC_PIO_IDX,
+ PCI_CFGADDR_PIO_IDX,
+ PCI_CFGDATA_PIO_IDX,
+ PM1A_EVT_PIO_IDX,
+ PM1A_CNT_PIO_IDX,
+ PM1B_EVT_PIO_IDX,
+ PM1B_CNT_PIO_IDX,
+ RTC_PIO_IDX,
+ VIRTUAL_PM1A_CNT_PIO_IDX,
+ KB_PIO_IDX,
+ CF9_PIO_IDX,
+ PIO_RESET_REG_IDX,
+ SLEEP_CTL_PIO_IDX,
+ UART_PIO_IDX0,
+ EMUL_PIO_IDX_MAX = (UART_PIO_IDX0 + MAX_VUART_NUM_PER_VM),
+};
+
A reminder: using enumeration constants as integers is prohibited by
ACRN coding guideline.

In this case the enumeration above is not exhaustive (due to the
variable number of UARTs) and will eventually trigger enum to integer
conversions somewhere in the code.

--
Best Regards
Junjie Mao

/**
* @brief The handler of VM exits on I/O instructions
*


Re: [PATCH v6 2/4] misc: define the MAX_VUART_NUM_PER_VM by offline tool

Junjie Mao
 

Chenli Wei <chenli.wei@...> writes:

The current code define MAX_VUART_NUM_PER_VM for all VM and it's a hard
code which can't match our vUART logic which need dynamic setting.

This patch move the define of MAX_VUART_NUM_PER_VM to offline tool and
calculate it automatically.

v5-->v6:
1.collect the number of vUART controllers of each VMs and calculate
the MAX to define MAX_VUART_NUM_PER_VM

Signed-off-by: Chenli Wei <chenli.wei@...>
Reviewed-by: Junjie Mao <junjie.mao@...>

One minor comment below.

---
misc/config_tools/xforms/vm_configurations.h.xsl | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/misc/config_tools/xforms/vm_configurations.h.xsl b/misc/config_tools/xforms/vm_configurations.h.xsl
index b596ef692..0758ff42f 100644
--- a/misc/config_tools/xforms/vm_configurations.h.xsl
+++ b/misc/config_tools/xforms/vm_configurations.h.xsl
@@ -9,6 +9,7 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dyn="http://exslt.org/dynamic"
xmlns:math="http://exslt.org/math"
+ xmlns:str="http://exslt.org/strings"
xmlns:acrn="http://projectacrn.org">
<xsl:include href="lib.xsl" />
<xsl:output method="text" />
@@ -32,6 +33,21 @@
<xsl:template match="config-data/acrn-config">
<xsl:call-template name="vm_count" />
<xsl:call-template name="sos_vm_bootarges" />
+ <xsl:call-template name="vm_vuart_num" />
+ </xsl:template>
+
+ <xsl:template name ="vm_vuart_num">
+ <xsl:variable name="vuart_nums">
+ <xsl:for-each select = "//config-data//vm">
+ <xsl:variable name = "vm_name" select = "./name/text()" />
+ <xsl:variable name = "vuart_num" select = "count(//endpoint[vm_name = $vm_name]) + 1" />
+ <xsl:value-of select = "$vuart_num" />
+ <xsl:if test = "position() != last()">
+ <xsl:value-of select = "concat(',', ' ')" />
Why do you need `concat` here? A single ',' should do the trick.

--
Best Regards
Junjie Mao

+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+ <xsl:value-of select = "acrn:define('MAX_VUART_NUM_PER_VM', math:max(str:split($vuart_nums, ',')), 'U')" />
</xsl:template>

<xsl:template name ="vm_count">


Re: [PATCH v6 1/4] misc: add vUART channel for s5 feature

Junjie Mao
 

Chenli Wei <chenli.wei@...> writes:

"S5" is one of the ACPI sleep states which means the function to shut
down the VMs.

On ACRN, the User VM must be shut down before powering off the Service
VM, so we need a vUART channel to communicate between the Service VM
and User VMs.

This patch adds a vUART channel for each User VM connect to Service VM

Tracked-On: #8782
Reviewed-by: Junjie Mao <junjie.mao@...>
As a general guideline, please append "Reviewed-by" or "Acked-by" after "Signed-off-by".

--
Best Regards
Junjie Mao

Signed-off-by: Chenli Wei <chenli.wei@...>
---
.../service_vm_config/serial_config.py | 30 +++----
misc/config_tools/static_allocators/intx.py | 25 +++++-
.../static_allocators/s5_vuart.py | 87 +++++++++++++++++++
3 files changed, 124 insertions(+), 18 deletions(-)
create mode 100644 misc/config_tools/static_allocators/s5_vuart.py

diff --git a/misc/config_tools/service_vm_config/serial_config.py b/misc/config_tools/service_vm_config/serial_config.py
index fda214c07..3c53c42c1 100644
--- a/misc/config_tools/service_vm_config/serial_config.py
+++ b/misc/config_tools/service_vm_config/serial_config.py
@@ -17,7 +17,7 @@ VUART_DEV_NAME_NUM = 8
stadard_uart_port = {'0x3F8', '0x2F8', '0x3E8', '0x2E8'}
UART_IRQ_BAUD = " irq 0 uart 16550A baud_base 115200"

-def find_non_standard_uart(vm, scenario_etree):
+def find_non_standard_uart(vm, scenario_etree, allocation_etree):
uart_list = []
vmname = common.get_node("./name/text()", vm)

@@ -30,7 +30,17 @@ def find_non_standard_uart(vm, scenario_etree):

port = common.get_node(f".//endpoint[vm_name = '{vmname}']/io_port/text()", connection)
if port not in stadard_uart_port:
- uart_list.append(connection)
+ target_vm_name = common.get_node(f".//endpoint[vm_name != '{vmname}']/vm_name/text()", connection)
+ target_vm_id = common.get_node(f"//vm[name = '{target_vm_name}']/@id", scenario_etree)
+ uart_list.append({"io_port" : port, "target_vm_id" : target_vm_id})
+
+ legacy_uart_list = allocation_etree.xpath(f"//vm[load_order = 'SERVICE_VM']/legacy_vuart")
+ for legacy_uart in legacy_uart_list:
+ port = common.get_node(f"./addr.port_base/text()", legacy_uart)
+ if port is None:
+ continue
+ elif port not in stadard_uart_port:
+ uart_list.append({"io_port" : port, "target_vm_id": common.get_node(f"./t_vuart.vm_id/text()", legacy_uart)})

return uart_list

@@ -45,23 +55,13 @@ def main(args):

vm_list = scenario_etree.xpath("//vm[load_order = 'SERVICE_VM']")
for vm in vm_list:
- vmname = common.get_node("./name/text()", vm)
- for connection in scenario_etree.xpath(f"//vuart_connection[endpoint/vm_name = '{vmname}']"):
- vm_name = common.get_node(f".//endpoint[vm_name != '{vmname}']/vm_name/text()", connection)
- for target_vm in scenario_etree.xpath(f"//vm[name = '{vm_name}']"):
- vuart_target_vmid[connection.find('name').text] = target_vm.attrib["id"]
-
- vm_list = scenario_etree.xpath("//vm[load_order = 'SERVICE_VM']")
- for vm in vm_list:
- vuart_list = find_non_standard_uart(vm, scenario_etree)
+ vuart_list = find_non_standard_uart(vm, scenario_etree, allocation_etree)
vmname = common.get_node("./name/text()", vm)
if len(vuart_list) != 0:
with open(args.out, "w+") as config_f:
for uart_start_num, vuart in enumerate(vuart_list, start=START_VUART_DEV_NAME_NO):
- port = common.get_node(f".//endpoint[vm_name = '{vmname}']/io_port/text()", vuart)
- base = " port " + str(port)
- connection_name = vuart.find('name').text
- vm_id_note = "# User_VM_id: " + str(vuart_target_vmid[connection_name]) + '\n'
+ base = " port " + vuart["io_port"]
+ vm_id_note = "# User_VM_id: " + str(vuart["target_vm_id"])+ '\n'
config_f.write(vm_id_note)
conf = "/dev/ttyS" + str(uart_start_num) + base + UART_IRQ_BAUD + '\n'
config_f.write(conf)
diff --git a/misc/config_tools/static_allocators/intx.py b/misc/config_tools/static_allocators/intx.py
index b36d89eb0..cea43deb4 100644
--- a/misc/config_tools/static_allocators/intx.py
+++ b/misc/config_tools/static_allocators/intx.py
@@ -55,11 +55,30 @@ def alloc_vuart_connection_irqs(board_etree, scenario_etree, allocation_etree):
hv_debug_console = lib.lib.parse_hv_console(scenario_etree)

vm_node_list = scenario_etree.xpath("//vm")
+ user_vm_list = scenario_etree.xpath("//vm[load_order != 'SERVICE_VM']/name/text()")
+ service_vm_id = common.get_node(f"//vm[load_order = 'SERVICE_VM']/@id", scenario_etree)
+
+ for index in range(0, len(user_vm_list)):
+ vuart_id = index + 1
+ create_vuart_irq_node(allocation_etree, service_vm_id, "SERVICE_VM", str(vuart_id), "0")
+
for vm_node in vm_node_list:
load_order = common.get_node("./load_order/text()", vm_node)
irq_list = get_native_valid_irq() if load_order == "SERVICE_VM" else [f"{d}" for d in list(range(1,15))]
- vuart_id = '1'
+
+ if load_order != "SERVICE_VM":
+ vuart_id = 1
+ else:
+ vuart_id = 1 + len(user_vm_list)
+
vmname = common.get_node("./name/text()", vm_node)
+
+ # Allocate irq for S5 vuart
+ if load_order != "SERVICE_VM":
+ legacy_vuart_irq = alloc_irq(irq_list)
+ create_vuart_irq_node(allocation_etree, common.get_node("./@id", vm_node), load_order, str(vuart_id), legacy_vuart_irq)
+ vuart_id = vuart_id + 1
+
vuart_connections = scenario_etree.xpath("//vuart_connection")
for connection in vuart_connections:
endpoint_list = connection.xpath(".//endpoint")
@@ -67,8 +86,8 @@ def alloc_vuart_connection_irqs(board_etree, scenario_etree, allocation_etree):
vm_name = common.get_node("./vm_name/text()",endpoint)
if vm_name == vmname:
legacy_vuart_irq = alloc_irq(irq_list)
- create_vuart_irq_node(allocation_etree, common.get_node("./@id", vm_node), load_order, vuart_id, legacy_vuart_irq)
- vuart_id = str(int(vuart_id) + 1)
+ create_vuart_irq_node(allocation_etree, common.get_node("./@id", vm_node), load_order, str(vuart_id), legacy_vuart_irq)
+ vuart_id = vuart_id + 1

def get_irqs_of_device(device_node):
irqs = set()
diff --git a/misc/config_tools/static_allocators/s5_vuart.py b/misc/config_tools/static_allocators/s5_vuart.py
new file mode 100644
index 000000000..793046504
--- /dev/null
+++ b/misc/config_tools/static_allocators/s5_vuart.py
@@ -0,0 +1,87 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) 2022 Intel Corporation.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+import sys
+import common, lib.error
+
+standard_uart_port = ['0x3F8', '0x2F8', '0x3E8', '0x2E8']
+
+# The COM1 was used for console vUART, so we alloc io_port frome COM2~COM4
+service_port_list = list(range(0x9000, 0x9100, 8))
+
+def create_s5_vuart_connection(allocation_etree, service_vm_name, service_vm_port, user_vm_name, user_vm_port):
+ vuart_connections_node = common.get_node(f"/acrn-config/hv/vuart_connections", allocation_etree)
+ if vuart_connections_node is None:
+ vuart_connections_node = common.append_node("/acrn-config/hv/vuart_connections", None, allocation_etree)
+
+ connection_name = service_vm_name + "_" + user_vm_name
+
+ vuart_connection_node = common.append_node(f"./vuart_connection", None, vuart_connections_node)
+ common.append_node(f"./name", connection_name, vuart_connection_node)
+ common.append_node(f"./type", "type", vuart_connection_node)
+
+ service_vm_endpoint = common.append_node(f"./endpoint", None, vuart_connection_node)
+ common.append_node(f"./vm_name", service_vm_name, service_vm_endpoint)
+ common.append_node(f"./io_port", service_vm_port, service_vm_endpoint)
+
+ user_vm_endpoint = common.append_node(f"./endpoint", None, vuart_connection_node)
+ common.append_node(f"./vm_name", user_vm_name, user_vm_endpoint)
+ common.append_node(f"./io_port", user_vm_port, user_vm_endpoint)
+
+def get_console_vuart_port(scenario_etree, vm_name):
+ port = common.get_node(f"//vm[name = '{vm_name}']/console_vuart/text()", scenario_etree)
+
+ if port == "COM Port 1":
+ port = "0x3F8U"
+ elif port == "COM Port 2":
+ port = "0x2F8U"
+ elif port == "COM Port 3":
+ port = "0x3E8U"
+ elif port == "COM Port 4":
+ port = "0x2E8U"
+
+ return port
+
+def alloc_free_port(scenario_etree, load_order, vm_name):
+ port_list = scenario_etree.xpath(f"//endpoint[vm_name = '{vm_name}']/io_port/text()")
+ console_port = get_console_vuart_port(scenario_etree, vm_name)
+ if console_port is not None:
+ port_list.append(console_port.replace("U", ""))
+
+ if load_order == "SERVICE_VM":
+ tmp_list = []
+ for port in port_list:
+ tmp_list.append(int(port, 16))
+
+ port_list = list(set(service_port_list) - set(tmp_list))
+ port = hex(service_port_list[0])
+ service_port_list.remove(port_list[0])
+ return str(port).upper()
+ else:
+ tmp_list = list(set(standard_uart_port) - set(port_list))
+ try:
+ port = tmp_list[0]
+ return port
+ except IndexError as e:
+ raise lib.error.ResourceError("Cannot allocate legacy io port: {}, {}".format(e, port_list)) from e
+
+def alloc_vuart_connection_info(board_etree, scenario_etree, allocation_etree):
+ user_vm_list = scenario_etree.xpath("//vm[load_order != 'SERVICE_VM']")
+ service_vm_id = common.get_node(f"//vm[load_order = 'SERVICE_VM']/@id", scenario_etree)
+ service_vm_name = common.get_node(f"//vm[load_order = 'SERVICE_VM']/name/text()", scenario_etree)
+
+ for index,vm_node in enumerate(user_vm_list):
+ vm_id = common.get_node("./@id", vm_node)
+ load_order = common.get_node("./load_order/text()", vm_node)
+ user_vm_name = common.get_node(f"./name/text()", vm_node)
+ service_vm_port = alloc_free_port(scenario_etree, "SERVICE_VM", user_vm_name)
+ user_vm_port = alloc_free_port(scenario_etree, load_order, user_vm_name)
+
+ create_s5_vuart_connection(allocation_etree, service_vm_name, service_vm_port, user_vm_name, user_vm_port)
+
+def fn(board_etree, scenario_etree, allocation_etree):
+ alloc_vuart_connection_info(board_etree, scenario_etree, allocation_etree)

1061 - 1080 of 37102