[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH v4 02/16] include/uk/arch: assert for undefined behavior in ffs-functions
After discussing this with Simon and Sharan, I suggest to remove this patch from the series and postpone it. (It's stand-alone, so removing this doesn't hurt the rest of the series.) I know I asked for some sort of assertion mechanism for this, but it seems there is still some open discussion of how exactly to implement it for functions in the include/uk/ hierarchy. Cheers, Florian On 09/06/2018 03:48 PM, Yuri Volchkov wrote: The behavior of bitops functions in unikraft is undefined, if the first/last bit is searched, while none is set (zero is passed as an argument). This patch adds an assertion if argument is 0 Signed-off-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx> --- include/uk/arch/x86_64/atomic.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/uk/arch/x86_64/atomic.h b/include/uk/arch/x86_64/atomic.h index c48d5bd..7bab838 100644 --- a/include/uk/arch/x86_64/atomic.h +++ b/include/uk/arch/x86_64/atomic.h @@ -30,6 +30,16 @@ #error Do not include this header directly #endif+#ifdef CONFIG_LIBUKDEBUG+#include <uk/assert.h> +#define __ukarch_atomic_assert(x) UK_ASSERT(x) +#else +#define __ukarch_atomic_assert(x) \ + do { \ + } while (0) +#endif /* CONFIG_LIBUKDEBUG */ + + /** * ukarch_ffs - find first (lowest) set bit in word. * @word: The word to search @@ -38,6 +48,8 @@ */ static inline unsigned int ukarch_ffs(unsigned int word) { + __ukarch_atomic_assert(word); + __asm__("bsfl %1,%0" : "=r" (word) : "rm" (word)); @@ -52,6 +64,8 @@ static inline unsigned int ukarch_ffs(unsigned int word) */ static inline unsigned int ukarch_fls(unsigned int word) { + __ukarch_atomic_assert(word); + __asm__("bsrl %1,%0" : "=r" (word) : "rm" (word)); @@ -66,6 +80,8 @@ static inline unsigned int ukarch_fls(unsigned int word) */ static inline unsigned long ukarch_ffsl(unsigned long word) { + __ukarch_atomic_assert(word); + __asm__("bsfq %1,%0" : "=r" (word) : "rm" (word)); @@ -80,6 +96,8 @@ static inline unsigned long ukarch_ffsl(unsigned long word) */ static inline unsigned long ukarch_flsl(unsigned long word) { + __ukarch_atomic_assert(word); + __asm__("bsrq %1,%0" : "=r" (word) : "rm" (word)); -- Dr. Florian Schmidt フローリアン・シュミット Research Scientist, Systems and Machine Learning Group NEC Laboratories Europe Kurfürsten-Anlage 36, D-69115 Heidelberg Tel. +49 (0)6221 4342-265 Fax: +49 (0)6221 4342-155 e-mail: florian.schmidt@xxxxxxxxx ============================================================ Registered at Amtsgericht Mannheim, Germany, HRB728558 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |