From patchwork Thu Feb 27 12:20:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Grimm X-Patchwork-Id: 1245841 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Sswh6781z9sP7 for ; Thu, 27 Feb 2020 23:51:00 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48Sswh192fzDr4Y for ; Thu, 27 Feb 2020 23:51:00 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=grimm@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 48SsK745lMzDqWG for ; Thu, 27 Feb 2020 23:23:39 +1100 (AEDT) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01RCLjFw118058 for ; Thu, 27 Feb 2020 07:23:37 -0500 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ydq6j5ntc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 27 Feb 2020 07:23:37 -0500 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 01RCLuTY118865 for ; Thu, 27 Feb 2020 07:23:36 -0500 Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ydq6j5nsv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Feb 2020 07:23:36 -0500 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 01RCKWFf004155; Thu, 27 Feb 2020 12:23:35 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma04wdc.us.ibm.com with ESMTP id 2ydcmkw445-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Feb 2020 12:23:35 +0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01RCNXiX39518624 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Feb 2020 12:23:33 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6744F6A04F; Thu, 27 Feb 2020 12:23:33 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7182C6A047; Thu, 27 Feb 2020 12:23:32 +0000 (GMT) Received: from alain.ibm.com (unknown [9.80.218.175]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 27 Feb 2020 12:23:32 +0000 (GMT) From: Ryan Grimm To: oohall@gmail.com Date: Thu, 27 Feb 2020 07:20:40 -0500 Message-Id: <20200227122042.32692-15-grimm@linux.ibm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200227122042.32692-1-grimm@linux.ibm.com> References: <20200227122042.32692-1-grimm@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-02-27_03:2020-02-26, 2020-02-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 spamscore=0 impostorscore=0 suspectscore=3 bulkscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 malwarescore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002270100 Subject: [Skiboot] [RFC PATCH v4 14/16] Add an ultravisor device tree in secure memory X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: janani@us.ibm.com, suka@us.ibm.com, skiboot@lists.ozlabs.org Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This patch adds a UV FDT created in secure memory. It is allocated directly after the ultravisor. The UV FDT will contain information like the wrapping key. The code uses libfdt directly to ensure only secure memory is used. Signed-off-by: Ryan Grimm Signed-off-by: Ram Pai --- hw/ultravisor.c | 27 ++++++++++++++++++++++++++- include/ultravisor.h | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/hw/ultravisor.c b/hw/ultravisor.c index 650466e8..1467a1e5 100644 --- a/hw/ultravisor.c +++ b/hw/ultravisor.c @@ -12,6 +12,7 @@ #include #include #include +#include static struct dt_node *uv_fw_node; static uint64_t uv_base_addr; @@ -115,9 +116,27 @@ static int uv_decompress_image(void) return OPAL_SUCCESS; } +static int create_dtb_uv(void *uv_fdt) +{ + if (fdt_create(uv_fdt, UV_FDT_MAX_SIZE)) { + prerror("UV: Failed to create uv_fdt\n"); + return OPAL_NO_MEM; + } + + fdt_finish_reservemap(uv_fdt); + fdt_begin_node(uv_fdt, ""); + fdt_property_string(uv_fdt, "description", "Ultravisor fdt"); + fdt_begin_node(uv_fdt, "ibm,uv-fdt"); + fdt_property_string(uv_fdt, "compatible", "ibm,uv-fdt"); + fdt_end_node(uv_fdt); + fdt_finish(uv_fdt); + + return OPAL_SUCCESS; +} + void init_uv() { - uint64_t uv_dt_src, uv_fw_sz; + uint64_t uv_dt_src, uv_fw_sz, uv_fdt_addr; int ret; if (!is_msr_bit_set(MSR_S)) { @@ -131,6 +150,8 @@ void init_uv() goto err; } + uv_base_addr = dt_get_address(uv_fw_node, 0, &uv_fw_sz); + ret = uv_decompress_image(); if (ret) { if (!dt_find_property(uv_fw_node, "uv-src-address")) { @@ -149,6 +170,10 @@ void init_uv() dt_add_property_u64(uv_fw_node, "memcons", (u64)&uv_memcons); debug_descriptor.uv_memcons_phys = (u64)&uv_memcons; + + uv_fdt_addr = uv_base_addr + UV_LOAD_MAX_SIZE; + create_dtb_uv((void *)uv_fdt_addr); + dt_add_property_u64(uv_fw_node, "uv-fdt", uv_fdt_addr); err: local_free(uv_image); } diff --git a/include/ultravisor.h b/include/ultravisor.h index 26a986cd..347b085d 100644 --- a/include/ultravisor.h +++ b/include/ultravisor.h @@ -14,6 +14,7 @@ #define UCALL_BUFSIZE 4 #define UV_READ_SCOM 0xF114 #define UV_WRITE_SCOM 0xF118 +#define UV_FDT_MAX_SIZE 0x100000 extern long ucall(unsigned long opcode, unsigned long *retbuf, ...); extern int start_uv(uint64_t entry, void *fdt);