Skip to contentSkip to conversation

Refactor x86 domain builder

RFC PATCH Superseded Wei Liu 4 participants 30 messages Mar 3, 2017

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
author
#1 lore raw

RFC PATCH 1/5 xen: move round_pg{up,down} to pfn.h

In reply to Wei Liu

They are going to be needed in multiple places. Instead of replicating more, move them to pfn.h.

---
 xen/arch/x86/domain_build.c | 3 ---
 xen/common/page_alloc.c     | 4 +---
 xen/include/xen/pfn.h       | 3 +++
 3 files changed, 4 insertions(+), 6 deletions(-)
xen/arch/x86/domain_build.c +0 -3
index e4b60d436f..00ce5f24e9 100644
@@ -267,9 +267,6 @@ boolean_param("ro-hpet", ro_hpet);
 #define L3_PROT (BASE_PROT|_PAGE_DIRTY)
 #define L4_PROT (BASE_PROT|_PAGE_DIRTY)
 
-#define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
-#define round_pgdown(_p)  ((_p)&PAGE_MASK)
-
 static unsigned int __initdata memflags = MEMF_no_dma|MEMF_exact_node;
 
 static struct page_info * __init alloc_chunk(
xen/common/page_alloc.c +1 -3
index 530ede1d20..42c20cb201 100644
@@ -131,6 +131,7 @@
 #include <xen/domain_page.h>
 #include <xen/keyhandler.h>
 #include <xen/perfc.h>
+#include <xen/pfn.h>
 #include <xen/numa.h>
 #include <xen/nodemask.h>
 #include <xen/event.h>
@@ -176,9 +177,6 @@ size_param("bootscrub_chunk", opt_bootscrub_chunk);
 static unsigned int dma_bitsize;
 integer_param("dma_bits", dma_bitsize);
 
-#define round_pgdown(_p)  ((_p)&PAGE_MASK)
-#define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
-
 /* Offlined page list, protected by heap_lock. */
 PAGE_LIST_HEAD(page_offlined_list);
 /* Broken page list, protected by heap_lock. */
xen/include/xen/pfn.h +3 -0
index 3626197de3..ed9d27d568 100644
@@ -6,4 +6,7 @@
 #define PFN_DOWN(x)   ((x) >> PAGE_SHIFT)
 #define PFN_UP(x)     (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
 
+#define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
+#define round_pgdown(_p)  ((_p)&PAGE_MASK)
+
 #endif /* __XEN_PFN_H__ */
Signature · 7 lines
2.11.0


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

RFC PATCH 2/5 xen: include xen/types.h in domain.h

In reply to Wei Liu

The public header expects a few types to be present.

This works in the code base only because types.h is included by some other headers which happen to be placed before the inclusion of domain.h.

Include types.h before xen.h in domain.h to fix it properly.

---
 xen/include/xen/domain.h | 2 ++
 1 file changed, 2 insertions(+)
xen/include/xen/domain.h +2 -0
index bce0ea1ea9..347f264047 100644
@@ -2,6 +2,8 @@
 #ifndef __XEN_DOMAIN_H__
 #define __XEN_DOMAIN_H__
 
+#include <xen/types.h>
+
 #include <public/xen.h>
 #include <asm/domain.h>
 #include <asm/numa.h>
Signature · 7 lines
2.11.0


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

Wei Liu

author
#0 lore raw

cover Refactor x86 domain builder

Long term we want to separate different sets of guest supporting code. We would like to have CONFIG_HVM and CONFIG_PV (maybe even CONFIG_PVH?). I will start to dientangle Xen code component by component. This is also somewhat related to the project to move PV interface inside a PVH container, which I plan to work on soon.

RFC because I would like to know whether I should start putting them into pv and hvm directory respectively. And I would also like to know the reception of the idea to disentangle Xen guest supporting code in general.

This series is built on top of Roger's PVHv1 removal series.

Wei Liu (5):
xen: move round_pg{up,down} to pfn.h
xen: include xen/types.h in domain.h
x86: split PV dom0 builder to domain_build_pv.c
x86: split PVH dom0 builder to domain_build_pv.c
x86: clean up header files in domain_build.c

 xen/arch/x86/Makefile           |    2 +
 xen/arch/x86/domain_build.c     | 2003 +--------------------------------------
 xen/arch/x86/domain_build.h     |   40 +
 xen/arch/x86/domain_build_pv.c  |  909 ++++++++++++++++++
 xen/arch/x86/domain_build_pvh.c | 1097 +++++++++++++++++++++
 xen/common/page_alloc.c         |    4 +-
 xen/include/xen/domain.h        |    2 +
 xen/include/xen/pfn.h           |    3 +
 8 files changed, 2070 insertions(+), 1990 deletions(-)
 create mode 100644 xen/arch/x86/domain_build.h
 create mode 100644 xen/arch/x86/domain_build_pv.c
 create mode 100644 xen/arch/x86/domain_build_pvh.c
Signature · 7 lines
2.11.0


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

RFC PATCH 4/5 x86: split PVH dom0 builder to domain_build_pv.c

Long term we want to be able to disentangle PV and HVM code. Move the PVH domain builder to a dedicated file. It will later depends on CONFIG_HVM or CONFIG_PVH.

This in turn requires exposing a few functions and variables via domain_build.h.

---
 xen/arch/x86/Makefile           |    1 +
 xen/arch/x86/domain_build.c     | 1068 +------------------------------------
 xen/arch/x86/domain_build.h     |    8 +
 xen/arch/x86/domain_build_pvh.c | 1097 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 1108 insertions(+), 1066 deletions(-)
 create mode 100644 xen/arch/x86/domain_build_pvh.c
xen/arch/x86/Makefile +1 -0
index e4c134e66a..2ad94f50a8 100644
@@ -25,6 +25,7 @@ obj-y += domctl.o
 obj-y += domain.o
 obj-bin-y += domain_build.init.o
 obj-bin-y += domain_build_pv.init.o
+obj-bin-y += domain_build_pvh.init.o
 obj-y += domain_page.o
 obj-y += e820.o
 obj-y += extable.o
xen/arch/x86/domain_build.c +2 -1066

1,086 lines not on this page · raw message

xen/arch/x86/domain_build.h +8 -0
index 403b90b77e..e8fc0ff4d7 100644
@@ -19,6 +19,14 @@ int construct_dom0_pv(
     void *(*bootstrap_map)(const module_t *),
     char *cmdline);
 
+int construct_dom0_pvh(struct domain *d, const module_t *image,
+                       unsigned long image_headroom,
+                       module_t *initrd,
+                       void *(*bootstrap_map)(const module_t *),
+                       char *cmdline);
+unsigned long dom0_paging_pages(const struct domain *d,
+                                unsigned long nr_pages);
+
 #endif	/* _DOMAIN_BUILD_H_ */
 
 /*
xen/arch/x86/domain_build_pvh.c new file +1097 -0

1,097 lines not on this page · raw message

Signature · 7 lines
2.11.0


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

RFC PATCH 3/5 x86: split PV dom0 builder to domain_build_pv.c

In reply to Wei Liu

Long term we want to be able to disentangle PV and HVM code. Move the PV domain builder to a dedicated file.

This in turn requires exposing a few functions and variables via a new header domain_build.h.

---
 xen/arch/x86/Makefile          |   1 +
 xen/arch/x86/domain_build.c    | 894 +---------------------------------------
 xen/arch/x86/domain_build.h    |  32 ++
 xen/arch/x86/domain_build_pv.c | 909 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 951 insertions(+), 885 deletions(-)
 create mode 100644 xen/arch/x86/domain_build.h
 create mode 100644 xen/arch/x86/domain_build_pv.c
xen/arch/x86/Makefile +1 -0
index d6980b563d..e4c134e66a 100644
@@ -24,6 +24,7 @@ obj-bin-y += dmi_scan.init.o
 obj-y += domctl.o
 obj-y += domain.o
 obj-bin-y += domain_build.init.o
+obj-bin-y += domain_build_pv.init.o
 obj-y += domain_page.o
 obj-y += e820.o
 obj-y += extable.o
xen/arch/x86/domain_build.c +9 -885

931 lines not on this page · raw message

xen/arch/x86/domain_build.h new file +32 -0
new file mode 100644
index 0000000000..403b90b77e
@@ -0,0 +1,32 @@
+#ifndef _DOMAIN_BUILD_H_
+#define _DOMAIN_BUILD_H_
+
+#include <xen/init.h>
+
+extern unsigned int memflags;
+extern cpumask_t dom0_cpus;
+
+unsigned long compute_dom0_nr_pages(
+    struct domain *d, struct elf_dom_parms *parms, unsigned long initrd_len);
+struct vcpu *setup_dom0_vcpu(struct domain *d, unsigned int vcpu_id,
+                                    unsigned int cpu);
+int setup_permissions(struct domain *d);
+
+int construct_dom0_pv(
+    struct domain *d,
+    const module_t *image, unsigned long image_headroom,
+    module_t *initrd,
+    void *(*bootstrap_map)(const module_t *),
+    char *cmdline);
+
+#endif	/* _DOMAIN_BUILD_H_ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
xen/arch/x86/domain_build_pv.c new file +909 -0

909 lines not on this page · raw message

Signature · 7 lines
2.11.0


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

RFC PATCH 5/5 x86: clean up header files in domain_build.c

In reply to Wei Liu

Remove the ones that are no longer needed and sort them.

---
 xen/arch/x86/domain_build.c | 40 ++++++----------------------------------
 1 file changed, 6 insertions(+), 34 deletions(-)
xen/arch/x86/domain_build.c +6 -34
index 64a978473d..e66aacdad6 100644
@@ -5,45 +5,17 @@
  */
 
 #include <xen/init.h>
-#include <xen/lib.h>
-#include <xen/ctype.h>
-#include <xen/sched.h>
-#include <xen/sched-if.h>
-#include <xen/smp.h>
-#include <xen/delay.h>
-#include <xen/event.h>
-#include <xen/console.h>
-#include <xen/kernel.h>
-#include <xen/domain.h>
-#include <xen/version.h>
 #include <xen/iocap.h>
-#include <xen/bitops.h>
-#include <xen/compat.h>
 #include <xen/libelf.h>
 #include <xen/pfn.h>
-#include <xen/guest_access.h>
-#include <xen/acpi.h>
-#include <asm/regs.h>
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/processor.h>
-#include <asm/desc.h>
-#include <asm/i387.h>
-#include <asm/paging.h>
+#include <xen/sched.h>
+#include <xen/sched-if.h>
+#include <xen/softirq.h>
+
+#include <asm/hpet.h>
+#include <asm/io_apic.h>
 #include <asm/p2m.h>
-#include <asm/e820.h>
-#include <asm/acpi.h>
 #include <asm/setup.h>
-#include <asm/bzimage.h> /* for bzimage_parse */
-#include <asm/io_apic.h>
-#include <asm/hpet.h>
-
-#include <acpi/actables.h>
-
-#include <public/version.h>
-#include <public/hvm/hvm_info_table.h>
-#include <public/arch-x86/hvm/start_info.h>
-#include <public/hvm/hvm_vcpu.h>
 
 #include "domain_build.h"
 
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#23 lore raw
In reply to Wei Liu
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 10:41, <[email protected]> wrote:

Long term we want to separate different sets of guest supporting code. We would like to have CONFIG_HVM and CONFIG_PV (maybe even CONFIG_PVH?). I will start to dientangle Xen code component by component. This is also somewhat related to the project to move PV interface inside a PVH container, which I plan to work on soon.

RFC because I would like to know whether I should start putting them into pv and hvm directory respectively.

Yes please, along the lines of an RFC patch Andrew had sent not sao long ago.

Quoted 2 lines

And I would also like to know the reception of
the idea to disentangle Xen guest supporting code in general.

I think this is generally a good idea, provided it doesn't end up requiring too many clumsy internal interfaces (e.g. when trying to share code).

Jan

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

Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH RFC 1/5] xen: move round_pg{up, down} to pfn.h

