All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <JBeulich@suse.com>
To: Petre Ovidiu PIRCALABU <ppircalabu@bitdefender.com>
Cc: "Stefano Stabellini" <sstabellini@kernel.org>,
	"Wei Liu" <wl@xen.org>,
	"Razvan Cojocaru" <rcojocaru@bitdefender.com>,
	"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
	"George Dunlap" <George.Dunlap@eu.citrix.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	IanJackson <ian.jackson@eu.citrix.com>,
	"Tim Deegan" <tim@xen.org>, JulienGrall <julien.grall@arm.com>,
	"Paul Durrant" <Paul.Durrant@citrix.com>,
	"Tamas K Lengyel" <tamas@tklengyel.com>,
	"Alexandru Stefan ISAILA" <aisaila@bitdefender.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH v2 07/10] vm_event: Add vm_event_ng interface
Date: Wed, 31 Jul 2019 13:09:29 +0000	[thread overview]
Message-ID: <9b579c4e-9fbb-e568-4928-dc097971d0c3@suse.com> (raw)
In-Reply-To: <2f0005b7f2ec4a7e35d6a64348becc4e9628d801.camel@bitdefender.com>

On 31.07.2019 14:53, Petre Ovidiu PIRCALABU wrote:
> On Thu, 2019-07-18 at 14:44 +0000, Jan Beulich wrote:
>> On 18.07.2019 15:59, Petre Ovidiu PIRCALABU wrote:
>>> Before using xenforeignmemory_map_resource I investigated several
>>> different approaches:
>>> - Allocate the memory in hypervisor and xc_map_foreign_pages
>>> (doesn't
>>> work because you cannot "foreignmap" pages of your own domain.
>>> - Allocate the memory in guest, and map the allocated pages in XEN.
>>> To
>>> my knowledge there is no such API in linux to do this and the
>>> monitor
>>> application, as an userspace program, is not aware of the actual
>>> gfns
>>> for an allocated memory area.
>>>
>>> So, at this point the most promising solution is allocating the
>>> memory
>>> in XEN, sharing it with ID using share_xen_page_with_guest, and
>>> mapping
>>> it with xenforeignmemory_map_resource (with the flag
>>> XENMEM_rsrc_acq_caller_owned set)
>>
>> Which is fine - that's why Paul had introduced the generic interface.
>>
>>> To my understanding the cleanup sequence from
>>> gnttab_unpopulate_status_frames basically boils down to:
>>> 1. guest_physmap_remove_page
>>> 2. if ( test_and_clear_bit(_PGC_allocated, &pg->count_info) )
>>>          put_page(pg);
>>> 3. free_xenheap_page
>>
>> You're missing the crucial part of undoing step 2 if you find
>> that there are still references left to the page.
>>
>> And then, because of your use of vzalloc(), you can't use
>> free_xenheap_pages(), as that takes a (direct map) linear address
>> as input. It has to be free_domheap_pages() in your case.
>>
>>> My current implementation uses vzalloc instead of
>>> alloc_xenheap_pages
>>> and that's why I assumed vunmap and free_domheap_pages will suffice
>>> (I
>>> would have called vfree directly, but the temporary linked list
>>> that is
>>> used to hold the page references causes free_domheap_pages to
>>> crash)
>>>
>>> Do I also have to call guest_physmap_remove_page and put_page?
>>> (steps
>>> 1. and 2.)
>>
>> guest_physmap_remove_page() needs to be called for translated page-
>> owning domains if the page was ever added to their physmap. As long
>> as you avoid adding, you also don't need to remove. I don't recall
>> though whether a translated domain can access a resource without it
>> having a representation in its GFN space.
>>
> I've traced the GFN value for the shared MFN and it's invalid. It's set
> to INVALID_M2P_ENTRY in share_xen_page_with_guest, but I was expecting
> it to be set to valid value later on (e.g. xenmem_add_to_physmap).
> Am I missing something?

By "traced" do you mean "observed" (e.g. by way of logging) or "gone
through the code to verify it can't ever become valid"? In the latter
case you'd have proven what you want/need. Thinking about it though,
seeing how xenmem_add_to_physmap_one() works and assuming you indeed
don't add the page by other means, it looks to me as if you've done
more than is needed, as I've said already that you need to remove the
page only if it had been added.

Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-07-31 13:19 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-16 17:06 [Xen-devel] [PATCH v2 00/10] Per vcpu vm_event channels Petre Pircalabu
2019-07-16 17:06 ` [Xen-devel] [PATCH v2 01/10] vm_event: Define VM_EVENT type Petre Pircalabu
2019-07-16 20:59   ` Tamas K Lengyel
2019-07-17  7:59     ` Petre Ovidiu PIRCALABU
2019-07-17  8:49   ` Alexandru Stefan ISAILA
2019-07-17  9:57     ` Petre Ovidiu PIRCALABU
2019-07-16 17:06 ` [Xen-devel] [PATCH v2 02/10] vm_event: Remove "ring" suffix from vm_event_check_ring Petre Pircalabu
2019-07-17  9:11   ` Alexandru Stefan ISAILA
2019-07-16 17:06 ` [Xen-devel] [PATCH v2 03/10] vm_event: Add 'struct domain' backpointer to vm_event_domain Petre Pircalabu
2019-07-16 21:02   ` Tamas K Lengyel
2019-07-17  9:28   ` Jan Beulich
2019-07-16 17:06 ` [Xen-devel] [PATCH v2 04/10] vm_event: Simplify vm_event interface Petre Pircalabu
2019-07-16 21:04   ` Tamas K Lengyel
2019-07-17 11:13   ` Alexandru Stefan ISAILA
2019-07-16 17:06 ` [Xen-devel] [PATCH v2 05/10] vm_event: Move struct vm_event_domain to vm_event.c Petre Pircalabu
2019-07-17  9:31   ` Jan Beulich
2019-07-17 12:26     ` Petre Ovidiu PIRCALABU
2019-07-16 17:06 ` [Xen-devel] [PATCH v2 06/10] vm_event: Decouple implementation details from interface Petre Pircalabu
2019-07-16 17:06 ` [Xen-devel] [PATCH v2 07/10] vm_event: Add vm_event_ng interface Petre Pircalabu
2019-07-16 21:13   ` Tamas K Lengyel
2019-07-17 12:13     ` Petre Ovidiu PIRCALABU
2019-07-17 10:06   ` Jan Beulich
2019-07-17 12:38     ` Tamas K Lengyel
2019-07-17 13:12       ` Jan Beulich
2019-07-17 14:41     ` Petre Ovidiu PIRCALABU
2019-07-17 16:32       ` Jan Beulich
2019-07-17 18:42         ` Paul Durrant
2019-07-18 13:59         ` Petre Ovidiu PIRCALABU
2019-07-18 14:44           ` Jan Beulich
2019-07-18 14:55             ` Petre Ovidiu PIRCALABU
2019-07-31 12:53             ` Petre Ovidiu PIRCALABU
2019-07-31 13:09               ` Jan Beulich [this message]
2019-07-19  7:56           ` Paul Durrant
2019-07-19  8:22             ` Jan Beulich
2019-07-19  8:26               ` Paul Durrant
2019-07-19 11:23                 ` Petre Ovidiu PIRCALABU
2019-07-19 12:11                   ` Paul Durrant
2019-07-19 12:32                     ` Jan Beulich
2019-07-19 12:37                       ` Paul Durrant
2019-07-19 12:59                         ` Jan Beulich
2019-07-19 17:40                           ` Petre Ovidiu PIRCALABU
2019-07-22  7:58                             ` Paul Durrant
2019-07-22  7:59                             ` Jan Beulich
2019-07-22 10:44                               ` Petre Ovidiu PIRCALABU
2019-07-17 13:42   ` Alexandru Stefan ISAILA
2019-07-17 14:46     ` Petre Ovidiu PIRCALABU
2019-07-16 17:06 ` [Xen-devel] [PATCH v2 08/10] xen-access: Use getopt_long for cmdline parsing Petre Pircalabu
2019-07-16 21:09   ` Tamas K Lengyel
2019-07-17 11:16   ` Alexandru Stefan ISAILA
2019-07-16 17:06 ` [Xen-devel] [PATCH v2 09/10] xen-access: Code cleanup Petre Pircalabu
2019-07-16 21:07   ` Tamas K Lengyel
2019-07-17 11:18   ` Alexandru Stefan ISAILA
2019-07-16 17:06 ` [Xen-devel] [PATCH v2 10/10] xen-access: Add support for vm_event_ng interface Petre Pircalabu
2019-07-16 20:45 ` [Xen-devel] [PATCH v2 00/10] Per vcpu vm_event channels Tamas K Lengyel
2019-07-17  9:14   ` Petre Ovidiu PIRCALABU

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=9b579c4e-9fbb-e568-4928-dc097971d0c3@suse.com \
    --to=jbeulich@suse.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Paul.Durrant@citrix.com \
    --cc=aisaila@bitdefender.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=julien.grall@arm.com \
    --cc=konrad.wilk@oracle.com \
    --cc=ppircalabu@bitdefender.com \
    --cc=rcojocaru@bitdefender.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=tamas@tklengyel.com \
    --cc=tim@xen.org \
    --cc=wl@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.