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

Re: [PATCH v3 9/9] x86/P2M: relax permissions of PVH Dom0's MMIO entries


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 23 Sep 2021 14:15:25 +0200
  • 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; bh=ExwpCERfHVHuyBQ4YOWGVqCv6sGKRn/7ZIEZKUo9moE=; b=Wtoabq85ED9akWW9+8pgCXbs2+eKXoTp2mOMCJWX3vpxN6RM6Fok5NtjciEfAyChAL3rN3mMeafycCuAhL09l3liCVjcU0ETeISFdV0QWYav5Xk4g/WdZBNsNlkfpLJNjT0DoZqjxtdAq8s1nXsjez/ncFHlsK8gPRUgczUz5SV5fyemVaQlqw6nhzr7KTGS0jPBTnibm+H9ma6pFuAuAWVMlfbzjxH13vwWwj4oj+KQUQp5dRi5CkPlsK7jC27IoXCxF8Ipv3v96ucxHeXAZ5INL+Rcx8ptPPwyyacZbFj3+j0zPpTph1Lzt0WS/V2VpkgdSXx7ffvm1wsvfnqedg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iACBpTn7+EAyj9VpDsNsuhmci9zCGAycBl8yGq30EBcFEzDkZxlEqqOvlsszL1pB+c0r88MCDAOOeqlAqkX2bNDNn2Hd3HITgWL0v5+BKokMhZUj3T+0KFzEh6V1PwzZgHzhRlSGrm0p+F+jiUNc7IHcUJmaL79PsdrEFpdrtTDJgl96TpblqGTAm35Dg1XBvHFR+4HHtuEE3Fiu1pgB4mySAF+WscMfZNRAfya4dthQGz0LL7GA6Lf6z3AnYBK+CFGfIDwAoAQuz91xDhD+q+1/RBiDM3q9AeyRadJ7+cm/t8XUwRQwjvNkUQhgJa+Tbvq7DJbPWxE5dvFq+osrAQ==
  • Authentication-results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; dmarc=none action=none header.from=suse.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>
  • Delivery-date: Thu, 23 Sep 2021 12:15:37 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 23.09.2021 13:54, Roger Pau Monné wrote:
> On Thu, Sep 23, 2021 at 01:32:52PM +0200, Jan Beulich wrote:
>> On 23.09.2021 13:10, Roger Pau Monné wrote:
>>> On Tue, Sep 21, 2021 at 09:21:11AM +0200, Jan Beulich wrote:
>>>> --- a/xen/arch/x86/mm/p2m.c
>>>> +++ b/xen/arch/x86/mm/p2m.c
>>>> @@ -1319,6 +1319,18 @@ static int set_typed_p2m_entry(struct do
>>>>              return -EPERM;
>>>>          }
>>>>  
>>>> +        /*
>>>> +         * Gross bodge, to go away again rather sooner than later:
>>>> +         *
>>>> +         * For MMIO allow access permissions to accumulate, but only for 
>>>> Dom0.
>>>> +         * Since set_identity_p2m_entry() and set_mmio_p2m_entry() differ 
>>>> in
>>>> +         * the way they specify "access", this will allow the ultimate 
>>>> result
>>>> +         * to be independent of the sequence of operations.
>>>
>>> Wouldn't it be better to 'fix' those operations so that they can work
>>> together?
>>
>> Yes, but then we should do this properly by removing all abuse of
>> p2m_access_t.
> 
> I'm not sure I follow what that abuse is.

As was clarified, p2m_access_t should be solely used by e.g.
introspection agents, who are then the entity responsible for
resolving the resulting faults. Any other uses (to e.g. merely
restrict permissions for other reasons) are really abuses. That
is, if e.g. a r/o direct-MMIO mapping is needed, this should not
be expressed as (p2m_mmio_direct, p2m_access_r) tuple, but would
require a distinct p2m_mmio_direct_ro type.

>>> It's my understanding that set_identity_p2m_entry is the one that has
>>> strong requirements regarding the access permissions, as on AMD ACPI
>>> tables can specify how should regions be mapped.
>>>
>>> A possible solution might be to make set_mmio_p2m_entry more tolerant
>>> to how present mappings are handled. For once that function doesn't
>>> let callers specify access permissions, so I would consider that if a
>>> mapping is present on the gfn and it already points to the requested
>>> mfn no error should be returned to the caller. At the end the 'default
>>> access' for that gfn -> mfn relation is the one established by
>>> set_identity_p2m_entry and shouldn't be subject to the p2m default
>>> access.
>>
>> I think further reducing access is in theory supposed to be possible.
> 
> Couldn't an access reduction introduce issues, kind of similar to what
> would happen if the regions are unmapped? (and that XSA-378 addressed)
> 
> I think whatever permissions set_identity_p2m_entry sets should be
> mandatory ones, and no changes should be allowed. That would maybe
> require introducing a new p2m type (p2m_mmio_mandatory) in order to
> differentiate firmware mandatory MMIO mappings from the rest.

Hmm, indeed. No deviation in either direction should be permitted.

Jan




 


Rackspace

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