p***@xen.org
2018-11-20 14:22:04 UTC
commit cb3b3438c7c73657f3e025f8af8b8dca63fb79d3
Author: Jan Beulich <***@suse.com>
AuthorDate: Tue Nov 20 15:02:18 2018 +0100
Commit: Jan Beulich <***@suse.com>
CommitDate: Tue Nov 20 15:02:18 2018 +0100
x86emul: introduce EXPECT()
This abstracts away the debug/release coverage using both
ASSERT_UNREACHABLE() and a return value of X86EMUL_UNHANDLEABLE.
Signed-off-by: Jan Beulich <***@suse.com>
Reviewed-by: Andrew Cooper <***@citrix.com>
---
xen/arch/x86/x86_emulate/x86_emulate.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index e69dfdd983..ffd8632479 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -1017,6 +1017,15 @@ do { \
if ( rc ) goto done; \
} while (0)
+#define EXPECT(p) \
+do { \
+ if ( unlikely(!(p)) ) \
+ { \
+ ASSERT_UNREACHABLE(); \
+ goto unhandleable; \
+ } \
+} while (0)
+
static inline int mkec(uint8_t e, int32_t ec, ...)
{
return (e < 32 && ((1u << e) & EXC_HAS_EC)) ? ec : X86_EVENT_NO_EC;
@@ -8837,12 +8846,7 @@ x86_emulate(
dst.type = OP_NONE;
break;
default:
- if ( (d & DstMask) != DstMem )
- {
- ASSERT_UNREACHABLE();
- rc = X86EMUL_UNHANDLEABLE;
- goto done;
- }
+ EXPECT((d & DstMask) == DstMem);
break;
}
if ( (d & DstMask) == DstMem )
@@ -8974,9 +8978,11 @@ x86_emulate(
stub.func);
generate_exception_if(stub_exn.info.fields.trapnr == EXC_UD, EXC_UD);
domain_crash(current->domain);
+#endif
+
+ unhandleable:
rc = X86EMUL_UNHANDLEABLE;
goto done;
-#endif
}
#undef op_bytes
--
generated by git-patchbot for /home/xen/git/xen.git#staging
Author: Jan Beulich <***@suse.com>
AuthorDate: Tue Nov 20 15:02:18 2018 +0100
Commit: Jan Beulich <***@suse.com>
CommitDate: Tue Nov 20 15:02:18 2018 +0100
x86emul: introduce EXPECT()
This abstracts away the debug/release coverage using both
ASSERT_UNREACHABLE() and a return value of X86EMUL_UNHANDLEABLE.
Signed-off-by: Jan Beulich <***@suse.com>
Reviewed-by: Andrew Cooper <***@citrix.com>
---
xen/arch/x86/x86_emulate/x86_emulate.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index e69dfdd983..ffd8632479 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -1017,6 +1017,15 @@ do { \
if ( rc ) goto done; \
} while (0)
+#define EXPECT(p) \
+do { \
+ if ( unlikely(!(p)) ) \
+ { \
+ ASSERT_UNREACHABLE(); \
+ goto unhandleable; \
+ } \
+} while (0)
+
static inline int mkec(uint8_t e, int32_t ec, ...)
{
return (e < 32 && ((1u << e) & EXC_HAS_EC)) ? ec : X86_EVENT_NO_EC;
@@ -8837,12 +8846,7 @@ x86_emulate(
dst.type = OP_NONE;
break;
default:
- if ( (d & DstMask) != DstMem )
- {
- ASSERT_UNREACHABLE();
- rc = X86EMUL_UNHANDLEABLE;
- goto done;
- }
+ EXPECT((d & DstMask) == DstMem);
break;
}
if ( (d & DstMask) == DstMem )
@@ -8974,9 +8978,11 @@ x86_emulate(
stub.func);
generate_exception_if(stub_exn.info.fields.trapnr == EXC_UD, EXC_UD);
domain_crash(current->domain);
+#endif
+
+ unhandleable:
rc = X86EMUL_UNHANDLEABLE;
goto done;
-#endif
}
#undef op_bytes
--
generated by git-patchbot for /home/xen/git/xen.git#staging