Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752006AbdHALfl (ORCPT ); Tue, 1 Aug 2017 07:35:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50980 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751857AbdHALfj (ORCPT ); Tue, 1 Aug 2017 07:35:39 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B11E8C07643E Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=pbonzini@redhat.com Subject: Re: [PATCH] KVM: nVMX: INVPCID support To: David Hildenbrand , linux-kernel@vger.kernel.org, kvm@vger.kernel.org References: <1501161639-9707-1-git-send-email-pbonzini@redhat.com> <0b82ca85-7b3e-9dc4-a102-24d0e9033dcd@redhat.com> <42be1e05-b6e4-42db-5ed8-276d61c4334d@redhat.com> <60a8347a-744d-47d3-e53b-3218f5c50623@redhat.com> From: Paolo Bonzini Message-ID: Date: Tue, 1 Aug 2017 13:35:31 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <60a8347a-744d-47d3-e53b-3218f5c50623@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 01 Aug 2017 11:35:38 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1110 Lines: 27 On 01/08/2017 13:18, David Hildenbrand wrote: > >>> Can't we rewrite that a little bit, avoiding that "best" handling >>> (introducing guest_cpuid_disable_invpcid() and guest_cpuid_has_invpcid()) >>> >>> bool invpcid_enabled = guest_cpuid_has_pcid(vcpu) && >>> guest_cpuid_has_invpcid(); >>> >>> if (!invpcid_enabled) { >>> secondary_exec_ctl &= ~SECONDARY_EXEC_ENABLE_INVPCID; >>> /* make sure there is no no INVPCID without PCID */ >>> guest_cpuid_disable_invpcid(vcpu); >>> } >> >> I don't know... if you need a comment, it means the different structure >> of the code doesn't spare many doubts from the reader. And the code >> doesn't become much simpler since you have to handle "nested" anyway. >> What I tried to do was to mimic as much as possible the rdtscp case, but >> it cannot be exactly the same due to the interaction between PCID and >> INVPCID. > > It's more about the handling of best here, which can be avoided quite > easily as I showed (by encapsulating how cpuids are looked up/modified). Yeah, I don't like either option. :) Luckily there is a second maintainer! Paolo