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é <roger.pau@citrix.com>
---
Changes since v3:
- Use x86_msr_get_entry.
Changes since v1:
- Introduce a helper to perform a binary search of the MSR entries
array.
---
tools/include/xenguest.h | 2 ++
tools/libs/guest/xg_cpuid_x86.c | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/tools/include/xenguest.h b/tools/include/xenguest.h
index 7001e04e88d..8e8461b0660 100644
--- a/tools/include/xenguest.h
+++ b/tools/include/xenguest.h
@@ -747,6 +747,8 @@ int xc_cpu_policy_update_msrs(xc_interface *xch, xc_cpu_policy_t *policy,
int xc_cpu_policy_get_cpuid(xc_interface *xch, const xc_cpu_policy_t *policy,
uint32_t leaf, uint32_t subleaf,
xen_cpuid_leaf_t *out);
+int xc_cpu_policy_get_msr(xc_interface *xch, const xc_cpu_policy_t *policy,
+ uint32_t msr, xen_msr_entry_t *out);
/* Compatibility calculations. */
bool xc_cpu_policy_is_compatible(xc_interface *xch, xc_cpu_policy_t *host,
diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x86.c
index 460512d063b..cdfc79a86e7 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -883,6 +883,26 @@ int xc_cpu_policy_get_cpuid(xc_interface *xch, const xc_cpu_policy_t *policy,
return 0;
}
+int xc_cpu_policy_get_msr(xc_interface *xch, const xc_cpu_policy_t *policy,
+ uint32_t msr, xen_msr_entry_t *out)
+{
+ const uint64_t *val;
+
+ *out = (xen_msr_entry_t){};
+
+ val = x86_msr_get_entry(&policy->msr, msr);
+ if ( !val )
+ {
+ errno = ENOENT;
+ return -1;
+ }
+
+ out->idx = msr;
+ out->val = *val;
+
+ return 0;
+}
+
bool xc_cpu_policy_is_compatible(xc_interface *xch, xc_cpu_policy_t *host,
xc_cpu_policy_t *guest)
{
--
2.31.1