[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 04/13] libx86: introduce helper to fetch msr entry


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 20 Jun 2023 16:28:56 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=nY56vCJtK6HYMPRlBFCMKcdJnc89l1zcE3IbZpM7mvY=; b=PXvLpVGpEeUXBa5uni8OrQB1ldz45lVtZ3pviDDm0EIDnhjohi/avcu9h2u4aIvP8tfiLKVmOt5SbNchTfyWXKUe3I4BOththxteA9TK0sNnT2KFtNJefGdJb6HyZ1Wlr7ntG0QbWyZoMptgXwp6oBdDs0npyGMOT+KdyfEPqvxZbuA+xKaFvMc4C6vVCc5x5uFdh1t+Qp87dPav4I0tXeRfRWn0GmtVcMP26lD5tx0v1jVrjxkAEY6IBLWXRrvo2uTw8hNjtAz3V56ZiXoAVUpzPTIeuI9rt+07sxzMDAkZA6wjHxI3XtkLk9+N2UuUK8IBiQWl36EqYqH4SESXAw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lI3Jyr3+/U49njRPEYOWpkIRZh5nbMpOOnenJ488UnsCxHzoH1cgNbWIICATHnrcvx73cPDnCiyEJh+xp6cJyECU1CpsfOe7OJ70Uxv8lDd5UzNH3Zte/qWH0GIiBJ6R1vsGYaHEqno4XexjZzSPz2vlbsVWyZSIJryUaCAnLFK943+oOjxX5aiFRjQIjLVe9nm9vMNvdIxaBwoW2tj5lDHSwnyaiXEcZTSYXnxtWHl8tpU5ZI1n6WZfw69uoFsAHuuWD6v81Hx/UFbDvo9tl1IHr52BICcyDZF+APcSKnvvE1sF+rbW9jgkiML4Zwrt8kl51BtMbK93AT6ZPy5Mkg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 20 Jun 2023 14:29:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 16.06.2023 15:10, Roger Pau Monne wrote:
> @@ -119,6 +103,21 @@ int x86_msr_copy_from_buffer(struct cpu_policy *p,
>      return rc;
>  }
>  
> +const uint64_t *x86_msr_get_entry_const(const struct cpu_policy *p,
> +                                        uint32_t idx)

I don't think idx needs to be of a fixed width type; unsigned int
ought to be quite fine.

> +{
> +    switch ( idx )
> +    {
> +    case MSR_INTEL_PLATFORM_INFO:
> +        return &p->platform_info.raw;
> +
> +    case MSR_ARCH_CAPABILITIES:
> +        return &p->arch_caps.raw;

Earlier on (also for the CPUID counterpart) a risky aspect of this
didn't occur to me: The validity of the returned pointer is tied
to the scope of the object the address of which was passed in. I'm
afraid this is an aspect which is easy to miss, and hence wants
calling out in the comments in cpu-policy.h (provided we're okay
to accept this risk in the first place).

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.