Received: by 10.223.185.116 with SMTP id b49csp783764wrg; Wed, 21 Feb 2018 06:54:34 -0800 (PST) X-Google-Smtp-Source: AH8x224d0inMRWQeoNmtLu3aHBv5WIvmF0ZRsv6nJug5/NX0ECw60AWSfs5JKA6knm7R0S3R23E5 X-Received: by 10.101.64.67 with SMTP id h3mr2983128pgp.168.1519224874687; Wed, 21 Feb 2018 06:54:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519224874; cv=none; d=google.com; s=arc-20160816; b=xbYPF3CBsQv5j9xwk+YfOVtYpctiKPt16RzWxQEWJQqlZ/TzurkJZV2RVXxhO10rth eUOsidKBQGNUJdInMW6shrbSU33fNorUviizYMPUBD/UPh68IT/2g8D5y62lADRx9vrQ T43O3iIyF+nyq1x4mYlJ5G6BN/RcMmSf5UcSCEJsdY61riPNydWreezpn+gP74HNSpsb QC3HPlQZlRt5/5425IxgBKwc/8MXx1T3OmeeHbOHLnil+vTHIy8+tI/dtZvdekIo10XG L87bH7cU20hbcDHwMGM39uoWiw9o/F8IXEDMSd7SM33ASRKyovQ5hgzi8dvDYIeY1ALO SlbA== 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:references:cc :to:from:subject:dkim-signature:arc-authentication-results; bh=B37LW8ha/cLpF5Nn4d+X6CCXYhn8qSVUPQWmgLyA6Ak=; b=BHxeEuGMHaYcJd36rHJwHrpjb658P3F5/uEtb+l1T/LM66tSsXe5JLUYTbrXvAuAwR Nu3u3sgibTQsHtUo4npzIRDz7hDx3J33GNI6Wc9lIDWmLW2l053qP43RJ6QnIYWMaZjB Rly926XV0yG0F+IlyhUj5iWLnN7kmJjGZy81BmpeOjHFd8HQJ0a0bMjI5ghop8UkrK7Z EBImAEH9ZfBCcSHaRgRZD6Pl+8dN/5JqU+Xu7AH4LD++//vycC4uqVKkJFIkamf/ljS+ SmVh+7LpWUFHs9Qz3gTAkjPVO6+IQP4DlnAIdFO09dRyZqtl1lp22fncxUOwEFdDdrHt lj6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=AioDerSq; 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 j8-v6si54209plk.464.2018.02.21.06.54.19; Wed, 21 Feb 2018 06:54:34 -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=AioDerSq; 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 S937872AbeBUOxE (ORCPT + 99 others); Wed, 21 Feb 2018 09:53:04 -0500 Received: from mail-dm3nam03on0053.outbound.protection.outlook.com ([104.47.41.53]:49637 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933218AbeBUOxC (ORCPT ); Wed, 21 Feb 2018 09:53:02 -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=B37LW8ha/cLpF5Nn4d+X6CCXYhn8qSVUPQWmgLyA6Ak=; b=AioDerSqblgofvnagSeWvsX+S7lBaGjkbXoOrIoXMzFzOpZzbaudEZFibj5VAp4UvcC2EESED2fk5ltTubjQ5DYcKyFRG5T0WUL5bsaiDFbwgcF0o7Tp6k88RKrHzalVWiowHuVntIUdsCogLhLHA5jxHa9Uk2O74DDwyqvs+O8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Received: from [10.236.65.116] (165.204.78.1) by MWHPR12MB1151.namprd12.prod.outlook.com (2603:10b6:300:e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.527.15; Wed, 21 Feb 2018 14:52:56 +0000 Subject: Re: [PATCH v2 1/2] KVM: x86: Add a framework for supporting MSR-based features From: Tom Lendacky 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: <20180215231156.31016.79657.stgit@tlendack-t1.amdoffice.net> <20180215231206.31016.78914.stgit@tlendack-t1.amdoffice.net> <00583b68-d599-b709-133a-3741c258df13@redhat.com> <7f6a78ae-abab-2a03-aebd-e43e6fe168b4@amd.com> <94f6ed44-07ab-ff0f-2a6d-b3d8ff4ff4b1@redhat.com> Message-ID: Date: Wed, 21 Feb 2018 08:52:46 -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: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: CO1PR15CA0109.namprd15.prod.outlook.com (2603:10b6:101:21::29) To MWHPR12MB1151.namprd12.prod.outlook.com (2603:10b6:300:e::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 743adab9-2b28-4673-5bb5-08d5793acbd9 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020);SRVR:MWHPR12MB1151; X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1151;3:+LQg2t/UWUjx86G4pnUVSGli4yQhkxc0lZAqeGCpBwfSdqLMi8RZ9rgIuJURvdSR2GWN49Vk41uvoXzmUrT3ee7pGFuZZY1HHpjr07qZMFNzkbNv3ycmdWdz+33OjqS8uv+FRrLubCrtVtVQ1zrubxL6qNTTO2LrmV5yloHZwxv7edgYpdkVBc+8IBdY1psOcaYlGz1Uzsx+ncQGfjjso2o10gVk1a5F1MTC1nfProaI167TGRQn0pL0j4E8+ure;25:Ytw8LrGomzQEm5P9aINJgfrgM4flYkeOm0SyS3uUYIqm+HUV93vJr0IW1qf94FsAubF+W8ri+cQw+kB0/xRk4tkFrb/SVGFx8hTb267c7ylpPxV7YlIz+Vj7xq26wLDj1sREJq+7j6WYN8niOG1uc+MA3q/Yk7Q/NQzM8TmhRhzT4H97cHRv4tkxUP3y64LBLFGcaaAyoaF2755ql/3NXipU81wMYgwreYGb8TY0hSrg3zqEOTw1pXwzlGW6DsGWOS5yMXXJ39C26uAuDFoETy2j0WdvB9L2PT/1nvqRQKk+iawyZD1AJsI6JFWWQuzXVoWc9gh5QnUjyGKjaY91OA==;31:il+nnyc+fg0YH1ZVptk6aaCpkQEAkuLaBJ+RQg2T3Etk4pCyH1q2HEwPnmZwA42IIGmAdnu1E+BvG8nCkkkYdMPU67PxLIzlsEUEP3ehuzTqcblHv7DCUaJKDT019KRndw8nq5V81I3jG7Y80XtD0QJLDpVF46ZwEi80GJWzHGVi1OJL++po7J7yF35YYTD9IDT2lClxmRVTpUZgmW8j72+xLVRDtgZIJpB+GPGFCDA= X-MS-TrafficTypeDiagnostic: MWHPR12MB1151: X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1151;20:ZQDyoBUckS4HP/OF39r0ZFqKlrQz6a2HJRfjztJZ6Cgb23xz8ZzkeTHF2QEJ+K07xrDoLwbhpsCkQ0VAokooNh+qsR73tA8kquIvJthKOtKp6Tid9WaCY0LdxBjIyU8MQMTTDitT7WJsciEQnja4PCa6/5FpN6YQuBxIPVHia7VziSz3R8Igm578ZZmZeZYzdedmZzX91CSILjcOe+8vtyzDp5//wZtpPZa427IfeCk5Voi5msTzBLRb8RKuDcDkA7xiGaPkAfxksNbj1nK4maEP8eQ8Btq22p8IRE32CDB0GWud2ZVRsqalGkOLldC/n6o5iSHf+WeO7CNLWQFAGOeL4oidnhvgESwb3Z/u2B1LH8kfeEMLxxCeVmm1i3VlcOiNoulo2Kgikr78WecvMZ1BDAviE86by7q9qN4PFPZxfGPp7/c95cDhsIvmU20XWXwfto9zBsAgZA7Fbd3nPHo0YFKYzqN5KhBt56m9suxBOnTXkQimNxTboxgfgnUS;4:OYSudRHMU3rtNEb9xs/fOM5Pg1tK3Jzb6Jdq9n81oj3cA2kv6aQTTl5LNUR8PF9+4QpMM2juTw3FygAP2JFL1M6T+IdQ/gpYOPIS5VUMPeNztZYgJV8xcrF9hjKNAt65dY0D8RfVJ+sKnnuTlVQAgxEhoGHobBW0h8/jE6ymfL++yb7+RUsae4IiVjxmBvCT2CfkJq2yJ+428FQAd2v/Jojd8PepW0/ap7xBnhttUJCNRgMXuaJqH6IZLbeKa2JNcoBHNr40k5kpnHcWe+g9Zg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001068)(6040501)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(3231101)(944501161)(6055026)(6041288)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:MWHPR12MB1151;BCL:0;PCL:0;RULEID:;SRVR:MWHPR12MB1151; X-Forefront-PRVS: 0590BBCCBC X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6049001)(396003)(376002)(346002)(39860400002)(39380400002)(366004)(189003)(199004)(86362001)(23676004)(2486003)(52146003)(6486002)(2950100002)(52116002)(50466002)(230700001)(6666003)(105586002)(4326008)(47776003)(31686004)(65956001)(31696002)(66066001)(3260700006)(106356001)(64126003)(65806001)(53936002)(93886005)(97736004)(25786009)(76176011)(386003)(229853002)(6306002)(53546011)(8936002)(72206003)(966005)(58126008)(478600001)(16576012)(316002)(6246003)(36756003)(81156014)(2906002)(186003)(16526019)(26005)(81166006)(5660300001)(65826007)(77096007)(8676002)(54906003)(3846002)(305945005)(6116002)(7736002)(68736007)(6606295002);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR12MB1151;H:[10.236.65.116];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjEyTUIxMTUxOzIzOmVTbWJqaENmVUdLLzlLK3pPWTI2QktvbmVU?= =?utf-8?B?RnF6QlVSYWIyY3JUT1cxS3JLNVk0QUxFbFhJY244Z2M0RkZta3lzSGRFZnVK?= =?utf-8?B?UXU3VkR4L0hXSkpUU25lRklsZ3ZoQVd2QVNId3IrYkkvZFZCQW9TRmtyd3dB?= =?utf-8?B?T1hrRWhYVGNZeXBua3JkM2w1MFR3QkdsU0R2bDVaY0FmcEpiUWxuZEhwWnE0?= =?utf-8?B?cTFRUTcrNTYwcmk5b0ZLUCt0WGFkOXFKVUlvV2lMN0p3QktGM0tML0d5TEF6?= =?utf-8?B?UTRIZUh2Rit4ZkRlVmU0U2lWZEx4WE5RRktzMkUwTGdMQVhtWkFaR0ViRmxM?= =?utf-8?B?ZlI1QUtmL01mbWpYU0RUWjh2SDNwaFFnUk9yeUthcHVBdWFuQWpWTExpbzNz?= =?utf-8?B?MEppeW83bnFrM0hFUTk4dkptL2pDZmI1N21zdzlCaER5RFZRbUloeUR5bENi?= =?utf-8?B?RGJOa1F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YaXLW0uyfplhKnAPjHB8CeSSsDkPafVxGj8L+Kwav7TpKOU53eVrERsSSf4xyUqpTy32DRHxkx3wSIZ3NPvSrce6gCoMkObw=;5:xSe2aJFXWQqunqPqFLUUPO5B3vEjAGafAaiOTEJ/zzEhHfzGFSJSYchOsUDVqV9grui0v4NcCrzctzyGgJGf3qKuta/eCGzz0OxFpTPq7YgqdMvhmTKuOzLSKQtSIZT4Emo0ZhS/M0RMNtOe8tS0c/IFfhjs9wPDFF6BTB6A8G0=;24:TDVInqHob+SI4dyYolYmB8aYCTtvtEk5MT69J05miU5ybqfawfkwesBaObpYQff4KS+eJgVKsDPBnfvUzmyz/5xef55UIoB7vzzNgd/44ks=;7:YTJ/nn1j2Wk4Am47Pa/WmazOLlaW5sy62Cw4B8ooPxB3ls92A+b4AVFLoCA2diONJ3zxOhaabrtlnPbIVp97f8MIYzfDsNhWwxynMRanmJURTfyULYUiiUufbupyLTXeYcaWgSegvcboeQF8AYZegnbEyjFfAHUcGD6vZrqUhcdwja+eM7CV0qeB6+gAw5mEJXL+EynyrN/eveT/HU92clIyZrtYe09dnigmdsHm6snY/4pEnY3Mbe0lL912mG1+ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1151;20:miHHopBDnUVSTrwSJDhrFFQTv4BURY31xUZfzOMGmTRqjOPJnTw3Ty6Kaf7j9vHbwineqenKaS+eDwmrUfsX04fYyFizcffKtOshZ19FaHggfavh370hXa7BDYZgww+4axVVP8pLZ1/3/ESp709+S0JoPWyr+4bQmnnfmDCvW///2+P+tiXWgJuW/hIGMSKFGHhcBlvgisdZ9chMmJwPu23L1WwCHc0+9aJntZAVcBMGzu921v5yt9+YfbRweT7o X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Feb 2018 14:52:56.8814 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 743adab9-2b28-4673-5bb5-08d5793acbd9 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1151 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/21/2018 8:47 AM, Tom Lendacky wrote: > On 2/21/2018 8:32 AM, Paolo Bonzini wrote: >> On 21/02/2018 15:15, Tom Lendacky wrote: >>> On 2/21/2018 5:41 AM, Paolo Bonzini wrote: >>>> On 16/02/2018 00:12, Tom Lendacky wrote: >>>>> +static u32 msr_based_features[] = { >>>>> +}; >>>>> + >>>>> +static unsigned int num_msr_based_features = ARRAY_SIZE(msr_based_features); >>>>> + >>>>> bool kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer) >>>>> { >>>>> if (efer & efer_reserved_bits) >>>>> @@ -2785,6 +2794,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) >>>>> case KVM_CAP_SET_BOOT_CPU_ID: >>>>> case KVM_CAP_SPLIT_IRQCHIP: >>>>> case KVM_CAP_IMMEDIATE_EXIT: >>>>> + case KVM_CAP_GET_MSR_FEATURES: >>>>> r = 1; >>>>> break; >>>>> case KVM_CAP_ADJUST_CLOCK: >>>>> @@ -4410,6 +4420,47 @@ long kvm_arch_vm_ioctl(struct file *filp, >>>>> r = kvm_x86_ops->mem_enc_unreg_region(kvm, ®ion); >>>>> break; >>>>> } >>>>> + case KVM_GET_MSR_INDEX_LIST: { >>>>> + struct kvm_msr_list __user *user_msr_list = argp; >>>>> + struct kvm_msr_list msr_list; >>>>> + unsigned int n; >>>>> + >>>>> + r = -EFAULT; >>>>> + if (copy_from_user(&msr_list, user_msr_list, sizeof(msr_list))) >>>>> + goto out; >>>>> + n = msr_list.nmsrs; >>>>> + msr_list.nmsrs = num_msr_based_features; >>>>> + if (copy_to_user(user_msr_list, &msr_list, sizeof(msr_list))) >>>>> + goto out; >>>>> + r = -E2BIG; >>>>> + if (n < msr_list.nmsrs) >>>>> + goto out; >>>>> + r = -EFAULT; >>>>> + if (copy_to_user(user_msr_list->indices, &msr_based_features, >>>>> + num_msr_based_features * sizeof(u32))) >>>>> + goto out; >>>>> + r = 0; >>>>> + break; >>>> >>>> I think it's better to have some logic in kvm_init_msr_list, to filter >>>> the MSR list based on whatever MSRs the backend provides. >>> >>> Ok, that's what I had originally and then you said to just return the full >>> list and let KVM_GET_MSR return a 0 or 1 if it was supported. I can switch >>> it back. >> >> Hmm, I cannot find this remark (I would have been very confused, so I >> tried to look for it). I commented on removing kvm_valid_msr_feature, >> but not kvm_init_msr_list. > > I think this is the reply that sent me off on that track: > https://marc.info/?l=linux-kernel&m=151862648123153&w=2 > > I'll make it consistent with the other MSR-related items and initialize > the list in kvm_init_msr_list(). I'll change the signature of the > msr_feature() kvm_x86_ops callback to take an index and optionally return > a data value so it can be used to check for support when building the > list and return a value when needed. Hmm, actually I'll just leave the signature alone and pass in a local kvm_msr_entry struct variable for the call when initializing the list. Thanks, Tom > > Thanks, > Tom > >> >>>> >>>>> + } >>>>> + case KVM_GET_MSR: { >>>> >>>> It's not that the API isn't usable, KVM_GET_MSR is fine for what we need >>>> here (it's not a fast path), but it's a bit confusing to have >>>> KVM_GET_MSR and KVM_GET_MSRS. >>>> >>>> I see two possibilities: >>>> >>>> 1) reuse KVM_GET_MSRS as in the previous version. It's okay to >>>> cut-and-paste code from msr_io. >>> >>> If I go back to trimming the list based on support, then KVM_GET_MSRS can >>> be used. >> >> No problem, renaming is enough---I should have made a better suggestion >> in the previous review. >> >> Paolo >>