Add hypervisor sysfs-like support
v5 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 V5:
- switched to xsm for privilege check
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/flask/policy/modules/dom0.te | 2 +- 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 | 395 ++++++++++++++++++++++++++ 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/include/xsm/dummy.h | 6 + xen/include/xsm/xsm.h | 6 + xen/tools/binfile | 41 +++ xen/xsm/flask/Makefile | 5 +- xen/xsm/flask/flask-policy.S | 16 -- xen/xsm/flask/policy/access_vectors | 2 + 40 files changed, 2123 insertions(+), 40 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 v5 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 v5 1/8] xen: add a generic way to include binary files as variables
Quoted 7 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]>Reviewed-by Jan Beulich <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v5 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 v5 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)
V5:
- switch to xsm for privilege check
--- tools/flask/policy/modules/dom0.te | 2 +- 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 | 357 ++++++++++++++++++++++++++++++++++++ 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 + xen/include/xsm/dummy.h | 6 + xen/include/xsm/xsm.h | 6 + xen/xsm/flask/policy/access_vectors | 2 + 15 files changed, 623 insertions(+), 1 deletion(-) create mode 100644 xen/common/hypfs.c create mode 100644 xen/include/public/hypfs.h create mode 100644 xen/include/xen/hypfs.h
tools/flask/policy/modules/dom0.te +1 -1
@@ -11,7 +11,7 @@ allow dom0_t xen_t:xen { mtrr_del mtrr_read microcode physinfo quirk writeconsole readapic writeapic privprofile nonprivprofile kexec firmware sleep frequency getidle debug getcpuinfo heap pm_op mca_op lockprof cpupool_op - getscheduler setscheduler + getscheduler setscheduler hypfs_op }; allow dom0_t xen_t:xen2 { resource_op psr_cmt_op psr_alloc pmu_ctrl get_symbol
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 +357 -0
357 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
xen/include/xsm/dummy.h +6 -0
@@ -433,6 +433,12 @@ static XSM_INLINE int xsm_page_offline(XSM_DEFAULT_ARG uint32_t cmd)return xsm_default_action (action, current->domain,NULL ); } +static XSM_INLINE int xsm_hypfs_op(XSM_DEFAULT_VOID) +{ +XSM_ASSERT_ACTION (XSM_PRIV ); +return xsm_default_action (action, current->domain,NULL ); +} +static XSM_INLINE long xsm_do_xsm_op (XEN_GUEST_HANDLE_PARAM (xsm_op_t) op) {return -ENOSYS ;
xen/include/xsm/xsm.h +6 -0
@@ -127,6 +127,7 @@ struct xsm_operations {int (*resource_setup_misc) (void );int (*page_offline)(uint32_t cmd); +int (*hypfs_op)(void );long (*do_xsm_op) (XEN_GUEST_HANDLE_PARAM (xsm_op_t) op);#ifdef CONFIG_COMPAT
@@ -536,6 +537,11 @@ static inline int xsm_page_offline(xsm_default_t def, uint32_t cmd)return xsm_ops->page_offline (cmd); } +static inline int xsm_hypfs_op (xsm_default_t def) +{ +return xsm_ops->hypfs_op (); +} +static inline long xsm_do_xsm_op (XEN_GUEST_HANDLE_PARAM (xsm_op_t) op) {return xsm_ops->do_xsm_op (op);
xen/xsm/flask/policy/access_vectors +2 -0
@@ -67,6 +67,8 @@ class xen lockprof # XEN_SYSCTL_cpupool_op cpupool_op +# hypfs hypercall + hypfs_op # XEN_SYSCTL_scheduler_op with XEN_DOMCTL_SCHEDOP_getinfo, XEN_SYSCTL_sched_id, XEN_DOMCTL_SCHEDOP_getvcpuinfo getscheduler # XEN_SYSCTL_scheduler_op with XEN_DOMCTL_SCHEDOP_putinfo, XEN_DOMCTL_SCHEDOP_putvcpuinfo
Signature · 7 lines
2.16.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v5 3/8] xen: add basic hypervisor filesystem support
xen/common/hypfs.c line 103
Quoted 12 lines · Juergen Gross
xen/common/hypfs.c new file +12
-0+static int hypfs_get_path_user (char *buf, +XEN_GUEST_HANDLE_PARAM (const_char) uaddr, +unsigned long ulen) +{ +if ( ulen >XEN_HYPFS_MAX_PATHLEN ) +return -EINVAL ; + +if (copy_from_guest (buf, uaddr, ulen) ) +return -EFAULT ; + +if ( buf[ulen -1 ] ) +return -EINVAL ;
I (still, but I may not have said so before) wonder whether memchr(buf, 0, ulen) != buf + ulen - 1 wouldn't be better here.
xen/common/hypfs.c line 232
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 ) +return -ENOSPC ;
Okay, this makes sure you don't overrun the internal buffer. What about the opposite mismatch (ulen < leaf->e.size)? The result, except perhaps for (nul-terminated) strings, is not going to be very useful, at the very least.
xen/common/hypfs.c line 243
Quoted 10 lines
xen/common/hypfs.c new file +10
-0+ buf =xmalloc_array (char, ulen); +if ( !buf ) +return -ENOMEM ; + + ret = -EFAULT ; +if (copy_from_guest (buf, uaddr, ulen) ) + goto out; + + ret = -EINVAL ; +if ( leaf->e.type ==XEN_HYPFS_TYPE_STRING && buf[ulen] )
buf[ulen - 1] I guess? Or, as above, memchr() again?
Quoted 24 lines
xen/common/hypfs.c new file +24
-0+int hypfs_write_bool (struct hypfs_entry_leaf *leaf, +XEN_GUEST_HANDLE_PARAM (void ) uaddr,unsigned long ulen) +{ +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 ; + +if (copy_from_guest (u.buf, uaddr, ulen) ) +return -EFAULT ; + +switch ( leaf->e.size ) + { +case 1 : + *(uint8_t *)leaf->write_ptr = !!u.u8; +break ;
xen/common/hypfs.c line 287
Quoted 10 lines
xen/common/hypfs.c new file +10
-0+case 2 : + *(uint16_t *)leaf->write_ptr = !!u.u16; +break ; +case 4 : + *(uint32_t *)leaf->write_ptr = !!u.u32; +break ; +case 8 : + *(uint64_t *)leaf->write_ptr = !!u.u64; +break ; + }
Looking at this again, is there really a need for uint64_t support here? I.e. can't you cap at unsigned long (or even unsigned int), and perhaps additionally avoid use of fixed width types here altogether (some trickery may be needed for 32-bit's sizeof(long) == sizeof(int))?
Quoted 32 lines
xen/include/public/hypfs.h new file +29
-0@@ -0,0 +1,127 @@ +/****************************************************************************** +* 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"
xen/include/public/hypfs.h line 39
Quoted 10 lines
xen/include/public/hypfs.h new file +10
-0+ +/* +* Definitions for the __HYPERVISOR_hypfs_op hypercall. +*/ + +/* Highest version number of the hypfs interface currently defined. */ +#define XEN_HYPFS_VERSION 1 + +/* Maximum length of a path in the filesystem. */ +#define XEN_HYPFS_MAX_PATHLEN 1024
I think it would be nice if the blank padding here matched that of the other #define-s up and down from here.
Quoted 11 lines
xen/include/public/hypfs.h new file +11
-0+/* +* 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/include/public/hypfs.h line 89
Quoted 10 lines
xen/include/public/hypfs.h new file +10
-0+/* +* XEN_HYPFS_OP_read +* +* Read 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
Looks like the "to have success" is stale now?
xen/include/public/hypfs.h line 102
Quoted 13 lines
xen/include/public/hypfs.h new file +13
-0+* -ENOBUFS and 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. +* The contents of a directory are multiple struct xen_hypfs_dirlistentry +* items. +* +* 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)
As is this?
xen/include/public/hypfs.h line 79
Quoted 6 lines
xen/include/public/hypfs.h new file +6
-0+static inline void hypfs_string_set (struct hypfs_entry_leaf *leaf, +const char *str) +{ + leaf->content = str; + leaf->e.size =strlen (str) +1 ; +}
This looks at least risky to me, as the function name does in no way indicate that no copy of the string will be made. Hence its use with e.g. .init.rodata contents or a stack variable will not produce the intended result.
Quoted 19 lines
xen/include/public/hypfs.h new file +19
-0+#define HYPFS_UINT_INIT (var, nam, contvar) \ + struct hypfs_entry_leaf __read_mostly var = { \ + .e.type = XEN_HYPFS_TYPE_UINT, \ + .e.encoding = XEN_HYPFS_ENC_PLAIN, \ + .e.name = nam, \ + .e.size = sizeof(contvar), \ + .e.read = hypfs_read_leaf, \ + .content = &contvar, \ + } + +#define HYPFS_INT_INIT (var, nam, contvar) \ + struct hypfs_entry_leaf __read_mostly var = { \ + .e.type = XEN_HYPFS_TYPE_INT, \ + .e.encoding = XEN_HYPFS_ENC_PLAIN, \ + .e.name = nam, \ + .e.size = sizeof(contvar), \ + .e.read = hypfs_read_leaf, \ + .content = &contvar, \ + }
xen/include/public/hypfs.h line 108
Quoted 10 lines
xen/include/public/hypfs.h new file +10
-0+ +#define HYPFS_BOOL_INIT (var, nam, contvar) \ + struct hypfs_entry_leaf __read_mostly var = { \ + .e.type = XEN_HYPFS_TYPE_BOOL, \ + .e.encoding = XEN_HYPFS_ENC_PLAIN, \ + .e.name = nam, \ + .e.size = sizeof(contvar), \ + .e.read = hypfs_read_leaf, \ + .content = &contvar, \ + }
Quite a lot of redundancy for just a single line of difference between the instance. Perhaps have another helper macro?
xen/include/xlat.lst line 90
Quoted 8 lines
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
Where are the checking macros used that these produce?
xen/xsm/flask/policy/access_vectors class xen · line 74
Quoted 11 lines
xen/xsm/flask/policy/access_vectors +2
-0@@ -67,6 +67,8 @@ class xen lockprof # XEN_SYSCTL_cpupool_op cpupool_op +# hypfs hypercall + hypfs_op # XEN_SYSCTL_scheduler_op with XEN_DOMCTL_SCHEDOP_getinfo, XEN_SYSCTL_sched_id, XEN_DOMCTL_SCHEDOP_getvcpuinfo getscheduler # XEN_SYSCTL_scheduler_op with XEN_DOMCTL_SCHEDOP_putinfo, XEN_DOMCTL_SCHEDOP_putvcpuinfo
I may not know enough about XSM to see why you can get away without also modifying flask/hooks.c.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v5 3/8] xen: add basic hypervisor filesystem support
Hi,
Quoted 33 lines · Jan Beulich
Quoted 32 lines · Juergen Gross
xen/common/hypfs.c new file +32
-0+int hypfs_write_bool (struct hypfs_entry_leaf *leaf, +XEN_GUEST_HANDLE_PARAM (void ) uaddr,unsigned long ulen) +{ +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 ; + +if (copy_from_guest (u.buf, uaddr, ulen) ) +return -EFAULT ; + +switch ( leaf->e.size ) + { +case 1 : + *(uint8_t *)leaf->write_ptr = !!u.u8; +break ; +case 2 : + *(uint16_t *)leaf->write_ptr = !!u.u16; +break ; +case 4 : + *(uint32_t *)leaf->write_ptr = !!u.u32; +break ; +case 8 : + *(uint64_t *)leaf->write_ptr = !!u.u64;
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ break; + }Looking at this again, is there really a need for
uint64_tsupport here? I.e. can't you cap at unsigned long (or even unsigned int), and perhaps additionally avoid use of fixed width types here altogether (some trickery may be needed for 32-bit's sizeof(long) == sizeof(int))?
On Arm, we want to have the interface exactly the same for 64-bit and 32-bit. If you plan to not support 8-byte here, this would effectively mean that 8-byte could not be used on Arm.
However, I can't find any use of hypfs_write_bool, so I am not entirely sure why we would want to cater size other than 1. Juerge, do you mind expanding your thoughts?
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v5 3/8] xen: add basic hypervisor filesystem support
In reply to Jan BeulichQuoted 16 lines · Jan Beulich
xen/common/hypfs.c line 103
Quoted 12 lines · Juergen Gross
xen/common/hypfs.c new file +12
-0+static int hypfs_get_path_user (char *buf, +XEN_GUEST_HANDLE_PARAM (const_char) uaddr, +unsigned long ulen) +{ +if ( ulen >XEN_HYPFS_MAX_PATHLEN ) +return -EINVAL ; + +if (copy_from_guest (buf, uaddr, ulen) ) +return -EFAULT ; + +if ( buf[ulen -1 ] ) +return -EINVAL ;I (still, but I may not have said so before) wonder whether
memchr(buf, 0, ulen)!= buf + ulen - 1 wouldn't be better here.
I like the idea.
Quoted 14 lines
xen/common/hypfs.c line 232
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 ) +return -ENOSPC ;Okay, this makes sure you don't overrun the internal buffer. What about the opposite mismatch (ulen <
leaf->e.size)? The result, except perhaps for (nul-terminated) strings, is not going to be very useful, at the very least.
Yes, will tighten the test.
Quoted 13 lines
xen/common/hypfs.c line 243
Quoted 11 lines
xen/common/hypfs.c new file +10
-0+ buf =xmalloc_array (char, ulen); +if ( !buf ) +return -ENOMEM ; + + ret = -EFAULT ; +if (copy_from_guest (buf, uaddr, ulen) ) + goto out; + + ret = -EINVAL ; +if ( leaf->e.type ==XEN_HYPFS_TYPE_STRING && buf[ulen] )buf[ulen - 1] I guess? Or, as above,
memchr()again?
I'll go the memchr() way.
Quoted 33 lines
Quoted 33 lines
xen/common/hypfs.c new file +32
-0+int hypfs_write_bool (struct hypfs_entry_leaf *leaf, +XEN_GUEST_HANDLE_PARAM (void ) uaddr,unsigned long ulen) +{ +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 ; + +if (copy_from_guest (u.buf, uaddr, ulen) ) +return -EFAULT ; + +switch ( leaf->e.size ) + { +case 1 : + *(uint8_t *)leaf->write_ptr = !!u.u8; +break ; +case 2 : + *(uint16_t *)leaf->write_ptr = !!u.u16; +break ; +case 4 : + *(uint32_t *)leaf->write_ptr = !!u.u32; +break ; +case 8 : + *(uint64_t *)leaf->write_ptr = !!u.u64;
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ break; + }Looking at this again, is there really a need for
uint64_tsupport here? I.e. can't you cap at unsigned long (or even unsigned int), and perhaps additionally avoid use of fixed width types here altogether (some trickery may be needed for 32-bit's sizeof(long) == sizeof(int))?
The reason for different lengths for bool is that boolean_param() is falling back to the general integer param handling with all the natural integer sizes.
I think I'll modify the macros in param.h to accept only sizeof(bool) variables for boolean parameters and then I can switch to this fixed size here.
Quoted 38 lines
Quoted 38 lines
xen/include/public/hypfs.h new file +34
-0@@ -0,0 +1,127 @@ +/****************************************************************************** +* 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 39
Quoted 5 lines
xen/include/public/hypfs.h new file +5
-0+/* Highest version number of the hypfs interface currently defined. */ +#define XEN_HYPFS_VERSION 1 + +/* Maximum length of a path in the filesystem. */ +#define XEN_HYPFS_MAX_PATHLEN 1024I think it would be nice if the blank padding here matched that of the other #define-s up and down from here.
Okay.
Quoted 16 lines
Quoted 16 lines
xen/include/public/hypfs.h new file +15
-0+/* +* 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 +* +* Read a filesystem entry.
Quoted 8 lines
xen/include/public/hypfs.h line 89
Quoted 6 lines
xen/include/public/hypfs.h new file +6
-0+* +* 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 Looks like the "to have success" is stale now?
Yes.
Quoted 15 lines
Quoted 4 lines
xen/include/public/hypfs.h new file +3
-0+* -ENOBUFS and 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. xen/include/public/hypfs.h line 102
Quoted 10 lines
xen/include/public/hypfs.h new file +10
-0+* The contents of a directory are multiple struct xen_hypfs_dirlistentry +* items. +* +* 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)
Quoted 1 line
As is this?
Yes.
Quoted 12 lines
xen/include/public/hypfs.h line 79
Quoted 7 lines
xen/include/public/hypfs.h new file +6
-0+static inline void hypfs_string_set (struct hypfs_entry_leaf *leaf, +const char *str) +{ + leaf->content = str; + leaf->e.size =strlen (str) +1 ; +}This looks at least risky to me, as the function name does in no way indicate that no copy of the string will be made. Hence its use with e.g. .init.rodata contents or a stack variable will not produce the intended result.
Okay, what about naming it hypfs_string_set_reference() ?
Quoted 25 lines
Quoted 25 lines
xen/include/public/hypfs.h new file +24
-0+#define HYPFS_UINT_INIT (var, nam, contvar) \ + struct hypfs_entry_leaf __read_mostly var = { \ + .e.type = XEN_HYPFS_TYPE_UINT, \ + .e.encoding = XEN_HYPFS_ENC_PLAIN, \ + .e.name = nam, \ + .e.size = sizeof(contvar), \ + .e.read = hypfs_read_leaf, \ + .content = &contvar, \ + } + +#define HYPFS_INT_INIT (var, nam, contvar) \ + struct hypfs_entry_leaf __read_mostly var = { \ + .e.type = XEN_HYPFS_TYPE_INT, \ + .e.encoding = XEN_HYPFS_ENC_PLAIN, \ + .e.name = nam, \ + .e.size = sizeof(contvar), \ + .e.read = hypfs_read_leaf, \ + .content = &contvar, \ + } + +#define HYPFS_BOOL_INIT (var, nam, contvar) \ + struct hypfs_entry_leaf __read_mostly var = { \ + .e.type = XEN_HYPFS_TYPE_BOOL, \ + .e.encoding = XEN_HYPFS_ENC_PLAIN, \
Quoted 8 lines
xen/include/public/hypfs.h line 108
Quoted 5 lines
xen/include/public/hypfs.h new file +5
-0+ .e.name = nam, \ + .e.size = sizeof(contvar), \ + .e.read = hypfs_read_leaf, \ + .content = &contvar, \ + }Quite a lot of redundancy for just a single line of difference between the instance. Perhaps have another helper macro?
Fine with me.
Quoted 11 lines
xen/include/xlat.lst line 90
Quoted 9 lines
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.hWhere are the checking macros used that these produce?
Ah, sorry. Will add them.
Quoted 15 lines
xen/xsm/flask/policy/access_vectors class xen · line 74
Quoted 12 lines
xen/xsm/flask/policy/access_vectors +2
-0@@ -67,6 +67,8 @@ class xen lockprof # XEN_SYSCTL_cpupool_op cpupool_op +# hypfs hypercall + hypfs_op # XEN_SYSCTL_scheduler_op with XEN_DOMCTL_SCHEDOP_getinfo, XEN_SYSCTL_sched_id, XEN_DOMCTL_SCHEDOP_getvcpuinfo getscheduler # XEN_SYSCTL_scheduler_op with XEN_DOMCTL_SCHEDOP_putinfo, XEN_DOMCTL_SCHEDOP_putvcpuinfoI may not know enough about XSM to see why you can get away without also modifying
flask/hooks.c.
Hmm, strange, I was sure to have added it.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v5 3/8] xen: add basic hypervisor filesystem support
Quoted 14 lines · Jürgen Groß
Quoted 12 lines · Jan Beulich
xen/include/xen/hypfs.h line 60
Quoted 6 lines · Juergen Gross
xen/include/xen/hypfs.h new file +6
-0+static inline void hypfs_string_set (struct hypfs_entry_leaf *leaf, +const char *str) +{ + leaf->content = str; + leaf->e.size =strlen (str) +1 ; +}This looks at least risky to me, as the function name does in no way indicate that no copy of the string will be made. Hence its use with e.g. .init.rodata contents or a stack variable will not produce the intended result.
Quoted 1 line
Okay, what about naming it
hypfs_string_set_reference()?
Hmm, a little better because of drawing more attention to it due to the longish name. I'd be curious what others think here, in particular towards the alternative of actually allocating space and copying the string. If it is to remain as it is, while the function body is small I still think you also want to attach a comment to call out this behavior.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v5 3/8] xen: add basic hypervisor filesystem support
Quoted 15 lines · Jan Beulich
Quoted 14 lines · Jürgen Groß
Quoted 12 lines · Jan Beulich
xen/include/xen/hypfs.h line 60
Quoted 6 lines · Juergen Gross
xen/include/xen/hypfs.h new file +6
-0+static inline void hypfs_string_set (struct hypfs_entry_leaf *leaf, +const char *str) +{ + leaf->content = str; + leaf->e.size =strlen (str) +1 ; +}This looks at least risky to me, as the function name does in no way indicate that no copy of the string will be made. Hence its use with e.g. .init.rodata contents or a stack variable will not produce the intended result.
Quoted 8 lines
Quoted 1 line
Okay, what about naming it
hypfs_string_set_reference()?Hmm, a little better because of drawing more attention to it due to the longish name. I'd be curious what others think here, in particular towards the alternative of actually allocating space and copying the string. If it is to remain as it is, while the function body is small I still think you also want to attach a comment to call out this behavior.
Okay.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v5 3/8] xen: add basic hypervisor filesystem support
In reply to Juergen Grossxen/common/hypfs.c line 265
Quoted 12 lines · Juergen Gross
xen/common/hypfs.c new file +12
-0+int hypfs_write_bool (struct hypfs_entry_leaf *leaf, +XEN_GUEST_HANDLE_PARAM (void ) uaddr,unsigned long ulen) +{ +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 );
Shouldn't this be XEN_HYPFSW_TYPE_BOOL? But then, why are we allowing a boolean parameter to be held in a 64-bit value?
IHMO, a boolean should really be hold in a bool and nothing else.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v5 3/8] xen: add basic hypervisor filesystem support
Quoted 19 lines · Julien Grall
xen/common/hypfs.c line 265
Quoted 13 lines · Juergen Gross
+int hypfs_write_bool(struct
hypfs_entry_leaf*leaf,
+XEN_GUEST_HANDLE_PARAM(void)uaddr, unsigned long ulen)xen/common/hypfs.c new file +10
-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);Shouldn't this be
XEN_HYPFSW_TYPE_BOOL? But then, why are we allowing a boolean parameter to be held in a 64-bit value?
Quoted 1 line
IHMO, a boolean should really be hold in a bool and nothing else.
After sending my e-mail, I realized the size of the bool is implementation defined. However, I think my point stands, it would be better to have a fixed size for bool (i.e 1) and deny all the other use.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v5 3/8] xen: add basic hypervisor filesystem support
In reply to Julien GrallQuoted 19 lines · Julien Grall
xen/common/hypfs.c line 265
Quoted 13 lines · Juergen Gross
+int hypfs_write_bool(struct
hypfs_entry_leaf*leaf,
+XEN_GUEST_HANDLE_PARAM(void)uaddr, unsigned long ulen)xen/common/hypfs.c new file +10
-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);Shouldn't this be
XEN_HYPFSW_TYPE_BOOL? But then, why are we allowing a boolean parameter to be held in a 64-bit value?
Quoted 1 line
IHMO, a boolean should really be hold in a bool and nothing else.
Yes, as already replied to Jan I'll modify the param handling for bool which allowed larger variables and which was the reason I added this possibility here, too.
And yes, the test should use XEN_HYPFSW_TYPE_BOOL.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v5 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
PATCH v5 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 v5 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 v5 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
Re: [Xen-devel] [PATCH v5 7/8] xen: add /buildinfo/config entry to hypervisor filesystem
xen/common/Makefile line 4
Quoted 7 lines · Juergen Gross
xen/common/Makefile +1
-0@@ -1,6 +1,7 @@ obj-$(CONFIG_ARGO) += argo.o obj-y += bitmap.o obj-y += bsearch.o +obj-y += config_data.o
In particular with embedded uses in mind, I think this wants to have a Kconfig control.
xen/common/Makefile static int __init buildinfo_init(void) · line 424
Quoted 5 lines
xen/common/Makefile +1
-0@@ -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;
This being the only use of xen_config_data_size, it suggests that it could in principle live in .init.rodata. I realize this may mean more customization to the binfile script than is warranted by these 4 bytes of data, but I wanted to at least point out the aspect.
xen/include/xen/kernel.h extern enum system_state { · line 104
Quoted 8 lines
xen/include/xen/kernel.h +2
-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;
const for both?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v5 7/8] xen: add /buildinfo/config entry to hypervisor filesystem
Quoted 11 lines · Jan Beulich
xen/common/Makefile line 4
Quoted 7 lines · Juergen Gross
xen/common/Makefile +1
-0@@ -1,6 +1,7 @@ obj-$(CONFIG_ARGO) += argo.o obj-y += bitmap.o obj-y += bsearch.o +obj-y += config_data.oIn particular with embedded uses in mind, I think this wants to have a
Kconfigcontrol.
Okay.
Quoted 5 lines
Quoted 5 lines
xen/common/Makefile +0
-0@@ -414,6 +421,9 @@ static int __init buildinfo_init(void) hypfs_add_leaf(&version, &major, true); hypfs_add_leaf(&version, &minor, true);
Quoted 7 lines
xen/common/Makefile static int __init buildinfo_init(void) · line 424
Quoted 1 line
xen/common/Makefile +1
-0+ config.e.size = xen_config_data_size;This being the only use of
xen_config_data_size, it suggests that it could in principle live in .init.rodata. I realize this may mean more customization to the binfile script than is warranted by these 4 bytes of data, but I wanted to at least point out the aspect.
In case this pattern is coming up again we might want to enhance the script, but right now I don't think this is needed.
Quoted 11 lines
xen/include/xen/kernel.h extern enum system_state { · line 104
Quoted 9 lines
xen/include/xen/kernel.h +2
-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;const for both?
Yes.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v5 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) {
@@ -355,3 +383,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
Re: [Xen-devel] [PATCH v5 8/8] xen: add runtime parameter access support to hypfs
Quoted 4 lines · Juergen Gross
docs/misc/hypfs-paths.pandoc +0
-0@@ -152,3 +152,12 @@ The major version of Xen. #### /buildinfo/version/minor = INTEGER
docs/misc/hypfs-paths.pandoc The major version of Xen. · line 162
Quoted 10 lines
docs/misc/hypfs-paths.pandoc +8
-0The minor version of Xen. + +#### /params/ + +A directory of runtime parameters. + +#### /params/* + +The single parameters. The description of the different parameters can be
s/single/individual/?
xen/arch/arm/xen.lds.S SECTIONS · line 96
Quoted 11 lines
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 = .;
Do you really need 8-byte alignment even on 32-bit Arm?
xen/arch/x86/hvm/vmx/vmcs.c integer_param("ple_window", ple_window); · line 73
Quoted 7 lines
xen/arch/x86/hvm/vmx/vmcs.c +1
-0@@ -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" ;
This is dangerous imo - such strings would better be populated during boot by invoking the same function that also does so after updating. Otherwise it won't take long until reported and actual settings will be out of sync, until first modified via this new interface.
xen/arch/x86/hvm/vmx/vmcs.c integer_param("ple_window", ple_window); · line 76
Quoted 3 lines
xen/arch/x86/hvm/vmx/vmcs.c +3
-0+ + +static void update_ept_param (void )
No double blank lines please.
Quoted 14 lines
xen/arch/x86/hvm/vmx/vmcs.c +2
-0@@ -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 :
xen/arch/x86/hvm/vmx/vmcs.c static int parse_pcid(const char *s) · line 54
Quoted 10 lines
xen/arch/x86/hvm/vmx/vmcs.c +2
-0@@ -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 ;
Pretty expensive to use snprintf() here - how about strlcpy()?
xen/arch/x86/hvm/vmx/vmcs.c static int parse_gnttab_limit(const char *param, const char *arg, · line 110
Quoted 11 lines
xen/arch/x86/hvm/vmx/vmcs.c +2
-0@@ -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" ;
This and the other option are plain integer ones from a presentation pov, so it would be nice to get away here without the extra buffers.
Quoted 11 lines
xen/arch/x86/hvm/vmx/vmcs.c +7
-0@@ -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; +
xen/arch/x86/hvm/vmx/vmcs.c int hypfs_write_bool(struct hypfs_entry_leaf *leaf, · line 309
Quoted 10 lines
xen/arch/x86/hvm/vmx/vmcs.c +10
-0+ 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 ] )
Perhaps memchr() again.
xen/arch/x86/hvm/vmx/vmcs.c struct kernel_param { · line 28
Quoted 6 lines
xen/arch/x86/hvm/vmx/vmcs.c +2
-0@@ -23,10 +24,17 @@ struct kernel_param { } par; }; +struct param_hypfs { +const struct kernel_param *param;
As long as this is here, I don't think ...
xen/arch/x86/hvm/vmx/vmcs.c extern const struct kernel_param __param_start[], __param_end[]; · line 88
Quoted 6 lines
xen/arch/x86/hvm/vmx/vmcs.c +2
-0@@ -76,40 +84,87 @@ extern const struct kernel_param __param_start[], __param_end[]; .type = OPT_IGNORE }#define __rtparam __param(__dataparam) +#define __paramfs static __paramhypfs \ + __attribute__((__aligned__(sizeof(void *)))) struct param_hypfs
... you need the alignment attribute here. But see below.
xen/arch/x86/hvm/vmx/vmcs.c extern const struct kernel_param __param_start[], __param_end[]; · line 95
Quoted 9 lines
xen/arch/x86/hvm/vmx/vmcs.c +4
-2-#define custom_runtime_only_param (_name, _var) \ +#define custom_runtime_only_param (_name, _var, contvar) \ __rtparam __rtpar_##_var = \ { .name = _name, \ .type = OPT_CUSTOM, \ - .par.func = _var } + .par.func = _var }; \ + __paramfs __parfs_##_var = \ + { .param = &__rtpar_##_var, \
Instead of a pointer, can't the param struct be part of this bigger structure?
xen/arch/x86/hvm/vmx/vmcs.c extern const struct kernel_param __param_start[], __param_end[]; · line 99
Quoted 4 lines
xen/arch/x86/hvm/vmx/vmcs.c +4
-0+ .hypfs.e.type = XEN_HYPFS_TYPE_STRING, \ + .hypfs.e.encoding = XEN_HYPFS_ENC_PLAIN, \ + .hypfs.e.name = _name, \ + .hypfs.e.size = sizeof(contvar), \
This will go wrong if contvar is not an array. I guess you want ARRAY_SIZE(contvar) * sizeof(*(convar)) here, and perhaps also
...
xen/arch/x86/hvm/vmx/vmcs.c extern const struct kernel_param __param_start[], __param_end[]; · line 102
Quoted 3 lines
xen/arch/x86/hvm/vmx/vmcs.c +3
-0+ .hypfs.e.read = hypfs_read_leaf, \ + .hypfs.e.write = hypfs_write_custom, \ + .hypfs.content = &contvar }
... omit the & here.
xen/arch/x86/hvm/vmx/vmcs.c extern const struct kernel_param __param_start[], __param_end[]; · line 182
Quoted 6 lines
xen/arch/x86/hvm/vmx/vmcs.c +2
-0@@ -123,4 +178,7 @@ extern const struct kernel_param __param_start[], __param_end[];string_param (_name, _var); \ string_runtime_only_param(_name, _var) +#define param_append_str (var, fmt, val) \ + snprintf(var + strlen(var), sizeof(var) - strlen(var), fmt, val)
The sizeof() here again isn't safe against var not being of array type. Also again perhaps cheaper to use strlcat()?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v5 8/8] xen: add runtime parameter access support to hypfs
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Juergen Gross
docs/misc/hypfs-paths.pandoc +0
-0@@ -152,3 +152,12 @@ The major version of Xen. #### /buildinfo/version/minor = INTEGER
Quoted 11 lines
docs/misc/hypfs-paths.pandoc The major version of Xen. · line 162
Quoted 9 lines
docs/misc/hypfs-paths.pandoc +8
-0The minor version of Xen. + +#### /params/ + +A directory of runtime parameters. + +#### /params/* + +The single parameters. The description of the different parameters can bes/single/individual/?
Yes, this is better.
Quoted 14 lines
xen/arch/arm/xen.lds.S SECTIONS · line 96
Quoted 12 lines
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 = .;Do you really need 8-byte alignment even on 32-bit Arm?
I just followed the general pattern in this file.
Quoted 14 lines
xen/arch/x86/hvm/vmx/vmcs.c integer_param("ple_window", ple_window); · line 73
Quoted 8 lines
xen/arch/x86/hvm/vmx/vmcs.c +1
-0@@ -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" ;This is dangerous imo - such strings would better be populated during boot by invoking the same function that also does so after updating. Otherwise it won't take long until reported and actual settings will be out of sync, until first modified via this new interface.
Hmm, this would require a general update_value() function for each custom runtime parameter.
I can see how this would look like.
Quoted 6 lines
xen/arch/x86/hvm/vmx/vmcs.c integer_param("ple_window", ple_window); · line 76
Quoted 4 lines
xen/arch/x86/hvm/vmx/vmcs.c +3
-0+ + +static void update_ept_param (void )No double blank lines please.
Oh, sorry.
Quoted 21 lines
Quoted 21 lines
xen/arch/x86/hvm/vmx/vmcs.c +3
-0@@ -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 ;
Quoted 6 lines
xen/arch/x86/hvm/vmx/vmcs.c static int parse_pcid(const char *s) · line 54
Quoted 4 lines
xen/arch/x86/hvm/vmx/vmcs.c +1
-0case 1 : opt_pcid =PCID_XPTI ; +snprintf (opt_pcid_val,sizeof (opt_pcid_val),"xpti" );break ;Pretty expensive to use
snprintf()here - how aboutstrlcpy()?
Oh, of course.
Quoted 7 lines
Quoted 7 lines
xen/arch/x86/hvm/vmx/vmcs.c +1
-0@@ -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);
Quoted 8 lines
xen/arch/x86/hvm/vmx/vmcs.c static int parse_gnttab_limit(const char *param, const char *arg, · line 110
Quoted 5 lines
xen/arch/x86/hvm/vmx/vmcs.c +1
-0return 0 ; }unsigned int __read_mostly opt_max_grant_frames =64 ; +static char gnttab_max_frames_val[PAR_VAL_SZ ] ="64" ;This and the other option are plain integer ones from a presentation pov, so it would be nice to get away here without the extra buffers.
There is more than pure integer semantics here: the value is limited, so I can't just use the normal integer assignment.
Its not as if those functions are performance critical, and special casing for sparing the buffer memory will probably waste more memory due to larger code size.
Quoted 16 lines
Quoted 16 lines
xen/arch/x86/hvm/vmx/vmcs.c +11
-0@@ -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 ; +
Quoted 8 lines
xen/arch/x86/hvm/vmx/vmcs.c int hypfs_write_bool(struct hypfs_entry_leaf *leaf, · line 309
Quoted 6 lines
xen/arch/x86/hvm/vmx/vmcs.c +6
-0+ ret = -EFAULT ; +if (copy_from_guest (buf, uaddr, ulen) ) + goto out; + + ret = -EDOM ; +if ( buf[ulen -1 ] )Perhaps
memchr()again.
Okay.
Quoted 19 lines
xen/arch/x86/hvm/vmx/vmcs.c struct kernel_param { · line 28
Quoted 7 lines
xen/arch/x86/hvm/vmx/vmcs.c +2
-0@@ -23,10 +24,17 @@ struct kernel_param { } par; }; +struct param_hypfs { +const struct kernel_param *param;As long as this is here, I don't think ...
xen/arch/x86/hvm/vmx/vmcs.c extern const struct kernel_param __param_start[], __param_end[]; · line 88
Quoted 6 lines
xen/arch/x86/hvm/vmx/vmcs.c +2
-0@@ -76,40 +84,87 @@ extern const struct kernel_param __param_start[], __param_end[]; .type = OPT_IGNORE }#define __rtparam __param(__dataparam) +#define __paramfs static __paramhypfs \ + __attribute__((__aligned__(sizeof(void *)))) struct param_hypfs... you need the alignment attribute here. But see below.
Quoted 12 lines
xen/arch/x86/hvm/vmx/vmcs.c extern const struct kernel_param __param_start[], __param_end[]; · line 95
Quoted 9 lines
xen/arch/x86/hvm/vmx/vmcs.c +4
-2-#define custom_runtime_only_param (_name, _var) \ +#define custom_runtime_only_param (_name, _var, contvar) \ __rtparam __rtpar_##_var = \ { .name = _name, \ .type = OPT_CUSTOM, \ - .par.func = _var } + .par.func = _var }; \ + __paramfs __parfs_##_var = \ + { .param = &__rtpar_##_var, \Instead of a pointer, can't the param struct be part of this bigger structure?
I have some further patches in my pipeline which will do even more, by removing the sysctl for setting parameters and using hypfs for that purpose in libxl. This will remove the need for the runtime copy of struct kernel_param completely.
But r
Quoted 8 lines
xen/arch/x86/hvm/vmx/vmcs.c extern const struct kernel_param __param_start[], __param_end[]; · line 99
Quoted 5 lines
xen/arch/x86/hvm/vmx/vmcs.c +4
-0+ .hypfs.e.type = XEN_HYPFS_TYPE_STRING, \ + .hypfs.e.encoding = XEN_HYPFS_ENC_PLAIN, \ + .hypfs.e.name = _name, \ + .hypfs.e.size = sizeof(contvar), \This will go wrong if contvar is not an array. I guess you want
ARRAY_SIZE(contvar)* sizeof(*(convar)) here, and perhaps also
Ah, nice idea.
Quoted 7 lines
...
xen/arch/x86/hvm/vmx/vmcs.c
Quoted 3 lines
xen/arch/x86/hvm/vmx/vmcs.c +3
-0+ .hypfs.e.read = hypfs_read_leaf, \ + .hypfs.e.write = hypfs_write_custom, \ + .hypfs.content = &contvar }... omit the & here.
Okay.
Quoted 10 lines
xen/arch/x86/hvm/vmx/vmcs.c extern const struct kernel_param __param_start[], __param_end[]; · line 182
Quoted 7 lines
xen/arch/x86/hvm/vmx/vmcs.c +2
-0@@ -123,4 +178,7 @@ extern const struct kernel_param __param_start[], __param_end[];string_param (_name, _var); \ string_runtime_only_param(_name, _var) +#define param_append_str (var, fmt, val) \ + snprintf(var + strlen(var), sizeof(var) - strlen(var), fmt, val)The
sizeof()here again isn't safe against var not being of array type. Also again perhaps cheaper to usestrlcat()?
Yes.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v5 8/8] xen: add runtime parameter access support to hypfs
Quoted 16 lines · Jürgen Groß
Quoted 14 lines · Jan Beulich
xen/arch/arm/xen.lds.S SECTIONS · line 96
Quoted 11 lines · Juergen Gross
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 = .;Do you really need 8-byte alignment even on 32-bit Arm?
Quoted 1 line
I just followed the general pattern in this file.
Well, it'll be the Arm maintainers to judge anyway. It merely caught my eye.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
xen/arch/arm/xen.lds.S +1
-0@@ -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; }
Quoted 8 lines
Quoted 5 lines
xen/arch/arm/xen.lds.S static int parse_gnttab_limit(const char *param, const char *arg, · line 110
Quoted 2 lines
xen/arch/arm/xen.lds.S +1
-0unsigned int __read_mostly opt_max_grant_frames = 64; +static char gnttab_max_frames_val[PAR_VAL_SZ] = "64";This and the other option are plain integer ones from a presentation pov, so it would be nice to get away here without the extra buffers.
There is more than pure integer semantics here: the value is limited, so I can't just use the normal integer assignment.
Which is why I've said "from a presentation pov", i.e. when consuming the value for passing back as a string.
Quoted 3 lines
Its not as if those functions are performance critical, and special casing for sparing the buffer memory will probably waste more memory due to larger code size.
Well, it's not so much the memory savings, but the reduction of redundant information being kept. But if it's not sufficiently simple to generalize, so be it then.
Quoted 31 lines
Quoted 18 lines
xen/arch/arm/xen.lds.S struct kernel_param { · line 28
Quoted 6 lines
xen/arch/arm/xen.lds.S +2
-0@@ -23,10 +24,17 @@ struct kernel_param { } par; }; +struct param_hypfs { + const struct kernel_param *param;As long as this is here, I don't think ...
xen/arch/arm/xen.lds.S extern const struct kernel_param __param_start[], __param_end[]; · line 88
Quoted 6 lines
xen/arch/arm/xen.lds.S +2
-0@@ -76,40 +84,87 @@ extern const struct kernel_param __param_start[], __param_end[]; .type = OPT_IGNORE } #define __rtparam __param(__dataparam) +#define __paramfs static __paramhypfs \ + __attribute__((__aligned__(sizeof(void *)))) struct param_hypfs... you need the alignment attribute here. But see below.
Quoted 12 lines
xen/arch/arm/xen.lds.S extern const struct kernel_param __param_start[], __param_end[]; · line 95
Quoted 9 lines
xen/arch/arm/xen.lds.S +4
-2-#define custom_runtime_only_param(_name, _var) \ +#define custom_runtime_only_param(_name, _var, contvar) \ __rtparam __rtpar_##_var = \ { .name = _name, \ .type = OPT_CUSTOM, \ - .par.func = _var } + .par.func = _var }; \ + __paramfs __parfs_##_var = \ + { .param = &__rtpar_##_var, \Instead of a pointer, can't the param struct be part of this bigger structure?
Quoted 4 lines
I have some further patches in my pipeline which will do even more, by removing the sysctl for setting parameters and using hypfs for that purpose in libxl. This will remove the need for the runtime copy of struct
kernel_paramcompletely.
Ah, good to know. While reviewing this I was wondering about exactly this.
Quoted 1 line
But r
???
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v5 8/8] xen: add runtime parameter access support to hypfs
Quoted 37 lines · Jan Beulich
Quoted 16 lines · Jürgen Groß
Quoted 14 lines · Jan Beulich
xen/arch/arm/xen.lds.S SECTIONS · line 96
Quoted 11 lines · Juergen Gross
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 = .;Do you really need 8-byte alignment even on 32-bit Arm?
Quoted 1 line
I just followed the general pattern in this file.
Well, it'll be the Arm maintainers to judge anyway. It merely caught my eye.
Quoted 15 lines
Quoted 14 lines
xen/arch/arm/xen.lds.S static int parse_gnttab_limit(const char *param, const char *arg, · line 110
Quoted 11 lines
xen/arch/arm/xen.lds.S +2
-0@@ -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";This and the other option are plain integer ones from a presentation pov, so it would be nice to get away here without the extra buffers.
Quoted 5 lines
Quoted 2 lines
There is more than pure integer semantics here: the value is limited, so I can't just use the normal integer assignment.
Which is why I've said "from a presentation pov", i.e. when consuming the value for passing back as a string.
Hmm, this might even be possible via not using the common macro. I'll have a look into it.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel