cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

unpack.h (1586B)


      1/* SPDX-License-Identifier: MIT */
      2#ifndef __NVIF_UNPACK_H__
      3#define __NVIF_UNPACK_H__
      4
      5#define nvif_unvers(r,d,s,m) ({                                                \
      6	void **_data = (d); __u32 *_size = (s); int _ret = (r);                \
      7	if (_ret == -ENOSYS && *_size == sizeof(m)) {                          \
      8		*_data = NULL;                                                 \
      9		*_size = _ret = 0;                                             \
     10	}                                                                      \
     11	_ret;                                                                  \
     12})
     13
     14#define nvif_unpack(r,d,s,m,vl,vh,x) ({                                        \
     15	void **_data = (d); __u32 *_size = (s);                                \
     16	int _ret = (r), _vl = (vl), _vh = (vh);                                \
     17	if (_ret == -ENOSYS && *_size >= sizeof(m) &&                          \
     18	    (m).version >= _vl && (m).version <= _vh) {                        \
     19		*_data = (__u8 *)*_data + sizeof(m);                           \
     20		*_size = *_size - sizeof(m);                                   \
     21		if (_ret = 0, !(x)) {                                          \
     22			_ret = *_size ? -E2BIG : 0;                            \
     23			*_data = NULL;                                         \
     24			*_size = 0;                                            \
     25		}                                                              \
     26	}                                                                      \
     27	_ret;                                                                  \
     28})
     29#endif