From 80e64b92b3212042ae817ea307fe36af3a525fc1 Mon Sep 17 00:00:00 2001 From: Joe Devlin Date: Sat, 13 Nov 2021 20:20:43 -0600 Subject: [PATCH 01/35] dynamic linking support including the ability to bootstrap by looking up a CMS Server w/o static code Signed-off-by: Joe Devlin --- c/cpool64.c | 124 ++++++++++++++++++++++++++++++++++++++ c/crossmemory.c | 157 ++++++++++++++++++++++++++++++++++++++++++++++++ c/le.c | 8 +-- h/cpool64.h | 42 +++++++++++++ h/crossmemory.h | 18 +++++- h/le.h | 14 ++++- h/metalio.h | 1 + h/scheduling.h | 1 + h/shrmem64.h | 5 ++ h/unixfile.h | 23 +++++++ h/utils.h | 4 +- h/zvt.h | 18 ++++-- 12 files changed, 397 insertions(+), 18 deletions(-) create mode 100644 c/cpool64.c create mode 100644 h/cpool64.h diff --git a/c/cpool64.c b/c/cpool64.c new file mode 100644 index 000000000..7a51dca4c --- /dev/null +++ b/c/cpool64.c @@ -0,0 +1,124 @@ + + +/* + This program and the accompanying materials are + made available under the terms of the Eclipse Public License v2.0 which accompanies + this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html + + SPDX-License-Identifier: EPL-2.0 + + Copyright Contributors to the Zowe Project. +*/ + +#ifdef METTLE +#include +#include +#include +#include +#include +#else +#include +#include +#include +#include +#include +#endif + +#include "zowetypes.h" +#include "alloc.h" +#include "cpool64.h" +#include "zos.h" + +#define IARCP64_PARMLIST_LENGTH 72 + +uint64_t iarcp64Create(bool isCommon, int cellSize, int *returnCodePtr, int *reasonCodePtr){ + uint64_t cpid = 0; + char header[24]; + int returnCode = 0; + int reasonCode = 0; + char parmlist[IARCP64_PARMLIST_LENGTH]; + if (isCommon){ + __asm(ASM_PREFIX + " IARCP64 REQUEST=BUILD,CELLSIZE=%3,OUTPUT_CPID=%0," + "HEADER=%1,COMMON=YES,OWNER=HOME,DUMP=NO,FPROT=NO," + "TYPE=PAGEABLE,CALLERKEY=YES,TRAILER=NO,FAILMODE=RC," + "RETCODE=%4,RSNCODE=%5,MF=(E,%2,COMPLETE) \n" + : + : + "m"(cpid),"m"(header),"m"(parmlist),"m"(cellSize),"m"(returnCode),"m"(reasonCode) + ); + } else{ + __asm(ASM_PREFIX + " IARCP64 REQUEST=BUILD,CELLSIZE=%3,OUTPUT_CPID=%0," + "HEADER=%1,COMMON=NO,OWNINGTASK=CMRO,DUMP=NO,FPROT=NO," + "TYPE=PAGEABLE,CALLERKEY=YES,TRAILER=NO,FAILMODE=RC," + "RETCODE=%4,RSNCODE=%5,MF=(E,%2,COMPLETE) \n" + : + : + "m"(cpid),"m"(header),"m"(parmlist),"m"(cellSize),"m"(returnCode),"m"(reasonCode) + ); + } + *returnCodePtr = returnCode; + *reasonCodePtr = reasonCode; + return cpid; +} + +void *iarcp64Get(uint64_t cpid, int *returnCodePtr, int *reasonCodePtr){ + uint64_t cellAddr = 0; + int returnCode = 0; + int reasonCode = 0; + char f4sa[160]; + __asm(ASM_PREFIX + " LAE 13,%4 \n" /* Required by REG=SAVE */ + " IARCP64 REQUEST=GET,INPUT_CPID=%3,REGS=SAVE," + "CELLADDR=%0,TRACE=NO,EXPAND=YES,FAILMODE=RC," + "RETCODE=%1,RSNCODE=%2 \n" + : + "=m"(cellAddr),"=m"(returnCode),"=m"(reasonCode) + : + "m"(cpid),"m"(f4sa) + ); + *returnCodePtr = returnCode; + *reasonCodePtr = reasonCode; + return (void*)cellAddr; +} + +void iarcp64Free(uint64_t cpid, void *cellAddr){ + char f4sa[160]; + __asm(ASM_PREFIX + " LAE 13,%2 \n" /* Required by REG=SAVE */ + " IARCP64 REQUEST=FREE,INPUT_CPID=%1,REGS=SAVE," + "CELLADDR=%0 \n" + : + : + "m"(cellAddr),"m"(cpid),"m"(f4sa) + ); +} + +int iarcp64Delete(uint64_t cpid, int *reasonCodePtr){ + int returnCode = 0; + int reasonCode = 0; + __asm(ASM_PREFIX + " IARCP64 REQUEST=DELETE,INPUT_CPID=%2 \n" + " ST 15,%0 \n" + " ST 0,%1 " + : + "=m"(returnCode),"=m"(reasonCode) + : + "m"(cpid) + ); + *reasonCodePtr = reasonCode; + return returnCode; +} + + +/* + This program and the accompanying materials are + made available under the terms of the Eclipse Public License v2.0 which accompanies + this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html + + SPDX-License-Identifier: EPL-2.0 + + Copyright Contributors to the Zowe Project. +*/ + diff --git a/c/crossmemory.c b/c/crossmemory.c index 1afe6b1cf..8044931ca 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -1598,6 +1598,7 @@ typedef struct PCRoutineEnvironment_tag { CAA dummyCAA; RLETask dummyRLETask; char filler0[4]; + RLEAnchor dummyRLEAnchor; RecoveryContext recoveryContext; } PCRoutineEnvironment; ZOWE_PRAGMA_PACK_RESET @@ -1607,6 +1608,8 @@ ZOWE_PRAGMA_PACK_RESET memset((envAddr), 0, sizeof(PCRoutineEnvironment)); \ memcpy((envAddr)->eyecatcher, PC_ROUTINE_ENV_EYECATCHER, sizeof((envAddr)->eyecatcher)); \ (envAddr)->dummyCAA.rleTask = &(envAddr)->dummyRLETask; \ + (envAddr)->dummyRLETask.anchor = &(envAddr)->dummyRLEAnchor; \ + (envAddr)->dummyRLEAnchor.metalDynamicLinkageVector = (cmsGlobalAreaAddr)->dynamicLinkageVector; \ int returnCode = RC_CMS_OK; \ __asm(" LA 12,0(,%0) " : : "r"(&(envAddr)->dummyCAA) : ); \ int recoveryRC = RC_RCV_OK; \ @@ -2810,10 +2813,164 @@ static CMSBuildTimestamp getServerBuildTimestamp() { return timestamp; } +#ifndef _LP64 + +static void *getCMSServerLookup(int *routineLengthPtr){ + void *routineAddress = NULL; + int routineLength; + __asm(ASM_PREFIX + " LARL 1,L$UXIT00 \n" + " ST 1,%0 \n" + " LRL 1,L$RTNLEN \n" + " ST 1,%1 \n" + " J L$UXITEX \n" + "L$UXIT00 DS 0H \n" + "L$UXITRT DS 0H \n" + " STM 14,12,12(13) \n" + " L 14,16 GET CVTPTR \n" + " L 14,X'8C'(,14) GET ECVT \n" + " L 14,X'CC'(,14) GET CSRCTABL \n" + " L 14,X'23C'(,14) GET ZVT \n" + " LTR 14,14 TEST NON ZERO \n" + " BZ L$NOZVT \n" + " L 14,X'9C'(,14) FIRST ZVTE \n" + "ZVTELOOP LTR 14,14 NULL CHECK ZVTE \n" + " BZ L$NOZVTE \n" + " L 4,X'4C'(,14) PRODUCT ANCHOR \n" + " LARL 3,L$CMSRVG LOAD CONSTANT \n" + " CLC 0(8,4),0(3) Is it RSCMSRVG \n" + " BNE ZVTECNTU No CMS Global Server \n" + " L 1,0(,1) Server Name is First Arg \n" + " CLC X'50'(16,4),0(1) Is it the right server name \n" + " BE ZVTEFND Found it ! \n" + "ZVTECNTU LG 14,X'40'(,14) ZVTE = ZVTE->NEXT \n" + " B ZVTELOOP Should limit by N, too \n" + "ZVTEFND LR 15,4 return the CMS GA \n" + " B L$RETURN Non error end \n" + "L$NOZVT XGR 15,15 clear result \n" + " LGFI 0,8 reason 8 \n" + " B L$RETURN \n" + "L$NOZVTE XGR 15,15 clear result \n" + " LGFI 0,12 reason 8 \n" + " B L$RETURN \n" + "L$NOCMSG XGR 15,15 clear result \n" + " LGFI 0,16 reason 8 \n" + " B L$RETURN \n" + "L$RETURN L 14,12(,13) Restore everything but R15 \n" + " LA 15,0 Let's not change the outside world \n" + " LM 1,12,24(13) Restore \n" + " BR 14 \n" + /* non executable code */ + " LTORG \n" + "L$CMSRVG DC CL8'RSCMSRVG' \n" + "L$RTNLEN DC A(*-L$UXIT00) \n" + "L$UXITEX DS 0H \n" + : "=m"(routineAddress),"=m"(routineLength) + : + : "r1"); + *routineLengthPtr = routineLength; + return routineAddress; +} + +#else + +static void *getCMSServerLookup(int *routineLengthPtr){ + void *routineAddress = NULL; + int routineLength; + __asm(ASM_PREFIX + " LARL 1,L$UXIT00 \n" + " STG 1,%0 \n" + " LRL 1,L$RTNLEN \n" + " ST 1,%1 \n" + " J L$UXITEX \n" + "L$UXIT00 DS 0H \n" + "L$UXITRT DS 0H \n" + " STMG 14,12,8(13) \n" + " LLGT 14,16 GET CVTPTR \n" + " LGF 14,X'8C'(,14) GET ECVT \n" + " LGF 14,X'CC'(,14) GET CSRCTABL \n" + " LGF 14,X'23C'(,14) GET ZVT \n" + " LTR 14,14 TEST NON ZERO \n" + " BZ L$NOZVT \n" + " LGF 14,X'9C'(,14) FIRST ZVTE \n" + "ZVTELOOP LTR 14,14 NULL CHECK ZVTE \n" + " BZ L$NOZVTE \n" + " LGF 4,X'4C'(,14) PRODUCT ANCHOR \n" + " LARL 3,L$CMSRVG LOAD CONSTANT \n" + " CLC 0(8,4),0(3) Is it RSCMSRVG \n" + " BNE ZVTECNTU No CMS Global Server \n" + " LG 1,0(,1) Server Name is First Arg \n" + " CLC X'50'(16,4),0(1) Is it the right server name \n" + " BE ZVTEFND Found it ! \n" + "ZVTECNTU LG 14,X'40'(,14) ZVTE = ZVTE->NEXT \n" + " B ZVTELOOP Should limit by N, too \n" + "ZVTEFND LGR 15,4 return the CMS GA \n" + " B L$RETURN Non error end \n" + "L$NOZVT XGR 15,15 clear result \n" + " LGFI 0,8 reason 8 \n" + " B L$RETURN \n" + "L$NOZVTE XGR 15,15 clear result \n" + " LGFI 0,12 reason 12 \n" + " B L$RETURN \n" + "L$NOCMSG XGR 15,15 clear result \n" + " LGFI 0,16 reason 16 \n" + " B L$RETURN \n" + "L$RETURN LG 14,8(,13) Restore everything but R15,R0 \n" + /* " DC XL2'0000' \n" */ + " LMG 1,12,32(13) Restore \n" + " BR 14 \n" + /* non executable code */ + " LTORG \n" + "L$CMSRVG DC CL8'RSCMSRVG' \n" + "L$RTNLEN DC A(*-L$UXIT00) \n" + "L$UXITEX DS 0H \n" + : "=m"(routineAddress),"=m"(routineLength) + : + : "r1"); + *routineLengthPtr = routineLength; + return routineAddress; +} + +#endif + +static int installCMSLookupRoutine(ZVT *zvt){ + int routineLength = 0; + char *routineMaster = getCMSServerLookup(&routineLength); + if (routineLength > MAX_CMS_GETTER_ROUTINE_SIZE){ + return RC_CMS_NO_ROOM_FOR_CMS_GETTER; + } + + int wasProblemState = supervisorMode(TRUE); + int originalKey = setKey(0); + + memcpy(zvt->cmsGetterRoutineCode,routineMaster,routineLength); + zvt->version = ZVT_VERSION; + zvt->cmsGetterRoutine = (void*)&(zvt->cmsGetterRoutineCode[0]); + + setKey(originalKey); + if (wasProblemState) { + supervisorMode(FALSE); + } + + return RC_CMS_OK; +} + + static int allocateGlobalResources(CrossMemoryServer *server) { #ifndef CROSS_MEMORY_SERVER_DEBUG + bool buildingZVTFromScratch = (zvtGet() == NULL); + zvtInit(); + ZVT *zvt = zvtGet(); + + if (buildingZVTFromScratch || + (zvt->version == 1 && ZVT_VERSION > 1)){ + int installStatus = installCMSLookupRoutine(zvt); + if (installStatus){ + return installStatus; + } + } #endif CrossMemoryServerGlobalArea *globalArea = NULL; diff --git a/c/le.c b/c/le.c index d4e243560..bb0e5a923 100644 --- a/c/le.c +++ b/c/le.c @@ -187,7 +187,7 @@ void showRTL(){ RLEAnchor *makeRLEAnchor(){ RLEAnchor *anchor = (RLEAnchor*)safeMalloc31(sizeof(RLEAnchor),"RLEAnchor"); memset(anchor,0,sizeof(RLEAnchor)); - memcpy(anchor->eyecatcher,"RLEANCHR",8); + memcpy(anchor->eyecatcher,RLE_ANCHOR_EYECATCHER,8); #ifdef __ZOWE_OS_ZOS @@ -202,11 +202,9 @@ RLEAnchor *makeRLEAnchor(){ #ifdef METTLE CAA *caa = (CAA*)safeMalloc31(sizeof(CAA),"METTLE CAA"); anchor->mainTaskCAA = caa; - anchor->masterRTLVector = NULL; /* we don't have one of these, yet */ #else CAA *caa = (CAA*)getCAA(); anchor->mainTaskCAA = caa; - anchor->masterRTLVector = caa->runtimeLibraryVectorTable; #endif #endif /* __ZOWE_OS_ZOS */ @@ -240,9 +238,9 @@ void returnGlobalEnvironment(void){ RLETask *makeRLETask(RLEAnchor *anchor, int taskFlags, int functionPointer(RLETask *task)){ - RLETask *task = (RLETask*)safeMalloc31(sizeof(RLETask),"RTSK"); + RLETask *task = (RLETask*)safeMalloc31(sizeof(RLETask),RLE_TASK_EYECATCHER); memset(task,0,sizeof(RLETask)); - memcpy(task->eyecatcher,"RTSK",4); + memcpy(task->eyecatcher,RLE_TASK_EYECATCHER,4); task->flags = taskFlags; task->anchor = anchor; return task; diff --git a/h/cpool64.h b/h/cpool64.h new file mode 100644 index 000000000..9dda7aee6 --- /dev/null +++ b/h/cpool64.h @@ -0,0 +1,42 @@ + + +/* + This program and the accompanying materials are + made available under the terms of the Eclipse Public License v2.0 which accompanies + this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html + + SPDX-License-Identifier: EPL-2.0 + + Copyright Contributors to the Zowe Project. +*/ + +#ifndef SRC_CPOOL64_H_ +#define SRC_CPOOL64_H_ + +#ifndef __LONGNAME__ + +#define iarcp64Create CPL64CRE +#define iarcp64Get CPL64GET +#define iarcp64Free CPL64FRE +#define iarcp64Delete CPL64DEL + +#endif + +uint64_t iarcp64Create(bool isCommon, int cellSize, int *returnCodePtr, int *reasonCodePtr); +void *iarcp64Get(uint64_t cpid, int *returnCodePtr, int *reasonCodePtr); +void iarcp64Free(uint64_t cpid, void *cellAddr); +int iarcp64Delete(uint64_t cpid, int *reasonCodePtr); + + +#endif /* SRC_CPOOL64_H_ */ + + +/* + This program and the accompanying materials are + made available under the terms of the Eclipse Public License v2.0 which accompanies + this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html + + SPDX-License-Identifier: EPL-2.0 + + Copyright Contributors to the Zowe Project. +*/ diff --git a/h/crossmemory.h b/h/crossmemory.h index 36f1cdcee..a116e29b6 100644 --- a/h/crossmemory.h +++ b/h/crossmemory.h @@ -138,7 +138,8 @@ #define RC_CMS_ALLOC_FAILED 87 #define RC_CMS_NON_PRIVATE_MODULE 88 #define RC_CMS_BAD_DUB_STATUS 89 -#define RC_CMS_MAX_RC 89 +#define RC_CMS_NO_ROOM_FOR_CMS_GETTER 90 +#define RC_CMS_MAX_RC 90 extern const char *CMS_RC_DESCRIPTION[]; @@ -233,7 +234,19 @@ typedef struct CrossMemoryServerGlobalArea_tag { PAD_LONG(0, RecoveryStatePool *pcssRecoveryPool); CPID pcssStackPool; - char reserved3[492]; + PAD_LONG(0, void *dynamicLinkageVector); /* This is an opt-in feature for CMS + Servers that want to offer Dynamic Linkage + to some of their routines is an MVS/Metal/ASM + way. That is to provide a well-known + linkage vector with well-known offsets. + + The CMS server does stipulate anything about + what these services are. + + The ZIS (a CMS) server uses this for its plugins. + + */ + char reserved3[484]; CrossMemoryService serviceTable[CROSS_MEMEORY_SERVER_MAX_SERVICE_COUNT]; @@ -379,6 +392,7 @@ ZOWE_PRAGMA_PACK_RESET #define cmsCallService2 CMCALLS2 #define cmsCallService3 CMCALLS3 #define cmsPrintf CMCMSPRF +#define vcmsPrintf CMCMSVPF #define cmsGetConfigParm CMGETPRM #define cmsGetConfigParmUnchecked CMGETPRU #define cmsGetPCLogLevel CMGETLOG diff --git a/h/le.h b/h/le.h index 964fed720..c692778bf 100644 --- a/h/le.h +++ b/h/le.h @@ -169,11 +169,18 @@ typedef struct LibraryFunction_tag{ #define RLE_RTL_64 0x0001 #define RLE_RTL_XPLINK 0x0002 +#define RLE_ANCHOR_EYECATCHER "RLEANCHR" + typedef struct RLEAnchor_tag{ char eyecatcher[8]; /* RLEANCHR */ int64 flags; CAA *mainTaskCAA; - void **masterRTLVector; /* copied from CAA */ + /* void **masterRTLVector; */ /* copied from CAA */ + + /* METAL libraries are in some system vector, + however, if applications want dynamic linking of their + services, there must be an anchor point for them, too */ + PAD_LONG(0, void *metalDynamicLinkageVector); } RLEAnchor; /* An RLE Task can run in SRB mode or TCB Mode or switchably depending on run @@ -193,9 +200,11 @@ typedef struct RLEAnchor_tag{ are better off in 31-bit land */ +#define RLE_TASK_EYECATCHER "RTSK" + /* Warning: must be kept in sync with RLETASK in scheduling.c */ typedef struct RLETask_tag{ - char eyecatcher[4]; /* "RTSK"; */ + char eyecatcher[4]; /* "RTSK" */ int statusIndicator; int flags; @@ -254,7 +263,6 @@ void showRTL(); #define RLE_TASK_RECOVERABLE 0x0010 #define RLE_TASK_DISPOSABLE 0x0020 - typedef struct RLEAnchor_tag{ char eyecatcher[8]; /* RLEANCHR */ } RLEAnchor; diff --git a/h/metalio.h b/h/metalio.h index ad6f87611..2e1c8b59a 100644 --- a/h/metalio.h +++ b/h/metalio.h @@ -163,6 +163,7 @@ typedef struct SYSOUT_struct{ #ifndef __LONGNAME__ #define getSYSOUTStruct GTSYSOUT #define wtoPrintf WTOPRNF +#define authWTOPrintf AWTOPRNF #define sendWTO SENDWTO #define qsamPrintf QSAMPRNF #endif diff --git a/h/scheduling.h b/h/scheduling.h index 5a8d7aa07..cfff2be22 100644 --- a/h/scheduling.h +++ b/h/scheduling.h @@ -25,6 +25,7 @@ #endif int zosWait(void *ecb, int clearFirst); +int zosWaitList(void *ecbList, int numberToWait); int zosPost(void *ecb, int completionCode); RLETask *makeRLETask(RLEAnchor *anchor, diff --git a/h/shrmem64.h b/h/shrmem64.h index b28cffe63..fd5c389da 100644 --- a/h/shrmem64.h +++ b/h/shrmem64.h @@ -29,11 +29,16 @@ #define shrmem64GetAddressSpaceToken SHR64TKN #define shrmem64Alloc SHR64ALC +#define shrmem64Alloc2 SHR64AL2 +#define shrmem64CommonAlloc SHR64CAL +#define shrmem64CommonAlloc2 SHR64CA2 #define shrmem64Release SHR64REL #define shrmem64ReleaseAll SHR64REA #define shrmem64GetAccess SHR64GAC +#define shrmem64GetAccess SHR64GA2 #define shrmem64RemoveAccess SHR64RAC +#define shrmem64RemoveAccess2 SHR64RA2 #endif diff --git a/h/unixfile.h b/h/unixfile.h index 58d8560ae..a0bf9c17b 100644 --- a/h/unixfile.h +++ b/h/unixfile.h @@ -393,6 +393,16 @@ int setFileTrace(int toWhat); reason code is perhaps platform specific debugging info */ +#ifndef __LONGNAME__ + +#define fileWrite FILWRITE +#define fileGetChar FILGTCHR +#define fileCopy FILECOPY +#define fileRename FILRNAME +#define fileDelete FILDLETE + +#endif + UnixFile *fileOpen(const char *filename, int options, int mode, int bufferSize, int *returnCode, int *reasonCode); int fileRead(UnixFile *file, char *buffer, int desiredBytes, @@ -474,6 +484,19 @@ int fileUnlock(UnixFile *file, int *returnCode, int *reasonCode); #endif +#ifndef __LONGNAME__ + +#define fileInfoIsDirectory FNFOISDR +#define fileInfoSize FNFOSIZE +#define fileInfoCCSID FNFOCCID +#define fileUnixCreaionime FILUXCRT +#define fileEOF FILISOEF +#define fileGetINode FILGINOD +#define fileGetDeviceID FILDEVID +#define fileClose FILCLOSE + +#endif + int fileInfoIsDirectory(const FileInfo *info); int64 fileInfoSize(const FileInfo *info); #if defined(__ZOWE_OS_LINUX) || defined(__ZOWE_OS_AIX) diff --git a/h/utils.h b/h/utils.h index ccd56fc41..26b571e33 100644 --- a/h/utils.h +++ b/h/utils.h @@ -184,8 +184,8 @@ typedef struct ShortLivedHeap_tag{ #define makeShortLivedHeap MAKESLH #define makeShortLivedHeap64 MAKSLH64 #define noisyMalloc NYMALLOC -#define decodeBase32 DECODB32 -#define encodeBase32 ENCODB32 +#define base32Encode DECODB32 +#define base32Decode ENCODB32 #define decodeBase64 DECODB64 #define encodeBase64 ENCODB64 #define cleanURLParamValue CLNURLPV diff --git a/h/zvt.h b/h/zvt.h index ba21de2cc..bf0bfbb8f 100644 --- a/h/zvt.h +++ b/h/zvt.h @@ -24,7 +24,7 @@ ZOWE_PRAGMA_PACK #define ZVT_OFFSET 0x023C #define ZVT_EYECATCHER "ZOWEVT " -#define ZVT_VERSION 1 +#define ZVT_VERSION 2 /* 2 introduces dynamic linking support */ #define ZVT_KEY 0 #define ZVT_SUBPOOL 228 @@ -65,10 +65,13 @@ typedef struct ZVTEntry_tag { uint16_t productMaint; char reserved4[2]; char productDescription[32]; - char reserved5[128]; + PAD_LONG(3, void *zisStubVector); + char reserved5[120]; } ZVTEntry; +#define MAX_CMS_GETTER_ROUTINE_SIZE 0x100 + typedef struct ZVT_tag { char eyecatcher[8]; @@ -78,11 +81,14 @@ typedef struct ZVT_tag { char reserved1[1]; uint16_t size; char reserved2[2]; + /* Offset 0x10 */ uint64_t creationTime; char jobName[8]; + /* Offset 0x20 */ uint16_t asid; - - char reserved3[118]; + char reserved22[6]; + PAD_LONG(9, void *cmsGetterRoutine); + char reserved3[104]; struct { PAD_LONG(10, ZVTEntry *zis); @@ -97,8 +103,8 @@ typedef struct ZVT_tag { PAD_LONG(19, ZVTEntry *reservedSlot9); } zvteSlots; - char reserved4[3864]; - + char reserved4[3864-MAX_CMS_GETTER_ROUTINE_SIZE]; + char cmsGetterRoutineCode[MAX_CMS_GETTER_ROUTINE_SIZE]; } ZVT; ZOWE_PRAGMA_PACK_RESET From 957141776f97b343673464224402e5bb4feb287d Mon Sep 17 00:00:00 2001 From: Joe Devlin Date: Tue, 30 Nov 2021 13:12:24 -0600 Subject: [PATCH 02/35] RAS changes for dynZIS Signed-off-by: Joe Devlin --- c/crossmemory.c | 87 ++++++++++++++++++++++++++++++------------------- h/crossmemory.h | 2 +- h/zvt.h | 7 ++-- 3 files changed, 59 insertions(+), 37 deletions(-) diff --git a/c/crossmemory.c b/c/crossmemory.c index 8044931ca..4e78e0d1b 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -2825,6 +2825,12 @@ static void *getCMSServerLookup(int *routineLengthPtr){ " ST 1,%1 \n" " J L$UXITEX \n" "L$UXIT00 DS 0H \n" + " J L$UXITRT \n" + " DC CL8'ZWECMSLK' ROUTINE NAME \n" + " DC XL1'01' VERSION \n" + " DC XL1'" ZVT_KEY_STR "' KEY \n" + " DC XL1'" ZVT_SUBPOOL_STR "' SUBPOOL \n" + " DC XL5'0000000000' Reserved \n" "L$UXITRT DS 0H \n" " STM 14,12,12(13) \n" " L 14,16 GET CVTPTR \n" @@ -2832,32 +2838,31 @@ static void *getCMSServerLookup(int *routineLengthPtr){ " L 14,X'CC'(,14) GET CSRCTABL \n" " L 14,X'23C'(,14) GET ZVT \n" " LTR 14,14 TEST NON ZERO \n" - " BZ L$NOZVT \n" + " JZ L$NOZVT \n" " L 14,X'9C'(,14) FIRST ZVTE \n" "ZVTELOOP LTR 14,14 NULL CHECK ZVTE \n" - " BZ L$NOZVTE \n" + " JZ L$NOZVTE \n" " L 4,X'4C'(,14) PRODUCT ANCHOR \n" " LARL 3,L$CMSRVG LOAD CONSTANT \n" " CLC 0(8,4),0(3) Is it RSCMSRVG \n" - " BNE ZVTECNTU No CMS Global Server \n" + " JNE ZVTECNTU No CMS Global Server \n" " L 1,0(,1) Server Name is First Arg \n" " CLC X'50'(16,4),0(1) Is it the right server name \n" - " BE ZVTEFND Found it ! \n" + " JE ZVTEFND Found it ! \n" "ZVTECNTU LG 14,X'40'(,14) ZVTE = ZVTE->NEXT \n" - " B ZVTELOOP Should limit by N, too \n" + " J ZVTELOOP Should limit by N, too \n" "ZVTEFND LR 15,4 return the CMS GA \n" - " B L$RETURN Non error end \n" + " J L$RETURN Non error end \n" "L$NOZVT XGR 15,15 clear result \n" " LGFI 0,8 reason 8 \n" - " B L$RETURN \n" + " J L$RETURN \n" "L$NOZVTE XGR 15,15 clear result \n" - " LGFI 0,12 reason 8 \n" - " B L$RETURN \n" + " LGFI 0,12 reason 12 \n" + " J L$RETURN \n" "L$NOCMSG XGR 15,15 clear result \n" - " LGFI 0,16 reason 8 \n" - " B L$RETURN \n" + " LGFI 0,16 reason 16 \n" + " J L$RETURN \n" "L$RETURN L 14,12(,13) Restore everything but R15 \n" - " LA 15,0 Let's not change the outside world \n" " LM 1,12,24(13) Restore \n" " BR 14 \n" /* non executable code */ @@ -2884,6 +2889,13 @@ static void *getCMSServerLookup(int *routineLengthPtr){ " ST 1,%1 \n" " J L$UXITEX \n" "L$UXIT00 DS 0H \n" + " J L$UXITRT \n" + " DC CL8'ZWECMSLK' ROUTINE NAME \n" + /* ZVT_KEY, ZVT_SUBPOOL */ + " DC XL1'01' VERSION \n" + " DC XL1'" ZVT_KEY_STR "' KEY \n" + " DC XL1'" ZVT_SUBPOOL_STR "' SUBPOOL \n" + " DC XL5'0000000000' Reserved \n" "L$UXITRT DS 0H \n" " STMG 14,12,8(13) \n" " LLGT 14,16 GET CVTPTR \n" @@ -2891,30 +2903,30 @@ static void *getCMSServerLookup(int *routineLengthPtr){ " LGF 14,X'CC'(,14) GET CSRCTABL \n" " LGF 14,X'23C'(,14) GET ZVT \n" " LTR 14,14 TEST NON ZERO \n" - " BZ L$NOZVT \n" + " JZ L$NOZVT \n" " LGF 14,X'9C'(,14) FIRST ZVTE \n" "ZVTELOOP LTR 14,14 NULL CHECK ZVTE \n" - " BZ L$NOZVTE \n" + " JZ L$NOZVTE \n" " LGF 4,X'4C'(,14) PRODUCT ANCHOR \n" " LARL 3,L$CMSRVG LOAD CONSTANT \n" " CLC 0(8,4),0(3) Is it RSCMSRVG \n" - " BNE ZVTECNTU No CMS Global Server \n" + " JNE ZVTECNTU No CMS Global Server \n" " LG 1,0(,1) Server Name is First Arg \n" " CLC X'50'(16,4),0(1) Is it the right server name \n" - " BE ZVTEFND Found it ! \n" + " JE ZVTEFND Found it ! \n" "ZVTECNTU LG 14,X'40'(,14) ZVTE = ZVTE->NEXT \n" - " B ZVTELOOP Should limit by N, too \n" + " J ZVTELOOP Should limit by N, too \n" "ZVTEFND LGR 15,4 return the CMS GA \n" - " B L$RETURN Non error end \n" + " J L$RETURN Non error end \n" "L$NOZVT XGR 15,15 clear result \n" " LGFI 0,8 reason 8 \n" - " B L$RETURN \n" + " J L$RETURN \n" "L$NOZVTE XGR 15,15 clear result \n" " LGFI 0,12 reason 12 \n" - " B L$RETURN \n" + " J L$RETURN \n" "L$NOCMSG XGR 15,15 clear result \n" " LGFI 0,16 reason 16 \n" - " B L$RETURN \n" + " J L$RETURN \n" "L$RETURN LG 14,8(,13) Restore everything but R15,R0 \n" /* " DC XL2'0000' \n" */ " LMG 1,12,32(13) Restore \n" @@ -2933,26 +2945,35 @@ static void *getCMSServerLookup(int *routineLengthPtr){ #endif +/* always give the routine its own page so that it might be marked executable + as opposed to most ZVT storage which is unexecutable data */ + +#define ZWECMSLK_LENGTH 0x1000 + static int installCMSLookupRoutine(ZVT *zvt){ int routineLength = 0; char *routineMaster = getCMSServerLookup(&routineLength); - if (routineLength > MAX_CMS_GETTER_ROUTINE_SIZE){ - return RC_CMS_NO_ROOM_FOR_CMS_GETTER; - } int wasProblemState = supervisorMode(TRUE); - int originalKey = setKey(0); - - memcpy(zvt->cmsGetterRoutineCode,routineMaster,routineLength); - zvt->version = ZVT_VERSION; - zvt->cmsGetterRoutine = (void*)&(zvt->cmsGetterRoutineCode[0]); - - setKey(originalKey); + int status = RC_CMS_OK; + char *routineStorage = cmAlloc(ZWECMSLK_LENGTH, ZVT_SUBPOOL, ZVT_KEY); + if (routineStorage == NULL){ + status = RC_CMS_NO_ROOM_FOR_CMS_GETTER; + } else{ + int originalKey = setKey(0); + + memset(routineStorage,0,ZWECMSLK_LENGTH); + memcpy(routineStorage,routineMaster,routineLength); + zvt->version = ZVT_VERSION; + zvt->cmsGetterRoutine = (void*)routineStorage; + + setKey(originalKey); + } if (wasProblemState) { supervisorMode(FALSE); } - return RC_CMS_OK; + return status; } @@ -2960,7 +2981,7 @@ static int allocateGlobalResources(CrossMemoryServer *server) { #ifndef CROSS_MEMORY_SERVER_DEBUG bool buildingZVTFromScratch = (zvtGet() == NULL); - + zvtInit(); ZVT *zvt = zvtGet(); diff --git a/h/crossmemory.h b/h/crossmemory.h index a116e29b6..4e2ebcdf5 100644 --- a/h/crossmemory.h +++ b/h/crossmemory.h @@ -234,7 +234,7 @@ typedef struct CrossMemoryServerGlobalArea_tag { PAD_LONG(0, RecoveryStatePool *pcssRecoveryPool); CPID pcssStackPool; - PAD_LONG(0, void *dynamicLinkageVector); /* This is an opt-in feature for CMS + PAD_LONG(1, void *dynamicLinkageVector); /* This is an opt-in feature for CMS Servers that want to offer Dynamic Linkage to some of their routines is an MVS/Metal/ASM way. That is to provide a well-known diff --git a/h/zvt.h b/h/zvt.h index bf0bfbb8f..ebf1291ae 100644 --- a/h/zvt.h +++ b/h/zvt.h @@ -27,6 +27,8 @@ ZOWE_PRAGMA_PACK #define ZVT_VERSION 2 /* 2 introduces dynamic linking support */ #define ZVT_KEY 0 #define ZVT_SUBPOOL 228 +#define ZVT_KEY_STR "0" +#define ZVT_SUBPOOL_STR "E4" typedef struct ZVTEntry_tag { @@ -87,7 +89,7 @@ typedef struct ZVT_tag { /* Offset 0x20 */ uint16_t asid; char reserved22[6]; - PAD_LONG(9, void *cmsGetterRoutine); + PAD_LONG(9, void *cmsGetterRoutine); /* points at another page in 31-common */ char reserved3[104]; struct { @@ -103,8 +105,7 @@ typedef struct ZVT_tag { PAD_LONG(19, ZVTEntry *reservedSlot9); } zvteSlots; - char reserved4[3864-MAX_CMS_GETTER_ROUTINE_SIZE]; - char cmsGetterRoutineCode[MAX_CMS_GETTER_ROUTINE_SIZE]; + char reserved4[3864]; } ZVT; ZOWE_PRAGMA_PACK_RESET From 3d2ca9b17e86aaa8baf6e5f90f05399be2de5b21 Mon Sep 17 00:00:00 2001 From: Aditya Ranshinge Date: Thu, 12 May 2022 12:59:42 +0530 Subject: [PATCH 03/35] API for Dataset/Dataset Member Allocation - Tim Signed-off-by: Aditya Ranshinge --- c/dynalloc.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++ h/dynalloc.h | 50 +++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+) diff --git a/c/dynalloc.c b/c/dynalloc.c index 1d68ff3e9..6f152169a 100644 --- a/c/dynalloc.c +++ b/c/dynalloc.c @@ -60,6 +60,10 @@ TextUnit *createIntTextUnit(int key, int value) { return createSimpleTextUnit2(key, (char*)&value, sizeof(value)); } +TextUnit *createIntTextUnitLength(int key, int value, int length) { + return createSimpleTextUnit2(key, (char*)&value, length); +} + TextUnit *createInt8TextUnit(int key, int8_t value) { return createSimpleTextUnit2(key, (char*)&value, sizeof(value)); } @@ -68,6 +72,14 @@ TextUnit *createInt16TextUnit(int key, int16_t value) { return createSimpleTextUnit2(key, (char*)&value, sizeof(value)); } +TextUnit *createInt24TextUnit(int key, int value) { + return createSimpleTextUnit2(key, (char*)&value + 1, INT24_SIZE); +} + +TextUnit *createLongIntTextUnit(int key, long long value) { + return createSimpleTextUnit2(key, (char*)&value, sizeof(value)); +} + TextUnit *createCharTextUnit(int key, char value) { char valueArray[2]; valueArray[0] = value; @@ -75,6 +87,14 @@ TextUnit *createCharTextUnit(int key, char value) { return createSimpleTextUnit2(key, valueArray, 1); } +TextUnit *createCharTextUnit2(int key, short value) { + char valueArray[3]; + valueArray[0] = value >> BYTE_LENGTH & BYTE_FULL_MASK; + valueArray[1] = value & BYTE_FULL_MASK; + valueArray[2] = 0; + return createSimpleTextUnit2(key, valueArray, 2); +} + TextUnit *createCompoundTextUnit(int key, char **values, int valueCount) { TextUnit *textUnit = NULL; @@ -834,6 +854,65 @@ int dynallocDataset(DynallocInputParms *inputParms, int *reasonCode) { } +int dynallocNewDataset(int *reasonCode, DynallocNewTextUnit *setTextUnits, int TextUnitsSize) { + ALLOC_STRUCT31( + STRUCT31_NAME(below2G), + STRUCT31_FIELDS( + DynallocParms parms; + TextUnit ** __ptr32 textUnits; + ) + ); + + below2G->textUnits = (TextUnit **)safeMalloc31(sizeof(TextUnit*) * TextUnitsSize, "Text units array"); + + DynallocParms *parms = &below2G->parms; + dynallocParmsInit(parms); + + dynallocParmsSetTextUnits(parms, below2G->textUnits, TextUnitsSize); + + int rc; + + do { + rc = -1; + for (int i = 0; i < TextUnitsSize; i++) { + if (setTextUnits[i].type == TEXT_UNIT_STRING) { + below2G->textUnits[i] = createSimpleTextUnit2(setTextUnits[i].key, setTextUnits[i].data.string, setTextUnits[i].size); + } + else if (setTextUnits[i].type == TEXT_UNIT_CHARINT) { + if (setTextUnits[i].size == sizeof(char)) { + below2G->textUnits[i] = createCharTextUnit(setTextUnits[i].key, setTextUnits[i].data.number); + } + else if (setTextUnits[i].size == sizeof(short)) { + below2G->textUnits[i] = createInt16TextUnit(setTextUnits[i].key, setTextUnits[i].data.number); + } + else if (setTextUnits[i].size == INT24_SIZE) { + below2G->textUnits[i] = createInt24TextUnit(setTextUnits[i].key, setTextUnits[i].data.number); + } + else if (setTextUnits[i].size == sizeof(long long)) { + long number = setTextUnits[i].data.number; + below2G->textUnits[i] = createLongIntTextUnit(setTextUnits[i].key, (long long)setTextUnits[i].data.number); + } + } + else if (setTextUnits[i].type == TEXT_UNIT_BOOLEAN) { + below2G->textUnits[i] = createSimpleTextUnit2(setTextUnits[i].key, NULL, 0); + } + } + + turn_on_HOB(below2G->textUnits[TextUnitsSize - 1]); + rc = invokeDynalloc(parms); + *reasonCode = dynallocParmsGetInfoCode(parms) + + (dynallocParmsGetErrorCode(parms) << 16); + } while (0); + freeTextUnitArray(below2G->textUnits, TextUnitsSize); + safeFree31((char*)below2G->textUnits, sizeof(TextUnit*) * TextUnitsSize); + dynallocParmsTerm(parms); + parms = NULL; + FREE_STRUCT31( + STRUCT31_NAME(below2G) + ); + return rc; +} + int dynallocDatasetMember(DynallocInputParms *inputParms, int *reasonCode, char *member) { diff --git a/h/dynalloc.h b/h/dynalloc.h index 7cebd8e4a..0ac158845 100644 --- a/h/dynalloc.h +++ b/h/dynalloc.h @@ -209,7 +209,17 @@ X'40' Data set available for printing at the end of the job. #define DALVSER 0x0010 #define DALVSEQ 0x0012 #define DALDSORG 0x003C +#define DALDSORG_VSAM 0x0008 +#define DALDSORG_GRAPHICS 0x0080 +#define DALDSORG_PO 0x0200 +#define DALDSORG_POU 0x0300 +#define DALDSORG_MQ 0x0400 +#define DALDSORG_CQ 0x0800 +#define DALDSORG_CX 0x1000 +#define DALDSORG_DA 0x2000 +#define DALDSORG_DAU 0x2100 #define DALDSORG_PS 0x4000 +#define DALDSORG_PSU 0x4100 #define DALBLKSZ 0x0030 #define DALLRECL 0x0042 #define DALBUFNO 0x0034 @@ -252,8 +262,11 @@ TextUnit *createSimpleTextUnit2(int key, char *value, int firstParameterLength); TextUnit *createCharTextUnit(int key, char value); TextUnit *createCompoundTextUnit(int key, char **values, int valueCount); TextUnit *createIntTextUnit(int key, int value); +TextUnit *createCharTextUnit2(int key, short value); TextUnit *createInt8TextUnit(int key, int8_t value); +TextUnit *createIntTextUnitLength(int key, int value, int length); TextUnit *createInt16TextUnit(int key, int16_t value); +TextUnit *createInt24TextUnit(int key, int value); void freeTextUnit(TextUnit * text_unit); /* open a stream to the internal reader */ @@ -681,9 +694,29 @@ int DeallocDDName(char *ddname); // Values for disposition field #define DISP_OLD 0x01 #define DISP_MOD 0x02 +#define DISP_NEW 0x04 #define DISP_SHARE 0x08 #define DISP_DELETE 0x04 +// Values for normal disposition field +#define DISP_UNCATLG 0x01 +#define DISP_CATLG 0x02 +#define DISP_DELETE 0x04 +#define DISP_KEEP 0x08 + +#define DALSYSOU_DEFAULT 0x08 + +#define SPIN_UNALLOC 0x80 +#define SPIN_ENDJOB 0x40 + +#define BYTE_LENGTH 8 +#define BYTE_FULL_MASK 0xff + +#define INT24_SIZE 3 +#define VOLSER_SIZE 6 +#define CLASS_WRITER_SIZE 8 +#define TOTAL_TEXT_UNITS 23 + /* Use this structure to pass parameters to DYNALLOC functions. * Dsname should be padded by spaces. */ typedef struct DynallocInputParms_tag { @@ -696,11 +729,28 @@ typedef struct DynallocInputParms_tag { char reserved[3]; } DynallocInputParms; +typedef struct DynallocNewTextUnit_tag { +#define TEXT_UNIT_STRING 1 +#define TEXT_UNIT_BOOLEAN 2 +#define TEXT_UNIT_CHARINT 3 +#define TEXT_UNIT_NULL 4 +#define JSON_TYPE_ERROR 666 + int type; + int size; + int key; + union { + int number; + char *string; + int boolean; + } data; +} DynallocNewTextUnit; + #pragma map(dynallocDataset, "DYNAUALC") #pragma map(dynallocDatasetMember, "DYNAUALM") #pragma map(unallocDataset, "DYNADALC") int dynallocDataset(DynallocInputParms *inputParms, int *reasonCode); +int dynallocNewDataset(int *reasonCode, DynallocNewTextUnit *setTextUnits, int TextUnitsSize); int dynallocDatasetMember(DynallocInputParms *inputParms, int *reasonCode, char *member); int unallocDataset(DynallocInputParms *inputParms, int *reasonCode); From cd65a55dcf4334a155a20e9f8b53428bcac33b2b Mon Sep 17 00:00:00 2001 From: Aditya Ranshinge Date: Mon, 16 May 2022 19:43:21 +0530 Subject: [PATCH 04/35] Added Allocation Unit, Average Record Unit, Primary Secondary Space, Directory Blocks, Dataset Name Type attributes for dataset creation Signed-off-by: Aditya Ranshinge --- h/dynalloc.h | 50 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/h/dynalloc.h b/h/dynalloc.h index 0ac158845..de498bff9 100644 --- a/h/dynalloc.h +++ b/h/dynalloc.h @@ -205,26 +205,40 @@ X'40' Data set available for printing at the end of the job. details at http://publib.boulder.ibm.com/infocenter/zos/v1r12/index.jsp?topic=%2Fcom.ibm.zos.r12.ieaa800%2Fsyssym.htm */ /* MORE DALXXXX PARMS EXIST BUT ARE NOT YET CODED !! */ +#define DALDSORG_NULL 0x00 +#define DALDSORG_LARGE 0x01 +#define DALDSORG_BASIC 0x02 +#define DALDSORG_EXTPREF 0x04 +#define DALDSORG_EXTREQ 0x08 +#define DALDSORG_HFS 0x10 +#define DALDSORG_PIPE 0x20 +#define DALDSORG_PDS 0x40 +#define DALDSORG_PDSE 0x80 + +#define DALDSORG_MREC 0x20 +#define DALDSORG_KREC 0x40 +#define DALDSORG_UREC 0x80 +#define DALDSORG_VSAM 0x0008 +#define DALDSORG_GRAPHICS 0x0080 +#define DALDSORG_PO 0x0200 +#define DALDSORG_POU 0x0300 +#define DALDSORG_MQ 0x0400 +#define DALDSORG_CQ 0x0800 +#define DALDSORG_CX 0x1000 +#define DALDSORG_DA 0x2000 +#define DALDSORG_DAU 0x2100 +#define DALDSORG_PS 0x4000 +#define DALDSORG_PSU 0x4100 #define DALVSER 0x0010 #define DALVSEQ 0x0012 #define DALDSORG 0x003C -#define DALDSORG_VSAM 0x0008 -#define DALDSORG_GRAPHICS 0x0080 -#define DALDSORG_PO 0x0200 -#define DALDSORG_POU 0x0300 -#define DALDSORG_MQ 0x0400 -#define DALDSORG_CQ 0x0800 -#define DALDSORG_CX 0x1000 -#define DALDSORG_DA 0x2000 -#define DALDSORG_DAU 0x2100 -#define DALDSORG_PS 0x4000 -#define DALDSORG_PSU 0x4100 #define DALBLKSZ 0x0030 #define DALLRECL 0x0042 #define DALBUFNO 0x0034 #define DALNCP 0x0044 #define DALAVGR 0x8010 +#define DALDSNT 0x8012 #define DALDIAGN 0x0054 #define DALBRTKN 0x006E /* dynamic unallocation */ @@ -716,6 +730,14 @@ int DeallocDDName(char *ddname); #define VOLSER_SIZE 6 #define CLASS_WRITER_SIZE 8 #define TOTAL_TEXT_UNITS 23 +#define LEN_THREE_BYTES 3 +#define LEN_ONE_BYTE 1 + +#define TEXT_UNIT_STRING 1 +#define TEXT_UNIT_BOOLEAN 2 +#define TEXT_UNIT_CHARINT 3 +#define TEXT_UNIT_NULL 4 +#define JSON_TYPE_ERROR 666 /* Use this structure to pass parameters to DYNALLOC functions. * Dsname should be padded by spaces. */ @@ -729,12 +751,8 @@ typedef struct DynallocInputParms_tag { char reserved[3]; } DynallocInputParms; + typedef struct DynallocNewTextUnit_tag { -#define TEXT_UNIT_STRING 1 -#define TEXT_UNIT_BOOLEAN 2 -#define TEXT_UNIT_CHARINT 3 -#define TEXT_UNIT_NULL 4 -#define JSON_TYPE_ERROR 666 int type; int size; int key; From eecd3c1f84c5afe3cfaccd90aa85071d602ce28e Mon Sep 17 00:00:00 2001 From: Aditya Ranshinge Date: Tue, 17 May 2022 18:29:40 +0530 Subject: [PATCH 05/35] type casting to resolve 64 bit build issue Signed-off-by: Aditya Ranshinge --- c/dynalloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c/dynalloc.c b/c/dynalloc.c index 6f152169a..641c6d3c9 100644 --- a/c/dynalloc.c +++ b/c/dynalloc.c @@ -868,7 +868,7 @@ int dynallocNewDataset(int *reasonCode, DynallocNewTextUnit *setTextUnits, int T DynallocParms *parms = &below2G->parms; dynallocParmsInit(parms); - dynallocParmsSetTextUnits(parms, below2G->textUnits, TextUnitsSize); + dynallocParmsSetTextUnits(parms, (TextUnit * __ptr32 *)below2G->textUnits, TextUnitsSize); int rc; @@ -903,7 +903,7 @@ int dynallocNewDataset(int *reasonCode, DynallocNewTextUnit *setTextUnits, int T *reasonCode = dynallocParmsGetInfoCode(parms) + (dynallocParmsGetErrorCode(parms) << 16); } while (0); - freeTextUnitArray(below2G->textUnits, TextUnitsSize); + freeTextUnitArray((TextUnit * __ptr32 *)below2G->textUnits, TextUnitsSize); safeFree31((char*)below2G->textUnits, sizeof(TextUnit*) * TextUnitsSize); dynallocParmsTerm(parms); parms = NULL; From feba774ebadfbd9b9aebc546da832a62f5d798ff Mon Sep 17 00:00:00 2001 From: Aditya Ranshinge Date: Thu, 2 Jun 2022 16:03:44 +0530 Subject: [PATCH 06/35] review comments fix Signed-off-by: Aditya Ranshinge --- c/dynalloc.c | 79 ++++++++++++++++++++++++++++++++++++---------------- h/dynalloc.h | 21 ++++---------- 2 files changed, 60 insertions(+), 40 deletions(-) diff --git a/c/dynalloc.c b/c/dynalloc.c index 641c6d3c9..5152447e4 100644 --- a/c/dynalloc.c +++ b/c/dynalloc.c @@ -30,6 +30,9 @@ #include "alloc.h" #include "dynalloc.h" +#define BYTE_LENGTH 8 +#define BYTE_FULL_MASK 0xff + #define TEXT_UNIT_ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) TextUnit *createSimpleTextUnit2(int key, char *value, int firstParameterLength) { @@ -854,7 +857,7 @@ int dynallocDataset(DynallocInputParms *inputParms, int *reasonCode) { } -int dynallocNewDataset(int *reasonCode, DynallocNewTextUnit *setTextUnits, int TextUnitsSize) { +int dynallocNewDataset(DynallocNewInputParms *inputParms, int textUnitsSize, int *reasonCode) { ALLOC_STRUCT31( STRUCT31_NAME(below2G), STRUCT31_FIELDS( @@ -863,48 +866,76 @@ int dynallocNewDataset(int *reasonCode, DynallocNewTextUnit *setTextUnits, int T ) ); - below2G->textUnits = (TextUnit **)safeMalloc31(sizeof(TextUnit*) * TextUnitsSize, "Text units array"); - + below2G->textUnits = (TextUnit **)safeMalloc31(sizeof(TextUnit*) * textUnitsSize, "Text units array"); + if(below2G->textUnits == NULL) { + return -1; + } DynallocParms *parms = &below2G->parms; dynallocParmsInit(parms); - dynallocParmsSetTextUnits(parms, (TextUnit * __ptr32 *)below2G->textUnits, TextUnitsSize); + dynallocParmsSetTextUnits(parms, (TextUnit * __ptr32 *)below2G->textUnits, textUnitsSize); int rc; do { - rc = -1; - for (int i = 0; i < TextUnitsSize; i++) { - if (setTextUnits[i].type == TEXT_UNIT_STRING) { - below2G->textUnits[i] = createSimpleTextUnit2(setTextUnits[i].key, setTextUnits[i].data.string, setTextUnits[i].size); + rc = 0; + for (int i = 0; i < textUnitsSize; i++) { + if (inputParms[i].type == TEXT_UNIT_STRING) { + below2G->textUnits[i] = createSimpleTextUnit2(inputParms[i].key, inputParms[i].data.stringValue, inputParms[i].size); + if (below2G->textUnits[i] == NULL) { + rc = -1; + break; + } } - else if (setTextUnits[i].type == TEXT_UNIT_CHARINT) { - if (setTextUnits[i].size == sizeof(char)) { - below2G->textUnits[i] = createCharTextUnit(setTextUnits[i].key, setTextUnits[i].data.number); + else if (inputParms[i].type == TEXT_UNIT_CHARINT) { + if (inputParms[i].size == sizeof(char)) { + below2G->textUnits[i] = createCharTextUnit(inputParms[i].key, inputParms[i].data.numValue); + if (below2G->textUnits[i] == NULL) { + rc = -1; + break; + } } - else if (setTextUnits[i].size == sizeof(short)) { - below2G->textUnits[i] = createInt16TextUnit(setTextUnits[i].key, setTextUnits[i].data.number); + else if (inputParms[i].size == sizeof(short)) { + below2G->textUnits[i] = createInt16TextUnit(inputParms[i].key, inputParms[i].data.numValue); + if (below2G->textUnits[i] == NULL) { + rc = -1; + break; + } } - else if (setTextUnits[i].size == INT24_SIZE) { - below2G->textUnits[i] = createInt24TextUnit(setTextUnits[i].key, setTextUnits[i].data.number); + else if (inputParms[i].size == INT24_SIZE) { + below2G->textUnits[i] = createInt24TextUnit(inputParms[i].key, inputParms[i].data.numValue); + if (below2G->textUnits[i] == NULL) { + rc = -1; + break; + } } - else if (setTextUnits[i].size == sizeof(long long)) { - long number = setTextUnits[i].data.number; - below2G->textUnits[i] = createLongIntTextUnit(setTextUnits[i].key, (long long)setTextUnits[i].data.number); + else if (inputParms[i].size == sizeof(long long)) { + //long number = inputParms[i].data.numValue; + below2G->textUnits[i] = createLongIntTextUnit(inputParms[i].key, (long long)inputParms[i].data.numValue); + if (below2G->textUnits[i] == NULL) { + rc = -1; + break; + } } } - else if (setTextUnits[i].type == TEXT_UNIT_BOOLEAN) { - below2G->textUnits[i] = createSimpleTextUnit2(setTextUnits[i].key, NULL, 0); + else if (inputParms[i].type == TEXT_UNIT_BOOLEAN) { + below2G->textUnits[i] = createSimpleTextUnit2(inputParms[i].key, NULL, 0); + if (below2G->textUnits[i] == NULL) { + rc = -1; + break; + } } } - - turn_on_HOB(below2G->textUnits[TextUnitsSize - 1]); + if (rc == -1) { + break; + } + turn_on_HOB(below2G->textUnits[textUnitsSize - 1]); rc = invokeDynalloc(parms); *reasonCode = dynallocParmsGetInfoCode(parms) + (dynallocParmsGetErrorCode(parms) << 16); } while (0); - freeTextUnitArray((TextUnit * __ptr32 *)below2G->textUnits, TextUnitsSize); - safeFree31((char*)below2G->textUnits, sizeof(TextUnit*) * TextUnitsSize); + freeTextUnitArray((TextUnit * __ptr32 *)below2G->textUnits, textUnitsSize); + safeFree31((char*)below2G->textUnits, sizeof(TextUnit*) * textUnitsSize); dynallocParmsTerm(parms); parms = NULL; FREE_STRUCT31( diff --git a/h/dynalloc.h b/h/dynalloc.h index de498bff9..7234437e8 100644 --- a/h/dynalloc.h +++ b/h/dynalloc.h @@ -723,21 +723,11 @@ int DeallocDDName(char *ddname); #define SPIN_UNALLOC 0x80 #define SPIN_ENDJOB 0x40 -#define BYTE_LENGTH 8 -#define BYTE_FULL_MASK 0xff - #define INT24_SIZE 3 -#define VOLSER_SIZE 6 -#define CLASS_WRITER_SIZE 8 -#define TOTAL_TEXT_UNITS 23 -#define LEN_THREE_BYTES 3 -#define LEN_ONE_BYTE 1 - #define TEXT_UNIT_STRING 1 #define TEXT_UNIT_BOOLEAN 2 #define TEXT_UNIT_CHARINT 3 #define TEXT_UNIT_NULL 4 -#define JSON_TYPE_ERROR 666 /* Use this structure to pass parameters to DYNALLOC functions. * Dsname should be padded by spaces. */ @@ -752,23 +742,22 @@ typedef struct DynallocInputParms_tag { } DynallocInputParms; -typedef struct DynallocNewTextUnit_tag { +typedef struct DynallocNewInputParms_tag { int type; int size; int key; union { - int number; - char *string; - int boolean; + int numValue; + char *stringValue; } data; -} DynallocNewTextUnit; +} DynallocNewInputParms; #pragma map(dynallocDataset, "DYNAUALC") #pragma map(dynallocDatasetMember, "DYNAUALM") #pragma map(unallocDataset, "DYNADALC") int dynallocDataset(DynallocInputParms *inputParms, int *reasonCode); -int dynallocNewDataset(int *reasonCode, DynallocNewTextUnit *setTextUnits, int TextUnitsSize); +int dynallocNewDataset(DynallocNewInputParms *setInputParms, int TextUnitsSize, int *reasonCode); int dynallocDatasetMember(DynallocInputParms *inputParms, int *reasonCode, char *member); int unallocDataset(DynallocInputParms *inputParms, int *reasonCode); From 47588a71e3d914ce731cab7559f359d08981bdea Mon Sep 17 00:00:00 2001 From: Aditya Ranshinge Date: Wed, 8 Jun 2022 10:35:05 +0530 Subject: [PATCH 07/35] updated variable name Signed-off-by: Aditya Ranshinge --- c/dynalloc.c | 15 +++++++-------- h/dynalloc.h | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/c/dynalloc.c b/c/dynalloc.c index 5152447e4..22b4e7cca 100644 --- a/c/dynalloc.c +++ b/c/dynalloc.c @@ -857,7 +857,7 @@ int dynallocDataset(DynallocInputParms *inputParms, int *reasonCode) { } -int dynallocNewDataset(DynallocNewInputParms *inputParms, int textUnitsSize, int *reasonCode) { +int dynallocNewDataset(DynallocNewInputParms *inputParms, int inputParmsCount, int *reasonCode) { ALLOC_STRUCT31( STRUCT31_NAME(below2G), STRUCT31_FIELDS( @@ -866,20 +866,20 @@ int dynallocNewDataset(DynallocNewInputParms *inputParms, int textUnitsSize, int ) ); - below2G->textUnits = (TextUnit **)safeMalloc31(sizeof(TextUnit*) * textUnitsSize, "Text units array"); + below2G->textUnits = (TextUnit **)safeMalloc31(sizeof(TextUnit*) * inputParmsCount, "Text units array"); if(below2G->textUnits == NULL) { return -1; } DynallocParms *parms = &below2G->parms; dynallocParmsInit(parms); - dynallocParmsSetTextUnits(parms, (TextUnit * __ptr32 *)below2G->textUnits, textUnitsSize); + dynallocParmsSetTextUnits(parms, (TextUnit * __ptr32 *)below2G->textUnits, inputParmsCount); int rc; do { rc = 0; - for (int i = 0; i < textUnitsSize; i++) { + for (int i = 0; i < inputParmsCount; i++) { if (inputParms[i].type == TEXT_UNIT_STRING) { below2G->textUnits[i] = createSimpleTextUnit2(inputParms[i].key, inputParms[i].data.stringValue, inputParms[i].size); if (below2G->textUnits[i] == NULL) { @@ -910,7 +910,6 @@ int dynallocNewDataset(DynallocNewInputParms *inputParms, int textUnitsSize, int } } else if (inputParms[i].size == sizeof(long long)) { - //long number = inputParms[i].data.numValue; below2G->textUnits[i] = createLongIntTextUnit(inputParms[i].key, (long long)inputParms[i].data.numValue); if (below2G->textUnits[i] == NULL) { rc = -1; @@ -929,13 +928,13 @@ int dynallocNewDataset(DynallocNewInputParms *inputParms, int textUnitsSize, int if (rc == -1) { break; } - turn_on_HOB(below2G->textUnits[textUnitsSize - 1]); + turn_on_HOB(below2G->textUnits[inputParmsCount - 1]); rc = invokeDynalloc(parms); *reasonCode = dynallocParmsGetInfoCode(parms) + (dynallocParmsGetErrorCode(parms) << 16); } while (0); - freeTextUnitArray((TextUnit * __ptr32 *)below2G->textUnits, textUnitsSize); - safeFree31((char*)below2G->textUnits, sizeof(TextUnit*) * textUnitsSize); + freeTextUnitArray((TextUnit * __ptr32 *)below2G->textUnits, inputParmsCount); + safeFree31((char*)below2G->textUnits, sizeof(TextUnit*) * inputParmsCount); dynallocParmsTerm(parms); parms = NULL; FREE_STRUCT31( diff --git a/h/dynalloc.h b/h/dynalloc.h index 7234437e8..77e089346 100644 --- a/h/dynalloc.h +++ b/h/dynalloc.h @@ -757,7 +757,7 @@ typedef struct DynallocNewInputParms_tag { #pragma map(unallocDataset, "DYNADALC") int dynallocDataset(DynallocInputParms *inputParms, int *reasonCode); -int dynallocNewDataset(DynallocNewInputParms *setInputParms, int TextUnitsSize, int *reasonCode); +int dynallocNewDataset(DynallocNewInputParms *inputParms, int inputParmsCount, int *reasonCode); int dynallocDatasetMember(DynallocInputParms *inputParms, int *reasonCode, char *member); int unallocDataset(DynallocInputParms *inputParms, int *reasonCode); From 472774b12ede3020d431646596111c7adc484df3 Mon Sep 17 00:00:00 2001 From: Aditya Ranshinge Date: Wed, 15 Jun 2022 11:03:56 +0530 Subject: [PATCH 08/35] used TextUnit structure instead of DynallocNewInputParms structure, removed unwanted functions and macros Signed-off-by: Aditya Ranshinge --- c/dynalloc.c | 108 ++++++++++++++++++++------------------------------- h/dynalloc.h | 30 ++++++-------- 2 files changed, 55 insertions(+), 83 deletions(-) diff --git a/c/dynalloc.c b/c/dynalloc.c index 22b4e7cca..8e385532c 100644 --- a/c/dynalloc.c +++ b/c/dynalloc.c @@ -30,8 +30,6 @@ #include "alloc.h" #include "dynalloc.h" -#define BYTE_LENGTH 8 -#define BYTE_FULL_MASK 0xff #define TEXT_UNIT_ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) @@ -63,10 +61,6 @@ TextUnit *createIntTextUnit(int key, int value) { return createSimpleTextUnit2(key, (char*)&value, sizeof(value)); } -TextUnit *createIntTextUnitLength(int key, int value, int length) { - return createSimpleTextUnit2(key, (char*)&value, length); -} - TextUnit *createInt8TextUnit(int key, int8_t value) { return createSimpleTextUnit2(key, (char*)&value, sizeof(value)); } @@ -90,14 +84,6 @@ TextUnit *createCharTextUnit(int key, char value) { return createSimpleTextUnit2(key, valueArray, 1); } -TextUnit *createCharTextUnit2(int key, short value) { - char valueArray[3]; - valueArray[0] = value >> BYTE_LENGTH & BYTE_FULL_MASK; - valueArray[1] = value & BYTE_FULL_MASK; - valueArray[2] = 0; - return createSimpleTextUnit2(key, valueArray, 2); -} - TextUnit *createCompoundTextUnit(int key, char **values, int valueCount) { TextUnit *textUnit = NULL; @@ -857,7 +843,38 @@ int dynallocDataset(DynallocInputParms *inputParms, int *reasonCode) { } -int dynallocNewDataset(DynallocNewInputParms *inputParms, int inputParmsCount, int *reasonCode) { +int setTextUnit(int type, int size, char* stringValue, int numValue, int key, + int *index, TextUnit **inputTextUnit) { + int rc = -1; + switch (type) { + case TEXT_UNIT_STRING: + inputTextUnit[*index] = createSimpleTextUnit2(key, stringValue, size); + break; + case TEXT_UNIT_CHAR: + inputTextUnit[*index] = createCharTextUnit(key, numValue); + break; + case TEXT_UNIT_INT16: + inputTextUnit[*index] = createInt16TextUnit(key, numValue); + break; + case TEXT_UNIT_INT24: + inputTextUnit[*index] = createInt24TextUnit(key, numValue); + break; + case TEXT_UNIT_LONGINT: + inputTextUnit[*index] = createLongIntTextUnit(key, (long long)numValue); + break; + case TEXT_UNIT_BOOLEAN: + inputTextUnit[*index] = createSimpleTextUnit2(key, NULL, 0); + break; + } + if (inputTextUnit[*index] == NULL) { + return rc; + } else { + (*index)++; + return 0; + } +} + +int dynallocNewDataset(TextUnit **inputTextUnit, int inputTextUnitCount, int *reasonCode) { ALLOC_STRUCT31( STRUCT31_NAME(below2G), STRUCT31_FIELDS( @@ -866,75 +883,36 @@ int dynallocNewDataset(DynallocNewInputParms *inputParms, int inputParmsCount, i ) ); - below2G->textUnits = (TextUnit **)safeMalloc31(sizeof(TextUnit*) * inputParmsCount, "Text units array"); + below2G->textUnits = (TextUnit **)safeMalloc31(sizeof(TextUnit*) * inputTextUnitCount, "Text units array"); if(below2G->textUnits == NULL) { return -1; } DynallocParms *parms = &below2G->parms; dynallocParmsInit(parms); - dynallocParmsSetTextUnits(parms, (TextUnit * __ptr32 *)below2G->textUnits, inputParmsCount); + dynallocParmsSetTextUnits(parms, (TextUnit * __ptr32 *)below2G->textUnits, inputTextUnitCount); int rc; do { rc = 0; - for (int i = 0; i < inputParmsCount; i++) { - if (inputParms[i].type == TEXT_UNIT_STRING) { - below2G->textUnits[i] = createSimpleTextUnit2(inputParms[i].key, inputParms[i].data.stringValue, inputParms[i].size); - if (below2G->textUnits[i] == NULL) { - rc = -1; - break; - } - } - else if (inputParms[i].type == TEXT_UNIT_CHARINT) { - if (inputParms[i].size == sizeof(char)) { - below2G->textUnits[i] = createCharTextUnit(inputParms[i].key, inputParms[i].data.numValue); - if (below2G->textUnits[i] == NULL) { - rc = -1; - break; - } - } - else if (inputParms[i].size == sizeof(short)) { - below2G->textUnits[i] = createInt16TextUnit(inputParms[i].key, inputParms[i].data.numValue); - if (below2G->textUnits[i] == NULL) { - rc = -1; - break; - } - } - else if (inputParms[i].size == INT24_SIZE) { - below2G->textUnits[i] = createInt24TextUnit(inputParms[i].key, inputParms[i].data.numValue); - if (below2G->textUnits[i] == NULL) { - rc = -1; - break; - } - } - else if (inputParms[i].size == sizeof(long long)) { - below2G->textUnits[i] = createLongIntTextUnit(inputParms[i].key, (long long)inputParms[i].data.numValue); - if (below2G->textUnits[i] == NULL) { - rc = -1; - break; - } - } - } - else if (inputParms[i].type == TEXT_UNIT_BOOLEAN) { - below2G->textUnits[i] = createSimpleTextUnit2(inputParms[i].key, NULL, 0); - if (below2G->textUnits[i] == NULL) { - rc = -1; - break; - } - } + for (int i = 0; i < inputTextUnitCount; i++) { + below2G->textUnits[i] = inputTextUnit[i]; + if (below2G->textUnits[i] == NULL) { + rc = -1; + break; + } } if (rc == -1) { break; } - turn_on_HOB(below2G->textUnits[inputParmsCount - 1]); + turn_on_HOB(below2G->textUnits[inputTextUnitCount - 1]); rc = invokeDynalloc(parms); *reasonCode = dynallocParmsGetInfoCode(parms) + (dynallocParmsGetErrorCode(parms) << 16); } while (0); - freeTextUnitArray((TextUnit * __ptr32 *)below2G->textUnits, inputParmsCount); - safeFree31((char*)below2G->textUnits, sizeof(TextUnit*) * inputParmsCount); + freeTextUnitArray((TextUnit * __ptr32 *)below2G->textUnits, inputTextUnitCount); + safeFree31((char*)below2G->textUnits, sizeof(TextUnit*) * inputTextUnitCount); dynallocParmsTerm(parms); parms = NULL; FREE_STRUCT31( diff --git a/h/dynalloc.h b/h/dynalloc.h index 77e089346..81bd37724 100644 --- a/h/dynalloc.h +++ b/h/dynalloc.h @@ -276,9 +276,7 @@ TextUnit *createSimpleTextUnit2(int key, char *value, int firstParameterLength); TextUnit *createCharTextUnit(int key, char value); TextUnit *createCompoundTextUnit(int key, char **values, int valueCount); TextUnit *createIntTextUnit(int key, int value); -TextUnit *createCharTextUnit2(int key, short value); TextUnit *createInt8TextUnit(int key, int8_t value); -TextUnit *createIntTextUnitLength(int key, int value, int length); TextUnit *createInt16TextUnit(int key, int16_t value); TextUnit *createInt24TextUnit(int key, int value); void freeTextUnit(TextUnit * text_unit); @@ -307,6 +305,10 @@ int AllocForDynamicOutput(char *outDescName, int DeallocDDName(char *ddname); +int setTextUnit(int type, int size, char* stringValue, + int numValue, int key, + int *index, TextUnit **inputTextUnit); + #define DOADDRES 0x0027 /* ADDRESS FieldCount: 4 FieldLength 0-60 EBCDIC text characters @@ -724,10 +726,13 @@ int DeallocDDName(char *ddname); #define SPIN_ENDJOB 0x40 #define INT24_SIZE 3 -#define TEXT_UNIT_STRING 1 -#define TEXT_UNIT_BOOLEAN 2 -#define TEXT_UNIT_CHARINT 3 -#define TEXT_UNIT_NULL 4 +#define TEXT_UNIT_STRING 1 +#define TEXT_UNIT_BOOLEAN 2 +#define TEXT_UNIT_CHAR 3 +#define TEXT_UNIT_INT16 4 +#define TEXT_UNIT_INT24 5 +#define TEXT_UNIT_LONGINT 6 +#define TEXT_UNIT_NULL 7 /* Use this structure to pass parameters to DYNALLOC functions. * Dsname should be padded by spaces. */ @@ -741,23 +746,12 @@ typedef struct DynallocInputParms_tag { char reserved[3]; } DynallocInputParms; - -typedef struct DynallocNewInputParms_tag { - int type; - int size; - int key; - union { - int numValue; - char *stringValue; - } data; -} DynallocNewInputParms; - #pragma map(dynallocDataset, "DYNAUALC") #pragma map(dynallocDatasetMember, "DYNAUALM") #pragma map(unallocDataset, "DYNADALC") int dynallocDataset(DynallocInputParms *inputParms, int *reasonCode); -int dynallocNewDataset(DynallocNewInputParms *inputParms, int inputParmsCount, int *reasonCode); +int dynallocNewDataset(TextUnit **inputTextUnit, int inputTextUnitCount, int *reasonCode); int dynallocDatasetMember(DynallocInputParms *inputParms, int *reasonCode, char *member); int unallocDataset(DynallocInputParms *inputParms, int *reasonCode); From 0385670b8b41e068b06841356f21fcb839e6651a Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Fri, 2 Sep 2022 14:08:36 -0400 Subject: [PATCH 09/35] Fix branch names Signed-off-by: 1000TurquoisePogs --- .github/workflows/build-configmgr.yml | 2 +- .github/workflows/build-rexxconfigmgr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-configmgr.yml b/.github/workflows/build-configmgr.yml index bc3362cc3..6b3d97a3c 100644 --- a/.github/workflows/build-configmgr.yml +++ b/.github/workflows/build-configmgr.yml @@ -61,7 +61,7 @@ jobs: - name: '[Prep 5] Set branchname' id: branch - run: echo "::set-output name=branch::$(if [ -n '${{ github.head_ref }}' ]; then echo '${{ github.head_ref }}'; else echo '${{ github.ref_name }}'; fi | sed 's@/@_@g')" + run: echo "::set-output name=branch::$(if [ -n '${{ github.head_ref }}' ]; then echo '${{ github.head_ref }}' | tr '[:lower:]' '[:upper:]'; else echo '${{ github.ref_name }}' | tr '[:lower:]' '[:upper:]'; fi | sed 's@/@-@g')" - name: '[Prep 6] Prepare workflow' diff --git a/.github/workflows/build-rexxconfigmgr.yml b/.github/workflows/build-rexxconfigmgr.yml index b6fb60ff8..a232d8f49 100644 --- a/.github/workflows/build-rexxconfigmgr.yml +++ b/.github/workflows/build-rexxconfigmgr.yml @@ -84,6 +84,6 @@ jobs: artifacts: | .pax/configmgr-rexx/configmgr-rexx.pax publish-target-path-pattern: libs-snapshot-local/org/zowe/configmgr-rexx/${{ steps.version.outputs.version }}-${{ steps.branch.outputs.branch }} - publish-target-file-pattern: configmgr_rexx-${{ steps.version.outputs.version }}-${{ steps.date.outputs.date }}.pax + publish-target-file-pattern: configmgr-rexx-${{ steps.version.outputs.version }}-${{ steps.date.outputs.date }}.pax perform-release: ${{ github.event.inputs.PERFORM_RELEASE }} From e309156a6ce3c3a90d5887a3501362046ef73340 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Fri, 2 Sep 2022 14:09:41 -0400 Subject: [PATCH 10/35] Fix branch names Signed-off-by: 1000TurquoisePogs --- .github/workflows/build-rexxconfigmgr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-rexxconfigmgr.yml b/.github/workflows/build-rexxconfigmgr.yml index a232d8f49..b6dcb0cd7 100644 --- a/.github/workflows/build-rexxconfigmgr.yml +++ b/.github/workflows/build-rexxconfigmgr.yml @@ -61,7 +61,7 @@ jobs: - name: '[Prep 5] Set branchname' id: branch - run: echo "::set-output name=branch::$(if [ -n '${{ github.head_ref }}' ]; then echo '${{ github.head_ref }}'; else echo '${{ github.ref_name }}'; fi | sed 's@/@_@g')" + run: echo "::set-output name=branch::$(if [ -n '${{ github.head_ref }}' ]; then echo '${{ github.head_ref }}' | tr '[:lower:]' '[:upper:]'; else echo '${{ github.ref_name }}' | tr '[:lower:]' '[:upper:]'; fi | sed 's@/@-@g')" - name: '[Prep 6] Prepare workflow' From 51df4897f57d0a36fe5b7bafdb8fcd1661d8bfc0 Mon Sep 17 00:00:00 2001 From: Jordan Filteau Date: Fri, 9 Sep 2022 11:33:22 -0500 Subject: [PATCH 11/35] fixing bad message and missed printf arg Signed-off-by: Jordan Filteau --- c/jsonschema.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/c/jsonschema.c b/c/jsonschema.c index 03d0995ed..39c3b26a1 100644 --- a/c/jsonschema.c +++ b/c/jsonschema.c @@ -796,8 +796,8 @@ static VResult validateJSONString(JsonValidator *validator, addValidityChild(pendingException, makeValidityException(validator, validityMessage(validator, - "string too long (len=%d) '%s' > MAX=%d at %s", - len,s,lim,validatorAccessPath(validator)))); + "string too long (len=%d) '%s' %d > MAX=%d at %s", + len,s,len,lim,validatorAccessPath(validator)))); } } if (valueSpec->validatorFlags & JS_VALIDATOR_MIN_LENGTH){ @@ -806,8 +806,8 @@ static VResult validateJSONString(JsonValidator *validator, addValidityChild(pendingException, makeValidityException(validator, validityMessage(validator, - "string too short (len=%d) '%s' %d < MAX=%d at %s", - len,s,lim,validatorAccessPath(validator)))); + "string too short (len=%d) '%s' %d < MIN=%d at %s", + len,s,len,lim,validatorAccessPath(validator)))); } } if (valueSpec->pattern && (valueSpec->regexCompilationError == 0)){ From 5885e509d1918ca299994146bc03a50a87d5ff1c Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Thu, 18 Nov 2021 09:25:28 -0500 Subject: [PATCH 12/35] Don't use 8-char names when long names are used Signed-off-by: Irek Fakhrutdinov --- h/lpa.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/h/lpa.h b/h/lpa.h index 520c073e0..656b4de75 100644 --- a/h/lpa.h +++ b/h/lpa.h @@ -71,8 +71,10 @@ typedef struct LPMED_tag { ZOWE_PRAGMA_PACK_RESET +#ifndef __LONGNAME__ #pragma map(lpaAdd, "LPAADD") -#pragma map(lpaDetele, "LPADEL") +#pragma map(lpaDelete, "LPADEL") +#endif int lpaAdd(LPMEA * __ptr32 lpmea, EightCharString * __ptr32 ddname, From 427b409b0583afc9b245ea7679e0b10a92e863a4 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Thu, 4 Aug 2022 13:58:53 +0200 Subject: [PATCH 13/35] Set the STC log level to debug when the xmem debug option is on. Signed-off-by: Irek Fakhrutdinov --- c/crossmemory.c | 1 + 1 file changed, 1 insertion(+) diff --git a/c/crossmemory.c b/c/crossmemory.c index 30523e1c5..859a33d62 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -2350,6 +2350,7 @@ CrossMemoryServer *makeCrossMemoryServer2( if (flags & CMS_SERVER_FLAG_DEBUG) { logSetLevel(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_DEBUG); logSetLevel(NULL, LOG_COMP_ID_CMSPC, ZOWE_LOG_DEBUG); + logSetLevel(NULL, LOG_COMP_STCBASE, ZOWE_LOG_DEBUG); } EightCharString cmsModule = {0}; From 072ca175bf795991ff72342e770647fe42d7ff56 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Tue, 9 Aug 2022 18:46:16 +0200 Subject: [PATCH 14/35] More robust look-up routine handling Signed-off-by: Irek Fakhrutdinov --- c/crossmemory.c | 187 ++++++++++++++++++++++++++++++++++++------------ c/zvt.c | 25 +++++++ h/crossmemory.h | 67 +++++++++++++++++ h/zvt.h | 23 +++++- 4 files changed, 253 insertions(+), 49 deletions(-) diff --git a/c/crossmemory.c b/c/crossmemory.c index 859a33d62..e134ed5f9 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -70,6 +70,10 @@ const CrossMemoryServerName CMS_DEFAULT_SERVER_NAME = {CROSS_MEMORY_DEFAULT_SERV #define TOSTR(number) #number #define INT_TO_STR(number) TOSTR(number) +#define CMS_SIZE_OF_FIELD($struct, $field) ({ \ + sizeof((($struct *)0)->$field); \ +}) + const char *CMS_RC_DESCRIPTION[] = { [RC_CMS_OK] = "Ok", [RC_CMS_ERROR] = "Error", @@ -94,7 +98,7 @@ const char *CMS_RC_DESCRIPTION[] = { [RC_CMS_LPA_ADD_FAILED] = "Module not loaded into LPA", [RC_CMS_LPA_DELETE_FAILED] = "Module not deleted from LPA", [RC_CMS_SERVER_NOT_READY] = "Server is not running", - [RC_CMS_NAME_TOKEN_DELETE_FAILED] = "Global area name/token not deleted", + [RC_CMS_NAME_TOKEN_DELETE_FAILED] = "Global area name/token not deleted", [RC_CMS_RACF_ROUTE_LIST_FAILED] = "RACROUTE list failed", [RC_CMS_PERMISSION_DENIED] = "Permission denied", [RC_CMS_PC_ENV_NOT_ESTABLISHED] = "PC environment not established", @@ -113,7 +117,7 @@ const char *CMS_RC_DESCRIPTION[] = { [RC_CMS_SERVICE_NOT_RELOCATABLE] = "Service function out of range, service not relocated", [RC_CMS_MAIN_LOOP_FAILED] = "Main loop unexpectedly terminated", [RC_CMS_IMPROPER_SERVICE_AS] = "Invalid service address space", - [RC_CMS_BAD_SERVER_KEY] = "Core server started with wrong key", + [RC_CMS_BAD_SERVER_KEY] = "Core server started with wrong key", [RC_CMS_RESMGR_NOT_ADDED] = "RESMGR not added", [RC_CMS_RESMGR_NOT_REMOVED] = "RESMGR not removed", [RC_CMS_RESMGR_NOT_LOCKED] = "RESMGR not locked", @@ -125,7 +129,7 @@ const char *CMS_RC_DESCRIPTION[] = { [RC_CMS_ZERO_PC_NUMBER] = "PC is unavailable", [RC_CMS_WRONG_CLIENT_VERSION] = "Wrong client version", [RC_CMS_ZVTE_CHAIN_LOOP] = "Potential loop in the ZVTE chain detected", - [RC_CMS_ZVTE_CHAIN_NOT_LOCKED] = "ZVTE chain is not locked", + [RC_CMS_ZVTE_CHAIN_NOT_LOCKED] = "ZVTE chain is not locked", [RC_CMS_ZVTE_CHAIN_NOT_RELEASED] = "ZVTE chain is not released", [RC_CMS_SNPRINTF_FAILED] = "snprintf failed", [RC_CMS_SLH_NOT_CREATED] = "Short lived heap is not created", @@ -139,13 +143,13 @@ const char *CMS_RC_DESCRIPTION[] = { [RC_CMS_STDSVC_PARM_NULL] = "Service parameter list is NULL", [RC_CMS_STDSVC_PARM_BAD_EYECATCHER] = "Service parameter list has an invalid eyecatcher", [RC_CMS_NOT_APF_AUTHORIZED] = "Cross-memory server is not APF-authorized", - [RC_CMS_NO_STEPLIB] = "STEPLIB not found", + [RC_CMS_NO_STEPLIB] = "STEPLIB not found", [RC_CMS_MODULE_NOT_IN_STEPLIB] = "Cross-memory server module not found in STEPLIB", [RC_CMS_SERVER_NAME_NULL] = "Server name is NULL", [RC_CMS_SERVICE_ENTRY_OCCUPIED] = "Service entry already occupied", - [RC_CMS_NO_STORAGE_FOR_MSG] = "No storage in the message queue", + [RC_CMS_NO_STORAGE_FOR_MSG] = "No storage in the message queue", [RC_CMS_ALLOC_FAILED] = "Storage allocation failed", - [RC_CMS_NON_PRIVATE_MODULE] = "Module is loaded from common storage, ensure module is valid in STEPLIB", + [RC_CMS_NON_PRIVATE_MODULE] = "Module is loaded from common storage, ensure module is valid in STEPLIB", [RC_CMS_BAD_DUB_STATUS] = "Bad dub status, verify that the started task user has an OMVS segment", [RC_CMS_MAX_RC + 1] = NULL }; @@ -1608,7 +1612,7 @@ ZOWE_PRAGMA_PACK_RESET memset((envAddr), 0, sizeof(PCRoutineEnvironment)); \ memcpy((envAddr)->eyecatcher, PC_ROUTINE_ENV_EYECATCHER, sizeof((envAddr)->eyecatcher)); \ (envAddr)->dummyCAA.rleTask = &(envAddr)->dummyRLETask; \ - (envAddr)->dummyRLETask.anchor = &(envAddr)->dummyRLEAnchor; \ + (envAddr)->dummyRLETask.anchor = &(envAddr)->dummyRLEAnchor; \ (envAddr)->dummyRLEAnchor.metalDynamicLinkageVector = (cmsGlobalAreaAddr)->dynamicLinkageVector; \ int returnCode = RC_CMS_OK; \ __asm(" LA 12,0(,%0) " : : "r"(&(envAddr)->dummyCAA) : ); \ @@ -1838,7 +1842,7 @@ static void extractServiceFunctionAbendInfo(RecoveryContext * __ptr32 context, if (sdwa){ int reason = 0; - + int cc = (sdwa->flagsAndCode >> 12) & 0x00000FFF; int flags = (sdwa->flagsAndCode >> 24) & 0x000000FF; SDWAPTRS *sdwaptrs = NULL; @@ -2828,7 +2832,7 @@ static CMSBuildTimestamp getServerBuildTimestamp() { return timestamp; } -#ifndef _LP64 +#ifndef _LP64 static void *getCMSServerLookup(int *routineLengthPtr){ void *routineAddress = NULL; @@ -2870,10 +2874,10 @@ static void *getCMSServerLookup(int *routineLengthPtr){ " J L$RETURN Non error end \n" "L$NOZVT XGR 15,15 clear result \n" " LGFI 0,8 reason 8 \n" - " J L$RETURN \n" + " J L$RETURN \n" "L$NOZVTE XGR 15,15 clear result \n" " LGFI 0,12 reason 12 \n" - " J L$RETURN \n" + " J L$RETURN \n" "L$NOCMSG XGR 15,15 clear result \n" " LGFI 0,16 reason 16 \n" " J L$RETURN \n" @@ -2892,11 +2896,11 @@ static void *getCMSServerLookup(int *routineLengthPtr){ return routineAddress; } -#else +#else -static void *getCMSServerLookup(int *routineLengthPtr){ - void *routineAddress = NULL; - int routineLength; +static const void *getCMSServerLookup(unsigned *routineLengthPtr) { + const void *routineAddress = NULL; + unsigned routineLength; __asm(ASM_PREFIX " LARL 1,L$UXIT00 \n" " STG 1,%0 \n" @@ -2935,10 +2939,10 @@ static void *getCMSServerLookup(int *routineLengthPtr){ " J L$RETURN Non error end \n" "L$NOZVT XGR 15,15 clear result \n" " LGFI 0,8 reason 8 \n" - " J L$RETURN \n" + " J L$RETURN \n" "L$NOZVTE XGR 15,15 clear result \n" " LGFI 0,12 reason 12 \n" - " J L$RETURN \n" + " J L$RETURN \n" "L$NOCMSG XGR 15,15 clear result \n" " LGFI 0,16 reason 16 \n" " J L$RETURN \n" @@ -2960,52 +2964,141 @@ static void *getCMSServerLookup(int *routineLengthPtr){ #endif +static CMSLookupRoutineAnchor *makeLookupRoutineAnchor(void) { + + unsigned routineLength = 0; + const void *routineMaster = getCMSServerLookup(&routineLength); + if (routineLength > CMS_SIZE_OF_FIELD(CMSLookupRoutineAnchor, routineBody)) { + return NULL; + } /* always give the routine its own page so that it might be marked executable as opposed to most ZVT storage which is unexecutable data */ +// TODO do we still need to do that? It wasn't executable to begin with + CMSLookupRoutineAnchor *anchor = cmAlloc(sizeof(CMSLookupRoutineAnchor), + CMS_LOOKUP_ANCHOR_SUBPOOL, + CMS_LOOKUP_ANCHOR_KEY); + if (anchor == NULL) { + return NULL; + } -#define ZWECMSLK_LENGTH 0x1000 + int wasProblemState = supervisorMode(TRUE); + int originalKey = setKey(0); + { + memset(anchor, 0, sizeof(CMSLookupRoutineAnchor)); + memcpy(anchor->eyecatcher, CMS_LOOKUP_ANCHOR_EYECATCHER, + sizeof(anchor->eyecatcher)); + anchor->version = CMS_LOOKUP_ANCHOR_VERSION; + anchor->key = CMS_LOOKUP_ANCHOR_KEY; + anchor->subpool = CMS_LOOKUP_ANCHOR_SUBPOOL; + anchor->size = sizeof(CMSLookupRoutineAnchor); + __stck((void *) &anchor->creationTime); -static int installCMSLookupRoutine(ZVT *zvt){ - int routineLength = 0; - char *routineMaster = getCMSServerLookup(&routineLength); + ASCB *ascb = getASCB(); - int wasProblemState = supervisorMode(TRUE); - int status = RC_CMS_OK; - char *routineStorage = cmAlloc(ZWECMSLK_LENGTH, ZVT_SUBPOOL, ZVT_KEY); - if (routineStorage == NULL){ - status = RC_CMS_NO_ROOM_FOR_CMS_GETTER; - } else{ - int originalKey = setKey(0); - - memset(routineStorage,0,ZWECMSLK_LENGTH); - memcpy(routineStorage,routineMaster,routineLength); - zvt->version = ZVT_VERSION; - zvt->cmsGetterRoutine = (void*)routineStorage; - - setKey(originalKey); + char *jobName = getASCBJobname(ascb); + if (jobName) { + memcpy(anchor->jobName, jobName, sizeof(anchor->jobName)); + } else { + memset(anchor->jobName, ' ', sizeof(anchor->jobName)); + } + anchor->asid = ascb->ascbasid; + + anchor->routineVersion = CMS_LOOKUP_ANCHOR_ROUTINE_VERSION; + memcpy(anchor->routineBody, routineMaster, routineLength); } + setKey(originalKey); if (wasProblemState) { supervisorMode(FALSE); } - return status; +} + +static void deleteLookupRoutineAnchor(CMSLookupRoutineAnchor *anchor) { + cmFree(anchor, anchor->size, CMS_LOOKUP_ANCHOR_SUBPOOL, + CMS_LOOKUP_ANCHOR_KEY); +} + +static bool isLookupRoutineAnchorValid(const CMSLookupRoutineAnchor *anchor, + const char **reason) { + if (memcmp(anchor->eyecatcher, CMS_LOOKUP_ANCHOR_EYECATCHER, + sizeof(anchor->eyecatcher))) { + *reason = "bad eyecatcher"; + return false; + } + if (anchor->version > CMS_LOOKUP_ANCHOR_VERSION) { + *reason = "incompatible version"; + return false; + } + if (anchor->size < sizeof(CMSLookupRoutineAnchor)) { + *reason = "insufficient size"; + return false; + } + if (anchor->key != CMS_LOOKUP_ANCHOR_KEY) { + *reason = "unexpected key"; + return false; + } + if (anchor->subpool != CMS_LOOKUP_ANCHOR_SUBPOOL) { + *reason = "unexpected subpool"; + return false; + } + if (anchor->routineVersion < CMS_LOOKUP_ANCHOR_ROUTINE_VERSION) { + *reason = "outdated look-up routine"; + return false; + } + *reason = ""; + return true; +} + +static int installCMSLookupRoutine(const CrossMemoryServer *server, ZVT *zvt) { + + CMSLookupRoutineAnchor *existingAnchor = zvtGetCMSLookupRoutineAnchor(zvt); + + const char *reasonInvalid = ""; + if (existingAnchor != NULL) { + if (!isLookupRoutineAnchorValid(existingAnchor, &reasonInvalid)) { + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_WARNING, + CMS_LOG_LOOKUP_ANC_DISCARDED_MSG, existingAnchor, reasonInvalid); + zowedump(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_WARNING, + existingAnchor, CMS_LOOKUP_ANCHOR_HEADER_SIZE); + existingAnchor = NULL; + } + } + + if (existingAnchor != NULL) { + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_INFO, + CMS_LOG_LOOKUP_ANC_REUSED_MSG); + return RC_CMS_OK; + } + + CMSLookupRoutineAnchor *newAnchor = makeLookupRoutineAnchor(); + if (newAnchor == NULL) { + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_SEVERE, + CMS_LOG_LOOKUP_ANC_ALLOC_ERROR_MSG); + return RC_CMS_ALLOC_FAILED; + } + + CMSLookupRoutineAnchor *installedAnchor = + zvtSetCMSLookupRoutineAnchor(zvt, newAnchor); + if (newAnchor != installedAnchor) { + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_WARNING, + CMS_LOG_LOOKUP_ANC_RACE_MSG, installedAnchor); + deleteLookupRoutineAnchor(newAnchor); + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_INFO, + CMS_LOG_LOOKUP_ANC_DELETED_MSG, newAnchor); + newAnchor = NULL; + } + + return RC_CMS_OK; } static int allocateGlobalResources(CrossMemoryServer *server) { #ifndef CROSS_MEMORY_SERVER_DEBUG - bool buildingZVTFromScratch = (zvtGet() == NULL); - zvtInit(); - ZVT *zvt = zvtGet(); - - if (buildingZVTFromScratch || - (zvt->version == 1 && ZVT_VERSION > 1)){ - int installStatus = installCMSLookupRoutine(zvt); - if (installStatus){ - return installStatus; - } + int installStatus = installCMSLookupRoutine(server, zvtGet()); + if (installStatus) { + return installStatus; } #endif @@ -3239,7 +3332,7 @@ static int establishPCRoutines(CrossMemoryServer *server) { server->globalArea->pcInfo.pcssSequenceNumber, server->globalArea->pcInfo.pccpPCNumber, server->globalArea->pcInfo.pccpSequenceNumber); - + return RC_CMS_OK; } diff --git a/c/zvt.c b/c/zvt.c index 8561fe061..9d52029fc 100644 --- a/c/zvt.c +++ b/c/zvt.c @@ -198,6 +198,31 @@ void zvtFreeEntry(ZVTEntry *entry) { } +void *zvtGetCMSLookupRoutineAnchor(ZVT *zvt) { + return zvt->cmsGetterRoutine; +} + +void *zvtSetCMSLookupRoutineAnchor(ZVT *zvt, void *anchor) { + + void *oldAnchor = anchor; + + int wasProblemState = supervisorMode(TRUE); + + int originalKey = setKey(0); + { + + cds((cds_t *)&oldAnchor, (cds_t *)zvt->cmsGetterRoutine, *(cds_t *)&anchor); + + } + setKey(originalKey); + + if (wasProblemState) { + supervisorMode(FALSE); + } + + return oldAnchor; +} + /* This program and the accompanying materials are diff --git a/h/crossmemory.h b/h/crossmemory.h index 90cc88298..0559b0dea 100644 --- a/h/crossmemory.h +++ b/h/crossmemory.h @@ -373,6 +373,37 @@ typedef struct CrossMemoryServerStatus_tag { char descriptionNullTerm[64]; } CrossMemoryServerStatus; +typedef struct CMSLookupRoutineAnchor_tag { + +#define CMS_LOOKUP_ANCHOR_EYECATCHER "ZWESISSV" +#define CMS_LOOKUP_ANCHOR_VERSION 1 +#define CMS_LOOKUP_ANCHOR_KEY CROSS_MEMORY_SERVER_KEY +#define CMS_LOOKUP_ANCHOR_SUBPOOL CROSS_MEMORY_SERVER_SUBPOOL +#define CMS_LOOKUP_ANCHOR_HEADER_SIZE 0x28 + +#define CMS_LOOKUP_ANCHOR_ROUTINE_VERSION 1 + + char eyecatcher[8]; + uint8_t version; + uint8_t key; + uint8_t subpool; + char reserved1[1]; + uint16_t size; + char reserved2[2]; + /* Offset 0x10 */ + uint64_t creationTime; + char jobName[8]; + /* Offset 0x20 */ + uint16_t asid; + char reserved22[4]; + + /* Offset 0x26 */ + uint16_t routineVersion; + /* Offset 0x28 */ + char routineBody[1024]; + +} CMSLookupRoutineAnchor; + ZOWE_PRAGMA_PACK_RESET #define LOG_COMP_ID_CMS 0x008F0001000C0001LLU @@ -959,6 +990,42 @@ CrossMemoryServerName cmsMakeServerName(const char *nameNullTerm); #define CMS_LOG_DUB_ERROR_MSG_TEXT "Bad dub status %d (%d,0x%04X), verify that the started task user has an OMVS segment" #define CMS_LOG_DUB_ERROR_MSG CMS_LOG_DUB_ERROR_MSG_ID" "CMS_LOG_DUB_ERROR_MSG_TEXT +#ifndef CMS_LOG_LOOKUP_ANC_CREATED_MSG_ID +#define CMS_LOG_LOOKUP_ANC_CREATED_MSG_ID CMS_MSG_PRFX"0251I" +#endif +#define CMS_LOG_LOOKUP_ANC_CREATED_MSG_TEXT "Look-up routine anchor has been created at %p" +#define CMS_LOG_LOOKUP_ANC_CREATED_MSG CMS_LOG_LOOKUP_ANC_CREATED_MSG_ID" "CMS_LOG_LOOKUP_ANC_CREATED_MSG_TEXT + +#ifndef CMS_LOG_LOOKUP_ANC_REUSED_MSG_ID +#define CMS_LOG_LOOKUP_ANC_REUSED_MSG_ID CMS_MSG_PRFX"0252I" +#endif +#define CMS_LOG_LOOKUP_ANC_REUSED_MSG_TEXT "Look-up routine anchor at % p has been reused" +#define CMS_LOG_LOOKUP_ANC_REUSED_MSG CMS_LOG_LOOKUP_ANC_REUSED_MSG_ID" "CMS_LOG_LOOKUP_ANC_REUSED_MSG_TEXT + +#ifndef CMS_LOG_LOOKUP_ANC_DELETED_MSG_ID +#define CMS_LOG_LOOKUP_ANC_DELETED_MSG_ID CMS_MSG_PRFX"0253I" +#endif +#define CMS_LOG_LOOKUP_ANC_DELETED_MSG_TEXT "Look-up routine anchor at % p has been deleted" +#define CMS_LOG_LOOKUP_ANC_DELETED_MSG CMS_LOG_LOOKUP_ANC_DELETED_MSG_ID" "CMS_LOG_LOOKUP_ANC_DELETED_MSG_TEXT + +#ifndef CMS_LOG_LOOKUP_ANC_DISCARDED_MSG_ID +#define CMS_LOG_LOOKUP_ANC_DISCARDED_MSG_ID CMS_MSG_PRFX"0254W" +#endif +#define CMS_LOG_LOOKUP_ANC_DISCARDED_MSG_TEXT "Look-up routine anchor at %p has been discarded due to %s:" +#define CMS_LOG_LOOKUP_ANC_DISCARDED_MSG CMS_LOG_LOOKUP_ANC_DISCARDED_MSG_ID" "CMS_LOG_LOOKUP_ANC_DISCARDED_MSG_TEXT + +#ifndef CMS_LOG_LOOKUP_ANC_ALLOC_ERROR_MSG_ID +#define CMS_LOG_LOOKUP_ANC_ALLOC_ERROR_MSG_ID CMS_MSG_PRFX"0255E" +#endif +#define CMS_LOG_LOOKUP_ANC_ALLOC_ERROR_MSG_TEXT "Look-up routine anchor has not been created" +#define CMS_LOG_LOOKUP_ANC_ALLOC_ERROR_MSG CMS_LOG_LOOKUP_ANC_ALLOC_ERROR_MSG_ID" "CMS_LOG_LOOKUP_ANC_ALLOC_ERROR_MSG_TEXT + +#ifndef CMS_LOG_LOOKUP_ANC_RACE_MSG_ID +#define CMS_LOG_LOOKUP_ANC_RACE_MSG_ID CMS_MSG_PRFX"0256W" +#endif +#define CMS_LOG_LOOKUP_ANC_RACE_MSG_TEXT "New look-up routine anchor is not installed due to race condition with anchor %p" +#define CMS_LOG_LOOKUP_ANC_RACE_MSG CMS_LOG_LOOKUP_ANC_RACE_MSG_ID" "CMS_LOG_LOOKUP_ANC_RACE_MSG_TEXT + #endif /* H_CROSSMEMORY_H_ */ diff --git a/h/zvt.h b/h/zvt.h index ebf1291ae..bcf3c0d14 100644 --- a/h/zvt.h +++ b/h/zvt.h @@ -67,8 +67,7 @@ typedef struct ZVTEntry_tag { uint16_t productMaint; char reserved4[2]; char productDescription[32]; - PAD_LONG(3, void *zisStubVector); - char reserved5[120]; + char reserved5[128]; } ZVTEntry; @@ -106,6 +105,7 @@ typedef struct ZVT_tag { } zvteSlots; char reserved4[3864]; + } ZVT; ZOWE_PRAGMA_PACK_RESET @@ -114,12 +114,31 @@ ZOWE_PRAGMA_PACK_RESET #pragma map(zvtGet, "ZVTGET") #pragma map(zvtAllocEntry, "ZVTAENTR") #pragma map(zvtFreeEntry, "ZVTFENTR") +#pragma map(zvtGetCMSLookupRoutineAnchor, "ZVTGXMLR") +#pragma map(zvtSetCMSLookupRoutineAnchor, "ZVTSXMLR") void zvtInit(); ZVT *zvtGet(); ZVTEntry *zvtAllocEntry(); void zvtFreeEntry(ZVTEntry *entry); +/** + * The function returns the cross-memory server look up routine anchor address; + * @param[in] zvt The ZVT to use. + * @return The anchor is returned. + */ +void *zvtGetCMSLookupRoutineAnchor(ZVT *zvt); + +/** + * The function sets the cross-memory look up routine anchor field to + * the provided value. + * @param[in] zvt The ZVT to be used. + * @param[in] anchor The anchor to be used. + * @return The anchor that has been set (if there has been a race condition, + * the return value will not be equal to the provided anchor). + */ +void *zvtSetCMSLookupRoutineAnchor(ZVT *zvt, void *anchor); + #endif /* H_ZVT_H_ */ From 87901fe19da1148a9a864c9a4d19934400dab730 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Tue, 9 Aug 2022 20:48:12 +0200 Subject: [PATCH 15/35] Minor cleanup. Signed-off-by: Irek Fakhrutdinov --- h/le.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/h/le.h b/h/le.h index eccf33bc8..118d9b1c8 100644 --- a/h/le.h +++ b/h/le.h @@ -189,8 +189,6 @@ typedef struct RLEAnchor_tag{ char eyecatcher[8]; /* RLEANCHR */ int64 flags; CAA *mainTaskCAA; - /* void **masterRTLVector; */ /* copied from CAA */ - /* METAL libraries are in some system vector, however, if applications want dynamic linking of their services, there must be an anchor point for them, too */ From 5efaa05d55ed6676e522bada49dd2c1c03da072f Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Fri, 12 Aug 2022 17:31:22 +0200 Subject: [PATCH 16/35] Map the look-up routine. Signed-off-by: Irek Fakhrutdinov --- c/crossmemory.c | 61 +++++++++++++++++++++++++++++++++++++++++-------- h/crossmemory.h | 31 ------------------------- 2 files changed, 52 insertions(+), 40 deletions(-) diff --git a/c/crossmemory.c b/c/crossmemory.c index e134ed5f9..9953e46b2 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -2832,6 +2832,44 @@ static CMSBuildTimestamp getServerBuildTimestamp() { return timestamp; } +ZOWE_PRAGMA_PACK + +typedef struct CMSLookupRoutineAnchor_tag { + +#define CMS_LOOKUP_ANCHOR_EYECATCHER "ZWECMSLK" +#define CMS_LOOKUP_ANCHOR_VERSION 1 +#define CMS_LOOKUP_ANCHOR_KEY ZVT_KEY +#define CMS_LOOKUP_ANCHOR_SUBPOOL ZVT_SUBPOOL +#define CMS_LOOKUP_ANCHOR_HEADER_SIZE 0x30 + +#define CMS_LOOKUP_ANCHOR_ROUTINE_VERSION 1 + + char jumpInstruction[4]; + char eyecatcher[8]; + uint8_t version; + uint8_t key; + uint8_t subpool; + char reserved1[1]; + uint16_t size; + char reserved2[6]; + /* Offset 0x18 */ + uint64_t creationTime; + /* Offset 0x20 */ + char jobName[8]; + /* Offset 0x28 */ + uint16_t asid; + /* Offset 0x2A */ + char reserved3[4]; + + /* Offset 0x2E */ + uint16_t routineVersion; + /* Offset 0x30 */ + char routineBody[1024]; + +} CMSLookupRoutineAnchor; + +ZOWE_PRAGMA_PACK_RESET + #ifndef _LP64 static void *getCMSServerLookup(int *routineLengthPtr){ @@ -2909,12 +2947,18 @@ static const void *getCMSServerLookup(unsigned *routineLengthPtr) { " J L$UXITEX \n" "L$UXIT00 DS 0H \n" " J L$UXITRT \n" - " DC CL8'ZWECMSLK' ROUTINE NAME \n" - /* ZVT_KEY, ZVT_SUBPOOL */ - " DC XL1'01' VERSION \n" - " DC XL1'" ZVT_KEY_STR "' KEY \n" - " DC XL1'" ZVT_SUBPOOL_STR "' SUBPOOL \n" - " DC XL5'0000000000' Reserved \n" + " DC CL8' ' Eyecatcher \n" + " DC XL1'00' Version \n" + " DC XL1'00' Key \n" + " DC XL1'00' Subpool \n" + " DC XL1'00' Reserved \n" + " DC XL2'0000' Size \n" + " DC XL6'000000000000' Reserved \n" + " DC XL8'0000000000000000' Creation time \n" + " DC CL8' ' Job name \n" + " DC XL2'0000' ASID \n" + " DC XL4'00000000' Reserved \n" + " DC XL2'0000' Routine version \n" "L$UXITRT DS 0H \n" " STMG 14,12,8(13) \n" " LLGT 14,16 GET CVTPTR \n" @@ -2968,7 +3012,7 @@ static CMSLookupRoutineAnchor *makeLookupRoutineAnchor(void) { unsigned routineLength = 0; const void *routineMaster = getCMSServerLookup(&routineLength); - if (routineLength > CMS_SIZE_OF_FIELD(CMSLookupRoutineAnchor, routineBody)) { + if (routineLength > sizeof(CMSLookupRoutineAnchor)) { return NULL; } /* always give the routine its own page so that it might be marked executable @@ -2985,6 +3029,7 @@ static CMSLookupRoutineAnchor *makeLookupRoutineAnchor(void) { int originalKey = setKey(0); { memset(anchor, 0, sizeof(CMSLookupRoutineAnchor)); + memcpy(anchor, routineMaster, routineLength); memcpy(anchor->eyecatcher, CMS_LOOKUP_ANCHOR_EYECATCHER, sizeof(anchor->eyecatcher)); anchor->version = CMS_LOOKUP_ANCHOR_VERSION; @@ -3002,9 +3047,7 @@ static CMSLookupRoutineAnchor *makeLookupRoutineAnchor(void) { memset(anchor->jobName, ' ', sizeof(anchor->jobName)); } anchor->asid = ascb->ascbasid; - anchor->routineVersion = CMS_LOOKUP_ANCHOR_ROUTINE_VERSION; - memcpy(anchor->routineBody, routineMaster, routineLength); } setKey(originalKey); if (wasProblemState) { diff --git a/h/crossmemory.h b/h/crossmemory.h index 0559b0dea..465c64310 100644 --- a/h/crossmemory.h +++ b/h/crossmemory.h @@ -373,37 +373,6 @@ typedef struct CrossMemoryServerStatus_tag { char descriptionNullTerm[64]; } CrossMemoryServerStatus; -typedef struct CMSLookupRoutineAnchor_tag { - -#define CMS_LOOKUP_ANCHOR_EYECATCHER "ZWESISSV" -#define CMS_LOOKUP_ANCHOR_VERSION 1 -#define CMS_LOOKUP_ANCHOR_KEY CROSS_MEMORY_SERVER_KEY -#define CMS_LOOKUP_ANCHOR_SUBPOOL CROSS_MEMORY_SERVER_SUBPOOL -#define CMS_LOOKUP_ANCHOR_HEADER_SIZE 0x28 - -#define CMS_LOOKUP_ANCHOR_ROUTINE_VERSION 1 - - char eyecatcher[8]; - uint8_t version; - uint8_t key; - uint8_t subpool; - char reserved1[1]; - uint16_t size; - char reserved2[2]; - /* Offset 0x10 */ - uint64_t creationTime; - char jobName[8]; - /* Offset 0x20 */ - uint16_t asid; - char reserved22[4]; - - /* Offset 0x26 */ - uint16_t routineVersion; - /* Offset 0x28 */ - char routineBody[1024]; - -} CMSLookupRoutineAnchor; - ZOWE_PRAGMA_PACK_RESET #define LOG_COMP_ID_CMS 0x008F0001000C0001LLU From 898117599d62120a86a1d042890ad96d394fc6cb Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Fri, 12 Aug 2022 17:48:09 +0200 Subject: [PATCH 17/35] Missing return statement. Signed-off-by: Irek Fakhrutdinov --- c/crossmemory.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/c/crossmemory.c b/c/crossmemory.c index 9953e46b2..5bb9cedf2 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -3013,6 +3013,9 @@ static CMSLookupRoutineAnchor *makeLookupRoutineAnchor(void) { unsigned routineLength = 0; const void *routineMaster = getCMSServerLookup(&routineLength); if (routineLength > sizeof(CMSLookupRoutineAnchor)) { + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_DEBUG, + CMS_LOG_DEBUG_MSG_ID" Look-up routine length %d vs %d\n", + routineLength, sizeof(CMSLookupRoutineAnchor)); return NULL; } /* always give the routine its own page so that it might be marked executable @@ -3022,6 +3025,8 @@ static CMSLookupRoutineAnchor *makeLookupRoutineAnchor(void) { CMS_LOOKUP_ANCHOR_SUBPOOL, CMS_LOOKUP_ANCHOR_KEY); if (anchor == NULL) { + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_DEBUG, + CMS_LOG_DEBUG_MSG_ID" Alloc failed for look-up anchor\n"); return NULL; } @@ -3054,6 +3059,7 @@ static CMSLookupRoutineAnchor *makeLookupRoutineAnchor(void) { supervisorMode(FALSE); } + return anchor; } static void deleteLookupRoutineAnchor(CMSLookupRoutineAnchor *anchor) { From 8b7826b4ffc85225e474e978217dd49dfc9d75a6 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Sat, 13 Aug 2022 13:26:08 +0200 Subject: [PATCH 18/35] Bugfixes in the ZVT look up routine code. Signed-off-by: Irek Fakhrutdinov --- c/zvt.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/c/zvt.c b/c/zvt.c index 9d52029fc..470ccc252 100644 --- a/c/zvt.c +++ b/c/zvt.c @@ -204,18 +204,16 @@ void *zvtGetCMSLookupRoutineAnchor(ZVT *zvt) { void *zvtSetCMSLookupRoutineAnchor(ZVT *zvt, void *anchor) { - void *oldAnchor = anchor; + void *oldAnchor = zvt->cmsGetterRoutine; int wasProblemState = supervisorMode(TRUE); - int originalKey = setKey(0); { - - cds((cds_t *)&oldAnchor, (cds_t *)zvt->cmsGetterRoutine, *(cds_t *)&anchor); - + if (cds((cds_t *)&oldAnchor, (cds_t *)&zvt->cmsGetterRoutine, + *(cds_t *)&anchor)) { + } } setKey(originalKey); - if (wasProblemState) { supervisorMode(FALSE); } From 665547f7dd4e34dbc7d3903840e37a5d9701237f Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Mon, 15 Aug 2022 13:59:07 +0200 Subject: [PATCH 19/35] Use enqueue to serialize the look-up anchor installation. Signed-off-by: Irek Fakhrutdinov --- c/crossmemory.c | 68 ++++++++++++++++++++++++++++++++++++++----------- h/crossmemory.h | 33 ++++++++++-------------- h/zvt.h | 3 +-- 3 files changed, 68 insertions(+), 36 deletions(-) diff --git a/c/crossmemory.c b/c/crossmemory.c index 5bb9cedf2..8e24860af 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -1613,7 +1613,7 @@ ZOWE_PRAGMA_PACK_RESET memcpy((envAddr)->eyecatcher, PC_ROUTINE_ENV_EYECATCHER, sizeof((envAddr)->eyecatcher)); \ (envAddr)->dummyCAA.rleTask = &(envAddr)->dummyRLETask; \ (envAddr)->dummyRLETask.anchor = &(envAddr)->dummyRLEAnchor; \ - (envAddr)->dummyRLEAnchor.metalDynamicLinkageVector = (cmsGlobalAreaAddr)->dynamicLinkageVector; \ + (envAddr)->dummyRLEAnchor.metalDynamicLinkageVector = (cmsGlobalAreaAddr)->userServerDynLinkVector; \ int returnCode = RC_CMS_OK; \ __asm(" LA 12,0(,%0) " : : "r"(&(envAddr)->dummyCAA) : ); \ int recoveryRC = RC_RCV_OK; \ @@ -2834,6 +2834,12 @@ static CMSBuildTimestamp getServerBuildTimestamp() { ZOWE_PRAGMA_PACK +/* These QNAME and RNAME must NEVER change and be the same across all + * cross-memory servers. They are used for the look-up anchoe chain + * serialization. */ +static const QName LANC_QNAME = {CMS_PROD_ID" "}; +static const RName LANC_RNAME = {8, "ISLUANC "}; + typedef struct CMSLookupRoutineAnchor_tag { #define CMS_LOOKUP_ANCHOR_EYECATCHER "ZWECMSLK" @@ -2864,7 +2870,7 @@ typedef struct CMSLookupRoutineAnchor_tag { /* Offset 0x2E */ uint16_t routineVersion; /* Offset 0x30 */ - char routineBody[1024]; + char routineBody[1024]; // TODO can we use less or do we need a page? } CMSLookupRoutineAnchor; @@ -3098,8 +3104,40 @@ static bool isLookupRoutineAnchorValid(const CMSLookupRoutineAnchor *anchor, return true; } +static int lockLookupAnchor(ENQToken *enqToken) { + int lockRC = 0, lockRSN = 0; + lockRC = isgenqGetExclusiveLock(&LANC_QNAME, &LANC_RNAME, ISGENQ_SCOPE_SYSTEM, + enqToken, &lockRSN); + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_DEBUG, + CMS_LOG_DEBUG_MSG_ID" Look-up anchor lock RC = %d, RSN = 0x%08X:\n", + lockRC, lockRSN); + if (lockRC > 4) { + return RC_CMS_LANC_NOT_LOCKED; + } + return RC_CMS_OK; +} + +static int unlockLookupAnchor(ENQToken *lockToken) { + int unlockRC = 0, unlockRSN = 0; + unlockRC = isgenqReleaseLock(lockToken, &unlockRSN); + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_DEBUG, + CMS_LOG_DEBUG_MSG_ID" Look-up anchor release RC = %d, RSN = 0x%08X:\n", + unlockRC, unlockRSN); + if (unlockRC > 4) { + return RC_CMS_LANC_NOT_RELEASED; + } + return RC_CMS_OK; +} + static int installCMSLookupRoutine(const CrossMemoryServer *server, ZVT *zvt) { + int status = RC_CMS_OK; + ENQToken lockToken; + int lockRC = lockLookupAnchor(&lockToken); + if (lockRC != RC_CMS_OK) { + return lockRC; + } + CMSLookupRoutineAnchor *existingAnchor = zvtGetCMSLookupRoutineAnchor(zvt); const char *reasonInvalid = ""; @@ -3116,28 +3154,28 @@ static int installCMSLookupRoutine(const CrossMemoryServer *server, ZVT *zvt) { if (existingAnchor != NULL) { zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_INFO, CMS_LOG_LOOKUP_ANC_REUSED_MSG); - return RC_CMS_OK; + status = RC_CMS_OK; + goto out_unlock; } CMSLookupRoutineAnchor *newAnchor = makeLookupRoutineAnchor(); if (newAnchor == NULL) { zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_SEVERE, CMS_LOG_LOOKUP_ANC_ALLOC_ERROR_MSG); - return RC_CMS_ALLOC_FAILED; + status = RC_CMS_ALLOC_FAILED; + goto out_unlock; } + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_INFO, + CMS_LOG_LOOKUP_ANC_CREATED_MSG, newAnchor); - CMSLookupRoutineAnchor *installedAnchor = - zvtSetCMSLookupRoutineAnchor(zvt, newAnchor); - if (newAnchor != installedAnchor) { - zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_WARNING, - CMS_LOG_LOOKUP_ANC_RACE_MSG, installedAnchor); - deleteLookupRoutineAnchor(newAnchor); - zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_INFO, - CMS_LOG_LOOKUP_ANC_DELETED_MSG, newAnchor); - newAnchor = NULL; - } + zvtSetCMSLookupRoutineAnchor(zvt, newAnchor); - return RC_CMS_OK; +out_unlock:; + int unlockRC = unlockLookupAnchor(&lockToken); + if (unlockRC != RC_CMS_OK) { + status = status != RC_CMS_OK ? status : unlockRC; + } + return status; } diff --git a/h/crossmemory.h b/h/crossmemory.h index 465c64310..e80e260c4 100644 --- a/h/crossmemory.h +++ b/h/crossmemory.h @@ -140,7 +140,9 @@ #define RC_CMS_BAD_DUB_STATUS 89 #define RC_CMS_MODULE_QUERY_FAILED 90 #define RC_CMS_NO_ROOM_FOR_CMS_GETTER 91 -#define RC_CMS_MAX_RC 91 +#define RC_CMS_LANC_NOT_LOCKED 92 +#define RC_CMS_LANC_NOT_RELEASED 93 +#define RC_CMS_MAX_RC 93 extern const char *CMS_RC_DESCRIPTION[]; @@ -235,19 +237,18 @@ typedef struct CrossMemoryServerGlobalArea_tag { PAD_LONG(0, struct RecoveryStatePool_tag *pcssRecoveryPool); CPID pcssStackPool; - PAD_LONG(1, void *dynamicLinkageVector); /* This is an opt-in feature for CMS - Servers that want to offer Dynamic Linkage - to some of their routines is an MVS/Metal/ASM - way. That is to provide a well-known - linkage vector with well-known offsets. - - The CMS server does stipulate anything about - what these services are. + char padding0[4]; + /* This is an opt-in feature for CMS Servers that want to offer Dynamic + * Linkage to some of their routines is an MVS/Metal/ASM way. That is to + * provide a well-known linkage vector with well-known offsets. + * + * The CMS server does not stipulate anything about what these services are. + * + * The ZIS (a CMS) server uses this for its plugins. + */ + PAD_LONG(1, void *userServerDynLinkVector); - The ZIS (a CMS) server uses this for its plugins. - - */ - char reserved3[484]; + char reserved3[480]; CrossMemoryService serviceTable[CROSS_MEMEORY_SERVER_MAX_SERVICE_COUNT]; @@ -989,12 +990,6 @@ CrossMemoryServerName cmsMakeServerName(const char *nameNullTerm); #define CMS_LOG_LOOKUP_ANC_ALLOC_ERROR_MSG_TEXT "Look-up routine anchor has not been created" #define CMS_LOG_LOOKUP_ANC_ALLOC_ERROR_MSG CMS_LOG_LOOKUP_ANC_ALLOC_ERROR_MSG_ID" "CMS_LOG_LOOKUP_ANC_ALLOC_ERROR_MSG_TEXT -#ifndef CMS_LOG_LOOKUP_ANC_RACE_MSG_ID -#define CMS_LOG_LOOKUP_ANC_RACE_MSG_ID CMS_MSG_PRFX"0256W" -#endif -#define CMS_LOG_LOOKUP_ANC_RACE_MSG_TEXT "New look-up routine anchor is not installed due to race condition with anchor %p" -#define CMS_LOG_LOOKUP_ANC_RACE_MSG CMS_LOG_LOOKUP_ANC_RACE_MSG_ID" "CMS_LOG_LOOKUP_ANC_RACE_MSG_TEXT - #endif /* H_CROSSMEMORY_H_ */ diff --git a/h/zvt.h b/h/zvt.h index bcf3c0d14..90daa3f75 100644 --- a/h/zvt.h +++ b/h/zvt.h @@ -134,8 +134,7 @@ void *zvtGetCMSLookupRoutineAnchor(ZVT *zvt); * the provided value. * @param[in] zvt The ZVT to be used. * @param[in] anchor The anchor to be used. - * @return The anchor that has been set (if there has been a race condition, - * the return value will not be equal to the provided anchor). + * @return The old anchor. */ void *zvtSetCMSLookupRoutineAnchor(ZVT *zvt, void *anchor); From 4f5348a074cc89042bde15f0b84bbd2a7de7cba4 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Mon, 15 Aug 2022 18:12:10 +0200 Subject: [PATCH 20/35] Clean up. Signed-off-by: Irek Fakhrutdinov --- c/crossmemory.c | 118 +++++++++++------------------------------------- 1 file changed, 27 insertions(+), 91 deletions(-) diff --git a/c/crossmemory.c b/c/crossmemory.c index 8e24860af..f581d74eb 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -70,10 +70,6 @@ const CrossMemoryServerName CMS_DEFAULT_SERVER_NAME = {CROSS_MEMORY_DEFAULT_SERV #define TOSTR(number) #number #define INT_TO_STR(number) TOSTR(number) -#define CMS_SIZE_OF_FIELD($struct, $field) ({ \ - sizeof((($struct *)0)->$field); \ -}) - const char *CMS_RC_DESCRIPTION[] = { [RC_CMS_OK] = "Ok", [RC_CMS_ERROR] = "Error", @@ -2876,80 +2872,18 @@ typedef struct CMSLookupRoutineAnchor_tag { ZOWE_PRAGMA_PACK_RESET -#ifndef _LP64 - -static void *getCMSServerLookup(int *routineLengthPtr){ - void *routineAddress = NULL; - int routineLength; - __asm(ASM_PREFIX - " LARL 1,L$UXIT00 \n" - " ST 1,%0 \n" - " LRL 1,L$RTNLEN \n" - " ST 1,%1 \n" - " J L$UXITEX \n" - "L$UXIT00 DS 0H \n" - " J L$UXITRT \n" - " DC CL8'ZWECMSLK' ROUTINE NAME \n" - " DC XL1'01' VERSION \n" - " DC XL1'" ZVT_KEY_STR "' KEY \n" - " DC XL1'" ZVT_SUBPOOL_STR "' SUBPOOL \n" - " DC XL5'0000000000' Reserved \n" - "L$UXITRT DS 0H \n" - " STM 14,12,12(13) \n" - " L 14,16 GET CVTPTR \n" - " L 14,X'8C'(,14) GET ECVT \n" - " L 14,X'CC'(,14) GET CSRCTABL \n" - " L 14,X'23C'(,14) GET ZVT \n" - " LTR 14,14 TEST NON ZERO \n" - " JZ L$NOZVT \n" - " L 14,X'9C'(,14) FIRST ZVTE \n" - "ZVTELOOP LTR 14,14 NULL CHECK ZVTE \n" - " JZ L$NOZVTE \n" - " L 4,X'4C'(,14) PRODUCT ANCHOR \n" - " LARL 3,L$CMSRVG LOAD CONSTANT \n" - " CLC 0(8,4),0(3) Is it RSCMSRVG \n" - " JNE ZVTECNTU No CMS Global Server \n" - " L 1,0(,1) Server Name is First Arg \n" - " CLC X'50'(16,4),0(1) Is it the right server name \n" - " JE ZVTEFND Found it ! \n" - "ZVTECNTU LG 14,X'40'(,14) ZVTE = ZVTE->NEXT \n" - " J ZVTELOOP Should limit by N, too \n" - "ZVTEFND LR 15,4 return the CMS GA \n" - " J L$RETURN Non error end \n" - "L$NOZVT XGR 15,15 clear result \n" - " LGFI 0,8 reason 8 \n" - " J L$RETURN \n" - "L$NOZVTE XGR 15,15 clear result \n" - " LGFI 0,12 reason 12 \n" - " J L$RETURN \n" - "L$NOCMSG XGR 15,15 clear result \n" - " LGFI 0,16 reason 16 \n" - " J L$RETURN \n" - "L$RETURN L 14,12(,13) Restore everything but R15 \n" - " LM 1,12,24(13) Restore \n" - " BR 14 \n" - /* non executable code */ - " LTORG \n" - "L$CMSRVG DC CL8'RSCMSRVG' \n" - "L$RTNLEN DC A(*-L$UXIT00) \n" - "L$UXITEX DS 0H \n" - : "=m"(routineAddress),"=m"(routineLength) - : - : "r1"); - *routineLengthPtr = routineLength; - return routineAddress; -} +#ifdef _LP64 -#else +// TODO more check are needed static const void *getCMSServerLookup(unsigned *routineLengthPtr) { const void *routineAddress = NULL; unsigned routineLength; __asm(ASM_PREFIX " LARL 1,L$UXIT00 \n" - " STG 1,%0 \n" + " STG 1,%[addr] \n" " LRL 1,L$RTNLEN \n" - " ST 1,%1 \n" + " ST 1,%[len] \n" " J L$UXITEX \n" "L$UXIT00 DS 0H \n" " J L$UXITRT \n" @@ -2967,17 +2901,17 @@ static const void *getCMSServerLookup(unsigned *routineLengthPtr) { " DC XL2'0000' Routine version \n" "L$UXITRT DS 0H \n" " STMG 14,12,8(13) \n" - " LLGT 14,16 GET CVTPTR \n" - " LGF 14,X'8C'(,14) GET ECVT \n" - " LGF 14,X'CC'(,14) GET CSRCTABL \n" - " LGF 14,X'23C'(,14) GET ZVT \n" - " LTR 14,14 TEST NON ZERO \n" + " LLGT 14,16 Get CVTPTR \n" + " LGF 14,X'8C'(,14) Get ECVT \n" + " LGF 14,X'CC'(,14) Get CSRCTABL \n" + " LGF 14,X'23C'(,14) Get ZVT \n" + " LTR 14,14 Test non zero \n" " JZ L$NOZVT \n" - " LGF 14,X'9C'(,14) FIRST ZVTE \n" - "ZVTELOOP LTR 14,14 NULL CHECK ZVTE \n" + " LGF 14,X'9C'(,14) First ZVTE \n" + "ZVTELOOP LTR 14,14 NULL check ZVTE \n" " JZ L$NOZVTE \n" - " LGF 4,X'4C'(,14) PRODUCT ANCHOR \n" - " LARL 3,L$CMSRVG LOAD CONSTANT \n" + " LGF 4,X'4C'(,14) Product anchor \n" + " LARL 3,L$CMSRVG Load constant \n" " CLC 0(8,4),0(3) Is it RSCMSRVG \n" " JNE ZVTECNTU No CMS Global Server \n" " LG 1,0(,1) Server Name is First Arg \n" @@ -2987,32 +2921,34 @@ static const void *getCMSServerLookup(unsigned *routineLengthPtr) { " J ZVTELOOP Should limit by N, too \n" "ZVTEFND LGR 15,4 return the CMS GA \n" " J L$RETURN Non error end \n" - "L$NOZVT XGR 15,15 clear result \n" - " LGFI 0,8 reason 8 \n" + "L$NOZVT XGR 15,15 Clear result \n" + " LGFI 0,8 Reason 8 \n" " J L$RETURN \n" - "L$NOZVTE XGR 15,15 clear result \n" - " LGFI 0,12 reason 12 \n" + "L$NOZVTE XGR 15,15 Clear result \n" + " LGFI 0,12 Reason 12 \n" " J L$RETURN \n" - "L$NOCMSG XGR 15,15 clear result \n" - " LGFI 0,16 reason 16 \n" + "L$NOCMSG XGR 15,15 Clear result \n" + " LGFI 0,16 Reason 16 \n" " J L$RETURN \n" - "L$RETURN LG 14,8(,13) Restore everything but R15,R0 \n" - /* " DC XL2'0000' \n" */ - " LMG 1,12,32(13) Restore \n" + "L$RETURN LG 14,8(,13) Return address \n" + " LMG 1,12,32(13) Restore everything but R15,R0 \n" " BR 14 \n" /* non executable code */ " LTORG \n" "L$CMSRVG DC CL8'RSCMSRVG' \n" "L$RTNLEN DC A(*-L$UXIT00) \n" "L$UXITEX DS 0H \n" - : "=m"(routineAddress),"=m"(routineLength) + : [addr]"=m"(routineAddress), [len]"=m"(routineLength) : - : "r1"); + : "r1" + ); *routineLengthPtr = routineLength; return routineAddress; } -#endif +#else +#error 64-bit is supported only +#endif /* __LP64 */ static CMSLookupRoutineAnchor *makeLookupRoutineAnchor(void) { From bdd272915d3713d0d78087d2d882ecde675f0d0f Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Wed, 17 Aug 2022 11:51:12 +0200 Subject: [PATCH 21/35] Add a command to explicitly discard the look-up anchor. Signed-off-by: Irek Fakhrutdinov --- c/crossmemory.c | 33 ++++++++++++++++++++++++++++++++- h/crossmemory.h | 14 ++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/c/crossmemory.c b/c/crossmemory.c index f581d74eb..6e972912a 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -2388,6 +2388,10 @@ CrossMemoryServer *makeCrossMemoryServer2( server->flags |= CROSS_MEMORY_SERVER_FLAG_CLEAN_LPA; } + if (flags & CMS_SERVER_FLAG_RESET_LOOKUP) { + server->flags |= CROSS_MEMORY_SERVER_FLAG_RESET_LOOKUP; + } + int allocResourcesRC = allocServerResources(server); if (allocResourcesRC != RC_CMS_OK) { safeFree31((char *)server, sizeof(CrossMemoryServer)); @@ -3009,6 +3013,20 @@ static void deleteLookupRoutineAnchor(CMSLookupRoutineAnchor *anchor) { CMS_LOOKUP_ANCHOR_KEY); } +static int discardLookupRoutineAnchor(CrossMemoryServer *server) { + + ZVT *zvt = zvtGet(); + if (zvt == NULL) { + return RC_CMS_ZVT_NULL; + } + + void *discardedAnchor = zvtSetCMSLookupRoutineAnchor(zvt, NULL); + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_INFO, CMS_LOG_LOOKUP_ANC_RESET_REQ_MSG, + discardedAnchor); + + return RC_CMS_OK; +} + static bool isLookupRoutineAnchorValid(const CMSLookupRoutineAnchor *anchor, const char **reason) { if (memcmp(anchor->eyecatcher, CMS_LOOKUP_ANCHOR_EYECATCHER, @@ -3089,7 +3107,7 @@ static int installCMSLookupRoutine(const CrossMemoryServer *server, ZVT *zvt) { if (existingAnchor != NULL) { zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_INFO, - CMS_LOG_LOOKUP_ANC_REUSED_MSG); + CMS_LOG_LOOKUP_ANC_REUSED_MSG, existingAnchor); status = RC_CMS_OK; goto out_unlock; } @@ -3691,6 +3709,7 @@ int backgroundHandler(STCBase *base, STCModule *module, int selectStatus) { #define CMS_COMMAND_VERB_DISPLAY_SHORT "DIS" #define CMS_COMMAND_VERB_DISPLAY_ABBRV "D" #define CMS_COMMAND_VERB_COLD "COLD" +#define CMS_COMMAND_VERB_RESET_LOOKUP "RESET(LOOKUP)" static char **tokenizeModifyCommand(ShortLivedHeap *slh, const char *command, unsigned short commandLength, unsigned int *tokenCount) { @@ -4178,6 +4197,11 @@ static int handleModifyCommand(STCBase *base, CIB *cib, STCConsoleCommandType co if (globalArea != NULL) { globalArea->serverFlags |= CROSS_MEMORY_SERVER_FLAG_COLD_START; } + } else if (strcmp(commandVerb, CMS_COMMAND_VERB_RESET_LOOKUP) == 0) { + server->flags |= CROSS_MEMORY_SERVER_FLAG_RESET_LOOKUP; + if (globalArea != NULL) { + globalArea->serverFlags |= CROSS_MEMORY_SERVER_FLAG_RESET_LOOKUP; + } } else { zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_WARNING, CMS_LOG_BAD_CMD_MSG, commandVerb); wtoPrintf2(consoleID, cart, CMS_LOG_BAD_CMD_MSG, commandVerb); @@ -4833,6 +4857,13 @@ int cmsStartMainLoop(CrossMemoryServer *srv) { zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_WARNING, CMS_LOG_GLB_CLEANUP_WARN_MSG, cleanRC); } } + if (srv->flags & CROSS_MEMORY_SERVER_FLAG_RESET_LOOKUP) { + int discardRC = discardLookupRoutineAnchor(srv); + if (discardRC != RC_CMS_OK) { + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_WARNING, + CMS_LOG_LOOKUP_ANC_RESET_WARN_MSG, discardRC); + } + } } if (status == RC_CMS_OK) { diff --git a/h/crossmemory.h b/h/crossmemory.h index e80e260c4..a38819ec5 100644 --- a/h/crossmemory.h +++ b/h/crossmemory.h @@ -310,6 +310,7 @@ typedef struct CrossMemoryServer_tag { #define CROSS_MEMORY_SERVER_FLAG_TERM_ENDED 0x00000008 #define CROSS_MEMORY_SERVER_FLAG_CHECKAUTH 0x00000010 #define CROSS_MEMORY_SERVER_FLAG_CLEAN_LPA 0x00000020 +#define CROSS_MEMORY_SERVER_FLAG_RESET_LOOKUP 0x00000040 STCBase * __ptr32 base; CMSStarCallback * __ptr32 startCallback; CMSStopCallback * __ptr32 stopCallback; @@ -413,6 +414,7 @@ ZOWE_PRAGMA_PACK_RESET #define CMS_SERVER_FLAG_CHECKAUTH 0x00000004 #define CMS_SERVER_FLAG_DEV_MODE 0x00000008 #define CMS_SERVER_FLAG_DEV_MODE_LPA 0x00000010 +#define CMS_SERVER_FLAG_RESET_LOOKUP 0x00000020 #define CMS_SERVICE_FLAG_NONE 0x00000000 #define CMS_SERVICE_FLAG_SPACE_SWITCH 0x00000001 @@ -990,6 +992,18 @@ CrossMemoryServerName cmsMakeServerName(const char *nameNullTerm); #define CMS_LOG_LOOKUP_ANC_ALLOC_ERROR_MSG_TEXT "Look-up routine anchor has not been created" #define CMS_LOG_LOOKUP_ANC_ALLOC_ERROR_MSG CMS_LOG_LOOKUP_ANC_ALLOC_ERROR_MSG_ID" "CMS_LOG_LOOKUP_ANC_ALLOC_ERROR_MSG_TEXT +#ifndef CMS_LOG_LOOKUP_ANC_RESET_REQ_MSG_ID +#define CMS_LOG_LOOKUP_ANC_RESET_REQ_MSG_ID CMS_MSG_PRFX"0256I" +#endif +#define CMS_LOG_LOOKUP_ANC_RESET_REQ_MSG_TEXT "Look-up routine anchor at %p has been explicitly discarded" +#define CMS_LOG_LOOKUP_ANC_RESET_REQ_MSG CMS_LOG_LOOKUP_ANC_RESET_REQ_MSG_ID" "CMS_LOG_LOOKUP_ANC_RESET_REQ_MSG_TEXT + +#ifndef CMS_LOG_LOOKUP_ANC_RESET_WARN_MSG_ID +#define CMS_LOG_LOOKUP_ANC_RESET_WARN_MSG_ID CMS_MSG_PRFX"0257W" +#endif +#define CMS_LOG_LOOKUP_ANC_RESET_WARN_MSG_TEXT "Look-up routine anchor discard RC = %d" +#define CMS_LOG_LOOKUP_ANC_RESET_WARN_MSG CMS_LOG_LOOKUP_ANC_RESET_WARN_MSG_ID" "CMS_LOG_LOOKUP_ANC_RESET_WARN_MSG_TEXT + #endif /* H_CROSSMEMORY_H_ */ From 11fdb7a89d10ee6824faa0dcba3495ff8a49ea1d Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Wed, 17 Aug 2022 14:27:28 +0200 Subject: [PATCH 22/35] Clean up. Signed-off-by: Irek Fakhrutdinov --- c/crossmemory.c | 28 +++++++++++++++++++++------- c/zvt.c | 6 +++--- h/zvt.h | 8 ++------ 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/c/crossmemory.c b/c/crossmemory.c index 6e972912a..2f76dcf41 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -2840,6 +2840,11 @@ ZOWE_PRAGMA_PACK static const QName LANC_QNAME = {CMS_PROD_ID" "}; static const RName LANC_RNAME = {8, "ISLUANC "}; +/** + * This struct maps the CMS look-up routine. + * + * IMPORTANT: any changes must be coordinated with @c getCMSLookupRoutine. + */ typedef struct CMSLookupRoutineAnchor_tag { #define CMS_LOOKUP_ANCHOR_EYECATCHER "ZWECMSLK" @@ -2880,7 +2885,16 @@ ZOWE_PRAGMA_PACK_RESET // TODO more check are needed -static const void *getCMSServerLookup(unsigned *routineLengthPtr) { +/** + * Returns the look up routine and its length; + * + * IMPORTANT: any changes in this function must be coordinated with + * @c CMSLookupRoutineAnchor. + * + * @param[out] routineLengthPtr The look-up routine length including its header. + * @return the look-up routine mapped by @c CMSLookupRoutineAnchor. + */ +static const void *getCMSLookupRoutineAnchor(unsigned *routineLengthPtr) { const void *routineAddress = NULL; unsigned routineLength; __asm(ASM_PREFIX @@ -2952,16 +2966,16 @@ static const void *getCMSServerLookup(unsigned *routineLengthPtr) { #else #error 64-bit is supported only -#endif /* __LP64 */ +#endif /* _LP64 */ static CMSLookupRoutineAnchor *makeLookupRoutineAnchor(void) { - unsigned routineLength = 0; - const void *routineMaster = getCMSServerLookup(&routineLength); - if (routineLength > sizeof(CMSLookupRoutineAnchor)) { + unsigned anchorLength = 0; + const void *anchorMaster = getCMSLookupRoutineAnchor(&anchorLength); + if (anchorLength > sizeof(CMSLookupRoutineAnchor)) { zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_DEBUG, CMS_LOG_DEBUG_MSG_ID" Look-up routine length %d vs %d\n", - routineLength, sizeof(CMSLookupRoutineAnchor)); + anchorLength, sizeof(CMSLookupRoutineAnchor)); return NULL; } /* always give the routine its own page so that it might be marked executable @@ -2980,7 +2994,7 @@ static CMSLookupRoutineAnchor *makeLookupRoutineAnchor(void) { int originalKey = setKey(0); { memset(anchor, 0, sizeof(CMSLookupRoutineAnchor)); - memcpy(anchor, routineMaster, routineLength); + memcpy(anchor, anchorMaster, anchorLength); memcpy(anchor->eyecatcher, CMS_LOOKUP_ANCHOR_EYECATCHER, sizeof(anchor->eyecatcher)); anchor->version = CMS_LOOKUP_ANCHOR_VERSION; diff --git a/c/zvt.c b/c/zvt.c index 470ccc252..0d916036a 100644 --- a/c/zvt.c +++ b/c/zvt.c @@ -199,17 +199,17 @@ void zvtFreeEntry(ZVTEntry *entry) { } void *zvtGetCMSLookupRoutineAnchor(ZVT *zvt) { - return zvt->cmsGetterRoutine; + return zvt->cmsLookupRoutine; } void *zvtSetCMSLookupRoutineAnchor(ZVT *zvt, void *anchor) { - void *oldAnchor = zvt->cmsGetterRoutine; + void *oldAnchor = zvt->cmsLookupRoutine; int wasProblemState = supervisorMode(TRUE); int originalKey = setKey(0); { - if (cds((cds_t *)&oldAnchor, (cds_t *)&zvt->cmsGetterRoutine, + if (cds((cds_t *)&oldAnchor, (cds_t *)&zvt->cmsLookupRoutine, *(cds_t *)&anchor)) { } } diff --git a/h/zvt.h b/h/zvt.h index 90daa3f75..c0464c470 100644 --- a/h/zvt.h +++ b/h/zvt.h @@ -24,11 +24,9 @@ ZOWE_PRAGMA_PACK #define ZVT_OFFSET 0x023C #define ZVT_EYECATCHER "ZOWEVT " -#define ZVT_VERSION 2 /* 2 introduces dynamic linking support */ +#define ZVT_VERSION 1 #define ZVT_KEY 0 #define ZVT_SUBPOOL 228 -#define ZVT_KEY_STR "0" -#define ZVT_SUBPOOL_STR "E4" typedef struct ZVTEntry_tag { @@ -71,8 +69,6 @@ typedef struct ZVTEntry_tag { } ZVTEntry; -#define MAX_CMS_GETTER_ROUTINE_SIZE 0x100 - typedef struct ZVT_tag { char eyecatcher[8]; @@ -88,7 +84,7 @@ typedef struct ZVT_tag { /* Offset 0x20 */ uint16_t asid; char reserved22[6]; - PAD_LONG(9, void *cmsGetterRoutine); /* points at another page in 31-common */ + PAD_LONG(9, void *cmsLookupRoutine); /* points at another page in 31-common */ char reserved3[104]; struct { From 557095b5e1ba9a13ed837417449793974a74df0f Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Thu, 18 Aug 2022 15:14:02 +0200 Subject: [PATCH 23/35] Remove unused fields taking up space. Signed-off-by: Irek Fakhrutdinov --- h/le.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/h/le.h b/h/le.h index 118d9b1c8..6af9cef86 100644 --- a/h/le.h +++ b/h/le.h @@ -241,8 +241,6 @@ typedef struct RLETask_tag{ char threadDataFiller[32]; }; - int sdwaBaseAddress; - char sdwaCopy[SDWA_COPY_MAX]; } RLETask; #ifdef __ZOWE_OS_ZOS From 970322998280eceac94fe5f000241d0e7a8cf511 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Fri, 19 Aug 2022 10:37:16 +0200 Subject: [PATCH 24/35] Loop protection in the look-up routine. Signed-off-by: Irek Fakhrutdinov --- c/crossmemory.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/c/crossmemory.c b/c/crossmemory.c index 2f76dcf41..4ef30f2b2 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -2925,9 +2925,12 @@ static const void *getCMSLookupRoutineAnchor(unsigned *routineLengthPtr) { " LGF 14,X'23C'(,14) Get ZVT \n" " LTR 14,14 Test non zero \n" " JZ L$NOZVT \n" + " LGHI 5,"INT_TO_STR(CMS_MAX_ZVTE_CHAIN_LENGTH)" Max ZVTEs \n" " LGF 14,X'9C'(,14) First ZVTE \n" "ZVTELOOP LTR 14,14 NULL check ZVTE \n" " JZ L$NOZVTE \n" + " AGHI 5,-1 Decrement the loop counter \n" + " JNP L$LOOPIN Exit if looping \n" " LGF 4,X'4C'(,14) Product anchor \n" " LARL 3,L$CMSRVG Load constant \n" " CLC 0(8,4),0(3) Is it RSCMSRVG \n" @@ -2948,6 +2951,9 @@ static const void *getCMSLookupRoutineAnchor(unsigned *routineLengthPtr) { "L$NOCMSG XGR 15,15 Clear result \n" " LGFI 0,16 Reason 16 \n" " J L$RETURN \n" + "L$LOOPIN XGR 15,15 Clear result \n" + " LGFI 0,32 Reason 32 \n" + " J L$RETURN \n" "L$RETURN LG 14,8(,13) Return address \n" " LMG 1,12,32(13) Restore everything but R15,R0 \n" " BR 14 \n" From b3af1652d06a9c1197a17dfda07da425be577eb8 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Mon, 22 Aug 2022 08:47:52 +0200 Subject: [PATCH 25/35] Comments about versions; version check in the look-up routine. Signed-off-by: Irek Fakhrutdinov --- c/crossmemory.c | 18 +++++++++++++----- h/crossmemory.h | 26 +++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/c/crossmemory.c b/c/crossmemory.c index 4ef30f2b2..b605fe4e4 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -2919,6 +2919,10 @@ static const void *getCMSLookupRoutineAnchor(unsigned *routineLengthPtr) { " DC XL2'0000' Routine version \n" "L$UXITRT DS 0H \n" " STMG 14,12,8(13) \n" + " PUSH USING \n" + " DROP \n" + " LARL 10,L$UXITRT \n" + " USING L$UXITRT,10 \n" " LLGT 14,16 Get CVTPTR \n" " LGF 14,X'8C'(,14) Get ECVT \n" " LGF 14,X'CC'(,14) Get CSRCTABL \n" @@ -2927,17 +2931,19 @@ static const void *getCMSLookupRoutineAnchor(unsigned *routineLengthPtr) { " JZ L$NOZVT \n" " LGHI 5,"INT_TO_STR(CMS_MAX_ZVTE_CHAIN_LENGTH)" Max ZVTEs \n" " LGF 14,X'9C'(,14) First ZVTE \n" + " LG 1,0(,1) Server Name is First Arg \n" "ZVTELOOP LTR 14,14 NULL check ZVTE \n" " JZ L$NOZVTE \n" " AGHI 5,-1 Decrement the loop counter \n" " JNP L$LOOPIN Exit if looping \n" " LGF 4,X'4C'(,14) Product anchor \n" - " LARL 3,L$CMSRVG Load constant \n" - " CLC 0(8,4),0(3) Is it RSCMSRVG \n" + " CLC 0(8,4),L$CMSRVG Is it RSCMSRVG \n" " JNE ZVTECNTU No CMS Global Server \n" - " LG 1,0(,1) Server Name is First Arg \n" " CLC X'50'(16,4),0(1) Is it the right server name \n" - " JE ZVTEFND Found it ! \n" + " JNE ZVTECNTU No, look further \n" + " LLGF 3,8(0,4) Load the version \n" + " CLG 3,L$CMSDVR Discarded version? \n" + " JE ZVTEFND Good version, found it! \n" "ZVTECNTU LG 14,X'40'(,14) ZVTE = ZVTE->NEXT \n" " J ZVTELOOP Should limit by N, too \n" "ZVTEFND LGR 15,4 return the CMS GA \n" @@ -2959,8 +2965,10 @@ static const void *getCMSLookupRoutineAnchor(unsigned *routineLengthPtr) { " BR 14 \n" /* non executable code */ " LTORG \n" - "L$CMSRVG DC CL8'RSCMSRVG' \n" + "L$CMSRVG DC CL8'"CMS_GLOBAL_AREA_EYECATCHER"' \n" + "L$CMSDVR DC FD'"INT_TO_STR(CROSS_MEMORY_SERVER_DISCARDED_VERSION)"' \n" "L$RTNLEN DC A(*-L$UXIT00) \n" + " POP USING \n" "L$UXITEX DS 0H \n" : [addr]"=m"(routineAddress), [len]"=m"(routineLength) : diff --git a/h/crossmemory.h b/h/crossmemory.h index a38819ec5..e798516ce 100644 --- a/h/crossmemory.h +++ b/h/crossmemory.h @@ -191,8 +191,32 @@ typedef struct CrossMemoryService_tag { PAD_LONG(1, void *serviceData); } CrossMemoryService; +/* + * TODO this version must not be incremented until the following gets addressed. + * + * When a cross-memory server starts it uses cmsGetGlobalArea to check if + * there is already an existing area for this server. The function discards + * any areas with versions not equal to CROSS_MEMORY_SERVER_VERSION. If this + * value is changed one day, cmsGetGlobalArea will return NULL and the server + * will allocate another area with the new version. + * + * Since cmsGetGlobalArea is also used by clients, updating this version in + * the server will cause them to use the wrong global area (the old one) and + * since that old area is inactive, the client won't be able to use the server + * with the specified name. That can happen if a client uses an older ZSS: + * the cmsGetGlobalArea function will have an older CROSS_MEMORY_SERVER_VERSION + * value, which won't match the new version of the area the cross-memory server + * has created. + * + * Possible solutions: + * - Make sure there are never more than 1 areas with valid versions (that is, + * not CROSS_MEMORY_SERVER_DISCARDED_VERSION). So that client will just have + * to deal with a single global area with the specified server name. + * - Change the look up code to return the area with the highest version. + * + */ #define CROSS_MEMORY_SERVER_VERSION 2 -#define CROSS_MEMORY_SERVER_DISCARDED_VERSION 0xDEADDA7A +#define CROSS_MEMORY_SERVER_DISCARDED_VERSION 3735935610 /* 0xDEADDA7A */ typedef struct CMSTimestamp_tag { char value[32]; From 4ec8a2a65318441b0d611c2641823ec725433c96 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Thu, 25 Aug 2022 14:02:10 +0200 Subject: [PATCH 26/35] Allocate less space for the look-up routine. Signed-off-by: Irek Fakhrutdinov --- c/crossmemory.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/c/crossmemory.c b/c/crossmemory.c index b605fe4e4..fa9833528 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -2870,12 +2870,12 @@ typedef struct CMSLookupRoutineAnchor_tag { /* Offset 0x28 */ uint16_t asid; /* Offset 0x2A */ - char reserved3[4]; + char reserved3[20]; - /* Offset 0x2E */ + /* Offset 0x3E */ uint16_t routineVersion; - /* Offset 0x30 */ - char routineBody[1024]; // TODO can we use less or do we need a page? + /* Offset 0x40 */ + char routineBody[448]; } CMSLookupRoutineAnchor; @@ -2883,8 +2883,6 @@ ZOWE_PRAGMA_PACK_RESET #ifdef _LP64 -// TODO more check are needed - /** * Returns the look up routine and its length; * @@ -2915,7 +2913,7 @@ static const void *getCMSLookupRoutineAnchor(unsigned *routineLengthPtr) { " DC XL8'0000000000000000' Creation time \n" " DC CL8' ' Job name \n" " DC XL2'0000' ASID \n" - " DC XL4'00000000' Reserved \n" + " DC XL20'00' Reserved \n" " DC XL2'0000' Routine version \n" "L$UXITRT DS 0H \n" " STMG 14,12,8(13) \n" @@ -2992,9 +2990,8 @@ static CMSLookupRoutineAnchor *makeLookupRoutineAnchor(void) { anchorLength, sizeof(CMSLookupRoutineAnchor)); return NULL; } -/* always give the routine its own page so that it might be marked executable - as opposed to most ZVT storage which is unexecutable data */ -// TODO do we still need to do that? It wasn't executable to begin with + // TODO if the cmutils alloc functions are changed to allocate non-executable + // storage, this call will need to change CMSLookupRoutineAnchor *anchor = cmAlloc(sizeof(CMSLookupRoutineAnchor), CMS_LOOKUP_ANCHOR_SUBPOOL, CMS_LOOKUP_ANCHOR_KEY); From 242ab96fbdebb6a38aec06f94297b63388a60fb9 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Fri, 26 Aug 2022 19:05:26 +0200 Subject: [PATCH 27/35] Clean up the look-up routine; add a macro to access the routine. Signed-off-by: Irek Fakhrutdinov --- c/crossmemory.c | 64 +++++++++++++++++++++++++++++++++---------------- h/crossmemory.h | 21 ++++++++++++++++ 2 files changed, 64 insertions(+), 21 deletions(-) diff --git a/c/crossmemory.c b/c/crossmemory.c index fa9833528..8139be5a6 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -2901,6 +2901,20 @@ static const void *getCMSLookupRoutineAnchor(unsigned *routineLengthPtr) { " LRL 1,L$RTNLEN \n" " ST 1,%[len] \n" " J L$UXITEX \n" + /* + * GPRs used in the routine: + * 0 - reason code + * 1 - parm list + * 2 - server name + * 3 - work register + * 4 - current anchor + * 5 - ZVTe loop counter + * 10 - base register + * 13 - save area + * 14 - work register + * 15 - return value (CMS anchor) + * + */ "L$UXIT00 DS 0H \n" " J L$UXITRT \n" " DC CL8' ' Eyecatcher \n" @@ -2922,44 +2936,52 @@ static const void *getCMSLookupRoutineAnchor(unsigned *routineLengthPtr) { " LARL 10,L$UXITRT \n" " USING L$UXITRT,10 \n" " LLGT 14,16 Get CVTPTR \n" - " LGF 14,X'8C'(,14) Get ECVT \n" - " LGF 14,X'CC'(,14) Get CSRCTABL \n" - " LGF 14,X'23C'(,14) Get ZVT \n" + " LLGT 14,X'8C'(,14) Get ECVT \n" + " LLGT 14,X'CC'(,14) Get CSRCTABL \n" + " LLGT 14,X'23C'(,14) Get ZVT \n" " LTR 14,14 Test non zero \n" " JZ L$NOZVT \n" " LGHI 5,"INT_TO_STR(CMS_MAX_ZVTE_CHAIN_LENGTH)" Max ZVTEs \n" - " LGF 14,X'9C'(,14) First ZVTE \n" - " LG 1,0(,1) Server Name is First Arg \n" - "ZVTELOOP LTR 14,14 NULL check ZVTE \n" - " JZ L$NOZVTE \n" + " LG 14,X'9C'(,14) First ZVTE \n" + " LG 2,0(,1) Server name address (1st arg) \n" + "ZVTELOOP DS 0H \n" + " LTR 14,14 NULL check ZVTE \n" + " JZ L$NOZVTE End of the ZVTE chain \n" " AGHI 5,-1 Decrement the loop counter \n" " JNP L$LOOPIN Exit if looping \n" - " LGF 4,X'4C'(,14) Product anchor \n" + " LTG 4,X'4C'(,14) Product anchor \n" + " JZ ZVTECNTU No anchor, skip \n" " CLC 0(8,4),L$CMSRVG Is it RSCMSRVG \n" " JNE ZVTECNTU No CMS Global Server \n" - " CLC X'50'(16,4),0(1) Is it the right server name \n" + " CLC X'50'(16,4),0(2) Is it the right server name \n" " JNE ZVTECNTU No, look further \n" " LLGF 3,8(0,4) Load the version \n" " CLG 3,L$CMSDVR Discarded version? \n" " JE ZVTEFND Good version, found it! \n" - "ZVTECNTU LG 14,X'40'(,14) ZVTE = ZVTE->NEXT \n" + "ZVTECNTU DS 0H \n" + " LG 14,X'40'(,14) ZVTE = ZVTE->NEXT \n" " J ZVTELOOP Should limit by N, too \n" - "ZVTEFND LGR 15,4 return the CMS GA \n" + "ZVTEFND DS 0H \n" + " LGR 15,4 Return the CMS GA \n" + " XGR 0,0 Reason 0 \n" " J L$RETURN Non error end \n" - "L$NOZVT XGR 15,15 Clear result \n" - " LGFI 0,8 Reason 8 \n" + "L$NOZVT DS 0H \n" + " XGR 15,15 Clear result \n" + " LGFI 0,2 Reason 2 \n" " J L$RETURN \n" - "L$NOZVTE XGR 15,15 Clear result \n" - " LGFI 0,12 Reason 12 \n" + "L$NOZVTE DS 0H \n" + " XGR 15,15 Clear result \n" + " LGFI 0,4 Reason 4 \n" " J L$RETURN \n" - "L$NOCMSG XGR 15,15 Clear result \n" + "L$LOOPIN DS 0H \n" + " XGR 15,15 Clear result \n" " LGFI 0,16 Reason 16 \n" " J L$RETURN \n" - "L$LOOPIN XGR 15,15 Clear result \n" - " LGFI 0,32 Reason 32 \n" - " J L$RETURN \n" - "L$RETURN LG 14,8(,13) Return address \n" - " LMG 1,12,32(13) Restore everything but R15,R0 \n" + "L$RETURN DS 0H \n" + " LG 3,8(,1) Reason code address (2nd arg) \n" + " ST 0,0(0,3) Store the reason code \n" + " LMG 1,12,32(13) Restore GPRs except R13-R15, R0 \n" + " LG 14,8(,13) Return address \n" " BR 14 \n" /* non executable code */ " LTORG \n" diff --git a/h/crossmemory.h b/h/crossmemory.h index e798516ce..957a74f7d 100644 --- a/h/crossmemory.h +++ b/h/crossmemory.h @@ -562,6 +562,27 @@ int cmsGetPCLogLevel(const CrossMemoryServerName *serverName); CrossMemoryServerStatus cmsGetStatus(const CrossMemoryServerName *serverName); CrossMemoryServerName cmsMakeServerName(const char *nameNullTerm); + +typedef CrossMemoryServerGlobalArea + *CMSLookupFunction(const CrossMemoryServerName *name, int *reasonCode); + +/** + * This macro returns the look-up routine mapped by @c CMSLookupFunction. + * @return The routine address, or NULL if the ZVT or the routine hasn't been + * found. + */ +#define cmsGetLookupFunction() ({ \ + const CVT *cvt = *(CVT * __ptr32 *)0x10; \ + const ECVT *ecvt = cvt->cvtecvt; \ + const char *ecvtctbl = ecvt->ecvtctbl;\ + const ZVT * __ptr32 *zvt = (const ZVT * __ptr32 *)(ecvtctbl + ZVT_OFFSET); \ + CMSLookupFunction *result = (CMSLookupFunction *)NULL; \ + if (*zvt != NULL) { \ + result = (CMSLookupFunction *)(*zvt)->cmsLookupRoutine; \ + } \ + result; \ +}); + /* default message IDs (users of crossmemory.c can potentially redefine them) */ /* 001 - 099 should be used by the application that use the core cross memory server */ From 78d285a98cb2bac5b5ad1968943870dd2fd36fb0 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Sat, 27 Aug 2022 14:52:37 +0200 Subject: [PATCH 28/35] Bug fixes in the look-up routine; helper macros. Signed-off-by: Irek Fakhrutdinov --- c/crossmemory.c | 18 +++++++++--------- h/crossmemory.h | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/c/crossmemory.c b/c/crossmemory.c index 8139be5a6..1f3386a30 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -2942,22 +2942,22 @@ static const void *getCMSLookupRoutineAnchor(unsigned *routineLengthPtr) { " LTR 14,14 Test non zero \n" " JZ L$NOZVT \n" " LGHI 5,"INT_TO_STR(CMS_MAX_ZVTE_CHAIN_LENGTH)" Max ZVTEs \n" - " LG 14,X'9C'(,14) First ZVTE \n" + " LG 14,X'98'(,14) First ZVTE \n" " LG 2,0(,1) Server name address (1st arg) \n" "ZVTELOOP DS 0H \n" " LTR 14,14 NULL check ZVTE \n" " JZ L$NOZVTE End of the ZVTE chain \n" " AGHI 5,-1 Decrement the loop counter \n" " JNP L$LOOPIN Exit if looping \n" - " LTG 4,X'4C'(,14) Product anchor \n" + " LTG 4,X'48'(,14) Product anchor \n" " JZ ZVTECNTU No anchor, skip \n" " CLC 0(8,4),L$CMSRVG Is it RSCMSRVG \n" - " JNE ZVTECNTU No CMS Global Server \n" + " JNE ZVTECNTU Not a valid CMS anchor \n" " CLC X'50'(16,4),0(2) Is it the right server name \n" " JNE ZVTECNTU No, look further \n" " LLGF 3,8(0,4) Load the version \n" " CLG 3,L$CMSDVR Discarded version? \n" - " JE ZVTEFND Good version, found it! \n" + " JNE ZVTEFND Good version, found it! \n" "ZVTECNTU DS 0H \n" " LG 14,X'40'(,14) ZVTE = ZVTE->NEXT \n" " J ZVTELOOP Should limit by N, too \n" @@ -2965,17 +2965,17 @@ static const void *getCMSLookupRoutineAnchor(unsigned *routineLengthPtr) { " LGR 15,4 Return the CMS GA \n" " XGR 0,0 Reason 0 \n" " J L$RETURN Non error end \n" - "L$NOZVT DS 0H \n" + "L$NOZVTE DS 0H \n" " XGR 15,15 Clear result \n" - " LGFI 0,2 Reason 2 \n" + " LGFI 0,"INT_TO_STR(RSN_CMSLOOKUP_NOCMS)" \n" " J L$RETURN \n" - "L$NOZVTE DS 0H \n" + "L$NOZVT DS 0H \n" " XGR 15,15 Clear result \n" - " LGFI 0,4 Reason 4 \n" + " LGFI 0,"INT_TO_STR(RSN_CMSLOOKUP_NOZVT)" \n" " J L$RETURN \n" "L$LOOPIN DS 0H \n" " XGR 15,15 Clear result \n" - " LGFI 0,16 Reason 16 \n" + " LGFI 0,"INT_TO_STR(RSN_CMSLOOKUP_LOOP)" \n" " J L$RETURN \n" "L$RETURN DS 0H \n" " LG 3,8(,1) Reason code address (2nd arg) \n" diff --git a/h/crossmemory.h b/h/crossmemory.h index 957a74f7d..57f55f787 100644 --- a/h/crossmemory.h +++ b/h/crossmemory.h @@ -563,15 +563,22 @@ CrossMemoryServerStatus cmsGetStatus(const CrossMemoryServerName *serverName); CrossMemoryServerName cmsMakeServerName(const char *nameNullTerm); +#if defined(METTLE) && defined(_LP64) + typedef CrossMemoryServerGlobalArea *CMSLookupFunction(const CrossMemoryServerName *name, int *reasonCode); +#define RSN_CMSLOOKUP_OK 0 +#define RSN_CMSLOOKUP_NOCMS 2 +#define RSN_CMSLOOKUP_NOZVT 4 +#define RSN_CMSLOOKUP_LOOP 16 + /** * This macro returns the look-up routine mapped by @c CMSLookupFunction. * @return The routine address, or NULL if the ZVT or the routine hasn't been * found. */ -#define cmsGetLookupFunction() ({ \ +#define CMS_GET_LOOKUP_FUNCTION() ({ \ const CVT *cvt = *(CVT * __ptr32 *)0x10; \ const ECVT *ecvt = cvt->cvtecvt; \ const char *ecvtctbl = ecvt->ecvtctbl;\ @@ -583,6 +590,37 @@ typedef CrossMemoryServerGlobalArea result; \ }); +typedef struct CMSDynlinkEnv_tag { + char eyecatcher[8]; +#define CMS_DYNLINK_ENV_EYECATCHER "ZWEDLENV" + CAA dummyCAA; + RLETask dummyRLETask; + char filler0[4]; + RLEAnchor dummyRLEAnchor; +} CMSDynlinkEnv; + +/** + * This macro establishes an environment in R12 which allows using the functions + * provided by the dynamic linkage vector in the provided + * @c CrossMemoryServerGlobalArea. + * + * IMPORTANT: + * - R12 must be reserved in your Metal C application + * - This must be used at the top level of your application + * + */ +#define CMS_SETUP_DYNLINK_ENV(cmsAnchorAddr) \ + CMSDynlinkEnv cmsDLEnv = { \ + .eyecatcher = CMS_DYNLINK_ENV_EYECATCHER, \ + }; \ + cmsDLEnv.dummyCAA.rleTask = &cmsDLEnv.dummyRLETask; \ + cmsDLEnv.dummyRLETask.anchor = &cmsDLEnv.dummyRLEAnchor; \ + cmsDLEnv.dummyRLEAnchor.metalDynamicLinkageVector = \ + (cmsAnchorAddr)->userServerDynLinkVector; \ + __asm(" LA 12,0(,%0) " : : "r"(&cmsDLEnv.dummyCAA) : ) + +#endif /* defined(METTLE) && defined(_LP64) */ + /* default message IDs (users of crossmemory.c can potentially redefine them) */ /* 001 - 099 should be used by the application that use the core cross memory server */ From 4e3665b4d6a52aec0d3056a457e0e1e0a579192a Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Sat, 27 Aug 2022 16:04:40 +0200 Subject: [PATCH 29/35] Add a macro to check if a CMS global area is eligible for dynlink env. Signed-off-by: Irek Fakhrutdinov --- h/crossmemory.h | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/h/crossmemory.h b/h/crossmemory.h index 57f55f787..23d64b26d 100644 --- a/h/crossmemory.h +++ b/h/crossmemory.h @@ -565,7 +565,7 @@ CrossMemoryServerName cmsMakeServerName(const char *nameNullTerm); #if defined(METTLE) && defined(_LP64) -typedef CrossMemoryServerGlobalArea +typedef const CrossMemoryServerGlobalArea *CMSLookupFunction(const CrossMemoryServerName *name, int *reasonCode); #define RSN_CMSLOOKUP_OK 0 @@ -588,7 +588,7 @@ typedef CrossMemoryServerGlobalArea result = (CMSLookupFunction *)(*zvt)->cmsLookupRoutine; \ } \ result; \ -}); +}) typedef struct CMSDynlinkEnv_tag { char eyecatcher[8]; @@ -599,24 +599,41 @@ typedef struct CMSDynlinkEnv_tag { RLEAnchor dummyRLEAnchor; } CMSDynlinkEnv; +/** + * The macro checks whether the provided cross-memory server supports dynamic + * linkage. + * + * @parm[in] cmsGlobalArea The cross-memory global area. + * @return @c true if the cross-memory server supports dynamic linkage. + */ +#define CMS_DYNLINK_SUPPORTED(cmsGlobalArea) ({ \ + bool result = false; \ + if ((cmsGlobalArea)->userServerDynLinkVector != NULL) { \ + result = true; \ + } \ + result; \ +}) + /** * This macro establishes an environment in R12 which allows using the functions * provided by the dynamic linkage vector in the provided * @c CrossMemoryServerGlobalArea. * + * @parm[in] cmsGlobalArea The cross-memory global area. + * * IMPORTANT: * - R12 must be reserved in your Metal C application * - This must be used at the top level of your application * */ -#define CMS_SETUP_DYNLINK_ENV(cmsAnchorAddr) \ +#define CMS_SETUP_DYNLINK_ENV(cmsGlobalArea) \ CMSDynlinkEnv cmsDLEnv = { \ .eyecatcher = CMS_DYNLINK_ENV_EYECATCHER, \ }; \ cmsDLEnv.dummyCAA.rleTask = &cmsDLEnv.dummyRLETask; \ cmsDLEnv.dummyRLETask.anchor = &cmsDLEnv.dummyRLEAnchor; \ cmsDLEnv.dummyRLEAnchor.metalDynamicLinkageVector = \ - (cmsAnchorAddr)->userServerDynLinkVector; \ + (cmsGlobalArea)->userServerDynLinkVector; \ __asm(" LA 12,0(,%0) " : : "r"(&cmsDLEnv.dummyCAA) : ) #endif /* defined(METTLE) && defined(_LP64) */ From 90b71fb4c13923dcb1b086e6d5c093900a052dc8 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Tue, 30 Aug 2022 11:03:33 +0200 Subject: [PATCH 30/35] Clean up headers for dynamic linkage. - Make sure functions have 8-char aliases - Remove unused aliases - Remove unused declarations - Make undeclared functions static Signed-off-by: Irek Fakhrutdinov --- c/metalio.c | 3 --- c/utils.c | 6 ++--- h/alloc.h | 5 ++++ h/bpxnet.h | 65 ++++++++++++++++++++++++++++++++++--------------- h/collections.h | 27 +++++++++++++++++--- h/crossmemory.h | 4 ++- h/logging.h | 4 +++ h/metalio.h | 5 ++++ h/qsam.h | 25 ++++++++++++------- h/recovery.h | 1 - h/shrmem64.h | 2 +- h/timeutls.h | 21 ++++++++++------ h/utils.h | 29 +++++++++++++++++++--- h/vsam.h | 8 +++++- h/zos.h | 26 ++++++++++++++++++-- 15 files changed, 174 insertions(+), 57 deletions(-) diff --git a/c/metalio.c b/c/metalio.c index bb32c941e..320651e0e 100644 --- a/c/metalio.c +++ b/c/metalio.c @@ -240,9 +240,6 @@ int createNameTokenPair(int level, char *name, char *token){ return retcode; } -/* External function deleteNameTokenPair - code never referenced in metalio.c - and is not defined in metalio.h for use elsewhere. -*/ int deleteNameTokenPair(int level, char *name){ int persopt = NT_NOPERSIST; /* no persist */ int retcode; diff --git a/c/utils.c b/c/utils.c index 89f3c5475..a1feb7c6e 100644 --- a/c/utils.c +++ b/c/utils.c @@ -222,7 +222,7 @@ int indexOfStringInsensitive(char *str, int len, char *searchString, int startPo return -1; } -int upchar(char c){ +static int upchar(char c){ char low = (char)(c & 0xf); char high = (char)(c &0xf0); @@ -1424,14 +1424,14 @@ int base32Encode (int alphabet, } -ListElt *cons(void *data, ListElt *list){ +static ListElt *cons(void *data, ListElt *list){ ListElt *newList = (ListElt*)safeMalloc(sizeof(ListElt),"ListElt"); newList->data = data; newList->next = list; return newList; } -ListElt *cons64(void *data, ListElt *list){ +static ListElt *cons64(void *data, ListElt *list){ ListElt *newList = (ListElt*)safeMalloc(sizeof(ListElt),"ListElt"); newList->data = data; newList->next = list; diff --git a/h/alloc.h b/h/alloc.h index fa05a97ad..2c0cd081f 100644 --- a/h/alloc.h +++ b/h/alloc.h @@ -25,10 +25,13 @@ */ #ifndef __LONGNAME__ +#define malloc31 MALLOC31 +#define free31 FREE31 #define safeMalloc SAFEMLLC #define safeMalloc2 SAFEMLC2 #define safeMalloc31 SAFMLC31 #define safeMalloc31Key8 SAFMLC38 +#define safeFree SAFEFREE #define safeFree31 SAFFRE31 #define safeFree31Key8 SAFFRE38 #define safeFree64 SAFFRE64 @@ -39,6 +42,8 @@ #define safeMalloc64v2 SAMLC642 #define safeFree64v3 SAFRE643 #define safeMalloc64v3 SAMLC643 +#define allocECSA ALLCECSA +#define freeECSA FREEECSA #endif char *malloc31(int size); diff --git a/h/bpxnet.h b/h/bpxnet.h index 89b76ce07..272c77137 100644 --- a/h/bpxnet.h +++ b/h/bpxnet.h @@ -90,6 +90,50 @@ typedef struct socketAddr_tag{ ZOWE_PRAGMA_PACK_RESET +#ifndef __LONGNAME__ + +#define getLocalHostName GETLOCHN +#define getSocketDebugID GETSOCDI +#define getLocalHostAddress GETLOCAD +#define getAddressByName GETADRBN +#define getSocketName GETSOCNM +#define getSocketName2 GETSOCN2 +#define tcpClient TCPCLIE1 +#define getSocketOption GTSKTOPT +#define tcpClient2 TCPCLIE2 +#define tcpServer TCPSERVR +#define tcpClient3 TCPCLIE3 +#define tcpServer2 TCPSERV2 +#define makePipeBasedSyntheticSocket MAKSPSOC +#define bpxSleep BPXSLEEP +#define tcpIOControl TCPIOCTR +#define udpPeer UDPPEER +#define udpReceiveFrom UDPRECVF +#define udpSendTo UDPSENDT +#define makeSocketSet MAKSOCST +#define freeSocketSet FRESOCST +#define socketSetAdd SOCSTADD +#define socketSetRemove SOCSTREM +#define tcpStatus TCPSTTUS +#define socketRead SOCREAD +#define socketWrite SOCWRITE +#define setSocketTimeout SETSKTTO +#define setSocketNoDelay SETSKTND +#define setSocketWriteBufferSize SETSKTWB +#define setSocketReadBufferSize SETSKTRB +#define setSocketBlockingMode SETSOCBM +#define setSocketOption SETSKTOP +#define socketSend SOCKSEND +#define socketAccept SOCACCPT +#define socketClose SOCCLOSE +#define extendedSelect EXSELECT +#define makeSocketAddr MACSOCAD +#define makeSocketAddrIPv6 MACSOCA6 +#define freeSocketAddr FRESOCAD +#define socketFree SOCFREE + +#endif + #elif defined(__ZOWE_OS_WINDOWS) #include @@ -267,14 +311,10 @@ int getSocketName2(Socket *socket, SocketAddress *socketAddress); /* AKA getpeer Socket *tcpClient(SocketAddress *socketAddress, int *returnCode, int *reasonCode); -#define getSocketOption gtsktopt - int getSocketOption(Socket *socket, int optionName, int *optionDataLength, char *optionData, int *returnCode, int *reasonCode); -#define tcpClient2 tcpclie2 - -Socket *tcpClient2(SocketAddress *socketAddress, +Socket *tcpClient2(SocketAddress *socketAddress, int timeoutInMillis, int *returnCode, /* errnum */ int *reasonCode); /* errnum - JR's */ @@ -284,8 +324,6 @@ Socket *tcpServer(InetAddr *addr, /* usually NULL/0 */ int *returnCode, int *reasonCode); -#define tcpClient3 tcpclie3 - Socket *tcpClient3(SocketAddress *socketAddress, int timeoutInMillis, int tlsFlags, @@ -414,17 +452,6 @@ int socketRead(Socket *socket, char *buffer, int desiredBytes, int socketWrite(Socket *socket, const char *buffer, int desiredBytes, int *returnCode, int *reasonCode); -/* TBD: Not sure about guarding these defined with LONGNAME; shouldn't - a bunch of other functions also be given short aliases? */ -#ifndef __LONGNAME__ - -#define setSocketTimeout setsktto -#define setSocketNoDelay setsktnd -#define setSocketWriteBufferSize setsktwb -#define setSocketReadBufferSize setsktrb - -#endif - int setSocketTimeout(Socket *socket, int timeout, int *returnCode, int *reasonCode); @@ -434,8 +461,6 @@ int setSocketReadBufferSize(Socket *socket, int bufferSize, int *returnCode, in int setSocketBlockingMode(Socket *socket, int isNonBlocking, int *returnCode, int *reasonCode); -#define setSocketOption setsktop - int setSocketOption(Socket *socket, int level, int optionName, int optionDataLength, char *optionData, int *returnCode, int *reasonCode); diff --git a/h/collections.h b/h/collections.h index 83be11c77..eceb60290 100644 --- a/h/collections.h +++ b/h/collections.h @@ -32,31 +32,50 @@ #define fbMgrFree FBMGRFRE #define fbMgrDestroy FBMGRDST -#define htDestroy HTDSTROY -#define htUIntPut HTUINTPT -#define htUIntGet HTUINTGT +#define htCreate HTCREATE +#define htAlter HTALTER +#define htGet HTGET #define htIntGet HTINTGET +#define htPut HTPUT #define htIntPut HTINTPUT +#define htUIntPut HTUINTPT +#define htUIntGet HTUINTGT +#define htRemove HTREMOVE +#define htMap HTMAP +#define htMap2 HTMAP2 +#define htPrune HTPRUNE #define htDestroy HTDSTROY +#define htCount HTCOUNT #define stringHash STRNGHSH #define stringCompare STRNGCMP #define makeLRUCache MKLRUCHE #define destroyLRUCache DSLRUCHE +#define lruGet LRUGET +#define lruStore LRUSTORE #define lhtCreate LNHTCRTE +#define lhtAlter LNHTALTR #define lhtDestroy LNHDSTRY +#define lhtGet LNHTGET +#define lhtPut LNHTPUT #define lhtRemove LNHTREMV +#define lhtMap LNHTMAP #define makeQueue MAKELCFQ #define destroyQueue DSTRLCFQ +#define qEnqueue QENQUEUE +#define qDequeue QDEQUEUE +#define qInsert QINSERT +#define qRemove QREMOVE #define makeArrayList ALSTMAKE +#define arrayListFree ALSTFREE #define arrayListAdd ALSTADD #define arrayListElement ALSTELMT +#define initEmbeddedArrayList ALINEMAR #define arrayListSort ALSTSORT #define arrayListShallowCopy ALSHLCPY -#define initEmbbededArrayList ALINEMAR #endif diff --git a/h/crossmemory.h b/h/crossmemory.h index 23d64b26d..6fe0bad9e 100644 --- a/h/crossmemory.h +++ b/h/crossmemory.h @@ -415,11 +415,13 @@ ZOWE_PRAGMA_PACK_RESET #define cmsStartMainLoop CMCMAINL #define cmsGetGlobalArea CMGETGA #define cmsAddConfigParm CMADDPRM +#define cmsTestAuth CMTSAUTH #define cmsCallService CMCMSRCS #define cmsCallService2 CMCALLS2 #define cmsCallService3 CMCALLS3 #define cmsPrintf CMCMSPRF -#define vcmsPrintf CMCMSVPF +#define vcmsPrintf CMCMSVPF +#define cmsHexDump CMHEXDMP #define cmsGetConfigParm CMGETPRM #define cmsGetConfigParmUnchecked CMGETPRU #define cmsGetPCLogLevel CMGETLOG diff --git a/h/logging.h b/h/logging.h index 3d4f71c26..1d7654f71 100644 --- a/h/logging.h +++ b/h/logging.h @@ -254,10 +254,14 @@ extern LoggingContext *theLoggingContext; #define removeLocalLoggingContext RMLLGCTX #define getLoggingContext GTLOGCTX #define setLoggingContext STLOGCTX +#define zowelog ZOWELOG +#define zowedump ZOWEDUMP #define logConfigureDestination LGCFGDST #define logConfigureDestination2 LGCFGDS2 #define logConfigureStandardDestinations LGCFGSTD #define logConfigureComponent LGCFGCMP +#define logSetLevel LGSETLVL +#define logGetLevel LGGETLVL #define logShouldTraceInternal LGSHTRCE #define logGetExternalContext LGGLOGCX #define logSetExternalContext LGSLOGCX diff --git a/h/metalio.h b/h/metalio.h index 2e1c8b59a..7429f550a 100644 --- a/h/metalio.h +++ b/h/metalio.h @@ -147,6 +147,7 @@ typedef int ntFunction(); ntFunction **getNameTokenFunctionTable(); int getNameTokenValue(int level, char *name, char *token); int createNameTokenPair(int level, char *name, char *token); +int deleteNameTokenPair(int level, char *name); typedef struct SYSOUT_struct{ char * __ptr32 dcb; @@ -166,6 +167,10 @@ typedef struct SYSOUT_struct{ #define authWTOPrintf AWTOPRNF #define sendWTO SENDWTO #define qsamPrintf QSAMPRNF +#define printf PRINTF +#define fflush FFLUSH +#define setjmp SETJMP +#define longjmp LONGJMP #endif SYSOUT *getSYSOUTStruct(char *ddname, SYSOUT *existingSysout, char *buffer); diff --git a/h/qsam.h b/h/qsam.h index 19c9634d2..8abd0e1bb 100644 --- a/h/qsam.h +++ b/h/qsam.h @@ -16,23 +16,30 @@ #ifndef __LONGNAME__ -#define hasVaryingRecordLength HASVRLEN -#define makeQSAMBuffer MKQSMBUF -#define freeQSAMBuffer FRQSMBUF -#define putlineV PUTLNEV -#define getlineV GETLNEV -#define getEODADBuffer GTEODBUF -#define freeEODADBuffer FREODBUF +#define malloc24 MALLOC24 +#define openSAM OPENSAM #define getSAMLength GTSAMLN #define getSAMBlksize GTSAMBS #define getSAMLrecl GTSAMLR #define getSAMCC GTSAMCC #define getSAMRecfm GTSAMRF +#define putline PUTLINE +#define getline GETLINE +#define getEODADBuffer GTEODBUF +#define freeEODADBuffer FREODBUF +#define getline2 GETLINE2 +#define makeQSAMBuffer MKQSMBUF +#define freeQSAMBuffer FRQSMBUF +#define putlineV PUTLNEV +#define getlineV GETLNEV +#define closeSAM CLOSESAM +#define openEXCP OPENEXCP +#define closeEXCP CLOSEXCP +#define hasVaryingRecordLength HASVRLEN +#define bpamDeleteMember BPAMDELM #define bpamFind BPAMFIND #define bpamRead BPAMREAD #define bpamRead2 BPAMRD2 -#define openEXCP OPENEXCP -#define closeEXCP CLOSEXCP #endif diff --git a/h/recovery.h b/h/recovery.h index fc131e241..576f45799 100644 --- a/h/recovery.h +++ b/h/recovery.h @@ -350,7 +350,6 @@ typedef struct RecoveryContext_tag { #define recoveryUpdateRouterServiceInfo RCVRURSI #define recoveryUpdateStateServiceInfo RCVRUSSI #define recoveryGetABENDCode RCVRGACD -#define runFunctioninESTAE RCVRNFNE #endif #ifdef __ZOWE_OS_ZOS diff --git a/h/shrmem64.h b/h/shrmem64.h index fd5c389da..5ae3f84c6 100644 --- a/h/shrmem64.h +++ b/h/shrmem64.h @@ -36,7 +36,7 @@ #define shrmem64ReleaseAll SHR64REA #define shrmem64GetAccess SHR64GAC -#define shrmem64GetAccess SHR64GA2 +#define shrmem64GetAccess2 SHR64GA2 #define shrmem64RemoveAccess SHR64RAC #define shrmem64RemoveAccess2 SHR64RA2 diff --git a/h/timeutls.h b/h/timeutls.h index ec3342f5f..a76f62f45 100644 --- a/h/timeutls.h +++ b/h/timeutls.h @@ -43,15 +43,20 @@ typedef struct dayMonth { } dayStamp; #ifndef __LONGNAME__ -#define convertTODToLocal convtodl -#define stckToTimestamp stckconv -#define timestampToSTCK convtod -#define timeFromMidnight midnight +#define getSTCK GETSTCK +#define getSTCKU GETSTCKU +#define convertTODToLocal CONVTODL +#define timeZoneDifferenceFor TZDIFFOR +#define stckToTimestamp STCKCONV +#define timestampToSTCK CONVTOD +#define timeFromMidnight MIDNIGHT #define stckFromYYYYMMDD STCKYYMD -#define elapsedTime elpstime -#define stckToUnix stckUnix -#define unixToTimestamp convunix -#define getDayAndMonth gtdaymnt +#define elapsedTime ELPSTIME +#define stckToUnix STCKUNIX +#define stckToUnixSecondsAndMicros STCK2USM +#define unixToTimestamp CONVUNIX +#define getDayAndMonth GTDAYMNT +#define snprintLocalTime SNPRNTLT #endif /* diff --git a/h/utils.h b/h/utils.h index 778ead6c0..d131c9716 100644 --- a/h/utils.h +++ b/h/utils.h @@ -32,7 +32,12 @@ extern "C" { #define indexOf INDEXOF #define indexOfString IDXSTR #define lastIndexOfString LIDXSTR +#define lastIndexOf LINDEXOF #define indexOfStringInsensitive IDXSTRNS +#define isZeros ISZEROS +#define isBlanks ISBLANKS +#define hasText HASTEXT +#define parseInt PARSEINT #endif char * strcopy_safe(char * dest, const char * source, int dest_size); @@ -69,6 +74,7 @@ int parseInt(const char *str, int start, int end); #ifndef __LONGNAME__ #define parseInitialInt PSINTINT #define nullTerminate NULLTERM +#define isCharAN ISCHARAN #define tknGetDecimal TKGTDCML #define tknGetQuoted TKGTQOTD #define tknGetAlphanumeric TKGTANUM @@ -77,6 +83,8 @@ int parseInt(const char *str, int start, int end); #define tknGetTerminating TKGTTERM #define tknTextEquals TKTXEQLS #define freeToken FREETKN +#define tknText TKNTEXT +#define tknInt TKNINT #define tknLength TKNLNGTH #endif @@ -111,9 +119,11 @@ int tknLength(token *t); #ifndef __LONGNAME__ #define dumpbuffer DMPBUFFR #define dumpbufferA DMPBUFFA +#define hexFill HEXFILL #define simpleHexFill SMPHXFIL #define simpleHexPrint SMPHXPRT #define simpleHexPrintLower SMPHXPRL +#define hexdump HEXDUMP #define dumpbuffer2 DMPBFFR2 #define dumpBufferToStream DMPBFFRS #define compareIgnoringCase CMPIGNCS @@ -159,8 +169,6 @@ typedef struct ListElt_tag { struct ListElt_tag *next; } ListElt; -ListElt *cons(void *data, ListElt *list); - /** * \brief The ShortLivedHeap is a memory manager for large numbers of small allocations followed by a single bulk deallocation, * @@ -183,11 +191,17 @@ typedef struct ShortLivedHeap_tag{ #ifndef __LONGNAME__ #define makeShortLivedHeap MAKESLH #define makeShortLivedHeap64 MAKSLH64 +#define SLHAlloc SLHALLOC +#define SLHFree SLHFREE #define noisyMalloc NYMALLOC #define base32Encode DECODB32 #define base32Decode ENCODB32 #define decodeBase64 DECODB64 +#define decodeBase64Unterminated DECDB64U #define encodeBase64 ENCODB64 +#define encodeBase64NoAlloc ENCDB64N +#define base64ToBase64url B642BURL +#define base64urlToBase64 B64URLTB #define cleanURLParamValue CLNURLPV #define percentEncode PCTENCOD #define destructivelyUnasciify DSTUNASC @@ -366,10 +380,19 @@ void charStreamFree(CharStream *s); #define SEQ_LESS -1 #define SEQ_ERROR 4 +#ifndef __LONGNAME__ #define padWithSpaces padwspcs #define replaceTerminateNulls rpltrmnl #define convertIntToString cnvintst +#define hexToDec HEXTODEC +#define decToHex DECTOHEX #define compareSequences compseqs +#define decimalToOctal DEC2OCT +#define convertUnixToISO UNX2ISO +#define matchWithWildcards MATCHWLD +#define stringIsDigit STRISDIG +#define trimRight TRMRIGHT +#endif int padWithSpaces(char *str, int actualLength, @@ -412,11 +435,9 @@ void trimRight(char *str, int length); #endif #ifndef __LONGNAME__ -#define isLowerCasePasswordAllowed ISLWCPWD #define isPassPhrase ISPASPHR #endif -int isLowerCasePasswordAllowed(); bool isPassPhrase(const char *password); #endif diff --git a/h/vsam.h b/h/vsam.h index 983c1e982..e588aa899 100644 --- a/h/vsam.h +++ b/h/vsam.h @@ -319,8 +319,13 @@ typedef struct linkDDNames{ ZOWE_PRAGMA_PACK_RESET - +#ifndef __LONGNAME__ +#define makeACB MAKEACB #define opencloseACB VOPCLACB +#define openACB OPENACB +#define closeACB CLOSEACB +#define modRPL MODRPL +#define point VSPOINT #define putRecord VPUTREC #define getRecord VGETREC #define makeDataBuffer VMKDBUFF @@ -332,6 +337,7 @@ ZOWE_PRAGMA_PACK_RESET #define allocateDataset VALLOCDS #define defineAIX VDEFAIX #define deleteCluster DELCLUST +#endif char *makeACB(char *ddname,int acbLen,int macrf1,int macrf2,int rplSubint,int rplType,int rplLen,int keyLen,int opCode1,int opCode2,int recLen,int bufLen); int opencloseACB(char *acb, int mode, int svc); diff --git a/h/zos.h b/h/zos.h index b19f07ab4..208dd6b0d 100644 --- a/h/zos.h +++ b/h/zos.h @@ -15,7 +15,9 @@ #ifndef __LONGNAME__ +#define extractPSW EXTRPSW #define supervisorMode SUPRMODE +#define setKey SETKEY #define ddnameExists DDEXISTS #define atomicIncrement ATOMINCR @@ -24,20 +26,32 @@ #define getParentTCB GTPRTTCB #define getNextSiblingTCB GTNXSTCB -#define getCVTPrefix GETCVTPR +#define getCVT GETCVT +#define getATCVT GETATCVT #define getIEACSTBL GETCSTBL +#define getCVTPrefix GETCVTPR +#define getECVT GETECVT +#define getTCB GETTCB +#define getSTCB GETSTCB +#define getOTCB GETOTCB +#define getASCB GETASCB +#define getASXB GETASXB +#define getASSB GETASSB +#define getJSAB GETJSAB #define getSysplexName GTSPLXNM #define getSystemName GTSYSTNM +#define getDSAB GETDSAB #define dsabIsOMVS DSABOMVS +#define locate LOCATE #define getR13 GETR13 #define getR12 GETR12 #define getASCBJobname GETASCBJ -#define loadByName LOADBYNAM +#define loadByName LOADBYNA #define loadByNameLocally LOADBNML #define isCallerLocked ZOSCLCKD @@ -1430,6 +1444,8 @@ int locate(char *dsn, int *volserCount, char *firstVolser); #define VERIFY_CHANGE 0x10 #define VERIFY_SUPERVISOR 0x01 /* perform check in supervisor mode */ +#ifndef __LONGNAME__ + #define getAddressSpaceAcee GADSACEE #define getTaskAcee GTSKACEE #define setTaskAcee STSKACEE @@ -1442,6 +1458,12 @@ int locate(char *dsn, int *volserCount, char *firstVolser); #define safVerify6 SAFVRFY6 #define safVerify7 SAFVRFY7 +#define safAuth SAFAUTH +#define safAuthStatus SAFAUTHS +#define safStat SAFSTAT +#define getSafProfileMaxLen GETSAFPL + +#endif ACEE *getAddressSpaceAcee(void); ACEE *getTaskAcee(void); From 29015757027cedd9f5bdfe307bc8f0e0bc0657c3 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Fri, 2 Sep 2022 14:14:16 +0200 Subject: [PATCH 31/35] Revert the aliases which could affect backward compatibility. Some aliases were moved to __LONGNAME__ blocks which can affect ZSS plugins built with older headers and which are used with a newer ZSS. Additionally, some aliases which were made all caps, have been reverted due to the same potential issue with ZSS plugins. Signed-off-by: Irek Fakhrutdinov --- h/bpxnet.h | 12 ++++++++---- h/lpa.h | 2 -- h/utils.h | 9 +++++---- h/vsam.h | 12 +++++------- h/zos.h | 4 ++-- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/h/bpxnet.h b/h/bpxnet.h index 272c77137..ea3b58dc7 100644 --- a/h/bpxnet.h +++ b/h/bpxnet.h @@ -96,13 +96,10 @@ ZOWE_PRAGMA_PACK_RESET #define getSocketDebugID GETSOCDI #define getLocalHostAddress GETLOCAD #define getAddressByName GETADRBN -#define getSocketName GETSOCNM #define getSocketName2 GETSOCN2 #define tcpClient TCPCLIE1 #define getSocketOption GTSKTOPT -#define tcpClient2 TCPCLIE2 #define tcpServer TCPSERVR -#define tcpClient3 TCPCLIE3 #define tcpServer2 TCPSERV2 #define makePipeBasedSyntheticSocket MAKSPSOC #define bpxSleep BPXSLEEP @@ -122,7 +119,6 @@ ZOWE_PRAGMA_PACK_RESET #define setSocketWriteBufferSize SETSKTWB #define setSocketReadBufferSize SETSKTRB #define setSocketBlockingMode SETSOCBM -#define setSocketOption SETSKTOP #define socketSend SOCKSEND #define socketAccept SOCACCPT #define socketClose SOCCLOSE @@ -311,9 +307,13 @@ int getSocketName2(Socket *socket, SocketAddress *socketAddress); /* AKA getpeer Socket *tcpClient(SocketAddress *socketAddress, int *returnCode, int *reasonCode); +#define getSocketOption gtsktopt + int getSocketOption(Socket *socket, int optionName, int *optionDataLength, char *optionData, int *returnCode, int *reasonCode); +#define tcpClient2 tcpclie2 + Socket *tcpClient2(SocketAddress *socketAddress, int timeoutInMillis, int *returnCode, /* errnum */ @@ -324,6 +324,8 @@ Socket *tcpServer(InetAddr *addr, /* usually NULL/0 */ int *returnCode, int *reasonCode); +#define tcpClient3 tcpclie3 + Socket *tcpClient3(SocketAddress *socketAddress, int timeoutInMillis, int tlsFlags, @@ -461,6 +463,8 @@ int setSocketReadBufferSize(Socket *socket, int bufferSize, int *returnCode, in int setSocketBlockingMode(Socket *socket, int isNonBlocking, int *returnCode, int *reasonCode); +#define setSocketOption setsktop + int setSocketOption(Socket *socket, int level, int optionName, int optionDataLength, char *optionData, int *returnCode, int *reasonCode); diff --git a/h/lpa.h b/h/lpa.h index 656b4de75..9446b988a 100644 --- a/h/lpa.h +++ b/h/lpa.h @@ -71,10 +71,8 @@ typedef struct LPMED_tag { ZOWE_PRAGMA_PACK_RESET -#ifndef __LONGNAME__ #pragma map(lpaAdd, "LPAADD") #pragma map(lpaDelete, "LPADEL") -#endif int lpaAdd(LPMEA * __ptr32 lpmea, EightCharString * __ptr32 ddname, diff --git a/h/utils.h b/h/utils.h index d131c9716..6b7094b4a 100644 --- a/h/utils.h +++ b/h/utils.h @@ -380,13 +380,14 @@ void charStreamFree(CharStream *s); #define SEQ_LESS -1 #define SEQ_ERROR 4 -#ifndef __LONGNAME__ #define padWithSpaces padwspcs #define replaceTerminateNulls rpltrmnl #define convertIntToString cnvintst +#define compareSequences compseqs + +#ifndef __LONGNAME__ #define hexToDec HEXTODEC #define decToHex DECTOHEX -#define compareSequences compseqs #define decimalToOctal DEC2OCT #define convertUnixToISO UNX2ISO #define matchWithWildcards MATCHWLD @@ -430,9 +431,9 @@ const char* strrstr(const char * base, const char * find); void trimRight(char *str, int length); -#if defined(__cplusplus) +#if defined(__cplusplus) } /* end of extern "C" */ -#endif +#endif #ifndef __LONGNAME__ #define isPassPhrase ISPASPHR diff --git a/h/vsam.h b/h/vsam.h index e588aa899..75d3dc508 100644 --- a/h/vsam.h +++ b/h/vsam.h @@ -319,13 +319,12 @@ typedef struct linkDDNames{ ZOWE_PRAGMA_PACK_RESET -#ifndef __LONGNAME__ -#define makeACB MAKEACB +#define makeACB makeACB #define opencloseACB VOPCLACB -#define openACB OPENACB -#define closeACB CLOSEACB -#define modRPL MODRPL -#define point VSPOINT +#define openACB openACB +#define closeACB closeACB +#define modRPL modRPL +#define point point #define putRecord VPUTREC #define getRecord VGETREC #define makeDataBuffer VMKDBUFF @@ -337,7 +336,6 @@ ZOWE_PRAGMA_PACK_RESET #define allocateDataset VALLOCDS #define defineAIX VDEFAIX #define deleteCluster DELCLUST -#endif char *makeACB(char *ddname,int acbLen,int macrf1,int macrf2,int rplSubint,int rplType,int rplLen,int keyLen,int opCode1,int opCode2,int recLen,int bufLen); int opencloseACB(char *acb, int mode, int svc); diff --git a/h/zos.h b/h/zos.h index 208dd6b0d..454c0220e 100644 --- a/h/zos.h +++ b/h/zos.h @@ -1444,8 +1444,6 @@ int locate(char *dsn, int *volserCount, char *firstVolser); #define VERIFY_CHANGE 0x10 #define VERIFY_SUPERVISOR 0x01 /* perform check in supervisor mode */ -#ifndef __LONGNAME__ - #define getAddressSpaceAcee GADSACEE #define getTaskAcee GTSKACEE #define setTaskAcee STSKACEE @@ -1458,6 +1456,8 @@ int locate(char *dsn, int *volserCount, char *firstVolser); #define safVerify6 SAFVRFY6 #define safVerify7 SAFVRFY7 +#ifndef __LONGNAME__ + #define safAuth SAFAUTH #define safAuthStatus SAFAUTHS #define safStat SAFSTAT From cad709327a08e3d55fdd7be758408217bd79bc11 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Mon, 5 Sep 2022 07:56:49 +0200 Subject: [PATCH 32/35] Fix an incorrect pragma map in radmin. Signed-off-by: Irek Fakhrutdinov --- h/radmin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h/radmin.h b/h/radmin.h index cef6c4aaa..44755d866 100644 --- a/h/radmin.h +++ b/h/radmin.h @@ -266,7 +266,7 @@ typedef struct RadminStatus_tag { * Specific wrapper data structures and definitions. */ -#pragma map(radminExtractUserProfiles, "RADMXUP") +#pragma map(radminExtractProfiles, "RADMXPRF") #pragma map(radminExtractBasicUserProfileInfo, "RADMXBUP") #pragma map(radminExtractBasicGenresProfileInfo, "RADMXBRP") #pragma map(radminExtractBasicGroupProfileInfo, "RADMXBGP") From 7693736c5d3a981708bacfed9cb1ff390db0530b Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Wed, 7 Sep 2022 09:34:02 +0200 Subject: [PATCH 33/35] Revert the changes initLogMessagePrefix but also keep clangd happy. The conversion of %08X to %8p led to removal of the leading zeroes in the ZIS log. Signed-off-by: Irek Fakhrutdinov --- c/crossmemory.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/c/crossmemory.c b/c/crossmemory.c index 1f3386a30..973dfc47a 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -602,7 +602,16 @@ static void initLogMessagePrefix(LogMessagePrefix *prefix) { ASCB *ascb = getASCB(); char *jobName = getASCBJobname(ascb); TCB *tcb = getTCB(); - snprintf(prefix->text, sizeof(prefix->text), "%22.22s %8.8s %8p(%04X) %8p ", currentTime.text, jobName, ascb, ascb->ascbasid, tcb); +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpointer-to-int-cast" +#endif + snprintf(prefix->text, sizeof(prefix->text), "%22.22s %8.8s %08X(%04X) %08X ", + currentTime.text, jobName, (unsigned) ascb, ascb->ascbasid, + (unsigned) tcb); +#if defined(__clang__) +#pragma clang diagnostic pop +#endif prefix->text[sizeof(prefix->text) - 1] = ' '; } From 542c771f2a09a411bbe42f857eb44c630ba97bba Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Sun, 2 Oct 2022 12:01:29 -0400 Subject: [PATCH 34/35] Added missing Any function headers from configmgr Signed-off-by: 1000TurquoisePogs --- c/configmgr.c | 24 ++++++++++++------------ h/configmgr.h | 5 +++++ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/c/configmgr.c b/c/configmgr.c index 0fd9ed130..1bf415f74 100644 --- a/c/configmgr.c +++ b/c/configmgr.c @@ -948,8 +948,8 @@ static Json *varargsDereference(Json *json, int argCount, va_list args, int *err } int arraySize = jsonArrayGetCount(array); if (index >= arraySize){ - *errorReason = JSON_POINTER_ARRAY_INDEX_OUT_OF_BOUNDS; - return NULL; + *errorReason = JSON_POINTER_ARRAY_INDEX_OUT_OF_BOUNDS; + return NULL; } value = jsonArrayGetItem(array,index); } else if (jsonIsObject(value)){ @@ -961,19 +961,19 @@ static Json *varargsDereference(Json *json, int argCount, va_list args, int *err } Json *newValue = jsonObjectGetPropertyValue(object,key); if (newValue == NULL){ - if (traceLevel >= 2){ - jsonObjectGetPropertyValueLoud(object,key); - jsonPrinter *p = makeJsonPrinter(stdoutFD()); - jsonEnablePrettyPrint(p); - jsonPrint(p,value); - printf("\n"); - jsonDumpObj(object); - fflush(stdout); - } + if (traceLevel >= 2){ + jsonObjectGetPropertyValueLoud(object,key); + jsonPrinter *p = makeJsonPrinter(stdoutFD()); + jsonEnablePrettyPrint(p); + jsonPrint(p,value); + printf("\n"); + jsonDumpObj(object); + fflush(stdout); + } *errorReason = JSON_POINTER_TOO_DEEP; return NULL; } else{ - value = newValue; + value = newValue; } } else { if (traceLevel >= 1){ diff --git a/h/configmgr.h b/h/configmgr.h index b38601629..ae5a932fb 100644 --- a/h/configmgr.h +++ b/h/configmgr.h @@ -73,11 +73,16 @@ int loadConfigurations(ConfigManager *mgr, const char *configName); /* Json-oriented value getters */ int cfgGetStringJ(ConfigManager *mgr, const char *configName, char **result, JsonPointer *jp); +int cfgGetAnyJ(ConfigManager *mgr, const char *configName, Json **result, JsonPointer *jp); /* Convenience getters for C Programmers, that don't require building paths, string allocation, etc */ int cfgGetIntC(ConfigManager *mgr, const char *configName, int *result, int argCount, ...); int cfgGetBooleanC(ConfigManager *mgr, const char *configName, bool *result, int argCount, ...); +/* returns JUST a Json, in case you need to get something we havent written a convenience for. */ +/* if you need to get for example an int array, you CAN use a path with "0" to get index 0. */ +int cfgGetAnyC(ConfigManager *mgr, const char *configName, Json **result, JsonPointer *jp); + /** result is null-terminated, when set, and not a copy */ int cfgGetStringC(ConfigManager *mgr, const char *configName, char **result, int argCount, ...); From ab5cf10a4421c25671300f59fc958fe4d237d8c4 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Sun, 2 Oct 2022 12:08:39 -0400 Subject: [PATCH 35/35] Added missing Any function headers from configmgr Signed-off-by: 1000TurquoisePogs --- h/configmgr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h/configmgr.h b/h/configmgr.h index ae5a932fb..008233302 100644 --- a/h/configmgr.h +++ b/h/configmgr.h @@ -81,7 +81,7 @@ int cfgGetIntC(ConfigManager *mgr, const char *configName, int *result, int argC int cfgGetBooleanC(ConfigManager *mgr, const char *configName, bool *result, int argCount, ...); /* returns JUST a Json, in case you need to get something we havent written a convenience for. */ /* if you need to get for example an int array, you CAN use a path with "0" to get index 0. */ -int cfgGetAnyC(ConfigManager *mgr, const char *configName, Json **result, JsonPointer *jp); +int cfgGetAnyC(ConfigManager *mgr, const char *configName, Json **result, int argCount, ...); /** result is null-terminated, when set, and not a copy */