In reply to Wei Liu

xen/include/xen/pfn.h line 10

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 10:41, <[email protected]> wrote:
xen/include/xen/pfn.h +2 -0
@@ -6,4 +6,7 @@
 #define PFN_DOWN(x)   ((x) >> PAGE_SHIFT)
 #define PFN_UP(x)     (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
 
+#define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
+#define round_pgdown(_p)  ((_p)&PAGE_MASK)

With blanks around binary operators added and leading underscores removed I think this could go in right away, i.e.

Jan

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

Acked-by on v1 2/5
#5 lore raw

Re: [PATCH RFC 2/5] xen: include xen/types.h in domain.h

In reply to Wei Liu
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 10:41, <[email protected]> wrote:

The public header expects a few types to be present.

This works in the code base only because types.h is included by some other headers which happen to be placed before the inclusion of domain.h.

Include types.h before xen.h in domain.h to fix it properly.

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

author
#3 lore raw

Re: [PATCH RFC 1/5] xen: move round_pg{up, down} to pfn.h

In reply to Jan Beulich
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 10:41, <[email protected]> wrote:
xen/include/xen/pfn.h +0 -0
@@ -6,4 +6,7 @@
 #define PFN_DOWN(x)   ((x) >> PAGE_SHIFT)
 #define PFN_UP(x)     (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
 
Quoted 7 lines

xen/include/xen/pfn.h line 10

Quoted 2 lines
xen/include/xen/pfn.h +2 -0
+#define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
+#define round_pgdown(_p)  ((_p)&PAGE_MASK)

With blanks around binary operators added and leading underscores removed I think this could go in right away, i.e.

Right. Thanks. I will commit the following hunk with your reviewed-by.

#define round_pgup(p) (((p) + (PAGE_SIZE - 1)) & PAGE_MASK)
#define round_pgdown(p) ((p) & PAGE_MASK)

Quoted 2 lines

Jan

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

#24 lore raw
In reply to Wei Liu
Quoted 2 lines · Wei Liu

Long term we want to separate different sets of guest supporting code. We would like to have CONFIG_HVM and CONFIG_PV (maybe even CONFIG_PVH?).

Probably not PVH. The only differences between HVM and PVH from Xen's point of view are some of the emulation choices.

Quoted 8 lines

I will start
to dientangle Xen code component by component. This is also somewhat related to the project to move PV interface inside a PVH container, which I plan to work on soon.

RFC because I would like to know whether I should start putting them into pv and hvm directory respectively. And I would also like to know the reception of the idea to disentangle Xen guest supporting code in general.

+10, although I have a couple of further suggestions.

If we are going to start this, I think we should actually include CONFIG_{PV,HVM} so we can make the files compilation-safe as they are touched.

