From f04974b93176ab7cfe1f237289d6c4fee25eebc2 Mon Sep 17 00:00:00 2001 From: Joe Devlin Date: Fri, 29 May 2020 14:13:07 -0500 Subject: [PATCH 01/33] First changes for zss64 project Signed-off-by: Joe Devlin --- c/discovery.c | 22 +++ c/httpserver.c | 13 +- c/radmin.c | 412 ++++++++++++++++++++++++++++++++---------------- c/recovery.c | 37 +++-- c/scheduling.c | 1 + c/shrmem64.c | 7 +- c/zos.c | 2 +- c/zosfile.c | 7 +- h/crossmemory.h | 1 - h/radmin.h | 6 +- h/recovery.h | 3 + h/zos.h | 261 +++++++++++++++++++++++++----- 12 files changed, 570 insertions(+), 202 deletions(-) diff --git a/c/discovery.c b/c/discovery.c index 5e6f9eecd..19263f9b0 100644 --- a/c/discovery.c +++ b/c/discovery.c @@ -97,6 +97,7 @@ DiscoveryContext *makeDiscoveryContext(ShortLivedHeap *outerSLH, ZOSModel *model context->slh = slh; context->model = model; + printf("mDCntxt() model=0x%x pSN=0x%x\n",model,model->privilegedServerName); if (model != NULL) { context->privilegedServerName = model->privilegedServerName; } else { @@ -315,6 +316,25 @@ static int walkTCBs1(DiscoveryContext *context, return 0; } + +int walkTCBs(DiscoveryContext *context, + ASCB *ascb, + TCB *tcb, + void (*visitor)(DiscoveryContext *discoveryContext, + void *visitorContext, + int depth, + ASCB *ascb, + TCB *tcb, + char *mustBeNull), + void *visitorContext){ + if (ascb){ + ASXB *asxb = (ASXB*)ascb->ascbasxb; + TCB *firstTCB = (TCB*)getStructCopy(context,ascb,0,asxb->asxbftcb,sizeof(TCB)); + walkTCBs1(context,ascb,firstTCB,(TCB*)ANY_TCB,0,visitor,visitorContext,NULL); + } +} + + static void visitSSCTEntry(DiscoveryContext *context, SSCT *ssctChain, GDA *gda, int subsystemTypeMask, char *specificBestName){ @@ -900,7 +920,9 @@ ZOSModel *makeZOSModel2(CrossMemoryServerName *privilegedServerName, model->slowScanExpiry = DEFAULT_SSCT_INTERVAL; if (privilegedServerName != NULL) { + printf("makeZOSModel case 1 0x%x\n",privilegedServerName); model->privilegedServerName = *privilegedServerName; + dumpbuffer(&(model->privilegedServerName),16); } else { model->privilegedServerName = zisGetDefaultServerName(); } diff --git a/c/httpserver.c b/c/httpserver.c index 98e9856c9..6676616d3 100644 --- a/c/httpserver.c +++ b/c/httpserver.c @@ -2493,6 +2493,7 @@ static bool isPassPhrase(const char *password) { #ifdef __ZOWE_OS_ZOS static int safAuthenticate(HttpService *service, HttpRequest *request, AuthResponse *authResponse){ + printf("safAuthenticate: HTTP request 0x%p\n",request); int safStatus = 0, racfStatus = 0, racfReason = 0; int options = VERIFY_CREATE; int authDataFound = FALSE; @@ -2571,7 +2572,8 @@ static int safAuthenticate(HttpService *service, HttpRequest *request, AuthRespo static int nativeAuth(HttpService *service, HttpRequest *request, AuthResponse *authResponse){ #ifdef __ZOWE_OS_ZOS - return safAuthenticate(service, request, authResponse); + printf("nativeAuth about to bless this request 0x%p\n",request); + return TRUE; /* safAuthenticate(service, request, authResponse); */ #else #ifdef DEBUG_AUTH printf("*** ERROR *** native auth not implemented for this platform\n"); @@ -3394,11 +3396,11 @@ static int handleHttpService(HttpServer *server, service->server = server; int clearSessionToken = FALSE; - AuthResponse authResponse; - switch (service->authType){ - + int authTypeHack = service->authType; + authTypeHack = SERVICE_AUTH_NONE; + switch (authTypeHack){ case SERVICE_AUTH_NONE: request->authenticated = TRUE; break; @@ -3446,6 +3448,9 @@ static int handleHttpService(HttpServer *server, respondWithAuthError(response, &authResponse); } // Response is finished on return +#define IGNORE_IMPERSONATION 1 + } else if (IGNORE_IMPERSONATION){ + serveRequest(service, response, request); } else { int impersonating = startImpersonating(service, request); diff --git a/c/radmin.c b/c/radmin.c index f722a8ac2..06145d06b 100644 --- a/c/radmin.c +++ b/c/radmin.c @@ -3,7 +3,7 @@ /* 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 + this distribution, and is available at www.eclipse.org/legal/epl-v20.html SPDX-License-Identifier: EPL-2.0 @@ -40,13 +40,11 @@ #include "utils.h" #ifndef METTLE - #ifdef _LP64 - #error Metal C 31/64-bit and LE 31-bit are supported only - #endif -#endif - -#ifndef METTLE +#ifdef _LP64 #pragma linkage(IRRSEQ00, OS) +#else +#pragma linkage(IRRSEQ00, OS) +#endif #endif #pragma enum(1) @@ -88,7 +86,7 @@ typedef enum RadminFunctionCode_tag { } RadminFunctionCode; #pragma enum(reset) -typedef char RadminWorkArea[1024]; +#define RADMIN_WORK_AREA_SIZE 1024 typedef void RadminParmList; #ifdef RADMIN_XMEM_MODE @@ -136,8 +134,21 @@ static void freeXTROutput(RadminXTROutput *data) { data = NULL; } +/* + linkage + CSRTABLE has some well known slots, is IRRSEQ00 in there?? + + CVT+0x220 (544) is the CSR table (CVTCSRT) + + 0x18 CSR slot (BPX services) + 0x28 RACF (IRR) slot + 0x48 GXL XML services + + */ + + int IRRSEQ00( - RadminWorkArea * __ptr32 workArea, + char * __ptr32 workArea, int32_t * __ptr32 safReturnCodeALET, int32_t * __ptr32 safReturnCode, int32_t * __ptr32 racfReturnCodeALET, int32_t * __ptr32 racfReturnCode, int32_t * __ptr32 racfReasonCodeALET, int32_t * __ptr32 racfReasonCode, @@ -145,31 +156,99 @@ int IRRSEQ00( RadminParmList * __ptr32 parmList, RadminUserID * __ptr32 userID, ACEE * __ptr32 * __ptr32 acee, - int8_t * __ptr32 outMessageSubpool, - void * __ptr32 * __ptr32 outMessage + uint8_t * __ptr32 outMessageSubpool, + void * __ptr32 * __ptr32 outMessage) #ifdef METTLE -) __attribute__((amode31)); +__attribute__((amode31)); #else -); +; #endif -static void invokeRadmin( - RadminWorkArea * __ptr32 workArea, - int32_t * __ptr32 safReturnCodeALET, int32_t * __ptr32 safReturnCode, - int32_t * __ptr32 racfReturnCodeALET, int32_t * __ptr32 racfReturnCode, - int32_t * __ptr32 racfReasonCodeALET, int32_t * __ptr32 racfReasonCode, - RadminFunctionCode * __ptr32 functionCode, - RadminParmList * __ptr32 parmList, - RadminUserID * __ptr32 userID, - ACEE * __ptr32 * __ptr32 acee, - int8_t * __ptr32 resultSubpool, - void * __ptr32 * __ptr32 result +#define DATA31_LENGTH 16 + +typedef struct IRRSEQ00Arguments_tag{ + char * __ptr32 workArea; + int32_t * __ptr32 safReturnCodeALET; + int32_t * __ptr32 safReturnCode; + int32_t * __ptr32 racfReturnCodeALET; + int32_t * __ptr32 racfReturnCode; + int32_t * __ptr32 racfReasonCodeALET; + int32_t * __ptr32 racfReasonCode; + RadminFunctionCode * __ptr32 functionCode; + RadminParmList * __ptr32 parmList; + RadminUserID * __ptr32 userID; + ACEE * __ptr32 * __ptr32 acee; + uint8_t * __ptr32 outMessageSubpool; + int outMessage; /* it's really a handle, but the VL bit and other issues just make this too annoying */ + +} IRRSEQ00Arguments; + + /* + IRRSEQ00( + workArea, + &(status->alet), &(status->safRC), + &(status->alet), &(status->racfRC), + &(status->alet), &(status->racfRSN), + functionCodeBox, + parmList, + &(callerAuthInfo->userID), + &(callerAuthInfo->acee), + subpoolBox, + resultPtr + ); +...i...0.........0..... +400280005F015F025F021F5F000F +1007900280008F208F08E08F007F +LA 0,X'27' +SLL 0,2 +L 15,10(,0) +L 15,X'220'(,15) +L 15,X'28'(15) +AHI 15,X'9C' +L 15,0(,15) +BASR 14,15 + */ + + +/* The result doesn't need to be a 32-bit pointer, it just needs to be a + 31 bit chunk of memory that is being pointed at. + */ + +static void *invokeRadmin(char * __ptr32 workArea, + RadminAPIStatus *__ptr32 status, + RadminFunctionCode functionCode, + RadminParmList * __ptr32 parmList, + RadminCallerAuthInfo *__ptr32 callerAuthInfo, + uint8_t resultSubpool ) { - void * __ptr32 * __ptr32 resultPtr = result; -#ifdef METTLE - resultPtr = (void * __ptr32 * __ptr32)((int32_t)resultPtr | 0x80000000); -#endif + + /* get the immediate data that needs to have 31 bit pointers into 31 bit area and + make some pointers that point in. */ + char *__ptr32 data31 = (char *__ptr32)safeMalloc31(DATA31_LENGTH,"IRRSEQ00Data:31"); + memset(data31,0,DATA31_LENGTH); + RadminFunctionCode *__ptr32 functionCodeBox = (RadminFunctionCode *__ptr32)data31; + *functionCodeBox = functionCode; + uint8_t *__ptr32 subpoolBox = (uint8_t*)(data31+4); + /* make the handle and the pointer be in 3 and fourth slots of DAT31 */ + *subpoolBox = resultSubpool; + + IRRSEQ00Arguments *__ptr32 arguments = (IRRSEQ00Arguments *__ptr32)safeMalloc31(sizeof(IRRSEQ00Arguments),"IRRSEQ00Arguments:31"); + arguments->workArea = workArea; + arguments->safReturnCodeALET = &(status->alet); + arguments->safReturnCode = &(status->safRC); + arguments->racfReturnCodeALET = &(status->alet); + arguments->racfReturnCode = &(status->racfRC); + arguments->racfReasonCodeALET = &(status->alet); + arguments->racfReasonCode = &(status->racfRSN); + arguments->functionCode = functionCodeBox; + arguments->parmList = parmList; + arguments->userID = &(callerAuthInfo->userID); + arguments->acee = &(callerAuthInfo->acee); + arguments->outMessageSubpool = subpoolBox; + arguments->outMessage = ((int)(data31+8))|0x80000000; + uint32_t argumentsAddress = (uint32_t)arguments; + #ifdef RADMIN_XMEM_MODE /* When in PC-cp PSW key != TCB key, depending on the subpool R_admin will @@ -180,57 +259,110 @@ static void invokeRadmin( int oldKey = setKey(0); #endif - IRRSEQ00( - workArea, - safReturnCodeALET, safReturnCode, - racfReturnCodeALET, racfReturnCode, - racfReasonCodeALET, racfReasonCode, - functionCode, - parmList, - userID, - acee, - resultSubpool, - resultPtr - ); + + printf("right before assembler code arguments at 0x%x\n",argumentsAddress); + dumpbuffer((char*)arguments,sizeof(IRRSEQ00Arguments)); + printf("status block\n"); + dumpbuffer((char*)status,sizeof(RadminAPIStatus)); + printf("Data 31 at 0x%p\n",data31); + dumpbuffer(data31,DATA31_LENGTH); + + __asm(ASM_PREFIX + /* still need compiled C-code addressing mode to get this address */ + " XGR 1,1 \n" + " L 1,%0 \n" +#ifdef _LP64 + " SAM31 \n" +#endif + " L 15,X'10'(,0) \n" + " L 15,X'220'(,15) \n" /* CSR Table */ + " L 15,X'28'(,15) \n" /* IRR Slot */ + " AHI 15,X'9C' \n" /* Make pointer int IRR Slot */ + " L 15,0(,15) \n" /* Load routine pointer for IRRSEQ00 */ + " BASR 14,15 \n" +#ifdef _LP64 + " SAM64 \n" +#endif + : : + "m"(argumentsAddress) + : "r1", "r14", "r15"); #ifdef RADMIN_XMEM_MODE setKey(oldKey); #endif + void *result = (void*)((int*)data31)[2]; + printf("right after assembler code result=0x%p\n"); + dumpbuffer((char*)arguments,sizeof(IRRSEQ00Arguments)); + printf("status block\n"); + dumpbuffer((char*)status,sizeof(RadminAPIStatus)); + printf("Data 31\n"); + dumpbuffer(data31,DATA31_LENGTH); + + safeFree31(data31,DATA31_LENGTH); + safeFree31((char*)arguments,sizeof(IRRSEQ00Arguments)); + return result; } -static RadminAPIStatus runRACFCommand( +static char *__ptr32 allocateWorkArea(){ + char *__ptr32 workArea = safeMalloc31(RADMIN_WORK_AREA_SIZE,"Radmin WorkArea"); + memset(workArea,0,RADMIN_WORK_AREA_SIZE); + return workArea; +} + +static void freeWorkArea(char *__ptr32 workArea){ + safeFree31(workArea,RADMIN_WORK_AREA_SIZE); +} + +static RadminAPIStatus *__ptr32 allocateAPIStatus(){ + RadminAPIStatus *__ptr32 apiStatus = (RadminAPIStatus *__ptr32)safeMalloc31(sizeof(RadminAPIStatus),"RadminAPIStatus:31"); + memset(apiStatus,0,sizeof(RadminAPIStatus)); + return apiStatus; +} + +static void freeAPIStatus(RadminAPIStatus *__ptr32 apiStatus){ + safeFree31((char *__ptr32)apiStatus,sizeof(RadminAPIStatus)); +} + +static RadminCallerAuthInfo *__ptr32 makeCallerAuthInfo31(RadminCallerAuthInfo callerAuthInfo){ + RadminCallerAuthInfo *__ptr32 authInfo31 = + (RadminCallerAuthInfo *__ptr32)safeMalloc31(sizeof(RadminCallerAuthInfo),"RadminCallerAuthInfo31"); + memcpy(authInfo31,&callerAuthInfo,sizeof(RadminCallerAuthInfo)); + return authInfo31; +} + +static void freeCallerAuthInfo31(RadminCallerAuthInfo *__ptr32 authInfo31){ + safeFree31((char*)authInfo31,sizeof(RadminCallerAuthInfo)); +} + +static RadminAPIStatus *__ptr32 runRACFCommand( RadminCallerAuthInfo callerAuthInfo, - RadminRACFCommand *command, + RadminRACFCommand *__ptr32 command, RadminCommandOutput * __ptr32 * __ptr32 result, ) { - RadminWorkArea workArea = {0}; + char *__ptr32 workArea = allocateWorkArea(); - int32_t statusALET = 0; /* primary */ - RadminAPIStatus status = {0}; - - RadminFunctionCode functionCode = RADMIN_FC_RUN_COMD; - - RadminParmList * __ptr32 parmList = command; + RadminAPIStatus *__ptr32 status = allocateAPIStatus(); + RadminCallerAuthInfo *__ptr32 authInfo31 = makeCallerAuthInfo31(callerAuthInfo); RadminUserID callerUserID = callerAuthInfo.userID; ACEE * __ptr32 callerACEE = callerAuthInfo.acee; - int8_t resultSubpool = RADMIN_RESULT_BUFFER_SUBPOOL; + uint8_t resultSubpool = RADMIN_RESULT_BUFFER_SUBPOOL; - invokeRadmin( - &workArea, - &statusALET, &status.safRC, - &statusALET, &status.racfRC, - &statusALET, &status.racfRSN, - &functionCode, - parmList, - &callerUserID, - &callerACEE, - &resultSubpool, - (void * __ptr32 * __ptr32)result + void *output = invokeRadmin( + workArea, + status, + RADMIN_FC_RUN_COMD, + (RadminParmList *__ptr32)command, + authInfo31, + resultSubpool ); + *result = (RadminCommandOutput *__ptr32)output; + + freeWorkArea(workArea); + freeCallerAuthInfo31(authInfo31); return status; } @@ -263,19 +395,22 @@ int radminRunRACFCommand( return RC_RADMIN_BAD_INPUT; } - RadminRACFCommand internalCommand = {commandLength, ""}; - memcpy(internalCommand.text, command, commandLength); + RadminRACFCommand *__ptr32 internalCommand = + (RadminRACFCommand *__ptr32)safeMalloc31(sizeof(RadminRACFCommand),"RadminRACFCommand"); + internalCommand->length = (uint16_t)commandLength; + memcpy(internalCommand->text, command, commandLength); int rc = RC_RADMIN_OK; RadminCommandOutput * __ptr32 result = NULL; - - RadminAPIStatus apiStatus = runRACFCommand(callAuthInfo, - &internalCommand, - &result); + RadminAPIStatus statusOnStack; + RadminAPIStatus *__ptr32 apiStatus31 = runRACFCommand(callAuthInfo, + internalCommand, + &result); + statusOnStack = *apiStatus31; if (result != NULL) { - int visitRC = userHandler(apiStatus, result, userHandlerData); + int visitRC = userHandler(statusOnStack, result, userHandlerData); if (visitRC != 0) { status->reasonCode = visitRC; rc = RC_RADMIN_NONZERO_USER_RC; @@ -283,9 +418,11 @@ int radminRunRACFCommand( } - if (apiStatus.safRC > 0) { + safeFree31((char*)internalCommand,sizeof(RadminRACFCommand)); + + if (apiStatus31->safRC > 0) { - status->apiStatus = apiStatus; + status->apiStatus = *apiStatus31; rc = RC_RADMIN_SYSTEM_ERROR; } @@ -295,6 +432,7 @@ int radminRunRACFCommand( result = NULL; } + freeAPIStatus(apiStatus31); return rc; } @@ -334,44 +472,47 @@ static RadminAPIStatus extractProfileInternal( size_t classNameLength, bool isNext, bool *isProfileGeneric, - RadminXTROutput * __ptr32 * __ptr32 result, + RadminXTROutput **result, ) { - RadminWorkArea workArea = {0}; + char *__ptr32 workArea = allocateWorkArea(); - int32_t statusALET = 0; /* primary */ - RadminAPIStatus status = {0}; + RadminAPIStatus *__ptr32 status = allocateAPIStatus(); + RadminCallerAuthInfo *__ptr32 authInfo31 = makeCallerAuthInfo31(callerAuthInfo); RadminFunctionCode functionCode = getProfileXTRFunctionCode(type, isNext); - RadminXTRParmList parmList = {0}; - parmList.header.profileNameLength = profileNameLength; - parmList.header.flag = RADMIN_XTR_HDR_FLAG_BASE_SEG_ONLY; + RadminXTRParmList *__ptr32 parmList = (RadminXTRParmList *__ptr32)safeMalloc31(sizeof(RadminXTRParmList),"RadminXTRParmList:31"); + parmList->header.profileNameLength = profileNameLength; + parmList->header.flag = RADMIN_XTR_HDR_FLAG_BASE_SEG_ONLY; if (*isProfileGeneric == true) { - parmList.header.flag |= RADMIN_XTR_HDR_FLAG_GENERIC; + parmList->header.flag |= RADMIN_XTR_HDR_FLAG_GENERIC; } - memset(parmList.header.className, ' ', sizeof(parmList.header.className)); - memcpy(parmList.header.className, className, classNameLength); - memcpy(parmList.profileName, profileName, profileNameLength); + memset(parmList->header.className, ' ', sizeof(parmList->header.className)); + memcpy(parmList->header.className, className, classNameLength); + memcpy(parmList->profileName, profileName, profileNameLength); RadminUserID callerUserID = callerAuthInfo.userID; ACEE * __ptr32 callerACEE = callerAuthInfo.acee; - int8_t resultSubpool = RADMIN_RESULT_BUFFER_SUBPOOL; - - invokeRadmin( - &workArea, - &statusALET, &status.safRC, - &statusALET, &status.racfRC, - &statusALET, &status.racfRSN, - &functionCode, - &parmList, - &callerUserID, - &callerACEE, - &resultSubpool, - (void * __ptr32 * __ptr32)result + uint8_t resultSubpool = RADMIN_RESULT_BUFFER_SUBPOOL; + + void *output = invokeRadmin( + workArea, + status, + functionCode, + (RadminParmList *__ptr32)parmList, + authInfo31, + resultSubpool ); + printf("output=0x%p\n",output);fflush(stdout); + *result = output; + + freeWorkArea(workArea); + freeCallerAuthInfo31(authInfo31); + safeFree31((char*)parmList,sizeof(RadminXTRParmList)); + if (*result != NULL) { RadminXTRHeader *resultHeader = &(*result)->header; if (resultHeader->flag & RADMIN_XTR_HDR_FLAG_GENERIC) { @@ -379,7 +520,8 @@ static RadminAPIStatus extractProfileInternal( } } - return status; + RadminAPIStatus statusOnStack = *status; + return statusOnStack; } #define IS_XTR_EODAT(apiStatus) \ @@ -458,7 +600,7 @@ int radminExtractProfiles( break; } - RadminXTROutput * __ptr32 result = NULL; + RadminXTROutput *result = NULL; RadminAPIStatus apiStatus = extractProfileInternal(callAuthInfo, type, @@ -1276,28 +1418,26 @@ int radminPerformResAction( return RC_RADMIN_BAD_INPUT; } - RadminWorkArea workArea = {0}; + char *__ptr32 workArea = allocateWorkArea(); + RadminCallerAuthInfo *__ptr32 authInfo31 = makeCallerAuthInfo31(callerAuthInfo); int32_t statusALET = 0; /* primary */ RadminAPIStatus *apiStatus = &status->apiStatus; RadminUserID callerUserID = callerAuthInfo.userID; ACEE * __ptr32 callerACEE = callerAuthInfo.acee; - int8_t resultSubpool = RADMIN_RESULT_BUFFER_SUBPOOL; - RadminCommandOutput * __ptr32 result = NULL; - - invokeRadmin( - &workArea, - &statusALET, &apiStatus->safRC, - &statusALET, &apiStatus->racfRC, - &statusALET, &apiStatus->racfRSN, - &functionCode, + uint8_t resultSubpool = RADMIN_RESULT_BUFFER_SUBPOOL; + RadminCommandOutput * __ptr32 result = invokeRadmin( + workArea, + apiStatus, + functionCode, actionParmList, - &callerUserID, - &callerACEE, - &resultSubpool, - (void * __ptr32 * __ptr32)&result + authInfo31, + resultSubpool ); + freeWorkArea(workArea); + freeCallerAuthInfo31(authInfo31); + int rc = RC_RADMIN_OK; if (apiStatus->safRC != 0) { rc = RC_RADMIN_SYSTEM_ERROR; @@ -1365,28 +1505,26 @@ int radminPerformGroupAction( return RC_RADMIN_BAD_INPUT; } - RadminWorkArea workArea = {0}; + char *__ptr32 workArea = allocateWorkArea(); + RadminCallerAuthInfo *__ptr32 authInfo31 = makeCallerAuthInfo31(callerAuthInfo); int32_t statusALET = 0; /* primary */ RadminAPIStatus *apiStatus = &status->apiStatus; RadminUserID callerUserID = callerAuthInfo.userID; ACEE * __ptr32 callerACEE = callerAuthInfo.acee; - int8_t resultSubpool = RADMIN_RESULT_BUFFER_SUBPOOL; - RadminCommandOutput * __ptr32 result = NULL; - - invokeRadmin( - &workArea, - &statusALET, &apiStatus->safRC, - &statusALET, &apiStatus->racfRC, - &statusALET, &apiStatus->racfRSN, - &functionCode, + uint8_t resultSubpool = RADMIN_RESULT_BUFFER_SUBPOOL; + RadminCommandOutput * __ptr32 result = invokeRadmin( + workArea, + apiStatus, + functionCode, actionParmList, - &callerUserID, - &callerACEE, - &resultSubpool, - (void * __ptr32 * __ptr32)&result + authInfo31, + resultSubpool ); + freeWorkArea(workArea); + freeCallerAuthInfo31(authInfo31); + int rc = RC_RADMIN_OK; if (apiStatus->safRC != 0) { rc = RC_RADMIN_SYSTEM_ERROR; @@ -1450,28 +1588,26 @@ int radminPerformConnectionAction( return RC_RADMIN_BAD_INPUT; } - RadminWorkArea workArea = {0}; + char *__ptr32 workArea = allocateWorkArea(); + RadminCallerAuthInfo *__ptr32 authInfo31 = makeCallerAuthInfo31(callerAuthInfo); int32_t statusALET = 0; /* primary */ RadminAPIStatus *apiStatus = &status->apiStatus; RadminUserID callerUserID = callerAuthInfo.userID; ACEE * __ptr32 callerACEE = callerAuthInfo.acee; - int8_t resultSubpool = RADMIN_RESULT_BUFFER_SUBPOOL; - RadminCommandOutput * __ptr32 result = NULL; - - invokeRadmin( - &workArea, - &statusALET, &apiStatus->safRC, - &statusALET, &apiStatus->racfRC, - &statusALET, &apiStatus->racfRSN, - &functionCode, + uint8_t resultSubpool = RADMIN_RESULT_BUFFER_SUBPOOL; + RadminCommandOutput * __ptr32 result = invokeRadmin( + workArea, + apiStatus, + functionCode, actionParmList, - &callerUserID, - &callerACEE, - &resultSubpool, - (void * __ptr32 * __ptr32)&result + authInfo31, + resultSubpool ); + freeWorkArea(workArea); + freeCallerAuthInfo31(authInfo31); + int rc = RC_RADMIN_OK; if (apiStatus->safRC != 0) { rc = RC_RADMIN_SYSTEM_ERROR; diff --git a/c/recovery.c b/c/recovery.c index 06710d299..5052c03c0 100644 --- a/c/recovery.c +++ b/c/recovery.c @@ -23,6 +23,7 @@ #include "stdlib.h" #include "stdio.h" #include "string.h" +#define srbPrintf printf #endif #include "zowetypes.h" @@ -896,7 +897,9 @@ void recoveryDESCTs(){ #endif RecoveryContext *getRecoveryContext() { + srbPrintf("getRecoveryContext()\n"); #ifdef CUSTOM_CONTEXT_GETTER + srbPrintf("custom case\n"); return rcvrgcxt(); #else #ifdef __ZOWE_OS_ZOS @@ -908,7 +911,8 @@ RecoveryContext *getRecoveryContext() { if (rleTask == NULL) { return NULL; } - return rleTask->recoveryContext; + RecoveryContext *ctx = rleTask->recoveryContext; + return ctx; #elif defined(__ZOWE_OS_AIX) || defined(__ZOWE_OS_LINUX) return theRecoveryContext; #endif /* __ZOWE_OS_ZOS */ @@ -1121,6 +1125,8 @@ static int establishRouterInternal(RecoveryContext *userContext, context = userContext; } + srbPrintf("recovery.c: about to set recovery context 0x%p frr?=%d\n", + context,frrRequired); int setRC = setRecoveryContext(context); if (setRC != RC_RCV_OK) { rc = RC_RCV_CONTEXT_NOT_SET; @@ -1157,7 +1163,6 @@ static int establishRouterInternal(RecoveryContext *userContext, : ); - if (!frrRequired) { /* ESTAEX */ @@ -1548,12 +1553,10 @@ int recoveryRemoveRouter() { static RecoveryStateEntry *addRecoveryStateEntry(RecoveryContext *context, char *name, int flags, char *dumpTitle, AnalysisFunction *userAnalysisFunction, void * __ptr32 analysisFunctionUserData, CleanupFunction *userCleanupFunction, void * __ptr32 cleanupFunctionUserData) { - RecoveryStateEntry *newEntry = allocRecoveryStateEntry(context); if (newEntry == NULL) { return NULL; } - #if !defined(METTLE) && defined(_LP64) if (userAnalysisFunction != NULL) { newEntry->analysisFunctionEnvironment = ((uint64 *)userAnalysisFunction)[0]; @@ -1567,10 +1570,8 @@ static RecoveryStateEntry *addRecoveryStateEntry(RecoveryContext *context, char newEntry->analysisFunction = (void * __ptr32 )userAnalysisFunction; newEntry->cleanupFunctionEntryPoint = (void * __ptr32 )userCleanupFunction; #endif - newEntry->analysisFunctionUserData = analysisFunctionUserData; newEntry->cleanupFunctionUserData = cleanupFunctionUserData; - if (name != NULL) { int stateNameLength = strlen(name); if (stateNameLength > sizeof(newEntry->serviceInfo.stateName)) { @@ -1579,7 +1580,6 @@ static RecoveryStateEntry *addRecoveryStateEntry(RecoveryContext *context, char newEntry->serviceInfo.stateNameLength = stateNameLength; memcpy(newEntry->serviceInfo.stateName, name, stateNameLength); } - newEntry->flags |= flags; newEntry->state = (flags & RCVR_FLAG_DISABLE) ? RECOVERY_STATE_DISABLED : RECOVERY_STATE_ENABLED; memset(newEntry->dumpTitle.title, ' ', sizeof(newEntry->dumpTitle.title)); @@ -1597,18 +1597,26 @@ static RecoveryStateEntry *addRecoveryStateEntry(RecoveryContext *context, char } static void removeRecoveryStateEntry(RecoveryContext *context) { - RecoveryStateEntry *entryToRemove = context->recoveryStateChain; if (entryToRemove != NULL) { context->recoveryStateChain = entryToRemove->next; } else { return; } - freeRecoveryStateEntry(context, entryToRemove); entryToRemove = NULL; } +void showRecoveryState(){ + RecoveryContext *context = getRecoveryContext(); + printf("showRecoveryState context = 0x%p\n",context); + if (context){ + printf("entry = 0x%p\n",context->recoveryStateChain); + } else{ + printf("no chain\n"); + } +} + #elif defined(__ZOWE_OS_AIX) || defined(__ZOWE_OS_LINUX) RecoveryStateEntry *addRecoveryStateEntry(RecoveryContext *context, char *name, int flags, char *dumpTitle, @@ -1640,16 +1648,15 @@ RecoveryStateEntry *addRecoveryStateEntry(RecoveryContext *context, char *name, } static void removeRecoveryStateEntry(RecoveryContext *context) { - RecoveryStateEntry *entryToRemove = context->recoveryStateChain; if (entryToRemove != NULL) { context->recoveryStateChain = entryToRemove->next; } - safeFree((char *)entryToRemove, sizeof(RecoveryStateEntry)); entryToRemove = NULL; } + #endif /* __ZOWE_OS_ZOS */ #ifdef __ZOWE_OS_ZOS @@ -1688,6 +1695,7 @@ int recoveryPush(char *name, int flags, char *dumpTitle, CleanupFunction *userCleanupFunction, void * __ptr32 cleanupFunctionUserData) { RecoveryContext *context = getRecoveryContext(); + srbPrintf("rPush context=0x%p\n",context); if (context == NULL) { return RC_RCV_CONTEXT_NOT_FOUND; } @@ -1697,14 +1705,16 @@ int recoveryPush(char *name, int flags, char *dumpTitle, return RC_RCV_LNKSTACK_ERROR; } + srbPrintf("rpush.1\n"); RecoveryStateEntry *newEntry = addRecoveryStateEntry(context, name, flags, dumpTitle, userAnalysisFunction, analysisFunctionUserData, userCleanupFunction, cleanupFunctionUserData); + srbPrintf("rpush.2 newEntry=0x%p\n",newEntry); if (newEntry == NULL) { return RC_RCV_ALLOC_FAILED; } - + srbPrintf("newEntry=0x%p\n",newEntry); newEntry->linkageStackToken = linkageStackToken; /* Extract key from the newly created stacked state. IPK cannot be used @@ -1786,6 +1796,8 @@ int recoveryPush(char *name, int flags, char *dumpTitle, : "r2", "r10", "r11", "r14", "r15" ); + srbPrintf("rPush after ASM\n"); + if (newEntry->state & RECOVERY_STATE_ABENDED) { if (newEntry->flags & RCVR_FLAG_DELETE_ON_RETRY) { removeRecoveryStateEntry(context); @@ -1987,7 +1999,6 @@ void recoveryUpdateStateServiceInfo(char *loadModuleName, char *csect, char *rec componentID, subcomponentName, buildDate, version, componentIDBaseNumber, stateName); - } void recoveryGetABENDCode(SDWA *sdwa, int *completionCode, int *reasonCode) { diff --git a/c/scheduling.c b/c/scheduling.c index 6636d89aa..e27bc275f 100644 --- a/c/scheduling.c +++ b/c/scheduling.c @@ -30,6 +30,7 @@ #include "zowetypes.h" #include "alloc.h" #include "utils.h" +#include "logging.h" #include "zos.h" #include "le.h" #include "recovery.h" diff --git a/c/shrmem64.c b/c/shrmem64.c index e6b4f767f..e9d46e86f 100644 --- a/c/shrmem64.c +++ b/c/shrmem64.c @@ -266,6 +266,11 @@ static void removeSystemInterestForSingleObject(MemObj object, } +static ASCB *localGetASCB(){ + int *mem = (int*)0; + return (ASCB*)(mem[CURRENT_ASCB/sizeof(int)]&0x7FFFFFFF); +} + MemObjToken shrmem64GetAddressSpaceToken(void) { union { @@ -274,7 +279,7 @@ MemObjToken shrmem64GetAddressSpaceToken(void) { ASCB * __ptr32 ascb; uint32_t asid; }; - } result = { .ascb = getASCB(), .asid = result.ascb->ascbasid }; + } result = { .ascb = localGetASCB(), .asid = result.ascb->ascbasid }; return result.token; } diff --git a/c/zos.c b/c/zos.c index 301f00a7a..ee084f48e 100644 --- a/c/zos.c +++ b/c/zos.c @@ -41,7 +41,7 @@ #include "utils.h" #include "zos.h" -#ifdef METTLE +#if defined(METTLE) && !defined(HAVE_PRINTF) #define fprintf(out,fmt,...) printf(fmt,__VA_ARGS__) #define printf wtoPrintf #define fflush(out) diff --git a/c/zosfile.c b/c/zosfile.c index cdc6f0e7b..907009169 100644 --- a/c/zosfile.c +++ b/c/zosfile.c @@ -1462,6 +1462,7 @@ int directoryCopy(const char *existingPathName, const char *newPathName, int *re return 0; } +#ifndef METTLE /* * Recursively, change the file tags of the requested file/tree */ @@ -1708,7 +1709,6 @@ int directoryChangeTagRecursive(const char *pathName, char *type, } - int directoryRename(const char *oldDirname, const char *newDirName, int *returnCode, int *reasonCode){ int returnValue = fileRename(oldDirname, newDirName, returnCode, reasonCode); @@ -1736,6 +1736,8 @@ int getUmask() { return previous; } +#endif + int fileDisableConversion(UnixFile *file, int *returnCode, int *reasonCode) { int *reasonCodePtr; int returnValue; @@ -1878,6 +1880,8 @@ int fileUnlock(UnixFile *file, int *returnCode, int *reasonCode) { return returnValue; } +#ifndef METTLE + static int patternChangeModeFile (const char *fileName, int mode, const char *compare, int *returnCode, int *reasonCode){ @@ -2147,6 +2151,7 @@ int directoryChangeOwnerRecursive(char * message, int messageLength, } return returnValue; } +#endif /* diff --git a/h/crossmemory.h b/h/crossmemory.h index 669c87247..eae084d32 100644 --- a/h/crossmemory.h +++ b/h/crossmemory.h @@ -194,7 +194,6 @@ typedef struct CMSTimestamp_tag { char value[32]; } CMSBuildTimestamp; - typedef struct CrossMemoryServerGlobalArea_tag { char eyecatcher[8]; diff --git a/h/radmin.h b/h/radmin.h index 2fa9d0493..2ef30fc76 100644 --- a/h/radmin.h +++ b/h/radmin.h @@ -27,11 +27,6 @@ #include "zowetypes.h" #include "zos.h" -#ifndef METTLE - #ifdef _LP64 - #error Metal C 31/64-bit and LE 31-bit are supported only - #endif -#endif /* * System mappings. These need to be in sync with the official doc. @@ -253,6 +248,7 @@ typedef struct RadminAPIStatus_tag { int safRC; int racfRC; int racfRSN; + int alet; /* always zero */ } RadminAPIStatus; typedef struct RadminStatus_tag { diff --git a/h/recovery.h b/h/recovery.h index ec7d91850..e07551398 100644 --- a/h/recovery.h +++ b/h/recovery.h @@ -351,6 +351,7 @@ typedef struct RecoveryContext_tag { #define recoveryUpdateStateServiceInfo RCVRUSSI #define recoveryGetABENDCode RCVRGACD #define runFunctioninESTAE RCVRNFNE +#define showRecoveryState SHRCVRST #endif #ifdef __ZOWE_OS_ZOS @@ -503,6 +504,8 @@ int recoveryPush(char *name, int flags, char *dumpTitle, *****************************************************************************/ void recoveryPop(); +void showRecoveryState(); + /***************************************************************************** * Set the new dump title * diff --git a/h/zos.h b/h/zos.h index 39c0f346c..7668d3352 100644 --- a/h/zos.h +++ b/h/zos.h @@ -177,7 +177,14 @@ typedef struct cvt_tag{ char cvtflags[4]; Addr31 cvtrt03; char cvtrs180[8]; - char iAmTired[0x98]; + char unmapped188[0x50]; + /* OFFSET 0x1D8 */ + Addr31 cvtstck; /* TSO Stack routine */ + short cvtmaxmp; /* max CPU address available in this IPL */ + short cvtbsm2; /* literally a a BSM 0,2 instruction */ + /* OFFSET 0x1E0 */ + char unmapped1E0[0x40]; + /* OFFSET 0x220 */ Addr31 cvtcsrt; /* callable services */ Addr31 cvtaqtop; /* pnter to allocation queue lock area */ Addr31 cvtvvmdi; /* owned by (P)LPA search algorithm */ @@ -297,9 +304,10 @@ typedef struct cvt_tag{ Addr31 cvtjterm; /* Auxiliary storage management job termination resource manager */ /* OFFSET 0x400 */ - char unmapped400[0xB0]; + char unmapped400[0xAC]; - /* OFFSET 0x4B0 */ + /* OFFSET 0x4AC */ + Addr31 cvtsmext; /* address of CVTVSTGX an extension containing storage layout info */ Addr31 cvtnucmp; /* address of nucleus map, array of 16-byte entries */ /* many, many slots follow this point. @@ -526,11 +534,78 @@ typedef struct ocvt_tag{ /* see SYS1.MACLIB(BPXZOCVT) */ } OCVT; /* Request blocks are octopus-chameleon hybrids. The documentation - is paleolithic and confusing. - - + is paleolithic and confusing. Multiple OS generations are vestigially visible in these + blocks. Which of the myriad flags currently drive behavior of dispatch (scheduler) + is profound and frustrating quetsion. */ +typedef struct RBPrefix_tag{ + char reserved[0x20]; + Addr31 rbxsb; /* the extended status block, where modern state info is stored */ + short reserved24; + char rbkeysta; /* key and state of IRB */ + char rbflags2; + int64 rbrtpsw1; /* Modern PSW Mask */ + int64 rbrtpsw2; /* Modern PSW Address unioned with a boatload of crap */ + char rbflags1; +#define RBFLAGS1_RBSLOCK 0x80 /* RB non-dispatchable until BCP CVTSYLK reset */ +#define RBFLAGS1_RBXWAIT 0x40 /* SVC Wait in progress */ +#define RBFLAGS1_RBABEND 0x20 +#define RBFLAGS1_RBXWPRM 0x10 +#define RBFLAGS1_RBLONGWT 0x04 /* Long wait */ +#define RBFLAGS1_RBSCB 0x02 /* Has STAE/ESTAE */ +#define RBFALSG1_RBSSSYN 0x01 + char rbflags3; +#define RBFLAGS3_RBWTECB 0x80 /* wait was issued with ECB provided */ + short rbxwaiti; /* wait index */ + char rbwcsa; + char rbinlnth; /* ILC */ + unsigned short rbintcod; /* Interrupt Code */ +} RBPrefix; + +#define RB_PREFIX_OFFSET (-64) +#define RBPRFXST (-32) + +#define PRBEND 0x68 +#define SIRBEND 0xA8 +#define TIRBEND 0x68 +#define IRBEND 0x60 +#define SVRBEND 0xD0 + +#define PRBLEN (PRBEND-RBPRFXST) +#define SIRBLEN (SIRBEND-RBPRFXST) +#define TIRBLEN (TIRBEND-RBPRFXST) +#define IRBLEN (IRBEND-RBPRFXST) +#define SVRBLEN (SVRBEND-RBPRFXST) +#define MAX_RB_LEN SVRBEND + +#define RB_TYPE_PRB 0 /* Program RB, normal stuff */ +#define RB_TYPE_IRB 2 /* Interrupt */ +#define RB_TYPE_TIRB 3 /* what are these used as, laundry baskets on every third Wednesday */ +#define RB_TYPE_SIRB 4 +#define RB_TYPE_SVRB 6 /* System call */ + + +typedef struct RB_tag{ + char aCompleteMess[8]; + unsigned short systemDependent08; + char rbStab1; /* Status and Attributes */ + char rbStab2; /* Status and Attributes */ +#define RBSTAB2_RBLINK_IS_TCB 0x80 +#define RBSTAB2_IS_QUEUED 0x40 /* ie. is active */ +#define RBSTAB2_FREE_STORAGE 0x02 /* free storage at exit */ +#define RBSTAT2_RBECBWT 0x01 /* read the Data areas book */ + int rbEPOrCDE; /* Entry point or CDE (24 bit for CDE */ + int64 rbopsw; /* old PSW, 31 bit style */ + /* Offset 0x18 */ + Addr31 systemDependent18; + int rblink; /* wait count and 24 bit pointer, shoot me now */ + /* Offset 0x20 */ + unsigned int rbgrs[16]; /* 32 bit register values */ + /* Offset 0x60 */ + char variantData[0x40]; /* RB's are a mess */ +} RB; + typedef struct IKJRB_tag{ char stuff[0x0C]; Addr31 rbcde; @@ -552,38 +627,38 @@ typedef struct tcb_tag{ char tcbflgs3; char tcbflgs4; /* 0x20 */ char tcbflgs5; - char tcblmp; /* task limiting priority */ - char tcbdsp; /* task dispatching priority */ - Addr31 tcblls; /* addr of last elt (LLE) in Load List */ - Addr31 tcbjlb; /* addr of joblib DCB */ - int tcbjpq; /* last cde in job pack areas 1+31 or 8+24 format */ + char tcblmp; /* task limiting priority */ + char tcbdsp; /* task dispatching priority */ + Addr31 tcblls; /* addr of last elt (LLE) in Load List */ + Addr31 tcbjlb; /* addr of joblib DCB */ + int tcbjpq; /* last cde in job pack areas 1+31 or 8+24 format */ int tcbgrs[16]; /* 0x30 General Register Save Area */ - Addr31 tcbfsa; /* 0x70 first prob program save area */ + Addr31 tcbfsa; /* 0x70 first prob program save area */ struct tcb_tag *__ptr32 tcbtcb; /* tcb chain in address space */ Addr31 tcbtme; Addr31 tcbjstcb; /* first job step TCB or this TCB is key 0 */ - Addr31 tcbntc; /* 0x80 attach stuff */ - Addr31 tcbotc; /* originating task */ + Addr31 tcbntc; /* 0x80 attach stuff */ + Addr31 tcbotc; /* originating task */ Addr31 tcbltc; Addr31 tcbiqe; /* interrupt queue element IQE */ - Addr31 tcbecb; /* 0x90 ECB to be posted for task term */ - char tcbtsflg; /* time-sharing flags */ - char tcbstpct; /* number of set task starts */ - char tcbtslp; /* limit prty of TS task */ - char tcbtsdp; /* disp prty of TS task */ - Addr31 tcbrd; /* DPQE-8 for job step serialization, aka TCBPQE */ - Addr31 tcbae; /* list origin of AQE's for this task serialization */ - char tcbnstae; /* 0xA0 STAE flags */ + Addr31 tcbecb; /* 0x90 ECB to be posted for task term */ + char tcbtsflg; /* time-sharing flags */ + char tcbstpct; /* number of set task starts */ + char tcbtslp; /* limit prty of TS task */ + char tcbtsdp; /* disp prty of TS task */ + Addr31 tcbrd; /* DPQE-8 for job step serialization, aka TCBPQE */ + Addr31 tcbae; /* list origin of AQE's for this task serialization */ + char tcbnstae; /* 0xA0 STAE flags */ char tcbstabb[3]; /* current stae control block */ - Addr31 tcbtct; /* timing control table - SMF */ - Addr31 tcbuser; /* user word, shouldn't be used!! */ - int tcbscndy; /* secondary nondispatchability bits */ - int tcbmdids; /* 0xB0 reserved for model-dep support */ - Addr31 tcbjscb; /* JSCB (job step control block), high-8 also abend recursion bits, TCBRECDE */ - Addr31 tcbssat; /* subsystem affinity table */ - Addr31 tcbiobrc; /* IOB restore chain */ - Addr31 tcbexcpd; /* 0xC0 EXCP debug area */ - Addr31 tcbext1; /* os-vs common extension ICB311 */ + Addr31 tcbtct; /* timing control table - SMF */ + Addr31 tcbuser; /* user word, shouldn't be used!! */ + int tcbscndy; /* secondary nondispatchability bits */ + int tcbmdids; /* 0xB0 reserved for model-dep support */ + Addr31 tcbjscb; /* JSCB (job step control block), high-8 also abend recursion bits, TCBRECDE */ + Addr31 tcbssat; /* subsystem affinity table */ + Addr31 tcbiobrc; /* IOB restore chain */ + Addr31 tcbexcpd; /* 0xC0 EXCP debug area */ + Addr31 tcbext1; /* os-vs common extension ICB311 */ char tcbdsp4; char tcbdsp5; char tcbflgs6; @@ -593,7 +668,11 @@ typedef struct tcb_tag{ char tcbsysct; /* # of outstanding system must-complete requests ICB497 */ char tcbstmct; /* # of outstanding step must-complete requests ICB497 */ Addr31 tcbext2; /* 0xD0 OS-VS common extension */ - char undifferentiated1[0x2C]; + int tcbr0D4; /* reserved */ + Addr31 tcbxsb; /* 0xD8 */ + Addr31 tcbback; /* 0xDC - previous entry on queue */ + Addr31 tcbrtwa; /* 0xE0 - Pointer to RTM2 work area */ + char undifferentiated1[0x1C]; char undifferentiated2[0x38]; /* 0x100 */ Addr31 tcbstcb; char undifferentiated3[0x18]; /* 0x100 */ @@ -603,12 +682,66 @@ typedef struct tcb_tag{ } TCB; typedef struct stcb_tag{ - char undifferentiated1[0xD8]; + char stcbstcb[4]; /* eyecatcher */ + Addr31 stcbracp; /* RACF Pointer */ + Addr31 stcbdivf; /* first DIV DOA control block */ + Addr31 stcbdivl; /* last DIV DOA control block */ + /* OFFSET 0x10 */ + unsigned short stcbafns; + short stcbctsc; /* consecutive dispatches remaining */ + Addr31 stcbessa; + char stcbr018; /* reserved */ + char stcbflg1; + unsigned short stcbr01a; + unsigned int stcbcmp; /* completion code broken int 8-12-12 bit sections */ + /* OFFSET 0x20 */ + Addr31 stcbalov; /* work unit access list virtual address */ + Addr31 stcbald; /* work uint access list designator, part real address, part table size */ + Addr31 stcbducv; /* DUCT virtual address */ + Addr31 stcbducr; /* DUCT real address */ + /* Offset 0x30 */ + unsigned int stcbars[16];/* Access register save area for 16 registers */ + /* Offset 0x70 */ + Addr31 stcblssd; /* Virtual Address of the LSSD for the task */ + Addr31 stcblsdp; /* Linkage Stack Entry Descriptor (LSED pointer) */ + Addr31 stcbrmef; /* Pointer to head of task-related Resource Manager queue */ + Addr31 stcbrmel; /* Pointer to tal of task-related Resource Manager queue */ + /* Offset 0x80 */ + Addr31 stcbestk; /* Virtual Address of the LSED representing empty linkage stack */ + char stcbflg2; + char stcbflg3; + unsigned short stcbnstp; /* Count of requests to ignore SRB to task percolations */ + Addr31 stcbtlsd; /* Address of task-related LSSD for the Linkage stack */ + Addr31 stcbtlsp; /* Address of task-related initial LSED for the Linkage stack */ + /* Offset 0x90 */ + char stcbttkn[16]; /* TToken for this task, see data area book for details */ + /* OFFSET 0xA0 */ + char undifferentiatedA0[0x18]; + /* OFFSET 0xB8 */ + Addr31 stcbdfts; /* Address of DFP-SMSX Structure for this task */ + Addr31 stcbjsab; /* Address of JSAB - Job Scheduler Address Block */ + /* OFFSET 0xC0 */ + Addr31 stcbttcb; /* Address of TCPIP Extension block */ + unsigned int stcbrfsv; /* Registration service indicators */ + Addr31 stcbnttp; /* Address of Task Level Name/Token Header */ + unsigned int stcbcon; /* Address of IXLCONNS in effect for this task, Sysplex stuff */ + /* OFFSET 0xD0 */ + unsigned short stcbarct; /* RSM # of reference patterns for address space virtual storage */ + unsigned short stcbdrct; /* RSM # of reference patterns for dataspace virtual storage */ + unsigned int stcbdfp; /* Owned by DFP */ Addr31 stcbotcb; Addr31 stcbdcxh; /* address of the job pack queue cde extensions hash table. ownership: contents supervisor (csv) serialization: local lock. */ - char undifferentiated2[0x120]; /* gets us to 0x200 */ + /* OFFSET 0xE0 */ + Addr31 stcbsjst; + Addr31 stcbatad; + Addr31 stcbweb; /* Address of the task's WEB */ + unsigned int stcbseqn; /* RB Sequence Number */ + /* OFFSET 0xF0 */ + unsigned short stcbxcnt; /* count of outstanding EXCP's */ + char undifferentiated2[0x200-0xF2]; /* gets us to 0x200 */ + /* OFFSET 0x200 */ Addr31 stcbotca; /* Address of OTCB Alternate Anchor For Cleanup Ownership: USS Serialization: run under this task. */ @@ -639,6 +772,20 @@ typedef struct stcb_tag{ */ +/* Seems to reside in 31 bit private, likely subpool 230 */ + +typedef struct oapb_tag{ + char eyecatcher[4]; /* "OAPB" */ + char subpool; + char unknown05; + unsigned short length; /* length of this block */ + char remainderOfOAPB1[252]; + char oapb2[20]; + char oapb3[132]; +} OAPB; + +/* Seems to reside in 31 bit private, likely subpool 241 */ + typedef struct otcb_tag{ char otcbid[4]; /* eyecatcher */ char otcbsp; /* subpool */ @@ -651,14 +798,14 @@ typedef struct otcb_tag{ char otcbflagsb2; /* flag set 2 */ char otcbflagsb3; /* flag set 3 - ACEE/RACF stuff */ char otcbflagsb4; /* flag set 4 */ - int otcbpprt; /* thread id part */ - int otcbseqno; /* ditto */ - int otcbsigglags; /* */ + int otcbpprt; /* thread id part, in two 4-byte pieces */ + int otcbseqno; /* ditto */ + int otcbsigflags; /* */ /* OFFSET 0x20 */ char undifferentiated1[0x40]; /* OFFSET 0x60 */ Addr31 otcbotim; - Addr31 otcboabp; + Addr31 otcboabp; /* the per-process extenions BPXZOAPB */ char stuff[8]; /* OFFSET 0x70 */ Addr31 otcbptlcppsdptr; /* Ptrace local Ppsd pointer */ @@ -707,6 +854,17 @@ typedef struct otcb_tag{ int otcbosenvseqn; /* 2nd half of OSENV token, the sequence number */ } OTCB; + + +typedef struct LLE_tag{ + struct LLE_tag *__ptr32 llechn; + struct IHACDE_tag *__ptr32 llecdpt; + unsigned short llecount; + unsigned short llesysct; +} LLE; + + + typedef struct IHACDE_tag{ struct IHACDE_tag *__ptr32 next; Addr31 cdrrbp; /* address of RB that had module, or not, kinda complex */ @@ -1035,6 +1193,33 @@ TCB *getNextSiblingTCB(TCB *tcb); */ +typedef struct JSCB_tag{ + char undocumentedStuff[0xBC]; /* Really. Look at the MVS Data Area books */ + int jscrsv01; /* reserved */ + int jschpcea; /* Address of JES Process Control Element, low three byte, 24 byte pointer */ + Addr31 jscbshr; /* Assembly Chain (VSAM) */ + Addr31 jscbtcp; /* TIOT Chaining Element Chain (VSAM) */ + Addr31 jscbpcc; /* Private Catalog Control Block (VSAM) */ + /* Offset 0xD0 */ + Addr31 jscbtcbp; /* Address of the initiators TCB */ + Addr31 jscbijsc; /* Address of the JSCB of the initiator that attached this job step */ + Addr31 jscbdbtb; /* DEB table for this job step */ + Addr31 jscbid; /* Job Serial Number */ + /* Offset 0xE0 */ + int jscbdcb; /* Don't touch this */ + int jscbstep; /* Step number, starting at 1, high byte only */ + char undifferentiatedE8[0xC]; + Addr31 jscbqmpi; /* Address of Queue Manager Parameter Area, which has some valuable data */ + char undifferentiatedF8[0x8]; + /* Offset 0x100 */ + Addr31 jscbcscb; /* Addr of CSCB Command Scheduling Block */ + /* theres a *LOT* of crufty JES stuff after here, really weird stuff, not all noted here */ + + char undifferentiated104[0x168-0x104]; + /* Offset 0x168 */ + char jscbpgnm[8]; /* Job Step Program Name */ +} JSCB; + #define GETDSAB_PLIST_LENGTH 16 #define DSABFLG4_DSABHIER 0x10 From 984a44914ebde4091ca6e7cebb83c1ad6998a168 Mon Sep 17 00:00:00 2001 From: Joe Devlin Date: Fri, 9 Oct 2020 14:44:30 -0500 Subject: [PATCH 02/33] more ZOS interface extensions including common 64 mem and more pause element capabilities and many more OS structures mapped Signed-off-by: Joe Devlin --- c/httpserver.c | 4 ++ c/pause-element.c | 42 +++++++++++++-- c/recovery.c | 13 +---- c/shrmem64.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++ c/utils.c | 13 +++-- h/le.h | 2 +- h/pause-element.h | 16 ++++-- h/shrmem64.h | 7 +++ h/zos.h | 27 +++++++++- 9 files changed, 226 insertions(+), 26 deletions(-) diff --git a/c/httpserver.c b/c/httpserver.c index 6676616d3..3a66b0b5f 100644 --- a/c/httpserver.c +++ b/c/httpserver.c @@ -3887,6 +3887,8 @@ static MimeType MIME_TYPES[] = { {"md", "text/markdown", FALSE}, {"sh", "application/x-sh", FALSE}, {"bin", "application/octet-stream", TRUE}, + {"o", "application/octet-stream", TRUE}, + {"dbg", "application/octet-stream", TRUE}, {"gz", "application/gzip", TRUE}, {"jar", "application/java-archive", TRUE}, {"tar", "application/x-tar", TRUE}, @@ -3979,6 +3981,7 @@ void respondWithUnixFileContents2 (HttpService* service, HttpResponse* response, // Response must ALWAYS be finished on return void respondWithUnixFileContentsWithAutocvtMode (HttpService* service, HttpResponse* response, char* absolutePath, int jsonMode, int autocvt) { + printf("JOE: respondWithUnixFileContentsWithAutocvtMode path=%s, jsonMode=%d autocvt=%d\n",absolutePath,jsonMode,autocvt); FileInfo info; int returnCode; int reasonCode; @@ -4197,6 +4200,7 @@ void respondWithUnixFile2(HttpService* service, HttpResponse* response, char* ab service->customHeadersFunction(service, response); } + printf("JOE: isBinary=%d ccsi=%d\n",isBinary,ccsid); if (isBinary || ccsid == -1) { writeHeader(response); #ifdef DEBUG diff --git a/c/pause-element.c b/c/pause-element.c index 24404b833..aad6a430f 100644 --- a/c/pause-element.c +++ b/c/pause-element.c @@ -196,6 +196,38 @@ int peRetrieveInfo(const PET *token, return rc; } +int peRetrieveInfo2(const PET *token, + PEInfo *info, + bool isBranchLinkage, + bool untrusted){ + + int32_t rc = 0; + int32_t linkage = isBranchLinkage ? PE_LINKAGE_BRANCH : PE_LINKAGE_SVC; + if (untrusted){ + linkage |= PE_LINKAGE_UNTRUSTED_PET; + } + + int wasProblemState; + int key; + if (isBranchLinkage) { + wasProblemState = supervisorMode(TRUE); + key = setKey(0); + } + + IEAVRPI2(&rc, &info->authLevel, token, &linkage, + &info->ownerStoken, &info->currentStoken, + &info->state, &info->releaseCode); + + if (isBranchLinkage) { + setKey(key); + if (wasProblemState) { + supervisorMode(FALSE); + } + } + + return rc; +} + int peTest(const PET *token, PEState *state, PEReleaseCode *releaseCode) { @@ -206,11 +238,11 @@ int peTest(const PET *token, return rc; } -int peTranfer(const PET *token, PET *newToken, - PEReleaseCode *releaseCode, - const PET *targetToken, - PEReleaseCode targetReleaseCode, - bool isBranchLinkage) { +int peTransfer(const PET *token, PET *newToken, + PEReleaseCode *releaseCode, + const PET *targetToken, + PEReleaseCode targetReleaseCode, + bool isBranchLinkage) { int32_t rc = 0; int32_t linkage = isBranchLinkage ? PE_LINKAGE_BRANCH : PE_LINKAGE_SVC; diff --git a/c/recovery.c b/c/recovery.c index 5052c03c0..d172baa0c 100644 --- a/c/recovery.c +++ b/c/recovery.c @@ -106,6 +106,8 @@ static void resetESPIE(int token) { supervisorMode(TRUE); } + + } static int setDummyESPIE() { @@ -134,7 +136,6 @@ static int setDummyESPIE() { : "r2" ); - ALLOC_STRUCT31( STRUCT31_NAME(parms31), STRUCT31_FIELDS( @@ -897,9 +898,7 @@ void recoveryDESCTs(){ #endif RecoveryContext *getRecoveryContext() { - srbPrintf("getRecoveryContext()\n"); #ifdef CUSTOM_CONTEXT_GETTER - srbPrintf("custom case\n"); return rcvrgcxt(); #else #ifdef __ZOWE_OS_ZOS @@ -1125,8 +1124,6 @@ static int establishRouterInternal(RecoveryContext *userContext, context = userContext; } - srbPrintf("recovery.c: about to set recovery context 0x%p frr?=%d\n", - context,frrRequired); int setRC = setRecoveryContext(context); if (setRC != RC_RCV_OK) { rc = RC_RCV_CONTEXT_NOT_SET; @@ -1695,7 +1692,6 @@ int recoveryPush(char *name, int flags, char *dumpTitle, CleanupFunction *userCleanupFunction, void * __ptr32 cleanupFunctionUserData) { RecoveryContext *context = getRecoveryContext(); - srbPrintf("rPush context=0x%p\n",context); if (context == NULL) { return RC_RCV_CONTEXT_NOT_FOUND; } @@ -1705,16 +1701,13 @@ int recoveryPush(char *name, int flags, char *dumpTitle, return RC_RCV_LNKSTACK_ERROR; } - srbPrintf("rpush.1\n"); RecoveryStateEntry *newEntry = addRecoveryStateEntry(context, name, flags, dumpTitle, userAnalysisFunction, analysisFunctionUserData, userCleanupFunction, cleanupFunctionUserData); - srbPrintf("rpush.2 newEntry=0x%p\n",newEntry); if (newEntry == NULL) { return RC_RCV_ALLOC_FAILED; } - srbPrintf("newEntry=0x%p\n",newEntry); newEntry->linkageStackToken = linkageStackToken; /* Extract key from the newly created stacked state. IPK cannot be used @@ -1796,8 +1789,6 @@ int recoveryPush(char *name, int flags, char *dumpTitle, : "r2", "r10", "r11", "r14", "r15" ); - srbPrintf("rPush after ASM\n"); - if (newEntry->state & RECOVERY_STATE_ABENDED) { if (newEntry->flags & RCVR_FLAG_DELETE_ON_RETRY) { removeRecoveryStateEntry(context); diff --git a/c/shrmem64.c b/c/shrmem64.c index e9d46e86f..56d664e42 100644 --- a/c/shrmem64.c +++ b/c/shrmem64.c @@ -19,6 +19,7 @@ #include "stdbool.h" #include "stddef.h" #include "stdint.h" +#include "stdio.h" #endif #include "shrmem64.h" @@ -82,6 +83,48 @@ static MemObj getSharedMemObject(uint64_t segmentCount, return result; } +static MemObj getCommonMemObject(uint64_t segmentCount, + MemObjToken token, + int key, + uint32_t *iarv64RC, + uint32_t *iarv64RSN){ + + MemObj result = 0; + int localRC = 0; + int localRSN = 0; + char parmList[IARV64_V4PLIST_SIZE] = {0}; + char keyByte = key & 0xF; + keyByte = (keyByte << 4); /* because there's always one more thing in MVS */ + + __asm( + ASM_PREFIX + " IARV64 REQUEST=GETCOMMON" + ",MOTKN=(%[token])" + ",COND=YES" + ",KEY=%[key]" + ",FPROT=NO" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList),[key]"m"(keyByte) + : "r0", "r1", "r14", "r15" + ); + + if (iarv64RC) { + *iarv64RC = localRC; + } + if (iarv64RSN) { + *iarv64RSN = localRSN; + } + + return result; +} + static void shareMemObject(MemObj object, MemObjToken token, uint32_t *iarv64RC, @@ -160,6 +203,42 @@ static void detachSingleSharedMemObject(MemObj object, } +static void detachSingleSharedMemObjectNotOwner(MemObj object, + MemObjToken token, + uint32_t *iarv64RC, + uint32_t *iarv64RSN) { + int localRC = 0; + int localRSN = 0; + char parmList[IARV64_V4PLIST_SIZE] = {0}; + + __asm( + ASM_PREFIX + " IARV64 REQUEST=DETACH" + ",MATCH=SINGLE" + ",MEMOBJSTART=(%[mobj])" + ",MOTKN=(%[token])" + ",MOTKNCREATOR=USER" + ",AFFINITY=LOCAL" + ",OWNER=NO" + ",COND=YES" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) + : "r0", "r1", "r14", "r15" + ); + + if (iarv64RC) { + *iarv64RC = localRC; + } + if (iarv64RSN) { + *iarv64RSN = localRSN; + } + +} + static void detachSharedMemObjects(MemObjToken token, uint32_t *iarv64RC, uint32_t *iarv64RSN) { @@ -310,6 +389,36 @@ int shrmem64Alloc(MemObjToken userToken, size_t size, void **result, int *rsn) { return RC_SHRMEM64_OK; } +int shrmem64CommonAlloc(MemObjToken userToken, size_t size, void **result, int *rsn) { + return shrmem64CommonAlloc2(userToken,size,0,result,rsn); +} + +int shrmem64CommonAlloc2(MemObjToken userToken, size_t size, int key, void **result, int *rsn) { + + uint32_t iarv64RC = 0, iarv64RSN = 0; + + /* + * Convert size in bytes into segments (megabytes), round up if necessary. + */ + uint64_t segmentCount = 0; + if ((size & 0xFFFFF) == 0) { + segmentCount = size >> 20; + } else{ + segmentCount = (size >> 20) + 1; + } + + MemObj mobj = getCommonMemObject(segmentCount, userToken, key, + &iarv64RC, &iarv64RSN); + if (!isIARV64OK(iarv64RC)) { + *rsn = makeRSN(RC_SHRMEM64_GETCOMMON_FAILED, iarv64RC, iarv64RSN); + return RC_SHRMEM64_GETSHARED_FAILED; + } + + *result = (void *)mobj; + + return RC_SHRMEM64_OK; +} + int shrmem64Release(MemObjToken userToken, void *target, int *rsn) { uint32_t iarv64RC = 0, iarv64RSN = 0; @@ -368,6 +477,25 @@ int shrmem64RemoveAccess(MemObjToken userToken, void *target, int *rsn) { return RC_SHRMEM64_OK; } +int shrmem64RemoveAccess2(MemObjToken userToken, void *target, bool isOwner, int *rsn) { + + uint32_t iarv64RC = 0, iarv64RSN = 0; + + MemObj mobj = (MemObj)target; + + if (isOwner){ + detachSingleSharedMemObject(mobj, userToken, &iarv64RC, &iarv64RSN); + } else{ + detachSingleSharedMemObjectNotOwner(mobj, userToken, &iarv64RC, &iarv64RSN); + } + if (!isIARV64OK(iarv64RC)) { + *rsn = makeRSN(RC_SHRMEM64_DETACH_FAILED, iarv64RC, iarv64RSN); + return RC_SHRMEM64_DETACH_FAILED; + } + + return RC_SHRMEM64_OK; +} + /* This program and the accompanying materials are diff --git a/c/utils.c b/c/utils.c index c9a9183b3..bc37e662f 100644 --- a/c/utils.c +++ b/c/utils.c @@ -667,6 +667,9 @@ void hexdump(char *buffer, int length, int nominalStartAddress, int formatWidth, } else{ linePos += sprintf(lineBuffer+linePos," "); } + if ((pos % 4) == 3){ + linePos += sprintf(lineBuffer+linePos," "); + } } linePos += sprintf(lineBuffer+linePos,"%s|",pad2); for (pos=0; posblockCount);fflush(stdout); */ int remainingHeapBytes = (slh->blockSize * (slh->maxBlocks - slh->blockCount)); if (size > remainingHeapBytes){ - printf("cannot allocate above block size %d > %d mb %d bc %d\n",size,remainingHeapBytes,slh->maxBlocks,slh->blockCount); + printf("SLH at 0x%p cannot allocate above block size %d > %d mxbl %d bkct %d bksz %d\n", + slh,size,remainingHeapBytes,slh->maxBlocks,slh->blockCount,slh->blockSize); + + char *mem = (char*)0; + mem[0] = 13; return NULL; } else if (size > slh->blockSize){ char *bigBlock = (slh->is64 ? diff --git a/h/le.h b/h/le.h index 56a8903fb..964fed720 100644 --- a/h/le.h +++ b/h/le.h @@ -45,7 +45,7 @@ typedef struct CAA_tag{ char ceecaalangp; /* PL/I flags */ char reserved003[5]; Addr31 ceecaabos; /* start of current storage segment */ - Addr31 ceecaaeoc; /* end of current storage segment */ + Addr31 ceecaaeos; /* end of current storage segment */ char reserved010[0x034]; short reserved044; short ceecaatorc; /* thread return code */ diff --git a/h/pause-element.h b/h/pause-element.h index 22e97b142..556b590cf 100644 --- a/h/pause-element.h +++ b/h/pause-element.h @@ -83,6 +83,7 @@ ZOWE_PRAGMA_PACK_RESET #define pePause PETPAUSE #define peRelease PETRLS #define peRetrieveInfo PETINFO +#define peRetrieveInfo2 PETINF2 #define peTest PETTEST #define peTranfer PETTRNFR @@ -169,6 +170,11 @@ int peRetrieveInfo(const PET *token, PEInfo *info, bool isBranchLinkage); +int peRetrieveInfo2(const PET *token, + PEInfo *info, + bool isBranchLinkage, + bool untrusted); + /** * @brief Test a pause element and determines its state. The caller is * responsible for providing any needed recovery. The call will ABEND if a bad @@ -207,11 +213,11 @@ int peTest(const PET *token, * * @return The IEAVXFR2 return code value. */ -int peTranfer(const PET *token, PET *newToken, - PEReleaseCode *releaseCode, - const PET *targetToken, - PEReleaseCode targetReleaseCode, - bool isBranchLinkage); +int peTransfer(const PET *token, PET *newToken, + PEReleaseCode *releaseCode, + const PET *targetToken, + PEReleaseCode targetReleaseCode, + bool isBranchLinkage); #endif /* SRC_PAUSE_ELEMENT_H_ */ diff --git a/h/shrmem64.h b/h/shrmem64.h index 91bf663ba..9e114aafe 100644 --- a/h/shrmem64.h +++ b/h/shrmem64.h @@ -64,6 +64,11 @@ MemObjToken shrmem64GetAddressSpaceToken(void); */ int shrmem64Alloc(MemObjToken userToken, size_t size, void **result, int *rsn); +/** Variant for common (shared with everybody!) + */ +int shrmem64CommonAlloc(MemObjToken userToken, size_t size, void **result, int *rsn); +int shrmem64CommonAlloc2(MemObjToken userToken, size_t size, int key, void **result, int *rsn); + /** * @brief Releases 64-bit shared storage. The storage will still be accessible * in the address spaces that have issued shrmem64GetAccess. No new access can @@ -121,6 +126,7 @@ int shrmem64GetAccess(MemObjToken userToken, void *target, int *rsn); * @return One of the RC_SHRMEM64_xx return codes. */ int shrmem64RemoveAccess(MemObjToken userToken, void *target, int *rsn); +int shrmem64RemoveAccess2(MemObjToken userToken, void *target, bool isOwner, int *rsn); #define RC_SHRMEM64_OK 0 #define RC_SHRMEM64_GETSHARED_FAILED 8 @@ -128,6 +134,7 @@ int shrmem64RemoveAccess(MemObjToken userToken, void *target, int *rsn); #define RC_SHRMEM64_ALL_SYS_DETACH_FAILED 10 #define RC_SHRMEM64_SINGLE_SYS_DETACH_FAILED 11 #define RC_SHRMEM64_DETACH_FAILED 12 +#define RC_SHRMEM64_GETCOMMON_FAILED 13 #endif /* SRC_SHRMEM64_H_ */ diff --git a/h/zos.h b/h/zos.h index 7668d3352..e9c109621 100644 --- a/h/zos.h +++ b/h/zos.h @@ -673,7 +673,15 @@ typedef struct tcb_tag{ Addr31 tcbback; /* 0xDC - previous entry on queue */ Addr31 tcbrtwa; /* 0xE0 - Pointer to RTM2 work area */ char undifferentiated1[0x1C]; - char undifferentiated2[0x38]; /* 0x100 */ + /* OFFSET 0x100 */ + char tcbtcbid[4]; /* eyecatcher */ + Addr31 tcbrtm12; + char tcbscbky; + char tcbestrm; + char tcbertyp; + char tcbmode; + /* 0x10C */ + char undifferentiated2[0x2C]; /* 0x100 */ Addr31 tcbstcb; char undifferentiated3[0x18]; /* 0x100 */ Addr31 tcbsenv; /* securirt environment, 0 or ACEE, 0 means use ASCB/ASXB env */ @@ -747,6 +755,23 @@ typedef struct stcb_tag{ Serialization: run under this task. */ Addr31 stcblaa; /* Address of LE Library Anchor Area */ Addr31 stcbpie; /* Address of PIE control block */ + char stcbpmsk; /* Program mask at time of SPIE initiation */ + char stcbflg8; /* Flags include 80-ESPIE-(not-SPIE), 40-ESPIE-SRB-SHOULD-CALL-LE */ + short stcbspov; /* count of SPIE/ESPIE overrdies */ + /* Offset 0x210 */ + Addr31 stcbrbp; /* Address of RB which had the program interrupt */ + char reserved214; + char stcbilc; /* instruction length code */ + unsigned short stcbintc; /* PIC code */ + char stcbppsw[8]; /* PSW at program interrupt */ + /* Offset 0x220 */ + Addr31 stcbrpp; /* PICA (SPIE definition) */ + Addr31 stcbfrpq; /* Free RPP queue header */ + Addr31 stcblscr; /* Linkage stack control register at time of error for ESPIE */ + unsigned int stcbsars[16]; /* Access registers at time of error */ + /* offset 0x26C */ + char stcbwork[4]; /* Work area used during ESPIE */ + } STCB; /* See for OMVS structs: From f9307521f72e0d5af9e219bc678141420f2f5184 Mon Sep 17 00:00:00 2001 From: Joe Devlin Date: Wed, 28 Jul 2021 00:10:13 -0500 Subject: [PATCH 03/33] Cleaning some traces, some small fixes, too Signed-off-by: Joe Devlin --- c/crossmemory.c | 165 ++++++++++--- c/httpserver.c | 31 +-- c/metalio.c | 78 +++++++ c/radmin.c | 1 + c/recovery.c | 44 +++- c/shrmem64.c | 598 +++++++++++++++++++++++++++++++++++++++++------- c/utils.c | 4 +- h/crossmemory.h | 24 ++ h/metalio.h | 1 + h/recovery.h | 12 +- h/shrmem64.h | 16 +- h/zos.h | 2 +- h/zowetypes.h | 2 +- 13 files changed, 839 insertions(+), 139 deletions(-) diff --git a/c/crossmemory.c b/c/crossmemory.c index e6e419e1b..1d8b04742 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -35,6 +35,7 @@ #include "lpa.h" #include "nametoken.h" #include "zos.h" +#include "recovery.h" #include "printables_for_dump.h" #include "qsam.h" #include "resmgr.h" @@ -482,7 +483,7 @@ typedef struct CrossMemoryServerDumpServiceParm_tag { #define CMS_DUMP_SERVICE_PARM_EYECATCHER "ZWESXDSV" #define CMS_DUMP_SERVICE_VERSION 1 - // TODO we can improve the data size limit by passing the data address itself + /* TODO we can improve the data size limit by passing the data address itself */ #define CMS_DUMP_SERVICE_MAX_DATA_SIZE 512 #define CMS_DUMP_SERVICE_MAX_DESC_SIZE 32 @@ -941,25 +942,7 @@ int cmsAddConfigParm(CrossMemoryServer *server, return RC_CMS_OK; } -ZOWE_PRAGMA_PACK - -typedef struct RACFEnityName_tag { - short bufferLength; - short entityLength; - char entityName[255]; - char padding[7]; -} RACFEnityName; - -typedef enum RACFAccessAttribute_tag { - RACF_ACCESS_ATTRIBUTE_READ = 0x02, - RACF_ACCESS_ATTRIBUTE_UPDATE = 0x04, - RACF_ACCESS_ATTRIBUTE_CONTROL = 0x08, - RACF_ACCESS_ATTRIBUTE_ALTER = 0x08, -} RACFAccessAttribute; - -ZOWE_PRAGMA_PACK_RESET - -static void racfEntityNameInit(RACFEnityName *string, char *cstring, char padChar) { +static void safEntityNameInit(SAFEnityName *string, char *cstring, char padChar) { memset(string->entityName, padChar, sizeof(string->entityName)); unsigned int cstringLength = strlen(cstring); unsigned int copyLength = cstringLength > sizeof(string->entityName) ? sizeof(string->entityName) : cstringLength; @@ -1127,7 +1110,7 @@ static int racrouteLIST(char *className, int *racfRC, int *racfRSN) { __asm("GLBFSTAP RACROUTE REQUEST=FASTAUTH,MF=L" : "DS"(GLBFSTAP)); -static int racroutFASTAUTH(ACEE *acee, char *className, char *profileName, RACFAccessAttribute accessLevel, +static int racroutFASTAUTH(ACEE *acee, char *className, char *profileName, SAFAccessAttribute accessLevel, int *racfRC, int *racfRSN, int traceLevel) { __asm("GLBFSTAP RACROUTE REQUEST=FASTAUTH,MF=L" : "DS"(fastauthParmList)); @@ -1140,8 +1123,8 @@ static int racroutFASTAUTH(ACEE *acee, char *className, char *profileName, RACFA EightCharString class; eightCharStringInit(&class, className, ' '); - RACFEnityName profile; - racfEntityNameInit(&profile, profileName, ' '); + SAFEnityName profile; + safEntityNameInit(&profile, profileName, ' '); int safRC = 0; @@ -1185,6 +1168,8 @@ static bool isAuthCheckRequired(const CrossMemoryServerGlobalArea *globalArea) { } static bool isCallerAuthorized(CrossMemoryServerGlobalArea *globalArea, + char *className, + char *entityName, bool noSAFRequested) { if (noSAFRequested) { @@ -1212,7 +1197,7 @@ static bool isCallerAuthorized(CrossMemoryServerGlobalArea *globalArea, } int racfRC = 0, racfRSN = 0; - int safRC = racroutFASTAUTH(callerACEEAddr, "FACILITY", CROSS_MEMORY_SERVER_RACF_PROFILE, RACF_ACCESS_ATTRIBUTE_READ, &racfRC, &racfRSN, 0); + int safRC = racroutFASTAUTH(callerACEEAddr, className, entityName, SAF_ACCESS_ATTRIBUTE_READ, &racfRC, &racfRSN, 0); if (safRC != 0) { return FALSE; } @@ -1220,6 +1205,24 @@ static bool isCallerAuthorized(CrossMemoryServerGlobalArea *globalArea, return TRUE; } +bool cmsTestAuth(CrossMemoryServerGlobalArea *globalArea, + char *className, + char *entityName){ + ACEE callerACEE; + ACEE *callerACEEAddr = NULL; + cmGetCallerAddressSpaceACEE(&callerACEE, &callerACEEAddr); + if (callerACEEAddr == NULL) { + return FALSE; + } + int racfRC = 0, racfRSN = 0; + int safRC = racroutFASTAUTH(callerACEEAddr, className, entityName, SAF_ACCESS_ATTRIBUTE_READ, &racfRC, &racfRSN, 0); + if (safRC != 0) { + return FALSE; + } + return TRUE; + +} + ZOWE_PRAGMA_PACK typedef struct LatentParmList_tag { @@ -1728,9 +1731,87 @@ static int handleStandardService(CrossMemoryServer *server, CrossMemoryServerPar return status; } +typedef struct ABENDInfo_tag { + char eyecatcher[8]; +#define ABEND_INFO_EYECATCHER "CMSABEDI" + int completionCode; + int reasonCode; +} ABENDInfo; + +typedef struct SDWAARC1_tag{ + char blob[0x1C8]; /* Access Registers start at D8 */ +} SDWAARC1; + +static void extractServiceFunctionAbendInfo(RecoveryContext * __ptr32 context, + SDWA * __ptr32 sdwa, + void * __ptr32 userData){ + authWTOPrintf("ZOWE ZIS plugin encountered an abend\n"); + ABENDInfo *info = (ABENDInfo *)userData; + + if (sdwa){ + int reason = 0; + + int cc = (sdwa->flagsAndCode >> 12) & 0x00000FFF; + int flags = (sdwa->flagsAndCode >> 24) & 0x000000FF; + SDWAPTRS *sdwaptrs = NULL; + SDWAARC4 *sdwaarc4 = NULL; + SDWAARC1 *sdwaarc1 = NULL; + + if (flags & 0x04) { + char *sdwadata = (char*)sdwa; + sdwaptrs = (SDWAPTRS *)(sdwa->sdwaxpad); + if (sdwaptrs != NULL) { + char *sdwarc1 = (char *)sdwaptrs->sdwasrvp; + if (sdwarc1 != NULL) { + reason = *(int * __ptr32)(sdwarc1 + 44); + } + sdwaarc4 = (SDWAARC4*)(sdwaptrs->sdwaxeme); + sdwaarc1 = (SDWAARC1*)(sdwaptrs->sdwasrvp); + } + } + authWTOPrintf("SDWA Code 0x%03x, reason=0x%x flags=0x%03x\n",cc,reason,flags); + authWTOPrintf("TCB: 0x%08x\n",*((int*)CURRENT_TCB)); + authWTOPrintf("PIC: 0x%04X\n",(uint16_t)sdwa->sdwaintp); + authWTOPrintf("EC1: 0x%016llx\n",(uint64_t)sdwa->sdwaec1); + authWTOPrintf("EC2: 0x%016llx\n",(uint64_t)sdwa->sdwaec2); + if (sdwaarc4){ + authWTOPrintf("BEA: 0x%llx\n",sdwaarc4->sdwabea); + } + for (int i=0; i<16; i++){ + if (sdwaarc4){ + authWTOPrintf("R%2d: %016llX ",i,(sdwaarc4->gprs[i])); + } else{ + authWTOPrintf("R%2d: __xxxx__%08X ",i,(sdwa->lowGPRs[i])); + } + if ((i % 4) == 3){ + authWTOPrintf("\n"); + } + } + if (sdwaarc1){ + authWTOPrintf("SDWAARC1 (has CR's and AR's)\n"); + /* dumpbuffer((char*)sdwaarc1,0x118); */ + } + int codeWindowSize = 0x60; + /* do things that touch memory after dumping anything of value from the SDWA */ + uint64_t failedInstructionAddress = (sdwa->sdwaec1&0x7FFFFFFF); + authWTOPrintf("Code near PSW at 0x%llx\n",failedInstructionAddress); + char *codePointer = (char*)(failedInstructionAddress & (~3)); + codePointer -= 20; + for (int i=0; i<10; i++){ + authWTOPrintf("Inst Stream at 0x%08p: 0x%08x\n",codePointer,*((int*)codePointer)); + codePointer += 4; + } + authWTOPrintf("end of abended PC call info\n"); + } else{ + authWTOPrintf("No SDWA for ABEND, this is going to be some tough sledding.\n"); + } +} + + static int handleUnsafeProgramCall(PCHandlerParmList *parmList, bool isSpaceSwitchPC) { + ABENDInfo abendInfo; LatentParmList *latentParmList = parmList->latentParmList; CrossMemoryServerGlobalArea *globalArea = latentParmList->parm1; @@ -1759,6 +1840,8 @@ static int handleUnsafeProgramCall(PCHandlerParmList *parmList, } if (!isCallerAuthorized(globalArea, + "FACILITY", + CROSS_MEMORY_SERVER_RACF_PROFILE, localParmList.flags & CMS_PARMLIST_FLAG_NO_SAF_CHECK)) { return RC_CMS_PERMISSION_DENIED; @@ -1791,8 +1874,10 @@ static int handleUnsafeProgramCall(PCHandlerParmList *parmList, int returnCode = RC_CMS_OK; int pushRC = recoveryPush("CMS service function call", - RCVR_FLAG_RETRY | RCVR_FLAG_DELETE_ON_RETRY | RCVR_FLAG_PRODUCE_DUMP, - "RCMS", NULL, NULL, NULL, NULL); + RCVR_FLAG_RETRY | RCVR_FLAG_DELETE_ON_RETRY | RCVR_FLAG_SDWA_TO_LOGREC, + "RCMS", + extractServiceFunctionAbendInfo, &abendInfo, + NULL, NULL); if (pushRC == RC_RCV_OK) { @@ -1847,7 +1932,7 @@ static int handleProgramCall(PCHandlerParmList *parmList, bool isSpaceSwitchPC) int returnCode = RC_CMS_OK; int pushRC = recoveryPush("CMS PC handler", - RCVR_FLAG_RETRY | RCVR_FLAG_DELETE_ON_RETRY, + RCVR_FLAG_RETRY | RCVR_FLAG_DELETE_ON_RETRY | RCVR_FLAG_SDWA_TO_LOGREC, "RCMS", NULL, NULL, NULL, NULL); if (pushRC == RC_RCV_OK) { @@ -2858,6 +2943,12 @@ static int establishPCRoutines(CrossMemoryServer *server) { server->globalArea->pcInfo.pccpPCNumber = elxList.entries[0].pcNumber + 1; server->globalArea->pcInfo.pccpSequenceNumber = elxList.entries[0].sequenceNumber; + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_DEBUG, CMS_LOG_DEBUG_MSG_ID" PCSS num 0x%x seq 0x%x, PCCP num 0x%x seq 0x%x\n", + server->globalArea->pcInfo.pcssPCNumber, + server->globalArea->pcInfo.pcssSequenceNumber, + server->globalArea->pcInfo.pccpPCNumber, + server->globalArea->pcInfo.pccpSequenceNumber); + return RC_CMS_OK; } @@ -3350,13 +3441,6 @@ static void reportCommandStatus(char *commandVerb, } -typedef struct ABENDInfo_tag { - char eyecatcher[8]; -#define ABEND_INFO_EYECATCHER "CMSABEDI" - int completionCode; - int reasonCode; -} ABENDInfo; - static void extractABENDInfo(RecoveryContext * __ptr32 context, SDWA * __ptr32 sdwa, void * __ptr32 userData) { @@ -4652,7 +4736,7 @@ int cmsCallService3(CrossMemoryServerGlobalArea *cmsGlobalArea, serviceRC); } -int cmsPrintf(const CrossMemoryServerName *serverName, const char *formatString, ...) { +int vcmsPrintf(const CrossMemoryServerName *serverName, const char *formatString, va_list argPointer){ CrossMemoryServerLogServiceParm msgParmList; memcpy(&msgParmList.eyecatcher, CMS_LOG_SERVICE_PARM_EYECATCHER, sizeof(msgParmList.eyecatcher)); @@ -4660,10 +4744,7 @@ int cmsPrintf(const CrossMemoryServerName *serverName, const char *formatString, LogMessagePrefix *prefix = &msgParmList.prefix; initLogMessagePrefix(prefix); - va_list argPointer; - va_start(argPointer, formatString); int charactersToBeWritten = vsnprintf(msgParmList.text, sizeof(msgParmList.text), formatString, argPointer); - va_end(argPointer); if (charactersToBeWritten < 0) { return RC_CMS_VSNPRINTF_FAILED; @@ -4677,6 +4758,14 @@ int cmsPrintf(const CrossMemoryServerName *serverName, const char *formatString, return cmsCallService(serverName, CROSS_MEMORY_SERVER_LOG_SERVICE_ID, &msgParmList, NULL); } +int cmsPrintf(const CrossMemoryServerName *serverName, const char *formatString, ...) { + va_list argPointer; + va_start(argPointer, formatString); + int result = vcmsPrintf(serverName,formatString,argPointer); + va_end(argPointer); + return result; +} + int cmsHexDump(const CrossMemoryServerName *serverName, const void *data, unsigned size, const char *description) { diff --git a/c/httpserver.c b/c/httpserver.c index 3a66b0b5f..48c522750 100644 --- a/c/httpserver.c +++ b/c/httpserver.c @@ -2445,9 +2445,16 @@ static int proxyServe(HttpService *service, static char *getCookieValue(HttpRequest *request, char *cookieName){ HttpHeader *cookieHeader = getHeader(request,"Cookie"); ShortLivedHeap *slh = request->slh; - char *cookieText = cookieHeader->nativeValue; - int cookieTextLength = strlen(cookieText); - int cookieNameLength = strlen(cookieName); + int cookieTextLength = 0; + int cookieNameLength = 0; + char *cookieText = NULL; + if (cookieHeader != NULL){ + cookieText = cookieHeader->nativeValue; + cookieTextLength = strlen(cookieText); + cookieNameLength = strlen(cookieName); + } else{ + return NULL; + } int pos = 0; while (posusername, request->password, &status); - authResponse->type = AUTH_TYPE_RACF; authResponse->responseDetails.safStatus = status.safStatus; @@ -2572,8 +2578,8 @@ static int safAuthenticate(HttpService *service, HttpRequest *request, AuthRespo static int nativeAuth(HttpService *service, HttpRequest *request, AuthResponse *authResponse){ #ifdef __ZOWE_OS_ZOS - printf("nativeAuth about to bless this request 0x%p\n",request); - return TRUE; /* safAuthenticate(service, request, authResponse); */ + int retValue = safAuthenticate(service, request, authResponse); + return retValue; #else #ifdef DEBUG_AUTH printf("*** ERROR *** native auth not implemented for this platform\n"); @@ -3292,6 +3298,10 @@ static void serveRequest(HttpService* service, HttpResponse* response, serveSimpleTemplate(service, response); // Response is finished on return } else { + /* + bills + try normal login and trace with Sean + */ service->serviceFunction(service, response); } } @@ -3355,7 +3365,6 @@ static int handleHttpService(HttpServer *server, HttpService *service, HttpRequest *request, HttpResponse *response){ - #ifdef __ZOWE_OS_ZOS HttpConversation *conversation = response->conversation; @@ -3398,9 +3407,7 @@ static int handleHttpService(HttpServer *server, int clearSessionToken = FALSE; AuthResponse authResponse; - int authTypeHack = service->authType; - authTypeHack = SERVICE_AUTH_NONE; - switch (authTypeHack){ + switch (service->authType){ case SERVICE_AUTH_NONE: request->authenticated = TRUE; break; @@ -3981,7 +3988,6 @@ void respondWithUnixFileContents2 (HttpService* service, HttpResponse* response, // Response must ALWAYS be finished on return void respondWithUnixFileContentsWithAutocvtMode (HttpService* service, HttpResponse* response, char* absolutePath, int jsonMode, int autocvt) { - printf("JOE: respondWithUnixFileContentsWithAutocvtMode path=%s, jsonMode=%d autocvt=%d\n",absolutePath,jsonMode,autocvt); FileInfo info; int returnCode; int reasonCode; @@ -4200,7 +4206,6 @@ void respondWithUnixFile2(HttpService* service, HttpResponse* response, char* ab service->customHeadersFunction(service, response); } - printf("JOE: isBinary=%d ccsi=%d\n",isBinary,ccsid); if (isBinary || ccsid == -1) { writeHeader(response); #ifdef DEBUG diff --git a/c/metalio.c b/c/metalio.c index a8a3fbcf5..9d4264d85 100644 --- a/c/metalio.c +++ b/c/metalio.c @@ -407,6 +407,43 @@ void message(char *message){ ); } +/* this can only be called from authorized callers */ +static void authWTOMessage(char *message){ + + ALLOC_STRUCT31( + STRUCT31_NAME(below2G), + STRUCT31_FIELDS( + WTOCommon31 common; + char text[126]; /* Maximum length of WTO text is 126 - ABEND D23-xxxx0005 if longer than 126 */ + ) + ); + + int len = strlen(message); + if (len>sizeof(below2G->text)) + len=sizeof(below2G->text); + + below2G->common.length = len+sizeof(below2G->common); /* +4 for header */ + memcpy(below2G->text,message,len); + + __asm(ASM_PREFIX +#ifdef _LP64 + " SAM31 \n" + " SYSSTATE AMODE64=NO \n" +#endif + " WTO LINKAGE=BRANCH,MF=(E,(%[wtobuf])) \n" +#ifdef _LP64 + " SAM64 \n" + " SYSSTATE AMODE64=YES \n" +#endif + : + :[wtobuf]"NR:r1"(&below2G->common) + :"r0","r1","r15"); + + FREE_STRUCT31( + STRUCT31_NAME(below2G) + ); +} + /* If descriptorCode and routingCode are both 0, then indicate to use system defaults */ void sendWTO(int descriptorCode, int routingCode, char *message, int length){ @@ -449,6 +486,7 @@ void sendWTO(int descriptorCode, int routingCode, char *message, int length){ STRUCT31_NAME(below2G) ); } + #define WTO_MAX_SIZE 126 void wtoPrintf(char *formatString, ...){ char text[WTO_MAX_SIZE+1]; /* Allow for trailing null character */ @@ -490,6 +528,46 @@ void wtoPrintf(char *formatString, ...){ message(text); } +void authWTOPrintf(char *formatString, ...){ + char text[WTO_MAX_SIZE+1]; /* Allow for trailing null character */ + va_list argPointer; + int cnt; + + for (int pass=0; pass<2; pass++){ + + /* The resulting text string from vsnprintf is unpredictable if + there is an error in the format string or arguments. In that + case we will set the output text area to null, repeat the + vsnprintf, and then find the length of the null terminated + string. This avoids initializing the output text area prior + to every successful request. + */ + + va_start(argPointer,formatString); + cnt = vsnprintf(text,sizeof(text),formatString,argPointer); + va_end(argPointer); + + if (cnt<0){ + if (pass==0) + memset(text,0,sizeof(text)); /* Clear the text buffer before retrying the vsnprint request */ + else { + text[WTO_MAX_SIZE] = 0; /* Ensure strlen stops at the end of the text buffer */ + cnt = strlen(text); /* Find the end of the text string */ + } + } else + break; /* vsnprintf did not return an error - cnt was set */ + } + if (cnt>WTO_MAX_SIZE) /* If more data to format than the text buffer length */ + cnt = WTO_MAX_SIZE; /* Truncate the formatted length to the text buffer length */ + + /* We never want to include a final \n character in the WTO text */ + + if (cnt>0 && text[cnt-1] == '\n') /* If text ends with \n */ + text[cnt-1] = 0; /* Change it into a null character */ + + authWTOMessage(text); +} + void qsamPrintf(char *formatString, ...){ va_list argPointer; diff --git a/c/radmin.c b/c/radmin.c index 06145d06b..8c27af1dd 100644 --- a/c/radmin.c +++ b/c/radmin.c @@ -402,6 +402,7 @@ int radminRunRACFCommand( int rc = RC_RADMIN_OK; RadminCommandOutput * __ptr32 result = NULL; + /* i think the ampersand operator will introduce a 64-bit pointer 3 lines down */ RadminAPIStatus statusOnStack; RadminAPIStatus *__ptr32 apiStatus31 = runRACFCommand(callAuthInfo, internalCommand, diff --git a/c/recovery.c b/c/recovery.c index d172baa0c..33fdd2880 100644 --- a/c/recovery.c +++ b/c/recovery.c @@ -526,11 +526,15 @@ static void * __ptr32 getRecoveryRouterAddress() { " LGR 1,11 CONTEXT AS THE FIRST PARM \n" " LGR 2,9 SDWA AS THE SECOND PARM \n" " LLGT 3,RSTAFUD USER DATA AS THE THIRD PARM \n" - " LG 4,RSTRGPR+32 STACK \n" + /* " LG 4,RSTRGPR+32 STACK \n" */ + " LG 4,RAFSTPTR (JOE)ANALYSIS STACK \n" " LG 12,RSTRGPR+96 CAA \n" " LLGT 6,RSTAFEP ANALYSIS FUNCTION ENTRY POINT \n" " LG 5,RSTAFEV ANALYSIS FUNCTION ENVIRONMENT \n" + /* " LA 11,999 \n" + " ABEND 797 \n" */ " BASR 7,6 CALL ANALYSIS FUNCTION \n" + " LG 4,RSTRGPR+32 (JOE) SLIP THE 'REAL' STACK BACK \n" " NOPR 0 \n" #else #ifdef _LP64 @@ -867,6 +871,8 @@ void recoveryDESCTs(){ "RSTUFPB DS CL32 \n" "RSTRINF DS CL(RCVSINFL) \n" "RSTDMTLT DS CL101 \n" + " DS 0D \n" + "RAFSTPTR DS D \n" "RSTLEN EQU *-RCVSTATE \n" " EJECT , \n" @@ -1687,9 +1693,10 @@ static int16_t getLinkageStackToken(void) { return token; } -int recoveryPush(char *name, int flags, char *dumpTitle, - AnalysisFunction *userAnalysisFunction, void * __ptr32 analysisFunctionUserData, - CleanupFunction *userCleanupFunction, void * __ptr32 cleanupFunctionUserData) { +int recoveryPush2(char *name, int flags, char *dumpTitle, + AnalysisFunction *userAnalysisFunction, void * __ptr32 analysisFunctionUserData, + char *analysisFunctionStack, int analysisFunctionStackSize, + CleanupFunction *userCleanupFunction, void * __ptr32 cleanupFunctionUserData) { RecoveryContext *context = getRecoveryContext(); if (context == NULL) { @@ -1789,6 +1796,25 @@ int recoveryPush(char *name, int flags, char *dumpTitle, : "r2", "r10", "r11", "r14", "r15" ); + /* this need to be set up right as the "correct" value for R13 or R4 on + retry. + + + how to get back on the real stack - analysis function is void so + use logic that sets R4/R13 now to be the real stack to resume on + + */ +#if defined(_LP64) && !defined(METTLE) + char *analysisFunctionStackEnd = ((char*)analysisFunctionStack)+analysisFunctionStackSize; + /* verify these pointers - tuesday morning */ + + long long stackPtr = (long long)analysisFunctionStackEnd-0x1000; /* give it the 2048 bias + "wiggle room" */ + newEntry->analysisStackPtr = (analysisFunctionStack ? + stackPtr : + newEntry->retryGPRs[4]); +#else + newEntry->analysisStackPtr = (analysisFunctionStack ? (long long)analysisFunctionStack : newEntry->retryGPRs[13]); +#endif if (newEntry->state & RECOVERY_STATE_ABENDED) { if (newEntry->flags & RCVR_FLAG_DELETE_ON_RETRY) { removeRecoveryStateEntry(context); @@ -1800,6 +1826,16 @@ int recoveryPush(char *name, int flags, char *dumpTitle, return RC_RCV_OK; } +int recoveryPush(char *name, int flags, char *dumpTitle, + AnalysisFunction *userAnalysisFunction, void * __ptr32 analysisFunctionUserData, + CleanupFunction *userCleanupFunction, void * __ptr32 cleanupFunctionUserData) { + return recoveryPush2(name,flags,dumpTitle, + userAnalysisFunction,analysisFunctionUserData, + NULL,0, + userCleanupFunction,cleanupFunctionUserData); +} + + #elif defined(__ZOWE_OS_AIX) || defined(__ZOWE_OS_LINUX) /* recoveryPush is a macro on AIX and Linux */ diff --git a/c/shrmem64.c b/c/shrmem64.c index 56d664e42..dddcd4114 100644 --- a/c/shrmem64.c +++ b/c/shrmem64.c @@ -26,7 +26,7 @@ #include "zos.h" #ifndef _LP64 -#error ILP32 is not supported +/* #error ILP32 is not supported */ #endif typedef uint64_t MemObj; @@ -46,8 +46,118 @@ static int makeRSN(int shrmem64RC, int iarv64RC, int iarv64RSN) { return rc; } +#pragma pack(packed) + +#define IARV64_REQUEST_GETSTOR 1 +#define IARV64_REQUEST_GETSHARED 2 +#define IARV64_REQUEST_DETACH 3 +#define IARV64_REQUEST_PAGEFIX 4 +#define IARV64_REQUEST_PAGEUNFIX 5 +#define IARV64_REQUEST_PAGEOUT 6 +#define IARV64_REQUEST_DISCARDDATA 7 +#define IARV64_REQUEST_PAGEIN 8 +#define IARV64_REQUEST_PROTECT 9 +#define IARV64_REQUEST_SHAREMEMOBJ 10 +#define IARV64_REQUEST_CHANGEACCESS 11 +#define IARV64_REQUEST_UNPROTECT 12 +#define IARV64_REQUEST_CHANGEGUARD 13 +#define IARV64_REQUEST_LIST 14 /* wtf is this */ +#define IARV64_REQUEST_GETCOMMON 15 +#define IARV64_REQUEST_COUNTPAGES 16 +#define IARV64_REQUEST_PCIEFIX 17 +#define IARV64_REQUEST_PCIEUNFIX 18 +#define IARV64_REQUEST_CHANGEATTRIBUTE 19 + +#define IARV64_FLAGS0_MTOKNSOURCE_SYSTEM 0x80 +#define IARV64_FLAGS0_MTOKNSOURCE_CREATOR 0x40 +#define IARV64_FLAGS0_MATCH_MOTOKEN 0x20 + +#define IARV64_FLAGS1_KEYUSED_KEY 0x80 +#define IARV64_FLAGS1_KEYUSED_USERTKN 0x40 +#define IARV64_FLAGS1_KEYUSED_TTOKEN 0x20 +#define IARV64_FLAGS1_KEYUSED_CONVERTSTART 0x10 +#define IARV64_FLAGS1_KEYUSED_GUARDSIZE64 0x08 +#define IARV64_FLAGS1_KEYUSED_CONVERTSIZE64 0x04 +#define IARV64_FLAGS1_KEYUSED_MOTKN 0x02 +#define IARV64_FLAGS1_KEYUSED_OWNERJOBNAME 0x01 + +#define IARV64_FLAGS2_COND_YES 0x80 +#define IARV64_FLAGS2_FPROT_NO 0x40 +#define IARV64_FLAGS2_CONTROL_AUTH 0x20 +#define IARV64_FLAGS2_GUARDLOC_HIGH 0x10 +#define IARV64_FLAGS2_CHANGEACCESS_GLOBAL 0x08 +#define IARV64_FLAGS2_PAGEFRAMESIZE_1MEG 0x04 +#define IARV64_FLAGS2_PAGEFRAMESIZE_MAX 0x02 +#define IARV64_FLAGS2_PAGEFRAMESIZE_ALL 0x01 + +#define IARV64_FLAGS3_X 0 + + +#define IARV64_FLAGS4_XX 1 + +#define IARV64_FLAGS5_XX 1 /* dump flags */ + + +typedef struct IARV64_V4Parms_tag{ + char version; /* 4 is the ly answer */ + char request; /* 2 is GETSHARED */ + char flags0; + char key; + char flags1; + char flags2; + char flags3; + char flags4; /* this one seems to have changeaccess.view=sharedwrite=0x10 */ + uint64_t segmentCount; + char ttoken[16]; /* i don't know the usage of this, but it is not filled in the calls in shrmem64 */ + /* offset 0x20 (32) */ + uint64_t token; /* input (literal token or address ??, probably address)*/ + uint64_t origin; /* output address */ + /* offset 0x30 (48) */ + uint64_t rangelistAddress; + uint64_t memobjStart; /* input */ + /* offset 0x40 (64) */ + uint32_t guardSize; + uint32_t convertSize; + uint32_t aletValue; + uint32_t numRange; /* number of ranges in range list */ + /* offset 0x50 (80) */ + uint32_t v64ListPtr; /* what is this? */ + uint32_t v64ListLength; /* what is this? */ + uint64_t convertStart; /* an address, i think */ + /* offset 0x60 (96) */ + uint64_t convertSize64; + uint64_t guardSize64; + /* offset 0x70 (112) */ + uint64_t userToken; /* how does this differ from token at offset 32?? */ + /* offset 0x78 (120) */ + char dumpPriority; + char flags5; + char flags6; + char flags7; + char dump; /* some constant */ + char flags8; + uint16_t ownerASID; + /* offset 0x80 (128) */ + char optionValue; + char unknown[8]; + char ownerJobName[8]; + char unknown145[7]; + /* offset 0x98 */ + uint64_t mapPageTable; + /* this next field is only in plist version = 5 and later */ + /* uint64_t units; + char flags9; + char flags10; + char flags11; + */ +} IARV64_V4Parms; + +#pragma pack(reset) + static MemObj getSharedMemObject(uint64_t segmentCount, MemObjToken token, + int key, + int alet, /* must be 0 (primary) or 2 (home) */ uint32_t *iarv64RC, uint32_t *iarv64RSN) { @@ -56,22 +166,88 @@ static MemObj getSharedMemObject(uint64_t segmentCount, int localRSN = 0; char parmList[IARV64_V4PLIST_SIZE] = {0}; - __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList) - : "r0", "r1", "r14", "r15" - ); + if (key == SHRMEM64_USE_CALLER_KEY){ + if (alet == 0){ + __asm( + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",ALETVALUE=0" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList) + : "r0", "r1", "r14", "r15" + ); + } else{ + __asm( + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",ALETVALUE=2" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList) + : "r0", "r1", "r14", "r15" + ); + } + } else{ + char keyByte = key & 0xF; + keyByte = (keyByte << 4); /* because there's always one more thing in MVS */ + if (alet == 0){ + __asm( + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",KEY=%[key]" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",ALETVALUE=0" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList),[key]"m"(keyByte) + : "r0", "r1", "r14", "r15" + ); + } else{ + __asm( + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",KEY=%[key]" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",ALETVALUE=2" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList),[key]"m"(keyByte) + : "r0", "r1", "r14", "r15" + ); + } + + } if (iarv64RC) { *iarv64RC = localRC; @@ -83,6 +259,116 @@ static MemObj getSharedMemObject(uint64_t segmentCount, return result; } +static MemObj getSharedMemObjectNoFPROT(uint64_t segmentCount, + MemObjToken token, + int key, + int alet, /* must be 0 (primary) or 2 (home) */ + uint32_t *iarv64RC, + uint32_t *iarv64RSN) { + + MemObj result = 0; + int localRC = 0; + int localRSN = 0; + char parmList[IARV64_V4PLIST_SIZE] = {0}; + + if (key == SHRMEM64_USE_CALLER_KEY){ + if (alet == 0){ + __asm( + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",FPROT=NO" + ",ALETVALUE=0" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList) + : "r0", "r1", "r14", "r15" + ); + } else{ + __asm( + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",FPROT=NO" + ",ALETVALUE=2" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList) + : "r0", "r1", "r14", "r15" + ); + } + } else{ + char keyByte = key & 0xF; + keyByte = (keyByte << 4); /* because there's always one more thing in MVS */ + if (alet == 0){ + __asm( + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",KEY=%[key]" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",FPROT=NO" + ",ALETVALUE=0" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList),[key]"m"(keyByte) + : "r0", "r1", "r14", "r15" + ); + } else{ + __asm( + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",KEY=%[key]" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",FPROT=NO" + ",ALETVALUE=2" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList),[key]"m"(keyByte) + : "r0", "r1", "r14", "r15" + ); + } + + } + + if (iarv64RC) { + *iarv64RC = localRC; + } + if (iarv64RSN) { + *iarv64RSN = localRSN; + } + + return result; +} + + static MemObj getCommonMemObject(uint64_t segmentCount, MemObjToken token, int key, @@ -127,6 +413,7 @@ static MemObj getCommonMemObject(uint64_t segmentCount, static void shareMemObject(MemObj object, MemObjToken token, + int aletValue, uint32_t *iarv64RC, uint32_t *iarv64RSN) { @@ -140,22 +427,104 @@ static void shareMemObject(MemObj object, } rangeList = {object, 0}; uint64_t rangeListAddress = (uint64_t)&rangeList; + + if (aletValue == 0){ + __asm( + ASM_PREFIX + " IARV64 REQUEST=SHAREMEMOBJ" + ",USERTKN=(%[token])" + ",RANGLIST=(%[range])" + ",NUMRANGE=1" + ",COND=YES" + ",ALETVALUE=0" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [range]"r"(&rangeListAddress), [parm]"r"(&parmList) + : "r0", "r1", "r14", "r15" + ); + } else{ + __asm( + ASM_PREFIX + " IARV64 REQUEST=SHAREMEMOBJ" + ",USERTKN=(%[token])" + ",RANGLIST=(%[range])" + ",NUMRANGE=1" + ",COND=YES" + ",ALETVALUE=2" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [range]"r"(&rangeListAddress), [parm]"r"(&parmList) + : "r0", "r1", "r14", "r15" + ); + } - __asm( - ASM_PREFIX - " IARV64 REQUEST=SHAREMEMOBJ" - ",USERTKN=(%[token])" - ",RANGLIST=(%[range])" - ",NUMRANGE=1" - ",COND=YES" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [range]"r"(&rangeListAddress), [parm]"r"(&parmList) - : "r0", "r1", "r14", "r15" - ); + if (iarv64RC) { + *iarv64RC = localRC; + } + if (iarv64RSN) { + *iarv64RSN = localRSN; + } + +} + +static void makeSharedWritable(MemObj object, + uint64_t segmentCount, + /* MemObjToken token, */ + int aletValue, + uint32_t *iarv64RC, + uint32_t *iarv64RSN) { + int localRC = 0; + int localRSN = 0; + char parmList[IARV64_V4PLIST_SIZE] = {0}; + + struct { + MemObj vsa; + uint64_t numsegments; + } rangeList = {object, segmentCount }; + + uint64_t rangeListAddress = (uint64_t)&rangeList; + + if (aletValue == 0){ + __asm( + ASM_PREFIX + " IARV64 REQUEST=CHANGEACCESS" + ",VIEW=SHAREDWRITE" + /* ",USERTKN=(%[token])" */ + ",RANGLIST=(%[range])" + ",NUMRANGE=1" + ",ALETVALUE=0" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [range]"r"(&rangeListAddress), [parm]"r"(&parmList) + : "r0", "r1", "r14", "r15" + ); + } else{ + __asm( + ASM_PREFIX + " IARV64 REQUEST=CHANGEACCESS" + ",VIEW=SHAREDWRITE" + /* ",USERTKN=(%[token])" */ + ",RANGLIST=(%[range])" + ",NUMRANGE=1" + ",ALETVALUE=2" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [range]"r"(&rangeListAddress), [parm]"r"(&parmList) + : "r0", "r1", "r14", "r15" + ); + } if (iarv64RC) { *iarv64RC = localRC; @@ -168,6 +537,7 @@ static void shareMemObject(MemObj object, static void detachSingleSharedMemObject(MemObj object, MemObjToken token, + int aletValue, uint32_t *iarv64RC, uint32_t *iarv64RSN) { @@ -175,24 +545,46 @@ static void detachSingleSharedMemObject(MemObj object, int localRSN = 0; char parmList[IARV64_V4PLIST_SIZE] = {0}; - __asm( - ASM_PREFIX - " IARV64 REQUEST=DETACH" - ",MATCH=SINGLE" - ",MEMOBJSTART=(%[mobj])" - ",MOTKN=(%[token])" - ",MOTKNCREATOR=USER" - ",AFFINITY=LOCAL" - ",OWNER=YES" - ",COND=YES" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) - : "r0", "r1", "r14", "r15" - ); + if (aletValue == 0){ + __asm( + ASM_PREFIX + " IARV64 REQUEST=DETACH" + ",MATCH=SINGLE" + ",MEMOBJSTART=(%[mobj])" + ",MOTKN=(%[token])" + ",MOTKNCREATOR=USER" + ",AFFINITY=LOCAL" + ",OWNER=YES" + ",COND=YES" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) + : "r0", "r1", "r14", "r15" + ); + } else{ + __asm( + ASM_PREFIX + " IARV64 REQUEST=DETACH" + ",MATCH=SINGLE" + ",MEMOBJSTART=(%[mobj])" + ",MOTKN=(%[token])" + ",MOTKNCREATOR=USER" + ",AFFINITY=LOCAL" + ",OWNER=YES" + ",COND=YES" + ",ALETVALUE=2" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) + : "r0", "r1", "r14", "r15" + ); + } if (iarv64RC) { *iarv64RC = localRC; @@ -205,30 +597,54 @@ static void detachSingleSharedMemObject(MemObj object, static void detachSingleSharedMemObjectNotOwner(MemObj object, MemObjToken token, + int aletValue, uint32_t *iarv64RC, uint32_t *iarv64RSN) { int localRC = 0; int localRSN = 0; char parmList[IARV64_V4PLIST_SIZE] = {0}; - __asm( - ASM_PREFIX - " IARV64 REQUEST=DETACH" - ",MATCH=SINGLE" - ",MEMOBJSTART=(%[mobj])" - ",MOTKN=(%[token])" - ",MOTKNCREATOR=USER" - ",AFFINITY=LOCAL" - ",OWNER=NO" - ",COND=YES" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) - : "r0", "r1", "r14", "r15" - ); + if (aletValue == 0){ + __asm( + ASM_PREFIX + " IARV64 REQUEST=DETACH" + ",MATCH=SINGLE" + ",MEMOBJSTART=(%[mobj])" + ",MOTKN=(%[token])" + ",MOTKNCREATOR=USER" + ",AFFINITY=LOCAL" + ",OWNER=NO" + ",COND=YES" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) + : "r0", "r1", "r14", "r15" + ); + } else{ + __asm( + ASM_PREFIX + " IARV64 REQUEST=DETACH" + ",MATCH=SINGLE" + ",MEMOBJSTART=(%[mobj])" + ",MOTKN=(%[token])" + ",MOTKNCREATOR=USER" + ",AFFINITY=LOCAL" + ",OWNER=NO" + ",ALETVALUE=2" + ",COND=YES" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) + : "r0", "r1", "r14", "r15" + ); + + } if (iarv64RC) { *iarv64RC = localRC; @@ -363,7 +779,7 @@ MemObjToken shrmem64GetAddressSpaceToken(void) { return result.token; } -int shrmem64Alloc(MemObjToken userToken, size_t size, void **result, int *rsn) { +int shrmem64Alloc2(MemObjToken userToken, size_t size, int key, int aletValue, bool fetchProtect, void **result, int *rsn) { uint32_t iarv64RC = 0, iarv64RSN = 0; @@ -377,8 +793,11 @@ int shrmem64Alloc(MemObjToken userToken, size_t size, void **result, int *rsn) { segmentCount = (size >> 20) + 1; } - MemObj mobj = getSharedMemObject(segmentCount, userToken, - &iarv64RC, &iarv64RSN); + MemObj mobj = (fetchProtect ? + getSharedMemObject(segmentCount, userToken, key, aletValue, + &iarv64RC, &iarv64RSN) : + getSharedMemObjectNoFPROT(segmentCount, userToken, key, aletValue, + &iarv64RC, &iarv64RSN)); if (!isIARV64OK(iarv64RC)) { *rsn = makeRSN(RC_SHRMEM64_GETSHARED_FAILED, iarv64RC, iarv64RSN); return RC_SHRMEM64_GETSHARED_FAILED; @@ -389,6 +808,10 @@ int shrmem64Alloc(MemObjToken userToken, size_t size, void **result, int *rsn) { return RC_SHRMEM64_OK; } +int shrmem64Alloc(MemObjToken userToken, size_t size, void **result, int *rsn) { + return shrmem64Alloc2(userToken,size,SHRMEM64_USE_CALLER_KEY,0,true,result,rsn); +} + int shrmem64CommonAlloc(MemObjToken userToken, size_t size, void **result, int *rsn) { return shrmem64CommonAlloc2(userToken,size,0,result,rsn); } @@ -447,28 +870,46 @@ int shrmem64ReleaseAll(MemObjToken userToken, int *rsn) { return RC_SHRMEM64_OK; } -int shrmem64GetAccess(MemObjToken userToken, void *target, int *rsn) { +int shrmem64GetAccess2(MemObjToken userToken, void *target, bool makeWritable, int aletValue, uint64_t size, int *rsn) { uint32_t iarv64RC = 0, iarv64RSN = 0; + uint64_t segmentCount = 0; + if ((size & 0xFFFFF) == 0) { + segmentCount = size >> 20; + } else{ + segmentCount = (size >> 20) + 1; + } MemObj mobj = (MemObj)target; - shareMemObject(mobj, userToken, &iarv64RC, &iarv64RSN); + shareMemObject(mobj, userToken, aletValue, &iarv64RC, &iarv64RSN); if (!isIARV64OK(iarv64RC)) { *rsn = makeRSN(RC_SHRMEM64_SHAREMEMOBJ_FAILED, iarv64RC, iarv64RSN); return RC_SHRMEM64_SHAREMEMOBJ_FAILED; } + if (makeWritable){ + makeSharedWritable(mobj, segmentCount, aletValue, &iarv64RC, &iarv64RSN); + if (!isIARV64OK(iarv64RC)) { + *rsn = makeRSN(RC_SHRMEM64_CHANGEACCESS_FAILED, iarv64RC, iarv64RSN); + return RC_SHRMEM64_CHANGEACCESS_FAILED; + } + } return RC_SHRMEM64_OK; } +int shrmem64GetAccess(MemObjToken userToken, void *target, int *rsn) { + /* it's ok to not know the number of segments if not making the MemObj writable */ + return shrmem64GetAccess2(userToken,target,false,0,0,rsn); +} + int shrmem64RemoveAccess(MemObjToken userToken, void *target, int *rsn) { uint32_t iarv64RC = 0, iarv64RSN = 0; MemObj mobj = (MemObj)target; - detachSingleSharedMemObject(mobj, userToken, &iarv64RC, &iarv64RSN); + detachSingleSharedMemObject(mobj, userToken, 0, &iarv64RC, &iarv64RSN); if (!isIARV64OK(iarv64RC)) { *rsn = makeRSN(RC_SHRMEM64_DETACH_FAILED, iarv64RC, iarv64RSN); return RC_SHRMEM64_DETACH_FAILED; @@ -477,16 +918,16 @@ int shrmem64RemoveAccess(MemObjToken userToken, void *target, int *rsn) { return RC_SHRMEM64_OK; } -int shrmem64RemoveAccess2(MemObjToken userToken, void *target, bool isOwner, int *rsn) { +int shrmem64RemoveAccess2(MemObjToken userToken, void *target, int aletValue, bool isOwner, int *rsn) { uint32_t iarv64RC = 0, iarv64RSN = 0; MemObj mobj = (MemObj)target; if (isOwner){ - detachSingleSharedMemObject(mobj, userToken, &iarv64RC, &iarv64RSN); + detachSingleSharedMemObject(mobj, userToken, aletValue, &iarv64RC, &iarv64RSN); } else{ - detachSingleSharedMemObjectNotOwner(mobj, userToken, &iarv64RC, &iarv64RSN); + detachSingleSharedMemObjectNotOwner(mobj, userToken, aletValue, &iarv64RC, &iarv64RSN); } if (!isIARV64OK(iarv64RC)) { *rsn = makeRSN(RC_SHRMEM64_DETACH_FAILED, iarv64RC, iarv64RSN); @@ -506,3 +947,6 @@ int shrmem64RemoveAccess2(MemObjToken userToken, void *target, bool isOwner, int Copyright Contributors to the Zowe Project. */ + + + diff --git a/c/utils.c b/c/utils.c index bc37e662f..8aa2e905b 100644 --- a/c/utils.c +++ b/c/utils.c @@ -596,9 +596,9 @@ void dumpBufferToStream(const char *buffer, int length, /* FILE* */void *traceOu for (last_index = length-1; last_index>=0 && 0 == buffer[last_index]; last_index--){} if (last_index < 0) #ifdef METTLE - printf("the buffer is empty at %x\n",buffer); + printf("the buffer is empty at %p\n",buffer); #else - fprintf((FILE*)traceOut,"the buffer is empty at %x\n",buffer); + fprintf((FILE*)traceOut,"the buffer is empty at %p\n",buffer); #endif while (index <= last_index){ diff --git a/h/crossmemory.h b/h/crossmemory.h index eae084d32..616d371b6 100644 --- a/h/crossmemory.h +++ b/h/crossmemory.h @@ -359,6 +359,20 @@ typedef struct CrossMemoryServerStatus_tag { char descriptionNullTerm[64]; } CrossMemoryServerStatus; +typedef struct SAFEnityName_tag { + short bufferLength; + short entityLength; + char entityName[255]; + char padding[7]; +} SAFEnityName; + +typedef enum SAFAccessAttribute_tag { + SAF_ACCESS_ATTRIBUTE_READ = 0x02, + SAF_ACCESS_ATTRIBUTE_UPDATE = 0x04, + SAF_ACCESS_ATTRIBUTE_CONTROL = 0x08, + SAF_ACCESS_ATTRIBUTE_ALTER = 0x08, +} SAFAccessAttribute; + ZOWE_PRAGMA_PACK_RESET #define LOG_COMP_ID_CMS 0x008F0001000C0001LLU @@ -427,6 +441,11 @@ int cmsAddConfigParm(CrossMemoryServer *server, const char *name, const void *value, CrossMemoryServerParmType type); +bool cmsTestAuth(CrossMemoryServerGlobalArea *globalArea, + char *className, + char *entityName); + + /* Use these inside your service functions if they need ECSA. * The number of allocated blocks is tracked in the CMS global area. */ void *cmsAllocateECSAStorage(CrossMemoryServerGlobalArea *globalArea, unsigned int size); @@ -457,6 +476,11 @@ int cmsCallService3(CrossMemoryServerGlobalArea *cmsGlobalArea, */ int cmsPrintf(const CrossMemoryServerName *serverName, const char *formatString, ...); +/* + @brief the var-args version of cmsPrintf, see above + */ +int vcmsPrintf(const CrossMemoryServerName *serverName, const char *formatString, va_list argPointer); + /** * @brief Print the hex dump of the specified storage to a cross-memory server's * log diff --git a/h/metalio.h b/h/metalio.h index f39ead447..ad6f87611 100644 --- a/h/metalio.h +++ b/h/metalio.h @@ -170,6 +170,7 @@ typedef struct SYSOUT_struct{ SYSOUT *getSYSOUTStruct(char *ddname, SYSOUT *existingSysout, char *buffer); void sendWTO(int descriptorCode, int routingCode, char *message, int length); +void authWTOPrintf(char *formatString, ...); void wtoPrintf(char *formatString, ...); void qsamPrintf(char *formatString, ...); diff --git a/h/recovery.h b/h/recovery.h index e07551398..a2c5417c1 100644 --- a/h/recovery.h +++ b/h/recovery.h @@ -264,7 +264,8 @@ typedef struct RecoveryStateEntry_tag { char length; char title[100]; } dumpTitle; - + char padding[3]; /* becaue of the weird 101 byte thing above to get to 8 byte alignment */ + long long analysisStackPtr; } RecoveryStateEntry; typedef struct RecoveryContext_tag { @@ -490,6 +491,15 @@ int recoveryPush(char *name, int flags, char *dumpTitle, AnalysisFunction *userAnalysisFunction, void * __ptr32 analysisFunctionUserData, CleanupFunction *userCleanupFunction, void * __ptr32 cleanupFunctionUserData); +/* recoveryPush2 is a variant that allows the analysisFunction to run on a clean stack and not + overwrite the stack upon which the error/abend occurred. + */ +int recoveryPush2(char *name, int flags, char *dumpTitle, + AnalysisFunction *userAnalysisFunction, void * __ptr32 analysisFunctionUserData, + char *analysisFunctionStack, int analysisFunctionStackSize, + CleanupFunction *userCleanupFunction, void * __ptr32 cleanupFunctionUserData); + + /***************************************************************************** * Pop the latest recovery state. diff --git a/h/shrmem64.h b/h/shrmem64.h index 9e114aafe..aa4808c5d 100644 --- a/h/shrmem64.h +++ b/h/shrmem64.h @@ -25,7 +25,7 @@ #include "zowetypes.h" #ifndef _LP64 -#error ILP32 is not supported +/* #error ILP32 is not supported */ #endif #ifndef __LONGNAME__ @@ -64,6 +64,10 @@ MemObjToken shrmem64GetAddressSpaceToken(void); */ int shrmem64Alloc(MemObjToken userToken, size_t size, void **result, int *rsn); +/** This is the key, alet and fprot varying version of the above */ +#define SHRMEM64_USE_CALLER_KEY -1 +int shrmem64Alloc2(MemObjToken userToken, size_t size, int key, int aletValue, bool fetchProtect, void **result, int *rsn); + /** Variant for common (shared with everybody!) */ int shrmem64CommonAlloc(MemObjToken userToken, size_t size, void **result, int *rsn); @@ -113,6 +117,12 @@ int shrmem64ReleaseAll(MemObjToken userToken, int *rsn); */ int shrmem64GetAccess(MemObjToken userToken, void *target, int *rsn); +/** + This is the beefed-up version of shrmem64GetAccess that lets the caller control + whether primary or home space is used and whether the object will be made writable. + */ +int shrmem64GetAccess2(MemObjToken userToken, void *target, bool makeWritable, int aletValue, uint64_t size, int *rsn); + /** * @brief Removes the addressability of the specified storage in the current * address space. See more details in the IARV64 doc @@ -126,7 +136,7 @@ int shrmem64GetAccess(MemObjToken userToken, void *target, int *rsn); * @return One of the RC_SHRMEM64_xx return codes. */ int shrmem64RemoveAccess(MemObjToken userToken, void *target, int *rsn); -int shrmem64RemoveAccess2(MemObjToken userToken, void *target, bool isOwner, int *rsn); +int shrmem64RemoveAccess2(MemObjToken userToken, void *target, int aletValue, bool isOwner, int *rsn); #define RC_SHRMEM64_OK 0 #define RC_SHRMEM64_GETSHARED_FAILED 8 @@ -135,6 +145,8 @@ int shrmem64RemoveAccess2(MemObjToken userToken, void *target, bool isOwner, int #define RC_SHRMEM64_SINGLE_SYS_DETACH_FAILED 11 #define RC_SHRMEM64_DETACH_FAILED 12 #define RC_SHRMEM64_GETCOMMON_FAILED 13 +#define RC_SHRMEM64_CHANGEACCESS_FAILED 14 + #endif /* SRC_SHRMEM64_H_ */ diff --git a/h/zos.h b/h/zos.h index e9c109621..1da135df3 100644 --- a/h/zos.h +++ b/h/zos.h @@ -595,7 +595,7 @@ typedef struct RB_tag{ #define RBSTAB2_IS_QUEUED 0x40 /* ie. is active */ #define RBSTAB2_FREE_STORAGE 0x02 /* free storage at exit */ #define RBSTAT2_RBECBWT 0x01 /* read the Data areas book */ - int rbEPOrCDE; /* Entry point or CDE (24 bit for CDE */ + int rbEPOrCDE; /* Entry point or CDE (24 bit for CDE) */ int64 rbopsw; /* old PSW, 31 bit style */ /* Offset 0x18 */ Addr31 systemDependent18; diff --git a/h/zowetypes.h b/h/zowetypes.h index f4532bc82..54a80838b 100644 --- a/h/zowetypes.h +++ b/h/zowetypes.h @@ -24,7 +24,7 @@ #ifndef __cplusplus #ifndef true -typedef int bool; +typedef char bool; /* this is a char on ZOS */ #define true 1 #define false 0 #endif From ee826a7dd8939c084e129ba4683e40583e57902b Mon Sep 17 00:00:00 2001 From: Joe Devlin Date: Fri, 30 Jul 2021 00:58:37 -0500 Subject: [PATCH 04/33] 64 bit version of session validity is buggy Signed-off-by: Joe Devlin --- c/httpserver.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/c/httpserver.c b/c/httpserver.c index 48c522750..183c63bac 100644 --- a/c/httpserver.c +++ b/c/httpserver.c @@ -2828,6 +2828,11 @@ static int getGroupSessionValidity(int *groupId, const HttpServerConfig *config, //validitySec 0=not found, -1=no expiration, positive int=session in seconds static int getUserSessionValidity(char *username, const HttpServerConfig *config, int *validitySec, int *returnCode, int *reasonCode) { +#ifdef _LP64 + /* Pointer chaos in 64 bit mode */ + *validitySec = 300; + return 0; +#else strupcase(username); /* upfold username */ if (config->userTimeouts) { *validitySec = (int)htGet(config->userTimeouts, (void*)username); @@ -2866,6 +2871,7 @@ static int getUserSessionValidity(char *username, const HttpServerConfig *config } else { return 0; } +#endif } static int sessionTokenStillValid(HttpService *service, HttpRequest *request, char *sessionTokenText, int *sessionValiditySec, uint64 *sessionTimeRemaining){ From d70f1ea62278eba4889108a65633f3e211a54db8 Mon Sep 17 00:00:00 2001 From: Leonty Chudinov Date: Fri, 30 Jul 2021 13:39:54 +0500 Subject: [PATCH 05/33] Fix a warning about incompartible types Signed-off-by: Leonty Chudinov --- c/discovery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/discovery.c b/c/discovery.c index 19263f9b0..12a4b7298 100644 --- a/c/discovery.c +++ b/c/discovery.c @@ -922,7 +922,7 @@ ZOSModel *makeZOSModel2(CrossMemoryServerName *privilegedServerName, if (privilegedServerName != NULL) { printf("makeZOSModel case 1 0x%x\n",privilegedServerName); model->privilegedServerName = *privilegedServerName; - dumpbuffer(&(model->privilegedServerName),16); + dumpbuffer((char*)&(model->privilegedServerName),16); } else { model->privilegedServerName = zisGetDefaultServerName(); } From 7abad8bbc36f1b1d74ddb7885bc35dd689e36118 Mon Sep 17 00:00:00 2001 From: Leonty Chudinov Date: Fri, 30 Jul 2021 18:16:15 +0500 Subject: [PATCH 06/33] Fix abend when checking session validity Signed-off-by: Leonty Chudinov --- c/httpserver.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/c/httpserver.c b/c/httpserver.c index 183c63bac..ee3cb9199 100644 --- a/c/httpserver.c +++ b/c/httpserver.c @@ -2809,11 +2809,11 @@ static int64 getFineGrainedTime(){ #define SESSION_VALIDITY_IN_SECONDS 3600 //validitySec 0=not found, -1=no expiration, positive int=session in seconds -static int getGroupSessionValidity(int *groupId, const HttpServerConfig *config, +static int getGroupSessionValidity(int groupId, const HttpServerConfig *config, int *validitySec, int *returnCode, int *reasonCode) { int retVal = 0; if (config->groupTimeouts) { - *validitySec = (int)htGet(config->groupTimeouts, (void*)groupId); + *validitySec = INT_FROM_POINTER(htGet(config->groupTimeouts, POINTER_FROM_INT(groupId))); AUTH_TRACE("exp=%d for gid=%d\n",*validitySec, groupId); if (*validitySec){ return 0; @@ -2828,14 +2828,9 @@ static int getGroupSessionValidity(int *groupId, const HttpServerConfig *config, //validitySec 0=not found, -1=no expiration, positive int=session in seconds static int getUserSessionValidity(char *username, const HttpServerConfig *config, int *validitySec, int *returnCode, int *reasonCode) { -#ifdef _LP64 - /* Pointer chaos in 64 bit mode */ - *validitySec = 300; - return 0; -#else strupcase(username); /* upfold username */ if (config->userTimeouts) { - *validitySec = (int)htGet(config->userTimeouts, (void*)username); + *validitySec = INT_FROM_POINTER(htGet(config->userTimeouts, (void*)username)); AUTH_TRACE("user validitySec found=%d\n",*validitySec); if (*validitySec){ return 0; @@ -2852,7 +2847,7 @@ static int getUserSessionValidity(char *username, const HttpServerConfig *config if (!retVal) { int currentValiditySec = 0; for (int i = 0; i < groupCount; i++) { - retVal = getGroupSessionValidity(POINTER_FROM_INT(groups[i]), config, ¤tValiditySec, returnCode, reasonCode); + retVal = getGroupSessionValidity(groups[i], config, ¤tValiditySec, returnCode, reasonCode); if (!retVal) { if (currentValiditySec && *validitySec != -1 && ((currentValiditySec == -1) || (currentValiditySec > *validitySec))) { *validitySec = currentValiditySec; @@ -2871,7 +2866,6 @@ static int getUserSessionValidity(char *username, const HttpServerConfig *config } else { return 0; } -#endif } static int sessionTokenStillValid(HttpService *service, HttpRequest *request, char *sessionTokenText, int *sessionValiditySec, uint64 *sessionTimeRemaining){ From 7050bfe260cfe798d27e3d8c22bd10e482eb0609 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Wed, 4 Aug 2021 07:46:08 +0200 Subject: [PATCH 07/33] Cross-memory fixes Signed-off-by: Irek Fakhrutdinov --- c/crossmemory.c | 30 +++++++++++++++++++++++------- h/crossmemory.h | 28 ++++++++++++---------------- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/c/crossmemory.c b/c/crossmemory.c index 1d8b04742..ea03ab618 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -942,6 +942,20 @@ int cmsAddConfigParm(CrossMemoryServer *server, return RC_CMS_OK; } +typedef struct SAFEnityName_tag { + short bufferLength; + short entityLength; + char entityName[255]; + char padding[7]; +} SAFEnityName; + +typedef enum SAFAccessAttribute_tag { + SAF_ACCESS_ATTRIBUTE_READ = 0x02, + SAF_ACCESS_ATTRIBUTE_UPDATE = 0x04, + SAF_ACCESS_ATTRIBUTE_CONTROL = 0x08, + SAF_ACCESS_ATTRIBUTE_ALTER = 0x08, + } SAFAccessAttribute; + static void safEntityNameInit(SAFEnityName *string, char *cstring, char padChar) { memset(string->entityName, padChar, sizeof(string->entityName)); unsigned int cstringLength = strlen(cstring); @@ -1168,8 +1182,8 @@ static bool isAuthCheckRequired(const CrossMemoryServerGlobalArea *globalArea) { } static bool isCallerAuthorized(CrossMemoryServerGlobalArea *globalArea, - char *className, - char *entityName, + char *className, + char *entityName, bool noSAFRequested) { if (noSAFRequested) { @@ -1206,8 +1220,8 @@ static bool isCallerAuthorized(CrossMemoryServerGlobalArea *globalArea, } bool cmsTestAuth(CrossMemoryServerGlobalArea *globalArea, - char *className, - char *entityName){ + const char *className, + const char *entityName) { ACEE callerACEE; ACEE *callerACEEAddr = NULL; cmGetCallerAddressSpaceACEE(&callerACEE, &callerACEEAddr); @@ -1215,7 +1229,9 @@ bool cmsTestAuth(CrossMemoryServerGlobalArea *globalArea, return FALSE; } int racfRC = 0, racfRSN = 0; - int safRC = racroutFASTAUTH(callerACEEAddr, className, entityName, SAF_ACCESS_ATTRIBUTE_READ, &racfRC, &racfRSN, 0); + int safRC = racroutFASTAUTH(callerACEEAddr, (char *)className, + (char *)entityName, + SAF_ACCESS_ATTRIBUTE_READ, &racfRC, &racfRSN, 0); if (safRC != 0) { return FALSE; } @@ -1840,8 +1856,8 @@ static int handleUnsafeProgramCall(PCHandlerParmList *parmList, } if (!isCallerAuthorized(globalArea, - "FACILITY", - CROSS_MEMORY_SERVER_RACF_PROFILE, + "FACILITY", + CROSS_MEMORY_SERVER_RACF_PROFILE, localParmList.flags & CMS_PARMLIST_FLAG_NO_SAF_CHECK)) { return RC_CMS_PERMISSION_DENIED; diff --git a/h/crossmemory.h b/h/crossmemory.h index 616d371b6..36f1cdcee 100644 --- a/h/crossmemory.h +++ b/h/crossmemory.h @@ -359,20 +359,6 @@ typedef struct CrossMemoryServerStatus_tag { char descriptionNullTerm[64]; } CrossMemoryServerStatus; -typedef struct SAFEnityName_tag { - short bufferLength; - short entityLength; - char entityName[255]; - char padding[7]; -} SAFEnityName; - -typedef enum SAFAccessAttribute_tag { - SAF_ACCESS_ATTRIBUTE_READ = 0x02, - SAF_ACCESS_ATTRIBUTE_UPDATE = 0x04, - SAF_ACCESS_ATTRIBUTE_CONTROL = 0x08, - SAF_ACCESS_ATTRIBUTE_ALTER = 0x08, -} SAFAccessAttribute; - ZOWE_PRAGMA_PACK_RESET #define LOG_COMP_ID_CMS 0x008F0001000C0001LLU @@ -441,9 +427,19 @@ int cmsAddConfigParm(CrossMemoryServer *server, const char *name, const void *value, CrossMemoryServerParmType type); +/** + * Checks if the cross-memory caller has read access to the provided class + * and entity. + * + * @param globalArea The global area of the server. + * @param className The class to be checked. + * @param entityName The entity to be checked. + * @return True if the caller has read access to the class/entity, otherwise + * false. + */ bool cmsTestAuth(CrossMemoryServerGlobalArea *globalArea, - char *className, - char *entityName); + const char *className, + const char *entityName); /* Use these inside your service functions if they need ECSA. From 785e6fc38a20bab25ec601250ba31b3bb46da890 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Wed, 4 Aug 2021 17:00:50 +0200 Subject: [PATCH 08/33] Use int for bool to keep backward compatibility. Signed-off-by: Irek Fakhrutdinov --- h/zowetypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h/zowetypes.h b/h/zowetypes.h index 54a80838b..f4532bc82 100644 --- a/h/zowetypes.h +++ b/h/zowetypes.h @@ -24,7 +24,7 @@ #ifndef __cplusplus #ifndef true -typedef char bool; /* this is a char on ZOS */ +typedef int bool; #define true 1 #define false 0 #endif From 9e722f90583c9f5e31fd31c43f29409cd22b0eca Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Wed, 4 Aug 2021 17:02:08 +0200 Subject: [PATCH 09/33] Put the additional ABEND diagnostics under CMS_ABEND_DIAG. Signed-off-by: Irek Fakhrutdinov --- c/crossmemory.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/c/crossmemory.c b/c/crossmemory.c index ea03ab618..fbb544eb7 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -1889,11 +1889,18 @@ static int handleUnsafeProgramCall(PCHandlerParmList *parmList, int returnCode = RC_CMS_OK; +#ifdef CMS_ABEND_DIAG int pushRC = recoveryPush("CMS service function call", - RCVR_FLAG_RETRY | RCVR_FLAG_DELETE_ON_RETRY | RCVR_FLAG_SDWA_TO_LOGREC, - "RCMS", - extractServiceFunctionAbendInfo, &abendInfo, - NULL, NULL); + RCVR_FLAG_RETRY | RCVR_FLAG_DELETE_ON_RETRY | + RCVR_FLAG_SDWA_TO_LOGREC, + "RCMS", + extractServiceFunctionAbendInfo, &abendInfo, + NULL, NULL); +#else + int pushRC = recoveryPush("CMS service function call", + RCVR_FLAG_RETRY | RCVR_FLAG_DELETE_ON_RETRY | RCVR_FLAG_PRODUCE_DUMP, + "RCMS", NULL, NULL, NULL, NULL); +#endif if (pushRC == RC_RCV_OK) { @@ -1947,9 +1954,15 @@ static int handleProgramCall(PCHandlerParmList *parmList, bool isSpaceSwitchPC) int returnCode = RC_CMS_OK; +#ifdef CMS_ABEND_DIAG int pushRC = recoveryPush("CMS PC handler", RCVR_FLAG_RETRY | RCVR_FLAG_DELETE_ON_RETRY | RCVR_FLAG_SDWA_TO_LOGREC, "RCMS", NULL, NULL, NULL, NULL); +#else + int pushRC = recoveryPush("CMS PC handler", + RCVR_FLAG_RETRY | RCVR_FLAG_DELETE_ON_RETRY, + "RCMS", NULL, NULL, NULL, NULL); +#endif if (pushRC == RC_RCV_OK) { From 0e8f40bb1fb36af9f9141688fd5aeef387e3c60b Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Wed, 4 Aug 2021 17:25:10 +0200 Subject: [PATCH 10/33] Revert whitespace changes. Signed-off-by: Irek Fakhrutdinov --- c/recovery.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/c/recovery.c b/c/recovery.c index 33fdd2880..bf74e2aa8 100644 --- a/c/recovery.c +++ b/c/recovery.c @@ -106,8 +106,6 @@ static void resetESPIE(int token) { supervisorMode(TRUE); } - - } static int setDummyESPIE() { @@ -136,6 +134,7 @@ static int setDummyESPIE() { : "r2" ); + ALLOC_STRUCT31( STRUCT31_NAME(parms31), STRUCT31_FIELDS( @@ -1166,6 +1165,7 @@ static int establishRouterInternal(RecoveryContext *userContext, : ); + if (!frrRequired) { /* ESTAEX */ @@ -1556,10 +1556,12 @@ int recoveryRemoveRouter() { static RecoveryStateEntry *addRecoveryStateEntry(RecoveryContext *context, char *name, int flags, char *dumpTitle, AnalysisFunction *userAnalysisFunction, void * __ptr32 analysisFunctionUserData, CleanupFunction *userCleanupFunction, void * __ptr32 cleanupFunctionUserData) { + RecoveryStateEntry *newEntry = allocRecoveryStateEntry(context); if (newEntry == NULL) { return NULL; } + #if !defined(METTLE) && defined(_LP64) if (userAnalysisFunction != NULL) { newEntry->analysisFunctionEnvironment = ((uint64 *)userAnalysisFunction)[0]; @@ -1573,8 +1575,10 @@ static RecoveryStateEntry *addRecoveryStateEntry(RecoveryContext *context, char newEntry->analysisFunction = (void * __ptr32 )userAnalysisFunction; newEntry->cleanupFunctionEntryPoint = (void * __ptr32 )userCleanupFunction; #endif + newEntry->analysisFunctionUserData = analysisFunctionUserData; newEntry->cleanupFunctionUserData = cleanupFunctionUserData; + if (name != NULL) { int stateNameLength = strlen(name); if (stateNameLength > sizeof(newEntry->serviceInfo.stateName)) { @@ -1583,6 +1587,7 @@ static RecoveryStateEntry *addRecoveryStateEntry(RecoveryContext *context, char newEntry->serviceInfo.stateNameLength = stateNameLength; memcpy(newEntry->serviceInfo.stateName, name, stateNameLength); } + newEntry->flags |= flags; newEntry->state = (flags & RCVR_FLAG_DISABLE) ? RECOVERY_STATE_DISABLED : RECOVERY_STATE_ENABLED; memset(newEntry->dumpTitle.title, ' ', sizeof(newEntry->dumpTitle.title)); @@ -1600,12 +1605,14 @@ static RecoveryStateEntry *addRecoveryStateEntry(RecoveryContext *context, char } static void removeRecoveryStateEntry(RecoveryContext *context) { + RecoveryStateEntry *entryToRemove = context->recoveryStateChain; if (entryToRemove != NULL) { context->recoveryStateChain = entryToRemove->next; } else { return; } + freeRecoveryStateEntry(context, entryToRemove); entryToRemove = NULL; } @@ -1651,15 +1658,16 @@ RecoveryStateEntry *addRecoveryStateEntry(RecoveryContext *context, char *name, } static void removeRecoveryStateEntry(RecoveryContext *context) { + RecoveryStateEntry *entryToRemove = context->recoveryStateChain; if (entryToRemove != NULL) { context->recoveryStateChain = entryToRemove->next; } + safeFree((char *)entryToRemove, sizeof(RecoveryStateEntry)); entryToRemove = NULL; } - #endif /* __ZOWE_OS_ZOS */ #ifdef __ZOWE_OS_ZOS @@ -1715,6 +1723,7 @@ int recoveryPush2(char *name, int flags, char *dumpTitle, if (newEntry == NULL) { return RC_RCV_ALLOC_FAILED; } + newEntry->linkageStackToken = linkageStackToken; /* Extract key from the newly created stacked state. IPK cannot be used @@ -2026,6 +2035,7 @@ void recoveryUpdateStateServiceInfo(char *loadModuleName, char *csect, char *rec componentID, subcomponentName, buildDate, version, componentIDBaseNumber, stateName); + } void recoveryGetABENDCode(SDWA *sdwa, int *completionCode, int *reasonCode) { From a497f7094a3f575745ab28f0f75f9fc36ff20aca Mon Sep 17 00:00:00 2001 From: Joe Devlin Date: Thu, 5 Aug 2021 01:13:58 -0500 Subject: [PATCH 11/33] fixing 31/64 issue in radmin.c and killing some traces Signed-off-by: Joe Devlin --- c/radmin.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/c/radmin.c b/c/radmin.c index 8c27af1dd..8d7d95f7a 100644 --- a/c/radmin.c +++ b/c/radmin.c @@ -259,14 +259,6 @@ static void *invokeRadmin(char * __ptr32 workArea, int oldKey = setKey(0); #endif - - printf("right before assembler code arguments at 0x%x\n",argumentsAddress); - dumpbuffer((char*)arguments,sizeof(IRRSEQ00Arguments)); - printf("status block\n"); - dumpbuffer((char*)status,sizeof(RadminAPIStatus)); - printf("Data 31 at 0x%p\n",data31); - dumpbuffer(data31,DATA31_LENGTH); - __asm(ASM_PREFIX /* still need compiled C-code addressing mode to get this address */ " XGR 1,1 \n" @@ -292,12 +284,6 @@ static void *invokeRadmin(char * __ptr32 workArea, #endif void *result = (void*)((int*)data31)[2]; - printf("right after assembler code result=0x%p\n"); - dumpbuffer((char*)arguments,sizeof(IRRSEQ00Arguments)); - printf("status block\n"); - dumpbuffer((char*)status,sizeof(RadminAPIStatus)); - printf("Data 31\n"); - dumpbuffer(data31,DATA31_LENGTH); safeFree31(data31,DATA31_LENGTH); safeFree31((char*)arguments,sizeof(IRRSEQ00Arguments)); @@ -402,11 +388,13 @@ int radminRunRACFCommand( int rc = RC_RADMIN_OK; RadminCommandOutput * __ptr32 result = NULL; + RadminCommandOutput * __ptr32 * __ptr32 resultHandle = (RadminCommandOutput * __ptr32 * __ptr32)safeMalloc31(4,"RACF Result Handle"); + *resultHandle = result; /* i think the ampersand operator will introduce a 64-bit pointer 3 lines down */ RadminAPIStatus statusOnStack; RadminAPIStatus *__ptr32 apiStatus31 = runRACFCommand(callAuthInfo, internalCommand, - &result); + resultHandle); statusOnStack = *apiStatus31; if (result != NULL) { @@ -432,6 +420,7 @@ int radminRunRACFCommand( freeCommandOutput(result); result = NULL; } + safeFree31((char*)resultHandle,4); freeAPIStatus(apiStatus31); return rc; From 10e543984b590c759ce2af5721f147c83c1a7cde Mon Sep 17 00:00:00 2001 From: Leonty Chudinov Date: Thu, 5 Aug 2021 12:12:20 +0500 Subject: [PATCH 12/33] Small fix for radmin. Update result after a call Signed-off-by: Leonty Chudinov --- c/radmin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/radmin.c b/c/radmin.c index 8d7d95f7a..880bb73ac 100644 --- a/c/radmin.c +++ b/c/radmin.c @@ -396,7 +396,7 @@ int radminRunRACFCommand( internalCommand, resultHandle); statusOnStack = *apiStatus31; - + result = *resultHandle; if (result != NULL) { int visitRC = userHandler(statusOnStack, result, userHandlerData); From 79a6f1d76074e2e8a30248e58027478248c2322b Mon Sep 17 00:00:00 2001 From: Joe Devlin Date: Tue, 10 Aug 2021 00:46:22 -0500 Subject: [PATCH 13/33] Temporarily stubbing recoveryPush2 out until design and testing improve Signed-off-by: Joe Devlin --- c/recovery.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/c/recovery.c b/c/recovery.c index bf74e2aa8..85356aec6 100644 --- a/c/recovery.c +++ b/c/recovery.c @@ -525,15 +525,11 @@ static void * __ptr32 getRecoveryRouterAddress() { " LGR 1,11 CONTEXT AS THE FIRST PARM \n" " LGR 2,9 SDWA AS THE SECOND PARM \n" " LLGT 3,RSTAFUD USER DATA AS THE THIRD PARM \n" - /* " LG 4,RSTRGPR+32 STACK \n" */ - " LG 4,RAFSTPTR (JOE)ANALYSIS STACK \n" + " LG 4,RSTRGPR+32 STACK \n" " LG 12,RSTRGPR+96 CAA \n" " LLGT 6,RSTAFEP ANALYSIS FUNCTION ENTRY POINT \n" " LG 5,RSTAFEV ANALYSIS FUNCTION ENVIRONMENT \n" - /* " LA 11,999 \n" - " ABEND 797 \n" */ " BASR 7,6 CALL ANALYSIS FUNCTION \n" - " LG 4,RSTRGPR+32 (JOE) SLIP THE 'REAL' STACK BACK \n" " NOPR 0 \n" #else #ifdef _LP64 @@ -1701,11 +1697,12 @@ static int16_t getLinkageStackToken(void) { return token; } -int recoveryPush2(char *name, int flags, char *dumpTitle, - AnalysisFunction *userAnalysisFunction, void * __ptr32 analysisFunctionUserData, - char *analysisFunctionStack, int analysisFunctionStackSize, - CleanupFunction *userCleanupFunction, void * __ptr32 cleanupFunctionUserData) { - +int recoveryPush(char *name, int flags, char *dumpTitle, + AnalysisFunction *userAnalysisFunction, void * __ptr32 analysisFunctionUserData, + CleanupFunction *userCleanupFunction, void * __ptr32 cleanupFunctionUserData) { + char *analysisFunctionStack = NULL; + int analysisFunctionStackSize = 0; + RecoveryContext *context = getRecoveryContext(); if (context == NULL) { return RC_RCV_CONTEXT_NOT_FOUND; @@ -1835,13 +1832,20 @@ int recoveryPush2(char *name, int flags, char *dumpTitle, return RC_RCV_OK; } -int recoveryPush(char *name, int flags, char *dumpTitle, - AnalysisFunction *userAnalysisFunction, void * __ptr32 analysisFunctionUserData, - CleanupFunction *userCleanupFunction, void * __ptr32 cleanupFunctionUserData) { - return recoveryPush2(name,flags,dumpTitle, - userAnalysisFunction,analysisFunctionUserData, - NULL,0, - userCleanupFunction,cleanupFunctionUserData); +/* This function is temporarily stubbed until fix available. It is an + experimental feature with no current callers */ + +int recoveryPush2(char *name, int flags, char *dumpTitle, + AnalysisFunction *userAnalysisFunction, void * __ptr32 analysisFunctionUserData, + char *analysisFunctionStack, int analysisFunctionStackSize, + CleanupFunction *userCleanupFunction, void * __ptr32 cleanupFunctionUserData) { + /* + return recoveryPushInternal(name,flags,dumpTitle, + userAnalysisFunction,analysisFunctionUserData, + analysisFunctionStack,analysisFunctionStackSize, + userCleanupFunction,cleanupFunctionUserData); + */ + return 0; } From b9883571c66d2a79a6c05a495e2fa1bca07dc12e Mon Sep 17 00:00:00 2001 From: Leonty Chudinov Date: Tue, 7 Sep 2021 09:27:30 +0500 Subject: [PATCH 14/33] Fix JWT for 64-bit mode Signed-off-by: Leonty Chudinov --- jwt/rscrypto/rs_icsfp11.c | 4 ++-- jwt/rscrypto/rs_icsfp11.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jwt/rscrypto/rs_icsfp11.c b/jwt/rscrypto/rs_icsfp11.c index cedd6e7f9..94d1ae1b1 100644 --- a/jwt/rscrypto/rs_icsfp11.c +++ b/jwt/rscrypto/rs_icsfp11.c @@ -321,7 +321,7 @@ int rs_icsfp11_hmacTokenKeyCreateFromRaw( int rs_icsfp11_findObjectsByLabelAndClass( ICSFP11_HANDLE_T *in_token_handle, char* in_label, - CK_ULONG in_objectClass, + unsigned int in_objectClass, char* in_appname, ICSFP11_HANDLE_T **out_handles, int *out_numfound, @@ -330,7 +330,7 @@ int rs_icsfp11_findObjectsByLabelAndClass( int status = RS_SUCCESS; CK_ATTRIBUTE object_attrs[3] = { - { CKA_CLASS, &in_objectClass, sizeof(CK_OBJECT_CLASS) }, + { CKA_CLASS, &in_objectClass, sizeof(unsigned int) }, { CKA_LABEL, NULL, 0 }, { CKA_APPLICATION, NULL, 0 } }; diff --git a/jwt/rscrypto/rs_icsfp11.h b/jwt/rscrypto/rs_icsfp11.h index 532a8f6db..940876133 100644 --- a/jwt/rscrypto/rs_icsfp11.h +++ b/jwt/rscrypto/rs_icsfp11.h @@ -158,7 +158,7 @@ int rs_icsfp11_findObjectsByLabel( int rs_icsfp11_findObjectsByLabelAndClass( const ICSFP11_HANDLE_T *in_token_handle, const char *in_label, - CK_ULONG in_objectClass, + unsigned int in_objectClass, const char *in_appname, ICSFP11_HANDLE_T **out_handles, int *out_numfound, From daf30e5bceb91f834b43332dbd70084bedb3ada5 Mon Sep 17 00:00:00 2001 From: Leonty Chudinov Date: Thu, 16 Sep 2021 09:22:39 +0500 Subject: [PATCH 15/33] Remove printf("safAuthenticate: HTTP request ...") Signed-off-by: Leonty Chudinov --- c/httpserver.c | 1 - 1 file changed, 1 deletion(-) diff --git a/c/httpserver.c b/c/httpserver.c index da5811e37..bb2b98920 100644 --- a/c/httpserver.c +++ b/c/httpserver.c @@ -2495,7 +2495,6 @@ static bool isPassPhrase(const char *password) { #ifdef __ZOWE_OS_ZOS static int safAuthenticate(HttpService *service, HttpRequest *request, AuthResponse *authResponse){ - printf("safAuthenticate: HTTP request 0x%p\n",request); int safStatus = 0, racfStatus = 0, racfReason = 0; int options = VERIFY_CREATE; int authDataFound = FALSE; From 4f21c890725b293e5f229ea23c09019f01eeba0a Mon Sep 17 00:00:00 2001 From: Leonty Chudinov Date: Wed, 22 Sep 2021 15:49:39 +0500 Subject: [PATCH 16/33] Remove termporary code that disabled impersonation Signed-off-by: Leonty Chudinov --- c/httpserver.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/c/httpserver.c b/c/httpserver.c index bb2b98920..34f7e71ad 100644 --- a/c/httpserver.c +++ b/c/httpserver.c @@ -3454,9 +3454,6 @@ static int handleHttpService(HttpServer *server, respondWithAuthError(response, &authResponse); } // Response is finished on return -#define IGNORE_IMPERSONATION 1 - } else if (IGNORE_IMPERSONATION){ - serveRequest(service, response, request); } else { int impersonating = startImpersonating(service, request); From d2b914fe78e2f9a01b5237491f511e8efc5a4b6c Mon Sep 17 00:00:00 2001 From: Leonty Chudinov Date: Thu, 30 Sep 2021 16:16:15 +0500 Subject: [PATCH 17/33] CSI 64bit + fixes for dataset json Signed-off-by: Leonty Chudinov --- c/datasetjson.c | 42 +++++++--- c/jcsi.c | 208 +++++++++++++++++++++++++++++------------------- h/datasetjson.h | 2 +- h/jcsi.h | 7 +- 4 files changed, 159 insertions(+), 100 deletions(-) diff --git a/c/datasetjson.c b/c/datasetjson.c index b324ad595..e23036f72 100644 --- a/c/datasetjson.c +++ b/c/datasetjson.c @@ -1001,7 +1001,7 @@ static int getVolserForDataset(const DatasetName *dataset, Volser *volser) { if (lParenIndex > -1 || asterixIndex > -1 || dollarIndex > -1){ return -1; } - csi_parmblock *returnParms = (csi_parmblock*)safeMalloc(sizeof(csi_parmblock),"CSI ParmBlock"); + csi_parmblock * __ptr32 returnParms = (csi_parmblock* __ptr32)safeMalloc31(sizeof(csi_parmblock),"CSI ParmBlock"); EntryDataSet *entrySet = returnEntries(dsnNullTerm, defaultDatasetTypesAllowed,3, 0, defaultCSIFields, defaultCSIFieldCount, NULL, NULL, returnParms); EntryData *entry = entrySet->entries ? entrySet->entries[0] : NULL; @@ -1031,7 +1031,7 @@ static int getVolserForDataset(const DatasetName *dataset, Volser *volser) { entrySet->entries = NULL; } safeFree((char*)entrySet,sizeof(EntryDataSet)); - safeFree((char*)returnParms,sizeof(csi_parmblock)); + safeFree31((char*)returnParms,sizeof(csi_parmblock)); return rc; } @@ -1322,7 +1322,7 @@ char getCSIType(char* absolutePath) { int fieldCount = defaultCSIFieldCount; char **csiFields = defaultCSIFields; - csi_parmblock *returnParms = (csi_parmblock*)safeMalloc(sizeof(csi_parmblock),"CSI ParmBlock"); + csi_parmblock * __ptr32 returnParms = (csi_parmblock* __ptr32)safeMalloc31(sizeof(csi_parmblock),"CSI ParmBlock"); DatasetName datasetName; DatasetMemberName memberName; @@ -1500,7 +1500,9 @@ static void respondWithDatasetInternal(HttpResponse* response, Volser volser; memset(&volser.value, ' ', sizeof(volser.value)); + fprintf (stderr, "begin getVolserForDataset\n"); int volserSuccess = getVolserForDataset(dsn, &volser); + fprintf (stderr, "end getVolserForDataset\n"); int handledThroughDSCB = FALSE; int lrecl; if (!volserSuccess){ @@ -1669,7 +1671,7 @@ void respondWithVSAMDataset(HttpResponse* response, char* absolutePath, hashtabl /* TODO: We should not need to do this on every call - only if the ACB needs to be opened */ /* TODO: How to access the CSI in cases where the entry is archived? Is this possible? */ - csi_parmblock *returnParms = (csi_parmblock*)safeMalloc(sizeof(csi_parmblock),"CSI ParmBlock"); + csi_parmblock * __ptr32 returnParms = (csi_parmblock* __ptr32)safeMalloc31(sizeof(csi_parmblock),"CSI ParmBlock"); EntryDataSet *entrySet = returnEntries(dsn, clusterTypesAllowed, clusterTypesCount, 0, defaultVSAMCSIFields, defaultVSAMCSIFieldCount, NULL, NULL, returnParms); EntryData *entry = entrySet->entries[0]; if (entry){ @@ -1704,7 +1706,7 @@ void respondWithVSAMDataset(HttpResponse* response, char* absolutePath, hashtabl EntryDataSet *entrySet = returnEntries(dsnData, clusterTypesAllowed, clusterTypesCount, 0, defaultVSAMCSIFields, defaultVSAMCSIFieldCount, NULL, NULL, returnParms); entry = entrySet->entries[0]; } else if (entry->type != 'D') { - safeFree((char*)returnParms,sizeof(csi_parmblock)); + safeFree31((char*)returnParms,sizeof(csi_parmblock)); for (int i = 0; i < entrySet->length; i++){ EntryData *currentEntry = entrySet->entries[i]; if (!(entrySet->entries)) break; @@ -1754,7 +1756,7 @@ void respondWithVSAMDataset(HttpResponse* response, char* absolutePath, hashtabl } /* end Catalog Search */ zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "vsamType = 0x%0x, ciSize = %d, maxlrecl = %d, keyLoc = %d, keyLen = %d\n", vsamType, ciSize, maxlrecl, keyLoc, keyLen); - safeFree((char*)returnParms,sizeof(csi_parmblock)); + safeFree31((char*)returnParms,sizeof(csi_parmblock)); for (int i = 0; i < entrySet->length; i++){ EntryData *currentEntry = entrySet->entries[i]; if (!(entrySet->entries)) break; @@ -2044,9 +2046,13 @@ void respondWithDatasetMetadata(HttpResponse *response) { int fieldCount = defaultCSIFieldCount; char **csiFields = defaultCSIFields; - - csi_parmblock *returnParms = (csi_parmblock*)safeMalloc(sizeof(csi_parmblock),"CSI ParmBlock"); - EntryDataSet *entrySet = returnEntries(dsnName.value, typesArg,datasetTypeCount, workAreaSizeArg, csiFields, fieldCount, resumeNameArg, resumeCatalogNameArg, returnParms); + char dsnNameNullTerm[45] = {0}; + memcpy(dsnNameNullTerm, dsnName.value, sizeof(dsnName.value)); + nullTerminate(dsnNameNullTerm, sizeof(dsnNameNullTerm) - 1); + csi_parmblock * __ptr32 returnParms = (csi_parmblock* __ptr32)safeMalloc31(sizeof(csi_parmblock),"CSI ParmBlock"); + EntryDataSet *entrySet = returnEntries(dsnNameNullTerm, typesArg,datasetTypeCount, workAreaSizeArg, csiFields, fieldCount, resumeNameArg, resumeCatalogNameArg, returnParms); + fprintf (stderr, "entrySet 0x%p\n", entrySet); + fprintf (stderr, "entrySet len %d\n", entrySet->length); char *resumeName = returnParms->resume_name; char *catalogName = returnParms->catalog_name; int isResume = (returnParms->is_resume == 'Y'); @@ -2081,12 +2087,15 @@ void respondWithDatasetMetadata(HttpResponse *response) { jsonStartObject(jPrinter, NULL); int datasetNameLength = sizeof(entry->name); char *datasetName = entry->name; + fprintf (stderr, "entry number %d '%.44s'\n", i, datasetName); + fprintf (stderr, "sizeof short %d\n", sizeof(short)); jsonAddUnterminatedString(jPrinter, "name", datasetName, datasetNameLength); jsonAddUnterminatedString(jPrinter, "csiEntryType", &entry->type, 1); int volserLength = 0; memset(volser, 0, sizeof(volser)); char type = entry->type; if (type == 'A' || type == 'B' || type == 'D' || type == 'H'){ + fprintf (stderr, "type %c\n", type); char *fieldData = (char*)entry+sizeof(EntryData); unsigned short *fieldLengthArray = ((unsigned short *)((char*)entry+sizeof(EntryData))); char *fieldValueStart = (char*)entry+sizeof(EntryData)+fieldCount*sizeof(short); @@ -2103,6 +2112,7 @@ void respondWithDatasetMetadata(HttpResponse *response) { fieldValueStart += fieldLengthArray[j]; } } + fprintf (stderr, "after volser\n"); int shouldListMembers = !strcmp(listMembersArg,"true") || (lParenIndex > 0); int detail = !strcmp(detailArg, "true"); @@ -2122,17 +2132,23 @@ void respondWithDatasetMetadata(HttpResponse *response) { jPrinter, includeUnprintable); } } + fprintf (stderr, "about to end object\n"); jsonEndObject(jPrinter); + fprintf (stderr, "about to free entry 0x%p of size %d bytes\n", entry, entrySize); safeFree((char*)(entry),entrySize); + fprintf (stderr, "entry freed\n"); } } + fprintf (stderr, "end array\n"); jsonEndArray(jPrinter); } jsonEnd(jPrinter); + fprintf (stderr, "about to finish response\n"); finishResponse(response); - safeFree((char*)returnParms,sizeof(csi_parmblock)); - safeFree((char*)(entrySet->entries),sizeof(EntryData*)*entrySet->length); + safeFree31((char*)returnParms,sizeof(csi_parmblock)); + safeFree((char*)(entrySet->entries),sizeof(EntryData*)*entrySet->size); safeFree((char*)entrySet,sizeof(EntryDataSet)); + fprintf (stderr, "end of %s\n", __FUNCTION__); #endif /* __ZOWE_OS_ZOS */ } @@ -2147,7 +2163,7 @@ void respondWithHLQNames(HttpResponse *response, MetadataQueryCache *metadataQue jsonPrinter *jPrinter = respondWithJsonPrinter(response); writeHeader(response); EntryDataSet *hlqSet; - csi_parmblock **returnParmsArray; + csi_parmblock * __ptr32 * __ptr32 returnParmsArray; char **csiFields = defaultCSIFields; int fieldCount = defaultCSIFieldCount; @@ -2180,7 +2196,7 @@ void respondWithHLQNames(HttpResponse *response, MetadataQueryCache *metadataQue HttpRequestParam *workAreaSizeParam = getCheckedParam(request,"workAreaSize"); int workAreaSizeArg = (workAreaSizeParam ? workAreaSizeParam->intValue : 0); - returnParmsArray = (csi_parmblock**)safeMalloc(29*sizeof(csi_parmblock*),"CSI Parm Results"); + returnParmsArray = (csi_parmblock* __ptr32 * __ptr32)safeMalloc31(29*sizeof(csi_parmblock* __ptr32),"CSI Parm Results"); hlqSet = getHLQs(typesArg, datasetTypeCount, workAreaSizeArg, csiFields, fieldCount, returnParmsArray); } jsonStart(jPrinter); diff --git a/c/jcsi.c b/c/jcsi.c index 70e9dc9d6..88432662f 100644 --- a/c/jcsi.c +++ b/c/jcsi.c @@ -26,8 +26,6 @@ #include "csi.h" #include "jcsi.h" -#define _EDC_ADD_ERRNO2 1 - /* c89 -o csi -Wl,ac=1 csitest.c @@ -39,75 +37,119 @@ */ +typedef void* __ptr32 CsiFn; +static CsiFn loadCsi() { + int entryPoint = 0; + int status = 0; + CsiFn csiFn = NULL; -typedef void (*void_fn_ptr)(); -void_fn_ptr fetch(const char *name); - -typedef int csi_fn(int* reason_code, void *param_block, void* work_area); -csi_fn *IGGCSI00; + __asm(ASM_PREFIX + " LOAD EP=IGGCSI00 \n" + " ST 15,%0 \n" + " ST 0,%1 \n" + :"=m"(status),"=m"(entryPoint) + : :"r0","r1","r15"); -#define TRUE 1 -#define FALSE 0 + if (status == 0) { + csiFn = (CsiFn)entryPoint; + } + zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG2, "IGGCSI00 0x%p LOAD status = 0x%x\n", csiFn, status); + return csiFn; +} +int callCsi(CsiFn *csiFn, void *__ptr32 paramList) { + int returnCode = 0; + + __asm( + ASM_PREFIX +#ifdef _LP64 + " SAM31 \n" + " SYSSTATE AMODE64=NO \n" +#endif + " LR 1,(%[paramList]) \n" + " CALL (%[csiFn]) \n" +#ifdef _LP64 + " SAM64 \n" + " SYSSTATE AMODE64=YES \n" +#endif + " ST 15,%[returnCode] \n" + : [returnCode] "=m"(returnCode) + : [csiFn] "r"(csiFn), + [paramList] "r"(paramList) + : "r0", "r1", "r15"); + + return returnCode; +} +char * __ptr32 csi(csi_parmblock* __ptr32 csi_parms, int *workAreaSizeInOut) { + int returnCode = 0; + int reasonCode = 0; + int status = 0; + int entryPoint = 0; + CsiFn csiFn = NULL; + char * __ptr32 workArea = NULL; + int * __ptr32 reasonCodePtr = NULL; + int workAreaSize = *workAreaSizeInOut > 2048 ? *workAreaSizeInOut : WORK_AREA_SIZE; + + ALLOC_STRUCT31( + STRUCT31_NAME(paramList), + STRUCT31_FIELDS( + int * __ptr32 reasonCodePtr; + csi_parmblock * __ptr32 paramBlock; + char * __ptr32 workArea; + ) + ); + + do { + if (!paramList) { + zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "could not allocate memory for CSI paramList\n"); + break; + } -void print_buffer(char *buffer_arg, int length_arg); + csiFn = loadCsi(); + if (!csiFn) { + zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "could not load IGGCSI00\n"); + break; + } + workArea = (char* __ptr32)safeMalloc31(workAreaSize, "CSI Work Area Size"); + if (!workArea) { + zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "could not allocate memory for CSI workArea\n"); + break; + } + *((int*)workArea) = workAreaSize; + reasonCodePtr = (int *__ptr32)safeMalloc31(sizeof(int), "CSI Reason Code"); + if (!reasonCodePtr) { + zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "could not allocate memory for CSI reason code\n"); + break; + } + paramList->workArea = workArea; + paramList->reasonCodePtr = reasonCodePtr; + paramList->paramBlock = csi_parms; -csi_parmblock *process_arguments(int argc, char **argv) -{ - int argindex; - int arglen; + returnCode = callCsi(csiFn, paramList); + reasonCode = *reasonCodePtr; - csi_parmblock* csi_parms = (csi_parmblock*)safeMalloc(sizeof(csi_parmblock),"CSI Parmblock"); - memset(csi_parms,' ',sizeof(csi_parmblock)); - for (argindex=0; argindex= argc) { - zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "missing argument after -filter\n"); - return 0; - } else { - arglen = strlen(argv[argindex]); - strncpy(csi_parms->filter_spec,argv[argindex],arglen); /* do not copy null terminator */ - /* sscanf(argv[argindex],"%d",&ssgargl->buffer_length); */ - } + if (returnCode != 0) { + zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "CSI failed ret=%d, reason=0x%x\n", returnCode, reasonCode); + safeFree31((char*)workArea, workAreaSize); + workArea = NULL; + break; } - } - csi_parms->num_fields = 4; - strncpy(csi_parms->fields+ 0,"NAME ",8); - strncpy(csi_parms->fields+ 8,"TYPE ",8); - strncpy(csi_parms->fields+ 16,"VOLSER ",8); - strncpy(csi_parms->fields+ 24,"VOLFLG ",8); + *workAreaSizeInOut = workAreaSize; + } while(0); - return csi_parms; -} - -char *csi(csi_parmblock* csi_parms, int *workAreaSize) -{ - int return_code; - int reason_code; - *workAreaSize = (*workAreaSize > 2048 ? *workAreaSize : WORK_AREA_SIZE); - void* work_area = (void*)safeMalloc(*workAreaSize,"CSI Work Area Size"); - *((int*)work_area) = *workAreaSize; - IGGCSI00 = (csi_fn *)fetch("IGGCSI00"); - if (0 == IGGCSI00) { - zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "could not fetch IGGCSI00\n"); - return 0; + if (reasonCodePtr) { + safeFree31((char*)reasonCodePtr, sizeof(*reasonCodePtr)); } - /* print_buffer((char*)work_area,256); */ - return_code = (*IGGCSI00)(&reason_code,csi_parms,work_area); - if (return_code != 0) { - zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "CSI failed ret=%d, rc=%d rchex=%x\n", return_code, reason_code, reason_code); - free(work_area); - return 0; - } else { - /* print_buffer((char*)work_area,256); */ - return work_area; + if (paramList) { + FREE_STRUCT31(STRUCT31_NAME(paramList)); } + + return workArea; } /* @@ -129,7 +171,7 @@ int pseudoLS(char *dsn, int fieldCount, char **fieldNames){ return DSN_ZERO_LENGTH_DSN; } - csi_parms = (csi_parmblock*)safeMalloc(sizeof(csi_parmblock),"CSI ParmBlock"); + csi_parms = (csi_parmblock*)safeMalloc31(sizeof(csi_parmblock),"CSI ParmBlock"); /* prep parms */ memset(csi_parms,' ',sizeof(csi_parmblock)); @@ -201,7 +243,7 @@ int pseudoLS(char *dsn, int fieldCount, char **fieldNames){ } else{ zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "no entries, no look up failure either\n"); } - safeFree((char*)workArea,WORK_AREA_SIZE); + safeFree31((char*)workArea,workAreaSize); return result; } else{ return DSN_CSI_FAILURE; @@ -232,16 +274,16 @@ int pseudoLS(char *dsn, int fieldCount, char **fieldNames){ static char *entriesFields[] ={ "NAME ", "TYPE "}; static char *myFields[] ={ "NAME ", "LRECL ", "TYPE ","VOLSER ","VOLFLG "}; -EntryDataSet *returnEntries(char *dsn, char *typesAllowed, int typesCount, int workAreaSize, char **fields, int fieldCount, char *resumeName, char *resumeCatalogName, csi_parmblock *returnParms){ - csi_parmblock* csi_parms = returnParms; - zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "csi query for %s\n", dsn); +EntryDataSet *returnEntries(char *dsn, char *typesAllowed, int typesCount, int workAreaSize, char **fields, int fieldCount, char *resumeName, char *resumeCatalogName, csi_parmblock * __ptr32 returnParms){ + csi_parmblock* __ptr32 csi_parms = returnParms; + zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "csi query for '%s'\n", dsn); int dsnLen = strlen(dsn); char *workArea = NULL; workAreaSize = (workAreaSize > 0 ? workAreaSize : WORK_AREA_SIZE); EntryDataSet *entrySet; - entrySet = (EntryDataSet*)safeMalloc(sizeof(EntryDataSet*),"Entry Data Set"); + entrySet = (EntryDataSet*)safeMalloc(sizeof(EntryDataSet),"Entry Data Set"); entrySet->length = 0; if (dsnLen == 0){ @@ -282,6 +324,7 @@ EntryDataSet *returnEntries(char *dsn, char *typesAllowed, int typesCount, int w EntryData **entries = (EntryData**)safeMalloc(entriesLength*sizeof(EntryData*),"Entry Datas"); entrySet->entries = entries; + entrySet->size = entriesLength; while (entryPointer < endPointer){ EntryData *entry = (EntryData*)entryPointer; char type = entry->type; @@ -316,6 +359,7 @@ EntryDataSet *returnEntries(char *dsn, char *typesAllowed, int typesCount, int w entries = tempPtr; entriesLength = entriesLength*2; entrySet->entries = entries; + entrySet->size = entriesLength*2; } EntryData *entryCopy = (EntryData*)safeMalloc(advance,"Entry"); memcpy(entryCopy,entry,advance); @@ -331,12 +375,12 @@ EntryDataSet *returnEntries(char *dsn, char *typesAllowed, int typesCount, int w } } } - safeFree((char*)workArea,workAreaSize); + safeFree31((char*)workArea,workAreaSize); return entrySet; } else{ zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "no entries, no look up failure either\n"); } - safeFree((char*)workArea,workAreaSize); + safeFree31((char*)workArea,workAreaSize); return entrySet; } else{ return entrySet; @@ -346,17 +390,17 @@ EntryDataSet *returnEntries(char *dsn, char *typesAllowed, int typesCount, int w static const char hlqFirstChar[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','$','@','#'}; -EntryDataSet *getHLQs(char *typesAllowed, int typesCount, int workAreaSize, char **fields, int fieldCount, csi_parmblock **returnParmsArray){ +EntryDataSet *getHLQs(char *typesAllowed, int typesCount, int workAreaSize, char **fields, int fieldCount, csi_parmblock * __ptr32 * __ptr32 returnParmsArray){ int status = 0; char *searchTerm = safeMalloc(3,"HLQ Search Term"); searchTerm[1] = '*'; searchTerm[2] = '\0'; - EntryDataSet **entrySets = (EntryDataSet**)safeMalloc(29*sizeof(EntryDataSet*),"HLQ entries"); + EntryDataSet **entrySets = (EntryDataSet**)safeMalloc31(29*sizeof(EntryDataSet*),"HLQ entries"); int combinedLength = 0; for (int i = 0; i < 29; i++){ searchTerm[0] = hlqFirstChar[i]; - returnParmsArray[i] = (csi_parmblock*)safeMalloc(sizeof(csi_parmblock),"CSI ParmBlock"); + returnParmsArray[i] = (csi_parmblock* __ptr32)safeMalloc31(sizeof(csi_parmblock),"CSI ParmBlock"); EntryDataSet *entrySet = returnEntries(searchTerm, typesAllowed, typesCount, workAreaSize, fields, fieldCount, NULL, NULL, returnParmsArray[i]); entrySets[i] = entrySet; combinedLength = combinedLength + entrySet->length; @@ -376,28 +420,26 @@ EntryDataSet *getHLQs(char *typesAllowed, int typesCount, int workAreaSize, char return combinedEntrySet; } +void freeEntryDataSet(EntryDataSet *entrySet) { + if (entrySet) { + if (entrySet->entries && entrySet->size > 0) { + safeFree((char*)entrySet->entries, entrySet->size * sizeof(EntryData*)); + entrySet->entries = NULL; + } + entrySet->size = 0; + entrySet->length = 0; + safeFree((char*)entrySet, sizeof(entrySet)); + } +} -/* + +#ifdef TEST_JCSI int main(int argc, char **argv) { - - EntryDataSet *hlqSet = getHLQs(); - for (int i = 0; i < hlqSet->length;i++){ - //printf("Checking entries pos=%d\n",i); - if (hlqSet->entries[i] && hlqSet->entries[i]->name) { - //dumpbuffer(hlqSet->entries[i]->name,44); - printf("Found entry: %44.44s\n",hlqSet->entries[i]->name); - fflush(stdout); - } - } - return 0; - int status = pseudoLS(argv[1],3,entriesFields); printf("status 0x%x\n",status); - return status; } -*/ - +#endif diff --git a/h/datasetjson.h b/h/datasetjson.h index b5ab5a60c..8993b57fd 100644 --- a/h/datasetjson.h +++ b/h/datasetjson.h @@ -26,7 +26,7 @@ typedef struct MetadataQueryCache_tag{ EntryDataSet *cachedHLQSet; - csi_parmblock **cachedCSIParmblocks; + csi_parmblock * __ptr32 * __ptr32 cachedCSIParmblocks; } MetadataQueryCache; typedef struct serveVSAMCache_tag{ diff --git a/h/jcsi.h b/h/jcsi.h index 79aba2008..c3c4f2288 100644 --- a/h/jcsi.h +++ b/h/jcsi.h @@ -106,12 +106,13 @@ typedef struct EntryData_tag{ typedef struct EntryDataSet_tag{ int length; + int size; EntryData **entries; } EntryDataSet; -char *csi(csi_parmblock* csi_parms, int *workAreaSize); -EntryDataSet *returnEntries(char *dsn, char *typesAllowed, int typeCount, int workAreaSize, char **fields, int fieldCount, char *resumeName, char *resumeCatalogName, csi_parmblock *returnParms); -EntryDataSet *getHLQs(char *typesAllowed, int typeCount, int workAreaSize, char **fields, int fieldCount, csi_parmblock **returnParmsArray); +char * __ptr32 csi(csi_parmblock* __ptr32 csi_parms, int *workAreaSize); +EntryDataSet *returnEntries(char *dsn, char *typesAllowed, int typeCount, int workAreaSize, char **fields, int fieldCount, char *resumeName, char *resumeCatalogName, csi_parmblock * __ptr32 returnParms); +EntryDataSet *getHLQs(char *typesAllowed, int typeCount, int workAreaSize, char **fields, int fieldCount, csi_parmblock *__ptr32 * __ptr32 returnParmsArray); #endif From 4a12797eb40cba953ab2fffc9248ebe58d775a13 Mon Sep 17 00:00:00 2001 From: Leonty Chudinov Date: Thu, 30 Sep 2021 20:48:54 +0500 Subject: [PATCH 18/33] More fixes Signed-off-by: Leonty Chudinov --- c/datasetjson.c | 12 +++++++++--- c/jcsi.c | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/c/datasetjson.c b/c/datasetjson.c index e23036f72..efd75699e 100644 --- a/c/datasetjson.c +++ b/c/datasetjson.c @@ -1001,6 +1001,7 @@ static int getVolserForDataset(const DatasetName *dataset, Volser *volser) { if (lParenIndex > -1 || asterixIndex > -1 || dollarIndex > -1){ return -1; } + fprintf (stderr, "%s dsnNullTerm '%s'\n", __FUNCTION__, dsnNullTerm); csi_parmblock * __ptr32 returnParms = (csi_parmblock* __ptr32)safeMalloc31(sizeof(csi_parmblock),"CSI ParmBlock"); EntryDataSet *entrySet = returnEntries(dsnNullTerm, defaultDatasetTypesAllowed,3, 0, defaultCSIFields, defaultCSIFieldCount, NULL, NULL, returnParms); @@ -1027,7 +1028,7 @@ static int getVolserForDataset(const DatasetName *dataset, Volser *volser) { safeFree((char*)(currentEntry),entrySize); } if (entrySet->entries != NULL) { - safeFree((char*)(entrySet->entries),sizeof(EntryData*)*entrySet->length); + safeFree((char*)(entrySet->entries),sizeof(EntryData*)*entrySet->size); entrySet->entries = NULL; } safeFree((char*)entrySet,sizeof(EntryDataSet)); @@ -1580,6 +1581,11 @@ void respondWithDataset(HttpResponse* response, char* absolutePath, int jsonMode DatasetMemberName memberName; extractDatasetAndMemberName(absolutePath, &dsn, &memberName); + Volser volser = {' '}; + fprintf (stderr, "about to get volser for %s\n", absolutePath); + getVolserForDataset(&dsn, &volser); + fprintf (stderr, "end to get volser for %s, volser %.8s\n", absolutePath, volser.value); + DynallocDatasetName daDsn; DynallocMemberName daMember; memcpy(daDsn.name, dsn.value, sizeof(daDsn.name)); @@ -1699,7 +1705,7 @@ void respondWithVSAMDataset(HttpResponse* response, char* absolutePath, hashtabl safeFree((char*)(currentEntry),entrySize); } memset((char*)(entrySet->entries),0,sizeof(EntryData*)*entrySet->length); - safeFree((char*)(entrySet->entries),sizeof(EntryData*)*entrySet->length); + safeFree((char*)(entrySet->entries),sizeof(EntryData*)*entrySet->size); memset((char*)entrySet,0,sizeof(EntryDataSet)); safeFree((char*)entrySet,sizeof(EntryDataSet)); @@ -1768,7 +1774,7 @@ void respondWithVSAMDataset(HttpResponse* response, char* absolutePath, hashtabl int entrySize = sizeof(EntryData)+fieldDataLength-4; safeFree((char*)(currentEntry),entrySize); } - safeFree((char*)(entrySet->entries),sizeof(EntryData*)*entrySet->length); + safeFree((char*)(entrySet->entries),sizeof(EntryData*)*entrySet->size); safeFree((char*)entrySet,sizeof(EntryDataSet)); char *dsnUidPair = safeMalloc(44+8+1, "DSN,UID Pair Entry"); /* TODO: plug this leak for each time it is htPut below. */ diff --git a/c/jcsi.c b/c/jcsi.c index 88432662f..c1b316aad 100644 --- a/c/jcsi.c +++ b/c/jcsi.c @@ -83,6 +83,9 @@ int callCsi(CsiFn *csiFn, void *__ptr32 paramList) { } char * __ptr32 csi(csi_parmblock* __ptr32 csi_parms, int *workAreaSizeInOut) { + fprintf (stdout, "csi_parms 0x%p\n", csi_parms); + dumpbuffer((char*)csi_parms, sizeof(csi_parmblock)); + fflush(stdout); int returnCode = 0; int reasonCode = 0; int status = 0; @@ -130,7 +133,9 @@ char * __ptr32 csi(csi_parmblock* __ptr32 csi_parms, int *workAreaSizeInOut) { paramList->reasonCodePtr = reasonCodePtr; paramList->paramBlock = csi_parms; + fprintf (stderr, "about to call csi\n"); returnCode = callCsi(csiFn, paramList); + fprintf (stderr, "csi called\n"); reasonCode = *reasonCodePtr; if (returnCode != 0) { From ac921df5997dba6810bd2eb97b6106264ff02376 Mon Sep 17 00:00:00 2001 From: Leonty Chudinov Date: Fri, 1 Oct 2021 15:54:31 +0500 Subject: [PATCH 19/33] Code cleanup Signed-off-by: Leonty Chudinov --- c/datasetjson.c | 20 -------------------- c/jcsi.c | 25 ++++++++++++++----------- 2 files changed, 14 insertions(+), 31 deletions(-) diff --git a/c/datasetjson.c b/c/datasetjson.c index efd75699e..23f3eb0a4 100644 --- a/c/datasetjson.c +++ b/c/datasetjson.c @@ -1001,7 +1001,6 @@ static int getVolserForDataset(const DatasetName *dataset, Volser *volser) { if (lParenIndex > -1 || asterixIndex > -1 || dollarIndex > -1){ return -1; } - fprintf (stderr, "%s dsnNullTerm '%s'\n", __FUNCTION__, dsnNullTerm); csi_parmblock * __ptr32 returnParms = (csi_parmblock* __ptr32)safeMalloc31(sizeof(csi_parmblock),"CSI ParmBlock"); EntryDataSet *entrySet = returnEntries(dsnNullTerm, defaultDatasetTypesAllowed,3, 0, defaultCSIFields, defaultCSIFieldCount, NULL, NULL, returnParms); @@ -1501,9 +1500,7 @@ static void respondWithDatasetInternal(HttpResponse* response, Volser volser; memset(&volser.value, ' ', sizeof(volser.value)); - fprintf (stderr, "begin getVolserForDataset\n"); int volserSuccess = getVolserForDataset(dsn, &volser); - fprintf (stderr, "end getVolserForDataset\n"); int handledThroughDSCB = FALSE; int lrecl; if (!volserSuccess){ @@ -1581,11 +1578,6 @@ void respondWithDataset(HttpResponse* response, char* absolutePath, int jsonMode DatasetMemberName memberName; extractDatasetAndMemberName(absolutePath, &dsn, &memberName); - Volser volser = {' '}; - fprintf (stderr, "about to get volser for %s\n", absolutePath); - getVolserForDataset(&dsn, &volser); - fprintf (stderr, "end to get volser for %s, volser %.8s\n", absolutePath, volser.value); - DynallocDatasetName daDsn; DynallocMemberName daMember; memcpy(daDsn.name, dsn.value, sizeof(daDsn.name)); @@ -2057,8 +2049,6 @@ void respondWithDatasetMetadata(HttpResponse *response) { nullTerminate(dsnNameNullTerm, sizeof(dsnNameNullTerm) - 1); csi_parmblock * __ptr32 returnParms = (csi_parmblock* __ptr32)safeMalloc31(sizeof(csi_parmblock),"CSI ParmBlock"); EntryDataSet *entrySet = returnEntries(dsnNameNullTerm, typesArg,datasetTypeCount, workAreaSizeArg, csiFields, fieldCount, resumeNameArg, resumeCatalogNameArg, returnParms); - fprintf (stderr, "entrySet 0x%p\n", entrySet); - fprintf (stderr, "entrySet len %d\n", entrySet->length); char *resumeName = returnParms->resume_name; char *catalogName = returnParms->catalog_name; int isResume = (returnParms->is_resume == 'Y'); @@ -2093,15 +2083,12 @@ void respondWithDatasetMetadata(HttpResponse *response) { jsonStartObject(jPrinter, NULL); int datasetNameLength = sizeof(entry->name); char *datasetName = entry->name; - fprintf (stderr, "entry number %d '%.44s'\n", i, datasetName); - fprintf (stderr, "sizeof short %d\n", sizeof(short)); jsonAddUnterminatedString(jPrinter, "name", datasetName, datasetNameLength); jsonAddUnterminatedString(jPrinter, "csiEntryType", &entry->type, 1); int volserLength = 0; memset(volser, 0, sizeof(volser)); char type = entry->type; if (type == 'A' || type == 'B' || type == 'D' || type == 'H'){ - fprintf (stderr, "type %c\n", type); char *fieldData = (char*)entry+sizeof(EntryData); unsigned short *fieldLengthArray = ((unsigned short *)((char*)entry+sizeof(EntryData))); char *fieldValueStart = (char*)entry+sizeof(EntryData)+fieldCount*sizeof(short); @@ -2118,7 +2105,6 @@ void respondWithDatasetMetadata(HttpResponse *response) { fieldValueStart += fieldLengthArray[j]; } } - fprintf (stderr, "after volser\n"); int shouldListMembers = !strcmp(listMembersArg,"true") || (lParenIndex > 0); int detail = !strcmp(detailArg, "true"); @@ -2138,23 +2124,17 @@ void respondWithDatasetMetadata(HttpResponse *response) { jPrinter, includeUnprintable); } } - fprintf (stderr, "about to end object\n"); jsonEndObject(jPrinter); - fprintf (stderr, "about to free entry 0x%p of size %d bytes\n", entry, entrySize); safeFree((char*)(entry),entrySize); - fprintf (stderr, "entry freed\n"); } } - fprintf (stderr, "end array\n"); jsonEndArray(jPrinter); } jsonEnd(jPrinter); - fprintf (stderr, "about to finish response\n"); finishResponse(response); safeFree31((char*)returnParms,sizeof(csi_parmblock)); safeFree((char*)(entrySet->entries),sizeof(EntryData*)*entrySet->size); safeFree((char*)entrySet,sizeof(EntryDataSet)); - fprintf (stderr, "end of %s\n", __FUNCTION__); #endif /* __ZOWE_OS_ZOS */ } diff --git a/c/jcsi.c b/c/jcsi.c index c1b316aad..3ae82997c 100644 --- a/c/jcsi.c +++ b/c/jcsi.c @@ -67,7 +67,7 @@ int callCsi(CsiFn *csiFn, void *__ptr32 paramList) { " SAM31 \n" " SYSSTATE AMODE64=NO \n" #endif - " LR 1,(%[paramList]) \n" + " LR 1,%[paramList] \n" " CALL (%[csiFn]) \n" #ifdef _LP64 " SAM64 \n" @@ -83,9 +83,6 @@ int callCsi(CsiFn *csiFn, void *__ptr32 paramList) { } char * __ptr32 csi(csi_parmblock* __ptr32 csi_parms, int *workAreaSizeInOut) { - fprintf (stdout, "csi_parms 0x%p\n", csi_parms); - dumpbuffer((char*)csi_parms, sizeof(csi_parmblock)); - fflush(stdout); int returnCode = 0; int reasonCode = 0; int status = 0; @@ -133,9 +130,7 @@ char * __ptr32 csi(csi_parmblock* __ptr32 csi_parms, int *workAreaSizeInOut) { paramList->reasonCodePtr = reasonCodePtr; paramList->paramBlock = csi_parms; - fprintf (stderr, "about to call csi\n"); returnCode = callCsi(csiFn, paramList); - fprintf (stderr, "csi called\n"); reasonCode = *reasonCodePtr; if (returnCode != 0) { @@ -285,15 +280,16 @@ EntryDataSet *returnEntries(char *dsn, char *typesAllowed, int typesCount, int w int dsnLen = strlen(dsn); char *workArea = NULL; + if (dsnLen == 0){ + return NULL; + } + workAreaSize = (workAreaSize > 0 ? workAreaSize : WORK_AREA_SIZE); EntryDataSet *entrySet; entrySet = (EntryDataSet*)safeMalloc(sizeof(EntryDataSet),"Entry Data Set"); entrySet->length = 0; - - if (dsnLen == 0){ - return NULL; - } + entrySet->size = 0; /* prep parms */ memset(csi_parms,' ',sizeof(csi_parmblock)); @@ -427,7 +423,14 @@ EntryDataSet *getHLQs(char *typesAllowed, int typesCount, int workAreaSize, char void freeEntryDataSet(EntryDataSet *entrySet) { if (entrySet) { - if (entrySet->entries && entrySet->size > 0) { + if (entrySet->entries) { + for (int i = 0; i < entrySet->length; i++) { + EntryData *currentEntry = entrySet->entries[i]; + int fieldDataLength = currentEntry->data.fieldInfoHeader.totalLength; + int entrySize = sizeof(EntryData) + fieldDataLength - 4; + memset((char*)(currentEntry),0, entrySize); + safeFree((char*)(currentEntry), entrySize); + } safeFree((char*)entrySet->entries, entrySet->size * sizeof(EntryData*)); entrySet->entries = NULL; } From 41bf206623a3d5886deb0a4164ed89ca6bc46f2b Mon Sep 17 00:00:00 2001 From: Leonty Chudinov Date: Thu, 7 Oct 2021 12:45:52 +0500 Subject: [PATCH 20/33] Provide saveArea in 64bit mode Signed-off-by: Leonty Chudinov --- c/jcsi.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/c/jcsi.c b/c/jcsi.c index 3ae82997c..83b95f759 100644 --- a/c/jcsi.c +++ b/c/jcsi.c @@ -58,12 +58,13 @@ static CsiFn loadCsi() { return csiFn; } -int callCsi(CsiFn *csiFn, void *__ptr32 paramList) { +static int callCsi(CsiFn *csiFn, void *__ptr32 paramList, char* __ptr32 saveArea) { int returnCode = 0; __asm( ASM_PREFIX #ifdef _LP64 + " L 13,%[saveArea] \n" " SAM31 \n" " SYSSTATE AMODE64=NO \n" #endif @@ -76,8 +77,9 @@ int callCsi(CsiFn *csiFn, void *__ptr32 paramList) { " ST 15,%[returnCode] \n" : [returnCode] "=m"(returnCode) : [csiFn] "r"(csiFn), - [paramList] "r"(paramList) - : "r0", "r1", "r15"); + [paramList] "r"(paramList), + [saveArea] "m"(saveArea) + : "r0", "r1", "r13", "r15"); return returnCode; } @@ -98,6 +100,7 @@ char * __ptr32 csi(csi_parmblock* __ptr32 csi_parms, int *workAreaSizeInOut) { int * __ptr32 reasonCodePtr; csi_parmblock * __ptr32 paramBlock; char * __ptr32 workArea; + char saveArea[72]; ) ); @@ -130,7 +133,7 @@ char * __ptr32 csi(csi_parmblock* __ptr32 csi_parms, int *workAreaSizeInOut) { paramList->reasonCodePtr = reasonCodePtr; paramList->paramBlock = csi_parms; - returnCode = callCsi(csiFn, paramList); + returnCode = callCsi(csiFn, paramList, paramList->saveArea); reasonCode = *reasonCodePtr; if (returnCode != 0) { From f0c71bc8f5c843b478da338854043ada65c6fe2c Mon Sep 17 00:00:00 2001 From: Leonty Chudinov Date: Thu, 7 Oct 2021 15:05:58 +0500 Subject: [PATCH 21/33] Load IGGCSI00 only once Signed-off-by: Leonty Chudinov --- c/jcsi.c | 20 ++++++++++++++------ h/jcsi.h | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/c/jcsi.c b/c/jcsi.c index 83b95f759..bcaf1dd72 100644 --- a/c/jcsi.c +++ b/c/jcsi.c @@ -38,11 +38,16 @@ */ typedef void* __ptr32 CsiFn; +static CsiFn csiFn = NULL; -static CsiFn loadCsi() { +int loadCsi() { int entryPoint = 0; int status = 0; - CsiFn csiFn = NULL; + + if (csiFn != NULL) { + zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG2, "IGGCSI00 already loaded at 0x%p\n", csiFn); + return 0; + } __asm(ASM_PREFIX " LOAD EP=IGGCSI00 \n" @@ -55,7 +60,7 @@ static CsiFn loadCsi() { csiFn = (CsiFn)entryPoint; } zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG2, "IGGCSI00 0x%p LOAD status = 0x%x\n", csiFn, status); - return csiFn; + return status; } static int callCsi(CsiFn *csiFn, void *__ptr32 paramList, char* __ptr32 saveArea) { @@ -89,7 +94,6 @@ char * __ptr32 csi(csi_parmblock* __ptr32 csi_parms, int *workAreaSizeInOut) { int reasonCode = 0; int status = 0; int entryPoint = 0; - CsiFn csiFn = NULL; char * __ptr32 workArea = NULL; int * __ptr32 reasonCodePtr = NULL; int workAreaSize = *workAreaSizeInOut > 2048 ? *workAreaSizeInOut : WORK_AREA_SIZE; @@ -110,9 +114,8 @@ char * __ptr32 csi(csi_parmblock* __ptr32 csi_parms, int *workAreaSizeInOut) { break; } - csiFn = loadCsi(); if (!csiFn) { - zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "could not load IGGCSI00\n"); + zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "IGGCSI00 not loaded\n"); break; } @@ -447,6 +450,11 @@ void freeEntryDataSet(EntryDataSet *entrySet) { #ifdef TEST_JCSI int main(int argc, char **argv) { + int status = 0; + if ((status = loadCsi()) != 0) { + fprintf (stderr, "failed to load IGGCSI00, status = 0x%x\n", status); + return EXIT_FAILURE; + } int status = pseudoLS(argv[1],3,entriesFields); printf("status 0x%x\n",status); } diff --git a/h/jcsi.h b/h/jcsi.h index c3c4f2288..b1e6c85e9 100644 --- a/h/jcsi.h +++ b/h/jcsi.h @@ -110,6 +110,7 @@ typedef struct EntryDataSet_tag{ EntryData **entries; } EntryDataSet; +int loadCsi(); char * __ptr32 csi(csi_parmblock* __ptr32 csi_parms, int *workAreaSize); EntryDataSet *returnEntries(char *dsn, char *typesAllowed, int typeCount, int workAreaSize, char **fields, int fieldCount, char *resumeName, char *resumeCatalogName, csi_parmblock * __ptr32 returnParms); EntryDataSet *getHLQs(char *typesAllowed, int typeCount, int workAreaSize, char **fields, int fieldCount, csi_parmblock *__ptr32 * __ptr32 returnParmsArray); From 6ec0cc2b43d507bb28d6557656909a5ccf0fb20a Mon Sep 17 00:00:00 2001 From: Leonty Chudinov Date: Thu, 7 Oct 2021 15:10:50 +0500 Subject: [PATCH 22/33] Don't clobber GPR 13 in 31-bit mode Signed-off-by: Leonty Chudinov --- c/jcsi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/c/jcsi.c b/c/jcsi.c index bcaf1dd72..2247a16b2 100644 --- a/c/jcsi.c +++ b/c/jcsi.c @@ -84,7 +84,11 @@ static int callCsi(CsiFn *csiFn, void *__ptr32 paramList, char* __ptr32 saveArea : [csiFn] "r"(csiFn), [paramList] "r"(paramList), [saveArea] "m"(saveArea) - : "r0", "r1", "r13", "r15"); + : "r0", "r1", +#ifdef _LP64 + "r13", +#endif + "r15"); return returnCode; } From 9cc35b0f39f7e6c6ced0430e3b1a30be89a29021 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Mon, 18 Oct 2021 02:24:48 -0400 Subject: [PATCH 23/33] Revert recovery changes Signed-off-by: Irek Fakhrutdinov --- c/recovery.c | 62 +++++----------------------------------------------- h/recovery.h | 15 +------------ 2 files changed, 6 insertions(+), 71 deletions(-) diff --git a/c/recovery.c b/c/recovery.c index 85356aec6..06710d299 100644 --- a/c/recovery.c +++ b/c/recovery.c @@ -23,7 +23,6 @@ #include "stdlib.h" #include "stdio.h" #include "string.h" -#define srbPrintf printf #endif #include "zowetypes.h" @@ -866,8 +865,6 @@ void recoveryDESCTs(){ "RSTUFPB DS CL32 \n" "RSTRINF DS CL(RCVSINFL) \n" "RSTDMTLT DS CL101 \n" - " DS 0D \n" - "RAFSTPTR DS D \n" "RSTLEN EQU *-RCVSTATE \n" " EJECT , \n" @@ -911,8 +908,7 @@ RecoveryContext *getRecoveryContext() { if (rleTask == NULL) { return NULL; } - RecoveryContext *ctx = rleTask->recoveryContext; - return ctx; + return rleTask->recoveryContext; #elif defined(__ZOWE_OS_AIX) || defined(__ZOWE_OS_LINUX) return theRecoveryContext; #endif /* __ZOWE_OS_ZOS */ @@ -1613,16 +1609,6 @@ static void removeRecoveryStateEntry(RecoveryContext *context) { entryToRemove = NULL; } -void showRecoveryState(){ - RecoveryContext *context = getRecoveryContext(); - printf("showRecoveryState context = 0x%p\n",context); - if (context){ - printf("entry = 0x%p\n",context->recoveryStateChain); - } else{ - printf("no chain\n"); - } -} - #elif defined(__ZOWE_OS_AIX) || defined(__ZOWE_OS_LINUX) RecoveryStateEntry *addRecoveryStateEntry(RecoveryContext *context, char *name, int flags, char *dumpTitle, @@ -1697,12 +1683,10 @@ static int16_t getLinkageStackToken(void) { return token; } -int recoveryPush(char *name, int flags, char *dumpTitle, - AnalysisFunction *userAnalysisFunction, void * __ptr32 analysisFunctionUserData, - CleanupFunction *userCleanupFunction, void * __ptr32 cleanupFunctionUserData) { - char *analysisFunctionStack = NULL; - int analysisFunctionStackSize = 0; - +int recoveryPush(char *name, int flags, char *dumpTitle, + AnalysisFunction *userAnalysisFunction, void * __ptr32 analysisFunctionUserData, + CleanupFunction *userCleanupFunction, void * __ptr32 cleanupFunctionUserData) { + RecoveryContext *context = getRecoveryContext(); if (context == NULL) { return RC_RCV_CONTEXT_NOT_FOUND; @@ -1802,25 +1786,6 @@ int recoveryPush(char *name, int flags, char *dumpTitle, : "r2", "r10", "r11", "r14", "r15" ); - /* this need to be set up right as the "correct" value for R13 or R4 on - retry. - - - how to get back on the real stack - analysis function is void so - use logic that sets R4/R13 now to be the real stack to resume on - - */ -#if defined(_LP64) && !defined(METTLE) - char *analysisFunctionStackEnd = ((char*)analysisFunctionStack)+analysisFunctionStackSize; - /* verify these pointers - tuesday morning */ - - long long stackPtr = (long long)analysisFunctionStackEnd-0x1000; /* give it the 2048 bias + "wiggle room" */ - newEntry->analysisStackPtr = (analysisFunctionStack ? - stackPtr : - newEntry->retryGPRs[4]); -#else - newEntry->analysisStackPtr = (analysisFunctionStack ? (long long)analysisFunctionStack : newEntry->retryGPRs[13]); -#endif if (newEntry->state & RECOVERY_STATE_ABENDED) { if (newEntry->flags & RCVR_FLAG_DELETE_ON_RETRY) { removeRecoveryStateEntry(context); @@ -1832,23 +1797,6 @@ int recoveryPush(char *name, int flags, char *dumpTitle, return RC_RCV_OK; } -/* This function is temporarily stubbed until fix available. It is an - experimental feature with no current callers */ - -int recoveryPush2(char *name, int flags, char *dumpTitle, - AnalysisFunction *userAnalysisFunction, void * __ptr32 analysisFunctionUserData, - char *analysisFunctionStack, int analysisFunctionStackSize, - CleanupFunction *userCleanupFunction, void * __ptr32 cleanupFunctionUserData) { - /* - return recoveryPushInternal(name,flags,dumpTitle, - userAnalysisFunction,analysisFunctionUserData, - analysisFunctionStack,analysisFunctionStackSize, - userCleanupFunction,cleanupFunctionUserData); - */ - return 0; -} - - #elif defined(__ZOWE_OS_AIX) || defined(__ZOWE_OS_LINUX) /* recoveryPush is a macro on AIX and Linux */ diff --git a/h/recovery.h b/h/recovery.h index a2c5417c1..ec7d91850 100644 --- a/h/recovery.h +++ b/h/recovery.h @@ -264,8 +264,7 @@ typedef struct RecoveryStateEntry_tag { char length; char title[100]; } dumpTitle; - char padding[3]; /* becaue of the weird 101 byte thing above to get to 8 byte alignment */ - long long analysisStackPtr; + } RecoveryStateEntry; typedef struct RecoveryContext_tag { @@ -352,7 +351,6 @@ typedef struct RecoveryContext_tag { #define recoveryUpdateStateServiceInfo RCVRUSSI #define recoveryGetABENDCode RCVRGACD #define runFunctioninESTAE RCVRNFNE -#define showRecoveryState SHRCVRST #endif #ifdef __ZOWE_OS_ZOS @@ -491,15 +489,6 @@ int recoveryPush(char *name, int flags, char *dumpTitle, AnalysisFunction *userAnalysisFunction, void * __ptr32 analysisFunctionUserData, CleanupFunction *userCleanupFunction, void * __ptr32 cleanupFunctionUserData); -/* recoveryPush2 is a variant that allows the analysisFunction to run on a clean stack and not - overwrite the stack upon which the error/abend occurred. - */ -int recoveryPush2(char *name, int flags, char *dumpTitle, - AnalysisFunction *userAnalysisFunction, void * __ptr32 analysisFunctionUserData, - char *analysisFunctionStack, int analysisFunctionStackSize, - CleanupFunction *userCleanupFunction, void * __ptr32 cleanupFunctionUserData); - - /***************************************************************************** * Pop the latest recovery state. @@ -514,8 +503,6 @@ int recoveryPush2(char *name, int flags, char *dumpTitle, *****************************************************************************/ void recoveryPop(); -void showRecoveryState(); - /***************************************************************************** * Set the new dump title * From b53a2a692940bc47f6982e7214b8de8c32c85998 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Sun, 31 Oct 2021 06:54:21 +0100 Subject: [PATCH 24/33] Remove tabs and dead code, fix formatting. Signed-off-by: Irek Fakhrutdinov --- c/shrmem64.c | 777 ++++++++++++++++++++++----------------------------- h/shrmem64.h | 19 +- 2 files changed, 344 insertions(+), 452 deletions(-) diff --git a/c/shrmem64.c b/c/shrmem64.c index dddcd4114..90e1b475f 100644 --- a/c/shrmem64.c +++ b/c/shrmem64.c @@ -19,16 +19,11 @@ #include "stdbool.h" #include "stddef.h" #include "stdint.h" -#include "stdio.h" #endif #include "shrmem64.h" #include "zos.h" -#ifndef _LP64 -/* #error ILP32 is not supported */ -#endif - typedef uint64_t MemObj; #define IARV64_V4PLIST_SIZE 160 @@ -46,118 +41,10 @@ static int makeRSN(int shrmem64RC, int iarv64RC, int iarv64RSN) { return rc; } -#pragma pack(packed) - -#define IARV64_REQUEST_GETSTOR 1 -#define IARV64_REQUEST_GETSHARED 2 -#define IARV64_REQUEST_DETACH 3 -#define IARV64_REQUEST_PAGEFIX 4 -#define IARV64_REQUEST_PAGEUNFIX 5 -#define IARV64_REQUEST_PAGEOUT 6 -#define IARV64_REQUEST_DISCARDDATA 7 -#define IARV64_REQUEST_PAGEIN 8 -#define IARV64_REQUEST_PROTECT 9 -#define IARV64_REQUEST_SHAREMEMOBJ 10 -#define IARV64_REQUEST_CHANGEACCESS 11 -#define IARV64_REQUEST_UNPROTECT 12 -#define IARV64_REQUEST_CHANGEGUARD 13 -#define IARV64_REQUEST_LIST 14 /* wtf is this */ -#define IARV64_REQUEST_GETCOMMON 15 -#define IARV64_REQUEST_COUNTPAGES 16 -#define IARV64_REQUEST_PCIEFIX 17 -#define IARV64_REQUEST_PCIEUNFIX 18 -#define IARV64_REQUEST_CHANGEATTRIBUTE 19 - -#define IARV64_FLAGS0_MTOKNSOURCE_SYSTEM 0x80 -#define IARV64_FLAGS0_MTOKNSOURCE_CREATOR 0x40 -#define IARV64_FLAGS0_MATCH_MOTOKEN 0x20 - -#define IARV64_FLAGS1_KEYUSED_KEY 0x80 -#define IARV64_FLAGS1_KEYUSED_USERTKN 0x40 -#define IARV64_FLAGS1_KEYUSED_TTOKEN 0x20 -#define IARV64_FLAGS1_KEYUSED_CONVERTSTART 0x10 -#define IARV64_FLAGS1_KEYUSED_GUARDSIZE64 0x08 -#define IARV64_FLAGS1_KEYUSED_CONVERTSIZE64 0x04 -#define IARV64_FLAGS1_KEYUSED_MOTKN 0x02 -#define IARV64_FLAGS1_KEYUSED_OWNERJOBNAME 0x01 - -#define IARV64_FLAGS2_COND_YES 0x80 -#define IARV64_FLAGS2_FPROT_NO 0x40 -#define IARV64_FLAGS2_CONTROL_AUTH 0x20 -#define IARV64_FLAGS2_GUARDLOC_HIGH 0x10 -#define IARV64_FLAGS2_CHANGEACCESS_GLOBAL 0x08 -#define IARV64_FLAGS2_PAGEFRAMESIZE_1MEG 0x04 -#define IARV64_FLAGS2_PAGEFRAMESIZE_MAX 0x02 -#define IARV64_FLAGS2_PAGEFRAMESIZE_ALL 0x01 - -#define IARV64_FLAGS3_X 0 - - -#define IARV64_FLAGS4_XX 1 - -#define IARV64_FLAGS5_XX 1 /* dump flags */ - - -typedef struct IARV64_V4Parms_tag{ - char version; /* 4 is the ly answer */ - char request; /* 2 is GETSHARED */ - char flags0; - char key; - char flags1; - char flags2; - char flags3; - char flags4; /* this one seems to have changeaccess.view=sharedwrite=0x10 */ - uint64_t segmentCount; - char ttoken[16]; /* i don't know the usage of this, but it is not filled in the calls in shrmem64 */ - /* offset 0x20 (32) */ - uint64_t token; /* input (literal token or address ??, probably address)*/ - uint64_t origin; /* output address */ - /* offset 0x30 (48) */ - uint64_t rangelistAddress; - uint64_t memobjStart; /* input */ - /* offset 0x40 (64) */ - uint32_t guardSize; - uint32_t convertSize; - uint32_t aletValue; - uint32_t numRange; /* number of ranges in range list */ - /* offset 0x50 (80) */ - uint32_t v64ListPtr; /* what is this? */ - uint32_t v64ListLength; /* what is this? */ - uint64_t convertStart; /* an address, i think */ - /* offset 0x60 (96) */ - uint64_t convertSize64; - uint64_t guardSize64; - /* offset 0x70 (112) */ - uint64_t userToken; /* how does this differ from token at offset 32?? */ - /* offset 0x78 (120) */ - char dumpPriority; - char flags5; - char flags6; - char flags7; - char dump; /* some constant */ - char flags8; - uint16_t ownerASID; - /* offset 0x80 (128) */ - char optionValue; - char unknown[8]; - char ownerJobName[8]; - char unknown145[7]; - /* offset 0x98 */ - uint64_t mapPageTable; - /* this next field is only in plist version = 5 and later */ - /* uint64_t units; - char flags9; - char flags10; - char flags11; - */ -} IARV64_V4Parms; - -#pragma pack(reset) - static MemObj getSharedMemObject(uint64_t segmentCount, MemObjToken token, - int key, - int alet, /* must be 0 (primary) or 2 (home) */ + int key, + int alet, /* must be 0 (primary) or 2 (home) */ uint32_t *iarv64RC, uint32_t *iarv64RSN) { @@ -166,85 +53,85 @@ static MemObj getSharedMemObject(uint64_t segmentCount, int localRSN = 0; char parmList[IARV64_V4PLIST_SIZE] = {0}; - if (key == SHRMEM64_USE_CALLER_KEY){ - if (alet == 0){ + if (key == SHRMEM64_USE_CALLER_KEY) { + if (alet == 0) { __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",ALETVALUE=0" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList) - : "r0", "r1", "r14", "r15" - ); - } else{ + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",ALETVALUE=0" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList) + : "r0", "r1", "r14", "r15" + ); + } else { __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",ALETVALUE=2" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList) - : "r0", "r1", "r14", "r15" - ); + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",ALETVALUE=2" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList) + : "r0", "r1", "r14", "r15" + ); } - } else{ + } else { char keyByte = key & 0xF; keyByte = (keyByte << 4); /* because there's always one more thing in MVS */ - if (alet == 0){ + if (alet == 0) { __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",KEY=%[key]" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",ALETVALUE=0" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList),[key]"m"(keyByte) - : "r0", "r1", "r14", "r15" - ); - } else{ + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",KEY=%[key]" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",ALETVALUE=0" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList),[key]"m"(keyByte) + : "r0", "r1", "r14", "r15" + ); + } else { __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",KEY=%[key]" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",ALETVALUE=2" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList),[key]"m"(keyByte) - : "r0", "r1", "r14", "r15" - ); + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",KEY=%[key]" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",ALETVALUE=2" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList),[key]"m"(keyByte) + : "r0", "r1", "r14", "r15" + ); } } @@ -260,100 +147,100 @@ static MemObj getSharedMemObject(uint64_t segmentCount, } static MemObj getSharedMemObjectNoFPROT(uint64_t segmentCount, - MemObjToken token, - int key, - int alet, /* must be 0 (primary) or 2 (home) */ - uint32_t *iarv64RC, - uint32_t *iarv64RSN) { + MemObjToken token, + int key, + int alet, /* must be 0 (primary) or 2 (home) */ + uint32_t *iarv64RC, + uint32_t *iarv64RSN) { MemObj result = 0; int localRC = 0; int localRSN = 0; char parmList[IARV64_V4PLIST_SIZE] = {0}; - if (key == SHRMEM64_USE_CALLER_KEY){ - if (alet == 0){ + if (key == SHRMEM64_USE_CALLER_KEY) { + if (alet == 0) { __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",FPROT=NO" - ",ALETVALUE=0" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList) - : "r0", "r1", "r14", "r15" - ); - } else{ + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",FPROT=NO" + ",ALETVALUE=0" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList) + : "r0", "r1", "r14", "r15" + ); + } else { __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",FPROT=NO" - ",ALETVALUE=2" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList) - : "r0", "r1", "r14", "r15" - ); + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",FPROT=NO" + ",ALETVALUE=2" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList) + : "r0", "r1", "r14", "r15" + ); } - } else{ + } else { char keyByte = key & 0xF; keyByte = (keyByte << 4); /* because there's always one more thing in MVS */ - if (alet == 0){ + if (alet == 0) { __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",KEY=%[key]" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",FPROT=NO" - ",ALETVALUE=0" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList),[key]"m"(keyByte) - : "r0", "r1", "r14", "r15" - ); - } else{ + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",KEY=%[key]" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",FPROT=NO" + ",ALETVALUE=0" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList),[key]"m"(keyByte) + : "r0", "r1", "r14", "r15" + ); + } else { __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",KEY=%[key]" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",FPROT=NO" - ",ALETVALUE=2" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList),[key]"m"(keyByte) - : "r0", "r1", "r14", "r15" - ); + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",KEY=%[key]" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",FPROT=NO" + ",ALETVALUE=2" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList),[key]"m"(keyByte) + : "r0", "r1", "r14", "r15" + ); } } @@ -371,9 +258,9 @@ static MemObj getSharedMemObjectNoFPROT(uint64_t segmentCount, static MemObj getCommonMemObject(uint64_t segmentCount, MemObjToken token, - int key, + int key, uint32_t *iarv64RC, - uint32_t *iarv64RSN){ + uint32_t *iarv64RSN) { MemObj result = 0; int localRC = 0; @@ -413,7 +300,7 @@ static MemObj getCommonMemObject(uint64_t segmentCount, static void shareMemObject(MemObj object, MemObjToken token, - int aletValue, + int aletValue, uint32_t *iarv64RC, uint32_t *iarv64RSN) { @@ -427,41 +314,41 @@ static void shareMemObject(MemObj object, } rangeList = {object, 0}; uint64_t rangeListAddress = (uint64_t)&rangeList; - - if (aletValue == 0){ + + if (aletValue == 0) { __asm( - ASM_PREFIX - " IARV64 REQUEST=SHAREMEMOBJ" - ",USERTKN=(%[token])" - ",RANGLIST=(%[range])" - ",NUMRANGE=1" - ",COND=YES" - ",ALETVALUE=0" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [range]"r"(&rangeListAddress), [parm]"r"(&parmList) - : "r0", "r1", "r14", "r15" - ); - } else{ + ASM_PREFIX + " IARV64 REQUEST=SHAREMEMOBJ" + ",USERTKN=(%[token])" + ",RANGLIST=(%[range])" + ",NUMRANGE=1" + ",COND=YES" + ",ALETVALUE=0" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [range]"r"(&rangeListAddress), [parm]"r"(&parmList) + : "r0", "r1", "r14", "r15" + ); + } else { __asm( - ASM_PREFIX - " IARV64 REQUEST=SHAREMEMOBJ" - ",USERTKN=(%[token])" - ",RANGLIST=(%[range])" - ",NUMRANGE=1" - ",COND=YES" - ",ALETVALUE=2" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [range]"r"(&rangeListAddress), [parm]"r"(&parmList) - : "r0", "r1", "r14", "r15" - ); + ASM_PREFIX + " IARV64 REQUEST=SHAREMEMOBJ" + ",USERTKN=(%[token])" + ",RANGLIST=(%[range])" + ",NUMRANGE=1" + ",COND=YES" + ",ALETVALUE=2" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [range]"r"(&rangeListAddress), [parm]"r"(&parmList) + : "r0", "r1", "r14", "r15" + ); } if (iarv64RC) { @@ -474,11 +361,10 @@ static void shareMemObject(MemObj object, } static void makeSharedWritable(MemObj object, - uint64_t segmentCount, - /* MemObjToken token, */ - int aletValue, - uint32_t *iarv64RC, - uint32_t *iarv64RSN) { + uint64_t segmentCount, + int aletValue, + uint32_t *iarv64RC, + uint32_t *iarv64RSN) { int localRC = 0; int localRSN = 0; char parmList[IARV64_V4PLIST_SIZE] = {0}; @@ -490,40 +376,39 @@ static void makeSharedWritable(MemObj object, uint64_t rangeListAddress = (uint64_t)&rangeList; - if (aletValue == 0){ + if (aletValue == 0) { __asm( - ASM_PREFIX - " IARV64 REQUEST=CHANGEACCESS" - ",VIEW=SHAREDWRITE" - /* ",USERTKN=(%[token])" */ - ",RANGLIST=(%[range])" - ",NUMRANGE=1" - ",ALETVALUE=0" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [range]"r"(&rangeListAddress), [parm]"r"(&parmList) - : "r0", "r1", "r14", "r15" - ); - } else{ + ASM_PREFIX + " IARV64 REQUEST=CHANGEACCESS" + ",VIEW=SHAREDWRITE" + /* ",USERTKN=(%[token])" */ + ",RANGLIST=(%[range])" + ",NUMRANGE=1" + ",ALETVALUE=0" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [range]"r"(&rangeListAddress), [parm]"r"(&parmList) + : "r0", "r1", "r14", "r15" + ); + } else { __asm( - ASM_PREFIX - " IARV64 REQUEST=CHANGEACCESS" - ",VIEW=SHAREDWRITE" - /* ",USERTKN=(%[token])" */ - ",RANGLIST=(%[range])" - ",NUMRANGE=1" - ",ALETVALUE=2" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [range]"r"(&rangeListAddress), [parm]"r"(&parmList) - : "r0", "r1", "r14", "r15" - ); + ASM_PREFIX + " IARV64 REQUEST=CHANGEACCESS" + ",VIEW=SHAREDWRITE" + ",RANGLIST=(%[range])" + ",NUMRANGE=1" + ",ALETVALUE=2" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [range]"r"(&rangeListAddress), [parm]"r"(&parmList) + : "r0", "r1", "r14", "r15" + ); } if (iarv64RC) { @@ -537,7 +422,7 @@ static void makeSharedWritable(MemObj object, static void detachSingleSharedMemObject(MemObj object, MemObjToken token, - int aletValue, + int aletValue, uint32_t *iarv64RC, uint32_t *iarv64RSN) { @@ -545,45 +430,45 @@ static void detachSingleSharedMemObject(MemObj object, int localRSN = 0; char parmList[IARV64_V4PLIST_SIZE] = {0}; - if (aletValue == 0){ + if (aletValue == 0) { __asm( - ASM_PREFIX - " IARV64 REQUEST=DETACH" - ",MATCH=SINGLE" - ",MEMOBJSTART=(%[mobj])" - ",MOTKN=(%[token])" - ",MOTKNCREATOR=USER" - ",AFFINITY=LOCAL" - ",OWNER=YES" - ",COND=YES" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) - : "r0", "r1", "r14", "r15" - ); - } else{ + ASM_PREFIX + " IARV64 REQUEST=DETACH" + ",MATCH=SINGLE" + ",MEMOBJSTART=(%[mobj])" + ",MOTKN=(%[token])" + ",MOTKNCREATOR=USER" + ",AFFINITY=LOCAL" + ",OWNER=YES" + ",COND=YES" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) + : "r0", "r1", "r14", "r15" + ); + } else { __asm( - ASM_PREFIX - " IARV64 REQUEST=DETACH" - ",MATCH=SINGLE" - ",MEMOBJSTART=(%[mobj])" - ",MOTKN=(%[token])" - ",MOTKNCREATOR=USER" - ",AFFINITY=LOCAL" - ",OWNER=YES" - ",COND=YES" - ",ALETVALUE=2" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) - : "r0", "r1", "r14", "r15" - ); + ASM_PREFIX + " IARV64 REQUEST=DETACH" + ",MATCH=SINGLE" + ",MEMOBJSTART=(%[mobj])" + ",MOTKN=(%[token])" + ",MOTKNCREATOR=USER" + ",AFFINITY=LOCAL" + ",OWNER=YES" + ",COND=YES" + ",ALETVALUE=2" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) + : "r0", "r1", "r14", "r15" + ); } if (iarv64RC) { @@ -596,53 +481,53 @@ static void detachSingleSharedMemObject(MemObj object, } static void detachSingleSharedMemObjectNotOwner(MemObj object, - MemObjToken token, - int aletValue, - uint32_t *iarv64RC, - uint32_t *iarv64RSN) { + MemObjToken token, + int aletValue, + uint32_t *iarv64RC, + uint32_t *iarv64RSN) { int localRC = 0; int localRSN = 0; char parmList[IARV64_V4PLIST_SIZE] = {0}; - if (aletValue == 0){ + if (aletValue == 0) { __asm( - ASM_PREFIX - " IARV64 REQUEST=DETACH" - ",MATCH=SINGLE" - ",MEMOBJSTART=(%[mobj])" - ",MOTKN=(%[token])" - ",MOTKNCREATOR=USER" - ",AFFINITY=LOCAL" - ",OWNER=NO" - ",COND=YES" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) - : "r0", "r1", "r14", "r15" - ); - } else{ + ASM_PREFIX + " IARV64 REQUEST=DETACH" + ",MATCH=SINGLE" + ",MEMOBJSTART=(%[mobj])" + ",MOTKN=(%[token])" + ",MOTKNCREATOR=USER" + ",AFFINITY=LOCAL" + ",OWNER=NO" + ",COND=YES" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) + : "r0", "r1", "r14", "r15" + ); + } else { __asm( - ASM_PREFIX - " IARV64 REQUEST=DETACH" - ",MATCH=SINGLE" - ",MEMOBJSTART=(%[mobj])" - ",MOTKN=(%[token])" - ",MOTKNCREATOR=USER" - ",AFFINITY=LOCAL" - ",OWNER=NO" - ",ALETVALUE=2" - ",COND=YES" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) - : "r0", "r1", "r14", "r15" - ); + ASM_PREFIX + " IARV64 REQUEST=DETACH" + ",MATCH=SINGLE" + ",MEMOBJSTART=(%[mobj])" + ",MOTKN=(%[token])" + ",MOTKNCREATOR=USER" + ",AFFINITY=LOCAL" + ",OWNER=NO" + ",ALETVALUE=2" + ",COND=YES" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) + : "r0", "r1", "r14", "r15" + ); } @@ -761,7 +646,7 @@ static void removeSystemInterestForSingleObject(MemObj object, } -static ASCB *localGetASCB(){ +static ASCB *localGetASCB() { int *mem = (int*)0; return (ASCB*)(mem[CURRENT_ASCB/sizeof(int)]&0x7FFFFFFF); } @@ -779,7 +664,8 @@ MemObjToken shrmem64GetAddressSpaceToken(void) { return result.token; } -int shrmem64Alloc2(MemObjToken userToken, size_t size, int key, int aletValue, bool fetchProtect, void **result, int *rsn) { +int shrmem64Alloc2(MemObjToken userToken, size_t size, int key, int aletValue, + bool fetchProtect, void **result, int *rsn) { uint32_t iarv64RC = 0, iarv64RSN = 0; @@ -789,15 +675,16 @@ int shrmem64Alloc2(MemObjToken userToken, size_t size, int key, int aletValue, b uint64_t segmentCount = 0; if ((size & 0xFFFFF) == 0) { segmentCount = size >> 20; - } else{ + } else { segmentCount = (size >> 20) + 1; } MemObj mobj = (fetchProtect ? - getSharedMemObject(segmentCount, userToken, key, aletValue, - &iarv64RC, &iarv64RSN) : - getSharedMemObjectNoFPROT(segmentCount, userToken, key, aletValue, - &iarv64RC, &iarv64RSN)); + getSharedMemObject(segmentCount, userToken, key, aletValue, + &iarv64RC, &iarv64RSN) : + getSharedMemObjectNoFPROT(segmentCount, userToken, key, + aletValue, + &iarv64RC, &iarv64RSN)); if (!isIARV64OK(iarv64RC)) { *rsn = makeRSN(RC_SHRMEM64_GETSHARED_FAILED, iarv64RC, iarv64RSN); return RC_SHRMEM64_GETSHARED_FAILED; @@ -809,14 +696,17 @@ int shrmem64Alloc2(MemObjToken userToken, size_t size, int key, int aletValue, b } int shrmem64Alloc(MemObjToken userToken, size_t size, void **result, int *rsn) { - return shrmem64Alloc2(userToken,size,SHRMEM64_USE_CALLER_KEY,0,true,result,rsn); + return shrmem64Alloc2(userToken, size, SHRMEM64_USE_CALLER_KEY, 0, true, + result, rsn); } -int shrmem64CommonAlloc(MemObjToken userToken, size_t size, void **result, int *rsn) { +int shrmem64CommonAlloc(MemObjToken userToken, size_t size, void **result, + int *rsn) { return shrmem64CommonAlloc2(userToken,size,0,result,rsn); } -int shrmem64CommonAlloc2(MemObjToken userToken, size_t size, int key, void **result, int *rsn) { +int shrmem64CommonAlloc2(MemObjToken userToken, size_t size, int key, + void **result, int *rsn) { uint32_t iarv64RC = 0, iarv64RSN = 0; @@ -826,7 +716,7 @@ int shrmem64CommonAlloc2(MemObjToken userToken, size_t size, int key, void **res uint64_t segmentCount = 0; if ((size & 0xFFFFF) == 0) { segmentCount = size >> 20; - } else{ + } else { segmentCount = (size >> 20) + 1; } @@ -870,13 +760,14 @@ int shrmem64ReleaseAll(MemObjToken userToken, int *rsn) { return RC_SHRMEM64_OK; } -int shrmem64GetAccess2(MemObjToken userToken, void *target, bool makeWritable, int aletValue, uint64_t size, int *rsn) { +int shrmem64GetAccess2(MemObjToken userToken, void *target, bool makeWritable, + int aletValue, uint64_t size, int *rsn) { uint32_t iarv64RC = 0, iarv64RSN = 0; uint64_t segmentCount = 0; if ((size & 0xFFFFF) == 0) { segmentCount = size >> 20; - } else{ + } else { segmentCount = (size >> 20) + 1; } @@ -887,7 +778,7 @@ int shrmem64GetAccess2(MemObjToken userToken, void *target, bool makeWritable, i *rsn = makeRSN(RC_SHRMEM64_SHAREMEMOBJ_FAILED, iarv64RC, iarv64RSN); return RC_SHRMEM64_SHAREMEMOBJ_FAILED; } - if (makeWritable){ + if (makeWritable) { makeSharedWritable(mobj, segmentCount, aletValue, &iarv64RC, &iarv64RSN); if (!isIARV64OK(iarv64RC)) { *rsn = makeRSN(RC_SHRMEM64_CHANGEACCESS_FAILED, iarv64RC, iarv64RSN); @@ -900,7 +791,7 @@ int shrmem64GetAccess2(MemObjToken userToken, void *target, bool makeWritable, i int shrmem64GetAccess(MemObjToken userToken, void *target, int *rsn) { /* it's ok to not know the number of segments if not making the MemObj writable */ - return shrmem64GetAccess2(userToken,target,false,0,0,rsn); + return shrmem64GetAccess2(userToken, target, false, 0, 0, rsn); } int shrmem64RemoveAccess(MemObjToken userToken, void *target, int *rsn) { @@ -918,16 +809,19 @@ int shrmem64RemoveAccess(MemObjToken userToken, void *target, int *rsn) { return RC_SHRMEM64_OK; } -int shrmem64RemoveAccess2(MemObjToken userToken, void *target, int aletValue, bool isOwner, int *rsn) { +int shrmem64RemoveAccess2(MemObjToken userToken, void *target, int aletValue, + bool isOwner, int *rsn) { uint32_t iarv64RC = 0, iarv64RSN = 0; MemObj mobj = (MemObj)target; - if (isOwner){ - detachSingleSharedMemObject(mobj, userToken, aletValue, &iarv64RC, &iarv64RSN); - } else{ - detachSingleSharedMemObjectNotOwner(mobj, userToken, aletValue, &iarv64RC, &iarv64RSN); + if (isOwner) { + detachSingleSharedMemObject(mobj, userToken, aletValue, &iarv64RC, + &iarv64RSN); + } else { + detachSingleSharedMemObjectNotOwner(mobj, userToken, aletValue, &iarv64RC, + &iarv64RSN); } if (!isIARV64OK(iarv64RC)) { *rsn = makeRSN(RC_SHRMEM64_DETACH_FAILED, iarv64RC, iarv64RSN); @@ -947,6 +841,3 @@ int shrmem64RemoveAccess2(MemObjToken userToken, void *target, int aletValue, bo Copyright Contributors to the Zowe Project. */ - - - diff --git a/h/shrmem64.h b/h/shrmem64.h index aa4808c5d..b28cffe63 100644 --- a/h/shrmem64.h +++ b/h/shrmem64.h @@ -24,10 +24,6 @@ #include "zowetypes.h" -#ifndef _LP64 -/* #error ILP32 is not supported */ -#endif - #ifndef __LONGNAME__ #define shrmem64GetAddressSpaceToken SHR64TKN @@ -66,12 +62,15 @@ int shrmem64Alloc(MemObjToken userToken, size_t size, void **result, int *rsn); /** This is the key, alet and fprot varying version of the above */ #define SHRMEM64_USE_CALLER_KEY -1 -int shrmem64Alloc2(MemObjToken userToken, size_t size, int key, int aletValue, bool fetchProtect, void **result, int *rsn); +int shrmem64Alloc2(MemObjToken userToken, size_t size, int key, int aletValue, + bool fetchProtect, void **result, int *rsn); /** Variant for common (shared with everybody!) */ -int shrmem64CommonAlloc(MemObjToken userToken, size_t size, void **result, int *rsn); -int shrmem64CommonAlloc2(MemObjToken userToken, size_t size, int key, void **result, int *rsn); +int shrmem64CommonAlloc(MemObjToken userToken, size_t size, void **result, + int *rsn); +int shrmem64CommonAlloc2(MemObjToken userToken, size_t size, int key, + void **result, int *rsn); /** * @brief Releases 64-bit shared storage. The storage will still be accessible @@ -121,7 +120,8 @@ int shrmem64GetAccess(MemObjToken userToken, void *target, int *rsn); This is the beefed-up version of shrmem64GetAccess that lets the caller control whether primary or home space is used and whether the object will be made writable. */ -int shrmem64GetAccess2(MemObjToken userToken, void *target, bool makeWritable, int aletValue, uint64_t size, int *rsn); +int shrmem64GetAccess2(MemObjToken userToken, void *target, bool makeWritable, + int aletValue, uint64_t size, int *rsn); /** * @brief Removes the addressability of the specified storage in the current @@ -136,7 +136,8 @@ int shrmem64GetAccess2(MemObjToken userToken, void *target, bool makeWritable, i * @return One of the RC_SHRMEM64_xx return codes. */ int shrmem64RemoveAccess(MemObjToken userToken, void *target, int *rsn); -int shrmem64RemoveAccess2(MemObjToken userToken, void *target, int aletValue, bool isOwner, int *rsn); +int shrmem64RemoveAccess2(MemObjToken userToken, void *target, int aletValue, + bool isOwner, int *rsn); #define RC_SHRMEM64_OK 0 #define RC_SHRMEM64_GETSHARED_FAILED 8 From 1a323dd691266e91781b446951137829c78c85ab Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Sun, 31 Oct 2021 06:58:51 +0100 Subject: [PATCH 25/33] Refactor the size-to-segment conversion. Signed-off-by: Irek Fakhrutdinov --- c/shrmem64.c | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/c/shrmem64.c b/c/shrmem64.c index 90e1b475f..eb4e3af4f 100644 --- a/c/shrmem64.c +++ b/c/shrmem64.c @@ -664,20 +664,25 @@ MemObjToken shrmem64GetAddressSpaceToken(void) { return result.token; } -int shrmem64Alloc2(MemObjToken userToken, size_t size, int key, int aletValue, - bool fetchProtect, void **result, int *rsn) { - - uint32_t iarv64RC = 0, iarv64RSN = 0; - - /* - * Convert size in bytes into segments (megabytes), round up if necessary. - */ +/* + * Convert size in bytes into segments (megabytes), round up if necessary. + */ +static uint64_t bytesToSegments(uint64_t size) { uint64_t segmentCount = 0; if ((size & 0xFFFFF) == 0) { segmentCount = size >> 20; } else { segmentCount = (size >> 20) + 1; } + return segmentCount; +} + +int shrmem64Alloc2(MemObjToken userToken, size_t size, int key, int aletValue, + bool fetchProtect, void **result, int *rsn) { + + uint32_t iarv64RC = 0, iarv64RSN = 0; + + uint64_t segmentCount = bytesToSegments(size); MemObj mobj = (fetchProtect ? getSharedMemObject(segmentCount, userToken, key, aletValue, @@ -710,15 +715,7 @@ int shrmem64CommonAlloc2(MemObjToken userToken, size_t size, int key, uint32_t iarv64RC = 0, iarv64RSN = 0; - /* - * Convert size in bytes into segments (megabytes), round up if necessary. - */ - uint64_t segmentCount = 0; - if ((size & 0xFFFFF) == 0) { - segmentCount = size >> 20; - } else { - segmentCount = (size >> 20) + 1; - } + uint64_t segmentCount = bytesToSegments(size); MemObj mobj = getCommonMemObject(segmentCount, userToken, key, &iarv64RC, &iarv64RSN); @@ -764,12 +761,8 @@ int shrmem64GetAccess2(MemObjToken userToken, void *target, bool makeWritable, int aletValue, uint64_t size, int *rsn) { uint32_t iarv64RC = 0, iarv64RSN = 0; - uint64_t segmentCount = 0; - if ((size & 0xFFFFF) == 0) { - segmentCount = size >> 20; - } else { - segmentCount = (size >> 20) + 1; - } + + uint64_t segmentCount = bytesToSegments(size); MemObj mobj = (MemObj)target; From d0ac7d2c6997116d058c18ebef43e4ff267197bd Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Sun, 31 Oct 2021 07:19:43 +0100 Subject: [PATCH 26/33] Simplify ALET handling. Signed-off-by: Irek Fakhrutdinov --- c/shrmem64.c | 453 +++++++++++++++++---------------------------------- 1 file changed, 145 insertions(+), 308 deletions(-) diff --git a/c/shrmem64.c b/c/shrmem64.c index eb4e3af4f..b11c9a58e 100644 --- a/c/shrmem64.c +++ b/c/shrmem64.c @@ -54,86 +54,44 @@ static MemObj getSharedMemObject(uint64_t segmentCount, char parmList[IARV64_V4PLIST_SIZE] = {0}; if (key == SHRMEM64_USE_CALLER_KEY) { - if (alet == 0) { - __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",ALETVALUE=0" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList) - : "r0", "r1", "r14", "r15" - ); - } else { - __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",ALETVALUE=2" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList) - : "r0", "r1", "r14", "r15" - ); - } + __asm( + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",ALETVALUE=%[alet]" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList), [alet]"m"(alet) + : "r0", "r1", "r14", "r15" + ); } else { char keyByte = key & 0xF; keyByte = (keyByte << 4); /* because there's always one more thing in MVS */ - if (alet == 0) { - __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",KEY=%[key]" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",ALETVALUE=0" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList),[key]"m"(keyByte) - : "r0", "r1", "r14", "r15" - ); - } else { - __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",KEY=%[key]" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",ALETVALUE=2" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList),[key]"m"(keyByte) - : "r0", "r1", "r14", "r15" - ); - } - + __asm( + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",KEY=%[key]" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",ALETVALUE=%[alet]" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList),[key]"m"(keyByte), [alet]"m"(alet) + : "r0", "r1", "r14", "r15" + ); } if (iarv64RC) { @@ -159,90 +117,46 @@ static MemObj getSharedMemObjectNoFPROT(uint64_t segmentCount, char parmList[IARV64_V4PLIST_SIZE] = {0}; if (key == SHRMEM64_USE_CALLER_KEY) { - if (alet == 0) { - __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",FPROT=NO" - ",ALETVALUE=0" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList) - : "r0", "r1", "r14", "r15" - ); - } else { - __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",FPROT=NO" - ",ALETVALUE=2" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList) - : "r0", "r1", "r14", "r15" - ); - } + __asm( + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",FPROT=NO" + ",ALETVALUE=%[alet]" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList), [alet]"m"(alet) + : "r0", "r1", "r14", "r15" + ); } else { char keyByte = key & 0xF; keyByte = (keyByte << 4); /* because there's always one more thing in MVS */ - if (alet == 0) { - __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",KEY=%[key]" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",FPROT=NO" - ",ALETVALUE=0" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList),[key]"m"(keyByte) - : "r0", "r1", "r14", "r15" - ); - } else { - __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",KEY=%[key]" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",FPROT=NO" - ",ALETVALUE=2" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList),[key]"m"(keyByte) - : "r0", "r1", "r14", "r15" - ); - } - + __asm( + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",KEY=%[key]" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",FPROT=NO" + ",ALETVALUE=%[alet]" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList),[key]"m"(keyByte), [alet]"m"(alet) + : "r0", "r1", "r14", "r15" + ); } if (iarv64RC) { @@ -315,41 +229,23 @@ static void shareMemObject(MemObj object, uint64_t rangeListAddress = (uint64_t)&rangeList; - if (aletValue == 0) { - __asm( - ASM_PREFIX - " IARV64 REQUEST=SHAREMEMOBJ" - ",USERTKN=(%[token])" - ",RANGLIST=(%[range])" - ",NUMRANGE=1" - ",COND=YES" - ",ALETVALUE=0" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [range]"r"(&rangeListAddress), [parm]"r"(&parmList) - : "r0", "r1", "r14", "r15" - ); - } else { - __asm( - ASM_PREFIX - " IARV64 REQUEST=SHAREMEMOBJ" - ",USERTKN=(%[token])" - ",RANGLIST=(%[range])" - ",NUMRANGE=1" - ",COND=YES" - ",ALETVALUE=2" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [range]"r"(&rangeListAddress), [parm]"r"(&parmList) - : "r0", "r1", "r14", "r15" - ); - } + __asm( + ASM_PREFIX + " IARV64 REQUEST=SHAREMEMOBJ" + ",USERTKN=(%[token])" + ",RANGLIST=(%[range])" + ",NUMRANGE=1" + ",COND=YES" + ",ALETVALUE=%[alet]" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [range]"r"(&rangeListAddress), [parm]"r"(&parmList), + [alet]"m"(aletValue) + : "r0", "r1", "r14", "r15" + ); if (iarv64RC) { *iarv64RC = localRC; @@ -376,40 +272,22 @@ static void makeSharedWritable(MemObj object, uint64_t rangeListAddress = (uint64_t)&rangeList; - if (aletValue == 0) { - __asm( - ASM_PREFIX - " IARV64 REQUEST=CHANGEACCESS" - ",VIEW=SHAREDWRITE" - /* ",USERTKN=(%[token])" */ - ",RANGLIST=(%[range])" - ",NUMRANGE=1" - ",ALETVALUE=0" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [range]"r"(&rangeListAddress), [parm]"r"(&parmList) - : "r0", "r1", "r14", "r15" - ); - } else { - __asm( - ASM_PREFIX - " IARV64 REQUEST=CHANGEACCESS" - ",VIEW=SHAREDWRITE" - ",RANGLIST=(%[range])" - ",NUMRANGE=1" - ",ALETVALUE=2" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [range]"r"(&rangeListAddress), [parm]"r"(&parmList) - : "r0", "r1", "r14", "r15" - ); - } + __asm( + ASM_PREFIX + " IARV64 REQUEST=CHANGEACCESS" + ",VIEW=SHAREDWRITE" + ",RANGLIST=(%[range])" + ",NUMRANGE=1" + ",ALETVALUE=%[alet]" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [range]"r"(&rangeListAddress), [parm]"r"(&parmList), + [alet]"m"(aletValue) + : "r0", "r1", "r14", "r15" + ); if (iarv64RC) { *iarv64RC = localRC; @@ -430,46 +308,26 @@ static void detachSingleSharedMemObject(MemObj object, int localRSN = 0; char parmList[IARV64_V4PLIST_SIZE] = {0}; - if (aletValue == 0) { - __asm( - ASM_PREFIX - " IARV64 REQUEST=DETACH" - ",MATCH=SINGLE" - ",MEMOBJSTART=(%[mobj])" - ",MOTKN=(%[token])" - ",MOTKNCREATOR=USER" - ",AFFINITY=LOCAL" - ",OWNER=YES" - ",COND=YES" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) - : "r0", "r1", "r14", "r15" - ); - } else { - __asm( - ASM_PREFIX - " IARV64 REQUEST=DETACH" - ",MATCH=SINGLE" - ",MEMOBJSTART=(%[mobj])" - ",MOTKN=(%[token])" - ",MOTKNCREATOR=USER" - ",AFFINITY=LOCAL" - ",OWNER=YES" - ",COND=YES" - ",ALETVALUE=2" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) - : "r0", "r1", "r14", "r15" - ); - } + __asm( + ASM_PREFIX + " IARV64 REQUEST=DETACH" + ",MATCH=SINGLE" + ",MEMOBJSTART=(%[mobj])" + ",MOTKN=(%[token])" + ",MOTKNCREATOR=USER" + ",AFFINITY=LOCAL" + ",OWNER=YES" + ",COND=YES" + ",ALETVALUE=%[alet]" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token), + [alet]"m"(aletValue) + : "r0", "r1", "r14", "r15" + ); if (iarv64RC) { *iarv64RC = localRC; @@ -489,47 +347,26 @@ static void detachSingleSharedMemObjectNotOwner(MemObj object, int localRSN = 0; char parmList[IARV64_V4PLIST_SIZE] = {0}; - if (aletValue == 0) { - __asm( - ASM_PREFIX - " IARV64 REQUEST=DETACH" - ",MATCH=SINGLE" - ",MEMOBJSTART=(%[mobj])" - ",MOTKN=(%[token])" - ",MOTKNCREATOR=USER" - ",AFFINITY=LOCAL" - ",OWNER=NO" - ",COND=YES" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) - : "r0", "r1", "r14", "r15" - ); - } else { - __asm( - ASM_PREFIX - " IARV64 REQUEST=DETACH" - ",MATCH=SINGLE" - ",MEMOBJSTART=(%[mobj])" - ",MOTKN=(%[token])" - ",MOTKNCREATOR=USER" - ",AFFINITY=LOCAL" - ",OWNER=NO" - ",ALETVALUE=2" - ",COND=YES" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token) - : "r0", "r1", "r14", "r15" - ); - - } + __asm( + ASM_PREFIX + " IARV64 REQUEST=DETACH" + ",MATCH=SINGLE" + ",MEMOBJSTART=(%[mobj])" + ",MOTKN=(%[token])" + ",MOTKNCREATOR=USER" + ",AFFINITY=LOCAL" + ",OWNER=NO" + ",ALETVALUE=%[alet]" + ",COND=YES" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [mobj]"r"(&object), [parm]"r"(&parmList), [token]"r"(&token), + [alet]"m"(aletValue) + : "r0", "r1", "r14", "r15" + ); if (iarv64RC) { *iarv64RC = localRC; From 7fffbc3014ff577656b119670e39dbaa756084f5 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Sun, 31 Oct 2021 07:29:19 +0100 Subject: [PATCH 27/33] Simplify key handling. Signed-off-by: Irek Fakhrutdinov --- c/shrmem64.c | 131 ++++++++++++++++++++------------------------------- 1 file changed, 52 insertions(+), 79 deletions(-) diff --git a/c/shrmem64.c b/c/shrmem64.c index b11c9a58e..e62438ed6 100644 --- a/c/shrmem64.c +++ b/c/shrmem64.c @@ -41,6 +41,12 @@ static int makeRSN(int shrmem64RC, int iarv64RC, int iarv64RSN) { return rc; } +static int getCurrentKey(void) { + int psw = extractPSW(); + int key = (psw >> 20) & 0x0000000F; + return key; +} + static MemObj getSharedMemObject(uint64_t segmentCount, MemObjToken token, int key, @@ -54,45 +60,29 @@ static MemObj getSharedMemObject(uint64_t segmentCount, char parmList[IARV64_V4PLIST_SIZE] = {0}; if (key == SHRMEM64_USE_CALLER_KEY) { - __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",ALETVALUE=%[alet]" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList), [alet]"m"(alet) - : "r0", "r1", "r14", "r15" - ); - } else { - char keyByte = key & 0xF; - keyByte = (keyByte << 4); /* because there's always one more thing in MVS */ - __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",KEY=%[key]" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",ALETVALUE=%[alet]" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList),[key]"m"(keyByte), [alet]"m"(alet) - : "r0", "r1", "r14", "r15" - ); + key = getCurrentKey(); } + char keyByte = key & 0xF; + keyByte = (keyByte << 4); /* because there's always one more thing in MVS */ + + __asm( + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",KEY=%[key]" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",ALETVALUE=%[alet]" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList), [key]"m"(keyByte), [alet]"m"(alet) + : "r0", "r1", "r14", "r15" + ); if (iarv64RC) { *iarv64RC = localRC; @@ -117,47 +107,30 @@ static MemObj getSharedMemObjectNoFPROT(uint64_t segmentCount, char parmList[IARV64_V4PLIST_SIZE] = {0}; if (key == SHRMEM64_USE_CALLER_KEY) { - __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",FPROT=NO" - ",ALETVALUE=%[alet]" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList), [alet]"m"(alet) - : "r0", "r1", "r14", "r15" - ); - } else { - char keyByte = key & 0xF; - keyByte = (keyByte << 4); /* because there's always one more thing in MVS */ - __asm( - ASM_PREFIX - " IARV64 REQUEST=GETSHARED" - ",USERTKN=(%[token])" - ",COND=YES" - ",KEY=%[key]" - ",SEGMENTS=(%[size])" - ",ORIGIN=(%[result])" - ",FPROT=NO" - ",ALETVALUE=%[alet]" - ",RETCODE=%[rc]" - ",RSNCODE=%[rsn]" - ",PLISTVER=4" - ",MF=(E,(%[parm]),COMPLETE) \n" - : [rc]"=m"(localRC), [rsn]"=m"(localRSN) - : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList),[key]"m"(keyByte), [alet]"m"(alet) - : "r0", "r1", "r14", "r15" - ); + key = getCurrentKey(); } + char keyByte = key & 0xF; + keyByte = (keyByte << 4); /* because there's always one more thing in MVS */ + + __asm( + ASM_PREFIX + " IARV64 REQUEST=GETSHARED" + ",USERTKN=(%[token])" + ",COND=YES" + ",KEY=%[key]" + ",SEGMENTS=(%[size])" + ",ORIGIN=(%[result])" + ",FPROT=NO" + ",ALETVALUE=%[alet]" + ",RETCODE=%[rc]" + ",RSNCODE=%[rsn]" + ",PLISTVER=4" + ",MF=(E,(%[parm]),COMPLETE) \n" + : [rc]"=m"(localRC), [rsn]"=m"(localRSN) + : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), + [parm]"r"(&parmList), [key]"m"(keyByte), [alet]"m"(alet) + : "r0", "r1", "r14", "r15" + ); if (iarv64RC) { *iarv64RC = localRC; @@ -198,7 +171,7 @@ static MemObj getCommonMemObject(uint64_t segmentCount, ",MF=(E,(%[parm]),COMPLETE) \n" : [rc]"=m"(localRC), [rsn]"=m"(localRSN) : [token]"r"(&token), [size]"r"(&segmentCount), [result]"r"(&result), - [parm]"r"(&parmList),[key]"m"(keyByte) + [parm]"r"(&parmList), [key]"m"(keyByte) : "r0", "r1", "r14", "r15" ); From 31dee50cb072e0375afdf5e12c6c34f1d1410d53 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Tue, 2 Nov 2021 09:24:49 +0100 Subject: [PATCH 28/33] Remove tabs, add doc. Signed-off-by: Irek Fakhrutdinov --- c/pause-element.c | 20 ++++++++++---------- h/pause-element.h | 19 ++++++++++++++++--- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/c/pause-element.c b/c/pause-element.c index aad6a430f..cc978f555 100644 --- a/c/pause-element.c +++ b/c/pause-element.c @@ -197,13 +197,13 @@ int peRetrieveInfo(const PET *token, } int peRetrieveInfo2(const PET *token, - PEInfo *info, - bool isBranchLinkage, - bool untrusted){ - + PEInfo *info, + bool isBranchLinkage, + bool untrusted) { + int32_t rc = 0; int32_t linkage = isBranchLinkage ? PE_LINKAGE_BRANCH : PE_LINKAGE_SVC; - if (untrusted){ + if (untrusted) { linkage |= PE_LINKAGE_UNTRUSTED_PET; } @@ -221,7 +221,7 @@ int peRetrieveInfo2(const PET *token, if (isBranchLinkage) { setKey(key); if (wasProblemState) { - supervisorMode(FALSE); + supervisorMode(FALSE); } } @@ -239,10 +239,10 @@ int peTest(const PET *token, } int peTransfer(const PET *token, PET *newToken, - PEReleaseCode *releaseCode, - const PET *targetToken, - PEReleaseCode targetReleaseCode, - bool isBranchLinkage) { + PEReleaseCode *releaseCode, + const PET *targetToken, + PEReleaseCode targetReleaseCode, + bool isBranchLinkage) { int32_t rc = 0; int32_t linkage = isBranchLinkage ? PE_LINKAGE_BRANCH : PE_LINKAGE_SVC; diff --git a/h/pause-element.h b/h/pause-element.h index 556b590cf..768ffb1d5 100644 --- a/h/pause-element.h +++ b/h/pause-element.h @@ -170,10 +170,23 @@ int peRetrieveInfo(const PET *token, PEInfo *info, bool isBranchLinkage); +/** + * @brief Gets information about a pause element (see the IEAVRPI2 doc for + * details). + * + * @param token The pause element token associated with the pause element. + * @param info The pause element information. + * @param isBranchLinkage The services routine will be invoked via a branch + * instruction. The caller must be in both key 0 and supervisor state. + * @param untrusted If true, validate if the pause element is allowed to be + * used by an unauthorized caller. + * + * @return The IEAVRPI2 return code value. + */ int peRetrieveInfo2(const PET *token, - PEInfo *info, - bool isBranchLinkage, - bool untrusted); + PEInfo *info, + bool isBranchLinkage, + bool untrusted); /** * @brief Test a pause element and determines its state. The caller is From 3685d2797c455772ecc47f4cad247d13531746b0 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Tue, 2 Nov 2021 11:07:19 +0100 Subject: [PATCH 29/33] Avoid allocating storage in radmin Signed-off-by: Irek Fakhrutdinov --- c/radmin.c | 393 ++++++++++++++++++----------------------------------- h/radmin.h | 1 - 2 files changed, 129 insertions(+), 265 deletions(-) diff --git a/c/radmin.c b/c/radmin.c index 880bb73ac..8ff85254a 100644 --- a/c/radmin.c +++ b/c/radmin.c @@ -3,7 +3,7 @@ /* 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 www.eclipse.org/legal/epl-v20.html + this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html SPDX-License-Identifier: EPL-2.0 @@ -39,13 +39,6 @@ #include "radmin.h" #include "utils.h" -#ifndef METTLE -#ifdef _LP64 -#pragma linkage(IRRSEQ00, OS) -#else -#pragma linkage(IRRSEQ00, OS) -#endif -#endif #pragma enum(1) typedef enum RadminFunctionCode_tag { @@ -86,7 +79,7 @@ typedef enum RadminFunctionCode_tag { } RadminFunctionCode; #pragma enum(reset) -#define RADMIN_WORK_AREA_SIZE 1024 +typedef char RadminWorkArea[1024]; typedef void RadminParmList; #ifdef RADMIN_XMEM_MODE @@ -141,33 +134,13 @@ static void freeXTROutput(RadminXTROutput *data) { CVT+0x220 (544) is the CSR table (CVTCSRT) 0x18 CSR slot (BPX services) - 0x28 RACF (IRR) slot - 0x48 GXL XML services - - */ - + 0x28 RACF (IRR) slot + 0x48 GXL XML services -int IRRSEQ00( - char * __ptr32 workArea, - int32_t * __ptr32 safReturnCodeALET, int32_t * __ptr32 safReturnCode, - int32_t * __ptr32 racfReturnCodeALET, int32_t * __ptr32 racfReturnCode, - int32_t * __ptr32 racfReasonCodeALET, int32_t * __ptr32 racfReasonCode, - RadminFunctionCode * __ptr32 functionCode, - RadminParmList * __ptr32 parmList, - RadminUserID * __ptr32 userID, - ACEE * __ptr32 * __ptr32 acee, - uint8_t * __ptr32 outMessageSubpool, - void * __ptr32 * __ptr32 outMessage) -#ifdef METTLE -__attribute__((amode31)); -#else -; -#endif - -#define DATA31_LENGTH 16 + */ -typedef struct IRRSEQ00Arguments_tag{ - char * __ptr32 workArea; +typedef struct IRRSEQ00Arguments_tag { + RadminWorkArea * __ptr32 workArea; int32_t * __ptr32 safReturnCodeALET; int32_t * __ptr32 safReturnCode; int32_t * __ptr32 racfReturnCodeALET; @@ -179,76 +152,50 @@ typedef struct IRRSEQ00Arguments_tag{ RadminUserID * __ptr32 userID; ACEE * __ptr32 * __ptr32 acee; uint8_t * __ptr32 outMessageSubpool; - int outMessage; /* it's really a handle, but the VL bit and other issues just make this too annoying */ - + uint32_t outMessage; /* it's really a handle, but the VL bit and other issues just make this too annoying */ } IRRSEQ00Arguments; - /* - IRRSEQ00( - workArea, - &(status->alet), &(status->safRC), - &(status->alet), &(status->racfRC), - &(status->alet), &(status->racfRSN), - functionCodeBox, - parmList, - &(callerAuthInfo->userID), - &(callerAuthInfo->acee), - subpoolBox, - resultPtr - ); -...i...0.........0..... -400280005F015F025F021F5F000F -1007900280008F208F08E08F007F -LA 0,X'27' -SLL 0,2 -L 15,10(,0) -L 15,X'220'(,15) -L 15,X'28'(15) -AHI 15,X'9C' -L 15,0(,15) -BASR 14,15 - */ - - -/* The result doesn't need to be a 32-bit pointer, it just needs to be a - 31 bit chunk of memory that is being pointed at. - */ - -static void *invokeRadmin(char * __ptr32 workArea, - RadminAPIStatus *__ptr32 status, +static void *invokeRadmin( + RadminAPIStatus *status, RadminFunctionCode functionCode, RadminParmList * __ptr32 parmList, - RadminCallerAuthInfo *__ptr32 callerAuthInfo, + RadminCallerAuthInfo *callerAuthInfo, uint8_t resultSubpool ) { + ALLOC_STRUCT31( + STRUCT31_NAME(below2G), + STRUCT31_FIELDS( + IRRSEQ00Arguments arguments; + RadminWorkArea workArea; + RadminCallerAuthInfo callerAuthInfo; + RadminAPIStatus status; + void * __ptr32 result; + int32_t alet; + RadminFunctionCode functionCode; + uint8_t resultSubpool; + ) + ); - /* get the immediate data that needs to have 31 bit pointers into 31 bit area and - make some pointers that point in. */ - char *__ptr32 data31 = (char *__ptr32)safeMalloc31(DATA31_LENGTH,"IRRSEQ00Data:31"); - memset(data31,0,DATA31_LENGTH); - RadminFunctionCode *__ptr32 functionCodeBox = (RadminFunctionCode *__ptr32)data31; - *functionCodeBox = functionCode; - uint8_t *__ptr32 subpoolBox = (uint8_t*)(data31+4); - /* make the handle and the pointer be in 3 and fourth slots of DAT31 */ - *subpoolBox = resultSubpool; - - IRRSEQ00Arguments *__ptr32 arguments = (IRRSEQ00Arguments *__ptr32)safeMalloc31(sizeof(IRRSEQ00Arguments),"IRRSEQ00Arguments:31"); - arguments->workArea = workArea; - arguments->safReturnCodeALET = &(status->alet); - arguments->safReturnCode = &(status->safRC); - arguments->racfReturnCodeALET = &(status->alet); - arguments->racfReturnCode = &(status->racfRC); - arguments->racfReasonCodeALET = &(status->alet); - arguments->racfReasonCode = &(status->racfRSN); - arguments->functionCode = functionCodeBox; + below2G->callerAuthInfo = *callerAuthInfo; + below2G->alet = 0; /* primary */ + below2G->functionCode = functionCode; + below2G->resultSubpool = resultSubpool; + + IRRSEQ00Arguments * __ptr32 arguments = &below2G->arguments; + arguments->workArea = &below2G->workArea; + arguments->safReturnCodeALET = &below2G->alet; + arguments->safReturnCode = &below2G->status.safRC; + arguments->racfReturnCodeALET = &below2G->alet; + arguments->racfReturnCode = &below2G->status.racfRC; + arguments->racfReasonCodeALET = &below2G->alet; + arguments->racfReasonCode = &below2G->status.racfRSN; + arguments->functionCode = &below2G->functionCode; arguments->parmList = parmList; - arguments->userID = &(callerAuthInfo->userID); - arguments->acee = &(callerAuthInfo->acee); - arguments->outMessageSubpool = subpoolBox; - arguments->outMessage = ((int)(data31+8))|0x80000000; - uint32_t argumentsAddress = (uint32_t)arguments; - + arguments->userID = &below2G->callerAuthInfo.userID; + arguments->acee = &below2G->callerAuthInfo.acee; + arguments->outMessageSubpool = &below2G->resultSubpool; + arguments->outMessage = ((uint32_t)&below2G->result | 0x80000000); #ifdef RADMIN_XMEM_MODE /* When in PC-cp PSW key != TCB key, depending on the subpool R_admin will @@ -260,95 +207,53 @@ static void *invokeRadmin(char * __ptr32 workArea, #endif __asm(ASM_PREFIX - /* still need compiled C-code addressing mode to get this address */ - " XGR 1,1 \n" - " L 1,%0 \n" #ifdef _LP64 - " SAM31 \n" -#endif - " L 15,X'10'(,0) \n" - " L 15,X'220'(,15) \n" /* CSR Table */ - " L 15,X'28'(,15) \n" /* IRR Slot */ - " AHI 15,X'9C' \n" /* Make pointer int IRR Slot */ - " L 15,0(,15) \n" /* Load routine pointer for IRRSEQ00 */ - " BASR 14,15 \n" + " SAM31 \n" +#endif + " L 15,X'10'(,0) \n" + " L 15,X'220'(,15) \n" /* CSR Table */ + " L 15,X'28'(,15) \n" /* IRR Slot */ + " AHI 15,X'9C' \n" /* Make pointer int IRR Slot */ + " L 15,0(,15) \n" /* Load routine pointer for IRRSEQ00 */ + " BASR 14,15 \n" #ifdef _LP64 - " SAM64 \n" -#endif - : : - "m"(argumentsAddress) - : "r1", "r14", "r15"); + " SAM64 \n" +#endif + : + : "NR:r1"(arguments) + : "r1", "r14", "r15" + ); #ifdef RADMIN_XMEM_MODE setKey(oldKey); #endif - void *result = (void*)((int*)data31)[2]; - - safeFree31(data31,DATA31_LENGTH); - safeFree31((char*)arguments,sizeof(IRRSEQ00Arguments)); - return result; -} - -static char *__ptr32 allocateWorkArea(){ - char *__ptr32 workArea = safeMalloc31(RADMIN_WORK_AREA_SIZE,"Radmin WorkArea"); - memset(workArea,0,RADMIN_WORK_AREA_SIZE); - return workArea; -} - -static void freeWorkArea(char *__ptr32 workArea){ - safeFree31(workArea,RADMIN_WORK_AREA_SIZE); -} - -static RadminAPIStatus *__ptr32 allocateAPIStatus(){ - RadminAPIStatus *__ptr32 apiStatus = (RadminAPIStatus *__ptr32)safeMalloc31(sizeof(RadminAPIStatus),"RadminAPIStatus:31"); - memset(apiStatus,0,sizeof(RadminAPIStatus)); - return apiStatus; -} - -static void freeAPIStatus(RadminAPIStatus *__ptr32 apiStatus){ - safeFree31((char *__ptr32)apiStatus,sizeof(RadminAPIStatus)); -} + *status = below2G->status; + void *result = below2G->result; -static RadminCallerAuthInfo *__ptr32 makeCallerAuthInfo31(RadminCallerAuthInfo callerAuthInfo){ - RadminCallerAuthInfo *__ptr32 authInfo31 = - (RadminCallerAuthInfo *__ptr32)safeMalloc31(sizeof(RadminCallerAuthInfo),"RadminCallerAuthInfo31"); - memcpy(authInfo31,&callerAuthInfo,sizeof(RadminCallerAuthInfo)); - return authInfo31; -} + FREE_STRUCT31( + STRUCT31_NAME(below2G) + ); -static void freeCallerAuthInfo31(RadminCallerAuthInfo *__ptr32 authInfo31){ - safeFree31((char*)authInfo31,sizeof(RadminCallerAuthInfo)); + return result; } -static RadminAPIStatus *__ptr32 runRACFCommand( +static RadminAPIStatus runRACFCommand( RadminCallerAuthInfo callerAuthInfo, RadminRACFCommand *__ptr32 command, - RadminCommandOutput * __ptr32 * __ptr32 result, + RadminCommandOutput **result ) { - char *__ptr32 workArea = allocateWorkArea(); - - RadminAPIStatus *__ptr32 status = allocateAPIStatus(); - RadminCallerAuthInfo *__ptr32 authInfo31 = makeCallerAuthInfo31(callerAuthInfo); - - RadminUserID callerUserID = callerAuthInfo.userID; - ACEE * __ptr32 callerACEE = callerAuthInfo.acee; - - uint8_t resultSubpool = RADMIN_RESULT_BUFFER_SUBPOOL; + RadminAPIStatus status = {0}; void *output = invokeRadmin( - workArea, - status, + &status, RADMIN_FC_RUN_COMD, - (RadminParmList *__ptr32)command, - authInfo31, - resultSubpool + command, + &callerAuthInfo, + RADMIN_RESULT_BUFFER_SUBPOOL ); - *result = (RadminCommandOutput *__ptr32)output; - - freeWorkArea(workArea); - freeCallerAuthInfo31(authInfo31); + *result = output; return status; } @@ -381,25 +286,29 @@ int radminRunRACFCommand( return RC_RADMIN_BAD_INPUT; } - RadminRACFCommand *__ptr32 internalCommand = - (RadminRACFCommand *__ptr32)safeMalloc31(sizeof(RadminRACFCommand),"RadminRACFCommand"); - internalCommand->length = (uint16_t)commandLength; - memcpy(internalCommand->text, command, commandLength); - int rc = RC_RADMIN_OK; - RadminCommandOutput * __ptr32 result = NULL; - RadminCommandOutput * __ptr32 * __ptr32 resultHandle = (RadminCommandOutput * __ptr32 * __ptr32)safeMalloc31(4,"RACF Result Handle"); - *resultHandle = result; - /* i think the ampersand operator will introduce a 64-bit pointer 3 lines down */ - RadminAPIStatus statusOnStack; - RadminAPIStatus *__ptr32 apiStatus31 = runRACFCommand(callAuthInfo, - internalCommand, - resultHandle); - statusOnStack = *apiStatus31; - result = *resultHandle; + RadminCommandOutput *result = NULL; + + ALLOC_STRUCT31( + STRUCT31_NAME(below2G), + STRUCT31_FIELDS( + RadminRACFCommand internalCommand; + ) + ); + below2G->internalCommand.length = commandLength; + memcpy(below2G->internalCommand.text, command, commandLength); + + RadminAPIStatus apiStatus = runRACFCommand(callAuthInfo, + &below2G->internalCommand, + &result); + + FREE_STRUCT31( + STRUCT31_NAME(below2G) + ); + if (result != NULL) { - int visitRC = userHandler(statusOnStack, result, userHandlerData); + int visitRC = userHandler(apiStatus, result, userHandlerData); if (visitRC != 0) { status->reasonCode = visitRC; rc = RC_RADMIN_NONZERO_USER_RC; @@ -407,11 +316,9 @@ int radminRunRACFCommand( } - safeFree31((char*)internalCommand,sizeof(RadminRACFCommand)); - - if (apiStatus31->safRC > 0) { + if (apiStatus.safRC > 0) { - status->apiStatus = *apiStatus31; + status->apiStatus = apiStatus; rc = RC_RADMIN_SYSTEM_ERROR; } @@ -420,9 +327,7 @@ int radminRunRACFCommand( freeCommandOutput(result); result = NULL; } - safeFree31((char*)resultHandle,4); - freeAPIStatus(apiStatus31); return rc; } @@ -462,46 +367,43 @@ static RadminAPIStatus extractProfileInternal( size_t classNameLength, bool isNext, bool *isProfileGeneric, - RadminXTROutput **result, + RadminXTROutput **result ) { - char *__ptr32 workArea = allocateWorkArea(); - - RadminAPIStatus *__ptr32 status = allocateAPIStatus(); - RadminCallerAuthInfo *__ptr32 authInfo31 = makeCallerAuthInfo31(callerAuthInfo); + RadminAPIStatus status = {0}; RadminFunctionCode functionCode = getProfileXTRFunctionCode(type, isNext); - RadminXTRParmList *__ptr32 parmList = (RadminXTRParmList *__ptr32)safeMalloc31(sizeof(RadminXTRParmList),"RadminXTRParmList:31"); - parmList->header.profileNameLength = profileNameLength; - parmList->header.flag = RADMIN_XTR_HDR_FLAG_BASE_SEG_ONLY; + ALLOC_STRUCT31( + STRUCT31_NAME(below2G), + STRUCT31_FIELDS( + RadminXTRParmList parmList; + ) + ); + + below2G->parmList.header.profileNameLength = profileNameLength; + below2G->parmList.header.flag = RADMIN_XTR_HDR_FLAG_BASE_SEG_ONLY; if (*isProfileGeneric == true) { - parmList->header.flag |= RADMIN_XTR_HDR_FLAG_GENERIC; + below2G->parmList.header.flag |= RADMIN_XTR_HDR_FLAG_GENERIC; } - memset(parmList->header.className, ' ', sizeof(parmList->header.className)); - memcpy(parmList->header.className, className, classNameLength); - memcpy(parmList->profileName, profileName, profileNameLength); - - RadminUserID callerUserID = callerAuthInfo.userID; - ACEE * __ptr32 callerACEE = callerAuthInfo.acee; - - uint8_t resultSubpool = RADMIN_RESULT_BUFFER_SUBPOOL; + memset(below2G->parmList.header.className, ' ', + sizeof(below2G->parmList.header.className)); + memcpy(below2G->parmList.header.className, className, classNameLength); + memcpy(below2G->parmList.profileName, profileName, profileNameLength); void *output = invokeRadmin( - workArea, - status, + &status, functionCode, - (RadminParmList *__ptr32)parmList, - authInfo31, - resultSubpool + &below2G->parmList, + &callerAuthInfo, + RADMIN_RESULT_BUFFER_SUBPOOL ); - printf("output=0x%p\n",output);fflush(stdout); - *result = output; + FREE_STRUCT31( + STRUCT31_NAME(below2G) + ); - freeWorkArea(workArea); - freeCallerAuthInfo31(authInfo31); - safeFree31((char*)parmList,sizeof(RadminXTRParmList)); + *result = output; if (*result != NULL) { RadminXTRHeader *resultHeader = &(*result)->header; @@ -510,8 +412,7 @@ static RadminAPIStatus extractProfileInternal( } } - RadminAPIStatus statusOnStack = *status; - return statusOnStack; + return status; } #define IS_XTR_EODAT(apiStatus) \ @@ -1408,28 +1309,16 @@ int radminPerformResAction( return RC_RADMIN_BAD_INPUT; } - char *__ptr32 workArea = allocateWorkArea(); - RadminCallerAuthInfo *__ptr32 authInfo31 = makeCallerAuthInfo31(callerAuthInfo); - int32_t statusALET = 0; /* primary */ - RadminAPIStatus *apiStatus = &status->apiStatus; - RadminUserID callerUserID = callerAuthInfo.userID; - ACEE * __ptr32 callerACEE = callerAuthInfo.acee; - - uint8_t resultSubpool = RADMIN_RESULT_BUFFER_SUBPOOL; RadminCommandOutput * __ptr32 result = invokeRadmin( - workArea, - apiStatus, + &status->apiStatus, functionCode, actionParmList, - authInfo31, - resultSubpool + &callerAuthInfo, + RADMIN_RESULT_BUFFER_SUBPOOL ); - freeWorkArea(workArea); - freeCallerAuthInfo31(authInfo31); - int rc = RC_RADMIN_OK; - if (apiStatus->safRC != 0) { + if (status->apiStatus.racfRC != 0) { rc = RC_RADMIN_SYSTEM_ERROR; } @@ -1495,28 +1384,16 @@ int radminPerformGroupAction( return RC_RADMIN_BAD_INPUT; } - char *__ptr32 workArea = allocateWorkArea(); - RadminCallerAuthInfo *__ptr32 authInfo31 = makeCallerAuthInfo31(callerAuthInfo); - int32_t statusALET = 0; /* primary */ - RadminAPIStatus *apiStatus = &status->apiStatus; - RadminUserID callerUserID = callerAuthInfo.userID; - ACEE * __ptr32 callerACEE = callerAuthInfo.acee; - - uint8_t resultSubpool = RADMIN_RESULT_BUFFER_SUBPOOL; RadminCommandOutput * __ptr32 result = invokeRadmin( - workArea, - apiStatus, + &status->apiStatus, functionCode, actionParmList, - authInfo31, - resultSubpool + &callerAuthInfo, + RADMIN_RESULT_BUFFER_SUBPOOL ); - freeWorkArea(workArea); - freeCallerAuthInfo31(authInfo31); - int rc = RC_RADMIN_OK; - if (apiStatus->safRC != 0) { + if (status->apiStatus.safRC != 0) { rc = RC_RADMIN_SYSTEM_ERROR; } @@ -1578,28 +1455,16 @@ int radminPerformConnectionAction( return RC_RADMIN_BAD_INPUT; } - char *__ptr32 workArea = allocateWorkArea(); - RadminCallerAuthInfo *__ptr32 authInfo31 = makeCallerAuthInfo31(callerAuthInfo); - int32_t statusALET = 0; /* primary */ - RadminAPIStatus *apiStatus = &status->apiStatus; - RadminUserID callerUserID = callerAuthInfo.userID; - ACEE * __ptr32 callerACEE = callerAuthInfo.acee; - - uint8_t resultSubpool = RADMIN_RESULT_BUFFER_SUBPOOL; RadminCommandOutput * __ptr32 result = invokeRadmin( - workArea, - apiStatus, + &status->apiStatus, functionCode, actionParmList, - authInfo31, - resultSubpool + &callerAuthInfo, + RADMIN_RESULT_BUFFER_SUBPOOL ); - freeWorkArea(workArea); - freeCallerAuthInfo31(authInfo31); - int rc = RC_RADMIN_OK; - if (apiStatus->safRC != 0) { + if (status->apiStatus.safRC != 0) { rc = RC_RADMIN_SYSTEM_ERROR; } diff --git a/h/radmin.h b/h/radmin.h index 2ef30fc76..cef6c4aaa 100644 --- a/h/radmin.h +++ b/h/radmin.h @@ -248,7 +248,6 @@ typedef struct RadminAPIStatus_tag { int safRC; int racfRC; int racfRSN; - int alet; /* always zero */ } RadminAPIStatus; typedef struct RadminStatus_tag { From 3250790debfddea3d188464bc8f13d4ca28931f9 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Fri, 5 Nov 2021 11:20:26 +0100 Subject: [PATCH 30/33] Use zowelog instead of naked printfs Signed-off-by: Irek Fakhrutdinov --- c/discovery.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/c/discovery.c b/c/discovery.c index 12a4b7298..2f2306837 100644 --- a/c/discovery.c +++ b/c/discovery.c @@ -97,7 +97,9 @@ DiscoveryContext *makeDiscoveryContext(ShortLivedHeap *outerSLH, ZOSModel *model context->slh = slh; context->model = model; - printf("mDCntxt() model=0x%x pSN=0x%x\n",model,model->privilegedServerName); + zowelog(NULL, LOG_COMP_DISCOVERY, ZOWE_LOG_DEBUG, + "mDCntxt() model=%p pSN=\'%.16s\'\n", model, + model ? model->privilegedServerName.nameSpacePadded : ""); if (model != NULL) { context->privilegedServerName = model->privilegedServerName; } else { @@ -920,7 +922,8 @@ ZOSModel *makeZOSModel2(CrossMemoryServerName *privilegedServerName, model->slowScanExpiry = DEFAULT_SSCT_INTERVAL; if (privilegedServerName != NULL) { - printf("makeZOSModel case 1 0x%x\n",privilegedServerName); + zowelog(NULL, LOG_COMP_DISCOVERY, ZOWE_LOG_DEBUG, + "makeZOSModel case 1 %p\n", privilegedServerName); model->privilegedServerName = *privilegedServerName; dumpbuffer((char*)&(model->privilegedServerName),16); } else { From eeac26ab1cc84e4b492e0060ae65e53b5f6a8782 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Fri, 5 Nov 2021 15:20:40 +0100 Subject: [PATCH 31/33] Remove some data structs. Signed-off-by: Irek Fakhrutdinov --- h/zos.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/h/zos.h b/h/zos.h index 1da135df3..0580d21aa 100644 --- a/h/zos.h +++ b/h/zos.h @@ -797,20 +797,6 @@ typedef struct stcb_tag{ */ -/* Seems to reside in 31 bit private, likely subpool 230 */ - -typedef struct oapb_tag{ - char eyecatcher[4]; /* "OAPB" */ - char subpool; - char unknown05; - unsigned short length; /* length of this block */ - char remainderOfOAPB1[252]; - char oapb2[20]; - char oapb3[132]; -} OAPB; - -/* Seems to reside in 31 bit private, likely subpool 241 */ - typedef struct otcb_tag{ char otcbid[4]; /* eyecatcher */ char otcbsp; /* subpool */ From df05b290c3eced86340604a8d4fa300afed8d1ac Mon Sep 17 00:00:00 2001 From: Aditya Ranshinge Date: Wed, 10 Nov 2021 14:53:08 +0530 Subject: [PATCH 32/33] Added description to ZIS return codes Signed-off-by: Aditya Ranshinge --- c/crossmemory.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/c/crossmemory.c b/c/crossmemory.c index e6e419e1b..1c85572c0 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -71,13 +71,88 @@ const CrossMemoryServerName CMS_DEFAULT_SERVER_NAME = {CROSS_MEMORY_DEFAULT_SERV const char *CMS_RC_DESCRIPTION[] = { [RC_CMS_OK] = "Ok", + [RC_CMS_ERROR] = "Error", + [RC_CMS_PARM_NULL] = "Empty PC handler parameter", + [RC_CMS_PARM_BAD_EYECATCHER] = "Parameter has invalid eyecatcher", + [RC_CMS_FUNCTION_ID_OUT_OF_RANGE] = "Server ID is out of range", + [RC_CMS_GLOBAL_AREA_NULL] = "Global area address is NULL", + [RC_CMS_GLOBAL_AREA_BAD_EYECATCHER] = "Global area has bad eyecatcher", + [RC_CMS_SERVER_NULL] = "Server address is NULL", + [RC_CMS_FUNCTION_NULL] = "Service function address is NULL", + [RC_CMS_AXSET_FAILED] = "PC-ss not set, AXSET failed", + [RC_CMS_LXRES_FAILED] = "PC-ss/cp not set, LXRES failed", + [RC_CMS_ETCRE_FAILED] = "PC-ss/cp not set, build entry table failed", + [RC_CMS_ETCON_FAILED] = "PC-ss/cp not set, ETCON failed", + [RC_CMS_DUPLICATE_SERVER] = "A duplicate server is running", + [RC_CMS_ISGENQ_FAILED] = "Server not locked", + [RC_CMS_ECSA_ALLOC_FAILED] = "Resource manager ECSA storage not allocated", + [RC_CMS_NAME_TOKEN_CREATE_FAILED] = "Name/Token create failed", + [RC_CMS_SERVER_NOT_AVAILABLE] = "Server not reachable", + [RC_CMS_NAME_TOKEN_NOT_FOUND] = "Name/Token not found", + [RC_CMS_NAME_TOKEN_BAD_EYECATCHER] = "Name/Token has bad eyecatcher", + [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] = "Name/Token delete failed", + [RC_CMS_RACF_ROUTE_LIST_FAILED] = "RACF route list failed ", [RC_CMS_PERMISSION_DENIED] = "Permission denied", - [RC_CMS_SERVER_ABENDED] = "Cross-memory call ABENDed", + [RC_CMS_PC_ENV_NOT_ESTABLISHED] = "PC environment not established", + [RC_CMS_PC_ENV_NOT_TERMINATED] = "PC environment not terminated", + [RC_CMS_PC_SERVICE_ABEND_DETECTED] = "PC service abended", + [RC_CMS_PC_RECOVERY_ENV_FAILED] = "PC recovery environment failed", + [RC_CMS_SERVER_ABENDED] = "Cross-memory call abended", + [RC_CMS_VSNPRINTF_FAILED] = "vsnprintf failed", + [RC_CMS_MESSAGE_TOO_LONG] = "Message too long", + [RC_CMS_LOGGING_CNTX_NOT_FOUND] = "Logging context not found", + [RC_CMS_RECOVERY_CNTX_NOT_FOUND] = "Recovery context not found", + [RC_CMS_SERVICE_NOT_INITIALIZED] = "Service is not initialized", + [RC_CMS_ZVT_NULL] = "ZVT is NULL", + [RC_CMS_ZVTE_NULL] = "ZVTE is NULL", + [RC_CMS_ZVTE_NOT_ALLOCATED] = "ZVTE is not allocated", + [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_RESMGR_NOT_ADDED] = "RESMGR not added", + [RC_CMS_RESMGR_NOT_REMOVED] = "RESMGR not removed", + [RC_CMS_RESMGR_NOT_LOCKED] = "RESMGR not locked", + [RC_CMS_RESMGR_NAMETOKEN_FAILED] = "RESMGR Name/Token not retrieved", [RC_CMS_WRONG_SERVER_VERSION] = "Wrong server version", + [RC_CMS_LATENT_PARM_NULL] = "Latent parameter is NULL", + [RC_CMS_USER_PARM_NULL] = "User parameter is NULL", + [RC_CMS_PC_HDLR_PARM_BAD_EYECATCHER] = "PC handler parameter has invalid eyecatcher", + [RC_CMS_ZERO_PC_NUMBER] = "Zero PC number", [RC_CMS_WRONG_CLIENT_VERSION] = "Wrong client version", + [RC_CMS_ZVTE_CHAIN_LOOP] = "", + [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", + [RC_CMS_MSG_QUEUE_NOT_CREATED] = "Message queue is not created", + [RC_CMS_CONFIG_HT_NOT_CREATED] = "Server config hash table is not created", + [RC_CMS_SLH_ALLOC_FAILED] = "Short lived heap memory allocation failed", + [RC_CMS_UNKNOWN_PARM_TYPE] = "Config parameter type is not known", + [RC_CMS_CONFIG_PARM_NAME_TOO_LONG] = "Config parameter key name is too long", + [RC_CMS_CHAR_PARM_TOO_LONG] = "Value of config parameter is too long", + [RC_CMS_CONFIG_PARM_NOT_FOUND] = "Config parameter not found", + [RC_CMS_STDSVC_PARM_NULL] = "Service parameter is NULL", + [RC_CMS_STDSVC_PARM_BAD_EYECATCHER] = "Service parameter has invalid eyecatcher", + [RC_CMS_NOT_APF_AUTHORIZED] = "Not APF-authorized", + [RC_CMS_NO_STEPLIB] = "STEPLIB not found", + [RC_CMS_MODULE_NOT_IN_STEPLIB] = "Module not found in STEPLIB", [RC_CMS_SERVER_NAME_NULL] = "Server name is NULL", + [RC_CMS_SERVICE_ENTRY_OCCUPIED] = "Service entry occupied", + [RC_CMS_NO_STORAGE_FOR_MSG] = "No storage available for msg", + [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_BAD_DUB_STATUS] = "Bad dub status, verify that the started task user has an OMVS segment", [RC_CMS_MAX_RC + 1] = NULL + //[RC_CMS_SERVER_NOT_READY] = "Server is not running", + //[RC_CMS_PERMISSION_DENIED] = "Permission denied", + //[RC_CMS_SERVER_ABENDED] = "Cross-memory call ABENDed", + //[RC_CMS_WRONG_SERVER_VERSION] = "Wrong server version", + //[RC_CMS_WRONG_CLIENT_VERSION] = "Wrong client version", + //[RC_CMS_SERVER_NAME_NULL] = "Server name is NULL", }; #define CMS_DDNAME "STEPLIB " From 8f1e1dd3455d7c54c547e1fea07d3e5d276fd210 Mon Sep 17 00:00:00 2001 From: Aditya Ranshinge Date: Fri, 12 Nov 2021 15:07:19 +0530 Subject: [PATCH 33/33] Added description for ZIS return codes Signed-off-by: Aditya Ranshinge --- c/crossmemory.c | 68 ++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/c/crossmemory.c b/c/crossmemory.c index 1c85572c0..bd80086c6 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -72,35 +72,35 @@ const CrossMemoryServerName CMS_DEFAULT_SERVER_NAME = {CROSS_MEMORY_DEFAULT_SERV const char *CMS_RC_DESCRIPTION[] = { [RC_CMS_OK] = "Ok", [RC_CMS_ERROR] = "Error", - [RC_CMS_PARM_NULL] = "Empty PC handler parameter", - [RC_CMS_PARM_BAD_EYECATCHER] = "Parameter has invalid eyecatcher", - [RC_CMS_FUNCTION_ID_OUT_OF_RANGE] = "Server ID is out of range", + [RC_CMS_PARM_NULL] = "PC handler parameter list is NULL", + [RC_CMS_PARM_BAD_EYECATCHER] = "Cross-memory server parameter list has an invalid eyecatcher", + [RC_CMS_FUNCTION_ID_OUT_OF_RANGE] = "Service ID is out of range", [RC_CMS_GLOBAL_AREA_NULL] = "Global area address is NULL", - [RC_CMS_GLOBAL_AREA_BAD_EYECATCHER] = "Global area has bad eyecatcher", - [RC_CMS_SERVER_NULL] = "Server address is NULL", + [RC_CMS_GLOBAL_AREA_BAD_EYECATCHER] = "Global area has an invalid eyecatcher", + [RC_CMS_SERVER_NULL] = "Server address is NULL in global area", [RC_CMS_FUNCTION_NULL] = "Service function address is NULL", - [RC_CMS_AXSET_FAILED] = "PC-ss not set, AXSET failed", - [RC_CMS_LXRES_FAILED] = "PC-ss/cp not set, LXRES failed", - [RC_CMS_ETCRE_FAILED] = "PC-ss/cp not set, build entry table failed", - [RC_CMS_ETCON_FAILED] = "PC-ss/cp not set, ETCON failed", + [RC_CMS_AXSET_FAILED] = "PC not set, AXSET failed", + [RC_CMS_LXRES_FAILED] = "PC not set, LXRES failed", + [RC_CMS_ETCRE_FAILED] = "PC not set, build entry table failed", + [RC_CMS_ETCON_FAILED] = "PC not set, ETCON failed", [RC_CMS_DUPLICATE_SERVER] = "A duplicate server is running", - [RC_CMS_ISGENQ_FAILED] = "Server not locked", - [RC_CMS_ECSA_ALLOC_FAILED] = "Resource manager ECSA storage not allocated", - [RC_CMS_NAME_TOKEN_CREATE_FAILED] = "Name/Token create failed", - [RC_CMS_SERVER_NOT_AVAILABLE] = "Server not reachable", - [RC_CMS_NAME_TOKEN_NOT_FOUND] = "Name/Token not found", - [RC_CMS_NAME_TOKEN_BAD_EYECATCHER] = "Name/Token has bad eyecatcher", + [RC_CMS_ISGENQ_FAILED] = "Server not locked, ISGENQ failed", + [RC_CMS_ECSA_ALLOC_FAILED] = "ECSA storage allocation failed", + [RC_CMS_NAME_TOKEN_CREATE_FAILED] = "Global area name/token not created", + [RC_CMS_SERVER_NOT_AVAILABLE] = "Server not available", + [RC_CMS_NAME_TOKEN_NOT_FOUND] = "Global area name/token not found", + [RC_CMS_NAME_TOKEN_BAD_EYECATCHER] = "Global area name/token has an invalid eyecatcher", [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] = "Name/Token delete failed", - [RC_CMS_RACF_ROUTE_LIST_FAILED] = "RACF route list failed ", + [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", [RC_CMS_PC_ENV_NOT_TERMINATED] = "PC environment not terminated", [RC_CMS_PC_SERVICE_ABEND_DETECTED] = "PC service abended", [RC_CMS_PC_RECOVERY_ENV_FAILED] = "PC recovery environment failed", - [RC_CMS_SERVER_ABENDED] = "Cross-memory call abended", + [RC_CMS_SERVER_ABENDED] = "Cross-memory server abended", [RC_CMS_VSNPRINTF_FAILED] = "vsnprintf failed", [RC_CMS_MESSAGE_TOO_LONG] = "Message too long", [RC_CMS_LOGGING_CNTX_NOT_FOUND] = "Logging context not found", @@ -108,7 +108,7 @@ const char *CMS_RC_DESCRIPTION[] = { [RC_CMS_SERVICE_NOT_INITIALIZED] = "Service is not initialized", [RC_CMS_ZVT_NULL] = "ZVT is NULL", [RC_CMS_ZVTE_NULL] = "ZVTE is NULL", - [RC_CMS_ZVTE_NOT_ALLOCATED] = "ZVTE is not allocated", + [RC_CMS_ZVTE_NOT_ALLOCATED] = "ZVTE allocation failed", [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", @@ -116,14 +116,14 @@ const char *CMS_RC_DESCRIPTION[] = { [RC_CMS_RESMGR_NOT_ADDED] = "RESMGR not added", [RC_CMS_RESMGR_NOT_REMOVED] = "RESMGR not removed", [RC_CMS_RESMGR_NOT_LOCKED] = "RESMGR not locked", - [RC_CMS_RESMGR_NAMETOKEN_FAILED] = "RESMGR Name/Token not retrieved", + [RC_CMS_RESMGR_NAMETOKEN_FAILED] = "RESMGR name/token not retrieved", [RC_CMS_WRONG_SERVER_VERSION] = "Wrong server version", [RC_CMS_LATENT_PARM_NULL] = "Latent parameter is NULL", - [RC_CMS_USER_PARM_NULL] = "User parameter is NULL", - [RC_CMS_PC_HDLR_PARM_BAD_EYECATCHER] = "PC handler parameter has invalid eyecatcher", - [RC_CMS_ZERO_PC_NUMBER] = "Zero PC number", + [RC_CMS_USER_PARM_NULL] = "Cross-memory server parameter list is NULL", + [RC_CMS_PC_HDLR_PARM_BAD_EYECATCHER] = "PC handler parameter list has an invalid eyecatcher", + [RC_CMS_ZERO_PC_NUMBER] = "PC is unavailable", [RC_CMS_WRONG_CLIENT_VERSION] = "Wrong client version", - [RC_CMS_ZVTE_CHAIN_LOOP] = "", + [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_RELEASED] = "ZVTE chain is not released", [RC_CMS_SNPRINTF_FAILED] = "snprintf failed", @@ -131,28 +131,22 @@ const char *CMS_RC_DESCRIPTION[] = { [RC_CMS_MSG_QUEUE_NOT_CREATED] = "Message queue is not created", [RC_CMS_CONFIG_HT_NOT_CREATED] = "Server config hash table is not created", [RC_CMS_SLH_ALLOC_FAILED] = "Short lived heap memory allocation failed", - [RC_CMS_UNKNOWN_PARM_TYPE] = "Config parameter type is not known", + [RC_CMS_UNKNOWN_PARM_TYPE] = "Unknown config parameter type", [RC_CMS_CONFIG_PARM_NAME_TOO_LONG] = "Config parameter key name is too long", [RC_CMS_CHAR_PARM_TOO_LONG] = "Value of config parameter is too long", [RC_CMS_CONFIG_PARM_NOT_FOUND] = "Config parameter not found", - [RC_CMS_STDSVC_PARM_NULL] = "Service parameter is NULL", - [RC_CMS_STDSVC_PARM_BAD_EYECATCHER] = "Service parameter has invalid eyecatcher", - [RC_CMS_NOT_APF_AUTHORIZED] = "Not APF-authorized", + [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_MODULE_NOT_IN_STEPLIB] = "Module not found in STEPLIB", + [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 occupied", - [RC_CMS_NO_STORAGE_FOR_MSG] = "No storage available for msg", + [RC_CMS_SERVICE_ENTRY_OCCUPIED] = "Service entry already occupied", + [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_BAD_DUB_STATUS] = "Bad dub status, verify that the started task user has an OMVS segment", [RC_CMS_MAX_RC + 1] = NULL - //[RC_CMS_SERVER_NOT_READY] = "Server is not running", - //[RC_CMS_PERMISSION_DENIED] = "Permission denied", - //[RC_CMS_SERVER_ABENDED] = "Cross-memory call ABENDed", - //[RC_CMS_WRONG_SERVER_VERSION] = "Wrong server version", - //[RC_CMS_WRONG_CLIENT_VERSION] = "Wrong client version", - //[RC_CMS_SERVER_NAME_NULL] = "Server name is NULL", }; #define CMS_DDNAME "STEPLIB "