Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3690528ybv; Mon, 10 Feb 2020 04:46:51 -0800 (PST) X-Google-Smtp-Source: APXvYqySdeIuWv9ToZRxSyaOo5qOTFhxMiigC0q+QmNl0EXNc7savnk1SlJq/Zs1hrD8rgzOvtgC X-Received: by 2002:a9d:6183:: with SMTP id g3mr932450otk.304.1581338810904; Mon, 10 Feb 2020 04:46:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581338810; cv=none; d=google.com; s=arc-20160816; b=HVet5Dxihx1CfshHl4o/r3UZwYQgQkA5ai/M3y+NY7eBpfeQAQIZDZI8yw/vrOkPcC f9Cb2jaABYPhLWVdVgsMPEJvlwuuBEYmrsRuNlqXnDTLyBuwCll7nV/SWe6OSJuzVqGB axqptG6a8y3Jec3U8aJg3U3IPC/M85pR45VWHVlLcOtq7mNEDQTrUDA6KrXPyo1w/LOd W+B5mXbAwM3sG6mybPPexIWRZn/C6ogQFQ9ciPjVNtpqVS2SpO8XuMAtBJGO2CLVVLJn Xh3r8r4apeDYGBdyQTNOdYfXFN/mP2Gq+zM7gyx5swItPUhYr+qlAoSJ/+GcUPoIveDB xGuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XWTrfPuHfy1ODeSncrwr1NifhzS9XvkvOR9SqAwskhg=; b=k0pbrvvZ8NGSY9f7xbZOcqBcBj88Aa1LmLp3CKueH3FhPawZbd6PZ5lXEDWaziAbwW u8IBckAvJoyl3jmYFPA8A6M32oWIxaGMf5kdabnGZG4MYRzv+pHbPOAKQCkD3nwk39/G jY5ABq7MzZ8MTwkPemUA0Ck9nq7xMFLQaVaVD+DIK5zfuGHiym2Rh3Flt0R28g4RsyxZ 8oZX5Dvwe24KwvepRiKcc+jGdG/y/MONdefqpYzmD0Oe9tidoVwmBcSpDoAa87eiLsvg dm1qJPROESdmkuT2+ud6Rsmh7AXt10mE+DWm9F45gXGvrUOf2wRh2+jQncHp++1mmxZ8 8hpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xl5ykg0g; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j10si148385otn.122.2020.02.10.04.46.38; Mon, 10 Feb 2020 04:46:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xl5ykg0g; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728810AbgBJMqY (ORCPT + 99 others); Mon, 10 Feb 2020 07:46:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:44168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729384AbgBJMlg (ORCPT ); Mon, 10 Feb 2020 07:41:36 -0500 Received: from localhost (unknown [209.37.97.194]) (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 13F702051A; Mon, 10 Feb 2020 12:41:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338496; bh=86r4UqeeZ+aKmHn3QahEc9xR1oMyCEz9S0COPm5NdfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xl5ykg0gW2p0DRifMJDZn2UNdXaWNG9KDXeDklIaoeDmOEm4dWG1AYP4UlyTx4Ly9 ZkWj4+Tdv9GmIXn02XTmwozwyyK0XtpLV8+m5j/FPEGHUrrZTr9Vp8kCOKiqzs2ET+ CNVCk3N3ycGh5lx72R7fajXwrrCIBYbtWdOMnVF4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Boris Ostrovsky , Joao Martins , Paolo Bonzini Subject: [PATCH 5.5 249/367] x86/KVM: Clean up hosts steal time structure Date: Mon, 10 Feb 2020 04:32:42 -0800 Message-Id: <20200210122447.183043847@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Boris Ostrovsky commit a6bd811f1209fe1c64c9f6fd578101d6436c6b6e upstream. Now that we are mapping kvm_steal_time from the guest directly we don't need keep a copy of it in kvm_vcpu_arch.st. The same is true for the stime field. This is part of CVE-2019-3016. Signed-off-by: Boris Ostrovsky Reviewed-by: Joao Martins Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/kvm_host.h | 3 +-- arch/x86/kvm/x86.c | 11 +++-------- 2 files changed, 4 insertions(+), 10 deletions(-) --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -685,10 +685,9 @@ struct kvm_vcpu_arch { bool pvclock_set_guest_stopped_request; struct { + u8 preempted; u64 msr_val; u64 last_steal; - struct gfn_to_hva_cache stime; - struct kvm_steal_time steal; struct gfn_to_pfn_cache cache; } st; --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2611,7 +2611,7 @@ static void record_steal_time(struct kvm if (xchg(&st->preempted, 0) & KVM_VCPU_FLUSH_TLB) kvm_vcpu_flush_tlb(vcpu, false); - vcpu->arch.st.steal.preempted = 0; + vcpu->arch.st.preempted = 0; if (st->version & 1) st->version += 1; /* first time write, random junk */ @@ -2795,11 +2795,6 @@ int kvm_set_msr_common(struct kvm_vcpu * if (data & KVM_STEAL_RESERVED_MASK) return 1; - if (kvm_gfn_to_hva_cache_init(vcpu->kvm, &vcpu->arch.st.stime, - data & KVM_STEAL_VALID_BITS, - sizeof(struct kvm_steal_time))) - return 1; - vcpu->arch.st.msr_val = data; if (!(data & KVM_MSR_ENABLED)) @@ -3519,7 +3514,7 @@ static void kvm_steal_time_set_preempted if (!(vcpu->arch.st.msr_val & KVM_MSR_ENABLED)) return; - if (vcpu->arch.st.steal.preempted) + if (vcpu->arch.st.preempted) return; if (kvm_map_gfn(vcpu, vcpu->arch.st.msr_val >> PAGE_SHIFT, &map, @@ -3529,7 +3524,7 @@ static void kvm_steal_time_set_preempted st = map.hva + offset_in_page(vcpu->arch.st.msr_val & KVM_STEAL_VALID_BITS); - st->preempted = vcpu->arch.st.steal.preempted = KVM_VCPU_PREEMPTED; + st->preempted = vcpu->arch.st.preempted = KVM_VCPU_PREEMPTED; kvm_unmap_gfn(vcpu, &map, &vcpu->arch.st.cache, true, true); }