16c00db4bb
Pull AFS fixes from David Howells: "Here's a set of patches that fix a number of bugs in the in-kernel AFS client, including: - Fix directory locking to not use individual page locks for directory reading/scanning but rather to use a semaphore on the afs_vnode struct as the directory contents must be read in a single blob and data from different reads must not be mixed as the entire contents may be shuffled about between reads. - Fix address list parsing to handle port specifiers correctly. - Only give up callback records on a server if we actually talked to that server (we might not be able to access a server). - Fix some callback handling bugs, including refcounting, whole-volume callbacks and when callbacks actually get broken in response to a CB.CallBack op. - Fix some server/address rotation bugs, including giving up if we can't probe a server; giving up if a server says it doesn't have a volume, but there are more servers to try. - Fix the decoding of fetched statuses to be OpenAFS compatible. - Fix the handling of server lookups in Cache Manager ops (such as CB.InitCallBackState3) to use a UUID if possible and to handle no server being found. - Fix a bug in server lookup where not all addresses are compared. - Fix the non-encryption of calls that prevents some servers from being accessed (this also requires an AF_RXRPC patch that has already gone in through the net tree). There's also a patch that adds tracepoints to log Cache Manager ops that don't find a matching server, either by UUID or by address" * tag 'afs-fixes-20180514' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs: afs: Fix the non-encryption of calls afs: Fix CB.CallBack handling afs: Fix whole-volume callback handling afs: Fix afs_find_server search loop afs: Fix the handling of an unfound server in CM operations afs: Add a tracepoint to record callbacks from unlisted servers afs: Fix the handling of CB.InitCallBackState3 to find the server by UUID afs: Fix VNOVOL handling in address rotation afs: Fix AFSFetchStatus decoder to provide OpenAFS compatibility afs: Fix server rotation's handling of fileserver probe failure afs: Fix refcounting in callback registration afs: Fix giving up callbacks on server destruction afs: Fix address list parsing afs: Fix directory page locking
162 lines
4.3 KiB
C
162 lines
4.3 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include <regex.h>
|
|
|
|
#include "../../perf.h"
|
|
#include "../../util/util.h"
|
|
#include "../../util/perf_regs.h"
|
|
#include "../../util/debug.h"
|
|
|
|
const struct sample_reg sample_reg_masks[] = {
|
|
SMPL_REG(r0, PERF_REG_POWERPC_R0),
|
|
SMPL_REG(r1, PERF_REG_POWERPC_R1),
|
|
SMPL_REG(r2, PERF_REG_POWERPC_R2),
|
|
SMPL_REG(r3, PERF_REG_POWERPC_R3),
|
|
SMPL_REG(r4, PERF_REG_POWERPC_R4),
|
|
SMPL_REG(r5, PERF_REG_POWERPC_R5),
|
|
SMPL_REG(r6, PERF_REG_POWERPC_R6),
|
|
SMPL_REG(r7, PERF_REG_POWERPC_R7),
|
|
SMPL_REG(r8, PERF_REG_POWERPC_R8),
|
|
SMPL_REG(r9, PERF_REG_POWERPC_R9),
|
|
SMPL_REG(r10, PERF_REG_POWERPC_R10),
|
|
SMPL_REG(r11, PERF_REG_POWERPC_R11),
|
|
SMPL_REG(r12, PERF_REG_POWERPC_R12),
|
|
SMPL_REG(r13, PERF_REG_POWERPC_R13),
|
|
SMPL_REG(r14, PERF_REG_POWERPC_R14),
|
|
SMPL_REG(r15, PERF_REG_POWERPC_R15),
|
|
SMPL_REG(r16, PERF_REG_POWERPC_R16),
|
|
SMPL_REG(r17, PERF_REG_POWERPC_R17),
|
|
SMPL_REG(r18, PERF_REG_POWERPC_R18),
|
|
SMPL_REG(r19, PERF_REG_POWERPC_R19),
|
|
SMPL_REG(r20, PERF_REG_POWERPC_R20),
|
|
SMPL_REG(r21, PERF_REG_POWERPC_R21),
|
|
SMPL_REG(r22, PERF_REG_POWERPC_R22),
|
|
SMPL_REG(r23, PERF_REG_POWERPC_R23),
|
|
SMPL_REG(r24, PERF_REG_POWERPC_R24),
|
|
SMPL_REG(r25, PERF_REG_POWERPC_R25),
|
|
SMPL_REG(r26, PERF_REG_POWERPC_R26),
|
|
SMPL_REG(r27, PERF_REG_POWERPC_R27),
|
|
SMPL_REG(r28, PERF_REG_POWERPC_R28),
|
|
SMPL_REG(r29, PERF_REG_POWERPC_R29),
|
|
SMPL_REG(r30, PERF_REG_POWERPC_R30),
|
|
SMPL_REG(r31, PERF_REG_POWERPC_R31),
|
|
SMPL_REG(nip, PERF_REG_POWERPC_NIP),
|
|
SMPL_REG(msr, PERF_REG_POWERPC_MSR),
|
|
SMPL_REG(orig_r3, PERF_REG_POWERPC_ORIG_R3),
|
|
SMPL_REG(ctr, PERF_REG_POWERPC_CTR),
|
|
SMPL_REG(link, PERF_REG_POWERPC_LINK),
|
|
SMPL_REG(xer, PERF_REG_POWERPC_XER),
|
|
SMPL_REG(ccr, PERF_REG_POWERPC_CCR),
|
|
SMPL_REG(softe, PERF_REG_POWERPC_SOFTE),
|
|
SMPL_REG(trap, PERF_REG_POWERPC_TRAP),
|
|
SMPL_REG(dar, PERF_REG_POWERPC_DAR),
|
|
SMPL_REG(dsisr, PERF_REG_POWERPC_DSISR),
|
|
SMPL_REG_END
|
|
};
|
|
|
|
/* REG or %rREG */
|
|
#define SDT_OP_REGEX1 "^(%r)?([1-2]?[0-9]|3[0-1])$"
|
|
|
|
/* -NUM(REG) or NUM(REG) or -NUM(%rREG) or NUM(%rREG) */
|
|
#define SDT_OP_REGEX2 "^(\\-)?([0-9]+)\\((%r)?([1-2]?[0-9]|3[0-1])\\)$"
|
|
|
|
static regex_t sdt_op_regex1, sdt_op_regex2;
|
|
|
|
static int sdt_init_op_regex(void)
|
|
{
|
|
static int initialized;
|
|
int ret = 0;
|
|
|
|
if (initialized)
|
|
return 0;
|
|
|
|
ret = regcomp(&sdt_op_regex1, SDT_OP_REGEX1, REG_EXTENDED);
|
|
if (ret)
|
|
goto error;
|
|
|
|
ret = regcomp(&sdt_op_regex2, SDT_OP_REGEX2, REG_EXTENDED);
|
|
if (ret)
|
|
goto free_regex1;
|
|
|
|
initialized = 1;
|
|
return 0;
|
|
|
|
free_regex1:
|
|
regfree(&sdt_op_regex1);
|
|
error:
|
|
pr_debug4("Regex compilation error.\n");
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* Parse OP and convert it into uprobe format, which is, +/-NUM(%gprREG).
|
|
* Possible variants of OP are:
|
|
* Format Example
|
|
* -------------------------
|
|
* NUM(REG) 48(18)
|
|
* -NUM(REG) -48(18)
|
|
* NUM(%rREG) 48(%r18)
|
|
* -NUM(%rREG) -48(%r18)
|
|
* REG 18
|
|
* %rREG %r18
|
|
* iNUM i0
|
|
* i-NUM i-1
|
|
*
|
|
* SDT marker arguments on Powerpc uses %rREG form with -mregnames flag
|
|
* and REG form with -mno-regnames. Here REG is general purpose register,
|
|
* which is in 0 to 31 range.
|
|
*/
|
|
int arch_sdt_arg_parse_op(char *old_op, char **new_op)
|
|
{
|
|
int ret, new_len;
|
|
regmatch_t rm[5];
|
|
char prefix;
|
|
|
|
/* Constant argument. Uprobe does not support it */
|
|
if (old_op[0] == 'i') {
|
|
pr_debug4("Skipping unsupported SDT argument: %s\n", old_op);
|
|
return SDT_ARG_SKIP;
|
|
}
|
|
|
|
ret = sdt_init_op_regex();
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
if (!regexec(&sdt_op_regex1, old_op, 3, rm, 0)) {
|
|
/* REG or %rREG --> %gprREG */
|
|
|
|
new_len = 5; /* % g p r NULL */
|
|
new_len += (int)(rm[2].rm_eo - rm[2].rm_so);
|
|
|
|
*new_op = zalloc(new_len);
|
|
if (!*new_op)
|
|
return -ENOMEM;
|
|
|
|
scnprintf(*new_op, new_len, "%%gpr%.*s",
|
|
(int)(rm[2].rm_eo - rm[2].rm_so), old_op + rm[2].rm_so);
|
|
} else if (!regexec(&sdt_op_regex2, old_op, 5, rm, 0)) {
|
|
/*
|
|
* -NUM(REG) or NUM(REG) or -NUM(%rREG) or NUM(%rREG) -->
|
|
* +/-NUM(%gprREG)
|
|
*/
|
|
prefix = (rm[1].rm_so == -1) ? '+' : '-';
|
|
|
|
new_len = 8; /* +/- ( % g p r ) NULL */
|
|
new_len += (int)(rm[2].rm_eo - rm[2].rm_so);
|
|
new_len += (int)(rm[4].rm_eo - rm[4].rm_so);
|
|
|
|
*new_op = zalloc(new_len);
|
|
if (!*new_op)
|
|
return -ENOMEM;
|
|
|
|
scnprintf(*new_op, new_len, "%c%.*s(%%gpr%.*s)", prefix,
|
|
(int)(rm[2].rm_eo - rm[2].rm_so), old_op + rm[2].rm_so,
|
|
(int)(rm[4].rm_eo - rm[4].rm_so), old_op + rm[4].rm_so);
|
|
} else {
|
|
pr_debug4("Skipping unsupported SDT argument: %s\n", old_op);
|
|
return SDT_ARG_SKIP;
|
|
}
|
|
|
|
return SDT_ARG_VALID;
|
|
}
|