Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2011176pxk; Tue, 1 Sep 2020 13:19:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3DIywi90sR9AREwpr5M+3oJ32FC+bYqXkBPEqgwpMVryvEEDSplBZehqgPQit5IBuCWgJ X-Received: by 2002:a17:906:180b:: with SMTP id v11mr3411109eje.427.1598991580611; Tue, 01 Sep 2020 13:19:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598991580; cv=none; d=google.com; s=arc-20160816; b=QpeJBWwyCPiJFaVzvonqld+DVYLUZdR/QbudS1hdRBJxcHf25uVuQnIlvayqHemfCG XwWx6uVMjIH5NtyQu3Nauf82GVqymEKABFIK+MybGxY2PXds+S+MpUBUW/GdBqfi5u8z NaB4kE1RDUcMCleE8Pq6VnFbS1napmII8bujgrOnmxMh3WsDr0a+gIY8x3TnRYQ7wzyO mSCvu8NGZXl+7KNTMJqFnZBPy3U/MVF2Vd5NS7jjoe6oxIKKa/1+llsNWWJ+xXbZSkYh kQMdazly4lVFQusnUq+Gtg/7TRU4VecbSuUMdH7pLdjJBOQ7wbncp8f8JQOeyJH9pPYY j58g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=VYPzQ7D+jLbCQnGNcQsVhw02s7DcBHMB0lYxDbNXIBs=; b=NJ1lSCFFkC0rc/0l2s4RGxT1VozosHAKvUAIAYDwAheiHhE7BaMJu9iuKggv9vamSm 5CnUHpiu1K+cNGYy6HvuL127dMV2L5eit4CO8lTJe/mx3Wee7P9nXFF4kL4ylm2VPbGb R6Md0N44M8bslp8nb6jChNQx/jmikO9F70noFubIXLdk6Mwz96CJlOJJaDGBU4/sUnST CUChXXP5TXi2+YiuoabzapUOMljm+9aYFCJRyGOrhUGgPpv8lbcbQRr+dUSJqhXy1lXC DxiJXddiLY8COgRK4JZ1hLgYbwmLfrG/6b9I2JJsw1Nw8WE3UWz5UUr5f/QhaBYS6pjZ yTUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b="suJs/KuR"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u1si1261003edv.460.2020.09.01.13.19.17; Tue, 01 Sep 2020 13:19:40 -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=@amazon.com header.s=amazon201209 header.b="suJs/KuR"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729509AbgIAUP5 (ORCPT + 99 others); Tue, 1 Sep 2020 16:15:57 -0400 Received: from smtp-fw-9101.amazon.com ([207.171.184.25]:5552 "EHLO smtp-fw-9101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728320AbgIAUPv (ORCPT ); Tue, 1 Sep 2020 16:15:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1598991351; x=1630527351; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=VYPzQ7D+jLbCQnGNcQsVhw02s7DcBHMB0lYxDbNXIBs=; b=suJs/KuRg+H0mvdxI9liVrpL9AVF2ySrgdEIN1q9qJh6MdLMMx/Ep4L0 lvlVvkIfFR9uBLcMllWAFQ5dCZWoM8+9v8DRfsDC3afwJ1ypl/B3y/VC9 8vGU8kUdpP0QoFSYtGX8rKO+HI7IhjjR+3X2JTUy0X7LCK1D3lyhBCFKm c=; X-IronPort-AV: E=Sophos;i="5.76,380,1592870400"; d="scan'208";a="64602816" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2a-53356bf6.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP; 01 Sep 2020 20:15:36 +0000 Received: from EX13MTAUWC002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2a-53356bf6.us-west-2.amazon.com (Postfix) with ESMTPS id 9773DA1C7D; Tue, 1 Sep 2020 20:15:35 +0000 (UTC) Received: from EX13D20UWC001.ant.amazon.com (10.43.162.244) by EX13MTAUWC002.ant.amazon.com (10.43.162.240) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 1 Sep 2020 20:15:35 +0000 Received: from u79c5a0a55de558.ant.amazon.com (10.43.160.229) by EX13D20UWC001.ant.amazon.com (10.43.162.244) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 1 Sep 2020 20:15:31 +0000 From: Alexander Graf To: Paolo Bonzini CC: Jonathan Corbet , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , "Joerg Roedel" , KarimAllah Raslan , Aaron Lewis , Dan Carpenter , , , Subject: [PATCH v6 2/7] KVM: x86: Add infrastructure for MSR filtering Date: Tue, 1 Sep 2020 22:15:12 +0200 Message-ID: <20200901201517.29086-3-graf@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901201517.29086-1-graf@amazon.com> References: <20200901201517.29086-1-graf@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.160.229] X-ClientProxiedBy: EX13D18UWC001.ant.amazon.com (10.43.162.105) To EX13D20UWC001.ant.amazon.com (10.43.162.244) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the following commits we will add pieces of MSR filtering. To ensure that code compiles even with the feature half-merged, let's add a few stubs and struct definitions before the real patches start. Signed-off-by: Alexander Graf --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/include/uapi/asm/kvm.h | 2 ++ arch/x86/kvm/x86.c | 5 +++++ arch/x86/kvm/x86.h | 1 + 4 files changed, 9 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 6608c8efbfa1..a9e3cc13bca6 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1272,6 +1272,7 @@ struct kvm_x86_ops { int (*enable_direct_tlbflush)(struct kvm_vcpu *vcpu); void (*migrate_timers)(struct kvm_vcpu *vcpu); + void (*msr_filter_changed)(struct kvm_vcpu *vcpu); }; struct kvm_x86_nested_ops { diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h index 0780f97c1850..50650cfd235a 100644 --- a/arch/x86/include/uapi/asm/kvm.h +++ b/arch/x86/include/uapi/asm/kvm.h @@ -192,6 +192,8 @@ struct kvm_msr_list { __u32 indices[0]; }; +#define KVM_MSR_ALLOW_READ (1 << 0) +#define KVM_MSR_ALLOW_WRITE (1 << 1) struct kvm_cpuid_entry { __u32 function; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 4d285bf054fb..6a921145754b 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1472,6 +1472,11 @@ void kvm_enable_efer_bits(u64 mask) } EXPORT_SYMBOL_GPL(kvm_enable_efer_bits); +bool kvm_msr_allowed(struct kvm_vcpu *vcpu, u32 index, u32 type) +{ + return true; +} + /* * Write @data into the MSR specified by @index. Select MSR specific fault * checks are bypassed if @host_initiated is %true. diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h index 6eb62e97e59f..1d67d9168b8c 100644 --- a/arch/x86/kvm/x86.h +++ b/arch/x86/kvm/x86.h @@ -365,5 +365,6 @@ void kvm_load_guest_xsave_state(struct kvm_vcpu *vcpu); void kvm_load_host_xsave_state(struct kvm_vcpu *vcpu); u64 kvm_spec_ctrl_valid_bits(struct kvm_vcpu *vcpu); bool kvm_vcpu_exit_request(struct kvm_vcpu *vcpu); +bool kvm_msr_allowed(struct kvm_vcpu *vcpu, u32 index, u32 type); #endif -- 2.17.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879