Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4517428ybi; Mon, 3 Jun 2019 12:19:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvhGym4vVq+ZS8krwwrTeUKOlogrD7N805LrBtYLcbIu0YkORJkpEuonhaSgm6+XnFRxs2 X-Received: by 2002:a63:1d14:: with SMTP id d20mr30756251pgd.281.1559589583135; Mon, 03 Jun 2019 12:19:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559589583; cv=none; d=google.com; s=arc-20160816; b=KVdeJUig79wMEOGmSW5BHP2+EJvZj6phr9PG/nbcZoWWbsqYrCUk0FDsZxhqYTPVhY 0t2HcsNQVOpQaRnyL1m5iR5g2daxLmq+qj/nBKYEA15HVAG5v0cX3JzHvS31ZKuULsA+ /MjoXQKzDj50pyI7IOKmAZ/6W7NrqYA+N7dUajcRBo9EVkGaJ0hrO6GnBqY5W23gtO0l OtrsMlvv4aR1iSxPfsWTQRGm563wNcN3YIZj6YXOPyMXS7kCacatDRSpvrQ4gOG0J3LH 5nVpQsSM4XKDNaFqFWJAGNjvLbtdXNRaypQvb3Zw1Z7JkbAIsOiLU7By+/z0vGxRB5fQ PGNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=pdNnUFbduuPd3F6dyrCa5UuVfRZNSbbBn07GvT15l8w=; b=TvB66yN4Q57t82q5qPbpoogGBSM7SURTommei+7I0qlRvXV66nd3WAFPjz0viEGV1R 0ZKoY6k09Ooe+u+4r9WWtBMvTI8KeEpMn6P098wsorahzh/1ctgaxqyZ30lj6R+HK8SU v8yXod1NOfq4wZE7cQBZz2q3nJqG1BPjiaFa8VW2KdGPpUWaIp5KLPCGdX7OxJY5fDpi XkYL9prIN6m9htVUWty0Ma8DmTFd/m6j5k0WivcIQ4xejb8c3y2ZqaOVuIs0R9JJDC5x xl1+DqCcSJ4ghXRu804Z7Kg137Grw2nxdctpYJICbxHxQ5GPujP7BFsmPURldMxsntpR za0Q== 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 k24si18298624pgj.510.2019.06.03.12.19.25; Mon, 03 Jun 2019 12:19:43 -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 S1726531AbfFCTST (ORCPT + 99 others); Mon, 3 Jun 2019 15:18:19 -0400 Received: from mga11.intel.com ([192.55.52.93]:55903 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725876AbfFCTST (ORCPT ); Mon, 3 Jun 2019 15:18:19 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jun 2019 12:18:18 -0700 X-ExtLoop1: 1 Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.36]) by orsmga002.jf.intel.com with ESMTP; 03 Jun 2019 12:18:18 -0700 Date: Mon, 3 Jun 2019 12:18:18 -0700 From: Sean Christopherson To: Radim =?utf-8?B?S3LEjW3DocWZ?= Cc: Like Xu , Paolo Bonzini , kvm@vger.kernel.org, Ingo Molnar , linux-kernel@vger.kernel.org Subject: Re: [RESEND PATCH v3] KVM: x86: Add Intel CPUID.1F cpuid emulation support Message-ID: <20190603191818.GF13384@linux.intel.com> References: <20190526133052.4069-1-like.xu@linux.intel.com> <20190603165616.GA11101@flask> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190603165616.GA11101@flask> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.