Received: by 10.213.65.68 with SMTP id h4csp1877imn; Fri, 16 Mar 2018 15:12:22 -0700 (PDT) X-Google-Smtp-Source: AG47ELs8guSy2nZeIUqishORy6jifRddpQXl36t/xnwrybadzY+amUfOHSRSVfJMk5jFQwySCugU X-Received: by 10.99.120.5 with SMTP id t5mr2816347pgc.30.1521238342375; Fri, 16 Mar 2018 15:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521238342; cv=none; d=google.com; s=arc-20160816; b=saSKRlkxHAECcqeRI35N+EAIHMpM/Qd4C2amSYQOJj33oKS4Etl7cqfJhyK0K5rtFu vp3iyzbFM9a7Y+Aeap8oJPu9DDVUkX0G16bpJfNfkgTvU5p0L6snE64LBcOQ7h6xLOnd LbwgtZifKyRpp8CUkf0oUD6ikupQO5ejhJubDBcoEwiB8odeKQUQ8DYNGv/7ba6UEN5q EjNoBg1rHHiX0v+p5qt+JnJcY1rT76pGaWyNfrIdIXFTi6Nzl6GO7sCEZe0fL24zTry1 /CzgTGVvOLIrshnVQnSUAqWw6D6mRD6TUQZnjjhDOait6wSuh8plDLBdNte2VvdBr8fU 1fRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:cc:references:to:subject:arc-authentication-results; bh=iGyMNiysTgX9tThTrVAs8FiAzZQzTKs+6dbmunbh2m0=; b=r5PowiVG/4jNUPbF6wBy+C9JbEKTyboaMTDuqh4ybuY+fWzrfHbHb4lzDu8c5U+Sts s/wJAn+jroKQx159rMysifAYOsCChxwPk69Bxyft2wHdEkoonFA5YX9gxegr6Bj48kUn jeOGjQ4sTpXWG+B7bLqNXMJYUjJ9r7WDMiovDWJ2o5Hsf6+zVWAqCYHN/ms388Vr2XFb E3xiLv1gAwOXX3TPodsTmon0GoP/gHg8ldebJIyGyYkeAoQqScWzpBOcWAVLJsqKCX6J 4stoCQouDCV8htRpz0reuWyNsy6VJaKKZcYHYtcF4Knl6KULkkNHt6qYGUzps1MYWzGb /u6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y92-v6si6937278plb.213.2018.03.16.15.12.08; Fri, 16 Mar 2018 15:12:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752099AbeCPWKR (ORCPT + 99 others); Fri, 16 Mar 2018 18:10:17 -0400 Received: from mga14.intel.com ([192.55.52.115]:50519 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751245AbeCPWKQ (ORCPT ); Fri, 16 Mar 2018 18:10:16 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Mar 2018 15:10:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,317,1517904000"; d="scan'208";a="25369736" Received: from ray.jf.intel.com (HELO [10.7.201.16]) ([10.7.201.16]) by orsmga007.jf.intel.com with ESMTP; 16 Mar 2018 15:10:15 -0700 Subject: Re: [PATCH v12 08/22] selftests/vm: clear the bits in shadow reg when a pkey is freed. To: Ram Pai , shuahkh@osg.samsung.com, linux-kselftest@vger.kernel.org References: <1519264541-7621-1-git-send-email-linuxram@us.ibm.com> <1519264541-7621-9-git-send-email-linuxram@us.ibm.com> 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 From: Dave Hansen Message-ID: Date: Fri, 16 Mar 2018 15:10:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.