-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unifies adjusted and unadjusted register value types (e.g. FRAME_POINTER is now just a PTR_TO_STACK with zero offset). Tracks value alignment by means of tracking known & unknown bits. This also replaces the 'reg->imm' (leading zero bits) calculations for (what were) UNKNOWN_VALUEs. If pointer leaks are allowed, and adjust_ptr_min_max_vals returns -EACCES, treat the pointer as an unknown scalar and try again, because we might be able to conclude something about the result (e.g. pointer & 0x40 is either 0 or 0x40). Verifier hooks in the netronome/nfp driver were changed to match the new data structures. Signed-off-by: Edward Cree <ecree@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Edward Cree
authored and
David S. Miller
committed
Aug 9, 2017
1 parent
e1cb90f
commit f1174f7
Showing
7 changed files
with
1,265 additions
and
852 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* tnum: tracked (or tristate) numbers | ||
* | ||
* A tnum tracks knowledge about the bits of a value. Each bit can be either | ||
* known (0 or 1), or unknown (x). Arithmetic operations on tnums will | ||
* propagate the unknown bits such that the tnum result represents all the | ||
* possible results for possible values of the operands. | ||
*/ | ||
#include <linux/types.h> | ||
|
||
struct tnum { | ||
u64 value; | ||
u64 mask; | ||
}; | ||
|
||
/* Constructors */ | ||
/* Represent a known constant as a tnum. */ | ||
struct tnum tnum_const(u64 value); | ||
/* A completely unknown value */ | ||
extern const struct tnum tnum_unknown; | ||
|
||
/* Arithmetic and logical ops */ | ||
/* Shift a tnum left (by a fixed shift) */ | ||
struct tnum tnum_lshift(struct tnum a, u8 shift); | ||
/* Shift a tnum right (by a fixed shift) */ | ||
struct tnum tnum_rshift(struct tnum a, u8 shift); | ||
/* Add two tnums, return @a + @b */ | ||
struct tnum tnum_add(struct tnum a, struct tnum b); | ||
/* Subtract two tnums, return @a - @b */ | ||
struct tnum tnum_sub(struct tnum a, struct tnum b); | ||
/* Bitwise-AND, return @a & @b */ | ||
struct tnum tnum_and(struct tnum a, struct tnum b); | ||
/* Bitwise-OR, return @a | @b */ | ||
struct tnum tnum_or(struct tnum a, struct tnum b); | ||
/* Bitwise-XOR, return @a ^ @b */ | ||
struct tnum tnum_xor(struct tnum a, struct tnum b); | ||
/* Multiply two tnums, return @a * @b */ | ||
struct tnum tnum_mul(struct tnum a, struct tnum b); | ||
|
||
/* Return a tnum representing numbers satisfying both @a and @b */ | ||
struct tnum tnum_intersect(struct tnum a, struct tnum b); | ||
|
||
/* Return @a with all but the lowest @size bytes cleared */ | ||
struct tnum tnum_cast(struct tnum a, u8 size); | ||
|
||
/* Returns true if @a is a known constant */ | ||
static inline bool tnum_is_const(struct tnum a) | ||
{ | ||
return !a.mask; | ||
} | ||
|
||
/* Returns true if @a == tnum_const(@b) */ | ||
static inline bool tnum_equals_const(struct tnum a, u64 b) | ||
{ | ||
return tnum_is_const(a) && a.value == b; | ||
} | ||
|
||
/* Returns true if @a is completely unknown */ | ||
static inline bool tnum_is_unknown(struct tnum a) | ||
{ | ||
return !~a.mask; | ||
} | ||
|
||
/* Returns true if @a is known to be a multiple of @size. | ||
* @size must be a power of two. | ||
*/ | ||
bool tnum_is_aligned(struct tnum a, u64 size); | ||
|
||
/* Returns true if @b represents a subset of @a. */ | ||
bool tnum_in(struct tnum a, struct tnum b); | ||
|
||
/* Formatting functions. These have snprintf-like semantics: they will write | ||
* up to @size bytes (including the terminating NUL byte), and return the number | ||
* of bytes (excluding the terminating NUL) which would have been written had | ||
* sufficient space been available. (Thus tnum_sbin always returns 64.) | ||
*/ | ||
/* Format a tnum as a pair of hex numbers (value; mask) */ | ||
int tnum_strn(char *str, size_t size, struct tnum a); | ||
/* Format a tnum as tristate binary expansion */ | ||
int tnum_sbin(char *str, size_t size, struct tnum a); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.