Jan: Would you be happy accepting my CONFIG_{PV,HVM} patch in its silent form for now? If so, I will respin it.

I'd also like to us taking the effort to move as much as is suitable into the pv/ and hvm/ subdirectories, to logically separate it from the properly common code.

However, with the hypercall series, I was also taking the effort to ensure that the code (particularly in pv/) was properly bool/const/mfn_t and style correct, to try and break the cycle of uncertainty and poor code quality. For this, I was vaguely planning to clean the code up, then move the file, rather than the other way around.

Quoted 8 lines

This series is built on top of Roger's PVHv1 removal series.

Wei Liu (5):
xen: move round_pg{up,down} to pfn.h
xen: include xen/types.h in domain.h
x86: split PV dom0 builder to domain_build_pv.c
x86: split PVH dom0 builder to domain_build_pv.c
x86: clean up header files in domain_build.c

I'd argue that these should be named differently. They are specifically hwdom_build.c, distinct from general domain building operations.

~Andrew

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

#25 lore raw
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 11:56, <[email protected]> wrote:

On 03/03/17 09:41, Wei Liu wrote:
Jan: Would you be happy accepting my CONFIG_{PV,HVM} patch in its silent form for now? If so, I will respin it.

I think so, yes.

Quoted 11 lines
Quoted 8 lines

This series is built on top of Roger's PVHv1 removal series.

Wei Liu (5):
xen: move round_pg{up,down} to pfn.h
xen: include xen/types.h in domain.h
x86: split PV dom0 builder to domain_build_pv.c
x86: split PVH dom0 builder to domain_build_pv.c
x86: clean up header files in domain_build.c

I'd argue that these should be named differently. They are specifically hwdom_build.c, distinct from general domain building operations.

hwdom_build.c is wrong too - this is strictly Dom0, i.e. it ought to be dom0_build.c.

Jan

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

#7 lore raw

Re: [PATCH RFC 3/5] x86: split PV dom0 builder to domain_build_pv.c

In reply to Wei Liu
Quoted 5 lines · Wei Liu

Long term we want to be able to disentangle PV and HVM code. Move the PV domain builder to a dedicated file.

This in turn requires exposing a few functions and variables via a new header domain_build.h.

I would add: "No functional change introduced", to make it clearer that it's mostly just code movement.

Quoted 5 lines
---
 xen/arch/x86/Makefile          |   1 +
 xen/arch/x86/domain_build.c    | 894 +---------------------------------------
 xen/arch/x86/domain_build.h    |  32 ++

IMHO I would place this in include/asm-x86/, there are really no headers in arch/x86/.

xen/arch/x86/domain_build_pv.c

Quoted 1 line
xen/arch/x86/domain_build_pv.c +0 -0

I would place this in arch/xen/x86/pv/domain_build.c

xen/arch/x86/domain_build_pv.c line 3

Quoted 8 lines

new file mode 100644
index 0000000000..b4877c8dac

xen/arch/x86/domain_build_pv.c new file +3 -0
@@ -0,0 +1,909 @@
+/******************************************************************************
+ * domain_build_pv.c
+ */

You should probably keep Kier's copyright here, since this is all PV code.

Roger.

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

#29 lore raw
In reply to Andrew Cooper
Quoted 11 lines · Andrew Cooper
Quoted 8 lines · Wei Liu

This series is built on top of Roger's PVHv1 removal series.

Wei Liu (5):
xen: move round_pg{up,down} to pfn.h
xen: include xen/types.h in domain.h
x86: split PV dom0 builder to domain_build_pv.c
x86: split PVH dom0 builder to domain_build_pv.c
x86: clean up header files in domain_build.c

I'd argue that these should be named differently. They are specifically hwdom_build.c, distinct from general domain building operations.

Actually on further thought, these are not even hwdom. They are dom0 specific.

~Andrew

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

#8 lore raw

Re: [PATCH RFC 3/5] x86: split PV dom0 builder to domain_build_pv.c

In reply to Roger Pau Monné
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 12:06, <[email protected]> wrote:
Quoted 5 lines · Wei Liu

Long term we want to be able to disentangle PV and HVM code. Move the PV domain builder to a dedicated file.

This in turn requires exposing a few functions and variables via a new header domain_build.h.

I would add: "No functional change introduced", to make it clearer that it's mostly just code movement.

Quoted 8 lines
Quoted 5 lines
---
 xen/arch/x86/Makefile          |   1 +
 xen/arch/x86/domain_build.c    | 894 +---------------------------------------
 xen/arch/x86/domain_build.h    |  32 ++

IMHO I would place this in include/asm-x86/, there are really no headers in arch/x86/.

