[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: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 24 Mar 2023 10:32:02 +0100
  • 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=/eb9zZBdVD9kLbjQiVzrnk6F6uIDZ0JTkaxciTQ9YVU=; b=Zl3IWdzP5ZwpxBzxnHzZRoDfW7Xls6/vYwDHxlJ1obWs6c+SXQokpNCL1GjczpcrDos/m7AgI9NpLx/U0hSr1E2kHDJYe7Ba8duHAnOGGrAAypvs5Tehsv9mP4YdikFiskjhdxkugoTeRljDNh+GPtRc+7iikuTf7/UkjrGqQ5ffAj94bdP2lXC5QcMGaU4TtjN49MUJRUAud99RBhqOkm1c42fayM6SrMGBZH83jgzRJjiBrxtd+WhoPiN2cZ7dpFD5Y/tgQV9vSE8x42/Rx1xerMRJdKPmdy/xHZAokyc955g1LJm4cFbZxf84ZgbZfeB7nFRHT8noP7alyS5m9g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OkznySi0NABaabY4ddk84/iOGN5ByI9EmBFmq1O0fOT0kvt6MggfgicULO4zP8zGygGdpDqwCll8qRhT3BkOCuyqaUzsHJj+pbOkDWTocSxODfSHVB5jWGmF6HiigAxVzt0V0Jh9j1R2ixencqopAoyMw8L055+3RNvCx7cnwjl0IkEdiJwUDhYwjnGFUEzhM5M62WOemCuRAWg+qa6EXL5JLBTwzQBuHkduZvuiJFGuIQJ11IN96o2xLgdcvteHSTfx+XoJldcXFr5qgflB4wpZM16g692qTKsuJ8W3OO4wpmfU9khOlTnTobPk/GfbDihJDwbjPHgGp/ynNcHpKA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Demi Marie Obenour <demi@xxxxxxxxxxxxxxxxxxxxxx>, Edwin Torok <edvin.torok@xxxxxxxxxx>
  • Delivery-date: Fri, 24 Mar 2023 09:32:15 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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>

Jan



 


Rackspace

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