Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1157446pxk; Fri, 25 Sep 2020 07:37:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxM81dveuPxEGbec8PGj2R+OENUvmBxeLUAhC9wgnU0p/5+dBZwI5tzoqGq0qdVlNmhZC67 X-Received: by 2002:a05:6402:228c:: with SMTP id cw12mr1734664edb.174.1601044673316; Fri, 25 Sep 2020 07:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601044673; cv=none; d=google.com; s=arc-20160816; b=Wj8IYBJU227OZ1SDSJIR865wUj3j6ZOxcKqPTEzo89YhEI0kkdo96CqS3b6fx3fqGd IearNjVTVKlgUuTFUKlKsVrpA2SIsMqU7qalZn+l+8rkNyUncWswm/alUwG4pTDfxzfX UD3PmWnDTkLRoYRlVVOgZHTVYU909uBeCAQAefUg8OzjpQKu6tyleRxh/04UBBJ6ogeq 4kd9iEGRAIE/ycHnhSjigHOm7Edl9wX50yxeEP/YGGtpcRDLZeAm1SePUGMbBL+ZkOJd ulqnj/n5HdbRLSG91hKtROUHp79VaN4OwnYEk/spNATZ6mQys4nKCXlZWNEiEi/jGGCt HigA== 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=1LHqImoa9AOhn+U8HGEXWfcgPf+CfO1zdGMYpSdpeY0=; b=arl0u2PHrzI3EPyxDDLUz5Q8du9Ai+EeOjfUY5hirNqt06xDul48NFFlMOI47ahiW3 +/ZyQGq0fzrZWmJBfBsa24S4cAADluB4N5YTIBT5oGsB4tKk4f/nrU8ZL2+u8KQb7Vcr K3FM5IjgRYHTYsmPdgNTAj3VTEf0uZaiXydFY+jmA+YzoNM964nVR0NI3RlPVuSyLzsK 88VrzMO8RdA0rYxZZwEIpml5k+wL1vQuR73pDaQoUL6jMh/aL2Fe+nfN2vMSS5NLwhp7 ZlJUSMl1+PbUHkIiRWe0R7Onyxhp4H9Blsy0zqKGv6L0/Vw5EcubKwgN/FE2jsERDwn6 rDLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=FBnr49fh; 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 d20si1890314ejb.704.2020.09.25.07.37.29; Fri, 25 Sep 2020 07:37:53 -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=FBnr49fh; 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 S1729121AbgIYOgF (ORCPT + 99 others); Fri, 25 Sep 2020 10:36:05 -0400 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:32836 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729103AbgIYOgE (ORCPT ); Fri, 25 Sep 2020 10:36:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1601044564; x=1632580564; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1LHqImoa9AOhn+U8HGEXWfcgPf+CfO1zdGMYpSdpeY0=; b=FBnr49fhiSauDbJgPYIyashUUUOAxr6t+MWQcJNcp6Mx/atOG4iPznCb 2dRTuURP5qSGTK0ddAzPk4qjVKad8PwQCh4sj4f8XkiuGHvenWHkBqv9p 94v0MqC5BEFN/9uyOpNqKdNclUzCJG/hMklCfEdTbhYXgbz8pMRZHfV8g w=; X-IronPort-AV: E=Sophos;i="5.77,302,1596499200"; d="scan'208";a="78058000" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 25 Sep 2020 14:34:46 +0000 Received: from EX13MTAUWC001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com (Postfix) with ESMTPS id 0A793A232D; Fri, 25 Sep 2020 14:34:44 +0000 (UTC) Received: from EX13D20UWC001.ant.amazon.com (10.43.162.244) by EX13MTAUWC001.ant.amazon.com (10.43.162.135) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 25 Sep 2020 14:34:44 +0000 Received: from u79c5a0a55de558.ant.amazon.com (10.43.162.221) by EX13D20UWC001.ant.amazon.com (10.43.162.244) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 25 Sep 2020 14:34:41 +0000 From: Alexander Graf To: kvm list CC: Aaron Lewis , Sean Christopherson , Paolo Bonzini , Jonathan Corbet , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , "Joerg Roedel" , KarimAllah Raslan , "Dan Carpenter" , Maxim Levitsky , , Subject: [PATCH v8 3/8] KVM: x86: Add infrastructure for MSR filtering Date: Fri, 25 Sep 2020 16:34:17 +0200 Message-ID: <20200925143422.21718-4-graf@amazon.com> X-Mailer: git-send-email 2.28.0.394.ge197136389 In-Reply-To: <20200925143422.21718-1-graf@amazon.com> References: <20200925143422.21718-1-graf@amazon.com> MIME-Version: 1.0 X-Originating-IP: [10.43.162.221] X-ClientProxiedBy: EX13D08UWC002.ant.amazon.com (10.43.162.168) To EX13D20UWC001.ant.amazon.com (10.43.162.244) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 --- v7 -> v8: s/KVM_MSR_ALLOW/KVM_MSR_FILTER/g --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/include/uapi/asm/kvm.h | 2 ++ arch/x86/kvm/x86.c | 6 ++++++ arch/x86/kvm/x86.h | 1 + 4 files changed, 10 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 12c3f048f18b..9bc4fa34c90b 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1230,6 +1230,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..c2fd0aa2f587 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_FILTER_READ (1 << 0) +#define KVM_MSR_FILTER_WRITE (1 << 1) struct kvm_cpuid_entry { __u32 function; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 5f0fbd49c65c..8fe7d9730182 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1487,6 +1487,12 @@ 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; +} +EXPORT_SYMBOL_GPL(kvm_msr_allowed); + /* * 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 941f288c38aa..3900ab0c6004 100644 --- a/arch/x86/kvm/x86.h +++ b/arch/x86/kvm/x86.h @@ -374,6 +374,7 @@ bool kvm_vcpu_exit_request(struct kvm_vcpu *vcpu); int kvm_handle_memory_failure(struct kvm_vcpu *vcpu, int r, struct x86_exception *e); int kvm_handle_invpcid(struct kvm_vcpu *vcpu, unsigned long type, gva_t gva); +bool kvm_msr_allowed(struct kvm_vcpu *vcpu, u32 index, u32 type); #define KVM_MSR_RET_INVALID 2 -- 2.28.0.394.ge197136389 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