From patchwork Mon Jun 27 11:26:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Behme X-Patchwork-Id: 640939 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3rdRTp6N0Kz9t1G for ; Mon, 27 Jun 2016 21:26:37 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=de.bosch.com header.i=@de.bosch.com header.b=FLvmlGhE; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C6EB1A75E6; Mon, 27 Jun 2016 13:26:33 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9O_sKE7tBFLU; Mon, 27 Jun 2016 13:26:33 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 38B3EA7548; Mon, 27 Jun 2016 13:26:33 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 46B3EA7548 for ; Mon, 27 Jun 2016 13:26:30 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uVRId7L4Ud3z for ; Mon, 27 Jun 2016 13:26:30 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from imta22.fe.bosch.de (imta22.fe.bosch.de [139.15.243.26]) by theia.denx.de (Postfix) with ESMTPS id 16812A7527 for ; Mon, 27 Jun 2016 13:26:27 +0200 (CEST) Received: from smtp6-v.fe.bosch.de (imta24.fe.bosch.de [139.15.243.27]) by imta22.fe.bosch.de (Postfix) with ESMTP id 24939840263 for ; Mon, 27 Jun 2016 13:26:27 +0200 (CEST) Received: from vsmta12.fe.internet.bosch.com (unknown [10.4.98.52]) by imta24.fe.bosch.de (Postfix) with ESMTP id 45811D8021B; Mon, 27 Jun 2016 13:26:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=de.bosch.com; s=2015-01-21; t=1467026782; bh=D+ZtgfBwZlQH9X0deBUMWM2iAmLBuRJuYCTU6sVqLmQ=; l=10; h=From:From:Reply-To:Sender; b=FLvmlGhEbKxBtOoaf7lMLkGnclJG0tXQevOFxIU59ZTPDEs2ds8fd4XWMNKL5V/vy yVOXruYqUZaPnllMa+7Qytpz2F7GtDVcwKz5loFF0P2shryQfrvk6dMU3+YB6CzHkn MEDmP3IAJucIL0ikCF5SmKEg7j8+SB39CQW0PLyY= Received: from FE-HUB1001.de.bosch.com (vsgw22.fe.internet.bosch.com [10.4.98.11]) by vsmta12.fe.internet.bosch.com (Postfix) with ESMTP id E435A1B80274; Mon, 27 Jun 2016 13:26:21 +0200 (CEST) Received: from [10.34.217.161] (10.34.217.161) by FE-HUB1001.de.bosch.com (10.4.103.109) with Microsoft SMTP Server id 14.3.195.1; Mon, 27 Jun 2016 13:26:21 +0200 To: Mateusz Kulikowski References: <1444841757-28043-1-git-send-email-s.temerkhanov@gmail.com> <1444841757-28043-4-git-send-email-s.temerkhanov@gmail.com> <568D10E5.4060005@gmail.com> <568E7F0F.5000001@xilinx.com> <568EDB1A.9030707@gmail.com> <7c1595fe-f3a3-5a11-5f22-f729bf74e465@de.bosch.com> <576ED5CA.203@gmail.com> From: Dirk Behme Organization: Robert Bosch Car Multimedia GmbH Message-ID: Date: Mon, 27 Jun 2016 13:26:20 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <576ED5CA.203@gmail.com> X-Originating-IP: [10.34.217.161] X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1679-8.0.0.1202-22416.006 X-TMASE-MatchedRID: u7Yf2n7Ca/1fsB4HYR80Zia1MaKuob8Pt3aeg7g/usDfUZT83lbkEJas fA8Y/RCFX8O+6rCS8eGK0Joj0npda2KplHd7ThK1iUPZPmKZOQlzd7C7BtJobk4K0IMk2m3GAmL /YMh+r1HrhNrc/XiBXYw71wd+Sze3XW7Ff6hveHHuykw7cfAoICEdaywSZvzO5e3sEEAszZvndH pLMBrOmvWB6SghU8x7QEUU7tHYIugUN/8aAzvyJRcanaCAqviGO+1reiMOYH/xCQaCt6X8brqHz XVMW/hzvvJoxo0uTMSN/3dDbj3CNUJH8WyQMk5ungIgpj8eDcC063Wh9WVqgnlZfqMjiglX1GcR AJRT6POOhzOa6g8KrQSvRiqU5p6KaiYpppY9P1mwAbgpE5e9q1WmZJBlQx68YbnR+lY7n0I= Cc: Corey Minyard , Tom Rini , Michal Simek , Masahiro Yamada , u-boot@lists.denx.de, Tom Warren , Ian Campbell , Thierry Reding , Radha Mohan Chintakuntla Subject: Re: [U-Boot] [PATCH v7 3/9] armv8: Add Secure Monitor/Hypervisor Call (SMC/HVC) infrastructure X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" On 25.06.2016 21:04, Mateusz Kulikowski wrote: > Hi Dirk, > > On 23.06.2016 13:33, Dirk Behme wrote: > [...] >>>>> >>>>> Idea: perhaps after this series is merged we can add 2 new commands to u-boot (SMC/HVC) to >>>>> play with hypervisors/secure monitors (and perhaps use some simple functionality if needed). >>>> >>>> How this should look like? >>> >>> I thought of something like this (I did such code few times): >>> >>> u-boot> smc 42 42 42 42 42 42 >>> ret => (0x1, 0x2, 0x3, 0x4) >> >> >> Could you share any (example?) code you have for such an smc/hvc U-Boot command? > > I'm afraid I don't have it anymore :( > > SMC call itself is trivial, you can use smc_call @ u-boot: > arch/arm/cpu/armv8/fwcall.c > (this is code for armv8 in 64-bit mode, but you can easily port it to armv7) > > As for adding custom commands - just use any existing as template (sleep may be a good idea :) ). Anything like below [1]? Best regards Dirk [1] From f5fb9bdab3054fdc37ca3fed44703f0dc5c8b083 Mon Sep 17 00:00:00 2001 From: Dirk Behme Date: Mon, 27 Jun 2016 12:39:35 +0200 Subject: [PATCH] common: Add ARMv8 smc command Add a command line interface to do ARMv8 secure monitor calls (smc). Signed-off-by: Dirk Behme --- common/Makefile | 2 + common/cmd_armv8svchvc.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 0 deletions(-) create mode 100644 common/cmd_armv8svchvc.c + " - 8 SMC parameters for the registers x0 - x7" +); diff --git a/common/Makefile b/common/Makefile index 252fbf1..5a8dad0 100644 --- a/common/Makefile +++ b/common/Makefile @@ -191,6 +191,8 @@ obj-$(CONFIG_CMD_SPL) += cmd_spl.o obj-$(CONFIG_CMD_ZIP) += cmd_zip.o obj-$(CONFIG_CMD_ZFS) += cmd_zfs.o +obj-$(CONFIG_ARM64) += cmd_armv8svchvc.o + # others obj-$(CONFIG_BOOTSTAGE) += bootstage.o obj-$(CONFIG_CONSOLE_MUX) += iomux.o diff --git a/common/cmd_armv8svchvc.c b/common/cmd_armv8svchvc.c new file mode 100644 index 0000000..6491704 --- /dev/null +++ b/common/cmd_armv8svchvc.c @@ -0,0 +1,60 @@ +/* + * (C) Copyright 2016 + * Robert Bosch Car Multimedia GmbH + * Dirk Behme + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include + +static int do_smc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + struct pt_regs regs; + + memset(®s, 0, sizeof(struct pt_regs)); + + switch (argc) { + case 9: + regs.regs[7] = simple_strtoul(argv[8], NULL, 16); + /* fall through */ + case 8: + regs.regs[6] = simple_strtoul(argv[7], NULL, 16); + /* fall through */ + case 7: + regs.regs[5] = simple_strtoul(argv[6], NULL, 16); + /* fall through */ + case 6: + regs.regs[4] = simple_strtoul(argv[5], NULL, 16); + /* fall through */ + case 5: + regs.regs[3] = simple_strtoul(argv[4], NULL, 16); + /* fall through */ + case 4: + regs.regs[2] = simple_strtoul(argv[3], NULL, 16); + /* fall through */ + case 3: + regs.regs[1] = simple_strtoul(argv[2], NULL, 16); + /* fall through */ + case 2: + regs.regs[0] = simple_strtoul(argv[1], NULL, 16); + break; + default: + return CMD_RET_USAGE; + } + + smc_call(®s); + + printf("ret: x0: 0x%016luX\n x1: 0x%016luX\n x2: 0x%016luX x3: 0x%016lX\n", + regs.regs[0], regs.regs[1], regs.regs[2], regs.regs[3]); + + return 0; +} + +U_BOOT_CMD( + smc , 9, 0, do_smc, + "do ARMv8 hypervisor call (SMC)", + "x0 [x1 x2 x3 x4 x5 x6 x7]\n"