mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Kleikamp <dave.kleikamp@oracle.com>
To: Babu Moger <babu.moger@amd.com>,
	Dave Hansen <dave.hansen@intel.com>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com,
	luto@kernel.org, peterz@infradead.org, shuah@kernel.org,
	jroedel@suse.de, ubizjak@gmail.com, viro@zeniv.linux.org.uk,
	jpa@git.mail.kapsi.fi, fenghua.yu@intel.com,
	kan.liang@linux.intel.com, akpm@linux-foundation.org,
	rppt@kernel.org, Fan_Yang@sjtu.edu.cn, anshuman.khandual@arm.com,
	b.thiel@posteo.de, jgross@suse.com, keescook@chromium.org,
	seanjc@google.com, mh@glandium.org, sashal@kernel.org,
	krisman@collabora.com, chang.seok.bae@intel.com,
	0x7f454c46@gmail.com, jhubbard@nvidia.com,
	sandipan@linux.ibm.com, ziy@nvidia.com,
	kirill.shutemov@linux.intel.com, suxingxing@loongson.cn,
	harish@linux.ibm.com, rong.a.chen@intel.com, linuxram@us.ibm.com,
	bauerman@linux.ibm.com
Subject: Re: x86/fpu/xsave: protection key test failures
Date: Wed, 26 May 2021 10:50:27 -0500	[thread overview]
Message-ID: <036bd3d8-d6fb-db0f-c4f1-6b2a4a104191@oracle.com> (raw)
In-Reply-To: <ab564da6-1029-1dab-d54e-a266a623974f@amd.com>

[-- Attachment #1: Type: text/plain, Size: 813 bytes --]

On 5/26/21 10:25 AM, Babu Moger wrote:
> 
> 
> On 5/25/21 7:20 PM, Dave Hansen wrote:
>> On 5/25/21 5:03 PM, Babu Moger wrote:
>>>> What values do PKRU and the shadow have when the test fails?  Is PKRU 0?
>>> It goes back to default value 0x55555554. The test is expecting it to be
>>> 0. Printed them below.
>>>
>>> test_ptrace_of_child()::1346, pkey_reg: 0x0000000055555554 shadow:
>>> 0000000000000000
>>> protection_keys_64: pkey-helpers.h:127: _read_pkey_reg: Assertion
>>> `pkey_reg == shadow_pkey_reg' failed.
>>
>> That's backwards (shadow vs pkru) from what I was expecting.
>>
>> Can you turn on all the debuging?
>>
>> Just compile with -DDEBUG_LEVEL=5
>>
> 
> 
> Copied the logs at https://pastebin.com/gtQiHg8Q

I think this failed early due to the debug code. I have a patch that 
gets around this.

[-- Attachment #2: selftests_vm_pkeys_fix_assert.patch --]
[-- Type: text/x-patch, Size: 1615 bytes --]

From: Dave Kleikamp <dave.kleikamp@oracle.com>
Subject: [PATCH] selftests/vm/pkeys: fix assert when DEBUG_LEVEL is set to 2
Date: Mon, 12 Apr 2021 17:13:31 -0500

test_implicit_mprotect_exec_only_memory() hits an assert in
_read_pkey_reg() when DEBUG_LEVEL=2.

test 12 starting with pkey: 2
doing malloc_pkey_anon_huge(size=4096, prot=0x3, pkey=2)
new_nr_records: 1
new_size: 24
sys_mprotect_pkey(0x0x7f44144bb000, 400000, prot=3, pkey=2)
mprotect_pkey(0x7f44144bb000, 400000, prot=0x3, pkey=2) ret: 0
mprotect_pkey()::628, ret: 0 pkey_reg: 0x0000000000000000 shadow: 0x0000000000000000
unaligned protection_keys: pkey-helpers.h:127: _read_pkey_reg: Assertion `pkey_reg == shadow_pkey_reg' failed.

This patch provides one way to fix it. Would it be better to make sure
that shadow_pkey_reg is properly set?

Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Cc: Ram Pai <linuxram@us.ibm.com>
---
 tools/testing/selftests/vm/protection_keys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c
index fdbb602ecf32..070f6f90dcce 100644
--- a/tools/testing/selftests/vm/protection_keys.c
+++ b/tools/testing/selftests/vm/protection_keys.c
@@ -1449,7 +1449,7 @@ void test_implicit_mprotect_exec_only_memory(int *ptr, u16 pkey)
 	ret = mprotect(p1, PAGE_SIZE, PROT_EXEC);
 	pkey_assert(!ret);
 
-	dprintf2("pkey_reg: %016llx\n", read_pkey_reg());
+	dprintf2("pkey_reg: %016llx\n", __read_pkey_reg());
 
 	/* Make sure this is an *instruction* fault */
 	madvise(p1, PAGE_SIZE, MADV_DONTNEED);
-- 
2.31.1


  reply	other threads:[~2021-05-26 15:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-25 21:37 Babu Moger
2021-05-25 22:18 ` Dave Hansen
2021-05-25 22:22   ` Dave Kleikamp
2021-05-25 22:28     ` Dave Hansen
2021-05-26  0:03   ` Babu Moger
2021-05-26  0:20     ` Dave Hansen
2021-05-26 15:25       ` Babu Moger
2021-05-26 15:50         ` Dave Kleikamp [this message]
2021-05-26 16:06         ` Dave Hansen
2021-05-26 17:03           ` Babu Moger
2021-05-26  0:36 ` Andy Lutomirski
2021-05-26 21:14   ` Babu Moger
2021-05-26 21:17     ` Andy Lutomirski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=036bd3d8-d6fb-db0f-c4f1-6b2a4a104191@oracle.com \
    --to=dave.kleikamp@oracle.com \
    --cc=0x7f454c46@gmail.com \
    --cc=Fan_Yang@sjtu.edu.cn \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=b.thiel@posteo.de \
    --cc=babu.moger@amd.com \
    --cc=bauerman@linux.ibm.com \
    --cc=bp@alien8.de \
    --cc=chang.seok.bae@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=fenghua.yu@intel.com \
    --cc=harish@linux.ibm.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=jhubbard@nvidia.com \
    --cc=jpa@git.mail.kapsi.fi \
    --cc=jroedel@suse.de \
    --cc=kan.liang@linux.intel.com \
    --cc=keescook@chromium.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=krisman@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linuxram@us.ibm.com \
    --cc=luto@kernel.org \
    --cc=mh@glandium.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rong.a.chen@intel.com \
    --cc=rppt@kernel.org \
    --cc=sandipan@linux.ibm.com \
    --cc=sashal@kernel.org \
    --cc=seanjc@google.com \
    --cc=shuah@kernel.org \
    --cc=suxingxing@loongson.cn \
    --cc=tglx@linutronix.de \
    --cc=ubizjak@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=x86@kernel.org \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®