[PATCH v6 06/12] libs/guest: make a cpu policy compatible with older Xen versions

2022-01-17 Thread Roger Pau Monne
Older Xen versions used to expose some CPUID bits which are no longer exposed by default. In order to keep a compatible behavior with guests migrated from versions of Xen that don't encode the CPUID data on the migration stream introduce a function that sets the same bits as older Xen versions.

[PATCH v6 05/12] libs/guest: allow fetching a specific MSR entry from a cpu policy

2022-01-17 Thread Roger Pau Monne
Introduce an interface that returns a specific MSR entry from a cpu policy in xen_msr_entry_t format. This is useful to callers can peek data from the opaque xc_cpu_policy_t type. No caller of the interface introduced on this patch. Signed-off-by: Roger Pau Monné --- Changes since v3: - Use

[PATCH v6 04/12] libx86: introduce helper to fetch msr entry

2022-01-17 Thread Roger Pau Monne
Use such helper in order to replace the code in x86_msr_copy_from_buffer. Note the introduced helper should not be directly called and instead x86_msr_get_entry should be used that will properly deal with const and non-const inputs. Note this requires making the raw fields uint64_t so that it can

[PATCH v6 03/12] libs/guest: allow fetching a specific CPUID leaf from a cpu policy

2022-01-17 Thread Roger Pau Monne
Introduce an interface that returns a specific leaf/subleaf from a cpu policy in xen_cpuid_leaf_t format. This is useful to callers can peek data from the opaque xc_cpu_policy_t type. No caller of the interface introduced on this patch. Signed-off-by: Roger Pau Monné --- Changes since v5: -

[PATCH v6 02/12] libx86: introduce helper to fetch cpuid leaf

2022-01-17 Thread Roger Pau Monne
Introduce a helper based on the current Xen guest_cpuid code in order to fetch a cpuid leaf from a policy. The newly introduced function in cpuid.c should not be directly called and instead the provided x86_cpuid_get_leaf macro should be used that will properly deal with const and non-const

[PATCH v6 01/12] libs/guest: move cpu policy related prototypes to xenguest.h

2022-01-17 Thread Roger Pau Monne
Do this before adding any more stuff to xg_cpuid_x86.c. The placement in xenctrl.h is wrong, as they are implemented by the xenguest library. Note that xg_cpuid_x86.c needs to include xg_private.h, and in turn also fix xg_private.h to include xc_bitops.h. The bitops definition of BITS_PER_LONG

[PATCH v6 00/12] libs/guest: new CPUID/MSR interface

2022-01-17 Thread Roger Pau Monne
. Thanks, Roger. Jan Beulich (1): x86/CPUID: shrink max_{,sub}leaf fields according to actual leaf contents Roger Pau Monne (11): libs/guest: move cpu policy related prototypes to xenguest.h libx86: introduce helper to fetch cpuid leaf libs/guest: allow fetching a specific CPUID leaf

[PATCH v5 07/12] libs/guest: introduce helper set cpu topology in cpu policy

2021-11-29 Thread Roger Pau Monne
This logic is pulled out from xc_cpuid_apply_policy and placed into a separate helper. Note the legacy part of the introduced function, as long term Xen will require a proper topology setter function capable of expressing a more diverse set of topologies. No functional change intended.

[PATCH v5 10/12] libs/{light,guest}: implement xc_cpuid_apply_policy in libxl

2021-11-29 Thread Roger Pau Monne
With the addition of the xc_cpu_policy_* now libxl can have better control over the cpu policy, this allows removing the xc_cpuid_apply_policy function and instead coding the required bits by libxl in libxl__cpuid_legacy directly. Remove xc_cpuid_apply_policy. Signed-off-by: Roger Pau Monné

[PATCH v5 12/12] x86/CPUID: shrink max_{,sub}leaf fields according to actual leaf contents

