Message ID | 20230201103755.1398086-1-qperret@google.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp211994wrn; Wed, 1 Feb 2023 03:10:13 -0800 (PST) X-Google-Smtp-Source: AK7set9/262CIOFzagbmt8sIayOHseSqjkqriOs+BUxvQ+4ZSR+6x+cYI51ZknRfBi2omYAAbekI X-Received: by 2002:a05:6a00:18a2:b0:572:6e9b:9f9e with SMTP id x34-20020a056a0018a200b005726e9b9f9emr2842372pfh.19.1675249813154; Wed, 01 Feb 2023 03:10:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675249813; cv=none; d=google.com; s=arc-20160816; b=XP/gF8NWeK54whH6/YU/ZYDbwaeP/ZRp7aYuNd3v9tfcNkzD1JRJ3fui/aVOX0nfQx VWdL/YFMFCT3DWqJViLqRTt2HeDWm20QBcgr2+Oi7U9Z36JoMPX9eHIw9CNP9XNlCh6R ZDDNbEV3Y9OC4zNGYgcMv+airSegXAlA/8FsrxnGVizE5ZPu1Kxc4MyF5SrmufpJ6C18 XbytFMLVKgcRoH6b213yxrEnTPsyibM/9mQ7CCgCFYNcEkDDXy8VQN1XRMna8A/PFkFN PNNhQ7STxzltmj0r9T6qTCaejXNDT21pQO1a7U25cEMJjUQn6xoykdjtDqRsW8pixHJr nu8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=s4zWblSgk9sC59/aeD2C4zXhl1NkdUvsWjCEZ+kae5w=; b=uFXkA2+QrHxqsyRQE58rtmrjaVdcJxEd761c49DLuQRAx1CltH7nKNgK0kZdWP9xir eB5bQxAqsD0fcuZ+LotlbBl1c0CvdD1zStHqOdJ5Usfm9vd3K+bRZ5voAB0nEqDiDcAq FnjR24wRGgTT4uYLXq/Lcg+jG3JmZCWV2Lum9emA3uIEeeStvjYQE0fhF5sGlRwOT/rB xHPOlpg9atl9IZNVAfEpwsKuSQbQ08NIYsGfP6ut7dyE6BydCSGFJ8yegB8PeKEolUDM MMm/yw3ZI4F1mNVlJCADgEe/ADa4Qwdoqo42AxUnQP0Iw1Ku2heC390Qzg6ZGjuIE0G0 Dsog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=kDd5sNOx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 124-20020a621882000000b0057374ca3be1si19348386pfy.151.2023.02.01.03.10.00; Wed, 01 Feb 2023 03:10:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=kDd5sNOx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232124AbjBAKiq (ORCPT <rfc822;duw91626@gmail.com> + 99 others); Wed, 1 Feb 2023 05:38:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232099AbjBAKiN (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 1 Feb 2023 05:38:13 -0500 Received: from mail-wr1-x44a.google.com (mail-wr1-x44a.google.com [IPv6:2a00:1450:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A94E8686 for <linux-kernel@vger.kernel.org>; Wed, 1 Feb 2023 02:38:01 -0800 (PST) Received: by mail-wr1-x44a.google.com with SMTP id j25-20020adfd219000000b002bfd1484f9bso2333895wrh.2 for <linux-kernel@vger.kernel.org>; Wed, 01 Feb 2023 02:38:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=s4zWblSgk9sC59/aeD2C4zXhl1NkdUvsWjCEZ+kae5w=; b=kDd5sNOxRKfGTyQyrwC8Z9FLlQkrpsj/Nng2DTWB6IJUir3WQndNIexufILUN++wdV JDwcGHttIbcRuSGZu7j9qulGqGELbopzYZ3m8BIvsoLl5QqurHIf6HGUOy+1AH4o06Ba VNDrWbdJVT7ESS5kjdleefmF0NLuB3WcOoOJtsonsWVaNaBJDrHQTAgCuYmv5i/ph5Zl UR2zJtbSKKV85ivzBHyqklZSKeSB/QSPrTRbPWkBl7+94vRWUCwYOn/R+g7PNWGcQH08 xrRKBM3IyQbvObsc3VmNRqTfnUlUIxxqTU0sIC/IIuFBnorDytqD1S3czSqHoRXsHpoc XzaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=s4zWblSgk9sC59/aeD2C4zXhl1NkdUvsWjCEZ+kae5w=; b=Walh0lLKd/JI9ZpCLBh674MGd4MKRJZtX52YkbYD/HN/YL/aT9g39PHuWDKZPN/O1K bEvFxsJZ+k+6ED8t+MBSKRuWtwsRWD4CFer3lsgtwDnzfa0bgqIRFRSQuhfor89X6XPX ZRcrf19NfqJSzCyfSJGLCPp8GUgquBq/lO72cMdRS2fDsR8lP4F6B5PKijkobke2jQeR bmLjZaFAP4UL21kCFgBp/cpAX2AKOkpwhcvXT1WudtSzwUOf6BVJ3cQ97FCHMoZykfN2 QAykv89uBy+fwwHiUneIX9BaGEwv8+cx8KQAGcqmZUAE3MGCPoVjfrqYArRN656K+Jx1 8fNQ== X-Gm-Message-State: AO0yUKV6i4xFqtJSswj/LQbBxj7Ol/gOgxfNGhPX9OU36ZDURQY2gRBX QBU7hCtjd03bqt018zr1P6Ct3P6epb0+ X-Received: from big-boi.c.googlers.com ([fda3:e722:ac3:cc00:31:98fb:c0a8:129]) (user=qperret job=sendgmr) by 2002:a05:600c:170a:b0:3dc:5240:a87b with SMTP id c10-20020a05600c170a00b003dc5240a87bmr145717wmn.12.1675247879605; Wed, 01 Feb 2023 02:37:59 -0800 (PST) Date: Wed, 1 Feb 2023 10:37:50 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog Message-ID: <20230201103755.1398086-1-qperret@google.com> Subject: [PATCH 0/4] KVM: arm64: Fix CPU resume/on with pKVM From: Quentin Perret <qperret@google.com> To: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>, James Morse <james.morse@arm.com>, Suzuki K Poulose <suzuki.poulose@arm.com>, Oliver Upton <oliver.upton@linux.dev>, Zenghui Yu <yuzenghui@huawei.com>, Mark Brown <broonie@kernel.org> Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, kernel-team@android.com, Quentin Perret <qperret@google.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756626748168900535?= X-GMAIL-MSGID: =?utf-8?q?1756626748168900535?= |
Series | KVM: arm64: Fix CPU resume/on with pKVM | |
Message
Quentin Perret
Feb. 1, 2023, 10:37 a.m. UTC
When using pKVM, we do not reset the EL2 exception vectors back to the stubs for e.g. Power Management or CPU hotplug as we normally do in KVM. As consequence, the initialisation perfomed by __finalise_el2 is missing on e.g. the CPU_RESUME path with pKVM, hence leaving certain registers in an incorrect state. One such example is ZCR_EL2 which remains configured with SVE traps enabled. And so using SVE on a CPU that has gone through a hotplug off/on cycle leads to a hyp panic. Not good. This series fixes this by macroizing the first half of __finalise_el2 (that is, the part that is not specific to VHE) to allow its re-use from pKVM's PSCI relay. Quentin Perret (4): KVM: arm64: Provide sanitized SYS_ID_AA64SMFR0_EL1 to nVHE KVM: arm64: Introduce finalise_el2_state macro KVM: arm64: Use sanitized values in __check_override in nVHE KVM: arm64: Finalise EL2 state from pKVM PSCI relay arch/arm64/include/asm/el2_setup.h | 92 ++++++++++++++++++++++++++++++ arch/arm64/include/asm/kvm_hyp.h | 1 + arch/arm64/kernel/hyp-stub.S | 79 +------------------------ arch/arm64/kvm/arm.c | 1 + arch/arm64/kvm/hyp/nvhe/hyp-init.S | 1 + arch/arm64/kvm/hyp/nvhe/sys_regs.c | 1 + 6 files changed, 98 insertions(+), 77 deletions(-)
Comments
On Wed, 01 Feb 2023 10:37:50 +0000, Quentin Perret <qperret@google.com> wrote: > > When using pKVM, we do not reset the EL2 exception vectors back to the > stubs for e.g. Power Management or CPU hotplug as we normally do in KVM. > As consequence, the initialisation perfomed by __finalise_el2 is missing > on e.g. the CPU_RESUME path with pKVM, hence leaving certain registers > in an incorrect state. > > One such example is ZCR_EL2 which remains configured with SVE traps > enabled. And so using SVE on a CPU that has gone through a hotplug > off/on cycle leads to a hyp panic. Not good. > > This series fixes this by macroizing the first half of __finalise_el2 > (that is, the part that is not specific to VHE) to allow its re-use > from pKVM's PSCI relay. For the series: Reviewed-by: Marc Zyngier <maz@kernel.org> I think it might be a bit late to send this as fixes for 6.2 (my latest pull request for kvmarm-fixes-6.2-3 is still in limbo), so I'd suggest we take it for 6.3. How do you want to deal with the backports? None of the patches have a Cc: stable, and only the last one has a Fixes: tag, but cannot be applied standalone. Thanks, M.
On Wednesday 01 Feb 2023 at 14:48:03 (+0000), Marc Zyngier wrote: > On Wed, 01 Feb 2023 10:37:50 +0000, > Quentin Perret <qperret@google.com> wrote: > > > > When using pKVM, we do not reset the EL2 exception vectors back to the > > stubs for e.g. Power Management or CPU hotplug as we normally do in KVM. > > As consequence, the initialisation perfomed by __finalise_el2 is missing > > on e.g. the CPU_RESUME path with pKVM, hence leaving certain registers > > in an incorrect state. > > > > One such example is ZCR_EL2 which remains configured with SVE traps > > enabled. And so using SVE on a CPU that has gone through a hotplug > > off/on cycle leads to a hyp panic. Not good. > > > > This series fixes this by macroizing the first half of __finalise_el2 > > (that is, the part that is not specific to VHE) to allow its re-use > > from pKVM's PSCI relay. > > For the series: > > Reviewed-by: Marc Zyngier <maz@kernel.org> > > I think it might be a bit late to send this as fixes for 6.2 (my > latest pull request for kvmarm-fixes-6.2-3 is still in limbo), so I'd > suggest we take it for 6.3. Works for me. > How do you want to deal with the backports? None of the patches have a > Cc: stable, and only the last one has a Fixes: tag, but cannot be > applied standalone. Right, I wasn't sure what was best -- the first patches aren't really fixing anything per se but yeah, we kinda need them... Happy to re-post a version with the same 'Fixes:' tag on all patches and 'Cc: stable' everywhere if that makes things easier. Wdyt? Cheers, Quentin
On Wed, Feb 01, 2023 at 04:57:09PM +0000, Quentin Perret wrote: > On Wednesday 01 Feb 2023 at 14:48:03 (+0000), Marc Zyngier wrote: > > How do you want to deal with the backports? None of the patches have a > > Cc: stable, and only the last one has a Fixes: tag, but cannot be > > applied standalone. > > Right, I wasn't sure what was best -- the first patches aren't really > fixing anything per se but yeah, we kinda need them... > > Happy to re-post a version with the same 'Fixes:' tag on all patches and > 'Cc: stable' everywhere if that makes things easier. Wdyt? I'd like to get these patches cooking in -next so I'll probably just take what you've posted.
On Wed, 1 Feb 2023 10:37:50 +0000, Quentin Perret wrote: > When using pKVM, we do not reset the EL2 exception vectors back to the > stubs for e.g. Power Management or CPU hotplug as we normally do in KVM. > As consequence, the initialisation perfomed by __finalise_el2 is missing > on e.g. the CPU_RESUME path with pKVM, hence leaving certain registers > in an incorrect state. > > One such example is ZCR_EL2 which remains configured with SVE traps > enabled. And so using SVE on a CPU that has gone through a hotplug > off/on cycle leads to a hyp panic. Not good. > > [...] Applied to kvmarm/next, thanks! [1/4] KVM: arm64: Provide sanitized SYS_ID_AA64SMFR0_EL1 to nVHE https://git.kernel.org/kvmarm/kvmarm/c/8669651ce0d9 [2/4] KVM: arm64: Introduce finalise_el2_state macro https://git.kernel.org/kvmarm/kvmarm/c/e2d4f5ae1771 [3/4] KVM: arm64: Use sanitized values in __check_override in nVHE https://git.kernel.org/kvmarm/kvmarm/c/3c4cc31537ec [4/4] KVM: arm64: Finalise EL2 state from pKVM PSCI relay https://git.kernel.org/kvmarm/kvmarm/c/6f10f2ec61c7 -- Best, Oliver