Received: by 10.223.185.116 with SMTP id b49csp235919wrg; Tue, 13 Feb 2018 20:43:50 -0800 (PST) X-Google-Smtp-Source: AH8x224127LWRUXRWHEq/jCtRPwjKFmI/Ega+Qevtrr4rF3FcGUI7j8LqvYB7B4h6fY46bn88hwW X-Received: by 2002:a17:902:8546:: with SMTP id d6-v6mr3226202plo.147.1518583430205; Tue, 13 Feb 2018 20:43:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518583430; cv=none; d=google.com; s=arc-20160816; b=s8iixybKMNxdOKoL/IJXglHgXMvsXgVlHyjdMUwUIk+E4kdWrviSC+IhqxIAoPxQeX Iznk2rmPQwEScFcvL1IAzJZCwa+/gyGN4CfA+IyAeIFR9SC0gDujPxvAGdH3oK/YmriD Tba4Cz/Ewr1i9ou5aQ9nbKxOaRklFZxCwnh95hCm5HcvCJNegcTFu4gCNk0SYMXKLuaf oEkXxzoPR45U3at9yFNEiNkQE/MTjqThWAQ119wOQ/n74RScCTP7vuqpaX5TlT+SzrtM UQJq2/aRCQp70MnugfPtoeHDWiOylKLpWRIfEZlfoAEy5Y8MKHcft0nT2EDdUnCSWMSB zJdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput: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=trNDJ6t9noiV87AehgSqXdu58yZYTSZs1Kio1pDvi88=; b=iDrC8tbEqxGqlgg5E+K2D2ExuQEsPsxQHmtsHTLwjX1lPRdPi5lkX9FOiS4ipQWf8H mMug5uvwMLdOnt/Z3c/w7a2OUN52X4KyOwkWreOtzjxmpuYpnU6kehCQoyC/hJZQRSn8 vcyhl7ABDgb8TtQGeVw/BSH7r5UeejcOK6fMvag14Ns5iJ1YKky1jjTidnOqTt1eOsRx Ujmzv73AGMcK76gcYCs8YvuFvNNmTRsN/ulgdh2GFH9ap6FhCDz8eTYloF7XcS1FAeV5 AZcEin0i1ktFYsO7pwj1cEBOgt2OsVET7aURiUtZcEC4bbIPTyChnv+iQJCwUuXgU5+4 J8DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=3N+dzXFK; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y92-v6si6439476plb.137.2018.02.13.20.43.35; Tue, 13 Feb 2018 20:43:50 -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=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=3N+dzXFK; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966899AbeBNEmK (ORCPT + 99 others); Tue, 13 Feb 2018 23:42:10 -0500 Received: from mail-by2nam03on0087.outbound.protection.outlook.com ([104.47.42.87]:36722 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S966761AbeBNEmH (ORCPT ); Tue, 13 Feb 2018 23:42:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=trNDJ6t9noiV87AehgSqXdu58yZYTSZs1Kio1pDvi88=; b=3N+dzXFKFp7BULxVuJwE4mCdzhKNCE0NMGgi3cwXgDeN3HUaPkkb07C5e46OS+7mikJUeMnSDDA4auf1PAdJMgLt8OqSKzZmpaZqWxJBhPlW8HlOgTtnf6sdN0kj5vgeuU8yAJhaqMkBLl2cDic+SBNz2SOgOkoPrL1EI/BG/iQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Received: from [10.236.65.116] (165.204.78.1) by CY4PR12MB1141.namprd12.prod.outlook.com (2603:10b6:903:36::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.485.10; Wed, 14 Feb 2018 04:42:04 +0000 Subject: Re: [RFC PATCH 1/2] KVM: x86: Add a framework for supporting MSR-based features To: Paolo Bonzini , 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> From: Tom Lendacky Message-ID: <79f0ea64-6634-4b1c-7ac6-82f6798c680b@amd.com> Date: Tue, 13 Feb 2018 22:42:00 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1105042a-327b-9be9-c0be-5f07f7110852@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: BN6PR08CA0086.namprd08.prod.outlook.com (2603:10b6:404:b6::24) To CY4PR12MB1141.namprd12.prod.outlook.com (2603:10b6:903:36::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 33c99569-8b65-4c3a-7ce2-08d573654cb7 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060)(7193020);SRVR:CY4PR12MB1141; X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1141;3:4dEjq0KxkhcUBX7+BYGxmQ9dTk2P+xl/xXhhUc62XJJXxqzTQ4RDnPJMqBPDU/DG1rKnH7U3EeADLBhOmZh/xqmzlxxHnIhIGozGbskI5l6xV0GM8+XcSlxNnfrCsii4RSPw9UM+Z9bzuRhGSLmUtHu5b8kOaAZlc9bqDVDeq9WzJH7z5914LsaS242Uxu+jRvijZtyLTy6BWuZkVPrQnH/rVLO0w9jcyQO2w60dncDFh23xph8FeR0MhfRFLP5a;25:fcshNHpW4m1YqVitGu5yljD7WDkEuI15P5PENBi62W30/pATNVprbRJBUtQlVQx72Kb9Hb5S/iUbfxuLv1srmbedGh9HmLXB6/kt9rq0N05/xPdjk3mQgyywe5a4S7bVfoFQJzi85J5qZkSplK02o/PMJBbv5I8M9qxHATCE2sCsGrJL0HiNOnSuKijt89a2zF2RsSjtEN5gQtARnzMUOEOQuMCL31IIaw0zJknJ/vFcvSfTD4nxK8QJz0hzdUOm+v1CRE8hK3lSMQ5qGd+EwzD7/VSV6x5pSqPlAAnVpxhiak6vC9JwOl/JhFT9+GUb7cYwNnwK1tSO+K+Ttu7VNA==;31:bPCGc8YV3Sftk9grJnPxjZ+LkRMIacwf690YClJ73u1un1bEZO2MBZeoo4vTOdfbY1cy+OimZM+K/8EPQRKO6/FMtrBLc12V/mxWYgOLzuZb30u2T4IAiuxjaBIayI4Q5nKJzJm9BfF4/TkXx8gRv3ne2uIviIy6AkfbzGFH9VEZmFeJkwn464jhD9TMsFXgwOLgmLj8tXkLPCwYgm/DSC4r6RXpQuuxGB8yITrLOdk= X-MS-TrafficTypeDiagnostic: CY4PR12MB1141: X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1141;20:JdGJ0ICfVGhnN6J6/EwOWuXqw15eiGTPxS4Zi457Xz3cHqUrs5AgCFdcBKrcKrdPDECZUnZ012LqMkC/Vmv+OC66Ml3Mnnzq/NUrq75z6QujLN+Lxo+jiUr/ACu0T+IotppV7CmdfkXNFbT/2WmRDQic1VkFjuP3W+Y6iubDL7wwC0+V8Td389eE+fYQH1yRia14r+OB3MsI0vdEK38fSyQUZoYayUwg9V/xaAsUafgGn6MgvCFF0YeJcJkYAdJ2PSvrWqpOCI/nfWn2EZ0/oQUrcDkxeLLvJRfq242119hrE/ZfSGmdbHsjzRVIjchbQ1bfNMQTFgiWY4ma9OfwlW7hSezv817YoGEg/ds1frPKzlZV2wDA2PoUUtqgpPIf4CPlGcS1kT1G3QP8DMFwPJ/jmb8D5UxK+nruGHHrOSdO9RPGQHK8DBytsMA4WY3YnwDCro5GYgGcxoUOQr2JO9+BfwVRbPZhQiWjIg4UG+tnkhNKIWSr2Czoy4My3h5p;4:2zyoKyuv4mOXq0NraAg/BJiXYS4mUsZzrJTwRmdB8d0xhi4cBpBdawfsSq9ycLlYdB2gc5u0BYvBf1fb+2IhObRVoZBl3wX3P1r4mgQYIOr7F9Hsnq7lCNbszMn1EsFtBGL8az5bfbIcYgv13SwRcyOYsPwKrXIMYjlktN4heBE+9HHCMoLhPuCEa5iN8geQyjGb2pVp7v7QIz7/iFzJ0kqeYWugbMhtTrmcJCww0qvAeVaeKQvVxE5yRGE+vIrQ5VHfmrwasVaWgBmC4c2YIw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040501)(2401047)(8121501046)(5005006)(10201501046)(3002001)(3231101)(944501161)(93006095)(93001095)(6055026)(6041288)(20161123562045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:CY4PR12MB1141;BCL:0;PCL:0;RULEID:;SRVR:CY4PR12MB1141; X-Forefront-PRVS: 0583A86C08 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6049001)(396003)(366004)(376002)(346002)(39380400002)(39860400002)(199004)(189003)(66066001)(52116002)(52146003)(65956001)(65806001)(229853002)(64126003)(8936002)(6666003)(68736007)(16576012)(81156014)(8676002)(81166006)(50466002)(47776003)(97736004)(53936002)(65826007)(2906002)(2950100002)(5660300001)(6246003)(83506002)(58126008)(36756003)(53546011)(76176011)(230700001)(72206003)(386003)(186003)(6486002)(31686004)(16526019)(31696002)(6116002)(3846002)(23676004)(2486003)(7736002)(54906003)(316002)(4326008)(105586002)(106356001)(3260700006)(478600001)(305945005)(26005)(25786009)(86362001)(77096007)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR12MB1141;H:[10.236.65.116];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxMTQxOzIzOjM4TS81VWwreThZcHdqYTMrZVp3OVdwUnA3?= =?utf-8?B?QVFrd3RnaHJzUC9LYk8vOGhxWEd6OUQvMXBMRExTRjk2U2hoa3U5MVlXN0dP?= =?utf-8?B?UWRxajlHekFVZkRQMjV6T0Y0cWdMdTU4MkU3ZksrOHJUcUZJZERnUUR3enRK?= =?utf-8?B?L0tFd1NLVkc0UStnUHhyWTJqdHpmZjJ1ME1iM2g1bkNaSXYzRnBsNDBUYkI3?= =?utf-8?B?WDFKVzZUUDlnemhQUmp1UUlLN2NKa1UvL0NQOUx6Vkp5U1Y4QWRDRFlKaW1X?= =?utf-8?B?S2FUNnN3Vldyd0J6MXFvdmZiRmxoMFhwWk96YUJ6TUpPazQwR0ZUUzNCSDI4?= =?utf-8?B?N2ZhZ3Z6TmN2OWoxMVpRRTF5TEQ1T2p0OVd5T1YwdXo4K1NTczB2Yitld2Rs?= =?utf-8?B?NWRIVE0zaHl4ODdiZU81ajd4OGpwc3lnYllkbmg0TGlsVHVtdEh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FRwxMa/l+0=;5:oZ5Xsm6fVlr+JIV+n4L7BXxSH30WJsn1YHsvCEWOpL+c9PTROxwI4d5YgJESDy5S0shvSadODglEBWWtCk6N903w1GTVUZMxFrpPUM5sHb7OTmcO3bPcVc2OZVsDHFHpml1hpCZQA1LfmgwTjel7Y3Ca1YAhmNSRgkgGNVtLJu8=;24:MjPkXbyvNbRcBOAArrUq1UNBjzYYhnCPCvMBn7BuWjUDE1RoTWKxggKjdFETF7CPvyNQFA+n+qAKZj7URtsZV/SyCasODR06kfx9CZkEJZI=;7:AksgaNm91kh8+EnS3mMnkKPMRlXbKqd0lea+mbEnpqamGTCQhctlcmFp5LcPzxWoynqr0TwEqyPX/LIt0ejWTV9pk2oUFzibiwixezrFWwJceG6VpvZ5aFIJ7qRyLiNBdKTDDvtK5V2gFMAg8YzMuTfGQ/6yC8nU18OD+SGAGb3DUzZwLb0NFJ2xSzqsvh1B/57g5Q8yw1ohnUipXiC/Zx+jwBkNtA/TBDKdO6jj7nuDd7kaWguQUBQzzm/I7wNV SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1141;20:o9KDIcPA3cNNDSLHWg8P9QY5NaHpt9+irSTRjzkOpUxWZa2JApvTfeIZy2zpbicllum/7LZ4vkUJxKnau2nibV3jvegbgPGDKw0btOvjC3nOsJVzn7YvPe5eSjFay3ISbNN0Uy/XMz8wCYn4hqBt6Bte3phyYHBVnhv7PU6J1s1rgcH91cGrkw0TWhE2kxN/dFxJVOe5ihpomB4P50zSiRT36fXudNN7R0AAfQVOHatLelc9RtR5Cti9QWmv5H3i X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2018 04:42:04.8933 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 33c99569-8b65-4c3a-7ce2-08d573654cb7 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1141 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/13/2018 10:25 AM, Paolo Bonzini wrote: > 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. The whole routine or just the bit checking? I can see still needing the check to be sure the "feature" is present. Thanks, Tom > > Paolo >