Skip to contentSkip to conversation

Add hypervisor sysfs-like support

PATCH Superseded Juergen Gross 9 participants 42 messages Jan 21, 2020 – Jun 3, 2020

v3 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add hypervisor sysfs-like support

On the 2019 Xen developer summit there was agreement that the Xen hypervisor should gain support for a hierarchical name-value store similar to the Linux kernel's sysfs.

This is a first implementation of that idea adding the basic functionality to hypervisor and tools side. The interface to any user program making use of that "xen-hypfs" is a new library "libxenhypfs" with a stable interface.

As a followup switching libxl to use the hypervisor file system for runtime parameter modifications is possible. This would enable removal of the XEN_SYSCTL_set_parameter sysctl operation.

Changes in V3:
- major rework, especially by supporting binary contents of entries
- added several new patches (1, 2, 7)
- full support of all runtime parameters
- support of writing entries (especially runtime parameters)

Changes in V2:
- all comments to V1 addressed
- added man-page for xenhypfs tool
- added runtime parameter read access for string parameters

Changes in V1:
- renamed xenfs ->xenhypfs
- added writable entries support at the interface level and in the xenhypfs tool
- added runtime parameter read access (integer type only for now)
- added docs/misc/hypfs-paths.pandoc for path descriptions

Juergen Gross (9):
xen: add a generic way to include binary files as variables
xen: split parameter related definitions in own header file
docs: add feature document for Xen hypervisor sysfs-like support
xen: add basic hypervisor filesystem support
libs: add libxenhypfs
tools: add xenfs tool
xen: provide version information in hypfs
xen: add /buildinfo/config entry to hypervisor filesystem
xen: add runtime parameter access support to hypfs

 .gitignore                               |   6 +
 docs/features/hypervisorfs.pandoc        |  86 +++++
 docs/man/xenhypfs.1.pod                  |  61 ++++
 docs/misc/hypfs-paths.pandoc             | 153 +++++++++
 tools/Rules.mk                           |   6 +
 tools/libs/Makefile                      |   1 +
 tools/libs/hypfs/Makefile                |  16 +
 tools/libs/hypfs/core.c                  | 535 +++++++++++++++++++++++++++++++
 tools/libs/hypfs/include/xenhypfs.h      |  75 +++++
 tools/libs/hypfs/libxenhypfs.map         |  10 +
 tools/libs/hypfs/xenhypfs.pc.in          |  10 +
 tools/misc/Makefile                      |   6 +
 tools/misc/xenhypfs.c                    | 189 +++++++++++
 xen/arch/arm/acpi/boot.c                 |   1 +
 xen/arch/arm/cpuerrata.c                 |   1 +
 xen/arch/arm/domain_build.c              |   1 +
 xen/arch/arm/gic-v3-lpi.c                |   1 +
 xen/arch/arm/setup.c                     |   1 +
 xen/arch/arm/smpboot.c                   |   1 +
 xen/arch/arm/traps.c                     |   2 +
 xen/arch/arm/xen.lds.S                   |   5 +
 xen/arch/x86/acpi/boot.c                 |   1 +
 xen/arch/x86/acpi/cpu_idle.c             |   1 +
 xen/arch/x86/acpi/cpufreq/cpufreq.c      |   1 +
 xen/arch/x86/acpi/power.c                |   1 +
 xen/arch/x86/apic.c                      |   1 +
 xen/arch/x86/cpu/amd.c                   |   1 +
 xen/arch/x86/cpu/common.c                |   1 +
 xen/arch/x86/cpu/mcheck/mce.c            |   1 +
 xen/arch/x86/cpu/mcheck/mce_intel.c      |   1 +
 xen/arch/x86/cpu/mtrr/generic.c          |   1 +
 xen/arch/x86/cpu/mwait-idle.c            |   1 +
 xen/arch/x86/cpu/vpmu.c                  |   1 +
 xen/arch/x86/cpuid.c                     |   1 +
 xen/arch/x86/dom0_build.c                |   1 +
 xen/arch/x86/e820.c                      |   1 +
 xen/arch/x86/genapic/probe.c             |   1 +
 xen/arch/x86/genapic/x2apic.c            |   1 +
 xen/arch/x86/hpet.c                      |   1 +
 xen/arch/x86/hvm/asid.c                  |   1 +
 xen/arch/x86/hvm/hvm.c                   |   1 +
 xen/arch/x86/hvm/hypercall.c             |   1 +
 xen/arch/x86/hvm/quirks.c                |   1 +
 xen/arch/x86/hvm/viridian/viridian.c     |   1 +
 xen/arch/x86/hvm/vmx/vmcs.c              |  18 +-
 xen/arch/x86/hvm/vmx/vmx.c               |   1 +
 xen/arch/x86/hypercall.c                 |   1 +
 xen/arch/x86/io_apic.c                   |   1 +
 xen/arch/x86/irq.c                       |   1 +
 xen/arch/x86/microcode.c                 |   1 +
 xen/arch/x86/mm.c                        |   1 +
 xen/arch/x86/mm/p2m.c                    |   1 +
 xen/arch/x86/msi.c                       |   1 +
 xen/arch/x86/nmi.c                       |   1 +
 xen/arch/x86/numa.c                      |   1 +
 xen/arch/x86/oprofile/nmi_int.c          |   1 +
 xen/arch/x86/psr.c                       |   1 +
 xen/arch/x86/pv/domain.c                 |   8 +-
 xen/arch/x86/pv/hypercall.c              |   1 +
 xen/arch/x86/pv/shim.c                   |   1 +
 xen/arch/x86/setup.c                     |   1 +
 xen/arch/x86/shutdown.c                  |   1 +
 xen/arch/x86/spec_ctrl.c                 |   1 +
 xen/arch/x86/tboot.c                     |   1 +
 xen/arch/x86/time.c                      |   1 +
 xen/arch/x86/traps.c                     |   1 +
 xen/arch/x86/tsx.c                       |   1 +
 xen/arch/x86/x86_64/mmconfig-shared.c    |   1 +
 xen/arch/x86/xen.lds.S                   |   5 +
 xen/arch/x86/xstate.c                    |   1 +
 xen/common/Makefile                      |  13 +
 xen/common/argo.c                        |   1 +
 xen/common/core_parking.c                |   1 +
 xen/common/cpupool.c                     |   1 +
 xen/common/debugtrace.c                  |   1 +
 xen/common/domain.c                      |   1 +
 xen/common/efi/boot.c                    |   1 +
 xen/common/gdbstub.c                     |   1 +
 xen/common/grant_table.c                 |  18 +-
 xen/common/hypfs.c                       | 403 +++++++++++++++++++++++
 xen/common/kernel.c                      |  79 ++++-
 xen/common/kexec.c                       |   1 +
 xen/common/memory.c                      |   1 +
 xen/common/page_alloc.c                  |   1 +
 xen/common/rcupdate.c                    |   1 +
 xen/common/sched_credit.c                |   1 +
 xen/common/sched_credit2.c               |   1 +
 xen/common/schedule.c                    |   1 +
 xen/common/shutdown.c                    |   1 +
 xen/common/timer.c                       |   1 +
 xen/common/trace.c                       |   1 +
 xen/drivers/acpi/apei/hest.c             |   1 +
 xen/drivers/acpi/tables.c                |   1 +
 xen/drivers/char/arm-uart.c              |   1 +
 xen/drivers/char/console.c               |  50 ++-
 xen/drivers/char/ehci-dbgp.c             |   1 +
 xen/drivers/char/ns16550.c               |   1 +
 xen/drivers/char/serial.c                |   1 +
 xen/drivers/cpufreq/cpufreq.c            |   1 +
 xen/drivers/passthrough/amd/iommu_acpi.c |   1 +
 xen/drivers/passthrough/iommu.c          |   1 +
 xen/drivers/passthrough/pci.c            |   1 +
 xen/drivers/passthrough/vtd/dmar.c       |   1 +
 xen/drivers/passthrough/vtd/quirks.c     |   1 +
 xen/drivers/passthrough/vtd/x86/vtd.c    |   1 +
 xen/drivers/passthrough/x86/ats.c        |   1 +
 xen/drivers/video/vesa.c                 |   1 +
 xen/drivers/video/vga.c                  |   1 +
 xen/include/public/hypfs.h               | 124 +++++++
 xen/include/public/xen.h                 |   1 +
 xen/include/xen/hypercall.h              |   8 +
 xen/include/xen/hypfs.h                  |  93 ++++++
 xen/include/xen/init.h                   | 120 -------
 xen/include/xen/kernel.h                 |   3 +
 xen/include/xen/param.h                  | 184 +++++++++++
 xen/tools/binfile                        |  29 ++
 xen/xsm/flask/Makefile                   |   5 +-
 xen/xsm/flask/flask-policy.S             |  16 -
 xen/xsm/flask/flask_op.c                 |   1 +
 xen/xsm/xsm_core.c                       |   1 +
 120 files changed, 2274 insertions(+), 151 deletions(-)
 create mode 100644 docs/features/hypervisorfs.pandoc
 create mode 100644 docs/man/xenhypfs.1.pod
 create mode 100644 docs/misc/hypfs-paths.pandoc
 create mode 100644 tools/libs/hypfs/Makefile
 create mode 100644 tools/libs/hypfs/core.c
 create mode 100644 tools/libs/hypfs/include/xenhypfs.h
 create mode 100644 tools/libs/hypfs/libxenhypfs.map
 create mode 100644 tools/libs/hypfs/xenhypfs.pc.in
 create mode 100644 tools/misc/xenhypfs.c
 create mode 100644 xen/common/hypfs.c
 create mode 100644 xen/include/public/hypfs.h
 create mode 100644 xen/include/xen/hypfs.h
 create mode 100644 xen/include/xen/param.h
 create mode 100755 xen/tools/binfile
 delete mode 100644 xen/xsm/flask/flask-policy.S
Signature · 7 lines
2.16.4


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

PATCH v3 1/9 xen: add a generic way to include binary files as variables

Add a new script xen/tools/binfile for including a binary file at build time being usable via a pointer and a size variable in the hypervisor.

Make use of that generic tool in xsm.

---
V3:
- new patch

---
 .gitignore                   |  1 +
 xen/tools/binfile            | 29 +++++++++++++++++++++++++++++
 xen/xsm/flask/Makefile       |  5 ++++-
 xen/xsm/flask/flask-policy.S | 16 ----------------
 4 files changed, 34 insertions(+), 17 deletions(-)
 create mode 100755 xen/tools/binfile
 delete mode 100644 xen/xsm/flask/flask-policy.S
.gitignore +1 -0
index 4ca679ddbc..b2624df79a 100644
@@ -313,6 +313,7 @@ xen/test/livepatch/*.livepatch
 xen/tools/kconfig/.tmp_gtkcheck
 xen/tools/kconfig/.tmp_qtcheck
 xen/tools/symbols
+xen/xsm/flask/flask-policy.S
 xen/xsm/flask/include/av_perm_to_string.h
 xen/xsm/flask/include/av_permissions.h
 xen/xsm/flask/include/class_to_string.h
xen/tools/binfile new file +29 -0
new file mode 100755
index 0000000000..122111ff6d
@@ -0,0 +1,29 @@
+#!/bin/sh
+# usage: binfile [-i] <target-src.S> <binary-file> <varname>
+# -i     add to .init.rodata (default: .rodata) section
+
+[ "$1" = "-i" ] && {
+    shift
+    section=".init"
+}
+
+target=$1
+binsource=$2
+varname=$3
+
+cat <<EOF >$target
+#include <asm/asm_defns.h>
+
+        .section $section.rodata, "a", %progbits
+
+        .global $varname
+$varname:
+        .incbin "$binsource"
+.Lend:
+
+        .type $varname, %object
+        .size $varname, . - $varname
+
+        .global ${varname}_size
+        ASM_INT(${varname}_size, .Lend - $varname)
+EOF
xen/xsm/flask/Makefile +4 -1
index 7c3f381287..a807521235 100644
@@ -30,6 +30,9 @@ $(AV_H_FILES): $(AV_H_DEPEND)
 obj-bin-$(CONFIG_XSM_FLASK_POLICY) += flask-policy.o
 flask-policy.o: policy.bin
 
+flask-policy.S: $(XEN_ROOT)/xen/tools/binfile
+	$(XEN_ROOT)/xen/tools/binfile -i $@ policy.bin xsm_flask_init_policy
+
 FLASK_BUILD_DIR := $(CURDIR)
 POLICY_SRC := $(FLASK_BUILD_DIR)/xenpolicy-$(XEN_FULLVERSION)
 
@@ -39,4 +42,4 @@ policy.bin: FORCE
 
 .PHONY: clean
 clean::
-	rm -f $(ALL_H_FILES) *.o $(DEPS_RM) policy.* $(POLICY_SRC)
+	rm -f $(ALL_H_FILES) *.o $(DEPS_RM) policy.* $(POLICY_SRC) flask-policy.S
xen/xsm/flask/flask-policy.S deleted +0 -16
deleted file mode 100644
index d38aa39964..0000000000
@@ -1,16 +0,0 @@
-#include <asm/asm_defns.h>
-
-        .section .init.rodata, "a", %progbits
-
-/* const unsigned char xsm_flask_init_policy[] __initconst */
-        .global xsm_flask_init_policy
-xsm_flask_init_policy:
-        .incbin "policy.bin"
-.Lend:
-
-        .type xsm_flask_init_policy, %object
-        .size xsm_flask_init_policy, . - xsm_flask_init_policy
-
-/* const unsigned int __initconst xsm_flask_init_policy_size */
-        .global xsm_flask_init_policy_size
-        ASM_INT(xsm_flask_init_policy_size, .Lend - xsm_flask_init_policy)
Signature · 7 lines
2.16.4


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

Re: [Xen-devel] [PATCH v3 1/9] xen: add a generic way to include binary files as variables

Quoted 18 lines · Juergen Gross
xen/tools/binfile new file +15 -0
@@ -0,0 +1,29 @@
+#!/bin/sh
+# usage: binfile [-i] <target-src.S> <binary-file> <varname>
+# -i     add to .init.rodata (default: .rodata) section
+
+[ "$1" = "-i" ] && {
+    shift
+    section=".init"
+}
+
+target=$1
+binsource=$2
+varname=$3
+
+cat <<EOF >$target
+#include <asm/asm_defns.h>

xen/tools/binfile line 25

Quoted 10 lines
xen/tools/binfile new file +10 -0
+
+        .section $section.rodata, "a", %progbits
+
+        .global $varname
+$varname:
+        .incbin "$binsource"
+.Lend:
+
+        .type $varname, %object
+        .size $varname, . - $varname

I'd prefer if you used .Lend here as well.

I wonder whether, right from the beginning, there wouldn't better be a way to also request better than byte alignment for such a blob.

xen/xsm/flask/Makefile $(AV_H_FILES): $(AV_H_DEPEND) · line 34

Quoted 8 lines
xen/xsm/flask/Makefile +2 -0
@@ -30,6 +30,9 @@ $(AV_H_FILES): $(AV_H_DEPEND)
 obj-bin-$(CONFIG_XSM_FLASK_POLICY) += flask-policy.o
 flask-policy.o: policy.bin
 
+flask-policy.S: $(XEN_ROOT)/xen/tools/binfile
+	$(XEN_ROOT)/xen/tools/binfile -i $@ policy.bin xsm_flask_init_policy

Doesn't objcopy provide a means to convert a binary blob into an ELF object containing the binary data from the input file? If so, why involve the assembler and an intermediate file here?

Jan

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

#3 lore raw

Re: [Xen-devel] [PATCH v3 1/9] xen: add a generic way to include binary files as variables

Quoted 23 lines · Jan Beulich
Quoted 22 lines · Juergen Gross
xen/tools/binfile new file +19 -0
@@ -0,0 +1,29 @@
+#!/bin/sh
+# usage: binfile [-i] <target-src.S> <binary-file> <varname>
+# -i     add to .init.rodata (default: .rodata) section
+
+[ "$1" = "-i" ] && {
+    shift
+    section=".init"
+}
+
+target=$1
+binsource=$2
+varname=$3
+
+cat <<EOF >$target
+#include <asm/asm_defns.h>
+
+        .section $section.rodata, "a", %progbits
+
+        .global $varname
Quoted 8 lines

xen/tools/binfile line 25

Quoted 6 lines
xen/tools/binfile new file +6 -0
+$varname:
+        .incbin "$binsource"
+.Lend:
+
+        .type $varname, %object
+        .size $varname, . - $varname

I'd prefer if you used .Lend here as well.

Okay.

Quoted 3 lines

I wonder whether, right from the beginning, there wouldn't better be a way to also request better than byte alignment for such a blob.

I can add that. What about "-a <n>" for 2^n alignment?

Quoted 7 lines
Quoted 7 lines
xen/xsm/flask/Makefile +0 -0
@@ -30,6 +30,9 @@ $(AV_H_FILES): $(AV_H_DEPEND)
  obj-bin-$(CONFIG_XSM_FLASK_POLICY) += flask-policy.o
  flask-policy.o: policy.bin
 
Quoted 6 lines

xen/xsm/flask/Makefile $(AV_H_FILES): $(AV_H_DEPEND) · line 34

Quoted 2 lines
xen/xsm/flask/Makefile +2 -0
+flask-policy.S: $(XEN_ROOT)/xen/tools/binfile
+	$(XEN_ROOT)/xen/tools/binfile -i $@ policy.bin xsm_flask_init_policy

Doesn't objcopy provide a means to convert a binary blob into an ELF object containing the binary data from the input file? If so, why involve the assembler and an intermediate file here?

I can see how to add a symbol for that purpose using a dedicated section for each blob, but how to add the size information of the blob?

In the end I just followed commit 8d5671eb31e4bf for the inclusion of the blob.

Juergen

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

#4 lore raw

Re: [Xen-devel] [PATCH v3 1/9] xen: add a generic way to include binary files as variables

Quoted 33 lines · Jürgen Groß
Quoted 23 lines · Jan Beulich
Quoted 22 lines · Juergen Gross
xen/tools/binfile new file +19 -0
@@ -0,0 +1,29 @@
+#!/bin/sh
+# usage: binfile [-i] <target-src.S> <binary-file> <varname>
+# -i     add to .init.rodata (default: .rodata) section
+
+[ "$1" = "-i" ] && {
+    shift
+    section=".init"
+}
+
+target=$1
+binsource=$2
+varname=$3
+
+cat <<EOF >$target
+#include <asm/asm_defns.h>
+
+        .section $section.rodata, "a", %progbits
+
+        .global $varname
Quoted 8 lines

xen/tools/binfile line 25

Quoted 6 lines
xen/tools/binfile new file +6 -0
+$varname:
+        .incbin "$binsource"
+.Lend:
+
+        .type $varname, %object
+        .size $varname, . - $varname

I'd prefer if you used .Lend here as well.

Quoted 7 lines

Okay.

Quoted 3 lines

I wonder whether, right from the beginning, there wouldn't better be a way to also request better than byte alignment for such a blob.

I can add that. What about "-a <n>" for 2^n alignment?

SGTM.

Quoted 13 lines
Quoted 6 lines
Quoted 6 lines
xen/xsm/flask/Makefile +0 -0
@@ -30,6 +30,9 @@ $(AV_H_FILES): $(AV_H_DEPEND)
  obj-bin-$(CONFIG_XSM_FLASK_POLICY) += flask-policy.o
  flask-policy.o: policy.bin
 
Quoted 6 lines

xen/xsm/flask/Makefile $(AV_H_FILES): $(AV_H_DEPEND) · line 34

Quoted 2 lines
xen/xsm/flask/Makefile +2 -0
+flask-policy.S: $(XEN_ROOT)/xen/tools/binfile
+	$(XEN_ROOT)/xen/tools/binfile -i $@ policy.bin xsm_flask_init_policy

Doesn't objcopy provide a means to convert a binary blob into an ELF object containing the binary data from the input file? If so, why involve the assembler and an intermediate file here?

Quoted 2 lines

I can see how to add a symbol for that purpose using a dedicated section for each blob, but how to add the size information of the blob?

Hmm, right. It would be doable, but perhaps indeed not very nice. Fair enough then.

Jan

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

#5 lore raw

PATCH v3 2/9 xen: split parameter related definitions in own header file

In reply to Juergen Gross

Move the parameter related definitions from init.h into a new header file param.h. This will avoid include hell when new dependencies are added to parameter definitions.

---
V3:
- new patch

---
 xen/arch/arm/acpi/boot.c                 |   1 +
 xen/arch/arm/cpuerrata.c                 |   1 +
 xen/arch/arm/domain_build.c              |   1 +
 xen/arch/arm/gic-v3-lpi.c                |   1 +
 xen/arch/arm/setup.c                     |   1 +
 xen/arch/arm/smpboot.c                   |   1 +
 xen/arch/arm/traps.c                     |   1 +
 xen/arch/x86/acpi/boot.c                 |   1 +
 xen/arch/x86/acpi/cpu_idle.c             |   1 +
 xen/arch/x86/acpi/cpufreq/cpufreq.c      |   1 +
 xen/arch/x86/acpi/power.c                |   1 +
 xen/arch/x86/apic.c                      |   1 +
 xen/arch/x86/cpu/amd.c                   |   1 +
 xen/arch/x86/cpu/common.c                |   1 +
 xen/arch/x86/cpu/mcheck/mce.c            |   1 +
 xen/arch/x86/cpu/mcheck/mce_intel.c      |   1 +
 xen/arch/x86/cpu/mtrr/generic.c          |   1 +
 xen/arch/x86/cpu/mwait-idle.c            |   1 +
 xen/arch/x86/cpu/vpmu.c                  |   1 +
 xen/arch/x86/cpuid.c                     |   1 +
 xen/arch/x86/dom0_build.c                |   1 +
 xen/arch/x86/e820.c                      |   1 +
 xen/arch/x86/genapic/probe.c             |   1 +
 xen/arch/x86/genapic/x2apic.c            |   1 +
 xen/arch/x86/hpet.c                      |   1 +
 xen/arch/x86/hvm/asid.c                  |   1 +
 xen/arch/x86/hvm/hvm.c                   |   1 +
 xen/arch/x86/hvm/quirks.c                |   1 +
 xen/arch/x86/hvm/viridian/viridian.c     |   1 +
 xen/arch/x86/hvm/vmx/vmcs.c              |   1 +
 xen/arch/x86/hvm/vmx/vmx.c               |   1 +
 xen/arch/x86/io_apic.c                   |   1 +
 xen/arch/x86/irq.c                       |   1 +
 xen/arch/x86/microcode.c                 |   1 +
 xen/arch/x86/mm.c                        |   1 +
 xen/arch/x86/mm/p2m.c                    |   1 +
 xen/arch/x86/msi.c                       |   1 +
 xen/arch/x86/nmi.c                       |   1 +
 xen/arch/x86/numa.c                      |   1 +
 xen/arch/x86/oprofile/nmi_int.c          |   1 +
 xen/arch/x86/psr.c                       |   1 +
 xen/arch/x86/pv/domain.c                 |   1 +
 xen/arch/x86/pv/shim.c                   |   1 +
 xen/arch/x86/setup.c                     |   1 +
 xen/arch/x86/shutdown.c                  |   1 +
 xen/arch/x86/spec_ctrl.c                 |   1 +
 xen/arch/x86/tboot.c                     |   1 +
 xen/arch/x86/time.c                      |   1 +
 xen/arch/x86/traps.c                     |   1 +
 xen/arch/x86/tsx.c                       |   1 +
 xen/arch/x86/x86_64/mmconfig-shared.c    |   1 +
 xen/arch/x86/xstate.c                    |   1 +
 xen/common/argo.c                        |   1 +
 xen/common/core_parking.c                |   1 +
 xen/common/cpupool.c                     |   1 +
 xen/common/debugtrace.c                  |   1 +
 xen/common/domain.c                      |   1 +
 xen/common/efi/boot.c                    |   1 +
 xen/common/gdbstub.c                     |   1 +
 xen/common/grant_table.c                 |   1 +
 xen/common/kernel.c                      |   1 +
 xen/common/kexec.c                       |   1 +
 xen/common/memory.c                      |   1 +
 xen/common/page_alloc.c                  |   1 +
 xen/common/rcupdate.c                    |   1 +
 xen/common/sched_credit.c                |   1 +
 xen/common/sched_credit2.c               |   1 +
 xen/common/schedule.c                    |   1 +
 xen/common/shutdown.c                    |   1 +
 xen/common/timer.c                       |   1 +
 xen/common/trace.c                       |   1 +
 xen/drivers/acpi/apei/hest.c             |   1 +
 xen/drivers/acpi/tables.c                |   1 +
 xen/drivers/char/arm-uart.c              |   1 +
 xen/drivers/char/console.c               |   1 +
 xen/drivers/char/ehci-dbgp.c             |   1 +
 xen/drivers/char/ns16550.c               |   1 +
 xen/drivers/char/serial.c                |   1 +
 xen/drivers/cpufreq/cpufreq.c            |   1 +
 xen/drivers/passthrough/amd/iommu_acpi.c |   1 +
 xen/drivers/passthrough/iommu.c          |   1 +
 xen/drivers/passthrough/pci.c            |   1 +
 xen/drivers/passthrough/vtd/dmar.c       |   1 +
 xen/drivers/passthrough/vtd/quirks.c     |   1 +
 xen/drivers/passthrough/vtd/x86/vtd.c    |   1 +
 xen/drivers/passthrough/x86/ats.c        |   1 +
 xen/drivers/video/vesa.c                 |   1 +
 xen/drivers/video/vga.c                  |   1 +
 xen/include/xen/init.h                   | 120 -----------------------------
 xen/include/xen/param.h                  | 126 +++++++++++++++++++++++++++++++
 xen/xsm/flask/flask_op.c                 |   1 +
 xen/xsm/xsm_core.c                       |   1 +
 92 files changed, 216 insertions(+), 120 deletions(-)
 create mode 100644 xen/include/xen/param.h
