All of lore.kernel.org
 help / color / mirror / Atom feed
* file xen/include/xen/lib/x86/cpu-policy.h: Meaning of CPUID constants
@ 2024-05-06  7:46 Fonyuy-Asheri Caleb
  2024-05-06  8:13 ` Jan Beulich
  2024-05-06  8:34 ` Roger Pau Monné
  0 siblings, 2 replies; 5+ messages in thread
From: Fonyuy-Asheri Caleb @ 2024-05-06  7:46 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 859 bytes --]

Hi, 
I am currently doing a study on the way xen handles CPUID information. 

I came across these constants in the code (xen/include/xen/lib/x86/cpu-policy.h file) but no explanation of why they have been set that way. 

#define CPUID_GUEST_NR_BASIC (0xdu + 1) 
#define CPUID_GUEST_NR_CACHE (5u + 1) 
#define CPUID_GUEST_NR_FEAT (2u + 1) 
#define CPUID_GUEST_NR_TOPO (1u + 1) 
#define CPUID_GUEST_NR_XSTATE (62u + 1) 
#define CPUID_GUEST_NR_EXTD_INTEL (0x8u + 1) 
#define CPUID_GUEST_NR_EXTD_AMD (0x21u + 1) 

Please can someone explain to me why we have these constants or point to a documentation which explains it? 
I am particularly interested in the CPUID_GUEST_NR_BASIC given that for intel processors for example, we have 
basic leaves running up to 0x21u already for recent processors. This value sort of forces a particular max leaf value. 


Caleb 

