From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f198.google.com (mail-pf0-f198.google.com [209.85.192.198]) by kanga.kvack.org (Postfix) with ESMTP id 570606B000E for ; Fri, 16 Mar 2018 18:10:17 -0400 (EDT) Received: by mail-pf0-f198.google.com with SMTP id v3so5833873pfm.21 for ; Fri, 16 Mar 2018 15:10:17 -0700 (PDT) Received: from mga04.intel.com (mga04.intel.com. [192.55.52.120]) by mx.google.com with ESMTPS id y3-v6si7605060pln.209.2018.03.16.15.10.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Mar 2018 15:10:16 -0700 (PDT) Subject: Re: [PATCH v12 08/22] selftests/vm: clear the bits in shadow reg when a pkey is freed. References: <1519264541-7621-1-git-send-email-linuxram@us.ibm.com> <1519264541-7621-9-git-send-email-linuxram@us.ibm.com> From: Dave Hansen Message-ID: Date: Fri, 16 Mar 2018 15:10:07 -0700 MIME-Version: 1.0 In-Reply-To: <1519264541-7621-9-git-send-email-linuxram@us.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Ram Pai , shuahkh@osg.samsung.com, linux-kselftest@vger.kernel.org Cc: mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, x86@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, akpm@linux-foundation.org, benh@kernel.crashing.org, paulus@samba.org, khandual@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com, bsingharora@gmail.com, hbabu@us.ibm.com, mhocko@kernel.org, bauerman@linux.vnet.ibm.com, ebiederm@xmission.com, arnd@arndb.de On 02/21/2018 05:55 PM, Ram Pai wrote: > When a key is freed, the key is no more effective. > Clear the bits corresponding to the pkey in the shadow > register. Otherwise it will carry some spurious bits > which can trigger false-positive asserts. ... > diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c > index ca54a95..aaf9f09 100644 > --- a/tools/testing/selftests/vm/protection_keys.c > +++ b/tools/testing/selftests/vm/protection_keys.c > @@ -582,6 +582,9 @@ int alloc_pkey(void) > int sys_pkey_free(unsigned long pkey) > { > int ret = syscall(SYS_pkey_free, pkey); > + > + if (!ret) > + shadow_pkey_reg &= reset_bits(pkey, PKEY_DISABLE_ACCESS); > dprintf1("%s(pkey=%ld) syscall ret: %d\n", __func__, pkey, ret); > return ret; > } Did this cause problems for you in practice? On x86, sys_pkey_free() does not affect PKRU, so this isn't quite right. I'd much rather have the actual tests explicitly clear the PKRU bits and also in the process clear the shadow bits.