Received: by 10.223.185.116 with SMTP id b49csp3829767wrg; Tue, 13 Feb 2018 08:22:28 -0800 (PST) X-Google-Smtp-Source: AH8x227/5kK1cgXr2gIXI7BVGSGgcXDrSKBr1lLXnwS1uFq3hwXxlqm/mYn+daH7COR1RtFcAySF X-Received: by 10.101.75.68 with SMTP id k4mr1431306pgt.335.1518538948396; Tue, 13 Feb 2018 08:22:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518538948; cv=none; d=google.com; s=arc-20160816; b=U933RL0cYsBRGqPjLWbIaI1Y6VSI37h3DGXw/LcW9kjfBBkRjwpos1E9EL2AZ0IME7 /Fy76KQG2X/lTo65T+ZqIiujd9PotI9yyCnOQcz4y02RBBs5MNWlSo2H3d+0TEQCQhvP n6ROWozBkTKdQ9ZAqz2R+6W9WrNxHnjBGCBbeHVteLVtYYY/SBjGi102sLW8T3S2GPUq Gg9e2TDycpURcjvR4ttGi2d60LSCRQSAHexBpxGn9ZS7oAaBJfJkPBSyvVPK1fZUrStY oYunhcbDzrcefAZr+QwW4vi2go1cntYn6MRVo+jbSmiUtKjS4q0k2FLsRjQJtyGgBIDa Lwzw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=X55cwmxrrw3jmuEBiwacgKJAKxzWHcRnHMBfildM4h8=; b=O58D0QysVkBkYFxBDD1gLLnV0r4Np6u6Z31F6/+X7ipMwd1gV7P71vP882c+MsKFXW jU/ZzVqikuWDjJ1zg0vfuU6xO5RzTMVqztzOtq6FjWu0Q8bosqHx8+cIqwB3cOInX2L1 gYZiGiIanGHG9lqOZDWa3zzoDY29QnqYXegXnbqSbJWpEM+6TXDYaOmLckJ6j5C/0wvn PfBMiBVywscC+r48+2gtd4rqNnZfjH6ax9mY3vrKnQDlANfGHuIMFAPrWPlaho9Q6Ash R2Hh9Mj/jVVK4YRNO0/9SzDa/JQ0EI3mFsVMo+bUcuFQAFW23Bx0UDisNJADtUoylXCj TUhw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y10si8294485pff.4.2018.02.13.08.22.13; Tue, 13 Feb 2018 08:22:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934735AbeBMQVG (ORCPT + 99 others); Tue, 13 Feb 2018 11:21:06 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60322 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933927AbeBMQVE (ORCPT ); Tue, 13 Feb 2018 11:21:04 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 021EA40FB645; Tue, 13 Feb 2018 16:21:04 +0000 (UTC) Received: from [10.36.116.223] (ovpn-116-223.ams2.redhat.com [10.36.116.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 73B9CB2885; Tue, 13 Feb 2018 16:21:02 +0000 (UTC) Subject: Re: [RFC PATCH 1/2] KVM: x86: Add a framework for supporting MSR-based features To: Tom Lendacky , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Joerg Roedel , Borislav Petkov , Thomas Gleixner , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= References: <20180208225833.22074.25995.stgit@tlendack-t1.amdoffice.net> <20180208225846.22074.70944.stgit@tlendack-t1.amdoffice.net> From: Paolo Bonzini Message-ID: <45f3c26d-9580-7336-6c74-a0c1cd1e8963@redhat.com> Date: Tue, 13 Feb 2018 17:21:00 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180208225846.22074.70944.stgit@tlendack-t1.amdoffice.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 16:21:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 13 Feb 2018 16:21:04 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/02/2018 23:58, Tom Lendacky wrote: > Provide a new KVM capability that allows bits within MSRs to be recognized > as features. Two new ioctls are added to the VM ioctl routine to retrieve > the list of these MSRs and their values. The MSR features can optionally > be exposed based on a CPU and/or a CPU feature. Yes, pretty much. Just two changes: > +struct kvm_msr_based_features { > + u32 msr; /* MSR to query */ > + u64 mask; /* MSR mask */ > + const struct x86_cpu_id *match; /* Match criteria */ > + u64 value; /* MSR value */ 1) These two should be replaced by a kvm_x86_ops callback, because computing the value is sometimes a bit more complicated than just rdmsr (for example, MSRs for VMX capabilities depend on the kvm_intel.ko module parameters). > + case KVM_CAP_GET_MSR_FEATURES: This should be KVM_GET_MSR. > + r = msr_io(NULL, argp, do_get_msr_features, 1); > + break; Bonus points for writing documentation :) and for moving the MSR handling code to arch/x86/kvm/msr.{c,h}. Thanks, Paolo