[-- Attachment #2: Type: text/html, Size: 1417 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: file xen/include/xen/lib/x86/cpu-policy.h: Meaning of CPUID constants
  2024-05-06  7:46 file xen/include/xen/lib/x86/cpu-policy.h: Meaning of CPUID constants Fonyuy-Asheri Caleb
@ 2024-05-06  8:13 ` Jan Beulich
  2024-05-06  8:34 ` Roger Pau Monné
  1 sibling, 0 replies; 5+ messages in thread
From: Jan Beulich @ 2024-05-06  8:13 UTC (permalink / raw)
  To: Fonyuy-Asheri Caleb; +Cc: xen-devel

On 06.05.2024 09:46, Fonyuy-Asheri Caleb wrote:
> I came across these constants in the code (xen/include/xen/lib/x86/cpu-policy.h file) but no explanation of why they have been set that way. 
> 
> #define CPUID_GUEST_NR_BASIC (0xdu + 1) 
> #define CPUID_GUEST_NR_CACHE (5u + 1) 
> #define CPUID_GUEST_NR_FEAT (2u + 1) 
> #define CPUID_GUEST_NR_TOPO (1u + 1) 
> #define CPUID_GUEST_NR_XSTATE (62u + 1) 
> #define CPUID_GUEST_NR_EXTD_INTEL (0x8u + 1) 
> #define CPUID_GUEST_NR_EXTD_AMD (0x21u + 1) 
> 
> Please can someone explain to me why we have these constants or point to a documentation which explains it? 

These specify the number of (sub)leaves Xen supports, first and foremost to
dimension internal arrays accordingly. I.e. the "why" lies in the way they're
used.

> I am particularly interested in the CPUID_GUEST_NR_BASIC given that for intel processors for example, we have 
> basic leaves running up to 0x21u already for recent processors. This value sort of forces a particular max leaf value. 

Right, but support (for guests) for these needs properly enabling. Hence why
that limit is the way it is, for the time being.

Jan


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: file xen/include/xen/lib/x86/cpu-policy.h: Meaning of CPUID constants
  2024-05-06  7:46 file xen/include/xen/lib/x86/cpu-policy.h: Meaning of CPUID constants Fonyuy-Asheri Caleb
  2024-05-06  8:13 ` Jan Beulich
@ 2024-05-06  8:34 ` Roger Pau Monné
  2024-05-06  8:45   ` Fonyuy-Asheri Caleb
  1 sibling, 1 reply; 5+ messages in thread
From: Roger Pau Monné @ 2024-05-06  8:34 UTC (permalink / raw)
  To: Fonyuy-Asheri Caleb; +Cc: xen-devel

On Mon, May 06, 2024 at 09:46:58AM +0200, Fonyuy-Asheri Caleb wrote:
> Hi, 
> I am currently doing a study on the way xen handles CPUID information. 
> 
> I came across these constants in the code (xen/include/xen/lib/x86/cpu-policy.h file) but no explanation of why they have been set that way. 
> 
> #define CPUID_GUEST_NR_BASIC (0xdu + 1) 
> #define CPUID_GUEST_NR_CACHE (5u + 1) 
> #define CPUID_GUEST_NR_FEAT (2u + 1) 
> #define CPUID_GUEST_NR_TOPO (1u + 1) 
> #define CPUID_GUEST_NR_XSTATE (62u + 1) 
> #define CPUID_GUEST_NR_EXTD_INTEL (0x8u + 1) 
> #define CPUID_GUEST_NR_EXTD_AMD (0x21u + 1) 
> 
> Please can someone explain to me why we have these constants or point to a documentation which explains it? 
> I am particularly interested in the CPUID_GUEST_NR_BASIC given that for intel processors for example, we have 
> basic leaves running up to 0x21u already for recent processors. This value sort of forces a particular max leaf value. 

This is related to the maximum leaves supported in the cpu_policy
structure:

https://elixir.bootlin.com/xen/latest/source/xen/include/xen/lib/x86/cpu-policy.h#L122

For basic leaves (0x000000xx) we support up to leaf 0xd (XSTATE).  It
doesn't mean there are no further leaves behind it, but we likely
still have no use for them, and hence they are not part of the policy.
The cpu-policy is used to store a (cpuid) policy object for guests,
so if the information exposed in those leaves are related to features
that are never exposed to guests is makes no sense to have space for
them.

Regards, Roger.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: file xen/include/xen/lib/x86/cpu-policy.h: Meaning of CPUID constants
  2024-05-06  8:34 ` Roger Pau Monné
@ 2024-05-06  8:45   ` Fonyuy-Asheri Caleb
  2024-05-06  8:47     ` Jan Beulich
  0 siblings, 1 reply; 5+ messages in thread
From: Fonyuy-Asheri Caleb @ 2024-05-06  8:45 UTC (permalink / raw)
  To: Roger Pau Monné; +Cc: xen-devel

> From: "Roger Pau Monné" <roger.pau@citrix.com>
> To: "Fonyuy-Asheri Caleb" <fonyuy-asheri.caleb@inria.fr>
> Cc: "xen-devel" <xen-devel@lists.xenproject.org>
> Sent: Monday, May 6, 2024 10:34:20 AM
> Subject: Re: file xen/include/xen/lib/x86/cpu-policy.h: Meaning of CPUID constants

> On Mon, May 06, 2024 at 09:46:58AM +0200, Fonyuy-Asheri Caleb wrote:
>> Hi,
>> I am currently doing a study on the way xen handles CPUID information.
>> 
>> I came across these constants in the code (xen/include/xen/lib/x86/cpu-policy.h
>> file) but no explanation of why they have been set that way.
>> 
>> #define CPUID_GUEST_NR_BASIC (0xdu + 1)
>> #define CPUID_GUEST_NR_CACHE (5u + 1)
>> #define CPUID_GUEST_NR_FEAT (2u + 1)
>> #define CPUID_GUEST_NR_TOPO (1u + 1)
>> #define CPUID_GUEST_NR_XSTATE (62u + 1)
>> #define CPUID_GUEST_NR_EXTD_INTEL (0x8u + 1)
>> #define CPUID_GUEST_NR_EXTD_AMD (0x21u + 1)
>> 
>> Please can someone explain to me why we have these constants or point to a
>> documentation which explains it?
>> I am particularly interested in the CPUID_GUEST_NR_BASIC given that for intel
>> processors for example, we have
>> basic leaves running up to 0x21u already for recent processors. This value sort
>> of forces a particular max leaf value.
> 
> This is related to the maximum leaves supported in the cpu_policy
> structure:
> 
> https://elixir.bootlin.com/xen/latest/source/xen/include/xen/lib/x86/cpu-policy.h#L122
> 
> For basic leaves (0x000000xx) we support up to leaf 0xd (XSTATE).  It
> doesn't mean there are no further leaves behind it, but we likely
> still have no use for them, and hence they are not part of the policy.
> The cpu-policy is used to store a (cpuid) policy object for guests,
> so if the information exposed in those leaves are related to features
> that are never exposed to guests is makes no sense to have space for
> them.

So if I understand you well, you mean before extending this, we need to perform a study on the 
leaves to confirm how useful they are to the guests depending on the cpu information they carry. 

> 
> Regards, Roger.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: file xen/include/xen/lib/x86/cpu-policy.h: Meaning of CPUID constants
  2024-05-06  8:45   ` Fonyuy-Asheri Caleb
@ 2024-05-06  8:47     ` Jan Beulich
  0 siblings, 0 replies; 5+ messages in thread
From: Jan Beulich @ 2024-05-06  8:47 UTC (permalink / raw)
  To: Fonyuy-Asheri Caleb; +Cc: xen-devel, Roger Pau Monné

On 06.05.2024 10:45, Fonyuy-Asheri Caleb wrote:
>> From: "Roger Pau Monné" <roger.pau@citrix.com>
>> Sent: Monday, May 6, 2024 10:34:20 AM
> 
>> For basic leaves (0x000000xx) we support up to leaf 0xd (XSTATE).  It
>> doesn't mean there are no further leaves behind it, but we likely
>> still have no use for them, and hence they are not part of the policy.
>> The cpu-policy is used to store a (cpuid) policy object for guests,
>> so if the information exposed in those leaves are related to features
>> that are never exposed to guests is makes no sense to have space for
>> them.
> 
> So if I understand you well, you mean before extending this, we need to perform a study on the 
> leaves to confirm how useful they are to the guests depending on the cpu information they carry. 

It's not only question of usefulness, but of correctness. We can't blindly
expose leaves.

Jan


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-05-06  8:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-06  7:46 file xen/include/xen/lib/x86/cpu-policy.h: Meaning of CPUID constants Fonyuy-Asheri Caleb
2024-05-06  8:13 ` Jan Beulich
2024-05-06  8:34 ` Roger Pau Monné
2024-05-06  8:45   ` Fonyuy-Asheri Caleb
2024-05-06  8:47     ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.