IOREQ server on Arm
Hi Paul,
I am looking at porting the IOREQ server infrastructure on Arm. I didn't need much modification to make it run for Arm. Although, the implementation could be simplified over the x86 implementation.
I noticed some issue while trying to implement the hypercall XENMEM_acquire_resource. Per my understanding, all the page mapped via that hypercall will use the type p2m_mapping_foreign.
This will result to trigger the ASSERT(fdom != dom) in get_page_from_gfn (asm-arm/p2m.h) because the IOREQ page has been allocated to the emulator domain and mapped to it. AFAICT x86 has the same assert in p2m_get_page_from_gfn(...).
IHMO, the ASSERT makes sense because you are only meant to map page belonging to other domain with that type.
So I am wondering whether IOREQ server running in PVH Dom0 has been tested? What would be the best course of action to fix the issue?
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 00:39, <[email protected]> wrote:
Hi Paul,
I am looking at porting the IOREQ server infrastructure on Arm. I didn't need much modification to make it run for Arm. Although, the implementation could be simplified over the x86 implementation.
I noticed some issue while trying to implement the hypercall
XENMEM_acquire_resource. Per my understanding, all the page mapped via that hypercall will use the typep2m_mapping_foreign.This will result to trigger the ASSERT(fdom != dom) in
get_page_from_gfn(asm-arm/p2m.h) because the IOREQ page has been allocated to the emulator domain and mapped to it. AFAICT x86 has the same assert inp2m_get_page_from_gfn(...).
Quoted 5 lines
IHMO, the ASSERT makes sense because you are only meant to map page belonging to other domain with that type.
So I am wondering whether IOREQ server running in PVH Dom0 has been tested? What would be the best course of action to fix the issue?
I think the p2m type needs to be chosen based onXENMEM_rsrc_acq_caller_owned.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 26 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 26 September 2018 09:09
To: Julien Grall <[email protected]>; Paul Durrant <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen- devel <[email protected]>
Subject: Re: IOREQ server on ArmQuoted 16 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 00:39, <[email protected]> wrote:
Hi Paul,
I am looking at porting the IOREQ server infrastructure on Arm. I didn't need much modification to make it run for Arm. Although, the implementation could be simplified over the x86 implementation.
I noticed some issue while trying to implement the hypercall
XENMEM_acquire_resource. Per my understanding, all the page mapped via that hypercall will use the typep2m_mapping_foreign.This will result to trigger the ASSERT(fdom != dom) in
get_page_from_gfn(asm-arm/p2m.h) because the IOREQ page has been allocated to the emulator domain and mapped to it. AFAICT x86 has the same assert inp2m_get_page_from_gfn(...).
Quoted 9 lines
Quoted 5 lines
IHMO, the ASSERT makes sense because you are only meant to map page belonging to other domain with that type.
So I am wondering whether IOREQ server running in PVH Dom0 has been tested? What would be the best course of action to fix the issue?
I think the p2m type needs to be chosen based on
XENMEM_rsrc_acq_caller_owned.
Yes, that's correct. There is a FIXME clause in acquire_resource so that that only caller owned resources can be mapped by HVM/PVH domains. Thus the new call can be used for IOREQ server pages, but not grant frames.
Paul
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi,
Quoted 29 lines · Paul Durrant
Quoted 29 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 26 September 2018 09:09
To: Julien Grall <[email protected]>; Paul Durrant <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen- devel <[email protected]>
Subject: Re: IOREQ server on ArmQuoted 19 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 00:39, <[email protected]> wrote:
Hi Paul,
I am looking at porting the IOREQ server infrastructure on Arm. I didn't need much modification to make it run for Arm. Although, the implementation could be simplified over the x86 implementation.
I noticed some issue while trying to implement the hypercall
XENMEM_acquire_resource. Per my understanding, all the page mapped via that hypercall will use the typep2m_mapping_foreign.This will result to trigger the ASSERT(fdom != dom) in
get_page_from_gfn(asm-arm/p2m.h) because the IOREQ page has been allocated to the emulator domain and mapped to it. AFAICT x86 has the same assert inp2m_get_page_from_gfn(...).IHMO, the ASSERT makes sense because you are only meant to map page belonging to other domain with that type.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
So I am wondering whether IOREQ server running in PVH Dom0 has been tested? What would be the best course of action to fix the issue?
I think the p2m type needs to be chosen based on
XENMEM_rsrc_acq_caller_owned.Yes, that's correct. There is a FIXME clause in
acquire_resourceso that that only caller owned resources can be mapped by HVM/PVH domains. Thus the new call can be used for IOREQ server pages, but not grant frames.
I don't understand your last sentence. IOREQ is caller owned and therefore should work.
As I said, I don't have any problem with mapping the resource. The problem is when unmapping it because the region is set with p2m_mapping_foreign. You will reach the ASSERT(fdom != p2m->domain) in p2m_get_page_from_gfn.
Regardless the reference problem (we support it on Arm). Can you explain how this is working on PVH Dom0 today?
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 50 lines · Julien Grall
Hi,
Quoted 35 lines · Paul Durrant
Quoted 35 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 26 September 2018 09:09
To: Julien Grall <[email protected]>; Paul Durrant <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen-
devel <[email protected]>
Subject: Re: IOREQ server on ArmQuoted 23 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 00:39, <[email protected]> wrote:
Hi Paul,
I am looking at porting the IOREQ server infrastructure on Arm. I didn't
need much modification to make it run for Arm. Although, the implementation could be simplified over the x86 implementation.I noticed some issue while trying to implement the hypercall
XENMEM_acquire_resource. Per my understanding, all the page mapped via that hypercall will use the typep2m_mapping_foreign.This will result to trigger the ASSERT(fdom != dom) in
get_page_from_gfn
(asm-arm/p2m.h) because the IOREQ page has been allocated to the emulator domain and mapped to it. AFAICT x86 has the same assert inp2m_get_page_from_gfn(...).IHMO, the ASSERT makes sense because you are only meant to map page belonging to other domain with that type.
So I am wondering whether IOREQ server running in PVH Dom0 has been tested? What would be the best course of action to fix the issue?
Quoted 8 lines
Quoted 3 lines
I think the p2m type needs to be chosen based on
XENMEM_rsrc_acq_caller_owned.Yes, that's correct. There is a FIXME clause in
acquire_resourceso that that only caller owned resources can be mapped by HVM/PVH domains. Thus the new call can be used for IOREQ server pages, but not grant frames.I don't understand your last sentence. IOREQ is caller owned and therefore should work.
Quoted 7 lines
As I said, I don't have any problem with mapping the resource. The problem is when unmapping it because the region is set with
p2m_mapping_foreign. You will reach theASSERT(fdom != p2m->domain)inp2m_get_page_from_gfn.Regardless the reference problem (we support it on Arm). Can you explain how this is working on PVH Dom0 today?
I doubt anyone has tried using it with a PVH Dom0.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 52 lines
-----Original Message-----
From: Julien Grall [mailto:[email protected]]
Sent: 26 September 2018 11:33
To: Paul Durrant <[email protected]>; 'Jan Beulich' <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen- devel <[email protected]>
Subject: Re: IOREQ server on ArmHi,
Quoted 7 lines · Paul Durrant
Quoted 7 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 26 September 2018 09:09
To: Julien Grall <[email protected]>; Paul Durrant <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>;xen-
Quoted 7 lines
Quoted 7 lines
devel <[email protected]>
Subject: Re: IOREQ server on ArmQuoted 4 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 00:39, <[email protected]> wrote:
Hi Paul,
I am looking at porting the IOREQ server infrastructure on Arm. I
didn't
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
need much modification to make it run for Arm. Although, the implementation could be simplified over the x86 implementation.
I noticed some issue while trying to implement the hypercall
XENMEM_acquire_resource. Per my understanding, all the page mapped via that hypercall will use the typep2m_mapping_foreign.This will result to trigger the ASSERT(fdom != dom) in
get_page_from_gfnQuoted 14 lines
Quoted 13 lines
Quoted 9 lines
(
asm-arm/p2m.h) because the IOREQ page has been allocated to the emulator domain and mapped to it. AFAICT x86 has the same assert inp2m_get_page_from_gfn(...).IHMO, the ASSERT makes sense because you are only meant to map page belonging to other domain with that type.
So I am wondering whether IOREQ server running in PVH Dom0 has been tested? What would be the best course of action to fix the issue?
I think the p2m type needs to be chosen based on
XENMEM_rsrc_acq_caller_owned.
Quoted 6 lines
Quoted 1 line
Yes, that's correct. There is a FIXME clause in
acquire_resourceso thatthat only caller owned resources can be mapped by HVM/PVH domains. Thus the new call can be used for IOREQ server pages, but not grant frames.
I don't understand your last sentence. IOREQ is caller owned and therefore should work.
Yes, I was just saying that it is currently the only resource that should work.
Quoted 9 lines
As I said, I don't have any problem with mapping the resource. The problem is when unmapping it because the region is set with
p2m_mapping_foreign. You will reach theASSERT(fdom != p2m->domain)inp2m_get_page_from_gfn.Regardless the reference problem (we support it on Arm). Can you explain how this is working on PVH Dom0 today?
I never tested with a PVH dom0, but I did run tests with an HVM domU (and a Xen with the privilege checks hacked out). I guess I didn't re-test with HVM after the switch to caller-owned (which came quite late in review) and so missed this problem. Sorry about that.
Paul
Quoted 4 lines
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 44 lines · Julien Grall
Hi,
Quoted 29 lines · Paul Durrant
Quoted 29 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 26 September 2018 09:09
To: Julien Grall <[email protected]>; Paul Durrant <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen- devel <[email protected]>
Subject: Re: IOREQ server on ArmQuoted 19 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 00:39, <[email protected]> wrote:
Hi Paul,
I am looking at porting the IOREQ server infrastructure on Arm. I didn't need much modification to make it run for Arm. Although, the implementation could be simplified over the x86 implementation.
I noticed some issue while trying to implement the hypercall
XENMEM_acquire_resource. Per my understanding, all the page mapped via that hypercall will use the typep2m_mapping_foreign.This will result to trigger the ASSERT(fdom != dom) in
get_page_from_gfn(asm-arm/p2m.h) because the IOREQ page has been allocated to the emulator domain and mapped to it. AFAICT x86 has the same assert inp2m_get_page_from_gfn(...).IHMO, the ASSERT makes sense because you are only meant to map page belonging to other domain with that type.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
So I am wondering whether IOREQ server running in PVH Dom0 has been tested? What would be the best course of action to fix the issue?
I think the p2m type needs to be chosen based on
XENMEM_rsrc_acq_caller_owned.Yes, that's correct. There is a FIXME clause in
acquire_resourceso that that only caller owned resources can be mapped by HVM/PVH domains. Thus the new call can be used for IOREQ server pages, but not grant frames.I don't understand your last sentence. IOREQ is caller owned and therefore should work.
Quoted 6 lines
As I said, I don't have any problem with mapping the resource. The problem is when unmapping it because the region is set with
p2m_mapping_foreign. You will reach theASSERT(fdom != p2m->domain)inp2m_get_page_from_gfn.Regardless the reference problem (we support it on Arm). Can you explain how this is working on PVH Dom0 today?
IOREQs (QEMU) used to work on a PVH Dom0 in the past, it's been some time since I've launched a HVM guest now, but it definitely worked before, like it worked for PVHv1 Dom0.
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi Jan,
Quoted 16 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 00:39, <[email protected]> wrote:
Hi Paul,
I am looking at porting the IOREQ server infrastructure on Arm. I didn't need much modification to make it run for Arm. Although, the implementation could be simplified over the x86 implementation.
I noticed some issue while trying to implement the hypercall
XENMEM_acquire_resource. Per my understanding, all the page mapped via that hypercall will use the typep2m_mapping_foreign.This will result to trigger the ASSERT(fdom != dom) in
get_page_from_gfn(asm-arm/p2m.h) because the IOREQ page has been allocated to the emulator domain and mapped to it. AFAICT x86 has the same assert inp2m_get_page_from_gfn(...).
Quoted 8 lines
Quoted 5 lines
IHMO, the ASSERT makes sense because you are only meant to map page belonging to other domain with that type.
So I am wondering whether IOREQ server running in PVH Dom0 has been tested? What would be the best course of action to fix the issue?
I think the p2m type needs to be chosen based on
XENMEM_rsrc_acq_caller_owned.
I am thinking to introduce p2m_mapping_owned. Or do we have a p2m_type that we could re-use?
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 34 lines
-----Original Message-----
From: Julien Grall [mailto:[email protected]]
Sent: 26 September 2018 11:41
To: Jan Beulich <[email protected]>; Paul Durrant <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen- devel <[email protected]>
Subject: Re: IOREQ server on ArmHi Jan,
Quoted 4 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 00:39, <[email protected]> wrote:
Hi Paul,
I am looking at porting the IOREQ server infrastructure on Arm. I
didn't
Quoted 8 lines
Quoted 8 lines
need much modification to make it run for Arm. Although, the implementation could be simplified over the x86 implementation.
I noticed some issue while trying to implement the hypercall
XENMEM_acquire_resource. Per my understanding, all the page mapped via that hypercall will use the typep2m_mapping_foreign.This will result to trigger the ASSERT(fdom != dom) in
get_page_from_gfnQuoted 7 lines
Quoted 7 lines
(
asm-arm/p2m.h) because the IOREQ page has been allocated to the emulator domain and mapped to it. AFAICT x86 has the same assert inp2m_get_page_from_gfn(...).IHMO, the ASSERT makes sense because you are only meant to map page belonging to other domain with that type.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
So I am wondering whether IOREQ server running in PVH Dom0 has been tested? What would be the best course of action to fix the issue?
I think the p2m type needs to be chosen based on
XENMEM_rsrc_acq_caller_owned.I am thinking to introduce
p2m_mapping_owned. Or do we have ap2m_typethat we could re-use?
I think we should be able to just use p2m_ram_rw if it is caller owned.
Paul
Quoted 4 lines
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 38 lines
Quoted 38 lines
Quoted 1 line · On 26.09.18 at 12:51, <[email protected]> wrote:
-----Original Message-----
From: Julien Grall [mailto:[email protected]]
Sent: 26 September 2018 11:41
To: Jan Beulich <[email protected]>; Paul Durrant <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen- devel <[email protected]>
Subject: Re: IOREQ server on ArmHi Jan,
Quoted 4 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 00:39, <[email protected]> wrote:
Hi Paul,
I am looking at porting the IOREQ server infrastructure on Arm. I
didn't
Quoted 8 lines
Quoted 8 lines
need much modification to make it run for Arm. Although, the implementation could be simplified over the x86 implementation.
I noticed some issue while trying to implement the hypercall
XENMEM_acquire_resource. Per my understanding, all the page mapped via that hypercall will use the typep2m_mapping_foreign.This will result to trigger the ASSERT(fdom != dom) in
get_page_from_gfnQuoted 10 lines
Quoted 9 lines
(
asm-arm/p2m.h) because the IOREQ page has been allocated to the emulator domain and mapped to it. AFAICT x86 has the same assert inp2m_get_page_from_gfn(...).IHMO, the ASSERT makes sense because you are only meant to map page belonging to other domain with that type.
So I am wondering whether IOREQ server running in PVH Dom0 has been tested? What would be the best course of action to fix the issue?
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
I think the p2m type needs to be chosen based on
XENMEM_rsrc_acq_caller_owned.I am thinking to introduce
p2m_mapping_owned. Or do we have ap2m_typethat we could re-use?I think we should be able to just use
p2m_ram_rwif it is caller owned.
Yes, that's what I too would have thought. If there ever was a resource which may only be mapped r/o, p2m_ram_ro should then be equally usable.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 53 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 26 September 2018 11:58
To: Julien Grall <[email protected]>; Paul Durrant <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen- devel <[email protected]>
Subject: RE: IOREQ server on ArmQuoted 8 lines
Quoted 8 lines
Quoted 1 line · On 26.09.18 at 12:51, <[email protected]> wrote:
-----Original Message-----
From: Julien Grall [mailto:[email protected]]
Sent: 26 September 2018 11:41
To: Jan Beulich <[email protected]>; Paul Durrant <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>;xen-
Quoted 9 lines
Quoted 9 lines
devel <[email protected]>
Subject: Re: IOREQ server on ArmHi Jan,
Quoted 3 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 00:39, <[email protected]> wrote:
Hi Paul,
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
I am looking at porting the IOREQ server infrastructure on Arm. I
didn't
Quoted 5 lines
Quoted 5 lines
need much modification to make it run for Arm. Although, the implementation could be simplified over the x86 implementation.
I noticed some issue while trying to implement the hypercall
XENMEM_acquire_resource. Per my understanding, all the page mappedvia
Quoted 17 lines
Quoted 17 lines
Quoted 3 lines
Quoted 3 lines
that hypercall will use the type
p2m_mapping_foreign.This will result to trigger the ASSERT(fdom != dom) in
get_page_from_gfnQuoted 12 lines
Quoted 9 lines
(
asm-arm/p2m.h) because the IOREQ page has been allocated to the emulator domain and mapped to it. AFAICT x86 has the same assert inp2m_get_page_from_gfn(...).IHMO, the ASSERT makes sense because you are only meant to map page belonging to other domain with that type.
So I am wondering whether IOREQ server running in PVH Dom0 has been tested? What would be the best course of action to fix the issue?
I think the p2m type needs to be chosen based on
XENMEM_rsrc_acq_caller_owned.
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
I am thinking to introduce
p2m_mapping_owned. Or do we have ap2m_typethat we could re-use?I think we should be able to just use
p2m_ram_rwif it is caller owned.Yes, that's what I too would have thought. If there ever was a resource which may only be mapped r/o,
p2m_ram_roshould then be equally usable.
Yes, that's true. The only existent resources are read-write though so I guess another flag passed back to the caller could be used to indicate a read-only resource.
I was thinking along the lines of a patch like this:
xen/common/memory.c +5 -2
@@ -1105,8 +1105,11 @@ static int acquire_resource(for ( i =0 ; !rc && i < xmar.nr_frames; i++ ) { - rc =set_foreign_p2m_entry (currd, gfn_list[i], -_mfn (mfn_list[i])); + rc = (xmar.flags & XENMEM_rsrc_acq_caller_owned) ? +guest_physmap_add_entry (currd, gfn_list[i], +_mfn (mfn_list[i]),0 , p2m_ram_rw) : +set_foreign_p2m_entry (currd, gfn_list[i], +_mfn (mfn_list[i]));/* rc should be -EIO for any iteration other than the first */ if ( rc && i ) rc = -EIO ;
But the guest_physmap_add_entry() is problematic as it will IOMMU map pages as well, which is probably not wanted.
Paul
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 13:02, <[email protected]> wrote:
xen/common/memory.c +5
-2@@ -1105,8 +1105,11 @@ static int acquire_resource(for ( i =0 ; !rc && i < xmar.nr_frames; i++ ) { - rc =set_foreign_p2m_entry (currd, gfn_list[i], -_mfn (mfn_list[i])); + rc = (xmar.flags & XENMEM_rsrc_acq_caller_owned) ? +guest_physmap_add_entry (currd, gfn_list[i], +_mfn (mfn_list[i]),0 , p2m_ram_rw) : +set_foreign_p2m_entry (currd, gfn_list[i], +_mfn (mfn_list[i]));/* rc should be -EIO for any iteration other than the first */ if ( rc && i ) rc = -EIO ;
Quoted 2 lines
But the
guest_physmap_add_entry()is problematic as it will IOMMU map pages as well, which is probably not wanted.
Yeah, I'd prefer if we avoided establishing IOMMU mappings here. How about transforming set_foreign_p2m_entry() into set_special_p2m_entry(), with a type passed in?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 30 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 26 September 2018 12:57
To: Paul Durrant <[email protected]>
Cc: Julien Grall <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen-devel <xen- [email protected]>
Subject: RE: IOREQ server on Armxen/common/memory.c static int acquire_resource( · line 1110
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 13:02, <[email protected]> wrote:
xen/common/memory.c +3
-2@@ -1105,8 +1105,11 @@ static int acquire_resource(for ( i =0 ; !rc && i < xmar.nr_frames; i++ ) { - rc =set_foreign_p2m_entry (currd, gfn_list[i], -_mfn (mfn_list[i])); + rc = (xmar.flags & XENMEM_rsrc_acq_caller_owned) ? + guest_physmap_add_entry(currd, gfn_list[i], + _mfn(mfn_list[i]), 0,
p2m_ram_rw) :xen/common/memory.c static int acquire_resource(
Quoted 3 lines
xen/common/memory.c +2
-0+set_foreign_p2m_entry (currd, gfn_list[i], +_mfn (mfn_list[i]));/* rc should be -EIO for any iteration other than the first */
Quoted 3 lines
xen/common/memory.c +0
-0if ( rc && i ) rc = -EIO ;
Quoted 8 lines
Quoted 1 line
But the
guest_physmap_add_entry()is problematic as it will IOMMU mappages
Quoted 1 line
as well, which is probably not wanted.
Yeah, I'd prefer if we avoided establishing IOMMU mappings here. How about transforming
set_foreign_p2m_entry()intoset_special_p2m_entry(), with a type passed in?
That sounds like it might work.
Julien, do you want page types to distinguish caller-owned resources from normal RAM are you ok with p2m_ram_rw even though it could be subject of another domain's foreign map?
Paul
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi Paul,
Quoted 34 lines · Paul Durrant
Quoted 34 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 26 September 2018 12:57
To: Paul Durrant <[email protected]>
Cc: Julien Grall <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen-devel <xen- [email protected]>
Subject: RE: IOREQ server on Armxen/common/memory.c static int acquire_resource( · line 1110
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 13:02, <[email protected]> wrote:
xen/common/memory.c +3
-2@@ -1105,8 +1105,11 @@ static int acquire_resource(for ( i =0 ; !rc && i < xmar.nr_frames; i++ ) { - rc =set_foreign_p2m_entry (currd, gfn_list[i], -_mfn (mfn_list[i])); + rc = (xmar.flags & XENMEM_rsrc_acq_caller_owned) ? + guest_physmap_add_entry(currd, gfn_list[i], + _mfn(mfn_list[i]), 0,
p2m_ram_rw) :xen/common/memory.c static int acquire_resource(
Quoted 3 lines
xen/common/memory.c +2
-0+set_foreign_p2m_entry (currd, gfn_list[i], +_mfn (mfn_list[i]));/* rc should be -EIO for any iteration other than the first */
Quoted 4 lines
xen/common/memory.c +0
-0if ( rc && i ) rc = -EIO ;But the
guest_physmap_add_entry()is problematic as it will IOMMU mappages
Quoted 1 line
as well, which is probably not wanted.
Quoted 8 lines
Quoted 4 lines
Yeah, I'd prefer if we avoided establishing IOMMU mappings here. How about transforming
set_foreign_p2m_entry()intoset_special_p2m_entry(), with a type passed in?That sounds like it might work.
Julien, do you want page types to distinguish caller-owned resources from normal RAM are you ok with
p2m_ram_rweven though it could be subject of another domain's foreign map?
Based on your previous e-mail, I would be fine with that on Arm.
This brings me to the next question. Do you expect set_special_p2m_entry to take a reference on the page?
If not, we may run into some troubles because AFAICT you can map twice the ioreq page in a guest but reference will only be taken on the allocation.
However, the unmap path will always drop a reference when removing the page. This is because Xen at the moment, reference will not be taken on mapping but allocation (we assume a page could not be mapped twice in a guest).
Foreign mapping on Arm are a bit special because we get a reference on mapping them and will drop it when the mapping disappear. So we would not have any problem there.
Any thoughts?
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 23:32, <[email protected]> wrote:
This brings me to the next question. Do you expect
set_special_p2m_entryto take a reference on the page?If not, we may run into some troubles because AFAICT you can map twice the ioreq page in a guest but reference will only be taken on the allocation.
Quoted 8 lines
However, the unmap path will always drop a reference when removing the page. This is because Xen at the moment, reference will not be taken on mapping but allocation (we assume a page could not be mapped twice in a guest).
Foreign mapping on Arm are a bit special because we get a reference on mapping them and will drop it when the mapping disappear. So we would not have any problem there.
Well, at least on x86 no refcounting happens at all in the p2m layer. That's something we mean to fix eventually, but I'm unaware of any work into that direction. If the situation is different on ARM, then the behavior of set_special_p2m_entry() may need to differ between it and x86 for the time being.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 73 lines
-----Original Message-----
From: Julien Grall [mailto:[email protected]]
Sent: 26 September 2018 22:32
To: Paul Durrant <[email protected]>; 'Jan Beulich' <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen- devel <[email protected]>
Subject: Re: IOREQ server on ArmHi Paul,
Quoted 23 lines · Paul Durrant
Quoted 23 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 26 September 2018 12:57
To: Paul Durrant <[email protected]>
Cc: Julien Grall <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen-devel <xen- [email protected]>
Subject: RE: IOREQ server on Armxen/common/memory.c static int acquire_resource( · line 1110
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 13:02, <[email protected]> wrote:
xen/common/memory.c +3
-2@@ -1105,8 +1105,11 @@ static int acquire_resource(for ( i =0 ; !rc && i < xmar.nr_frames; i++ ) { - rc =set_foreign_p2m_entry (currd, gfn_list[i], -_mfn (mfn_list[i])); + rc = (xmar.flags & XENMEM_rsrc_acq_caller_owned) ? + guest_physmap_add_entry(currd, gfn_list[i], + _mfn(mfn_list[i]), 0,
p2m_ram_rw) :Quoted 3 lines
Quoted 3 lines
xen/common/memory.c static int acquire_resource(
Quoted 3 lines
xen/common/memory.c +2
-0+set_foreign_p2m_entry (currd, gfn_list[i], +_mfn (mfn_list[i]));/* rc should be -EIO for any iteration other than the first
Quoted 8 lines
Quoted 8 lines
*/
Quoted 4 lines
xen/common/memory.c +0
-0if ( rc && i ) rc = -EIO ;But the
guest_physmap_add_entry()is problematic as it will IOMMU mappages
Quoted 1 line
as well, which is probably not wanted.
Quoted 8 lines
Quoted 4 lines
Yeah, I'd prefer if we avoided establishing IOMMU mappings here. How about transforming
set_foreign_p2m_entry()intoset_special_p2m_entry(), with a type passed in?That sounds like it might work.
Julien, do you want page types to distinguish caller-owned resources
from normal RAM are you ok with
p2m_ram_rweven though it could be subject of another domain's foreign map?Based on your previous e-mail, I would be fine with that on Arm.
This brings me to the next question. Do you expect
set_special_p2m_entryto take a reference on the page?If not, we may run into some troubles because AFAICT you can map twice the ioreq page in a guest but reference will only be taken on the allocation.
However, the unmap path will always drop a reference when removing the page. This is because Xen at the moment, reference will not be taken on mapping but allocation (we assume a page could not be mapped twice in a guest).
Quoted 5 lines
Foreign mapping on Arm are a bit special because we get a reference on mapping them and will drop it when the mapping disappear. So we would not have any problem there.
Any thoughts?
Well, as Jan says, on x86 we don't reference count in the P2M so multiple mappings should not be an issue AFAICT. It sounds like resource mapping should be treated the same way as foreign mapping (albeit with a non-foreign domid) such that the reference acquisition occurs at map time.
Paul
Quoted 3 lines
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi Paul,
Quoted 73 lines · Paul Durrant
Quoted 73 lines
-----Original Message-----
From: Julien Grall [mailto:[email protected]]
Sent: 26 September 2018 22:32
To: Paul Durrant <[email protected]>; 'Jan Beulich' <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen- devel <[email protected]>
Subject: Re: IOREQ server on ArmHi Paul,
Quoted 23 lines · Paul Durrant
Quoted 23 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 26 September 2018 12:57
To: Paul Durrant <[email protected]>
Cc: Julien Grall <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen-devel <xen- [email protected]>
Subject: RE: IOREQ server on Armxen/common/memory.c static int acquire_resource( · line 1110
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 13:02, <[email protected]> wrote:
xen/common/memory.c +3
-2@@ -1105,8 +1105,11 @@ static int acquire_resource(for ( i =0 ; !rc && i < xmar.nr_frames; i++ ) { - rc =set_foreign_p2m_entry (currd, gfn_list[i], -_mfn (mfn_list[i])); + rc = (xmar.flags & XENMEM_rsrc_acq_caller_owned) ? + guest_physmap_add_entry(currd, gfn_list[i], + _mfn(mfn_list[i]), 0,
p2m_ram_rw) :Quoted 3 lines
Quoted 3 lines
xen/common/memory.c static int acquire_resource(
Quoted 3 lines
xen/common/memory.c +2
-0+set_foreign_p2m_entry (currd, gfn_list[i], +_mfn (mfn_list[i]));/* rc should be -EIO for any iteration other than the first
Quoted 8 lines
Quoted 8 lines
*/
Quoted 4 lines
xen/common/memory.c +0
-0if ( rc && i ) rc = -EIO ;But the
guest_physmap_add_entry()is problematic as it will IOMMU mappages
Quoted 1 line
as well, which is probably not wanted.
Quoted 8 lines
Quoted 4 lines
Yeah, I'd prefer if we avoided establishing IOMMU mappings here. How about transforming
set_foreign_p2m_entry()intoset_special_p2m_entry(), with a type passed in?That sounds like it might work.
Julien, do you want page types to distinguish caller-owned resources
from normal RAM are you ok with
p2m_ram_rweven though it could be subject of another domain's foreign map?Based on your previous e-mail, I would be fine with that on Arm.
This brings me to the next question. Do you expect
set_special_p2m_entryto take a reference on the page?If not, we may run into some troubles because AFAICT you can map twice the ioreq page in a guest but reference will only be taken on the allocation.
However, the unmap path will always drop a reference when removing the page. This is because Xen at the moment, reference will not be taken on mapping but allocation (we assume a page could not be mapped twice in a guest).
Quoted 7 lines
Quoted 5 lines
Foreign mapping on Arm are a bit special because we get a reference on mapping them and will drop it when the mapping disappear. So we would not have any problem there.
Any thoughts?
Well, as Jan says, on x86 we don't reference count in the P2M so multiple mappings should not be an issue AFAICT.
I understand that you don't have reference count in the P2M (that's the same on Arm today except for foreign mapping). But I think I can list at least 2 major issues with the design today. Let me give an example based on my understanding.
1. DM requests to map the IOREQ page
a) page allocated (one reference)
b) get reference (will be dropped when the IOREQ server is destroyed)
2. DM requests to map the IOREQ page (second time) No reference taken
3. DM unmap the IOREQ page
4. DM unmap the IOREQ page
AFAIU, 3. 4. would be done through XENMEM_remove_from_physmap. So no reference dropped there. While the reference 1.b) will be dropped in hvm_free_ioreq_mfn. AFAICT 1.a) would be kept until the domain die. This would result to Xen memory exhaustion in long term. Did I miss anything?
But, I think there are another way for badly written guest to remove the page. It looks like you can use XENMEM_decrease_reservation as the page belongs to the guest. So a reference would be dropped by 3. and 4.
While 3. will drop the reference drop by 1.a), 4. may drop the reference from 1.b) and releasing the page for good. Although the page will still be associated with the IOREQ server until it has been effectively destroyed. Did I miss anything in the code?
Quoted 1 line
It sounds like resource mapping should be treated the same way as foreign mapping (albeit with a non-foreign domid) such that the reference acquisition occurs at map time.
If my understanding is correct then yes it would be much safer to get reference here.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 112 lines
-----Original Message-----
From: Julien Grall [mailto:[email protected]]
Sent: 27 September 2018 10:42
To: Paul Durrant <[email protected]>; 'Jan Beulich' <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen- devel <[email protected]>
Subject: Re: IOREQ server on ArmHi Paul,
Quoted 7 lines · Paul Durrant
Quoted 7 lines
-----Original Message-----
From: Julien Grall [mailto:[email protected]]
Sent: 26 September 2018 22:32
To: Paul Durrant <[email protected]>; 'Jan Beulich' <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>;xen-
Quoted 32 lines
Quoted 32 lines
devel <[email protected]>
Subject: Re: IOREQ server on ArmHi Paul,
Quoted 26 lines · Paul Durrant
Quoted 26 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 26 September 2018 12:57
To: Paul Durrant <[email protected]>
Cc: Julien Grall <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen-devel <xen- [email protected]>
Subject: RE: IOREQ server on Armxen/common/memory.c static int acquire_resource( · line 1110
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 13:02, <[email protected]> wrote:
xen/common/memory.c +3
-2@@ -1105,8 +1105,11 @@ static int acquire_resource(for ( i =0 ; !rc && i < xmar.nr_frames; i++ ) { - rc =set_foreign_p2m_entry (currd, gfn_list[i], -_mfn (mfn_list[i])); + rc = (xmar.flags & XENMEM_rsrc_acq_caller_owned) ? + guest_physmap_add_entry(currd, gfn_list[i], + _mfn(mfn_list[i]), 0,
p2m_ram_rw) :Quoted 3 lines
xen/common/memory.c +2
-0+set_foreign_p2m_entry (currd, gfn_list[i], +_mfn (mfn_list[i]));/* rc should be -EIO for any iteration other than the Quoted 6 lines
Quoted 6 lines
first
Quoted 5 lines
Quoted 5 lines
*/
Quoted 4 lines
xen/common/memory.c +0
-0if ( rc && i ) rc = -EIO ;But the
guest_physmap_add_entry()is problematic as it will IOMMUmap
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
pages
Quoted 1 line
as well, which is probably not wanted.
Yeah, I'd prefer if we avoided establishing IOMMU mappings here. How about transforming
set_foreign_p2m_entry()intoset_special_p2m_entry(), with a type passed in?Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
That sounds like it might work.
Julien, do you want page types to distinguish caller-owned resources
from normal RAM are you ok with
p2m_ram_rweven though it could besubject
Quoted 5 lines
Quoted 5 lines
of another domain's foreign map?
Based on your previous e-mail, I would be fine with that on Arm.
This brings me to the next question. Do you expect
set_special_p2m_entryQuoted 11 lines
Quoted 11 lines
to take a reference on the page?
If not, we may run into some troubles because AFAICT you can map twice the ioreq page in a guest but reference will only be taken on the allocation.
However, the unmap path will always drop a reference when removing the page. This is because Xen at the moment, reference will not be taken on mapping but allocation (we assume a page could not be mapped twice in a guest).
Quoted 7 lines
Quoted 5 lines
Foreign mapping on Arm are a bit special because we get a reference on mapping them and will drop it when the mapping disappear. So we would not have any problem there.
Any thoughts?
Well, as Jan says, on x86 we don't reference count in the P2M so
multiple mappings should not be an issue AFAICT.
I understand that you don't have reference count in the P2M (that's the same on Arm today except for foreign mapping). But I think I can list at least 2 major issues with the design today. Let me give an example based on my understanding.
1. DM requests to map the IOREQ page
a) page allocated (one reference)
b) get reference (will be dropped when the IOREQ server is
destroyed)2. DM requests to map the IOREQ page (second time) No reference taken
Quoted 8 lines
3. DM unmap the IOREQ page
4. DM unmap the IOREQ pageAFAIU, 3. 4. would be done through
XENMEM_remove_from_physmap. So no reference dropped there. While the reference 1.b) will be dropped inhvm_free_ioreq_mfn. AFAICT 1.a) would be kept until the domain die. This would result to Xen memory exhaustion in long term. Did I miss anything?
1.a) would be kept until the IOREQ server is destroyed, which will happen either at domain destruction *or* when the DM destroys it.
Quoted 4 lines
But, I think there are another way for badly written guest to remove the page. It looks like you can use
XENMEM_decrease_reservationas the page belongs to the guest. So a reference would be dropped by 3. and 4.
How so? The pages don't belong to the guest; they belong the the DM domain. They never appear in guest P2M so how can the guest decrease_reservation them? Are you worried about the DM domain doing a decrease reservation?
Paul
Quoted 9 lines
While 3. will drop the reference drop by 1.a), 4. may drop the reference from 1.b) and releasing the page for good. Although the page will still be associated with the IOREQ server until it has been effectively destroyed. Did I miss anything in the code?
Quoted 1 line
It sounds like resource mapping should be treated the same way as
foreign mapping (albeit with a non-foreign domid) such that the reference acquisition occurs at map time.
Quoted 7 lines
If my understanding is correct then yes it would be much safer to get reference here.
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi Paul,
Quoted 115 lines · Paul Durrant
Quoted 115 lines
-----Original Message-----
From: Julien Grall [mailto:[email protected]]
Sent: 27 September 2018 10:42
To: Paul Durrant <[email protected]>; 'Jan Beulich' <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen- devel <[email protected]>
Subject: Re: IOREQ server on ArmHi Paul,
Quoted 7 lines · Paul Durrant
Quoted 7 lines
-----Original Message-----
From: Julien Grall [mailto:[email protected]]
Sent: 26 September 2018 22:32
To: Paul Durrant <[email protected]>; 'Jan Beulich' <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>;xen-
Quoted 32 lines
Quoted 32 lines
devel <[email protected]>
Subject: Re: IOREQ server on ArmHi Paul,
Quoted 26 lines · Paul Durrant
Quoted 26 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 26 September 2018 12:57
To: Paul Durrant <[email protected]>
Cc: Julien Grall <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen-devel <xen- [email protected]>
Subject: RE: IOREQ server on Armxen/common/memory.c static int acquire_resource( · line 1110
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 13:02, <[email protected]> wrote:
xen/common/memory.c +3
-2@@ -1105,8 +1105,11 @@ static int acquire_resource(for ( i =0 ; !rc && i < xmar.nr_frames; i++ ) { - rc =set_foreign_p2m_entry (currd, gfn_list[i], -_mfn (mfn_list[i])); + rc = (xmar.flags & XENMEM_rsrc_acq_caller_owned) ? + guest_physmap_add_entry(currd, gfn_list[i], + _mfn(mfn_list[i]), 0,
p2m_ram_rw) :Quoted 3 lines
xen/common/memory.c +2
-0+set_foreign_p2m_entry (currd, gfn_list[i], +_mfn (mfn_list[i]));/* rc should be -EIO for any iteration other than the Quoted 6 lines
Quoted 6 lines
first
Quoted 5 lines
Quoted 5 lines
*/
Quoted 4 lines
xen/common/memory.c +0
-0if ( rc && i ) rc = -EIO ;But the
guest_physmap_add_entry()is problematic as it will IOMMUmap
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
pages
Quoted 1 line
as well, which is probably not wanted.
Yeah, I'd prefer if we avoided establishing IOMMU mappings here. How about transforming
set_foreign_p2m_entry()intoset_special_p2m_entry(), with a type passed in?Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
That sounds like it might work.
Julien, do you want page types to distinguish caller-owned resources
from normal RAM are you ok with
p2m_ram_rweven though it could besubject
Quoted 5 lines
Quoted 5 lines
of another domain's foreign map?
Based on your previous e-mail, I would be fine with that on Arm.
This brings me to the next question. Do you expect
set_special_p2m_entryQuoted 11 lines
Quoted 11 lines
to take a reference on the page?
If not, we may run into some troubles because AFAICT you can map twice the ioreq page in a guest but reference will only be taken on the allocation.
However, the unmap path will always drop a reference when removing the page. This is because Xen at the moment, reference will not be taken on mapping but allocation (we assume a page could not be mapped twice in a guest).
Quoted 7 lines
Quoted 5 lines
Foreign mapping on Arm are a bit special because we get a reference on mapping them and will drop it when the mapping disappear. So we would not have any problem there.
Any thoughts?
Well, as Jan says, on x86 we don't reference count in the P2M so
multiple mappings should not be an issue AFAICT.
I understand that you don't have reference count in the P2M (that's the same on Arm today except for foreign mapping). But I think I can list at least 2 major issues with the design today. Let me give an example based on my understanding.
1. DM requests to map the IOREQ page
a) page allocated (one reference)
b) get reference (will be dropped when the IOREQ server is
destroyed)2. DM requests to map the IOREQ page (second time) No reference taken
3. DM unmap the IOREQ page
4. DM unmap the IOREQ page
Quoted 7 lines
Quoted 5 lines
AFAIU, 3. 4. would be done through
XENMEM_remove_from_physmap. So no reference dropped there. While the reference 1.b) will be dropped inhvm_free_ioreq_mfn. AFAICT 1.a) would be kept until the domain die. This would result to Xen memory exhaustion in long term. Did I miss anything?1.a) would be kept until the IOREQ server is destroyed, which will happen either at domain destruction *or* when the DM destroys it.
Argh, I mixed get_page_type and get_page(). Sorry for the noise.
Quoted 7 lines
Quoted 5 lines
But, I think there are another way for badly written guest to remove the page. It looks like you can use
XENMEM_decrease_reservationas the page belongs to the guest. So a reference would be dropped by 3. and 4.How so? The pages don't belong to the guest; they belong the the DM domain. They never appear in guest P2M so how can the guest
decrease_reservationthem? Are you worried about the DM domain doing a decrease reservation?
By guest I meant DM domain.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 158 lines
-----Original Message-----
From: Julien Grall [mailto:[email protected]]
Sent: 27 September 2018 11:31
To: Paul Durrant <[email protected]>; 'Jan Beulich' <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen- devel <[email protected]>
Subject: Re: IOREQ server on ArmHi Paul,
Quoted 7 lines · Paul Durrant
Quoted 7 lines
-----Original Message-----
From: Julien Grall [mailto:[email protected]]
Sent: 27 September 2018 10:42
To: Paul Durrant <[email protected]>; 'Jan Beulich' <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>;xen-
Quoted 19 lines
Quoted 19 lines
devel <[email protected]>
Subject: Re: IOREQ server on ArmHi Paul,
Quoted 7 lines · Paul Durrant
Quoted 7 lines
-----Original Message-----
From: Julien Grall [mailto:[email protected]]
Sent: 26 September 2018 22:32
To: Paul Durrant <[email protected]>; 'Jan Beulich' <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>;xen-
Quoted 5 lines
Quoted 5 lines
devel <[email protected]>
Subject: Re: IOREQ server on ArmHi Paul,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Paul Durrant
Quoted 6 lines
Quoted 6 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 26 September 2018 12:57
To: Paul Durrant <[email protected]>
Cc: Julien Grall <[email protected]>; Andrew Cooper <[email protected]>; Roger Pau MonneQuoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Stefano Stabellini <[email protected]>; xen-devel <xen- [email protected]>
Subject: RE: IOREQ server on Armxen/common/memory.c static int acquire_resource( · line 1110
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 13:02, <[email protected]> wrote:
xen/common/memory.c +3
-2@@ -1105,8 +1105,11 @@ static int acquire_resource(for ( i =0 ; !rc && i < xmar.nr_frames; i++ ) { - rc =set_foreign_p2m_entry (currd, gfn_list[i], -_mfn (mfn_list[i])); + rc = (xmar.flags & XENMEM_rsrc_acq_caller_owned) ? + guest_physmap_add_entry(currd, gfn_list[i], + _mfn(mfn_list[i]), 0,
p2m_ram_rw) :Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
xen/common/memory.c static int acquire_resource( · line 1113
Quoted 3 lines
xen/common/memory.c +2
-0+set_foreign_p2m_entry (currd, gfn_list[i], +_mfn (mfn_list[i]));/* rc should be -EIO for any iteration other than the
Quoted 22 lines
Quoted 22 lines
Quoted 6 lines
Quoted 6 lines
first
Quoted 5 lines
Quoted 5 lines
*/
Quoted 4 lines
xen/common/memory.c +0
-0if ( rc && i ) rc = -EIO ;But the
guest_physmap_add_entry()is problematic as it will IOMMUmap
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
pages
Quoted 1 line
as well, which is probably not wanted.
Yeah, I'd prefer if we avoided establishing IOMMU mappings here. How about transforming
set_foreign_p2m_entry()intoset_special_p2m_entry(), with a type passed in?Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
That sounds like it might work.
Julien, do you want page types to distinguish caller-owned resources
from normal RAM are you ok with
p2m_ram_rweven though it could besubject
Quoted 2 lines
Quoted 2 lines
of another domain's foreign map?
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Based on your previous e-mail, I would be fine with that on Arm.
This brings me to the next question. Do you expect
set_special_p2m_entryQuoted 3 lines
Quoted 3 lines
to take a reference on the page?
If not, we may run into some troubles because AFAICT you can map
twice
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
the ioreq page in a guest but reference will only be taken on the allocation.
However, the unmap path will always drop a reference when removing
the
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
page. This is because Xen at the moment, reference will not be taken
on
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
mapping but allocation (we assume a page could not be mapped twice in
a
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
guest).
Foreign mapping on Arm are a bit special because we get a reference
on
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
mapping them and will drop it when the mapping disappear. So we would not have any problem there.
Any thoughts?
Well, as Jan says, on x86 we don't reference count in the P2M so
multiple mappings should not be an issue AFAICT.
I understand that you don't have reference count in the P2M (that's the same on Arm today except for foreign mapping). But I think I can list
at
Quoted 1 line
Quoted 1 line
least 2 major issues with the design today. Let me give an example
based
Quoted 10 lines
Quoted 10 lines
on my understanding.
1. DM requests to map the IOREQ page
a) page allocated (one reference)
b) get reference (will be dropped when the IOREQ server is
destroyed)2. DM requests to map the IOREQ page (second time) No reference taken
Quoted 6 lines
Quoted 6 lines
3. DM unmap the IOREQ page
4. DM unmap the IOREQ pageAFAIU, 3. 4. would be done through
XENMEM_remove_from_physmap. So no reference dropped there. While the reference 1.b) will be dropped inhvm_free_ioreq_mfn. AFAICT 1.a) would be kept until the domain die.This
Quoted 1 line
Quoted 1 line
would result to Xen memory exhaustion in long term. Did I miss
anything?
Quoted 3 lines
Quoted 1 line
1.a) would be kept until the IOREQ server is destroyed, which will
happen either at domain destruction *or* when the DM destroys it.
Argh, I mixed
get_page_typeandget_page(). Sorry for the noise.Quoted 2 lines
Quoted 2 lines
But, I think there are another way for badly written guest to remove
the
Quoted 4 lines
Quoted 3 lines
page. It looks like you can use
XENMEM_decrease_reservationas the page belongs to the guest. So a reference would be dropped by 3. and 4.
Quoted 7 lines
Quoted 1 line
How so? The pages don't belong to the guest; they belong the the DM
domain. They never appear in guest P2M so how can the guest
decrease_reservationthem? Are you worried about the DM domain doing a decrease reservation?By guest I meant DM domain.
If the DM domain is not PV then currently it must be the hardware domain to be able to map resources. Hence we trust it not to descrease_reservation IOREQ pages.
Paul
Quoted 4 lines
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi Paul,
Thank you for your help understanding the resource code.
Quoted 1 line · Paul Durrant
If the DM domain is not PV then currently it must be the hardware domain to be able to map resources. Hence we trust it not to
descrease_reservationIOREQ pages.
Can you point me to check in the code? The only check I found is:
!(xmar.flags & XENMEM_rsrc_acq_caller_owned) && !is_hardware_domain(d)
But this is still allowing to map some of the resources in a DM domain.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi Paul,
Quoted 37 lines · Paul Durrant
Quoted 37 lines
-----Original Message-----
From: Julien Grall [mailto:[email protected]]
Sent: 26 September 2018 11:41
To: Jan Beulich <[email protected]>; Paul Durrant <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen- devel <[email protected]>
Subject: Re: IOREQ server on ArmHi Jan,
On 09/26/2018 09:08 AM, Jan Beulich wrote:_
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 00:39, <[email protected]> wrote:
Hi Paul,
I am looking at porting the IOREQ server infrastructure on Arm. I
didn't
Quoted 8 lines
Quoted 8 lines
need much modification to make it run for Arm. Although, the implementation could be simplified over the x86 implementation.
I noticed some issue while trying to implement the hypercall
XENMEM_acquire_resource. Per my understanding, all the page mapped via that hypercall will use the typep2m_mapping_foreign.This will result to trigger the ASSERT(fdom != dom) in
get_page_from_gfnQuoted 10 lines
Quoted 9 lines
(
asm-arm/p2m.h) because the IOREQ page has been allocated to the emulator domain and mapped to it. AFAICT x86 has the same assert inp2m_get_page_from_gfn(...).IHMO, the ASSERT makes sense because you are only meant to map page belonging to other domain with that type.
So I am wondering whether IOREQ server running in PVH Dom0 has been tested? What would be the best course of action to fix the issue?
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
I think the p2m type needs to be chosen based on
XENMEM_rsrc_acq_caller_owned.I am thinking to introduce
p2m_mapping_owned. Or do we have ap2m_typethat we could re-use?I think we should be able to just use
p2m_ram_rwif it is caller owned.
I thought about p2m_ram_rw but discarded because of the security implications. At least on Arm, this type can be used for foreign mapping, guest_copy helpers. This is not the case for p2m_mapping_foreign.
Do we want to allow thoses resources to be used in hypercall buffer and/or mapped by other guest via the foreign API? If not, then we want to use a different type.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 59 lines
-----Original Message-----
From: Julien Grall [mailto:[email protected]]
Sent: 26 September 2018 12:01
To: Paul Durrant <[email protected]>; Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>; xen- devel <[email protected]>
Subject: Re: IOREQ server on ArmHi Paul,
Quoted 7 lines · Paul Durrant
Quoted 7 lines
-----Original Message-----
From: Julien Grall [mailto:[email protected]]
Sent: 26 September 2018 11:41
To: Jan Beulich <[email protected]>; Paul Durrant <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Stefano Stabellini <[email protected]>;xen-
Quoted 9 lines
Quoted 9 lines
devel <[email protected]>
Subject: Re: IOREQ server on ArmHi Jan,
On 09/26/2018 09:08 AM, Jan Beulich wrote:_
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 26.09.18 at 00:39, <[email protected]> wrote:
Hi Paul,
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
I am looking at porting the IOREQ server infrastructure on Arm. I
didn't
Quoted 5 lines
Quoted 5 lines
need much modification to make it run for Arm. Although, the implementation could be simplified over the x86 implementation.
I noticed some issue while trying to implement the hypercall
XENMEM_acquire_resource. Per my understanding, all the page mappedvia
Quoted 21 lines
Quoted 20 lines
Quoted 3 lines
Quoted 3 lines
that hypercall will use the type
p2m_mapping_foreign.This will result to trigger the ASSERT(fdom != dom) in
get_page_from_gfnQuoted 4 lines
Quoted 4 lines
(
asm-arm/p2m.h) because the IOREQ page has been allocated to the emulator domain and mapped to it. AFAICT x86 has the same assert inp2m_get_page_from_gfn(...).Quoted 8 lines
Quoted 5 lines
IHMO, the ASSERT makes sense because you are only meant to map page belonging to other domain with that type.
So I am wondering whether IOREQ server running in PVH Dom0 has been tested? What would be the best course of action to fix the issue?
I think the p2m type needs to be chosen based on
XENMEM_rsrc_acq_caller_owned.I am thinking to introduce
p2m_mapping_owned. Or do we have ap2m_typethat we could re-use?
Quoted 6 lines
Quoted 1 line
I think we should be able to just use
p2m_ram_rwif it is caller owned.I thought about
p2m_ram_rwbut discarded because of the security implications. At least on Arm, this type can be used for foreign mapping,guest_copyhelpers. This is not the case forp2m_mapping_foreign.
Not sure. The emulator has to have privilege over the target, so any domain having privilege over the emulator would have privilege over the target, wouldn't it? So I don't think there is any security issue.
Quoted 4 lines
Do we want to allow thoses resources to be used in hypercall buffer and/or mapped by other guest via the foreign API? If not, then we want to use a different type.
I can't think of a use-case where we would want that, but I'm not sure there is any particular problem allowing it. Same goes for the IOMMU mappings that I mentioned to Jan though... not really desirable but not necessarily a problem (for existing resource types). A new p2m type may well be a better option.
Paul
Quoted 4 lines
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel