From patchwork Wed Feb 1 10:37:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 13124130 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7709CC636D3 for ; Wed, 1 Feb 2023 10:39:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: Mime-Version: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=WegQWHYLVkxfXdHxGWKt6CVb2xe2sVzqBbLIRBiquWU=; b=JFi rBHPpqk7x+8fyMAtt2RpGOyFiZUNyqNJDPG3PaPHgY7eCiOSFdzQVShhqD1sQOWvOC4CzOndNDVyD pyCg54tc/5BU3BcdjsJWOPICmW6nvDkMbMuHsfQCQZ4qvplLJB511aOIuYThx1MnyJ944Mo6ziEHf VZKwrJD8PQhe7rVYjbqzd3buPreiV2gVmR4tq1qVp1xxJJWOGkGoMSeuQRWpv8MCHQ2oqmBy16H6K WLCq0jI0VMBitUWwPap5SWK+bqV4S+XTSqNVoqn5J7cKssgJ8rUf8b47uRmUtx5ScQ/rbA3CIK4eW iH3ArVbA2D2op8974N8W6xMNmOCql9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNAVJ-00BHGX-I2; Wed, 01 Feb 2023 10:38:13 +0000 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNAV8-00BHDY-S6 for linux-arm-kernel@lists.infradead.org; Wed, 01 Feb 2023 10:38:04 +0000 Received: by mail-wm1-x34a.google.com with SMTP id e38-20020a05600c4ba600b003dc434dabbdso846643wmp.6 for ; Wed, 01 Feb 2023 02:38:00 -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=YDrhtlZLraH3sgauk4LvjFHAgnRxH9SSxLvW2HBD+7rVt+2SP4C70wJcl864kKwHHd iJ6rkj6ITDjvnkPtvld1Xd3Q4mUWwBdFn4fyy9sTQtxnu5ymxQ2GIu/8POf/dasMXpnj EBVcoiOHo0qlRMpBxvIKhzR0uANyJA32/F2OzqAVwlbxQ0xwBKAoRgmtPbKr4qiBSgvw fEZnaMCHAQWWX0EV4jN3bPhMem5KX1XSVawYyYVftYu+Y8tCLSvmcORTj+CAXwJDUrui NEd0q8WEGLYJRlc9K/KHv0I+I5QNtWc1rnuQEgWCXfRVgTSMKG+ppldFqFs7Czez02sE rQdg== X-Gm-Message-State: AO0yUKXiu69zxHOiKsLUeRynn6kCvQp46IOJKC14CZZI5svtoEU5yLGd NZFq9A9du5oWWicImthinmRl9yb+gAjA X-Google-Smtp-Source: AK7set9OO31MOIG5ytUAh8LFORGHH4kWKzwK1XEnu8LH1geO7NiaHrTAAjdFjC0NALlJrHjXuGZHsPmGikuT 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 To: Catalin Marinas , Will Deacon , Marc Zyngier , James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Mark Brown 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230201_023802_944584_FE884CB4 X-CRM114-Status: GOOD ( 10.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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(-) Reviewed-by: Marc Zyngier