Date   

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

chenli.wei
 

On 5/18/2022 9:07 AM, Li, Fei1 wrote:
On Wed, May 18, 2022 at 02:10:32AM +0800, Dong, Eddie wrote:

-----Original Message-----
From: acrn-dev@... <acrn-dev@...> On
Behalf Of chenli.wei
Sent: Sunday, May 15, 2022 11:07 PM
To: Mao, Junjie <junjie.mao@...>; Li, Fei1 <fei1.li@...>; acrn-
dev@...
Cc: Wei, Chenli <chenli.wei@...>
Subject: [acrn-dev] [PATCH v2 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_ENTRIES, and the code style is very ugly when we use
macro to fix it.

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

v1-->v2:
1. remove ROUND2/4/8 MACROs of powerof2_roundup

Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/include/arch/x86/asm/vtd.h | 7 -------
hypervisor/include/lib/util.h | 21 ---------------------
2 files changed, 28 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
-
Can you add following comments at the 1st place (vtd.c) where the MACRO is used?
MAX_IR_ENTRIES is roundup (to power of 2) of CONFIG_MAX_PT_IRQ_ENTRIES.
OK


Also, I want you to add a check somewhere:

ASSERT( ~(MAX_IR_ENTRIES-1UL) & CONFIG_MAX_PT_IRQ_ENTRIES == 0);
Now we did this check
#if ((MAX_IR_ENTRIES < 256U) || (MAX_IR_ENTRIES > 0x10000U) || (MAX_IR_ENTRIES & (MAX_IR_ENTRIES -1)) != 0U)
#error "MAX_IR_ENTRIES must in the region of [256,0x10000] and be 2^n"
#endif
in misc/hv_prebuild/static_checks.c already.
We also check the CONFIG_MAX_PT_IRQ_ENTRIES by config tool before we align it.


You can PR with above changes.

/* Values for entry_type in ACPI_DMAR_DEVICE_SCOPE - device types */
enum acpi_dmar_scope_type {
ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0,
diff --git a/hypervisor/include/lib/util.h b/hypervisor/include/lib/util.h index
ca3296556..d702ae253 100644
--- a/hypervisor/include/lib/util.h
+++ b/hypervisor/include/lib/util.h
@@ -25,27 +25,6 @@
/** Replaces 'x' by the string "x". */
#define STRINGIFY(x) #x

-/*
- * This algorithm get the round up 2^n
- *
- * n = input - 1; 0x1002 ----> 0x1001
- * n |= n >> 1; 0x1001 | 0x800
- * n |= n >> 2; 0x1801 | 0x600
- * n |= n >> 4; 0x1e01 | 0x1e0
- * n |= n >> 8; 0x1fe1 | 0x1f
- * n |= n >> 16; 0x1fff
- * n |= n >> 32; 0x1fff
- * n += 1; 0x2000
- */
-#define ROUND0(x) ((x)-1)
-#define ROUND1(x) (ROUND0(x) |(ROUND0(x)>>1)) -#define ROUND2(x)
(ROUND1(x) |(ROUND1(x)>>2)) -#define ROUND4(x) (ROUND2(x)
|(ROUND2(x)>>4)) -#define ROUND8(x) (ROUND4(x) |(ROUND4(x)>>8)) -
#define ROUND16(x) (ROUND8(x) |(ROUND8(x)>>16)) -#define ROUND32(x)
(ROUND16(x) |(ROUND16(x)>>32)) -#define powerof2_roundup(x)
((ROUND32(x) == (~0UL)) ? ~0UL : (ROUND32(x) +1))
-
/* Macro used to check if a value is aligned to the required boundary.
* Returns TRUE if aligned; FALSE if not aligned
* NOTE: The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc)
--
2.17.1






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

Li, Fei1
 

On Wed, May 18, 2022 at 02:10:32AM +0800, Dong, Eddie wrote:


-----Original Message-----
From: acrn-dev@... <acrn-dev@...> On
Behalf Of chenli.wei
Sent: Sunday, May 15, 2022 11:07 PM
To: Mao, Junjie <junjie.mao@...>; Li, Fei1 <fei1.li@...>; acrn-
dev@...
Cc: Wei, Chenli <chenli.wei@...>
Subject: [acrn-dev] [PATCH v2 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_ENTRIES, and the code style is very ugly when we use
macro to fix it.

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

v1-->v2:
1. remove ROUND2/4/8 MACROs of powerof2_roundup

Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/include/arch/x86/asm/vtd.h | 7 -------
hypervisor/include/lib/util.h | 21 ---------------------
2 files changed, 28 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
-
Can you add following comments at the 1st place (vtd.c) where the MACRO is used?
MAX_IR_ENTRIES is roundup (to power of 2) of CONFIG_MAX_PT_IRQ_ENTRIES.


Also, I want you to add a check somewhere:

ASSERT( ~(MAX_IR_ENTRIES-1UL) & CONFIG_MAX_PT_IRQ_ENTRIES == 0);
Now we did this check
#if ((MAX_IR_ENTRIES < 256U) || (MAX_IR_ENTRIES > 0x10000U) || (MAX_IR_ENTRIES & (MAX_IR_ENTRIES -1)) != 0U)
#error "MAX_IR_ENTRIES must in the region of [256,0x10000] and be 2^n"
#endif
in misc/hv_prebuild/static_checks.c already.


You can PR with above changes.

/* Values for entry_type in ACPI_DMAR_DEVICE_SCOPE - device types */
enum acpi_dmar_scope_type {
ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0,
diff --git a/hypervisor/include/lib/util.h b/hypervisor/include/lib/util.h index
ca3296556..d702ae253 100644
--- a/hypervisor/include/lib/util.h
+++ b/hypervisor/include/lib/util.h
@@ -25,27 +25,6 @@
/** Replaces 'x' by the string "x". */
#define STRINGIFY(x) #x

-/*
- * This algorithm get the round up 2^n
- *
- * n = input - 1; 0x1002 ----> 0x1001
- * n |= n >> 1; 0x1001 | 0x800
- * n |= n >> 2; 0x1801 | 0x600
- * n |= n >> 4; 0x1e01 | 0x1e0
- * n |= n >> 8; 0x1fe1 | 0x1f
- * n |= n >> 16; 0x1fff
- * n |= n >> 32; 0x1fff
- * n += 1; 0x2000
- */
-#define ROUND0(x) ((x)-1)
-#define ROUND1(x) (ROUND0(x) |(ROUND0(x)>>1)) -#define ROUND2(x)
(ROUND1(x) |(ROUND1(x)>>2)) -#define ROUND4(x) (ROUND2(x)
|(ROUND2(x)>>4)) -#define ROUND8(x) (ROUND4(x) |(ROUND4(x)>>8)) -
#define ROUND16(x) (ROUND8(x) |(ROUND8(x)>>16)) -#define ROUND32(x)
(ROUND16(x) |(ROUND16(x)>>32)) -#define powerof2_roundup(x)
((ROUND32(x) == (~0UL)) ? ~0UL : (ROUND32(x) +1))
-
/* Macro used to check if a value is aligned to the required boundary.
* Returns TRUE if aligned; FALSE if not aligned
* NOTE: The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc)
--
2.17.1





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

Eddie Dong
 

-----Original Message-----
From: acrn-dev@... <acrn-dev@...> On
Behalf Of chenli.wei
Sent: Sunday, May 15, 2022 11:32 PM
To: acrn-dev@...; Wei, Chenli <chenli.wei@...>
Cc: Mao, Junjie <junjie.mao@...>
Subject: Re: [acrn-dev] [PATCH v2 2/2] hv: move the define of
MAX_IR_ENTRIES to offline tool


On 5/16/2022 2:23 PM, Li, Fei1 wrote:
On Mon, May 16, 2022 at 02:07:12PM +0800, Chenli Wei wrote:
There is an issue of calculate 2^n roundup of
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_ENTRIES to offline tool which could do
align check and calculate it automatically.
This patch is LGTM.
One question: would it better to add ACFG_ prefix to MAX_IR_ENTRIES ?
The name "MAX_IR_ENTRIES " was rename from
"CONFIG_MAX_IR_ENTRIES".

That's because the "MAX_IR_ENTRIES " was not config by user after we align
it with CONFIG_MAX_PT_IRQ_ENTRIES
Make sense. Let us remain with the current name.


Now we move it too config tool, by it's not user config, so I think it's better
to keep the current name.

v1-->v2:
1. remove ROUND2/4/8 MACROs of powerof2_roundup

Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/include/arch/x86/asm/vtd.h | 7 -------
hypervisor/include/lib/util.h | 21 ---------------------
2 files changed, 28 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,
diff --git a/hypervisor/include/lib/util.h
b/hypervisor/include/lib/util.h index ca3296556..d702ae253 100644
--- a/hypervisor/include/lib/util.h
+++ b/hypervisor/include/lib/util.h
@@ -25,27 +25,6 @@
/** Replaces 'x' by the string "x". */
#define STRINGIFY(x) #x

-/*
- * This algorithm get the round up 2^n
- *
- * n = input - 1; 0x1002 ----> 0x1001
- * n |= n >> 1; 0x1001 | 0x800
- * n |= n >> 2; 0x1801 | 0x600
- * n |= n >> 4; 0x1e01 | 0x1e0
- * n |= n >> 8; 0x1fe1 | 0x1f
- * n |= n >> 16; 0x1fff
- * n |= n >> 32; 0x1fff
- * n += 1; 0x2000
- */
-#define ROUND0(x) ((x)-1)
-#define ROUND1(x) (ROUND0(x) |(ROUND0(x)>>1)) -#define ROUND2(x)
(ROUND1(x) |(ROUND1(x)>>2)) -#define ROUND4(x) (ROUND2(x)
|(ROUND2(x)>>4)) -#define ROUND8(x) (ROUND4(x) |(ROUND4(x)>>8))
-#define ROUND16(x) (ROUND8(x) |(ROUND8(x)>>16)) -#define
ROUND32(x)
(ROUND16(x) |(ROUND16(x)>>32)) -#define powerof2_roundup(x)
((ROUND32(x) == (~0UL)) ? ~0UL : (ROUND32(x) +1))
-
/* Macro used to check if a value is aligned to the required boundary.
* Returns TRUE if aligned; FALSE if not aligned
* NOTE: The required alignment must be a power of 2 (2, 4, 8, 16,
32, etc)
--
2.17.1





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

Eddie Dong
 

-----Original Message-----
From: acrn-dev@... <acrn-dev@...> On
Behalf Of chenli.wei
Sent: Sunday, May 15, 2022 11:07 PM
To: Mao, Junjie <junjie.mao@...>; Li, Fei1 <fei1.li@...>; acrn-
dev@...
Cc: Wei, Chenli <chenli.wei@...>
Subject: [acrn-dev] [PATCH v2 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_ENTRIES, and the code style is very ugly when we use
macro to fix it.

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

v1-->v2:
1. remove ROUND2/4/8 MACROs of powerof2_roundup

Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/include/arch/x86/asm/vtd.h | 7 -------
hypervisor/include/lib/util.h | 21 ---------------------
2 files changed, 28 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
-
Can you add following comments at the 1st place (vtd.c) where the MACRO is used?
MAX_IR_ENTRIES is roundup (to power of 2) of CONFIG_MAX_PT_IRQ_ENTRIES.


Also, I want you to add a check somewhere:

ASSERT( ~(MAX_IR_ENTRIES-1UL) & CONFIG_MAX_PT_IRQ_ENTRIES == 0);



You can PR with above changes.

/* Values for entry_type in ACPI_DMAR_DEVICE_SCOPE - device types */
enum acpi_dmar_scope_type {
ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0,
diff --git a/hypervisor/include/lib/util.h b/hypervisor/include/lib/util.h index
ca3296556..d702ae253 100644
--- a/hypervisor/include/lib/util.h
+++ b/hypervisor/include/lib/util.h
@@ -25,27 +25,6 @@
/** Replaces 'x' by the string "x". */
#define STRINGIFY(x) #x

-/*
- * This algorithm get the round up 2^n
- *
- * n = input - 1; 0x1002 ----> 0x1001
- * n |= n >> 1; 0x1001 | 0x800
- * n |= n >> 2; 0x1801 | 0x600
- * n |= n >> 4; 0x1e01 | 0x1e0
- * n |= n >> 8; 0x1fe1 | 0x1f
- * n |= n >> 16; 0x1fff
- * n |= n >> 32; 0x1fff
- * n += 1; 0x2000
- */
-#define ROUND0(x) ((x)-1)
-#define ROUND1(x) (ROUND0(x) |(ROUND0(x)>>1)) -#define ROUND2(x)
(ROUND1(x) |(ROUND1(x)>>2)) -#define ROUND4(x) (ROUND2(x)
|(ROUND2(x)>>4)) -#define ROUND8(x) (ROUND4(x) |(ROUND4(x)>>8)) -
#define ROUND16(x) (ROUND8(x) |(ROUND8(x)>>16)) -#define ROUND32(x)
(ROUND16(x) |(ROUND16(x)>>32)) -#define powerof2_roundup(x)
((ROUND32(x) == (~0UL)) ? ~0UL : (ROUND32(x) +1))
-
/* Macro used to check if a value is aligned to the required boundary.
* Returns TRUE if aligned; FALSE if not aligned
* NOTE: The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc)
--
2.17.1





Re: [PATCH v2] misc: add assert for vUART connection

chenli.wei
 

On 5/17/2022 11:12 AM, Junjie Mao wrote:
"chenli.wei" <chenli.wei@...> writes:

The current UI have no live-check to check whether a VM connect to
itself.

So we add an assert to the schema and return error when user connect a
VM to itself.

v1-->v2:
1. change the remind msg format

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

One minor comment below.

---
.../config_tools/schema/checks/vuart_config.xsd | 17 +++++++++++++++++
misc/config_tools/schema/datachecks.xsd | 1 +
2 files changed, 18 insertions(+)
create mode 100644 misc/config_tools/schema/checks/vuart_config.xsd

diff --git a/misc/config_tools/schema/checks/vuart_config.xsd b/misc/config_tools/schema/checks/vuart_config.xsd
new file mode 100644
index 000000000..f08d83c13
--- /dev/null
+++ b/misc/config_tools/schema/checks/vuart_config.xsd
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2022 Intel Corporation. -->
+<!-- SPDX-License-Identifier: BSD-3-Clause -->
+
+<xs:schema xml:id="root"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:acrn="https://projectacrn.org">
+
+ <xs:assert test="every $vuart_connection in /acrn-config//vuart_connection satisfies
+ every $vm_name in $vuart_connection/endpoint/vm_name/text() satisfies
+ count($vuart_connection/endpoint[./vm_name/text()=$vm_name]) = 1">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vuart_connection/endpoint">
+ <xs:documentation>"{$vm_name}" can't connected to itself</xs:documentation>
Add "VM" before "{$vm_name}" to say explicitly that it is a VM.
Done


Re: [PATCH v2] misc: add assert for vUART connection

Junjie Mao
 

"chenli.wei" <chenli.wei@...> writes:

The current UI have no live-check to check whether a VM connect to
itself.

So we add an assert to the schema and return error when user connect a
VM to itself.

v1-->v2:
1. change the remind msg format

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

One minor comment below.

---
.../config_tools/schema/checks/vuart_config.xsd | 17 +++++++++++++++++
misc/config_tools/schema/datachecks.xsd | 1 +
2 files changed, 18 insertions(+)
create mode 100644 misc/config_tools/schema/checks/vuart_config.xsd

diff --git a/misc/config_tools/schema/checks/vuart_config.xsd b/misc/config_tools/schema/checks/vuart_config.xsd
new file mode 100644
index 000000000..f08d83c13
--- /dev/null
+++ b/misc/config_tools/schema/checks/vuart_config.xsd
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2022 Intel Corporation. -->
+<!-- SPDX-License-Identifier: BSD-3-Clause -->
+
+<xs:schema xml:id="root"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:acrn="https://projectacrn.org">
+
+ <xs:assert test="every $vuart_connection in /acrn-config//vuart_connection satisfies
+ every $vm_name in $vuart_connection/endpoint/vm_name/text() satisfies
+ count($vuart_connection/endpoint[./vm_name/text()=$vm_name]) = 1">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vuart_connection/endpoint">
+ <xs:documentation>"{$vm_name}" can't connected to itself</xs:documentation>
Add "VM" before "{$vm_name}" to say explicitly that it is a VM.

--
Best Regards
Junjie Mao

+ </xs:annotation>
+ </xs:assert>
+
+</xs:schema>
diff --git a/misc/config_tools/schema/datachecks.xsd b/misc/config_tools/schema/datachecks.xsd
index f8c934eda..fc9badf53 100644
--- a/misc/config_tools/schema/datachecks.xsd
+++ b/misc/config_tools/schema/datachecks.xsd
@@ -14,6 +14,7 @@
<xi:include href="checks/vbdf_assignment.xsd" xpointer="xpointer(id('root')/*)" />
<xi:include href="checks/vm_types.xsd" xpointer="xpointer(id('root')/*)" />
<xi:include href="checks/passthrough_devices.xsd" xpointer="xpointer(id('root')/*)" />
+ <xi:include href="checks/vuart_config.xsd" xpointer="xpointer(id('root')/*)" />

</xs:complexType>
</xs:element>


[PATCH v2] misc: add assert for vUART connection

chenli.wei
 

The current UI have no live-check to check whether a VM connect to
itself.

So we add an assert to the schema and return error when user connect a
VM to itself.

v1-->v2:
1. change the remind msg format

Signed-off-by: Chenli Wei <chenli.wei@...>
---
.../config_tools/schema/checks/vuart_config.xsd | 17 +++++++++++++++++
misc/config_tools/schema/datachecks.xsd | 1 +
2 files changed, 18 insertions(+)
create mode 100644 misc/config_tools/schema/checks/vuart_config.xsd

diff --git a/misc/config_tools/schema/checks/vuart_config.xsd b/misc/config_tools/schema/checks/vuart_config.xsd
new file mode 100644
index 000000000..f08d83c13
--- /dev/null
+++ b/misc/config_tools/schema/checks/vuart_config.xsd
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2022 Intel Corporation. -->
+<!-- SPDX-License-Identifier: BSD-3-Clause -->
+
+<xs:schema xml:id="root"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:acrn="https://projectacrn.org">
+
+ <xs:assert test="every $vuart_connection in /acrn-config//vuart_connection satisfies
+ every $vm_name in $vuart_connection/endpoint/vm_name/text() satisfies
+ count($vuart_connection/endpoint[./vm_name/text()=$vm_name]) = 1">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vuart_connection/endpoint">
+ <xs:documentation>"{$vm_name}" can't connected to itself</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
+</xs:schema>
diff --git a/misc/config_tools/schema/datachecks.xsd b/misc/config_tools/schema/datachecks.xsd
index f8c934eda..fc9badf53 100644
--- a/misc/config_tools/schema/datachecks.xsd
+++ b/misc/config_tools/schema/datachecks.xsd
@@ -14,6 +14,7 @@
<xi:include href="checks/vbdf_assignment.xsd" xpointer="xpointer(id('root')/*)" />
<xi:include href="checks/vm_types.xsd" xpointer="xpointer(id('root')/*)" />
<xi:include href="checks/passthrough_devices.xsd" xpointer="xpointer(id('root')/*)" />
+ <xi:include href="checks/vuart_config.xsd" xpointer="xpointer(id('root')/*)" />

</xs:complexType>
</xs:element>
--
2.17.1


Re: [PATCH] misc: add assert for vUART connection

chenli.wei
 

On 5/17/2022 8:14 AM, Junjie Mao wrote:
Chenli Wei <chenli.wei@...> writes:

The current UI have no live-check to check whether a VM connect to
itself.

So we add an assert to the schema and return error when user connect a
VM to itself.

Signed-off-by: Chenli Wei <chenli.wei@...>
---
.../config_tools/schema/checks/vuart_config.xsd | 17 +++++++++++++++++
misc/config_tools/schema/datachecks.xsd | 1 +
2 files changed, 18 insertions(+)
create mode 100644 misc/config_tools/schema/checks/vuart_config.xsd

diff --git a/misc/config_tools/schema/checks/vuart_config.xsd b/misc/config_tools/schema/checks/vuart_config.xsd
new file mode 100644
index 000000000..511075d92
--- /dev/null
+++ b/misc/config_tools/schema/checks/vuart_config.xsd
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2022 Intel Corporation. -->
+<!-- SPDX-License-Identifier: BSD-3-Clause -->
+
+<xs:schema xml:id="root"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:acrn="https://projectacrn.org">
+
+ <xs:assert test="every $vuart_connection in /acrn-config//vuart_connection satisfies
+ every $vm_name in $vuart_connection/endpoint/vm_name/text() satisfies
+ count($vuart_connection/endpoint[./vm_name/text()=$vm_name]) = 1">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vuart_connection/name">
+ <xs:documentation>vuart_connection "{$vm_name}" can't connected to itself</xs:documentation>
`vm_name` is not the name of the vUART connection.
This message want to remind user the VM connected to it self, so I change the report-on to make it clear:

 12     <xs:annotation acrn:severity="error" acrn:report-on="$vuart_connection/endpoint">
 13       <xs:documentation>"{$vm_name}" can't connected to itself</xs:documentation>

Now the message is:

"ERROR:root:/acrn-config/hv/vuart_connections/vuart_connection[2]/endpoint[1], /acrn-config/hv/vuart_connections/vuart_connection[2]/endpoint[2]: "POST_RT_VM1" can't connected to itself"


Re: [PATCH] misc: add assert for vUART connection

Junjie Mao
 

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

The current UI have no live-check to check whether a VM connect to
itself.

So we add an assert to the schema and return error when user connect a
VM to itself.

Signed-off-by: Chenli Wei <chenli.wei@...>
---
.../config_tools/schema/checks/vuart_config.xsd | 17 +++++++++++++++++
misc/config_tools/schema/datachecks.xsd | 1 +
2 files changed, 18 insertions(+)
create mode 100644 misc/config_tools/schema/checks/vuart_config.xsd

diff --git a/misc/config_tools/schema/checks/vuart_config.xsd b/misc/config_tools/schema/checks/vuart_config.xsd
new file mode 100644
index 000000000..511075d92
--- /dev/null
+++ b/misc/config_tools/schema/checks/vuart_config.xsd
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2022 Intel Corporation. -->
+<!-- SPDX-License-Identifier: BSD-3-Clause -->
+
+<xs:schema xml:id="root"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:acrn="https://projectacrn.org">
+
+ <xs:assert test="every $vuart_connection in /acrn-config//vuart_connection satisfies
+ every $vm_name in $vuart_connection/endpoint/vm_name/text() satisfies
+ count($vuart_connection/endpoint[./vm_name/text()=$vm_name]) = 1">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vuart_connection/name">
+ <xs:documentation>vuart_connection "{$vm_name}" can't connected to itself</xs:documentation>
`vm_name` is not the name of the vUART connection.

--
Best Regards
Junjie Mao

+ </xs:annotation>
+ </xs:assert>
+
+</xs:schema>
diff --git a/misc/config_tools/schema/datachecks.xsd b/misc/config_tools/schema/datachecks.xsd
index f8c934eda..fc9badf53 100644
--- a/misc/config_tools/schema/datachecks.xsd
+++ b/misc/config_tools/schema/datachecks.xsd
@@ -14,6 +14,7 @@
<xi:include href="checks/vbdf_assignment.xsd" xpointer="xpointer(id('root')/*)" />
<xi:include href="checks/vm_types.xsd" xpointer="xpointer(id('root')/*)" />
<xi:include href="checks/passthrough_devices.xsd" xpointer="xpointer(id('root')/*)" />
+ <xi:include href="checks/vuart_config.xsd" xpointer="xpointer(id('root')/*)" />

</xs:complexType>
</xs:element>


Re: [PATCH v3] config_tools: format vitio input in configurator

Junjie Mao
 

Kunhui-Li <kunhuix.li@...> writes:

This patch formats virtio input entry as "Device name: xxx, Device physical path: xxx".

v2-->v3:
1. remove the exception handler of enum in pyodide/loadBoard.py.
3. update the `acrn:options-sorted-by` function for virtio input.

v1-->v2:
use XPATH instead of the specific python code to parse virtio input data.

Tracked-On: #6691
Signed-off-by: Kunhui-Li <kunhuix.li@...>
Reviewed-by: Junjie Mao <junjie.mao@...>

--
Best Regards
Junjie Mao

---
misc/config_tools/schema/VMtypes.xsd | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd
index 302e152b6..91fd76cd6 100644
--- a/misc/config_tools/schema/VMtypes.xsd
+++ b/misc/config_tools/schema/VMtypes.xsd
@@ -395,7 +395,9 @@ 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" acrn:widget-options="'placeholder': '/dev/input/eventX'">
+ <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'"
+ acrn:options="for $input in //inputs/input return concat('Device name: ', $input/name/text(), ', Device physical path: ', $input/phys/text())"
+ acrn:options-sorted-by="lambda s: s">
<xs:documentation>Specifying backend device in service vm with device description.</xs:documentation>
</xs:annotation>
</xs:element>


[PATCH v3] config_tools: format vitio input in configurator

Kunhui Li
 

This patch formats virtio input entry as "Device name: xxx, Device physical path: xxx".

v2-->v3:
1. remove the exception handler of enum in pyodide/loadBoard.py.
3. update the `acrn:options-sorted-by` function for virtio input.

v1-->v2:
use XPATH instead of the specific python code to parse virtio input data.

Tracked-On: #6691
Signed-off-by: Kunhui-Li <kunhuix.li@...>
---
misc/config_tools/schema/VMtypes.xsd | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd
index 302e152b6..91fd76cd6 100644
--- a/misc/config_tools/schema/VMtypes.xsd
+++ b/misc/config_tools/schema/VMtypes.xsd
@@ -395,7 +395,9 @@ 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" acrn:widget-options="'placeholder': '/dev/input/eventX'">
+ <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'"
+ acrn:options="for $input in //inputs/input return concat('Device name: ', $input/name/text(), ', Device physical path: ', $input/phys/text())"
+ acrn:options-sorted-by="lambda s: s">
<xs:documentation>Specifying backend device in service vm with device description.</xs:documentation>
</xs:annotation>
</xs:element>
--
2.25.1


Re: [PATCH v2] config_tools: format vitio input in configurator

Kunhui Li
 

-----Original Message-----
From: Mao, Junjie <junjie.mao@...>
Sent: Monday, May 16, 2022 5:02 PM
To: Li, KunhuiX <kunhuix.li@...>
Cc: acrn-dev@...; Xie, Nanlin <nanlin.xie@...>; Sun, Victor <victor.sun@...>
Subject: Re: [PATCH v2] config_tools: format vitio input in configurator

Kunhui-Li <kunhuix.li@...> writes:

This patch formats virtio input entry as "Device name: xxx, Device physical path: xxx".

v1-->v2:
use XPATH instead of the specific python code to parse virtio input data.

Tracked-On: #6691
Signed-off-by: Kunhui-Li <kunhuix.li@...>
---
misc/config_tools/configurator/pyodide/loadBoard.py | 6 +++++-
misc/config_tools/schema/VMtypes.xsd | 4 +++-
2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/misc/config_tools/configurator/pyodide/loadBoard.py b/misc/config_tools/configurator/pyodide/loadBoard.py
index 48bb02715..dc44ad7fe 100644
--- a/misc/config_tools/configurator/pyodide/loadBoard.py
+++ b/misc/config_tools/configurator/pyodide/loadBoard.py
@@ -2,6 +2,7 @@
__package__ = 'configurator.pyodide'

import json
+import logging
from copy import deepcopy

import elementpath
@@ -42,7 +43,10 @@ def get_dynamic_scenario(board):
# get enum data
enum = function(source, selector, obj_type)
if sorted_func:
- enum = sorted(enum, key=eval(sorted_func))
+ try:
+ enum = sorted(enum, key=eval(sorted_func))
+ except IndexError as e:
+ logging.warning(e)
Recommend to get rid of this because the logging module is not
initialized in pyodide for now.
Will remove it.

return enum

def dynamic_enum_apply(obj):
diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd
index 302e152b6..d7b1985e2 100644
--- a/misc/config_tools/schema/VMtypes.xsd
+++ b/misc/config_tools/schema/VMtypes.xsd
@@ -395,7 +395,9 @@ 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" acrn:widget-options="'placeholder': '/dev/input/eventX'">
+ <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'"
+ acrn:options="for $input in //inputs/input return concat('Device name: ', $input/name/text(), ', Device physical path: ',
$input/phys/text())"
+ acrn:options-sorted-by="lambda s: (s.split('Device name: ')[1].split(', Device physical path')[0], s.split('Device physical path:
')[1])">

How is this sorting function different from sorting by `s` itself?
It's same with the function "lambda s: s"...
will update.

--
Best Regards
Junjie Mao

<xs:documentation>Specifying backend device in service vm with device description.</xs:documentation>
</xs:annotation>
</xs:element>


[PATCH] misc: add assert for vUART connection

chenli.wei
 

The current UI have no live-check to check whether a VM connect to
itself.

So we add an assert to the schema and return error when user connect a
VM to itself.

Signed-off-by: Chenli Wei <chenli.wei@...>
---
.../config_tools/schema/checks/vuart_config.xsd | 17 +++++++++++++++++
misc/config_tools/schema/datachecks.xsd | 1 +
2 files changed, 18 insertions(+)
create mode 100644 misc/config_tools/schema/checks/vuart_config.xsd

diff --git a/misc/config_tools/schema/checks/vuart_config.xsd b/misc/config_tools/schema/checks/vuart_config.xsd
new file mode 100644
index 000000000..511075d92
--- /dev/null
+++ b/misc/config_tools/schema/checks/vuart_config.xsd
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2022 Intel Corporation. -->
+<!-- SPDX-License-Identifier: BSD-3-Clause -->
+
+<xs:schema xml:id="root"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:acrn="https://projectacrn.org">
+
+ <xs:assert test="every $vuart_connection in /acrn-config//vuart_connection satisfies
+ every $vm_name in $vuart_connection/endpoint/vm_name/text() satisfies
+ count($vuart_connection/endpoint[./vm_name/text()=$vm_name]) = 1">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vuart_connection/name">
+ <xs:documentation>vuart_connection "{$vm_name}" can't connected to itself</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
+</xs:schema>
diff --git a/misc/config_tools/schema/datachecks.xsd b/misc/config_tools/schema/datachecks.xsd
index f8c934eda..fc9badf53 100644
--- a/misc/config_tools/schema/datachecks.xsd
+++ b/misc/config_tools/schema/datachecks.xsd
@@ -14,6 +14,7 @@
<xi:include href="checks/vbdf_assignment.xsd" xpointer="xpointer(id('root')/*)" />
<xi:include href="checks/vm_types.xsd" xpointer="xpointer(id('root')/*)" />
<xi:include href="checks/passthrough_devices.xsd" xpointer="xpointer(id('root')/*)" />
+ <xi:include href="checks/vuart_config.xsd" xpointer="xpointer(id('root')/*)" />

</xs:complexType>
</xs:element>
--
2.17.1


Re: [PATCH v2] config_tools: format vitio input in configurator

Junjie Mao
 

Kunhui-Li <kunhuix.li@...> writes:

This patch formats virtio input entry as "Device name: xxx, Device physical path: xxx".

v1-->v2:
use XPATH instead of the specific python code to parse virtio input data.

Tracked-On: #6691
Signed-off-by: Kunhui-Li <kunhuix.li@...>
---
misc/config_tools/configurator/pyodide/loadBoard.py | 6 +++++-
misc/config_tools/schema/VMtypes.xsd | 4 +++-
2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/misc/config_tools/configurator/pyodide/loadBoard.py b/misc/config_tools/configurator/pyodide/loadBoard.py
index 48bb02715..dc44ad7fe 100644
--- a/misc/config_tools/configurator/pyodide/loadBoard.py
+++ b/misc/config_tools/configurator/pyodide/loadBoard.py
@@ -2,6 +2,7 @@
__package__ = 'configurator.pyodide'

import json
+import logging
from copy import deepcopy

import elementpath
@@ -42,7 +43,10 @@ def get_dynamic_scenario(board):
# get enum data
enum = function(source, selector, obj_type)
if sorted_func:
- enum = sorted(enum, key=eval(sorted_func))
+ try:
+ enum = sorted(enum, key=eval(sorted_func))
+ except IndexError as e:
+ logging.warning(e)
Recommend to get rid of this because the logging module is not
initialized in pyodide for now.

return enum

def dynamic_enum_apply(obj):
diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd
index 302e152b6..d7b1985e2 100644
--- a/misc/config_tools/schema/VMtypes.xsd
+++ b/misc/config_tools/schema/VMtypes.xsd
@@ -395,7 +395,9 @@ 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" acrn:widget-options="'placeholder': '/dev/input/eventX'">
+ <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'"
+ acrn:options="for $input in //inputs/input return concat('Device name: ', $input/name/text(), ', Device physical path: ', $input/phys/text())"
+ acrn:options-sorted-by="lambda s: (s.split('Device name: ')[1].split(', Device physical path')[0], s.split('Device physical path: ')[1])">
How is this sorting function different from sorting by `s` itself?

--
Best Regards
Junjie Mao

<xs:documentation>Specifying backend device in service vm with device description.</xs:documentation>
</xs:annotation>
</xs:element>


[PATCH v2] config_tools: format vitio input in configurator

Kunhui Li
 

This patch formats virtio input entry as "Device name: xxx, Device physical path: xxx".

v1-->v2:
use XPATH instead of the specific python code to parse virtio input data.

Tracked-On: #6691
Signed-off-by: Kunhui-Li <kunhuix.li@...>
---
misc/config_tools/configurator/pyodide/loadBoard.py | 6 +++++-
misc/config_tools/schema/VMtypes.xsd | 4 +++-
2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/misc/config_tools/configurator/pyodide/loadBoard.py b/misc/config_tools/configurator/pyodide/loadBoard.py
index 48bb02715..dc44ad7fe 100644
--- a/misc/config_tools/configurator/pyodide/loadBoard.py
+++ b/misc/config_tools/configurator/pyodide/loadBoard.py
@@ -2,6 +2,7 @@
__package__ = 'configurator.pyodide'

import json
+import logging
from copy import deepcopy

import elementpath
@@ -42,7 +43,10 @@ def get_dynamic_scenario(board):
# get enum data
enum = function(source, selector, obj_type)
if sorted_func:
- enum = sorted(enum, key=eval(sorted_func))
+ try:
+ enum = sorted(enum, key=eval(sorted_func))
+ except IndexError as e:
+ logging.warning(e)
return enum

def dynamic_enum_apply(obj):
diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd
index 302e152b6..d7b1985e2 100644
--- a/misc/config_tools/schema/VMtypes.xsd
+++ b/misc/config_tools/schema/VMtypes.xsd
@@ -395,7 +395,9 @@ 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" acrn:widget-options="'placeholder': '/dev/input/eventX'">
+ <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'"
+ acrn:options="for $input in //inputs/input return concat('Device name: ', $input/name/text(), ', Device physical path: ', $input/phys/text())"
+ acrn:options-sorted-by="lambda s: (s.split('Device name: ')[1].split(', Device physical path')[0], s.split('Device physical path: ')[1])">
<xs:documentation>Specifying backend device in service vm with device description.</xs:documentation>
</xs:annotation>
</xs:element>
--
2.25.1


Re: [PATCH 1/2] config_tools: format vitio input in configurator

Kunhui Li
 

-----Original Message-----
From: Mao, Junjie <junjie.mao@...>
Sent: Monday, May 16, 2022 1:39 PM
To: Li, KunhuiX <kunhuix.li@...>
Cc: acrn-dev@...; Xie, Nanlin <nanlin.xie@...>; Feng, WeiyiX <weiyix.feng@...>
Subject: Re: [PATCH 1/2] config_tools: format vitio input in configurator

Kunhui-Li <kunhuix.li@...> writes:

This patch formats virtio input entry as "Device name: xxx, Device physical path: xxx".

Tracked-On: #6691
Signed-off-by: Kunhui-Li <kunhuix.li@...>
---
misc/config_tools/configurator/pyodide/loadBoard.py | 12 ++++++++++--
misc/config_tools/schema/VMtypes.xsd | 3 ++-
2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/misc/config_tools/configurator/pyodide/loadBoard.py b/misc/config_tools/configurator/pyodide/loadBoard.py
index 48bb02715..035c89fa2 100644
--- a/misc/config_tools/configurator/pyodide/loadBoard.py
+++ b/misc/config_tools/configurator/pyodide/loadBoard.py
@@ -2,6 +2,7 @@
__package__ = 'configurator.pyodide'

import json
+import logging
from copy import deepcopy

import elementpath
@@ -20,7 +21,11 @@ def get_dynamic_scenario(board):
board_xml = etree.fromstring(board)

def get_enum(source, options, obj_type):
- elements = [str(x) for x in elementpath.select(source, options) if x]
+ if options == "//inputs/input":
+ inputs_etree = [x for x in elementpath.select(source, options) if x is not None]
+ elements = [f"Device name: {str(elementpath.select(i, './name/text()')[0])}, Device physical path: {str(elementpath.select(i,
'./phys/text()')[0])}" for i in inputs_etree]
+ else:
+ elements = [str(x) for x in elementpath.select(source, options) if x]
This file contains the general logic to extract enum values from
annotations and is not where item-specific logic should be placed. XPATH
2.0 already supports functions like string-join and for-expressions. You
should be able to express what you need using a single XPATH.
Will update.

elements = list(set(elements))
if not elements:
elements = ['']
@@ -42,7 +47,10 @@ def get_dynamic_scenario(board):
# get enum data
enum = function(source, selector, obj_type)
if sorted_func:
- enum = sorted(enum, key=eval(sorted_func))
+ try:
+ enum = sorted(enum, key=eval(sorted_func))
+ except IndexError as e:
+ logging.warning(e)
Why do you need catch this exception?
Because the "IndexError" will be raise if the //input/name and //input/phys data is not found in board xml file, then user will fail to import board xml.
May I can remove this because it is unnecessary if we use XPATH to parse data.

--
Best Regards
Junjie Mao

return enum

def dynamic_enum_apply(obj):
diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd
index 302e152b6..8fe381caa 100644
--- a/misc/config_tools/schema/VMtypes.xsd
+++ b/misc/config_tools/schema/VMtypes.xsd
@@ -395,7 +395,8 @@ 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" acrn:widget-options="'placeholder': '/dev/input/eventX'">
+ <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'"
acrn:options="//inputs/input"
+ acrn:options-sorted-by="lambda s: (s.split('Device name: ')[1].split(', Device physical path')[0], s.split('Device physical path:
')[1])">
<xs:documentation>Specifying backend device in service vm with device description.</xs:documentation>
</xs:annotation>
</xs:element>


Canceled: 2022 ACRN Project Technical Community Meeting: @ Monthly 3rd Wednesday 4PM (China-Shanghai), Wednesday 10AM (Europe-Munich), Tuesday 1AM (US-West Coast)

Zou, Terry
 

   Cancel this month’s TCM, thanks.
WW21 ACRN Based X86 OPTEE Introduction Liu Yifan 5/18/2021
 
Special Notes: If you have Zoom connection issue by using web browser, please install & launch Zoom application, manually input the meeting ID (320664063) to join the Zoom meeting.
 
Agenda & Archives:
WW Topic Presenter Status
Chinese New Year Break
WW12 Libvirt Enhancement Introduction to Replace acrnctl Wu Xiangyang 3/16/2021
WW17 ACRN DX: New config/para Design and Application Xie Nanlin 4/20/2021
WW21 ACRN Based X86 OPTEE Introduction Liu Yifan 5/18/2021
WW25 ACRN Modularization Introduction Chen Jason 6/15/2021
WW30 ACRN DX: Dynamic Parameter Configuration Liu, Hang 7/20/2021
 
Project ACRN: A flexible, light-weight, open source reference hypervisor for IoT devices
We invite you to attend a monthly "Technical Community" meeting where we'll meet community members and talk about the ACRN project and plans.
As we explore community interest and involvement opportunities, we'll (re)schedule these meetings at a time convenient to most attendees:
  • Meets every 3rd Wednesday, 4-5:00 PM (China-Shanghai), Wednesday 10-11:00 AM (Europe-Munich), Tuesday 1-2:00 AM (US-West Coast)
  • Chairperson: Terry ZOU, terry.zou@... (Intel)
  • Online conference link: https://zoom.com.cn/j/320664063
  • Zoom Meeting ID: 320 664 063
  • Special Notes: If you have Zoom connection issue by using web browser, please launch Zoom application, manually input the meeting ID (320664063) to join the Zoom meeting.
  • Online conference phone:
  • China: +86 010 87833177  or 400 669 9381 (Toll Free)
  • Germany: +49 (0) 30 3080 6188  or +49 800 724 3138 (Toll Free)
  • US: +1 669 900 6833  or +1 646 558 8656   or +1 877 369 0926 (Toll Free) or +1 855 880 1246 (Toll Free)
  • Additional international phone numbers
  • Meeting Notes:
 
 


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

chenli.wei
 

On 5/16/2022 2:23 PM, Li, Fei1 wrote:
On Mon, May 16, 2022 at 02:07:12PM +0800, Chenli Wei wrote:
There is an issue of calculate 2^n roundup of 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_ENTRIES to offline tool which could do align
check and calculate it automatically.
This patch is LGTM.
One question: would it better to add ACFG_ prefix to MAX_IR_ENTRIES ?
The name "MAX_IR_ENTRIES " was rename from "CONFIG_MAX_IR_ENTRIES".

That's because the "MAX_IR_ENTRIES " was not config by user after we align it with CONFIG_MAX_PT_IRQ_ENTRIES

Now we move it too config tool, by it's not user config, so I think it's better to keep the current name.

v1-->v2:
1. remove ROUND2/4/8 MACROs of powerof2_roundup

Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/include/arch/x86/asm/vtd.h | 7 -------
hypervisor/include/lib/util.h | 21 ---------------------
2 files changed, 28 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,
diff --git a/hypervisor/include/lib/util.h b/hypervisor/include/lib/util.h
index ca3296556..d702ae253 100644
--- a/hypervisor/include/lib/util.h
+++ b/hypervisor/include/lib/util.h
@@ -25,27 +25,6 @@
/** Replaces 'x' by the string "x". */
#define STRINGIFY(x) #x
-/*
- * This algorithm get the round up 2^n
- *
- * n = input - 1; 0x1002 ----> 0x1001
- * n |= n >> 1; 0x1001 | 0x800
- * n |= n >> 2; 0x1801 | 0x600
- * n |= n >> 4; 0x1e01 | 0x1e0
- * n |= n >> 8; 0x1fe1 | 0x1f
- * n |= n >> 16; 0x1fff
- * n |= n >> 32; 0x1fff
- * n += 1; 0x2000
- */
-#define ROUND0(x) ((x)-1)
-#define ROUND1(x) (ROUND0(x) |(ROUND0(x)>>1))
-#define ROUND2(x) (ROUND1(x) |(ROUND1(x)>>2))
-#define ROUND4(x) (ROUND2(x) |(ROUND2(x)>>4))
-#define ROUND8(x) (ROUND4(x) |(ROUND4(x)>>8))
-#define ROUND16(x) (ROUND8(x) |(ROUND8(x)>>16))
-#define ROUND32(x) (ROUND16(x) |(ROUND16(x)>>32))
-#define powerof2_roundup(x) ((ROUND32(x) == (~0UL)) ? ~0UL : (ROUND32(x) +1))
-
/* Macro used to check if a value is aligned to the required boundary.
* Returns TRUE if aligned; FALSE if not aligned
* NOTE: The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc)
--
2.17.1


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

Li, Fei1
 

On Mon, May 16, 2022 at 02:07:12PM +0800, Chenli Wei wrote:
There is an issue of calculate 2^n roundup of 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_ENTRIES to offline tool which could do align
check and calculate it automatically.
This patch is LGTM.
One question: would it better to add ACFG_ prefix to MAX_IR_ENTRIES ?

v1-->v2:
1. remove ROUND2/4/8 MACROs of powerof2_roundup

Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/include/arch/x86/asm/vtd.h | 7 -------
hypervisor/include/lib/util.h | 21 ---------------------
2 files changed, 28 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,
diff --git a/hypervisor/include/lib/util.h b/hypervisor/include/lib/util.h
index ca3296556..d702ae253 100644
--- a/hypervisor/include/lib/util.h
+++ b/hypervisor/include/lib/util.h
@@ -25,27 +25,6 @@
/** Replaces 'x' by the string "x". */
#define STRINGIFY(x) #x