2021-11-29 Thread Roger Pau Monne
From: Jan Beulich Zapping leaf data for out of range leaves is just one half of it: To avoid guests (bogusly or worse) inferring information from mere leaf presence, also shrink maximum indicators such that the respective trailing entry is not all blank (unless of course it's the initial subleaf

[PATCH v5 11/12] libs/guest: (re)move xc_cpu_policy_apply_cpuid

2021-11-29 Thread Roger Pau Monne
Move the logic from xc_cpu_policy_apply_cpuid into libxl, now that the xc_cpu_policy_* helpers allow modifying a cpu policy. By moving such parsing into libxl directly we can get rid of xc_xend_cpuid, as libxl will now implement it's own private type for storing CPUID information, which currently

[PATCH v5 08/12] libs/guest: rework xc_cpuid_xend_policy

2021-11-29 Thread Roger Pau Monne
Rename xc_cpuid_xend_policy to xc_cpu_policy_apply_cpuid and make it public. Modify the function internally to use the new xc_cpu_policy_* set of functions. Also don't apply the passed policy to a domain directly, and instead modify the provided xc_cpu_policy_t. The caller will be responsible of

[PATCH v5 09/12] libs/guest: apply a featureset into a cpu policy

2021-11-29 Thread Roger Pau Monne
Pull out the code from xc_cpuid_apply_policy that applies a featureset to a cpu policy and place it on it's own standalone function that's part of the public interface. No functional change intended. Signed-off-by: Roger Pau Monné --- tools/include/xenguest.h| 5 ++

[PATCH v5 05/12] libs/guest: allow fetching a specific MSR entry from a cpu policy

2021-11-29 Thread Roger Pau Monne
Introduce an interface that returns a specific MSR entry from a cpu policy in xen_msr_entry_t format. This is useful to callers can peek data from the opaque xc_cpu_policy_t type. No caller of the interface introduced on this patch. Signed-off-by: Roger Pau Monné --- Changes since v3: - Use

[PATCH v5 06/12] libs/guest: make a cpu policy compatible with older Xen versions

2021-11-29 Thread Roger Pau Monne
Older Xen versions used to expose some CPUID bits which are no longer exposed by default. In order to keep a compatible behavior with guests migrated from versions of Xen that don't encode the CPUID data on the migration stream introduce a function that sets the same bits as older Xen versions.

[PATCH v5 04/12] libx86: introduce helper to fetch msr entry

2021-11-29 Thread Roger Pau Monne
Use such helper in order to replace the code in x86_msr_copy_from_buffer. Note the introduced helper should not be directly called and instead x86_msr_get_entry should be used that will properly deal with const and non-const inputs. Note this requires making the raw fields uint64_t so that it can

[PATCH v5 03/12] libs/guest: allow fetching a specific CPUID leaf from a cpu policy

2021-11-29 Thread Roger Pau Monne
Introduce an interface that returns a specific leaf/subleaf from a cpu policy in xen_cpuid_leaf_t format. This is useful to callers can peek data from the opaque xc_cpu_policy_t type. No caller of the interface introduced on this patch. Note that callers of find_leaf need to be slightly

[PATCH v5 02/12] libx86: introduce helper to fetch cpuid leaf

2021-11-29 Thread Roger Pau Monne
Introduce a helper based on the current Xen guest_cpuid code in order to fetch a cpuid leaf from a policy. The newly introduced function in cpuid.c should not be directly called and instead the provided x86_cpuid_get_leaf macro should be used that will properly deal with const and non-const

[PATCH v5 01/12] libs/guest: move cpu policy related prototypes to xenguest.h

2021-11-29 Thread Roger Pau Monne
Do this before adding any more stuff to xg_cpuid_x86.c. The placement in xenctrl.h is wrong, as they are implemented by the xenguest library. Note that xg_cpuid_x86.c needs to include xg_private.h, and in turn also fix xg_private.h to include xc_bitops.h. The bitops definition of BITS_PER_LONG

[PATCH v5 00/12] libs/guest: new CPUID/MSR interface

2021-11-29 Thread Roger Pau Monne
. Thanks, Roger. Jan Beulich (1): x86/CPUID: shrink max_{,sub}leaf fields according to actual leaf contents Roger Pau Monne (11): libs/guest: move cpu policy related prototypes to xenguest.h libx86: introduce helper to fetch cpuid leaf libs/guest: allow fetching a specific CPUID leaf

[PATCH] osstest: enable timestamp on guests logs

2021-11-25 Thread Roger Pau Monne
Enable the timestamp feature of xenconsoled so guests logs have a time reference. Can be helpful when debugging boot related slowness. This requires using the XENCONSOLED_ARGS option and setting both the log and the timestamp options. Note that setting XENCONSOLED_TRACE will override any options

[PATCH for-4.16] x86/cpuid: do not shrink number of leaves in max policies

2021-11-24 Thread Roger Pau Monne
Shrinking max policies can lead to failures in migration as previous versions of Xen didn't shrink the number of leaves in any case, so it's possible for a guest created on previous versions of Xen that pass CPUID data on the migration stream to contain a max leaf number greatest than the one

[PATCH for-4.16 v4] CHANGELOG: add missing entries for work during the 4.16 release cycle

2021-11-24 Thread Roger Pau Monne
Document some of the relevant changes during the 4.16 release cycle. Signed-off-by: Roger Pau Monné Release-Acked-by: Ian Jackson --- Changes since v3: - Remove a duplicated line about not building qemu-trad and pv-grub. Changes since v2: - Reword the x86 page table API change. Changes

[PATCH for-4.16 v3] CHANGELOG: add missing entries for work during the 4.16 release cycle

2021-11-23 Thread Roger Pau Monne
Document some of the relevant changes during the 4.16 release cycle. Signed-off-by: Roger Pau Monné Release-Acked-by: Ian Jackson --- Changes since v2: - Reword the x86 page table API change. Changes since v1: - Add qemu-traditional and pvgrub notes. - Expand vPMU support to note it's

[PATCH for-4.16 v2] CHANGELOG: add missing entries for work during the 4.16 release cycle

2021-11-22 Thread Roger Pau Monne
Document some of the relevant changes during the 4.16 release cycle. Signed-off-by: Roger Pau Monné Release-Acked-by: Ian Jackson --- Changes since v1: - Add qemu-traditional and pvgrub notes. - Expand vPMU support to note it's limited. - xenstore library API changes. - xencall2L addition.

[PATCH for-4.16 v2] efi: fix alignment of function parameters in compat mode

2021-11-18 Thread Roger Pau Monne
Currently the max_store_size, remain_store_size and max_size in compat_pf_efi_runtime_call are 4 byte aligned, which makes clang 13.0.0 complain with: In file included from compat.c:30: ./runtime.c:646:13: error: passing 4-byte aligned argument to 8-byte aligned parameter 2 of

[PATCH for-4.16] efi: fix alignment of function parameters in compat mode

2021-11-17 Thread Roger Pau Monne
Currently the max_store_size, remain_store_size and max_size in compat_pf_efi_runtime_call are 4 byte aligned, which makes clang complain with: In file included from compat.c:30: ./runtime.c:646:13: error: passing 4-byte aligned argument to 8-byte aligned parameter 2 of 'QueryVariableInfo' may

[PATCH for-4.16] MAINTAINERS: declare REMUS support orphaned

2021-11-17 Thread Roger Pau Monne
The designated maintainer email address for the remus entry is bouncing, so remove it and declare the entry as orphaned as there's no other maintainer. Signed-off-by: Roger Pau Monné --- MAINTAINERS | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS

[PATCH for-4.16 2/2] CHANGELOG: add missing entries for work during the 4.16 release cycle

2021-11-17 Thread Roger Pau Monne
Document some of the relevant changes during the 4.16 release cycle, likely more entries are missing. Signed-off-by: Roger Pau Monné --- CHANGELOG.md | 11 +++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad1a8c2bc2..8b0bdd9cf0 100644 ---

[PATCH for-4.16 0/2] CHANGELOG: start to populate entries for 4.16

2021-11-17 Thread Roger Pau Monne
Hello, The following changes are preparation work for the 4.16 release. This is my first pass at the log for the release, it's likely missing more entries. I'm Ccing all maintainers in this cover letter and also in patch #2 for further feedback on missing items. Thanks, Roger. Roger Pau Monne

[PATCH for-4.16 1/2] CHANGELOG: set Xen 4.15 release date

2021-11-17 Thread Roger Pau Monne
Signed-off-by: Roger Pau Monné --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5ab49e779..ad1a8c2bc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ The format is based on [Keep a

[PATCH for-4.16] CHANGELOG: set Xen 4.15 release date

2021-11-16 Thread Roger Pau Monne
Signed-off-by: Roger Pau Monné --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5ab49e779..7f3114a96c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ The format is based on [Keep a

[PATCH for-4.16 4/4] tools/python: fix python libxc bindings to pass a max grant version

2021-11-15 Thread Roger Pau Monne
Such max version should be provided by the caller, otherwise the bindings will default to specifying a max version of 2, which is inline with the current defaults in the hypervisor. Fixes: 7379f9e10a ('gnttab: allow setting max version per-domain') Signed-off-by: Roger Pau Monné --- Cc: Ian

[PATCH for-4.16 3/4] test/tsx: set grant version for created domains

2021-11-15 Thread Roger Pau Monne
Set the grant table version for the created domains to use version 1, as such tests domains don't require the usage of the grant table at all. A TODO note is added to switch those dummy domains to not have a grant table at all when possible. Without setting the grant version the domains for the

[PATCH for-4.16 2/4] tests/resource: set grant version for created domains

2021-11-15 Thread Roger Pau Monne
Set the grant table version for the created domains to use version 1, as that's the used by the test cases. Without setting the grant version the domains for the tests cannot be created. Fixes: 7379f9e10a ('gnttab: allow setting max version per-domain') Reported-by: Andrew Cooper Signed-off-by:

[PATCH for-4.16 0/4] gnttab: fallout/improvements from max version

2021-11-15 Thread Roger Pau Monne
for the release, or else we need to revert the grant table version per domain change. Thanks, Roger. Roger Pau Monne (4): domctl: introduce a macro to set the grant table max version tests/resource: set grant version for created domains test/tsx: set grant version for created domains tools

[PATCH for-4.16 1/4] domctl: introduce a macro to set the grant table max version

2021-11-15 Thread Roger Pau Monne
Such macro just clamps the passed version to fit in the designated bits of the domctl field. The main purpose is to make it clearer in the code when max grant version is being set in the grant_opts field. Existing users that where setting the version in the grant_opts field are switched to use

[PATCH for-4.16] freebsd/privcmd: fix MMAP_RESOURCE ioctl definition

2021-11-15 Thread Roger Pau Monne
Current ioctl definition was wrong in both FreeBSD and Xen sources, as the MMAP_RESOURCE ioctl needs to copy back the size of the resource when passed a zero address and size. FreeBSD encodes in the definition of the ioctl number whether parameters should be copied in (W) and/or copied out (R).

[PATCH for-4.16] tests/resource: set grant version for created domains

2021-11-15 Thread Roger Pau Monne
Set the grant table version for the created domains to use version 1, as that's the used by the test cases. Without setting the grant version the domains for the tests cannot be created. Fixes: 7379f9e10a ('gnttab: allow setting max version per-domain') Reported-by: Andrew Cooper Signed-off-by:

[PATCH for-4.16 v2] Revert "domctl: improve locking during domain destruction"

2021-11-12 Thread Roger Pau Monne
This reverts commit 228ab9992ffb1d8f9d2475f2581e68b2913acb88. Performance analysis has shown that dropping the domctl lock during domain destruction greatly increases the contention in the heap_lock, thus making parallel destruction of domains slower. The following lockperf data shows the

[PATCH for-4.16] x86/cpuid: prevent shrinking migrated policies max leaves

2021-11-10 Thread Roger Pau Monne
CPUID policies from guest being migrated shouldn't have the maximum leaves shrink, as that would be a guest visible change. The hypervisor has no knowledge on whether a guest has been migrated or is build from scratch, and hence it must not blindly shrink the CPUID policy in

[PATCH for-4.16] Revert "domctl: improve locking during domain destruction"

2021-11-09 Thread Roger Pau Monne
This reverts commit 228ab9992ffb1d8f9d2475f2581e68b2913acb88. Performance analysis has shown that dropping the domctl lock during domain destruction greatly increases the contention in the heap_lock, thus making parallel destruction of domains slower. The following lockperf data shows the

[PATCH for-4.16] tools/configure: make iPXE dependent on QEMU traditional

2021-11-09 Thread Roger Pau Monne
iPXE is only used by QEMU traditional, so make it off by default unless QEMU traditional is enabled. Reported-by: Andrew Cooper Fixes: bcf77ce510 ('configure: modify default of building rombios') Signed-off-by: Roger Pau Monné --- Cc: Ian Jackson Please run autoconf before commit. Without

[PATCH for-4.16 v6] gnttab: allow setting max version per-domain

2021-11-04 Thread Roger Pau Monne
Introduce a new domain create field so that toolstack can specify the maximum grant table version usable by the domain. This is plumbed into xl and settable by the user as max_grant_version. Previously this was only settable on a per host basis using the gnttab command line option. Note the

[PATCH for-4.16 v5] gnttab: allow setting max version per-domain

2021-11-03 Thread Roger Pau Monne
Introduce a new domain create field so that toolstack can specify the maximum grant table version usable by the domain. This is plumbed into xl and settable by the user as max_grant_version. Previously this was only settable on a per host basis using the gnttab command line option. Note the

[PATCH for-4.16 v4] gnttab: allow setting max version per-domain

2021-10-29 Thread Roger Pau Monne
Introduce a new domain create field so that toolstack can specify the maximum grant table version usable by the domain. This is plumbed into xl and settable by the user as max_grant_version. Previously this was only settable on a per host basis using the gnttab command line option. Note the

[PATCH for-4.16 v3] gnttab: allow setting max version per-domain

2021-10-28 Thread Roger Pau Monne
Introduce a new domain create field so that toolstack can specify the maximum grant table version usable by the domain. This is plumbed into xl and settable by the user as max_grant_version. Previously this was only settable on a per host basis using the gnttab command line option. Note the

[PATCH] x86/cpuid: prevent decreasing of hypervisor max leaf on migration

2021-10-27 Thread Roger Pau Monne
In order to be compatible with previous Xen versions, and not change max hypervisor leaf as a result of a migration, keep the clamping of the maximum leaf value provided to XEN_CPUID_MAX_NUM_LEAVES, instead of doing it based on the domain type. Also set the default maximum leaf without taking the

[PATCH] x86/hpet: setup HPET even when disabled due to stopping in deep C states

2021-10-26 Thread Roger Pau Monne
Always allow the HPET to be setup, but don't report a frequency back to the platform time source probe in order to avoid it from being selected as a valid timer if it's not usable. Doing the setup even when not intended to be used as a platform timer is required so that is can be used in legacy

[PATCH v2 3/6] gnttab: allow per-domain control over transitive grants

2021-09-22 Thread Roger Pau Monne
Introduce a new grant options flags field in domain create and use it to signal whether transitive grants are allowed on the domain. This is settable from xl using the transitive_grants option. Signed-off-by: Roger Pau Monné --- docs/man/xl.cfg.5.pod.in| 6 ++

[PATCH v2 6/6] gnttab: allow disabling grant table per-domain

2021-09-22 Thread Roger Pau Monne
Allow setting max_grant_version to 0 in order to disable grant table usage by a domain. This prevents allocating the grant-table structure inside of Xen and requires guards to be added in several functions in order to prevent dereferencing the structure. Note that a domain without a grant table

[PATCH v2 5/6] tools/xenstored: partially handle domains without a shared ring

2021-09-22 Thread Roger Pau Monne
Failure to map the shared ring and thus establish a xenstore connection with a domain shouldn't prevent the "@introduceDomain" watch from firing, likewise with "@releaseDomain". In order to handle such events properly xenstored should keep track of the domains even if the shared communication

[PATCH v2 4/6] tools/xenstored: use atexit to close interfaces

2021-09-22 Thread Roger Pau Monne
Exploiting the talloc clean up routines to close the Xen interfaces is cumbersome, specially when atexit can be used to the same effect. Convert xc and gnttab to use atexit which allows to drop one indirection from the storing variables. While there also close the event channel interface. No

[PATCH v2 2/6] gnttab: allow setting max version per-domain

2021-09-22 Thread Roger Pau Monne
Introduce a new domain create field so that toolstack can specify the maximum grant table version usable by the domain. This is plumbed into xl and settable by the user as max_grant_version. Previously this was only settable on a per host basis using the gnttab command line option. Note the

[PATCH v2 1/6] tools/console: use xenforeigmemory to map console ring

2021-09-22 Thread Roger Pau Monne
This patch replaces the usage of xc_map_foreign_range with xenforeignmemory_map from the stable xenforeignmemory library. Note there are still other uses of libxc functions which prevents removing the dependency. No functional change intended. Signed-off-by: Roger Pau Monné Reviewed-by: Ian

[PATCH v2 0/6] gnttab: add per-domain controls

2021-09-22 Thread Roger Pau Monne
. Thanks, Roger. Roger Pau Monne (6): tools/console: use xenforeigmemory to map console ring gnttab: allow setting max version per-domain gnttab: allow per-domain control over transitive grants tools/xenstored: use atexit to close interfaces tools/xenstored: partially handle domains

[PATCH 6/6] gnttab: allow disabling grant table per-domain

2021-09-17 Thread Roger Pau Monne
Allow setting max_grant_version to 0 in order to disable grant table usage by a domain. This prevents allocating the grant-table structure inside of Xen and requires guards to be added in several functions in order to prevent dereferencing the structure. Note that a domain without a grant table

[PATCH DNA 5/6] tools/xenstored: restore support for mapping ring as foreign memory

2021-09-17 Thread Roger Pau Monne
Restore the previous way of mapping the xenstore ring using foreign memory. Use xenforeignmemory instead of libxc in order to avoid adding another dependency on a unstable interface. This in turn requires storing the gfn into xs_state_connection for resume purposes, which breaks the current

[PATCH 4/6] tools/xenstored: use atexit to close interfaces

2021-09-17 Thread Roger Pau Monne
Exploiting the talloc clean up routines to close the Xen interfaces is cumbersome, specially when atexit can be used to the same effect. Convert xc and gnttab to use atexit which allows to drop one indirection from the storing variables. No functional change intended. Signed-off-by: Roger Pau

[PATCH 1/6] gnttab: allow setting max version per-domain

2021-09-17 Thread Roger Pau Monne
Introduce a new domain create field so that toolstack can specify the maximum grant table version usable by the domain. This is plumbed into xl and settable by the user as max_grant_version. Previously this was only settable on a per host basis using the gnttab command line option.

[PATCH 3/6] tools/console: use xenforeigmemory to map console ring

2021-09-17 Thread Roger Pau Monne
This patch replaces the usage of xc_map_foreign_range with xenforeignmemory_map from the stable xenforeignmemory library. Note there are still other uses of libxc functions which prevents removing the dependency. No functional change intended. Signed-off-by: Roger Pau Monné ---

[PATCH 2/6] gnttab: allow per-domain control over transitive grants

2021-09-17 Thread Roger Pau Monne
Introduce a new grant options flags field in domain create and use it to signal whether transitive grants are allowed on the domain. This is settable from xl using the transitive_grants option. Signed-off-by: Roger Pau Monné --- docs/man/xl.cfg.5.pod.in| 6 ++

[PATCH 0/6] gnttab: add per-domain controls

2021-09-17 Thread Roger Pau Monne
guests without grant table support at all. This requires some changes to xenstore in order to map shared ring using foreign memory instead of grant table. Note that patch 5 will break the save format for xenstore records, and should not be applied. Thanks, Roger. Roger Pau Monne (6): gnttab

[PATCH] x86: quote section names when defining them in linker script

2021-09-15 Thread Roger Pau Monne
LLVM ld seems to require section names to be quoted at both definition and when referencing them for a match to happen, or else we get the following errors: ld: error: xen.lds:45: undefined section ".text" ld: error: xen.lds:69: undefined section ".rodata" ld: error: xen.lds:104: undefined

[PATCH v2] x86/p2m: fix xenmem_add_to_physmap_one double page removal

2021-09-15 Thread Roger Pau Monne
If the new gfn matches the previous one (ie: gpfn == old_gpfn) xenmem_add_to_physmap_one will issue a duplicated call to guest_physmap_remove_page with the same guest frame number, because the get_gpfn_from_mfn call has been moved by commit f8582da041 to be performed before the original page is

[PATCH] x86/p2m: fix xenmem_add_to_physmap_one double page removal

2021-09-14 Thread Roger Pau Monne
If the new gfn matches the previous one (ie: gfn == old_gpfn) xenmem_add_to_physmap_one will issue a duplicated call to guest_physmap_remove_page with the same gfn, because the get_gpfn_from_mfn call has been moved by commit f8582da041 to be performed before the original page is removed. This

[PATCH] tools/go: honor append build flags

2021-07-07 Thread Roger Pau Monne
Make the go build use APPEND_{C/LD}FLAGS when necessary, just like other parts of the build. Reported-by: Ting-Wei Lan Signed-off-by: Roger Pau Monné --- Note sure if it's the best way to add the appended flags, I'm not familiar with the go build system. In any case this fixes the build when

[PATCH 3/3] x86/ept: force WB cache attributes for grant and foreign maps

2021-05-28 Thread Roger Pau Monne
Force WB type for grants and foreign pages. Those are usually mapped over unpopulated physical ranges in the p2m, and those ranges would usually be UC in the MTRR state, which is unlikely to be the correct cache attribute. It's also cumbersome (or even impossible) for the guest to be setting the

[PATCH 2/3] x86/mtrr: move epte_get_entry_emt to p2m-ept.c

2021-05-28 Thread Roger Pau Monne
This is an EPT specific function, so it shouldn't live in the generic mtrr file. Such movement is also needed for future work that will require passing a p2m_type_t parameter to epte_get_entry_emt, and making that type visible to the mtrr users is cumbersome and unneeded. Moving

[PATCH 1/3] x86/mtrr: remove stale function prototype

2021-05-28 Thread Roger Pau Monne
Fixes: 1c84d04673 ('VMX: remove the problematic set_uc_mode logic') Signed-off-by: Roger Pau Monné --- xen/include/asm-x86/mtrr.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/xen/include/asm-x86/mtrr.h b/xen/include/asm-x86/mtrr.h index 4be704cb6a..24e5de5c22 100644 ---

[PATCH 0/3] x86/ept: force WB to foreign and grant mappings

2021-05-28 Thread Roger Pau Monne
the correct MTRR attributes is also unlikely, because the number of MTRR ranges is finite. Roger Pau Monne (3): x86/mtrr: remove stale function prototype x86/mtrr: move epte_get_entry_emt to p2m-ept.c x86/ept: force WB cache attributes for grant and foreign maps xen/arch/x86/hvm/mtrr.c

[PATCH v3 1/2] libelf: don't attempt to parse __xen_guest for PVH

2021-05-20 Thread Roger Pau Monne
The legacy __xen_guest section doesn't support the PHYS32_ENTRY elfnote, so it's pointless to attempt to parse the elfnotes from that section when called from an hvm container. Suggested-by: Jan Beulich Signed-off-by: Roger Pau Monné --- Changes since v2: - New in this version. ---

[PATCH v3 2/2] libelf: improve PVH elfnote parsing

2021-05-20 Thread Roger Pau Monne
Pass an hvm boolean parameter to the elf note parsing and checking routines, so that better checking can be done in case libelf is dealing with an hvm container. elf_xen_note_check shouldn't return early unless PHYS32_ENTRY is set and the container is of type HVM, or else the loader and version

[PATCH v3 0/2] libelf: small fixes for PVH

2021-05-20 Thread Roger Pau Monne
to perform the bound calculations. Thanks, Roger. Roger Pau Monne (2): libelf: don't attempt to parse __xen_guest for PVH libelf: improve PVH elfnote parsing tools/fuzz/libelf/libelf-fuzzer.c | 3 +- tools/libs/guest/xg_dom_elfloader.c | 6 ++-- tools/libs/guest/xg_dom_hvmloader.c | 2

[PATCH v2] libelf: improve PVH elfnote parsing

2021-05-18 Thread Roger Pau Monne
Pass an hvm boolean parameter to the elf note parsing and checking routines, so that better checking can be done in case libelf is dealing with an hvm container. elf_xen_note_check shouldn't return early unless PHYS32_ENTRY is set and the container is of type HVM, or else the loader and version

[PATCH] libelf: improve PVH elfnote parsing

2021-05-14 Thread Roger Pau Monne
Pass an hvm boolean parameter to the elf note parsing and checking routines, so that better checking can be done in case libelf is dealing with an hvm container. elf_xen_note_check shouldn't return early unless PHYS32_ENTRY is set and the container is of type HVM, or else the loader and version

[PATCH v4 09/10] libs/{light,guest}: implement xc_cpuid_apply_policy in libxl

2021-05-07 Thread Roger Pau Monne
With the addition of the xc_cpu_policy_* now libxl can have better control over the cpu policy, this allows removing the xc_cpuid_apply_policy function and instead coding the required bits by libxl in libxl__cpuid_legacy directly. Remove xc_cpuid_apply_policy. Signed-off-by: Roger Pau Monné

[PATCH v4 10/10] libs/guest: (re)move xc_cpu_policy_apply_cpuid

2021-05-07 Thread Roger Pau Monne
Move the logic from xc_cpu_policy_apply_cpuid into libxl, now that the xc_cpu_policy_* helpers allow modifying a cpu policy. By moving such parsing into libxl directly we can get rid of xc_xend_cpuid, as libxl will now implement it's own private type for storing CPUID information, which currently

[PATCH v4 07/10] libs/guest: rework xc_cpuid_xend_policy

2021-05-07 Thread Roger Pau Monne
Rename xc_cpuid_xend_policy to xc_cpu_policy_apply_cpuid and make it public. Modify the function internally to use the new xc_cpu_policy_* set of functions. Also don't apply the passed policy to a domain directly, and instead modify the provided xc_cpu_policy_t. The caller will be responsible of

[PATCH v4 08/10] libs/guest: apply a featureset into a cpu policy

2021-05-07 Thread Roger Pau Monne
Pull out the code from xc_cpuid_apply_policy that applies a featureset to a cpu policy and place it on it's own standalone function that's part of the public interface. No functional change intended. Signed-off-by: Roger Pau Monné --- tools/include/xenguest.h| 5 ++

[PATCH v4 06/10] libs/guest: introduce helper set cpu topology in cpu policy

2021-05-07 Thread Roger Pau Monne
This logic is pulled out from xc_cpuid_apply_policy and placed into a separate helper. Note the legacy part of the introduced function, as long term Xen will require a proper topology setter function capable of expressing a more diverse set of topologies. No functional change intended.

[PATCH v4 05/10] libs/guest: make a cpu policy compatible with older Xen versions

2021-05-07 Thread Roger Pau Monne
Older Xen versions used to expose some CPUID bits which are no longer exposed by default. In order to keep a compatible behavior with guests migrated from versions of Xen that don't encode the CPUID data on the migration stream introduce a function that sets the same bits as older Xen versions.

[PATCH v4 04/10] libs/guest: allow fetching a specific MSR entry from a cpu policy

2021-05-07 Thread Roger Pau Monne
Introduce an interface that returns a specific MSR entry from a cpu policy in xen_msr_entry_t format. This is useful to callers can peek data from the opaque xc_cpu_policy_t type. No caller of the interface introduced on this patch. Signed-off-by: Roger Pau Monné --- Changes since v3: - Use

[PATCH v4 03/10] libx86: introduce helper to fetch msr entry

2021-05-07 Thread Roger Pau Monne
Use such helper in order to replace the code in x86_msr_copy_from_buffer. Note the introduced helper should not be directly called and instead x86_msr_get_entry should be used that will properly deal with const and non-const inputs. Note this requires making the raw fields uint64_t so that it can

[PATCH v4 02/10] libs/guest: allow fetching a specific CPUID leaf from a cpu policy

2021-05-07 Thread Roger Pau Monne
Introduce an interface that returns a specific leaf/subleaf from a cpu policy in xen_cpuid_leaf_t format. This is useful to callers can peek data from the opaque xc_cpu_policy_t type. No caller of the interface introduced on this patch. Note that callers of find_leaf need to be slightly

[PATCH v4 01/10] libx86: introduce helper to fetch cpuid leaf

2021-05-07 Thread Roger Pau Monne
Introduce a helper based on the current Xen guest_cpuid code in order to fetch a cpuid leaf from a policy. The newly introduced function in cpuid.c should not be directly called and instead the provided x86_cpuid_get_leaf macro should be used that will properly deal with const and non-const

[PATCH v4 00/10] libs/guest: new CPUID/MSR interface

2021-05-07 Thread Roger Pau Monne
. Thanks, Roger. Roger Pau Monne (10): libx86: introduce helper to fetch cpuid leaf libs/guest: allow fetching a specific CPUID leaf from a cpu policy libx86: introduce helper to fetch msr entry libs/guest: allow fetching a specific MSR entry from a cpu policy libs/guest: make a cpu policy

[PATCH v2] tools/libs: move cpu policy related prototypes to xenguest.h

2021-05-06 Thread Roger Pau Monne
Do this before adding any more stuff to xg_cpuid_x86.c. The placement in xenctrl.h is wrong, as they are implemented by the xenguest library. Note that xg_cpuid_x86.c needs to include xg_private.h, and in turn also fix xg_private.h to include xc_bitops.h. The bitops definition of BITS_PER_LONG

[PATCH] tools/libs: move cpu policy related prototypes to xenguest.h

2021-05-05 Thread Roger Pau Monne
Do this before adding any more stuff to xg_cpuid_x86.c. The placement in xenctrl.h is wrong, as they are implemented by the xenguest library. Note that xg_cpuid_x86.c needs to include xg_private.h, and in turn also fix xg_private.h to include xc_bitops.h. As a result also modify xen-cpuid to

[PATCH] x86/vhpet: fix RTC special casing

2021-05-04 Thread Roger Pau Monne
Restore setting the virtual timer callback private data to NULL if the timer is not level triggered. This fixes the special casing done in pt_update_irq so that the RTC interrupt when originating from the HPET is suspended if the interrupt source is masked. Note the RTC special casing done in

[PATCH v3 13/13] libs/guest: (re)move xc_cpu_policy_apply_cpuid

2021-04-30 Thread Roger Pau Monne
Move the logic from xc_cpu_policy_apply_cpuid into libxl, now that the xc_cpu_policy_* helpers allow modifying a cpu policy. By moving such parsing into libxl directly we can get rid of xc_xend_cpuid, as libxl will now implement it's own private type for storing CPUID information, which currently

[PATCH v3 12/13] libs/{light,guest}: implement xc_cpuid_apply_policy in libxl

2021-04-30 Thread Roger Pau Monne
With the addition of the xc_cpu_policy_* now libxl can have better control over the cpu policy, this allows removing the xc_cpuid_apply_policy function and instead coding the required bits by libxl in libxl__cpuid_legacy directly. Remove xc_cpuid_apply_policy. Signed-off-by: Roger Pau Monné ---

[PATCH v3 11/13] libs/guest: apply a featureset into a cpu policy

2021-04-30 Thread Roger Pau Monne
Pull out the code from xc_cpuid_apply_policy that applies a featureset to a cpu policy and place it on it's own standalone function that's part of the public interface. No functional change intended. Signed-off-by: Roger Pau Monné --- tools/include/xenctrl.h | 5 ++

[PATCH v3 10/13] libs/guest: rework xc_cpuid_xend_policy

2021-04-30 Thread Roger Pau Monne
Rename xc_cpuid_xend_policy to xc_cpu_policy_apply_cpuid and make it public. Modify the function internally to use the new xc_cpu_policy_* set of functions. Also don't apply the passed policy to a domain directly, and instead modify the provided xc_cpu_policy_t. The caller will be responsible of

[PATCH v3 09/13] libs/guest: introduce helper set cpu topology in cpu policy

2021-04-30 Thread Roger Pau Monne
This logic is pulled out from xc_cpuid_apply_policy and placed into a separate helper. Note the legacy part of the introduced function, as long term Xen will require a proper topology setter function capable of expressing a more diverse set of topologies. No functional change intended.

[PATCH v3 08/13] libs/guest: make a cpu policy compatible with older Xen versions

2021-04-30 Thread Roger Pau Monne
Older Xen versions used to expose some CPUID bits which are no longer exposed by default. In order to keep a compatible behavior with guests migrated from versions of Xen that don't encode the CPUID data on the migration stream introduce a function that sets the same bits as older Xen versions.

[PATCH v3 07/13] libs/guest: obtain a compatible cpu policy from two input ones

2021-04-30 Thread Roger Pau Monne
Introduce a helper to obtain a compatible cpu policy based on two input cpu policies. Currently this is done by and'ing all CPUID feature leaves and MSR entries, except for MSR_ARCH_CAPABILITIES which has the RSBA bit or'ed. The _AC macro is pulled from libxl_internal.h into xen-tools/libs.h

[PATCH v3 06/13] libs/guest: introduce helper to check cpu policy compatibility

2021-04-30 Thread Roger Pau Monne
Such helpers is just a wrapper to the existing x86_cpu_policies_are_compatible function. This requires building policy.c from libx86 on user land also. No user of the interface introduced. Signed-off-by: Roger Pau Monné --- Changes since v1: - Initialize err. - Explicitly name parameters as

[PATCH v3 05/13] libs/guest: allow updating a cpu policy MSR data

2021-04-30 Thread Roger Pau Monne
Introduce a helper to update the MSR policy using an array of xen_msr_entry_t entries. Note the MSRs present in the input xen_msr_entry_t array will replace any existing entries on the policy. No user of the interface introduced on this patch. Signed-off-by: Roger Pau Monné --- Changes since

[PATCH v3 04/13] libs/guest: allow updating a cpu policy CPUID data

2021-04-30 Thread Roger Pau Monne
Introduce a helper to update the CPUID policy using an array of xen_cpuid_leaf_t entries. Note the leaves present in the input xen_cpuid_leaf_t array will replace any existing leaves on the policy. No user of the interface introduced on this patch. Signed-off-by: Roger Pau Monné --- Changes

<    3   4   5   6   7   8   9   10   11   12   >