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

Re: [PATCH] x86/shadow: sh_type_to_size[] needs L2H entry when HVM+PV32


  • To: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 23 Jan 2023 17:58:42 +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=0yHRVQxuv4tZGsOTtvADB08XHjyedRpuCMjpilpE5Nw=; b=Da3AfREpsmoC5mf5SC56I3+20W/kt4jYKx2wW3ub0yOe4qlyHiTiD9DmayIZOnbaor594F5ABk9i1WNvsxlrM3gQWQQhOmc7C461EPtUNHmIyo6KslUdXS/SwJ4eiLbV+xzzuWwZ/pVR36Rbi0ajGoC4/EFxnKuWWSj2nyUigAncjvL64bI0bJEmGhtXNeF/jEdah8GLKoF+u21FL4MouwdWTHdnbZtAzBmnN8XMlUn8DttOgW4EFSNjhZiuuXXrgOL7w8ocB+GK6x8q+IDw6cq/T1wrpM6ZJtWUS+lkTlczywFJNRJocIku2xrytC5tOkrDxnYQ2VbjAp6mAlEujg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kHeA42YueRqNfTfix+huWZ91uayUiqEYKjij3TTxZsj0OgFl521zI0LPTHPzeafaZ6l9wvOhi22d0jUe9xZkxBV3FtFv0ZDS9rz5Ff8E+1fo+aqpj72QPmH5Lsu2cdDQoQ8fZLCmZ43IdP7WRKQ4FYg3c936yQrL1048zJloAUYds4k+iFWoJeeyP5UO02MNQsakE18LPK7ELrgw2UgLAZuonQoG/razSe6DCmrYCYNqRS1skZWbsZOI785iVE3Ll6j3PMuG1mfatrSN1UCp46d+XYFbOBpC7Jg9RJ27TgrWAOvFFwpO97UFYA2yOsKXuF+0ULq1ttkOIxxu4SqScg==
  • 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>, "Tim (Xen.org)" <tim@xxxxxxx>, George Dunlap <George.Dunlap@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 23 Jan 2023 16:58:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 23.01.2023 17:56, Jan Beulich wrote:
> On 23.01.2023 13:49, Jan Beulich wrote:
>> On 23.01.2023 13:30, Andrew Cooper wrote:
>>> This is a layering violation which has successfully tricked you into
>>> making a buggy patch.
>>>
>>> I'm unwilling to bet this will be the final time either...  "this file
>>> is HVM-only, therefore no PV paths enter it" is a reasonable
>>> expectation, and should be true.
>>
>> Nice abstract consideration, but would mind pointing out how you envision
>> shadow_size() to look like meeting your constraints _and_ meeting my
>> demand of no excess #ifdef-ary? The way I'm reading your reply is that
>> you ask to special case L2H _right in_ shadow_size(). Then again see also
>> my remark in the original (now known faulty) patch regarding such special
>> casing. I could of course follow that route, regardless of HVM (i.e.
>> unlike said there not just for the #else part) ...
> 
> Actually no, that remark was about the opposite (!PV32) case, so if I
> took both together, this would result:
> 
> static inline unsigned int
> shadow_size(unsigned int shadow_type)
> {
> #ifdef CONFIG_HVM
> #ifdef CONFIG_PV32
>     if ( shadow_type == SH_type_l2h_64_shadow )
>         return 1;
> #endif
>     ASSERT(shadow_type < ARRAY_SIZE(sh_type_to_size));
>     return sh_type_to_size[shadow_type];
> #else
> #ifndef CONFIG_PV32
>     if ( shadow_type == SH_type_l2h_64_shadow )
>         return 0;
> #endif
>     ASSERT(shadow_type < SH_type_unused);
>     return shadow_type != SH_type_none;
> #endif
> }
> 
> I think that's quite a bit worse than using sh_type_to_size[] for all
> kinds of guest uniformly when HVM=y. This
> 
> static inline unsigned int
> shadow_size(unsigned int shadow_type)
> {
>     if ( shadow_type == SH_type_l2h_64_shadow )
>         return IS_ENABLED(CONFIG_PV32);

Which might better use opt_pv32 instead, if we really were to go this route.

Jan

> #ifdef CONFIG_HVM
>     ASSERT(shadow_type < ARRAY_SIZE(sh_type_to_size));
>     return sh_type_to_size[shadow_type];
> #else
>     ASSERT(shadow_type < SH_type_unused);
>     return shadow_type != SH_type_none;
> #endif
> }
> 
> is also only marginally better, as we really would better avoid any
> such open-coding.
> 
> Jan
> 




 


Rackspace

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