Skip to contentSkip to conversation

Add hypervisor sysfs-like support

PATCH Superseded Juergen Gross 3 participants 21 messages Sep 27, 2019 – Sep 30, 2019

v1 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

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.

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 (6):
docs: add feature document for Xen hypervisor sysfs-like support
xen: add basic hypervisor filesystem support
libs: add libxenhypfs
tools: add xenfs tool
xen: add /buildinfo/config entry to hypervisor filesystem
xen: add runtime parameter reading support to hypfs

 .gitignore                          |   3 +
 docs/features/hypervisorfs.pandoc   | 119 +++++++++++++
 docs/misc/hypfs-paths.pandoc        |  70 ++++++++
 tools/Rules.mk                      |   6 +
 tools/libs/Makefile                 |   1 +
 tools/libs/hypfs/Makefile           |  14 ++
 tools/libs/hypfs/core.c             | 252 +++++++++++++++++++++++++++
 tools/libs/hypfs/include/xenhypfs.h |  60 +++++++
 tools/libs/hypfs/libxenhypfs.map    |   9 +
 tools/libs/hypfs/xenhypfs.pc.in     |  10 ++
 tools/misc/Makefile                 |   6 +
 tools/misc/xenhypfs.c               | 120 +++++++++++++
 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                 |  10 ++
 xen/common/hypfs.c                  | 331 ++++++++++++++++++++++++++++++++++++
 xen/common/kernel.c                 |  27 +++
 xen/include/public/errno.h          |   1 +
 xen/include/public/hypfs.h          | 123 ++++++++++++++
 xen/include/public/xen.h            |   1 +
 xen/include/xen/hypercall.h         |   8 +
 xen/include/xen/hypfs.h             |  40 +++++
 xen/include/xen/kernel.h            |   2 +
 xen/tools/Makefile                  |   9 +-
 xen/tools/bin2c.c                   |  28 +++
 27 files changed, 1252 insertions(+), 2 deletions(-)
 create mode 100644 docs/features/hypervisorfs.pandoc
 create mode 100644 docs/misc/hypfs-paths.pandoc
 create mode 100644 tools/libs/hypfs/Makefile
 create mode 100644 tools/libs/hypfs/core.c
 create mode 100644 tools/libs/hypfs/include/xenhypfs.h
 create mode 100644 tools/libs/hypfs/libxenhypfs.map
 create mode 100644 tools/libs/hypfs/xenhypfs.pc.in
 create mode 100644 tools/misc/xenhypfs.c
 create mode 100644 xen/common/hypfs.c
 create mode 100644 xen/include/public/hypfs.h
 create mode 100644 xen/include/xen/hypfs.h
 create mode 100644 xen/tools/bin2c.c
Signature · 7 lines
2.16.4


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

PATCH 1/6 docs: add feature document for Xen 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.

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

---
 docs/features/hypervisorfs.pandoc | 119 ++++++++++++++++++++++++++++++++++++++
 docs/misc/hypfs-paths.pandoc      |  55 ++++++++++++++++++
 2 files changed, 174 insertions(+)
 create mode 100644 docs/features/hypervisorfs.pandoc
 create mode 100644 docs/misc/hypfs-paths.pandoc
docs/features/hypervisorfs.pandoc new file +119 -0
new file mode 100644
index 0000000000..3155cee7d3
@@ -0,0 +1,119 @@
+% Hypervisor FS
+% Revision 1
+
+\clearpage
+
+# Basics
+---------------- ---------------------
+         Status: e.g. **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, but without the functionality to directly alter
+entries values. Entries and directories are created by the hypervisor,
+while the toolstack is able to use a hypercall to query the entry
+values.
+
+# 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 structure is:
+
+    /
+        buildinfo/           directory containing build-time data
+            config           contents of .config file used to build Xen
+        cpu-bugs/            x86: directory of cpu bug information
+            l1tf             "Vulnerable" or "Not vulnerable"
+            mds              "Vulnerable" or "Not vulnerable"
+            meltdown         "Vulnerable" or "Not vulnerable"
+            spec-store-bypass "Vulnerable" or "Not vulnerable"
+            spectre-v1       "Vulnerable" or "Not vulnerable"
+            spectre-v2       "Vulnerable" or "Not vulnerable"
+            mitigations/     directory of mitigation settings
+                bti-thunk    "N/A", "RETPOLINE", "LFENCE" or "JMP"
+                spec-ctrl    "No", "IBRS+" or IBRS-"
+                ibpb         "No" or "Yes"
+                l1d-flush    "No" or "Yes"
+                md-clear     "No" or "VERW"
+                l1tf-barrier "No" or "Yes"
+            active-hvm/      directory for mitigations active in hvm doamins
+                msr-spec-ctrl "No" or "Yes"
+                rsb          "No" or "Yes"
+                eager-fpu    "No" or "Yes"
+                md-clear     "No" or "Yes"
+            active-pv/       directory for mitigations active in pv doamins
+                msr-spec-ctrl "No" or "Yes"
+                rsb          "No" or "Yes"
+                eager-fpu    "No" or "Yes"
+                md-clear     "No" or "Yes"
+                xpti         "No" or list of "dom0", "domU", "PCID on"
+                l1tf-shadow  "No" or list of "dom0", "domU"
+        parameters/          directory with hypervisor parameter values
+                             (boot/runtime parameters)
+
+# Technical details
+
+Access to the hypervisor filesystem is done via the stable new hypercall
+__HYPERVISOR_filesystem_op.
+
+* hypercall interface specification
+    * `xen/include/public/filesystem.h`
+* hypervisor internal files
+    * `xen/include/xen/filesystem.h`
+    * `xen/common/filesystem.c`
+* `libxenhypfs`
+    * `tools/libs/libxenhypfs/*`
+* `xenhypfs`
+    * `tools/misc/xenhypfs.c`
+* path documentation
+    * `docs/misc/hypfs-paths.pandoc`
+ 
+# Testing
+
+Any new parameters or hardware mitigations should be verified to show up
+correctly in the filesystem.
+
+# Areas for improvement
+
+* More detailed access rights
+* Entries per domain and/or per cpupool
+
+# Known issues
+
+* None
+
+# References
+
+* None
+
+# History
+
+------------------------------------------------------------------------
+Date       Revision Version  Notes
+---------- -------- -------- -------------------------------------------
+2019-09-18 1        Xen 4.13 Document written
+---------- -------- -------- -------------------------------------------
docs/misc/hypfs-paths.pandoc new file +55 -0

55 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
#2 lore raw

Re: [Xen-devel] [PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support

Juergen Gross writes ("[PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support"):

Quoted 10 lines

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

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

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

Thanks for this work. Like others, I approve of the basic idea.

Reading your spec document here, I think there is a key part missing:
please could you specify the allowable syntax for keys, and for values.

I guess that keys will be chosen from some limited safe character set ? What about values ? Might we create a key whose value contains binary data ?

Depend on the answer to this question, I may want to suggest changes or enhancements to your proposed command-line tool.

Also, your top-level document has a list of paths in it, which is presumably prospective. Maybe that information should be a non-parsed header section in the paths document ?

Would it be possible to add a script to xen.git which lists the xenhypfs and checks that all the paths are documented ? We could add a few calls to that to osstest...

Thanks,
Ian.

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

#3 lore raw

Re: [Xen-devel] [PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support

Quoted 9 lines · Ian Jackson

Juergen Gross writes ("[PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support"):

Quoted 8 lines

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

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

Quoted 8 lines
Quoted 2 lines

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

Thanks for this work. Like others, I approve of the basic idea.

Reading your spec document here, I think there is a key part missing:
please could you specify the allowable syntax for keys, and for values.

Yes, that should be done.

Quoted 4 lines

I guess that keys will be chosen from some limited safe character set ? What about values ? Might we create a key whose value contains binary data ?

I'd go with "[-A-Za-z0-9@_.:()\[\]#,;]*" for keys and ASCII for values.

Quoted 6 lines

Depend on the answer to this question, I may want to suggest changes or enhancements to your proposed command-line tool.

Also, your top-level document has a list of paths in it, which is presumably prospective. Maybe that information should be a non-parsed header section in the paths document ?

Yes, that's better.

Quoted 3 lines

Would it be possible to add a script to xen.git which lists the xenhypfs and checks that all the paths are documented ? We could add a few calls to that to osstest...

I'd expect some parts to be described rather generically (as can be seen in patch 6 for the runtime parameters). Maybe I should add the entries with wildcards there.

OTOH adding such a script can easily be done later, maybe with some tweaks to the path documentation.

Juergen

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

#4 lore raw

Re: [Xen-devel] [PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support

Jürgen Groß writes ("Re: [PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support"):

Quoted 6 lines · Ian Jackson
Quoted 3 lines

I guess that keys will be chosen from some limited safe character set ? What about values ? Might we create a key whose value contains binary data ?

I'd go with "[-A-Za-z0-9@_.:()\[\]#,;]*" for keys

I think this is ASCII printing characters with the exception of
! " ` $ % ^ & * = + { } ' ~ < > / \ |

I struggle to find a principled explanation for this particular exclusion set (apart from /), considering that following are included:
- @ _ . : ( ) [ ] # , ;

Could we borrow some existing permitted character set ? If we are permitting shell metacharacters why not just permit all printable ASCII except / ?

Quoted 1 line

and ASCII for values.

Do you mean "any 7-bit byte", or octet values 32-126 (0x20-0x7e) inclusive, or something else ?

Quoted 7 lines
Quoted 3 lines

Would it be possible to add a script to xen.git which lists the xenhypfs and checks that all the paths are documented ? We could add a few calls to that to osstest...

I'd expect some parts to be described rather generically (as can be seen in patch 6 for the runtime parameters). Maybe I should add the entries with wildcards there.

That would be nice.

Quoted 2 lines

OTOH adding such a script can easily be done later, maybe with some tweaks to the path documentation.

Sure. Having at least some unit tests ought to be on the roadmap for supported status, but it doesn't need to happen now.

Ian.

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

#5 lore raw

Re: [Xen-devel] [PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support

Quoted 11 lines · Ian Jackson

Jürgen Groß writes ("Re: [PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support"):

Quoted 6 lines · Ian Jackson
Quoted 3 lines

I guess that keys will be chosen from some limited safe character set ? What about values ? Might we create a key whose value contains binary data ?

I'd go with "[-A-Za-z0-9@_.:()\[\]#,;]*" for keys

I think this is ASCII printing characters with the exception of
! " ` $ % ^ & * = + { } ' ~ < > / \ |

Quoted 8 lines

I struggle to find a principled explanation for this particular exclusion set (apart from /), considering that following are included:
- @ _ . : ( ) [ ] # , ;

Could we borrow some existing permitted character set ? If we are permitting shell metacharacters why not just permit all printable ASCII except / ?

Hmm, maybe we should allow just the "Posix portable file name character set"? That would be [-._0-9A-Za-z]. And we should explicitly not allow the key names "." and "..".

Quoted 5 lines
Quoted 2 lines

and ASCII for values.

Do you mean "any 7-bit byte", or octet values 32-126 (0x20-0x7e) inclusive, or something else ?

:-)

As I'd like to support e.g. the .config file contents of the hypervisor build I guess I need (0x01-0xff) inclusive, right?

Quoted 10 lines
Quoted 8 lines
Quoted 4 lines

Would it be possible to add a script to xen.git which lists the xenhypfs and checks that all the paths are documented ? We could add a few calls to that to osstest...

I'd expect some parts to be described rather generically (as can be seen in patch 6 for the runtime parameters). Maybe I should add the entries with wildcards there.

That would be nice.

Okay, will do.

Juergen

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

#6 lore raw

Re: [Xen-devel] [PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support

Jürgen Groß writes ("Re: [PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support"):

Quoted 9 lines · Ian Jackson
Quoted 8 lines

I think this is ASCII printing characters with the exception of
! " ` $ % ^ & * = + { } ' ~ < > / \ |

I struggle to find a principled explanation for this particular exclusion set (apart from /), considering that following are included:
- @ _ . : ( ) [ ] # , ;

Quoted 7 lines
Quoted 3 lines

Could we borrow some existing permitted character set ? If we are permitting shell metacharacters why not just permit all printable ASCII except / ?

Hmm, maybe we should allow just the "Posix portable file name character set"? That would be [-._0-9A-Za-z]. And we should explicitly not allow the key names "." and "..".

I agree about "." and "..".

I'm not sure the "Posix portable file name character set" is a very good guide. Posix will be pretty restricted there. What is the legal set in a Linux sysfs filename ?

Quoted 7 lines
Quoted 2 lines

Do you mean "any 7-bit byte", or octet values 32-126 (0x20-0x7e) inclusive, or something else ?

:-)

As I'd like to support e.g. the .config file contents of the hypervisor build I guess I need (0x01-0xff) inclusive, right?

The .config file I have here does not seem to contain any control characters. If it did surely that would be a bug? If you want this you obviously do need to permit newlines and spaces and perhaps tabs too.

Ian.

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

#7 lore raw

Re: [Xen-devel] [PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support

Quoted 18 lines · Ian Jackson

Jürgen Groß writes ("Re: [PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support"):

Quoted 9 lines · Ian Jackson
Quoted 8 lines

I think this is ASCII printing characters with the exception of

    ! " ` $ % ^ & * = + { } ' ~ < > / \ |

I struggle to find a principled explanation for this particular exclusion set (apart from /), considering that following are included:
- @ _ . : ( ) [ ] # , ;

Quoted 7 lines
Quoted 3 lines

Could we borrow some existing permitted character set ? If we are permitting shell metacharacters why not just permit all printable ASCII except / ?

Hmm, maybe we should allow just the "Posix portable file name character set"? That would be [-._0-9A-Za-z]. And we should explicitly not allow the key names "." and "..".

Quoted 5 lines

I agree about "." and "..".

I'm not sure the "Posix portable file name character set" is a very good guide. Posix will be pretty restricted there. What is the legal set in a Linux sysfs filename ?

Everything but "/" and "\0".

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

Do you mean "any 7-bit byte", or octet values 32-126 (0x20-0x7e) inclusive, or something else ?

:-)

Quoted 7 lines
Quoted 2 lines

As I'd like to support e.g. the .config file contents of the hypervisor build I guess I need (0x01-0xff) inclusive, right?

The .config file I have here does not seem to contain any control characters. If it did surely that would be a bug? If you want this you obviously do need to permit newlines and spaces and perhaps tabs too.

.config can contain user supplied strings. While not making much sense to have unprintable characters in there I don't see how to prevent them. And I guess we'd want to see them in case such a weird .config was used (and probably resulted in strange behavior).

Juergen

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

#8 lore raw

Re: [Xen-devel] [PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support

Quoted 36 lines · Jürgen Groß
Quoted 18 lines · Ian Jackson

Jürgen Groß writes ("Re: [PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support"):

Quoted 9 lines · Ian Jackson
Quoted 8 lines

I think this is ASCII printing characters with the exception of

    ! " ` $ % ^ & * = + { } ' ~ < > / \ |

I struggle to find a principled explanation for this particular exclusion set (apart from /), considering that following are included:
- @ _ . : ( ) [ ] # , ;

Quoted 7 lines
Quoted 3 lines

Could we borrow some existing permitted character set ? If we are permitting shell metacharacters why not just permit all printable ASCII except / ?

Hmm, maybe we should allow just the "Posix portable file name character set"? That would be [-._0-9A-Za-z]. And we should explicitly not allow the key names "." and "..".

Quoted 5 lines

I agree about "." and "..".

I'm not sure the "Posix portable file name character set" is a very good guide. Posix will be pretty restricted there. What is the legal set in a Linux sysfs filename ?

Everything but "/" and "\0".

Quoted 9 lines
Quoted 8 lines
Quoted 3 lines

Do you mean "any 7-bit byte", or octet values 32-126 (0x20-0x7e) inclusive, or something else ?

:-)

As I'd like to support e.g. the .config file contents of the hypervisor build I guess I need (0x01-0xff) inclusive, right?

Quoted 7 lines
Quoted 4 lines

The .config file I have here does not seem to contain any control characters. If it did surely that would be a bug? If you want this you obviously do need to permit newlines and spaces and perhaps tabs too.

.config can contain user supplied strings. While not making much sense to have unprintable characters in there I don't see how to prevent them.

Does / can't kconfig reject them?

Jan

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

#9 lore raw

Re: [Xen-devel] [PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support

Quoted 42 lines · Jan Beulich
Quoted 41 lines · Jürgen Groß
Quoted 18 lines · Ian Jackson

Jürgen Groß writes ("Re: [PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support"):

Quoted 9 lines · Ian Jackson
Quoted 8 lines

I think this is ASCII printing characters with the exception of

     ! " ` $ % ^ & * = + { } ' ~ < > / \ |

I struggle to find a principled explanation for this particular exclusion set (apart from /), considering that following are included:
- @ _ . : ( ) [ ] # , ;

Quoted 7 lines
Quoted 3 lines

Could we borrow some existing permitted character set ? If we are permitting shell metacharacters why not just permit all printable ASCII except / ?

Hmm, maybe we should allow just the "Posix portable file name character set"? That would be [-._0-9A-Za-z]. And we should explicitly not allow the key names "." and "..".

Quoted 5 lines

I agree about "." and "..".

I'm not sure the "Posix portable file name character set" is a very good guide. Posix will be pretty restricted there. What is the legal set in a Linux sysfs filename ?

Everything but "/" and "\0".

Quoted 13 lines
Quoted 8 lines
Quoted 3 lines

Do you mean "any 7-bit byte", or octet values 32-126 (0x20-0x7e) inclusive, or something else ?

:-)

As I'd like to support e.g. the .config file contents of the hypervisor build I guess I need (0x01-0xff) inclusive, right?

The .config file I have here does not seem to contain any control characters. If it did surely that would be a bug? If you want this you obviously do need to permit newlines and spaces and perhaps tabs too.

Quoted 4 lines
Quoted 2 lines

.config can contain user supplied strings. While not making much sense to have unprintable characters in there I don't see how to prevent them.

Does / can't kconfig reject them?

Right now it doesn't.

I tested that by manually modifying my .config and then doing a make. The (wrong) .config was accepted and the hypervisor built with it.

Juergen

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

#10 lore raw

Re: [Xen-devel] [PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support

Jürgen Groß writes ("Re: [PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support"):

Quoted 11 lines · Jan Beulich
Quoted 5 lines · Jürgen Groß
Quoted 2 lines

.config can contain user supplied strings. While not making much sense to have unprintable characters in there I don't see how to prevent them.

Does / can't kconfig reject them?

Right now it doesn't.

I tested that by manually modifying my .config and then doing a make. The (wrong) .config was accepted and the hypervisor built with it.

Urgh.

I think that either

(A) this needs to be prevented somehow, or

(B) your userland tools, at the very least, need souping up so that they (i) by default do not risk spamming the user's terminal with binary gibberish which someone stored in xenhypfs (ii) can be used to reliably extract any binary objects which have been stored.

I think (B)(i) necessarily involves some kind of quoting scheme :-/. (B)(ii) means the quoting needs to be turn-off-able.

Ian.

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

#11 lore raw

Re: [Xen-devel] [PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support

Quoted 10 lines · Ian Jackson

Jürgen Groß writes ("Re: [PATCH v1 1/6] docs: add feature document for Xen hypervisor sysfs-like support"):

Quoted 9 lines · Jan Beulich
Quoted 5 lines · Jürgen Groß
Quoted 2 lines

.config can contain user supplied strings. While not making much sense to have unprintable characters in there I don't see how to prevent them.

Does / can't kconfig reject them?

Right now it doesn't.

Quoted 8 lines
Quoted 2 lines

I tested that by manually modifying my .config and then doing a make. The (wrong) .config was accepted and the hypervisor built with it.

Urgh.

I think that either

(A) this needs to be prevented somehow, or

Difficult, as we inherit kconfig from the Linux kernel.

Quoted 7 lines

(B) your userland tools, at the very least, need souping up so that they (i) by default do not risk spamming the user's terminal with binary gibberish which someone stored in xenhypfs (ii) can be used to reliably extract any binary objects which have been stored.

I think (B)(i) necessarily involves some kind of quoting scheme :-/. (B)(ii) means the quoting needs to be turn-off-able.

Yes, this seems to be a sensible thing to do.

Juergen

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

#12 lore raw

PATCH 2/6 xen: add basic hypervisor filesystem support

In reply to Juergen Gross

Add the infrastructure for the hypervisor filesystem.

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

Initially we support string and unsigned integer entry types. The saved entry size is an upper bound, so for unsigned integer entries we always set the value "11".

---
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

---
 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           | 314 +++++++++++++++++++++++++++++++++++++++++++
 xen/include/public/errno.h   |   1 +
 xen/include/public/hypfs.h   | 123 +++++++++++++++++
 xen/include/public/xen.h     |   1 +
 xen/include/xen/hypercall.h  |   8 ++
 xen/include/xen/hypfs.h      |  40 ++++++
 11 files changed, 492 insertions(+)
 create mode 100644 xen/common/hypfs.c
 create mode 100644 xen/include/public/hypfs.h
 create mode 100644 xen/include/xen/hypfs.h
xen/arch/arm/traps.c +1 -0
index a3b961bd06..4b1acd67a2 100644
@@ -1401,6 +1401,7 @@ static arm_hypercall_t arm_hypercall_table[] = {
 #ifdef CONFIG_ARGO
     HYPERCALL(argo_op, 5),
 #endif
+    HYPERCALL(hypfs_op, 5),
 };
 
 #ifndef NDEBUG
xen/arch/x86/hvm/hypercall.c +1 -0
index 33dd2d99d2..210dda4f38 100644
@@ -144,6 +144,7 @@ static const hypercall_table_t hvm_hypercall_table[] = {
 #endif
     HYPERCALL(xenpmu_op),
     COMPAT_CALL(dm_op),
+    HYPERCALL(hypfs_op),
     HYPERCALL(arch_1)
 };
 
xen/arch/x86/hypercall.c +1 -0
index d483dbaa6b..8a8f223481 100644
@@ -73,6 +73,7 @@ const hypercall_args_t hypercall_args_table[NR_hypercalls] =
     ARGS(hvm_op, 2),
     ARGS(dm_op, 3),
 #endif
+    ARGS(hypfs_op, 5),
     ARGS(mca, 1),
     ARGS(arch_1, 1),
 };
xen/arch/x86/pv/hypercall.c +1 -0
index 0c84c0b3a0..e6860247cc 100644
@@ -84,6 +84,7 @@ const hypercall_table_t pv_hypercall_table[] = {
     HYPERCALL(hvm_op),
     COMPAT_CALL(dm_op),
 #endif
+    HYPERCALL(hypfs_op),
     HYPERCALL(mca),
     HYPERCALL(arch_1),
 };
xen/common/Makefile +1 -0
index 62b34e69e9..a3f66aa0c0 100644
@@ -11,6 +11,7 @@ obj-y += domain.o
 obj-y += event_2l.o
 obj-y += event_channel.o
 obj-y += event_fifo.o
+obj-y += hypfs.o
 obj-$(CONFIG_CRASH_DEBUG) += gdbstub.o
 obj-$(CONFIG_GRANT_TABLE) += grant_table.o
 obj-y += guestcopy.o
xen/common/hypfs.c new file +314 -0

314 lines not on this page · raw message

xen/include/public/errno.h +1 -0
index e1d02fcddf..5c53af6af9 100644
@@ -78,6 +78,7 @@ XEN_ERRNO(EBUSY,	16)	/* Device or resource busy */
 XEN_ERRNO(EEXIST,	17)	/* File exists */
 XEN_ERRNO(EXDEV,	18)	/* Cross-device link */
 XEN_ERRNO(ENODEV,	19)	/* No such device */
+XEN_ERRNO(ENOTDIR,	20)	/* Not a directory */
 XEN_ERRNO(EISDIR,	21)	/* Is a directory */
 XEN_ERRNO(EINVAL,	22)	/* Invalid argument */
 XEN_ERRNO(ENFILE,	23)	/* File table overflow */
xen/include/public/hypfs.h new file +123 -0

123 lines not on this page · raw message

xen/include/public/xen.h +1 -0
index d2198dffad..bf80f1da8c 100644
@@ -130,6 +130,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_ulong_t);
 #define __HYPERVISOR_argo_op              39
 #define __HYPERVISOR_xenpmu_op            40
 #define __HYPERVISOR_dm_op                41
+#define __HYPERVISOR_hypfs_op             42
 
 /* Architecture-specific hypercall definitions. */
 #define __HYPERVISOR_arch_0               48
xen/include/xen/hypercall.h +8 -0
index ad8ad27b23..349a0f6487 100644
@@ -150,6 +150,14 @@ do_dm_op(
     unsigned int nr_bufs,
     XEN_GUEST_HANDLE_PARAM(xen_dm_op_buf_t) bufs);
 
+extern long
+do_hypfs_op(
+    unsigned int cmd,
+    XEN_GUEST_HANDLE_PARAM(void) arg1,
+    unsigned long arg2,
+    XEN_GUEST_HANDLE_PARAM(void) arg3,
+    unsigned long arg4);
+
 #ifdef CONFIG_COMPAT
 
 extern int
xen/include/xen/hypfs.h new file +40 -0
new file mode 100644
index 0000000000..d2537211f6
@@ -0,0 +1,40 @@
+#ifndef __XEN_HYPFS_H__
+#define __XEN_HYPFS_H__
+
+#include <xen/list.h>
+
+struct hypfs_dir {
+    unsigned int content_size;
+    struct list_head list;
+};
+
+enum hypfs_entry_type {
+    hypfs_type_dir,
+    hypfs_type_string,
+    hypfs_type_uint
+};
+
+struct hypfs_entry {
+    enum hypfs_entry_type type;
+    const char *name;
+    struct list_head list;
+    struct hypfs_dir *parent;
+    union {
+        void *content;
+        struct hypfs_dir *dir;
+        char *str_val;
+        unsigned int *uint_val;
+    };
+};
+
+extern struct hypfs_dir hypfs_root;
+
+int hypfs_new_dir(struct hypfs_dir *parent, const char *name,
+                  struct hypfs_dir *dir);
+int hypfs_new_entry_string(struct hypfs_dir *parent, const char *name,
+                           char *val);
+int hypfs_new_entry_uint(struct hypfs_dir *parent, const char *name,
+                         unsigned int *val);
+struct hypfs_entry *hypfs_get_entry(char *path);
+
+#endif /* __XEN_HYPFS_H__ */
Signature · 7 lines
2.16.4


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

PATCH 3/6 libs: add libxenhypfs

In reply to Juergen Gross

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

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

---
 tools/Rules.mk                      |   6 +
 tools/libs/Makefile                 |   1 +
 tools/libs/hypfs/Makefile           |  14 ++
 tools/libs/hypfs/core.c             | 252 ++++++++++++++++++++++++++++++++++++
 tools/libs/hypfs/include/xenhypfs.h |  60 +++++++++
 tools/libs/hypfs/libxenhypfs.map    |   9 ++
 tools/libs/hypfs/xenhypfs.pc.in     |  10 ++
 7 files changed, 352 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
tools/Rules.mk +6 -0
index cf8935d6a3..b1ebb4c96c 100644
@@ -19,6 +19,7 @@ XEN_LIBXENGNTTAB   = $(XEN_ROOT)/tools/libs/gnttab
 XEN_LIBXENCALL     = $(XEN_ROOT)/tools/libs/call
 XEN_LIBXENFOREIGNMEMORY = $(XEN_ROOT)/tools/libs/foreignmemory
 XEN_LIBXENDEVICEMODEL = $(XEN_ROOT)/tools/libs/devicemodel
+XEN_LIBXENHYPFS    = $(XEN_ROOT)/tools/libs/hypfs
 XEN_LIBXC          = $(XEN_ROOT)/tools/libxc
 XEN_XENLIGHT       = $(XEN_ROOT)/tools/libxl
 # Currently libxlutil lives in the same directory as libxenlight
@@ -134,6 +135,11 @@ SHDEPS_libxendevicemodel = $(SHLIB_libxentoollog) $(SHLIB_libxentoolcore) $(SHLI
 LDLIBS_libxendevicemodel = $(SHDEPS_libxendevicemodel) $(XEN_LIBXENDEVICEMODEL)/libxendevicemodel$(libextension)
 SHLIB_libxendevicemodel  = $(SHDEPS_libxendevicemodel) -Wl,-rpath-link=$(XEN_LIBXENDEVICEMODEL)
 
+CFLAGS_libxenhypfs = -I$(XEN_LIBXENHYPFS)/include $(CFLAGS_xeninclude)
+SHDEPS_libxenhypfs = $(SHLIB_libxentoollog) $(SHLIB_libxentoolcore) $(SHLIB_xencall)
+LDLIBS_libxenhypfs = $(SHDEPS_libxenhypfs) $(XEN_LIBXENHYPFS)/libxenhypfs$(libextension)
+SHLIB_libxenhypfs  = $(SHDEPS_libxenhypfs) -Wl,-rpath-link=$(XEN_LIBXENHYPFS)
+
 # code which compiles against libxenctrl get __XEN_TOOLS__ and
 # therefore sees the unstable hypercall interfaces.
 CFLAGS_libxenctrl = -I$(XEN_LIBXC)/include $(CFLAGS_libxentoollog) $(CFLAGS_libxenforeignmemory) $(CFLAGS_libxendevicemodel) $(CFLAGS_xeninclude) -D__XEN_TOOLS__
tools/libs/Makefile +1 -0
index 88901e7341..69cdfb5975 100644
@@ -9,6 +9,7 @@ SUBDIRS-y += gnttab
 SUBDIRS-y += call
 SUBDIRS-y += foreignmemory
 SUBDIRS-y += devicemodel
+SUBDIRS-y += hypfs
 
 ifeq ($(CONFIG_RUMP),y)
 SUBDIRS-y := toolcore
tools/libs/hypfs/Makefile new file +14 -0
new file mode 100644
index 0000000000..c571597686
@@ -0,0 +1,14 @@
+XEN_ROOT = $(CURDIR)/../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+MAJOR    = 1
+MINOR    = 0
+LIBNAME  := hypfs
+USELIBS  := toollog toolcore call
+
+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 +252 -0

252 lines not on this page · raw message

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

60 lines not on this page · raw message

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


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

Re: [Xen-devel] [PATCH v1 3/6] libs: add libxenhypfs

Juergen Gross writes ("[PATCH v1 3/6] libs: add libxenhypfs"):

Quoted 1 line

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

This code looks as expected to me.

It does make me thing you have had to write rather a lot of rather boring (and in some cases, fiddly) code. I'm not sure that I have a good answer to this. In any case it's not your fault :-).

Regards,
Ian.

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

#15 lore raw

Re: [Xen-devel] [PATCH v1 3/6] libs: add libxenhypfs

Quoted 10 lines · Ian Jackson

Juergen Gross writes ("[PATCH v1 3/6] libs: add libxenhypfs"):

Quoted 1 line

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

This code looks as expected to me.

It does make me thing you have had to write rather a lot of rather boring (and in some cases, fiddly) code. I'm not sure that I have a good answer to this. In any case it's not your fault :-).

Copy-and-paste are the developer's best friends. ;-)

Juergen

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

#16 lore raw

PATCH 4/6 tools: add xenfs tool

In reply to Juergen Gross

Add the xenfs tool for accessing the hypervisor filesystem.

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

---
 .gitignore            |   1 +
 tools/misc/Makefile   |   6 +++
 tools/misc/xenhypfs.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 127 insertions(+)
 create mode 100644 tools/misc/xenhypfs.c
.gitignore +1 -0
index 3ada0c4f0b..954c1da2cb 100644
@@ -370,6 +370,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
tools/misc/Makefile +6 -0
index 63947bfadc..9fdb13597f 100644
@@ -24,6 +24,7 @@ INSTALL_SBIN-$(CONFIG_X86)     += xen-lowmemd
 INSTALL_SBIN-$(CONFIG_X86)     += xen-mfndump
 INSTALL_SBIN-$(CONFIG_X86)     += xen-ucode
 INSTALL_SBIN                   += xencov
+INSTALL_SBIN                   += xenhypfs
 INSTALL_SBIN                   += xenlockprof
 INSTALL_SBIN                   += xenperf
 INSTALL_SBIN                   += xenpm
@@ -86,6 +87,9 @@ xenperf: xenperf.o
 xenpm: xenpm.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
 
+xenhypfs: xenhypfs.o
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenhypfs) $(APPEND_LDFLAGS)
+
 xenlockprof: xenlockprof.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
 
@@ -94,6 +98,8 @@ xen-hptool.o: CFLAGS += -I$(XEN_ROOT)/tools/libxc $(CFLAGS_libxencall)
 xen-hptool: xen-hptool.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) $(APPEND_LDFLAGS)
 
