Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2712574ybi; Thu, 18 Jul 2019 13:01:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEHa8RlpM7hcxgdzGGXn9jSzOSjwriifOV7EeLt6t3CBElldltwI8CzHQq1Os22VKc/ksh X-Received: by 2002:a17:902:bd94:: with SMTP id q20mr41213213pls.307.1563480067564; Thu, 18 Jul 2019 13:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563480067; cv=none; d=google.com; s=arc-20160816; b=iIgZKgf4emgnpv7B0Bndn7OKkHJEv17sLySoyayw1p82MavVIUNA0yhAuK3kLV1wfc VqFfXf1E8OFRNv5CN3h+w2A/yZz53MfxoLgOVispuw6dW6ytAzTDzNMBROMe8rszjTjU qB8qlSpy7PYSfR7sJ6/0RIyWjJAenH5dfC8/3OqvnprBaFsfZy+TSm0v27VpCh6ylU3/ 1eTZormk2YYkdSDB9QHdZObVplgBhY317nXBk+pz7EmCXQhHAqKeT8SULHzSIyaXA9AP D4hPhWVPgDQkS2kLw6ebJ3T+IH2l71f6Oi/1muP52qMIBl3fbI2rEcjAw9vNt4zzNNi+ F1xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=tFyOyvCTDk3R6YY5qhlU7WJqlVFgTHut57RFcymuHRU=; b=R9HdqUf8fGV65Dxb54+H0+VtLtmisr3ORy3xU6LSmp6qJvIXav6lCfjldjR7SZKKqr fgE/75ye3eB07bFY7eyjKGH0e9Nf3zO6IE41DEJvt6rfQrKnE0uZUFpKP6aicVpeziCE zigFHWgRi+DiT2ljNTWgA7X76Ofq9NYzQoAC0DUyQaES+VJtfFJxrBL4q1oyk/BRIfjA 5NXOWjGNuFKpagIjszzVz8JihDV6IsWSatgUzISIvtq2t5kHI27QmhRBDp82ku0QZPfZ XgxGznlhMwuHD7Wf0gtBqABeqzPmRVpkWv2X3E0ikAqjfortHKj55/Ktlkq3iTF4idNX zhGA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k43si26546024pje.59.2019.07.18.13.00.50; Thu, 18 Jul 2019 13:01:07 -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; Authentication-Results: mx.google.com; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391391AbfGRT7R (ORCPT + 99 others); Thu, 18 Jul 2019 15:59:17 -0400 Received: from gate.crashing.org ([63.228.1.57]:52801 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727780AbfGRT7R (ORCPT ); Thu, 18 Jul 2019 15:59:17 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x6IJwpXD009323; Thu, 18 Jul 2019 14:58:52 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id x6IJwou7009319; Thu, 18 Jul 2019 14:58:50 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Thu, 18 Jul 2019 14:58:50 -0500 From: Segher Boessenkool To: Alexey Kardashevskiy Cc: Thiago Jung Bauermann , linuxppc-dev@lists.ozlabs.org, Anshuman Khandual , Mike Anderson , Ram Pai , linux-kernel@vger.kernel.org, Claudio Carvalho , Paul Mackerras , Christoph Hellwig Subject: Re: [PATCH v2 03/13] powerpc/prom_init: Add the ESM call to prom_init Message-ID: <20190718195850.GU20882@gate.crashing.org> References: <20190713060023.8479-1-bauerman@linux.ibm.com> <20190713060023.8479-4-bauerman@linux.ibm.com> <70f8097f-7222-fe18-78b4-9372c21bfc9d@ozlabs.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <70f8097f-7222-fe18-78b4-9372c21bfc9d@ozlabs.ru> User-Agent: Mutt/1.4.2.3i Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (Sorry to hijack your reply). On Thu, Jul 18, 2019 at 06:11:48PM +1000, Alexey Kardashevskiy wrote: > On 13/07/2019 16:00, Thiago Jung Bauermann wrote: > >From: Ram Pai > >+static int enter_secure_mode(unsigned long kbase, unsigned long fdt) > >+{ > >+ register uint64_t func asm("r3") = UV_ESM; > >+ register uint64_t arg1 asm("r4") = (uint64_t)kbase; > >+ register uint64_t arg2 asm("r5") = (uint64_t)fdt; > > What does UV do with kbase and fdt precisely? Few words in the commit > log will do. > > >+ > >+ asm volatile("sc 2\n" > >+ : "=r"(func) > >+ : "0"(func), "r"(arg1), "r"(arg2) > >+ :); > >+ > >+ return (int)func; > > And why "func"? Is it "function"? Weird name. Thanks, Maybe the three vars should just be called "r3", "r4", and "r5" -- r3 is used as return value as well, so "func" isn't a great name for it. Some other comments about this inline asm: The "\n" makes the generated asm look funny and has no other function. Instead of using backreferences you can use a "+" constraint, "inout". Empty clobber list is strange. Casts to the return type, like most other casts, are an invitation to bugs and not actually useful. So this can be written static int enter_secure_mode(unsigned long kbase, unsigned long fdt) { register uint64_t r3 asm("r3") = UV_ESM; register uint64_t r4 asm("r4") = kbase; register uint64_t r4 asm("r5") = fdt; asm volatile("sc 2" : "+r"(r3) : "r"(r4), "r"(r5)); return r3; } (and it probably should use u64 instead of both uint64_t and unsigned long?) Segher