Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4092504pxb; Mon, 4 Oct 2021 17:20:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVfQJ6ePRn87seqBvHcOFwCLA2X5DyXesMHyawu+R6MZVR/VZE4JxJQXHHyrhK7A8jDf2x X-Received: by 2002:a50:c04e:: with SMTP id u14mr21838344edd.235.1633393207148; Mon, 04 Oct 2021 17:20:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633393207; cv=none; d=google.com; s=arc-20160816; b=wDts8s00mfiRY9rAohbZlKOBWDv5QntNQCd1Ge+4Tfunn34pSFBysw5Z9+fDXgoZNQ WLxtmrHG9LGzCV/NH4WsUFoBpjiYqEccY5F5qkc1rd0RIGpge8yALXcK6FQOkmzpdy1U EyOfYi0zZsy9cTx8GN9J33+r6EH752lnXWhAKt5Vv0Y1E5MV5ICdjC5kcCKA2vvimHzU NDdAPRQ20E6ry2DAo65uXxvWYtjofCWuCNB9i1NAr0pCSc/obtMLkiLPa4Wx5X+Y/X53 l88le6Czl2uqdf+DKqSkgH7B+6Wjd8GxWufOqs5PywM4GNWt7r3qrEwEig+YpVRHwwIO zRsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Xj4JwB4kWkuG/z25OsWmjVkOfRniZNfLqIXfxRm7zoE=; b=aKBdWL9+leNmUjqEF4hgxpOej8SFBynxFT5MFaR3H1R7t0nbaxw4BbbuGeYvJslcnA vTOBRRkkDiklwQa1UdSqmRdVoaBcBJrBB1eXMz0vHgQK0lQTDlgUbBnr6vpCvwVkTc7x vdQL9GwuP411awSghdNjqX+9skXpjvJJCWyDbvQC1m9kokCd5X4mJyFHQzFZDxeSGU6Y VW6F9upeWc6XPBVDgqKUzFSXRWs7BZVtr0toY8km77sJAJu3R0MqCTbjT1jGBIu5Upzk UyzgroERSwIkOPdgiV0ns9nMqfSCiXwEHQ0o/ryHLkGb6t7Ui0D68oWSdweGabjBxPSX KxpA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p4si21341127edj.221.2021.10.04.17.19.43; Mon, 04 Oct 2021 17:20:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233928AbhJDRvV (ORCPT + 99 others); Mon, 4 Oct 2021 13:51:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:32922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235334AbhJDRu4 (ORCPT ); Mon, 4 Oct 2021 13:50:56 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 350BC6124D; Mon, 4 Oct 2021 17:49:03 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mXS5F-00EhBv-7V; Mon, 04 Oct 2021 18:49:01 +0100 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: will@kernel.org, qperret@google.com, dbrazdil@google.com, Steven Price , Andrew Jones , Fuad Tabba , Srivatsa Vaddagiri , Shanker R Donthineni , James Morse , Suzuki K Poulose , Alexandru Elisei , kernel-team@android.com Subject: [PATCH v2 06/16] KVM: arm64: Force a full unmap on vpcu reinit Date: Mon, 4 Oct 2021 18:48:39 +0100 Message-Id: <20211004174849.2831548-7-maz@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211004174849.2831548-1-maz@kernel.org> References: <20211004174849.2831548-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, will@kernel.org, qperret@google.com, dbrazdil@google.com, steven.price@arm.com, drjones@redhat.com, tabba@google.com, vatsa@codeaurora.org, sdonthineni@nvidia.com, james.morse@arm.com, suzuki.poulose@arm.com, alexandru.elisei@arm.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As we now keep information in the S2PT, we must be careful not to keep it across a VM reboot, which could otherwise lead to interesting problems. Make sure that the S2 is completely discarded on reset of a vcpu, and remove the flag that enforces the MMIO check. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/psci.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/kvm/psci.c b/arch/arm64/kvm/psci.c index 74c47d420253..6c9cb041f764 100644 --- a/arch/arm64/kvm/psci.c +++ b/arch/arm64/kvm/psci.c @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -180,6 +181,13 @@ static void kvm_prepare_system_event(struct kvm_vcpu *vcpu, u32 type) tmp->arch.power_off = true; kvm_make_all_cpus_request(vcpu->kvm, KVM_REQ_SLEEP); + /* + * If the MMIO guard was enabled, we pay the price of a full + * unmap to get back to a sane state (and clear the flag). + */ + if (test_and_clear_bit(KVM_ARCH_FLAG_MMIO_GUARD, &vcpu->kvm->arch.flags)) + stage2_unmap_vm(vcpu->kvm); + memset(&vcpu->run->system_event, 0, sizeof(vcpu->run->system_event)); vcpu->run->system_event.type = type; vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT; -- 2.30.2