From patchwork Fri Sep 8 22:31:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 811851 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xpsVv6JPqz9rvt for ; Sat, 9 Sep 2017 08:31:35 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3xpsVv55WVzDrcd for ; Sat, 9 Sep 2017 08:31:35 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=bauerman@linux.vnet.ibm.com; receiver=) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3xpsVb15GGzDrcW for ; Sat, 9 Sep 2017 08:31:18 +1000 (AEST) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v88MSjpV107964 for ; Fri, 8 Sep 2017 18:31:16 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cv16wedbp-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 08 Sep 2017 18:31:16 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 8 Sep 2017 16:31:15 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 8 Sep 2017 16:31:13 -0600 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v88MVDsg1311210; Fri, 8 Sep 2017 15:31:13 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E609BE03A; Fri, 8 Sep 2017 16:31:13 -0600 (MDT) Received: from morokweng.ibm.com (unknown [9.80.233.116]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP id 1ED2DBE044; Fri, 8 Sep 2017 16:31:07 -0600 (MDT) From: Thiago Jung Bauermann To: skiboot@lists.ozlabs.org Date: Fri, 8 Sep 2017 19:31:02 -0300 X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17090822-0016-0000-0000-0000077D725A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007691; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000227; SDB=6.00914228; UDB=6.00458926; IPR=6.00694486; BA=6.00005576; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017074; XFM=3.00000015; UTC=2017-09-08 22:31:14 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17090822-0017-0000-0000-00003B64E49A Message-Id: <20170908223102.20470-1-bauerman@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-08_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709080333 Subject: [Skiboot] [PATCH v2] core/init: Add ibm, processor-storage-keys property to /cpus DT node. X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Mackerras Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" LoPAPR says: “ibm,processor-storage-keys” property name indicating the number of virtual storage keys supported by the processor described by this node. prop-encoded-array: Consists of two cells encoded as with encode-int. The first cell represents the number of virtual storage keys supported for data accesses while the second cell represents the number of virtual storage keys supported for instruction accesses. The cell value of zero indicates that no storage keys are supported for the access type. pHyp provides the property above but there's a bug in P8 firmware where the second cell is zero even though POWER8 supports instruction access keys. This bug will be fixed for P9. While this is a PAPR property, it's useful to have it in powernv as well so that Linux has a uniform way of checking for the feature regardless of the platform it's running on. On PAPR there is one property for each CPU node, but since it's highly unlikely that different CPUs will support a different number of keys, we put the property in the /cpus node instead. Tested on QEMU POWER8 powernv model and Mambo P9. Signed-off-by: Thiago Jung Bauermann --- core/init.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) Changes in v2: - Put property in /cpus instead of in each CPU node. diff --git a/core/init.c b/core/init.c index 8951e17b4c90..4a6f9155511d 100644 --- a/core/init.c +++ b/core/init.c @@ -563,6 +563,22 @@ void __noreturn load_and_boot_kernel(bool is_reboot) start_kernel(kernel_entry, fdt, mem_top); } +static void storage_keys_fixup(void) +{ + /* P7 doesn't support instruction access keys. */ + const u32 insn_keys = (proc_gen == proc_gen_p7) ? 0 : 32; + struct dt_node *cpus = dt_find_by_path(dt_root, "/cpus"); + + assert(cpus); + + if (proc_gen == proc_gen_unknown) + return; + else if (dt_has_node_property(cpus, "ibm,processor-storage-keys", NULL)) + return; + + dt_add_property_cells(cpus, "ibm,processor-storage-keys", 32, insn_keys); +} + static void dt_fixups(void) { struct dt_node *n; @@ -590,6 +606,8 @@ static void dt_fixups(void) if (!dt_has_node_property(n, "scom-controller", NULL)) dt_add_property(n, "scom-controller", NULL, 0); } + + storage_keys_fixup(); } static void add_arch_vector(void)