From patchwork Mon Nov 9 17:59:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 11892153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BFEAC2D0A3 for ; Mon, 9 Nov 2020 18:00:50 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7BF2E221FF for ; Mon, 9 Nov 2020 18:00:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="zpSiorg5"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="1WyyWxd6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7BF2E221FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=02qhTEhWlzPrSxi4s87DWk4JmXYlgPT/R4+cZCgd/0o=; b=zpSiorg5mjaRePTSbkl3E86htU IWsNpSRbkjli3L9OHE9ETSU/RXsPMj1YYEpUyvO5gfUKNRJqYLnmLSL2w5/Z4YowvlcOW/w4XYMaW cK6isRoMMfx9E9CZ/i+mtgcSc4v311H1TPDt5RQu/b56slKIccfNQ0xTLvqt3Mwq+al6mokKEWqS+ 8KM0KSbLh1mjkJYG0jNQESJKryyeNo/PsxBHr+PBiihwt4Y/pCiKAWIpAe74nMyf/zTMZgi93v827 41KWwuRL6dHCwbdGfaXER5US/fUX/LvpjEjIDaSs+c6GODh88IO7eHcDfNrUQ3bVHST54nDbh6pNT 8Bj5+iig==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcBS4-0003Md-NH; Mon, 09 Nov 2020 17:59:36 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcBRz-0003Jc-4H for linux-arm-kernel@lists.infradead.org; Mon, 09 Nov 2020 17:59:32 +0000 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 47E8920665; Mon, 9 Nov 2020 17:59:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604944769; bh=VB4W1R6Xidy63HPldBkvYgNymeTHvz90LHtlTza6wcQ=; h=From:To:Cc:Subject:Date:From; b=1WyyWxd6omZIqHS646zTRLqZpPKC0zBMKlpQ++0dgOSQlhLk+b4uq2Q45g3bt7jFP oWSo3EUsYmCs6w/muSDYPFB5Kmg2A1XuCLYVpmszzmdd08s+bMofK656RIoxq+7/VC mvacaEITP9Jz8ni9pNyFrBepc5qQ6ujtFysiCDvM= Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1kcBRv-009BQs-17; Mon, 09 Nov 2020 17:59:27 +0000 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Subject: [PATCH v2 0/5] KVM: arm64: Host EL2 entry improvements Date: Mon, 9 Nov 2020 17:59:18 +0000 Message-Id: <20201109175923.445945-1-maz@kernel.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, alexandru.elisei@arm.com, ascull@google.com, will@kernel.org, qperret@google.com, ndesaulniers@google.com, dbrazdil@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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201109_125931_338734_2DF8697C X-CRM114-Status: GOOD ( 15.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-team@android.com, Suzuki K Poulose , Will Deacon , Quentin Perret , ndesaulniers@google.com, James Morse , Andrew Scull , dbrazdil@google.com, Alexandru Elisei , Julien Thierry Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This small series reworks various bits of the host EL2 entry after Andrew's extensive rework to move from direct function calls to a SMCCC implementation. The first 2 patches allow the use of direct function pointers at EL2, something that we can't do at the moment (other than PC-relative addressing). This requires a helper to translate pointers at runtime, but the result is neat enough. This allows the rewrite of the host HVC handling in a more maintainable way. Note that this version now includes the result of a discussion with Nick, providing some funky pointer mangling in order to make the use of these pointers vaguely safer (no, they are not safe at all). Another patch removes the direct use of kimage_voffset, which we won't be able to trust for much longer. The last two patches are just cleanups and optimisations. * From v1 [1]: - Merged the 3 first patches as fixes - Added pointer mangling for function calls - Moved EL2 entry ldp a couple of instructions later (as suggested by Alex) - Rebased on top of -rc3 [1] https://lore.kernel.org/r/20201026095116.72051-1-maz@kernel.org Marc Zyngier (5): KVM: arm64: Add kimg_hyp_va() helper KVM: arm64: Turn host HVC handling into a dispatch table KVM: arm64: Patch kimage_voffset instead of loading the EL1 value KVM: arm64: Simplify __kvm_enable_ssbs() KVM: arm64: Avoid repetitive stack access on host EL1 to EL2 exception arch/arm64/include/asm/kvm_asm.h | 2 - arch/arm64/include/asm/kvm_mmu.h | 40 +++++ arch/arm64/include/asm/sysreg.h | 1 + arch/arm64/kernel/image-vars.h | 5 +- arch/arm64/kvm/hyp/nvhe/host.S | 11 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 232 +++++++++++++++++----------- arch/arm64/kvm/hyp/nvhe/sysreg-sr.c | 11 -- arch/arm64/kvm/va_layout.c | 56 +++++++ 8 files changed, 241 insertions(+), 117 deletions(-)