summaryrefslogtreecommitdiff
path: root/tools/libs
Commit message (Collapse)AuthorAgeFilesLines
* tools: drop bogus and obsolete ptyfuncs.m4HEADmasterOlaf Hering2023-05-162-5/+1
| | | | | | | | | | | | | | | | | | | | | | According to openpty(3) it is required to include <pty.h> to get the prototypes for openpty() and login_tty(). But this is not what the function AX_CHECK_PTYFUNCS actually does. It makes no attempt to include the required header. The two source files which call openpty() and login_tty() already contain the conditionals to include the required header. Remove the bogus m4 file to fix build with clang, which complains about calls to undeclared functions. Remove usage of INCLUDE_LIBUTIL_H in libxl_bootloader.c, it is already covered by inclusion of libxl_osdep.h. Remove usage of PTYFUNCS_LIBS in libxl/Makefile, it is already covered by UTIL_LIBS from config/StdGNU.mk. Signed-off-by: Olaf Hering <olaf@aepfle.de> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
* x86: Add AMD's CpuidUserDis bit definitionsAlejandro Vallejo2023-05-111-0/+1
| | | | | | | | | | AMD reports support for CpuidUserDis in CPUID and provides the toggle in HWCR. This patch adds the positions of both of those bits to both xen and tools. No functional change. Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
* domctl: Modify XEN_DOMCTL_getdomaininfo to fail if domid is not foundAlejandro Vallejo2023-05-101-73/+0
| | | | | | | | | | | | | | | | | | | | | | | | It previously mimicked the getdomaininfo sysctl semantics by returning the first domid higher than the requested domid that does exist. This unintuitive behaviour causes quite a few mistakes and makes the call needlessly slow in its error path. This patch removes the fallback search, returning -ESRCH if the requested domain doesn't exist. Domain discovery can still be done through the sysctl interface as that performs a linear search on the list of domains. With this modification the xc_domain_getinfo() function is deprecated and removed to make sure it's not mistakenly used expecting the old behaviour. The new xc wrapper is xc_domain_getinfo_single(). All previous callers of xc_domain_getinfo() have been updated to use xc_domain_getinfo_single() or xc_domain_getinfolist() instead. This also means xc_dominfo_t is no longer used by anything and can be purged. Resolves: xen-project/xen#105 Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Anthony PERARD <anthony.perard@citrix.com>
* tools: Use new xc function for some xc_domain_getinfo() callsAlejandro Vallejo2023-05-1021-141/+121
| | | | | | | | | Move calls that require a information about a single precisely identified domain to the new xc_domain_getinfo_single(). Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Anthony PERARD <anthony.perard@citrix.com>
* tools: Modify single-domid callers of xc_domain_getinfolist()Alejandro Vallejo2023-05-105-38/+22
| | | | | | | | | | | | | | xc_domain_getinfolist() internally relies on a sysctl that performs a linear search for the domids. Many callers of xc_domain_getinfolist() who require information about a precise domid are much better off calling xc_domain_getinfo_single() instead, that will use the getdomaininfo domctl instead and ensure the returned domid matches the requested one. The domtctl will find the domid faster too, because that uses hashed lists. Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Christian Lindig <christian.lindig@cloud.com> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
* x86/platform: introduce XENPF_get_ucode_revisionSergey Dyasli2023-05-031-0/+18
| | | | | | | | | | | | Currently it's hard to get CPU's microcode revision from Xen after late loading without looking into Xen logs, which is not always convenient. Add a new platform op in order to get the required data from Xen and provide a wrapper for libxenctrl. Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
* tools/xenctrl: add xc_get_cpu_version()Sergey Dyasli2023-05-031-0/+17
| | | | | | | As a wrapper for XENPF_get_cpu_version platform op. Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
* tools/libs/guest: assist gcc13's realloc analyzerOlaf Hering2023-05-031-10/+6
| | | | | | | | | | | | | | | | | | | | | gcc13 fails to track the allocated memory in backup_ptes: xg_offline_page.c: In function 'backup_ptes': xg_offline_page.c:191:13: error: pointer 'orig' may be used after 'realloc' [-Werror=use-after-free] 191 | free(orig); Assist the analyzer by slightly rearranging the code: In case realloc succeeds, the previous allocation is either extended or released internally. In case realloc fails, the previous allocation is left unchanged. Return an error in this case, the caller will release the currently allocated memory in its error path. http://bugzilla.suse.com/show_bug.cgi?id=1210570 Signed-off-by: Olaf Hering <olaf@aepfle.de> Reviewed-by: Juergen Gross <jgross@suse.com> Compile-tested-by: Jason Andryuk <jandryuk@gmail.com> Acked-by: Jan Beulich <jbeulich@suse.com>
* libxl: fix matching of generic virtio deviceViresh Kumar2023-05-031-4/+8
| | | | | | | | | | | The strings won't be an exact match, as we are only looking to match the prefix here, i.e. "virtio,device". This is already done properly in libxl_virtio.c file, lets do the same here too. Fixes: 43ba5202e2ee ("libxl: add support for generic virtio device") Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> Acked-by: Anthony PERARD <anthony.perard@citrix.com>
* tools: Create xc_domain_getinfo_single()Alejandro Vallejo2023-04-281-0/+24
| | | | | | | | | | It's a stricter version of xc_domain_getinfo() where the returned domid always matches the requested domid or the error code shows an error instead. A few patches ahead usages of xc_domain_getinfo() are removed until only xc_domain_getinfo_single() and xc_domain_getinfolist() remain. Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
* libxl: Print device_kind as a stringJason Andryuk2023-04-261-2/+2
| | | | | | | | | Printing the integer isn't particularly informative. Switch to a human-readable string when printing the device_kind in libxl__get_hotplug_script_info(). Signed-off-by: Jason Andryuk <jandryuk@gmail.com> Reviewed-by: Juergen Gross <jgross@suse.com>
* libxl: device_backend_callback() print rc on errorJason Andryuk2023-04-261-2/+3
| | | | | | | | Print the rc when an error is found in device_backend_callback() so the user can have some idea of why things went wrong. Signed-off-by: Jason Andryuk <jandryuk@gmail.com> Reviewed-by: Juergen Gross <jgross@suse.com>
* x86emul: support AVX-NE-CONVERT insnsJan Beulich2023-04-171-0/+1
| | | | | | | | Matching what was done earlier, explicit tests are added only for irregular insn / memory access patterns. Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
* x86emul: support AVX-VNNI-INT8Jan Beulich2023-04-171-0/+1
| | | | | | | | | | | | | | | These are close relatives of the AVX-VNNI ISA extension. Since the insns here and in particular their memory access patterns follow the usual scheme (and especially the byte variants of AVX-VNNI), I didn't think it was necessary to add a contrived test specifically for them. While making the addition also re-wire AVX-VNNI's handling to simd_0f_ymm: There's no reason to check the AVX feature alongside the one actually of interest (there are a few features where two checks are actually necessary, e.g. GFNI+AVX, but this isn't the case here). Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
* x86emul: support AVX-IFMA insnsJan Beulich2023-04-171-0/+1
| | | | | | | | | | As in a few cases before (in particular: AVX512_IFMA), since the insns here and in particular their memory access patterns follow the usual scheme, I didn't think it was necessary to add a contrived test specifically for them. Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
* tools/libs/guest: Fix build following libx86 changesAndrew Cooper2023-04-051-1/+1
| | | | | | | | I appear to have lost this hunk somewhere... Fixes: 1b67fccf3b02 ("libx86: Update library API for cpu_policy") Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Roger Pau Monné <roger.pau@citrix.com>
* x86: Out-of-inline the policy<->featureset convertorsAndrew Cooper2023-04-051-1/+1
| | | | | | | | | | | | | These are already getting over-large for being inline functions, and are only going to grow further over time. Out of line them, yielding the following net delta from bloat-o-meter: add/remove: 2/0 grow/shrink: 0/4 up/down: 276/-1877 (-1601) Switch to the newer cpu_policy terminology while doing so. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com>
* x86: Drop struct old_cpu_policyAndrew Cooper2023-04-051-3/+1
| | | | | | | | | | | | | With all the complicated callers of x86_cpu_policies_are_compatible() updated to use a single cpu_policy object, we can drop the final user of struct old_cpu_policy. Update x86_cpu_policies_are_compatible() to take (new) cpu_policy pointers, reducing the amount of internal pointer chasing, and update all callers to pass their cpu_policy objects directly. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
* x86: Merge xc_cpu_policy's cpuid and msr objectsAndrew Cooper2023-04-052-21/+20
| | | | | | | | | | | | | | | | | | Right now, they're the same underlying type, containing disjoint information. Use a single object instead. Also take the opportunity to rename 'entries' to 'msrs' which is more descriptive, and more in line with nr_msrs being the count of MSR entries in the API. test-tsx uses xg_private.h to access the internals of xc_cpu_policy, so needs updating at the same time. Take the opportunity to improve the code clarity by passing a cpu_policy rather than an xc_cpu_policy into some functions. No practical change. This undoes the transient doubling of storage space from earlier patches. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
* x86: Rename {domctl,sysctl}.cpu_policy.{cpuid,msr}_policy fieldsAndrew Cooper2023-04-051-6/+6
| | | | | | | | | | | | | | These weren't great names to begin with, and using {leaves,msrs} matches up better with the existing nr_{leaves,msr} parameters anyway. Furthermore, by renaming these fields we can get away with using some #define trickery to avoid the struct {cpuid,msr}_policy merge needing to happen in a single changeset. No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
* x86: Rename struct cpu_policy to struct old_cpuid_policyAndrew Cooper2023-04-051-2/+2
| | | | | | | | | | | | | | We want to merge struct cpuid_policy and struct msr_policy together, and the result wants to be called struct cpu_policy. The current struct cpu_policy, being a pair of pointers, isn't terribly useful. Rename the type to struct old_cpu_policy, but it will disappear entirely once the merge is complete. No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
* x86/monitor: add new monitor event to catch I/O instructionsDmitry Isaykin2023-03-281-0/+13
| | | | | | | | | | | Adds monitor support for I/O instructions. Signed-off-by: Dmitry Isaykin <isaikin-dmitry@yandex.ru> Signed-off-by: Anton Belousov <abelousov@ptsecurity.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Acked-by: Jan Beulich <jbeulich@suse.com> Acked-by: Anthony PERARD <anthony.perard@citrix.com> Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
* tools/migration: Fix iovec handling in send_checkpoint_dirty_pfn_list()Andrew Cooper2023-03-241-19/+6
| | | | | | | | | | | | | | We shouldn't be using two struct iovec's to write half of 'rec' each, and there is no need to malloc() for two struct iovec's at all. Simplify down to just two - one covering the whole of 'rec', and one covering the pfns array. No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> Acked-by: Olaf Hering <olaf@aepfle.de>
* tools/libs/vchan: remove private offsetof() definitionJuergen Gross2023-03-241-4/+1
| | | | | | | | vchan/init.c is defining offsetof privately. Remove that definition and just use stddef.h instead. Signed-off-by: Juergen Gross <jgross@suse.com> Acked-by: Anthony PERARD <anthony.perard@citrix.com>
* tools: get rid of additional min() and max() definitionsJuergen Gross2023-03-241-2/+1
| | | | | | | | | | | | Defining min(), min_t(), max() and max_t() at other places than xen-tools/common-macros.h isn't needed, as the definitions in said header can be used instead. Same applies to BUILD_BUG_ON() in hvmloader. Signed-off-by: Juergen Gross <jgross@suse.com> Acked-by: Jan Beulich <jbeulich@suse.com> Acked-by: Anthony PERARD <anthony.perard@citrix.com>
* tools: use libxenlight for writing xenstore-stubdom console nodesJuergen Gross2023-03-231-0/+23
| | | | | | | | | | | | | | | | Instead of duplicating libxl__device_console_add() work in init-xenstore-domain.c, just use libxenlight. This requires to add a small wrapper function to libxenlight, as libxl__device_console_add() is an internal function. This at once removes a theoretical race between starting xenconsoled and xenstore-stubdom, as the old code wasn't using a single transaction for writing all the entries, leading to the possibility that xenconsoled would see only some of the entries being written. Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
* tools: rename xen-tools/libs.h file to common-macros.hJuergen Gross2023-03-2215-15/+15
| | | | | | | | | | | | | | | In order to better reflect the contents of the header and to make it more appropriate to use it for different runtime environments like programs, libraries, and firmware, rename the libs.h include file to common-macros.h. Additionally add a comment pointing out the need to be self-contained. Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Juergen Gross <jgross@suse.com> Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> # tools/python/xen/lowlevel/xc/xc.c Acked-by: Christian Lindig <christian.lindig@cloud.com> Acked-by: Anthony PERARD <anthony.perard@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com>
* libxl: Fix libxl__device_pci_reset error messagesJason Andryuk2023-03-151-7/+7
| | | | | | | | | | | | | | | | Don't use the LOG*D macros. They expect a domid, but "domain" here is the PCI domain. Hence it is inappropriate for this use. Make the write error messages uniform with LOGE. errno has the interesting information while rc is just -1. Drop printing rc and use LOGE to print errno as text. The interesting part of a failed write to do_flr is that PCI BDF, so print that. Signed-off-by: Jason Andryuk <jandryuk@gmail.com> Reviewed-by: Juergen Gross <jgross@suse.com> Acked-by: Anthony PERARD <anthony.perard@citrix.com>
* xl/libxl: Add OEM string support to smbiosJason Andryuk2023-03-152-2/+15
| | | | | | | | | | | Add support for OEM strings in the SMBIOS type 11. hvmloader checks them sequentially, so hide the implementation detail. Allow multiple plain oem= items and assign the numeric values internally. Signed-off-by: Jason Andryuk <jandryuk@gmail.com> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
* xl/libxl: Add ability to specify SMBIOS stringsJason Andryuk2023-03-152-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | hvm_xs_strings.h specifies xenstore entries which can be used to set or override smbios strings. hvmloader has support for reading them, but xl/libxl support is not wired up. Allow specifying the strings with the new xl.cfg option: smbios=["bios_vendor=Xen Project","system_version=1.0"] In terms of strings, the SMBIOS specification 3.5 says: https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.5.0.pdf """ Strings must be encoded as UTF-8 with no byte order mark (BOM). For compatibility with older SMBIOS parsers, US-ASCII characters should be used. NOTE There is no limit on the length of each individual text string. However, the length of the entire structure table (including all strings) must be reported in the Structure Table Length field of the 32-bit Structure Table Entry Point (see 5.2.1) and/or the Structure Table Maximum Size field of the 64-bit Structure Table Entry Point (see 5.2.2). """ The strings aren't checked for utf-8 or length. hvmloader has a sanity check on the overall length. The libxl_smbios_type enum starts at 1 since otherwise the 0th key is not printed in the json output. Signed-off-by: Jason Andryuk <jandryuk@gmail.com> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
* x86/spec-ctrl: Enumerations for DDP controlsAndrew Cooper2023-03-131-0/+1
| | | | | | | | | | | | https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/technical-documentation/data-dependent-prefetcher.html We should offer DDP-CTRL to guests, but I'm not sure when it is appearing in hardware, and it's not massively urgent - the DDP behaviour is mostly sane (having been designed in a post-spectre world) and this is a just-in-case control. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
* x86/spec-ctrl: Add BHI controls to userspace componentsAndrew Cooper2023-03-131-0/+3
| | | | | | | | This was an oversight when adding the Xen parts. Fixes: cea9ae062295 ("x86/spec-ctrl: Enumeration for new Intel BHI controls") Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
* libs/guest: Fix leak on realloc failure in backup_ptes()Edwin Török2023-02-271-2/+8
| | | | | | | | | | | | | | | | | | From `man 2 realloc`: If realloc() fails, the original block is left untouched; it is not freed or moved. Found using GCC -fanalyzer: | 184 | backup->entries = realloc(backup->entries, | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | | | | | (91) when ‘realloc’ fails | | | (92) ‘old_ptes.entries’ leaks here; was allocated at (44) | | (90) ...to here Signed-off-by: Edwin Török <edwin.torok@cloud.com> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
* libs/guest: Fix resource leaks in xc_core_arch_map_p2m_tree_rw()Andrew Cooper2023-02-271-5/+3
| | | | | | | | | | | | | | Edwin, with the help of GCC's -fanalyzer, identified that p2m_frame_list_list gets leaked. What fanalyzer can't see is that the live_p2m_frame_list_list and live_p2m_frame_list foreign mappings are leaked too. Rework the logic so the out path is executed unconditionally, which cleans up all the intermediate allocations/mappings appropriately. Fixes: bd7a29c3d0b9 ("tools/libs/ctrl: fix xc_core_arch_map_p2m() to support linear p2m table") Reported-by: Edwin Török <edwin.torok@cloud.com> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Juergen Gross <jgross@suse.com>
* tools: Use PKG_CONFIG_FILE instead of PKG_CONFIG variableBertrand Marquis2023-02-242-9/+9
| | | | | | | | | | | | | | | Replace PKG_CONFIG variable name with PKG_CONFIG_FILE for the name of the pkg-config file. This is preventing a conflict in some build systems where PKG_CONFIG actually contains the path to the pkg-config executable to use, as the default assignment in libs.mk is using a weak assignment (?=). This problem has been found when trying to build the latest version of Xen tools using buildroot. Fixes: d400dc5729e4 ("tools: tweak tools/libs/libs.mk for being able to support libxenctrl") Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
* libs: Fix unstable libs build with LLVM, auto-generate version-scriptAnthony PERARD2023-02-161-2/+9
| | | | | | | | | | | | | | Unfortunatly, --default-symver doesn't work with LLVM's LD, LLD. Instead, we will generate a temporary version-script. In order to allow regenerating the script, we'll have a different filename. In order to check if the content is up-to-date, we'll always generated it and compare. Reported-by: Andrew Cooper <andrew.cooper3@citrix.com> Fixes: 98d95437edb6 ("libs: Fix auto-generation of version-script for unstable libs") Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
* x86/shskt: Disable CET-SS on parts susceptible to fractured updatesAndrew Cooper2023-02-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refer to Intel SDM Rev 70 (Dec 2022), Vol3 17.2.3 "Supervisor Shadow Stack Token". Architecturally, an event delivery which starts in CPL<3 and switches shadow stack will first validate the Supervisor Shadow Stack Token (setting the busy bit), then pushes CS/LIP/SSP. One example of this is an NMI interrupting Xen. Some CPUs suffer from an issue called fracturing, whereby a fault/vmexit/etc between setting the busy bit and completing the event injection renders the action non-restartable, because when it comes time to restart, the busy bit is found to be already set. This is far more easily encountered under virt, yet it is not the fault of the hypervisor, nor the fault of the guest kernel. The fault lies somewhere between the architectural specification, and the uarch behaviour. Intel have allocated CPUID.7[1].ecx[18] CET_SSS to enumerate that supervisor shadow stacks are safe to use. Because of how Xen lays out its shadow stacks, fracturing is not expected to be a problem on native. Detect this case on boot and default to not using shstk if virtualised. Specifying `cet=shstk` on the command line will override this heuristic and enable shadow stacks irrespective. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
* libs/util: Fix parallel build between flex/bison and CC rulesAnthony PERARD2023-02-091-0/+8
| | | | | | | | | | | | | | | | | | | flex/bison generate two targets, and when those targets are prerequisite of other rules they are considered independently by make. We can have a situation where the .c file is out-of-date but not the .h, git checkout for example. In this case, if a rule only have the .h file as prerequiste, make will procced and start to build the object. In parallel, another target can have the .c file as prerequisite and make will find out it need re-generating and do so, changing the .h at the same time. This parallel task breaks the first one. To avoid this scenario, we put both the header and the source as prerequisite for all object even if they only need the header. Reported-by: Andrew Cooper <Andrew.Cooper3@citrix.com> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
* libs/util: Remove unused headers in libxlu_pci.cAnthony PERARD2023-02-091-3/+0
| | | | | | | | | libxlu_pci.c doesn't use any "xlu__cfg*()" functions and doesn't use any of the disk parsing functions "xlu__disk*()", so all those headers can be removed. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
* libs/light: Makefile cleanupAnthony PERARD2023-02-082-10/+8
| | | | | | | | | | | | | Rework "libacpi.h" include in "libxl_x86_acpi.c" as to be more selective about the include path and only add "tools/libacpi/". Also "libxl_dom.c" don't use "libacpi.h" anymore. Use "-iquote" for libacpi headers. Get rid of the weird "$(eval stem =" in the middle of a recipe and use a make automatic variable "$(*F)" instead. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Reviewed-by: Juergen Gross <jgross@suse.com>
* libs/light: Rework targets prerequisitesAnthony PERARD2023-02-081-12/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | No need for $(AUTOSRCS), GNU make can generate them as needed when trying to build them as needed when trying to build the object. Also, those two AUTOSRCS don't need to be a prerequisite of "all". As for the "clean" target, those two files are already removed via "_*.c". We don't need $(AUTOINCS) either: - As for both _libxl_save_msgs*.h headers, we are adding more selective dependencies so the headers will still be generated as needed. - "clean" rule already delete the _*.h files, so AUTOINCS aren't needed there. "libxl_internal_json.h" doesn't seems to have ever existed, so the dependency is removed. Rework objects prerequisites, to have them dependents on either "libxl.h" or "libxl_internal.h". "libxl.h" is not normally included directly in the source code as "libxl_internal.h" is used instead, but we have "libxl.h" as prerequisite of "libxl_internal.h", so generated headers will still be generated as needed. Make doesn't need "libxl.h" to generate "testidl.c", "libxl.h" is only needed later when building "testidl.o". This avoid the need to regenerate "testidl.c" when only "libxl.h" changed. Also use automatic variables $< and $@. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Reviewed-by: Juergen Gross <jgross@suse.com>
* libxl/x86: use public interface TSC mode definitionsJan Beulich2023-02-071-3/+4
| | | | | | | | | | | | Now that they're properly represented in the public interface, stop using literal numbers. No functional change intended. Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Juergen Gross <jgross@suse.com> Acked-by: Anthony PERARD <anthony.perard@citrix.com>
* libs: Fix auto-generation of version-script for unstable libsAnthony PERARD2023-02-0716-20/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | When there isn't a version-script for a shared library (like for unstable libs), we create one based on the current Xen version. But that version-script became out-of-date as soon as Xen's version changes and make as no way to regenerate the version-script on rebuild. For unstable libs, we only needs the symver to be different from a previous release of Xen. There's an option "--default-symver" which allow to use the soname as symver and as the soname have the Xen release version, it will be different for every release. With --default-symver we don't need to generate a version-script. But we also need to know if there's already an existing version script , for that we introduce $(version-script) to be used to point to the path of the existing script. (Guessing if a version script exist for a stable library with for example $(wildcard) won't work as a file will exist when building the library without this patch.) We don't need the version-script unless we are making the shared library so it is removed from the "all" target. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
* libxl: fix guest kexec - skip cpuid policyJason Andryuk2023-01-263-1/+4
| | | | | | | | | | | | | | | | | | | | | When a domain performs a kexec (soft reset), libxl__build_pre() is called with the existing domid. Calling libxl__cpuid_legacy() on the existing domain fails since the cpuid policy has already been set, and the guest isn't rebuilt and doesn't kexec. xc: error: Failed to set d1's policy (err leaf 0xffffffff, subleaf 0xffffffff, msr 0xffffffff) (17 = File exists): Internal error libxl: error: libxl_cpuid.c:494:libxl__cpuid_legacy: Domain 1:Failed to apply CPUID policy: File exists libxl: error: libxl_create.c:1641:domcreate_rebuild_done: Domain 1:cannot (re-)build domain: -3 libxl: error: libxl_xshelp.c:201:libxl__xs_read_mandatory: xenstore read failed: `/libxl/1/type': No such file or directory libxl: warning: libxl_dom.c:49:libxl__domain_type: unable to get domain type for domid=1, assuming HVM During a soft_reset, skip calling libxl__cpuid_legacy() to avoid the issue. Before commit 34990446ca91, the libxl__cpuid_legacy() failure would have been ignored, so kexec would continue. Fixes: 34990446ca91 ("libxl: don't ignore the return value from xc_cpuid_apply_policy") Signed-off-by: Jason Andryuk <jandryuk@gmail.com> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
* x86: Initial support for WRMSRNSAndrew Cooper2023-01-201-0/+1
| | | | | | | | | | | WRMSR Non-Serialising is an optimisation intended for cases where an MSR needs updating, but architectural serialising properties are not needed. In is anticipated that this will apply to most if not all MSRs modified on context switch paths. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
* x86/prot-key: Enumeration for Protection Key SupervisorAndrew Cooper2023-01-201-0/+1
| | | | | | | | | | | | | | Protection Key Supervisor works in a very similar way to Protection Key User, except that instead of a PKRU register used by the {RD,WR}PKRU instructions, the supervisor protection settings live in MSR_PKRS and is accessed using normal {RD,WR}MSR instructions. PKS has the same problematic interactions with PV guests as PKU (more infact, given the guest kernel's CPL), so we'll only support this for HVM guests for now. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
* tools/libxl: Fix virtio build error for 32-bit platformsViresh Kumar2022-12-151-2/+2
| | | | | | | | | | | | | | | | | | | The field 'base' in 'struct libxl_device_virtio' is defined as uint64, while we are printing it with '%lu', which is 32bit only 32-bit platforms. And so generates a error like: libxl_internal.h:4388:51: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'uint64_t' {aka 'long long unsigned int'} [-Werror=format=] Fix it by switching to a 64bit PRI instead. While fixing this, switch from decimal to hex which is the more natural base to use for a field like this. Fixes: 43ba5202e2ee ("libxl: add support for generic virtio device") Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
* libxl: add support for generic virtio deviceViresh Kumar2022-12-147-0/+274
| | | | | | | | | | | | | | | | | | | | | | | | | This patch adds basic support for configuring and assisting generic Virtio backends, which could run in any domain. An example of domain configuration for mmio based Virtio I2C device is: virtio = ["type=virtio,device22,transport=mmio"] To make this work on Arm, allocate Virtio MMIO params (IRQ and memory region) and pass them to the backend and update guest device-tree to create a DT node for the Virtio devices. Add special support for I2C and GPIO devices, which require the "compatible" DT property to be set, among other device specific properties. Support for generic virtio devices is also added, which just need a MMIO node but not any special DT properties, for such devices the user needs to pass "virtio,device" in the "type" string. The parsing of generic virtio device configurations will be done in a separate commit. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com> Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
* libxl: abort on memory allocation errorsMarek Marczykowski-Górecki2022-12-131-1/+1
| | | | | | | | | | | Use abort() instead of just _exit() in libxl__alloc_failed(). This is more friendly for debugging, as it will trap into debugger, systemd-coredump will collect coredump/backtrace etc. It's much more useful than just "libxl: FATAL ERROR: memory allocation failure (...)" message without context where it actually failed. Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> Acked-by: Anthony PERARD <anthony.perard@citrix.com>
* libxl: arm: make creation of iommu node independent of disk deviceViresh Kumar2022-12-061-7/+10
| | | | | | | | | | | | | The iommu node will be required for other virtio device types too, not just disk device. Move the call to make_xen_iommu_node(), out of the disk device specific block and rename "iommu_created" variable to "iommu_needed", and set it to true for virtio disk device. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com> Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>