Received: by 2002:a25:d80d:0:0:0:0:0 with SMTP id p13csp131456ybg; Sat, 23 May 2020 09:19:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZLOn3+jvihSMBnxiXlRG2Dk4Yj7rWs/c4kRFgVY154hx7XLDiJIwW9h1IdWY3qv8cNDvn X-Received: by 2002:a50:9f66:: with SMTP id b93mr7365120edf.376.1590250749128; Sat, 23 May 2020 09:19:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590250749; cv=none; d=google.com; s=arc-20160816; b=MMoOJh8JCP16XT4G12wylDCUizLSeajdsWiaNdN2dc4v8ETLGXPsj6C6jAKV2kRlq+ O1Z6jDt8kcs581/SyV1DhBnk2slwd935epEDIAHVGxWJ4RhpXUVyaftnTVFckZoIZYvf 3WxkLCEksxvHqN7jVSZUnFCq4NM5VMfz1yWUmJaaEqr4RZ4HQFmmDlxP/Dj6kSJ+aPrs Oc+BGn59MnMBReupnwvGUFCtG4IeOeizANmzpZE2lFcZEKvufVJZXZx6ll3SSiuhq1vb 0fMBjbvA0Hu7zLO/JbSa0vqdRN1jHNtMRSps+lM07lcahdDS1sV2sAjx9wmLCbQBsWqN SNJQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HFg02eb4YubKQIu550jTk5UUZALiVej3kr4L4u3iifQ=; b=gVv1Sv24CSmkv1d85bBCzeJs+PDqftQ6Rfg+8/LTAEdlnv8/WxGgNNPu7AOe8tCUY7 u8PJG1LH69pNnaf1oe25yxdpVEpBAA8shrcb3WGpwOuUKkmPmC+q45wr3053CJuoPr9B /y9vm29W/LTvhs6tcuwhtJM3D3ySBtDvo6M/LTb5U/uAI5IHOc/6GDh8s2JJtN6dxgsd QjQjn8esCWaig2NSep8S/hvcPKycXbmtU3akVpZYvTC25WwpHBy/FkYYrVAVDzYq5Uhx W0klFS2kS2ITCgJZsN/lf4PG5HVhZwD/Wje/6LlYdVaPIkrveO3YO16h7cyqxbAjtF0B 7RKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=S7ocvhb1; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t19si5720437eds.141.2020.05.23.09.18.46; Sat, 23 May 2020 09:19:09 -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=@redhat.com header.s=mimecast20190719 header.b=S7ocvhb1; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728197AbgEWQPd (ORCPT + 99 others); Sat, 23 May 2020 12:15:33 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:56019 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728154AbgEWQPd (ORCPT ); Sat, 23 May 2020 12:15:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590250532; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HFg02eb4YubKQIu550jTk5UUZALiVej3kr4L4u3iifQ=; b=S7ocvhb1Qj4uIJ2lOieIOzlXrfBJJm+FWjfr06QHSQvkaHNq3gvCvl6u96OrCdt51z48dz et+o+68v7AvqgKnkLZ4mdMq1Z5fbRlvZXim5NtNvtTEj4p7DnIDBgYHJk92mTCNoHmV8ab XCW4yMa0PINlDKR4a0vWeezyRo2DK+Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-19-0ITODA4gNVadJer3b5CRCw-1; Sat, 23 May 2020 12:15:28 -0400 X-MC-Unique: 0ITODA4gNVadJer3b5CRCw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 810B18005AA; Sat, 23 May 2020 16:15:26 +0000 (UTC) Received: from starship.f32vm (unknown [10.35.206.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01ACC600E5; Sat, 23 May 2020 16:15:15 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: Paolo Bonzini , "H. Peter Anvin" , Tao Xu , Sean Christopherson , Jim Mattson , linux-kernel@vger.kernel.org, Joerg Roedel , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), Wanpeng Li , Ingo Molnar , Thomas Gleixner , Borislav Petkov , Vitaly Kuznetsov , Jingqi Liu , Maxim Levitsky Subject: [PATCH 2/2] kvm/x86: don't expose MSR_IA32_UMWAIT_CONTROL unconditionally Date: Sat, 23 May 2020 19:14:55 +0300 Message-Id: <20200523161455.3940-3-mlevitsk@redhat.com> In-Reply-To: <20200523161455.3940-1-mlevitsk@redhat.com> References: <20200523161455.3940-1-mlevitsk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This msr is only available when the host supports WAITPKG feature. This breaks a nested guest, if the L1 hypervisor is set to ignore unknown msrs, because the only other safety check that the kernel does is that it attempts to read the msr and rejects it if it gets an exception. Fixes: 6e3ba4abce KVM: vmx: Emulate MSR IA32_UMWAIT_CONTROL Signed-off-by: Maxim Levitsky --- arch/x86/kvm/x86.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index b226fb8abe41b..4752293312947 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5316,6 +5316,10 @@ static void kvm_init_msr_list(void) min(INTEL_PMC_MAX_GENERIC, x86_pmu.num_counters_gp)) continue; break; + case MSR_IA32_UMWAIT_CONTROL: + if (!kvm_cpu_cap_has(X86_FEATURE_WAITPKG)) + continue; + break; default: break; } -- 2.26.2