docs: Improve coverage docs
cover docs: Improve coverage docs
This was identified IRL at the safety summit, so I took the opportunity to improve things.
The result of this series, and some other in-development bits, can be found at:
https://andrewcoop-xen.readthedocs.io/en/docs-devel/index.html
Andrew Cooper (2):
docs/sphinx: Introduce a hypervisor guide section docs/hypervisor-guide: Code Coverage
docs/hypervisor-guide/code-coverage.rst | 102 ++++++++++++++++++++++++++ docs/hypervisor-guide/index.rst | 7 ++ docs/index.rst | 18 +++++ docs/misc/coverage.pandoc | 124 -------------------------------- 4 files changed, 127 insertions(+), 124 deletions(-) create mode 100644 docs/hypervisor-guide/code-coverage.rst create mode 100644 docs/hypervisor-guide/index.rst delete mode 100644 docs/misc/coverage.pandoc
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 1/2 docs/sphinx: Introduce a hypervisor guide section
Include (and retrofit to the user guide) an introductory paragraph describing the intended audience.
---
CC: George Dunlap <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>
--- docs/hypervisor-guide/index.rst | 5 +++++ docs/index.rst | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 docs/hypervisor-guide/index.rst
docs/hypervisor-guide/index.rst new file +5 -0
@@ -0,0 +1,5 @@ +Hypervisor documentation +======================== + +.. toctree:: + :maxdepth: 2
docs/index.rst +18 -0
@@ -10,7 +10,25 @@ The Xen Hypervisor documentation User documentation ------------------ +This is documentation for an administrator of a Xen system. It is intended +for someone who is not necesserily a developer, has installed Xen from their +preferred distribution, and is attempting to run virtual machines and +configure the system. + .. toctree:: :maxdepth: 2 admin-guide/index + + +Hypervisor developer documentation +---------------------------------- + +This is documentation for a hypervisor developer. It is intended for someone +who is building Xen from source, and is running the new hypervisor in some +kind of development environment. + +.. toctree:: + :maxdepth: 2 + + hypervisor-guide/index
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/2] docs/sphinx: Introduce a hypervisor guide section
Quoted 4 lines · Andrew Cooper
Include (and retrofit to the user guide) an introductory paragraph describing the intended audience.
Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 2/2 docs/hypervisor-guide: Code Coverage
In reply to Andrew CooperDuring a discussion in person, it was identified that Coverage doesn't currently work for ARM yet. Also, there are a number of errors with the existing coverage document.
Take the opportunity to rewrite it in RST, making it easier to follow for a non-expert user.
---
CC: George Dunlap <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>
CC: Artem Mygaiev <[email protected]>
--- docs/hypervisor-guide/code-coverage.rst | 102 ++++++++++++++++++++++++++ docs/hypervisor-guide/index.rst | 2 + docs/misc/coverage.pandoc | 124 -------------------------------- 3 files changed, 104 insertions(+), 124 deletions(-) create mode 100644 docs/hypervisor-guide/code-coverage.rst delete mode 100644 docs/misc/coverage.pandoc
docs/hypervisor-guide/code-coverage.rst new file +102 -0
@@ -0,0 +1,102 @@ +Code Coverage +============= + +Xen can be compiled with coverage support. When configured, Xen will record +the coverage of its own basic blocks. Being a piece of system software rather +than a userspace, it can't automatically write coverage out to the filesystem, +so some extra steps are required to collect and process the data. + + +Compiling Xen +------------- + +Coverage support is dependent on the compiler and toolchain used. However, as +Xen isn't a userspace application, it can't use the compiler supplied library. +Instead, Xen has to provide some parts of the implementation itself. + +For x86, coverage support was introduced with GCC 3.4 or later, and Clang 3.9 +or later, and Xen is compatible with these. However, the compiler internal +formats do change occasionally, and this may involve adjustments to Xen. +While we do our best to keep up with these changes, Xen may not be compatible +with bleeding edge compilers. + +To build with coverage support, enable ``CONFIG_COVERAGE`` in Kconfig. The +build system will automatically select the appropriate format based on the +compiler in use. + +The resulting binary will record its own coverage while running. + +.. warning:: + + For ARM builds, while Xen will compile with ``CONFIG_COVERAGE`` enabled, the + resulting binary will not successfully boot if it exceeds 2MB in size. + Xen's early memory management code needs adjusting to resolve this issue. + + +Accessing the raw coverage data +------------------------------- + +The ``SYSCTL_coverage_op`` hypercall is used to interact with the coverage +data. A dom0 userspace helper, ``xenconv`` is provided as well, which thinly +wraps this hypercall. + +The ``read`` subcommand can be used to obtain the raw coverage data:: + + [root@host ~]# xencov read > coverage.dat + +This is toolchain-specific data and needs to be fed back to the appropriate +programs to post-process. + +Alternatively, the ``reset`` subcommand can be used reset all counters back to +0:: + + [root@host ~]# xencov reset + + +GCC coverage +------------ + +A build using GCC's coverage will result in ``*.gcno`` artefact for every +object file. The raw coverage data needs splitting to form the matching +``*.gcda`` files. + +An example of how to view the data is as follows. It additionally depends on +presence of ``lcov`` which is a graphical frontend to ``gcov``. + +* Obtain the raw coverage data from the test host, and pull it back to the + build working tree. +* Use ``xencov_split`` to extract the ``*.gcda`` files. Note that full build + paths are used by the tools, so splitting needs to output relative to ``/``. +* Use ``geninfo`` to post-process the raw data. +* Use ``genhtml`` to render the results as HTML. +* View the results in a browser. + +:: + + xen.git/xen$ ssh root@host xencov read > coverage.dat + xen.git/xen$ ../tools/xencov_split coverage.dat --output-dir=/ + xen.git/xen$ geninfo . -o cov.info + xen.git/xen$ genhtml cov.info -o cov/ + xen.git/xen$ $BROWSER cov/index.html + +Clang coverage +-------------- + +An example of how to view the data is as follows. + +* Obtain the raw coverage data from the test host, and pull it back to the + build working tree. +* Use ``llvm-profdata`` to post-process the raw data. +* Use ``llvm-cov show`` in combination with ``xen-syms`` from the build to + render the results as HTML. +* View the results in a browser. + +:: + + xen.git/xen$ ssh root@host xencov read > xen.profraw + xen.git/xen$ llvm-profdata merge xen.profraw -o xen.profdata + xen.git/xen$ llvm-cov show -format=html -output-dir=cov/ xen-syms -instr-profile=xen.profdata + xen.git/xen$ $BROWSER cov/index.html + +Full documentation on Clang's coverage capabilities can be found at: +https://clang.llvm.org/docs/SourceBasedCodeCoverage.html
docs/hypervisor-guide/index.rst +2 -0
@@ -3,3 +3,5 @@ Hypervisor documentation .. toctree:: :maxdepth: 2 + + code-coverage
docs/misc/coverage.pandoc deleted +0 -124
124 lines not on this page · raw message
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/2] docs/hypervisor-guide: Code Coverage
Hello Andrew
Minor note below.
On Wed, 2019-04-03 at 16:00 +0100, Andrew Cooper wrote:
[snip]
Quoted 6 lines
+ For ARM builds, while Xen will compile with ``CONFIG_COVERAGE`` enabled, the
+ resulting binary will not successfully boot if it exceeds 2MB in size.
+ Xen's early memory management code needs adjusting to resolve this issue.
Julien mentioned that on staging the binary is 1.5MB only so we must be able to run it without changes to Xen mem management. I will ask someone to try it today or tomorrow and get back with results
-- Artem
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/2] docs/hypervisor-guide: Code Coverage
Quoted 1 line · Artem Mygaiev
Hello Andrew
Hi,
Quoted 13 lines
Minor note below.
On Wed, 2019-04-03 at 16:00 +0100, Andrew Cooper wrote:
[snip]
Quoted 6 lines
+ For ARM builds, while Xen will compile with ``CONFIG_COVERAGE`` enabled, the
+ resulting binary will not successfully boot if it exceeds 2MB in size.
+ Xen's early memory management code needs adjusting to resolve this issue.
Quoted 3 lines
Julien mentioned that on staging the binary is 1.5MB only so we must be able to run it without changes to Xen mem management. I will ask someone to try it today or tomorrow and get back with results
I tried with a different .config and Xen will use 1.8MB. I have computed the size using (_start - _end).
This is dangerously close to 2MB and it might be possible be possible that we reach the limit with another .config.
I think Andrew's statement is correct. It does not say the binary will always be above 2MB but it might exceeds it. It only warns that it may happen and fail to boot.
The boot failure may not be obvious for the user. I wrote the patch below to fail when linking instead. We can consider it for backporting as well:
commit 256528c97b4c265911d960073facd4fdffcc650a
Author: Julien Grall <[email protected]> Date: Thu Apr 4 13:22:46 2019 +0100
xen/arm: Check Xen size when linking
The linker will happily link Xen if it is bigger than what we can handle (e.g 2MB). This will result to unexpected failure after boot.
This unexpected failure can be prevented by forbidding linking if Xen is bigger than 2MB.
xen/arch/arm/xen.lds.S +1 -0
@@ -242,3 +242,4 @@ ASSERT( _end_boot - start <= PAGE_SIZE, "Boot code is larger than 4K") */ ASSERT(IS_ALIGNED(__init_begin, 4), "__init_begin is misaligned") ASSERT(IS_ALIGNED(__init_end, 4), "__init_end is misaligned") +ASSERT(_end - start < XEN_SLOT_SIZE, "Xen is larger than 2M")
xen/include/asm-arm/config.h +1 -0
@@ -107,6 +107,7 @@* Unused */ +#define XEN_SLOT_SIZE MB(2)#define XEN_VIRT_START _AT(vaddr_t,0x00200000)#define FIXMAP_ADDR (n) (_AT(vaddr_t,0x00400000) + (n) * PAGE_SIZE)
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/2] docs/hypervisor-guide: Code Coverage
Quoted 53 lines · Julien Grall
Quoted 1 line · Artem Mygaiev
Hello Andrew
Hi,
Quoted 12 lines
Minor note below.
On Wed, 2019-04-03 at 16:00 +0100, Andrew Cooper wrote:
[snip]
Quoted 6 lines
+ For ARM builds, while Xen will compile with ``CONFIG_COVERAGE`` enabled, the
+ resulting binary will not successfully boot if it exceeds 2MB in size.
+ Xen's early memory management code needs adjusting to resolve this issue.Quoted 3 lines
Julien mentioned that on staging the binary is 1.5MB only so we must be able to run it without changes to Xen mem management. I will ask someone to try it today or tomorrow and get back with results
I tried with a different .config and Xen will use 1.8MB. I have computed the size using (
_start-_end).This is dangerously close to 2MB and it might be possible be possible that we reach the limit with another .config.
I think Andrew's statement is correct. It does not say the binary will always be above 2MB but it might exceeds it. It only warns that it may happen and fail to boot.
The boot failure may not be obvious for the user. I wrote the patch below to fail when linking instead. We can consider it for backporting as well:
commit
256528c97b4c265911d960073facd4fdffcc650aAuthor: Julien Grall <[email protected]> Date: Thu Apr 4 13:22:46 2019 +0100xen/arm: Check Xen size when linking
The linker will happily link Xen if it is bigger than what we can handle (e.g 2MB). This will result to unexpected failure after boot.
This unexpected failure can be prevented by forbidding linking if Xen is bigger than 2MB.
Signed-off-by Julien Grall <[email protected]>xen/arch/arm/xen.lds.S +0
-0
xen/arch/arm/xen.lds.S ASSERT( _end_boot - start <= PAGE_SIZE, "Boot code is larger than 4K") · line 245
Quoted 4 lines
xen/arch/arm/xen.lds.S +1
-0@@ -242,3 +242,4 @@ ASSERT( _end_boot - start <= PAGE_SIZE, "Boot code is larger than 4K") */ ASSERT(IS_ALIGNED(__init_begin, 4), "__init_begin is misaligned") ASSERT(IS_ALIGNED(__init_end, 4), "__init_end is misaligned") +ASSERT(_end - start < XEN_SLOT_SIZE, "Xen is larger than 2M")
I think you probably want an opencoded MB(2) here, or the comment will become stale as soon as the other issues get fixed. That way, someone will be forced to adjust this comment when the limit is lifted.
Given a patch like this, I'll drop the warning from the docs.
As an aside, do you happen to know which versions of GCC are expected to work. Alternatively, shall I just say that ARM isn't supported, by virtue of it never having actually been tested.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/2] docs/hypervisor-guide: Code Coverage
Hi,
Quoted 49 lines · Andrew Cooper
Quoted 48 lines · Julien Grall
Quoted 1 line · Artem Mygaiev
Hello Andrew
Hi,
Quoted 12 lines
Minor note below.
On Wed, 2019-04-03 at 16:00 +0100, Andrew Cooper wrote:
[snip]
Quoted 6 lines
+ For ARM builds, while Xen will compile with ``CONFIG_COVERAGE`` enabled, the
+ resulting binary will not successfully boot if it exceeds 2MB in size.
+ Xen's early memory management code needs adjusting to resolve this issue.Quoted 3 lines
Julien mentioned that on staging the binary is 1.5MB only so we must be able to run it without changes to Xen mem management. I will ask someone to try it today or tomorrow and get back with results
I tried with a different .config and Xen will use 1.8MB. I have computed the size using (
_start-_end).This is dangerously close to 2MB and it might be possible be possible that we reach the limit with another .config.
I think Andrew's statement is correct. It does not say the binary will always be above 2MB but it might exceeds it. It only warns that it may happen and fail to boot.
The boot failure may not be obvious for the user. I wrote the patch below to fail when linking instead. We can consider it for backporting as well:
commit
256528c97b4c265911d960073facd4fdffcc650aAuthor: Julien Grall <[email protected]> Date: Thu Apr 4 13:22:46 2019 +0100xen/arm: Check Xen size when linking
The linker will happily link Xen if it is bigger than what we can handle (e.g 2MB). This will result to unexpected failure after boot.
This unexpected failure can be prevented by forbidding linking if Xen is bigger than 2MB.
Signed-off-by Julien Grall <[email protected]>
Quoted 13 lines
xen/arch/arm/xen.lds.S ASSERT( _end_boot - start <= PAGE_SIZE, "Boot code is larger than 4K") · line 245
Quoted 9 lines
xen/arch/arm/xen.lds.S +1
-0@@ -242,3 +242,4 @@ ASSERT( _end_boot - start <= PAGE_SIZE, "Boot code is larger than 4K") */ ASSERT(IS_ALIGNED(__init_begin, 4), "__init_begin is misaligned") ASSERT(IS_ALIGNED(__init_end, 4), "__init_end is misaligned") +ASSERT(_end - start < XEN_SLOT_SIZE, "Xen is larger than 2M")I think you probably want an opencoded MB(2) here, or the comment will become stale as soon as the other issues get fixed. That way, someone will be forced to adjust this comment when the limit is lifted.
I would prefer to make the message agnostic. This could potentially allow us to make XEN_SLOT_SIZE configurable.
Quoted 6 lines
Given a patch like this, I'll drop the warning from the docs.
As an aside, do you happen to know which versions of GCC are expected to work. Alternatively, shall I just say that ARM isn't supported, by virtue of it never having actually been tested.
I have no idea. I haven't tried more than building GCOV.
It would be best if it is marked as unsupported until someone actually test it.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/2] docs/hypervisor-guide: Code Coverage
In reply to Andrew CooperQuoted 8 lines · Andrew Cooper
During a discussion in person, it was identified that Coverage doesn't currently work for ARM yet. Also, there are a number of errors with the existing coverage document.
Take the opportunity to rewrite it in RST, making it easier to follow for a non-expert user.
Signed-off-by Andrew Cooper <[email protected]>
(with or without adjustment to the statement regarding ARM)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel