Re: [PATCH v4] xen/x86: On x2APIC mode, derive LDR from APIC ID

2023-11-27 Thread Alejandro Vallejo
On 24/11/2023 22:05, Andrew Cooper wrote: diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c index 5cb87f8649..cd4701c5a2 100644 --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -1061,13 +1061,26 @@ static const struct hvm_mmio_ops vlapic_mmio_ops = { .writ

Re: [PATCH v4] xen/x86: On x2APIC mode, derive LDR from APIC ID

2023-11-27 Thread Alejandro Vallejo
On 27/11/2023 08:40, Jan Beulich wrote: On 23.11.2023 18:30, Alejandro Vallejo wrote: @@ -1498,27 +1511,36 @@ static int cf_check lapic_save_regs(struct vcpu *v, hvm_domain_context_t *h) */ static void lapic_load_fixup(struct vlapic *vlapic) { -uint32_t id = vlapic->loaded

Re: [PATCH v4] xen/x86: On x2APIC mode, derive LDR from APIC ID

2023-11-27 Thread Alejandro Vallejo
On 27/11/2023 12:20, Andrew Cooper wrote: > On 27/11/2023 12:08 pm, Alejandro Vallejo wrote: >> On 24/11/2023 22:05, Andrew Cooper wrote: >>>> diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c >>>> index 5cb87f8649..cd4701c5a2 100644 >>>&g

Re: [PATCH v4] xen/x86: On x2APIC mode, derive LDR from APIC ID

2023-11-27 Thread Alejandro Vallejo
On 27/11/2023 12:24, Jan Beulich wrote: > On 27.11.2023 13:17, Alejandro Vallejo wrote: >> On 27/11/2023 08:40, Jan Beulich wrote: >>> On 23.11.2023 18:30, Alejandro Vallejo wrote: >>>> @@ -1498,27 +1511,36 @@ static int cf_check lapic_save_regs(struct vcpu &g

[PATCH v5] xen/x86: On x2APIC mode, derive LDR from APIC ID

2023-11-27 Thread Alejandro Vallejo
f7b35 ("x86/HVM: fix ID handling of x2APIC emulation") Signed-off-by: Alejandro Vallejo Reviewed-by: Roger Pau Monné Reviewed-by: Andrew Cooper --- v5: [Andrew] * Missing full stop in commit message * Specifically mention spec violation in the commit message * Use struct vcpu* dir

Re: [PATCH v5] xen/x86: On x2APIC mode, derive LDR from APIC ID

2023-11-27 Thread Alejandro Vallejo
On 27/11/2023 13:46, Alejandro Vallejo wrote: > Both Intel and AMD manuals agree that on x2APIC mode, the APIC LDR and ID > registers are derivable from each other through a fixed formula. > > Xen uses that formula, but applies it to vCPU IDs (which are sequential) > rather than x2

[PATCH] tools/xg: Fix potential memory leak in cpu policy getters/setters

2023-11-29 Thread Alejandro Vallejo
ement XEN_SYSCTL_get_cpu_policy') Fixes: 60529dfeca14 ('x86/domctl: Implement XEN_DOMCTL_get_cpu_policy') Fixes: 14ba07e6f816 ('x86/domctl: Implement XEN_DOMCTL_set_cpumsr_policy') Signed-off-by: Alejandro Vallejo --- tools/libs/guest/xg_cpuid_x86.c | 86 +++

[PATCH] tools/xg: Reserialise CPU policies with the allocated number of leaves.

2023-12-12 Thread Alejandro Vallejo
no accross free() Signed-off-by: Alejandro Vallejo --- tools/libs/guest/xg_cpuid_x86.c | 98 +++-- 1 file changed, 45 insertions(+), 53 deletions(-) diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x86.c index db5aebc815..4453178100 100644 --- a/

[PATCH 5/6] xen/x86: Derive topologically correct x2APIC IDs from the policy

2024-01-09 Thread Alejandro Vallejo
that case, the new helper just returns the legacy mapping. Signed-off-by: Alejandro Vallejo --- tools/tests/cpu-policy/test-cpu-policy.c | 128 +++ xen/include/xen/lib/x86/cpu-policy.h | 2 + xen/lib/x86/policy.c | 75 +++-- 3 files changed

[PATCH 1/6] xen/x86: Add initial x2APIC ID to the per-vLAPIC save area

2024-01-09 Thread Alejandro Vallejo
IDs are calculated from the CPU policy where the guest topology is defined. For the time being, the function simply returns the old relationship, but will eventually return results consistent with the topology. Signed-off-by: Alejandro Vallejo --- xen/arch/x86/cpuid.c | 20

[PATCH 3/6] xen/x86: Refactor xen/lib/x86 so it can be linked in hvmloader

2024-01-09 Thread Alejandro Vallejo
* errno.h => Use xen/errno.h instead No functional change intended. Signed-off-by: Alejandro Vallejo --- xen/lib/x86/cpuid.c | 12 ++-- xen/lib/x86/private.h | 8 +--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/xen/lib/x86/cpuid.c b/xen/lib/x86/cpuid

[PATCH 6/6] xen/x86: Add topology generator

2024-01-09 Thread Alejandro Vallejo
This allows toolstack to synthesise sensible topologies for guests. In particular, this patch causes x2APIC IDs to be packed according to the topology now exposed to the guests on leaf 0xb. Signed-off-by: Alejandro Vallejo --- tools/include/xenguest.h| 15 tools/libs/guest

[PATCH 0/6] x86: Expose consistent topology to guests

2024-01-09 Thread Alejandro Vallejo
ts have topologically consistent information in CPUID Alejandro Vallejo (6): xen/x86: Add initial x2APIC ID to the per-vLAPIC save area tools/xc: Add xc_cpu_policy to the public xenctrl.h header xen/x86: Refactor xen/lib/x86 so it can be linked in hvmloader tools/hvmloader: Use c

[PATCH 2/6] tools/xc: Add xc_cpu_policy to the public xenctrl.h header

2024-01-09 Thread Alejandro Vallejo
Move struct xc_cpu_policy data structure out of xg_private.h and into the public xenguest.h so it can be used by libxl. Signed-off-by: Alejandro Vallejo --- tools/include/xenguest.h | 8 +++- tools/libs/guest/xg_private.h| 10 -- xen/include/xen/lib/x86/cpu

[PATCH 4/6] tools/hvmloader: Use cpu_policy to determine APIC IDs

2024-01-09 Thread Alejandro Vallejo
As part of topology correction efforts, APIC IDs can no longer be derived strictly through the vCPU ID alone. Bring in the machinery for policy retrieval and parsing in order to generate the proper MADT table and wake the appropriate CPUs. Signed-off-by: Alejandro Vallejo --- tools/firmware

Re: [PATCH 6/6] xen/x86: Add topology generator

2024-01-10 Thread Alejandro Vallejo
Review-to-self after running in Gitlab: On 09/01/2024 15:38, Alejandro Vallejo wrote: > +p->basic.lppp = 0xff; > +if ( threads_per_pkg < 0xff ) > +p->basic.lppp = threads_per_pkg; > + > +switch ( p->x86_vendor ) > +{ > +case X86_VE

[PATCH 1/3] tools/xg: Move xc_cpu_policy_t to xenguest.h

2024-02-07 Thread Alejandro Vallejo
This enables a set of follow-up simplifications in the toolstack. No functional change. Signed-off-by: Alejandro Vallejo --- tools/include/xenguest.h | 8 +++- tools/libs/guest/xg_private.h| 10 -- xen/include/xen/lib/x86/cpu-policy.h | 6 -- 3 files

[PATCH 3/3] tools/xg: Clean up xend-style overrides for CPU policies

2024-02-07 Thread Alejandro Vallejo
Factor out policy getters/setters from both (CPUID and MSR) policy override functions. Additionally, use host policy rather than featureset when preparing the cur policy, saving one hypercall and several lines of boilerplate. No functional change intended. Signed-off-by: Alejandro Vallejo

[PATCH 0/3] Clean the policy manipulation path in domain creation

2024-02-07 Thread Alejandro Vallejo
uired. Patch 3: Performs the refactor of the policy manipulation code so that it follows a strict: PULL_POLICIES, MUTATE_POLICY (n times), PUSH_POLICY. Alejandro Vallejo (3): tools/xg: Move xc_cpu_policy_t to xenguest.h tools/xg: Streamline cpu policy serialise/deserialise calls too

[PATCH 2/3] tools/xg: Streamline cpu policy serialise/deserialise calls

2024-02-07 Thread Alejandro Vallejo
allocating dynamic memory aside from the policy objects in xen-cpuid. Also minor cleanup in the policy print call sites. No functional change intended. Signed-off-by: Alejandro Vallejo --- Splitting this patch in several is quite annoying, as it implies artificially creating duplicates of the

Re: [PATCH] hvmloader/PCI: skip huge BARs in certain calculations

2024-03-04 Thread Alejandro Vallejo
Hi, On 04/03/2024 07:32, Jan Beulich wrote: > BARs of size 2Gb and up can't possibly fit below 4Gb: Both the bottom of > the lower 2Gb range and the top of the higher 2Gb range have special > purpose. Don't even have them influence whether to (perhaps) relocate > low RAM. > > Reported-by: Neowutra

[PATCH v8 0/4] Prevent attempting updates known to fail

2023-08-30 Thread Alejandro Vallejo
init() and early_microcode_init() (was v7/patch2) Patch 4 Adds the logic to detect microcode updates being disabled on Intel. (was v7/patch3) Alejandro Vallejo (4): x86/microcode: WARN->INFO for the "no ucode loading" log message x86/microcode: Ignore microcode loading interface

[PATCH v8 2/4] x86/microcode: Ignore microcode loading interface for revision = -1

2023-08-30 Thread Alejandro Vallejo
Some hypervisors report ~0 as the microcode revision to mean "don't issue microcode updates". Ignore the microcode loading interface in that case. Signed-off-by: Alejandro Vallejo Reviewed-by: Jan Beulich --- v8: * Added missing newline in printk statement * Reduced indent

[PATCH v8 3/4] x86: Read MSR_ARCH_CAPS immediately after early_microcode_init()

2023-08-30 Thread Alejandro Vallejo
Move MSR_ARCH_CAPS read code from tsx_init() to early_cpu_init(). Because microcode updates might make them that MSR to appear/have different values we also must reload it after a microcode update in early_microcode_init(). Signed-off-by: Alejandro Vallejo Reviewed-by: Jan Beulich --- v8: * No

[PATCH v8 1/4] x86/microcode: WARN->INFO for the "no ucode loading" log message

2023-08-30 Thread Alejandro Vallejo
Currently there's a printk statement triggered when no ucode loading facilities are discovered. This statement should have severity INFO rather than WARNING because it's not reporting anything wrong. Warnings ought to be reserved for recoverable system errors. Signed-off-by: Alejand

[PATCH v8 4/4] x86/microcode: Disable microcode update handler if DIS_MCU_UPDATE is set

2023-08-30 Thread Alejandro Vallejo
g set then simply disable the "apply_microcode" handler so we can't even try to perform update (as it's known to be silently dropped). While at it, remove the Intel family check, as microcode loading is supported on every Intel64 CPU. Signed-off-by: Alejandro Vallejo Reviewe

Re: [PATCH] tools/misc/xencov_split: Add python 3 compatibility

2023-09-04 Thread Alejandro Vallejo
Hi, On Mon, Sep 04, 2023 at 08:51:31AM +0200, Jan Beulich wrote: > On 02.09.2023 18:21, Javi Merino wrote: > > Closes #154 > > > > Signed-off-by: Javi Merino > > The title isn't really in line with ... > > > --- a/tools/misc/xencov_split > > +++ b/tools/misc/xencov_split > > @@ -1,5 +1,7 @@ >

[PATCH 2/7] tools: Create xc_domain_getinfo_single()

2023-04-26 Thread Alejandro Vallejo
d-off-by: Alejandro Vallejo --- Cc: Andrew Cooper Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross --- tools/include/xenctrl.h | 16 tools/libs/ctrl/xc_domain.c | 22 ++ 2 files changed, 38 insertions(+) diff --git a/tools/include/xenctrl.h b/tools/in

[PATCH 5/7] tools: Modify single-domid callers of xc_domain_getinfolist

2023-04-26 Thread Alejandro Vallejo
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 --- Cc: Andrew Cooper Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross --- tools/libs/light/libxl_dom.c | 15

[PATCH 3/7] tools: Refactor the console/io.c to avoid using xc_domain_getinfo()

2023-04-26 Thread Alejandro Vallejo
It has 2 avoidable occurences * Check whether a domain is valid, which can be done faster with xc_domain_getinfo_single() * Domain discovery, which can be done much faster with the sysctl interface through xc_domain_getinfolist(). Signed-off-by: Alejandro Vallejo --- Cc: Andrew Cooper

[PATCH 1/7] tools: Make some callers of xc_domain_getinfo use xc_domain_getinfolist

2023-04-26 Thread Alejandro Vallejo
migrate the callers interested in more than 1 domain to the the *list() version. Signed-off-by: Alejandro Vallejo --- Cc: Andrew Cooper Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross --- tools/include/xenctrl.h | 5 + tools/python/xen/lowlevel/xc/xc.c | 29

[PATCH 4/7] tools: Make init-xenstore-domain use xc_domain_getinfolist()

2023-04-26 Thread Alejandro Vallejo
so we can (hopefully) get away with a single hypercall in a typical system. Signed-off-by: Alejandro Vallejo --- Cc: Andrew Cooper Cc: Wei Liu Cc: Juergen Gross --- tools/helpers/init-xenstore-domain.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/helpers/ini

[PATCH 7/7] domctl: Modify getdomaininfo to fail if domid is not found

2023-04-26 Thread Alejandro Vallejo
en-project/xen#105 Signed-off-by: Alejandro Vallejo --- Cc: Andrew Cooper Cc: George Dunlap Cc: Jan Beulich Cc: Julien Grall Cc: Stefano Stabellini Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross --- tools/include/xenctrl.h | 43 --- tools/libs/ctrl/xc_dom

[PATCH 0/7] Rationalize usage of xc_domain_getinfo{,list}()

2023-04-26 Thread Alejandro Vallejo
l itself. Alejandro Vallejo (7): tools: Make some callers of xc_domain_getinfo use xc_domain_getinfolist tools: Create xc_domain_getinfo_single() tools: Refactor the console/io.c to avoid using xc_domain_getinfo() tools: Make init-xenstore-domain use xc_domain_getinfolist() tools: Modif

[PATCH 6/7] tools: Use new xc function for some xc_domain_getinfo calls

2023-04-26 Thread Alejandro Vallejo
Move calls that require a information about a single precisely identified domain to the new xc_domain_getinfo_single(). Signed-off-by: Alejandro Vallejo --- Cc: Andrew Cooper Cc: Wei Liu Cc: Anthony PERARD Cc: Tim Deegan Cc: George Dunlap Cc: Juergen Gross --- tools/console/client/main.c

Re: [PATCH 4/7] tools: Make init-xenstore-domain use xc_domain_getinfolist()

2023-04-27 Thread Alejandro Vallejo
Ah, I didn't notice that header. Sure, added locally on v2. Cheers, Alejandro On Wed, Apr 26, 2023 at 05:20:01PM +0200, Juergen Gross wrote: > Please include instead of defining ARRAY_SIZE(). > > With that changed: > > Reviewed-by: Juergen Gross > > > Juergen

Re: [PATCH 1/7] tools: Make some callers of xc_domain_getinfo use xc_domain_getinfolist

2023-04-27 Thread Alejandro Vallejo
Answers inlined On Thu, Apr 27, 2023 at 10:51:03AM +0100, Andrew Cooper wrote: > Just as a note for the subject, we more commonly write function names > with ()'s. No harm in abiding by that. Done on v2. > > +"crashed", (info[i].flags & XEN_DOMINF_shutdown) && > > +

Re: [PATCH 6/7] tools: Use new xc function for some xc_domain_getinfo calls

2023-04-27 Thread Alejandro Vallejo
On Thu, Apr 27, 2023 at 01:35:18PM +0100, Andrew Cooper wrote: > > > +xc_domaininfo_t di; > > unsigned int nr_leaves, nr_msrs; > > uint32_t err_leaf = -1, err_subleaf = -1, err_msr = -1; > > /* > > @@ -291,13 +292,13 @@ static int xc_cpuid_xend_policy( > > xen_cpuid_leaf_t

[PATCH v2 1/7] tools: Make some callers of xc_domain_getinfo() use xc_domain_getinfolist()

2023-04-28 Thread Alejandro Vallejo
migrate the callers interested in more than 1 domain to the the *list() version. Signed-off-by: Alejandro Vallejo --- Cc: Andrew Cooper Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross --- tools/include/xenctrl.h | 12 tools/python/xen/lowlevel/xc/xc.c | 28

[PATCH v2 2/7] tools: Create xc_domain_getinfo_single()

2023-04-28 Thread Alejandro Vallejo
d-off-by: Alejandro Vallejo --- Cc: Andrew Cooper Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross --- tools/include/xenctrl.h | 16 tools/libs/ctrl/xc_domain.c | 23 +++ 2 files changed, 39 insertions(+) diff --git a/tools/include/xenctrl.h b/tools/in

[PATCH v2 0/7] Rationalize usage of xc_domain_getinfo{,list}()

2023-04-28 Thread Alejandro Vallejo
simplified to only use its fastpath. With the DOMCTL amended, the new xc_domain_getinfo_single() drops its stricter check, becoming a simple wrapper to invoke the hypercall itself. Alejandro Vallejo (7): tools: Make some callers of xc_domain_getinfo() use xc_domain_getinfolist

[PATCH v2 4/7] tools: Make init-xenstore-domain use xc_domain_getinfolist()

2023-04-28 Thread Alejandro Vallejo
so we can (hopefully) get away with a single hypercall in a typical system. Signed-off-by: Alejandro Vallejo --- Cc: Andrew Cooper Cc: Wei Liu Cc: Juergen Gross --- tools/helpers/init-xenstore-domain.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/helpers/ini

[PATCH v2 5/7] tools: Modify single-domid callers of xc_domain_getinfolist()

2023-04-28 Thread Alejandro Vallejo
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 --- Cc: Andrew Cooper Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross --- tools/libs/light/libxl_dom.c | 15

[PATCH v2 3/7] tools: Refactor console/io.c to avoid using xc_domain_getinfo()

2023-04-28 Thread Alejandro Vallejo
It has 2 avoidable occurences * Check whether a domain is valid, which can be done faster with xc_domain_getinfo_single() * Domain discovery, which can be done much faster with the sysctl interface through xc_domain_getinfolist(). Signed-off-by: Alejandro Vallejo --- Cc: Andrew Cooper

[PATCH v2 6/7] tools: Use new xc function for some xc_domain_getinfo() calls

2023-04-28 Thread Alejandro Vallejo
Move calls that require a information about a single precisely identified domain to the new xc_domain_getinfo_single(). Signed-off-by: Alejandro Vallejo --- Cc: Andrew Cooper Cc: Wei Liu Cc: Anthony PERARD Cc: Tim Deegan Cc: George Dunlap Cc: Juergen Gross --- tools/console/client/main.c

[PATCH v2 7/7] domctl: Modify XEN_DOMCTL_getdomaininfo to fail if domid is not found

2023-04-28 Thread Alejandro Vallejo
en-project/xen#105 Signed-off-by: Alejandro Vallejo --- Cc: Andrew Cooper Cc: George Dunlap Cc: Jan Beulich Cc: Julien Grall Cc: Stefano Stabellini Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross --- tools/include/xenctrl.h| 43 tools/libs/ctrl/xc_domain

Re: [PATCH v2 4/7] tools: Make init-xenstore-domain use xc_domain_getinfolist()

2023-04-28 Thread Alejandro Vallejo
Sounds good to me. Cheers, Alejandro On Fri, Apr 28, 2023 at 01:40:50PM +0100, Andrew Cooper wrote: > I'm recommend having a comment here, saying something like /* Commonly > dom0 is the only domain, but buffer a little for efficiency. */ > > Because this is also the justification for why we don

Re: [PATCH v2 3/7] tools: Refactor console/io.c to avoid using xc_domain_getinfo()

2023-04-28 Thread Alejandro Vallejo
On Fri, Apr 28, 2023 at 01:33:45PM +0100, Andrew Cooper wrote: > On 28/04/2023 11:41 am, Alejandro Vallejo wrote: > > It has 2 avoidable occurences > > > > * Check whether a domain is valid, which can be done faster with > > xc_domain_getinfo_single() > > * Do

Re: xen | Failed pipeline for staging | 6a47ba2f

2023-05-02 Thread Alejandro Vallejo
On Tue, May 02, 2023 at 08:53:31AM +0200, Jan Beulich wrote: > I'm also having a hard time seeing what failure case the test ended > up encountering: There are only two errors which can occur - one > from the XSM hook (which is mishandled, and I'll make a separate > patch for that) and the other fr

[PATCH v3 0/3] Rationalize usage of xc_domain_getinfo{,list}()

2023-05-02 Thread Alejandro Vallejo
e DOMCTL ammended, the new xc_domain_getinfo_single() drops its stricter check, becoming a simple wrapper to invoke the hypercall itself. Alejandro Vallejo (3): tools: Modify single-domid callers of xc_domain_getinfolist() tools: Use new xc function for some xc_domain_getinfo() calls domctl

[PATCH v3 1/3] tools: Modify single-domid callers of xc_domain_getinfolist()

2023-05-02 Thread Alejandro Vallejo
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 --- Cc: Andrew Cooper Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Cc: Christian Lindig v3: * Replaced single-domid

[PATCH v3 3/3] domctl: Modify XEN_DOMCTL_getdomaininfo to fail if domid is not found

2023-05-02 Thread Alejandro Vallejo
en-project/xen#105 Signed-off-by: Alejandro Vallejo Reviewed-by: Andrew Cooper --- Cc: Andrew Cooper Cc: George Dunlap Cc: Jan Beulich Cc: Julien Grall Cc: Stefano Stabellini Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross v3: * No changes --- tools/include/xenctrl.

[PATCH v3 2/3] tools: Use new xc function for some xc_domain_getinfo() calls

2023-05-02 Thread Alejandro Vallejo
Move calls that require a information about a single precisely identified domain to the new xc_domain_getinfo_single(). Signed-off-by: Alejandro Vallejo Reviewed-by: Andrew Cooper --- Cc: Andrew Cooper Cc: Wei Liu Cc: Anthony PERARD Cc: Tim Deegan Cc: George Dunlap Cc: Juergen Gross v3

Re: [PATCH v3 1/3] tools: Modify single-domid callers of xc_domain_getinfolist()

2023-05-02 Thread Alejandro Vallejo
On Tue, May 02, 2023 at 12:13:36PM +0100, Alejandro Vallejo wrote: > 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 of

Re: [PATCH v3 2/3] tools: Use new xc function for some xc_domain_getinfo() calls

2023-05-02 Thread Alejandro Vallejo
On Tue, May 02, 2023 at 12:13:37PM +0100, Alejandro Vallejo wrote: > Move calls that require a information about a single precisely identified > domain to the new xc_domain_getinfo_single(). > > Signed-off-by: Alejandro Vallejo > Reviewed-by: Andrew Cooper > > --- >

[PATCH 1/3] x86: Add AMD's CpuidUserDis bit definitions

2023-05-05 Thread Alejandro Vallejo
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 --- tools/libs/light/libxl_cpuid.c | 1 + tools/misc/xen-cpuid.c

[PATCH 0/3] Add CpuidUserDis support

2023-05-05 Thread Alejandro Vallejo
bing path and the context switching path. Patch 3 enables HVM guests to use CpuidUserDis as if it was CPUID faulting, saving an avoidable roundtrip through the hypervisor at fault handling. Alejandro Vallejo (3): x86: Add AMD's CpuidUserDis bit definitions x86: Add support for CpuidUserDis

[PATCH 2/3] x86: Add support for CpuidUserDis

2023-05-05 Thread Alejandro Vallejo
Includes a refactor to move vendor-specific probes to vendor-specific files. Furthermore, because CpuIdUserDis is reported in Cpuid itself, the extended leaf containing that bit must be retrieved before calling c_early_init() Signed-off-by: Alejandro Vallejo --- xen/arch/x86/cpu/amd.c

[PATCH 3/3] x86: Use CpuidUserDis if an AMD HVM guest toggles CPUID faulting

2023-05-05 Thread Alejandro Vallejo
This is in order to aid guests of AMD hardware that we have exposed CPUID faulting to. If they try to modify the Intel MSR that enables the feature, trigger levelling so AMD's version of it (CpuidUserDis) is used instead. Signed-off-by: Alejandro Vallejo --- xen/arch/x86/msr.c | 9 +++

Re: [PATCH 3/3] x86: Use CpuidUserDis if an AMD HVM guest toggles CPUID faulting

2023-05-09 Thread Alejandro Vallejo
On Tue, May 09, 2023 at 04:41:49PM +0200, Jan Beulich wrote: > > I asked Alejandro to do it like this. > > > > Advertising this to guests requires plumbing another MSR into the > > infrastructure which isn't quite set up properly let, and is in flux > > from my work. > > > > For now, this just le

[PATCH v4 0/3] Rationalize usage of xc_domain_getinfo{,list}()

2023-05-09 Thread Alejandro Vallejo
ified to only use its fastpath. With the DOMCTL ammended, the new xc_domain_getinfo_single() drops its stricter check, becoming a simple wrapper to invoke the hypercall itself. Alejandro Vallejo (3): tools: Modify single-domid callers of xc_domain_getinfolist() tools: Use new xc function

[PATCH v4 1/3] tools: Modify single-domid callers of xc_domain_getinfolist()

2023-05-09 Thread Alejandro Vallejo
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 Reviewed-by: Andrew Cooper Acked-by: Christian Lindig --- Cc: Andrew Cooper Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross Cc

[PATCH v4 3/3] domctl: Modify XEN_DOMCTL_getdomaininfo to fail if domid is not found

2023-05-09 Thread Alejandro Vallejo
en-project/xen#105 Signed-off-by: Alejandro Vallejo Reviewed-by: Andrew Cooper Acked-by: Anthony PERARD --- Cc: Andrew Cooper Cc: George Dunlap Cc: Jan Beulich Cc: Julien Grall Cc: Stefano Stabellini Cc: Wei Liu Cc: Anthony PERARD Cc: Juergen Gross --- tools/include/xenctrl.

[PATCH v4 2/3] tools: Use new xc function for some xc_domain_getinfo() calls

2023-05-09 Thread Alejandro Vallejo
Move calls that require a information about a single precisely identified domain to the new xc_domain_getinfo_single(). Signed-off-by: Alejandro Vallejo Reviewed-by: Andrew Cooper --- Cc: Andrew Cooper Cc: Wei Liu Cc: Anthony PERARD Cc: Tim Deegan Cc: George Dunlap Cc: Juergen Gross v4

[PATCH v2 0/3] Add CpuidUserDis support

2023-05-09 Thread Alejandro Vallejo
y adds definitions to various places in CPUID and MSR Patch 2 moves vendor-specific code on probe_cpuid_faulting() to amd.c/intel.c Patch 3 adds support for CpuidUserDis, hooking it in the probing path and the context switching path. Alejandro Vallejo (3): x86: Add AMD's CpuidUserDi

[PATCH v2 2/3] x86: Refactor conditional guard in probe_cpuid_faulting()

2023-05-09 Thread Alejandro Vallejo
Move vendor-specific checks to the vendor-specific callers. No functional change. Signed-off-by: Alejandro Vallejo --- v2: * Patch factored out from patch2 of v1 --- xen/arch/x86/cpu/amd.c| 10 +- xen/arch/x86/cpu/common.c | 11 --- xen/arch/x86/cpu/intel.c | 9

[PATCH v2 1/3] x86: Add AMD's CpuidUserDis bit definitions

2023-05-09 Thread Alejandro Vallejo
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 --- tools/libs/light/libxl_cpuid.c | 1 + tools/misc/xen-cpuid.c

[PATCH v2 3/3] x86: Add support for CpuidUserDis

2023-05-09 Thread Alejandro Vallejo
Because CpuIdUserDis is reported in CPUID itself, the extended leaf containing that bit must be retrieved before calling c_early_init() Signed-off-by: Alejandro Vallejo --- v2: * Style fixes * MSR index inlined in rdmsr/wrmsr * Swapped Intel's conditional guard so typically true cond

Re: [PATCH 3/3] x86: Use CpuidUserDis if an AMD HVM guest toggles CPUID faulting

2023-05-10 Thread Alejandro Vallejo
On Wed, May 10, 2023 at 10:15:31AM +0200, Jan Beulich wrote: > On 09.05.2023 12:05, Andrew Cooper wrote: > > On 08/05/2023 2:18 pm, Jan Beulich wrote: > >> On 05.05.2023 19:57, Alejandro Vallejo wrote: > >>> This is in order to aid guests of AMD hardware that we hav

Re: [PATCH 0/3] Add CpuidUserDis support

2023-05-10 Thread Alejandro Vallejo
On Mon, May 08, 2023 at 11:06:31AM +0200, Jan Beulich wrote: > On 05.05.2023 19:57, Alejandro Vallejo wrote: > > Nowadays AMD supports trapping the CPUID instruction from ring3 to ring0, > > Since it's relevant for PV32: Their doc talks about CPL > 0, i.e. not just >

Re: [PATCH v2 1/3] x86: Add AMD's CpuidUserDis bit definitions

2023-05-11 Thread Alejandro Vallejo
On Thu, May 11, 2023 at 11:41:13AM +0200, Jan Beulich wrote: > On 09.05.2023 18:43, Alejandro Vallejo wrote: > > --- a/xen/include/public/arch-x86/cpufeatureset.h > > +++ b/xen/include/public/arch-x86/cpufeatureset.h > > @@ -287,6 +287,7 @@ XEN_CPUFEATURE(AVX_IFMA, 10

Re: [PATCH v2 3/3] x86: Add support for CpuidUserDis

2023-05-11 Thread Alejandro Vallejo
On Thu, May 11, 2023 at 01:05:42PM +0200, Jan Beulich wrote: > > --- a/xen/arch/x86/cpu/amd.c > > +++ b/xen/arch/x86/cpu/amd.c > > @@ -279,8 +279,12 @@ static void __init noinline amd_init_levelling(void) > > * that can only be present when Xen is itself virtualized (because > > * it can

[PATCH v3 1/2] x86: Refactor conditional guard in probe_cpuid_faulting()

2023-05-15 Thread Alejandro Vallejo
Move vendor-specific checks to the vendor-specific callers. While at it move the synth cap setters to the callers too, as it's needed for a later patch and it's not a functional change either. No functional change. Signed-off-by: Alejandro Vallejo Reviewed-by: Jan Beulich --- v3: *

[PATCH v3 2/2] x86: Add support for CpuidUserDis

2023-05-15 Thread Alejandro Vallejo
Because CpuIdUserDis is reported in CPUID itself, the extended leaf containing that bit must be retrieved before calling c_early_init() Signed-off-by: Alejandro Vallejo --- v3: * Moved LCAP_* setters to the callers in patch1/v3 * Added rationale for checking CPUID faulting before CpuidUserDis

[PATCH v3 0/2] Add CpuidUserDis support

2023-05-15 Thread Alejandro Vallejo
el.c Patch 2 adds support for CpuidUserDis, hooking it in the probing path and the context switching path. Alejandro Vallejo (2): x86: Refactor conditional guard in probe_cpuid_faulting() x86: Add support for CpuidUserDis xen/arch/x86/cpu/amd.c | 32 - xen/arch/x86/cpu/

[PATCH 1/3] x86: Add bit definitions for Automatic IBRS

2023-05-26 Thread Alejandro Vallejo
This is AMD's version of Intel's Enhanced IBRS. Exposed in CPUID and toggled in EFER. Signed-off-by: Alejandro Vallejo --- tools/libs/light/libxl_cpuid.c | 1 + tools/misc/xen-cpuid.c | 2 ++ xen/arch/x86/include/asm/cpufeature.h | 1 + xe

[PATCH 2/3] x86: Add support for AMD's Automatic IBRS

2023-05-26 Thread Alejandro Vallejo
dom0 is set up, just like setting SPEC_CTRL. Signed-off-by: Alejandro Vallejo --- xen/arch/x86/setup.c | 3 +++ xen/arch/x86/smpboot.c | 3 +++ xen/arch/x86/spec_ctrl.c | 52 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/xen/arch

[PATCH 3/3] x86: Expose Automatic IBRS to guests

2023-05-26 Thread Alejandro Vallejo
Expose AutoIBRS to HVM guests, because they can just use it. Make sure writes to EFER:AIBRSE are gated on the feature being exposed. Also hide EFER:AIBRSE from PV guests as they have no say in the matter. Signed-off-by: Alejandro Vallejo --- xen/arch/x86/hvm/hvm.c | 3

[PATCH 0/3] Add Automatic IBRS support

2023-05-26 Thread Alejandro Vallejo
h 3 exposes the feature to HVM guests. Alejandro Vallejo (3): x86: Add bit definitions for Automatic IBRS x86: Add support for AMD's Automatic IBRS x86: Expose Automatic IBRS to guests tools/libs/light/libxl_cpuid.c | 1 + tools/misc/xen-cpuid.c | 2

Re: [PATCH 2/3] x86: Add support for AMD's Automatic IBRS

2023-05-26 Thread Alejandro Vallejo
On Fri, May 26, 2023 at 12:28:39PM -0400, Jason Andryuk wrote: > > if ( boot_cpu_data.extended_cpuid_level >= 0x8008 ) > > +{ > > cpuid(0x8008, &tmp, &e8b, &tmp, &tmp); > > +cpuid(0x8021, &e21a, &tmp, &tmp, &tmp); > > +} > > Do you need to check boot_cpu_d

Re: [PATCH 1/3] x86: Add bit definitions for Automatic IBRS

2023-05-26 Thread Alejandro Vallejo
On Fri, May 26, 2023 at 05:46:51PM +0100, Andrew Cooper wrote: > AIBRS and EIBRS are very much not the same, and I argued hard to not > have Linux confuse the too, but alas. > > Don't mention EIBRS at all. > > Simply "Auto IBRS is a new feature in AMD Zen4 CPUs and late, intended > to reduce the

Re: [PATCH 2/3] x86: Add support for AMD's Automatic IBRS

2023-05-30 Thread Alejandro Vallejo
On Tue, May 30, 2023 at 10:25:36AM +0200, Jan Beulich wrote: > On 26.05.2023 17:00, Alejandro Vallejo wrote: > > --- a/xen/arch/x86/smpboot.c > > +++ b/xen/arch/x86/smpboot.c > > @@ -376,6 +376,9 @@ void start_secondary(void *unused) > > { > &

Re: [PATCH 2/3] x86: Add support for AMD's Automatic IBRS

2023-05-30 Thread Alejandro Vallejo
On Fri, May 26, 2023 at 04:00:43PM +0100, Alejandro Vallejo wrote: > diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c > index 74e3915a4d..09cfef2676 100644 > --- a/xen/arch/x86/setup.c > +++ b/xen/arch/x86/setup.c > @@ -2036,6 +2036,9 @@ void __init noreturn __start_xen(unsi

[PATCH v2 2/3] x86: Expose Automatic IBRS to guests

2023-05-30 Thread Alejandro Vallejo
Expose AutoIBRS to HVM guests. EFER is swapped by VMRUN, so Xen only has to make sure writes to EFER.AIBRSE are gated on the feature being exposed. Also hide EFER.AIBRSE from PV guests as they have no say in the matter. Signed-off-by: Alejandro Vallejo Reviewed-by: Andrew Cooper --- v2

[PATCH v2 0/3] Add Automatic IBRS support

2023-05-30 Thread Alejandro Vallejo
D and EFER. Patch 2 exposes the feature to HVM guests. Patch 3 Hooks up AutoIBRS to spec_ctrl. so it's used when IBRS is picked. It also tweaks the heuristics so AutoIBRS is preferred over retpolines as BTI mitigation. This is enough to protect Xen. Alejandro Vallejo (3):

[PATCH v2 1/3] x86: Add bit definitions for Automatic IBRS

2023-05-30 Thread Alejandro Vallejo
This is an AMD feature to reduce the IBRS handling overhead. Once enabled, processes running at CPL=0 are automatically IBRS-protected even if SPEC_CTRL.IBRS is not set. Furthermore, the RAS/RSB is cleared on VMEXIT. The feature is exposed in CPUID and toggled in EFER. Signed-off-by: Alejandro

[PATCH v2 3/3] x86: Add support for AMD's Automatic IBRS

2023-05-30 Thread Alejandro Vallejo
In cases where AutoIBRS is supported by the host: * Prefer AutoIBRS to retpolines as BTI mitigation in heuristics calculations. * Always enable AutoIBRS if IBRS is chosen as a BTI mitigation. * Avoid stuffing the RAS/RSB on VMEXIT if AutoIBRS is enabled. Signed-off-by: Alejandro Vallejo

Re: [PATCH 1/3] x86/acpi: Drop acpi_video_flags and use bootsym(video_flags) directly

2024-09-05 Thread Alejandro Vallejo
300Mhz CPU (Pentium 2 era) from 1998 when MMX was the headline > feature, sporting 64M of RAM. Being a 32-bit processor, it hasn't been able > to run Xen for about a decade now, so drop the quirk entirely. > > Signed-off-by: Andrew Cooper > --- > CC: Jan Beulich > CC:

[PATCH] x86/traps: Re-enable IRQs after reading cr2 in the #PF handler

2024-09-11 Thread Alejandro Vallejo
Moves sti directly after the cr2 read and immediately after the #PF handler. While in the area, remove redundant q suffix to a movq in entry.S Signed-off-by: Alejandro Vallejo --- I don't think this is a bug as much as an accident about to happen. Even if there's no cases at the momen

Re: [PATCH] x86/traps: Re-enable IRQs after reading cr2 in the #PF handler

2024-09-12 Thread Alejandro Vallejo
On Thu Sep 12, 2024 at 10:49 AM BST, Andrew Cooper wrote: > On 11/09/2024 3:58 pm, Alejandro Vallejo wrote: > > diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S > > index b8482de8ee..ef803f6288 100644 > > --- a/xen/arch/x86/x86_64/entry.S > > +++ b/

Re: [PATCH v2 3/4] x86/trampoline: Document how the trampoline is laid out

2024-11-14 Thread Alejandro Vallejo
Monné > CC: Daniel P. Smith > CC: Frediano Ziglio > CC: Alejandro Vallejo > > v2: > * Rebase over the introduction of trampoline_perm_end > * Fix the description of the boot stack position > --- > xen/arch/x86/include/asm/trampoline.h | 57 +

Re: [RFC PATCH 12/25] xen: Replace sysctl/readconsole with autogenerated version

2024-11-26 Thread Alejandro Vallejo
On Tue Nov 26, 2024 at 9:40 AM GMT, Jan Beulich wrote: > On 25.11.2024 19:51, Alejandro Vallejo wrote: > > On Mon Nov 25, 2024 at 12:05 PM GMT, Jan Beulich wrote: > >> On 15.11.2024 12:51, Alejandro Vallejo wrote: > >>> Describe sysctl/readconsole as a TOML specif

Re: [PATCH V4 03/15] x86/pv: Rewrite how building PV dom0 handles domheap mappings

2024-12-09 Thread Alejandro Vallejo
Hi, I've been trying to run this series for a while, but it crashes very frequentyly starting from the patch that generalizes the mapcache. I think I've tracked it down to this patch. On Mon Nov 11, 2024 at 1:11 PM GMT, Elias El Yandouzi wrote: > From: Hongyan Xia > > Building a PV dom0 is alloc

Re: [PATCH 0/3] tools/hvmloader: Decouple APIC IDs from vCPU IDs

2025-02-04 Thread Alejandro Vallejo
On Thu Jan 30, 2025 at 9:17 AM GMT, Jan Beulich wrote: > On 29.01.2025 17:25, Roger Pau Monné wrote: > > On Tue, Jan 28, 2025 at 06:42:38PM +, Alejandro Vallejo wrote: > >> On Tue Jan 28, 2025 at 5:45 PM GMT, Roger Pau Monné wrote: > >>> On Tue, Jan 28, 2025

[PATCH v2 0/2] tools/hvmloader: Decouple APIC IDs from vCPU IDs

2025-02-04 Thread Alejandro Vallejo
er and the toolstack currently engage in a shared assumption that for every vCPU apicid == 2 * vcpuid. This series removes such assumption from hvmloader, by making it read the APIC ID of each vCPU and storing it for later use. Alejandro Vallejo (2): tools/hvmloader: Retrieve APIC IDs from t

[PATCH v2 1/2] tools/hvmloader: Retrieve APIC IDs from the APs themselves

2025-02-04 Thread Alejandro Vallejo
used for the vcpu id. Signed-off-by: Alejandro Vallejo --- v1->v2: * Removed "(x2)" from the comment of cpu_to_apicid. * Added "APIC ID" to the printed string on AP boot up. Changes from the v7 version of this patch in the longer topology series: * s/cpu_to

[PATCH v2 2/2] tools/hvmloader: Replace LAPIC_ID() with cpu_to_apicid[]

2025-02-04 Thread Alejandro Vallejo
using it uninitialised. Note that bringing up the APs doesn't need the APIC in hvmloader becasue it always runs virtualized and uses the PV interface. Signed-off-by: Alejandro Vallejo --- v1->v2: * No changes Changes wrt original series * No changes (it was wrongly stated in v1 that s

Re: [PATCH v2 2/2] tools/hvmloader: Replace LAPIC_ID() with cpu_to_apicid[]

2025-02-04 Thread Alejandro Vallejo
On Tue Feb 4, 2025 at 3:07 PM GMT, Jan Beulich wrote: > On 04.02.2025 15:45, Alejandro Vallejo wrote: > > --- a/tools/firmware/hvmloader/config.h > > +++ b/tools/firmware/hvmloader/config.h > > @@ -48,8 +48,9 @@ extern uint8_t ioapic_version; > > > >

Re: [RFC] enable UBSAN for automation tests

2025-02-05 Thread Alejandro Vallejo
On Wed Feb 5, 2025 at 12:44 AM GMT, Stefano Stabellini wrote: > Hi all, > > I would like to propose to enable the UBSAN config option in our Gitlab > pipelines. The attached patch (just for testing, do not commit) enables > UBSAN on the Xen build jobs used for most of the ARM and x86 tests. The > p

Re: [PATCH v2 2/2] tools/hvmloader: Replace LAPIC_ID() with cpu_to_apicid[]

2025-02-04 Thread Alejandro Vallejo
On Tue Feb 4, 2025 at 3:46 PM GMT, Jan Beulich wrote: > On 04.02.2025 16:25, Alejandro Vallejo wrote: > > On Tue Feb 4, 2025 at 3:07 PM GMT, Jan Beulich wrote: > >> On 04.02.2025 15:45, Alejandro Vallejo wrote: > >>> --- a/tools/firmware/hvmloader/config.h > &

<    1   2   3   4   5   6   7   8   >