Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2817691pxb; Tue, 13 Apr 2021 10:51:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcFDxYu0Etmp/OtQtv21/aAnwWqQ1WHNa13ICYFiMJ+qHLeLBH+pdxiXsa4rcc1rFXHzXn X-Received: by 2002:a17:906:34da:: with SMTP id h26mr24157271ejb.496.1618336289811; Tue, 13 Apr 2021 10:51:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618336289; cv=none; d=google.com; s=arc-20160816; b=wfngKCQRBur+fOcSdxbXHQHuwvrZ6NzBz5GLJTvq5bIMTEyJGDckoqUg/WDdO2Y8sh T8W+xXB7zcopt5OcVEydJgEzfOiRdy80hyNbsVze1a2XSg0zX+XzG5wbi+mAe56xUhSF l6/pmGQn02pP9Yr1hSoNvn5XqvFfMASqSkaVS6QyCpaSx6eLCZ5tqOhOe9wRrH/gihvv gG3QlrAfURv2xD6CD3jyHIvH054jzXbghZ7oZuHI9X6kkQOLkd/MSIrdYnvruLySEbYv Krirf6/a24/RRpA1DctRd+vM0sL0XLY5E8V0miE6wDsGPgj+CFx8f30bFYkpXKYu2r2j uEuQ== 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=o9sP7+bqT1/7D4m+jHPuhuseMhiAgoZVCcAP69ZyNS4=; b=zooggUJsgh29QO1tAjY+4YSjCYUvc3HRzRXfg0ESnffFM7leOJwJ7hs95EVa62CqLD OAdvUFwUnQnUpoNUMBZkNvxbALKxSqyvVpPf/S2uZyYvkb8NNn+urx+4tRCWr5N7uzLA 9YgvkoLUoWi5pr0sCsBgUO89NV0vBPXqeE8uTZEeaLe9QK3bnggWkKPyuv1j3ivQLipB EK3PZZ8rQQK7bU+ZuCTPumFMFzOQeHFJoMIH0AJOtnehedd5uKmLuwdEtWkrISqk1MUx qkX8I9NtapMIhL18RjRnxjIh0vTwK9NIgUey2CMqohRgM+TFCWLWgoo957UtPKb9fv4M wcSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Bhj9uRtr; 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 i10si2583714edc.63.2021.04.13.10.51.06; Tue, 13 Apr 2021 10:51:29 -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=Bhj9uRtr; 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 S1345561AbhDMM1Q (ORCPT + 99 others); Tue, 13 Apr 2021 08:27:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24534 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345531AbhDMM1J (ORCPT ); Tue, 13 Apr 2021 08:27:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618316809; 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=o9sP7+bqT1/7D4m+jHPuhuseMhiAgoZVCcAP69ZyNS4=; b=Bhj9uRtrm/Ca77EQ7mIfMlIgJm79cbPso2TWEILKXDwzswEX2LuvsQgFOYM8cDY9ShLqN+ FwxjXhW1aOkg9E7mIFCWXK6e5f4a0ofQrcss8CYwG/B//zJyAK2pOSqp8gDrBlNRjUlH9n T32PaWSPDA3xnqpyLqJQAYGD44pDwAk= 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-53-8msTuak6NVuvH4CML75q3Q-1; Tue, 13 Apr 2021 08:26:46 -0400 X-MC-Unique: 8msTuak6NVuvH4CML75q3Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B3A5483DD20; Tue, 13 Apr 2021 12:26:44 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.195.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9972760C04; Tue, 13 Apr 2021 12:26:39 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , Siddharth Chandrasekaran , linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org Subject: [PATCH RFC 03/22] KVM: x86: hyper-v: Honor HV_MSR_VP_RUNTIME_AVAILABLE privilege bit Date: Tue, 13 Apr 2021 14:26:11 +0200 Message-Id: <20210413122630.975617-4-vkuznets@redhat.com> In-Reply-To: <20210413122630.975617-1-vkuznets@redhat.com> References: <20210413122630.975617-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org HV_X64_MSR_VP_RUNTIME is only available to guest when HV_MSR_VP_RUNTIME_AVAILABLE bit is exposed. Note, writing to HV_X64_MSR_VP_RUNTIME is only available from the host so kvm_hv_set_msr() doesn't need an additional check. Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 781f9da9a418..b39445aabbc2 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -1504,6 +1504,10 @@ static int kvm_hv_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata, data = hv_vcpu->hv_vapic; break; case HV_X64_MSR_VP_RUNTIME: + if (unlikely(!host && !(hv_vcpu->cpuid_cache.features_eax & + HV_MSR_VP_RUNTIME_AVAILABLE))) + return 1; + data = current_task_runtime_100ns() + hv_vcpu->runtime_offset; break; case HV_X64_MSR_SCONTROL: -- 2.30.2