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

Re: [PATCH] x86/hvm: Improve hvm_set_guest_pat() code generation again


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Date: Fri, 24 Mar 2023 12:15:58 +0000
  • 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=6+3AYN/G6DDqD5rYkzUHJWi9jP6p/gpjXT027LhFltw=; b=Dh1kWPQqyPvo+X1TC20yfb8XEbIr8kp0ViYWlcbRhcA3wt3HE/3q4qqU/MDRw0PLGsb8T+r1nOS8efu+QZncRkV4mca21iytHWjg6opJXAsi2uv4Uw9r0gZyJaLz67rxbMqpwv2ubfH5sEeOsKk79SlQY9W3tGeyfa8ex1pBFjyCfoJ1Zptfgs64y+lVj8LMm8B4naW5X8E9h7+kgFc62wAMcBZgACSn9b/3H+YEzNQFM3Um9MOWkjtkWnnT3jtx+GKXN9Z457ETIMeo5QwaOdnw1nEAOBeI1OYCN8uo85r/Mp7pKnBIVOA1oXgI6Hlkxe8OyDKcYrBv2RzT2KHBWQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ciV+xoz3q+gXo4IDG48Ao40yZdANjPo5fanExoF5M1+S2wpFg7KumDwYHOrrYTtYNhFBeUBNzla6m/NiHBOWAB/YrC42RWkqS46zfgglwfQN38rL9V2pl4EMyVv2fZyNxzfB34xdBzhYCNLk54MDyS5WyOHbhySgBruu7JixZ24YrgmPMvcmxGQJlg6Mpa3pidjpFvtFCn8uim79Q7Mm5OCYub79kCUz68zEUzfVOD+CI1fLlI5A09zHTO+G1QDUwhAvaJPF4jOFjXfLYMbtrhZujKekO3i05xG1V3nWG5H75MLRZMVdoDsjet/UxRHckBk2uwMvmKJj3YQSOzanrA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Delivery-date: Fri, 24 Mar 2023 12:16:23 +0000
  • Ironport-data: A9a23:48zmAKu4OjMov8+WGB4UMrRSfufnVFlfMUV32f8akzHdYApBsoF/q tZmKTrSOfuOMGf3ed10Yd/l9EtSsJ+EzodnQFRs/y4zESoW+JbJXdiXEBz9bniYRiHhoOCLz O1FM4Wdc5pkJpP4jk3wWlQ0hSAkjclkfpKlVKiffHg3HVQ+IMsYoUoLs/YjhYJ1isSODQqIu Nfjy+XSI1bg0DNvWo4uw/vrRChH4bKj6Fv0gnRkPaoQ5ASEyyFMZH4iDfrZw0XQE9E88tGSH 44v/JnhlkvF8hEkDM+Sk7qTWiXmlZaLYGBiIlIPM0STqkAqSh4ai87XB9JFAatjsB2bnsgZ9 Tl4ncfYpTHFnEH7sL91vxFwS0mSNEDdkVPNCSDXXce7lyUqf5ZwqhnH4Y5f0YAwo45K7W9yG fMwOSINUyqFluWK7423Zrh0vpoOPdG0M9ZK0p1g5Wmx4fcOZ7nmGvyPz/kImTA6i4ZJAOrUY NcfZXx3dhPcbhZTO1ARTpUjgOOvgXq5eDpdwL6XjfNvvy6Pk0osgP60bou9lt+iHK25mm6xo G7c8nu/KRYdLNGFkhKO8262h/+JliT+MG4XPOTgrKc63gDLnAT/DjUxCEKgqKmakHSzfN5HK UtL6wg/oqYboRnDot7VGkfQTGS/lg4RXZ9cHvM37CmJy7HI+ECJC24cVDlDZdc68sgsSlQXO kShmtroAXlltu2TQHfEr7OM92rsaG4SMHMIYjICQU0d+d7/rYovjxXJCNF+DKqyid6zEjb1q 9yXkBUDa3wopZZj/82GEZrv2mLESkThJuLt2jjqYw==
  • Ironport-hdrordr: A9a23:7npTGq1y5jXys0/DKDSY4AqjBIwkLtp133Aq2lEZdPU1SK2lfq WV954mPHDP+VUssR0b9OxoQZPwJ080lqQa3WByB9uftWDd0QOVxOsL1/qa/9SKIULDH4BmtZ uJf8BFeb/N5VUTt7ec3OGze+xQpeVu/8iT9IPj80s=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 24/03/2023 9:32 am, Jan Beulich wrote:
> On 24.03.2023 01:59, Andrew Cooper wrote:
>> On 19/12/2022 7:28 am, Jan Beulich wrote:
>>> On 16.12.2022 21:53, Andrew Cooper wrote:
>>> Again - one way to look at things. Plus, with Demi's series now also in
>>> mind, what's done here is moving us in exactly the opposite direction.
>>> Is this hot enough a function to warrant that?
>> Yes - from the first cset, 9ce0a5e207f3 - it's used on virtual
>> vmentry/exit so is (or will be) reasonably hot in due course.
>>
>> What is more important in the short term is avoiding the catastrophic
>> code generation that Clang still does with default Xen build settings,
>> also linked from the commit message.
>>
>>>>>> --- a/xen/arch/x86/hvm/hvm.c
>>>>>> +++ b/xen/arch/x86/hvm/hvm.c
>>>>>> @@ -302,24 +302,43 @@ void hvm_get_guest_pat(struct vcpu *v, u64 
>>>>>> *guest_pat)
>>>>>>          *guest_pat = v->arch.hvm.pat_cr;
>>>>>>  }
>>>>>>  
>>>>>> -int hvm_set_guest_pat(struct vcpu *v, uint64_t guest_pat)
>>>>>> +/*
>>>>>> + * MSR_PAT takes 8 uniform fields, each of which must be a valid 
>>>>>> architectural
>>>>>> + * memory type (0, 1, 4-7).  This is a fully vectorised form of the
>>>>>> + * 8-iteration loop over bytes looking for PAT_TYPE_* constants.
>>>>> While grep-ing for PAT_TYPE_ will hit this line, I think we want
>>>>> every individual type to also be found here when grep-ing for one.
>>>>> The actual values aren't going to change, but perhaps the beast
>>>>> way to do so would still be by way of BUILD_BUG_ON()s.
>>>> Why?  What does that solve or improve?
>>>>
>>>> "pat" is the thing people are going to be looking for if they're
>>>> actually trying to find this logic.
>>>>
>>>> (And I bring this patch up specifically after reviewing Demi's series,
>>>> where PAT_TYPE_* changes to X86_MT_* but "pat" is still the useful
>>>> search term IMO.)
>>> I don't think "PAT" is a good thing to grep for when trying to find uses
>>> of particular memory types.
>> This is not a logical use of a particular memory type.  Being an
>> architectural auditing function, the only legitimate use of these
>> constants here is all of them at once.  This is the one place you firmly
>> don't care about finding when asking the question "How does Xen go about
>> handling WP mappings".
>>
>> I have swapped PAT_TYPE_* for X86_MT_* now that Demi's series has been
>> committed, but that is the extent to which I think there are relevant
>> changes to be made.
> In the interest of getting the code gen issue addressed, but without
> being fully convinced this is a good move:
> Acked-by: Jan Beulich <jbeulich@xxxxxxxx>

Thankyou.

~Andrew



 


Rackspace

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