Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3650352ybf; Tue, 3 Mar 2020 09:47:36 -0800 (PST) X-Google-Smtp-Source: ADFU+vvEscYer1jL6EvQCeXpFf32xOJ6Ee+0ynmjZEM5q0I9LzSE0CzT8gRwbGM5Xlo4qxMFYt6W X-Received: by 2002:a9d:7508:: with SMTP id r8mr4287191otk.116.1583257656531; Tue, 03 Mar 2020 09:47:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583257656; cv=none; d=google.com; s=arc-20160816; b=bOjHdceTM/nzJ9z4LJfZNhmcYcNHKif4oIRpHn57/uo34a6xoxxLqcP1YUil6K7RM2 o8sWa27yX56mh3nx3A6bxqwi6lOTU8egr3kM5NODreMmdzSb18vh+M6lwJ06oB1rRgMZ 2Xfxqv7uTHOecePySoBerSh9AROoy2tvCQRf2RhKbvvDKheobFKTQzSHjGhwuHJZWnMp Zhg9rJn6iuRxhrCQ08m00FBGizAwfIWpANN3LnO0itrVdhyWRqCc8rWWsYqd62UqvbZI qoT5Spkon4sSLSVCYjdRTqKGrFHeadlt59hkbUEUb8xi+WIC8TP08de1PqmOHP1Ppxh9 oENg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Gtm53TC5rqrHg3h0I9s+1/H4clMch7YrubYWxhwSBQI=; b=LgUg2ualCvOjUotXNetqNmoytxyELMBXGOLqtb/Pn8miqAs3c9aKRewecc5QyH1lhC JPjgFgkPbJ0qS+I5RjDT08VRJUR4rKcNbtY+weUlht4oFXvHePE5MXlU9j4GMm3fYm3o yO0knIIztjRPO66Y9Dgt3MB/AI7y+Ttw6k+EPUMI5h7MAjNRwvMXvEy0cJitmU4vi2Io 8uq7sRI0epTBm0Fdpgd1DUuKx09d+ausbjY2q+kPkbuzPCtXdCjFYkAneSMwJlO2taS0 sXBccxuTr7AmHOSnsz9bJnvTgGHaYZ0FZrDqU2KDzMwZ6RI3cbb88Mk0tCRPqRUVpbDt uVPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=b1jcbLgw; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q11si6798627oti.270.2020.03.03.09.47.23; Tue, 03 Mar 2020 09:47:36 -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=@google.com header.s=20161025 header.b=b1jcbLgw; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730521AbgCCRmz (ORCPT + 99 others); Tue, 3 Mar 2020 12:42:55 -0500 Received: from mail-il1-f193.google.com ([209.85.166.193]:39403 "EHLO mail-il1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728955AbgCCRmy (ORCPT ); Tue, 3 Mar 2020 12:42:54 -0500 Received: by mail-il1-f193.google.com with SMTP id w69so3514174ilk.6 for ; Tue, 03 Mar 2020 09:42:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Gtm53TC5rqrHg3h0I9s+1/H4clMch7YrubYWxhwSBQI=; b=b1jcbLgwz/oSW/Syh5ZSg2zyIcmG8ytdYX3QgbkeaKBI3ELKUb//qk2+9DWlYPai3q PguqBBpF9nF6tmxau6uB1enqyLCxYqPmyRELbaxd5EZW9OHb/KJxRjIeCI1oAEDFtKUi hxbL8KD9Lgl5HhXPJSXTU7nt9PZufXI4SYW5PZQAmW+ZzE2DbPWkZKfxizkMdwAPfPbf ir9Z7SxvDNkruM6RUd/5XoYEegF6JGygXWV21eyaZtALdiY9iDGKvKqoQ9ZSeCIYJcIK Xa3O8k9/42GoiijumnPhmbD1S7HLDdic/NKH3pUTffa1xtFUCGHObxvdFD5WHaPsbTO/ lkWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Gtm53TC5rqrHg3h0I9s+1/H4clMch7YrubYWxhwSBQI=; b=DvNv2xvBjW/m8DzrmsOI8A3XYScupcY9xe8kRFsVGIy8jRPBx6tKBaTKPUTCgNKtgk EjMxuYJI0Xzfl6I4OzW+Ipf5Tnx7lMhGAH0i2+WVhYMEbVL1XK8f2Yn/wuzn+rfX6sIJ pFngkUqxDLHT/MmMtcPYVodnBwKsA4MFECVd08q4czAJshXs/9o8Uk7pec8wPjQAybth BidBo8keHPzSWLVgwZRnEyEYaMciaf/uAJUx7d1UoaU/4xcnMpuDmwGCi9xDkvC/qcXQ EAoJILRE034sLcRQLAJqCisa+Mb+OUWcA8aGqbv4yvAQc9cbln2Lt/Y9K6k8VDuNT+6Y tilw== X-Gm-Message-State: ANhLgQ2vHHof0RRHKwKoiJKoUeDhrwRb5MlIBjO6ZMBIHU+A9yIk6Db2 ABhzKxuZKzzQqxvDD5Fx6eGWY1PXNXpmajEPQrWlGg== X-Received: by 2002:a92:8458:: with SMTP id l85mr6037720ild.296.1583257373851; Tue, 03 Mar 2020 09:42:53 -0800 (PST) MIME-Version: 1.0 References: <20200302195736.24777-1-sean.j.christopherson@intel.com> <20200302195736.24777-3-sean.j.christopherson@intel.com> <20200303045838.GF27842@linux.intel.com> In-Reply-To: <20200303045838.GF27842@linux.intel.com> From: Jim Mattson Date: Tue, 3 Mar 2020 09:42:42 -0800 Message-ID: Subject: Re: [PATCH 2/6] KVM: x86: Fix CPUID range check for Centaur and Hypervisor ranges To: Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm list , LKML , Jan Kiszka , Xiaoyao Li Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Unfathomable was the wrong word. I can see what you're trying to do. I just don't think it's defensible. I suspect that Intel CPU architects will be surprised and disappointed to find that the maximum effective value of CPUID.0H:EAX is now 255, and that they have to define CPUID.100H:EAX as the "maximum leaf between 100H and 1FFH" if they want to define any leaves between 100H and 1FFH. Furthermore, AMD has only ceded 4000_0000h through 4000_00FFh to hypervisors, so kvm's use of 40000100H through 400001FFH appears to be a land grab, akin to VIA's unilateral grab of the C0000000H leaves. Admittedly, one could argue that the 40000000H leaves are not AMD's to apportion, since AMD and Intel appear to have reached a detente by splitting the available space down the middle. Intel, who seems to be the recognized authority for this range, declares the entire range from 40000000H through 4FFFFFFFH to be invalid. Make of that what you will. In any event, no one has ever documented what's supposed to happen if you leave gaps in the 4xxxxxxxH range when defining synthesized CPUID leaves under kvm. On Mon, Mar 2, 2020 at 8:58 PM Sean Christopherson wrote: > > On Mon, Mar 02, 2020 at 08:25:31PM -0800, Jim Mattson wrote: > > On Mon, Mar 2, 2020 at 7:25 PM Jim Mattson wrote: > > > > > > On Mon, Mar 2, 2020 at 11:57 AM Sean Christopherson > > > wrote: > > > > > > > The bad behavior can be visually confirmed by dumping CPUID output in > > > > the guest when running Qemu with a stable TSC, as Qemu extends the limit > > > > of range 0x40000000 to 0x40000010 to advertise VMware's cpuid_freq, > > > > without defining zeroed entries for 0x40000002 - 0x4000000f. > > > > > > I think it could be reasonably argued that this is a userspace bug. > > > Clearly, when userspace explicitly supplies the results for a leaf, > > > those results override the default CPUID values for that leaf. But I > > > haven't seen it documented anywhere that leaves *not* explicitly > > > supplied by userspace will override the default CPUID values, just > > > because they happen to appear in some magic range. > > > > In fact, the more I think about it, the original change is correct, at > > least in this regard. Your "fix" introduces undocumented and > > unfathomable behavior. > > Heh, the takeaway from this is that whatever we decide on needs to be > documented somewhere :-) > > I wouldn't say it's unfathomable, conceptually it seems like the intent > of the hypervisor range was to mimic the basic and extended ranges. The > whole thing is arbitrary behavior. Of course if Intel CPUs would just > return 0s on undefined leafs it would be a lot less arbitrary :-) > > Anyways, I don't have a strong opinion on whether this patch stays or goes.