That's the wrong criteria: If all consumers of a header are in the same directory, putting it there is fine (even if it's the first one). In fact in such a case I consider it worse to put it in asm-x86/, as that more widely exposes such a supposedly limited scope header. And along those lines I actually have plans to move some of the stuff currently under include/asm-x86/ into (sub-trees of) arch/x86/.

However, with ...

Quoted 3 lines

xen/arch/x86/domain_build_pv.c

Quoted 1 line
xen/arch/x86/domain_build_pv.c +0 -0

I would place this in arch/xen/x86/pv/domain_build.c

... this the case becomes less clear: Personally I'm not a fan of #include "../file.h", so I wouldn't be certain which of the two is the less undesirable place for the header.

Jan

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

#17 lore raw

Re: [PATCH RFC 4/5] x86: split PVH dom0 builder to domain_build_pv.c

In reply to Wei Liu
Quoted 6 lines · Wei Liu

Long term we want to be able to disentangle PV and HVM code. Move the PVH domain builder to a dedicated file. It will later depends on CONFIG_HVM or CONFIG_PVH.

This in turn requires exposing a few functions and variables via domain_build.h.

Again I would add something along the lines: "No functional changes expected".

Quoted 6 lines
---
 xen/arch/x86/Makefile           |    1 +
 xen/arch/x86/domain_build.c     | 1068 +------------------------------------
 xen/arch/x86/domain_build.h     |    8 +
 xen/arch/x86/domain_build_pvh.c | 1097 +++++++++++++++++++++++++++++++++++++++

I would prefer that to be in arch/x86/hvm/.

xen/arch/x86/domain_build_pvh.c line 3

Quoted 9 lines
xen/arch/x86/domain_build_pvh.c new file +3 -0
new file mode 100644
index 0000000000..6cd3ff2ef2
@@ -0,0 +1,1097 @@
+/******************************************************************************
+ * domain_build_pvh.c
+ */

Since you are already touching this, and it's mostly my code, I would rather prefer that you add the following header:

/******************************************************************************
* arch/x86/hvm/domain_build.c
*
* PVH domain builder
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (c) 2017 Citrix Systems Ltd.
*/

(I wouldn't mind licensing this under a dual GPL/BSD license, but I don't think that's possible or useful inside of Xen).

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

author
#9 lore raw

Re: [PATCH RFC 3/5] x86: split PV dom0 builder to domain_build_pv.c

In reply to Jan Beulich
Quoted 17 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 12:06, <[email protected]> wrote:
Quoted 5 lines · Wei Liu

Long term we want to be able to disentangle PV and HVM code. Move the PV domain builder to a dedicated file.

This in turn requires exposing a few functions and variables via a new header domain_build.h.

I would add: "No functional change introduced", to make it clearer that it's mostly just code movement.

Quoted 5 lines
---
 xen/arch/x86/Makefile          |   1 +
 xen/arch/x86/domain_build.c    | 894 +---------------------------------------
 xen/arch/x86/domain_build.h    |  32 ++
Quoted 7 lines
Quoted 2 lines

IMHO I would place this in include/asm-x86/, there are really no headers in arch/x86/.

That's the wrong criteria: If all consumers of a header are in the same directory, putting it there is fine (even if it's the first one). In fact in such a case I consider it worse to put it in asm-x86/, as that more widely exposes such a supposedly limited scope header. And along

My thought as well.

Quoted 5 lines

those lines I actually have plans to move some of the stuff currently under include/asm-x86/ into (sub-trees of) arch/x86/.

However, with ...

Quoted 8 lines
Quoted 3 lines

xen/arch/x86/domain_build_pv.c

Quoted 1 line
xen/arch/x86/domain_build_pv.c +0 -0

I would place this in arch/xen/x86/pv/domain_build.c

... this the case becomes less clear: Personally I'm not a fan of #include "../file.h", so I wouldn't be certain which of the two is the less undesirable place for the header.

But in this case I would prefer to move the to xen/include/xen and named in dom0_build.h.

Wei.

Quoted 2 lines

Jan

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

author
#18 lore raw

Re: [PATCH RFC 4/5] x86: split PVH dom0 builder to domain_build_pv.c

In reply to Roger Pau Monné
Quoted 32 lines · Roger Pau Monné
Quoted 6 lines · Wei Liu

Long term we want to be able to disentangle PV and HVM code. Move the PVH domain builder to a dedicated file. It will later depends on CONFIG_HVM or CONFIG_PVH.

This in turn requires exposing a few functions and variables via domain_build.h.

Again I would add something along the lines: "No functional changes expected".

Quoted 6 lines
---
 xen/arch/x86/Makefile           |    1 +
 xen/arch/x86/domain_build.c     | 1068 +------------------------------------
 xen/arch/x86/domain_build.h     |    8 +
 xen/arch/x86/domain_build_pvh.c | 1097 +++++++++++++++++++++++++++++++++++++++