xen/arch/arm/acpi/boot.c +1 -0
index bf9c78b02c..30e4bd1bc5 100644
@@ -30,6 +30,7 @@
 #include <xen/errno.h>
 #include <acpi/actables.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/device_tree.h>
 
 #include <asm/acpi.h>
xen/arch/arm/cpuerrata.c +1 -0
index da72b02442..0248893de0 100644
@@ -2,6 +2,7 @@
 #include <xen/cpumask.h>
 #include <xen/init.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/sizes.h>
 #include <xen/smp.h>
 #include <xen/spinlock.h>
xen/arch/arm/domain_build.c +1 -0
index dd9c3b73ba..d2d11eda26 100644
@@ -2,6 +2,7 @@
 #include <xen/compile.h>
 #include <xen/lib.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/domain_page.h>
 #include <xen/sched.h>
 #include <xen/sizes.h>
xen/arch/arm/gic-v3-lpi.c +1 -0
index 78b9521b21..869bc97fa1 100644
@@ -20,6 +20,7 @@
 
 #include <xen/lib.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/sizes.h>
 #include <xen/warning.h>
xen/arch/arm/setup.c +1 -0
index 9dd3738d44..5d8eb46203 100644
@@ -30,6 +30,7 @@
 #include <xen/init.h>
 #include <xen/irq.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/softirq.h>
 #include <xen/keyhandler.h>
 #include <xen/cpu.h>
xen/arch/arm/smpboot.c +1 -0
index 00b64c3322..cae2179126 100644
@@ -23,6 +23,7 @@
 #include <xen/errno.h>
 #include <xen/init.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/smp.h>
 #include <xen/softirq.h>
xen/arch/arm/traps.c +1 -0
index a20474f87c..6f9bec22d3 100644
@@ -26,6 +26,7 @@
 #include <xen/livepatch.h>
 #include <xen/mem_access.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/perfc.h>
 #include <xen/smp.h>
 #include <xen/softirq.h>
xen/arch/x86/acpi/boot.c +1 -0
index 15542a9bdf..2aae4b480a 100644
@@ -27,6 +27,7 @@
 #include <xen/acpi.h>
 #include <xen/irq.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/dmi.h>
 #include <asm/fixmap.h>
 #include <asm/page.h>
xen/arch/x86/acpi/cpu_idle.c +1 -0
index 5edd1844f4..b9d99a0468 100644
@@ -37,6 +37,7 @@
 #include <xen/smp.h>
 #include <xen/guest_access.h>
 #include <xen/keyhandler.h>
+#include <xen/param.h>
 #include <xen/trace.h>
 #include <xen/irq.h>
 #include <asm/cache.h>
xen/arch/x86/acpi/cpufreq/cpufreq.c +1 -0
index f05275578d..281be131a3 100644
@@ -31,6 +31,7 @@
 #include <xen/errno.h>
 #include <xen/delay.h>
 #include <xen/cpumask.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/timer.h>
 #include <xen/xmalloc.h>
xen/arch/x86/acpi/power.c +1 -0
index 8078352312..f5f4aa9bda 100644
@@ -14,6 +14,7 @@
 #include <xen/acpi.h>
 #include <xen/errno.h>
 #include <xen/iocap.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <asm/acpi.h>
 #include <asm/irq.h>
xen/arch/x86/apic.c +1 -0
index a6a7754d77..2d68396feb 100644
@@ -20,6 +20,7 @@
 #include <xen/errno.h>
 #include <xen/init.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/irq.h>
 #include <xen/delay.h>
xen/arch/x86/cpu/amd.c +1 -0
index 8b5f0f2e4c..e351dd227f 100644
@@ -1,6 +1,7 @@
 #include <xen/init.h>
 #include <xen/bitops.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/smp.h>
 #include <xen/pci.h>
 #include <asm/io.h>
xen/arch/x86/cpu/common.c +1 -0
index e5ad17d8d9..1b33f1ed71 100644
@@ -1,6 +1,7 @@
 #include <xen/init.h>
 #include <xen/string.h>
 #include <xen/delay.h>
+#include <xen/param.h>
 #include <xen/smp.h>
 #include <asm/current.h>
 #include <asm/debugreg.h>
xen/arch/x86/cpu/mcheck/mce.c +1 -0
index 198595ff97..d61e582af3 100644
@@ -6,6 +6,7 @@
 #include <xen/init.h>
 #include <xen/types.h>
 #include <xen/kernel.h>
+#include <xen/param.h>
 #include <xen/smp.h>
 #include <xen/errno.h>
 #include <xen/console.h>
xen/arch/x86/cpu/mcheck/mce_intel.c +1 -0
index 70738852b9..6f23ea5329 100644
@@ -4,6 +4,7 @@
 #include <xen/event.h>
 #include <xen/kernel.h>
 #include <xen/delay.h>
+#include <xen/param.h>
 #include <xen/smp.h>
 #include <xen/mm.h>
 #include <xen/cpu.h>
xen/arch/x86/cpu/mtrr/generic.c +1 -0
index cc0bf4c310..89634f918f 100644
@@ -3,6 +3,7 @@
 #include <xen/lib.h>
 #include <xen/init.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/stdbool.h>
 #include <asm/flushtlb.h>
 #include <asm/invpcid.h>
xen/arch/x86/cpu/mwait-idle.c +1 -0
index 52413e6da1..1c5d6eb023 100644
@@ -52,6 +52,7 @@
 #include <xen/lib.h>
 #include <xen/cpu.h>
 #include <xen/init.h>
+#include <xen/param.h>
 #include <xen/softirq.h>
 #include <xen/trace.h>
 #include <asm/cpuidle.h>
xen/arch/x86/cpu/vpmu.c +1 -0
index b62095eef2..3c778450ac 100644
@@ -22,6 +22,7 @@
 #include <xen/event.h>
 #include <xen/guest_access.h>
 #include <xen/cpu.h>
+#include <xen/param.h>
 #include <asm/regs.h>
 #include <asm/types.h>
 #include <asm/msr.h>
xen/arch/x86/cpuid.c +1 -0
index b1ed33d524..aee221dc44 100644
@@ -1,5 +1,6 @@
 #include <xen/init.h>
 #include <xen/lib.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/nospec.h>
 #include <asm/cpuid.h>
xen/arch/x86/dom0_build.c +1 -0
index 28b964e018..909b01330d 100644
@@ -7,6 +7,7 @@
 #include <xen/init.h>
 #include <xen/iocap.h>
 #include <xen/libelf.h>
+#include <xen/param.h>
 #include <xen/pfn.h>
 #include <xen/sched.h>
 #include <xen/sched-if.h>
xen/arch/x86/e820.c +1 -0
index 082f9928a1..0fe9af3ca6 100644
@@ -1,6 +1,7 @@
 #include <xen/init.h>
 #include <xen/lib.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/compat.h>
 #include <xen/dmi.h>
 #include <xen/pfn.h>
xen/arch/x86/genapic/probe.c +1 -0
index 1fcc1734f5..d4d7a554a0 100644
@@ -8,6 +8,7 @@
 #include <xen/kernel.h>
 #include <xen/ctype.h>
 #include <xen/init.h>
+#include <xen/param.h>
 #include <asm/cache.h>
 #include <asm/fixmap.h>
 #include <asm/mpspec.h>
xen/arch/x86/genapic/x2apic.c +1 -0
index 1cb16bc10d..f9b5e49761 100644
@@ -19,6 +19,7 @@
 #include <xen/init.h>
 #include <xen/cpu.h>
 #include <xen/cpumask.h>
+#include <xen/param.h>
 #include <asm/apicdef.h>
 #include <asm/genapic.h>
 #include <asm/apic.h>
xen/arch/x86/hpet.c +1 -0
index 57f68fa81b..ae99993d90 100644
@@ -11,6 +11,7 @@
 #include <xen/softirq.h>
 #include <xen/irq.h>
 #include <xen/numa.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <asm/fixmap.h>
 #include <asm/div64.h>
xen/arch/x86/hvm/asid.c +1 -0
index 9d3c671a5f..8e00a28443 100644
@@ -18,6 +18,7 @@
 
 #include <xen/init.h>
 #include <xen/lib.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/smp.h>
 #include <xen/percpu.h>
xen/arch/x86/hvm/hvm.c +1 -0
index 4723f5d09c..19dc703603 100644
@@ -35,6 +35,7 @@
 #include <xen/mem_access.h>
 #include <xen/rangeset.h>
 #include <xen/monitor.h>
+#include <xen/param.h>
 #include <xen/warning.h>
 #include <xen/vpci.h>
 #include <xen/nospec.h>
xen/arch/x86/hvm/quirks.c +1 -0
index 881c6b99d2..54cc66c382 100644
@@ -19,6 +19,7 @@
 #include <xen/lib.h>
 #include <xen/dmi.h>
 #include <xen/bitmap.h>
+#include <xen/param.h>
 #include <asm/hvm/support.h>
 
 s8 __read_mostly hvm_port80_allowed = -1;
xen/arch/x86/hvm/viridian/viridian.c +1 -0
index 44c8e6cac6..f2302dc1e6 100644
@@ -9,6 +9,7 @@
 #include <xen/version.h>
 #include <xen/hypercall.h>
 #include <xen/domain_page.h>
+#include <xen/param.h>
 #include <asm/guest_access.h>
 #include <asm/guest/hyperv-tlfs.h>
 #include <asm/paging.h>
xen/arch/x86/hvm/vmx/vmcs.c +1 -0
index 634d1946d3..65445afeb0 100644
@@ -18,6 +18,7 @@
 #include <xen/init.h>
 #include <xen/mm.h>
 #include <xen/lib.h>
+#include <xen/param.h>
 #include <xen/errno.h>
 #include <xen/domain_page.h>
 #include <xen/event.h>
xen/arch/x86/hvm/vmx/vmx.c +1 -0
index f83f102638..4fc9d1128c 100644
@@ -17,6 +17,7 @@
 
 #include <xen/init.h>
 #include <xen/lib.h>
+#include <xen/param.h>
 #include <xen/trace.h>
 #include <xen/sched.h>
 #include <xen/irq.h>
xen/arch/x86/io_apic.c +1 -0
index 4125ea0c0c..e98e08e9c8 100644
@@ -24,6 +24,7 @@
 #include <xen/init.h>
 #include <xen/irq.h>
 #include <xen/delay.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/acpi.h>
 #include <xen/keyhandler.h>
xen/arch/x86/irq.c +1 -0
index 310ac00a60..cc2eb8e925 100644
@@ -10,6 +10,7 @@
 #include <xen/errno.h>
 #include <xen/event.h>
 #include <xen/irq.h>
+#include <xen/param.h>
 #include <xen/perfc.h>
 #include <xen/sched.h>
 #include <xen/keyhandler.h>
xen/arch/x86/microcode.c +1 -0
index 6ced293d88..2f22bc2bb2 100644
@@ -26,6 +26,7 @@
 #include <xen/kernel.h>
 #include <xen/init.h>
 #include <xen/notifier.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/smp.h>
 #include <xen/softirq.h>
xen/arch/x86/mm.c +1 -0
index 654190e9e9..9d5f45b506 100644
@@ -103,6 +103,7 @@
 #include <xen/kernel.h>
 #include <xen/lib.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/domain.h>
 #include <xen/sched.h>
 #include <xen/err.h>
xen/arch/x86/mm/p2m.c +1 -0
index 3119269073..09e4d1910a 100644
@@ -27,6 +27,7 @@
 #include <xen/iommu.h>
 #include <xen/vm_event.h>
 #include <xen/event.h>
+#include <xen/param.h>
 #include <public/vm_event.h>
 #include <asm/domain.h>
 #include <asm/page.h>
xen/arch/x86/msi.c +1 -0
index df97ce0c72..c85cf9f85a 100644
@@ -14,6 +14,7 @@
 #include <xen/acpi.h>
 #include <xen/cpu.h>
 #include <xen/errno.h>
+#include <xen/param.h>
 #include <xen/pci.h>
 #include <xen/pci_regs.h>
 #include <xen/iocap.h>
xen/arch/x86/nmi.c +1 -0
index e26121a737..a5c6bdd0ce 100644
@@ -16,6 +16,7 @@
 #include <xen/init.h>
 #include <xen/lib.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/irq.h>
 #include <xen/delay.h>
 #include <xen/time.h>
xen/arch/x86/numa.c +1 -0
index 7e1f563012..6ef15b34d5 100644
@@ -11,6 +11,7 @@
 #include <xen/nodemask.h>
 #include <xen/numa.h>
 #include <xen/keyhandler.h>
+#include <xen/param.h>
 #include <xen/time.h>
 #include <xen/smp.h>
 #include <xen/pfn.h>
xen/arch/x86/oprofile/nmi_int.c +1 -0
index 3dfb8fef93..8f97f7522c 100644
@@ -15,6 +15,7 @@
 #include <xen/types.h>
 #include <xen/errno.h>
 #include <xen/init.h>
+#include <xen/param.h>
 #include <xen/string.h>
 #include <xen/delay.h>
 #include <xen/xenoprof.h>
xen/arch/x86/psr.c +1 -0
index 8bf1c23751..d7f8864651 100644
@@ -16,6 +16,7 @@
 #include <xen/cpu.h>
 #include <xen/err.h>
 #include <xen/init.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <asm/psr.h>
 
xen/arch/x86/pv/domain.c +1 -0
index 4da0b2afff..c3473b9a47 100644
@@ -7,6 +7,7 @@
 #include <xen/domain_page.h>
 #include <xen/errno.h>
 #include <xen/lib.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 
 #include <asm/cpufeature.h>
xen/arch/x86/pv/shim.c +1 -0
index 7a898fdbe5..76fb380100 100644
@@ -23,6 +23,7 @@
 #include <xen/hypercall.h>
 #include <xen/init.h>
 #include <xen/iocap.h>
+#include <xen/param.h>
 #include <xen/shutdown.h>
 #include <xen/types.h>
 #include <xen/consoled.h>
xen/arch/x86/setup.c +1 -0
index d858883404..9aa171f733 100644
@@ -2,6 +2,7 @@
 #include <xen/lib.h>
 #include <xen/err.h>
 #include <xen/grant_table.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/domain.h>
 #include <xen/serial.h>
xen/arch/x86/shutdown.c +1 -0
index 005c0bf4fa..acef033143 100644
@@ -6,6 +6,7 @@
 
 #include <xen/init.h>
 #include <xen/lib.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/smp.h>
 #include <xen/delay.h>
xen/arch/x86/spec_ctrl.c +1 -0
index aa632bdcee..20f562902b 100644
@@ -19,6 +19,7 @@
 #include <xen/errno.h>
 #include <xen/init.h>
 #include <xen/lib.h>
+#include <xen/param.h>
 #include <xen/warning.h>
 
 #include <asm/microcode.h>
xen/arch/x86/tboot.c +1 -0
index 5020c4ad49..8c232270b4 100644
@@ -1,6 +1,7 @@
 #include <xen/init.h>
 #include <xen/types.h>
 #include <xen/lib.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/domain_page.h>
 #include <xen/iommu.h>
xen/arch/x86/time.c +1 -0
index f6b26f8883..cf3e51fb5e 100644
@@ -14,6 +14,7 @@
 #include <xen/sched.h>
 #include <xen/lib.h>
 #include <xen/init.h>
+#include <xen/param.h>
 #include <xen/time.h>
 #include <xen/timer.h>
 #include <xen/smp.h>
xen/arch/x86/traps.c +1 -0
index 97499a0c79..56067f85d1 100644
@@ -30,6 +30,7 @@
 #include <xen/err.h>
 #include <xen/errno.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/console.h>
 #include <xen/shutdown.h>
 #include <xen/guest_access.h>
xen/arch/x86/tsx.c +1 -0
index 2d202a0d4e..39e483640a 100644
@@ -1,4 +1,5 @@
 #include <xen/init.h>
+#include <xen/param.h>
 #include <asm/msr.h>
 
 /*
xen/arch/x86/x86_64/mmconfig-shared.c +1 -0
index cc08b52a35..0c55c7206e 100644
@@ -14,6 +14,7 @@
 
 #include <xen/init.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/acpi.h>
 #include <xen/xmalloc.h>
 #include <xen/pci.h>
xen/arch/x86/xstate.c +1 -0
index 243495ed07..078419a171 100644
@@ -5,6 +5,7 @@
  *
  */
 
+#include <xen/param.h>
 #include <xen/percpu.h>
 #include <xen/sched.h>
 #include <asm/current.h>
xen/common/argo.c +1 -0
index 2b91e94499..aa3443a377 100644
@@ -24,6 +24,7 @@
 #include <xen/guest_access.h>
 #include <xen/lib.h>
 #include <xen/nospec.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/time.h>
 #include <xsm/xsm.h>
xen/common/core_parking.c +1 -0
index a6669e1766..411106c675 100644
@@ -19,6 +19,7 @@
 #include <xen/cpu.h>
 #include <xen/init.h>
 #include <xen/cpumask.h>
+#include <xen/param.h>
 
 #include <asm/smp.h>
 
xen/common/cpupool.c +1 -0
index d66b541a94..9712614f16 100644
@@ -14,6 +14,7 @@
 #include <xen/lib.h>
 #include <xen/init.h>
 #include <xen/cpumask.h>
+#include <xen/param.h>
 #include <xen/percpu.h>
 #include <xen/sched.h>
 #include <xen/sched-if.h>
xen/common/debugtrace.c +1 -0
index a788e55b4c..c21ec99ee0 100644
@@ -11,6 +11,7 @@
 #include <xen/keyhandler.h>
 #include <xen/lib.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/percpu.h>
 #include <xen/serial.h>
 #include <xen/smp.h>
xen/common/domain.c +1 -0
index ee3f9ffd3e..086177d3c8 100644
@@ -9,6 +9,7 @@
 #include <xen/lib.h>
 #include <xen/ctype.h>
 #include <xen/err.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/sched-if.h>
 #include <xen/domain.h>
xen/common/efi/boot.c +1 -0
index bf7bb95999..b9f461505c 100644
@@ -11,6 +11,7 @@
 #include <xen/lib.h>
 #include <xen/mm.h>
 #include <xen/multiboot.h>
+#include <xen/param.h>
 #include <xen/pci_regs.h>
 #include <xen/pfn.h>
 #if EFI_PAGE_SIZE != PAGE_SIZE
xen/common/gdbstub.c +1 -0
index 6234834a20..848c1f4327 100644
@@ -40,6 +40,7 @@
 #include <xen/watchdog.h>
 #include <asm/debugger.h>
 #include <xen/init.h>
+#include <xen/param.h>
 #include <xen/smp.h>
 #include <xen/console.h>
 #include <xen/errno.h>
xen/common/grant_table.c +1 -0
index 5536d282b9..2ecf38dfbe 100644
@@ -28,6 +28,7 @@
 #include <xen/lib.h>
 #include <xen/sched.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/event.h>
 #include <xen/trace.h>
 #include <xen/grant_table.h>
xen/common/kernel.c +1 -0
index 760917dab5..22941cec94 100644
@@ -7,6 +7,7 @@
 #include <xen/init.h>
 #include <xen/lib.h>
 #include <xen/errno.h>
+#include <xen/param.h>
 #include <xen/version.h>
 #include <xen/sched.h>
 #include <xen/paging.h>
xen/common/kexec.c +1 -0
index a262cc5a18..9af7de4df3 100644
@@ -12,6 +12,7 @@
 #include <xen/ctype.h>
 #include <xen/errno.h>
 #include <xen/guest_access.h>
+#include <xen/param.h>
 #include <xen/watchdog.h>
 #include <xen/sched.h>
 #include <xen/types.h>
xen/common/memory.c +1 -0
index 309e872edf..e262e63e4a 100644
@@ -11,6 +11,7 @@
 #include <xen/types.h>
 #include <xen/lib.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/perfc.h>
 #include <xen/sched.h>
 #include <xen/event.h>
xen/common/page_alloc.c +1 -0
index 919a270587..97902d42c1 100644
@@ -126,6 +126,7 @@
 #include <xen/sched.h>
 #include <xen/spinlock.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/irq.h>
 #include <xen/softirq.h>
 #include <xen/domain_page.h>
xen/common/rcupdate.c +1 -0
index a56103c6f7..11cfc196fd 100644
@@ -34,6 +34,7 @@
 #include <xen/types.h>
 #include <xen/kernel.h>
 #include <xen/init.h>
+#include <xen/param.h>
 #include <xen/spinlock.h>
 #include <xen/smp.h>
 #include <xen/rcupdate.h>
xen/common/sched_credit.c +1 -0
index aa41a3301b..2ab89140db 100644
@@ -10,6 +10,7 @@
 
 #include <xen/init.h>
 #include <xen/lib.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/domain.h>
 #include <xen/delay.h>
xen/common/sched_credit2.c +1 -0
index f7c477053c..3c65269aef 100644
@@ -12,6 +12,7 @@
 
 #include <xen/init.h>
 #include <xen/lib.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/domain.h>
 #include <xen/delay.h>
xen/common/schedule.c +1 -0
index 54a07ff9e8..cef2414659 100644
@@ -16,6 +16,7 @@
 #ifndef COMPAT
 #include <xen/init.h>
 #include <xen/lib.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/domain.h>
 #include <xen/delay.h>
xen/common/shutdown.c +1 -0
index 2ed4d62214..912593915b 100644
@@ -1,5 +1,6 @@
 #include <xen/init.h>
 #include <xen/lib.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/domain.h>
 #include <xen/delay.h>
xen/common/timer.c +1 -0
index 645206a989..1bb265ceea 100644
@@ -10,6 +10,7 @@
 #include <xen/errno.h>
 #include <xen/sched.h>
 #include <xen/lib.h>
+#include <xen/param.h>
 #include <xen/smp.h>
 #include <xen/perfc.h>
 #include <xen/time.h>
xen/common/trace.c +1 -0
index ebfc735b31..a2a389a1c7 100644
@@ -19,6 +19,7 @@
 #include <asm/types.h>
 #include <asm/io.h>
 #include <xen/lib.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/smp.h>
 #include <xen/trace.h>
xen/drivers/acpi/apei/hest.c +1 -0
index 70734ab0e2..c5f3aaab7c 100644
@@ -30,6 +30,7 @@
 #include <xen/init.h>
 #include <xen/kernel.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/pfn.h>
 #include <acpi/acpi.h>
 #include <acpi/apei.h>
xen/drivers/acpi/tables.c +1 -0
index b890b73901..8c2a279e18 100644
@@ -24,6 +24,7 @@
 
 #include <xen/init.h>
 #include <xen/kernel.h>
+#include <xen/param.h>
 #include <xen/smp.h>
 #include <xen/string.h>
 #include <xen/types.h>
xen/drivers/char/arm-uart.c +1 -0
index 627746ba89..eeb9ceefc0 100644
@@ -21,6 +21,7 @@
 #include <asm/types.h>
 #include <xen/console.h>
 #include <xen/device_tree.h>
+#include <xen/param.h>
 #include <xen/serial.h>
 #include <xen/errno.h>
 #include <xen/acpi.h>
xen/drivers/char/console.c +1 -0
index 4bcbbfa7d6..913ae1b66a 100644
@@ -15,6 +15,7 @@
 #include <xen/init.h>
 #include <xen/event.h>
 #include <xen/console.h>
+#include <xen/param.h>
 #include <xen/serial.h>
 #include <xen/softirq.h>
 #include <xen/keyhandler.h>
xen/drivers/char/ehci-dbgp.c +1 -0
index b6e155d17b..c893d246de 100644
@@ -8,6 +8,7 @@
 #include <xen/console.h>
 #include <xen/delay.h>
 #include <xen/errno.h>
+#include <xen/param.h>
 #include <xen/pci.h>
 #include <xen/serial.h>
 #include <asm/byteorder.h>
xen/drivers/char/ns16550.c +1 -0
index aa87c57fc9..bd048f307a 100644
@@ -11,6 +11,7 @@
 #include <xen/console.h>
 #include <xen/init.h>
 #include <xen/irq.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/timer.h>
 #include <xen/serial.h>
xen/drivers/char/serial.c +1 -0
index 88cd876790..5ecba0af33 100644
@@ -9,6 +9,7 @@
 #include <xen/delay.h>
 #include <xen/init.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/serial.h>
 #include <xen/cache.h>
 
xen/drivers/cpufreq/cpufreq.c +1 -0
index 2d716abf72..e630a47419 100644
@@ -31,6 +31,7 @@
 #include <xen/delay.h>
 #include <xen/cpumask.h>
 #include <xen/list.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/string.h>
 #include <xen/timer.h>
xen/drivers/passthrough/amd/iommu_acpi.c +1 -0
index 9fbc343c58..6c5f8e46ec 100644
@@ -19,6 +19,7 @@
 
 #include <xen/errno.h>
 #include <xen/acpi.h>
