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

Re: [PATCH 6/8] x86/shadow: adjust and move sh_type_to_size[]


  • To: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 22 Dec 2022 09:27:05 +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=W+ndfufsbCvvr6VDuB9yDWu7QNF6veOi+RYiSRjzuxo=; b=aE2NYeoza6d6/6tiT0KiAyoM2CJNFDr8He7SqQEAaznxn34ijTNsWw+Pocz7G4fVUPnYXQ4jyu3+1simYeCimuaSMMJgHj7CiYUqqP4BQrlQg00X/NLuXnbMyX2QnIaxQgxgR1HLpa7+NQKIFOSTZzdtKUnKct2acGDzi+IxPQjNwsyJPwPWsDVBXwduPuYjTe6P2k3CnGcHLrbmdnoy8NtdzSt7WAFnn+IuwPdf47xn42SzJxNWui2pQ0KNB73YS8b2sP1toQ8OhBtC0HYo3jCe2DTjvLqWlqHjYOqAQNfQ9o82LDBTsm7/tIGnu1I/aTH9dSqgmBimu3WnKW1uYQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KFuDR7fMaYkzoo8yt3k/BG3fOa5aNLLkRb6tcseQaV1Q2TZpWuS/4kwGAk1FNOxiyZ2y+azchT45gstYNBY1mfkVKNLO4oQb9Amj0zR5/dIrvlRYcwUNwIWBNQByJk6K9rlXs7rFrd26mWv8cCFZLs9eXSvg6XoSiJoLgH9//d1CM/yDhs1pXkhe7ELqODORK5JNJ4vAi0kXjxMvRqcrbPgGWmhFZ4g3XBIHbWv9uDzd8gnvAFLMPTZJdTIIPKs4lXwvcIyY9xpdOlm6FM0r2eSq2robjpxQqjRQ5+HkU85g9hFOP3kvJxznqnh2LVpedNLMmh7kdsASXpeJilgWAA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Wei Liu <wl@xxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, George Dunlap <George.Dunlap@xxxxxxxxxx>, "Tim (Xen.org)" <tim@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 22 Dec 2022 08:27:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 21.12.2022 19:58, Andrew Cooper wrote:
> On 21/12/2022 1:27 pm, Jan Beulich wrote:
>> Drop the SH_type_none entry - there are no allocation attempts with
>> this type, and there also shouldn't be any. Adjust the shadow_size()
>> alternative path to match that change. Also generalize two related
>> assertions.
>>
>> While there move the entire table and the respective part of the comment
>> there to hvm.c, resulting in one less #ifdef. In the course of the
>> movement switch to using designated initializers.
>>
>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> 
> Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, although ...

Thanks.

>> --- a/xen/arch/x86/mm/shadow/hvm.c
>> +++ b/xen/arch/x86/mm/shadow/hvm.c
>> @@ -33,6 +33,37 @@
>>  
>>  #include "private.h"
>>  
>> +/*
>> + * This table shows the allocation behaviour of the different modes:
>> + *
>> + * Xen paging      64b  64b  64b
>> + * Guest paging    32b  pae  64b
>> + * PV or HVM       HVM  HVM   *
>> + * Shadow paging   pae  pae  64b
>> + *
>> + * sl1 size         8k   4k   4k
>> + * sl2 size        16k   4k   4k
>> + * sl3 size         -    -    4k
>> + * sl4 size         -    -    4k
>> + */
>> +const uint8_t sh_type_to_size[] = {
>> +    [SH_type_l1_32_shadow]   = 2,
>> +    [SH_type_fl1_32_shadow]  = 2,
>> +    [SH_type_l2_32_shadow]   = 4,
>> +    [SH_type_l1_pae_shadow]  = 1,
>> +    [SH_type_fl1_pae_shadow] = 1,
>> +    [SH_type_l2_pae_shadow]  = 1,
>> +    [SH_type_l1_64_shadow]   = 1,
>> +    [SH_type_fl1_64_shadow]  = 1,
>> +    [SH_type_l2_64_shadow]   = 1,
>> +    [SH_type_l2h_64_shadow]  = 1,
>> +    [SH_type_l3_64_shadow]   = 1,
>> +    [SH_type_l4_64_shadow]   = 1,
>> +    [SH_type_p2m_table]      = 1,
>> +    [SH_type_monitor_table]  = 1,
>> +    [SH_type_oos_snapshot]   = 1,
> 
> ... this feels like it's wanting to turn into a (1 + ...) expression.  I
> can't see anything that prevents us from reordering the SH_type
> constants, but
> 
> 1 + (idx == 1 /* l1 */ || idx == /* fl1 */) + 2 * (idx == 3 /* l2 */);
> 
> doesn't obviously simplify further.

But that would then undermine the cases where the function returns 0,
which the two (generalized in this change) assertions actually check
for not having got back. This would also become relevant for the l2h
slot, which - if not right here (see the respective remark) - will
become zero in a subsequent patch when !PV32.

Jan



 


Rackspace

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