Skip to content

Commit 9f00bbb

Browse files
kvaneeshgregkh
authored andcommitted
selftests/powerpc: ptrace-pkey: Rename variables to make it easier to follow code
[ Upstream commit 9a11f12 ] Rename variable to indicate that they are invalid values which we will use to test ptrace update of pkeys. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20200709032946.881753-21-aneesh.kumar@linux.ibm.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a24e10a commit 9f00bbb

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct shared_info {
4444
unsigned long amr2;
4545

4646
/* AMR value that ptrace should refuse to write to the child. */
47-
unsigned long amr3;
47+
unsigned long invalid_amr;
4848

4949
/* IAMR value the parent expects to read from the child. */
5050
unsigned long expected_iamr;
@@ -57,8 +57,8 @@ struct shared_info {
5757
* (even though they're valid ones) because userspace doesn't have
5858
* access to those registers.
5959
*/
60-
unsigned long new_iamr;
61-
unsigned long new_uamor;
60+
unsigned long invalid_iamr;
61+
unsigned long invalid_uamor;
6262
};
6363

6464
static int sys_pkey_alloc(unsigned long flags, unsigned long init_access_rights)
@@ -100,7 +100,7 @@ static int child(struct shared_info *info)
100100

101101
info->amr1 |= 3ul << pkeyshift(pkey1);
102102
info->amr2 |= 3ul << pkeyshift(pkey2);
103-
info->amr3 |= info->amr2 | 3ul << pkeyshift(pkey3);
103+
info->invalid_amr |= info->amr2 | 3ul << pkeyshift(pkey3);
104104

105105
if (disable_execute)
106106
info->expected_iamr |= 1ul << pkeyshift(pkey1);
@@ -111,8 +111,8 @@ static int child(struct shared_info *info)
111111

112112
info->expected_uamor |= 3ul << pkeyshift(pkey1) |
113113
3ul << pkeyshift(pkey2);
114-
info->new_iamr |= 1ul << pkeyshift(pkey1) | 1ul << pkeyshift(pkey2);
115-
info->new_uamor |= 3ul << pkeyshift(pkey1);
114+
info->invalid_iamr |= 1ul << pkeyshift(pkey1) | 1ul << pkeyshift(pkey2);
115+
info->invalid_uamor |= 3ul << pkeyshift(pkey1);
116116

117117
/*
118118
* We won't use pkey3. We just want a plausible but invalid key to test
@@ -196,9 +196,9 @@ static int parent(struct shared_info *info, pid_t pid)
196196
PARENT_SKIP_IF_UNSUPPORTED(ret, &info->child_sync);
197197
PARENT_FAIL_IF(ret, &info->child_sync);
198198

199-
info->amr1 = info->amr2 = info->amr3 = regs[0];
200-
info->expected_iamr = info->new_iamr = regs[1];
201-
info->expected_uamor = info->new_uamor = regs[2];
199+
info->amr1 = info->amr2 = info->invalid_amr = regs[0];
200+
info->expected_iamr = info->invalid_iamr = regs[1];
201+
info->expected_uamor = info->invalid_uamor = regs[2];
202202

203203
/* Wake up child so that it can set itself up. */
204204
ret = prod_child(&info->child_sync);
@@ -234,10 +234,10 @@ static int parent(struct shared_info *info, pid_t pid)
234234
return ret;
235235

236236
/* Write invalid AMR value in child. */
237-
ret = ptrace_write_regs(pid, NT_PPC_PKEY, &info->amr3, 1);
237+
ret = ptrace_write_regs(pid, NT_PPC_PKEY, &info->invalid_amr, 1);
238238
PARENT_FAIL_IF(ret, &info->child_sync);
239239

240-
printf("%-30s AMR: %016lx\n", ptrace_write_running, info->amr3);
240+
printf("%-30s AMR: %016lx\n", ptrace_write_running, info->invalid_amr);
241241

242242
/* Wake up child so that it can verify it didn't change. */
243243
ret = prod_child(&info->child_sync);
@@ -249,15 +249,15 @@ static int parent(struct shared_info *info, pid_t pid)
249249

250250
/* Try to write to IAMR. */
251251
regs[0] = info->amr1;
252-
regs[1] = info->new_iamr;
252+
regs[1] = info->invalid_iamr;
253253
ret = ptrace_write_regs(pid, NT_PPC_PKEY, regs, 2);
254254
PARENT_FAIL_IF(!ret, &info->child_sync);
255255

256256
printf("%-30s AMR: %016lx IAMR: %016lx\n",
257257
ptrace_write_running, regs[0], regs[1]);
258258

259259
/* Try to write to IAMR and UAMOR. */
260-
regs[2] = info->new_uamor;
260+
regs[2] = info->invalid_uamor;
261261
ret = ptrace_write_regs(pid, NT_PPC_PKEY, regs, 3);
262262
PARENT_FAIL_IF(!ret, &info->child_sync);
263263

0 commit comments

Comments
 (0)