Skip to contentSkip to conversation

Extend resources to support more vcpus in single VM

RFC PATCH In review Chao Gao 8 participants 56 messages Dec 6, 2017 – Apr 18, 2018

Subsystems (2)
lore
Share & tools
lore

Chao Gao

author
#0 lore raw

v4 cover Extend resources to support more vcpus in single VM

This series is based on Paul Durrant's "x86: guest resource mapping"
(https://lists.xenproject.org/archives/html/xen-devel/2017-11/msg01735.html)
and "add vIOMMU support with irq remapping function of virtual VT-d"
(https://lists.xenproject.org/archives/html/xen-devel/2017-11/msg01063.html).

In order to support more vcpus in hvm, this series is to remove VCPU number constraint imposed by several components:
1. IOREQ server: current only one IOREQ page is used, which limits the maximum number of vcpus to 128.
2. libacpi: no x2apic entry is built in MADT and SRAT
3. Size of pre-allocated shadow memory
4. The way how we boot up APs.

This series is RFC for
1. I am not sure whether changes in patch 2 are acceptable.
2. It depends on our VIOMMU patches which are still under review.

Change since v3:
- Respond Wei and Roger's comments.
- Support multiple IOREQ pages. Seeing patch 1 and 2.
- boot APs through broadcast. Seeing patch 4.
- unify the computation of lapic_id.
- Add x2apic entry in SRAT.
- Increase shadow memory according to the maximum vcpus of HVM.

Change since v2:
1) Increase page pool size during setting max vcpu
2) Allocate madt table size according APIC id of each vcpus
3) Fix some code style issues.

Change since v1:
1) Increase hap page pool according vcpu number
2) Use "Processor" syntax to define vcpus with APIC id < 255
in dsdt and use "Device" syntax for other vcpus in ACPI DSDT table.
3) Use XAPIC structure for vcpus with APIC id < 255
in dsdt and use x2APIC structure for other vcpus in the ACPI MADT table.

This patchset is to extend some resources(i.e, event channel, hap and so) to support more vcpus for single VM.

Chao Gao (6):
ioreq: remove most 'buf' parameter from static functions
ioreq: bump the number of IOREQ page to 4 pages xl/acpi: unify the computation of lapic_id
hvmloader: boot cpu through broadcast
x86/hvm: bump the number of pages of shadow memory x86/hvm: bump the maximum number of vcpus to 512

Lan Tianyu (2):
Tool/ACPI: DSDT extension to support more vcpus
hvmload: Add x2apic entry support in the MADT and SRAT build

 tools/firmware/hvmloader/apic_regs.h    |   4 +
 tools/firmware/hvmloader/config.h       |   3 +-
 tools/firmware/hvmloader/smp.c          |  64 ++++++++++++--
 tools/libacpi/acpi2_0.h                 |  25 +++++-
 tools/libacpi/build.c                   |  57 +++++++++---
 tools/libacpi/libacpi.h                 |   9 ++
 tools/libacpi/mk_dsdt.c                 |  40 +++++++--
 tools/libxc/include/xc_dom.h            |   2 +-
 tools/libxc/xc_dom_x86.c                |   6 +-
 tools/libxl/libxl_x86_acpi.c            |   2 +-
 xen/arch/x86/hvm/hvm.c                  |   1 +
 xen/arch/x86/hvm/ioreq.c                | 150 ++++++++++++++++++++++----------
 xen/arch/x86/mm/hap/hap.c               |   2 +-
 xen/arch/x86/mm/shadow/common.c         |   2 +-
 xen/include/asm-x86/hvm/domain.h        |   6 +-
 xen/include/public/hvm/hvm_info_table.h |   2 +-
 xen/include/public/hvm/ioreq.h          |   2 +
 xen/include/public/hvm/params.h         |   8 +-
 18 files changed, 303 insertions(+), 82 deletions(-)
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
author
#1 lore raw

RFC PATCH v4 1/8 ioreq: remove most 'buf' parameter from static functions

It is a preparation to support multiple IOREQ pages. No functional change.

---
v4:
-new

---
 xen/arch/x86/hvm/ioreq.c | 48 +++++++++++++++++++++++-------------------------
 1 file changed, 23 insertions(+), 25 deletions(-)
xen/arch/x86/hvm/ioreq.c +23 -25
index d991ac9..a879f20 100644
@@ -237,10 +237,9 @@ static void hvm_free_ioreq_gfn(struct hvm_ioreq_server *s, gfn_t gfn)
     set_bit(i, &d->arch.hvm_domain.ioreq_gfn.mask);
 }
 
-static void hvm_unmap_ioreq_gfn(struct hvm_ioreq_server *s, bool buf)
+static void hvm_unmap_ioreq_gfn(struct hvm_ioreq_server *s,
+                                struct hvm_ioreq_page *iorp)
 {
-    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
-
     if ( gfn_eq(iorp->gfn, INVALID_GFN) )
         return;
 
@@ -289,15 +288,15 @@ static int hvm_map_ioreq_gfn(struct hvm_ioreq_server *s, bool buf)
                                  &iorp->va);
 
     if ( rc )
-        hvm_unmap_ioreq_gfn(s, buf);
+        hvm_unmap_ioreq_gfn(s, iorp);
 
     return rc;
 }
 
-static int hvm_alloc_ioreq_mfn(struct hvm_ioreq_server *s, bool buf)
+static int hvm_alloc_ioreq_mfn(struct hvm_ioreq_server *s,
+                               struct hvm_ioreq_page *iorp)
 {
     struct domain *currd = current->domain;
-    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
 
     if ( iorp->page )
     {
@@ -344,10 +343,9 @@ static int hvm_alloc_ioreq_mfn(struct hvm_ioreq_server *s, bool buf)
     return 0;
 }
 
-static void hvm_free_ioreq_mfn(struct hvm_ioreq_server *s, bool buf)
+static void hvm_free_ioreq_mfn(struct hvm_ioreq_server *s,
+                               struct hvm_ioreq_page *iorp)
 {
-    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
-
     if ( !iorp->page )
         return;
 
@@ -380,11 +378,11 @@ bool is_ioreq_server_page(struct domain *d, const struct page_info *page)
     return found;
 }
 
-static void hvm_remove_ioreq_gfn(struct hvm_ioreq_server *s, bool buf)
+static void hvm_remove_ioreq_gfn(struct hvm_ioreq_server *s,
+                                 struct hvm_ioreq_page *iorp)
 
 {
     struct domain *d = s->domain;
-    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
 
     if ( IS_DEFAULT(s) || gfn_eq(iorp->gfn, INVALID_GFN) )
         return;
@@ -395,10 +393,10 @@ static void hvm_remove_ioreq_gfn(struct hvm_ioreq_server *s, bool buf)
     clear_page(iorp->va);
 }
 
-static int hvm_add_ioreq_gfn(struct hvm_ioreq_server *s, bool buf)
+static int hvm_add_ioreq_gfn(struct hvm_ioreq_server *s,
+                             struct hvm_ioreq_page *iorp)
 {
     struct domain *d = s->domain;
-    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
     int rc;
 
     if ( IS_DEFAULT(s) || gfn_eq(iorp->gfn, INVALID_GFN) )
@@ -550,36 +548,36 @@ static int hvm_ioreq_server_map_pages(struct hvm_ioreq_server *s)
         rc = hvm_map_ioreq_gfn(s, true);
 
     if ( rc )
-        hvm_unmap_ioreq_gfn(s, false);
+        hvm_unmap_ioreq_gfn(s, &s->ioreq);
 
     return rc;
 }
 
 static void hvm_ioreq_server_unmap_pages(struct hvm_ioreq_server *s)
 {
-    hvm_unmap_ioreq_gfn(s, true);
-    hvm_unmap_ioreq_gfn(s, false);
+    hvm_unmap_ioreq_gfn(s, &s->ioreq);
+    hvm_unmap_ioreq_gfn(s, &s->bufioreq);
 }
 
 static int hvm_ioreq_server_alloc_pages(struct hvm_ioreq_server *s)
 {
     int rc;
 
-    rc = hvm_alloc_ioreq_mfn(s, false);
+    rc = hvm_alloc_ioreq_mfn(s, &s->ioreq);
 
     if ( !rc && (s->bufioreq_handling != HVM_IOREQSRV_BUFIOREQ_OFF) )
-        rc = hvm_alloc_ioreq_mfn(s, true);
+        rc = hvm_alloc_ioreq_mfn(s, &s->bufioreq);
 
     if ( rc )
-        hvm_free_ioreq_mfn(s, false);
+        hvm_free_ioreq_mfn(s, &s->ioreq);
 
     return rc;
 }
 
 static void hvm_ioreq_server_free_pages(struct hvm_ioreq_server *s)
 {
-    hvm_free_ioreq_mfn(s, true);
-    hvm_free_ioreq_mfn(s, false);
+    hvm_free_ioreq_mfn(s, &s->bufioreq);
+    hvm_free_ioreq_mfn(s, &s->ioreq);
 }
 
 static void hvm_ioreq_server_free_rangesets(struct hvm_ioreq_server *s)
@@ -646,8 +644,8 @@ static void hvm_ioreq_server_enable(struct hvm_ioreq_server *s)
     if ( s->enabled )
         goto done;
 
-    hvm_remove_ioreq_gfn(s, false);
-    hvm_remove_ioreq_gfn(s, true);
+    hvm_remove_ioreq_gfn(s, &s->ioreq);
+    hvm_remove_ioreq_gfn(s, &s->bufioreq);
 
     s->enabled = true;
 
@@ -667,8 +665,8 @@ static void hvm_ioreq_server_disable(struct hvm_ioreq_server *s)
     if ( !s->enabled )
         goto done;
 
-    hvm_add_ioreq_gfn(s, true);
-    hvm_add_ioreq_gfn(s, false);
+    hvm_add_ioreq_gfn(s, &s->bufioreq);
+    hvm_add_ioreq_gfn(s, &s->ioreq);
 
     s->enabled = false;
 
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#2 lore raw

Re: [RFC Patch v4 1/8] ioreq: remove most 'buf' parameter from static functions

Quoted 27 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 06 December 2017 07:50
To: [email protected]
Cc: Chao Gao <[email protected]>; Andrew Cooper <[email protected]>; Jan Beulich <[email protected]>; Paul Durrant <[email protected]>
Subject: [RFC Patch v4 1/8] ioreq: remove most 'buf' parameter from static functions

It is a preparation to support multiple IOREQ pages. No functional change.

---
v4:
-new

---
 xen/arch/x86/hvm/ioreq.c | 48 +++++++++++++++++++++++------------------
-------
 1 file changed, 23 insertions(+), 25 deletions(-)
xen/arch/x86/hvm/ioreq.c +0 -0
index d991ac9..a879f20 100644

xen/arch/x86/hvm/ioreq.c static void hvm_free_ioreq_gfn(struct · line 244

Quoted 10 lines
xen/arch/x86/hvm/ioreq.c +2 -3
@@ -237,10 +237,9 @@ static void hvm_free_ioreq_gfn(struct
 hvm_ioreq_server *s, gfn_t gfn)
     set_bit(i, &d->arch.hvm_domain.ioreq_gfn.mask);
 }
 
-static void hvm_unmap_ioreq_gfn(struct hvm_ioreq_server *s, bool buf)
+static void hvm_unmap_ioreq_gfn(struct hvm_ioreq_server *s,
+                                struct hvm_ioreq_page *iorp)
 {
-    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
-

I don't really like this approach. I'd prefer swapping the bool for an unsigned page index, where we follow the convention adopted in hvm_get_ioreq_server_frame() for which macros exist: 0 equating to the bufioreq page, 1+ for the struct-per-cpu pages.

Paul

Quoted 137 lines
xen/arch/x86/hvm/ioreq.c +3 -3
     if ( gfn_eq(iorp->gfn, INVALID_GFN) )
         return;
@@ -289,15 +288,15 @@ static int hvm_map_ioreq_gfn(struct
 hvm_ioreq_server *s, bool buf)
                                  &iorp->va);
 
     if ( rc )
-        hvm_unmap_ioreq_gfn(s, buf);
+        hvm_unmap_ioreq_gfn(s, iorp);
 
     return rc;
 }
 
-static int hvm_alloc_ioreq_mfn(struct hvm_ioreq_server *s, bool buf)
+static int hvm_alloc_ioreq_mfn(struct hvm_ioreq_server *s,
+                               struct hvm_ioreq_page *iorp)
 {
     struct domain *currd = current->domain;
-    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
 
     if ( iorp->page )
     {
xen/arch/x86/hvm/ioreq.c +4 -5
@@ -344,10 +343,9 @@ static int hvm_alloc_ioreq_mfn(struct
 hvm_ioreq_server *s, bool buf)
     return 0;
 }
 
-static void hvm_free_ioreq_mfn(struct hvm_ioreq_server *s, bool buf)
+static void hvm_free_ioreq_mfn(struct hvm_ioreq_server *s,
+                               struct hvm_ioreq_page *iorp)
 {
-    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
-
     if ( !iorp->page )
         return;
@@ -380,11 +378,11 @@ bool is_ioreq_server_page(struct domain *d, const
 struct page_info *page)
     return found;
 }
 
-static void hvm_remove_ioreq_gfn(struct hvm_ioreq_server *s, bool buf)
+static void hvm_remove_ioreq_gfn(struct hvm_ioreq_server *s,
+                                 struct hvm_ioreq_page *iorp)
 
 {
     struct domain *d = s->domain;
-    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
 
     if ( IS_DEFAULT(s) || gfn_eq(iorp->gfn, INVALID_GFN) )
         return;
xen/arch/x86/hvm/ioreq.c +2 -2
@@ -395,10 +393,10 @@ static void hvm_remove_ioreq_gfn(struct
 hvm_ioreq_server *s, bool buf)
     clear_page(iorp->va);
 }
 
-static int hvm_add_ioreq_gfn(struct hvm_ioreq_server *s, bool buf)
+static int hvm_add_ioreq_gfn(struct hvm_ioreq_server *s,
+                             struct hvm_ioreq_page *iorp)
 {
     struct domain *d = s->domain;
-    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
     int rc;
 
     if ( IS_DEFAULT(s) || gfn_eq(iorp->gfn, INVALID_GFN) )
xen/arch/x86/hvm/ioreq.c +8 -8
@@ -550,36 +548,36 @@ static int hvm_ioreq_server_map_pages(struct
 hvm_ioreq_server *s)
         rc = hvm_map_ioreq_gfn(s, true);
 
     if ( rc )
-        hvm_unmap_ioreq_gfn(s, false);
+        hvm_unmap_ioreq_gfn(s, &s->ioreq);
 
     return rc;
 }
 
 static void hvm_ioreq_server_unmap_pages(struct hvm_ioreq_server *s)
 {
-    hvm_unmap_ioreq_gfn(s, true);
-    hvm_unmap_ioreq_gfn(s, false);
+    hvm_unmap_ioreq_gfn(s, &s->ioreq);
+    hvm_unmap_ioreq_gfn(s, &s->bufioreq);
 }
 
 static int hvm_ioreq_server_alloc_pages(struct hvm_ioreq_server *s)
 {
     int rc;
 
-    rc = hvm_alloc_ioreq_mfn(s, false);
+    rc = hvm_alloc_ioreq_mfn(s, &s->ioreq);
 
     if ( !rc && (s->bufioreq_handling != HVM_IOREQSRV_BUFIOREQ_OFF) )
-        rc = hvm_alloc_ioreq_mfn(s, true);
+        rc = hvm_alloc_ioreq_mfn(s, &s->bufioreq);
 
     if ( rc )
-        hvm_free_ioreq_mfn(s, false);
+        hvm_free_ioreq_mfn(s, &s->ioreq);
 
     return rc;
 }
 
 static void hvm_ioreq_server_free_pages(struct hvm_ioreq_server *s)
 {
-    hvm_free_ioreq_mfn(s, true);
-    hvm_free_ioreq_mfn(s, false);
+    hvm_free_ioreq_mfn(s, &s->bufioreq);
+    hvm_free_ioreq_mfn(s, &s->ioreq);
 }
 

static void hvm_ioreq_server_free_rangesets(struct hvm_ioreq_server *s)

xen/arch/x86/hvm/ioreq.c +4 -5
@@ -646,8 +644,8 @@ static void hvm_ioreq_server_enable(struct
 hvm_ioreq_server *s)
     if ( s->enabled )
         goto done;
 
-    hvm_remove_ioreq_gfn(s, false);
-    hvm_remove_ioreq_gfn(s, true);
+    hvm_remove_ioreq_gfn(s, &s->ioreq);
+    hvm_remove_ioreq_gfn(s, &s->bufioreq);
 
     s->enabled = true;
@@ -667,8 +665,8 @@ static void hvm_ioreq_server_disable(struct
 hvm_ioreq_server *s)
     if ( !s->enabled )
         goto done;
 
-    hvm_add_ioreq_gfn(s, true);
-    hvm_add_ioreq_gfn(s, false);
+    hvm_add_ioreq_gfn(s, &s->bufioreq);
+    hvm_add_ioreq_gfn(s, &s->ioreq);
 
     s->enabled = false;
 
--
Quoted 1 line

1.8.3.1

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#3 lore raw

Re: [RFC Patch v4 1/8] ioreq: remove most 'buf' parameter from static functions

Quoted 31 lines · Paul Durrant
Quoted 31 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 06 December 2017 07:50
To: [email protected]
Cc: Chao Gao <[email protected]>; Andrew Cooper <[email protected]>; Jan Beulich <[email protected]>; Paul Durrant <[email protected]>
Subject: [RFC Patch v4 1/8] ioreq: remove most 'buf' parameter from static functions

It is a preparation to support multiple IOREQ pages. No functional change.

---
v4:
-new

---
 xen/arch/x86/hvm/ioreq.c | 48 +++++++++++++++++++++++------------------
-------
 1 file changed, 23 insertions(+), 25 deletions(-)
xen/arch/x86/hvm/ioreq.c +0 -0
index d991ac9..a879f20 100644
@@ -237,10 +237,9 @@ static void hvm_free_ioreq_gfn(struct
 hvm_ioreq_server *s, gfn_t gfn)
     set_bit(i, &d->arch.hvm_domain.ioreq_gfn.mask);
 }
 
Quoted 8 lines

xen/arch/x86/hvm/ioreq.c static void hvm_free_ioreq_gfn(struct hvm_ioreq_server *s, gfn_t gfn) · line 243

Quoted 6 lines
xen/arch/x86/hvm/ioreq.c +2 -3
-static void hvm_unmap_ioreq_gfn(struct hvm_ioreq_server *s, bool buf)
+static void hvm_unmap_ioreq_gfn(struct hvm_ioreq_server *s,
+                                struct hvm_ioreq_page *iorp)
 {
-    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
-

I don't really like this approach. I'd prefer swapping the bool for an unsigned page index, where we follow the convention adopted in hvm_get_ioreq_server_frame() for which macros exist: 0 equating to the bufioreq page, 1+ for the struct-per-cpu pages.

Ok. I have no preference for these two. But I will take your advice.

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#4 lore raw

RFC PATCH v4 2/8 ioreq: bump the number of IOREQ page to 4 pages

In reply to Chao Gao

One 4K-byte page at most contains 128 'ioreq_t'. In order to remove the vcpu number constraint imposed by one IOREQ page, bump the number of IOREQ page to 4 pages. With this patch, multiple pages can be used as IOREQ page.

Basically, this patch extends 'ioreq' field in struct hvm_ioreq_server to an array. All accesses to 'ioreq' field such as 's->ioreq' are replaced with FOR_EACH_IOREQ_PAGE macro.

In order to access an IOREQ page, QEMU should get the gmfn and map this gmfn to its virtual address space. Now there are several pages, to be compatible with previous QEMU, the interface to get the gmfn doesn't change. But newer QEMU needs to get the gmfn repeatly until a same gmfn is found. To implement this, an internal index is introduced: when QEMU queries the gmfn, the gmfn of IOREQ page referenced by the index is returned. After each operation, the index increases by 1 and rewinds when it overflows.

---
v4:
- new

---
 tools/libxc/include/xc_dom.h     |   2 +-
 tools/libxc/xc_dom_x86.c         |   6 +-
 xen/arch/x86/hvm/hvm.c           |   1 +
 xen/arch/x86/hvm/ioreq.c         | 116 ++++++++++++++++++++++++++++++---------
 xen/include/asm-x86/hvm/domain.h |   6 +-
 xen/include/public/hvm/ioreq.h   |   2 +
 xen/include/public/hvm/params.h  |   8 ++-
 7 files changed, 110 insertions(+), 31 deletions(-)
tools/libxc/include/xc_dom.h +1 -1
index 45c9d67..2f8b412 100644
@@ -20,7 +20,7 @@
 #include <xenguest.h>
 
 #define INVALID_PFN ((xen_pfn_t)-1)
-#define X86_HVM_NR_SPECIAL_PAGES    8
+#define X86_HVM_NR_SPECIAL_PAGES    11
 #define X86_HVM_END_SPECIAL_REGION  0xff000u
 
 /* --- typedefs and structs ---------------------------------------- */
tools/libxc/xc_dom_x86.c +4 -2
index bff68a0..b316ebc 100644
@@ -32,6 +32,7 @@
 #include <xen/foreign/x86_32.h>
 #include <xen/foreign/x86_64.h>
 #include <xen/hvm/hvm_info_table.h>
+#include <xen/hvm/ioreq.h>
 #include <xen/arch-x86/hvm/start_info.h>
 #include <xen/io/protocols.h>
 
@@ -57,8 +58,8 @@
 #define SPECIALPAGE_BUFIOREQ 3
 #define SPECIALPAGE_XENSTORE 4
 #define SPECIALPAGE_IOREQ    5
-#define SPECIALPAGE_IDENT_PT 6
-#define SPECIALPAGE_CONSOLE  7
+#define SPECIALPAGE_IDENT_PT (5 + MAX_IOREQ_PAGE)
+#define SPECIALPAGE_CONSOLE  (SPECIALPAGE_IDENT_PT + 1)
 #define special_pfn(x) \
     (X86_HVM_END_SPECIAL_REGION - X86_HVM_NR_SPECIAL_PAGES + (x))
 
@@ -612,6 +613,7 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
                                X86_HVM_NR_SPECIAL_PAGES) )
             goto error_out;
 
+    xc_hvm_param_set(xch, domid, HVM_PARAM_IOREQ_PAGES, MAX_IOREQ_PAGE);
     xc_hvm_param_set(xch, domid, HVM_PARAM_STORE_PFN,
                      special_pfn(SPECIALPAGE_XENSTORE));
     xc_hvm_param_set(xch, domid, HVM_PARAM_BUFIOREQ_PFN,
xen/arch/x86/hvm/hvm.c +1 -0
index 5d06767..0b3bd04 100644
@@ -4077,6 +4077,7 @@ static int hvm_allow_set_param(struct domain *d,
     case HVM_PARAM_NR_IOREQ_SERVER_PAGES:
     case HVM_PARAM_ALTP2M:
     case HVM_PARAM_MCA_CAP:
+    case HVM_PARAM_IOREQ_PAGES:
         if ( value != 0 && a->value != value )
             rc = -EEXIST;
         break;
xen/arch/x86/hvm/ioreq.c +90 -26

241 lines not on this page · raw message

xen/include/asm-x86/hvm/domain.h +5 -1
index 87f7994..ff8c44d 100644
@@ -51,6 +51,7 @@ struct hvm_ioreq_vcpu {
 
 #define NR_IO_RANGE_TYPES (XEN_DMOP_IO_RANGE_PCI + 1)
 #define MAX_NR_IO_RANGES  256
+#define IOREQ_NUM_PER_PAGE (PAGE_SIZE / sizeof(ioreq_t))
 
 struct hvm_ioreq_server {
     struct list_head       list_entry;
@@ -61,7 +62,10 @@ struct hvm_ioreq_server {
 
     /* Domain id of emulating domain */
     domid_t                domid;
-    struct hvm_ioreq_page  ioreq;
+    /* Index and size of ioreq page array */
+    uint8_t                ioreq_idx;
+    uint8_t                ioreq_page_nr;
+    struct hvm_ioreq_page  ioreq[MAX_IOREQ_PAGE];
     struct list_head       ioreq_vcpu_list;
     struct hvm_ioreq_page  bufioreq;
 
xen/include/public/hvm/ioreq.h +2 -0
index d309d12..d628303 100644
@@ -71,6 +71,8 @@ struct shared_iopage {
 };
 typedef struct shared_iopage shared_iopage_t;
 
+#define MAX_IOREQ_PAGE 4
+
 struct buf_ioreq {
     uint8_t  type;   /* I/O type                    */
     uint8_t  pad:1;
xen/include/public/hvm/params.h +7 -1
index 2ec2e7c..537799d 100644
@@ -279,6 +279,12 @@
 #define XEN_HVM_MCA_CAP_LMCE   (xen_mk_ullong(1) << 0)
 #define XEN_HVM_MCA_CAP_MASK   XEN_HVM_MCA_CAP_LMCE
 
-#define HVM_NR_PARAMS 39
+/*
+ * Number of pages that are reserved for default IOREQ server. The base PFN
+ * is set via HVM_PARAM_IOREQ_PFN.
+ */
+#define HVM_PARAM_IOREQ_PAGES 39
+
+#define HVM_NR_PARAMS 40
 
 #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#5 lore raw

Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 19 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 06 December 2017 07:50
To: [email protected]
Cc: Chao Gao <[email protected]>; Paul Durrant <[email protected]>; Tim (Xen.org) <[email protected]>; Stefano Stabellini <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Jan Beulich <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; Ian Jackson <[email protected]>
Subject: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

One 4K-byte page at most contains 128 'ioreq_t'. In order to remove the vcpu number constraint imposed by one IOREQ page, bump the number of IOREQ page to
4 pages. With this patch, multiple pages can be used as IOREQ page.

Quoted 7 lines

Basically, this patch extends 'ioreq' field in struct hvm_ioreq_server to an array. All accesses to 'ioreq' field such as 's->ioreq' are replaced with FOR_EACH_IOREQ_PAGE macro.

In order to access an IOREQ page, QEMU should get the gmfn and map this gmfn
to its virtual address space.

No. There's no need to extend the 'legacy' mechanism of using magic page gfns. You should only handle the case where the mfns are allocated on demand (see the call to hvm_ioreq_server_alloc_pages() in hvm_get_ioreq_server_frame()). The number of guest vcpus is known at this point so the correct number of pages can be allocated. If the creator of the ioreq server attempts to use the legacy hvm_get_ioreq_server_info() and the guest has >128 vcpus then the call should fail.

Paul

Quoted 416 lines

Now there are several pages, to be compatible
with previous QEMU, the interface to get the gmfn doesn't change. But newer
QEMU needs to get the gmfn repeatly until a same gmfn is found. To implement
this, an internal index is introduced: when QEMU queries the gmfn, the gmfn of
IOREQ page referenced by the index is returned. After each operation, the index increases by 1 and rewinds when it overflows.

---
v4:
- new

---
 tools/libxc/include/xc_dom.h     |   2 +-
 tools/libxc/xc_dom_x86.c         |   6 +-
 xen/arch/x86/hvm/hvm.c           |   1 +
 xen/arch/x86/hvm/ioreq.c         | 116
++++++++++++++++++++++++++++++---------
 xen/include/asm-x86/hvm/domain.h |   6 +-
 xen/include/public/hvm/ioreq.h   |   2 +
 xen/include/public/hvm/params.h  |   8 ++-
 7 files changed, 110 insertions(+), 31 deletions(-)
tools/libxc/include/xc_dom.h +1 -1
index 45c9d67..2f8b412 100644
@@ -20,7 +20,7 @@
 #include <xenguest.h>
 
 #define INVALID_PFN ((xen_pfn_t)-1)
-#define X86_HVM_NR_SPECIAL_PAGES    8
+#define X86_HVM_NR_SPECIAL_PAGES    11
 #define X86_HVM_END_SPECIAL_REGION  0xff000u
 
 /* --- typedefs and structs ---------------------------------------- */
tools/libxc/xc_dom_x86.c +4 -2
index bff68a0..b316ebc 100644
@@ -32,6 +32,7 @@
 #include <xen/foreign/x86_32.h>
 #include <xen/foreign/x86_64.h>
 #include <xen/hvm/hvm_info_table.h>
+#include <xen/hvm/ioreq.h>
 #include <xen/arch-x86/hvm/start_info.h>
 #include <xen/io/protocols.h>
 
@@ -57,8 +58,8 @@
 #define SPECIALPAGE_BUFIOREQ 3
 #define SPECIALPAGE_XENSTORE 4
 #define SPECIALPAGE_IOREQ    5
-#define SPECIALPAGE_IDENT_PT 6
-#define SPECIALPAGE_CONSOLE  7
+#define SPECIALPAGE_IDENT_PT (5 + MAX_IOREQ_PAGE)
+#define SPECIALPAGE_CONSOLE  (SPECIALPAGE_IDENT_PT + 1)
 #define special_pfn(x) \
     (X86_HVM_END_SPECIAL_REGION - X86_HVM_NR_SPECIAL_PAGES + (x))
 
@@ -612,6 +613,7 @@ static int alloc_magic_pages_hvm(struct
 xc_dom_image *dom)
                                X86_HVM_NR_SPECIAL_PAGES) )
             goto error_out;
 
+    xc_hvm_param_set(xch, domid, HVM_PARAM_IOREQ_PAGES,
 MAX_IOREQ_PAGE);
     xc_hvm_param_set(xch, domid, HVM_PARAM_STORE_PFN,

special_pfn(SPECIALPAGE_XENSTORE));
xc_hvm_param_set(xch, domid, HVM_PARAM_BUFIOREQ_PFN,

xen/arch/x86/hvm/hvm.c +1 -0
index 5d06767..0b3bd04 100644
@@ -4077,6 +4077,7 @@ static int hvm_allow_set_param(struct domain *d,
     case HVM_PARAM_NR_IOREQ_SERVER_PAGES:
     case HVM_PARAM_ALTP2M:
     case HVM_PARAM_MCA_CAP:
+    case HVM_PARAM_IOREQ_PAGES:
         if ( value != 0 && a->value != value )
             rc = -EEXIST;
         break;
xen/arch/x86/hvm/ioreq.c +12 -2
index a879f20..0a36001 100644
@@ -64,14 +64,24 @@ static struct hvm_ioreq_server
 *get_ioreq_server(const struct domain *d,
             continue; \
         else
 
+/* Iterate over all ioreq pages */
+#define FOR_EACH_IOREQ_PAGE(s, i, iorp) \
+    for ( (i) = 0, iorp = s->ioreq; (i) < (s)->ioreq_page_nr; (i)++, iorp++ )
+
 static ioreq_t *get_ioreq(struct hvm_ioreq_server *s, struct vcpu *v)
 {
-    shared_iopage_t *p = s->ioreq.va;
+    shared_iopage_t *p = s->ioreq[v->vcpu_id /
 IOREQ_NUM_PER_PAGE].va;
 
     ASSERT((v == current) || !vcpu_runnable(v));
     ASSERT(p != NULL);
 
-    return &p->vcpu_ioreq[v->vcpu_id];
+    return &p->vcpu_ioreq[v->vcpu_id % IOREQ_NUM_PER_PAGE];
+}
+
+static ioreq_t *get_ioreq_fallible(struct hvm_ioreq_server *s, struct vcpu
 *v)
+{
+    return s->ioreq[v->vcpu_id / IOREQ_NUM_PER_PAGE].va ?
+           get_ioreq(s, v) : NULL;

}

bool hvm_io_pending(struct vcpu *v)

xen/arch/x86/hvm/ioreq.c +2 -2
@@ -252,10 +262,10 @@ static void hvm_unmap_ioreq_gfn(struct
 hvm_ioreq_server *s,
     iorp->gfn = INVALID_GFN;
 }
 
-static int hvm_map_ioreq_gfn(struct hvm_ioreq_server *s, bool buf)
+static int hvm_map_ioreq_gfn(struct hvm_ioreq_server *s, bool buf,
 uint8_t i)
 {
     struct domain *d = s->domain;
-    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
+    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq[i];
     int rc;
     if ( iorp->page )
xen/arch/x86/hvm/ioreq.c +17 -2
@@ -277,7 +287,7 @@ static int hvm_map_ioreq_gfn(struct
 hvm_ioreq_server *s, bool buf)
     if ( IS_DEFAULT(s) )
         iorp->gfn = _gfn(buf ?
                          d->arch.hvm_domain.params[HVM_PARAM_BUFIOREQ_PFN] :
-                         d->arch.hvm_domain.params[HVM_PARAM_IOREQ_PFN]);
+                         d->arch.hvm_domain.params[HVM_PARAM_IOREQ_PFN] + i);
     else
         iorp->gfn = hvm_alloc_ioreq_gfn(s);
@@ -366,7 +376,22 @@ bool is_ioreq_server_page(struct domain *d, const
 struct page_info *page)
 
     FOR_EACH_IOREQ_SERVER(d, id, s)
     {
-        if ( (s->ioreq.page == page) || (s->bufioreq.page == page) )
+        int i;
+        const struct hvm_ioreq_page *iorp;
+
+        FOR_EACH_IOREQ_PAGE(s, i, iorp)
+        {
+            if ( iorp->page == page )
+            {
+                found = true;
+                break;
+            }
+        }
+
+        if ( found )
+            break;
+
+        if ( s->bufioreq.page == page )
         {
             found = true;
             break;
xen/arch/x86/hvm/ioreq.c +3 -5
@@ -415,14 +440,12 @@ static int hvm_add_ioreq_gfn(struct
 hvm_ioreq_server *s,
 static void hvm_update_ioreq_evtchn(struct hvm_ioreq_server *s,
                                     struct hvm_ioreq_vcpu *sv)
 {
-    ASSERT(spin_is_locked(&s->lock));
+    ioreq_t *p = get_ioreq_fallible(s, sv->vcpu);
 
-    if ( s->ioreq.va != NULL )
-    {
-        ioreq_t *p = get_ioreq(s, sv->vcpu);
+    ASSERT(spin_is_locked(&s->lock));
 
+    if ( p )
         p->vp_eport = sv->ioreq_evtchn;
-    }
 }
 

#define HANDLE_BUFIOREQ(s) \

xen/arch/x86/hvm/ioreq.c +31 -9
@@ -540,44 +563,66 @@ static void
 hvm_ioreq_server_remove_all_vcpus(struct hvm_ioreq_server *s)
 
 static int hvm_ioreq_server_map_pages(struct hvm_ioreq_server *s)
 {
-    int rc;
+    int i, rc = -EINVAL;
+    struct hvm_ioreq_page *iorp;
 
-    rc = hvm_map_ioreq_gfn(s, false);
+    for ( i = 0; i < s->ioreq_page_nr; i++ )
+    {
+        rc = hvm_map_ioreq_gfn(s, false, i);
+        if ( rc )
+            break;
+    }
 
     if ( !rc && HANDLE_BUFIOREQ(s) )
-        rc = hvm_map_ioreq_gfn(s, true);
+        rc = hvm_map_ioreq_gfn(s, true, 0);
 
     if ( rc )
-        hvm_unmap_ioreq_gfn(s, &s->ioreq);
+        FOR_EACH_IOREQ_PAGE(s, i, iorp)
+            hvm_unmap_ioreq_gfn(s, iorp);
 
     return rc;
 }
 
 static void hvm_ioreq_server_unmap_pages(struct hvm_ioreq_server *s)
 {
-    hvm_unmap_ioreq_gfn(s, &s->ioreq);
+    int i;
+    struct hvm_ioreq_page *iorp;
+
+    FOR_EACH_IOREQ_PAGE(s, i, iorp)
+        hvm_unmap_ioreq_gfn(s, iorp);
     hvm_unmap_ioreq_gfn(s, &s->bufioreq);
 }
 
 static int hvm_ioreq_server_alloc_pages(struct hvm_ioreq_server *s)
 {
-    int rc;
+    int i, rc = -EINVAL;
+    struct hvm_ioreq_page *iorp;
 
-    rc = hvm_alloc_ioreq_mfn(s, &s->ioreq);
+    FOR_EACH_IOREQ_PAGE(s, i, iorp)
+    {
+        rc = hvm_alloc_ioreq_mfn(s, iorp);
+        if ( rc )
+            break;
+    }
 
     if ( !rc && (s->bufioreq_handling != HVM_IOREQSRV_BUFIOREQ_OFF) )
         rc = hvm_alloc_ioreq_mfn(s, &s->bufioreq);
 
     if ( rc )
-        hvm_free_ioreq_mfn(s, &s->ioreq);
+        FOR_EACH_IOREQ_PAGE(s, i, iorp)
+            hvm_free_ioreq_mfn(s, iorp);
 
     return rc;
 }
 
 static void hvm_ioreq_server_free_pages(struct hvm_ioreq_server *s)
 {
+    int i;
+    struct hvm_ioreq_page *iorp;
+
     hvm_free_ioreq_mfn(s, &s->bufioreq);
-    hvm_free_ioreq_mfn(s, &s->ioreq);
+    FOR_EACH_IOREQ_PAGE(s, i, iorp)
+        hvm_free_ioreq_mfn(s, iorp);
 }
 

static void hvm_ioreq_server_free_rangesets(struct hvm_ioreq_server *s)

xen/arch/x86/hvm/ioreq.c +4 -1
@@ -638,13 +683,16 @@ static int hvm_ioreq_server_alloc_rangesets(struct
 hvm_ioreq_server *s,
 static void hvm_ioreq_server_enable(struct hvm_ioreq_server *s)
 {
     struct hvm_ioreq_vcpu *sv;
+    struct hvm_ioreq_page *iorp;
+    int i;
 
     spin_lock(&s->lock);
 
     if ( s->enabled )
         goto done;
 
-    hvm_remove_ioreq_gfn(s, &s->ioreq);
+    FOR_EACH_IOREQ_PAGE(s, i, iorp)
+        hvm_remove_ioreq_gfn(s, iorp);
     hvm_remove_ioreq_gfn(s, &s->bufioreq);
 
     s->enabled = true;
xen/arch/x86/hvm/ioreq.c +7 -2
@@ -660,13 +708,17 @@ static void hvm_ioreq_server_enable(struct
 hvm_ioreq_server *s)
 
 static void hvm_ioreq_server_disable(struct hvm_ioreq_server *s)
 {
+    struct hvm_ioreq_page *iorp;
+    int i;
+
     spin_lock(&s->lock);
 
     if ( !s->enabled )
         goto done;
 
     hvm_add_ioreq_gfn(s, &s->bufioreq);
-    hvm_add_ioreq_gfn(s, &s->ioreq);
+    FOR_EACH_IOREQ_PAGE(s, i, iorp)
+        hvm_add_ioreq_gfn(s, iorp);
 
     s->enabled = false;
@@ -679,7 +731,8 @@ static int hvm_ioreq_server_init(struct
 hvm_ioreq_server *s,
                                  int bufioreq_handling, ioservid_t id)
 {
     struct vcpu *v;
-    int rc;
+    int rc, i;
+    struct hvm_ioreq_page *iorp;
 
     s->domain = d;
     s->domid = domid;
xen/arch/x86/hvm/ioreq.c +8 -1
@@ -688,8 +741,15 @@ static int hvm_ioreq_server_init(struct
 hvm_ioreq_server *s,
     INIT_LIST_HEAD(&s->ioreq_vcpu_list);
     spin_lock_init(&s->bufioreq_lock);
 
-    s->ioreq.gfn = INVALID_GFN;
+    FOR_EACH_IOREQ_PAGE(s, i, iorp)
+        iorp->gfn = INVALID_GFN;
     s->bufioreq.gfn = INVALID_GFN;
+    s->ioreq_page_nr = (d->max_vcpus + IOREQ_NUM_PER_PAGE - 1) /
+                       IOREQ_NUM_PER_PAGE;
+    if ( s->ioreq_page_nr > d-
 >arch.hvm_domain.params[HVM_PARAM_IOREQ_PAGES] )
+        return -EINVAL;
+
+    s->ioreq_idx = 0;
 

rc = hvm_ioreq_server_alloc_rangesets(s, id); if ( rc )

xen/arch/x86/hvm/ioreq.c +4 -1
@@ -866,7 +926,10 @@ int hvm_get_ioreq_server_info(struct domain *d,
 ioservid_t id,
     }
 
     if ( ioreq_gfn )
-        *ioreq_gfn = gfn_x(s->ioreq.gfn);
+    {
+        *ioreq_gfn = gfn_x(s->ioreq[s->ioreq_idx].gfn);
+        s->ioreq_idx = (s->ioreq_idx + 1) % s->ioreq_page_nr;
+    }
 
     if ( HANDLE_BUFIOREQ(s) )
     {
xen/arch/x86/hvm/ioreq.c +2 -1
@@ -916,7 +979,8 @@ int hvm_get_ioreq_server_frame(struct domain *d,
 ioservid_t id,
         break;
 
     case XENMEM_resource_ioreq_server_frame_ioreq(0):
-        *mfn = _mfn(page_to_mfn(s->ioreq.page));
+        *mfn = _mfn(page_to_mfn(s->ioreq[s->ioreq_idx].page));
+        s->ioreq_idx = (s->ioreq_idx + 1) % s->ioreq_page_nr;
         rc = 0;
         break;
xen/include/asm- renamed from xen/include/asm-x86/hvm/domain.h +0 -0

x86/hvm/domain.h
index 87f7994..ff8c44d 100644

xen/include/asm-x86/hvm/domain.h +5 -1
@@ -51,6 +51,7 @@ struct hvm_ioreq_vcpu {
 
 #define NR_IO_RANGE_TYPES (XEN_DMOP_IO_RANGE_PCI + 1)
 #define MAX_NR_IO_RANGES  256
+#define IOREQ_NUM_PER_PAGE (PAGE_SIZE / sizeof(ioreq_t))
 
 struct hvm_ioreq_server {
     struct list_head       list_entry;
@@ -61,7 +62,10 @@ struct hvm_ioreq_server {
 
     /* Domain id of emulating domain */
     domid_t                domid;
-    struct hvm_ioreq_page  ioreq;
+    /* Index and size of ioreq page array */
+    uint8_t                ioreq_idx;
+    uint8_t                ioreq_page_nr;
+    struct hvm_ioreq_page  ioreq[MAX_IOREQ_PAGE];
     struct list_head       ioreq_vcpu_list;
     struct hvm_ioreq_page  bufioreq;
 
xen/include/public/hvm/ioreq.h +2 -0
index d309d12..d628303 100644
@@ -71,6 +71,8 @@ struct shared_iopage {
 };
 typedef struct shared_iopage shared_iopage_t;
 
+#define MAX_IOREQ_PAGE 4
+
 struct buf_ioreq {
     uint8_t  type;   /* I/O type                    */
     uint8_t  pad:1;
xen/include/public/hvm/params.h +2 -1
index 2ec2e7c..537799d 100644
@@ -279,6 +279,12 @@
 #define XEN_HVM_MCA_CAP_LMCE   (xen_mk_ullong(1) << 0)
 #define XEN_HVM_MCA_CAP_MASK   XEN_HVM_MCA_CAP_LMCE
 
-#define HVM_NR_PARAMS 39
+/*
+ * Number of pages that are reserved for default IOREQ server. The base

PFN
+ * is set via HVM_PARAM_IOREQ_PFN.
+ */

xen/include/public/hvm/params.h +3 -1
+#define HVM_PARAM_IOREQ_PAGES 39
+
+#define HVM_NR_PARAMS 40
 
 #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */
--
Quoted 1 line

1.8.3.1

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#6 lore raw

Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 23 lines · Paul Durrant
Quoted 23 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 06 December 2017 07:50
To: [email protected]
Cc: Chao Gao <[email protected]>; Paul Durrant <[email protected]>; Tim (Xen.org) <[email protected]>; Stefano Stabellini <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Jan Beulich <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; Ian Jackson <[email protected]>
Subject: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

One 4K-byte page at most contains 128 'ioreq_t'. In order to remove the vcpu number constraint imposed by one IOREQ page, bump the number of IOREQ page to
4 pages. With this patch, multiple pages can be used as IOREQ page.

Basically, this patch extends 'ioreq' field in struct hvm_ioreq_server to an array. All accesses to 'ioreq' field such as 's->ioreq' are replaced with FOR_EACH_IOREQ_PAGE macro.

Quoted 5 lines
Quoted 3 lines

In order to access an IOREQ page, QEMU should get the gmfn and map this gmfn
to its virtual address space.

No. There's no need to extend the 'legacy' mechanism of using magic page gfns. You should only handle the case where the mfns are allocated on demand (see the call to hvm_ioreq_server_alloc_pages() in hvm_get_ioreq_server_frame()). The number of guest vcpus is known at this point so the correct number of pages can be allocated. If the creator of the ioreq server attempts to use the legacy hvm_get_ioreq_server_info() and the guest has >128 vcpus then the call should fail.

Great suggestion. I will introduce a new dmop, a variant of hvm_get_ioreq_server_frame() for creator to get an array of gfns and the size of array. And the legacy interface will report an error if more than one IOREQ PAGES are needed.

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#7 lore raw

Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 54 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 06 December 2017 09:02
To: Paul Durrant <[email protected]>
Cc: [email protected]; Tim (Xen.org) <[email protected]>; Stefano Stabellini <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Jan Beulich <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; Ian Jackson <[email protected]>
Subject: Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 6 lines · Paul Durrant
Quoted 6 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 06 December 2017 07:50
To: [email protected]
Cc: Chao Gao <[email protected]>; Paul Durrant <[email protected]>; Tim (Xen.org) <[email protected]>; Stefano

Stabellini

Quoted 4 lines
Quoted 4 lines

<[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Jan Beulich <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; Ian

Jackson

Quoted 5 lines
Quoted 5 lines

<[email protected]>
Subject: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

One 4K-byte page at most contains 128 'ioreq_t'. In order to remove the

vcpu

Quoted 1 line
Quoted 1 line

number constraint imposed by one IOREQ page, bump the number of

IOREQ

Quoted 8 lines
Quoted 8 lines

page to
4 pages. With this patch, multiple pages can be used as IOREQ page.

Basically, this patch extends 'ioreq' field in struct hvm_ioreq_server to an array. All accesses to 'ioreq' field such as 's->ioreq' are replaced with FOR_EACH_IOREQ_PAGE macro.

In order to access an IOREQ page, QEMU should get the gmfn and map

this

Quoted 4 lines
Quoted 2 lines

gmfn
to its virtual address space.

No. There's no need to extend the 'legacy' mechanism of using magic page

gfns. You should only handle the case where the mfns are allocated on demand (see the call to hvm_ioreq_server_alloc_pages() in hvm_get_ioreq_server_frame()). The number of guest vcpus is known at this point so the correct number of pages can be allocated. If the creator of the ioreq server attempts to use the legacy hvm_get_ioreq_server_info() and the guest has >128 vcpus then the call should fail.

Quoted 4 lines

Great suggestion. I will introduce a new dmop, a variant of hvm_get_ioreq_server_frame() for creator to get an array of gfns and the size of array. And the legacy interface will report an error if more than one IOREQ PAGES are needed.

You don't need a new dmop for mapping I think. The mem op to map ioreq server frames should work. All you should need to do is update hvm_get_ioreq_server_frame() to deal with an index > 1, and provide some means for the ioreq server creator to convert the number of guest vcpus into the correct number of pages to map. (That might need a new dm op).

Paul

Quoted 3 lines

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#8 lore raw

Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 74 lines

-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Paul Durrant
Sent: 06 December 2017 16:10
To: 'Chao Gao' <[email protected]>
Cc: Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Andrew Cooper <[email protected]>; Tim (Xen.org) <[email protected]>; George Dunlap <[email protected]>; [email protected]; Jan Beulich <[email protected]>; Ian Jackson <[email protected]>
Subject: Re: [Xen-devel] [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 26 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 06 December 2017 09:02
To: Paul Durrant <[email protected]>
Cc: [email protected]; Tim (Xen.org) <[email protected]>; Stefano Stabellini <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Jan Beulich <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; Ian Jackson <[email protected]>
Subject: Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 6 lines · Paul Durrant
Quoted 6 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 06 December 2017 07:50
To: [email protected]
Cc: Chao Gao <[email protected]>; Paul Durrant <[email protected]>; Tim (Xen.org) <[email protected]>; Stefano

Stabellini

Quoted 4 lines
Quoted 4 lines

<[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Jan Beulich <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; Ian

Jackson

Quoted 12 lines
Quoted 5 lines
Quoted 5 lines

<[email protected]>
Subject: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

One 4K-byte page at most contains 128 'ioreq_t'. In order to remove the

vcpu

Quoted 1 line
Quoted 1 line

number constraint imposed by one IOREQ page, bump the number of

IOREQ

Quoted 4 lines
Quoted 4 lines

page to
4 pages. With this patch, multiple pages can be used as IOREQ page.

Basically, this patch extends 'ioreq' field in struct hvm_ioreq_server to

an

Quoted 9 lines
Quoted 4 lines
Quoted 4 lines

array. All accesses to 'ioreq' field such as 's->ioreq' are replaced with FOR_EACH_IOREQ_PAGE macro.

In order to access an IOREQ page, QEMU should get the gmfn and map

this

Quoted 4 lines
Quoted 2 lines

gmfn
to its virtual address space.

No. There's no need to extend the 'legacy' mechanism of using magic

page

Quoted 11 lines

gfns. You should only handle the case where the mfns are allocated on demand (see the call to hvm_ioreq_server_alloc_pages() in hvm_get_ioreq_server_frame()). The number of guest vcpus is known at this point so the correct number of pages can be allocated. If the creator of the ioreq server attempts to use the legacy hvm_get_ioreq_server_info() and the guest has >128 vcpus then the call should fail.

Great suggestion. I will introduce a new dmop, a variant of hvm_get_ioreq_server_frame() for creator to get an array of gfns and the size of array. And the legacy interface will report an error if more than one IOREQ PAGES are needed.

Quoted 5 lines

You don't need a new dmop for mapping I think. The mem op to map ioreq server frames should work. All you should need to do is update hvm_get_ioreq_server_frame() to deal with an index > 1, and provide some means for the ioreq server creator to convert the number of guest vcpus into the correct number of pages to map. (That might need a new dm op).

I realise after saying this that an emulator already knows the size of the ioreq structure and so can easily calculate the correct number of pages to map, given the number of guest vcpus.

Paul

Quoted 11 lines

Paul

Quoted 3 lines

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#9 lore raw

Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 74 lines · Paul Durrant
Quoted 74 lines

-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Paul Durrant
Sent: 06 December 2017 16:10
To: 'Chao Gao' <[email protected]>
Cc: Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Andrew Cooper <[email protected]>; Tim (Xen.org) <[email protected]>; George Dunlap <[email protected]>; [email protected]; Jan Beulich <[email protected]>; Ian Jackson <[email protected]>
Subject: Re: [Xen-devel] [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 26 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 06 December 2017 09:02
To: Paul Durrant <[email protected]>
Cc: [email protected]; Tim (Xen.org) <[email protected]>; Stefano Stabellini <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Jan Beulich <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; Ian Jackson <[email protected]>
Subject: Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 6 lines · Paul Durrant
Quoted 6 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 06 December 2017 07:50
To: [email protected]
Cc: Chao Gao <[email protected]>; Paul Durrant <[email protected]>; Tim (Xen.org) <[email protected]>; Stefano

Stabellini

Quoted 4 lines
Quoted 4 lines

<[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Jan Beulich <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; Ian

Jackson

Quoted 12 lines
Quoted 5 lines
Quoted 5 lines

<[email protected]>
Subject: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

One 4K-byte page at most contains 128 'ioreq_t'. In order to remove the

vcpu

Quoted 1 line
Quoted 1 line

number constraint imposed by one IOREQ page, bump the number of

IOREQ

Quoted 4 lines
Quoted 4 lines

page to
4 pages. With this patch, multiple pages can be used as IOREQ page.

Basically, this patch extends 'ioreq' field in struct hvm_ioreq_server to

an

Quoted 9 lines
Quoted 4 lines
Quoted 4 lines

array. All accesses to 'ioreq' field such as 's->ioreq' are replaced with FOR_EACH_IOREQ_PAGE macro.

In order to access an IOREQ page, QEMU should get the gmfn and map

this

Quoted 4 lines
Quoted 2 lines

gmfn
to its virtual address space.

No. There's no need to extend the 'legacy' mechanism of using magic

page

Quoted 11 lines

gfns. You should only handle the case where the mfns are allocated on demand (see the call to hvm_ioreq_server_alloc_pages() in hvm_get_ioreq_server_frame()). The number of guest vcpus is known at this point so the correct number of pages can be allocated. If the creator of the ioreq server attempts to use the legacy hvm_get_ioreq_server_info() and the guest has >128 vcpus then the call should fail.

Great suggestion. I will introduce a new dmop, a variant of hvm_get_ioreq_server_frame() for creator to get an array of gfns and the size of array. And the legacy interface will report an error if more than one IOREQ PAGES are needed.

Quoted 7 lines
Quoted 5 lines

You don't need a new dmop for mapping I think. The mem op to map ioreq server frames should work. All you should need to do is update hvm_get_ioreq_server_frame() to deal with an index > 1, and provide some means for the ioreq server creator to convert the number of guest vcpus into the correct number of pages to map. (That might need a new dm op).

I realise after saying this that an emulator already knows the size of the ioreq structure and so can easily calculate the correct number of pages to map, given the number of guest vcpus.

How about the patch in the bottom? Is it in the right direction? Do you have the QEMU patch, which replaces the old method with the new method to set up mapping? I want to integrate that patch and do some tests.

Thanks
Chao

From 44919e1e80f36981d6e213f74302c8c89cc9f828 Mon Sep 17 00:00:00 2001
From: Chao Gao <[email protected]>
Date: Tue, 5 Dec 2017 14:20:24 +0800
Subject: [PATCH] ioreq: add support of multiple ioreq pages

Each vcpu should have an corresponding 'ioreq_t' structure in the ioreq page. Currently, only one 4K-byte page is used as ioreq page. Thus it also limits the number of vcpu to 128 if device model is in use.

This patch changes 'ioreq' field to an array. At most, 4 pages can be used. When creating IO server, the actual number of ioreq page is calculated according to the number of vcpus. All ioreq pages are allocated on demand. The creator should provide enough number of gfn to set up the mapping.

For compatibility, all legacy operations take effect on ioreq[0].

---
 xen/arch/x86/hvm/ioreq.c         | 86 ++++++++++++++++++++++++++++------------
 xen/include/asm-x86/hvm/domain.h |  6 ++-
 2 files changed, 65 insertions(+), 27 deletions(-)
xen/arch/x86/hvm/ioreq.c +60 -26
index d991ac9..598aedb 100644
@@ -66,12 +66,12 @@ static struct hvm_ioreq_server *get_ioreq_server(const struct domain *d,
 
 static ioreq_t *get_ioreq(struct hvm_ioreq_server *s, struct vcpu *v)
 {
-    shared_iopage_t *p = s->ioreq.va;
+    shared_iopage_t *p = s->ioreq[v->vcpu_id / NR_IOREQ_PER_PAGE].va;
 
     ASSERT((v == current) || !vcpu_runnable(v));
     ASSERT(p != NULL);
 
-    return &p->vcpu_ioreq[v->vcpu_id];
+    return &p->vcpu_ioreq[v->vcpu_id % NR_IOREQ_PER_PAGE];
 }
 
 bool hvm_io_pending(struct vcpu *v)
@@ -239,7 +239,7 @@ static void hvm_free_ioreq_gfn(struct hvm_ioreq_server *s, gfn_t gfn)
 
 static void hvm_unmap_ioreq_gfn(struct hvm_ioreq_server *s, bool buf)
 {
-    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
+    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq[0];
 
     if ( gfn_eq(iorp->gfn, INVALID_GFN) )
         return;
@@ -256,7 +256,7 @@ static void hvm_unmap_ioreq_gfn(struct hvm_ioreq_server *s, bool buf)
 static int hvm_map_ioreq_gfn(struct hvm_ioreq_server *s, bool buf)
 {
     struct domain *d = s->domain;
-    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
+    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq[0];
     int rc;
 
     if ( iorp->page )
@@ -294,10 +294,10 @@ static int hvm_map_ioreq_gfn(struct hvm_ioreq_server *s, bool buf)
     return rc;
 }
 
-static int hvm_alloc_ioreq_mfn(struct hvm_ioreq_server *s, bool buf)
+static int hvm_alloc_ioreq_mfn(struct hvm_ioreq_server *s, uint8_t idx)
 {
     struct domain *currd = current->domain;
-    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
+    struct hvm_ioreq_page *iorp = idx ? &s->ioreq[idx - 1] : &s->bufioreq;
 
     if ( iorp->page )
     {
@@ -344,9 +344,9 @@ static int hvm_alloc_ioreq_mfn(struct hvm_ioreq_server *s, bool buf)
     return 0;
 }
 
-static void hvm_free_ioreq_mfn(struct hvm_ioreq_server *s, bool buf)
+static void hvm_free_ioreq_mfn(struct hvm_ioreq_server *s, uint8_t idx)
 {
-    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
+    struct hvm_ioreq_page *iorp = idx ? &s->ioreq[idx - 1] : &s->bufioreq;
 
     if ( !iorp->page )
         return;
@@ -368,7 +368,18 @@ bool is_ioreq_server_page(struct domain *d, const struct page_info *page)
 
     FOR_EACH_IOREQ_SERVER(d, id, s)
     {
-        if ( (s->ioreq.page == page) || (s->bufioreq.page == page) )
+        int i;
+
+        for ( i = 0; i < s->nr_ioreq_page; i++ )
+        {
+            if ( s->ioreq[i].page == page )
+            {
+                found = true;
+                break;
+            }
+        }
+
+        if ( !found && s->bufioreq.page == page )
         {
             found = true;
             break;
@@ -384,7 +395,7 @@ static void hvm_remove_ioreq_gfn(struct hvm_ioreq_server *s, bool buf)
 
 {
     struct domain *d = s->domain;
-    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
+    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq[0];
 
     if ( IS_DEFAULT(s) || gfn_eq(iorp->gfn, INVALID_GFN) )
         return;
@@ -398,7 +409,7 @@ static void hvm_remove_ioreq_gfn(struct hvm_ioreq_server *s, bool buf)
 static int hvm_add_ioreq_gfn(struct hvm_ioreq_server *s, bool buf)
 {
     struct domain *d = s->domain;
-    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq;
+    struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq[0];
     int rc;
 
     if ( IS_DEFAULT(s) || gfn_eq(iorp->gfn, INVALID_GFN) )
@@ -419,7 +430,7 @@ static void hvm_update_ioreq_evtchn(struct hvm_ioreq_server *s,
 {
     ASSERT(spin_is_locked(&s->lock));
 
-    if ( s->ioreq.va != NULL )
+    if ( s->ioreq[sv->vcpu->vcpu_id / NR_IOREQ_PER_PAGE].va )
     {
         ioreq_t *p = get_ioreq(s, sv->vcpu);
 
@@ -563,23 +574,27 @@ static void hvm_ioreq_server_unmap_pages(struct hvm_ioreq_server *s)
 
 static int hvm_ioreq_server_alloc_pages(struct hvm_ioreq_server *s)
 {
-    int rc;
-
-    rc = hvm_alloc_ioreq_mfn(s, false);
+    int rc = 0, i;
 
-    if ( !rc && (s->bufioreq_handling != HVM_IOREQSRV_BUFIOREQ_OFF) )
-        rc = hvm_alloc_ioreq_mfn(s, true);
+    for ( i = !HANDLE_BUFIOREQ(s); i <= s->nr_ioreq_page; i++ )
+    {
+        rc = hvm_alloc_ioreq_mfn(s, i);
+        break;
+    }
 
     if ( rc )
-        hvm_free_ioreq_mfn(s, false);
+        for ( ; i >= 0; i-- )
+            hvm_free_ioreq_mfn(s, i);
 
     return rc;
 }
 
 static void hvm_ioreq_server_free_pages(struct hvm_ioreq_server *s)
 {
-    hvm_free_ioreq_mfn(s, true);
-    hvm_free_ioreq_mfn(s, false);
+    int i;
+
+    for ( i = 0; i <= s->nr_ioreq_page; i++ )
+        hvm_free_ioreq_mfn(s, i);
 }
 
 static void hvm_ioreq_server_free_rangesets(struct hvm_ioreq_server *s)
@@ -681,7 +696,7 @@ static int hvm_ioreq_server_init(struct hvm_ioreq_server *s,
                                  int bufioreq_handling, ioservid_t id)
 {
     struct vcpu *v;
-    int rc;
+    int rc, i;
 
     s->domain = d;
     s->domid = domid;
@@ -690,7 +705,10 @@ static int hvm_ioreq_server_init(struct hvm_ioreq_server *s,
     INIT_LIST_HEAD(&s->ioreq_vcpu_list);
     spin_lock_init(&s->bufioreq_lock);
 
-    s->ioreq.gfn = INVALID_GFN;
+    s->nr_ioreq_page = (d->max_vcpus + NR_IOREQ_PER_PAGE - 1) /
+                       NR_IOREQ_PER_PAGE;
+    for ( i = 0; i < MAX_NR_IOREQ_PAGE; i++ )
+        s->ioreq[i].gfn = INVALID_GFN;
     s->bufioreq.gfn = INVALID_GFN;
 
     rc = hvm_ioreq_server_alloc_rangesets(s, id);
@@ -760,6 +778,10 @@ int hvm_create_ioreq_server(struct domain *d, domid_t domid,
         rc = -EEXIST;
         if ( GET_IOREQ_SERVER(d, i) )
             goto fail;
+
+        /* Don't create default IO server if > 1 ioreq pages are needed */
+        if ( d->max_vcpus > NR_IOREQ_PER_PAGE )
+            goto fail;
     }
     else
     {
@@ -858,6 +880,9 @@ int hvm_get_ioreq_server_info(struct domain *d, ioservid_t id,
     if ( !s )
         goto out;
 
+    if ( s->nr_ioreq_page > 1 )
+        return -EINVAL;
+
     ASSERT(!IS_DEFAULT(s));
 
     if ( ioreq_gfn || bufioreq_gfn )
@@ -868,7 +893,7 @@ int hvm_get_ioreq_server_info(struct domain *d, ioservid_t id,
     }
 
     if ( ioreq_gfn )
-        *ioreq_gfn = gfn_x(s->ioreq.gfn);
+        *ioreq_gfn = gfn_x(s->ioreq[0].gfn);
 
     if ( HANDLE_BUFIOREQ(s) )
     {
@@ -917,10 +942,19 @@ int hvm_get_ioreq_server_frame(struct domain *d, ioservid_t id,
         rc = 0;
         break;
 
-    case XENMEM_resource_ioreq_server_frame_ioreq(0):
-        *mfn = _mfn(page_to_mfn(s->ioreq.page));
-        rc = 0;
+    case XENMEM_resource_ioreq_server_frame_ioreq(0) ... \
+         XENMEM_resource_ioreq_server_frame_ioreq(MAX_NR_IOREQ_PAGE):
+    {
+        int i = idx - XENMEM_resource_ioreq_server_frame_ioreq(0);
+
+        rc = -EINVAL;
+        if ( i < s->nr_ioreq_page )
+        {
+            *mfn = _mfn(page_to_mfn(s->ioreq[i].page));
+            rc = 0;
+        }
         break;
+    }
 
     default:
         rc = -EINVAL;
xen/include/asm-x86/hvm/domain.h +5 -1
index 87f7994..3202f74 100644
@@ -51,6 +51,8 @@ struct hvm_ioreq_vcpu {
 
 #define NR_IO_RANGE_TYPES (XEN_DMOP_IO_RANGE_PCI + 1)
 #define MAX_NR_IO_RANGES  256
+#define MAX_NR_IOREQ_PAGE 4
+#define NR_IOREQ_PER_PAGE (PAGE_SIZE / sizeof(ioreq_t))
 
 struct hvm_ioreq_server {
     struct list_head       list_entry;
@@ -61,7 +63,9 @@ struct hvm_ioreq_server {
 
     /* Domain id of emulating domain */
     domid_t                domid;
-    struct hvm_ioreq_page  ioreq;
+    /* Per-IOserver limitation on the size of 'ioreq' array */
+    uint8_t                nr_ioreq_page;
+    struct hvm_ioreq_page  ioreq[MAX_NR_IOREQ_PAGE];
     struct list_head       ioreq_vcpu_list;
     struct hvm_ioreq_page  bufioreq;
 
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#10 lore raw

Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 107 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 07 December 2017 06:57
To: Paul Durrant <[email protected]>
Cc: Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Andrew Cooper <[email protected]>; Tim (Xen.org) <[email protected]>; George Dunlap <[email protected]>; [email protected]; Jan Beulich <[email protected]>; Ian Jackson <[email protected]>
Subject: Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 2 lines · Paul Durrant
Quoted 2 lines

-----Original Message-----
From: Xen-devel [mailto:[email protected]] On

Behalf

Quoted 5 lines
Quoted 5 lines

Of Paul Durrant
Sent: 06 December 2017 16:10
To: 'Chao Gao' <[email protected]>
Cc: Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Andrew Cooper <[email protected]>;

Tim

Quoted 6 lines
Quoted 6 lines

(Xen.org) <[email protected]>; George Dunlap <[email protected]>; [email protected]; Jan Beulich <[email protected]>; Ian Jackson <[email protected]>
Subject: Re: [Xen-devel] [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 06 December 2017 09:02
To: Paul Durrant <[email protected]>
Cc: [email protected]; Tim (Xen.org) <[email protected]>; Stefano Stabellini <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Jan Beulich <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; Ian

Jackson

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

<[email protected]>
Subject: Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page

to 4

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

pages

Quoted 6 lines · Paul Durrant
Quoted 6 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 06 December 2017 07:50
To: [email protected]
Cc: Chao Gao <[email protected]>; Paul Durrant <[email protected]>; Tim (Xen.org) <[email protected]>; Stefano

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Stabellini

Quoted 2 lines
Quoted 2 lines

<[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Jan Beulich <[email protected]>;

George

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; Ian

Jackson

Quoted 2 lines
Quoted 2 lines

<[email protected]>
Subject: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page

to 4

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

pages

One 4K-byte page at most contains 128 'ioreq_t'. In order to remove

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

vcpu

Quoted 1 line
Quoted 1 line

number constraint imposed by one IOREQ page, bump the number

of

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

IOREQ

Quoted 4 lines
Quoted 4 lines

page to
4 pages. With this patch, multiple pages can be used as IOREQ page.

Basically, this patch extends 'ioreq' field in struct hvm_ioreq_server

to

Quoted 5 lines
Quoted 5 lines

an

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

array. All accesses to 'ioreq' field such as 's->ioreq' are replaced with FOR_EACH_IOREQ_PAGE macro.

In order to access an IOREQ page, QEMU should get the gmfn and

map

Quoted 9 lines
Quoted 9 lines
Quoted 5 lines

this

Quoted 4 lines
Quoted 2 lines

gmfn
to its virtual address space.

No. There's no need to extend the 'legacy' mechanism of using magic

page

Quoted 3 lines

gfns. You should only handle the case where the mfns are allocated on demand (see the call to hvm_ioreq_server_alloc_pages() in hvm_get_ioreq_server_frame()). The number of guest vcpus is known

at

Quoted 1 line
Quoted 1 line
Quoted 1 line

this point so the correct number of pages can be allocated. If the creator

of

Quoted 1 line
Quoted 1 line
Quoted 1 line

the ioreq server attempts to use the legacy

hvm_get_ioreq_server_info()

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

and the guest has >128 vcpus then the call should fail.

Great suggestion. I will introduce a new dmop, a variant of hvm_get_ioreq_server_frame() for creator to get an array of gfns and

the

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

size of array. And the legacy interface will report an error if more than one IOREQ PAGES are needed.

You don't need a new dmop for mapping I think. The mem op to map

ioreq

Quoted 2 lines
Quoted 2 lines

server frames should work. All you should need to do is update hvm_get_ioreq_server_frame() to deal with an index > 1, and provide

some

Quoted 1 line
Quoted 1 line

means for the ioreq server creator to convert the number of guest vcpus

Quoted 8 lines

into

Quoted 3 lines
Quoted 1 line

the correct number of pages to map. (That might need a new dm op).

I realise after saying this that an emulator already knows the size of the

ioreq structure and so can easily calculate the correct number of pages to map, given the number of guest vcpus.

How about the patch in the bottom? Is it in the right direction?

Yes, certainly along the right lines. I would probably do away with MAX_NR_IOREQ_PAGE though. You should just to dynamically allocate the correct number of ioreq pages when the ioreq server is created (since you already calculate nr_ioreq_page there anyway).

Quoted 3 lines

Do you have the QEMU patch, which replaces the old method with the new method
to set up mapping? I want to integrate that patch and do some tests.

Sure. There's a couple of patched. I have not tested them with recent rebases of my series so you may find some issues.

Cheers,

Paul

From b162cc6d92bffe28efac38f5b9501a9c28b5be79 Mon Sep 17 00:00:00 2001
From: Paul Durrant <[email protected]>
Date: Thu, 10 Aug 2017 11:37:22 +0100
Subject: [PATCH 1/2] Separate ioreq server mapping code from general init

---
 hw/i386/xen/xen-hvm.c | 81 ++++++++++++++++++++++++++++++---------------------
 1 file changed, 48 insertions(+), 33 deletions(-)
hw/i386/xen/xen-hvm.c +48 -33
index d9ccd5d0d6..59e3122daf 100644
@@ -95,7 +95,8 @@ typedef struct XenIOState {
     CPUState **cpu_by_vcpu_id;
     /* the evtchn port for polling the notification, */
     evtchn_port_t *ioreq_local_port;
-    /* evtchn local port for buffered io */
+    /* evtchn remote and local ports for buffered io */
+    evtchn_port_t bufioreq_remote_port;
     evtchn_port_t bufioreq_local_port;
     /* the evtchn fd for polling */
     xenevtchn_handle *xce_handle;
@@ -1232,12 +1233,52 @@ static void xen_wakeup_notifier(Notifier *notifier, void *data)
     xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 0);
 }
 
-void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
+static int xen_map_ioreq_server(XenIOState *state)
 {
-    int i, rc;
     xen_pfn_t ioreq_pfn;
     xen_pfn_t bufioreq_pfn;
     evtchn_port_t bufioreq_evtchn;
+    int rc;
+    
+    rc = xen_get_ioreq_server_info(xen_domid, state->ioservid,
+                                   &ioreq_pfn, &bufioreq_pfn,
+                                   &bufioreq_evtchn);
+    if (rc < 0) {
+        error_report("failed to get ioreq server info: error %d handle=%p",
+                     errno, xen_xc);
+        return rc;
+    }
+
+    DPRINTF("shared page at pfn %lx\n", ioreq_pfn);
+    DPRINTF("buffered io page at pfn %lx\n", bufioreq_pfn);
+    DPRINTF("buffered io evtchn is %x\n", bufioreq_evtchn);
+
+    state->shared_page = xenforeignmemory_map(xen_fmem, xen_domid,
+                                              PROT_READ|PROT_WRITE,
+                                              1, &ioreq_pfn, NULL);
+    if (state->shared_page == NULL) {
+        error_report("map shared IO page returned error %d handle=%p",
+                     errno, xen_xc);
+        return -1;
+    }
+
+    state->buffered_io_page = xenforeignmemory_map(xen_fmem, xen_domid,
+                                                   PROT_READ|PROT_WRITE,
+                                                   1, &bufioreq_pfn, NULL);
+    if (state->buffered_io_page == NULL) {
+        error_report("map buffered IO page returned error %d", errno);
+        return -1;
+    }
+
+    state->bufioreq_remote_port = bufioreq_evtchn;
+    
+    return 0;
+}
+
+void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
+{
+    int i, rc;
+    xen_pfn_t ioreq_pfn;
     XenIOState *state;
 
     state = g_malloc0(sizeof (XenIOState));
@@ -1273,28 +1314,10 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
     state->wakeup.notify = xen_wakeup_notifier;
     qemu_register_wakeup_notifier(&state->wakeup);
 
-    rc = xen_get_ioreq_server_info(xen_domid, state->ioservid,
-                                   &ioreq_pfn, &bufioreq_pfn,
-                                   &bufioreq_evtchn);
-    if (rc < 0) {
-        error_report("failed to get ioreq server info: error %d handle=%p",
-                     errno, xen_xc);
+    rc = xen_map_ioreq_server(state);
+    if (rc < 0)
         goto err;
-    }
-
-    DPRINTF("shared page at pfn %lx\n", ioreq_pfn);
-    DPRINTF("buffered io page at pfn %lx\n", bufioreq_pfn);
-    DPRINTF("buffered io evtchn is %x\n", bufioreq_evtchn);
-
-    state->shared_page = xenforeignmemory_map(xen_fmem, xen_domid,
-                                              PROT_READ|PROT_WRITE,
-                                              1, &ioreq_pfn, NULL);
-    if (state->shared_page == NULL) {
-        error_report("map shared IO page returned error %d handle=%p",
-                     errno, xen_xc);
-        goto err;
-    }
-
+    
     rc = xen_get_vmport_regs_pfn(xen_xc, xen_domid, &ioreq_pfn);
     if (!rc) {
         DPRINTF("shared vmport page at pfn %lx\n", ioreq_pfn);
@@ -1312,14 +1335,6 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
         goto err;
     }
 
-    state->buffered_io_page = xenforeignmemory_map(xen_fmem, xen_domid,
-                                                   PROT_READ|PROT_WRITE,
-                                                   1, &bufioreq_pfn, NULL);
-    if (state->buffered_io_page == NULL) {
-        error_report("map buffered IO page returned error %d", errno);
-        goto err;
-    }
-
     /* Note: cpus is empty at this point in init */
     state->cpu_by_vcpu_id = g_malloc0(max_cpus * sizeof(CPUState *));
 
@@ -1344,7 +1359,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
     }
 
     rc = xenevtchn_bind_interdomain(state->xce_handle, xen_domid,
-                                    bufioreq_evtchn);
+                                    state->bufioreq_remote_port);
     if (rc == -1) {
         error_report("buffered evtchn bind error %d", errno);
         goto err;
Signature · 1 line
2.11.0

From 0afb65e74d4ba5b1fae47cd7fef65a6bdc859b57 Mon Sep 17 00:00:00 2001
From: Paul Durrant <[email protected]>
Date: Thu, 10 Aug 2017 11:38:01 +0100
Subject: [PATCH 2/2] use new interface

---
 configure                   |  1 +
 hw/i386/xen/xen-hvm.c       | 62 +++++++++++++++++++++++++++++++++++----------
 include/hw/xen/xen_common.h | 16 ++++++++++++
 3 files changed, 66 insertions(+), 13 deletions(-)
configure +1 -0
index dd73cce62f..55b67f9845 100755
@@ -2114,6 +2114,7 @@ int main(void) {
 
   xfmem = xenforeignmemory_open(0, 0);
   xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
+  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
 
   return 0;
 }
hw/i386/xen/xen-hvm.c +49 -13

86 lines not on this page · raw message

include/hw/xen/xen_common.h +16 -0
index 86c7f26106..6c59ab56e9 100644
@@ -91,6 +91,22 @@ static inline void *xenforeignmemory_map2(xenforeignmemory_handle *h,
     return xenforeignmemory_map(h, dom, prot, pages, arr, err);
 }
 
+typedef void xenforeignmemory_resource_handle;
+
+static inline xenforeignmemory_resource_handle *xenforeignmemory_map_resource(
+    xenforeignmemory_handle *fmem, domid_t domid, unsigned int type,
+    unsigned int id, unsigned long frame, unsigned long nr_frames,
+    void **paddr, int prot, int flags)
+{
+    errno = EOPNOTSUPP;
+    return -1;
+}
+
+static inline void xenforeignmemory_unmap_resource(
+    xenforeignmemory_handle *fmem, xenforeignmemory_resource_handle *fres)
+{
+}
+
 #endif
 
 #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 40900
Signature · 1 line
2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#11 lore raw

Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 116 lines · Paul Durrant
Quoted 107 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 07 December 2017 06:57
To: Paul Durrant <[email protected]>
Cc: Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Andrew Cooper <[email protected]>; Tim (Xen.org) <[email protected]>; George Dunlap <[email protected]>; [email protected]; Jan Beulich <[email protected]>; Ian Jackson <[email protected]>
Subject: Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 2 lines · Paul Durrant
Quoted 2 lines

-----Original Message-----
From: Xen-devel [mailto:[email protected]] On

Behalf

Quoted 5 lines
Quoted 5 lines

Of Paul Durrant
Sent: 06 December 2017 16:10
To: 'Chao Gao' <[email protected]>
Cc: Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Andrew Cooper <[email protected]>;

Tim

Quoted 6 lines
Quoted 6 lines

(Xen.org) <[email protected]>; George Dunlap <[email protected]>; [email protected]; Jan Beulich <[email protected]>; Ian Jackson <[email protected]>
Subject: Re: [Xen-devel] [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 06 December 2017 09:02
To: Paul Durrant <[email protected]>
Cc: [email protected]; Tim (Xen.org) <[email protected]>; Stefano Stabellini <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Jan Beulich <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; Ian

Jackson

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

<[email protected]>
Subject: Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page

to 4

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

pages

Quoted 6 lines · Paul Durrant
Quoted 6 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 06 December 2017 07:50
To: [email protected]
Cc: Chao Gao <[email protected]>; Paul Durrant <[email protected]>; Tim (Xen.org) <[email protected]>; Stefano

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Stabellini

Quoted 2 lines
Quoted 2 lines

<[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Jan Beulich <[email protected]>;

George

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Wei Liu <[email protected]>; Ian

Jackson

Quoted 2 lines
Quoted 2 lines

<[email protected]>
Subject: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page

to 4

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

pages

One 4K-byte page at most contains 128 'ioreq_t'. In order to remove

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

vcpu

Quoted 1 line
Quoted 1 line

number constraint imposed by one IOREQ page, bump the number

of

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

IOREQ

Quoted 4 lines
Quoted 4 lines

page to
4 pages. With this patch, multiple pages can be used as IOREQ page.

Basically, this patch extends 'ioreq' field in struct hvm_ioreq_server

to

Quoted 5 lines
Quoted 5 lines

an

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

array. All accesses to 'ioreq' field such as 's->ioreq' are replaced with FOR_EACH_IOREQ_PAGE macro.

In order to access an IOREQ page, QEMU should get the gmfn and

map

Quoted 9 lines
Quoted 9 lines
Quoted 5 lines

this

Quoted 4 lines
Quoted 2 lines

gmfn
to its virtual address space.

No. There's no need to extend the 'legacy' mechanism of using magic

page

Quoted 3 lines

gfns. You should only handle the case where the mfns are allocated on demand (see the call to hvm_ioreq_server_alloc_pages() in hvm_get_ioreq_server_frame()). The number of guest vcpus is known

at

Quoted 1 line
Quoted 1 line
Quoted 1 line

this point so the correct number of pages can be allocated. If the creator

of

Quoted 1 line
Quoted 1 line
Quoted 1 line

the ioreq server attempts to use the legacy

hvm_get_ioreq_server_info()

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

and the guest has >128 vcpus then the call should fail.

Great suggestion. I will introduce a new dmop, a variant of hvm_get_ioreq_server_frame() for creator to get an array of gfns and

the

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

size of array. And the legacy interface will report an error if more than one IOREQ PAGES are needed.

You don't need a new dmop for mapping I think. The mem op to map

ioreq

Quoted 2 lines
Quoted 2 lines

server frames should work. All you should need to do is update hvm_get_ioreq_server_frame() to deal with an index > 1, and provide

some

Quoted 1 line
Quoted 1 line

means for the ioreq server creator to convert the number of guest vcpus

Quoted 8 lines

into

Quoted 3 lines
Quoted 1 line

the correct number of pages to map. (That might need a new dm op).

I realise after saying this that an emulator already knows the size of the

ioreq structure and so can easily calculate the correct number of pages to map, given the number of guest vcpus.

How about the patch in the bottom? Is it in the right direction?

Quoted 7 lines

Yes, certainly along the right lines. I would probably do away with MAX_NR_IOREQ_PAGE though. You should just to dynamically allocate the correct number of ioreq pages when the ioreq server is created (since you already calculate nr_ioreq_page there anyway).

Quoted 3 lines

Do you have the QEMU patch, which replaces the old method with the new method
to set up mapping? I want to integrate that patch and do some tests.

Sure. There's a couple of patched. I have not tested them with recent rebases of my series so you may find some issues.

Hi, Paul.

I merged the two qemu patches, the privcmd patch [1] and did some tests. I encountered a small issue and report it to you, so you can pay more attention to it when doing some tests. The symptom is that using the new interface to map grant table in xc_dom_gnttab_seed() always fails. After adding some printk in privcmd, I found it is xen_remap_domain_gfn_array() that fails with errcode -16. Mapping ioreq server doesn't have such an issue.

[1] http://xenbits.xen.org/gitweb/?p=people/pauldu/linux.git;a=commit;h=ce59a05e6712

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#12 lore raw

Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 1 line

-----Original Message-----

[snip]

Quoted 11 lines

Hi, Paul.

I merged the two qemu patches, the privcmd patch [1] and did some tests. I encountered a small issue and report it to you, so you can pay more attention to it when doing some tests. The symptom is that using the new interface to map grant table in xc_dom_gnttab_seed() always fails. After adding some printk in privcmd, I found it is xen_remap_domain_gfn_array() that fails with errcode -16. Mapping ioreq server doesn't have such an issue.

Quoted 4 lines

[1]
http://xenbits.xen.org/gitweb/?p=people/pauldu/linux.git;a=commit;h=ce5
9a05e6712

Chao,

That privcmd patch is out of date. I've just pushed a new one:

http://xenbits.xen.org/gitweb/?p=people/pauldu/linux.git;a=commit;h=9f00199f5f12cef401c6370c94a1140de9b318fc

Give that a try. I've been using it for a few weeks now.

Cheers,

Paul

Quoted 2 lines

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#13 lore raw

Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 18 lines · Paul Durrant
Quoted 1 line

-----Original Message-----

[snip]

Quoted 11 lines

Hi, Paul.

I merged the two qemu patches, the privcmd patch [1] and did some tests. I encountered a small issue and report it to you, so you can pay more attention to it when doing some tests. The symptom is that using the new interface to map grant table in xc_dom_gnttab_seed() always fails. After adding some printk in privcmd, I found it is xen_remap_domain_gfn_array() that fails with errcode -16. Mapping ioreq server doesn't have such an issue.

Quoted 4 lines

[1]
http://xenbits.xen.org/gitweb/?p=people/pauldu/linux.git;a=commit;h=ce5
9a05e6712

Quoted 7 lines

Chao,

That privcmd patch is out of date. I've just pushed a new one:

http://xenbits.xen.org/gitweb/?p=people/pauldu/linux.git;a=commit;h=9f00199f5f12cef401c6370c94a1140de9b318fc

Give that a try. I've been using it for a few weeks now.

Mapping ioreq server always fails, while mapping grant table succeeds.

QEMU fails with following log:
xenforeignmemory: error: ioctl failed: Device or resource busy
qemu-system-i386: failed to map ioreq server resources: error 16 handle=0x5614a6df5e00
qemu-system-i386: xen hardware virtual machine initialisation failed

Xen encountered the following error:
(XEN) [13118.909787] mm.c:1003:d0v109 pg_owner d2 l1e_owner d0, but real_pg_owner d0
(XEN) [13118.918122] mm.c:1079:d0v109 Error getting mfn 5da5841 (pfn ffffffffffffffff) from L1 entry 8000005da5841227 for l1e_owner d0, pg_owner d2

I only fixed some obvious issues with a patch to your privcmd patch:

arch/x86/xen/mmu.c +3 -3
@@ -181,7 +181,7 @@ int xen_remap_domain_gfn_range(struct vm_area_struct *vma,
        if (xen_feature(XENFEAT_auto_translated_physmap))
                return -EOPNOTSUPP;
 
-       return do_remap_gfn(vma, addr, &gfn, nr, NULL, prot, domid, pages);
+       return do_remap_pfn(vma, addr, &gfn, nr, NULL, prot, domid, false, pages
 }
 EXPORT_SYMBOL_GPL(xen_remap_domain_gfn_range);
 
@@ -200,8 +200,8 @@ int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
         * cause of "wrong memory was mapped in".
         */
        BUG_ON(err_ptr == NULL);
-        do_remap_pfn(vma, addr, gfn, nr, err_ptr, prot, domid,
-                    false, pages);
+       return do_remap_pfn(vma, addr, gfn, nr, err_ptr, prot, domid,
+                       false, pages);
 }
 EXPORT_SYMBOL_GPL(xen_remap_domain_gfn_array);
 

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#14 lore raw

Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 51 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 12 December 2017 23:39
To: Paul Durrant <[email protected]>
Cc: Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Andrew Cooper <[email protected]>; Tim (Xen.org) <[email protected]>; George Dunlap <[email protected]>; [email protected]; Jan Beulich <[email protected]>; Ian Jackson <[email protected]>
Subject: Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 6 lines · Paul Durrant
Quoted 1 line

-----Original Message-----

[snip]

Quoted 4 lines

Hi, Paul.

I merged the two qemu patches, the privcmd patch [1] and did some

tests.

Quoted 5 lines
Quoted 5 lines

I encountered a small issue and report it to you, so you can pay more attention to it when doing some tests. The symptom is that using the new interface to map grant table in xc_dom_gnttab_seed() always fails. After adding some printk in privcmd, I found it is xen_remap_domain_gfn_array() that fails with errcode -16. Mapping

ioreq

Quoted 4 lines
Quoted 4 lines

server doesn't have such an issue.

[1]

http://xenbits.xen.org/gitweb/?p=people/pauldu/linux.git;a=commit;h=ce5

Quoted 8 lines
Quoted 2 lines

9a05e6712

Chao,

That privcmd patch is out of date. I've just pushed a new one:

http://xenbits.xen.org/gitweb/?p=people/pauldu/linux.git;a=commit;h=9f

00199f5f12cef401c6370c94a1140de9b318fc

Quoted 2 lines

Give that a try. I've been using it for a few weeks now.

Mapping ioreq server always fails, while mapping grant table succeeds.

QEMU fails with following log:
xenforeignmemory: error: ioctl failed: Device or resource busy
qemu-system-i386: failed to map ioreq server resources: error 16 handle=0x5614a6df5e00
qemu-system-i386: xen hardware virtual machine initialisation failed

Quoted 6 lines

Xen encountered the following error:
(XEN) [13118.909787] mm.c:1003:d0v109 pg_owner d2 l1e_owner d0, but real_pg_owner d0
(XEN) [13118.918122] mm.c:1079:d0v109 Error getting mfn 5da5841 (pfn ffffffffffffffff) from L1 entry 8000005da5841227 for l1e_owner d0, pg_owner d2

Hmm. That looks like it is because the ioreq server pages are not owned by the correct domain. The Xen patch series underwent some changes later in review and I did not re-test my QEMU patch after that so I wonder if mapping IOREQ pages has simply become broken. I'll investigate.

Paul

Quoted 27 lines

I only fixed some obvious issues with a patch to your privcmd patch:

arch/x86/xen/mmu.c +1 -1
@@ -181,7 +181,7 @@ int xen_remap_domain_gfn_range(struct
 vm_area_struct *vma,
        if (xen_feature(XENFEAT_auto_translated_physmap))
                return -EOPNOTSUPP;
 
-       return do_remap_gfn(vma, addr, &gfn, nr, NULL, prot, domid, pages);
+       return do_remap_pfn(vma, addr, &gfn, nr, NULL, prot, domid, false,

pages
}
EXPORT_SYMBOL_GPL(xen_remap_domain_gfn_range);

arch/x86/xen/mmu.c +2 -2
@@ -200,8 +200,8 @@ int xen_remap_domain_gfn_array(struct
 vm_area_struct *vma,
         * cause of "wrong memory was mapped in".
         */
        BUG_ON(err_ptr == NULL);
-        do_remap_pfn(vma, addr, gfn, nr, err_ptr, prot, domid,
-                    false, pages);
+       return do_remap_pfn(vma, addr, gfn, nr, err_ptr, prot, domid,
+                       false, pages);
 }
 EXPORT_SYMBOL_GPL(xen_remap_domain_gfn_array);
Quoted 2 lines

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#15 lore raw

Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 74 lines

-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Paul Durrant
Sent: 13 December 2017 10:49
To: 'Chao Gao' <[email protected]>
Cc: Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Andrew Cooper <[email protected]>; Tim (Xen.org) <[email protected]>; George Dunlap <[email protected]>; [email protected]; Jan Beulich <[email protected]>; Ian Jackson <[email protected]>
Subject: Re: [Xen-devel] [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 6 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 12 December 2017 23:39
To: Paul Durrant <[email protected]>
Cc: Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Andrew Cooper <[email protected]>;

Tim

Quoted 6 lines

(Xen.org) <[email protected]>; George Dunlap <[email protected]>; [email protected]; Jan Beulich <[email protected]>; Ian Jackson <[email protected]>
Subject: Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 10 lines
Quoted 6 lines · Paul Durrant
Quoted 1 line

-----Original Message-----

[snip]

Quoted 4 lines

Hi, Paul.

I merged the two qemu patches, the privcmd patch [1] and did some

tests.

Quoted 2 lines
Quoted 2 lines

I encountered a small issue and report it to you, so you can pay more attention to it when doing some tests. The symptom is that using the

new

Quoted 1 line
Quoted 1 line
Quoted 1 line

interface to map grant table in xc_dom_gnttab_seed() always fails.

After

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

adding some printk in privcmd, I found it is xen_remap_domain_gfn_array() that fails with errcode -16. Mapping

ioreq

Quoted 4 lines
Quoted 4 lines

server doesn't have such an issue.

[1]

http://xenbits.xen.org/gitweb/?p=people/pauldu/linux.git;a=commit;h=ce5

Quoted 21 lines
Quoted 7 lines
Quoted 2 lines

9a05e6712

Chao,

That privcmd patch is out of date. I've just pushed a new one:

http://xenbits.xen.org/gitweb/?p=people/pauldu/linux.git;a=commit;h=9f
00199f5f12cef401c6370c94a1140de9b318fc

Quoted 2 lines

Give that a try. I've been using it for a few weeks now.

Mapping ioreq server always fails, while mapping grant table succeeds.

QEMU fails with following log:
xenforeignmemory: error: ioctl failed: Device or resource busy
qemu-system-i386: failed to map ioreq server resources: error 16 handle=0x5614a6df5e00
qemu-system-i386: xen hardware virtual machine initialisation failed

Quoted 5 lines

Xen encountered the following error:
(XEN) [13118.909787] mm.c:1003:d0v109 pg_owner d2 l1e_owner d0, but real_pg_owner d0
(XEN) [13118.918122] mm.c:1079:d0v109 Error getting mfn 5da5841 (pfn ffffffffffffffff) from L1 entry 8000005da5841227 for l1e_owner d0,

Quoted 8 lines

pg_owner

Quoted 1 line

d2

Hmm. That looks like it is because the ioreq server pages are not owned by the correct domain. The Xen patch series underwent some changes later in review and I did not re-test my QEMU patch after that so I wonder if mapping IOREQ pages has simply become broken. I'll investigate.

I have reproduced the problem locally now. Will try to figure out the bug tomorrow.

Paul

Quoted 29 lines

Paul

Quoted 27 lines

I only fixed some obvious issues with a patch to your privcmd patch:

arch/x86/xen/mmu.c +1 -1
@@ -181,7 +181,7 @@ int xen_remap_domain_gfn_range(struct
 vm_area_struct *vma,
        if (xen_feature(XENFEAT_auto_translated_physmap))
                return -EOPNOTSUPP;
 
-       return do_remap_gfn(vma, addr, &gfn, nr, NULL, prot, domid, pages);
+       return do_remap_pfn(vma, addr, &gfn, nr, NULL, prot, domid, false,

pages
}
EXPORT_SYMBOL_GPL(xen_remap_domain_gfn_range);

arch/x86/xen/mmu.c +2 -2
@@ -200,8 +200,8 @@ int xen_remap_domain_gfn_array(struct
 vm_area_struct *vma,
         * cause of "wrong memory was mapped in".
         */
        BUG_ON(err_ptr == NULL);
-        do_remap_pfn(vma, addr, gfn, nr, err_ptr, prot, domid,
-                    false, pages);
+       return do_remap_pfn(vma, addr, gfn, nr, err_ptr, prot, domid,
+                       false, pages);
 }
 EXPORT_SYMBOL_GPL(xen_remap_domain_gfn_array);
Quoted 7 lines
Quoted 2 lines

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#16 lore raw

Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 11 lines

-----Original Message-----

Quoted 6 lines

Hmm. That looks like it is because the ioreq server pages are not owned by the correct domain. The Xen patch series underwent some changes later in review and I did not re-test my QEMU patch after that so I wonder if mapping IOREQ pages has simply become broken. I'll investigate.

I have reproduced the problem locally now. Will try to figure out the bug tomorrow.

Chao,

Can you try my new branch http://xenbits.xen.org/gitweb/?p=people/pauldu/xen.git;a=shortlog;h=refs/heads/ioreq24?

The problem was indeed that the ioreq pages were owned by the emulating domain rather than the target domain, which is no longer compatible with privcmd's use of HYPERVISOR_mmu_update.

Cheers,

Paul
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#17 lore raw

Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 12 lines · Paul Durrant
Quoted 11 lines

-----Original Message-----

Quoted 6 lines

Hmm. That looks like it is because the ioreq server pages are not owned by the correct domain. The Xen patch series underwent some changes later in review and I did not re-test my QEMU patch after that so I wonder if mapping IOREQ pages has simply become broken. I'll investigate.

I have reproduced the problem locally now. Will try to figure out the bug tomorrow.

Quoted 5 lines

Chao,

Can you try my new branch http://xenbits.xen.org/gitweb/?p=people/pauldu/xen.git;a=shortlog;h=refs/heads/ioreq24?

The problem was indeed that the ioreq pages were owned by the emulating domain rather than the target domain, which is no longer compatible with privcmd's use of HYPERVISOR_mmu_update.

Of course. I tested this branch. It works well.

But, I think your privcmd patch couldn't set 'err_ptr' to NULL when calling xen_remap_domain_mfn_array(). It works for the ioreq page is allocated right before the bufioreq page, and then they happen to be continuous.

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#18 lore raw

Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 37 lines

-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 15 December 2017 00:36
To: Paul Durrant <[email protected]>
Cc: Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Andrew Cooper <[email protected]>; Tim (Xen.org) <[email protected]>; George Dunlap <[email protected]>; [email protected]; Jan Beulich <[email protected]>; Ian Jackson <[email protected]>
Subject: Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

Quoted 3 lines · Paul Durrant
Quoted 3 lines

-----Original Message-----

Quoted 2 lines

Hmm. That looks like it is because the ioreq server pages are not owned

by

Quoted 1 line
Quoted 1 line
Quoted 1 line

the correct domain. The Xen patch series underwent some changes

later in

Quoted 11 lines
Quoted 7 lines
Quoted 3 lines

review and I did not re-test my QEMU patch after that so I wonder if mapping IOREQ pages has simply become broken. I'll investigate.

I have reproduced the problem locally now. Will try to figure out the bug tomorrow.

Chao,

Can you try my new branch

http://xenbits.xen.org/gitweb/?p=people/pauldu/xen.git;a=shortlog;h=refs
/heads/ioreq24?

Quoted 2 lines

The problem was indeed that the ioreq pages were owned by the

emulating domain rather than the target domain, which is no longer compatible with privcmd's use of HYPERVISOR_mmu_update.

Quoted 7 lines

Of course. I tested this branch. It works well.

But, I think your privcmd patch couldn't set 'err_ptr' to NULL when calling xen_remap_domain_mfn_array(). It works for the ioreq page is allocated right before the bufioreq page, and then they happen to be continuous.

I'll have a look at that. The pages should not need to be contiguous MFNs for things to work. They will, by design, by mapped so that they are virtually contiguous. That's just a convenient way of getting pointers to the buf and synchronous structures in QEMU using only a single IOCTL to privcmd.

Paul

Quoted 2 lines

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#19 lore raw

Re: [RFC Patch v4 2/8] ioreq: bump the number of IOREQ page to 4 pages

In reply to Chao Gao
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 06.12.17 at 08:50, <[email protected]> wrote:

One 4K-byte page at most contains 128 'ioreq_t'. In order to remove the vcpu number constraint imposed by one IOREQ page, bump the number of IOREQ page to 4 pages. With this patch, multiple pages can be used as IOREQ page.

In case I didn't say so before - I'm opposed to simply changing the upper limit here. Please make sure any number of vCPU-s can be supported by the new code (it looks like it mostly does already, so it may be mainly the description which needs changing). If we want to impose an upper limit, this shouldn't affect the ioreq page handling code at all.

xen/arch/x86/hvm/ioreq.c static struct hvm_ioreq_server *get_ioreq_server(const struct domain *d, · line 69

Quoted 9 lines
xen/arch/x86/hvm/ioreq.c +3 -0
@@ -64,14 +64,24 @@ static struct hvm_ioreq_server *get_ioreq_server(const struct domain *d,
             continue; \
         else
 
+/* Iterate over all ioreq pages */
+#define FOR_EACH_IOREQ_PAGE(s, i, iorp) \
+    for ( (i) = 0, iorp = s->ioreq; (i) < (s)->ioreq_page_nr; (i)++, iorp++ )

You're going too far with parenthesization here: Just like iorp, i is required to be a simple identifier anyway. Otoh you parenthesize s only once.

xen/arch/x86/hvm/ioreq.c static struct hvm_ioreq_server *get_ioreq_server(const struct domain *d, · line 81

Quoted 1 line
xen/arch/x86/hvm/ioreq.c +1 -0
+static ioreq_t *get_ioreq_fallible(struct hvm_ioreq_server *s, struct vcpu *v)

What is "fallible"? And why such a separate wrapper anyway? But I guess a lot of this will need to change anyway with Paul's recent changes. I'm therefore not going to look in close detail at any of this.

xen/arch/x86/hvm/ioreq.c static void hvm_ioreq_server_remove_all_vcpus(struct hvm_ioreq_server *s) · line 588

Quoted 4 lines
xen/arch/x86/hvm/ioreq.c +1 -1
 static void hvm_ioreq_server_unmap_pages(struct hvm_ioreq_server *s)
 {
-    hvm_unmap_ioreq_gfn(s, &s->ioreq);
+    int i;

At the example of this - unsigned int please in all cases where the value can't go negative.

xen/arch/x86/hvm/ioreq.c static int hvm_ioreq_server_init(struct hvm_ioreq_server *s, · line 748

Quoted 10 lines
xen/arch/x86/hvm/ioreq.c +4 -1
@@ -688,8 +741,15 @@ static int hvm_ioreq_server_init(struct hvm_ioreq_server *s,
     INIT_LIST_HEAD(&s->ioreq_vcpu_list);
     spin_lock_init(&s->bufioreq_lock);
 
-    s->ioreq.gfn = INVALID_GFN;
+    FOR_EACH_IOREQ_PAGE(s, i, iorp)
+        iorp->gfn = INVALID_GFN;
     s->bufioreq.gfn = INVALID_GFN;
+    s->ioreq_page_nr = (d->max_vcpus + IOREQ_NUM_PER_PAGE - 1) /
+                       IOREQ_NUM_PER_PAGE;

DIV_ROUND_UP() - please don't open-code things.

xen/include/public/hvm/params.h line 286

Quoted 12 lines
xen/include/public/hvm/params.h +5 -1
@@ -279,6 +279,12 @@
 #define XEN_HVM_MCA_CAP_LMCE   (xen_mk_ullong(1) << 0)
 #define XEN_HVM_MCA_CAP_MASK   XEN_HVM_MCA_CAP_LMCE
 
-#define HVM_NR_PARAMS 39
+/*
+ * Number of pages that are reserved for default IOREQ server. The base PFN
+ * is set via HVM_PARAM_IOREQ_PFN.
+ */
+#define HVM_PARAM_IOREQ_PAGES 39

Why is this needed? It can be derived from the vCPU count permitted for the domain.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#20 lore raw

RFC PATCH v4 3/8 xl/acpi: unify the computation of lapic_id

In reply to Chao Gao

There were two places where the lapic_id is computed, one in hvmloader and one in libacpi. Unify them by defining LAPIC_ID in a header file and incluing it in both places.

To address compilation issue and make libacpi.h self-contained, include stdint.h in libacpi.h.

---
v4:
- new

---
 tools/firmware/hvmloader/config.h | 3 +--
 tools/libacpi/libacpi.h           | 3 +++
 tools/libxl/libxl_x86_acpi.c      | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)
tools/firmware/hvmloader/config.h +1 -2
index 6e00413..55e3a27 100644
@@ -1,7 +1,7 @@
 #ifndef __HVMLOADER_CONFIG_H__
 #define __HVMLOADER_CONFIG_H__
 
-#include <stdint.h>
+#include <libacpi.h>
 
 enum virtual_vga { VGA_none, VGA_std, VGA_cirrus, VGA_pt };
 extern enum virtual_vga virtual_vga;
@@ -48,7 +48,6 @@ extern uint8_t ioapic_version;
 #define IOAPIC_ID           0x01
 
 #define LAPIC_BASE_ADDRESS  0xfee00000
-#define LAPIC_ID(vcpu_id)   ((vcpu_id) * 2)
 
 #define PCI_ISA_DEVFN       0x08    /* dev 1, fn 0 */
 #define PCI_ISA_IRQ_MASK    0x0c20U /* ISA IRQs 5,10,11 are PCI connected */
tools/libacpi/libacpi.h +3 -0
index 46a819d..b89fdb5 100644
@@ -21,6 +21,9 @@
 #define __LIBACPI_H__
 
 #include <stdbool.h>
+#include <stdint.h>  /* uintXX_t */
+
+#define LAPIC_ID(vcpu_id)   ((vcpu_id) * 2)
 
 #define ACPI_HAS_COM1              (1<<0)
 #define ACPI_HAS_COM2              (1<<1)
tools/libxl/libxl_x86_acpi.c +1 -1
index bbe9219..0b7507d 100644
@@ -87,7 +87,7 @@ static void acpi_mem_free(struct acpi_ctxt *ctxt,
 
 static uint32_t acpi_lapic_id(unsigned cpu)
 {
-    return cpu * 2;
+    return LAPIC_ID(cpu);
 }
 
 static int init_acpi_config(libxl__gc *gc, 
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v4 3/8
#21 lore raw

Re: [RFC Patch v4 3/8] xl/acpi: unify the computation of lapic_id

Quoted 8 lines · Chao Gao

There were two places where the lapic_id is computed, one in hvmloader and one in libacpi. Unify them by defining LAPIC_ID in a header file and incluing it in both places.

To address compilation issue and make libacpi.h self-contained, include stdint.h in libacpi.h.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#22 lore raw

RFC PATCH v4 4/8 hvmloader: boot cpu through broadcast

In reply to Chao Gao

Intel SDM Extended XAPIC (X2APIC) -> "Initialization by System Software" has the following description:

"The ACPI interfaces for the x2APIC are described in Section 5.2, “ACPI System Description Tables,” of the Advanced Configuration and Power Interface Specification, Revision 4.0a (http://www.acpi.info/spec.htm). The default behavior for BIOS is to pass the control to the operating system with the local x2APICs in xAPIC mode if all APIC IDs reported by CPUID.0BH:EDX are less than 255, and in x2APIC mode if there are any logical processor reporting an APIC ID of 255 or greater."

In this patch, hvmloader enables x2apic mode for all vcpus if there are cpus with APIC ID > 255. To wake up processors whose APIC ID is greater than 255, the SIPI is broadcasted to all APs. It is the way how Seabios wakes up APs. APs may compete for the stack, thus a lock is introduced to protect the stack.

---
v4:
- new

---
 tools/firmware/hvmloader/apic_regs.h |  4 +++
 tools/firmware/hvmloader/smp.c       | 64 ++++++++++++++++++++++++++++++++----
 2 files changed, 61 insertions(+), 7 deletions(-)
tools/firmware/hvmloader/apic_regs.h +4 -0
index f737b47..bc39ecd 100644
@@ -105,6 +105,10 @@
 #define     APIC_TDR_DIV_64          0x9
 #define     APIC_TDR_DIV_128         0xA
 
+#define MSR_IA32_APICBASE            0x1b
+#define MSR_IA32_APICBASE_EXTD       (1<<10)
+#define MSR_IA32_APICBASE_MSR        0x800
+
 #endif
 
 /*
tools/firmware/hvmloader/smp.c +57 -7

107 lines not on this page · raw message

Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#23 lore raw

Re: [RFC Patch v4 4/8] hvmloader: boot cpu through broadcast

Quoted 56 lines · Chao Gao

Intel SDM Extended XAPIC (X2APIC) -> "Initialization by System Software" has the following description:

"The ACPI interfaces for the x2APIC are described in Section 5.2, “ACPI System Description Tables,” of the Advanced Configuration and Power Interface Specification, Revision 4.0a (http://www.acpi.info/spec.htm). The default behavior for BIOS is to pass the control to the operating system with the local x2APICs in xAPIC mode if all APIC IDs reported by CPUID.0BH:EDX are less than 255, and in x2APIC mode if there are any logical processor reporting an APIC ID of 255 or greater."

In this patch, hvmloader enables x2apic mode for all vcpus if there are cpus with APIC ID > 255. To wake up processors whose APIC ID is greater than 255, the SIPI is broadcasted to all APs. It is the way how Seabios wakes up APs. APs may compete for the stack, thus a lock is introduced to protect the stack.

---
v4:
- new

---
 tools/firmware/hvmloader/apic_regs.h |  4 +++
 tools/firmware/hvmloader/smp.c       | 64 ++++++++++++++++++++++++++++++++----
 2 files changed, 61 insertions(+), 7 deletions(-)
tools/firmware/hvmloader/apic_regs.h +4 -0
index f737b47..bc39ecd 100644
@@ -105,6 +105,10 @@
 #define     APIC_TDR_DIV_64          0x9
 #define     APIC_TDR_DIV_128         0xA
 
+#define MSR_IA32_APICBASE            0x1b
+#define MSR_IA32_APICBASE_EXTD       (1<<10)
+#define MSR_IA32_APICBASE_MSR        0x800
+
 #endif
 
 /*
tools/firmware/hvmloader/smp.c +3 -1
index 082b17f..e3dade4 100644
@@ -26,7 +26,9 @@
 #define AP_BOOT_EIP 0x1000
 extern char ap_boot_start[], ap_boot_end[];
 
-static int ap_callin, ap_cpuid;
+static int ap_callin;
+static int enable_x2apic;
+static bool lock = 1;
 
 asm (
     "    .text                       \n"

tools/firmware/hvmloader/smp.c asm ( · line 52

Quoted 5 lines
tools/firmware/hvmloader/smp.c +1 -1
@@ -47,7 +49,15 @@ asm (
     "    mov   %eax,%ds              \n"
     "    mov   %eax,%es              \n"
     "    mov   %eax,%ss              \n"
-    "    movl  $stack_top,%esp       \n"
+    "3:  movb  $1, %bl               \n"

I would rather you label this 1 and increment the number as you go.

tools/firmware/hvmloader/smp.c asm ( · line 53

Quoted 1 line
tools/firmware/hvmloader/smp.c +1 -0
+    "    mov   $lock,%edx            \n"

Not really an expert in x86 asm -- shouldn't this be lea instead?

tools/firmware/hvmloader/smp.c asm ( · line 55

Quoted 2 lines
tools/firmware/hvmloader/smp.c +2 -0
+    "    movzbl %bl,%eax             \n"
+    "    xchg  %al, (%edx)           \n"

Why not just use %bl directly?

Quoted 12 lines
tools/firmware/hvmloader/smp.c +5 -0
+    "    test  %al,%al               \n"
+    "    je    2f                    \n"
+    "    pause                       \n"
+    "    jmp   3b                    \n"
+    "2:  movl  $stack_top,%esp       \n"
     "    movl  %esp,%ebp             \n"
     "    call  ap_start              \n"
     "1:  hlt                         \n"
@@ -68,14 +78,34 @@ asm (
     "    .text                       \n"
     );
 

[...]

Quoted 20 lines
tools/firmware/hvmloader/smp.c +15 -0
+static void boot_cpu_broadcast_x2apic(unsigned int nr_cpus)
+{
+    wrmsr(MSR_IA32_APICBASE_MSR + (APIC_ICR >> 4),
+          APIC_DEST_ALLBUT | APIC_DM_INIT);
+
+    wrmsr(MSR_IA32_APICBASE_MSR + (APIC_ICR >> 4),
+          APIC_DEST_ALLBUT | APIC_DM_STARTUP | (AP_BOOT_EIP >> 12));
+
+    while ( ap_callin != nr_cpus )
+        cpu_relax();
+
+    wrmsr(MSR_IA32_APICBASE_MSR + (APIC_ICR >> 4),
+          APIC_DEST_ALLBUT | APIC_DM_INIT);
+}
+
 void smp_initialise(void)
 {
     unsigned int i, nr_cpus = hvm_info->nr_vcpus;

tools/firmware/hvmloader/smp.c void smp_initialise(void) · line 176

Quoted 10 lines
tools/firmware/hvmloader/smp.c +4 -2
@@ -125,9 +169,15 @@ void smp_initialise(void)
     memcpy((void *)AP_BOOT_EIP, ap_boot_start, ap_boot_end - ap_boot_start);
 
     printf("Multiprocessor initialisation:\n");
+    if ( nr_cpus > MADT_MAX_LOCAL_APIC )
+        enable_x2apic = 1;
+
     ap_start();
-    for ( i = 1; i < nr_cpus; i++ )
-        boot_cpu(i);
+    if ( nr_cpus > MADT_MAX_LOCAL_APIC )

Use enable_x2apic here instead.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#24 lore raw

Re: [RFC Patch v4 4/8] hvmloader: boot cpu through broadcast

Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 22.02.18 at 19:44, <[email protected]> wrote:
Quoted 1 line · Chao Gao

+ " mov $lock,%edx \n"

Not really an expert in x86 asm -- shouldn't this be lea instead?

No, when MOV can be used it's preferable as having a 1 byte shorter encoding. There are a few cases where MOV may not be appropriate, but I don't think the one here is.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#25 lore raw

Re: [RFC Patch v4 4/8] hvmloader: boot cpu through broadcast

In reply to Chao Gao
Quoted 11 lines · Chao Gao

Intel SDM Extended XAPIC (X2APIC) -> "Initialization by System Software" has the following description:

"The ACPI interfaces for the x2APIC are described in Section 5.2, “ACPI System Description Tables,” of the Advanced Configuration and Power Interface Specification, Revision 4.0a (http://www.acpi.info/spec.htm). The default behavior for BIOS is to pass the control to the operating system with the local x2APICs in xAPIC mode if all APIC IDs reported by CPUID.0BH:EDX are less than 255, and in x2APIC mode if there are any logical processor reporting an APIC ID of 255 or greater."

Quoted 4 lines

In this patch, hvmloader enables x2apic mode for all vcpus if there are cpus with APIC ID > 255. To wake up processors whose APIC ID is greater than 255, the SIPI is broadcasted to all APs. It is the way how Seabios wakes up APs. APs may compete for the stack, thus a lock is introduced to protect the stack.

Hm, how are we going to deal with this on PVH? hvmloader doesn't run for PVH guests, hence it seems like switching to x2APIC mode should be done somewhere else that shared between HVM and PVH.

Maybe the hypercall that sets the number of vCPUs should change the APIC mode?

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#26 lore raw

Re: [RFC Patch v4 4/8] hvmloader: boot cpu through broadcast

Quoted 17 lines · Roger Pau Monné
Quoted 11 lines · Chao Gao

Intel SDM Extended XAPIC (X2APIC) -> "Initialization by System Software" has the following description:

"The ACPI interfaces for the x2APIC are described in Section 5.2, “ACPI System Description Tables,” of the Advanced Configuration and Power Interface Specification, Revision 4.0a (http://www.acpi.info/spec.htm). The default behavior for BIOS is to pass the control to the operating system with the local x2APICs in xAPIC mode if all APIC IDs reported by CPUID.0BH:EDX are less than 255, and in x2APIC mode if there are any logical processor reporting an APIC ID of 255 or greater."

Quoted 4 lines

In this patch, hvmloader enables x2apic mode for all vcpus if there are cpus with APIC ID > 255. To wake up processors whose APIC ID is greater than 255, the SIPI is broadcasted to all APs. It is the way how Seabios wakes up APs. APs may compete for the stack, thus a lock is introduced to protect the stack.

Quoted 6 lines

Hm, how are we going to deal with this on PVH? hvmloader doesn't run for PVH guests, hence it seems like switching to x2APIC mode should be done somewhere else that shared between HVM and PVH.

Maybe the hypercall that sets the number of vCPUs should change the APIC mode?

Yes. A flag can be passed when setting the maximum number of vCPUs. Xen will switch all local APICs to x2APIC mode or xAPIC mode according to the flag.

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#27 lore raw

Re: [RFC Patch v4 4/8] hvmloader: boot cpu through broadcast

Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 24.02.18 at 06:49, <[email protected]> wrote:
Quoted 21 lines · Roger Pau Monné
Quoted 11 lines · Chao Gao

Intel SDM Extended XAPIC (X2APIC) -> "Initialization by System Software" has the following description:

"The ACPI interfaces for the x2APIC are described in Section 5.2, “ACPI System Description Tables,” of the Advanced Configuration and Power Interface Specification, Revision 4.0a (http://www.acpi.info/spec.htm). The default behavior for BIOS is to pass the control to the operating system with the local x2APICs in xAPIC mode if all APIC IDs reported by CPUID.0BH:EDX are less than 255, and in x2APIC mode if there are any logical processor reporting an APIC ID of 255 or greater."

Quoted 4 lines

In this patch, hvmloader enables x2apic mode for all vcpus if there are cpus with APIC ID > 255. To wake up processors whose APIC ID is greater than 255, the SIPI is broadcasted to all APs. It is the way how Seabios wakes up APs. APs may compete for the stack, thus a lock is introduced to protect the stack.

Hm, how are we going to deal with this on PVH? hvmloader doesn't run for PVH guests, hence it seems like switching to x2APIC mode should be done somewhere else that shared between HVM and PVH.

Quoted 6 lines
Quoted 2 lines

Maybe the hypercall that sets the number of vCPUs should change the APIC mode?

Yes. A flag can be passed when setting the maximum number of vCPUs. Xen will switch all local APICs to x2APIC mode or xAPIC mode according to the flag.

A flag? Where? Why isn't 256+ vCPU-s on its own sufficient to tell that the mode needs to be switched?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#28 lore raw

Re: [RFC Patch v4 4/8] hvmloader: boot cpu through broadcast

Quoted 26 lines · Jan Beulich
Quoted 26 lines
Quoted 1 line
Quoted 1 line · On 24.02.18 at 06:49, <[email protected]> wrote:
Quoted 23 lines · Roger Pau Monné
Quoted 11 lines · Chao Gao

Intel SDM Extended XAPIC (X2APIC) -> "Initialization by System Software" has the following description:

"The ACPI interfaces for the x2APIC are described in Section 5.2, “ACPI System Description Tables,” of the Advanced Configuration and Power Interface Specification, Revision 4.0a (http://www.acpi.info/spec.htm). The default behavior for BIOS is to pass the control to the operating system with the local x2APICs in xAPIC mode if all APIC IDs reported by CPUID.0BH:EDX are less than 255, and in x2APIC mode if there are any logical processor reporting an APIC ID of 255 or greater."

Quoted 4 lines

In this patch, hvmloader enables x2apic mode for all vcpus if there are cpus with APIC ID > 255. To wake up processors whose APIC ID is greater than 255, the SIPI is broadcasted to all APs. It is the way how Seabios wakes up APs. APs may compete for the stack, thus a lock is introduced to protect the stack.

Hm, how are we going to deal with this on PVH? hvmloader doesn't run for PVH guests, hence it seems like switching to x2APIC mode should be done somewhere else that shared between HVM and PVH.

Maybe the hypercall that sets the number of vCPUs should change the APIC mode?

Quoted 6 lines
Quoted 3 lines

Yes. A flag can be passed when setting the maximum number of vCPUs. Xen will switch all local APICs to x2APIC mode or xAPIC mode according to the flag.

A flag? Where? Why isn't 257+ vCPU-s on its own sufficient to tell that the mode needs to be switched?

In struct xen_domctl_max_vcpus, a flag, like SWITCH_TO_X2APIC_MODE, can be used to instruct Xen to initialize vlapic and do this switch.

Yes, it is another option: Xen can do this switch when need. This solution leads to smaller code change compared with introducing a new flag when setting the maximum number of vCPUs.

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#29 lore raw

Re: [RFC Patch v4 4/8] hvmloader: boot cpu through broadcast

Quoted 34 lines · Chao Gao
Quoted 26 lines · Jan Beulich
Quoted 26 lines
Quoted 1 line
Quoted 1 line · On 24.02.18 at 06:49, <[email protected]> wrote:
Quoted 23 lines · Roger Pau Monné
Quoted 11 lines · Chao Gao

Intel SDM Extended XAPIC (X2APIC) -> "Initialization by System Software" has the following description:

"The ACPI interfaces for the x2APIC are described in Section 5.2, “ACPI System Description Tables,” of the Advanced Configuration and Power Interface Specification, Revision 4.0a (http://www.acpi.info/spec.htm). The default behavior for BIOS is to pass the control to the operating system with the local x2APICs in xAPIC mode if all APIC IDs reported by CPUID.0BH:EDX are less than 255, and in x2APIC mode if there are any logical processor reporting an APIC ID of 255 or greater."

Quoted 4 lines

In this patch, hvmloader enables x2apic mode for all vcpus if there are cpus with APIC ID > 255. To wake up processors whose APIC ID is greater than 255, the SIPI is broadcasted to all APs. It is the way how Seabios wakes up APs. APs may compete for the stack, thus a lock is introduced to protect the stack.

Hm, how are we going to deal with this on PVH? hvmloader doesn't run for PVH guests, hence it seems like switching to x2APIC mode should be done somewhere else that shared between HVM and PVH.

Maybe the hypercall that sets the number of vCPUs should change the APIC mode?

Quoted 6 lines
Quoted 3 lines

Yes. A flag can be passed when setting the maximum number of vCPUs. Xen will switch all local APICs to x2APIC mode or xAPIC mode according to the flag.

A flag? Where? Why isn't 257+ vCPU-s on its own sufficient to tell that the mode needs to be switched?

Quoted 6 lines

In struct xen_domctl_max_vcpus, a flag, like SWITCH_TO_X2APIC_MODE, can be used to instruct Xen to initialize vlapic and do this switch.

Yes, it is another option: Xen can do this switch when need. This solution leads to smaller code change compared with introducing a new flag when setting the maximum number of vCPUs.

Since APIC ID is currently hardcoded in guest_cpuid as vcpu_id * 2, IMO Xen should switch to x2APIC mode when it detects that vCPUs > 128, like Jan has suggest. Then you won't need to modify hvmloader at all, and the same would work for PVH I assume?

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#30 lore raw

Re: [RFC Patch v4 4/8] hvmloader: boot cpu through broadcast

In reply to Chao Gao
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 06.12.17 at 08:50, <[email protected]> wrote:

Intel SDM Extended XAPIC (X2APIC) -> "Initialization by System Software" has the following description:

"The ACPI interfaces for the x2APIC are described in Section 5.2, “ACPI System Description Tables,” of the Advanced Configuration and Power Interface Specification, Revision 4.0a (http://www.acpi.info/spec.htm). The default behavior for BIOS is to pass the control to the operating system with the local x2APICs in xAPIC mode if all APIC IDs reported by CPUID.0BH:EDX are less than 255, and in x2APIC mode if there are any logical processor reporting an APIC ID of 255 or greater."

With this you mean ...

Quoted 2 lines

In this patch, hvmloader enables x2apic mode for all vcpus if there are cpus with APIC ID > 255. To wake up processors whose APIC ID is greater than 255,

">= 255" and "greater than 254" here respectively. Please be precise.

Quoted 23 lines

the SIPI is broadcasted to all APs. It is the way how Seabios wakes up APs. APs may compete for the stack, thus a lock is introduced to protect the stack.

tools/firmware/hvmloader/smp.c +3 -1
@@ -26,7 +26,9 @@
 #define AP_BOOT_EIP 0x1000
 extern char ap_boot_start[], ap_boot_end[];
 
-static int ap_callin, ap_cpuid;
+static int ap_callin;
+static int enable_x2apic;
+static bool lock = 1;
 
 asm (
     "    .text                       \n"
@@ -47,7 +49,15 @@ asm (
     "    mov   %eax,%ds              \n"
     "    mov   %eax,%es              \n"
     "    mov   %eax,%ss              \n"

tools/firmware/hvmloader/smp.c asm ( · line 60

Quoted 10 lines
tools/firmware/hvmloader/smp.c +9 -1
-    "    movl  $stack_top,%esp       \n"
+    "3:  movb  $1, %bl               \n"
+    "    mov   $lock,%edx            \n"
+    "    movzbl %bl,%eax             \n"
+    "    xchg  %al, (%edx)           \n"
+    "    test  %al,%al               \n"
+    "    je    2f                    \n"
+    "    pause                       \n"
+    "    jmp   3b                    \n"
+    "2:  movl  $stack_top,%esp       \n"

Please be consistent with suffixes: Either add them only when really needed (preferred) or add them uniformly everywhere (when permitted of course). I also don't understand why you need to use %bl here at all.

tools/firmware/hvmloader/smp.c asm ( · line 81

Quoted 5 lines
tools/firmware/hvmloader/smp.c +1 -0
@@ -68,14 +78,34 @@ asm (
     "    .text                       \n"
     );
 
+unsigned int ap_cpuid(void)

static

tools/firmware/hvmloader/smp.c asm ( · line 90

Quoted 9 lines
tools/firmware/hvmloader/smp.c +9 -0
+{
+    if ( !(rdmsr(MSR_IA32_APICBASE) & MSR_IA32_APICBASE_EXTD) )
+    {
+        uint32_t eax, ebx, ecx, edx;
+
+        cpuid(1, &eax, &ebx, &ecx, &edx);
+        return ebx >> 24;
+    }
+    else

pointless "else"

Quoted 11 lines
tools/firmware/hvmloader/smp.c +4 -1
+        return rdmsr(MSR_IA32_APICBASE_MSR + (APIC_ID >> 4));
+}
+
 void ap_start(void); /* non-static avoids unused-function compiler warning */
 /*static*/ void ap_start(void)
 {
-    printf(" - CPU%d ... ", ap_cpuid);
+    printf(" - CPU%d ... ", ap_cpuid());
     cacheattr_init();
     printf("done.\n");
     wmb();

tools/firmware/hvmloader/smp.c asm ( · line 109

Quoted 10 lines
tools/firmware/hvmloader/smp.c +8 -1
-    ap_callin = 1;
+    ap_callin++;
+
+    if ( enable_x2apic )
+        wrmsr(MSR_IA32_APICBASE, rdmsr(MSR_IA32_APICBASE) |
+                                 MSR_IA32_APICBASE_EXTD);
+
+    /* Release the lock */
+    asm volatile ( "xchgb %1, %b0" : : "m" (lock), "r" (0) : "memory" );
 }

How can you release the lock here - you've not switched off the stack, and you're about to actually use it (for returning from the function)?

tools/firmware/hvmloader/smp.c void smp_initialise(void) · line 176

Quoted 11 lines
tools/firmware/hvmloader/smp.c +4 -2
@@ -125,9 +169,15 @@ void smp_initialise(void)
     memcpy((void *)AP_BOOT_EIP, ap_boot_start, ap_boot_end - ap_boot_start);
 
     printf("Multiprocessor initialisation:\n");
+    if ( nr_cpus > MADT_MAX_LOCAL_APIC )
+        enable_x2apic = 1;
+
     ap_start();
-    for ( i = 1; i < nr_cpus; i++ )
-        boot_cpu(i);
+    if ( nr_cpus > MADT_MAX_LOCAL_APIC )

Where does MADT_MAX_LOCAL_APIC come from? I can't find it anywhere, and hence can't judge (along the lines of my remark on the description) whether this is a correct comparison.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#31 lore raw

Re: [RFC Patch v4 4/8] hvmloader: boot cpu through broadcast

Quoted 12 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 06.12.17 at 08:50, <[email protected]> wrote:

Intel SDM Extended XAPIC (X2APIC) -> "Initialization by System Software" has the following description:

"The ACPI interfaces for the x2APIC are described in Section 5.2, “ACPI System Description Tables,” of the Advanced Configuration and Power Interface Specification, Revision 4.0a (http://www.acpi.info/spec.htm). The default behavior for BIOS is to pass the control to the operating system with the local x2APICs in xAPIC mode if all APIC IDs reported by CPUID.0BH:EDX are less than 255, and in x2APIC mode if there are any logical processor reporting an APIC ID of 255 or greater."

Quoted 6 lines

With this you mean ...

Quoted 2 lines

In this patch, hvmloader enables x2apic mode for all vcpus if there are cpus with APIC ID > 255. To wake up processors whose APIC ID is greater than 255,

">= 255" and "greater than 254" here respectively. Please be precise.

Will do.

Quoted 30 lines
Quoted 30 lines

the SIPI is broadcasted to all APs. It is the way how Seabios wakes up APs. APs may compete for the stack, thus a lock is introduced to protect the stack.

tools/firmware/hvmloader/smp.c +8 -2
@@ -26,7 +26,9 @@
 #define AP_BOOT_EIP 0x1000
 extern char ap_boot_start[], ap_boot_end[];
 
-static int ap_callin, ap_cpuid;
+static int ap_callin;
+static int enable_x2apic;
+static bool lock = 1;
 
 asm (
     "    .text                       \n"
@@ -47,7 +49,15 @@ asm (
     "    mov   %eax,%ds              \n"
     "    mov   %eax,%es              \n"
     "    mov   %eax,%ss              \n"
-    "    movl  $stack_top,%esp       \n"
+    "3:  movb  $1, %bl               \n"
+    "    mov   $lock,%edx            \n"
+    "    movzbl %bl,%eax             \n"
+    "    xchg  %al, (%edx)           \n"
+    "    test  %al,%al               \n"
Quoted 8 lines

tools/firmware/hvmloader/smp.c asm ( · line 60

Quoted 4 lines
tools/firmware/hvmloader/smp.c +4 -0
+    "    je    2f                    \n"
+    "    pause                       \n"
+    "    jmp   3b                    \n"
+    "2:  movl  $stack_top,%esp       \n"

Please be consistent with suffixes: Either add them only when really needed (preferred) or add them uniformly everywhere (when permitted of course). I also don't understand why you need to use %bl here at all.

will remove %bl stuff.

Quoted 37 lines

tools/firmware/hvmloader/smp.c asm ( · line 81

Quoted 6 lines
tools/firmware/hvmloader/smp.c +1 -0
@@ -68,14 +78,34 @@ asm (
     "    .text                       \n"
     );
 
+unsigned int ap_cpuid(void)

static

tools/firmware/hvmloader/smp.c asm ( · line 90

Quoted 9 lines
tools/firmware/hvmloader/smp.c +9 -0
+{
+    if ( !(rdmsr(MSR_IA32_APICBASE) & MSR_IA32_APICBASE_EXTD) )
+    {
+        uint32_t eax, ebx, ecx, edx;
+
+        cpuid(1, &eax, &ebx, &ecx, &edx);
+        return ebx >> 24;
+    }
+    else

pointless "else"

Quoted 16 lines
tools/firmware/hvmloader/smp.c +8 -2
+        return rdmsr(MSR_IA32_APICBASE_MSR + (APIC_ID >> 4));
+}
+
 void ap_start(void); /* non-static avoids unused-function compiler warning */
 /*static*/ void ap_start(void)
 {
-    printf(" - CPU%d ... ", ap_cpuid);
+    printf(" - CPU%d ... ", ap_cpuid());
     cacheattr_init();
     printf("done.\n");
     wmb();
-    ap_callin = 1;
+    ap_callin++;
+
+    if ( enable_x2apic )
+        wrmsr(MSR_IA32_APICBASE, rdmsr(MSR_IA32_APICBASE) |
Quoted 8 lines

tools/firmware/hvmloader/smp.c asm ( · line 109

Quoted 5 lines
tools/firmware/hvmloader/smp.c +4 -0
+                                 MSR_IA32_APICBASE_EXTD);
+
+    /* Release the lock */
+    asm volatile ( "xchgb %1, %b0" : : "m" (lock), "r" (0) : "memory" );
 }

How can you release the lock here - you've not switched off the stack, and you're about to actually use it (for returning from the function)?

    "2:  movl  $stack_top,%esp       \n"
    "    movl  %esp,%ebp             \n"
    "    call  ap_start              \n"
    "1:  hlt                         \n"
    "    jmp  1b                     \n"

Yes. I think it would be right to release the lock following the "call ap_start" here.

Quoted 4 lines
Quoted 4 lines
tools/firmware/hvmloader/smp.c +0 -0
@@ -125,9 +169,15 @@ void smp_initialise(void)
     memcpy((void *)AP_BOOT_EIP, ap_boot_start, ap_boot_end - ap_boot_start);
 
Quoted 12 lines

tools/firmware/hvmloader/smp.c void smp_initialise(void) · line 176

Quoted 8 lines
tools/firmware/hvmloader/smp.c +4 -2
     printf("Multiprocessor initialisation:\n");
+    if ( nr_cpus > MADT_MAX_LOCAL_APIC )
+        enable_x2apic = 1;
+
     ap_start();
-    for ( i = 1; i < nr_cpus; i++ )
-        boot_cpu(i);
+    if ( nr_cpus > MADT_MAX_LOCAL_APIC )

Where does MADT_MAX_LOCAL_APIC come from? I can't find it anywhere, and hence can't judge (along the lines of my remark on the description) whether this is a correct comparison.

It is defined in patch 5/8. I know it is a mistake.

With regard to this point, I only boot up vCPU-s via broadcasting INIT-STARTUP signal when the number of vCPU-s is greater than a given value, otherwise the previous way will be used.

In general, before all APs are up, BSP couldn't know each AP's APIC ID (currently, we know that because APIC ID can be inferred from vcpu_id) and whether there is a vCPU with APIC_ID >= 255. I plan to discard the old way and always use broadcast to boot up APs. And we don't need MADT_MAX_LOCAL_APIC here. Instead, a global variable can be set if any vCPU-s finds its APIC ID is greater than 254. Then all CPUs can switch to x2apic mode if need be. Do you think it is reasonable?

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#32 lore raw

Re: [RFC Patch v4 4/8] hvmloader: boot cpu through broadcast

Quoted 24 lines
Quoted 1 line
Quoted 1 line · On 18.04.18 at 13:20, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 06.12.17 at 08:50, <[email protected]> wrote:

/*static*/ void ap_start(void)
{

tools/firmware/hvmloader/smp.c +5 -2
-    printf(" - CPU%d ... ", ap_cpuid);
+    printf(" - CPU%d ... ", ap_cpuid());
     cacheattr_init();
     printf("done.\n");
     wmb();
-    ap_callin = 1;
+    ap_callin++;
+
+    if ( enable_x2apic )
+        wrmsr(MSR_IA32_APICBASE, rdmsr(MSR_IA32_APICBASE) |
Quoted 8 lines

tools/firmware/hvmloader/smp.c asm ( · line 109

Quoted 5 lines
tools/firmware/hvmloader/smp.c +4 -0
+                                 MSR_IA32_APICBASE_EXTD);
+
+    /* Release the lock */
+    asm volatile ( "xchgb %1, %b0" : : "m" (lock), "r" (0) : "memory" );
 }

How can you release the lock here - you've not switched off the stack, and you're about to actually use it (for returning from the function)?

Quoted 8 lines
    "2:  movl  $stack_top,%esp       \n"
    "    movl  %esp,%ebp             \n"
    "    call  ap_start              \n"
    "1:  hlt                         \n"
    "    jmp  1b                     \n"

Yes. I think it would be right to release the lock following the "call ap_start" here.

Strictly speaking even that's too early, as an NMI might arrive at the HLT (before actually executing it). Otoh that's going to be deadly anyway, so perhaps with a suitable comment that might be accptable.

Quoted 23 lines
Quoted 14 lines

tools/firmware/hvmloader/smp.c void smp_initialise(void) · line 176

Quoted 11 lines
tools/firmware/hvmloader/smp.c +4 -2
@@ -125,9 +169,15 @@ void smp_initialise(void)
     memcpy((void *)AP_BOOT_EIP, ap_boot_start, ap_boot_end - ap_boot_start);
 
     printf("Multiprocessor initialisation:\n");
+    if ( nr_cpus > MADT_MAX_LOCAL_APIC )
+        enable_x2apic = 1;
+
     ap_start();
-    for ( i = 1; i < nr_cpus; i++ )
-        boot_cpu(i);
+    if ( nr_cpus > MADT_MAX_LOCAL_APIC )

Where does MADT_MAX_LOCAL_APIC come from? I can't find it anywhere, and hence can't judge (along the lines of my remark on the description) whether

this

Quoted 1 line

is a correct comparison.

It is defined in patch 5/8. I know it is a mistake.

With regard to this point, I only boot up vCPU-s via broadcasting INIT-STARTUP signal when the number of vCPU-s is greater than a given value, otherwise the previous way will be used.

Quoted 7 lines

In general, before all APs are up, BSP couldn't know each AP's APIC ID (currently, we know that because APIC ID can be inferred from vcpu_id) and whether there is a vCPU with APIC_ID >= 255. I plan to discard the old way and always use broadcast to boot up APs. And we don't need MADT_MAX_LOCAL_APIC here. Instead, a global variable can be set if any vCPU-s finds its APIC ID is greater than 254. Then all CPUs can switch to x2apic mode if need be. Do you think it is reasonable?

At the first glance - why not.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#33 lore raw

RFC PATCH v4 5/8 Tool/ACPI: DSDT extension to support more vcpus

In reply to Chao Gao

From: Lan Tianyu <[email protected]>

This patch is to change DSDT table for processor object to support 4096 vcpus accroding to ACPI spec 8.4 Declaring Processors.

This patch contains the two changes:
1. Declare processors whose local APIC is declared as a x2apic via the ASL Device statement
2. Bump up the size of CPU ID used to compose processor name to 12 bits. Thus the processors number limitation imposed here is 4096.

---
 tools/libacpi/libacpi.h |  6 ++++++
 tools/libacpi/mk_dsdt.c | 40 +++++++++++++++++++++++++++++++++-------
 2 files changed, 39 insertions(+), 7 deletions(-)
tools/libacpi/libacpi.h +6 -0
index b89fdb5..7db4d92 100644
@@ -24,6 +24,12 @@
 #include <stdint.h>  /* uintXX_t */
 
 #define LAPIC_ID(vcpu_id)   ((vcpu_id) * 2)
+/*
+ * For x86, APIC ID is twice the vcpu id. In MADT, only APICs with
+ * APIC ID <= 254 can be declared as local APIC. Otherwise, APICs with
+ * APIC ID > 254 should be declared as local x2APIC.
+ */
+#define MADT_MAX_LOCAL_APIC 128U
 
 #define ACPI_HAS_COM1              (1<<0)
 #define ACPI_HAS_COM2              (1<<1)
tools/libacpi/mk_dsdt.c +33 -7
index 2daf32c..27e5d1b 100644
@@ -20,10 +20,13 @@
 #if defined(CONFIG_X86)
 #include <xen/arch-x86/xen.h>
 #include <xen/hvm/hvm_info_table.h>
+#include "libacpi.h"
 #elif defined(CONFIG_ARM_64)
 #include <xen/arch-arm.h>
 #endif
 
+#define CPU_NAME_FMT      "P%.03X"
+
 static unsigned int indent_level;
 static bool debug = false;
 
@@ -194,12 +197,35 @@ int main(int argc, char **argv)
 #endif
 
     /* Define processor objects and control methods. */
-    for ( cpu = 0; cpu < max_cpus; cpu++)
+    for ( cpu = 0; cpu < max_cpus; cpu++ )
     {
-        push_block("Processor", "PR%02X, %d, 0x0000b010, 0x06", cpu, cpu);
 
-        stmt("Name", "_HID, \"ACPI0007\"");
+#ifdef CONFIG_X86
+        /*
+         * According to the Processor Local x2APIC Structure of ACPI SPEC
+         * Revision 5.0, "OSPM associates the X2APIC Structure with a
+         * processor object declared in the namespace using the Device
+         * statement, when the _UID child object of the processor device
+         * evaluates to a numeric value, by matching the numeric value with
+         * this field".
+         *
+         * Anyhow, a numeric value is assigned to _UID object here. Thus,
+         * for each x2apic structure in MADT, instead of declaring the
+         * corresponding processor via the ASL Processor statement, declare
+         * it via the ASL Device statement.
+         *
+         * Note that If CPU ID is equal or greater than MADT_MAX_LOCAL_APIC,
+         * the lapic of this CPU should be enumerated as a local x2apic
+         * structure.
+         */
+        if ( cpu >= MADT_MAX_LOCAL_APIC )
+            push_block("Device", CPU_NAME_FMT, cpu);
+        else
+#endif
+            push_block("Processor", CPU_NAME_FMT ", %d,0x0000b010, 0x06",
+                       cpu, cpu);
 
+        stmt("Name", "_HID, \"ACPI0007\"");
         stmt("Name", "_UID, %d", cpu);
 #ifdef CONFIG_ARM_64
         pop_block();
@@ -268,15 +294,15 @@ int main(int argc, char **argv)
         /* Extract current CPU's status: 0=offline; 1=online. */
         stmt("And", "Local1, 1, Local2");
         /* Check if status is up-to-date in the relevant MADT LAPIC entry... */
-        push_block("If", "LNotEqual(Local2, \\_SB.PR%02X.FLG)", cpu);
+        push_block("If", "LNotEqual(Local2, \\_SB." CPU_NAME_FMT ".FLG)", cpu);
         /* ...If not, update it and the MADT checksum, and notify OSPM. */
-        stmt("Store", "Local2, \\_SB.PR%02X.FLG", cpu);
+        stmt("Store", "Local2, \\_SB." CPU_NAME_FMT ".FLG", cpu);
         push_block("If", "LEqual(Local2, 1)");
-        stmt("Notify", "PR%02X, 1", cpu); /* Notify: Device Check */
+        stmt("Notify", CPU_NAME_FMT ", 1", cpu); /* Notify: Device Check */
         stmt("Subtract", "\\_SB.MSU, 1, \\_SB.MSU"); /* Adjust MADT csum */
         pop_block();
         push_block("Else", NULL);
-        stmt("Notify", "PR%02X, 3", cpu); /* Notify: Eject Request */
+        stmt("Notify", CPU_NAME_FMT ", 3", cpu); /* Notify: Eject Request */
         stmt("Add", "\\_SB.MSU, 1, \\_SB.MSU"); /* Adjust MADT csum */
         pop_block();
         pop_block();
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
author
#34 lore raw

RFC PATCH v4 6/8 hvmload: Add x2apic entry support in the MADT and SRAT build

In reply to Chao Gao

From: Lan Tianyu <[email protected]>

This patch contains the following changes:
1. add x2apic entry support for ACPI MADT table according to ACPI spec 5.2.12.12 Processor Local x2APIC Structure.
2. add x2apic entry support for ACPI SRAT table according to ACPI spec 5.2.16.3 Processor Local x2APIC Affinity Structure.

---
v4:
- also add x2apic entry in SRAT

---
 tools/libacpi/acpi2_0.h | 25 ++++++++++++++++++++--
 tools/libacpi/build.c   | 57 +++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 69 insertions(+), 13 deletions(-)
tools/libacpi/acpi2_0.h +23 -2
index 6081417..7eb983d 100644
@@ -322,6 +322,7 @@ struct acpi_20_waet {
 #define ACPI_IO_SAPIC                       0x06
 #define ACPI_PROCESSOR_LOCAL_SAPIC          0x07
 #define ACPI_PLATFORM_INTERRUPT_SOURCES     0x08
+#define ACPI_PROCESSOR_LOCAL_X2APIC         0x09
 
 /*
  * APIC Structure Definitions.
@@ -338,6 +339,15 @@ struct acpi_20_madt_lapic {
     uint32_t flags;
 };
 
+struct acpi_20_madt_x2apic {
+    uint8_t  type;
+    uint8_t  length;
+    uint16_t reserved;
+    uint32_t x2apic_id;
+    uint32_t flags;
+    uint32_t acpi_processor_uid;
+};
+
 /*
  * Local APIC Flags.  All other bits are reserved and must be 0.
  */
@@ -378,8 +388,9 @@ struct acpi_20_srat {
 /*
  * System Resource Affinity Table structure types.
  */
-#define ACPI_PROCESSOR_AFFINITY 0x0
-#define ACPI_MEMORY_AFFINITY    0x1
+#define ACPI_PROCESSOR_AFFINITY         0x0
+#define ACPI_MEMORY_AFFINITY            0x1
+#define ACPI_PROCESSOR_X2APIC_AFFINITY  0x2
 struct acpi_20_srat_processor {
     uint8_t type;
     uint8_t length;
@@ -391,6 +402,16 @@ struct acpi_20_srat_processor {
     uint32_t reserved;
 };
 
+struct acpi_20_srat_processor_x2apic {
+    uint8_t type;
+    uint8_t length;
+    uint16_t reserved;
+    uint32_t domain;
+    uint32_t x2apic_id;
+    uint32_t flags;
+    uint32_t reserved2[2];
+};
+
 /*
  * Local APIC Affinity Flags.  All other bits are reserved and must be 0.
  */
tools/libacpi/build.c +46 -11

113 lines not on this page · raw message

Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#35 lore raw

Re: [RFC Patch v4 6/8] hvmload: Add x2apic entry support in the MADT and SRAT build

tools/libacpi/build.c line 37

Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 06.12.17 at 08:50, <[email protected]> wrote:
tools/libacpi/build.c +5 -0
@@ -30,6 +30,11 @@
 
 #define align16(sz)        (((sz) + 15) & ~15)
 #define fixed_strcpy(d, s) strncpy((d), (s), sizeof(d))
+#define min(X, Y) ({                             \
+            const typeof (X) _x = (X);           \
+            const typeof (Y) _y = (Y);           \
+            (void) (&_x == &_y);                 \
+            (_x < _y) ? _x : _y; })

No new name space violations please: Identifiers starting with a single underscore and a lower case letter are reserved for file scope symbols. Use a trailing underscore instead, for example.

tools/libacpi/build.c static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt, · line 89

Quoted 8 lines
tools/libacpi/build.c +2 -1
@@ -79,16 +84,19 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt,
     struct acpi_20_madt_intsrcovr *intsrcovr;
     struct acpi_20_madt_ioapic    *io_apic;
     struct acpi_20_madt_lapic     *lapic;
+    struct acpi_20_madt_x2apic    *x2apic;
     const struct hvm_info_table   *hvminfo = config->hvminfo;
-    int i, sz;
+    int i, sz, nr_apic;

Apart from your own addition I think both i and sz also want to be unsigned. Please make such corrections when you touch a line anyway.

tools/libacpi/build.c static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt, · line 94

Quoted 4 lines
tools/libacpi/build.c +1 -0
     if ( config->lapic_id == NULL )
         return NULL;
 
+    nr_apic = min(hvminfo->nr_vcpus, MADT_MAX_LOCAL_APIC);

With this the variable name is not well chosen. nr_xapic perhaps?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#36 lore raw

RFC PATCH v4 7/8 x86/hvm: bump the number of pages of shadow memory

In reply to Chao Gao

Each vcpu of hvm guest consumes at least one shadow page. Currently, only 256 (for hap case) pages are pre-allocated as shadow memory at beginning. It would run out if guest has more than 256 vcpus and guest creation fails. Bump the number of shadow pages to 2 * HVM_MAX_VCPUS for hap case and 8 * HVM_MAX_VCPUS for shadow case.

This patch won't lead to more memory consumption for the size of shadow memory will be adjusted via XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION according to the size of guest memory and the number of vcpus.

---
 xen/arch/x86/mm/hap/hap.c       | 2 +-
 xen/arch/x86/mm/shadow/common.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
xen/arch/x86/mm/hap/hap.c +1 -1
index 41deb90..f4cf578 100644
@@ -455,7 +455,7 @@ int hap_enable(struct domain *d, u32 mode)
     if ( old_pages == 0 )
     {
         paging_lock(d);
-        rv = hap_set_allocation(d, 256, NULL);
+        rv = hap_set_allocation(d, 2 * HVM_MAX_VCPUS, NULL);
         if ( rv != 0 )
         {
             hap_set_allocation(d, 0, NULL);
xen/arch/x86/mm/shadow/common.c +1 -1
index 72c674e..5e66603 100644
@@ -3093,7 +3093,7 @@ int shadow_enable(struct domain *d, u32 mode)
     if ( old_pages == 0 )
     {
         paging_lock(d);
-        rv = shadow_set_allocation(d, 1024, NULL); /* Use at least 4MB */
+        rv = shadow_set_allocation(d, 8 * HVM_MAX_VCPUS, NULL);
         if ( rv != 0 )
         {
             shadow_set_allocation(d, 0, NULL);
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v4 7/8
#37 lore raw

Re: [RFC Patch v4 7/8] x86/hvm: bump the number of pages of shadow memory

Quoted 11 lines · Chao Gao

Each vcpu of hvm guest consumes at least one shadow page. Currently, only 256 (for hap case) pages are pre-allocated as shadow memory at beginning. It would run out if guest has more than 256 vcpus and guest creation fails. Bump the number of shadow pages to 2 * HVM_MAX_VCPUS for hap case and 8 * HVM_MAX_VCPUS for shadow case.

This patch won't lead to more memory consumption for the size of shadow memory will be adjusted via XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION according to the size of guest memory and the number of vcpus.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#38 lore raw

Re: [RFC Patch v4 7/8] x86/hvm: bump the number of pages of shadow memory

In reply to Chao Gao
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 06.12.17 at 08:50, <[email protected]> wrote:

Each vcpu of hvm guest consumes at least one shadow page. Currently, only 256 (for hap case) pages are pre-allocated as shadow memory at beginning. It would run out if guest has more than 256 vcpus and guest creation fails. Bump the number of shadow pages to 2 * HVM_MAX_VCPUS for hap case and 8 * HVM_MAX_VCPUS for shadow case.

This patch won't lead to more memory consumption for the size of shadow memory will be adjusted via XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION according to the size of guest memory and the number of vcpus.

I don't understand this: What's the purpose of bumping the values if it won't lead to higher memory consumption? Afaict there's be higher consumption at least transiently. And I don't see why this would need doing independent of the intended vCPU count in the guest. I guess you want to base your series on top on Andrew's max-vCPU-s adjustments (which sadly didn't become ready in time for 4.11).

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#39 lore raw

Re: [RFC Patch v4 7/8] x86/hvm: bump the number of pages of shadow memory

Quoted 11 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 06.12.17 at 08:50, <[email protected]> wrote:

Each vcpu of hvm guest consumes at least one shadow page. Currently, only 256 (for hap case) pages are pre-allocated as shadow memory at beginning. It would run out if guest has more than 256 vcpus and guest creation fails. Bump the number of shadow pages to 2 * HVM_MAX_VCPUS for hap case and 8 * HVM_MAX_VCPUS for shadow case.

This patch won't lead to more memory consumption for the size of shadow memory will be adjusted via XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION according to the size of guest memory and the number of vcpus.

Quoted 5 lines

I don't understand this: What's the purpose of bumping the values if it won't lead to higher memory consumption? Afaict there's be higher consumption at least transiently. And I don't see why this would need doing independent of the intended vCPU count in the guest. I guess you want to base your series on top on Andrew's max-vCPU-s adjustments (which sadly didn't become ready in time for 4.11).

The situation here is some pages are pre-allocated as P2M page for domain initialization. After vCPU creation, the total number of P2M page are adjusted by the domctl interface. Before vCPU creation, this domctl is unusable for the check in paging_domctl():
if ( unlikely(d->vcpu == NULL) || unlikely(d->vcpu[0] == NULL) )

When the number of a guest's vCPU is small, the pre-allocated are enough. But it won't be if the number of vCPU is bigger than 256. Each vCPU will at least use one P2M page when it is created, seeing contruct_vmcs()->hap_update_paging_modes().

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#40 lore raw

Re: [RFC Patch v4 7/8] x86/hvm: bump the number of pages of shadow memory

Quoted 22 lines · Chao Gao
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 06.12.17 at 08:50, <[email protected]> wrote:

Each vcpu of hvm guest consumes at least one shadow page. Currently, only 256 (for hap case) pages are pre-allocated as shadow memory at beginning. It would run out if guest has more than 256 vcpus and guest creation fails. Bump the number of shadow pages to 2 * HVM_MAX_VCPUS for hap case and 8 * HVM_MAX_VCPUS for shadow case.

Quoted 8 lines
Quoted 3 lines

This patch won't lead to more memory consumption for the size of shadow memory will be adjusted via XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION according to the size of guest memory and the number of vcpus.

I don't understand this: What's the purpose of bumping the values if it won't lead to higher memory consumption? Afaict there's be higher consumption at least transiently. And I don't see why this would need doing independent of the intended vCPU count in the guest. I guess you want to base your series on top on Andrew's max-vCPU-s adjustments (which sadly didn't become ready in time for 4.11).

The situation here is some pages are pre-allocated as P2M page for domain initialization. After vCPU creation, the total number of P2M page are adjusted by the domctl interface. Before vCPU creation, this domctl is unusable for the check in paging_domctl():
if ( unlikely(d->vcpu == NULL) || unlikely(d->vcpu[0] == NULL) )

Quoted 4 lines

When the number of a guest's vCPU is small, the pre-allocated are enough. But it won't be if the number of vCPU is bigger than 256. Each vCPU will at least use one P2M page when it is created, seeing contruct_vmcs()->hap_update_paging_modes().

I've also found with XTF tests that the current minimum shadow calculations are insufficient for single-vcpu domains with 128M of ram.

I haven't had time fix the algorithm, and XTF is using "shadow_memory=4" as a bodge workaround.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#41 lore raw

Re: [RFC Patch v4 7/8] x86/hvm: bump the number of pages of shadow memory

In reply to Chao Gao
Quoted 22 lines
Quoted 1 line
Quoted 1 line · On 18.04.18 at 13:39, <[email protected]> wrote:
Quoted 2 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 06.12.17 at 08:50, <[email protected]> wrote:

Each vcpu of hvm guest consumes at least one shadow page. Currently, only

256

Quoted 1 line
Quoted 1 line

(for hap case) pages are pre-allocated as shadow memory at beginning. It

would

Quoted 2 lines
Quoted 2 lines

run out if guest has more than 256 vcpus and guest creation fails. Bump the number of shadow pages to 2 * HVM_MAX_VCPUS for hap case and 8 *

HVM_MAX_VCPUS

Quoted 11 lines
Quoted 5 lines

for shadow case.

This patch won't lead to more memory consumption for the size of shadow memory will be adjusted via XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION according to the size of guest memory and the number of vcpus.

I don't understand this: What's the purpose of bumping the values if it won't lead to higher memory consumption? Afaict there's be higher consumption at least transiently. And I don't see why this would need doing independent of the intended vCPU count in the guest. I guess you want to base your series on top on Andrew's max-vCPU-s adjustments (which sadly didn't become ready in time for 4.11).

Quoted 5 lines

The situation here is some pages are pre-allocated as P2M page for domain initialization. After vCPU creation, the total number of P2M page are adjusted by the domctl interface. Before vCPU creation, this domctl is unusable for the check in paging_domctl():
if ( unlikely(d->vcpu == NULL) || unlikely(d->vcpu[0] == NULL) )

Hence my reference to Andrew's series.

Quoted 4 lines

When the number of a guest's vCPU is small, the pre-allocated are enough. But it won't be if the number of vCPU is bigger than 256. Each vCPU will at least use one P2M page when it is created, seeing contruct_vmcs()->hap_update_paging_modes().

Hmm, that might be a problem perhaps to be addressed in Andrew's series then, as the implication would be that the amount of shadow/p2m memory also needs to be set right by XEN_DOMCTL_createdomain (which iirc the series doesn't do so far).

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#42 lore raw

RFC PATCH v4 8/8 x86/hvm: bump the maximum number of vcpus to 512

In reply to Chao Gao
---
 xen/include/public/hvm/hvm_info_table.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/public/hvm/hvm_info_table.h +1 -1
index 08c252e..6833a4c 100644
@@ -32,7 +32,7 @@
 #define HVM_INFO_PADDR       ((HVM_INFO_PFN << 12) + HVM_INFO_OFFSET)
 
 /* Maximum we can support with current vLAPIC ID mapping. */
-#define HVM_MAX_VCPUS        128
+#define HVM_MAX_VCPUS        512
 
 /*
  * In some cases SMP HVM guests may require knowledge of Xen's idea of vCPU ids
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#43 lore raw

Re: [RFC Patch v4 8/8] x86/hvm: bump the maximum number of vcpus to 512

Quoted 10 lines · Chao Gao
---
 xen/include/public/hvm/hvm_info_table.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/public/hvm/hvm_info_table.h +0 -0
index 08c252e..6833a4c 100644

xen/include/public/hvm/hvm_info_table.h line 35

Quoted 5 lines
xen/include/public/hvm/hvm_info_table.h +1 -1
@@ -32,7 +32,7 @@
 #define HVM_INFO_PADDR       ((HVM_INFO_PFN << 12) + HVM_INFO_OFFSET)
 
 /* Maximum we can support with current vLAPIC ID mapping. */
-#define HVM_MAX_VCPUS        128
+#define HVM_MAX_VCPUS        512

I checked a few places where this is used, bumping the number doesn't seem to be harmful on the surface.

Of course there is the question how many CPUs can upstream support, I think it is still under argument at the moment.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#44 lore raw

Re: [RFC Patch v4 8/8] x86/hvm: bump the maximum number of vcpus to 512

Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 22.02.18 at 19:46, <[email protected]> wrote:

xen/include/public/hvm/hvm_info_table.h line 35

Quoted 8 lines · Chao Gao
xen/include/public/hvm/hvm_info_table.h +1 -1
@@ -32,7 +32,7 @@
 #define HVM_INFO_PADDR       ((HVM_INFO_PFN << 12) + HVM_INFO_OFFSET)
 
 /* Maximum we can support with current vLAPIC ID mapping. */
-#define HVM_MAX_VCPUS        128
+#define HVM_MAX_VCPUS        512

I checked a few places where this is used, bumping the number doesn't seem to be harmful on the surface.

Quoted 2 lines

Of course there is the question how many CPUs can upstream support, I think it is still under argument at the moment.

Leaving the latter aside, it is never okay to simply change a #define in the public interface. See e.g. fb442e2171 ("x86_64: allow more vCPU-s per guest"), where we've already gone a somewhat harsh route by dropping the original #define altogether (thus at least causing build failures for consumers), taking the position that it wasn't correct to expose the value in the first place.

Hence at the very least I can't see how struct hvm_info_table (in the same public header) can be left alone with this change.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#45 lore raw

Re: [RFC Patch v4 8/8] x86/hvm: bump the maximum number of vcpus to 512

Quoted 24 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 22.02.18 at 19:46, <[email protected]> wrote:

xen/include/public/hvm/hvm_info_table.h line 35

Quoted 8 lines · Chao Gao
xen/include/public/hvm/hvm_info_table.h +1 -1
@@ -32,7 +32,7 @@
 #define HVM_INFO_PADDR       ((HVM_INFO_PFN << 12) + HVM_INFO_OFFSET)
 
 /* Maximum we can support with current vLAPIC ID mapping. */
-#define HVM_MAX_VCPUS        128
+#define HVM_MAX_VCPUS        512

I checked a few places where this is used, bumping the number doesn't seem to be harmful on the surface.

Quoted 2 lines

Of course there is the question how many CPUs can upstream support, I think it is still under argument at the moment.

Leaving the latter aside, it is never okay to simply change a #define in the public interface. See e.g. fb442e2171 ("x86_64: allow more vCPU-s per guest"), where we've already gone a somewhat harsh route by dropping the original #define altogether (thus at least causing build failures for consumers), taking the position that it wasn't correct to expose the value in the first place.

Quoted 2 lines

Hence at the very least I can't see how struct hvm_info_table (in the same public header) can be left alone with this change.

AIUI this change has made the structure larger by extending the trailing array. The resulting structure still fits into one page. At least to me the new ABI is still compatible with the old.

The commit you mentioned is different because it completely breaks ABI compatibility.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#46 lore raw

Re: [RFC Patch v4 8/8] x86/hvm: bump the maximum number of vcpus to 512

In reply to Chao Gao
Quoted 10 lines · Chao Gao
---
 xen/include/public/hvm/hvm_info_table.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/public/hvm/hvm_info_table.h +0 -0
index 08c252e..6833a4c 100644

xen/include/public/hvm/hvm_info_table.h line 35

Quoted 5 lines
xen/include/public/hvm/hvm_info_table.h +1 -1
@@ -32,7 +32,7 @@
 #define HVM_INFO_PADDR       ((HVM_INFO_PFN << 12) + HVM_INFO_OFFSET)
 
 /* Maximum we can support with current vLAPIC ID mapping. */
-#define HVM_MAX_VCPUS        128
+#define HVM_MAX_VCPUS        512

Wow, that looks like a pretty big jump. I certainly don't have access to any box with this number of vCPUs, so that's going to be quite hard to test. What the reasoning behind this bump? Is hardware with 512 ways expected soon-ish?

Also osstest is not even able to test the current limit, so I would maybe bump this to 256, but as I expressed in other occasions I don't feel comfortable with have a number of vCPUs that the current test system doesn't have hardware to test with.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#47 lore raw

Re: [RFC Patch v4 8/8] x86/hvm: bump the maximum number of vcpus to 512

Quoted 13 lines · Roger Pau Monné
Quoted 12 lines · Chao Gao
---
 xen/include/public/hvm/hvm_info_table.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/public/hvm/hvm_info_table.h +0 -0
index 08c252e..6833a4c 100644
@@ -32,7 +32,7 @@
 #define HVM_INFO_PADDR       ((HVM_INFO_PFN << 12) + HVM_INFO_OFFSET)
 
Quoted 7 lines

xen/include/public/hvm/hvm_info_table.h line 35

Quoted 3 lines
xen/include/public/hvm/hvm_info_table.h +1 -1
 /* Maximum we can support with current vLAPIC ID mapping. */
-#define HVM_MAX_VCPUS        128
+#define HVM_MAX_VCPUS        512

Wow, that looks like a pretty big jump. I certainly don't have access to any box with this number of vCPUs, so that's going to be quite hard to test. What the reasoning behind this bump?

There are 288 cpus on some Intel XEON-phi platform. Bumping this value to 288 would be weird because I think if I do that there would be some questions -- why it should be 288 and why the number of vCPUs should be the same with the number of pCPUs. I choose 512, just because it is the nearest next power of 2 number.

Quoted 1 line

Is hardware with 512 ways expected soon-ish?

No.

Quoted 2 lines

Also osstest is not even able to test the current limit, so I would

Do we have any plan to test guest with 128 vCPUs on osstest?

Quoted 3 lines

maybe bump this to 256, but as I expressed in other occasions I don't feel comfortable with have a number of vCPUs that the current test system doesn't have hardware to test with.

If we only test functionality (osstest doesn't test performance, right?), hardware needn't have so many pCPUs.

Could we declare that more than 128 vCPUs support is only experimental feature? Once some regular tests are available, we can announce that On x86, Xen supports HVM with, for example, 128 vCPUs or 512 vCPUs. It seems Geroge's work on SUPPORT.md is for this kind of propose.

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#48 lore raw

Re: [RFC Patch v4 8/8] x86/hvm: bump the maximum number of vcpus to 512

In reply to Roger Pau Monné
Quoted 24 lines
Quoted 1 line
Quoted 1 line · On 23.02.18 at 19:11, <[email protected]> wrote:

Review

Quoted 6 lines · Chao Gao
---
 xen/include/public/hvm/hvm_info_table.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/xen/include/public/hvm/hvm_info_table.h

xen/include/public/hvm/hvm_info_table.h line 35

Quoted 9 lines

index 08c252e..6833a4c 100644

xen/include/public/hvm/hvm_info_table.h +1 -1
@@ -32,7 +32,7 @@
 #define HVM_INFO_PADDR       ((HVM_INFO_PFN << 12) + HVM_INFO_OFFSET)
 
 /* Maximum we can support with current vLAPIC ID mapping. */
-#define HVM_MAX_VCPUS        128
+#define HVM_MAX_VCPUS        512

Wow, that looks like a pretty big jump. I certainly don't have access to any box with this number of vCPUs, so that's going to be quite hard to test. What the reasoning behind this bump? Is hardware with 512 ways expected soon-ish?

Quoted 4 lines

Also osstest is not even able to test the current limit, so I would maybe bump this to 256, but as I expressed in other occasions I don't feel comfortable with have a number of vCPUs that the current test system doesn't have hardware to test with.

I think implementation limit and supported limit need to be clearly distinguished here. Therefore I'd put the question the other way
around: What's causing the limit to be 512, rather than 1024, 4096, or even 4G-1 (x2APIC IDs are 32 bits wide, after all)?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#49 lore raw

Re: [RFC Patch v4 8/8] x86/hvm: bump the maximum number of vcpus to 512

Quoted 29 lines · Jan Beulich
Quoted 24 lines
Quoted 1 line
Quoted 1 line · On 23.02.18 at 19:11, <[email protected]> wrote:

Review

Quoted 6 lines · Chao Gao
---
 xen/include/public/hvm/hvm_info_table.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/xen/include/public/hvm/hvm_info_table.h

xen/include/public/hvm/hvm_info_table.h line 35

Quoted 9 lines

index 08c252e..6833a4c 100644

xen/include/public/hvm/hvm_info_table.h +1 -1
@@ -32,7 +32,7 @@
 #define HVM_INFO_PADDR       ((HVM_INFO_PFN << 12) + HVM_INFO_OFFSET)
 
 /* Maximum we can support with current vLAPIC ID mapping. */
-#define HVM_MAX_VCPUS        128
+#define HVM_MAX_VCPUS        512

Wow, that looks like a pretty big jump. I certainly don't have access to any box with this number of vCPUs, so that's going to be quite hard to test. What the reasoning behind this bump? Is hardware with 512 ways expected soon-ish?

Quoted 4 lines

Also osstest is not even able to test the current limit, so I would maybe bump this to 256, but as I expressed in other occasions I don't feel comfortable with have a number of vCPUs that the current test system doesn't have hardware to test with.

Quoted 4 lines

I think implementation limit and supported limit need to be clearly distinguished here. Therefore I'd put the question the other way
around: What's causing the limit to be 512, rather than 1024, 4096, or even 4G-1 (x2APIC IDs are 32 bits wide, after all)?

TBH, I have no idea. When I choose a value, what comes up to my mind is that the value should be 288, because Intel has Xeon-phi platform which has 288 physical threads, and some customers wants to use this new platform for HPC cloud. Furthermore, they requests to support a big VM in which almost computing and device resources are assigned to the VM. They just use virtulization technology to manage the machines. In this situation, I choose 512 is because I feel much better if the limit is a power of 2.

You are asking that as these patches remove limitations imposed by some components, which one is the next bottleneck and how many vcpus does it limit. Maybe it would be the use-case. No one is requesting to support more than 288 at this moment. So what is the value you prefer? 288 or 512? or you think I should find the next bottleneck in Xen's implementation.

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#50 lore raw

Re: [RFC Patch v4 8/8] x86/hvm: bump the maximum number of vcpus to 512

Quoted 44 lines
Quoted 1 line
Quoted 1 line · On 26.02.18 at 14:11, <[email protected]> wrote:
Quoted 29 lines · Jan Beulich
Quoted 24 lines
Quoted 1 line
Quoted 1 line · On 23.02.18 at 19:11, <[email protected]> wrote:

Review

Quoted 6 lines · Chao Gao
---
 xen/include/public/hvm/hvm_info_table.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/xen/include/public/hvm/hvm_info_table.h

xen/include/public/hvm/hvm_info_table.h line 35

Quoted 9 lines

index 08c252e..6833a4c 100644

xen/include/public/hvm/hvm_info_table.h +1 -1
@@ -32,7 +32,7 @@
 #define HVM_INFO_PADDR       ((HVM_INFO_PFN << 12) + HVM_INFO_OFFSET)
 
 /* Maximum we can support with current vLAPIC ID mapping. */
-#define HVM_MAX_VCPUS        128
+#define HVM_MAX_VCPUS        512

Wow, that looks like a pretty big jump. I certainly don't have access to any box with this number of vCPUs, so that's going to be quite hard to test. What the reasoning behind this bump? Is hardware with 512 ways expected soon-ish?

Quoted 4 lines

Also osstest is not even able to test the current limit, so I would maybe bump this to 256, but as I expressed in other occasions I don't feel comfortable with have a number of vCPUs that the current test system doesn't have hardware to test with.

Quoted 4 lines

I think implementation limit and supported limit need to be clearly distinguished here. Therefore I'd put the question the other way
around: What's causing the limit to be 512, rather than 1024, 4096, or even 4G-1 (x2APIC IDs are 32 bits wide, after all)?

TBH, I have no idea. When I choose a value, what comes up to my mind is that the value should be 288, because Intel has Xeon-phi platform which has 288 physical threads, and some customers wants to use this new platform for HPC cloud. Furthermore, they requests to support a big VM in which almost computing and device resources are assigned to the VM. They just use virtulization technology to manage the machines. In this situation, I choose 512 is because I feel much better if the limit is a power of 2.

Quoted 6 lines

You are asking that as these patches remove limitations imposed by some components, which one is the next bottleneck and how many vcpus does it limit. Maybe it would be the use-case. No one is requesting to support more than 288 at this moment. So what is the value you prefer? 288 or 512? or you think I should find the next bottleneck in Xen's implementation.

Again - here we're talking about implementation limits, not bottlenecks. So in this context all I'm interested in is whether (and if so which) implementation limit remains. If an (almost) arbitrary number is fine, perhaps we'll want to have a Kconfig option.

I'm also curious - do Phis not come in multi-socket configs? It's my understanding that 288 is the count for a single socket.

As to bottlenecks - you've been told they exist far below 128.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#51 lore raw

Re: [RFC Patch v4 8/8] x86/hvm: bump the maximum number of vcpus to 512

Quoted 51 lines · Jan Beulich
Quoted 44 lines
Quoted 1 line
Quoted 1 line · On 26.02.18 at 14:11, <[email protected]> wrote:
Quoted 29 lines · Jan Beulich
Quoted 24 lines
Quoted 1 line
Quoted 1 line · On 23.02.18 at 19:11, <[email protected]> wrote:

Review

Quoted 6 lines · Chao Gao
---
 xen/include/public/hvm/hvm_info_table.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/xen/include/public/hvm/hvm_info_table.h

xen/include/public/hvm/hvm_info_table.h line 35

Quoted 9 lines

index 08c252e..6833a4c 100644

xen/include/public/hvm/hvm_info_table.h +1 -1
@@ -32,7 +32,7 @@
 #define HVM_INFO_PADDR       ((HVM_INFO_PFN << 12) + HVM_INFO_OFFSET)
 
 /* Maximum we can support with current vLAPIC ID mapping. */
-#define HVM_MAX_VCPUS        128
+#define HVM_MAX_VCPUS        512

Wow, that looks like a pretty big jump. I certainly don't have access to any box with this number of vCPUs, so that's going to be quite hard to test. What the reasoning behind this bump? Is hardware with 512 ways expected soon-ish?

Quoted 4 lines

Also osstest is not even able to test the current limit, so I would maybe bump this to 256, but as I expressed in other occasions I don't feel comfortable with have a number of vCPUs that the current test system doesn't have hardware to test with.

Quoted 4 lines

I think implementation limit and supported limit need to be clearly distinguished here. Therefore I'd put the question the other way
around: What's causing the limit to be 512, rather than 1024, 4096, or even 4G-1 (x2APIC IDs are 32 bits wide, after all)?

TBH, I have no idea. When I choose a value, what comes up to my mind is that the value should be 288, because Intel has Xeon-phi platform which has 288 physical threads, and some customers wants to use this new platform for HPC cloud. Furthermore, they requests to support a big VM in which almost computing and device resources are assigned to the VM. They just use virtulization technology to manage the machines. In this situation, I choose 512 is because I feel much better if the limit is a power of 2.

Quoted 6 lines

You are asking that as these patches remove limitations imposed by some components, which one is the next bottleneck and how many vcpus does it limit. Maybe it would be the use-case. No one is requesting to support more than 288 at this moment. So what is the value you prefer? 288 or 512? or you think I should find the next bottleneck in Xen's implementation.

Quoted 5 lines

Again - here we're talking about implementation limits, not bottlenecks. So in this context all I'm interested in is whether (and if so which) implementation limit remains. If an (almost) arbitrary number is fine, perhaps we'll want to have a Kconfig option.

Do you think that struct hvm_info_table would be a implementation limits? To contain this struct in a single page, the HVM_MAX_VCPUS should be smaller than a value, like (PAGE_SIZE * 8). Supposing it is the only implementation limit, I don't think it is reasonable to set HVM_MAX_VCPUS to that value, because we don't have hardwares to perform tests, even Xeon-phi isn't capable. This value can be bumped when some methods verify a guest can work with more vcpus. Now I prefer 288 over 512 and some values else.

Quoted 3 lines

I'm also curious - do Phis not come in multi-socket configs? It's my understanding that 288 is the count for a single socket.

Currently we don't have. But it's hard to say for future products.

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#52 lore raw

Re: [RFC Patch v4 8/8] x86/hvm: bump the maximum number of vcpus to 512

Quoted 8 lines
Quoted 1 line
Quoted 1 line

Chao Gao <[email protected]> 03/01/18 7:34 AM >>>

Quoted 5 lines · Jan Beulich

Again - here we're talking about implementation limits, not bottlenecks. So in this context all I'm interested in is whether (and if so which) implementation limit remains. If an (almost) arbitrary number is fine, perhaps we'll want to have a Kconfig option.

Quoted 8 lines

Do you think that struct hvm_info_table would be a implementation limits? To contain this struct in a single page, the HVM_MAX_VCPUS should be smaller than a value, like (PAGE_SIZE * 8). Supposing it is the only implementation limit, I don't think it is reasonable to set HVM_MAX_VCPUS to that value, because we don't have hardwares to perform tests, even Xeon-phi isn't capable. This value can be bumped when some methods verify a guest can work with more vcpus. Now I prefer 288 over 512 and some values else.

Whether going beyond PAGE_SIZE with the structure size is a valid item to think about, but I don't think there's any implied limit from that. But - did you read my and George's subsequent reply at all? You continue to mix up supported (because of being able to test) limits with implementation ones. Even Jürgen's suggestion to take NR_CPUS as the limit is not very reasonable - PV guests have an implementation limit of (iirc) 8192. Once again - if there's no sensible upper limit imposed by the implementation, consider introducing a Kconfig option to pick the limit.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#53 lore raw

Re: [RFC Patch v4 8/8] x86/hvm: bump the maximum number of vcpus to 512

Quoted 17 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line

Chao Gao <[email protected]> 03/01/18 7:34 AM >>>

Quoted 5 lines · Jan Beulich

Again - here we're talking about implementation limits, not bottlenecks. So in this context all I'm interested in is whether (and if so which) implementation limit remains. If an (almost) arbitrary number is fine, perhaps we'll want to have a Kconfig option.

Quoted 8 lines

Do you think that struct hvm_info_table would be a implementation limits? To contain this struct in a single page, the HVM_MAX_VCPUS should be smaller than a value, like (PAGE_SIZE * 8). Supposing it is the only implementation limit, I don't think it is reasonable to set HVM_MAX_VCPUS to that value, because we don't have hardwares to perform tests, even Xeon-phi isn't capable. This value can be bumped when some methods verify a guest can work with more vcpus. Now I prefer 288 over 512 and some values else.

Quoted 3 lines

Whether going beyond PAGE_SIZE with the structure size is a valid item to think about, but I don't think there's any implied limit from that. But - did you read my and George's subsequent reply at all? You continue to

Yes. I did. But somehow I didn't clearly understand the difference. Sorry for this.

Quoted 5 lines

mix up supported (because of being able to test) limits with implementation ones. Even Jürgen's suggestion to take NR_CPUS as the limit is not very reasonable - PV guests have an implementation limit of (iirc) 8192. Once again - if there's no sensible upper limit imposed by the implementation, consider introducing a Kconfig option to pick the limit.

Got it.

Thanks
Chao

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

maintainer
#54 lore raw

Re: [RFC Patch v4 8/8] x86/hvm: bump the maximum number of vcpus to 512

In reply to Chao Gao
Quoted 68 lines · Chao Gao
Quoted 51 lines · Jan Beulich
Quoted 44 lines
Quoted 1 line
Quoted 1 line · On 26.02.18 at 14:11, <[email protected]> wrote:
Quoted 29 lines · Jan Beulich
Quoted 24 lines
Quoted 1 line
Quoted 1 line · On 23.02.18 at 19:11, <[email protected]> wrote:

Review

Quoted 6 lines · Chao Gao
---
 xen/include/public/hvm/hvm_info_table.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/xen/include/public/hvm/hvm_info_table.h

xen/include/public/hvm/hvm_info_table.h line 35

Quoted 9 lines

index 08c252e..6833a4c 100644

xen/include/public/hvm/hvm_info_table.h +1 -1
@@ -32,7 +32,7 @@
 #define HVM_INFO_PADDR       ((HVM_INFO_PFN << 12) + HVM_INFO_OFFSET)
 
 /* Maximum we can support with current vLAPIC ID mapping. */
-#define HVM_MAX_VCPUS        128
+#define HVM_MAX_VCPUS        512

Wow, that looks like a pretty big jump. I certainly don't have access to any box with this number of vCPUs, so that's going to be quite hard to test. What the reasoning behind this bump? Is hardware with 512 ways expected soon-ish?

Quoted 4 lines

Also osstest is not even able to test the current limit, so I would maybe bump this to 256, but as I expressed in other occasions I don't feel comfortable with have a number of vCPUs that the current test system doesn't have hardware to test with.

Quoted 4 lines

I think implementation limit and supported limit need to be clearly distinguished here. Therefore I'd put the question the other way
around: What's causing the limit to be 512, rather than 1024, 4096, or even 4G-1 (x2APIC IDs are 32 bits wide, after all)?

TBH, I have no idea. When I choose a value, what comes up to my mind is that the value should be 288, because Intel has Xeon-phi platform which has 288 physical threads, and some customers wants to use this new platform for HPC cloud. Furthermore, they requests to support a big VM in which almost computing and device resources are assigned to the VM. They just use virtulization technology to manage the machines. In this situation, I choose 512 is because I feel much better if the limit is a power of 2.

Quoted 6 lines

You are asking that as these patches remove limitations imposed by some components, which one is the next bottleneck and how many vcpus does it limit. Maybe it would be the use-case. No one is requesting to support more than 288 at this moment. So what is the value you prefer? 288 or 512? or you think I should find the next bottleneck in Xen's implementation.

Quoted 5 lines

Again - here we're talking about implementation limits, not bottlenecks. So in this context all I'm interested in is whether (and if so which) implementation limit remains. If an (almost) arbitrary number is fine, perhaps we'll want to have a Kconfig option.

Do you think that struct hvm_info_table would be a implementation limits? To contain this struct in a single page, the HVM_MAX_VCPUS should be smaller than a value, like (PAGE_SIZE * 8). Supposing it is the only implementation limit, I don't think it is reasonable to set HVM_MAX_VCPUS to that value, because we don't have hardwares to perform tests, even Xeon-phi isn't capable. This value can be bumped when some methods verify a guest can work with more vcpus. Now I prefer 288 over 512 and some values else.

Quoted 1 line
Quoted 4 lines
Quoted 2 lines

I'm also curious - do Phis not come in multi-socket configs? It's my understanding that 288 is the count for a single socket.

Currently we don't have. But it's hard to say for future products.

Is there any reason to set HVM_MAX_VCPUS to a lower limit than CONFIG_NR_CPUS? This can be set to 4095, so why not use the same limit for HVM_MAX_VCPUS?

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#55 lore raw

Re: [RFC Patch v4 8/8] x86/hvm: bump the maximum number of vcpus to 512

In reply to Chao Gao
Quoted 43 lines · Chao Gao
Quoted 29 lines · Jan Beulich
Quoted 24 lines
Quoted 1 line
Quoted 1 line · On 23.02.18 at 19:11, <[email protected]> wrote:

Review

Quoted 6 lines · Chao Gao
---
 xen/include/public/hvm/hvm_info_table.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/xen/include/public/hvm/hvm_info_table.h

xen/include/public/hvm/hvm_info_table.h line 35

Quoted 9 lines

index 08c252e..6833a4c 100644

xen/include/public/hvm/hvm_info_table.h +1 -1
@@ -32,7 +32,7 @@
 #define HVM_INFO_PADDR       ((HVM_INFO_PFN << 12) + HVM_INFO_OFFSET)
 
 /* Maximum we can support with current vLAPIC ID mapping. */
-#define HVM_MAX_VCPUS        128
+#define HVM_MAX_VCPUS        512

Wow, that looks like a pretty big jump. I certainly don't have access to any box with this number of vCPUs, so that's going to be quite hard to test. What the reasoning behind this bump? Is hardware with 512 ways expected soon-ish?

Quoted 4 lines

Also osstest is not even able to test the current limit, so I would maybe bump this to 256, but as I expressed in other occasions I don't feel comfortable with have a number of vCPUs that the current test system doesn't have hardware to test with.

Quoted 4 lines

I think implementation limit and supported limit need to be clearly distinguished here. Therefore I'd put the question the other way
around: What's causing the limit to be 512, rather than 1024, 4096, or even 4G-1 (x2APIC IDs are 32 bits wide, after all)?

TBH, I have no idea. When I choose a value, what comes up to my mind is that the value should be 288, because Intel has Xeon-phi platform which has 288 physical threads, and some customers wants to use this new platform for HPC cloud. Furthermore, they requests to support a big VM in which almost computing and device resources are assigned to the VM. They just use virtulization technology to manage the machines. In this situation, I choose 512 is because I feel much better if the limit is a power of 2.

Quoted 6 lines

You are asking that as these patches remove limitations imposed by some components, which one is the next bottleneck and how many vcpus does it limit. Maybe it would be the use-case. No one is requesting to support more than 288 at this moment. So what is the value you prefer? 288 or 512? or you think I should find the next bottleneck in Xen's implementation.

I understood Jan to be responding to Roger -- Roger said he didn't want to increase the limit beyond what osstest could reasonably test; Jan said that what osstest can test should be factored into the *supported* limit, not the *implementation* limit.

I agree with Jan: People should be allowed to run systems with 288 vcpus, understanding that they are at that point running essentially an experimental system which may not work; and that if it doesn't work, it may be that nobody will be able to reproduce and thus fix their issue.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel