Commit Graph
23 Commits
Author SHA1 Message Date
Frediano Ziglio 9b0adb928c libs/guest: move batch_pfns into a separate structure
Preparation for a followup patch "libs/guest: allocate various migration
arrays just once".

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>
2026-08-11 11:07:08 +02:00
Frediano Ziglio 42ef7f6106 libs/guest: Avoids using 2 indexes in process_page_data()
Simplify code, after the first scan of the various arrays we don't need to
keep original types and PFNs but only the ones having data.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Anthony PERARD <anthony.perard@vates.tech>
2026-07-08 15:35:45 +01:00
Frediano Ziglio f43ce6e8f7 x86/boot: Exclude not used string
If CONFIG_REQUIRE_NX is not enabled the string is not used.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2026-06-30 10:03:32 +02:00
Frediano Ziglio 60ea3a3ac3 x86/MCE: Fix race condition in mctelem_reserve
These lines (in mctelem_reserve)

        newhead = oldhead->mcte_next;
        if (cmpxchgptr(freelp, oldhead, newhead) == oldhead) {

are racy. After you read the newhead pointer it can happen that another
flow (thread or recursive invocation) change all the list but set head
with same value. So oldhead is the same as *freelp but you are setting
a new head that could point to whatever element (even already used).

This patch use instead a bit array and atomic bit operations.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Reviewed-by: Liu Jinsong <jinsong.liu@intel.com>
2014-02-24 12:07:41 +01:00
Frediano Ziglio e9af61b969 mce: fix race condition in mctelem_xchg_head
The function (mctelem_xchg_head()) used to exchange mce telemetry
list heads is racy.  It may write to the head twice, with the second
write linking to an element in the wrong state.

If there are two threads, T1 inserting on committed list; and T2
trying to consume it.

1. T1 starts inserting an element (A), sets prev pointer (mcte_prev).
2. T1 is interrupted after the cmpxchg succeeded.
3. T2 gets the list and changes element A and updates the commit list
   head.
4. T1 resumes, reads pointer to prev again and compare with result
   from the cmpxchg which succeeded but in the meantime prev changed
   in memory.
5. T1 thinks the cmpxchg failed and goes around the loop again,
   linking head to A again.

To solve the race use temporary variable for prev pointer.

*linkp (which point to a field in the element) must be updated before
the cmpxchg() as after a successful cmpxchg the element might be
immediately removed and reinitialized.

The wmb() prior to the cmpchgptr() call is not necessary since it is
already a full memory barrier.  This wmb() is thus removed.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Reviewed-by: Liu Jinsong <jinsong.liu@intel.com>
2014-01-17 15:58:27 +01:00
Frediano Ziglio 55e5d9527c gcov: Do not use mmap directly but use xc_hypercall_buffer_alloc
xencov.c did not compile on NetBSD so use xc_hypercall_buffer which is
more portable.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2013-06-27 12:11:32 +01:00
Frediano Ziglio 8789dfb557 gcov: update documentation on coverage.
Fix some spelling.
Add documentation for new xencov_split utility.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2013-05-30 09:31:05 +01:00
Frediano Ziglio cc1eca5194 gcov: Add script to split coverage informations.
Split coverage informations extracted from xencov utility.
This script accept coverage blob either as file or from input and extract
into files compatible with gcc format (gcda).

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2013-05-30 09:30:18 +01:00
Frediano Ziglio 31c59e7009 doc: Improve xc_domain_restore inline documentation
Was not clear that xc_domain_restore did not resume the machine.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
2013-02-22 16:34:04 +00:00
Frediano Ziglio 1ac127193d genid: Introduce again Windows generation ID device
This device was removed due to change in specifications.
Original patch written by Paul Durrant

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
2013-02-21 16:47:57 +00:00
Frediano Ziglio c5a29a8732 genid: Update Windows generation ID
First draft specification document it as a 64bit counter, now are a 128bit
value handled as a couple of 64bit values.

Allow to disable the device is values are all zeroes.

Add documentation for platform/generation-id key.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
2013-02-21 16:47:49 +00:00
Frediano Ziglio 922153cd37 gcov: Add documentation for coverage 2013-02-21 16:28:22 +00:00
Frediano Ziglio eb459da885 gcov: Add small utility to deal with test coverage information from Xen
Currently the utility can read and reset coverage informations.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
2013-02-21 16:28:11 +00:00
Frediano Ziglio 5043f14b5e gcov: Implement code to read coverage informations
Operations are handled by a sysctl specific operation.

Implement 4 operations
- check if coverage is compiled in
- read size of coverage information
- read coverage information
- reset coverage counters

Information are stored in a single blob in a format specific to Xen designed
to make code that generate coverage as small as possible.

This patch add a public header with the structure of blob exported by Xen.
This avoid problems distributing header which is GPL2.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
2013-02-21 16:23:57 +00:00
Frediano Ziglio 26c9d03dd4 gcov: Adding support for coverage information
This patch introduce coverage support to Xen.
Currently it allows to compile Xen with coverage support but there is no
way to extract them.

The declarations came from Linux source files (as you can see from file
headers).

The idea is to have some operations mainly
- get coverage information size
- read coverage information
- reset coverage counters

Linux use a file system to export these information. The information will
be a blob to handle with some tools (as usually tools require a bunch of
files but Xen does not handle files at all). I'll pack them to make things
simpler as possible.

These information cannot be put in a specific section (allowing a safe
mapping) as gcc use .rodata, .data, .text and .ctors sections.

I added code to handle constructors used in this case to initialize a
linked list of files.

I excluded %.init.o files as they are used before Xen start and should
not have section like .text or .data.

I used a "coverage" configuration option to mimic the "debug" one.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
2013-02-21 16:15:40 +00:00
Frediano Ziglio 68ca0bc4ba gcov: Call constructors during initialization
This allow modules to set initializer functions.
This is used by Gcc instrumentation code for profiling arcs and test
coverage.
2013-02-21 16:15:33 +00:00
Frediano Ziglio afecd83025 .gitignore: Do not ignore dsdl.asl file
dsdl.asl file is not autogenerated while all other dsdl_*.asl files are.
.hgignore is correct.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2013-02-20 16:59:43 +00:00
Frediano Ziglio efadaf957a trivial: Optimize printnum
Reuse the string of hexadecimal numbers to simplify printnum implementation

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
2013-02-15 13:32:06 +00:00
Frediano Ziglio 0ff01eebcd vgabios: Make Windows 8 support greater resolutions
Apparently Windows 8 refuse to use any mode if has more than one page.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2012-05-07 13:39:27 +01:00
Frediano Ziglio e7ee11ad72 vgabios: Check if mode is currently supported as vesa specifications
Vesa specification require that mode information return if a given
mode is supported or not so test if we can support it checking
required memory and set correctly supported bit.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2012-05-07 13:38:57 +01:00
Frediano Ziglio 4da31be120 vgabios: Reduce stack usage getting mode informations
Informations are stored in a structure that is smaller than final one.
Previous code copy this structure to stack extending with zeroes then
update it and copy to caller while now the not-extended version is
copied into stack and then is extended during copy reducing stack
usage.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2012-05-07 13:38:23 +01:00
Frediano Ziglio a8ceaf5c72 vgabios: Report mode not supported getting mode informations
If you try to get mode information for an unsupported mode
interrupt should return error but not that the function is not
supported.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2012-05-07 13:37:47 +01:00
Frediano Ziglio ab1f3cd4ab vgabios: Fix size computation overflow
Remove an overflow computing width x height x bit which does
not fit into a 16 bits. I wrote a routine to multiple these value
and get the size required for framebuffer in segment unit (64k).

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2012-05-07 13:37:10 +01:00