[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 1/6] libs/guest: introduce support for setting guest MSRs
- To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Date: Mon, 17 Jul 2023 15:48:53 +0200
- 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=7mcp3wEPnZ7rV3MUjZ1ALwGHSE+qdvWmUUEoyZC9CGY=; b=IgFYsZC/6wPt2FInIq2Igon3pdYlfXfM+P4s9nKEE2QhTKPbQkMGA/74w2tm6xjVGFGXBZRJmzrSyhLtI4+N1znEa7e7rTmdizy2i7n4uHZZCL9jTWr63IPOI6HvJDQywmaI+VZ+ykL0tnzRo1eL2OhwkGmktOw1zQSrZC+mPekVEbNnEjqzL2YK5+byijRN66qSPTSyxM4HQy4huk9J3C6x5Zp4UtIPIFCoehl6RulWGzd9FmbMibUxuo2PWWn2Rr4GJtzmMj+SLZ6sqZjJKp0XJmfK6mPydv6Ogxay/+AumkLXBsuO22f2tjzqShzF8GgPLdDIMvcMw4quVUpZQg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UiFJvCTYMdnHYwZpwstOjBKQXQKjPFYXU9dffbBvh5BeaSmwPgFZdw+ZhEEpYRJZI5dPau9dBjD0IJIneQvaDQGHPds3A9m8mTlLfQpq2BQ4QHXQ07BCY0ZMxIvV+tpUW+uY95oHMp24ihVsgLDJNWzWVjpWUEgJFWzqeWd2ofxJFVSRI0gEhAyFD4Jf4pmD3aujo46A1T0u1kE+Xs4oz6+KTWwMK8B/rUq2neQD6URe2Q1BtTkVo7+tlRkfM8ZKS6blkCrXBANj3452Ha51eJZgcA55aMKZ5WCvc9GbzU9i1rLg+oOWWcMD3eLCMPiCbec34V1bdjmcJyVLTIZvkQ==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
- Delivery-date: Mon, 17 Jul 2023 13:49:28 +0000
- Ironport-data: A9a23:CgVq+6MIBhKOVcTvrR2AlsFynXyQoLVcMsEvi/4bfWQNrUoq32AEx jdOWmCGbKnfMzbxeI91PIrn9kxVvpLUytcwGwto+SlhQUwRpJueD7x1DKtS0wC6dZSfER09v 63yTvGacajYm1eF/k/F3oDJ9CU6jufQAOKnUoYoAwgpLSd8UiAtlBl/rOAwh49skLCRDhiE/ Nj/uKUzAnf8s9JPGjxSs/vrRC9H5qyo42tH5wNmPJingXeF/5UrJMNHTU2OByOQrrl8RoaSW +vFxbelyWLVlz9F5gSNy+uTnuUiG9Y+DCDW4pZkc/HKbitq/0Te5p0TJvsEAXq7vh3S9zxHJ HehgrTrIeshFvWkdO3wyHC0GQkmVUFN0OevzXRSLaV/ZqAJGpfh66wGMa04AWEX0tlMK2JW9 uEIFDAISxS4v8mdyo68c+Y506zPLOGzVG8ekldJ6GmDSM0AGNXESaiM4sJE1jAtgMwIBezZe 8cSdTtoalLHfgFLPVAUTpk5mY9EhFGmK2Ee9A3T+PVxvzK7IA9ZidABNPLPfdOHX4NNl1uwr WPa5WXpRBodMbRzzBLcqyP027aUwXKTtIQ6FKaY39cx336oyjYwMBYYd3KwsablhRvrMz5YA wlOksY0loAi+UruQtTjUhmQpH+fogVaS9dWC/c96gyG1uzT+QnxLncAZi5MbpohrsBebT4lz FiShPvyGCdi9raSTBqgGqy8qDqzPW0OKzYEbCpcFw8duYG/+sc0kw7FSctlHOitlNrpFDrsw jeM6i8jm7EUis1N3KK+lbzavw+RSlHyZlZdzm3qsqiNt2uVuKbNi1SU1GXm
- Ironport-hdrordr: A9a23:Qef5Aqykf3thkdQ4ghChKrPw3L1zdoMgy1knxilNoHxuH/Bw9v re+8jzsCWftN9/Yh4dcLy7VpVoBEmslqKdgrNhWYtKPjOHhILAFugLgbcKgQeQeREWntQ36U 4KSdkaNDSfNzlHZcaR2njFLz4jquP3j5xBU43lvglQpQIBUdAQ0+9gYDzrdHGf3GN9dOAE/J z33Ls/mxOQPU45Q+6cHXc/U+3Kt7Tw5e/biU5vPW9e1OGW5wnYk4LHLw==
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Thu, Jul 13, 2023 at 04:14:30PM +0100, Andrew Cooper wrote:
> On 11/07/2023 10:22 am, Roger Pau Monne wrote:
> > diff --git a/tools/libs/guest/xg_cpuid_x86.c
> > b/tools/libs/guest/xg_cpuid_x86.c
> > index 5b035223f4f5..5e5c8124dd74 100644
> > --- a/tools/libs/guest/xg_cpuid_x86.c
> > +++ b/tools/libs/guest/xg_cpuid_x86.c
> > @@ -423,10 +423,169 @@ static int xc_cpuid_xend_policy(
> > return rc;
> > }
> >
> > +static int compare_msr(const void *l, const void *r)
> > +{
> > + const xen_msr_entry_t *lhs = l;
> > + const xen_msr_entry_t *rhs = r;
> > +
> > + if ( lhs->idx == rhs->idx )
> > + return 0;
> > +
> > + return lhs->idx < rhs->idx ? -1 : 1;
>
> The sum total of logic here is just
>
> return lhs->idx - rhs->idx;
>
> (I think. Double check which way around the subtraction works.)
Since MSR index is a 32bit value, what about one index being ~0u and
the other 0u: the result would then wrongly be -1 ((int)(~0u - 0u)),
when it should instead be a positive value to denote the left hand
side is greater than the right hand side.
Thanks, Roger.
|