This fixes a problem reported from upstream where a panic occurs if the unisys drivers are loaded on a non s-Par system. Reported-by: Fengguang Wu <fengguang.wu@xxxxxxxxx> Signed-off-by: Ken Cox <jkc@xxxxxxxxxx> Tested by: Ken Cox <jkc@xxxxxxxxxx> --- drivers/staging/unisys/channels/chanstub.c | 5 +++++ drivers/staging/unisys/uislib/uislib.c | 5 +++++ drivers/staging/unisys/virthba/virthba.c | 4 ++++ drivers/staging/unisys/virtpci/virtpci.c | 4 ++++ .../staging/unisys/visorchannel/visorchannel_main.c | 4 ++++ .../staging/unisys/visorchipset/visorchipset_main.c | 4 ++++ drivers/staging/unisys/visorutil/visorkmodutils.c | 19 +++++++++++++++++++ 7 files changed, 45 insertions(+) diff --git a/drivers/staging/unisys/channels/chanstub.c b/drivers/staging/unisys/channels/chanstub.c index f504f49..cf8242b 100644 --- a/drivers/staging/unisys/channels/chanstub.c +++ b/drivers/staging/unisys/channels/chanstub.c @@ -23,6 +23,8 @@ #include <linux/slab.h> /* for memcpy */ #include <linux/types.h> +#include <asm/hypervisor.h> + #include "channel.h" #include "chanstub.h" #include "version.h" @@ -30,6 +32,9 @@ static __init int channel_mod_init(void) { + if (x86_hyper != &x86_hyper_unisys_spar) + return -ENODEV; + return 0; } diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 3152a21..ea69803 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -24,6 +24,8 @@ #endif #include <linux/module.h> +#include <asm/hypervisor.h> + #include "commontypes.h" #include <linux/version.h> @@ -2277,6 +2279,9 @@ static int __init uislib_mod_init(void) { + if (x86_hyper != &x86_hyper_unisys_spar) + return -ENODEV; + LOGINF("MONITORAPIS"); LOGINF("sizeof(struct uiscmdrsp):%lu bytes\n", diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index 817b11d..528af0f 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -50,6 +50,7 @@ #include <scsi/scsi_cmnd.h> #include <scsi/scsi_device.h> #include <asm/param.h> +#include <asm/hypervisor.h> #include <linux/proc_fs.h> #include <linux/types.h> @@ -1691,6 +1692,9 @@ virthba_mod_init(void) int error; int i; + if (x86_hyper != &x86_hyper_unisys_spar) + return -ENODEV; + LOGINF("Entering virthba_mod_init...\n"); POSTCODE_LINUX_2(VHBA_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 8e34650..c6db25b 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -37,6 +37,7 @@ #include <linux/proc_fs.h> #include <linux/if_ether.h> #include <linux/version.h> +#include <asm/hypervisor.h> #include "version.h" #include "guestlinuxdebug.h" @@ -1687,6 +1688,9 @@ static int __init virtpci_mod_init(void) int ret; + if (x86_hyper != &x86_hyper_unisys_spar) + return -ENODEV; + LOGINF("Module build: Date:%s Time:%s...\n", __DATE__, __TIME__); POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); diff --git a/drivers/staging/unisys/visorchannel/visorchannel_main.c b/drivers/staging/unisys/visorchannel/visorchannel_main.c index 482ee0a..bd7331b 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_main.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_main.c @@ -23,12 +23,16 @@ #include "channel.h" #include "visorchannel.h" #include "guidutils.h" +#include <asm/hypervisor.h> #define MYDRVNAME "visorchannel" static int __init visorchannel_init(void) { + if (x86_hyper != &x86_hyper_unisys_spar) + return -ENODEV; + INFODRV("driver version %s loaded", VERSION); return 0; } diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index c475e25..a64efa7 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -34,6 +34,7 @@ #include <linux/nls.h> #include <linux/netdevice.h> #include <linux/platform_device.h> +#include <asm/hypervisor.h> #define CURRENT_FILE_PC VISOR_CHIPSET_PC_visorchipset_main_c #define TEST_VNIC_PHYSITF "eth0" /* physical network itf for @@ -2699,6 +2700,9 @@ visorchipset_init(void) struct proc_dir_entry *toolaction_file; struct proc_dir_entry *bootToTool_file; + if (x86_hyper != &x86_hyper_unisys_spar) + return -ENODEV; + LOGINF("chipset driver version %s loaded", VERSION); /* process module options */ POSTCODE_LINUX_2(DRIVER_ENTRY_PC, POSTCODE_SEVERITY_INFO); diff --git a/drivers/staging/unisys/visorutil/visorkmodutils.c b/drivers/staging/unisys/visorutil/visorkmodutils.c index a7d1e94..87ed5bf 100644 --- a/drivers/staging/unisys/visorutil/visorkmodutils.c +++ b/drivers/staging/unisys/visorutil/visorkmodutils.c @@ -17,6 +17,7 @@ #include "uniklog.h" #include "timskmod.h" +#include <asm/hypervisor.h> #define MYDRVNAME "timskmodutils" @@ -69,3 +70,21 @@ void visor_seq_file_done_buffer(struct seq_file *m) kfree(m); } EXPORT_SYMBOL_GPL(visor_seq_file_done_buffer); + + +static __init int +visorutil_mod_init(void) +{ + if (x86_hyper != &x86_hyper_unisys_spar) + return -ENODEV; + + return 0; +} + +static __exit void +visorutil_mod_exit(void) +{ +} + +module_init(visorutil_mod_init); +module_exit(visorutil_mod_exit); -- 1.8.5.3 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel