File xsa435-0-30.patch of Package xen.32200
From 1b67fccf3b02825f6a036bad06cd17963d0972d2 Mon Sep 17 00:00:00 2001
From: Andrew Cooper <andrew.cooper3@citrix.com>
Date: Mon, 3 Apr 2023 14:18:43 +0100
Subject: libx86: Update library API for cpu_policy
Adjust the API and comments appropriately.
x86_cpu_policy_fill_native() will eventually contain MSR reads, but leave a
TODO in the short term.
No practical change.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
tools/libs/guest: Fix build following libx86 changes
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>
--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -775,7 +775,7 @@ static void sanitise_featureset(struct c
const uint32_t *dfs;
if ( !test_bit(b, disabled_features) ||
- !(dfs = x86_cpuid_lookup_deep_deps(b)) )
+ !(dfs = x86_cpu_policy_lookup_deep_deps(b)) )
continue;
for ( i = 0; i < ARRAY_SIZE(disabled_features); ++i )
--- a/tools/tests/x86_emulator/x86-emulate.c
+++ b/tools/tests/x86_emulator/x86-emulate.c
@@ -65,7 +65,7 @@ bool emul_test_init(void)
unsigned long sp;
- x86_cpuid_policy_fill_native(&cp);
+ x86_cpu_policy_fill_native(&cp);
/*
* The emulator doesn't use these instructions, so can always emulate
--- a/xen/arch/x86/cpu-policy.c
+++ b/xen/arch/x86/cpu-policy.c
@@ -162,7 +162,7 @@ static void sanitise_featureset(uint32_t
for_each_set_bit(i, (void *)disabled_features,
sizeof(disabled_features) * 8)
{
- const uint32_t *dfs = x86_cpuid_lookup_deep_deps(i);
+ const uint32_t *dfs = x86_cpu_policy_lookup_deep_deps(i);
unsigned int j;
ASSERT(dfs); /* deep_features[] should guarentee this. */
@@ -342,7 +342,7 @@ static void __init calculate_raw_policy(
{
struct cpu_policy *p = &raw_cpu_policy;
- x86_cpuid_policy_fill_native(p);
+ x86_cpu_policy_fill_native(p);
p->x86_vendor = boot_cpu_data.x86_vendor;
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -67,7 +67,7 @@ void __init setup_clear_cpu_cap(unsigned
__builtin_return_address(0), cap);
__clear_bit(cap, boot_cpu_data.x86_capability);
- dfs = x86_cpuid_lookup_deep_deps(cap);
+ dfs = x86_cpu_policy_lookup_deep_deps(cap);
if (!dfs)
return;
--- a/xen/include/xen/lib/x86/cpu-policy.h
+++ b/xen/include/xen/lib/x86/cpu-policy.h
@@ -374,15 +374,20 @@ void x86_cpu_policy_to_featureset(const
void x86_cpu_featureset_to_policy(const uint32_t fs[FEATURESET_NR_ENTRIES],
struct cpu_policy *p);
-const uint32_t *x86_cpuid_lookup_deep_deps(uint32_t feature);
+/**
+ * For a specific feature, look up the dependent features. Returns NULL if
+ * this feature has no dependencies. Otherwise return a featureset of
+ * dependent features, which has been recursively flattened.
+ */
+const uint32_t *x86_cpu_policy_lookup_deep_deps(uint32_t feature);
/**
- * Fill a CPUID policy using the native CPUID instruction.
+ * Fill CPU policy using the native CPUID/RDMSR instruction.
*
* No sanitisation is performed. Values may be influenced by a hypervisor or
* from masking/faulting configuration.
*/
-void x86_cpuid_policy_fill_native(struct cpuid_policy *p);
+void x86_cpu_policy_fill_native(struct cpu_policy *p);
#ifdef __XEN__
#include <public/arch-x86/xen.h>
@@ -395,9 +400,10 @@ typedef xen_msr_entry_t msr_entry_buffer
#endif
/**
- * Serialise a cpuid_policy object into an array of cpuid leaves.
+ * Serialise the CPUID leaves of a cpu_policy object into an array of cpuid
+ * leaves.
*
- * @param policy The cpuid_policy to serialise.
+ * @param policy The cpu_policy to serialise.
* @param leaves The array of leaves to serialise into.
* @param nr_entries The number of entries in 'leaves'.
* @returns -errno
@@ -406,13 +412,13 @@ typedef xen_msr_entry_t msr_entry_buffer
* leaves array is too short. On success, nr_entries is updated with the
* actual number of leaves written.
*/
-int x86_cpuid_copy_to_buffer(const struct cpuid_policy *policy,
+int x86_cpuid_copy_to_buffer(const struct cpu_policy *policy,
cpuid_leaf_buffer_t leaves, uint32_t *nr_entries);
/**
- * Serialise an msr_policy object into an array.
+ * Serialise the MSRs of a cpu_policy object into an array.
*
- * @param policy The msr_policy to serialise.
+ * @param policy The cpu_policy to serialise.
* @param msrs The array of msrs to serialise into.
* @param nr_entries The number of entries in 'msrs'.
* @returns -errno
@@ -421,7 +427,7 @@ int x86_cpuid_copy_to_buffer(const struc
* buffer array is too short. On success, nr_entries is updated with the
* actual number of msrs written.
*/
-int x86_msr_copy_to_buffer(const struct msr_policy *policy,
+int x86_msr_copy_to_buffer(const struct cpu_policy *policy,
msr_entry_buffer_t msrs, uint32_t *nr_entries);
#endif /* !XEN_LIB_X86_POLICIES_H */
--- a/xen/lib/x86/cpuid.c
+++ b/xen/lib/x86/cpuid.c
@@ -44,7 +44,7 @@ void x86_cpu_featureset_to_policy(
p->feat._7d1 = fs[FEATURESET_7d1];
}
-void x86_cpuid_policy_fill_native(struct cpuid_policy *p)
+void x86_cpu_policy_fill_native(struct cpu_policy *p)
{
unsigned int i;
@@ -153,7 +153,7 @@ void x86_cpuid_policy_fill_native(struct
cpuid_leaf(0x80000000 + i, &p->extd.raw[i]);
}
-const uint32_t *x86_cpuid_lookup_deep_deps(uint32_t feature)
+const uint32_t *x86_cpu_policy_lookup_deep_deps(uint32_t feature)
{
static const uint32_t deep_features[] = INIT_DEEP_FEATURES;
static const struct {
@@ -208,7 +208,7 @@ static int copy_leaf_to_buffer(uint32_t
return 0;
}
-int x86_cpuid_copy_to_buffer(const struct cpuid_policy *p,
+int x86_cpuid_copy_to_buffer(const struct cpu_policy *p,
cpuid_leaf_buffer_t leaves, uint32_t *nr_entries_p)
{
const uint32_t nr_entries = *nr_entries_p;
--- a/xen/lib/x86/msr.c
+++ b/xen/lib/x86/msr.c
@@ -23,7 +23,7 @@ static int copy_msr_to_buffer(uint32_t i
return 0;
}
-int x86_msr_copy_to_buffer(const struct msr_policy *p,
+int x86_msr_copy_to_buffer(const struct cpu_policy *p,
msr_entry_buffer_t msrs, uint32_t *nr_entries_p)
{
const uint32_t nr_entries = *nr_entries_p;