Received: by 10.223.185.116 with SMTP id b49csp1133306wrg; Wed, 14 Feb 2018 12:08:16 -0800 (PST) X-Google-Smtp-Source: AH8x225LWiqJVrDTp60H4KAUllsdYj2ReG7cWA/4r4MY69d9HG0dxlbl+Rlm2ZkyRLi4rDmaLKTd X-Received: by 2002:a17:902:5682:: with SMTP id j2-v6mr161628pli.441.1518638895920; Wed, 14 Feb 2018 12:08:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518638895; cv=none; d=google.com; s=arc-20160816; b=yvlrYJzg4xDrV5t8v1aHl9EYk2bt3PS8ZBELA2U/FPb1qUw+I62aAXSEfjOR9pe47A mCu6bxVGOLXbSUpDVvAFBuMTSn3tvZedIvgozbKmLdLuvePT3uh3fYl8nS8WLi0M+QTe BcWdpqgQbjHSjhVxTvlfeQCX7q8JfoHEM380okGnJ+MMnX3ibYC5dF+yrBnL0mp1WoIN XJqLrqEYm4Cr+giCcbNetk9DKR2v1yg4E8t6qNP7Cw/7p0d7lBvQr8+xWoijQFfMeqwT eXlZuFlorXOzCYqx5dxj+SptTofzyGkMNeIVq2fn/8OxCS6Ig8ktjmPM7ij2ytFM/vsu Z/nA== 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=ZlZ/s1ueUf/7rFrUKcXrgenAYHnWuXNUDLHthI+hdIA=; b=SB8vkQ1d8F0976tmSwKv+edIqKy1Dx/CH8PDU/Di3dtko0HuiOYDJXlZ+dPimO61Ro zemk5j+UIhEW1KV7W44yvlkF3v6H6iiS+UKqYcQzHSFLJwmWU8BZQkMGaWwjqyzloI6Y hMQb7sX8DIraIPOXEjxJJ0hUk6e0ubAcuz8xyykZW+xliIxGWHZ+QEj7ZThxRukSpGLa iBbxVc2y3R34MaDWJjrDfd7wdjGfEnpuSWId/FIjdzb/zkaFKDm1Dh6IDpmYVsgp/jvw 1A1ne3FZyJ1w4K2Szc4mj5kH+Fs5JFrw0/xtJQfjVawwdHXu0PILnysDknuFa9Gr4RO0 pTkw== 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 33-v6si8471plo.650.2018.02.14.12.08.01; Wed, 14 Feb 2018 12:08:15 -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 S1032752AbeBNQlO (ORCPT + 99 others); Wed, 14 Feb 2018 11:41:14 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55644 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032470AbeBNQlN (ORCPT ); Wed, 14 Feb 2018 11:41:13 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1EFAD7CBB2; Wed, 14 Feb 2018 16:41:13 +0000 (UTC) Received: from [10.36.118.14] (unknown [10.36.118.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BECD7100839F; Wed, 14 Feb 2018 16:41:10 +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> <1105042a-327b-9be9-c0be-5f07f7110852@redhat.com> <79f0ea64-6634-4b1c-7ac6-82f6798c680b@amd.com> From: Paolo Bonzini Message-ID: <8f76fafc-ce4a-8460-261e-93480e694609@redhat.com> Date: Wed, 14 Feb 2018 17:41:06 +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: <79f0ea64-6634-4b1c-7ac6-82f6798c680b@amd.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 14 Feb 2018 16:41:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 14 Feb 2018 16:41:13 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.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 14/02/2018 05:42, 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. > > The whole routine or just the bit checking? I can see still needing the > check to be sure the "feature" is present. You can return the MSR unconditionally from KVM_GET_MSR_INDEX_LIST. Then KVM_GET_MSR would return 0 or 1 depending on whether the feature is present. Paolo