From: Julien Grall <julien.grall@linaro.org>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: Keir Fraser <keir@xen.org>,
patches@linaro.org, Tim Deegan <tim@xen.org>,
stefano.stabellini@citrix.com, Jan Beulich <jbeulich@suse.com>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH v4 08/11] xen/arm: Handle remove foreign mapping
Date: Mon, 16 Dec 2013 17:06:20 +0000 [thread overview]
Message-ID: <52AF330C.3050305@linaro.org> (raw)
In-Reply-To: <1387211584.21086.27.camel@kazak.uk.xensource.com>
On 12/16/2013 04:33 PM, Ian Campbell wrote:
> On Mon, 2013-12-16 at 16:26 +0000, Julien Grall wrote:
>> I have reworked this patch. I get a simpler patch:
>>
>> commit aab2e5d2ae7d0fa87c74cae2f22044f87be33f70
>> Author: Julien Grall <julien.grall@linaro.org>
>> Date: Fri Dec 13 16:51:03 2013 +0000
>>
>> xen/arm: Handle remove foreign mapping
>>
>> Modify get_page_from_gfn to take reference on foreign mapping. This will avoid
>> specific handling in the common code.
>>
>> Signed-off-by: Julien Grall <julien.grall@linaro.org>
>>
>> ---
>> Changes in v5:
>> - Remove specific p2m handling in common code
>> - Handle foreign mapping in get_page_from_gfn
>> Changes in v4:
>> - Split patch #6 from dom0 pvh series v6.2 to retrieve only common
>> code.
>> - Rework commit title
>> - Rename xen_rem_foreign_from_p2m in p2m_remove_foreign
>> - Get the mfn from the pte. We are not sure that maddr given in
>> parameters is valid
>> Changes in v3:
>> - Move put_page in create_p2m_entries
>> - Move xenmem_rem_foreign_from_p2m in arch/arm/p2m.c
>> Changes in v2:
>> - Introduce the patch
>>
>> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
>> index 39d8a03..f7bd7e2 100644
>> --- a/xen/arch/arm/p2m.c
>> +++ b/xen/arch/arm/p2m.c
>> @@ -317,10 +317,21 @@ static int create_p2m_entries(struct domain *d,
>> break;
>> case REMOVE:
>> {
>> - lpae_t pte;
>> + lpae_t pte = third[third_table_offset(addr)];
>> + unsigned long mfn;
>> +
>> + maddr = (pte.bits & PADDR_MASK & PAGE_MASK);
>
> I thought we had a macro for this, but apparently not. While looking for
> it I spotted that x86 has pte_to_mfn, which sounds like a useful
> innovation... (not essential as part of this series though).
>
>> + mfn = paddr_to_pfn(maddr);
>> +
>> + /* TODO: Handle other p2m type */
>> + if ( pte.p2m.valid && p2m_is_foreign(pte.p2m.type) )
>> + {
>> + ASSERT(mfn_valid(mfn));
>
> Something somewhere is making sure we don't put foreign MMIO regions
> into the p2m, right?
I misread this part. And the answer is still yes because in this case
MMIO won't belong to a domain (there is no reference on it), so get_page
will return NULL when the foreign mapping is created in
xenmem_add_to_physmap_one.
>> + put_page(mfn_to_page(mfn));
>> + }
>> +
>> memset(&pte, 0x00, sizeof(pte));
>> write_pte(&third[third_table_offset(addr)], pte);
>> - maddr += PAGE_SIZE;
>> }
>> break;
>> }
>> diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
>> index 0eb07a8..e0b58da 100644
>> --- a/xen/include/asm-arm/p2m.h
>> +++ b/xen/include/asm-arm/p2m.h
>> @@ -122,9 +122,21 @@ static inline struct page_info *get_page_from_gfn(
>> if ( !mfn_valid(mfn) )
>> return NULL;
>> page = mfn_to_page(mfn);
>> - if ( !get_page(page, d) )
>> - return NULL;
>> - return page;
>> +
>> + if ( get_page(page, d) )
>
> This isn't noisy (even at debug level) on failure, I thought so?
>
> Might be safer (and TBH more logical) to move it after the foreign
> special case.
>
>> + return page;
>> +
>> + /* get_page won't work on foreign mapping because the page doesn't
>> + * belong to the current domain.
>> + */
>> + if ( p2mt == p2m_map_foreign )
>> + {
>> + struct domain *fdom = page_get_owner_and_reference(page);
>> + ASSERT(fdom != NULL);
>
> ASSERT(fdom != d)
> ?
>
>> + return page;
>> + }
>> +
>> + return NULL;
>> }
>>
>> int get_page_type(struct page_info *page, unsigned long type);
>>
>
>
--
Julien Grall
next prev parent reply other threads:[~2013-12-16 17:06 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-13 19:37 [PATCH v4 00/11] xen/arm: Handle correctly foreign mapping Julien Grall
2013-12-13 19:37 ` [PATCH v4 01/11] pvh dom0: Introduce p2m_map_foreign Julien Grall
2013-12-13 23:19 ` Ian Campbell
2013-12-14 0:00 ` Julien Grall
2013-12-16 10:45 ` Ian Campbell
2013-12-16 10:59 ` Tim Deegan
2013-12-16 17:15 ` Julien Grall
2013-12-16 11:04 ` George Dunlap
2013-12-13 19:37 ` [PATCH v4 02/11] xen/arm: Introduce steps in domain_relinquish_resource Julien Grall
2013-12-13 19:37 ` [PATCH v4 03/11] xen/arm: move mfn_to_p2m_entry in arch/arm/p2m.c Julien Grall
2013-12-13 19:37 ` [PATCH v4 04/11] xen/arm: Implement p2m_type_t as an enum Julien Grall
2013-12-13 19:37 ` [PATCH v4 05/11] xen/arm: Store p2m type in each page of the guest Julien Grall
2013-12-13 19:37 ` [PATCH v4 06/11] xen/arm: p2m: Extend p2m_lookup parameters to retrieve the p2m type Julien Grall
2013-12-13 19:37 ` [PATCH v4 07/11] xen/arm: Retrieve p2m type in get_page_from_gfn Julien Grall
2013-12-13 19:37 ` [PATCH v4 08/11] xen/arm: Handle remove foreign mapping Julien Grall
2013-12-16 11:51 ` Tim Deegan
2013-12-16 11:55 ` Ian Campbell
2013-12-16 15:26 ` Tim Deegan
2013-12-16 15:34 ` Julien Grall
2013-12-16 15:40 ` Ian Campbell
2013-12-16 16:26 ` Julien Grall
2013-12-16 16:33 ` Ian Campbell
2013-12-16 16:40 ` Julien Grall
2013-12-16 17:06 ` Julien Grall [this message]
2013-12-16 17:21 ` Ian Campbell
2013-12-16 17:14 ` Julien Grall
2013-12-16 17:18 ` Ian Campbell
2013-12-13 19:37 ` [PATCH v4 09/11] xen/arm: Add relinquish_p2m_mapping to remove reference on every mapped page Julien Grall
2013-12-13 19:37 ` [PATCH v4 10/11] xen/arm: Set foreign page type to p2m_map_foreign Julien Grall
2013-12-13 19:37 ` [PATCH v4 11/11] xen/arm: grant-table: Support read-only mapping Julien Grall
2013-12-14 0:01 ` [PATCH v4 00/11] xen/arm: Handle correctly foreign mapping Julien Grall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52AF330C.3050305@linaro.org \
--to=julien.grall@linaro.org \
--cc=Ian.Campbell@citrix.com \
--cc=jbeulich@suse.com \
--cc=keir@xen.org \
--cc=patches@linaro.org \
--cc=stefano.stabellini@citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.