Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966403AbcDLWJf (ORCPT ); Tue, 12 Apr 2016 18:09:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57428 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965945AbcDLWJc (ORCPT ); Tue, 12 Apr 2016 18:09:32 -0400 Subject: Re: [PART1 RFC v4 09/11] svm: Do not expose x2APIC when enable AVIC To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Suravee Suthikulpanit References: <1460017232-17429-1-git-send-email-Suravee.Suthikulpanit@amd.com> <1460017232-17429-10-git-send-email-Suravee.Suthikulpanit@amd.com> <20160411205423.GA29328@potion.brq.redhat.com> Cc: joro@8bytes.org, bp@alien8.de, gleb@kernel.org, alex.williamson@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, wei@redhat.com, sherry.hurwitz@amd.com From: Paolo Bonzini Message-ID: <570D720C.8020603@redhat.com> Date: Wed, 13 Apr 2016 00:09:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <20160411205423.GA29328@potion.brq.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 976 Lines: 31 On 11/04/2016 22:54, Radim Krčmář wrote: >> > >> > static void svm_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry) >> > { >> > switch (func) { >> > + case 0x00000001: > ("case 1:" or "case 0x1:" would be easier to read.) > >> > + if (avic) >> > + entry->ecx &= ~bit(X86_FEATURE_X2APIC); >> > + break; > > --- > A rant for the unlikely case I get back to fix the broader situation: > Only one of these two additions is needed. If we do the second one, > then userspace should not set X2APIC, therefore the first one is > useless. > > Omitting the second one allows userspace to clear apicv_active and set > X86_FEATURE_X2APIC, but it needs a non-intuitive order of ioctls, so I > think we should have the second one. > > The problem is that KVM doesn't seems to check whether userspace sets > cpuid that is a subset of supported ones, so omitting the first one > needlessly expands the space for potential failures. Yes, we need both. Paolo