+#include <xen/param.h>
 #include <asm/apicdef.h>
 #include <asm/io_apic.h>
 #include <asm/amd-iommu.h>
xen/drivers/passthrough/iommu.c +1 -0
index 4e19cf56cc..9d421e06de 100644
@@ -17,6 +17,7 @@
 #include <xen/paging.h>
 #include <xen/guest_access.h>
 #include <xen/event.h>
+#include <xen/param.h>
 #include <xen/softirq.h>
 #include <xen/keyhandler.h>
 #include <xsm/xsm.h>
xen/drivers/passthrough/pci.c +1 -0
index c07a63981a..0d3ced1fcf 100644
@@ -22,6 +22,7 @@
 #include <xen/prefetch.h>
 #include <xen/iommu.h>
 #include <xen/irq.h>
+#include <xen/param.h>
 #include <xen/vm_event.h>
 #include <asm/hvm/irq.h>
 #include <xen/delay.h>
xen/drivers/passthrough/vtd/dmar.c +1 -0
index f36b99ae37..1784f91b34 100644
@@ -24,6 +24,7 @@
 #include <xen/kernel.h>
 #include <xen/acpi.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/xmalloc.h>
 #include <xen/pci.h>
 #include <xen/pci_regs.h>
xen/drivers/passthrough/vtd/quirks.c +1 -0
index 4dadd9523f..5594270678 100644
@@ -17,6 +17,7 @@
  */
 
 #include <xen/irq.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/xmalloc.h>
 #include <xen/domain_page.h>
xen/drivers/passthrough/vtd/x86/vtd.c +1 -0
index ff456e1e70..f379afac03 100644
@@ -17,6 +17,7 @@
  * Copyright (C) Weidong Han <[email protected]>
  */
 
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/softirq.h>
 #include <xen/domain_page.h>
xen/drivers/passthrough/x86/ats.c +1 -0
index 3eea7f89fc..8ae0eae4a2 100644
@@ -12,6 +12,7 @@
  * this program; If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/pci.h>
 #include <xen/pci_regs.h>
xen/drivers/video/vesa.c +1 -0
index fd2cb1312d..2c1bbd9278 100644
@@ -6,6 +6,7 @@
 
 #include <xen/init.h>
 #include <xen/lib.h>
+#include <xen/param.h>
 #include <xen/xmalloc.h>
 #include <xen/kernel.h>
 #include <xen/vga.h>
xen/drivers/video/vga.c +1 -0
index 666f2e2509..b7f04d0d97 100644
@@ -7,6 +7,7 @@
 #include <xen/init.h>
 #include <xen/lib.h>
 #include <xen/mm.h>
+#include <xen/param.h>
 #include <xen/vga.h>
 #include <xen/pci.h>
 #include <asm/io.h>
xen/include/xen/init.h +0 -120

126 lines not on this page · raw message

xen/include/xen/param.h new file +126 -0

126 lines not on this page · raw message

xen/xsm/flask/flask_op.c +1 -0
index 1c4decc6cd..a5f2b104e2 100644
@@ -13,6 +13,7 @@
 #include <xsm/xsm.h>
 #include <xen/guest_access.h>
 #include <xen/err.h>
+#include <xen/param.h>
 
 #include <public/xsm/flask_op.h>
 
xen/xsm/xsm_core.c +1 -0
index a319df253d..5eab21e1b1 100644
@@ -13,6 +13,7 @@
 #include <xen/init.h>
 #include <xen/errno.h>
 #include <xen/lib.h>
+#include <xen/param.h>
 
 #include <xen/hypercall.h>
 #include <xsm/xsm.h>
Signature · 7 lines
2.16.4


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

Re: [Xen-devel] [PATCH v3 2/9] xen: split parameter related definitions in own header file

Hi Juergen,

Quoted 3 lines · Juergen Gross

Move the parameter related definitions from init.h into a new header file param.h. This will avoid include hell when new dependencies are added to parameter definitions.

How did you find out the list of places where the new files need to be included?

Also, was it build test it on Arm?

Cheers,

Signature · 6 lines
Julien Grall

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

Re: [Xen-devel] [PATCH v3 2/9] xen: split parameter related definitions in own header file

Quoted 8 lines · Julien Grall

Hi Juergen,

Quoted 3 lines · Juergen Gross

Move the parameter related definitions from init.h into a new header file param.h. This will avoid include hell when new dependencies are added to parameter definitions.

How did you find out the list of places where the new files need to be included?

I did a grep for all parameter definitions.

Quoted 2 lines

Also, was it build test it on Arm?

Yes.

Juergen

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

Acked-by
#8 lore raw

Re: [Xen-devel] [PATCH v3 2/9] xen: split parameter related definitions in own header file

Quoted 11 lines · Jürgen Groß
Quoted 8 lines · Julien Grall

Hi Juergen,

Quoted 3 lines · Juergen Gross

Move the parameter related definitions from init.h into a new header file param.h. This will avoid include hell when new dependencies are added to parameter definitions.

How did you find out the list of places where the new files need to be included?

I did a grep for all parameter definitions.

That's what I thought but wanted to check :).

Quoted 4 lines
Quoted 2 lines

Also, was it build test it on Arm?

Yes.

Thanks!

For Arm + common code:

Cheers,

Signature · 6 lines
Julien Grall

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

Re: [Xen-devel] [PATCH v3 2/9] xen: split parameter related definitions in own header file

In reply to Juergen Gross
Quoted 6 lines · Juergen Gross

Move the parameter related definitions from init.h into a new header file param.h. This will avoid include hell when new dependencies are added to parameter definitions.

sched-stuff:

Regards

Signature · 6 lines
Dario Faggioli, Ph.D
http://about.me/dario.faggioli
Virtualization Software Engineer
SUSE Labs, SUSE https://www.suse.com/
-------------------------------------------------------------------
<<This happens because _I_ choose it to happen!>> (Raistlin Majere)

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

Acked-by Paul Durrant on v3 2/9
#10 lore raw

Re: [Xen-devel] [PATCH v3 2/9] xen: split parameter related definitions in own header file

In reply to Juergen Gross
Quoted 18 lines

-----Original Message-----
From: Juergen Gross <[email protected]>
Sent: 21 January 2020 08:43
To: [email protected]
Cc: Juergen Gross <[email protected]>; Stefano Stabellini <[email protected]>; Julien Grall <[email protected]>; Volodymyr Babchuk <[email protected]>; Andrew Cooper <[email protected]>; George Dunlap <[email protected]>; Ian Jackson <[email protected]>; Jan Beulich <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Wei Liu <[email protected]>; Roger Pau Monné <[email protected]>; Durrant, Paul <[email protected]>; Jun Nakajima <[email protected]>; Kevin Tian <[email protected]>; Lukasz Hawrylko <[email protected]>; Christopher Clark <[email protected]>; Dario Faggioli <[email protected]>; Daniel De Graaf <[email protected]>
Subject: [PATCH v3 2/9] xen: split parameter related definitions in own header file

Quoted 5 lines

Move the parameter related definitions from init.h into a new header file param.h. This will avoid include hell when new dependencies are added to parameter definitions.

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

Acked-by on v3 2/9
#11 lore raw

Re: [Xen-devel] [PATCH v3 2/9] xen: split parameter related definitions in own header file

In reply to Juergen Gross
Quoted 5 lines · Juergen Gross

Move the parameter related definitions from init.h into a new header file param.h. This will avoid include hell when new dependencies are added to parameter definitions.

x86:

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

Reviewed-by on v3 2/9
#12 lore raw

Re: [Xen-devel] [PATCH v3 2/9] xen: split parameter related definitions in own header file

In reply to Juergen Gross
Quoted 8 lines

From: Juergen Gross <[email protected]>
Sent: Tuesday, January 21, 2020 4:43 PM

Move the parameter related definitions from init.h into a new header file param.h. This will avoid include hell when new dependencies are added to parameter definitions.

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

#13 lore raw

Re: [Xen-devel] [PATCH v3 2/9] xen: split parameter related definitions in own header file

In reply to Juergen Gross
Quoted 5 lines · Juergen Gross

Move the parameter related definitions from init.h into a new header file param.h. This will avoid include hell when new dependencies are added to parameter definitions.

There was some re-basing necessary here, which I hope I didn't screw up. I also decided to commit this despite, from a strictly formal perspective, there still being missing acks here, based on this being an entirely mechanical change to those files, and on the grounds that further re-basing would likely turn out to be needed with further delays here.

Jan

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

#14 lore raw

PATCH v3 3/9 docs: add feature document for Xen hypervisor sysfs-like support

In reply to Juergen Gross

On the 2019 Xen developer summit there was agreement that the Xen hypervisor should gain support for a hierarchical name-value store similar to the Linux kernel's sysfs.

In the beginning there should only be basic support: entries can be added from the hypervisor itself only, there is a simple hypercall interface to read the data.

Add a feature document for setting the base of a discussion regarding the desired functionality and the entries to add.

---
V1:
- remove the "--" prefixes of the sub-commands of the user tool (Jan Beulich)
- rename xenfs to xenhypfs (Jan Beulich)
- add "tree" and "write" options to user tool

V2:
- move example tree to the paths description (Ian Jackson)
- specify allowed characters for keys and values (Ian Jackson)

V3:
- correct introduction (writable entries)

---
 docs/features/hypervisorfs.pandoc | 86 +++++++++++++++++++++++++++++++++++
 docs/misc/hypfs-paths.pandoc      | 95 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 181 insertions(+)
 create mode 100644 docs/features/hypervisorfs.pandoc
 create mode 100644 docs/misc/hypfs-paths.pandoc
docs/features/hypervisorfs.pandoc new file +86 -0
new file mode 100644
index 0000000000..8e5deaacfb
@@ -0,0 +1,86 @@
+% Hypervisor FS
+% Revision 1
+
+\clearpage
+
+# Basics
+---------------- ---------------------
+         Status: **Supported**
+
+  Architectures: all
+
+     Components: Hypervisor, toolstack
+---------------- ---------------------
+
+# Overview
+
+The Hypervisor FS is a hierarchical name-value store for reporting
+information to guests, especially dom0.  It is similar to the Linux
+kernel's sysfs. Entries and directories are created by the hypervisor,
+while the toolstack is able to use a hypercall to query the entry
+values or (if allowed by the hypervisor) to modify them.
+
+# User details
+
+With:
+
+    xenhypfs ls <path>
+
+the user can list the entries of a specific path of the FS. Using:
+
+    xenhypfs cat <path>
+
+the content of an entry can be retrieved. Using:
+
+    xenhypfs write <path> <string>
+
+a writable entry can be modified. With:
+
+    xenhypfs tree
+
+the complete Hypervisor FS entry tree can be printed.
+
+The FS paths are documented in `docs/misc/hypfs-paths.pandoc`.
+
+# Technical details
+
+Access to the hypervisor filesystem is done via the stable new hypercall
+__HYPERVISOR_filesystem_op.
+
+* hypercall interface specification
+    * `xen/include/public/filesystem.h`
+* hypervisor internal files
+    * `xen/include/xen/filesystem.h`
+    * `xen/common/filesystem.c`
+* `libxenhypfs`
+    * `tools/libs/libxenhypfs/*`
+* `xenhypfs`
+    * `tools/misc/xenhypfs.c`
+* path documentation
+    * `docs/misc/hypfs-paths.pandoc`
+ 
+# Testing
+
+Any new parameters or hardware mitigations should be verified to show up
+correctly in the filesystem.
+
+# Areas for improvement
+
+* More detailed access rights
+* Entries per domain and/or per cpupool
+
+# Known issues
+
+* None
+
+# References
+
+* None
+
+# History
+
+------------------------------------------------------------------------
+Date       Revision Version  Notes
+---------- -------- -------- -------------------------------------------
+2019-10-02 1        Xen 4.13 Document written
+---------- -------- -------- -------------------------------------------
docs/misc/hypfs-paths.pandoc new file +95 -0

95 lines not on this page · raw message

Signature · 7 lines
2.16.4


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

Re: [Xen-devel] [PATCH v3 3/9] docs: add feature document for Xen hypervisor sysfs-like support

Hi Juergen.

Quoted 46 lines · Juergen Gross

On the 2019 Xen developer summit there was agreement that the Xen hypervisor should gain support for a hierarchical name-value store similar to the Linux kernel's sysfs.

In the beginning there should only be basic support: entries can be added from the hypervisor itself only, there is a simple hypercall interface to read the data.

Add a feature document for setting the base of a discussion regarding the desired functionality and the entries to add.

---
V1:
- remove the "--" prefixes of the sub-commands of the user tool (Jan Beulich)
- rename xenfs to xenhypfs (Jan Beulich)
- add "tree" and "write" options to user tool

V2:
- move example tree to the paths description (Ian Jackson)
- specify allowed characters for keys and values (Ian Jackson)

V3:
- correct introduction (writable entries)

---
  docs/features/hypervisorfs.pandoc | 86 +++++++++++++++++++++++++++++++++++
  docs/misc/hypfs-paths.pandoc      | 95 +++++++++++++++++++++++++++++++++++++++
  2 files changed, 181 insertions(+)

create mode 100644 docs/features/hypervisorfs.pandoc create mode 100644 docs/misc/hypfs-paths.pandoc

docs/features/hypervisorfs.pandoc new file +8 -0
new file mode 100644
index 0000000000..8e5deaacfb
@@ -0,0 +1,86 @@
+% Hypervisor FS
+% Revision 1
+
+\clearpage
+
+# Basics
+---------------- ---------------------
+         Status: **Supported**

docs/features/hypervisorfs.pandoc line 18

Quoted 10 lines
docs/features/hypervisorfs.pandoc new file +10 -0
+
+  Architectures: all
+
+     Components: Hypervisor, toolstack
+---------------- ---------------------
+
+# Overview
+
+The Hypervisor FS is a hierarchical name-value store for reporting
+information to guests, especially dom0.  It is similar to the Linux

I would like to get some consitency in the formatting at least within a same file. In this case, you seem to mostly use a single space the full stop. So I think you want to use single space here too.

Quoted 57 lines
docs/features/hypervisorfs.pandoc new file +57 -0
+kernel's sysfs. Entries and directories are created by the hypervisor,
+while the toolstack is able to use a hypercall to query the entry
+values or (if allowed by the hypervisor) to modify them.
+
+# User details
+
+With:
+
+    xenhypfs ls <path>
+
+the user can list the entries of a specific path of the FS. Using:
+
+    xenhypfs cat <path>
+
+the content of an entry can be retrieved. Using:
+
+    xenhypfs write <path> <string>
+
+a writable entry can be modified. With:
+
+    xenhypfs tree
+
+the complete Hypervisor FS entry tree can be printed.
+
+The FS paths are documented in `docs/misc/hypfs-paths.pandoc`.
+
+# Technical details
+
+Access to the hypervisor filesystem is done via the stable new hypercall
+__HYPERVISOR_filesystem_op.
+
+* hypercall interface specification
+    * `xen/include/public/filesystem.h`
+* hypervisor internal files
+    * `xen/include/xen/filesystem.h`
+    * `xen/common/filesystem.c`
+* `libxenhypfs`
+    * `tools/libs/libxenhypfs/*`
+* `xenhypfs`
+    * `tools/misc/xenhypfs.c`
+* path documentation
+    * `docs/misc/hypfs-paths.pandoc`
+
+# Testing
+
+Any new parameters or hardware mitigations should be verified to show up
+correctly in the filesystem.
+
+# Areas for improvement
+
+* More detailed access rights
+* Entries per domain and/or per cpupool
+
+# Known issues
+
+* None
+

docs/features/hypervisorfs.pandoc line 85

Quoted 10 lines
docs/features/hypervisorfs.pandoc new file +10 -0
+# References
+
+* None
+
+# History
+
+------------------------------------------------------------------------
+Date       Revision Version  Notes
+---------- -------- -------- -------------------------------------------
+2019-10-02 1        Xen 4.13 Document written

Does this want any update? Such as using 4.14 rather than 4.13.

Quoted 41 lines
docs/features/hypervisorfs.pandoc new file +1 -0
+---------- -------- -------- -------------------------------------------
docs/misc/hypfs-paths.pandoc new file +34 -0
new file mode 100644
index 0000000000..67de8d2cf8
@@ -0,0 +1,95 @@
+# Xenhypfs Paths
+
+This document attempts to define all the paths which are available
+in the Xen hypervisor file system (hypfs).
+
+The hypervisor file system can be accessed via the xenhypfs tool.
+
+## Notation
+
+The hypervisor file system is similar to the Linux kernel's sysfs.
+In this document directories are always specified with a trailing "/".
+
+The following notation conventions apply:
+
+        DIRECTORY/
+
+        PATH = VALUES [TAGS]
+
+The first syntax defines a directory. It normally contains related
+entries and the general scope of the directory is described.
+
+The second syntax defines a file entry containing values which are
+either set by the hypervisor or, if the file is writable, can be set
+by the user.
+
+PATH can contain simple regex constructs following the Perl compatible
+regexp syntax described in pcre(3) or perlre(1).
+
+A hypervisor file system entry name can be any 0-delimited byte string
+not containing any '/' character. The names "." and ".." are reserved
+for file system internal use.
+
+VALUES are strings and can take the following forms:
+

docs/misc/hypfs-paths.pandoc line 44

Quoted 10 lines
docs/misc/hypfs-paths.pandoc new file +10 -0
+* STRING -- an arbitrary 0-delimited byte string.
+* INTEGER -- An integer, in decimal representation unless otherwise
+  noted.
+* "a literal string" -- literal strings are contained within quotes.
+* (VALUE | VALUE | ... ) -- a set of alternatives. Alternatives are
+  separated by a "|" and all the alternatives are enclosed in "(" and
+  ")".
+
+Additional TAGS may follow as a comma separated set of the following
+tags enclosed in square brackets.

It may be clearer if you replace a full stop with :.

However, I am not sure what are actually the tags? Do you have a concrete example how they can be used?

docs/misc/hypfs-paths.pandoc line 49

Quoted 5 lines
docs/misc/hypfs-paths.pandoc new file +5 -0
+
+* w -- Path is writable by the user. This capability is usually
+  limited to the control domain (e.g. dom0).
+* ARM | ARM32 | X86: the path is available for the respective architecture
+  only.

How about Arm64? Also, if it is support by both arm64 and arm32, should we use ARM or ARM32,ARM64?

Quoted 37 lines
docs/misc/hypfs-paths.pandoc new file +36 -0
+* PV --  Path is valid for PV capable hypervisors only.
+* HVM -- Path is valid for HVM capable hypervisors only.
+* CONFIG_* -- Path is valid only in case the hypervisor was built with
+  the respective config option.
+
+## Example
+
+A populated Xen hypervisor file system might look like the following example:
+
+    /
+        buildinfo/           directory containing build-time data
+            config           contents of .config file used to build Xen
+        cpu-bugs/            x86: directory of cpu bug information
+            l1tf             "Vulnerable" or "Not vulnerable"
+            mds              "Vulnerable" or "Not vulnerable"
+            meltdown         "Vulnerable" or "Not vulnerable"
+            spec-store-bypass "Vulnerable" or "Not vulnerable"
+            spectre-v1       "Vulnerable" or "Not vulnerable"
+            spectre-v2       "Vulnerable" or "Not vulnerable"
+            mitigations/     directory of mitigation settings
+                bti-thunk    "N/A", "RETPOLINE", "LFENCE" or "JMP"
+                spec-ctrl    "No", "IBRS+" or IBRS-"
+                ibpb         "No" or "Yes"
+                l1d-flush    "No" or "Yes"
+                md-clear     "No" or "VERW"
+                l1tf-barrier "No" or "Yes"
+            active-hvm/      directory for mitigations active in hvm doamins
+                msr-spec-ctrl "No" or "Yes"
+                rsb          "No" or "Yes"
+                eager-fpu    "No" or "Yes"
+                md-clear     "No" or "Yes"
+            active-pv/       directory for mitigations active in pv doamins
+                msr-spec-ctrl "No" or "Yes"
+                rsb          "No" or "Yes"
+                eager-fpu    "No" or "Yes"
+                md-clear     "No" or "Yes"

docs/misc/hypfs-paths.pandoc line 95

Quoted 10 lines
docs/misc/hypfs-paths.pandoc new file +10 -0
+                xpti         "No" or list of "dom0", "domU", "PCID on"
+                l1tf-shadow  "No" or list of "dom0", "domU"
+        params/              directory with hypervisor parameter values
+                             (boot/runtime parameters)
+
+## General Paths
+
+#### /
+
+The root of the hypervisor file system.

Cheers,

Signature · 6 lines
Julien Grall

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

Re: [Xen-devel] [PATCH v3 3/9] docs: add feature document for Xen hypervisor sysfs-like support

Quoted 55 lines · Julien Grall

Hi Juergen.

Quoted 52 lines · Juergen Gross

On the 2019 Xen developer summit there was agreement that the Xen hypervisor should gain support for a hierarchical name-value store similar to the Linux kernel's sysfs.

In the beginning there should only be basic support: entries can be added from the hypervisor itself only, there is a simple hypercall interface to read the data.

Add a feature document for setting the base of a discussion regarding the desired functionality and the entries to add.

---
V1:
- remove the "--" prefixes of the sub-commands of the user tool (Jan Beulich)
- rename xenfs to xenhypfs (Jan Beulich)
- add "tree" and "write" options to user tool

V2:
- move example tree to the paths description (Ian Jackson)
- specify allowed characters for keys and values (Ian Jackson)

V3:
- correct introduction (writable entries)
---
  docs/features/hypervisorfs.pandoc | 86
+++++++++++++++++++++++++++++++++++
  docs/misc/hypfs-paths.pandoc      | 95
+++++++++++++++++++++++++++++++++++++++

  2 files changed, 181 insertions(+)

  create mode 100644 docs/features/hypervisorfs.pandoc create mode 100644 docs/misc/hypfs-paths.pandoc

docs/features/hypervisorfs.pandoc new file +12 -0
new file mode 100644
index 0000000000..8e5deaacfb
@@ -0,0 +1,86 @@
+% Hypervisor FS
+% Revision 1
+
+\clearpage
+
+# Basics
+---------------- ---------------------
+         Status: **Supported**
+
+  Architectures: all
+
+     Components: Hypervisor, toolstack
Quoted 8 lines

docs/features/hypervisorfs.pandoc line 18

Quoted 6 lines
docs/features/hypervisorfs.pandoc new file +6 -0
+---------------- ---------------------
+
+# Overview
+
+The Hypervisor FS is a hierarchical name-value store for reporting
+information to guests, especially dom0.  It is similar to the Linux

I would like to get some consitency in the formatting at least within a same file. In this case, you seem to mostly use a single space the full stop. So I think you want to use single space here too.

Either is fine with me.

I'm going to use a single space in case no one steps up and asks for double spaces after full stops.

Quoted 62 lines
Quoted 62 lines
docs/features/hypervisorfs.pandoc new file +61 -0
+kernel's sysfs. Entries and directories are created by the hypervisor,
+while the toolstack is able to use a hypercall to query the entry
+values or (if allowed by the hypervisor) to modify them.
+
+# User details
+
+With:
+
+    xenhypfs ls <path>
+
+the user can list the entries of a specific path of the FS. Using:
+
+    xenhypfs cat <path>
+
+the content of an entry can be retrieved. Using:
+
+    xenhypfs write <path> <string>
+
+a writable entry can be modified. With:
+
+    xenhypfs tree
+
+the complete Hypervisor FS entry tree can be printed.
+
+The FS paths are documented in `docs/misc/hypfs-paths.pandoc`.
+
+# Technical details
+
+Access to the hypervisor filesystem is done via the stable new hypercall
+__HYPERVISOR_filesystem_op.
+
+* hypercall interface specification
+    * `xen/include/public/filesystem.h`
+* hypervisor internal files
+    * `xen/include/xen/filesystem.h`
+    * `xen/common/filesystem.c`
+* `libxenhypfs`
+    * `tools/libs/libxenhypfs/*`
+* `xenhypfs`
+    * `tools/misc/xenhypfs.c`
+* path documentation
+    * `docs/misc/hypfs-paths.pandoc`
+
+# Testing
+
+Any new parameters or hardware mitigations should be verified to show up
+correctly in the filesystem.
+
+# Areas for improvement
+
+* More detailed access rights
+* Entries per domain and/or per cpupool
+
+# Known issues
+
+* None
+
+# References
+
+* None
+
Quoted 8 lines

docs/features/hypervisorfs.pandoc line 85

Quoted 6 lines
docs/features/hypervisorfs.pandoc new file +6 -0
+# History
+
+------------------------------------------------------------------------
+Date       Revision Version  Notes
+---------- -------- -------- -------------------------------------------
+2019-10-02 1        Xen 4.13 Document written

Does this want any update? Such as using 4.14 rather than 4.13.

Uh, yes.