-/*
- * This algorithm get the round up 2^n
- *
- * n = input - 1; 0x1002 ----> 0x1001
- * n |= n >> 1; 0x1001 | 0x800
- * n |= n >> 2; 0x1801 | 0x600
- * n |= n >> 4; 0x1e01 | 0x1e0
- * n |= n >> 8; 0x1fe1 | 0x1f
- * n |= n >> 16; 0x1fff
- * n |= n >> 32; 0x1fff
- * n += 1; 0x2000
- */
-#define ROUND0(x) ((x)-1)
-#define ROUND1(x) (ROUND0(x) |(ROUND0(x)>>1))
-#define ROUND2(x) (ROUND1(x) |(ROUND1(x)>>2))
-#define ROUND4(x) (ROUND2(x) |(ROUND2(x)>>4))
-#define ROUND8(x) (ROUND4(x) |(ROUND4(x)>>8))
-#define ROUND16(x) (ROUND8(x) |(ROUND8(x)>>16))
-#define ROUND32(x) (ROUND16(x) |(ROUND16(x)>>32))
-#define powerof2_roundup(x) ((ROUND32(x) == (~0UL)) ? ~0UL : (ROUND32(x) +1))
-
/* Macro used to check if a value is aligned to the required boundary.
* Returns TRUE if aligned; FALSE if not aligned
* NOTE: The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc)
--
2.17.1


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

chenli.wei
 

On 5/16/2022 12:47 PM, Junjie Mao wrote:
"Junjie Mao" <junjie.mao@...> writes:

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

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@...>
Reviewed-by: Junjie Mao <junjie.mao@...>

Some minor comments below.

---
.../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
`1 << value.bit_length()` is simpler and more straightforward.
Need take care about the boundary values:

`0 if value == 0 else (1 << (value - 1).bit_length())`
Thanks, I have send again with the V2 of HV patch

1021 - 1040 of 37092