* [PATCH for-next] x86/shadow: Use ERR_PTR infrastructure for sh_emulate_map_dest()
@ 2017-05-10 10:42 Andrew Cooper
2017-05-10 12:24 ` Jan Beulich
2017-05-10 13:21 ` Tim Deegan
0 siblings, 2 replies; 3+ messages in thread
From: Andrew Cooper @ 2017-05-10 10:42 UTC (permalink / raw)
To: Xen-devel; +Cc: Andrew Cooper, Tim Deegan
sh_emulate_map_dest() predates the introduction of the generic ERR_PTR()
infrasturcture, but take the opportunity to avoid opencoding it.
The chosen error constants require negating to work with IS_ERR(), but no
other changes.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Tim Deegan <tim@xen.org>
---
xen/arch/x86/mm/shadow/multi.c | 8 ++++----
xen/arch/x86/mm/shadow/private.h | 7 +++----
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c
index f65ffc6..dc5d454 100644
--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -4752,8 +4752,8 @@ sh_x86_emulate_write(struct vcpu *v, unsigned long vaddr, void *src,
return X86EMUL_UNHANDLEABLE;
addr = sh_emulate_map_dest(v, vaddr, bytes, sh_ctxt);
- if ( sh_emulate_map_dest_failed(addr) )
- return (long)addr;
+ if ( IS_ERR(addr) )
+ return -PTR_ERR(addr);
paging_lock(v->domain);
memcpy(addr, src, bytes);
@@ -4794,8 +4794,8 @@ sh_x86_emulate_cmpxchg(struct vcpu *v, unsigned long vaddr,
return X86EMUL_UNHANDLEABLE;
addr = sh_emulate_map_dest(v, vaddr, bytes, sh_ctxt);
- if ( sh_emulate_map_dest_failed(addr) )
- return (long)addr;
+ if ( IS_ERR(addr) )
+ return -PTR_ERR(addr);
paging_lock(v->domain);
switch ( bytes )
diff --git a/xen/arch/x86/mm/shadow/private.h b/xen/arch/x86/mm/shadow/private.h
index 472676c..34d069b 100644
--- a/xen/arch/x86/mm/shadow/private.h
+++ b/xen/arch/x86/mm/shadow/private.h
@@ -395,10 +395,9 @@ void shadow_unhook_mappings(struct domain *d, mfn_t smfn, int user_only);
/* Returns a mapped pointer to write to, or one of the following error
* indicators. */
-#define MAPPING_UNHANDLEABLE ((void *)(unsigned long)X86EMUL_UNHANDLEABLE)
-#define MAPPING_EXCEPTION ((void *)(unsigned long)X86EMUL_EXCEPTION)
-#define MAPPING_SILENT_FAIL ((void *)(unsigned long)X86EMUL_OKAY)
-#define sh_emulate_map_dest_failed(rc) ((unsigned long)(rc) <= 3)
+#define MAPPING_UNHANDLEABLE ERR_PTR(-X86EMUL_UNHANDLEABLE)
+#define MAPPING_EXCEPTION ERR_PTR(-X86EMUL_EXCEPTION)
+#define MAPPING_SILENT_FAIL ERR_PTR(-X86EMUL_OKAY)
void *sh_emulate_map_dest(struct vcpu *v, unsigned long vaddr,
unsigned int bytes, struct sh_emulate_ctxt *sh_ctxt);
void sh_emulate_unmap_dest(struct vcpu *v, void *addr, unsigned int bytes,
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH for-next] x86/shadow: Use ERR_PTR infrastructure for sh_emulate_map_dest()
2017-05-10 10:42 [PATCH for-next] x86/shadow: Use ERR_PTR infrastructure for sh_emulate_map_dest() Andrew Cooper
@ 2017-05-10 12:24 ` Jan Beulich
2017-05-10 13:21 ` Tim Deegan
1 sibling, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2017-05-10 12:24 UTC (permalink / raw)
To: Andrew Cooper; +Cc: Tim Deegan, Xen-devel
>>> On 10.05.17 at 12:42, <andrew.cooper3@citrix.com> wrote:
> sh_emulate_map_dest() predates the introduction of the generic ERR_PTR()
> infrasturcture, but take the opportunity to avoid opencoding it.
>
> The chosen error constants require negating to work with IS_ERR(), but no
> other changes.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
although ...
> --- a/xen/arch/x86/mm/shadow/private.h
> +++ b/xen/arch/x86/mm/shadow/private.h
> @@ -395,10 +395,9 @@ void shadow_unhook_mappings(struct domain *d, mfn_t smfn, int user_only);
>
> /* Returns a mapped pointer to write to, or one of the following error
> * indicators. */
> -#define MAPPING_UNHANDLEABLE ((void *)(unsigned long)X86EMUL_UNHANDLEABLE)
> -#define MAPPING_EXCEPTION ((void *)(unsigned long)X86EMUL_EXCEPTION)
> -#define MAPPING_SILENT_FAIL ((void *)(unsigned long)X86EMUL_OKAY)
> -#define sh_emulate_map_dest_failed(rc) ((unsigned long)(rc) <= 3)
> +#define MAPPING_UNHANDLEABLE ERR_PTR(-X86EMUL_UNHANDLEABLE)
> +#define MAPPING_EXCEPTION ERR_PTR(-X86EMUL_EXCEPTION)
> +#define MAPPING_SILENT_FAIL ERR_PTR(-X86EMUL_OKAY)
... this last one is certainly a little off to have the minus: No matter
what, we fully depend on X86EMUL_OKAY being zero here.
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH for-next] x86/shadow: Use ERR_PTR infrastructure for sh_emulate_map_dest()
2017-05-10 10:42 [PATCH for-next] x86/shadow: Use ERR_PTR infrastructure for sh_emulate_map_dest() Andrew Cooper
2017-05-10 12:24 ` Jan Beulich
@ 2017-05-10 13:21 ` Tim Deegan
1 sibling, 0 replies; 3+ messages in thread
From: Tim Deegan @ 2017-05-10 13:21 UTC (permalink / raw)
To: Andrew Cooper; +Cc: Xen-devel
At 11:42 +0100 on 10 May (1494416566), Andrew Cooper wrote:
> sh_emulate_map_dest() predates the introduction of the generic ERR_PTR()
> infrasturcture, but take the opportunity to avoid opencoding it.
>
> The chosen error constants require negating to work with IS_ERR(), but no
> other changes.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
s/sturct/struct/
Reviewed-by: Tim Deegan <tim@xen.org>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-10 13:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-10 10:42 [PATCH for-next] x86/shadow: Use ERR_PTR infrastructure for sh_emulate_map_dest() Andrew Cooper
2017-05-10 12:24 ` Jan Beulich
2017-05-10 13:21 ` Tim Deegan
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.