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: 929172 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 415m0R6bLjz9s01 for ; Thu, 14 Jun 2018 11:16:07 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Qg0ukhS4"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 415m0R51QjzDrnp for ; Thu, 14 Jun 2018 11:16:07 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Qg0ukhS4"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400d:c0d::241; helo=mail-qt0-x241.google.com; envelope-from=ram.n.pai@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Qg0ukhS4"; dkim-atps=neutral Received: from mail-qt0-x241.google.com (mail-qt0-x241.google.com [IPv6:2607:f8b0:400d:c0d::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 415lLy5CzSzDrqN for ; Thu, 14 Jun 2018 10:47:06 +1000 (AEST) Received: by mail-qt0-x241.google.com with SMTP id x34-v6so4277612qtk.5 for ; Wed, 13 Jun 2018 17:47:06 -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=tA80ajCkK1fxKhlIyKSfcZlaMeIcSXNFyX+3QCgdvwmBu8JUuKSJ/WQoBhXieZikFB tZt62bPiJ8mYValrCmav43EE3HT9gjEQ9r8HCrH+5nwn+CUev65Ivv8s0ld6ENjTRbmP qCVza1bxKZ7qpiuC304+Kp158FadCkJlAAaKdWWjg+BBrN1vog6rK6jj0FyViQnDHGcY GTm3Ai9cHCB2j7cN2p7lxFfX31IgJCZeMRVxwZcVVvCdlJwk86xBRd9vUye6QMsrLyK4 B2PbGz6yTtr0DTteWs7GwS6oA2eodUGIg/HHIK6w+G/Tm8WesNRJoaSoKMkWo3yzX7Kp gkmA== X-Gm-Message-State: APt69E0hdS/3pPcV9dd6CwSHWCoZhqn7iPivq8gVNpFzIBKDK4OptN/R VPZpy/t9wkgE2UhaI/BdhRo= 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 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> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, fweimer@redhat.com, dave.hansen@intel.com, x86@kernel.org, linuxram@us.ibm.com, mhocko@kernel.org, linux-mm@kvack.org, mingo@redhat.com, aneesh.kumar@linux.vnet.ibm.com, bauerman@linux.vnet.ibm.com, msuchanek@suse.de, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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; }