From patchwork Thu Jun 14 00:45:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 10463051 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E1618603EE for ; Thu, 14 Jun 2018 00:47:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2C3A28988 for ; Thu, 14 Jun 2018 00:47:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C686728BAC; Thu, 14 Jun 2018 00:47:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 754FC28988 for ; Thu, 14 Jun 2018 00:47:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936014AbeFNArG (ORCPT ); Wed, 13 Jun 2018 20:47:06 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:35193 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935869AbeFNArF (ORCPT ); Wed, 13 Jun 2018 20:47:05 -0400 Received: by mail-qt0-f193.google.com with SMTP id s9-v6so4284997qtg.2; Wed, 13 Jun 2018 17:47:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=RePhmNpB7vH0qzi7VF1eS4JNjN1obSSpKL3qQNnVils=; b=Qg0ukhS4B1rJIhTEf6D6vvd94XR1fFT1xIDkFNpSlUnUu6agCkh4MwYwtbtMXUsCS7 sWTOHc4xhJxUQoVU5ITxMf45zwt086z1v8+zxfCI4TB8XyAitj41qyGaxt7Ve3I9U+us u0ZdJBxa12MMEMNJV6zSIFP4d7yacr1i4/FKaaXwMcvwnwdxrL1IcCcOin2MGvR9rO7B jdUJVO9sz7oIcbrSLUmeigZ92TOlBi35pzkiNEIWvrFTEcljTxX+5E9p3WW5JW1GeWzO /Lw443RpAJXW+Q3WINkSnZP24QR762pWT5uPgkQIfdLuD38WAV1Usy4qppj6o866Fjzs 3Psw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=RePhmNpB7vH0qzi7VF1eS4JNjN1obSSpKL3qQNnVils=; b=cxrILndVIjdsfo8epH2mLVV9dAK252vYCQ5pqDNlGLSbKt4IBhxMCGTyck83Cj2jDc 3KpS1Lm52pPS7DcCvTrSx7X46lu01VqW6H2WCaop22wGUO/0HF63dYn/+Ybec4UKvqZz rAisIDIlVUcpcd18uTDScP96xt1VHxnEQIvs1AF0uQgmmLngBAibNw6DuTN5EVjx1TdX EiwhKAACsJgw5TK+MLJixEFeQgYh+/U23X4h7bUTULQWC8PKjzxjBGVyceEorX9+ehew C9oaTQKZO6EJD3pEbaCgpdwGrKSZ4mlDoHW1ApFI0i+AsRfGIidtXOrsS9ZV/XJlkgI7 pMDQ== X-Gm-Message-State: APt69E0kKFN+Ys36/T/MCvbPdWycAxb8fWvPJhmVmITa6MxJ0/Lk8G1d TcNVjt7gZ0yb8/bJnU5oJo0= X-Google-Smtp-Source: ADUXVKIjsoIqPXvu8X0BXSF5hnxvQsfMmcc6Hwok24BXyDYP+Y/TMmPqUBqt9U2oUlMCvYts0tRdvg== X-Received: by 2002:ac8:2631:: with SMTP id u46-v6mr375960qtu.306.1528937224700; Wed, 13 Jun 2018 17:47:04 -0700 (PDT) Received: from localhost.localdomain (50-39-100-161.bvtn.or.frontiernet.net. [50.39.100.161]) by smtp.gmail.com with ESMTPSA id u31-v6sm3225898qtc.28.2018.06.13.17.47.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jun 2018 17:47:04 -0700 (PDT) From: Ram Pai To: 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, mingo@redhat.com, dave.hansen@intel.com, mhocko@kernel.org, bauerman@linux.vnet.ibm.com, linuxram@us.ibm.com, fweimer@redhat.com, msuchanek@suse.de, aneesh.kumar@linux.vnet.ibm.com Subject: [PATCH v13 10/24] selftests/vm: clear the bits in shadow reg when a pkey is freed. Date: Wed, 13 Jun 2018 17:45:01 -0700 Message-Id: <1528937115-10132-11-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1528937115-10132-1-git-send-email-linuxram@us.ibm.com> References: <1528937115-10132-1-git-send-email-linuxram@us.ibm.com> Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. cc: Dave Hansen cc: Florian Weimer Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index da4f5d5..42a91c7 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -556,6 +556,9 @@ int alloc_pkey(void) int sys_pkey_free(unsigned long pkey) { int ret = syscall(SYS_pkey_free, pkey); + + if (!ret) + shadow_pkey_reg &= clear_pkey_flags(pkey, PKEY_DISABLE_ACCESS); dprintf1("%s(pkey=%ld) syscall ret: %d\n", __func__, pkey, ret); return ret; }