From patchwork Thu Aug 20 10:34:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Scull X-Patchwork-Id: 11726009 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 39D1013B1 for ; Thu, 20 Aug 2020 10:35:47 +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 1181A2078D for ; Thu, 20 Aug 2020 10:35:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Rftkv3qD"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="k5APOp+X" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1181A2078D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.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:To:From:Subject:Mime-Version:Message-Id:Date: 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=PakKObOogop4AsBTzwzfDE+6qnLJpY9x/ffpOOxs05c=; b=Rftkv3qDAzx+OCD/8QDD8tsqFk DAtpq/z4GEO3CgMhiwZN+HK51vZ8nH2dOQWDvJjOYIRl+GZVXCb6QKYdLoo4oT0zl2+N6F2PvFsAH 6W++b0mvl2UWYsW4myIb1t1Yf5mepZGxC3F7CaelaJghDbFeU0uDSgMCcwV9JIa3wHj/92wdXStfs ohyMk2vxDgCDYsPhZcYZIrZXvYhRdexNGZHEnH0yQxMd5m/bZmJRubKXIoSCFbqFRdH1x0DwqbR6p klzsOHMpsB4fAQFAo34z9azH432ps3WUh9WflhJyNgRBii9m1dFZ1zg85Udzwh+FngRJhGyKzK9Jt O5LtL2qw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8huo-0001xu-Fx; Thu, 20 Aug 2020 10:35:26 +0000 Received: from mail-wm1-x349.google.com ([2a00:1450:4864:20::349]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8hul-0001xN-HJ for linux-arm-kernel@lists.infradead.org; Thu, 20 Aug 2020 10:35:24 +0000 Received: by mail-wm1-x349.google.com with SMTP id p23so814961wmc.2 for ; Thu, 20 Aug 2020 03:35:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=roKza3OkfK9qcZNG3qmxeeQQHwHPlHxDLrwJREVN+jY=; b=k5APOp+X7954cRuBlSgSvvTmDsVBfbcBplTzg0SSnPyEE7dhYFN+VdiJCSQPR+07cb Nvbkt1+THK1iVcQnp3K+uGDSRpAZfc+RRw9BYjkTQ49/CplNabTPHPn0xG+Vzuvl8MNh 51NyxISNS0jYK9hgiOxqYFAIm4s4myZbu8QMBaM8k5Ob6leNVrSmP3WwYgw1kUx8kDsZ u4ORCB6SmLiWfDERaQVbOAyMpvYVw5gsAi/K/Y7WIoGoAxMbOo4wYBClpa0q/3rPhNiZ cJAfd/SqzB4ab6E+XkdFv/0zAp+GjorHTMFy0H3XS6K2mYu8oQmw/zvKA5MruFz4Jzyx K5gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=roKza3OkfK9qcZNG3qmxeeQQHwHPlHxDLrwJREVN+jY=; b=CmjIkA8fc4OXSex+0tVEuMhajjl8sFFnLKAGoDIh6QKU0CE+xBUZgACh+E3xp3dE8i qV/VUTk26ZPyG059S/GXrgF4g/OLtZG+X8l0UyF59a26HgG9j3NrHKOl3LbYP/Zt201o oB3Mi2cdFtsJgP23hA+q0CF3nkkQP+EJalvGIMWzdLTYpevxIjJdX8+gjQMsLXa9SO/U y+qr4zCaj5jIh0VxsFXNSRy8hKYXRa53y/nF7yBJ09VS+baRBrqlZV0XfQ7eUSHoXtF6 /ZYQf2rSYHR+Nu0MNhon2oRmY7FF+gj0VnlJysMb5smiDaX87C4/YnqawoLYsQdQQ/J8 vhxQ== X-Gm-Message-State: AOAM533Mkmr7agQx3nQJCBdRPwzR/InZJGKXat4wR/YAmmSbeTzxMfmD UXNmBL2CqZrck2yZ4xEE0ZRnHVW98O4= X-Google-Smtp-Source: ABdhPJzkMIHwFjPe2Er10blaW+o9uH+JH+Lopx4PDaqRilCeGhqNxB96dpkqGuO/lQKfISkrAI9EW3U0pFY= X-Received: from ascull.lon.corp.google.com ([2a00:79e0:d:109:4a0f:cfff:fe4a:6363]) (user=ascull job=sendgmr) by 2002:a7b:c20a:: with SMTP id x10mr2435124wmi.78.1597919720187; Thu, 20 Aug 2020 03:35:20 -0700 (PDT) Date: Thu, 20 Aug 2020 11:34:26 +0100 Message-Id: <20200820103446.959000-1-ascull@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [PATCH v2 00/20] Introduce separate nVHE hyp context From: Andrew Scull To: kvmarm@lists.cs.columbia.edu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200820_063523_610603_99A9EE76 X-CRM114-Status: GOOD ( 17.66 ) X-Spam-Score: -7.7 (-------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-7.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:349 listed in] [list.dnswl.org] -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_MED DKIMwl.org - Medium sender 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: linux-arm-kernel@lists.infradead.org, kernel-team@android.com, suzuki.poulose@arm.com, maz@kernel.org, Sudeep Holla , james.morse@arm.com, Andrew Scull , catalin.marinas@arm.com, will@kernel.org, julien.thierry.kdev@gmail.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org As a step on the way to isolating hyp from the host on nVHE as part of Android's "Protected KVM" project, this series introduces a separate register context for hyp visiting these topics on the way: - RAS for nVHE - Panicking from guest vectors with SCS - Switching to hyp context - Migration hyp interface off of function pointers After four small refactors, focus turns to adding a new exception vector for the nVHE hyp to use with the host. With this new freedom, the erroneous consumption of the host's RAS errors by nVHE is corrected. Following this, attention turns to fixing hyp panics from the guest context, e.g. an invalid vector, so they have a chance of completely cleanly with features such as shadow call stack (SCS) enabled on VHE. Then, hyp is made to switch to its own context rather than borrowing the host context before migrating the hyp interface from raw function pointers to SMCCC based functions IDs. This series is based on v5.8-rc1 and has been tested on a VIM 3L. From v1: - https://lore.kernel.org/kvmarm/20200715184438.1390996-1-ascull@google.com/ - HVC microbenchmark overhead cut from over 15% to under 6%. - Abandon the symmetry of a run loop in hyp and treating the host as a vCPU as there was little practical benefit for the overhead it introduced. Cc: Marc Zyngier Cc: James Morse Cc: Suzuki Poulose Cc: Sudeep Holla Cc: Will Deacon Cc: Catalin Marinas Cc: kernel-team@android.com Cc: kvmarm@lists.cs.columbia.edu Cc: linux-arm-kernel@lists.infradead.org Andrew Scull (20): KVM: arm64: Remove __activate_vm wrapper KVM: arm64: Remove hyp_panic arguments KVM: arm64: Remove kvm_host_data_t typedef KVM: arm64: Restrict symbol aliasing to outside nVHE KVM: arm64: Save chosen hyp vector to a percpu variable KVM: arm64: nVHE: Use separate vector for the host KVM: arm64: nVHE: Don't consume host SErrors with ESB KVM: arm64: Preserve host DISR_EL1 KVM: arm64: Introduce hyp context KVM: arm64: Update context references from host to hyp KVM: arm64: Restore hyp when panicking in guest context KVM: arm64: Share context save and restore macros KVM: arm64: nVHE: Switch to hyp context for EL2 KVM: arm64: nVHE: Handle hyp panics smccc: Cast arguments to unsigned long KVM: arm64: nVHE: Pass pointers consistently to hyp-init KVM: arm64: nVHE: Migrate hyp interface to SMCCC KVM: arm64: nVHE: Migrate hyp-init to SMCCC KVM: arm64: nVHE: Fix pointers during SMCCC convertion KVM: arm64: nVHE: Handle stub HVCs in the host loop arch/arm64/include/asm/kvm_asm.h | 78 ++++++++++ arch/arm64/include/asm/kvm_host.h | 26 ++-- arch/arm64/include/asm/kvm_hyp.h | 9 +- arch/arm64/include/asm/kvm_ptrauth.h | 6 +- arch/arm64/kernel/image-vars.h | 2 + arch/arm64/kvm/Makefile | 2 +- arch/arm64/kvm/arm.c | 34 +++- arch/arm64/kvm/hyp.S | 34 ---- arch/arm64/kvm/hyp/entry.S | 95 +++++------- arch/arm64/kvm/hyp/hyp-entry.S | 83 +--------- arch/arm64/kvm/hyp/include/hyp/switch.h | 9 +- arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 16 +- arch/arm64/kvm/hyp/nvhe/Makefile | 2 +- arch/arm64/kvm/hyp/nvhe/host.S | 156 +++++++++++++++++++ arch/arm64/kvm/hyp/nvhe/hyp-init.S | 80 ++++++---- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 171 +++++++++++++++++++++ arch/arm64/kvm/hyp/nvhe/switch.c | 37 ++--- arch/arm64/kvm/hyp/nvhe/tlb.c | 2 - arch/arm64/kvm/hyp/vhe/switch.c | 18 ++- arch/arm64/kvm/vgic/vgic-v3.c | 4 +- include/linux/arm-smccc.h | 20 +-- 21 files changed, 606 insertions(+), 278 deletions(-) delete mode 100644 arch/arm64/kvm/hyp.S create mode 100644 arch/arm64/kvm/hyp/nvhe/host.S create mode 100644 arch/arm64/kvm/hyp/nvhe/hyp-main.c