From patchwork Tue Sep 15 10:46:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Scull X-Patchwork-Id: 11776109 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 95C716CA for ; Tue, 15 Sep 2020 10:54:55 +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 EFE84206DB for ; Tue, 15 Sep 2020 10:54:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="oogce9qL"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="pCW2Jq+4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EFE84206DB 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=uiTdt0O7J0Ht7B1EXdkjVF8Sc1E4VMTC5A0dCRPEpSk=; b=oogce9qLuRqs4c3iD61PbazNiA 5rGoIAyRDGaoUk74gWSbxRgDKei+rSg9DBVPQdK3e/BHaZ0O+4eeLzMEVAQmvS4sz7gluFSkE6M0p +xGFVVyKms4/mgiw8dSslvcqHpvYLK2bmcVJSRv1SPLMimSLTFczaNdnxuz4jhgNgflur8jGOto0U NEN344k/PWLjFncUBRxdIhqX1Bz4jY39E7WEcfMgCOZ9UfHNQ951pKXIteYd81PRltFvutVabg203 o1K602s/5QM8NdQQVX0HdVIp31SxgyXoKyjAd6hxXRjkPl7DJuXYLc9v1fSnEbEo+1M/xwGl3O8hn ewn/qkiw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kI8bD-0003oK-C5; Tue, 15 Sep 2020 10:54:12 +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 1kI8U9-0000k6-V0 for linux-arm-kernel@lists.infradead.org; Tue, 15 Sep 2020 10:46:55 +0000 Received: by mail-wm1-x349.google.com with SMTP id u5so758191wme.3 for ; Tue, 15 Sep 2020 03:46:49 -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=q5iRRAj0SUsthOjBN2PJyc/yoW5r5Y3Rs945BK5S73I=; b=pCW2Jq+48EDIL/IC3ltwztUgjn5uEm1sV1tWhQgE1gH7ucq9gjhcdRebL2+yTmA+mK LFjoS8sKttmOQ+Eh4XSr0ceVlG4N4wje9xS/1557tc/Uv3CzaOO1LRd7nP/PJtYgNp7/ emwcmQHNfKwTZndNc412CUolKjToAutTlPim3TEOnJUXEfnOTfGiSuke9kDX6QUgKubQ yLzdxsucyAagIdbyTW98OlA6z7884I79DFdK2XvB4bax3jfd85Zqepy+U+R5jgWx1Rcq hhvGCA/vT9Fj93j1N3oVy2h2q0CEMnNQFUe+1+0yQqqmC20kvOa2VFIIJGpkQFBzc/Sv /sog== 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=q5iRRAj0SUsthOjBN2PJyc/yoW5r5Y3Rs945BK5S73I=; b=oAPIXH9yeY7wf24uTIIJRDnnBS4FEO2IenkJ1JrIwgMpfScHHPx5wuxhR+jCWElW1k 3/93FtFaUFRDQcR6flaoMvtzG/0onc0rdALKKM8mRGyyhXRYp1thbJWqVXdKq42FpMNk q4ci/J4fF82sFi9/9z7Q0mXEKbCDegyDWniL8Nnppp1vL1iiMSvLqICLvuUd/Lv+Ytyr Y7pZ4mAzVFd9EnOLgtfv1DutaXzWH4tn2kUeKmSJziDkaopeDXObPXc+Qmv3a84ZPUfI FZxiUmtBWwsvhiHmnxeItYKDr+cn83iB9VLG5UisiXgNtbLDCPitrbp2/ml9FRO53X4Z qtvQ== X-Gm-Message-State: AOAM533o7X7Vlv6PiLdesgopJTwRZG9Dj216YkL4UzCmixjC51KD0nrr i8/4j+wzTCpsWQS5sOimXnGl5gnmu2M= X-Google-Smtp-Source: ABdhPJwHZNc4IJ9YyBn/VOmidrd8JTUW1eIIQzrcOUj/V9w2IOUcSO1J6wpFQnqAWwHLRZTrZeCtrg//mOo= X-Received: from ascull.lon.corp.google.com ([2a00:79e0:d:109:4a0f:cfff:fe4a:6363]) (user=ascull job=sendgmr) by 2002:a7b:c38f:: with SMTP id s15mr4180830wmj.16.1600166808236; Tue, 15 Sep 2020 03:46:48 -0700 (PDT) Date: Tue, 15 Sep 2020 11:46:24 +0100 Message-Id: <20200915104643.2543892-1-ascull@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [PATCH v4 00/19] 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-20200915_064654_159674_C1537741 X-CRM114-Status: GOOD ( 17.48 ) 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] -0.0 SPF_PASS SPF: sender matches SPF record -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list 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_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's 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. Topics include: - RAS for nVHE - Panicking from guest vectors with SCS - Switching to hyp context - Migrating hyp interface off of function pointers First 4 patches are small refactors. Then an exception vector is added just for the nVHE host to untangle the existing EL2 vector e.g. to separate the RAS cases. Hyp panics from the guest context, e.g. from an invalid vector, are fixed so they have a chance of completely cleanly with features that depend on register state such as x18 for shadow call stack (SCS) enabled on VHE. Finally, 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. From v3: - https://lore.kernel.org/kvmarm/20200903135307.251331-1-ascull@google.com/ - Rebased onto 5.9-rc4 - Addressed review comments From v2: - https://lore.kernel.org/kvmarm/20200820103446.959000-1-ascull@google.com/ - Rebased onto 5.9-rc3. - Removed some of the unused separation of host and hyp. 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 *** BLURB HERE *** Andrew Scull (19): KVM: arm64: Remove __activate_vm wrapper KVM: arm64: Remove hyp_panic arguments KVM: arm64: Remove kvm_host_data_t typedef KVM: arm64: Choose hyp symbol based on context 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: 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 KVM: arm64: nVHE: Pass pointers consistently to hyp-init smccc: Define vendor hyp owned service call region smccc: Use separate variables for args and results KVM: arm64: nVHE: Migrate hyp interface to SMCCC KVM: arm64: nVHE: Migrate hyp-init to SMCCC KVM: arm64: nVHE: Fix pointers during SMCCC convertion arch/arm64/include/asm/kvm_asm.h | 100 ++++++++++++- 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 | 76 +--------- arch/arm64/kvm/hyp/include/hyp/switch.h | 15 +- arch/arm64/kvm/hyp/nvhe/Makefile | 2 +- arch/arm64/kvm/hyp/nvhe/host.S | 187 ++++++++++++++++++++++++ arch/arm64/kvm/hyp/nvhe/hyp-init.S | 67 +++++---- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 117 +++++++++++++++ arch/arm64/kvm/hyp/nvhe/switch.c | 41 +++--- arch/arm64/kvm/hyp/nvhe/tlb.c | 2 - arch/arm64/kvm/hyp/vhe/switch.c | 24 +-- arch/arm64/kvm/vgic/vgic-v3.c | 4 +- include/linux/arm-smccc.h | 74 ++++------ 20 files changed, 602 insertions(+), 315 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