Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp401986pxb; Thu, 5 Nov 2020 03:13:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0B1TbKwERf5H8u9uGKPqbAqO9XLKaQElERijzUD3hNzgxysGyaCTHezYQiXdL9V6U1nr+ X-Received: by 2002:a17:906:180b:: with SMTP id v11mr1733817eje.466.1604574801506; Thu, 05 Nov 2020 03:13:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604574801; cv=none; d=google.com; s=arc-20160816; b=CqIEAgdgA5+77NYGqm8CJY6oMsRLIaH2dLlOg53MuL/plSMHvtF9nnhjVDzOIWou9W p80WMdWh3RLCnY4k0mKyhRUpxfury3Fv8ktDfVFP4t9AfFaP5g9GDlfnWliJKNE7FLoi XvrppnD4uywm9Mw/Y00smWoWtaQvfHnDuzM+Rg3suW50k7zQLr57q3M0UMr3CUSPViPe yd5x0Ncugoxmk51rKoy3rvpJEEpptl2Gi3ah7nqqyv6hALnbHuZIbpZqz2SGTJslSpbV ou+E3htPad8vgr+j/KGOqd7MkbyIwvLmxBvjGPnUgYtoHiruUtqDKkZFp+p+qUsLvfx7 NnpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=qA3FZMwOcT3dP6C5Qe7UNitqxBDV3w42dy4HMxut1z8=; b=bAfLarATVlrOZRSxxm3KhGswbBKgNvXHk+jNPn/r1U3EfSEzl408/6pyWWnr0kl35Q zWkn8iROLwcaURVG30gCBESv+cs62Vp5xJoz8Ni5oSg9ePZ89oZzSZPtt2y8eX0azMOV jsGLxKmG26RTnJHbW1veMwG3tgH3nvVRztsrJ9oQM2QTummlZmKqILIc/njPoLS9TVna thkeNa6Zii57ABLGIl+JgvsLY59LOs+BeN5mZ7EP1nz4mnX5d1HsWCU74mduG/pJN7L4 jjwNP+rXWcM1po28qRj9e9eBJevmjEsU9QWF1TMvHG4inV4v5UpToJ8XVa6kgROTwBiK gehg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="s0/mPv6J"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ly22si761140ejb.511.2020.11.05.03.12.57; Thu, 05 Nov 2020 03:13:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="s0/mPv6J"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730044AbgKELIp (ORCPT + 99 others); Thu, 5 Nov 2020 06:08:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:49498 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730018AbgKELIp (ORCPT ); Thu, 5 Nov 2020 06:08:45 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DC76D2072E; Thu, 5 Nov 2020 11:08:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604574524; bh=3sUQ3ja2rj2uStC3OQabrdR0ZZMO2xkmRDD9nGypmls=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=s0/mPv6J5efk5VAAfbAzqZuUY+XMg/dc72UvmDXwVjd9/FXUVkSlXtaIh9i4EewIR xAboT+rU3ASTmQrXuEAmx1nJANjGc89lVfxmnu3rYnpMdRc7mrtvUXnlT2wYBGQI26 /bwE1BpoOzqDmHpWu5EvDo7L24La7KLz43g5vQhQ= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1kad8B-007oEK-0r; Thu, 05 Nov 2020 11:08:41 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 05 Nov 2020 11:08:38 +0000 From: Marc Zyngier To: David Brazdil Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, James Morse , Julien Thierry , Suzuki K Poulose , Catalin Marinas , Will Deacon , Dennis Zhou , Tejun Heo , Christoph Lameter , Mark Rutland , Lorenzo Pieralisi , Quentin Perret , Andrew Scull , kernel-team@android.com Subject: Re: [RFC PATCH 12/26] kvm: arm64: Add SMC handler in nVHE EL2 In-Reply-To: <20201104183630.27513-13-dbrazdil@google.com> References: <20201104183630.27513-1-dbrazdil@google.com> <20201104183630.27513-13-dbrazdil@google.com> User-Agent: Roundcube Webmail/1.4.9 Message-ID: <35d054aa819034831a04aa3332aceec2@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: dbrazdil@google.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, dennis@kernel.org, tj@kernel.org, cl@linux.com, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, qperret@google.com, ascull@google.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-11-04 18:36, David Brazdil wrote: > Add handler of host SMCs in KVM nVHE trap handler. Forward all SMCs to > EL3 and propagate the result back to EL1. This is done in preparation > for validating host SMCs. > > Signed-off-by: David Brazdil > --- > arch/arm64/kvm/hyp/nvhe/hyp-main.c | 36 ++++++++++++++++++++++++++++++ > 1 file changed, 36 insertions(+) > > diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c > b/arch/arm64/kvm/hyp/nvhe/hyp-main.c > index 19332c20fcde..fffc2dc09a1f 100644 > --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c > +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c > @@ -106,6 +106,38 @@ static void handle_host_hcall(struct > kvm_cpu_context *host_ctxt) > host_ctxt->regs.regs[1] = ret; > } > > +static void skip_host_instruction(void) > +{ > + write_sysreg_el2(read_sysreg_el2(SYS_ELR) + 4, SYS_ELR); > +} > + > +static void forward_host_smc(struct kvm_cpu_context *host_ctxt) > +{ > + struct arm_smccc_res res; > + > + arm_smccc_1_1_smc(host_ctxt->regs.regs[0], host_ctxt->regs.regs[1], > + host_ctxt->regs.regs[2], host_ctxt->regs.regs[3], > + host_ctxt->regs.regs[4], host_ctxt->regs.regs[5], > + host_ctxt->regs.regs[6], host_ctxt->regs.regs[7], > + &res); > + host_ctxt->regs.regs[0] = res.a0; > + host_ctxt->regs.regs[1] = res.a1; > + host_ctxt->regs.regs[2] = res.a2; > + host_ctxt->regs.regs[3] = res.a3; > +} > + > +static void handle_host_smc(struct kvm_cpu_context *host_ctxt) > +{ > + /* > + * Unlike HVC, the return address of an SMC is the instruction's PC. > + * Move the return address past the instruction. > + */ > + skip_host_instruction(); > + > + /* Forward SMC not handled in EL2 to EL3. */ > + forward_host_smc(host_ctxt); > +} > + > void handle_trap(struct kvm_cpu_context *host_ctxt) > { > u64 esr = read_sysreg_el2(SYS_ESR); > @@ -114,6 +146,10 @@ void handle_trap(struct kvm_cpu_context > *host_ctxt) > case ESR_ELx_EC_HVC64: > handle_host_hcall(host_ctxt); > break; > + case ESR_ELx_EC_SMC32: How is that even possible? Host EL1 is strictly 64bit, so SMC32 cannot occur. > + case ESR_ELx_EC_SMC64: > + handle_host_smc(host_ctxt); > + break; > default: > hyp_panic(); > } Thanks, M. -- Jazz is not dead. It just smells funny...