xen/pvshim: fix GNTTABOP_query_size hypercall forwarding with SMAP
PATCH 1/1 xen/pvshim: fix GNTTABOP_query_size hypercall forwarding with SMAP
Disable SMAP in the shim before bouncing the hypercall, or else L0 will fail to get the hypercall buffer.
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
---
Needs to be backported to the 4.10.0-shim-comet branch.
--- xen/arch/x86/pv/shim.c | 3 +++ 1 file changed, 3 insertions(+)
xen/arch/x86/pv/shim.c +3 -0
@@ -748,7 +748,10 @@ static long pv_shim_grant_table_op(unsigned int cmd, }case GNTTABOP_query_size: +/* Disable SMAP so L0 can access the buffer. */ +stac (); rc =xen_hypercall_grant_table_op (GNTTABOP_query_size, uop.p, count); +clac ();break ;default :
Signature · 7 lines
2.15.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 5 lines · Roger Pau Monne
Disable SMAP in the shim before bouncing the hypercall, or else L0 will fail to get the hypercall buffer.
Signed-off-by Roger Pau Monné <[email protected]>Reported-by Fatih Acar <[email protected]>
Do we have any other examples of this? I expect it might be a common shim pattern.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 21 lines · Roger Pau Monne
Disable SMAP in the shim before bouncing the hypercall, or else L0 will fail to get the hypercall buffer.
Signed-off-by Roger Pau Monné <[email protected]>Reported-by Fatih Acar <[email protected]>---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
---
Needs to be backported to the 4.10.0-shim-comet branch.--- xen/arch/x86/pv/shim.c | 3 +++ 1 file changed, 3 insertions(+)xen/arch/x86/pv/shim.c +0
-0
xen/arch/x86/pv/shim.c static long pv_shim_grant_table_op(unsigned int cmd, · line 751
Quoted 4 lines
xen/arch/x86/pv/shim.c +1
-0@@ -748,7 +748,10 @@ static long pv_shim_grant_table_op(unsigned int cmd, }case GNTTABOP_query_size: +/* Disable SMAP so L0 can access the buffer. */
Interesting.
xen/arch/x86/pv/shim.c static long pv_shim_grant_table_op(unsigned int cmd, · line 754
Quoted 3 lines
xen/arch/x86/pv/shim.c +2
-0+stac (); rc =xen_hypercall_grant_table_op (GNTTABOP_query_size, uop.p, count); +clac ();
There is so far only one instance of this, so doing this ad-hoc stac / clac is OK.
Probably another (more uniformed) way of fixing it is to have our own buffer (forbid passing through uop directly) and the copy back the result. Or we should invent a set of macros to deal with uop.
Either way, we'd better establish a rule going forward.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 33 lines · Wei Liu
Quoted 21 lines · Roger Pau Monne
Disable SMAP in the shim before bouncing the hypercall, or else L0 will fail to get the hypercall buffer.
Signed-off-by Roger Pau Monné <[email protected]>Reported-by Fatih Acar <[email protected]>---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
---
Needs to be backported to the 4.10.0-shim-comet branch.--- xen/arch/x86/pv/shim.c | 3 +++ 1 file changed, 3 insertions(+)xen/arch/x86/pv/shim.c +0
-0xen/arch/x86/pv/shim.c static long pv_shim_grant_table_op(unsigned int cmd, · line 751
Quoted 4 lines
xen/arch/x86/pv/shim.c +1
-0@@ -748,7 +748,10 @@ static long pv_shim_grant_table_op(unsigned int cmd, }case GNTTABOP_query_size: +/* Disable SMAP so L0 can access the buffer. */ Interesting.
xen/arch/x86/pv/shim.c static long pv_shim_grant_table_op(unsigned int cmd, · line 754
Quoted 3 lines
xen/arch/x86/pv/shim.c +2
-0+stac (); rc =xen_hypercall_grant_table_op (GNTTABOP_query_size, uop.p, count); +clac ();
Quoted 6 lines
There is so far only one instance of this, so doing this ad-hoc stac / clac is OK.
Probably another (more uniformed) way of fixing it is to have our own buffer (forbid passing through uop directly) and the copy back the result. Or we should invent a set of macros to deal with uop.
I guess we should figure out what's faster, disabling SMAP or copying to a buffer?
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 37 lines · Roger Pau Monné
Quoted 36 lines · Wei Liu
Quoted 21 lines · Roger Pau Monne
Disable SMAP in the shim before bouncing the hypercall, or else L0 will fail to get the hypercall buffer.
Signed-off-by Roger Pau Monné <[email protected]>Reported-by Fatih Acar <[email protected]>---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
---
Needs to be backported to the 4.10.0-shim-comet branch.--- xen/arch/x86/pv/shim.c | 3 +++ 1 file changed, 3 insertions(+)xen/arch/x86/pv/shim.c +0
-0xen/arch/x86/pv/shim.c static long pv_shim_grant_table_op(unsigned int cmd, · line 751
Quoted 4 lines
xen/arch/x86/pv/shim.c +1
-0@@ -748,7 +748,10 @@ static long pv_shim_grant_table_op(unsigned int cmd, }case GNTTABOP_query_size: +/* Disable SMAP so L0 can access the buffer. */ Interesting.
xen/arch/x86/pv/shim.c static long pv_shim_grant_table_op(unsigned int cmd, · line 754
Quoted 3 lines
xen/arch/x86/pv/shim.c +2
-0+stac (); rc =xen_hypercall_grant_table_op (GNTTABOP_query_size, uop.p, count); +clac ();There is so far only one instance of this, so doing this ad-hoc stac / clac is OK.
Quoted 7 lines
Quoted 3 lines
Probably another (more uniformed) way of fixing it is to have our own buffer (forbid passing through uop directly) and the copy back the result. Or we should invent a set of macros to deal with uop.
I guess we should figure out what's faster, disabling SMAP or copying to a buffer?
It depends. If there are going to be instances that L0 needs to copy to a large buffer in L2 userspace, disabling SMAP is definitely better then bouncing.
In this particular case, it doesn't matter.
You can have my Rb on this patch if you think disabling SMAP is better.
Wei.
Quoted 1 line
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 46 lines · Wei Liu
Quoted 37 lines · Roger Pau Monné
Quoted 36 lines · Wei Liu
Quoted 21 lines · Roger Pau Monne
Disable SMAP in the shim before bouncing the hypercall, or else L0 will fail to get the hypercall buffer.
Signed-off-by Roger Pau Monné <[email protected]>Reported-by Fatih Acar <[email protected]>---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
---
Needs to be backported to the 4.10.0-shim-comet branch.--- xen/arch/x86/pv/shim.c | 3 +++ 1 file changed, 3 insertions(+)xen/arch/x86/pv/shim.c +0
-0xen/arch/x86/pv/shim.c static long pv_shim_grant_table_op(unsigned int cmd, · line 751
Quoted 4 lines
xen/arch/x86/pv/shim.c +1
-0@@ -748,7 +748,10 @@ static long pv_shim_grant_table_op(unsigned int cmd, }case GNTTABOP_query_size: +/* Disable SMAP so L0 can access the buffer. */ Interesting.
xen/arch/x86/pv/shim.c static long pv_shim_grant_table_op(unsigned int cmd, · line 754
Quoted 3 lines
xen/arch/x86/pv/shim.c +2
-0+stac (); rc =xen_hypercall_grant_table_op (GNTTABOP_query_size, uop.p, count); +clac ();There is so far only one instance of this, so doing this ad-hoc stac / clac is OK.
Quoted 7 lines
Quoted 3 lines
Probably another (more uniformed) way of fixing it is to have our own buffer (forbid passing through uop directly) and the copy back the result. Or we should invent a set of macros to deal with uop.
I guess we should figure out what's faster, disabling SMAP or copying to a buffer?
Quoted 7 lines
It depends. If there are going to be instances that L0 needs to copy to a large buffer in L2 userspace, disabling SMAP is definitely better then bouncing.
In this particular case, it doesn't matter.
You can have my Rb on this patch if you think disabling SMAP is better.
It's less cumbersome than copying, and certainly faster if there's no SMAP support, since that's just a nop in that case.
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 47 lines · Roger Pau Monné
Quoted 46 lines · Wei Liu
Quoted 32 lines · Roger Pau Monné
Quoted 31 lines · Wei Liu
Quoted 21 lines · Roger Pau Monne
Disable SMAP in the shim before bouncing the hypercall, or else L0 will fail to get the hypercall buffer.
Signed-off-by Roger Pau Monné <[email protected]>Reported-by Fatih Acar <[email protected]>---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
---
Needs to be backported to the 4.10.0-shim-comet branch.--- xen/arch/x86/pv/shim.c | 3 +++ 1 file changed, 3 insertions(+)xen/arch/x86/pv/shim.c +0
-0xen/arch/x86/pv/shim.c static long pv_shim_grant_table_op(unsigned int cmd, · line 751
Quoted 4 lines
xen/arch/x86/pv/shim.c +1
-0@@ -748,7 +748,10 @@ static long pv_shim_grant_table_op(unsigned int cmd, }case GNTTABOP_query_size: +/* Disable SMAP so L0 can access the buffer. */ Interesting.
Quoted 3 lines
xen/arch/x86/pv/shim.c +2
-0+stac (); rc =xen_hypercall_grant_table_op (GNTTABOP_query_size, uop.p, count); +clac ();Quoted 9 lines
Quoted 6 lines
There is so far only one instance of this, so doing this ad-hoc stac / clac is OK.
Probably another (more uniformed) way of fixing it is to have our own buffer (forbid passing through uop directly) and the copy back the result. Or we should invent a set of macros to deal with uop.
I guess we should figure out what's faster, disabling SMAP or copying to a buffer?
It depends. If there are going to be instances that L0 needs to copy to a large buffer in L2 userspace, disabling SMAP is definitely better then bouncing.
Quoted 5 lines
Quoted 3 lines
In this particular case, it doesn't matter.
You can have my Rb on this patch if you think disabling SMAP is better.
It's less cumbersome than copying, and certainly faster if there's no SMAP support, since that's just a nop in that case.
This hypercall is used once on boot. Its not a perf-critical situation.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 25 lines
Quoted 1 line
Quoted 1 line · On 26.01.18 at 17:28, <[email protected]> wrote:
Quoted 23 lines · Roger Pau Monné
Quoted 21 lines · Wei Liu
xen/arch/x86/pv/shim.c static long pv_shim_grant_table_op(unsigned int cmd, · line 751
Quoted 7 lines · Roger Pau Monne
xen/arch/x86/pv/shim.c +1
-0@@ -748,7 +748,10 @@ static long pv_shim_grant_table_op(unsigned int cmd, }case GNTTABOP_query_size: +/* Disable SMAP so L0 can access the buffer. */ Interesting.
xen/arch/x86/pv/shim.c static long pv_shim_grant_table_op(unsigned int cmd, · line 754
Quoted 3 lines
xen/arch/x86/pv/shim.c +2
-0+stac (); rc =xen_hypercall_grant_table_op (GNTTABOP_query_size, uop.p, count); +clac ();There is so far only one instance of this, so doing this ad-hoc stac / clac is OK.
Probably another (more uniformed) way of fixing it is to have our own buffer (forbid passing through uop directly) and the copy back the result. Or we should invent a set of macros to deal with uop.
Quoted 7 lines
Quoted 3 lines
I guess we should figure out what's faster, disabling SMAP or copying to a buffer?
It depends. If there are going to be instances that L0 needs to copy to a large buffer in L2 userspace, disabling SMAP is definitely better then bouncing.
If you wanted to uniformly copy, determining the overall size of some of the structures would be non-trivial I think, plus you'd run into the same space problems that makes come of the 32-bit compat layer so ugly to read/maintain.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
4.10.0-shim-comet backport request (was: [PATCH] xen/pvshim: ...)
In reply to Roger Pau MonneQuoted 5 lines · Roger Pau Monne
Disable SMAP in the shim before bouncing the hypercall, or else L0 will fail to get the hypercall buffer.
Signed-off-by Roger Pau Monné <[email protected]>Reported-by Fatih Acar <[email protected]>
Quoted 7 lines
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
---
Needs to be backported to the 4.10.0-shim-comet branch.
Ian could you please backport this to the 4.10.0-shim-comet branch?
Staging commit id is 1124a9a26f05439a3aa31eaea227285e50dc94c0.
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel