Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp659200pxk; Wed, 16 Sep 2020 13:36:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdEF6qeiyTY2+YwkTKE5JOjpaoyH2s69y+ilFKDNuHrGAnBVh2zuIPyvYFADDNc6eHour7 X-Received: by 2002:a17:906:e113:: with SMTP id gj19mr27732703ejb.263.1600288586887; Wed, 16 Sep 2020 13:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600288586; cv=none; d=google.com; s=arc-20160816; b=t+oHG04Okx5xP3J98GHHzJEc+pomBqsIYu/dhnCWqeMdQXtLjpt7zZp1OoaJXBMtvm Vk5gnf+0Ea7O7hk51DzHnpa9HifS/lm9/mcoSxMet7n9O89hb2G6R1PTmv/d90JCUk6a wjqQ5O8Ke2e9UnCvs8WPBtfpC1UhX+o51C7Y1EfN28jr5ZIHZxz438HPVwfOUGCNSog3 BqEnUI2qLS9zaqRwVEjhHE33aGBuKdELowemZXZy/djkkQOmL0GoQvhFg5XAVnA0QbIi jNMJ4nsztnLKheoyrlbwRLe/OEt/XIY+E4CNPGDu0kWvFnBzV1MioU2OJ/UZG85jq2RO hgZw== 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=CvXGbYdsyCp6MMkEKXsckTqUOFzSJKpS5zXY9YWI2rE=; b=XpgwbLeg0tyKcNbCEAvFaNX1lvkbNZKStjgau9oBHmOujeyFtACiCmAQ/F3b/uMl99 VpgzEQIN/wt0vItm1EFYDJIOHh3pMrwEGjjOLhDcZP1yiXkF1K+cEobRBqRVCqoYFaRR 9hQJkbIw4/1VtSMu2ysz64Meqz0JpB0qIbNxBlS/s7x1JvxOBgwGhJR414ckzR0Pif+h eFGxLeFstnsyYf8Ev+ZWOD7VcNn6iKKaBx7UpJhJmskGTaOIc1YA5NFPEyRKXoKr2KH+ VLJHrTBc7enUTL2WiO6ZTncqsnIn+7d9M+7P3vpBPZy+0DwTkVwT/tp+Rkg0cHvFHHUS FeJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=EGSYJN9U; 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 a42si6185732edf.535.2020.09.16.13.36.03; Wed, 16 Sep 2020 13:36: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=@amazon.com header.s=amazon201209 header.b=EGSYJN9U; 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 S1726361AbgIPUch (ORCPT + 99 others); Wed, 16 Sep 2020 16:32:37 -0400 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:55369 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727133AbgIPUaQ (ORCPT ); Wed, 16 Sep 2020 16:30:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1600288216; x=1631824216; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CvXGbYdsyCp6MMkEKXsckTqUOFzSJKpS5zXY9YWI2rE=; b=EGSYJN9U46qVCLPdmVfl1TJJEGV7n8kM+Wz+4bFSTbUk01QavBIhCylu Eak5s3XlJEbUdPoGN/Ysu2X2CeXKRrYV8+GrVBNgq7sihZFnfP3yLzwDt a2XnivRtMQPz6BWfLkMSdJFsbBXe+oqGbTqpsl7aboQ/OaylYj7gLi0Pg 8=; X-IronPort-AV: E=Sophos;i="5.76,434,1592870400"; d="scan'208";a="75597510" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2c-2225282c.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 16 Sep 2020 20:30:11 +0000 Received: from EX13MTAUWC001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan3.pdx.amazon.com [10.170.41.166]) by email-inbound-relay-2c-2225282c.us-west-2.amazon.com (Postfix) with ESMTPS id B93C9A1D6D; Wed, 16 Sep 2020 20:30:09 +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; Wed, 16 Sep 2020 20:30:09 +0000 Received: from u79c5a0a55de558.ant.amazon.com (10.43.162.35) by EX13D20UWC001.ant.amazon.com (10.43.162.244) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 16 Sep 2020 20:30:05 +0000 From: Alexander Graf To: kvm list CC: Sean Christopherson , Aaron Lewis , Paolo Bonzini , Jonathan Corbet , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , KarimAllah Raslan , Dan Carpenter , , Subject: [PATCH v7 2/7] KVM: x86: Add infrastructure for MSR filtering Date: Wed, 16 Sep 2020 22:29:46 +0200 Message-ID: <20200916202951.23760-3-graf@amazon.com> X-Mailer: git-send-email 2.28.0.394.ge197136389 In-Reply-To: <20200916202951.23760-1-graf@amazon.com> References: <20200916202951.23760-1-graf@amazon.com> MIME-Version: 1.0 X-Originating-IP: [10.43.162.35] X-ClientProxiedBy: EX13D42UWA002.ant.amazon.com (10.43.160.16) To EX13D20UWC001.ant.amazon.com (10.43.162.244) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 | 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..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 3aea25fa9f00..99234244d97b 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