Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp360426pxb; Wed, 6 Oct 2021 06:36:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDVUIcvEgAUnod6Y/yemGrP1Mw1pgyTN9lUhjkpa5VJV8/KsdQ4mwkI7HLb+MXTqk3qD5Q X-Received: by 2002:a17:906:24c6:: with SMTP id f6mr28833657ejb.366.1633527362762; Wed, 06 Oct 2021 06:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633527362; cv=none; d=google.com; s=arc-20160816; b=GzKgOOnAQ5W53+d1HfnGQ1TXFuHMDy3dLDvx6p3qQCYqit5W9oreyyl34EYmTTzBBY sBsUkSxf9mfPhzzEY70xAMcq+HKCd810Ry9Wp+EU0OeNyBJzOHG1bR4bgEvtGQ5jSk6M mFS+kydOwrosfw4El27KmIJsLDLb27kZ0m9iZvBeT3HLVGF0B7xUUeir6gXAENn8sZ6I +wgJVDiYrXr6SN4c0djbXN7F5Wy9V4MdtIEo7RT0Ag2ZmubgTUGIiBmiBNvbvXvbuZ19 gqBVBBzDC8Cp17Gk+7t5+3XQDKDbxdVcgHFMVALRxkJEAUlqC7UBdK5krRpQs4XwulVU oSyA== 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 :dkim-signature; bh=naRPD09Lp41wu80lZbclu4X73z7KJC8DGEqngCzZs/Q=; b=NVcX9kh7uUrlqalFfQpz/2gBBXet8JzUBan0Db4C8T/ly2KlxI12wocrUbEjU1DFym fJSX0mlhItBythwMNAGEugv2Kzscdof3BrxqLRneJ+DAANoaFQZ2Eotnt6a3Trh2OBfl hYdB8IL0yqRupHULuylQcRM9KMba8EQ1ILwJtLFCdb4cUCeQH5COLm2ELhyP2yVdYH45 W9fxB5+/gz4zO+wFbFUGOmXKJlEHKdH0I8xjaCrUU0bEkDUMsSsppUenYYoI9aoG/2Zu jm6UNP5ndgn77Mq3hnw/Bl9eiymyLga+t5oaTFryTen3vpWY8STt0wE4GzlT+y2wfrEL 2vWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PAQeYtgP; 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 j4si26635986ejj.357.2021.10.06.06.35.14; Wed, 06 Oct 2021 06:36:02 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PAQeYtgP; 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 S239143AbhJFNcj (ORCPT + 99 others); Wed, 6 Oct 2021 09:32:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:48842 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238818AbhJFNcU (ORCPT ); Wed, 6 Oct 2021 09:32:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0CF33611B0; Wed, 6 Oct 2021 13:30:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1633527027; bh=QoqPlKb+8kwKBss6R/aDErIHG6AbYJdoLskd/FTD5W4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PAQeYtgPWIUWA5Ih7VIPWCvn56wwnhdAmZC1vxj4MShel46jmu08eB+uss9kWMiKw FpV8Z6ttcWakGgDl4R3xuy1e+fKX5tpKFUXzfIIcYKkHdzpmcSnU+8gcvlbOFE+nKL 14/6l2hLi41PL1Dj7Xn8ioV9vWiJCWBiS5rHt8pNCKlv4Qp2J66ru/DONSiM0HoPXU pgPD151i8GyK+Dg3bbPZ/P81Huuf7VBrHJ90+U5oUC/mcuod98epBHZbDST9jtnVzC iMq3rs/xVWAtS2/3zHINiBBFmfZq8jd4Raw3YUTr7tTXKN6Yr9Uffx8N1U4hozuexW mf2A2qLXmAFQQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Maxim Levitsky , Paolo Bonzini , Sasha Levin , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, kvm@vger.kernel.org Subject: [PATCH MANUALSEL 5.14 4/9] KVM: x86: reset pdptrs_from_userspace when exiting smm Date: Wed, 6 Oct 2021 09:30:16 -0400 Message-Id: <20211006133021.271905-4-sashal@kernel.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211006133021.271905-1-sashal@kernel.org> References: <20211006133021.271905-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maxim Levitsky [ Upstream commit 37687c403a641f251cb2ef2e7830b88aa0647ba9 ] When exiting SMM, pdpts are loaded again from the guest memory. This fixes a theoretical bug, when exit from SMM triggers entry to the nested guest which re-uses some of the migration code which uses this flag as a workaround for a legacy userspace. Signed-off-by: Maxim Levitsky Message-Id: <20210913140954.165665-4-mlevitsk@redhat.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/x86.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index b3f855d48f72..1e7d629bbf36 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7659,6 +7659,13 @@ static void kvm_smm_changed(struct kvm_vcpu *vcpu, bool entering_smm) /* Process a latched INIT or SMI, if any. */ kvm_make_request(KVM_REQ_EVENT, vcpu); + + /* + * Even if KVM_SET_SREGS2 loaded PDPTRs out of band, + * on SMM exit we still need to reload them from + * guest memory + */ + vcpu->arch.pdptrs_from_userspace = false; } kvm_mmu_reset_context(vcpu); -- 2.33.0