Received: by 10.223.164.202 with SMTP id h10csp16133wrb; Mon, 6 Nov 2017 01:37:51 -0800 (PST) X-Google-Smtp-Source: ABhQp+SAtCQ/A44kGBRjVpIEI/WUMOdc7dTlEZm6YNpg4dPKa1PZQ4tCWHER5zg1FCsnj8qjdlB4 X-Received: by 10.101.70.15 with SMTP id v15mr12216281pgq.320.1509961071806; Mon, 06 Nov 2017 01:37:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509961071; cv=none; d=google.com; s=arc-20160816; b=OpwLgvggjBft72MZ2zNzF1lTp+ddBnenRTNNkU4jV4eiqzJfZV7lS23myk3Y6vOs/s +UGunObIHEXtrDD4STAZQgrQFnI3ep6ZoYLsRoc2JME//TK113ptw5vLcaz4TObeTvbi rPvjZkT1jVMUmBAqnMNT/f/CHNpu1u1lMVy5vsDuCNuwdmUx8hU3C76+xi5IQSX2nuRP izoCCY4AEwlVAZZQg9pHWuLqw+cf2dyYXXTYHDX5Utas7uuVlVCMfZAnYNokqwtNnRN1 DsijpuwQWrJMMXAK/eK+PS21oEno+EDmvmHvracYaqgOaay6eZhLy0oYTlT6i8a9OUDQ Ge+w== 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=El7/lt9ChD4wJSx7Ks1dlFDESxj+vsahDQQv1gaFt+s=; b=ndCybrhXnRYDmF24OLemPHq/ZY1CO5qI+OQ7Pa85bX3V9NwJVX8h0FWSyBUkfRjI80 d4oZ/b9oKrTG8WO5DIxAWVt4cgosIExFbWw01iHQV6Z+wgkrwCDQDkg++j3hcRej1/sJ b5KwdTyYZFn+BmmoVkENIzx/GK7J0ZamLZ7H0HYoFstUtuV7HoBQkfsMHcRauU9fCJGo 0AT58o187hwX/Kr2kdg6SQM7PDMg5VzVooUSwq6TSUi5kY80QA+z6ehSoWz88+dbs7bR bQZ2f81mE2rLwr+fJTIhc/HFfSo9y8upMmWrcxepDBextw58JUQqbuzuUTdKFsoUpmks lBEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=gkymVvIZ; 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 d127si10951267pgc.372.2017.11.06.01.37.38; Mon, 06 Nov 2017 01:37:51 -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=gkymVvIZ; 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 S1752310AbdKFJfv (ORCPT + 98 others); Mon, 6 Nov 2017 04:35:51 -0500 Received: from mail-qt0-f195.google.com ([209.85.216.195]:43524 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751676AbdKFI7C (ORCPT ); Mon, 6 Nov 2017 03:59:02 -0500 Received: by mail-qt0-f195.google.com with SMTP id j58so10028803qtj.0; Mon, 06 Nov 2017 00:59:01 -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=El7/lt9ChD4wJSx7Ks1dlFDESxj+vsahDQQv1gaFt+s=; b=gkymVvIZ2fiG7gQiYKQdd34xUvPH/cvXJ22ZIcFcVdScpQXorZjWWxo0it/Dbmmzog vwsHxqWS2O4SLonqaqcdI/JCwRWpMpYpizBo9egqPiWVuLrXdc+QX3jEBBl1grZVkAew hmuoOa0qjkqO5qJ0oe/L4cr67KTJzuhZpLMvNasSnSlNhf34sliFtO2nrh0Ium2nYdnE spKzGJJ5kXu7HQjT4T2VlevFOYFsmydbyyKuLifaFGU5WNZTGiGenY7UWFfyHuVqH3d3 vatIOZNI2tv77Vvzhr00bgkQR2xycE11IfIx7Fsy/eXlD7rQpk+YLPX3Z2XDUG7n/9DE 1wWw== 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=El7/lt9ChD4wJSx7Ks1dlFDESxj+vsahDQQv1gaFt+s=; b=tJ06UIkkfNPeHaMcC/omom/iBCE4a/5JgaCBc6DJwmb+WlUsCSqiQfZK1c6BYaRP0A hxrh3sEw71YDUBGpKapFXCTXnVrXQD0or9rDH1z6SJaeO6rcuNndKLUV8WHgjpwX9o66 /heqYt+Apif/sFj2O/V85kjJa+wZqYnd/bt/nbn57utUd08vRvoBx2B09VJFoN2IDGZU ohS3EOmzivgtZ5s+B6nBftp9Ts/yq8o2sk2OVK/TxRbG3BW64I5pv5HC1Bt4ZV1Rsm65 /xdOuUnaCbGVHGvXmk/CPiP1AWZet2Y5PQEdLpiX46LUpiEzPLcnvKMR0tjQ5gin3EPl 74tg== X-Gm-Message-State: AMCzsaWZUEOLq4xVVxsI33n9Fk+M0+ti4q7XUvFkBVXN+sWxHGohTZPB SoJ14tzXOb6ExsYW7azMkag= X-Received: by 10.200.37.89 with SMTP id 25mr21924567qtn.268.1509958741068; Mon, 06 Nov 2017 00:59:01 -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.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 00:59:00 -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 15/51] powerpc: Program HPTE key protection bits Date: Mon, 6 Nov 2017 00:57:07 -0800 Message-Id: <1509958663-18737-16-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 Map the PTE protection key bits to the HPTE key protection bits, while creating HPTE entries. Acked-by: Balbir Singh Signed-off-by: Ram Pai --- arch/powerpc/include/asm/book3s/64/mmu-hash.h | 5 +++++ arch/powerpc/include/asm/mmu_context.h | 6 ++++++ arch/powerpc/include/asm/pkeys.h | 9 +++++++++ arch/powerpc/mm/hash_utils_64.c | 1 + 4 files changed, 21 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/mmu-hash.h b/arch/powerpc/include/asm/book3s/64/mmu-hash.h index 508275b..2e22357 100644 --- a/arch/powerpc/include/asm/book3s/64/mmu-hash.h +++ b/arch/powerpc/include/asm/book3s/64/mmu-hash.h @@ -90,6 +90,8 @@ #define HPTE_R_PP0 ASM_CONST(0x8000000000000000) #define HPTE_R_TS ASM_CONST(0x4000000000000000) #define HPTE_R_KEY_HI ASM_CONST(0x3000000000000000) +#define HPTE_R_KEY_BIT0 ASM_CONST(0x2000000000000000) +#define HPTE_R_KEY_BIT1 ASM_CONST(0x1000000000000000) #define HPTE_R_RPN_SHIFT 12 #define HPTE_R_RPN ASM_CONST(0x0ffffffffffff000) #define HPTE_R_RPN_3_0 ASM_CONST(0x01fffffffffff000) @@ -104,6 +106,9 @@ #define HPTE_R_C ASM_CONST(0x0000000000000080) #define HPTE_R_R ASM_CONST(0x0000000000000100) #define HPTE_R_KEY_LO ASM_CONST(0x0000000000000e00) +#define HPTE_R_KEY_BIT2 ASM_CONST(0x0000000000000800) +#define HPTE_R_KEY_BIT3 ASM_CONST(0x0000000000000400) +#define HPTE_R_KEY_BIT4 ASM_CONST(0x0000000000000200) #define HPTE_R_KEY (HPTE_R_KEY_LO | HPTE_R_KEY_HI) #define HPTE_V_1TB_SEG ASM_CONST(0x4000000000000000) diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h index a83d540..a557735 100644 --- a/arch/powerpc/include/asm/mmu_context.h +++ b/arch/powerpc/include/asm/mmu_context.h @@ -154,6 +154,12 @@ static inline int vma_pkey(struct vm_area_struct *vma) { return 0; } + +static inline u64 pte_to_hpte_pkey_bits(u64 pteflags) +{ + return 0x0UL; +} + #endif /* CONFIG_PPC_MEM_KEYS */ #endif /* __KERNEL__ */ diff --git a/arch/powerpc/include/asm/pkeys.h b/arch/powerpc/include/asm/pkeys.h index cfe61a9..06a58fe 100644 --- a/arch/powerpc/include/asm/pkeys.h +++ b/arch/powerpc/include/asm/pkeys.h @@ -73,6 +73,15 @@ static inline int vma_pkey(struct vm_area_struct *vma) #define arch_max_pkey() pkeys_total +static inline u64 pte_to_hpte_pkey_bits(u64 pteflags) +{ + return (((pteflags & H_PTE_PKEY_BIT0) ? HPTE_R_KEY_BIT0 : 0x0UL) | + ((pteflags & H_PTE_PKEY_BIT1) ? HPTE_R_KEY_BIT1 : 0x0UL) | + ((pteflags & H_PTE_PKEY_BIT2) ? HPTE_R_KEY_BIT2 : 0x0UL) | + ((pteflags & H_PTE_PKEY_BIT3) ? HPTE_R_KEY_BIT3 : 0x0UL) | + ((pteflags & H_PTE_PKEY_BIT4) ? HPTE_R_KEY_BIT4 : 0x0UL)); +} + #define pkey_alloc_mask(pkey) (0x1 << pkey) #define mm_pkey_allocation_map(mm) (mm->context.pkey_allocation_map) diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c index 1e74590..ddfc673 100644 --- a/arch/powerpc/mm/hash_utils_64.c +++ b/arch/powerpc/mm/hash_utils_64.c @@ -232,6 +232,7 @@ unsigned long htab_convert_pte_flags(unsigned long pteflags) */ rflags |= HPTE_R_M; + rflags |= pte_to_hpte_pkey_bits(pteflags); return rflags; } -- 1.7.1 From 1583314631491434192@xxx Mon Nov 06 11:08:18 +0000 2017 X-GM-THRID: 1574636603958149385 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread