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

Re: [PATCH][4.15] x86: mirror compat argument translation area for 32-bit PV

  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Wed, 24 Feb 2021 19:04:17 +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-SenderADCheck; bh=+S08kt1XYIigAJjpZxrc427W49akKuhZHOZEMUi8LqY=; b=WmRxcy9JEnSbtfVmioayV+pxMYdPciotw6UfXriBjN0D7BRfHSHFihpEMHPn9mbn+w0mbpTvXcsO5hHOnAZvO3YQLsabelEQMQlB4/XlKWoVRzzMRn6NgrQ1PsuySTppCNtSIFP9S00AvVQe/H2G4T8kIhqsl0PAwlikptlgBWqbs8dxJgJIjtk0cehRw7jAYR+WidHUouvjKfvpn6u5oC0dJ5z7vold2jpDfvZYMOX1uXUG75PF2wojsr2/bGP/5aKXOt2OFQeEbW90geNQlQqMYO8DI7BMqKrbWZKGYb7M+YmX53Lirp8nZTPSqQuTlWWoruk1bU7qBj5NeNtd4Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fB3bwUapHfEHx1Sus/NHHhu/UiHMe0n1WpdFfeFnyys8PPb/dalEPO32lZ5Kc0pSV6oEOIbF4c6hLLgwwOL8DoCjCDa8+KY+FP+bxye/7KBeLVj4oZHXrsU2+Bfx1dHoXnKi+FMNOawn0XHbdd3mlce1JST4OLj//iAqbNZluuNpooFbFux4TNNqCpsOwKesZNg+MWYfOLrAg1yNGZQdfi+Bqssl9801nl2xYJ9tSfGIzKkS8XKhK0D/O35UXZtAt5A0PfYHEmiFkvRWkr7uFkye5yV1JiBqgYDtd6GA2XhMm6TGHA/je4BvT+3bRctLPZWwbTNX/Zr9fvpd/OGcGQ==
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 24 Feb 2021 19:04:40 +0000
  • Ironport-sdr: xLylNo1rfKRRGvIiFgG6mAtzCUGpPlTFerFdRTdbOHusavtsDwkEooBbklIIBbBznC/GbNUpPc 20///Z3eja9/CuhA5Wj4gHGevn/QJztixP5MYTVz/lUGQD+vA83K+a/fZjVn83HQCZIhMbv0YH Nxn2lAN3GeCf/pjS383/ERzS4AJANBSN7fG/sCg+b1sBwIaQVwW03u5D3LWsrIVe42y2b0T0lz RhanjGyyg24Jnpp5TXJ+oNDQf4mYXPqK1EqzqpTZ7TwpTLq5hEfHM0mEYSsF+Zg8mIK2zR3ICy 568=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 23/02/2021 07:13, Jan Beulich wrote:
> On 22.02.2021 17:47, Andrew Cooper wrote:
>> On 22/02/2021 14:22, Jan Beulich wrote:
>>> On 22.02.2021 15:14, Andrew Cooper wrote:
>>>> On 22/02/2021 10:27, Jan Beulich wrote:
>>>>> Now that we guard the entire Xen VA space against speculative abuse
>>>>> through hypervisor accesses to guest memory, the argument translation
>>>>> area's VA also needs to live outside this range, at least for 32-bit PV
>>>>> guests. To avoid extra is_hvm_*() conditionals, use the alternative VA
>>>>> uniformly.
>>>>> While this could be conditionalized upon CONFIG_PV32 &&
>>>>> CONFIG_SPECULATIVE_HARDEN_GUEST_ACCESS, omitting such extra conditionals
>>>>> keeps the code more legible imo.
>>>>> Fixes: 4dc181599142 ("x86/PV: harden guest memory accesses against 
>>>>> speculative abuse")
>>>>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>>>>> --- a/xen/arch/x86/mm.c
>>>>> +++ b/xen/arch/x86/mm.c
>>>>> @@ -1727,6 +1727,11 @@ void init_xen_l4_slots(l4_pgentry_t *l4t
>>>>>                 (ROOT_PAGETABLE_FIRST_XEN_SLOT + slots -
>>>>>                  l4_table_offset(XEN_VIRT_START)) * sizeof(*l4t));
>>>>>      }
>>>>> +
>>>>> +    /* Slot 511: Per-domain mappings mirror. */
>>>>> +    if ( !is_pv_64bit_domain(d) )
>>>>> +        l4t[l4_table_offset(PERDOMAIN2_VIRT_START)] =
>>>>> +            l4e_from_page(d->arch.perdomain_l3_pg, __PAGE_HYPERVISOR_RW);
>>>> This virtual address is inside the extended directmap.
>>> No. That one covers only the range excluding the last L4 slot.
>>>>   You're going to
>>>> need to rearrange more things than just this, to make it safe.
>>> I specifically picked that entry because I don't think further
>>> arrangements are needed.
>> map_domain_page() will blindly hand this virtual address if an
>> appropriate mfn is passed, because there are no suitability checks.
>> The error handling isn't great, but at least any attempt to use that
>> pointer would fault, which is now no longer the case.
>> LA57 machines can have RAM or NVDIMMs in a range which will tickle this
>> bug.  In fact, they can have MFNs which would wrap around 0 into guest
>> space.
> This latter fact would be a far worse problem than accesses through
> the last L4 entry, populated or not. However, I don't really follow
> your concern: There are ample cases where functions assume to be
> passed sane arguments. A pretty good (imo) comparison here is with
> mfn_to_page(), which also will assume a sane MFN (i.e. one with a
> representable (in frame_table[]) value. If there was a bug, it
> would be either the caller taking an MFN out of thin air, or us
> introducing MFNs we can't cover in any of direct map, frame table,
> or M2P. But afaict there is guarding against the latter (look for
> the "Ignoring inaccessible memory range" loge messages in setup.c).

I'm not trying to say that this patch has introduced the bug.

But we should absolutely have defence in depth where appropriate.  I
don't mind if it is an unrelated change, but 4.15 does start trying to
introduce support for IceLake and I think this qualifies as a reasonable
precaution to add.

> In any event - imo any such bug would need fixing there, rather
> than being an argument against the change here.
> Also, besides your objection going quite a bit too far for my taste,
> I miss any form of an alternative suggestion. Do you want the mirror
> range to be put below the canonical boundary? Taking in mind your
> wrapping consideration, about _any_ VA would be unsuitable.

Honestly, I want the XLAT area to disappear entirely.  This is partly
PTSD from the acquire_resource fixes, but was an opinion held from
before that series as well, and I'm convinced that the result without
XLAT will be clearer and faster code.

Obviously, that's not an option at this point in 4.15.

I'd forgotten that the lower half of the address space was available,
and I do prefer that idea.  We don't need to put everything adjacent
together in the upper half.




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