Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2812110rwb; Mon, 15 Aug 2022 11:50:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR6x7Po+G4ce3PrL4aAMYmiaDg60J2oD4LxpLW1/Ny/p3JUYTnHsqI/idzhJv5z3vBaHtCWY X-Received: by 2002:a05:6402:26cb:b0:43e:6fab:11c6 with SMTP id x11-20020a05640226cb00b0043e6fab11c6mr14948867edd.272.1660589429091; Mon, 15 Aug 2022 11:50:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660589429; cv=none; d=google.com; s=arc-20160816; b=x5HA0oeacr0ldrdVgYk2tMHbNbthxUAeI7giVPSk6Wjj34S3y2OzINlFPO+SYTXoXJ qAjBqdm9OMbl0+RPtk7595ZOeI+oSmCdLA//MMBGQInUJSYAreblAeUiK2e8EdDlzSkm 3CNBCGS7TEP++I8ZAw/LEUwGKh4Z3yQ6jIM9PZ++P8SJxxREe9fi5hNBYVymH1vDvLyB dn7EXubBBQQRy08PLHLApRwmPkO5+xD9w/NyvTw20bpJfhtycqbEN7Q8A5D2K6X+dtLJ Y9r1uVSleILkw+xuOI5kHCNAurVTkRRgL3iCjlv709IXfJhUvpqiVVo0aw5osc+XP/B5 JOVA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QcD61Yd1aHepLliRpCC2oQhdohVVZpVMtDSzvLIU690=; b=Cve5dJ33kWG177HLj3fCDVxwjBVoc81gtiB7vEZCA+1TPpjSalkOxyngL+mrk3XRjh mxw1w2E8IUwxphZtW8TXpuVAlrRUVob//kZq/xzx/o+HVGKfmIfm4D1VF3jv7+2RhXWr WwVCbgnIFN9XH0mrl1vxt2JCALsLLXjbVTPpa54WC/7++00FOZ2Zogh3thZPbLLECxry 7MT/is0+AuDcl7eOJHevCJTGRYzGDRomNjKZugS7lTrz8NCQtS5gwOHt3BhSFPZ+5D2n O8Okfl7+3ZCeZSiaXHNc4s3bYrtIbNnc1pJmDd/zrYRkTYdKhE9Ia+WwLcpVbztTW4tJ tkxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QN+sPilZ; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a12-20020a170906190c00b0073317d6b047si6651722eje.569.2022.08.15.11.50.03; Mon, 15 Aug 2022 11:50:29 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=QN+sPilZ; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239441AbiHOSQa (ORCPT + 99 others); Mon, 15 Aug 2022 14:16:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233216AbiHOSPR (ORCPT ); Mon, 15 Aug 2022 14:15:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22DDC2A73B; Mon, 15 Aug 2022 11:14:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B6B776126D; Mon, 15 Aug 2022 18:14:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5FA1C433D6; Mon, 15 Aug 2022 18:14:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660587270; bh=1OITRAGOJJ4XFj+CUCDTY5YI0pSF38I7VP8XdWTEDT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QN+sPilZ0Fddgpqe5FxgppKr9dptwj1rhG4w3qWyRuEsf77r0m8xvzwKzV66bwK+9 /DDF+Y6LxaD3TNaOWxJFEgDZmQZW+GIWtqO4Qu/30KUlm9EXAea6N0vJtsXoIFU8cP 1x/laoZDmBxhYP5W5Ge4ZkRFgVpbgOAHZAGrYOuM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Woodhouse , Paolo Bonzini Subject: [PATCH 5.15 032/779] KVM: x86: do not report preemption if the steal time cache is stale Date: Mon, 15 Aug 2022 19:54:36 +0200 Message-Id: <20220815180338.606865611@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Bonzini commit c3c28d24d910a746b02f496d190e0e8c6560224b upstream. Commit 7e2175ebd695 ("KVM: x86: Fix recording of guest steal time / preempted status", 2021-11-11) open coded the previous call to kvm_map_gfn, but in doing so it dropped the comparison between the cached guest physical address and the one in the MSR. This cause an incorrect cache hit if the guest modifies the steal time address while the memslots remain the same. This can happen with kexec, in which case the preempted bit is written at the address used by the old kernel instead of the old one. Cc: David Woodhouse Cc: stable@vger.kernel.org Fixes: 7e2175ebd695 ("KVM: x86: Fix recording of guest steal time / preempted status") Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/x86.c | 2 ++ 1 file changed, 2 insertions(+) --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4378,6 +4378,7 @@ static void kvm_steal_time_set_preempted struct kvm_steal_time __user *st; struct kvm_memslots *slots; static const u8 preempted = KVM_VCPU_PREEMPTED; + gpa_t gpa = vcpu->arch.st.msr_val & KVM_STEAL_VALID_BITS; /* * The vCPU can be marked preempted if and only if the VM-Exit was on @@ -4405,6 +4406,7 @@ static void kvm_steal_time_set_preempted slots = kvm_memslots(vcpu->kvm); if (unlikely(slots->generation != ghc->generation || + gpa != ghc->gpa || kvm_is_error_hva(ghc->hva) || !ghc->memslot)) return;