forked from Minki/linux
staging: unisys: moved visor_check_channel from include/channel.h to visorbus/visorbus_main.c
Moved the function visor_check_channel() from include/channel.h to visorbus/visorbus_main.c. Signed-off-by: Sameer Wadgaonkar <sameer.wadgaonkar@unisys.com> Signed-off-by: David Kershner <david.kershner@unisys.com> Reviewed-by: David Binder <david.binder@unisys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
790627cdde
commit
403043c4e1
@ -206,61 +206,6 @@ struct signal_queue_header {
|
||||
u8 filler[12];
|
||||
} __packed;
|
||||
|
||||
/*
|
||||
* Generic function useful for validating any type of channel when it is
|
||||
* received by the client that will be accessing the channel.
|
||||
* Note that <logCtx> is only needed for callers in the EFI environment, and
|
||||
* is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
|
||||
*/
|
||||
static inline int
|
||||
visor_check_channel(struct channel_header *ch,
|
||||
uuid_le expected_uuid,
|
||||
char *chname,
|
||||
u64 expected_min_bytes,
|
||||
u32 expected_version,
|
||||
u64 expected_signature)
|
||||
{
|
||||
if (uuid_le_cmp(expected_uuid, NULL_UUID_LE) != 0) {
|
||||
/* caller wants us to verify type GUID */
|
||||
if (uuid_le_cmp(ch->chtype, expected_uuid) != 0) {
|
||||
pr_err("Channel mismatch on channel=%s(%pUL) field=type expected=%pUL actual=%pUL\n",
|
||||
chname, &expected_uuid,
|
||||
&expected_uuid, &ch->chtype);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* verify channel size */
|
||||
if (expected_min_bytes > 0) {
|
||||
if (ch->size < expected_min_bytes) {
|
||||
pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8Lx actual=0x%-8.8Lx\n",
|
||||
chname, &expected_uuid,
|
||||
(unsigned long long)expected_min_bytes,
|
||||
ch->size);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* verify channel version */
|
||||
if (expected_version > 0) {
|
||||
if (ch->version_id != expected_version) {
|
||||
pr_err("Channel mismatch on channel=%s(%pUL) field=version expected=0x%-8.8lx actual=0x%-8.8x\n",
|
||||
chname, &expected_uuid,
|
||||
(unsigned long)expected_version,
|
||||
ch->version_id);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* verify channel signature */
|
||||
if (expected_signature > 0) {
|
||||
if (ch->signature != expected_signature) {
|
||||
pr_err("Channel mismatch on channel=%s(%pUL) field=signature expected=0x%-8.8Lx actual=0x%-8.8Lx\n",
|
||||
chname, &expected_uuid,
|
||||
expected_signature, ch->signature);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* CHANNEL Guids */
|
||||
/* {414815ed-c58c-11da-95a9-00e08161165f} */
|
||||
#define VISOR_VHBA_CHANNEL_UUID \
|
||||
|
@ -172,6 +172,10 @@ struct visor_device {
|
||||
|
||||
#define to_visor_device(x) container_of(x, struct visor_device, device)
|
||||
|
||||
int visor_check_channel(struct channel_header *ch, uuid_le expected_uuid,
|
||||
char *chname, u64 expected_min_bytes,
|
||||
u32 expected_version, u64 expected_signature);
|
||||
|
||||
int visorbus_register_visor_driver(struct visor_driver *drv);
|
||||
void visorbus_unregister_visor_driver(struct visor_driver *drv);
|
||||
int visorbus_read_channel(struct visor_device *dev,
|
||||
|
@ -35,14 +35,6 @@
|
||||
*/
|
||||
#define VISOR_CONTROLVM_CHANNEL_VERSIONID 1
|
||||
|
||||
#define VISOR_CONTROLVM_CHANNEL_OK_CLIENT(ch) \
|
||||
(visor_check_channel(ch, \
|
||||
VISOR_CONTROLVM_CHANNEL_UUID, \
|
||||
"controlvm", \
|
||||
sizeof(struct visor_controlvm_channel), \
|
||||
VISOR_CONTROLVM_CHANNEL_VERSIONID, \
|
||||
VISOR_CHANNEL_SIGNATURE))
|
||||
|
||||
/* Defines for various channel queues */
|
||||
#define CONTROLVM_QUEUE_REQUEST 0
|
||||
#define CONTROLVM_QUEUE_RESPONSE 1
|
||||
|
@ -73,6 +73,61 @@ static LIST_HEAD(list_all_bus_instances);
|
||||
/* list of visor_device structs, linked via .list_all */
|
||||
static LIST_HEAD(list_all_device_instances);
|
||||
|
||||
/*
|
||||
* Generic function useful for validating any type of channel when it is
|
||||
* received by the client that will be accessing the channel.
|
||||
* Note that <logCtx> is only needed for callers in the EFI environment, and
|
||||
* is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
|
||||
*/
|
||||
int visor_check_channel(struct channel_header *ch,
|
||||
uuid_le expected_uuid,
|
||||
char *chname,
|
||||
u64 expected_min_bytes,
|
||||
u32 expected_version,
|
||||
u64 expected_signature)
|
||||
{
|
||||
if (uuid_le_cmp(expected_uuid, NULL_UUID_LE) != 0) {
|
||||
/* caller wants us to verify type GUID */
|
||||
if (uuid_le_cmp(ch->chtype, expected_uuid) != 0) {
|
||||
pr_err("Channel mismatch on channel=%s(%pUL) field=type expected=%pUL actual=%pUL\n",
|
||||
chname, &expected_uuid,
|
||||
&expected_uuid, &ch->chtype);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* verify channel size */
|
||||
if (expected_min_bytes > 0) {
|
||||
if (ch->size < expected_min_bytes) {
|
||||
pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8Lx actual=0x%-8.8Lx\n",
|
||||
chname, &expected_uuid,
|
||||
(unsigned long long)expected_min_bytes,
|
||||
ch->size);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* verify channel version */
|
||||
if (expected_version > 0) {
|
||||
if (ch->version_id != expected_version) {
|
||||
pr_err("Channel mismatch on channel=%s(%pUL) field=version expected=0x%-8.8lx actual=0x%-8.8x\n",
|
||||
chname, &expected_uuid,
|
||||
(unsigned long)expected_version,
|
||||
ch->version_id);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* verify channel signature */
|
||||
if (expected_signature > 0) {
|
||||
if (ch->signature != expected_signature) {
|
||||
pr_err("Channel mismatch on channel=%s(%pUL) field=signature expected=0x%-8.8Lx actual=0x%-8.8Lx\n",
|
||||
chname, &expected_uuid,
|
||||
expected_signature, ch->signature);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(visor_check_channel);
|
||||
|
||||
static int visorbus_uevent(struct device *xdev, struct kobj_uevent_env *env)
|
||||
{
|
||||
struct visor_device *dev;
|
||||
|
@ -1835,8 +1835,12 @@ visorchipset_init(struct acpi_device *acpi_device)
|
||||
if (err < 0)
|
||||
goto error_destroy_channel;
|
||||
|
||||
if (!VISOR_CONTROLVM_CHANNEL_OK_CLIENT(
|
||||
visorchannel_get_header(controlvm_channel)))
|
||||
if (!visor_check_channel(visorchannel_get_header(controlvm_channel),
|
||||
VISOR_CONTROLVM_CHANNEL_UUID,
|
||||
"controlvm",
|
||||
sizeof(struct visor_controlvm_channel),
|
||||
VISOR_CONTROLVM_CHANNEL_VERSIONID,
|
||||
VISOR_CHANNEL_SIGNATURE))
|
||||
goto error_delete_groups;
|
||||
|
||||
/* if booting in a crash kernel */
|
||||
|
Loading…
Reference in New Issue
Block a user