mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-16 13:36:43 +07:00
4dcc2a4d6c
Make sure that exported headers are save to be included by userspace exploiting /dev/chsc. Reported-by: Michael Holzheu <holzheu@linux.vnet.ibm.com> Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
55 lines
1004 B
C
55 lines
1004 B
C
/*
|
|
* Copyright IBM Corp. 2007, 2012
|
|
* Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
|
|
*/
|
|
|
|
#ifndef _ASM_S390_CHPID_H
|
|
#define _ASM_S390_CHPID_H
|
|
|
|
#include <linux/string.h>
|
|
#include <linux/types.h>
|
|
|
|
#define __MAX_CHPID 255
|
|
|
|
struct chp_id {
|
|
__u8 reserved1;
|
|
__u8 cssid;
|
|
__u8 reserved2;
|
|
__u8 id;
|
|
} __attribute__((packed));
|
|
|
|
#ifdef __KERNEL__
|
|
#include <asm/cio.h>
|
|
|
|
static inline void chp_id_init(struct chp_id *chpid)
|
|
{
|
|
memset(chpid, 0, sizeof(struct chp_id));
|
|
}
|
|
|
|
static inline int chp_id_is_equal(struct chp_id *a, struct chp_id *b)
|
|
{
|
|
return (a->id == b->id) && (a->cssid == b->cssid);
|
|
}
|
|
|
|
static inline void chp_id_next(struct chp_id *chpid)
|
|
{
|
|
if (chpid->id < __MAX_CHPID)
|
|
chpid->id++;
|
|
else {
|
|
chpid->id = 0;
|
|
chpid->cssid++;
|
|
}
|
|
}
|
|
|
|
static inline int chp_id_is_valid(struct chp_id *chpid)
|
|
{
|
|
return (chpid->cssid <= __MAX_CSSID);
|
|
}
|
|
|
|
|
|
#define chp_id_for_each(c) \
|
|
for (chp_id_init(c); chp_id_is_valid(c); chp_id_next(c))
|
|
#endif /* __KERNEL */
|
|
|
|
#endif /* _ASM_S390_CHPID_H */
|