libs/guest: introduce xc_cpu_policy_t

Introduce an opaque type that is used to store the CPUID and MSRs
policies of a domain. Such type uses the existing {cpuid,msr}_policy
structures to store the data, but doesn't expose the type to the users
of the xenguest library. There are also two arrays to allow for easier
serialization without requiring an allocation each time.

Introduce an allocation (init) and freeing function (destroy) to
manage the type.

Note the type is not yet used anywhere.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
This commit is contained in:
Roger Pau Monne authored and Andrew Cooper committed 2021-04-29 19:27:21 +01:00
1 parent 537ae41785
commit 989ec5bd1d
2 files changed
+24

No files matched your search

+6
View File
@@ -2590,6 +2590,12 @@ int xc_psr_get_domain_data(xc_interface *xch, uint32_t domid,
int xc_psr_get_hw_info(xc_interface *xch, uint32_t socket,
xc_psr_feat_type type, xc_psr_hw_info *hw_info);
typedef struct xc_cpu_policy *xc_cpu_policy_t;
/* Create and free a xc_cpu_policy object. */
xc_cpu_policy_t xc_cpu_policy_init(void);
void xc_cpu_policy_destroy(xc_cpu_policy_t policy);
int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps);
int xc_get_cpu_featureset(xc_interface *xch, uint32_t index,
uint32_t *nr_features, uint32_t *featureset);
+18
View File
@@ -39,6 +39,13 @@ enum {
#define bitmaskof(idx) (1u << ((idx) & 31))
#define featureword_of(idx) ((idx) >> 5)
struct xc_cpu_policy {
struct cpuid_policy cpuid;
struct msr_policy msr;
xen_cpuid_leaf_t leaves[CPUID_MAX_SERIALISED_LEAVES];
xen_msr_entry_t entries[MSR_MAX_SERIALISED_ENTRIES];
};
int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps)
{
DECLARE_SYSCTL;
@@ -665,3 +672,14 @@ out:
return rc;
}
xc_cpu_policy_t xc_cpu_policy_init(void)
{
return calloc(1, sizeof(struct xc_cpu_policy));
}
void xc_cpu_policy_destroy(xc_cpu_policy_t policy)
{
if ( policy )
free(policy);
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.