[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Xen-devel] [PATCH v3] xen-mapcache: use MAP_FIXED flag so the mmap address hint is always honored
- To: <qemu-devel@xxxxxxxxxx>
- From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
- Date: Mon, 18 Mar 2019 18:37:31 +0100
- Cc: Igor Druzhinin <igor.druzhinin@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Eduardo Habkost <ehabkost@xxxxxxxxxx>, "Michael S. Tsirkin" <mst@xxxxxxxxxx>, Paul Durrant <paul.durrant@xxxxxxxxxx>, Marcel Apfelbaum <marcel.apfelbaum@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Anthony Perard <anthony.perard@xxxxxxxxxx>, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Richard Henderson <rth@xxxxxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>
- Delivery-date: Mon, 18 Mar 2019 17:37:59 +0000
- Ironport-data: A9a23:X+cXgqwG+6TLGRh7MhF6t4n5zX2q8pwBZkZajsDslgifGU9jxPU8VO SFirS/VJh9ycLBV5Q3URkGp0cujdgYBNtxlqvBQIMKUbsJKHzeooXRtwdxjcE11W8xK3PsBm Ysus+SCU7vqWWVWLQcOIqn0vA42bi0YDVl8koL2XEHi1vsPzZt8XSotzCdB/8/o9dqoLWwHV cHd6+OW5AswX9eqL8+MDm1y5xf+SJ8mWs1X412KUkWDyjzGLVIl37nBPnQpFefgHYC64quPe lwYmNspr6FdaivC4lWNkj37E40GwFVcHfU7loid6TTrvIuRy/DZJne9Jxm4sdUPwfGjMENkr Mh1Eu6Tx/s/r/w1P2XQSoFM2G96KaUxcUKeKGbV1L4qtaTHC9BD4sbhp6uhb451rIR1yM03D KTEMROMwA/oc8X/WyxEwfvsK0eXC0Aq4he8MrRhwVPrz9jvuc88NNQOBAjg8mIN3+eYjjxEh vtTlGD48tYouaaijDiEgjZnFC0bOSgs5Qf2I0V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Sxgg3Px8S8ApF1vDgjyxK2yFBkpeVXRD9C E8X2QJESyXg2WVYWzBVujJZJnFIwCY24h5wtfkZycQZwUzEZGAbZ5mdy6/X3TAYUCQQWbiTU Z+/iLoMWMXaT/sGQH6fbrrj06mu554ZclzUsPQQyhbdN69TuR60vuu4FWTo1eRYOjFiK//46 yFPiBunqsBPt72iz/dXvX0fUB6pW79OeuFBJKSE8qeW66bQkv/vw4T/vmObg2iiwqNg9A8Mk +EbWu/WPBvMLNxBJiLzf8sfmQH2gxnMzlGqm5UMlU/mvRHd0C3ZYOtM1YlY1Qqft8YM8oh9m NFkdbIcO6lidDT/qiov1zPfyVn0+6C9s0eMvGZGxjCMCzM/B/1h/jpDtwTVeShA2lx3PO6ZP MOgqcuYzw5nJA3P+jnyxY5lJgKBdJwG2pDB9r1fYZ+O53vKpo8BDSUYPMtAAqcKFfiTMQHC6 h7UFlG5u51pixxvgLQd99UYL1yN4PqyzPv+qi2E2NoQXzCjJSIW5NyF+iWp5E3VdM=
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
Or if it's not possible to honor the hinted address an error is returned
instead. This makes it easier to spot the actual failure, instead of
failing later on when the caller of xen_remap_bucket realizes the
mapping has not been created at the requested address.
Also note that at least on FreeBSD using MAP_FIXED will cause mmap to
try harder to honor the passed address.
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Reviewed-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
Cc: Anthony Perard <anthony.perard@xxxxxxxxxx>
Cc: Paul Durrant <paul.durrant@xxxxxxxxxx>
Cc: Igor Druzhinin <igor.druzhinin@xxxxxxxxxx>
Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>
Cc: Richard Henderson <rth@xxxxxxxxxxx>
Cc: Eduardo Habkost <ehabkost@xxxxxxxxxx>
Cc: "Michael S. Tsirkin" <mst@xxxxxxxxxx>
Cc: Marcel Apfelbaum <marcel.apfelbaum@xxxxxxxxx>
Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx
---
Changes since v2:
- Move comment position.
Changes since v1:
- Use MAP_FIXED for the dummy mmap call also if a specific virtual
address is requested.
---
hw/i386/xen/xen-mapcache.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/hw/i386/xen/xen-mapcache.c b/hw/i386/xen/xen-mapcache.c
index 349f72d00c..254759f776 100644
--- a/hw/i386/xen/xen-mapcache.c
+++ b/hw/i386/xen/xen-mapcache.c
@@ -184,9 +184,14 @@ static void xen_remap_bucket(MapCacheEntry *entry,
pfns[i] = (address_index << (MCACHE_BUCKET_SHIFT-XC_PAGE_SHIFT)) + i;
}
+ /*
+ * If the caller has requested the mapping at a specific address use
+ * MAP_FIXED to make sure it's honored.
+ */
if (!dummy) {
vaddr_base = xenforeignmemory_map2(xen_fmem, xen_domid, vaddr,
- PROT_READ | PROT_WRITE, 0,
+ PROT_READ | PROT_WRITE,
+ vaddr ? MAP_FIXED : 0,
nb_pfn, pfns, err);
if (vaddr_base == NULL) {
perror("xenforeignmemory_map2");
@@ -198,7 +203,8 @@ static void xen_remap_bucket(MapCacheEntry *entry,
* mapping immediately due to certain circumstances (i.e. on resume
now)
*/
vaddr_base = mmap(vaddr, size, PROT_READ | PROT_WRITE,
- MAP_ANON | MAP_SHARED, -1, 0);
+ MAP_ANON | MAP_SHARED | (vaddr ? MAP_FIXED : 0),
+ -1, 0);
if (vaddr_base == MAP_FAILED) {
perror("mmap");
exit(-1);
--
2.17.2 (Apple Git-113)
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|