Received: by 10.223.185.116 with SMTP id b49csp3834263wrg; Tue, 13 Feb 2018 08:26:40 -0800 (PST) X-Google-Smtp-Source: AH8x2266oju3IoaocxilWgj6VfEjyPi/3gS5KozPRoid5UCqydHt0Zy13D3M0GvqXklMmnATQOnk X-Received: by 2002:a17:902:1746:: with SMTP id i64-v6mr1590559pli.53.1518539200880; Tue, 13 Feb 2018 08:26:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518539200; cv=none; d=google.com; s=arc-20160816; b=s3XJyT1BYXKRT7ilGz9S7pBPLrbYZfytrLGZu+0zVf89oMhtJutCw0uMFEdp1zlhnL MMrvL6mYCfK5ULxS5oJjA8uMaF4KaptTXtBA5aab5yEOAYQqt/Huzu9+O5pGra1D3dDP Cr7iy4d54m20H8QvtShCjW8ZFbAKPnxYBcONEbq+NlcJK+qOM6vebnxFPzm2pLPWOMJW Wg0lcrwTpSpZq/OjU2fKfzaFzxcloRCUL1NHLhO6FsSsRjHOD+K2lIFAQHnQzTv7q2lu GQbIl0GAV7/pMTl0U3TasHgv6jL2mLKw7uP31QpbrwvjRJ/4jc/b4YuZ1MtTR0AHPyYE r13A== 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:dkim-signature :arc-authentication-results; bh=/JYCAtKQt9BTIFjX3YsBwUi41fNaJuRTNZKj4C1CiLI=; b=Wy1zUadjynLpQUT3LnsUMN/FvlveZdJUOAMawrBGJ4REHcxuB7zUG5z91+4tFi4WVs XIhU2QOU05kYXR9glnqMGevnADdyrPUpOsxCegQsaxxVqLBPpBEOZ8RHncvPbrEAq15Q ljpjKAI7OTmvTNcpZYpG5PbduqxjhEyHyR/FwCrcLI1vreDOOqXv8QkyfWUY33im+FpO DPt5qKGCAREOq25X3t012DVr2kE4i1kqAniVbJD18ju+p2Wv2ASkF7UZbCn+EIiHtR7b eapx+7jt28MzNLqh8VP0+OtpUACI5YOr4NGjAYtSs/s3RQP2KWhmj4vvzsVBNZsmezw0 PwLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=RYWqt6T6; 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 o6-v6si1241510plk.288.2018.02.13.08.26.25; Tue, 13 Feb 2018 08:26:40 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=RYWqt6T6; 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 S934803AbeBMQZj (ORCPT + 99 others); Tue, 13 Feb 2018 11:25:39 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:38786 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933927AbeBMQZh (ORCPT ); Tue, 13 Feb 2018 11:25:37 -0500 Received: by mail-wr0-f196.google.com with SMTP id t94so19165359wrc.5; Tue, 13 Feb 2018 08:25:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=/JYCAtKQt9BTIFjX3YsBwUi41fNaJuRTNZKj4C1CiLI=; b=RYWqt6T6s60pK/6LktpGp9LszoBDIlddHjs6yvDt6r1qDagRBKQpkTxlynb4cW32I5 lISQoJoRxJk3uYgN23xzAzBY2bkxo+opbl78L3wAmGkf02/Sak8XYa3NmrRcJjvYFc2o vAax18Kzt69HRd6SHkaPxyhlJaixurC/erS/ncrYxj/QCVGLkRRUYrNIAuW7DRlti4MK 0q9m9Jjkp0jo5f1sirj66OekofAhHNry5VopIsA/Cm7uh33w87l+l2jHCPxdzXXVVqgd mTilRlpu4CwIx5S7fvDXSTcL37P8EHhZT2zNdDRaDczESH0PRQWQ/hMF09cQc4Y2nixU gwMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=/JYCAtKQt9BTIFjX3YsBwUi41fNaJuRTNZKj4C1CiLI=; b=UW9cgi5sL5mQkUOL0OEz+GHfhUXShVrvJPB4QXIdRthkx6+qHsXvY/+HuQi/KE/wBy mbOVZ2uhsTD0x96BeC0GcZwAjVZa2hx9XBNrGTiJ6jP3EQvGeQ7D8HvOWfG8fPKAS9Bj kVU21XsRdZgjdIAWQUJqz7tfk/8QKQBkP2tfxppNS+colY1UkYd661J2RVXtYU4+8+gi BD0HNTOdBDNHQbKF7v/WdfFkImURpSwhoZzEpaFn+ixknmQW9asQ8t0SZzr2MCIS4JRJ LKNcsp01od9984BBe3/y6puuSPB1Jn0VRZb4UZkygZbKANr16VrK43OOD7WlUfrL1V7/ CkIg== X-Gm-Message-State: APf1xPAOJ6wJqK9dJ0lFkfV71vy9jrSBCZz3EXXyvZxf8aQm7tOh88mi PjhoemW0mswTcae0h0Gw4Fw= X-Received: by 10.223.183.46 with SMTP id l46mr1810404wre.33.1518539136389; Tue, 13 Feb 2018 08:25:36 -0800 (PST) Received: from [192.168.10.165] ([82.84.102.245]) by smtp.googlemail.com with ESMTPSA id h200sm7382241wme.11.2018.02.13.08.25.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Feb 2018 08:25:35 -0800 (PST) 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: <1105042a-327b-9be9-c0be-5f07f7110852@redhat.com> Date: Tue, 13 Feb 2018 17:25:32 +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: 7bit 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: > +bool kvm_valid_msr_feature(u32 msr, u64 data) > +{ > + unsigned int i; > + > + for (i = 0; i < num_msr_based_features; i++) { > + struct kvm_msr_based_features *m = msr_based_features + i; > + > + if (msr != m->msr) > + continue; > + > + /* Make sure not trying to change unsupported bits */ > + return (data & ~m->mask) ? false : true; > + } > + > + return false; > +} > +EXPORT_SYMBOL_GPL(kvm_valid_msr_feature); > + This is probably unnecessary too (the allowed values are a bit more complicated for, you just guessed it, VMX capability MSRs) and you can just check bits other than LFENCE in svm_set_msr. Paolo