Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7459794ybi; Wed, 5 Jun 2019 18:32:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAu5zaUeCoL/cWAhIvIYrRIz15te/PTxWHV2vtlwM1XIizAP9O/va/Cj/FUPC8BwWA7r6V X-Received: by 2002:a17:902:824:: with SMTP id 33mr48945982plk.29.1559784762618; Wed, 05 Jun 2019 18:32:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559784762; cv=none; d=google.com; s=arc-20160816; b=tVWn1VNXC90Jg8FZrwjuJYiBm+yPi30XBcZGFsl6R2qiDyS4kDOuFGHdae6/y9UAOA /ozi52m7/OczV6AFAfkwIu3YUBFv6s+LfQ9fn4seG22QJF1qQYt2VkgovAFPJqOK7dQW PeysxhkNPn9jA4WVIgOczG5Ereq+0Ty3AMbIISlA9ePqjXotKC8ioEmHslr8o2AGM5VF 2qTOympJetuKl7T9OrAK8c51jNMlaSDowduAex+9qS0tSW7DPOdwZdU4SBgcnAxHn44n 1EJyoxtNDF6nfhx+31PyAY0wbCwcZEVWmXiUxkCaYbZknlItq7pRR0htuXjcgHyt+DkI hY5A== 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:organization:from:references:cc:to:subject; bh=H3MM9u2H6QtDsMyo9SueHKj5ySIi4t7wEUwLIDTD2a0=; b=Zsy2jdLXu3IBSbTs7o6iOodhIJUp6cS4+nMxnHzpZ7nR1UP3+7a9bvuoLXcuWuV3PO zqk6jKPrhW94ZsnV4XXNd8OQS9MkMNmaUFXH7raBkdpYnYxty2V/GqW0nn2nwdX7vNAb yADRgctM49GsYDz5sVRVZin8BnJGRqJTPZn6b2C5178eX+gihDXDCzCWhAkFG2AKVc60 qaNzI96LG3OMtJEfh0IYyDwsKafEmIU88eLIVFBLkUYzljd7FC03xPgxk3VfRgKcQM1P FpQGxjc3IVixeA6m2FcY7Dd+UmQhxRT6anCUz32AgwOzOyg3w1WrBwDTRnlqkvBZxZs2 Kbww== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e32si483278pgl.514.2019.06.05.18.32.24; Wed, 05 Jun 2019 18:32:42 -0700 (PDT) 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726701AbfFFBav (ORCPT + 99 others); Wed, 5 Jun 2019 21:30:51 -0400 Received: from mga09.intel.com ([134.134.136.24]:62051 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726593AbfFFBav (ORCPT ); Wed, 5 Jun 2019 21:30:51 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Jun 2019 18:30:49 -0700 Received: from likexu-mobl1.ccr.corp.intel.com (HELO [10.239.196.166]) ([10.239.196.166]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/AES256-SHA; 05 Jun 2019 18:30:48 -0700 Subject: Re: [RESEND PATCH v3] KVM: x86: Add Intel CPUID.1F cpuid emulation support To: Sean Christopherson , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Cc: Paolo Bonzini , kvm@vger.kernel.org, Ingo Molnar , linux-kernel@vger.kernel.org References: <20190526133052.4069-1-like.xu@linux.intel.com> <20190603165616.GA11101@flask> <20190603191818.GF13384@linux.intel.com> From: Like Xu Organization: Intel OTC Message-ID: <5e49ff48-9071-1419-ee36-bbc857164c28@linux.intel.com> Date: Thu, 6 Jun 2019 09:30:46 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190603191818.GF13384@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/6/4 3:18, Sean Christopherson wrote: > On Mon, Jun 03, 2019 at 06:56:17PM +0200, Radim Krčmář wrote: >>> + break; >>> + } >>> entry->eax = min(entry->eax, (u32)(f_intel_pt ? 0x14 : 0xd)); >> >> Similarly in the existing code. If we don't have f_intel_pt, then we >> should make sure that leaf 0x14 is not being filled, but we don't really >> have to limit the maximal index. >> >> Adding a single clamping like >> >> /* Limited to the highest leaf implemented in KVM. */ >> entry->eax = min(entry->eax, 0x1f); >> >> seems sufficient. >> >> (Passing the hardware value is ok in theory, but it is a cheap way to >> avoid future leaves that cannot be simply zeroed for some weird reason.) > > I don't have a strong opinion regarding the code itself, but whatever ends > up getting committed should have a big beefy changelog explaining why the > clamping exists, or at least extolling its virtues. I had a hell of a > time understanding the intent of this one line of code because as your > response shows, there is no one right answer. > Hi Radim & Sean, Thanks for your review and finally we find a better way. Please help review the new version, I am not sure that the changelog could help new submitter understand why the clamping exists.