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

Re: [PATCH RFC 0/9] x86: Merge cpuid and msr policy


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 30 Mar 2023 16:43:43 +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=pBmGcunSnTSN+LCjGzQyIiwP8JZ3jQ2WREZ87h1YaHI=; b=AdnB9Se7Kv0hx6R+gxwUGHHKEqgbRiF0wi3t1eTtji01UkEipmbT531ffcztlTOewtkEh35VCaJsms/8Xg+zSuz7AiEbIKOTlOFYCnxu+S074pG8emCw5sOvMMuN61WlIWcWMhusxnKnJ1tcDBgI4hNW7vZCe5BBDqsmURo63MrWF04CWQ9h3prYscKwdi07+Ryimh4A9n2m98TzhW773RJJfVuP+uvLKUTUePsXwltVOHu4ph4XI93w895ztk0hUpKes3ogXzfPoqJtsZsr/BAfzMCISkF3VpoBMkFykqsJjIeUm8fxZtHItK6gfrispX8JvE3doj6PsdgausUraw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RsluwsBEHm318guvOkyAYFdqnCqiZua/xbfwpsMrl+6gzmyvPNRLpLMJNZmfUQ9MWIAJMCCfrxCNSzQ7LhgREmQ21H3yqfCvrUib9v7K8SRqMNSFWAck5YItAWBoKuSvO+2x7ZtTC9tx9T+i1h1+k3tVIjPr+4yRHKc773yWGH0BIT2TXzuVAGwWeIXhaQcYGJ6Ni0QjZJUOw6srZdKkdr17YV8rYTLXZu3wtHyIu5JnROCF9jESfwKCxfhLtEcQpGuTWtZWa1NrSKjGFYHVwUcFpu6by3WEcfe4KzvMi7pQ+kv4KaebABOCPG4mLlk2AEPUzD7qHTjK9NmRUn1udg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Thu, 30 Mar 2023 14:44:26 +0000
  • Ironport-data: A9a23:t65HPqAahRrkNBVW/w/iw5YqxClBgxIJ4kV8jS/XYbTApD4h1zYBm mFMUG2BO6mDajH8L9skYNzkpEgOvsDVm4UyQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8nk/nOHuGmYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbyRFu8pvlDs15K6p4GhD5gRkDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIwwblTMVhs+ NokDi0payHcmfyqwu6qc7w57igjBJGD0II3nFhFlGucIdN4BJfJTuPN+MNS2yo2ioZWB/HCa sEFaD1pKhPdfxlIPVRRA5U79AuqriCnL3sE9xTI9OxuvDO7IA9ZidABNPLPfdOHX4NNl1uwr WPa5WXpRBodMbRzzBLcqinz3LWWxH2TtIQ6SJin/9pQnwWvmWUoAgYGcGCjq8CAoxvrMz5YA wlOksY0loAi+UruQtTjUhmQpH+fogVaS9dWC/c96gyG1uzT+QnxLkouQyNFadcmnNQrXjFs3 ViM9/v2ARR/vbvTTmiSnop4thu3MCkRaGMHOykNSFJf58G5+d5oyBXSUtxkDai5yMXvHi39y CyLqy54gKgPickM1OOw+lWvby+Qm6UlhzUdvm3/Nl9JJCsgDGJ5T+REMWTm0Ms=
  • Ironport-hdrordr: A9a23:MAhplKB4v0Pp1OnlHemh55DYdb4zR+YMi2TDtnoBLiC9F/bzqy nApoV56faZslYssRIb+OxoWpPwI080nKQdieIs1NyZLWzbUQWTXeVfBEjZrwEI2ReSygeQ78 hdmmFFZuHNMQ==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Mar 30, 2023 at 01:59:37PM +0100, Andrew Cooper wrote:
> On 30/03/2023 12:07 pm, Roger Pau Monné wrote:
> > On Wed, Mar 29, 2023 at 09:51:28PM +0100, Andrew Cooper wrote:
> >> tl;dr to add MSR_ARCH_CAPS features sensibly, cpu_{featureset<->policy}() 
> >> need
> >> to not operate on objects of differing lifetimes, so structs
> >> {cpuid,msr}_policy need merging and cpu_policy is the obvious name.
> > So the problem is that there's a chance we might get a cpu_policy
> > object that contains a valid (allocated) cpuid object, but not an msr
> > one?
> 
> No - not cpu_policy.  It is that we can get a cpuid_policy and an
> msr_policy that aren't at the same point in their lifecycle.
> 
> ... which is exactly what happens right now for the raw/host msr right
> now if you featureset_to_policy() to include MSR data.

I see, but that's mostly because we handle the featureset_to_policy()
in two different places for CPUID vs MSR, those need to be unified
into a single helper that does both at the same point.

I assume not having such pointers in side of cpu_policy makes it
clearer that both msr and cpuid should be handled at the same time,
but ultimately this would imply passing a cpu_policy object to
featureset_to_policy() so that both CPUID and MSR sub-structs are
filled from the same featureset.

Sorry, maybe I'm being a bit dull here, just would like to understand
the motivation of the change.

> Merging the two together into cpu_policy causes there to be a single
> object lifecycle.
> 
> 
> It's probably worth repeating the advise from the footnote in
> https://lwn.net/Articles/193245/ again.  Get your datastructures right,
> and the code takes care of itself.  Don't get them right, and the code
> tends to be unmaintainable.
> 
> 
> >> But this does mean that we now have
> >>
> >>   cpu_policy->basic.$X
> >>   cpu_policy->feat.$Y
> >>   cpu_policy->arch_caps.$Z
> > I'm not sure I like the fact that we now can't differentiate between
> > policy fields related to MSRs or CPUID leafs.
> >
> > Isn't there a chance we might in the future get some name space
> > collision by us having decided to unify both?
> 
> The names are chosen by me so far, and the compiler will tell us if
> things actually collide.
> 
> And renaming the existing field is a perfectly acceptable way of
> resolving a conflict which arises in the future.
> 
> But yes - this was the whole point of asking the question.

I think I would prefer to keep the cpu_policy->{cpuid,msr}.
distinction if it doesn't interfere with further work.

Thanks, Roger.



 


Rackspace

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