From patchwork Mon Apr 21 21:53:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 28747 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C243A2032B for ; Mon, 21 Apr 2014 21:54:53 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id c1sf9205386igq.6 for ; Mon, 21 Apr 2014 14:54:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=Ptg9WF5qRz1shrCIVWO2hVEP9qn5jLPM3OYnesmXd0s=; b=L/EQ7AY8WWS564LKO6L42GW5fk2idmnD74vIsCsKfuCcRGzejbPgpdaChpuAoTKze/ kmlogH252YXc+/WtGdINUa+UE5SZN523FXfcRvfpTfH2gxGeMG1w0PJlsxaKHctzDzl5 Li1u9uGNpqcJScI7sKPfMlc4Gcoyz++qY2I58ql+QIqnhf1evVh3AVSWFyT+v8yXCx0e YXXbhgUXx5pfU1L6M+v1ORIlec3spu3rOLUqAGgPF5hAL04y0yHj0GRawXYho7DSUDMZ ClR7i7n9f8oHqnnWrPQjvd66Vyww25rQuOkdPHoK23782adaNZPwTPKLLJjP55/k9ntw zBmg== X-Gm-Message-State: ALoCoQkOijwrXR/igFFe4MgwtnLh0iOA7PYK/y8EY7zIH1MUKbapo+VCNHJdaM1pco1lWXUtL/1l X-Received: by 10.50.73.74 with SMTP id j10mr11713155igv.1.1398117292982; Mon, 21 Apr 2014 14:54:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.30.4 with SMTP id c4ls1450045qgc.51.gmail; Mon, 21 Apr 2014 14:54:52 -0700 (PDT) X-Received: by 10.220.163.3 with SMTP id y3mr33480805vcx.7.1398117292876; Mon, 21 Apr 2014 14:54:52 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id f7si6476320vcz.165.2014.04.21.14.54.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Apr 2014 14:54:52 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.179; Received: by mail-ve0-f179.google.com with SMTP id db12so8405855veb.24 for ; Mon, 21 Apr 2014 14:54:52 -0700 (PDT) X-Received: by 10.52.241.106 with SMTP id wh10mr27991945vdc.16.1398117292788; Mon, 21 Apr 2014 14:54:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp321057vcb; Mon, 21 Apr 2014 14:54:52 -0700 (PDT) X-Received: by 10.66.161.69 with SMTP id xq5mr40319979pab.62.1398117292031; Mon, 21 Apr 2014 14:54:52 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id td10si21518495pac.263.2014.04.21.14.54.51; Mon, 21 Apr 2014 14:54:51 -0700 (PDT) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755316AbaDUVxt (ORCPT + 26 others); Mon, 21 Apr 2014 17:53:49 -0400 Received: from mail-yh0-f47.google.com ([209.85.213.47]:48795 "EHLO mail-yh0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755258AbaDUVxm (ORCPT ); Mon, 21 Apr 2014 17:53:42 -0400 Received: by mail-yh0-f47.google.com with SMTP id 29so4040349yhl.20 for ; Mon, 21 Apr 2014 14:53:42 -0700 (PDT) X-Received: by 10.236.159.67 with SMTP id r43mr53385284yhk.50.1398117222123; Mon, 21 Apr 2014 14:53:42 -0700 (PDT) Received: from localhost.localdomain (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPSA id t63sm74182258yhm.32.2014.04.21.14.53.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Apr 2014 14:53:41 -0700 (PDT) From: Alex Elder To: bcm@fixthebug.org, mporter@linaro.org Cc: bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 09/10] ARM: bcm: rewrite commentary for bcm_kona_do_smc() Date: Mon, 21 Apr 2014 16:53:10 -0500 Message-Id: <1398117191-2433-10-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1398117191-2433-1-git-send-email-elder@linaro.org> References: <1398117191-2433-1-git-send-email-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: elder@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The block of comments in bcm_kona_do_smc() are somewhat confusing. This patch attempts to clarify what's going on. Signed-off-by: Alex Elder Reviewed-by: Tim Kryger Reviewed-by: Markus Mayer Reviewed-by: Matt Porter --- arch/arm/mach-bcm/bcm_kona_smc.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/arch/arm/mach-bcm/bcm_kona_smc.c b/arch/arm/mach-bcm/bcm_kona_smc.c index cc81c86..a55a7ec 100644 --- a/arch/arm/mach-bcm/bcm_kona_smc.c +++ b/arch/arm/mach-bcm/bcm_kona_smc.c @@ -77,16 +77,34 @@ int __init bcm_kona_smc_init(void) } /* - * Since interrupts are disabled in the open mode, we must keep - * interrupts disabled in secure mode by setting R5=0x3. If interrupts - * are enabled in open mode, we can set R5=0x0 to allow interrupts in - * secure mode. If we did this, the secure monitor would return back - * control to the open mode to handle the interrupt prior to completing - * the secure service. If this happened, R12 would not be - * SEC_EXIT_NORMAL and we would need to call SMC again after resetting - * R5 (it gets clobbered by the secure monitor) and setting R4 to - * SSAPI_RET_FROM_INT_SERV to indicate that we want the secure monitor - * to finish up the previous uncompleted secure service. + * int bcm_kona_do_smc(u32 service_id, u32 buffer_addr) + * + * Only core 0 can run the secure monitor code. If an "smc" request + * is initiated on a different core it must be redirected to core 0 + * for execution. We rely on the caller to handle this. + * + * Each "smc" request supplies a service id and the address of a + * buffer containing parameters related to the service to be + * performed. A flags value defines the behavior of the level 2 + * cache and interrupt handling while the secure monitor executes. + * + * Parameters to the "smc" request are passed in r4-r6 as follows: + * r4 service id + * r5 flags (SEC_ROM_*) + * r6 physical address of buffer with other parameters + * + * Execution of an "smc" request produces two distinct results. + * + * First, the secure monitor call itself (regardless of the specific + * service request) can succeed, or can produce an error. When an + * "smc" request completes this value is found in r12; it should + * always be SEC_EXIT_NORMAL. + * + * In addition, the particular service performed produces a result. + * The values that should be expected depend on the service. We + * therefore return this value to the caller, so it can handle the + * request result appropriately. This result value is found in r0 + * when the "smc" request completes. */ static int bcm_kona_do_smc(u32 service_id, u32 buffer_phys) {