+xenhypfs.o: CFLAGS += $(CFLAGS_libxenhypfs)
+
 # xen-mfndump incorrectly uses libxc internals
 xen-mfndump.o: CFLAGS += -I$(XEN_ROOT)/tools/libxc $(CFLAGS_libxencall)
 xen-mfndump: xen-mfndump.o
tools/misc/xenhypfs.c new file +120 -0

120 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
#17 lore raw

Re: [Xen-devel] [PATCH v1 4/6] tools: add xenfs tool

Juergen Gross writes ("[PATCH v1 4/6] tools: add xenfs tool"):

Quoted 1 line

Add the xenfs tool for accessing the hypervisor filesystem.

Thanks for taking care about exit status. Can you document the exit statuses somewhere ?

Ian.

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

#18 lore raw

Re: [Xen-devel] [PATCH v1 4/6] tools: add xenfs tool

Quoted 5 lines · Ian Jackson

Juergen Gross writes ("[PATCH v1 4/6] tools: add xenfs tool"):

Quoted 1 line

Add the xenfs tool for accessing the hypervisor filesystem.

Thanks for taking care about exit status. Can you document the exit statuses somewhere ?

Yes. Might be a good reason to add a man-page. :-)

Juergen

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

#19 lore raw

PATCH 5/6 xen: add /buildinfo/config entry to hypervisor filesystem

In reply to Juergen Gross

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

---
 .gitignore                   |  2 ++
 docs/misc/hypfs-paths.pandoc |  9 +++++++++
 xen/common/Makefile          |  9 +++++++++
 xen/common/hypfs.c           | 17 +++++++++++++++++
 xen/include/xen/kernel.h     |  2 ++
 xen/tools/Makefile           |  9 +++++++--
 xen/tools/bin2c.c            | 28 ++++++++++++++++++++++++++++
 7 files changed, 74 insertions(+), 2 deletions(-)
 create mode 100644 xen/tools/bin2c.c
.gitignore +2 -0
index 954c1da2cb..16dfbb8302 100644
@@ -295,6 +295,7 @@ xen/arch/*/efi/boot.c
 xen/arch/*/efi/compat.c
 xen/arch/*/efi/efi.h
 xen/arch/*/efi/runtime.c
+xen/common/config_data.c
 xen/include/headers*.chk
 xen/include/asm
 xen/include/asm-*/asm-offsets.h
@@ -312,6 +313,7 @@ xen/test/livepatch/xen_bye_world.livepatch
 xen/test/livepatch/xen_hello_world.livepatch
 xen/test/livepatch/xen_nop.livepatch
 xen/test/livepatch/xen_replace_world.livepatch
+xen/tools/bin2c
 xen/tools/kconfig/.tmp_gtkcheck
 xen/tools/kconfig/.tmp_qtcheck
 xen/tools/symbols
docs/misc/hypfs-paths.pandoc +9 -0
index 2fe5455e6f..56ebdcd8be 100644
@@ -53,3 +53,12 @@ tags enclosed in square brackets.
 #### /
 
 The root of the hypervisor file system.
+
+#### /buildinfo/
+
+A directory containing static information generated while building the
+hypervisor.
+
+#### /buildinfo/config = STRING
+
+The contents of the `xen/.config` file at the time of the hypervisor build.
xen/common/Makefile +9 -0
index a3f66aa0c0..de7e0fa645 100644
@@ -1,6 +1,7 @@
 obj-$(CONFIG_ARGO) += argo.o
 obj-y += bitmap.o
 obj-y += bsearch.o
+obj-y += config_data.o
 obj-$(CONFIG_CORE_PARKING) += core_parking.o
 obj-y += cpu.o
 obj-y += cpupool.o
@@ -79,3 +80,11 @@ subdir-$(CONFIG_UBSAN) += ubsan
 
 subdir-$(CONFIG_NEEDS_LIBELF) += libelf
 subdir-$(CONFIG_HAS_DEVICE_TREE) += libfdt
+
+config_data.c: ../.config
+	( echo "char xen_config_data[] ="; \
+	  ../tools/bin2c <$<; \
+	  echo ";" ) > $@
+
+clean::
+	rm config_data.c 2>/dev/null || true
xen/common/hypfs.c +17 -0
index 7d9595dfa7..11b7b36e56 100644
@@ -25,6 +25,10 @@ static struct hypfs_entry hypfs_root_entry = {
     .dir = &hypfs_root,
 };
 
+static struct hypfs_dir hypfs_buildinfo = {
+    .list = LIST_HEAD_INIT(hypfs_buildinfo.list),
+};
+
 static int hypfs_add_entry(struct hypfs_dir *parent, struct hypfs_entry *new)
 {
     int ret = -ENOENT;
@@ -312,3 +316,16 @@ long do_hypfs_op(unsigned int cmd,
 
     return ret;
 }
+
+static int __init hypfs_init(void)
+{
+    int ret;
+
+    ret = hypfs_new_dir(&hypfs_root, "buildinfo", &hypfs_buildinfo);
+    BUG_ON(ret);
+    ret = hypfs_new_entry_string(&hypfs_buildinfo, "config", xen_config_data);
+    BUG_ON(ret);
+
+    return 0;
+}
+__initcall(hypfs_init);
xen/include/xen/kernel.h +2 -0
index 548b64da9f..5ff2280b0f 100644
@@ -100,5 +100,7 @@ extern enum system_state {
 
 bool_t is_active_kernel_text(unsigned long addr);
 
+extern char xen_config_data[];
+
 #endif /* _LINUX_KERNEL_H */
 
xen/tools/Makefile +7 -2
index e940939d61..cd2bbbf647 100644
@@ -1,13 +1,18 @@
 
 include $(XEN_ROOT)/Config.mk
 
+PROGS = symbols bin2c
+
 .PHONY: default
 default:
-	$(MAKE) symbols
+	$(MAKE) $(PROGS)
 
 .PHONY: clean
 clean:
-	rm -f *.o symbols
+	rm -f *.o $(PROGS)
 
 symbols: symbols.c
 	$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
+
+bin2c: bin2c.c
+	$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
xen/tools/bin2c.c new file +28 -0
new file mode 100644
index 0000000000..c332399b70
@@ -0,0 +1,28 @@
+/*
+ * Unloved program to convert a binary on stdin to a C include on stdout
+ *
+ * Jan 1999 Matt Mackall <[email protected]>
+ *
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ */
+
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+	int ch, total = 0;
+
+	do {
+		printf("\t\"");
+		while ((ch = getchar()) != EOF) {
+			total++;
+			printf("\\x%02x", ch);
+			if (total % 16 == 0)
+				break;
+		}
+		printf("\"\n");
+	} while (ch != EOF);
+
+	return 0;
+}
Signature · 7 lines
2.16.4


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

PATCH 6/6 xen: add runtime parameter reading support to hypfs

In reply to Juergen Gross

Add support to read values of hypervisor runtime parameters via the hypervisor file system for all unsigned integer type runtime parameters.

---
 docs/misc/hypfs-paths.pandoc |  6 ++++++
 xen/common/kernel.c          | 27 +++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)
docs/misc/hypfs-paths.pandoc +6 -0
index 56ebdcd8be..d710b83185 100644
@@ -62,3 +62,9 @@ hypervisor.
 #### /buildinfo/config = STRING
 
 The contents of the `xen/.config` file at the time of the hypervisor build.
+
+#### /params/
+
+A directory of runtime parameters (those can be set via xl set-parameters).
+The description of the different parameters can be found in
+`docs/misc/xen-command-line.pandoc`.
xen/common/kernel.c +27 -0
index 760917dab5..09787b5a34 100644
@@ -7,6 +7,7 @@
 #include <xen/init.h>
 #include <xen/lib.h>
 #include <xen/errno.h>
+#include <xen/hypfs.h>
 #include <xen/version.h>
 #include <xen/sched.h>
 #include <xen/paging.h>
@@ -320,6 +321,32 @@ int cmdline_strcmp(const char *frag, const char *name)
     }
 }
 
+static struct hypfs_dir hypfs_params = {
+    .list = LIST_HEAD_INIT(hypfs_params.list),
+};
+
+static int __init runtime_param_hypfs_add(void)
+{
+    const struct kernel_param *param;
+    int ret;
+
+    ret = hypfs_new_dir(&hypfs_root, "params", &hypfs_params);
+    BUG_ON(ret);
+
+    for ( param = __param_start; param < __param_end; param++ )
+    {
+        if ( param->type == OPT_UINT && param->len == sizeof(unsigned int) )
+        {
+            ret = hypfs_new_entry_uint(&hypfs_params, param->name,
+                                       (unsigned int *)(param->par.var));
+            BUG_ON(ret);
+        }
+    }
+
+    return 0;
+}
+__initcall(runtime_param_hypfs_add);
+
 unsigned int tainted;
 
 /**
Signature · 7 lines
2.16.4


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