Quoted 46 lines
Quoted 46 lines
docs/features/hypervisorfs.pandoc new file +1 -0
+---------- -------- -------- -------------------------------------------
docs/misc/hypfs-paths.pandoc new file +38 -0
new file mode 100644
index 0000000000..67de8d2cf8
@@ -0,0 +1,95 @@
+# Xenhypfs Paths
+
+This document attempts to define all the paths which are available
+in the Xen hypervisor file system (hypfs).
+
+The hypervisor file system can be accessed via the xenhypfs tool.
+
+## Notation
+
+The hypervisor file system is similar to the Linux kernel's sysfs.
+In this document directories are always specified with a trailing "/".
+
+The following notation conventions apply:
+
+        DIRECTORY/
+
+        PATH = VALUES [TAGS]
+
+The first syntax defines a directory. It normally contains related
+entries and the general scope of the directory is described.
+
+The second syntax defines a file entry containing values which are
+either set by the hypervisor or, if the file is writable, can be set
+by the user.
+
+PATH can contain simple regex constructs following the Perl compatible
+regexp syntax described in pcre(3) or perlre(1).
+
+A hypervisor file system entry name can be any 0-delimited byte string
+not containing any '/' character. The names "." and ".." are reserved
+for file system internal use.
+
+VALUES are strings and can take the following forms:
+
+* STRING -- an arbitrary 0-delimited byte string.
+* INTEGER -- An integer, in decimal representation unless otherwise
+  noted.
+* "a literal string" -- literal strings are contained within quotes.
Quoted 8 lines

docs/misc/hypfs-paths.pandoc line 44

Quoted 6 lines
docs/misc/hypfs-paths.pandoc new file +6 -0
+* (VALUE | VALUE | ... ) -- a set of alternatives. Alternatives are
+  separated by a "|" and all the alternatives are enclosed in "(" and
+  ")".
+
+Additional TAGS may follow as a comma separated set of the following
+tags enclosed in square brackets.

It may be clearer if you replace a full stop with :.

Okay.

Quoted 2 lines

However, I am not sure what are actually the tags? Do you have a concrete example how they can be used?

I'll add this one:

/cpu-bugs/active-pv/xpti (0|1) [w,X86,PV]

Quoted 9 lines
Quoted 7 lines
docs/misc/hypfs-paths.pandoc new file +4 -0
+
+* w -- Path is writable by the user. This capability is usually
+  limited to the control domain (e.g. dom0).
+* ARM | ARM32 | X86: the path is available for the respective 

architecture
+  only.

How about Arm64? Also, if it is support by both arm64 and arm32, should we use ARM or ARM32,ARM64?

ARM64 should be added and I'd suggest to use "ARM" instead of "ARM32,ARM64".

Quoted 42 lines
Quoted 42 lines
docs/misc/hypfs-paths.pandoc new file +8 -0
+* PV --  Path is valid for PV capable hypervisors only.
+* HVM -- Path is valid for HVM capable hypervisors only.
+* CONFIG_* -- Path is valid only in case the hypervisor was built with
+  the respective config option.
+
+## Example
+
+A populated Xen hypervisor file system might look like the following 

example:
+
+    /
+        buildinfo/           directory containing build-time data +            config           contents of .config file used to build Xen +        cpu-bugs/            x86: directory of cpu bug information +            l1tf             "Vulnerable" or "Not vulnerable" +            mds              "Vulnerable" or "Not vulnerable" +            meltdown         "Vulnerable" or "Not vulnerable" +            spec-store-bypass "Vulnerable" or "Not vulnerable" +            spectre-v1       "Vulnerable" or "Not vulnerable" +            spectre-v2       "Vulnerable" or "Not vulnerable" +            mitigations/     directory of mitigation settings +                bti-thunk    "N/A", "RETPOLINE", "LFENCE" or "JMP" +                spec-ctrl    "No", "IBRS+" or IBRS-"
+                ibpb         "No" or "Yes"
+                l1d-flush    "No" or "Yes"
+                md-clear     "No" or "VERW"
+                l1tf-barrier "No" or "Yes"
+            active-hvm/      directory for mitigations active in hvm doamins
+                msr-spec-ctrl "No" or "Yes"
+                rsb          "No" or "Yes"
+                eager-fpu    "No" or "Yes"
+                md-clear     "No" or "Yes"
+            active-pv/       directory for mitigations active in pv doamins
+                msr-spec-ctrl "No" or "Yes"
+                rsb          "No" or "Yes"
+                eager-fpu    "No" or "Yes"
+                md-clear     "No" or "Yes"
+                xpti         "No" or list of "dom0", "domU", "PCID on" +                l1tf-shadow  "No" or list of "dom0", "domU"

Quoted 8 lines

docs/misc/hypfs-paths.pandoc line 95

Quoted 8 lines

+        params/              directory with hypervisor parameter values +                             (boot/runtime parameters)

docs/misc/hypfs-paths.pandoc new file +6 -0
+
+## General Paths
+
+#### /
+
+The root of the hypervisor file system.

Juergen

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

#17 lore raw

Re: [Xen-devel] [PATCH v3 3/9] docs: add feature document for Xen hypervisor sysfs-like support

Quoted 17 lines · Jürgen Groß
Quoted 1 line · Julien Grall

However, I am not sure what are actually the tags? Do you have a concrete example how they can be used?

I'll add this one:

/cpu-bugs/active-pv/xpti (0|1) [w,X86,PV]

Quoted 9 lines
Quoted 7 lines
docs/misc/hypfs-paths.pandoc new file +4 -0
+
+* w -- Path is writable by the user. This capability is usually
+  limited to the control domain (e.g. dom0).
+* ARM | ARM32 | X86: the path is available for the respective 

architecture
+  only.

How about Arm64? Also, if it is support by both arm64 and arm32, should we use ARM or ARM32,ARM64?

Quoted 2 lines

ARM64 should be added and I'd suggest to use "ARM" instead of "ARM32,ARM64".

I am happy with that.

Cheers,

Signature · 6 lines
Julien Grall

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

PATCH v3 4/9 xen: add basic hypervisor filesystem support

In reply to Juergen Gross

Add the infrastructure for the hypervisor filesystem.

This includes the hypercall interface and the base functions for entry creation, deletion and modification.

---
V1:
- rename files from filesystem.* to hypfs.*
- add dummy write entry support
- rename hypercall filesystem_op to hypfs_op
- add support for unsigned integer entries

V2:
- test new entry name to be valid

V3:
- major rework, especially by supporting binary contents of entries
- addressed all comments

---
 xen/arch/arm/traps.c         |   1 +
 xen/arch/x86/hvm/hypercall.c |   1 +
 xen/arch/x86/hypercall.c     |   1 +
 xen/arch/x86/pv/hypercall.c  |   1 +
 xen/common/Makefile          |   1 +
 xen/common/hypfs.c           | 365 +++++++++++++++++++++++++++++++++++++++++++
 xen/include/public/hypfs.h   | 124 +++++++++++++++
 xen/include/public/xen.h     |   1 +
 xen/include/xen/hypercall.h  |   8 +
 xen/include/xen/hypfs.h      |  89 +++++++++++
 10 files changed, 592 insertions(+)
 create mode 100644 xen/common/hypfs.c
 create mode 100644 xen/include/public/hypfs.h
 create mode 100644 xen/include/xen/hypfs.h
xen/arch/arm/traps.c +1 -0
index 6f9bec22d3..87af810667 100644
@@ -1382,6 +1382,7 @@ static arm_hypercall_t arm_hypercall_table[] = {
 #ifdef CONFIG_ARGO
     HYPERCALL(argo_op, 5),
 #endif
+    HYPERCALL(hypfs_op, 5),
 };
 
 #ifndef NDEBUG
xen/arch/x86/hvm/hypercall.c +1 -0
index 33dd2d99d2..210dda4f38 100644
@@ -144,6 +144,7 @@ static const hypercall_table_t hvm_hypercall_table[] = {
 #endif
     HYPERCALL(xenpmu_op),
     COMPAT_CALL(dm_op),
+    HYPERCALL(hypfs_op),
     HYPERCALL(arch_1)
 };
 
xen/arch/x86/hypercall.c +1 -0
index 7f299d45c6..05a3f5e25b 100644
@@ -73,6 +73,7 @@ const hypercall_args_t hypercall_args_table[NR_hypercalls] =
     ARGS(hvm_op, 2),
     ARGS(dm_op, 3),
 #endif
+    ARGS(hypfs_op, 5),
     ARGS(mca, 1),
     ARGS(arch_1, 1),
 };
xen/arch/x86/pv/hypercall.c +1 -0
index 17ddf9ea1f..83907d4f00 100644
@@ -85,6 +85,7 @@ const hypercall_table_t pv_hypercall_table[] = {
     HYPERCALL(hvm_op),
     COMPAT_CALL(dm_op),
 #endif
+    HYPERCALL(hypfs_op),
     HYPERCALL(mca),
     HYPERCALL(arch_1),
 };
xen/common/Makefile +1 -0
index 62b34e69e9..a3f66aa0c0 100644
@@ -11,6 +11,7 @@ obj-y += domain.o
 obj-y += event_2l.o
 obj-y += event_channel.o
 obj-y += event_fifo.o
+obj-y += hypfs.o
 obj-$(CONFIG_CRASH_DEBUG) += gdbstub.o
 obj-$(CONFIG_GRANT_TABLE) += grant_table.o
 obj-y += guestcopy.o
xen/common/hypfs.c new file +365 -0

365 lines not on this page · raw message

xen/include/public/hypfs.h new file +124 -0

124 lines not on this page · raw message

xen/include/public/xen.h +1 -0
index d2198dffad..bf80f1da8c 100644
@@ -130,6 +130,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_ulong_t);
 #define __HYPERVISOR_argo_op              39
 #define __HYPERVISOR_xenpmu_op            40
 #define __HYPERVISOR_dm_op                41
+#define __HYPERVISOR_hypfs_op             42
 
 /* Architecture-specific hypercall definitions. */
 #define __HYPERVISOR_arch_0               48
xen/include/xen/hypercall.h +8 -0
index ad8ad27b23..349a0f6487 100644
@@ -150,6 +150,14 @@ do_dm_op(
     unsigned int nr_bufs,
     XEN_GUEST_HANDLE_PARAM(xen_dm_op_buf_t) bufs);
 
+extern long
+do_hypfs_op(
+    unsigned int cmd,
+    XEN_GUEST_HANDLE_PARAM(void) arg1,
+    unsigned long arg2,
+    XEN_GUEST_HANDLE_PARAM(void) arg3,
+    unsigned long arg4);
+
 #ifdef CONFIG_COMPAT
 
 extern int
xen/include/xen/hypfs.h new file +89 -0

89 lines not on this page · raw message

Signature · 7 lines
2.16.4


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

Re: [Xen-devel] [PATCH v3 4/9] xen: add basic hypervisor filesystem support

On Tue, Jan 21, 2020 at 09:43:25AM +0100, Juergen Gross wrote:
[...]

Quoted 6 lines
xen/common/hypfs.c new file +0 -0
new file mode 100644
index 0000000000..6762d20dfd

xen/common/hypfs.c line 8

Quoted 8 lines
xen/common/hypfs.c new file +8 -0
@@ -0,0 +1,365 @@
+/******************************************************************************
+ *
+ * hypfs.c
+ *
+ * Simple sysfs-like file system for the hypervisor.
+ */
+
+#include <xen/lib.h>

This should come after hypfs.h.

If it has come first it probably means one of the headers below hasn't included it properly?

xen/common/hypfs.c line 14

Quoted 6 lines
xen/common/hypfs.c new file +6 -0
+#include <xen/err.h>
+#include <xen/guest_access.h>
+#include <xen/hypercall.h>
+#include <xen/hypfs.h>
+#include <xen/rwlock.h>
+#include <public/hypfs.h>

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

#20 lore raw

Re: [Xen-devel] [PATCH v3 4/9] xen: add basic hypervisor filesystem support

Quoted 19 lines · Wei Liu

On Tue, Jan 21, 2020 at 09:43:25AM +0100, Juergen Gross wrote:
[...]

Quoted 6 lines
xen/common/hypfs.c new file +0 -0
new file mode 100644
index 0000000000..6762d20dfd

xen/common/hypfs.c line 8

Quoted 8 lines
xen/common/hypfs.c new file +8 -0
@@ -0,0 +1,365 @@
+/******************************************************************************
+ *
+ * hypfs.c
+ *
+ * Simple sysfs-like file system for the hypervisor.
+ */
+
+#include <xen/lib.h>

This should come after hypfs.h.

Quoted 2 lines

If it has come first it probably means one of the headers below hasn't included it properly?

I'll move it, as the build will still be fine.

Juergen

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

#21 lore raw

Re: [Xen-devel] [PATCH v3 4/9] xen: add basic hypervisor filesystem support

In reply to Juergen Gross
Quoted 4 lines · Juergen Gross
---
 xen/arch/arm/traps.c         |   1 +
 xen/arch/x86/hvm/hypercall.c |   1 +
 xen/arch/x86/hypercall.c     |   1 +
Quoted 8 lines
 xen/arch/x86/pv/hypercall.c  |   1 +
 xen/common/Makefile          |   1 +
 xen/common/hypfs.c           | 365 +++++++++++++++++++++++++++++++++++++++++++
 xen/include/public/hypfs.h   | 124 +++++++++++++++
 xen/include/public/xen.h     |   1 +
 xen/include/xen/hypercall.h  |   8 +
 xen/include/xen/hypfs.h      |  89 +++++++++++
 10 files changed, 592 insertions(+)

Even if it's just two structures that you have in the public header, your assertion of the interface being guest bitness agnostic should be accompanied by actual proof, i.e. addition to xen/include/xlat.lst.

Quoted 25 lines
xen/common/hypfs.c new file +25 -0
+static int add_entry(struct hypfs_entry_dir *parent, struct hypfs_entry *new)
+{
+    int ret = -ENOENT;
+    struct hypfs_entry *e;
+
+    write_lock(&hypfs_lock);
+
+    list_for_each_entry ( e, &parent->dirlist, list )
+    {
+        int cmp = strcmp(e->name, new->name);
+
+        if ( cmp > 0 )
+        {
+            ret = 0;
+            list_add_tail(&new->list, &e->list);
+            break;
+        }
+        if ( cmp == 0 )
+        {
+            ret = -EEXIST;
+            break;
+        }
+    }
+
+    if ( ret == -ENOENT )

xen/common/hypfs.c line 58

Quoted 10 lines
xen/common/hypfs.c new file +10 -0
+    {
+        ret = 0;
+        list_add_tail(&new->list, &parent->dirlist);
+    }
+
+    if ( !ret )
+    {
+        unsigned int sz = strlen(new->name) + 1;
+
+        parent->e.size += DIRENTRY_SIZE(sz);

Would DIRENTRY_SIZE() perhaps better include the "+ 1"?

xen/common/hypfs.c line 75

Quoted 10 lines
xen/common/hypfs.c new file +10 -0
+int hypfs_add_entry(struct hypfs_entry_dir *parent,
+                    struct hypfs_entry *entry, bool nofault)
+{
+    int ret;
+
+    ret = add_entry(parent, entry);
+    BUG_ON(nofault && ret);
+
+    return ret;
+}

While this and its two siblings have no caller, the one above doesn't even have a declaration in the header file. What is this intended to be used for (from external callers)?

I also think the "nofault" aspect could do with discussing in the commit message - it seems quite odd to me.

xen/common/hypfs.c line 103

Quoted 2 lines
xen/common/hypfs.c new file +2 -0
+static int hypfs_get_path_user(char *buf, XEN_GUEST_HANDLE_PARAM(void) uaddr,
+                               unsigned long len)

For consistency with naming elsewhere as well as uaddr here - ulen?

xen/common/hypfs.c line 128

Quoted 12 lines
xen/common/hypfs.c new file +12 -0
+static struct hypfs_entry *hypfs_get_entry_rel(struct hypfs_entry_dir *dir,
+                                               const char *path)
+{
+    const char *end;
+    struct hypfs_entry *entry;
+    unsigned int name_len;
+
+    if ( !*path )
+        return &dir->e;
+
+    if ( dir->e.type != XEN_HYPFS_TYPE_DIR )
+        return NULL;

Don't these two need switching around, to make sure /a/b/c/ doesn't match a non-dir /a/b/c ?

xen/common/hypfs.c line 138

Quoted 9 lines
xen/common/hypfs.c new file +9 -0
+    end = strchr(path, '/');
+    if ( !end )
+        end = strchr(path, '\0');
+    name_len = end - path;
+
+    list_for_each_entry ( entry, &dir->dirlist, list )
+    {
+        int cmp = strncmp(path, entry->name, name_len);
+	struct hypfs_entry_dir *d = container_of(entry,

A hard tab slipped in here.

Quoted 14 lines
xen/common/hypfs.c new file +14 -0
+                                                 struct hypfs_entry_dir, e);
+
+        if ( cmp < 0 )
+            return NULL;
+        if ( !cmp && strlen(entry->name) == name_len )
+            return *end ? hypfs_get_entry_rel(d, end + 1) : entry;
+    }
+
+    return NULL;
+}
+
+struct hypfs_entry *hypfs_get_entry(const char *path)
+{
+    if ( path[0] != '/' )

xen/common/hypfs.c line 162

Quoted 10 lines
xen/common/hypfs.c new file +10 -0
+        return NULL;
+
+    return hypfs_get_entry_rel(&hypfs_root, path + 1);
+}
+
+int hypfs_read_dir(const struct hypfs_entry *entry,
+                   XEN_GUEST_HANDLE_PARAM(void) uaddr)
+{
+    const struct hypfs_entry_dir *d;
+    struct hypfs_entry *e;

const?

Quoted 11 lines
xen/common/hypfs.c new file +11 -0
+static int hypfs_read(const struct hypfs_entry *entry,
+                      XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen)
+{
+    struct xen_hypfs_direntry e;
+    long ret = -EINVAL;
+
+    if ( ulen < sizeof(e) )
+        goto out;
+
+    e.flags = entry->write ? XEN_HYPFS_WRITEABLE : 0;
+    e.type = entry->type;

xen/common/hypfs.c line 224

Quoted 10 lines
xen/common/hypfs.c new file +10 -0
+    e.encoding = entry->encoding;
+    e.content_len = entry->size;
+
+    ret = -EFAULT;
+    if ( copy_to_guest(uaddr, &e, 1) )
+        goto out;
+
+    ret = 0;
+    if ( ulen < entry->size + sizeof(e) )
+        goto out;

So you return "success" even if the operation didn't complete successfully. This isn't very nice, plus ...

xen/common/hypfs.c line 228

Quoted 3 lines
xen/common/hypfs.c new file +3 -0
+    guest_handle_add_offset(uaddr, sizeof(e));
+
+    ret = entry->read(entry, uaddr);

... how is the caller to know whether direntry was at least copied if this then fails?

xen/common/hypfs.c line 241

Quoted 8 lines
xen/common/hypfs.c new file +8 -0
+int hypfs_write_leaf(struct hypfs_entry_leaf *leaf,
+                     XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen)
+{
+    char *buf;
+    int ret;
+
+    if ( ulen > leaf->e.size )
+        ulen = leaf->e.size;

Silent truncation?

Quoted 1 line

+ buf = xzalloc_array(char, ulen);

Why the z variant?

xen/common/hypfs.c line 253

Quoted 10 lines
xen/common/hypfs.c new file +10 -0
+    if ( !buf )
+        return -ENOMEM;
+
+    ret = -EFAULT;
+    if ( copy_from_guest(buf, uaddr, ulen) )
+        goto out;
+
+    ret = 0;
+    if ( leaf->e.type == XEN_HYPFS_TYPE_STRING )
+        buf[leaf->e.size - 1] = 0;

And possible further silent truncation? And if the incoming buffer has no nul byte at ulen-1, you'll then ...

Quoted 1 line

+ memcpy(leaf->write_ptr, buf, ulen);

... produce a strange concatenation of new and tail of old contents?

Anyway, this and ...

xen/common/hypfs.c line 263

Quoted 8 lines

+ out:

xen/common/hypfs.c new file +7 -0
+    xfree(buf);
+    return ret;
+}
+
+int hypfs_write_bool(struct hypfs_entry_leaf *leaf,
+                     XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen)
+{

... this function aren't very helpful to review without there being a caller. Could these be introduced at the time a first caller appears?

xen/common/hypfs.c line 275

Quoted 12 lines
xen/common/hypfs.c new file +12 -0
+    union {
+        char buf[8];
+        uint8_t u8;
+        uint16_t u16;
+        uint32_t u32;
+        uint64_t u64;
+    } u;
+
+    ASSERT(leaf->e.type == XEN_HYPFS_TYPE_UINT && leaf->e.size <= 8);
+
+    if ( ulen != leaf->e.size )
+        return -EDOM;

Is this restriction really necessary? Setting e.g. a 4-byte field from 1-byte input is no problem at all. This being for booleans I anyway wonder why input might be helpful to have larger than a single byte. But maybe all of this is again a result of not seeing what a user of the function would look like.

Quoted 33 lines
xen/common/hypfs.c new file +33 -0
+long do_hypfs_op(unsigned int cmd,
+                 XEN_GUEST_HANDLE_PARAM(void) arg1, unsigned long arg2,
+                 XEN_GUEST_HANDLE_PARAM(void) arg3, unsigned long arg4)
+{
+    int ret;
+    struct hypfs_entry *entry;
+    static char path[XEN_HYPFS_MAX_PATHLEN];
+
+    if ( !is_control_domain(current->domain) &&
+         !is_hardware_domain(current->domain) )
+        return -EPERM;
+
+    if ( cmd == XEN_HYPFS_OP_get_version )
+        return XEN_HYPFS_VERSION;
+
+    if ( cmd == XEN_HYPFS_OP_write_contents )
+        write_lock(&hypfs_lock);
+    else
+        read_lock(&hypfs_lock);
+
+    ret = hypfs_get_path_user(path, arg1, arg2);
+    if ( ret )
+        goto out;
+
+    entry = hypfs_get_entry(path);
+    if ( !entry )
+    {
+        ret = -ENOENT;
+        goto out;
+    }
+
+    switch ( cmd )
+    {

xen/common/hypfs.c line 354

Quoted 10 lines
xen/common/hypfs.c new file +10 -0
+    case XEN_HYPFS_OP_read_contents:
+        ret = hypfs_read(entry, arg3, arg4);
+        break;
+
+    case XEN_HYPFS_OP_write_contents:
+        ret = hypfs_write(entry, arg3, arg4);
+        break;
+
+    default:
+        ret = -ENOSYS;

EINVAL or EOPNOTSUPP please. ENOSYS should be used only for not implemented top level functions.

Quoted 29 lines
xen/include/public/hypfs.h new file +26 -0
@@ -0,0 +1,124 @@
+/******************************************************************************
+ * Xen Hypervisor Filesystem
+ *
+ * Copyright (c) 2019, SUSE Software Solutions Germany GmbH
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __XEN_PUBLIC_HYPFS_H__

xen/include/public/hypfs.h line 36

Quoted 10 lines
xen/include/public/hypfs.h new file +10 -0
+#define __XEN_PUBLIC_HYPFS_H__
+
+#include "xen.h"
+
+/*
+ * Definitions for the __HYPERVISOR_hypfs_op hypercall.
+ */
+
+/* Highest version number of the hypfs interface currently defined. */
+#define XEN_HYPFS_VERSION      1

For this and the accompanying XEN_HYPFS_OP_get_version, at least the doc added by patch 3 could actually do with mentioning the intentions you have with this.

Quoted 6 lines
xen/include/public/hypfs.h new file +6 -0
+/* Maximum length of a path in the filesystem. */
+#define XEN_HYPFS_MAX_PATHLEN 1024
+
+struct xen_hypfs_direntry {
+    uint16_t flags;
+#define XEN_HYPFS_WRITEABLE    0x0001

xen/include/public/hypfs.h line 53

Quoted 10 lines
xen/include/public/hypfs.h new file +10 -0
+    uint8_t type;
+#define XEN_HYPFS_TYPE_DIR     0x0000
+#define XEN_HYPFS_TYPE_BLOB    0x0001
+#define XEN_HYPFS_TYPE_STRING  0x0002
+#define XEN_HYPFS_TYPE_UINT    0x0003
+#define XEN_HYPFS_TYPE_INT     0x0004
+#define XEN_HYPFS_TYPE_BOOL    0x0005
+    uint8_t encoding;
+#define XEN_HYPFS_ENC_PLAIN    0x0000
+#define XEN_HYPFS_ENC_GZIP     0x0001

Meaning I can e.g. have a gzip-ed string or bool (or even dir)? If this is just for "blob", why have separate fields instead of e.g. BLOB_RAW and BLOB_GZIP or some such?

Also - why 4 digits in the constants when the fields are uint8_t? Since these are enum-like, I even wonder if hex is warranted here.

xen/include/public/hypfs.h line 62

Quoted 9 lines
xen/include/public/hypfs.h new file +9 -0
+    uint32_t content_len;
+};
+
+struct xen_hypfs_dirlistentry {
+    struct xen_hypfs_direntry e;
+    /* Offset in bytes to next entry (0 == this is the last entry). */
+    uint16_t off_next;
+    char name[XEN_FLEX_ARRAY_DIM];
+};

The interaction of the last two fields may want spelling out:
I _assume_ name[] is nul-terminated, and off_next exists to potentially skip trailing padding?

Quoted 18 lines
xen/include/public/hypfs.h new file +18 -0
+/*
+ * Hypercall operations.
+ */
+
+/*
+ * XEN_HYPFS_OP_get_version
+ *
+ * Read highest interface version supported by the hypervisor.
+ *
+ * Possible return values:
+ * >0: highest supported interface version
+ * <0: negative Xen errno value
+ */
+#define XEN_HYPFS_OP_get_version     0
+
+/*
+ * XEN_HYPFS_OP_read_contents
+ *

xen/include/public/hypfs.h line 91

Quoted 10 lines
xen/include/public/hypfs.h new file +10 -0
+ * Read contents of a filesystem entry.
+ *
+ * Returns the direntry and contents of an entry in the buffer supplied by the
+ * caller (struct xen_hypfs_direntry with the contents following directly
+ * after it).
+ * The data buffer must be at least the size of the direntry returned in order
+ * to have success. If the data buffer was not large enough for all the data
+ * no entry data is returned, but the direntry will contain the needed size
+ * for the returned data.
+ * The format of the contents is according to its entry type and encoding.

What specifically this means for a dir would be nice to be spelled out.

Quoted 20 lines
xen/include/public/hypfs.h new file +20 -0
+ * arg1: XEN_GUEST_HANDLE(path name)
+ * arg2: length of path name (including trailing zero byte)
+ * arg3: XEN_GUEST_HANDLE(data buffer written by hypervisor)
+ * arg4: data buffer size
+ *
+ * Possible return values:
+ * 0: success (at least the direntry was returned)
+ * <0 : negative Xen errno value
+ */
+#define XEN_HYPFS_OP_read_contents     1
+
+/*
+ * XEN_HYPFS_OP_write_contents
+ *
+ * Write contents of a filesystem entry.
+ *
+ * Writes an entry with the contents of a buffer supplied by the caller.
+ * The data type and encoding can't be changed. The size can be changed only
+ * for blobs and strings.
+ *

xen/include/public/hypfs.h line 122

Quoted 10 lines
xen/include/public/hypfs.h new file +10 -0
+ * arg1: XEN_GUEST_HANDLE(path name)
+ * arg2: length of path name (including trailing zero byte)
+ * arg3: XEN_GUEST_HANDLE(content buffer read by hypervisor)
+ * arg4: content buffer size
+ *
+ * Possible return values:
+ * 0: success
+ * <0 : negative Xen errno value
+ */
+#define XEN_HYPFS_OP_write_contents    2

This one indeed accesses only the actual data (contents) of the referenced entry. XEN_HYPFS_OP_read_contents hands back also the dir entry. Should the latter then better be named just XEN_HYPFS_OP_read?

xen/include/xen/hypercall.h do_dm_op( · line 156

Quoted 10 lines
xen/include/xen/hypercall.h +4 -0
@@ -150,6 +150,14 @@ do_dm_op(
     unsigned int nr_bufs,
     XEN_GUEST_HANDLE_PARAM(xen_dm_op_buf_t) bufs);
 
+extern long
+do_hypfs_op(
+    unsigned int cmd,
+    XEN_GUEST_HANDLE_PARAM(void) arg1,

Do you anticipate this parameter to be used for other than path names? If not, perhaps better XEN_GUEST_HANDLE_PARAM(const_char)?

Quoted 63 lines
xen/include/xen/hypfs.h new file +60 -0
@@ -0,0 +1,89 @@
+#ifndef __XEN_HYPFS_H__
+#define __XEN_HYPFS_H__
+
+#include <xen/list.h>
+#include <xen/string.h>
+#include <public/hypfs.h>
+
+struct hypfs_entry_leaf;
+
+struct hypfs_entry {
+    unsigned short type;
+    unsigned short encoding;
+    unsigned int size;
+    const char *name;
+    struct list_head list;
+    int (*read)(const struct hypfs_entry *entry,
+                XEN_GUEST_HANDLE_PARAM(void) uaddr);
+    int (*write)(struct hypfs_entry_leaf *leaf,
+                 XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen);
+};
+
+struct hypfs_entry_leaf {
+    struct hypfs_entry e;
+    union {
+        const void *content;
+        void *write_ptr;
+    };
+};
+
+struct hypfs_entry_dir {
+    struct hypfs_entry e;
+    struct list_head dirlist;
+};
+
+#define HYPFS_DIR_INIT(var, nam)                \
+    struct hypfs_entry_dir var = {              \
+        .e.type = XEN_HYPFS_TYPE_DIR,           \
+        .e.encoding = XEN_HYPFS_ENC_PLAIN,      \
+        .e.name = nam,                          \
+        .e.size = 0,                            \
+        .e.list = LIST_HEAD_INIT(var.e.list),   \
+        .e.read = hypfs_read_dir,               \
+        .dirlist = LIST_HEAD_INIT(var.dirlist), \
+    }
+
+/* Content and size need to be set via hypfs_string_set(). */
+#define HYPFS_STRING_INIT(var, nam)             \
+    struct hypfs_entry_leaf var = {             \
+        .e.type = XEN_HYPFS_TYPE_STRING,        \
+        .e.encoding = XEN_HYPFS_ENC_PLAIN,      \
+        .e.name = nam,                          \
+        .e.read = hypfs_read_leaf,              \
+    }
+
+static inline void hypfs_string_set(struct hypfs_entry_leaf *leaf,
+                                    const char *str)
+{
+    leaf->content = str;
+    leaf->e.size = strlen(str) + 1;
+}

xen/include/xen/hypfs.h line 70

Quoted 10 lines
xen/include/xen/hypfs.h new file +10 -0
+
+#define HYPFS_UINT_INIT(var, nam, uint)         \
+    struct hypfs_entry_leaf var = {             \
+        .e.type = XEN_HYPFS_TYPE_UINT,          \
+        .e.encoding = XEN_HYPFS_ENC_PLAIN,      \
+        .e.name = nam,                          \
+        .e.size = sizeof(uint),                 \
+        .e.read = hypfs_read_leaf,              \
+        .content = &uint,                       \
+    }

So you've got such helper macros for dir, string, and uint. Why not e.g. int and bool?

xen/include/xen/hypfs.h line 73

Quoted 3 lines
xen/include/xen/hypfs.h new file +3 -0
+
+
+extern struct hypfs_entry_dir hypfs_root;

No double blank lines please.

xen/include/xen/hypfs.h line 75

Quoted 1 line
xen/include/xen/hypfs.h new file +1 -0
+struct hypfs_entry *hypfs_get_entry(const char *path);

Does the only caller really need a non-const return type? Even hypfs_write() doesn't look to modify what its leaf parameter points at.

And is there indeed an expectation for this to be used from outside of the source file it's defined in?

Jan

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

#22 lore raw

Re: [Xen-devel] [PATCH v3 4/9] xen: add basic hypervisor filesystem support

Quoted 14 lines · Jan Beulich
Quoted 4 lines · Juergen Gross
---
  xen/arch/arm/traps.c         |   1 +
  xen/arch/x86/hvm/hypercall.c |   1 +
  xen/arch/x86/hypercall.c     |   1 +
Quoted 8 lines
  xen/arch/x86/pv/hypercall.c  |   1 +
  xen/common/Makefile          |   1 +
  xen/common/hypfs.c           | 365 +++++++++++++++++++++++++++++++++++++++++++
  xen/include/public/hypfs.h   | 124 +++++++++++++++
  xen/include/public/xen.h     |   1 +
  xen/include/xen/hypercall.h  |   8 +
  xen/include/xen/hypfs.h      |  89 +++++++++++
  10 files changed, 592 insertions(+)
Quoted 4 lines

Even if it's just two structures that you have in the public header, your assertion of the interface being guest bitness agnostic should be accompanied by actual proof, i.e. addition to xen/include/xlat.lst.

Okay.

Quoted 30 lines
Quoted 30 lines
xen/common/hypfs.c new file +29 -0
+static int add_entry(struct hypfs_entry_dir *parent, struct hypfs_entry *new)
+{
+    int ret = -ENOENT;
+    struct hypfs_entry *e;
+
+    write_lock(&hypfs_lock);
+
+    list_for_each_entry ( e, &parent->dirlist, list )
+    {
+        int cmp = strcmp(e->name, new->name);
+
+        if ( cmp > 0 )
+        {
+            ret = 0;
+            list_add_tail(&new->list, &e->list);
+            break;
+        }
+        if ( cmp == 0 )
+        {
+            ret = -EEXIST;
+            break;
+        }
+    }
+
+    if ( ret == -ENOENT )
+    {
+        ret = 0;
+        list_add_tail(&new->list, &parent->dirlist);
+    }
Quoted 8 lines

xen/common/hypfs.c line 58

Quoted 6 lines
xen/common/hypfs.c new file +6 -0
+
+    if ( !ret )
+    {
+        unsigned int sz = strlen(new->name) + 1;
+
+        parent->e.size += DIRENTRY_SIZE(sz);

Would DIRENTRY_SIZE() perhaps better include the "+ 1"?

Good idea.

Quoted 15 lines

xen/common/hypfs.c line 75

Quoted 11 lines
xen/common/hypfs.c new file +10 -0
+int hypfs_add_entry(struct hypfs_entry_dir *parent,
+                    struct hypfs_entry *entry, bool nofault)
+{
+    int ret;
+
+    ret = add_entry(parent, entry);
+    BUG_ON(nofault && ret);
+
+    return ret;
+}

While this and its two siblings have no caller, the one above doesn't even have a declaration in the header file. What is this intended to be used for (from external callers)?

Oh, this seems to be a leftover from development phase. I'll remove it.

Quoted 2 lines

I also think the "nofault" aspect could do with discussing in the commit message - it seems quite odd to me.

I realized I was repeating the same code pattern multiple times, so I decidied to have a common function for it. Will add something to the commit message.

Quoted 6 lines

xen/common/hypfs.c line 103

Quoted 3 lines
xen/common/hypfs.c new file +2 -0
+static int hypfs_get_path_user(char *buf, XEN_GUEST_HANDLE_PARAM(void) uaddr,
+                               unsigned long len)

For consistency with naming elsewhere as well as uaddr here - ulen?

Okay.

Quoted 16 lines

xen/common/hypfs.c line 128

Quoted 13 lines
xen/common/hypfs.c new file +12 -0
+static struct hypfs_entry *hypfs_get_entry_rel(struct hypfs_entry_dir *dir,
+                                               const char *path)
+{
+    const char *end;
+    struct hypfs_entry *entry;
+    unsigned int name_len;
+
+    if ( !*path )
+        return &dir->e;
+
+    if ( dir->e.type != XEN_HYPFS_TYPE_DIR )
+        return NULL;

Don't these two need switching around, to make sure /a/b/c/ doesn't match a non-dir /a/b/c ?

Oh, indeed.

Quoted 12 lines

xen/common/hypfs.c line 138

Quoted 10 lines
xen/common/hypfs.c new file +9 -0
+    end = strchr(path, '/');
+    if ( !end )
+        end = strchr(path, '\0');
+    name_len = end - path;
+
+    list_for_each_entry ( entry, &dir->dirlist, list )
+    {
+        int cmp = strncmp(path, entry->name, name_len);
+	struct hypfs_entry_dir *d = container_of(entry,

A hard tab slipped in here.

Sorry for that.

Quoted 19 lines
Quoted 19 lines
xen/common/hypfs.c new file +18 -0
+                                                 struct hypfs_entry_dir, e);
+
+        if ( cmp < 0 )
+            return NULL;
+        if ( !cmp && strlen(entry->name) == name_len )
+            return *end ? hypfs_get_entry_rel(d, end + 1) : entry;
+    }
+
+    return NULL;
+}
+
+struct hypfs_entry *hypfs_get_entry(const char *path)
+{
+    if ( path[0] != '/' )
+        return NULL;
+
+    return hypfs_get_entry_rel(&hypfs_root, path + 1);
+}
Quoted 8 lines

xen/common/hypfs.c line 162

Quoted 6 lines
xen/common/hypfs.c new file +6 -0
+
+int hypfs_read_dir(const struct hypfs_entry *entry,
+                   XEN_GUEST_HANDLE_PARAM(void) uaddr)
+{
+    const struct hypfs_entry_dir *d;
+    struct hypfs_entry *e;

const?

Yes.

Quoted 17 lines
Quoted 17 lines
xen/common/hypfs.c new file +16 -0
+static int hypfs_read(const struct hypfs_entry *entry,
+                      XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen)
+{
+    struct xen_hypfs_direntry e;
+    long ret = -EINVAL;
+
+    if ( ulen < sizeof(e) )
+        goto out;
+
+    e.flags = entry->write ? XEN_HYPFS_WRITEABLE : 0;
+    e.type = entry->type;
+    e.encoding = entry->encoding;
+    e.content_len = entry->size;
+
+    ret = -EFAULT;
+    if ( copy_to_guest(uaddr, &e, 1) )
Quoted 8 lines

xen/common/hypfs.c line 224

Quoted 5 lines
xen/common/hypfs.c new file +5 -0
+        goto out;
+
+    ret = 0;
+    if ( ulen < entry->size + sizeof(e) )
+        goto out;

So you return "success" even if the operation didn't complete successfully. This isn't very nice, plus ...

The direntry contains the needed size. The caller should know the size he passed to Xen.

Quoted 7 lines

xen/common/hypfs.c line 228

Quoted 4 lines
xen/common/hypfs.c new file +3 -0
+    guest_handle_add_offset(uaddr, sizeof(e));
+
+    ret = entry->read(entry, uaddr);

... how is the caller to know whether direntry was at least copied if this then fails?

Is this really important? Normally -EFAULT should just not happen. In case it does I don't think the caller can make real use of the direntry.

Quoted 11 lines

xen/common/hypfs.c line 241

Quoted 9 lines
xen/common/hypfs.c new file +8 -0
+int hypfs_write_leaf(struct hypfs_entry_leaf *leaf,
+                     XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen)
+{
+    char *buf;
+    int ret;
+
+    if ( ulen > leaf->e.size )
+        ulen = leaf->e.size;

Silent truncation?

Hmm, true. I'll modify it to return an error in that case.

Quoted 3 lines
Quoted 1 line

+ buf = xzalloc_array(char, ulen);

Why the z variant?

Okay, will use xmalloc().

Quoted 15 lines

xen/common/hypfs.c line 253

Quoted 11 lines
xen/common/hypfs.c new file +10 -0
+    if ( !buf )
+        return -ENOMEM;
+
+    ret = -EFAULT;
+    if ( copy_from_guest(buf, uaddr, ulen) )
+        goto out;
+
+    ret = 0;
+    if ( leaf->e.type == XEN_HYPFS_TYPE_STRING )
+        buf[leaf->e.size - 1] = 0;

And possible further silent truncation? And if the incoming buffer has no nul byte at ulen-1, you'll then ...

Quoted 4 lines
Quoted 1 line

+ memcpy(leaf->write_ptr, buf, ulen);

... produce a strange concatenation of new and tail of old contents?

Will rework by returning an error if the size is too large or there is no terminating nul byte.

Quoted 15 lines

Anyway, this and ...

xen/common/hypfs.c line 263

Quoted 8 lines

+ out:

xen/common/hypfs.c new file +7 -0
+    xfree(buf);
+    return ret;
+}
+
+int hypfs_write_bool(struct hypfs_entry_leaf *leaf,
+                     XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen)
+{

... this function aren't very helpful to review without there being a caller. Could these be introduced at the time a first caller appears?

Of course. Question is where to stop. I wanted to have the basic hypfs support in one patch. Are you fine with just those two functions being moved to the runtime parameter patch?

Quoted 12 lines
Quoted 12 lines
xen/common/hypfs.c new file +11 -0
+    union {
+        char buf[8];
+        uint8_t u8;
+        uint16_t u16;
+        uint32_t u32;
+        uint64_t u64;
+    } u;
+
+    ASSERT(leaf->e.type == XEN_HYPFS_TYPE_UINT && leaf->e.size <= 8);
+
+    if ( ulen != leaf->e.size )
Quoted 8 lines
Quoted 1 line

+ return -EDOM;

Is this restriction really necessary? Setting e.g. a 4-byte field from 1-byte input is no problem at all. This being for booleans I anyway wonder why input might be helpful to have larger than a single byte. But maybe all of this is again a result of not seeing what a user of the function would look like.

I wanted to have as little functionality as possible in the hypervisor. It is no problem for the library to pass a properly sized buffer.

Allowing larger variables for booleans is just a consequence of the hypervisor parameters allowing that.

Quoted 39 lines
Quoted 39 lines
xen/common/hypfs.c new file +38 -0
+long do_hypfs_op(unsigned int cmd,
+                 XEN_GUEST_HANDLE_PARAM(void) arg1, unsigned long arg2,
+                 XEN_GUEST_HANDLE_PARAM(void) arg3, unsigned long arg4)
+{
+    int ret;
+    struct hypfs_entry *entry;
+    static char path[XEN_HYPFS_MAX_PATHLEN];
+
+    if ( !is_control_domain(current->domain) &&
+         !is_hardware_domain(current->domain) )
+        return -EPERM;
+
+    if ( cmd == XEN_HYPFS_OP_get_version )
+        return XEN_HYPFS_VERSION;
+
+    if ( cmd == XEN_HYPFS_OP_write_contents )
+        write_lock(&hypfs_lock);
+    else
+        read_lock(&hypfs_lock);
+
+    ret = hypfs_get_path_user(path, arg1, arg2);
+    if ( ret )
+        goto out;
+
+    entry = hypfs_get_entry(path);
+    if ( !entry )
+    {
+        ret = -ENOENT;
+        goto out;
+    }
+
+    switch ( cmd )
+    {
+    case XEN_HYPFS_OP_read_contents:
+        ret = hypfs_read(entry, arg3, arg4);
+        break;
+
+    case XEN_HYPFS_OP_write_contents:
Quoted 8 lines

xen/common/hypfs.c line 354

Quoted 5 lines
xen/common/hypfs.c new file +5 -0
+        ret = hypfs_write(entry, arg3, arg4);
+        break;
+
+    default:
+        ret = -ENOSYS;

EINVAL or EOPNOTSUPP please. ENOSYS should be used only for not implemented top level functions.

Okay, will use EOPNOTSUPP.

Quoted 36 lines
Quoted 36 lines
xen/include/public/hypfs.h new file +32 -0
@@ -0,0 +1,124 @@
+/******************************************************************************
+ * Xen Hypervisor Filesystem
+ *
+ * Copyright (c) 2019, SUSE Software Solutions Germany GmbH
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __XEN_PUBLIC_HYPFS_H__
+#define __XEN_PUBLIC_HYPFS_H__
+
+#include "xen.h"
+
+/*
+ * Definitions for the __HYPERVISOR_hypfs_op hypercall.
Quoted 8 lines

xen/include/public/hypfs.h line 36

Quoted 4 lines
xen/include/public/hypfs.h new file +4 -0
+ */
+
+/* Highest version number of the hypfs interface currently defined. */
+#define XEN_HYPFS_VERSION      1

For this and the accompanying XEN_HYPFS_OP_get_version, at least the doc added by patch 3 could actually do with mentioning the intentions you have with this.

Okay.

Quoted 13 lines
Quoted 13 lines
xen/include/public/hypfs.h new file +12 -0
+/* Maximum length of a path in the filesystem. */
+#define XEN_HYPFS_MAX_PATHLEN 1024
+
+struct xen_hypfs_direntry {
+    uint16_t flags;
+#define XEN_HYPFS_WRITEABLE    0x0001
+    uint8_t type;
+#define XEN_HYPFS_TYPE_DIR     0x0000
+#define XEN_HYPFS_TYPE_BLOB    0x0001
+#define XEN_HYPFS_TYPE_STRING  0x0002
+#define XEN_HYPFS_TYPE_UINT    0x0003
+#define XEN_HYPFS_TYPE_INT     0x0004
Quoted 8 lines

xen/include/public/hypfs.h line 53

Quoted 4 lines
xen/include/public/hypfs.h new file +4 -0
+#define XEN_HYPFS_TYPE_BOOL    0x0005
+    uint8_t encoding;
+#define XEN_HYPFS_ENC_PLAIN    0x0000
+#define XEN_HYPFS_ENC_GZIP     0x0001

Meaning I can e.g. have a gzip-ed string or bool (or even dir)? If this is just for "blob", why have separate fields instead of e.g. BLOB_RAW and BLOB_GZIP or some such?

gzip-ed string or blob are the primary targets.

Maybe we want to have other encoding s later (Andrew asked for that possibility when I posted the patch for retrieving the .config file contents early last year).

Quoted 3 lines

Also - why 4 digits in the constants when the fields are uint8_t? Since these are enum-like, I even wonder if hex is warranted here.

I'm fine with switching to plain integers.

Quoted 14 lines

xen/include/public/hypfs.h line 62

Quoted 10 lines
xen/include/public/hypfs.h new file +9 -0
+    uint32_t content_len;
+};
+
+struct xen_hypfs_dirlistentry {
+    struct xen_hypfs_direntry e;
+    /* Offset in bytes to next entry (0 == this is the last entry). */
+    uint16_t off_next;
+    char name[XEN_FLEX_ARRAY_DIM];
+};

The interaction of the last two fields may want spelling out:
I _assume_ name[] is nul-terminated, and off_next exists to potentially skip trailing padding?

Yes. Will add a comment.

Quoted 24 lines
Quoted 24 lines
xen/include/public/hypfs.h new file +23 -0
+/*
+ * Hypercall operations.
+ */
+
+/*
+ * XEN_HYPFS_OP_get_version
+ *
+ * Read highest interface version supported by the hypervisor.
+ *
+ * Possible return values:
+ * >0: highest supported interface version
+ * <0: negative Xen errno value
+ */
+#define XEN_HYPFS_OP_get_version     0
+
+/*
+ * XEN_HYPFS_OP_read_contents
+ *
+ * Read contents of a filesystem entry.
+ *
+ * Returns the direntry and contents of an entry in the buffer supplied by the
+ * caller (struct xen_hypfs_direntry with the contents following directly
+ * after it).
Quoted 8 lines

xen/include/public/hypfs.h line 91

Quoted 5 lines
xen/include/public/hypfs.h new file +5 -0
+ * The data buffer must be at least the size of the direntry returned in order
+ * to have success. If the data buffer was not large enough for all the data
+ * no entry data is returned, but the direntry will contain the needed size
+ * for the returned data.
+ * The format of the contents is according to its entry type and encoding.

What specifically this means for a dir would be nice to be spelled out.

Okay.

Quoted 28 lines
Quoted 28 lines
xen/include/public/hypfs.h new file +27 -0
+ * arg1: XEN_GUEST_HANDLE(path name)
+ * arg2: length of path name (including trailing zero byte)
+ * arg3: XEN_GUEST_HANDLE(data buffer written by hypervisor)
+ * arg4: data buffer size
+ *
+ * Possible return values:
+ * 0: success (at least the direntry was returned)
+ * <0 : negative Xen errno value
+ */
+#define XEN_HYPFS_OP_read_contents     1
+
+/*
+ * XEN_HYPFS_OP_write_contents
+ *
+ * Write contents of a filesystem entry.
+ *
+ * Writes an entry with the contents of a buffer supplied by the caller.
+ * The data type and encoding can't be changed. The size can be changed only
+ * for blobs and strings.
+ *
+ * arg1: XEN_GUEST_HANDLE(path name)
+ * arg2: length of path name (including trailing zero byte)
+ * arg3: XEN_GUEST_HANDLE(content buffer read by hypervisor)
+ * arg4: content buffer size
+ *
+ * Possible return values:
+ * 0: success
Quoted 8 lines

xen/include/public/hypfs.h line 122

Quoted 3 lines
xen/include/public/hypfs.h new file +3 -0
+ * <0 : negative Xen errno value
+ */
+#define XEN_HYPFS_OP_write_contents    2

This one indeed accesses only the actual data (contents) of the referenced entry. XEN_HYPFS_OP_read_contents hands back also the dir entry. Should the latter then better be named just XEN_HYPFS_OP_read?

Yes, this might be better.

Quoted 7 lines
Quoted 7 lines
xen/include/xen/hypercall.h +0 -0
@@ -150,6 +150,14 @@ do_dm_op(
      unsigned int nr_bufs,
      XEN_GUEST_HANDLE_PARAM(xen_dm_op_buf_t) bufs);
 
Quoted 7 lines

xen/include/xen/hypercall.h do_dm_op( · line 156

Quoted 4 lines
xen/include/xen/hypercall.h +4 -0
+extern long
+do_hypfs_op(
+    unsigned int cmd,
+    XEN_GUEST_HANDLE_PARAM(void) arg1,

Do you anticipate this parameter to be used for other than path names? If not, perhaps better XEN_GUEST_HANDLE_PARAM(const_char)?

Yes, I think this can be changed.

Quoted 69 lines
Quoted 69 lines
xen/include/xen/hypfs.h new file +65 -0
@@ -0,0 +1,89 @@
+#ifndef __XEN_HYPFS_H__
+#define __XEN_HYPFS_H__
+
+#include <xen/list.h>
+#include <xen/string.h>
+#include <public/hypfs.h>
+
+struct hypfs_entry_leaf;
+
+struct hypfs_entry {
+    unsigned short type;
+    unsigned short encoding;
+    unsigned int size;
+    const char *name;
+    struct list_head list;
+    int (*read)(const struct hypfs_entry *entry,
+                XEN_GUEST_HANDLE_PARAM(void) uaddr);
+    int (*write)(struct hypfs_entry_leaf *leaf,
+                 XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen);
+};
+
+struct hypfs_entry_leaf {
+    struct hypfs_entry e;
+    union {
+        const void *content;
+        void *write_ptr;
+    };
+};
+
+struct hypfs_entry_dir {
+    struct hypfs_entry e;
+    struct list_head dirlist;
+};
+
+#define HYPFS_DIR_INIT(var, nam)                \
+    struct hypfs_entry_dir var = {              \
+        .e.type = XEN_HYPFS_TYPE_DIR,           \
+        .e.encoding = XEN_HYPFS_ENC_PLAIN,      \
+        .e.name = nam,                          \
+        .e.size = 0,                            \
+        .e.list = LIST_HEAD_INIT(var.e.list),   \
+        .e.read = hypfs_read_dir,               \
+        .dirlist = LIST_HEAD_INIT(var.dirlist), \
+    }
+
+/* Content and size need to be set via hypfs_string_set(). */
+#define HYPFS_STRING_INIT(var, nam)             \
+    struct hypfs_entry_leaf var = {             \
+        .e.type = XEN_HYPFS_TYPE_STRING,        \
+        .e.encoding = XEN_HYPFS_ENC_PLAIN,      \
+        .e.name = nam,                          \
+        .e.read = hypfs_read_leaf,              \
+    }
+
+static inline void hypfs_string_set(struct hypfs_entry_leaf *leaf,
+                                    const char *str)
+{
+    leaf->content = str;
+    leaf->e.size = strlen(str) + 1;
+}
+
+#define HYPFS_UINT_INIT(var, nam, uint)         \
+    struct hypfs_entry_leaf var = {             \
+        .e.type = XEN_HYPFS_TYPE_UINT,          \
+        .e.encoding = XEN_HYPFS_ENC_PLAIN,      \
Quoted 8 lines

xen/include/xen/hypfs.h line 70

Quoted 5 lines
xen/include/xen/hypfs.h new file +5 -0
+        .e.name = nam,                          \
+        .e.size = sizeof(uint),                 \
+        .e.read = hypfs_read_leaf,              \
+        .content = &uint,                       \
+    }

So you've got such helper macros for dir, string, and uint. Why not e.g. int and bool?

There are no users in my series yet.

Quoted 6 lines

xen/include/xen/hypfs.h line 73

Quoted 4 lines
xen/include/xen/hypfs.h new file +3 -0
+
+
+extern struct hypfs_entry_dir hypfs_root;

No double blank lines please.

Oh, sorry.

Quoted 6 lines

xen/include/xen/hypfs.h line 75

Quoted 2 lines
xen/include/xen/hypfs.h new file +1 -0
+struct hypfs_entry *hypfs_get_entry(const char *path);

Does the only caller really need a non-const return type? Even hypfs_write() doesn't look to modify what its leaf parameter points at.

This might change when support for dynamically allocated strings or blobs is added (I have no plans to do this right now, but its easy to think about the need).

Quoted 3 lines

And is there indeed an expectation for this to be used from outside of the source file it's defined in?

Yes. As soon as support for e.g. per-domain or per-cpupool nodes is added this will be needed.

Juergen

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

#23 lore raw

Re: [Xen-devel] [PATCH v3 4/9] xen: add basic hypervisor filesystem support

Quoted 35 lines · Jürgen Groß
Quoted 17 lines · Jan Beulich
Quoted 16 lines · Juergen Gross
xen/common/hypfs.c new file +16 -0
+static int hypfs_read(const struct hypfs_entry *entry,
+                      XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen)
+{
+    struct xen_hypfs_direntry e;
+    long ret = -EINVAL;
+
+    if ( ulen < sizeof(e) )
+        goto out;
+
+    e.flags = entry->write ? XEN_HYPFS_WRITEABLE : 0;
+    e.type = entry->type;
+    e.encoding = entry->encoding;
+    e.content_len = entry->size;
+
+    ret = -EFAULT;
+    if ( copy_to_guest(uaddr, &e, 1) )
Quoted 8 lines

xen/common/hypfs.c line 224

Quoted 5 lines
xen/common/hypfs.c new file +5 -0
+        goto out;
+
+    ret = 0;
+    if ( ulen < entry->size + sizeof(e) )
+        goto out;

So you return "success" even if the operation didn't complete successfully. This isn't very nice, plus ...

The direntry contains the needed size. The caller should know the size he passed to Xen.

Quoted 5 lines
Quoted 4 lines
xen/common/hypfs.c new file +3 -0
+    guest_handle_add_offset(uaddr, sizeof(e));
+
+    ret = entry->read(entry, uaddr);
Quoted 5 lines
Quoted 2 lines

... how is the caller to know whether direntry was at least copied if this then fails?

Is this really important? Normally -EFAULT should just not happen. In case it does I don't think the caller can make real use of the direntry.

"Important" has various possible meanings. The success/failure indication to the caller should at least be rational. "If the data buffer was not large enough for all the data no entry data is returned, but the direntry will contain the needed size for the returned data" is fine to be stated in the public header, but I think this wants to be -ENOBUFS then, not 0 (success).

Quoted 15 lines
Quoted 14 lines

Anyway, this and ...

xen/common/hypfs.c line 263

Quoted 8 lines

+ out:

xen/common/hypfs.c new file +7 -0
+    xfree(buf);
+    return ret;
+}
+
+int hypfs_write_bool(struct hypfs_entry_leaf *leaf,
+                     XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen)
+{

... this function aren't very helpful to review without there being a caller. Could these be introduced at the time a first caller appears?

Quoted 3 lines

Of course. Question is where to stop. I wanted to have the basic hypfs support in one patch. Are you fine with just those two functions being moved to the runtime parameter patch?

Let me put it this way: For anything the patch adds but there's no usage at all (i.e. not even in a macro, where at least the usage intentions get sufficiently clarified), the description should cover for this lack of sufficient context. Therefore I'd also be fine with the two functions remaining here, as long as readers (reviewers) can understand the intentions. It might still be _easier_ for everyone to have them in a later patch. But then the same still goes for other functions that have no users here. (The helper macros HYPFS_*_INIT(), otoh, are clear enough the way they are imo, and hence are fine to remain, plus they serve as usage explanation for hypfs_read_{leaf,dir}(), which as it looks would otherwise too be orphaned.)

Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
xen/common/hypfs.c new file +11 -0
+    union {
+        char buf[8];
+        uint8_t u8;
+        uint16_t u16;
+        uint32_t u32;
+        uint64_t u64;
+    } u;
+
+    ASSERT(leaf->e.type == XEN_HYPFS_TYPE_UINT && leaf->e.size <= 8);
+
+    if ( ulen != leaf->e.size )
Quoted 8 lines
Quoted 1 line

+ return -EDOM;

Is this restriction really necessary? Setting e.g. a 4-byte field from 1-byte input is no problem at all. This being for booleans I anyway wonder why input might be helpful to have larger than a single byte. But maybe all of this is again a result of not seeing what a user of the function would look like.

Quoted 5 lines

I wanted to have as little functionality as possible in the hypervisor. It is no problem for the library to pass a properly sized buffer.

Allowing larger variables for booleans is just a consequence of the hypervisor parameters allowing that.

But the caller shouldn't be concerned of the hypervisor implementation detail of what the chose width is. Over time we e.g. convert int (along with bool_t) to bool when it's used in a boolean way. This should not result in the caller needing to change, despite the width change of the variable.

Quoted 68 lines
Quoted 35 lines
Quoted 35 lines
xen/include/public/hypfs.h new file +32 -0
@@ -0,0 +1,124 @@
+/******************************************************************************
+ * Xen Hypervisor Filesystem
+ *
+ * Copyright (c) 2019, SUSE Software Solutions Germany GmbH
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __XEN_PUBLIC_HYPFS_H__
+#define __XEN_PUBLIC_HYPFS_H__
+
+#include "xen.h"
+
+/*
+ * Definitions for the __HYPERVISOR_hypfs_op hypercall.
Quoted 8 lines

xen/include/public/hypfs.h line 36

Quoted 4 lines
xen/include/public/hypfs.h new file +4 -0
+ */
+
+/* Highest version number of the hypfs interface currently defined. */
+#define XEN_HYPFS_VERSION      1

For this and the accompanying XEN_HYPFS_OP_get_version, at least the doc added by patch 3 could actually do with mentioning the intentions you have with this.

Okay.

Quoted 13 lines
Quoted 13 lines
xen/include/public/hypfs.h new file +12 -0
+/* Maximum length of a path in the filesystem. */
+#define XEN_HYPFS_MAX_PATHLEN 1024
+
+struct xen_hypfs_direntry {
+    uint16_t flags;
+#define XEN_HYPFS_WRITEABLE    0x0001
+    uint8_t type;
+#define XEN_HYPFS_TYPE_DIR     0x0000
+#define XEN_HYPFS_TYPE_BLOB    0x0001
+#define XEN_HYPFS_TYPE_STRING  0x0002
+#define XEN_HYPFS_TYPE_UINT    0x0003
+#define XEN_HYPFS_TYPE_INT     0x0004
Quoted 8 lines

xen/include/public/hypfs.h line 53

Quoted 4 lines
xen/include/public/hypfs.h new file +4 -0
+#define XEN_HYPFS_TYPE_BOOL    0x0005
+    uint8_t encoding;
+#define XEN_HYPFS_ENC_PLAIN    0x0000
+#define XEN_HYPFS_ENC_GZIP     0x0001

Meaning I can e.g. have a gzip-ed string or bool (or even dir)? If this is just for "blob", why have separate fields instead of e.g. BLOB_RAW and BLOB_GZIP or some such?

Quoted 5 lines

gzip-ed string or blob are the primary targets.

Maybe we want to have other encoding s later (Andrew asked for that possibility when I posted the patch for retrieving the .config file contents early last year).

To me it would seem preferable if the contents of a blob identified itself as to its format. But since this leaves room for ambiguities I accept that the format needs specifying. However, to me a gzip-ed string is as good as a gzip-ed blob, and hence I still think sub-dividing "blob" is the way to go, with no separate "encoding". Otherwise at the very least a comment here would need adding to clarify what combinations are valid / to be expected by callers.

Quoted 40 lines
Quoted 31 lines
Quoted 31 lines
xen/include/public/hypfs.h new file +31 -0
+#define HYPFS_DIR_INIT(var, nam)                \
+    struct hypfs_entry_dir var = {              \
+        .e.type = XEN_HYPFS_TYPE_DIR,           \
+        .e.encoding = XEN_HYPFS_ENC_PLAIN,      \
+        .e.name = nam,                          \
+        .e.size = 0,                            \
+        .e.list = LIST_HEAD_INIT(var.e.list),   \
+        .e.read = hypfs_read_dir,               \
+        .dirlist = LIST_HEAD_INIT(var.dirlist), \
+    }
+
+/* Content and size need to be set via hypfs_string_set(). */
+#define HYPFS_STRING_INIT(var, nam)             \
+    struct hypfs_entry_leaf var = {             \
+        .e.type = XEN_HYPFS_TYPE_STRING,        \
+        .e.encoding = XEN_HYPFS_ENC_PLAIN,      \
+        .e.name = nam,                          \
+        .e.read = hypfs_read_leaf,              \
+    }
+
+static inline void hypfs_string_set(struct hypfs_entry_leaf *leaf,
+                                    const char *str)
+{
+    leaf->content = str;
+    leaf->e.size = strlen(str) + 1;
+}
+
+#define HYPFS_UINT_INIT(var, nam, uint)         \
+    struct hypfs_entry_leaf var = {             \
+        .e.type = XEN_HYPFS_TYPE_UINT,          \
+        .e.encoding = XEN_HYPFS_ENC_PLAIN,      \
Quoted 8 lines

xen/include/public/hypfs.h line 88

Quoted 5 lines
xen/include/public/hypfs.h new file +5 -0
+        .e.name = nam,                          \
+        .e.size = sizeof(uint),                 \
+        .e.read = hypfs_read_leaf,              \
+        .content = &uint,                       \
+    }

So you've got such helper macros for dir, string, and uint. Why not e.g. int and bool?

Quoted 1 line

There are no users in my series yet.

Hmm, as per above strictly speaking it is this patch which matters, not the entire series. Hence I think you either want to supply a full set of helper macros here, or introduce the ones actually needed in the patches where they get first used.

Quoted 11 lines
Quoted 5 lines

xen/include/public/hypfs.h line 89

Quoted 1 line
xen/include/public/hypfs.h new file +1 -0
+struct hypfs_entry *hypfs_get_entry(const char *path);

Does the only caller really need a non-const return type? Even hypfs_write() doesn't look to modify what its leaf parameter points at.

This might change when support for dynamically allocated strings or blobs is added (I have no plans to do this right now, but its easy to think about the need).

Quoted 1 line
Quoted 5 lines
Quoted 2 lines

And is there indeed an expectation for this to be used from outside of the source file it's defined in?

Yes. As soon as support for e.g. per-domain or per-cpupool nodes is added this will be needed.

Until then, make the function both static and return ptr-to-const? Such that when this changes, the need for either can actually be seen?

Jan

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

#24 lore raw

Re: [Xen-devel] [PATCH v3 4/9] xen: add basic hypervisor filesystem support

Quoted 42 lines · Jan Beulich
Quoted 35 lines · Jürgen Groß
Quoted 17 lines · Jan Beulich
Quoted 16 lines · Juergen Gross
xen/common/hypfs.c new file +16 -0
+static int hypfs_read(const struct hypfs_entry *entry,
+                      XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen)
+{
+    struct xen_hypfs_direntry e;
+    long ret = -EINVAL;
+
+    if ( ulen < sizeof(e) )
+        goto out;
+
+    e.flags = entry->write ? XEN_HYPFS_WRITEABLE : 0;
+    e.type = entry->type;
+    e.encoding = entry->encoding;
+    e.content_len = entry->size;
+
+    ret = -EFAULT;
+    if ( copy_to_guest(uaddr, &e, 1) )
Quoted 8 lines

xen/common/hypfs.c line 224

Quoted 5 lines
xen/common/hypfs.c new file +5 -0
+        goto out;
+
+    ret = 0;
+    if ( ulen < entry->size + sizeof(e) )
+        goto out;

So you return "success" even if the operation didn't complete successfully. This isn't very nice, plus ...

The direntry contains the needed size. The caller should know the size he passed to Xen.

Quoted 5 lines
Quoted 4 lines
xen/common/hypfs.c new file +3 -0
+    guest_handle_add_offset(uaddr, sizeof(e));
+
+    ret = entry->read(entry, uaddr);
Quoted 5 lines
Quoted 2 lines

... how is the caller to know whether direntry was at least copied if this then fails?

Is this really important? Normally -EFAULT should just not happen. In case it does I don't think the caller can make real use of the direntry.

Quoted 6 lines

"Important" has various possible meanings. The success/failure indication to the caller should at least be rational. "If the data buffer was not large enough for all the data no entry data is returned, but the direntry will contain the needed size for the returned data" is fine to be stated in the public header, but I think this wants to be -ENOBUFS then, not 0 (success).

I would be fine with this, but this contradicts your previous demand not to enumerate the possible failure cases, which would be essential for this case.

Quoted 20 lines
Quoted 16 lines
Quoted 15 lines

Anyway, this and ...

xen/common/hypfs.c line 263

Quoted 8 lines

+ out:

xen/common/hypfs.c new file +7 -0
+    xfree(buf);
+    return ret;
+}
+
+int hypfs_write_bool(struct hypfs_entry_leaf *leaf,
+                     XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen)
+{

... this function aren't very helpful to review without there being a caller. Could these be introduced at the time a first caller appears?

Quoted 3 lines

Of course. Question is where to stop. I wanted to have the basic hypfs support in one patch. Are you fine with just those two functions being moved to the runtime parameter patch?

Quoted 12 lines

Let me put it this way: For anything the patch adds but there's no usage at all (i.e. not even in a macro, where at least the usage intentions get sufficiently clarified), the description should cover for this lack of sufficient context. Therefore I'd also be fine with the two functions remaining here, as long as readers (reviewers) can understand the intentions. It might still be _easier_ for everyone to have them in a later patch. But then the same still goes for other functions that have no users here. (The helper macros HYPFS_*_INIT(), otoh, are clear enough the way they are imo, and hence are fine to remain, plus they serve as usage explanation for hypfs_read_{leaf,dir}(), which as it looks would otherwise too be orphaned.)

Fair enough.

Quoted 24 lines
Quoted 24 lines
Quoted 12 lines
Quoted 12 lines
xen/common/hypfs.c new file +11 -0
+    union {
+        char buf[8];
+        uint8_t u8;
+        uint16_t u16;
+        uint32_t u32;
+        uint64_t u64;
+    } u;
+
+    ASSERT(leaf->e.type == XEN_HYPFS_TYPE_UINT && leaf->e.size <= 8);
+
+    if ( ulen != leaf->e.size )
Quoted 8 lines
Quoted 1 line

+ return -EDOM;

Is this restriction really necessary? Setting e.g. a 4-byte field from 1-byte input is no problem at all. This being for booleans I anyway wonder why input might be helpful to have larger than a single byte. But maybe all of this is again a result of not seeing what a user of the function would look like.

I wanted to have as little functionality as possible in the hypervisor. It is no problem for the library to pass a properly sized buffer.

Quoted 8 lines
Quoted 2 lines

Allowing larger variables for booleans is just a consequence of the hypervisor parameters allowing that.

But the caller shouldn't be concerned of the hypervisor implementation detail of what the chose width is. Over time we e.g. convert int (along with bool_t) to bool when it's used in a boolean way. This should not result in the caller needing to change, despite the width change of the variable.

This is basically a consequence of now passing binary values to and from the hypervisor.

The normal way of handling this (as can be seen in libxenhypfs) is to query the hypervisor for the size of the value (no matter whether its int, uint or bool) and then to do the conversion between ASCII and the binary value at the caller's side.

Quoted 75 lines
Quoted 69 lines
Quoted 36 lines
Quoted 36 lines
xen/include/public/hypfs.h new file +32 -0
@@ -0,0 +1,124 @@
+/******************************************************************************
+ * Xen Hypervisor Filesystem
+ *
+ * Copyright (c) 2019, SUSE Software Solutions Germany GmbH
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __XEN_PUBLIC_HYPFS_H__
+#define __XEN_PUBLIC_HYPFS_H__
+
+#include "xen.h"
+
+/*
+ * Definitions for the __HYPERVISOR_hypfs_op hypercall.
Quoted 8 lines

xen/include/public/hypfs.h line 36

Quoted 4 lines
xen/include/public/hypfs.h new file +4 -0
+ */
+
+/* Highest version number of the hypfs interface currently defined. */
+#define XEN_HYPFS_VERSION      1

For this and the accompanying XEN_HYPFS_OP_get_version, at least the doc added by patch 3 could actually do with mentioning the intentions you have with this.

Okay.

Quoted 13 lines
Quoted 13 lines
xen/include/public/hypfs.h new file +12 -0
+/* Maximum length of a path in the filesystem. */
+#define XEN_HYPFS_MAX_PATHLEN 1024
+
+struct xen_hypfs_direntry {
+    uint16_t flags;
+#define XEN_HYPFS_WRITEABLE    0x0001
+    uint8_t type;
+#define XEN_HYPFS_TYPE_DIR     0x0000
+#define XEN_HYPFS_TYPE_BLOB    0x0001
+#define XEN_HYPFS_TYPE_STRING  0x0002
+#define XEN_HYPFS_TYPE_UINT    0x0003
+#define XEN_HYPFS_TYPE_INT     0x0004
Quoted 8 lines

xen/include/public/hypfs.h line 53

Quoted 4 lines
xen/include/public/hypfs.h new file +4 -0
+#define XEN_HYPFS_TYPE_BOOL    0x0005
+    uint8_t encoding;
+#define XEN_HYPFS_ENC_PLAIN    0x0000
+#define XEN_HYPFS_ENC_GZIP     0x0001

Meaning I can e.g. have a gzip-ed string or bool (or even dir)? If this is just for "blob", why have separate fields instead of e.g. BLOB_RAW and BLOB_GZIP or some such?

Quoted 5 lines

gzip-ed string or blob are the primary targets.

Maybe we want to have other encoding s later (Andrew asked for that possibility when I posted the patch for retrieving the .config file contents early last year).

Quoted 8 lines

To me it would seem preferable if the contents of a blob identified itself as to its format. But since this leaves room for ambiguities I accept that the format needs specifying. However, to me a gzip-ed string is as good as a gzip-ed blob, and hence I still think sub-dividing "blob" is the way to go, with no separate "encoding". Otherwise at the very least a comment here would need adding to clarify what combinations are valid / to be expected by callers.

libxenhypfs is able to handle all possible combinations. I just don't think some of the combinations are making sense (gzip-ing a binary value of 4 bytes e.g. is nonsense).

OTOH in case we'll add large arrays of longs in the future it might be beneficial to compress them in some way. So I'd like to keep type and encoding as separate information.

Quoted 41 lines
Quoted 41 lines
Quoted 40 lines
Quoted 27 lines
xen/include/public/hypfs.h new file +26 -0
+#define HYPFS_DIR_INIT(var, nam)                \
+    struct hypfs_entry_dir var = {              \
+        .e.type = XEN_HYPFS_TYPE_DIR,           \
+        .e.encoding = XEN_HYPFS_ENC_PLAIN,      \
+        .e.name = nam,                          \
+        .e.size = 0,                            \
+        .e.list = LIST_HEAD_INIT(var.e.list),   \
+        .e.read = hypfs_read_dir,               \
+        .dirlist = LIST_HEAD_INIT(var.dirlist), \
+    }
+
+/* Content and size need to be set via hypfs_string_set(). */
+#define HYPFS_STRING_INIT(var, nam)             \
+    struct hypfs_entry_leaf var = {             \
+        .e.type = XEN_HYPFS_TYPE_STRING,        \
+        .e.encoding = XEN_HYPFS_ENC_PLAIN,      \
+        .e.name = nam,                          \
+        .e.read = hypfs_read_leaf,              \
+    }
+
+static inline void hypfs_string_set(struct hypfs_entry_leaf *leaf,
+                                    const char *str)
+{
+    leaf->content = str;
+    leaf->e.size = strlen(str) + 1;
+}

xen/include/public/hypfs.h line 88

Quoted 10 lines
xen/include/public/hypfs.h new file +10 -0
+
+#define HYPFS_UINT_INIT(var, nam, uint)         \
+    struct hypfs_entry_leaf var = {             \
+        .e.type = XEN_HYPFS_TYPE_UINT,          \
+        .e.encoding = XEN_HYPFS_ENC_PLAIN,      \
+        .e.name = nam,                          \
+        .e.size = sizeof(uint),                 \
+        .e.read = hypfs_read_leaf,              \
+        .content = &uint,                       \
+    }

So you've got such helper macros for dir, string, and uint. Why not e.g. int and bool?

Quoted 6 lines
Quoted 1 line

There are no users in my series yet.

Hmm, as per above strictly speaking it is this patch which matters, not the entire series. Hence I think you either want to supply a full set of helper macros here, or introduce the ones actually needed in the patches where they get first used.

Okay, I'll go with the full set of helpers.

Quoted 15 lines
Quoted 15 lines
Quoted 6 lines

xen/include/public/hypfs.h line 89

Quoted 2 lines
xen/include/public/hypfs.h new file +1 -0
+struct hypfs_entry *hypfs_get_entry(const char *path);

Does the only caller really need a non-const return type? Even hypfs_write() doesn't look to modify what its leaf parameter points at.

This might change when support for dynamically allocated strings or blobs is added (I have no plans to do this right now, but its easy to think about the need).

Quoted 3 lines

And is there indeed an expectation for this to be used from outside of the source file it's defined in?

Quoted 6 lines
Quoted 2 lines

Yes. As soon as support for e.g. per-domain or per-cpupool nodes is added this will be needed.

Until then, make the function both static and return ptr-to-const? Such that when this changes, the need for either can actually be seen?

Fine with me.

Juergen

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

#25 lore raw

Re: [Xen-devel] [PATCH v3 4/9] xen: add basic hypervisor filesystem support

Quoted 50 lines · Jürgen Groß
Quoted 42 lines · Jan Beulich
Quoted 35 lines · Jürgen Groß
Quoted 17 lines · Jan Beulich
Quoted 16 lines · Juergen Gross
xen/common/hypfs.c new file +16 -0
+static int hypfs_read(const struct hypfs_entry *entry,
+                      XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen)
+{
+    struct xen_hypfs_direntry e;
+    long ret = -EINVAL;
+
+    if ( ulen < sizeof(e) )
+        goto out;
+
+    e.flags = entry->write ? XEN_HYPFS_WRITEABLE : 0;
+    e.type = entry->type;
+    e.encoding = entry->encoding;
+    e.content_len = entry->size;
+
+    ret = -EFAULT;
+    if ( copy_to_guest(uaddr, &e, 1) )
Quoted 8 lines

xen/common/hypfs.c line 224

Quoted 5 lines
xen/common/hypfs.c new file +5 -0
+        goto out;
+
+    ret = 0;
+    if ( ulen < entry->size + sizeof(e) )
+        goto out;

So you return "success" even if the operation didn't complete successfully. This isn't very nice, plus ...

The direntry contains the needed size. The caller should know the size he passed to Xen.

Quoted 5 lines
Quoted 4 lines
xen/common/hypfs.c new file +3 -0
+    guest_handle_add_offset(uaddr, sizeof(e));
+
+    ret = entry->read(entry, uaddr);
Quoted 5 lines
Quoted 2 lines

... how is the caller to know whether direntry was at least copied if this then fails?

Is this really important? Normally -EFAULT should just not happen. In case it does I don't think the caller can make real use of the direntry.

Quoted 6 lines

"Important" has various possible meanings. The success/failure indication to the caller should at least be rational. "If the data buffer was not large enough for all the data no entry data is returned, but the direntry will contain the needed size for the returned data" is fine to be stated in the public header, but I think this wants to be -ENOBUFS then, not 0 (success).

Quoted 3 lines

I would be fine with this, but this contradicts your previous demand not to enumerate the possible failure cases, which would be essential for this case.

Slightly re-writing the part of the comment I did quote would be all that's needed afaict: "If the data buffer was not large enough for all the data -ENOBUFS and no entry data is returned, but the direntry will contain the needed size for the returned data."

Quoted 32 lines
Quoted 23 lines
Quoted 23 lines
Quoted 11 lines
Quoted 11 lines
xen/common/hypfs.c new file +11 -0
+    union {
+        char buf[8];
+        uint8_t u8;
+        uint16_t u16;
+        uint32_t u32;
+        uint64_t u64;
+    } u;
+
+    ASSERT(leaf->e.type == XEN_HYPFS_TYPE_UINT && leaf->e.size <= 8);
+
+    if ( ulen != leaf->e.size )
Quoted 8 lines
Quoted 1 line

+ return -EDOM;

Is this restriction really necessary? Setting e.g. a 4-byte field from 1-byte input is no problem at all. This being for booleans I anyway wonder why input might be helpful to have larger than a single byte. But maybe all of this is again a result of not seeing what a user of the function would look like.

I wanted to have as little functionality as possible in the hypervisor. It is no problem for the library to pass a properly sized buffer.

Quoted 8 lines
Quoted 2 lines

Allowing larger variables for booleans is just a consequence of the hypervisor parameters allowing that.

But the caller shouldn't be concerned of the hypervisor implementation detail of what the chose width is. Over time we e.g. convert int (along with bool_t) to bool when it's used in a boolean way. This should not result in the caller needing to change, despite the width change of the variable.

Quoted 7 lines

This is basically a consequence of now passing binary values to and from the hypervisor.

The normal way of handling this (as can be seen in libxenhypfs) is to query the hypervisor for the size of the value (no matter whether its int, uint or bool) and then to do the conversion between ASCII and the binary value at the caller's side.

I can see why this is needed for e.g. integer values, but I don't see the need for booleans.

Quoted 33 lines
Quoted 24 lines
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
xen/include/public/hypfs.h new file +9 -0
+struct xen_hypfs_direntry {
+    uint16_t flags;
+#define XEN_HYPFS_WRITEABLE    0x0001
+    uint8_t type;
+#define XEN_HYPFS_TYPE_DIR     0x0000
+#define XEN_HYPFS_TYPE_BLOB    0x0001
+#define XEN_HYPFS_TYPE_STRING  0x0002
+#define XEN_HYPFS_TYPE_UINT    0x0003
+#define XEN_HYPFS_TYPE_INT     0x0004
Quoted 8 lines

xen/include/public/hypfs.h line 53

Quoted 4 lines
xen/include/public/hypfs.h new file +4 -0
+#define XEN_HYPFS_TYPE_BOOL    0x0005
+    uint8_t encoding;
+#define XEN_HYPFS_ENC_PLAIN    0x0000
+#define XEN_HYPFS_ENC_GZIP     0x0001

Meaning I can e.g. have a gzip-ed string or bool (or even dir)? If this is just for "blob", why have separate fields instead of e.g. BLOB_RAW and BLOB_GZIP or some such?

Quoted 5 lines

gzip-ed string or blob are the primary targets.

Maybe we want to have other encoding s later (Andrew asked for that possibility when I posted the patch for retrieving the .config file contents early last year).

Quoted 8 lines

To me it would seem preferable if the contents of a blob identified itself as to its format. But since this leaves room for ambiguities I accept that the format needs specifying. However, to me a gzip-ed string is as good as a gzip-ed blob, and hence I still think sub-dividing "blob" is the way to go, with no separate "encoding". Otherwise at the very least a comment here would need adding to clarify what combinations are valid / to be expected by callers.

Quoted 7 lines

libxenhypfs is able to handle all possible combinations. I just don't think some of the combinations are making sense (gzip-ing a binary value of 4 bytes e.g. is nonsense).

OTOH in case we'll add large arrays of longs in the future it might be beneficial to compress them in some way. So I'd like to keep type and encoding as separate information.

Okay, I'm not entirely opposed. But I'd be curious if anyone else has an opinion here.

Jan

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

#26 lore raw

Re: [Xen-devel] [PATCH v3 4/9] xen: add basic hypervisor filesystem support

Quoted 51 lines · Jan Beulich
Quoted 50 lines · Jürgen Groß
Quoted 48 lines · Jan Beulich
Quoted 35 lines · Jürgen Groß
Quoted 17 lines · Jan Beulich
Quoted 16 lines · Juergen Gross
xen/common/hypfs.c new file +16 -0
+static int hypfs_read(const struct hypfs_entry *entry,
+                      XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen)
+{
+    struct xen_hypfs_direntry e;
+    long ret = -EINVAL;
+
+    if ( ulen < sizeof(e) )
+        goto out;
+
+    e.flags = entry->write ? XEN_HYPFS_WRITEABLE : 0;
+    e.type = entry->type;
+    e.encoding = entry->encoding;
+    e.content_len = entry->size;
+
+    ret = -EFAULT;
+    if ( copy_to_guest(uaddr, &e, 1) )
Quoted 8 lines

xen/common/hypfs.c line 224

Quoted 5 lines
xen/common/hypfs.c new file +5 -0
+        goto out;
+
+    ret = 0;
+    if ( ulen < entry->size + sizeof(e) )
+        goto out;

So you return "success" even if the operation didn't complete successfully. This isn't very nice, plus ...

The direntry contains the needed size. The caller should know the size he passed to Xen.

Quoted 5 lines
Quoted 4 lines
xen/common/hypfs.c new file +3 -0
+    guest_handle_add_offset(uaddr, sizeof(e));
+
+    ret = entry->read(entry, uaddr);
Quoted 5 lines
Quoted 2 lines

... how is the caller to know whether direntry was at least copied if this then fails?

Is this really important? Normally -EFAULT should just not happen. In case it does I don't think the caller can make real use of the direntry.

"Important" has various possible meanings. The success/failure indication to the caller should at least be rational. "If the data buffer was not large enough for all the data no entry data is returned, but the direntry will contain the needed size for the returned data" is fine to be stated in the public header, but I think this wants to be -ENOBUFS then, not 0 (success).

Quoted 8 lines
Quoted 3 lines

I would be fine with this, but this contradicts your previous demand not to enumerate the possible failure cases, which would be essential for this case.

Slightly re-writing the part of the comment I did quote would be all that's needed afaict: "If the data buffer was not large enough for all the data -ENOBUFS and no entry data is returned, but the direntry will contain the needed size for the returned data."

Okay. Fine with me.

Quoted 36 lines
Quoted 36 lines
Quoted 24 lines
Quoted 24 lines
Quoted 12 lines
Quoted 12 lines
xen/common/hypfs.c new file +11 -0
+    union {
+        char buf[8];
+        uint8_t u8;
+        uint16_t u16;
+        uint32_t u32;
+        uint64_t u64;
+    } u;
+
+    ASSERT(leaf->e.type == XEN_HYPFS_TYPE_UINT && leaf->e.size <= 8);
+
+    if ( ulen != leaf->e.size )
Quoted 8 lines
Quoted 1 line

+ return -EDOM;

Is this restriction really necessary? Setting e.g. a 4-byte field from 1-byte input is no problem at all. This being for booleans I anyway wonder why input might be helpful to have larger than a single byte. But maybe all of this is again a result of not seeing what a user of the function would look like.

I wanted to have as little functionality as possible in the hypervisor. It is no problem for the library to pass a properly sized buffer.

Quoted 8 lines
Quoted 2 lines

Allowing larger variables for booleans is just a consequence of the hypervisor parameters allowing that.

But the caller shouldn't be concerned of the hypervisor implementation detail of what the chose width is. Over time we e.g. convert int (along with bool_t) to bool when it's used in a boolean way. This should not result in the caller needing to change, despite the width change of the variable.

This is basically a consequence of now passing binary values to and from the hypervisor.

Quoted 7 lines
Quoted 4 lines

The normal way of handling this (as can be seen in libxenhypfs) is to query the hypervisor for the size of the value (no matter whether its int, uint or bool) and then to do the conversion between ASCII and the binary value at the caller's side.

I can see why this is needed for e.g. integer values, but I don't see the need for booleans.

At some level the conversion needs to be done. I'd rather do it for all types at the same level.

Quoted 38 lines
Quoted 38 lines
Quoted 25 lines
Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
xen/include/public/hypfs.h new file +9 -0
+struct xen_hypfs_direntry {
+    uint16_t flags;
+#define XEN_HYPFS_WRITEABLE    0x0001
+    uint8_t type;
+#define XEN_HYPFS_TYPE_DIR     0x0000
+#define XEN_HYPFS_TYPE_BLOB    0x0001
+#define XEN_HYPFS_TYPE_STRING  0x0002
+#define XEN_HYPFS_TYPE_UINT    0x0003
+#define XEN_HYPFS_TYPE_INT     0x0004
Quoted 8 lines

xen/include/public/hypfs.h line 53

Quoted 4 lines
xen/include/public/hypfs.h new file +4 -0
+#define XEN_HYPFS_TYPE_BOOL    0x0005
+    uint8_t encoding;
+#define XEN_HYPFS_ENC_PLAIN    0x0000
+#define XEN_HYPFS_ENC_GZIP     0x0001

Meaning I can e.g. have a gzip-ed string or bool (or even dir)? If this is just for "blob", why have separate fields instead of e.g. BLOB_RAW and BLOB_GZIP or some such?

Quoted 5 lines

gzip-ed string or blob are the primary targets.

Maybe we want to have other encoding s later (Andrew asked for that possibility when I posted the patch for retrieving the .config file contents early last year).

Quoted 8 lines

To me it would seem preferable if the contents of a blob identified itself as to its format. But since this leaves room for ambiguities I accept that the format needs specifying. However, to me a gzip-ed string is as good as a gzip-ed blob, and hence I still think sub-dividing "blob" is the way to go, with no separate "encoding". Otherwise at the very least a comment here would need adding to clarify what combinations are valid / to be expected by callers.

libxenhypfs is able to handle all possible combinations. I just don't think some of the combinations are making sense (gzip-ing a binary value of 4 bytes e.g. is nonsense).

Quoted 6 lines
Quoted 3 lines

OTOH in case we'll add large arrays of longs in the future it might be beneficial to compress them in some way. So I'd like to keep type and encoding as separate information.

Okay, I'm not entirely opposed. But I'd be curious if anyone else has an opinion here.

I think content type and transport encoding should not be mixed up. They are orthogonal to each other and so they should be handled.

Juergen

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

#27 lore raw

Re: [Xen-devel] [PATCH v3 4/9] xen: add basic hypervisor filesystem support

Quoted 47 lines · Jürgen Groß
Quoted 46 lines · Jan Beulich
Quoted 44 lines · Jürgen Groß
Quoted 27 lines · Jan Beulich
Quoted 20 lines · Jürgen Groß
Quoted 10 lines · Jan Beulich
Quoted 9 lines · Juergen Gross
(quoted diff) +9 -0
+struct xen_hypfs_direntry {
+    uint16_t flags;
+#define XEN_HYPFS_WRITEABLE    0x0001
+    uint8_t type;
+#define XEN_HYPFS_TYPE_DIR     0x0000
+#define XEN_HYPFS_TYPE_BLOB    0x0001
+#define XEN_HYPFS_TYPE_STRING  0x0002
+#define XEN_HYPFS_TYPE_UINT    0x0003
+#define XEN_HYPFS_TYPE_INT     0x0004
Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+#define XEN_HYPFS_TYPE_BOOL    0x0005
+    uint8_t encoding;
+#define XEN_HYPFS_ENC_PLAIN    0x0000
+#define XEN_HYPFS_ENC_GZIP     0x0001

Meaning I can e.g. have a gzip-ed string or bool (or even dir)? If this is just for "blob", why have separate fields instead of e.g. BLOB_RAW and BLOB_GZIP or some such?

Quoted 5 lines

gzip-ed string or blob are the primary targets.

Maybe we want to have other encoding s later (Andrew asked for that possibility when I posted the patch for retrieving the .config file contents early last year).

Quoted 8 lines

To me it would seem preferable if the contents of a blob identified itself as to its format. But since this leaves room for ambiguities I accept that the format needs specifying. However, to me a gzip-ed string is as good as a gzip-ed blob, and hence I still think sub-dividing "blob" is the way to go, with no separate "encoding". Otherwise at the very least a comment here would need adding to clarify what combinations are valid / to be expected by callers.

libxenhypfs is able to handle all possible combinations. I just don't think some of the combinations are making sense (gzip-ing a binary value of 4 bytes e.g. is nonsense).

OTOH in case we'll add large arrays of longs in the future it might be beneficial to compress them in some way. So I'd like to keep type and encoding as separate information.

Quoted 5 lines
Quoted 2 lines

Okay, I'm not entirely opposed. But I'd be curious if anyone else has an opinion here.

I think content type and transport encoding should not be mixed up. They are orthogonal to each other and so they should be handled.

In principle I agree, but "blob" really covers anything or nothing at all. Yes, if strings are meant to be possible to be gzip-ed, then there is value in the separation. I'm not fully convinced though that such compressed strings (Are you thinking about .config here?) shouldn't simply be "blob" then, too.

Jan

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

#28 lore raw

Re: [Xen-devel] [PATCH v3 4/9] xen: add basic hypervisor filesystem support

Quoted 51 lines · Jan Beulich
Quoted 50 lines · Jürgen Groß
Quoted 48 lines · Jan Beulich
Quoted 37 lines · Jürgen Groß
Quoted 27 lines · Jan Beulich
Quoted 20 lines · Jürgen Groß
Quoted 10 lines · Jan Beulich
Quoted 9 lines · Juergen Gross
(quoted diff) +9 -0
+struct xen_hypfs_direntry {
+    uint16_t flags;
+#define XEN_HYPFS_WRITEABLE    0x0001
+    uint8_t type;
+#define XEN_HYPFS_TYPE_DIR     0x0000
+#define XEN_HYPFS_TYPE_BLOB    0x0001
+#define XEN_HYPFS_TYPE_STRING  0x0002
+#define XEN_HYPFS_TYPE_UINT    0x0003
+#define XEN_HYPFS_TYPE_INT     0x0004
Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+#define XEN_HYPFS_TYPE_BOOL    0x0005
+    uint8_t encoding;
+#define XEN_HYPFS_ENC_PLAIN    0x0000
+#define XEN_HYPFS_ENC_GZIP     0x0001

Meaning I can e.g. have a gzip-ed string or bool (or even dir)? If this is just for "blob", why have separate fields instead of e.g. BLOB_RAW and BLOB_GZIP or some such?

Quoted 5 lines

gzip-ed string or blob are the primary targets.

Maybe we want to have other encoding s later (Andrew asked for that possibility when I posted the patch for retrieving the .config file contents early last year).

Quoted 8 lines

To me it would seem preferable if the contents of a blob identified itself as to its format. But since this leaves room for ambiguities I accept that the format needs specifying. However, to me a gzip-ed string is as good as a gzip-ed blob, and hence I still think sub-dividing "blob" is the way to go, with no separate "encoding". Otherwise at the very least a comment here would need adding to clarify what combinations are valid / to be expected by callers.

Quoted 7 lines

libxenhypfs is able to handle all possible combinations. I just don't think some of the combinations are making sense (gzip-ing a binary value of 4 bytes e.g. is nonsense).

OTOH in case we'll add large arrays of longs in the future it might be beneficial to compress them in some way. So I'd like to keep type and encoding as separate information.

Okay, I'm not entirely opposed. But I'd be curious if anyone else has an opinion here.

Quoted 8 lines
Quoted 2 lines

I think content type and transport encoding should not be mixed up. They are orthogonal to each other and so they should be handled.

In principle I agree, but "blob" really covers anything or nothing at all. Yes, if strings are meant to be possible to be gzip-ed, then there is value in the separation. I'm not fully convinced though that such compressed strings (Are you thinking about .config here?) shouldn't simply be "blob" then, too.

With a library on top of the hypercall it is easy to hide the encoding from the standard user. So even with .config being held in gzip-ed format in the hypervisor the xenhypfs tool will still just print the textual form of it when reading the associated node. This is different from sysfs or procfs of the Linux kernel, where the raw data is presented at the primary user interface. Additionally this enables us to avoid having to specify the compression format as a stable ABI. We could at any time switch to uncompressed format without problem.

Juergen

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

#29 lore raw

PATCH v3 5/9 libs: add libxenhypfs

In reply to Juergen Gross

Add the new library libxenhypfs for access to the hypervisor filesystem.

---
V1:
- rename to libxenhypfs
- add xenhypfs_write()

V3:
- major rework due to new hypervisor interface
- add decompression capability

---
 .gitignore                          |   2 +
 tools/Rules.mk                      |   6 +
 tools/libs/Makefile                 |   1 +
 tools/libs/hypfs/Makefile           |  16 ++
 tools/libs/hypfs/core.c             | 535 ++++++++++++++++++++++++++++++++++++
 tools/libs/hypfs/include/xenhypfs.h |  75 +++++
 tools/libs/hypfs/libxenhypfs.map    |  10 +
 tools/libs/hypfs/xenhypfs.pc.in     |  10 +
 8 files changed, 655 insertions(+)
 create mode 100644 tools/libs/hypfs/Makefile
 create mode 100644 tools/libs/hypfs/core.c
 create mode 100644 tools/libs/hypfs/include/xenhypfs.h
 create mode 100644 tools/libs/hypfs/libxenhypfs.map
 create mode 100644 tools/libs/hypfs/xenhypfs.pc.in
.gitignore +2 -0
index b2624df79a..e98c3f056d 100644
@@ -109,6 +109,8 @@ tools/libs/evtchn/headers.chk
 tools/libs/evtchn/xenevtchn.pc
 tools/libs/gnttab/headers.chk
 tools/libs/gnttab/xengnttab.pc
+tools/libs/hypfs/headers.chk
+tools/libs/hypfs/xenhypfs.pc
 tools/libs/call/headers.chk
 tools/libs/call/xencall.pc
 tools/libs/foreignmemory/headers.chk
tools/Rules.mk +6 -0
index 52f47be3f8..a04697a33c 100644
@@ -19,6 +19,7 @@ XEN_LIBXENGNTTAB   = $(XEN_ROOT)/tools/libs/gnttab
 XEN_LIBXENCALL     = $(XEN_ROOT)/tools/libs/call
 XEN_LIBXENFOREIGNMEMORY = $(XEN_ROOT)/tools/libs/foreignmemory
 XEN_LIBXENDEVICEMODEL = $(XEN_ROOT)/tools/libs/devicemodel
+XEN_LIBXENHYPFS    = $(XEN_ROOT)/tools/libs/hypfs
 XEN_LIBXC          = $(XEN_ROOT)/tools/libxc
 XEN_XENLIGHT       = $(XEN_ROOT)/tools/libxl
 # Currently libxlutil lives in the same directory as libxenlight
@@ -134,6 +135,11 @@ SHDEPS_libxendevicemodel = $(SHLIB_libxentoollog) $(SHLIB_libxentoolcore) $(SHLI
 LDLIBS_libxendevicemodel = $(SHDEPS_libxendevicemodel) $(XEN_LIBXENDEVICEMODEL)/libxendevicemodel$(libextension)
 SHLIB_libxendevicemodel  = $(SHDEPS_libxendevicemodel) -Wl,-rpath-link=$(XEN_LIBXENDEVICEMODEL)
 
+CFLAGS_libxenhypfs = -I$(XEN_LIBXENHYPFS)/include $(CFLAGS_xeninclude)
+SHDEPS_libxenhypfs = $(SHLIB_libxentoollog) $(SHLIB_libxentoolcore) $(SHLIB_xencall)
+LDLIBS_libxenhypfs = $(SHDEPS_libxenhypfs) $(XEN_LIBXENHYPFS)/libxenhypfs$(libextension)
+SHLIB_libxenhypfs  = $(SHDEPS_libxenhypfs) -Wl,-rpath-link=$(XEN_LIBXENHYPFS)
+
 # code which compiles against libxenctrl get __XEN_TOOLS__ and
 # therefore sees the unstable hypercall interfaces.
 CFLAGS_libxenctrl = -I$(XEN_LIBXC)/include $(CFLAGS_libxentoollog) $(CFLAGS_libxenforeignmemory) $(CFLAGS_libxendevicemodel) $(CFLAGS_xeninclude) -D__XEN_TOOLS__
tools/libs/Makefile +1 -0
index 88901e7341..69cdfb5975 100644
@@ -9,6 +9,7 @@ SUBDIRS-y += gnttab
 SUBDIRS-y += call
 SUBDIRS-y += foreignmemory
 SUBDIRS-y += devicemodel
+SUBDIRS-y += hypfs
 
 ifeq ($(CONFIG_RUMP),y)
 SUBDIRS-y := toolcore
tools/libs/hypfs/Makefile new file +16 -0
new file mode 100644
index 0000000000..06dd449929
@@ -0,0 +1,16 @@
+XEN_ROOT = $(CURDIR)/../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+MAJOR    = 1
+MINOR    = 0
+LIBNAME  := hypfs
+USELIBS  := toollog toolcore call
+
+APPEND_LDFLAGS += -lz
+
+SRCS-y                 += core.c
+
+include ../libs.mk
+
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_LIBXENHYPFS)/include
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
tools/libs/hypfs/core.c new file +535 -0

535 lines not on this page · raw message

tools/libs/hypfs/include/xenhypfs.h new file +75 -0

75 lines not on this page · raw message

tools/libs/hypfs/libxenhypfs.map new file +10 -0
new file mode 100644
index 0000000000..47f1edda3e
@@ -0,0 +1,10 @@
+VERS_1.0 {
+	global:
+		xenhypfs_open;
+		xenhypfs_close;
+		xenhypfs_read_raw;
+		xenhypfs_read;
+		xenhypfs_readdir;
+		xenhypfs_write;
+	local: *; /* Do not expose anything by default */
+};
tools/libs/hypfs/xenhypfs.pc.in new file +10 -0
new file mode 100644
index 0000000000..9cb968f0db
@@ -0,0 +1,10 @@
+prefix=@@prefix@@
+includedir=@@incdir@@
+libdir=@@libdir@@
+
+Name: Xenhypfs
+Description: The Xenhypfs library for Xen hypervisor
+Version: @@version@@
+Cflags: -I${includedir} @@cflagslocal@@
+Libs: @@libsflag@@${libdir} -lxenhypfs
+Requires.private: xentoolcore,xentoollog,xencall
Signature · 7 lines
2.16.4


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

Re: [Xen-devel] [PATCH v3 5/9] libs: add libxenhypfs

Quoted 3 lines · Juergen Gross

Add the new library libxenhypfs for access to the hypervisor filesystem.

I've only skimmed read it. The code looks sensible.

One minor comment.

Quoted 6 lines
tools/libs/hypfs/xenhypfs.pc.in new file +0 -0
new file mode 100644
index 0000000000..9cb968f0db

tools/libs/hypfs/xenhypfs.pc.in line 10

Quoted 10 lines
tools/libs/hypfs/xenhypfs.pc.in new file +10 -0
@@ -0,0 +1,10 @@
+prefix=@@prefix@@
+includedir=@@incdir@@
+libdir=@@libdir@@
+
+Name: Xenhypfs
+Description: The Xenhypfs library for Xen hypervisor
+Version: @@version@@
+Cflags: -I${includedir} @@cflagslocal@@
+Libs: @@libsflag@@${libdir} -lxenhypfs
+Requires.private: xentoolcore,xentoollog,xencall

Need to list libz here?

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

#31 lore raw

Re: [Xen-devel] [PATCH v3 5/9] libs: add libxenhypfs

Quoted 19 lines · Wei Liu
Quoted 3 lines · Juergen Gross

Add the new library libxenhypfs for access to the hypervisor filesystem.

I've only skimmed read it. The code looks sensible.

One minor comment.

Quoted 10 lines
tools/libs/hypfs/xenhypfs.pc.in new file +4 -0
new file mode 100644
index 0000000000..9cb968f0db
@@ -0,0 +1,10 @@
+prefix=@@prefix@@
+includedir=@@incdir@@
+libdir=@@libdir@@
+
Quoted 8 lines

tools/libs/hypfs/xenhypfs.pc.in line 10

Quoted 6 lines
tools/libs/hypfs/xenhypfs.pc.in new file +6 -0
+Name: Xenhypfs
+Description: The Xenhypfs library for Xen hypervisor
+Version: @@version@@
+Cflags: -I${includedir} @@cflagslocal@@
+Libs: @@libsflag@@${libdir} -lxenhypfs
+Requires.private: xentoolcore,xentoollog,xencall

Need to list libz here?

Probably, yes.

Juergen

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

#32 lore raw

Re: [Xen-devel] [PATCH v3 5/9] libs: add libxenhypfs

Quoted 5 lines · Jürgen Groß
Quoted 3 lines · Wei Liu
Quoted 1 line · Juergen Gross

+Requires.private: xentoolcore,xentoollog,xencall

Need to list libz here?

Probably, yes.

See "rpm -qf --provides /usr/include/zlib.h" for the proper value within the "pkgconfig" namespace. It is 'zlib' instead of 'z'.

Olaf

#33 lore raw

PATCH v3 6/9 tools: add xenfs tool

In reply to Juergen Gross

Add the xenfs tool for accessing the hypervisor filesystem.

---
V1:
- rename to xenhypfs
- don't use "--" for subcommands
- add write support

V2:
- escape non-printable characters per default with cat subcommand (Ian Jackson)
- add -b option to cat subcommand (Ian Jackson)
- add man page

V3:
- adapt to new hypfs interface

---
 .gitignore              |   1 +
 docs/man/xenhypfs.1.pod |  61 ++++++++++++++++
 tools/misc/Makefile     |   6 ++
 tools/misc/xenhypfs.c   | 189 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 257 insertions(+)
 create mode 100644 docs/man/xenhypfs.1.pod
 create mode 100644 tools/misc/xenhypfs.c
.gitignore +1 -0
index e98c3f056d..fd5610718d 100644
@@ -367,6 +367,7 @@ tools/libxl/test_timedereg
 tools/libxl/test_fdderegrace
 tools/firmware/etherboot/eb-roms.h
 tools/firmware/etherboot/gpxe-git-snapshot.tar.gz
+tools/misc/xenhypfs
 tools/misc/xenwatchdogd
 tools/misc/xen-hvmcrash
 tools/misc/xen-lowmemd
docs/man/xenhypfs.1.pod new file +61 -0

61 lines not on this page · raw message

tools/misc/Makefile +6 -0
index 63947bfadc..9fdb13597f 100644
@@ -24,6 +24,7 @@ INSTALL_SBIN-$(CONFIG_X86)     += xen-lowmemd
 INSTALL_SBIN-$(CONFIG_X86)     += xen-mfndump
 INSTALL_SBIN-$(CONFIG_X86)     += xen-ucode
 INSTALL_SBIN                   += xencov
+INSTALL_SBIN                   += xenhypfs
 INSTALL_SBIN                   += xenlockprof
 INSTALL_SBIN                   += xenperf
 INSTALL_SBIN                   += xenpm
@@ -86,6 +87,9 @@ xenperf: xenperf.o
 xenpm: xenpm.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
 
+xenhypfs: xenhypfs.o
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenhypfs) $(APPEND_LDFLAGS)
+
 xenlockprof: xenlockprof.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
 
@@ -94,6 +98,8 @@ xen-hptool.o: CFLAGS += -I$(XEN_ROOT)/tools/libxc $(CFLAGS_libxencall)
 xen-hptool: xen-hptool.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) $(APPEND_LDFLAGS)
 
+xenhypfs.o: CFLAGS += $(CFLAGS_libxenhypfs)
+
 # xen-mfndump incorrectly uses libxc internals
 xen-mfndump.o: CFLAGS += -I$(XEN_ROOT)/tools/libxc $(CFLAGS_libxencall)
 xen-mfndump: xen-mfndump.o
tools/misc/xenhypfs.c new file +189 -0

189 lines not on this page · raw message

Signature · 7 lines
2.16.4


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

PATCH v3 7/9 xen: provide version information in hypfs

In reply to Juergen Gross

Provide version and compile information in /buildinfo/ node of the Xen hypervisor file system. As this information is accessible by dom0 only no additional security problem arises.

---
V3:
- new patch

---
 docs/misc/hypfs-paths.pandoc | 45 ++++++++++++++++++++++++++++++++++++++++++++
 xen/common/kernel.c          | 45 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+)
docs/misc/hypfs-paths.pandoc +45 -0
index 67de8d2cf8..1f63c5c13e 100644
@@ -93,3 +93,48 @@ A populated Xen hypervisor file system might look like the following example:
 #### /
 
 The root of the hypervisor file system.
+
+#### /buildinfo/
+
+A directory containing static information generated while building the
+hypervisor.
+
+#### /buildinfo/changeset = STRING
+
+Git commit of the hypervisor.
+
+#### /buildinfo/compileinfo/
+
+A directory containing information about compilation of Xen.
+
+#### /buildinfo/compileinfo/compile_by = STRING
+
+Information who compiled the hypervisor.
+
+#### /buildinfo/compileinfo/compile_date = STRING
+
+Date of the hypervisor compilation.
+
+#### /buildinfo/compileinfo/compile_domain = STRING
+
+Information about the compile domain.
+
+#### /buildinfo/compileinfo/compiler = STRING
+
+The compiler used to build Xen.
+
+#### /buildinfo/version/
+
+A directory containing version information of the hypervisor.
+
+#### /buildinfo/version/extra = STRING
+
+Extra version information.
+
+#### /buildinfo/version/major = INTEGER
+
+The major version of Xen.
+
+#### /buildinfo/version/minor = INTEGER
+
+The minor version of Xen.
xen/common/kernel.c +45 -0

57 lines not on this page · raw message

Signature · 7 lines
2.16.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v3 7/9
#36 lore raw

Re: [Xen-devel] [PATCH v3 7/9] xen: provide version information in hypfs

Quoted 5 lines · Juergen Gross

Provide version and compile information in /buildinfo/ node of the Xen hypervisor file system. As this information is accessible by dom0 only no additional security problem arises.

with on suggestion:

Quoted 8 lines
xen/common/kernel.c +4 -0
@@ -373,6 +374,50 @@ void __init do_initcalls(void)
         (*call)();
 }
 
+static unsigned int major_version;
+static unsigned int minor_version;
+
+static HYPFS_DIR_INIT(buildinfo, "buildinfo");

xen/common/kernel.c void __init do_initcalls(void) · line 390

Quoted 10 lines
xen/common/kernel.c +10 -0
+static HYPFS_DIR_INIT(compileinfo, "compileinfo");
+static HYPFS_DIR_INIT(version, "version");
+static HYPFS_UINT_INIT(major, "major", major_version);
+static HYPFS_UINT_INIT(minor, "minor", minor_version);
+static HYPFS_STRING_INIT(changeset, "changeset");
+static HYPFS_STRING_INIT(compiler, "compiler");
+static HYPFS_STRING_INIT(compile_by, "compile_by");
+static HYPFS_STRING_INIT(compile_date, "compile_date");
+static HYPFS_STRING_INIT(compile_domain, "compile_domain");
+static HYPFS_STRING_INIT(extra, "extra");

Please consider making all of the above __read_mostly.

Jan

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

#37 lore raw

Re: [Xen-devel] [PATCH v3 7/9] xen: provide version information in hypfs

Quoted 14 lines · Jan Beulich
Quoted 5 lines · Juergen Gross

Provide version and compile information in /buildinfo/ node of the Xen hypervisor file system. As this information is accessible by dom0 only no additional security problem arises.

with on suggestion:

Quoted 4 lines
xen/common/kernel.c +0 -0
@@ -373,6 +374,50 @@ void __init do_initcalls(void)
          (*call)();
  }
 
Quoted 16 lines
Quoted 4 lines
xen/common/kernel.c +4 -0
+static unsigned int major_version;
+static unsigned int minor_version;
+
+static HYPFS_DIR_INIT(buildinfo, "buildinfo");

xen/common/kernel.c void __init do_initcalls(void) · line 390

Quoted 10 lines
xen/common/kernel.c +10 -0
+static HYPFS_DIR_INIT(compileinfo, "compileinfo");
+static HYPFS_DIR_INIT(version, "version");
+static HYPFS_UINT_INIT(major, "major", major_version);
+static HYPFS_UINT_INIT(minor, "minor", minor_version);
+static HYPFS_STRING_INIT(changeset, "changeset");
+static HYPFS_STRING_INIT(compiler, "compiler");
+static HYPFS_STRING_INIT(compile_by, "compile_by");
+static HYPFS_STRING_INIT(compile_date, "compile_date");
+static HYPFS_STRING_INIT(compile_domain, "compile_domain");
+static HYPFS_STRING_INIT(extra, "extra");

Please consider making all of the above __read_mostly.

Okay.

Juergen

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

#38 lore raw

PATCH v3 8/9 xen: add /buildinfo/config entry to hypervisor filesystem

In reply to Juergen Gross

Add the /buildinfo/config entry to the hypervisor filesystem. This entry contains the .config file used to build the hypervisor.

---
V3:
- store data in gzip format
- use binfile mechanism to create data file
- move code to kernel.c

---
 .gitignore                   |  2 ++
 docs/misc/hypfs-paths.pandoc |  4 ++++
 xen/common/Makefile          | 12 ++++++++++++
 xen/common/kernel.c          | 10 ++++++++++
 xen/include/xen/kernel.h     |  3 +++
 5 files changed, 31 insertions(+)
.gitignore +2 -0
index fd5610718d..bc8e053ccb 100644
@@ -297,6 +297,8 @@ xen/arch/*/efi/boot.c
 xen/arch/*/efi/compat.c
 xen/arch/*/efi/efi.h
 xen/arch/*/efi/runtime.c
+xen/common/config_data.S
+xen/common/config.gz
 xen/include/headers*.chk
 xen/include/asm
 xen/include/asm-*/asm-offsets.h
docs/misc/hypfs-paths.pandoc +4 -0
index 1f63c5c13e..e8ae52ea45 100644
@@ -123,6 +123,10 @@ Information about the compile domain.
 
 The compiler used to build Xen.
 
+#### /buildinfo/config = STRING
+
+The contents of the `xen/.config` file at the time of the hypervisor build.
+
 #### /buildinfo/version/
 
 A directory containing version information of the hypervisor.
xen/common/Makefile +12 -0
index a3f66aa0c0..64017dd130 100644
@@ -1,6 +1,7 @@
 obj-$(CONFIG_ARGO) += argo.o
 obj-y += bitmap.o
 obj-y += bsearch.o
+obj-y += config_data.o
 obj-$(CONFIG_CORE_PARKING) += core_parking.o
 obj-y += cpu.o
 obj-y += cpupool.o
@@ -79,3 +80,14 @@ subdir-$(CONFIG_UBSAN) += ubsan
 
 subdir-$(CONFIG_NEEDS_LIBELF) += libelf
 subdir-$(CONFIG_HAS_DEVICE_TREE) += libfdt
+
+config.gz: ../.config
+	gzip -c $< >$@
+
+config_data.o: config.gz
+
+config_data.S: $(XEN_ROOT)/xen/tools/binfile
+	$(XEN_ROOT)/xen/tools/binfile $@ config.gz xen_config_data
+
+clean::
+	rm config_data.S config.gz 2>/dev/null || true
xen/common/kernel.c +10 -0
index 3186fd59c2..b5ee3011f5 100644
@@ -388,6 +388,13 @@ static HYPFS_STRING_INIT(compile_by, "compile_by");
 static HYPFS_STRING_INIT(compile_date, "compile_date");
 static HYPFS_STRING_INIT(compile_domain, "compile_domain");
 static HYPFS_STRING_INIT(extra, "extra");
+static struct hypfs_entry_leaf config = {
+    .e.type = XEN_HYPFS_TYPE_STRING,
+    .e.encoding = XEN_HYPFS_ENC_GZIP,
+    .e.name = "config",
+    .e.read = hypfs_read_leaf,
+    .content = &xen_config_data
+};
 
 static int __init buildinfo_init(void)
 {
@@ -414,6 +421,9 @@ static int __init buildinfo_init(void)
     hypfs_add_leaf(&version, &major, true);
     hypfs_add_leaf(&version, &minor, true);
 
+    config.e.size = xen_config_data_size;
+    hypfs_add_leaf(&buildinfo, &config, true);
+
     return 0;
 }
 __initcall(buildinfo_init);
xen/include/xen/kernel.h +3 -0
index 548b64da9f..2f883031f9 100644
@@ -100,5 +100,8 @@ extern enum system_state {
 
 bool_t is_active_kernel_text(unsigned long addr);
 
+extern char xen_config_data;
+extern unsigned int xen_config_data_size;
+
 #endif /* _LINUX_KERNEL_H */
 
Signature · 7 lines
2.16.4


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

PATCH v3 9/9 xen: add runtime parameter access support to hypfs

In reply to Juergen Gross

Add support to read and modify values of hypervisor runtime parameters via the hypervisor file system.

As runtime parameters can be modified via a sysctl, too, this path has to take the hypfs rw_lock as writer.

For custom runtime parameters the resulting parameter value needs to be stored in a string buffer for being consumable by the file system.

---
V3:
- complete rework
- support custom parameters, too
- support parameter writing

---
 docs/misc/hypfs-paths.pandoc |  9 ++++++
 xen/arch/arm/xen.lds.S       |  5 +++
 xen/arch/x86/hvm/vmx/vmcs.c  | 17 +++++++++-
 xen/arch/x86/pv/domain.c     |  7 ++++-
 xen/arch/x86/xen.lds.S       |  5 +++
 xen/common/grant_table.c     | 17 +++++++---
 xen/common/hypfs.c           | 38 +++++++++++++++++++++++
 xen/common/kernel.c          | 23 +++++++++++++-
 xen/drivers/char/console.c   | 49 +++++++++++++++++++++++++----
 xen/include/xen/hypfs.h      |  4 +++
 xen/include/xen/param.h      | 74 +++++++++++++++++++++++++++++++++++++++-----
 11 files changed, 226 insertions(+), 22 deletions(-)
docs/misc/hypfs-paths.pandoc +9 -0
index e8ae52ea45..1554039e46 100644
@@ -142,3 +142,12 @@ The major version of Xen.
 #### /buildinfo/version/minor = INTEGER
 
 The minor version of Xen.
+
+#### /params/
+
+A directory of runtime parameters.
+
+#### /params/*
+
+The single parameters. The description of the different parameters can be
+found in `docs/misc/xen-command-line.pandoc`.
xen/arch/arm/xen.lds.S +5 -0
index a497f6a48d..0061a8dfea 100644
@@ -89,6 +89,11 @@ SECTIONS
        __start_schedulers_array = .;
        *(.data.schedulers)
        __end_schedulers_array = .;
+
+       . = ALIGN(8);
+       __paramhypfs_start = .;
+       *(.data.paramhypfs)
+       __paramhypfs_end = .;
        *(.data.rel)
        *(.data.rel.*)
        CONSTRUCTORS
xen/arch/x86/hvm/vmx/vmcs.c +16 -1
index 65445afeb0..36ddccfb73 100644
@@ -70,6 +70,17 @@ integer_param("ple_window", ple_window);
 static bool __read_mostly opt_ept_pml = true;
 static s8 __read_mostly opt_ept_ad = -1;
 int8_t __read_mostly opt_ept_exec_sp = -1;
+static char opt_ept_setting[16] = "pml=1";
+
+
+static void update_ept_param(void)
+{
+    snprintf(opt_ept_setting, sizeof(opt_ept_setting), "pml=%d", opt_ept_pml);
+    if ( opt_ept_ad >= 0 )
+        param_append_str(opt_ept_setting, ",ad=%d", opt_ept_ad);
+    if ( opt_ept_exec_sp >= 0 )
+        param_append_str(opt_ept_setting, ",exec-sp=%d", opt_ept_exec_sp);
+}
 
 static int __init parse_ept_param(const char *s)
 {
@@ -93,6 +104,8 @@ static int __init parse_ept_param(const char *s)
         s = ss + 1;
     } while ( *ss );
 
+    update_ept_param();
+
     return rc;
 }
 custom_param("ept", parse_ept_param);
@@ -115,6 +128,8 @@ static int parse_ept_param_runtime(const char *s)
 
     opt_ept_exec_sp = val;
 
+    update_ept_param();
+
     rcu_read_lock(&domlist_read_lock);
     for_each_domain ( d )
     {
@@ -144,7 +159,7 @@ static int parse_ept_param_runtime(const char *s)
 
     return 0;
 }
-custom_runtime_only_param("ept", parse_ept_param_runtime);
+custom_runtime_only_param("ept", parse_ept_param_runtime, opt_ept_setting);
 
 /* Dynamic (run-time adjusted) execution control flags. */
 u32 vmx_pin_based_exec_control __read_mostly;
xen/arch/x86/pv/domain.c +6 -1
index c3473b9a47..9e0d24ce81 100644
@@ -22,6 +22,7 @@ static __read_mostly enum {
     PCID_XPTI,
     PCID_NOXPTI
 } opt_pcid = PCID_XPTI;
+static char opt_pcid_val[7] = "xpti";
 
 static int parse_pcid(const char *s)
 {
@@ -31,10 +32,12 @@ static int parse_pcid(const char *s)
     {
     case 0:
         opt_pcid = PCID_OFF;
+        snprintf(opt_pcid_val, sizeof(opt_pcid_val), "off");
         break;
 
     case 1:
         opt_pcid = PCID_ALL;
+        snprintf(opt_pcid_val, sizeof(opt_pcid_val), "on");
         break;
 
     default:
@@ -42,10 +45,12 @@ static int parse_pcid(const char *s)
         {
         case 0:
             opt_pcid = PCID_NOXPTI;
+            snprintf(opt_pcid_val, sizeof(opt_pcid_val), "noxpti");
             break;
 
         case 1:
             opt_pcid = PCID_XPTI;
+            snprintf(opt_pcid_val, sizeof(opt_pcid_val), "xpti");
             break;
 
         default:
@@ -57,7 +62,7 @@ static int parse_pcid(const char *s)
 
     return rc;
 }
-custom_runtime_param("pcid", parse_pcid);
+custom_runtime_param("pcid", parse_pcid, opt_pcid_val);
 
 static void noreturn continue_nonidle_domain(struct vcpu *v)
 {
xen/arch/x86/xen.lds.S +5 -0
index 29ef507432..9b717602db 100644
@@ -280,6 +280,11 @@ SECTIONS
        __start_schedulers_array = .;
        *(.data.schedulers)
        __end_schedulers_array = .;
+
+       . = ALIGN(8);
+       __paramhypfs_start = .;
+       *(.data.paramhypfs)
+       __paramhypfs_end = .;
   } :text
 
   DECL_SECTION(.data) {
xen/common/grant_table.c +12 -5
index 2ecf38dfbe..2de2c7e373 100644
@@ -85,8 +85,10 @@ struct grant_table {
     struct grant_table_arch arch;
 };
 
+#define PAR_VAL_SZ 12
+
 static int parse_gnttab_limit(const char *param, const char *arg,
-                              unsigned int *valp)
+                              unsigned int *valp, char *par_val)
 {
     const char *e;
     unsigned long val;
@@ -99,28 +101,33 @@ static int parse_gnttab_limit(const char *param, const char *arg,
         return -ERANGE;
 
     *valp = val;
+    snprintf(par_val, PAR_VAL_SZ, "%lu", val);
 
     return 0;
 }
 
 unsigned int __read_mostly opt_max_grant_frames = 64;
+static char gnttab_max_frames_val[PAR_VAL_SZ] = "64";
 
 static int parse_gnttab_max_frames(const char *arg)
 {
     return parse_gnttab_limit("gnttab_max_frames", arg,
-                              &opt_max_grant_frames);
+                              &opt_max_grant_frames, gnttab_max_frames_val);
 }
-custom_runtime_param("gnttab_max_frames", parse_gnttab_max_frames);
+custom_runtime_param("gnttab_max_frames", parse_gnttab_max_frames,
+                     gnttab_max_frames_val);
 
 static unsigned int __read_mostly opt_max_maptrack_frames = 1024;
+static char max_maptrack_frames_val[PAR_VAL_SZ] = "1024";
 
 static int parse_gnttab_max_maptrack_frames(const char *arg)
 {
     return parse_gnttab_limit("gnttab_max_maptrack_frames", arg,
-                              &opt_max_maptrack_frames);
+                              &opt_max_maptrack_frames,
+                              max_maptrack_frames_val);
 }
 custom_runtime_param("gnttab_max_maptrack_frames",
-                     parse_gnttab_max_maptrack_frames);
+                     parse_gnttab_max_maptrack_frames, max_maptrack_frames_val);
 
 #ifndef GNTTAB_MAX_VERSION
 #define GNTTAB_MAX_VERSION 2
xen/common/hypfs.c +38 -0
index 6762d20dfd..667636d63e 100644
@@ -10,6 +10,7 @@
 #include <xen/guest_access.h>
 #include <xen/hypercall.h>
 #include <xen/hypfs.h>
+#include <xen/param.h>
 #include <xen/rwlock.h>
 #include <public/hypfs.h>
 
@@ -296,6 +297,33 @@ int hypfs_write_bool(struct hypfs_entry_leaf *leaf,
     return 0;
 }
 
+int hypfs_write_custom(struct hypfs_entry_leaf *leaf,
+                       XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen)
+{
+    struct param_hypfs *p;
+    char *buf;
+    int ret;
+
+    buf = xzalloc_array(char, ulen);
+    if ( !buf )
+        return -ENOMEM;
+
+    ret = -EFAULT;
+    if ( copy_from_guest(buf, uaddr, ulen) )
+        goto out;
+
+    ret = -EDOM;
+    if ( buf[ulen - 1] )
+        goto out;
+
+    p = container_of(leaf, struct param_hypfs, hypfs);
+    ret = p->param->par.func(buf);
+
+ out:
+    xfree(buf);
+    return ret;
+}
+
 static int hypfs_write(struct hypfs_entry *entry,
                        XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen)
 {
@@ -363,3 +391,13 @@ long do_hypfs_op(unsigned int cmd,
 
     return ret;
 }
+
+void hypfs_write_lock(void)
+{
+    write_lock(&hypfs_lock);
+}
+
+void hypfs_write_unlock(void)
+{
+    write_unlock(&hypfs_lock);
+}
xen/common/kernel.c +22 -1
index b5ee3011f5..e9a501e0e1 100644
@@ -198,7 +198,13 @@ static void __init _cmdline_parse(const char *cmdline)
 
 int runtime_parse(const char *line)
 {
-    return parse_params(line, __param_start, __param_end);
+    int ret;
+
+    hypfs_write_lock();
+    ret = parse_params(line, __param_start, __param_end);
+    hypfs_write_unlock();
+
+    return ret;
 }
 
 /**
@@ -428,6 +434,21 @@ static int __init buildinfo_init(void)
 }
 __initcall(buildinfo_init);
 
+static HYPFS_DIR_INIT(params, "params");
+
+static int __init param_init(void)
+{
+    struct param_hypfs *param;
+
+    hypfs_add_dir(&hypfs_root, &params, true);
+
+    for ( param = __paramhypfs_start; param < __paramhypfs_end; param++ )
+        hypfs_add_leaf(&params, &param->hypfs, true);
+
+    return 0;
+}
+__initcall(param_init);
+
 # define DO(fn) long do_##fn
 
 #endif
xen/drivers/char/console.c +43 -6

136 lines not on this page · raw message

xen/include/xen/hypfs.h +4 -0
index a1c2140398..d1ea095dc1 100644
@@ -85,5 +85,9 @@ int hypfs_write_leaf(struct hypfs_entry_leaf *leaf,
                      XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen);
 int hypfs_write_bool(struct hypfs_entry_leaf *leaf,
                      XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen);
+int hypfs_write_custom(struct hypfs_entry_leaf *leaf,
+                       XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long ulen);
+void hypfs_write_lock(void);
+void hypfs_write_unlock(void);
 
 #endif /* __XEN_HYPFS_H__ */
xen/include/xen/param.h +66 -8

126 lines not on this page · raw message

Signature · 7 lines
2.16.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#40 lore raw
In reply to Juergen Gross
Quoted 4 lines · Juergen Gross

On the 2019 Xen developer summit there was agreement that the Xen hypervisor should gain support for a hierarchical name-value store similar to the Linux kernel's sysfs.

Is there a short summary of the most recent use cases for this feature and expected interactions with other Xen features (e.g. Panopticon Xen, security controls on information that is visible to guests, e.g. recent discussion on version number hiding). This would impact many subsystems.

Presumably Kconfig could enable/disable this optional feature and all dependencies, and the Xen toolstack would continue to function normally in its absence.

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

#41 lore raw
Quoted 7 lines · Rich Persaud
Quoted 4 lines · Juergen Gross

On the 2019 Xen developer summit there was agreement that the Xen hypervisor should gain support for a hierarchical name-value store similar to the Linux kernel's sysfs.

Is there a short summary of the most recent use cases for this feature and expected interactions with other Xen features (e.g. Panopticon Xen, security controls on information that is visible to guests, e.g. recent discussion on version number hiding). This would impact many subsystems.

In the first run access is permitted to dom0 only. Access to other guests needs to be discussed.

Current use cases are just the buildinfo leafs including the .config of the hypervisor, plus reading and writing runtime parameters.

I'd like to add per-cpupool parameters (like SMT per cpupool, scheduling granularity) and maybe per-domain ones (e.g. mitigation settings). Another area to cover would be debugging interfaces like lock profiling, performance counters, ...

Quoted 1 line

Presumably Kconfig could enable/disable this optional feature and all dependencies, and the Xen toolstack would continue to function normally in its absence.

I'd rather go the other way round: have a detailed look which current privileged interfaces (domctl, sysctl) can be replaced by the file system and switch over to it with (where necessary) fine grained access control. I think this is something to discuss at the next Xen summit in summer (I have already registered a session for that purpose).

Juergen

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