From patchwork Thu Jun 14 00:45:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 10463105 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 9D6CC603EE for ; Thu, 14 Jun 2018 00:47:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F31B28988 for ; Thu, 14 Jun 2018 00:47:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83CBB28BA8; Thu, 14 Jun 2018 00:47:46 +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=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F7EF28988 for ; Thu, 14 Jun 2018 00:47:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE0146B027E; Wed, 13 Jun 2018 20:47:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A927C6B0280; Wed, 13 Jun 2018 20:47:17 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 959C96B0281; Wed, 13 Jun 2018 20:47:17 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f200.google.com (mail-qk0-f200.google.com [209.85.220.200]) by kanga.kvack.org (Postfix) with ESMTP id 68E686B027E for ; Wed, 13 Jun 2018 20:47:17 -0400 (EDT) Received: by mail-qk0-f200.google.com with SMTP id 84-v6so3598536qkz.3 for ; Wed, 13 Jun 2018 17:47:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:sender:from:to:cc:subject:date :message-id:in-reply-to:references; bh=C4udlJABF5eeWZNs013FSwjyDB7eJazveNCvpjydk4w=; b=nR5RXb9w3yD0akHS6ZbPKznL5n7vdPNBp+1KfJU/iz8XaSyjRcRqX7b9V3fgAIIGcb t0hDqC/jxMImaT83dylXkrtcx+bdTvED9Mp742uerq4Z7uniyL661ntRDCuXn1hrXbBF 9jjq6WJhwGjtbfXzvbbOfKlfNoG6g+7bUqCfj+nhKaeWFwt5Mcc3OEer3Q56lrs/eKOp uJurRlE0WGKHW4JtKdERssufaUSzra251a4Dpu2ilDLeetsBGfNX55o1LnDncH1sF+VS wkBbQEdikdOQsVd94CNJwV9gFzjbJHLAmMElxmZ5MpNq1ZFKzx8qn5JXAvMFXAGcgLhP Cjeg== X-Gm-Message-State: APt69E205gnIYUwflzFkKpc0gLWx+kroA9bDrtnuXf8lOxx6hjniXFFE vCYyiujvScsrqlM8Bob3qMfC8y0/3/kfnhEmdiROVf9iB4XDKDjpD2vfA5YEsqulnSp2h0vPJcf r1J7WBOikNHsJR3CdsphPBUnad9r4cOBu23018RA013dnJSQu43zPVDtEv9T+PPiixx/yc23p+S OSY6z4LUrnFoRUfx1zl5oMBxSBGrX+JnY8inU/KYCfpGy5bus1TF8vuekCM+B2qpFxx/gWr3pZG +j0u1bvmxSoLxpIxk8JATs8HFuksehHXQI2j3ASlhyhCE5o1ZIuPRX9w/vSGcucoBv2O0dt33sU +6IvVSOQi6IaoqedhOul5sxqxs+t6b0j3Xq/puaOPWu+0ZvxPfF6EeRYMPZKQRHotQgL1og6wg= = X-Received: by 2002:aed:3ce8:: with SMTP id e37-v6mr363664qtf.295.1528937237234; Wed, 13 Jun 2018 17:47:17 -0700 (PDT) X-Received: by 2002:aed:3ce8:: with SMTP id e37-v6mr363641qtf.295.1528937236599; Wed, 13 Jun 2018 17:47:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528937236; cv=none; d=google.com; s=arc-20160816; b=lg+/JE5Bc413nKQ0sHCiTcguY0hlFsefe+52wENCWJdhUtzwBz1RV6OhoVUouEOp7J hrX0Zpe2e+/x3+Os/8lV35+wAovj9bsToSGJc39641cSBs0nF/DrgLmW0UVVp5ju8vrT KgXL2I/X0ytsiyK0ttxv1QK218AQfUwgWGuVWkWANTNsKFZ5OlrL0yqHLRktednoQlKW vF6Y3dv6ekFki5HpqiAjGJ7ZnvtwLyn+6SSyGwubFj8chwBXoHOtSQ9IYLDHvnmvcLRU UvdgKZOEuLC+CrKQG/zRn3yv2wNRJ4dv2kGObofRJeJWNGBwvt0DaD5s46Xgwn3nHuld GQ/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature:arc-authentication-results; bh=C4udlJABF5eeWZNs013FSwjyDB7eJazveNCvpjydk4w=; b=zAyfyRExHIbnKBYs7hNsv1m3ie4d8lOQwj4YXx8zDBOWFuER7P9AHHHPJfORV0Yp5n uXxj7RxPPdDwN0a6I5RqD11qmjpf/SUCudINjjBad57qFhV+q8XDAnvdN68BHpZTu/W1 UeisWIUd0CUVlG++KPQLgJHa3u/1T33HedoRwRbwCDoPmoVJF8QyO+BM6CNxvaugU6yP Nnps9XUsL6fEBIi6pH5yYcaxViBorfTwYiLdrc5o+EovYZIbhJHGvawvvzK8qoF7C4oe qaD/BRDyWSmmu36YQ3be5yrMNoVM1A/StRCon3JJGKSBwLvzOAG2N5nAuKkEze8DnlvI TK8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=F74EpYzO; spf=pass (google.com: domain of ram.n.pai@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=ram.n.pai@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id y4-v6sor2325002qkd.83.2018.06.13.17.47.16 for (Google Transport Security); Wed, 13 Jun 2018 17:47:16 -0700 (PDT) Received-SPF: pass (google.com: domain of ram.n.pai@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=F74EpYzO; spf=pass (google.com: domain of ram.n.pai@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=ram.n.pai@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com 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=C4udlJABF5eeWZNs013FSwjyDB7eJazveNCvpjydk4w=; b=F74EpYzOmt869Z0pMV2duKoetV68qgN0DzvXrXioyxTkqCMO+Uw/lgjWiqlAdMYuYX MhtGJzHZzMPkEGPxi802KLjv8+efQ8SIueY3Ys5bGSAcAUB7edeQ2zgaipqtSZQR84g/ /t/PKBt0INxLo7gOwUtojTsOaJah9IMPQ+38kkVVp6DMAHUL12gtNnK6dcVIp8Dm/taP Mf6B9d4te9p/b6fVz9omRaD8ik/DTgi6QzqYRthCyFEEgorV5l/c5THylDwIIXigU5Az 5QuilHRkV6i3282bXQJjjXYY28zYauShFJaiXSdNuTOzh9HPmOEfJeGfCtuf9lz078tt nIOQ== X-Google-Smtp-Source: ADUXVKI8heSsgXbdYStazmmEvjsEwjrqaZNqP8AFLtskasAHwSOavfpncgKO7owxU3qRb+lyRamWkQ== X-Received: by 2002:a37:17ea:: with SMTP id 103-v6mr315160qkx.373.1528937236408; Wed, 13 Jun 2018 17:47:16 -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.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jun 2018 17:47:16 -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 16/24] selftests/vm: clear the bits in shadow reg when a pkey is freed. Date: Wed, 13 Jun 2018 17:45:07 -0700 Message-Id: <1528937115-10132-17-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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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, 2 insertions(+), 1 deletions(-) diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index 88dfa40..ba184ca 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -577,7 +577,8 @@ 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); + shadow_pkey_reg &= clear_pkey_flags(pkey, + PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE); dprintf1("%s(pkey=%ld) syscall ret: %d\n", __func__, pkey, ret); return ret; }