I would prefer that to be in arch/x86/hvm/.

xen/arch/x86/domain_build_pvh.c line 3

Quoted 9 lines
xen/arch/x86/domain_build_pvh.c new file +3 -0
new file mode 100644
index 0000000000..6cd3ff2ef2
@@ -0,0 +1,1097 @@
+/******************************************************************************
+ * domain_build_pvh.c
+ */

Since you are already touching this, and it's mostly my code, I would rather prefer that you add the following header:

Quoted 9 lines

/******************************************************************************
* arch/x86/hvm/domain_build.c
*
* PVH domain builder
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.

I suggest we use the inbound licence listed in CONTRIBUTING. I think it is GPL v2 only, without the any later version part.

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

author
#26 lore raw
In reply to Jan Beulich
Quoted 16 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 11:56, <[email protected]> wrote:

On 03/03/17 09:41, Wei Liu wrote:
Jan: Would you be happy accepting my CONFIG_{PV,HVM} patch in its silent form for now? If so, I will respin it.

I think so, yes.

Quoted 9 lines
Quoted 8 lines

This series is built on top of Roger's PVHv1 removal series.

Wei Liu (5):
xen: move round_pg{up,down} to pfn.h
xen: include xen/types.h in domain.h
x86: split PV dom0 builder to domain_build_pv.c
x86: split PVH dom0 builder to domain_build_pv.c
x86: clean up header files in domain_build.c

Quoted 5 lines
Quoted 2 lines

I'd argue that these should be named differently. They are specifically hwdom_build.c, distinct from general domain building operations.

hwdom_build.c is wrong too - this is strictly Dom0, i.e. it ought to be dom0_build.c.

Yes, I agree.

We shall have dom0_build.c, dom0_build_pv.c and dom0_build_pvh.c in v2.

Wei.

Quoted 3 lines

Jan

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

#10 lore raw

Re: [PATCH RFC 3/5] x86: split PV dom0 builder to domain_build_pv.c

In reply to Wei Liu
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 14:35, <[email protected]> wrote:
Quoted 8 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 12:06, <[email protected]> wrote:

On Fri, Mar 03, 2017 at 09:41:09AM +0000, Wei Liu wrote:

However, with ...

Quoted 3 lines

xen/arch/x86/domain_build_pv.c

Quoted 1 line
xen/arch/x86/domain_build_pv.c +0 -0

I would place this in arch/xen/x86/pv/domain_build.c

Quoted 7 lines
Quoted 4 lines

... this the case becomes less clear: Personally I'm not a fan of #include "../file.h", so I wouldn't be certain which of the two is the less undesirable place for the header.

But in this case I would prefer to move the to xen/include/xen and named in dom0_build.h.

Well, it's x86_specific, so if anything include/asm-x86/.

Jan

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

#27 lore raw
In reply to Wei Liu
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 14:41, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 11:56, <[email protected]> wrote:

On 03/03/17 09:41, Wei Liu wrote:
Jan: Would you be happy accepting my CONFIG_{PV,HVM} patch in its silent form for now? If so, I will respin it.

I think so, yes.

Quoted 11 lines
Quoted 8 lines

This series is built on top of Roger's PVHv1 removal series.

Wei Liu (5):
xen: move round_pg{up,down} to pfn.h
xen: include xen/types.h in domain.h
x86: split PV dom0 builder to domain_build_pv.c
x86: split PVH dom0 builder to domain_build_pv.c
x86: clean up header files in domain_build.c

I'd argue that these should be named differently. They are specifically hwdom_build.c, distinct from general domain building operations.

Quoted 6 lines
Quoted 2 lines

hwdom_build.c is wrong too - this is strictly Dom0, i.e. it ought to be dom0_build.c.

Yes, I agree.

We shall have dom0_build.c, dom0_build_pv.c and dom0_build_pvh.c in v2.

You mean

dom0_build.c
hvm/dom0_build.c
pv/dom0_build.c

Jan

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

author
#11 lore raw

Re: [PATCH RFC 3/5] x86: split PV dom0 builder to domain_build_pv.c

In reply to Jan Beulich
Quoted 15 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 14:35, <[email protected]> wrote:
Quoted 12 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 12:06, <[email protected]> wrote:

On Fri, Mar 03, 2017 at 09:41:09AM +0000, Wei Liu wrote:

However, with ...

Quoted 3 lines

xen/arch/x86/domain_build_pv.c

Quoted 1 line
xen/arch/x86/domain_build_pv.c +0 -0

I would place this in arch/xen/x86/pv/domain_build.c

... this the case becomes less clear: Personally I'm not a fan of #include "../file.h", so I wouldn't be certain which of the two is the less undesirable place for the header.

Quoted 5 lines
Quoted 2 lines

But in this case I would prefer to move the to xen/include/xen and named in dom0_build.h.

Well, it's x86_specific, so if anything include/asm-x86/.

OK.

Quoted 2 lines

Jan

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

author
#28 lore raw
In reply to Jan Beulich
Quoted 26 lines · Jan Beulich
Quoted 26 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 14:41, <[email protected]> wrote:
Quoted 16 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 11:56, <[email protected]> wrote:

On 03/03/17 09:41, Wei Liu wrote:
Jan: Would you be happy accepting my CONFIG_{PV,HVM} patch in its silent form for now? If so, I will respin it.

I think so, yes.

Quoted 9 lines
Quoted 8 lines

This series is built on top of Roger's PVHv1 removal series.

Wei Liu (5):
xen: move round_pg{up,down} to pfn.h
xen: include xen/types.h in domain.h
x86: split PV dom0 builder to domain_build_pv.c
x86: split PVH dom0 builder to domain_build_pv.c
x86: clean up header files in domain_build.c

Quoted 5 lines
Quoted 2 lines

I'd argue that these should be named differently. They are specifically hwdom_build.c, distinct from general domain building operations.

hwdom_build.c is wrong too - this is strictly Dom0, i.e. it ought to be dom0_build.c.

Yes, I agree.

Quoted 8 lines
Quoted 1 line

We shall have dom0_build.c, dom0_build_pv.c and dom0_build_pvh.c in v2.

You mean

dom0_build.c
hvm/dom0_build.c
pv/dom0_build.c

Yes, indeed.

Quoted 2 lines

Jan

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

#12 lore raw

Re: [PATCH RFC 3/5] x86: split PV dom0 builder to domain_build_pv.c

In reply to Wei Liu
Quoted 9 lines · Wei Liu
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 14:35, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 12:06, <[email protected]> wrote:

On Fri, Mar 03, 2017 at 09:41:09AM +0000, Wei Liu wrote:

However, with ...

Quoted 2 lines

xen/arch/x86/domain_build_pv.c

Quoted 1 line
xen/arch/x86/domain_build_pv.c +0 -0

I would place this in arch/xen/x86/pv/domain_build.c

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

... this the case becomes less clear: Personally I'm not a fan of #include "../file.h", so I wouldn't be certain which of the two is the less undesirable place for the header.

But in this case I would prefer to move the to xen/include/xen and named in dom0_build.h.

Well, it's x86_specific, so if anything include/asm-x86/.

On a related tangent, I'd like to clean up our include hierachy, in the same way Linux has.

I.e.

move include/asm-x86/ to arch/x86/include/asm

and include/asm-arm/ to arch/arm/include/asm

which allows for the removal of all symlink games, which get in the way of tools like cscope/tags.

Are people amenable to this? (I seem to recall asking before, and it not being objected to).

~Andrew

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

#13 lore raw

Re: [PATCH RFC 3/5] x86: split PV dom0 builder to domain_build_pv.c

Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 15:49, <[email protected]> wrote:

On a related tangent, I'd like to clean up our include hierachy, in the same way Linux has.

I.e.

move include/asm-x86/ to arch/x86/include/asm

Quoted 7 lines

and include/asm-arm/ to arch/arm/include/asm

which allows for the removal of all symlink games, which get in the way of tools like cscope/tags.

Are people amenable to this? (I seem to recall asking before, and it not being objected to).

Well, I'm not overly interested in code getting moved around, but I also don't really object. I have to admit that I never really understood why Linux absolutely wanted it that way (and no, external tool limitations don't really count as an argument imo).

Jan

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

#19 lore raw

Re: [PATCH RFC 4/5] x86: split PVH dom0 builder to domain_build_pv.c

In reply to Wei Liu
Quoted 21 lines · Wei Liu
Quoted 10 lines · Roger Pau Monné

xen/arch/x86/domain_build_pvh.c line 3

Quoted 5 lines · Wei Liu

+++ b/xen/arch/x86/domain_build_pvh.c

xen/arch/x86/domain_build_pvh.c new file +3 -0
@@ -0,0 +1,1097 @@
+/******************************************************************************
+ * domain_build_pvh.c
+ */

