s390: add vmcp interface.
Subsystems (5)
PATCH 2/3 s390: add vmcp interface.
[patch 2/3] s390: add vmcp interface.
From: Christian Borntraeger <[email protected]>
Add interface to issue VM control program commands.
Signed-off-by Martin Schwidefsky <[email protected]>
diffstat:
arch/s390/defconfig | 1 arch/s390/kernel/cpcmd.c | 109 ++++++++++++--------- arch/s390/kernel/setup.c | 6 - arch/s390/kernel/smp.c | 6 - arch/s390/kernel/traps.c | 2 arch/s390/mm/extmem.c | 4 drivers/s390/Kconfig | 7 + drivers/s390/char/Makefile | 1 drivers/s390/char/con3215.c | 4 drivers/s390/char/con3270.c | 4 drivers/s390/char/vmcp.c | 219 +++++++++++++++++++++++++++++++++++++++++++ drivers/s390/char/vmcp.h | 30 +++++ drivers/s390/char/vmlogrdr.c | 10 - drivers/s390/net/smsgiucv.c | 4 include/asm-s390/cpcmd.h | 18 +++ 15 files changed, 359 insertions(+), 66 deletions(-)
arch/s390/defconfig +1 -0
@@ -254,6 +254,7 @@ CONFIG_S390_TAPE_BLOCK=y # CONFIG_S390_TAPE_34XX=m # CONFIG_VMLOGRDR is not set +# CONFIG_VMCP is not set # CONFIG_MONREADER is not set # CONFIG_DCSS_SHM is not set
arch/s390/kernel/cpcmd.c +65 -44
165 lines not on this page · raw message
arch/s390/kernel/setup.c +3 -3
@@ -198,11 +198,11 @@ static void __init conmode_default(void)char *ptr;if (MACHINE_IS_VM ) { -__cpcmd ("QUERY CONSOLE" , query_buffer,1024 ); +__cpcmd ("QUERY CONSOLE" , query_buffer,1024 ,NULL ); console_devno =simple_strtoul (query_buffer +5 ,NULL ,16 ); ptr =strstr (query_buffer,"SUBCHANNEL =" ); console_irq =simple_strtoul (ptr +13 ,NULL ,16 ); -__cpcmd ("QUERY TERM" , query_buffer,1024 ); +__cpcmd ("QUERY TERM" , query_buffer,1024 ,NULL ); ptr =strstr (query_buffer,"CONMODE" );/* * Set the conmode to 3215 so that the device recognition
@@ -211,7 +211,7 @@ static void __init conmode_default(void)* 3215 and the 3270 driver will try to access the console * device (3215 as console and 3270 as normal tty). */ -__cpcmd ("TERM CONMODE 3215" ,NULL ,0 ); +__cpcmd ("TERM CONMODE 3215" ,NULL ,0 ,NULL );if (ptr ==NULL ) {#if defined(CONFIG_SCLP_CONSOLE )SET_CONSOLE_SCLP ;
arch/s390/kernel/smp.c +3 -3
@@ -284,7 +284,7 @@ static void do_machine_restart(void * __* locks are always held disabled). */ if (MACHINE_IS_VM ) -cpcmd ("IPL" ,NULL ,0 ); +cpcmd ("IPL" ,NULL ,0 ,NULL );else reipl (0x10000 | S390_lowcore.ipl_device); }
@@ -313,7 +313,7 @@ static void do_machine_halt(void * __unuif (atomic_compare_and_swap (-1 ,smp_processor_id (), &cpuid) ==0 ) {smp_send_stop ();if (MACHINE_IS_VM &&strlen (vmhalt_cmd) >0 ) -cpcmd (vmhalt_cmd,NULL ,0 ); +cpcmd (vmhalt_cmd,NULL ,0 ,NULL );signal_processor (smp_processor_id (), sigp_stop_and_store_status); }
@@ -332,7 +332,7 @@ static void do_machine_power_off(void *if (atomic_compare_and_swap (-1 ,smp_processor_id (), &cpuid) ==0 ) {smp_send_stop ();if (MACHINE_IS_VM &&strlen (vmpoff_cmd) >0 ) -cpcmd (vmpoff_cmd,NULL ,0 ); +cpcmd (vmpoff_cmd,NULL ,0 ,NULL );signal_processor (smp_processor_id (), sigp_stop_and_store_status); }
arch/s390/kernel/traps.c +1 -1
@@ -735,7 +735,7 @@ void __init trap_init(void) &ext_int_pfault);#endif #ifndef CONFIG_ARCH_S390X -cpcmd ("SET PAGEX ON" ,NULL ,0 ); +cpcmd ("SET PAGEX ON" ,NULL ,0 ,NULL );#endif } }
arch/s390/mm/extmem.c +2 -2
@@ -576,8 +576,8 @@ segment_save(char *name) segtype_string[seg->range[i].start & 0xff]); }sprintf (cmd2,"SAVESEG %s" , name); -cpcmd (cmd1,NULL ,0 ); -cpcmd (cmd2,NULL ,0 ); +cpcmd (cmd1,NULL ,0 ,NULL ); +cpcmd (cmd2,NULL ,0 ,NULL );spin_unlock (&dcss_lock); }
drivers/s390/char/con3215.c +2 -2
@@ -860,8 +860,8 @@ con3215_init(void)/* Set the console mode for VM */ if (MACHINE_IS_VM ) { -cpcmd ("TERM CONMODE 3215" ,NULL ,0 ); -cpcmd ("TERM AUTOCR OFF" ,NULL ,0 ); +cpcmd ("TERM CONMODE 3215" ,NULL ,0 ,NULL ); +cpcmd ("TERM AUTOCR OFF" ,NULL ,0 ,NULL ); }/* allocate 3215 request structures */
drivers/s390/char/con3270.c +2 -2
@@ -591,8 +591,8 @@ con3270_init(void)/* Set the console mode for VM */ if (MACHINE_IS_VM ) { -cpcmd ("TERM CONMODE 3270" ,0 ,0 ); -cpcmd ("TERM AUTOCR OFF" ,0 ,0 ); +cpcmd ("TERM CONMODE 3270" ,NULL ,0 ,NULL ); +cpcmd ("TERM AUTOCR OFF" ,NULL ,0 ,NULL ); } cdev =ccw_device_probe_console ();
drivers/s390/char/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-$(CONFIG_SCLP_CPI) += sclp_cpi.o obj-$(CONFIG_ZVM_WATCHDOG) += vmwatchdog.o obj-$(CONFIG_VMLOGRDR) += vmlogrdr.o +obj-$(CONFIG_VMCP) += vmcp.o tape-$(CONFIG_S390_TAPE_BLOCK) += tape_block.o tape-$(CONFIG_PROC_FS) += tape_proc.o
drivers/s390/char/vmcp.c +219 -0
219 lines not on this page · raw message
drivers/s390/char/vmcp.h +30 -0
@@ -0,0 +1,30 @@ +/* +* Copyright (C) 2004, 2005 IBM Corporation +* Interface implementation for communication with the v/VM control program +* Version 1.0 +* Author(s): Christian Borntraeger <[email protected]> +* +* +* z/VMs CP offers the possibility to issue commands via the diagnose code 8 +* this driver implements a character device that issues these commands and +* returns the answer of CP. +* +* The idea of this driver is based on cpint from Neale Ferguson +*/ + +#include <asm/semaphore.h> +#include <linux/ioctl.h> + +#define VMCP_GETCODE _IOR(0x10, 1, int) +#define VMCP_SETBUF _IOW(0x10, 2, int) +#define VMCP_GETSIZE _IOR(0x10, 3, int) + +struct vmcp_session { +unsigned int bufsize; +char *response; +int resp_size; +int resp_code; +/* As we use copy_from/to_user, which might * +* sleep and cannot use a spinlock */ +struct semaphore mutex; +};
drivers/s390/char/vmlogrdr.c +5 -5
@@ -236,7 +236,7 @@ vmlogrdr_get_recording_class_AB(void) {int len,i;printk (KERN_DEBUG "vmlogrdr: query command: %s\n" , cp_command); -cpcmd (cp_command, cp_response,sizeof (cp_response)); +cpcmd (cp_command, cp_response,sizeof (cp_response),NULL );printk (KERN_DEBUG "vmlogrdr: response: %s" , cp_response); len =strnlen (cp_response,sizeof (cp_response));// now the parsing
@@ -288,7 +288,7 @@ vmlogrdr_recording(struct vmlogrdr_priv_printk (KERN_DEBUG "vmlogrdr: recording command: %s\n" , cp_command); -cpcmd (cp_command, cp_response,sizeof (cp_response)); +cpcmd (cp_command, cp_response,sizeof (cp_response),NULL );printk (KERN_DEBUG "vmlogrdr: recording response: %s" , cp_response); }
@@ -301,7 +301,7 @@ vmlogrdr_recording(struct vmlogrdr_priv_ qid_string);printk (KERN_DEBUG "vmlogrdr: recording command: %s\n" , cp_command); -cpcmd (cp_command, cp_response,sizeof (cp_response)); +cpcmd (cp_command, cp_response,sizeof (cp_response),NULL );printk (KERN_DEBUG "vmlogrdr: recording response: %s" , cp_response);/* The recording command will usually answer with 'Command complete'
@@ -607,7 +607,7 @@ vmlogrdr_purge_store(struct device * dev priv->recording_name);printk (KERN_DEBUG "vmlogrdr: recording command: %s\n" , cp_command); -cpcmd (cp_command, cp_response,sizeof (cp_response)); +cpcmd (cp_command, cp_response,sizeof (cp_response),NULL );printk (KERN_DEBUG "vmlogrdr: recording response: %s" , cp_response);
@@ -682,7 +682,7 @@ vmlogrdr_recording_status_show(struct dechar cp_command[] ="QUERY RECORDING " ;int len; -cpcmd (cp_command, buf,4096 ); +cpcmd (cp_command, buf,4096 ,NULL ); len =strlen (buf);return len; }
drivers/s390/Kconfig +7 -0
@@ -187,6 +187,13 @@ config VMLOGRDR *SYMPTOM. This driver depends on the IUCV support driver. +config VMCP + tristate "Support for the z/VM CP interface (VM only)" + help + Select this option if you want to be able to interact with the control + program on z/VM + + config MONREADER tristate "API for reading z/VM monitor service records" depends on IUCV
drivers/s390/net/smsgiucv.c +2 -2
@@ -138,7 +138,7 @@ static void __exitsmsg_exit (void) {if (smsg_handle >0 ) { -cpcmd ("SET SMSG OFF" ,0 ,0 ); +cpcmd ("SET SMSG OFF" ,NULL ,0 ,NULL );iucv_sever (smsg_pathid,0 );iucv_unregister_program (smsg_handle);driver_unregister (&smsg_driver);
@@ -177,7 +177,7 @@ smsg_init(void) smsg_handle =0 ;return -EIO ; } -cpcmd ("SET SMSG IUCV" ,0 ,0 ); +cpcmd ("SET SMSG IUCV" ,NULL ,0 ,NULL );return 0 ; }
include/asm-s390/cpcmd.h +16 -2
@@ -11,14 +11,28 @@#define __CPCMD__/* +* the lowlevel function for cpcmd * the caller of __cpcmd has to ensure that the response buffer is below 2 GB */ -extern void __cpcmd (char *cmd,char *response,int rlen); +extern int __cpcmd (const char *cmd,char *response,int rlen,int *response_code);#ifndef __s390x__#define cpcmd __cpcmd#else -extern void cpcmd (char *cmd,char *response,int rlen); +/* +* cpcmd is the in-kernel interface for issuing CP commands +* +* cmd: null-terminated command string, max 240 characters +* response: response buffer for VM's textual response +* rlen: size of the response buffer, cpcmd will not exceed this size +* but will cap the output, if its too large. Everything that +* did not fit into the buffer will be silently dropped +* response_code: return pointer for VM's error code +* return value: the size of the response. The caller can check if the buffer +* was large enough by comparing the return value and rlen +* NOTE: If the response buffer is not below 2 GB, cpcmd can sleep +*/ +extern int cpcmd (const char *cmd,char *response,int rlen,int *response_code);#endif /*__s390x__*/ #endif