From patchwork Thu Sep 3 13:52:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Scull X-Patchwork-Id: 11753631 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 D7C7F618 for ; Thu, 3 Sep 2020 13:53:29 +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 AAF56208C7 for ; Thu, 3 Sep 2020 13:53:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="muhBPVN4"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="Am4pM3dw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AAF56208C7 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=CIGM9d1wedWrFjANZamcLgbsNhZPn2GtDkXAIeJIISI=; b=muhBPVN4IZz9xd7qrl0H9DPKbd QsyBVy1Ub6zjHS3spaBtwP82+jPt1c9WKnM14Lq6naosKqkUPgrIiZTKr6f7Qh9t7WrHI+0bxTq2u ODhP30ZR9zIiu9SZi2WDRIcQTDe8OTPWbjWTzOIWXtHd6aIMNZ/2iNLrJhOL8Ot1qd/+MNENQlVsD Z3yVlTQ3RGrHpoANuNKwpSrdL1+F+gRH2VL8h0/6YYyZyB1XqO8g2TDZe8Mq0+6kYefwe9nI6dfvX DSLSQQ3cSk4U7RfWkT/wWFbKR03tBDtWGssBLimxYeEjXE4ebUVFJyD8VHFbuyCkgSp9NvKYfXH3c pnB735ig==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDpfy-0001uU-S9; Thu, 03 Sep 2020 13:53:18 +0000 Received: from mail-qt1-x849.google.com ([2607:f8b0:4864:20::849]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDpfw-0001t3-Bu for linux-arm-kernel@lists.infradead.org; Thu, 03 Sep 2020 13:53:17 +0000 Received: by mail-qt1-x849.google.com with SMTP id e6so2163018qtg.13 for ; Thu, 03 Sep 2020 06:53:13 -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=oARo4br58HswRBa/XJtx2f6i8RkRRLNeOBdf/wy5IPE=; b=Am4pM3dwLxj0G271v/o7CMB2X/Kt0OI71p6MGo1VcGYDoN0edf/GoOBGZt2wSVyMVC 2kkskUq7OlW9LQtviHOHIBO+jcnUeqss2FbF+Scszuc1CzOVYcvV7h85fM7GkcY51pU5 ntuBPWFhFuUswHgMvAXL6ppYrhHhMo842SB9RN1ddvwfn2mdo9BzmyhuHbE0t398ao3M 4d/DHB/M3q4WHKAyBCXz1xuwsbm67u0vAsjh3hpaR1ht9tyKRdQrue72Q9dR4g1PrCEg lwE/JPJw+Uhgzh90LXl+3cj+kbfLsD5yICm6jan7C52ph1qFWZ9EuJ1awxIeeYF/j9Kp Zhcw== 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=oARo4br58HswRBa/XJtx2f6i8RkRRLNeOBdf/wy5IPE=; b=Jsyxnv5E4nVc/f6KxEuuHoC+hKxevkoBhHOYNMDyEQvIDTD7hkqJ0Hhv3o8lLa0bsU JPJEJTLh/J2CmQ6B0qbysfs6XQiya5NfJvzPdmaJr/E8OHhW1KfU/g0+TbKnMC5XW1bE 5KZwHL+0w4Aca9J8vn3dQ8Go/eRabqjWNMcI4Ao0KLVbHdRq2aEyBjWTlqlJc9mngBKL hYZYjB1+Jyxk8CqFLMqBTYRMTtgFOrHnHDmh+8QhS0sK0A2mYowo2pGQgZ4Qt7RmWih5 QlT7ww/lPjU0lEpsrBASqFeA2ffr9BA77iWVLXJMBz+M9NifphR5PnQBRRxkMla11GPU KLcg== X-Gm-Message-State: AOAM5300qphtMp/Dh5oej/rliKq+yWc9iFk92OGYSzveKCzcfSn6vC7K O0bDqAKMtoU/alKytZ1aeSdgoYradHE= X-Google-Smtp-Source: ABdhPJzRKjkOQJpZOgNieiBEmg3ydMZMhOsCCF5jheIUU7hLmGsXYeDZZxPV7z8Y+tAX/0e42AQK4E6EdKQ= X-Received: from ascull.lon.corp.google.com ([2a00:79e0:d:109:4a0f:cfff:fe4a:6363]) (user=ascull job=sendgmr) by 2002:a0c:f887:: with SMTP id u7mr1033416qvn.124.1599141191218; Thu, 03 Sep 2020 06:53:11 -0700 (PDT) Date: Thu, 3 Sep 2020 14:52:49 +0100 Message-Id: <20200903135307.251331-1-ascull@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [PATCH v3 00/18] 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-20200903_095316_458503_E346AD3B X-CRM114-Status: GOOD ( 17.07 ) X-Spam-Score: -8.2 (--------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-8.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:849 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_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.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.5 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. Topic include: - RAS for nVHE - Panicking from guest vectors with SCS - Switching to hyp context - Migration 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 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 Andrew Scull (18): 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: 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 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 | 76 +--------- arch/arm64/kvm/hyp/include/hyp/switch.h | 15 +- arch/arm64/kvm/hyp/nvhe/Makefile | 2 +- arch/arm64/kvm/hyp/nvhe/host.S | 180 ++++++++++++++++++++++++ arch/arm64/kvm/hyp/nvhe/hyp-init.S | 67 +++++---- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 122 ++++++++++++++++ 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 +-- 20 files changed, 558 insertions(+), 271 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