Received: by 10.223.164.202 with SMTP id h10csp18692wrb; Mon, 6 Nov 2017 01:40:58 -0800 (PST) X-Google-Smtp-Source: ABhQp+Tw6ROk6ODmERd+Vb5swA6bgJ0LJWZBDBImqvu7SZXN9f9BGQTXugl1l0CDmuMkPU18wMDH X-Received: by 10.98.201.87 with SMTP id k84mr16157543pfg.109.1509961258652; Mon, 06 Nov 2017 01:40:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509961258; cv=none; d=google.com; s=arc-20160816; b=JtWHd1gouB1pWDYyjstO79xXO88kpFgFeYKMTnterRXNp+HYP7ioj1dNBJsMD6IWAl 3+DPwTEL+44084x2msN5dFJm/PPD2b6QtadH7QRWxiw7M0Xrrnk9wB3BrF7w87I8UyTR PTBxU/6kEdd1/ORoWWTrMb8Y0j4nehFZ1cCFkFxcGQhvWEWsfX+3Qm7fwR73IJGNoMvf iwWeWqiU21SLNSDwkRU+8XL0VcSduwU5XoTW01+SrTL6V4XLVTLHrkDCbsx+42izTQpa AF+laMrhprwJz52NK6EDJLCOGoPnIameKHodhya8tueMd/fTzNUH55cfVKinGYwKmBi4 WLdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=/NGprG9bGGXGmcHehfemklX7xYliFAGm0AG06j+g1oI=; b=mhOiD7tjTqMH2gV4Zw+EVTTfVps7TkFckXkGcX25dbpz0h4PeQPjlZJoFZGJebeYof tydvHVSPqAR/73CJFfyd8298NX3iMK2ah8Ta4z2NpxU5q2AR/rXaJwN8cTciMdTEDOxK iN8/5PsrkapSyYINgTgL04+q9+FBgkRyYazt8aAI2i6DsisVnJXffIYVVy3QQtUFaTox fsFxU6shqd8O55ANteBNcl+66ks9DXXuOII4KoA6zAlpoTVMeEHDvI+spqyJ81x+2ZRj /Z3xnqc0I0w2OeBIR2hPQmJ8O94UjNkhGrcqOk11bHOSo5cLY4tmo8GAQ8UMqdkfXkUt JSIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=e3wfR5v7; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y66si10995558pgb.156.2017.11.06.01.40.44; Mon, 06 Nov 2017 01:40:58 -0800 (PST) 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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=e3wfR5v7; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752126AbdKFJjF (ORCPT + 99 others); Mon, 6 Nov 2017 04:39:05 -0500 Received: from mail-qt0-f193.google.com ([209.85.216.193]:52829 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752001AbdKFI6k (ORCPT ); Mon, 6 Nov 2017 03:58:40 -0500 Received: by mail-qt0-f193.google.com with SMTP id 31so9993075qtz.9; Mon, 06 Nov 2017 00:58:40 -0800 (PST) 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=/NGprG9bGGXGmcHehfemklX7xYliFAGm0AG06j+g1oI=; b=e3wfR5v7fUiFTyrLJLR19PUI5/2eTwktQ4Oj6qV9l3m/4+eJK+EiPt5LTfV8NQLznn mJ+hZM3eR+Uwqbawt1m1D5ZjVWr0SX0ctNomWZacJNasAcickfVZJ/o81+XjhJo9c0qG CUCJ5ZzjrAU9VddU0rnA71tMJyC64VDbztWD67aBdbwghBtnnyqM3wZrA9cXFg5/uBLQ JycSLpZUQR3BG8NZOTbcihuCgdpMS/RvZlPQIAgJMASmMUjfe+pYqqDrItzNPJjgskJf oCQj/WAoHN+8A5RHIXGUk5Bq+bhs5CVsgn1Z2VT+/zIxg6mQb782/hRD7wVTT4t3o/3k 3B6A== 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=/NGprG9bGGXGmcHehfemklX7xYliFAGm0AG06j+g1oI=; b=Iyw+/kaNK/Z9+KJbBx6g/fc3jUOCmC9YpaiT4asXssyg2pd7ELv4T0E+yeK5n+0OXq dctLg+/02E8ezstV+tZc/HkHymNVhTIiaZiKisnz2LXlpN7LFQahqxXuUI4VLWDoQxJO oa9rnZDiS43dMa2jGAJ+fI3xPJBsmQxUcbguxEHdwgKgRVZ2tRshvMgFdQUZWPK4rsIj 3wqg2wieai+ii4wYBD+P7MhkTn+trS+Dti3Mho1wmNwf59kg5Wx3BkRLkNH+ZNw684dj P3sSNagn3vb4QgLh7UEjscB9+xsPBsx5acJk3Y6ySDAYl6KpfwnFznz/yQcrPS0YAXqX 35CQ== X-Gm-Message-State: AMCzsaXdLdJe/w45TlYxxSF1LNc1uh55RhGUnkBeoVHC6fU+SdtragB2 WdnN/bBORkK+L+3I9HX3XBc= X-Received: by 10.200.46.132 with SMTP id h4mr21967185qta.88.1509958719706; Mon, 06 Nov 2017 00:58:39 -0800 (PST) Received: from localhost.localdomain (50-39-103-96.bvtn.or.frontiernet.net. [50.39.103.96]) by smtp.gmail.com with ESMTPSA id r26sm8001094qki.42.2017.11.06.00.58.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 00:58:39 -0800 (PST) From: Ram Pai To: mpe@ellerman.id.au, mingo@redhat.com, akpm@linux-foundation.org, corbet@lwn.net, arnd@arndb.de Cc: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, x86@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, dave.hansen@intel.com, 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, linuxram@us.ibm.com Subject: [PATCH v9 07/51] powerpc: cleanup AMR, IAMR when a key is allocated or freed Date: Mon, 6 Nov 2017 00:56:59 -0800 Message-Id: <1509958663-18737-8-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1509958663-18737-1-git-send-email-linuxram@us.ibm.com> References: <1509958663-18737-1-git-send-email-linuxram@us.ibm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cleanup the bits corresponding to a key in the AMR, and IAMR register, when the key is newly allocated/activated or is freed. We dont want some residual bits cause the hardware enforce unintended behavior when the key is activated or freed. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Ram Pai --- arch/powerpc/include/asm/pkeys.h | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/pkeys.h b/arch/powerpc/include/asm/pkeys.h index e5deac7..0d00a54 100644 --- a/arch/powerpc/include/asm/pkeys.h +++ b/arch/powerpc/include/asm/pkeys.h @@ -69,6 +69,8 @@ static inline bool mm_pkey_is_allocated(struct mm_struct *mm, int pkey) __mm_pkey_is_allocated(mm, pkey)); } +extern void __arch_activate_pkey(int pkey); +extern void __arch_deactivate_pkey(int pkey); /* * Returns a positive, 5-bit key on success, or -1 on failure. * Relies on the mmap_sem to protect against concurrency in mm_pkey_alloc() and @@ -96,6 +98,12 @@ static inline int mm_pkey_alloc(struct mm_struct *mm) ret = ffz((u32)mm_pkey_allocation_map(mm)); __mm_pkey_allocated(mm, ret); + + /* + * Enable the key in the hardware + */ + if (ret > 0) + __arch_activate_pkey(ret); return ret; } @@ -107,6 +115,10 @@ static inline int mm_pkey_free(struct mm_struct *mm, int pkey) if (!mm_pkey_is_allocated(mm, pkey)) return -EINVAL; + /* + * Disable the key in the hardware + */ + __arch_deactivate_pkey(pkey); __mm_pkey_free(mm, pkey); return 0; -- 1.7.1 From 1583367088635555944@xxx Tue Nov 07 01:02:05 +0000 2017 X-GM-THRID: 1583367088635555944 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread