[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 05/12] libs/guest: allow fetching a specific MSR entry from a cpu policy
- To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
- Date: Mon, 17 Jan 2022 10:48:20 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ttKOShXOtJhXrlltWfsF3kLq+OT0ydsXDZqofm2TxBw=; b=W4CpENHRVPhg6RVyHOgq7kkviIiMJPAqAFdlxfXpuoL4g5B/IHwbo8iwLMvp8t195YluRciDhrkS7qShCqkbvAxKiFllBqpS68837pxkM3i+navzXjEbCE+Spm8OXbqQDiO4WZr+wwhuBS/C4R5onR/W5m2B0t5dc2xsiBLi61WrE0BYSCeCqUcFFpOcJPEDPZ7pQvIsL7DmR4d9y6NdlzMv6Ur65Y/G6nw5WNTfOf4iTZ8OyHwLmkXkNAlTuaPX17nxKgIJ71v1ZdJreTdecz18W5hvVvPhRhi5z7OPTL/07676rjvFHnNSuJv6ZwTzjSFo/B+0pGrq8fr8G6hGuQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LdsrO2He3AM7acPokpEdm+diZdtQH0OUtl2hg7FStwSoYqG1VrO78wHJ7f9d+KWWs87maC3HNcZS/XW/Mnww6HGAyYeMiS6t027RjfAS4LZ+a8rM/hwL4T4nZ2v3iepbV68cJVyuZ2Ukq+meZtxZP+nf2wriEY+iBsHuxtaj2IqDxvMi9ya9WYaqwQvfROjmngx9hRQDWLYmWfhLbNQ3AtHh6GV2tWXRiykKJibOb6+3x4Cj9uEOIQ5ZW5hzR2F1+UV69nmenX8TL1Lk9JoCNbQPY3ILKV2tjvKgPiZKIqpTnBv4lGL9hrxaGAHHIe0ZmPvF1jr9oLq0gwQUSTbGGg==
- Authentication-results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, "Anthony PERARD" <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
- Delivery-date: Mon, 17 Jan 2022 09:49:51 +0000
- Ironport-data: A9a23:LA4WQKOEqGZ1TnDvrR1CkMFynXyQoLVcMsEvi/4bfWQNrUom1zAEz WNNDWiAOa2IamH1etB+at++8BtXuJTdy99lHgto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdpJYz/uUGuCJQUNUjMlkfZKhTr6UUsxNbVU8En150Es8w7dRbrNA2rBVPSvc4 bsenOWHULOV82Yc3rU8sv/rRLtH5ZweiRtA1rAMTakjUGz2zhH5OKk3N6CpR0YUd6EPdgKMq 0Qv+5nilo/R109F5tpICd8XeGVSKlLZFVDmZna7x8FOK/WNz8A/+v9TCRYSVatYoySpjvdu7 OpAjJzzdQkPHbyLyek4TDANRkmSPYUekFPGCX22sMjVxEzaaXr8hf5pCSnaP6VBpLwxWzsXs 6VFdnZdNXhvhMrvqF6/YvNrick5atHiIasUu216zCGfBvEjKXzGa/uQvIQIjGxt7ixINd/4a sQdTGpeUBDncQFNKk8WVLM0ks790xETdBUH8QnI9MLb+VP7zgNr16P2GMHIYdHMTsJQ9m6Ho krW8mK/BQsVXPSPxDzA/n+yi+vnmSLgRJlUBLC+7uRtglCY2ioUEhJ+aLegiaDn0AjkAYsZc hFKvHp1xUQvyKC1ZsjdTjqnhEGJhx5fZ9R2MPx9uQyo1YOBtm51GVM4ZjJGbdUnsuo/S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ed3AVV0gK1XYfNu/0KDwSeOEQbqBJa6 Z0q/A37AaISDAyVICWF3MFV+/Mq5nik4/nWwcPA1oC5BOVhT2lxbbmG1zAty1uHg9n8PMHyy zoggb57qKsv7WSzQLd7Xba69BzlMH6wtVOKcSQgow+KynqiCyveIN9Mofy9gwdkaWK0hIHgd PMqxAvM4Ba7G7QRHi8pV/X1wzpwF8Vmgnf4G7dpUGmjd3yRTo8BcYEr5leaAHl500pu8w5+L 5X3kqC3qAnQy/orWDY3ZzlRhtqnk27rT4JiugIlUFSVoMYdft4sZEfxkVIC50NdRiKp7zPKN MeTP002cwmMm9zNxvizytSKZ2XLzgO9y69Mwk/Upf/6UkSoJh7p3Fos/D30E1wsK7VcKM0lN gsBJ4Y4I2mfvVmHZ6VO91xM/dfcla9OS4kEFjiaGgPR5t3c04klfbMkcAIDaeRCds18Kc=
- Ironport-sdr: 2PcGYcKNwyYdslBSXkvrUVRGF57rDCnaKOvJuYzwfFn3KGOIJA812/cD3TkNxJ4Xuz1p8M7FZ8 0TpewO7+2bz5W3kB7Vj3xLCXpesf0tLviJc1hGuoSKk9LxiXjAdFLTs86X3xZSqn7Zh5ZVXSrF U0cFU1Y7odF+uun3baEInsURHeh5O3CiTBBa0ursDtGj8ybjVFqjbjEQfPCO6HNahbvWtqHQwg ofBjAuyrsfLnMrzCuAQzPMMI1XBCHn7WwcNZTS+A92e/fStlM5mS7zRUpNWY7hP1dlCJ4Wo0Im gyDW13DBc+OSAPLx5c+WdfT/
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
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@xxxxxxxxxx>
---
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 0a6fd99306..2672fd043c 100644
--- a/tools/include/xenguest.h
+++ b/tools/include/xenguest.h
@@ -810,6 +810,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 aff4efe78d..67981b1711 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -880,6 +880,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.34.1
|