Since you are already touching this, and it's mostly my code, I would rather prefer that you add the following header:

Quoted 9 lines

/******************************************************************************
* arch/x86/hvm/domain_build.c
*
* PVH domain builder
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.

Quoted 2 lines

I suggest we use the inbound licence listed in CONTRIBUTING. I think it is GPL v2 only, without the any later version part.

That's perfectly fine for me.

Thanks, Roger.

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

#15 lore raw

Re: [PATCH RFC 3/5] x86: split PV dom0 builder to domain_build_pv.c

In reply to Wei Liu
Quoted 56 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 10:41, <[email protected]> wrote:
xen/arch/x86/domain_build.c +0 -51
@@ -258,66 +260,7 @@ string_param("dom0_ioports_disable", opt_dom0_ioports_disable);
 static bool_t __initdata ro_hpet = 1;
 boolean_param("ro-hpet", ro_hpet);
 
-/* Allow ring-3 access in long mode as guest cannot use ring 1 ... */
-#define BASE_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_USER)
-#define L1_PROT (BASE_PROT|_PAGE_GUEST_KERNEL)
-/* ... except for compatibility mode guests. */
-#define COMPAT_L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
-#define L2_PROT (BASE_PROT|_PAGE_DIRTY)
-#define L3_PROT (BASE_PROT|_PAGE_DIRTY)
-#define L4_PROT (BASE_PROT|_PAGE_DIRTY)
-
-static unsigned int __initdata memflags = MEMF_no_dma|MEMF_exact_node;
-
-static struct page_info * __init alloc_chunk(
-    struct domain *d, unsigned long max_pages)
-{
-    static unsigned int __initdata last_order = MAX_ORDER;
-    struct page_info *page;
-    unsigned int order = get_order_from_pages(max_pages), free_order;
-
-    if ( order > last_order )
-        order = last_order;
-    else if ( max_pages & (max_pages - 1) )
-        --order;
-    while ( (page = alloc_domheap_pages(d, order, memflags)) == NULL )
-        if ( order-- == 0 )
-            break;
-    if ( page )
-        last_order = order;
-    else if ( memflags )
-    {
-        /*
-         * Allocate up to 2MB at a time: It prevents allocating very large
-         * chunks from DMA pools before the >4GB pool is fully depleted.
-         */
-        last_order = 21 - PAGE_SHIFT;
-        memflags = 0;
-        return alloc_chunk(d, max_pages);
-    }
-
-    /*
-     * Make a reasonable attempt at finding a smaller chunk at a higher
-     * address, to avoid allocating from low memory as much as possible.
-     */
-    for ( free_order = order; !memflags && page && order--; )
-    {
-        struct page_info *pg2;
-
-        if ( d->tot_pages + (1 << order) > d->max_pages )
-            continue;
-        pg2 = alloc_domheap_pages(d, order, MEMF_exact_node);
-        if ( pg2 > page )
-        {

xen/arch/x86/domain_build.c string_param("dom0_ioports_disable", opt_dom0_ioports_disable); · line 263

Quoted 10 lines
xen/arch/x86/domain_build.c +1 -9
-            free_domheap_pages(page, free_order);
-            page = pg2;
-            free_order = order;
-        }
-        else if ( pg2 )
-            free_domheap_pages(pg2, order);
-    }
-    return page;
-}
+unsigned int __initdata memflags = MEMF_no_dma|MEMF_exact_node;

Making a variable with this name non-static requires adding a suitable prefix, e.g dom0_. setup_permissions() has the same issue.

Jan

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

#20 lore raw

Re: [PATCH RFC 4/5] x86: split PVH dom0 builder to domain_build_pv.c

In reply to Wei Liu
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 10:41, <[email protected]> wrote:

Long term we want to be able to disentangle PV and HVM code. Move the PVH domain builder to a dedicated file. It will later depends on CONFIG_HVM or CONFIG_PVH.

This in turn requires exposing a few functions and variables via domain_build.h.

There are no affected variables here afaics.

Jan

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

Acked-by on v1 5/5
#22 lore raw

Re: [PATCH RFC 5/5] x86: clean up header files in domain_build.c

In reply to Wei Liu
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 10:41, <[email protected]> wrote:

Remove the ones that are no longer needed and sort them.

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

author
#14 lore raw

Re: [PATCH RFC 3/5] x86: split PV dom0 builder to domain_build_pv.c

In reply to Andrew Cooper
Quoted 26 lines · Andrew Cooper
Quoted 9 lines · Wei Liu
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 14:35, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 03.03.17 at 12:06, <[email protected]> wrote:

On Fri, Mar 03, 2017 at 09:41:09AM +0000, Wei Liu wrote:

However, with ...

Quoted 2 lines

xen/arch/x86/domain_build_pv.c

Quoted 1 line
xen/arch/x86/domain_build_pv.c +0 -0

I would place this in arch/xen/x86/pv/domain_build.c

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

... this the case becomes less clear: Personally I'm not a fan of #include "../file.h", so I wouldn't be certain which of the two is the less undesirable place for the header.

But in this case I would prefer to move the to xen/include/xen and named in dom0_build.h.

Well, it's x86_specific, so if anything include/asm-x86/.

On a related tangent, I'd like to clean up our include hierachy, in the same way Linux has.

I.e.

move include/asm-x86/ to arch/x86/include/asm

Quoted 8 lines

and include/asm-arm/ to arch/arm/include/asm

which allows for the removal of all symlink games, which get in the way of tools like cscope/tags.

Are people amenable to this? (I seem to recall asking before, and it not being objected to).

+0 from me. Avoiding symlink game is good, but the current system isn't really broken either.

Wei.

Quoted 1 line

~Andrew

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