Add hypervisor sysfs-like support
v4 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 V4:
- former patch 2 removed as already committed
- addressed review comments
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 (8):
xen: add a generic way to include binary files as variables
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 | 92 +++++++ docs/man/xenhypfs.1.pod | 61 +++++ docs/misc/hypfs-paths.pandoc | 163 +++++++++++ tools/Rules.mk | 6 + tools/libs/Makefile | 1 + tools/libs/hypfs/Makefile | 16 ++ tools/libs/hypfs/core.c | 533 ++++++++++++++++++++++++++++++++++++ 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/traps.c | 1 + xen/arch/arm/xen.lds.S | 5 + xen/arch/x86/hvm/hypercall.c | 1 + xen/arch/x86/hvm/vmx/vmcs.c | 17 +- xen/arch/x86/hypercall.c | 1 + xen/arch/x86/pv/domain.c | 7 +- xen/arch/x86/pv/hypercall.c | 1 + xen/arch/x86/xen.lds.S | 5 + xen/common/Makefile | 13 + xen/common/grant_table.c | 17 +- xen/common/hypfs.c | 396 +++++++++++++++++++++++++++ xen/common/kernel.c | 78 +++++- xen/drivers/char/console.c | 49 +++- xen/include/public/hypfs.h | 127 +++++++++ xen/include/public/xen.h | 1 + xen/include/xen/hypercall.h | 8 + xen/include/xen/hypfs.h | 112 ++++++++ xen/include/xen/kernel.h | 3 + xen/include/xen/param.h | 74 ++++- xen/include/xlat.lst | 2 + xen/tools/binfile | 41 +++ xen/xsm/flask/Makefile | 5 +- xen/xsm/flask/flask-policy.S | 16 -- 36 files changed, 2109 insertions(+), 39 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 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
PATCH v4 1/8 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
V4:
- add alignment parameter (Jan Beulich)
- use .Lend instead of . (Jan Beulich)
--- .gitignore | 1 + xen/tools/binfile | 41 +++++++++++++++++++++++++++++++++++++++++ xen/xsm/flask/Makefile | 5 ++++- xen/xsm/flask/flask-policy.S | 16 ---------------- 4 files changed, 46 insertions(+), 17 deletions(-) create mode 100755 xen/tools/binfile delete mode 100644 xen/xsm/flask/flask-policy.S
.gitignore +1 -0
@@ -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 +41 -0
41 lines not on this page · raw message
xen/xsm/flask/Makefile +4 -1
@@ -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
@@ -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
Re: [Xen-devel] [PATCH v4 1/8] xen: add a generic way to include binary files as variables
Quoted 6 lines · Juergen Gross
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.
Signed-off-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v4 2/8 docs: add feature document for Xen hypervisor sysfs-like support
In reply to Juergen GrossOn 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)
V4:
- add list specification
- add entry example (Julien Grall)
- correct date and Xen version (Julien Grall)
- add ARM64 as possible architecture (Julien Grall)
- add version description to the feature doc (Jan Beulich)
--- docs/features/hypervisorfs.pandoc | 92 +++++++++++++++++++++++++++++++++ docs/misc/hypfs-paths.pandoc | 105 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+) create mode 100644 docs/features/hypervisorfs.pandoc create mode 100644 docs/misc/hypfs-paths.pandoc
docs/features/hypervisorfs.pandoc new file +92 -0
@@ -0,0 +1,92 @@ +% 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. This hypercall supports a sub-command +XEN_HYPFS_OP_get_version which will return the highest version of the +interface supported by the hypervisor. Additions to the interface need +to bump the interface version. The hypervisor is required to support the +previous interface versions, too (this implies that additions will always +require new sub-commands in order to allow the hypervisor to decide which +version of the interface to use). + +* hypercall interface specification + * `xen/include/public/hypfs.h` +* hypervisor internal files + * `xen/include/xen/hypfs.h` + * `xen/common/hypfs.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 +---------- -------- -------- ------------------------------------------- +2020-01-23 1 Xen 4.14 Document written +---------- -------- -------- -------------------------------------------
docs/misc/hypfs-paths.pandoc new file +105 -0
105 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
PATCH v4 3/8 xen: add basic hypervisor filesystem support
In reply to Juergen GrossAdd the infrastructure for the hypervisor filesystem.
This includes the hypercall interface and the base functions for entry creation, deletion and modification.
In order not to have to repeat the same pattern multiple times in case adding a new node should BUG_ON() failure, the helpers for adding a node (hypfs_add_dir() and hypfs_add_leaf()) get a nofault parameter causing the BUG() in case of a failure.
When supporting writable leafs the entry's write pointer will need to be set to the function performing the write to the variable holding the content. In case there are no special constraints this will be hypfs_write_bool() for type XEN_HYPFS_TYPE_BOOL and hypfs_write_leaf() for the other entry types.
---
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
V4:
- sort #includes alphabetically (Wei Liu)
- add public interface structures to xlat.lst (Jan Beulich)
- let DIRENTRY_SIZE() add 1 for trailing nul byte (Jan Beulich)
- remove hypfs_add_entry() (Jan Beulich)
- len -> ulen (Jan Beulich)
- switch sequence of tests in hypfs_get_entry_rel() (Jan Beulich)
- add const qualifier (Jan Beulich)
- return -ENOBUFS if only direntry but no entry contents are returned (Jan Beulich)
- use xmalloc() instead of xzalloc() (Jan Beulich)
- better error handling in hypfs_write_leaf() (Jan Beulich)
- return -EOPNOTSUPP for unknown sub-command (Jan Beulich)
- use plain integers for enum-like constants in public interface (Jan Beulich)
- rename XEN_HYPFS_OP_read_contents to XEN_HYPFS_OP_read (Jan Beulich)
- add some comments in include/public/hypfs.h (Jan Beulich)
- use const_char for user parameter path (Jan Beulich)
- add helpers for XEN_HYPFS_TYPE_BOOL and XEN_HYPFS_TYPE_INT entry definitions (Jan Beulich)
- make statically defined entries __read_mostly (Jan Beulich)
--- 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 | 358 +++++++++++++++++++++++++++++++++++++++++++ xen/include/public/hypfs.h | 127 +++++++++++++++ xen/include/public/xen.h | 1 + xen/include/xen/hypercall.h | 8 + xen/include/xen/hypfs.h | 108 +++++++++++++ xen/include/xlat.lst | 2 + 11 files changed, 609 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -10,6 +10,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 +358 -0
358 lines not on this page · raw message
xen/include/public/hypfs.h new file +127 -0
127 lines not on this page · raw message
xen/include/public/xen.h +1 -0
@@ -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
@@ -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 (const_char) 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 +108 -0
108 lines not on this page · raw message
xen/include/xlat.lst +2 -0
@@ -86,6 +86,8 @@ ? vcpu_hvm_context hvm/hvm_vcpu.h ? vcpu_hvm_x86_32 hvm/hvm_vcpu.h ? vcpu_hvm_x86_64 hvm/hvm_vcpu.h +? xen_hypfs_direntry hypfs.h +? xen_hypfs_dirlistentry hypfs.h ? kexec_exec kexec.h ! kexec_image kexec.h ! kexec_range kexec.h
Signature · 7 lines
2.16.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v4 4/8 libs: add libxenhypfs
In reply to Juergen GrossAdd 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
V4:
- add dependency to libz in pkgconfig file (Wei Liu)
--- .gitignore | 2 + tools/Rules.mk | 6 + tools/libs/Makefile | 1 + tools/libs/hypfs/Makefile | 16 ++ tools/libs/hypfs/core.c | 533 ++++++++++++++++++++++++++++++++++++ tools/libs/hypfs/include/xenhypfs.h | 75 +++++ tools/libs/hypfs/libxenhypfs.map | 10 + tools/libs/hypfs/xenhypfs.pc.in | 10 + 8 files changed, 653 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
@@ -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
@@ -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
@@ -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
@@ -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 +533 -0
533 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
@@ -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
@@ -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,z
Signature · 7 lines
2.16.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v4 4/8] libs: add libxenhypfs
Quoted 3 lines · Juergen Gross
Add the new library libxenhypfs for access to the hypervisor filesystem.
Signed-off-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v4 5/8 tools: add xenfs tool
In reply to Juergen GrossAdd 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
@@ -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
@@ -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
PATCH v4 6/8 xen: provide version information in hypfs
In reply to Juergen GrossProvide 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
V4:
- add __read_mostly annotations (Jan Beulich)
--- docs/misc/hypfs-paths.pandoc | 45 ++++++++++++++++++++++++++++++++++++++++++++ xen/common/kernel.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+)
docs/misc/hypfs-paths.pandoc +45 -0
@@ -103,3 +103,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
PATCH v4 7/8 xen: add /buildinfo/config entry to hypervisor filesystem
In reply to Juergen GrossAdd 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
@@ -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
@@ -133,6 +133,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
@@ -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-$(CONFIG_DEBUG_TRACE) += debugtrace.o
@@ -73,3 +74,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
@@ -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
@@ -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
PATCH v4 8/8 xen: add runtime parameter access support to hypfs
In reply to Juergen GrossAdd 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
@@ -152,3 +152,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
@@ -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
@@ -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
@@ -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 noreturncontinue_nonidle_domain (struct vcpu *v) {
xen/arch/x86/xen.lds.S +5 -0
@@ -279,6 +279,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
@@ -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
@@ -10,6 +10,7 @@#include <xen/hypercall.h> #include <xen/hypfs.h> #include <xen/lib.h> +#include <xen/param.h> #include <xen/rwlock.h> #include <public/hypfs.h>
@@ -289,6 +290,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) {
@@ -356,3 +384,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
@@ -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, ¶ms, true); + +for ( param = __paramhypfs_start; param < __paramhypfs_end; param++ ) +hypfs_add_leaf (¶ms, ¶m->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
@@ -104,5 +104,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