Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2817640pxb; Tue, 13 Apr 2021 10:51:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxS3wkqfh2RW2scR1xDDP5pxFERP6Ms5a4uTS8umONjLrOjM5Ms3/BuCfekJ6RVSr3pJVd3 X-Received: by 2002:a17:907:988c:: with SMTP id ja12mr16632483ejc.41.1618336286209; Tue, 13 Apr 2021 10:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618336286; cv=none; d=google.com; s=arc-20160816; b=mMrqPaB0eM/9iO7Bv3n7jWHzfvYOitXi/0+wHKyHosGDJeZZ54cZmlPLI73pmXaq3p q9THYOJeBPxwHShLekXKuX9zqIR2mHaztyNqlyRefFXsXm0G6w2xhDi0o6YvrNBIhfIX MAoIlw3ZeN7RgG7cn9v4G37BU/Tm08cP2kcmq5fFYJfBUXQBQXYULz9Z++TwkE5d0bMj 2btNpcyXXOJvhhtDYmui8aW/RmByev2+OqBB9sdMFe2IOe2/0Rxy5P1gAalLkU5kgFoW y+1XGn33C+dCa2nkJW5NXAVu9By3FIyLpE0nnLM85e59v/tRd6M8IpnTBC7sfXbBKO5l jiNw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=gHXO771pHe9zTon0JL2N9C6BipX6JwrG/i20Z7QO1yU=; b=Lt1unMBoTHiGVl3UZeZCoDw5KZT+RdnLLivKIe5p2Z2WRRiereHUWMtqDKiBFgCOSv XVDyM07flCtnWJhXSJjesjHp7iDD5Vs6BJo4pFJ350NRCcU/0e/vT6fp0RTJBRT/3POV 26TAwy3/pftztitoBXjB9Mu6OZYA0bsHdIZfM5p8JrtjZWZWe+BmlM27vIqeWixuH5EB B8GyAI5HH/P2bzkAoo9YJiuNkKKO908ju4wLHmKPNa9qi1TESPrw5PjLm4DrwfMCBMJE VNL+jj17z6FsXhfAt06HTMvEa0eZrhMTrE5yddvRvPgGYyp1+rYtp4y+zppQeJDzlOAy H3nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GuA6Rtth; 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 z13si10956836edc.6.2021.04.13.10.51.02; Tue, 13 Apr 2021 10:51:26 -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=GuA6Rtth; 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 S231337AbhDMM06 (ORCPT + 99 others); Tue, 13 Apr 2021 08:26:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47948 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231592AbhDMM05 (ORCPT ); Tue, 13 Apr 2021 08:26:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618316797; 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; bh=gHXO771pHe9zTon0JL2N9C6BipX6JwrG/i20Z7QO1yU=; b=GuA6Rtthf8JXqJQFj/qpp7burMWEpjnmaWQmghpIYLFBTi2eIyag/QVldlDlzsulqwCFlb wbItJAknyNXHEdulcAA5LOpaNx394ssS15qoeKg6Al0909mfgps1JzlDY1KOANPa8KmgZ/ LNOi4wiTsNcO48vT2ORJ2lmmO9oiSv8= 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-325-XnBuu0xjN3SGTxk9jSZ6cQ-1; Tue, 13 Apr 2021 08:26:36 -0400 X-MC-Unique: XnBuu0xjN3SGTxk9jSZ6cQ-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 44E488030D0; Tue, 13 Apr 2021 12:26:34 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.195.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3AB660C04; Tue, 13 Apr 2021 12:26:31 +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 00/22] KVM: x86: hyper-v: Fine-grained access check to Hyper-V hypercalls and MSRs Date: Tue, 13 Apr 2021 14:26:08 +0200 Message-Id: <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 Currently, all implemented Hyper-V features (MSRs and hypercalls) are available unconditionally to all Hyper-V enabled guests. This is not ideal as KVM userspace may decide to provide only a subset of the currently implemented features to emulate an older Hyper-V version, to reduce attack surface,... Implement checks against guest visible CPUIDs for all currently implemented MSRs and hypercalls. RFC part: - KVM has KVM_CAP_ENFORCE_PV_FEATURE_CPUID for KVM PV features. Should we use it for Hyper-V as well or should we rather add a Hyper-V specific CAP (or neither)? TODO: - Write a selftest - Check with various Windows/Hyper-V versions that CPUID feature bits are actually respected. Vitaly Kuznetsov (22): asm-generic/hyperv: add HV_STATUS_ACCESS_DENIED definition KVM: x86: hyper-v: Cache guest CPUID leaves determining features availability KVM: x86: hyper-v: Honor HV_MSR_VP_RUNTIME_AVAILABLE privilege bit KVM: x86: hyper-v: Honor HV_MSR_TIME_REF_COUNT_AVAILABLE privilege bit KVM: x86: hyper-v: Honor HV_MSR_HYPERCALL_AVAILABLE privilege bit KVM: x86: hyper-v: Honor HV_MSR_VP_INDEX_AVAILABLE privilege bit KVM: x86: hyper-v: Honor HV_MSR_RESET_AVAILABLE privilege bit KVM: x86: hyper-v: Honor HV_MSR_REFERENCE_TSC_AVAILABLE privilege bit KVM: x86: hyper-v: Honor HV_MSR_SYNIC_AVAILABLE privilege bit KVM: x86: hyper-v: Honor HV_MSR_SYNTIMER_AVAILABLE privilege bit KVM: x86: hyper-v: Honor HV_MSR_APIC_ACCESS_AVAILABLE privilege bit KVM: x86: hyper-v: Honor HV_ACCESS_FREQUENCY_MSRS privilege bit KVM: x86: hyper-v: Honor HV_ACCESS_REENLIGHTENMENT privilege bit KVM: x86: hyper-v: Honor HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE privilege bit KVM: x86: hyper-v: Honor HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE privilege bit KVM: x86: hyper-v: Honor HV_STIMER_DIRECT_MODE_AVAILABLE privilege bit KVM: x86: hyper-v: Honor HV_POST_MESSAGES privilege bit KVM: x86: hyper-v: Honor HV_SIGNAL_EVENTS privilege bit KVM: x86: hyper-v: Honor HV_DEBUGGING privilege bit KVM: x86: hyper-v: Honor HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED bit KVM: x86: hyper-v: Honor HV_X64_CLUSTER_IPI_RECOMMENDED bit KVM: x86: hyper-v: Check access to HVCALL_NOTIFY_LONG_SPIN_WAIT hypercall arch/x86/include/asm/kvm_host.h | 8 + arch/x86/kvm/hyperv.c | 305 +++++++++++++++++++++++++++--- include/asm-generic/hyperv-tlfs.h | 1 + 3 files changed, 291 insertions(+), 23 deletions(-) -- 2.30.2