Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5927231pxj; Wed, 23 Jun 2021 12:03:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQbGRc1AxM2qv4DBWNhJsZEVcOeZhH/PCUHmXXygzQ61VIC1F05v8Y/Vx/pvClO1Aq8gHJ X-Received: by 2002:a05:6638:110e:: with SMTP id n14mr1046902jal.4.1624475008623; Wed, 23 Jun 2021 12:03:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624475008; cv=none; d=google.com; s=arc-20160816; b=E7OMZwrdfVqGWL4fV54llJB09hqc1iYkzT8zy8YdYtiRyIlIj7SO+oYXujCWaesgmJ YSNb4mAkJL93XmYbgAQnMHpIM3U1w7F2f3GdBi73ErgF8ksVFayCu171BF/Ir/ON+yAe Auso9ocQ4wNVoCnyo1tLOA52yiVbsDn1lzw3sRDs+YvhXFDKzyDK4YVBUzzKCrzuinAS Ymtw4UoWX3jFqRPp1ljgN7O9EWNCbmvMP11zSu6N7T5obcP1Edjn2cZmCsrZ6lW2fDdC cpbst3WKS9qOiljVxp1qYP6E+iJP3fZVa8ljqF2gK7uD8/QigyxHDjSpbbzVpGrXknVU 3qTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=MRqftscF1FzfzzSjl5zFo7iO4VJxE2+eaqEj1NzMIwk=; b=JEa+IKM7+EIDr/09tUSlWP6l92TtZUOkQbG0PBw7eFOQCO2xez7E0O++uJ+cFC/atN q6FYUs1PeRMWmVDv5VE9RJmizRArO4HRv72CYIXOHtPWJMpJ9yhAWywceB94UMnc9zUX iGC4CmKaPvlN90KOmfeQeYJT+L70nvnmuLPFm9g5QnBHGBbDNsQ69bfFTZtMeCLpi5iD Th48OetGZsQcSoC1ys/C85J6bIenV4Jbt7aAVoGpNf8debvAucnnvMgSQLU2KP8cgPe6 uILZhMnsWy+MDpOnxAu1q5acNiYnQVlNWC+PEXbPXg12dlb9L39x+tvqiOKmbV1zL1ZF sAzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=N3zmO53v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id a14si879702jat.22.2021.06.23.12.03.15; Wed, 23 Jun 2021 12:03:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=N3zmO53v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S230001AbhFWTEw (ORCPT + 99 others); Wed, 23 Jun 2021 15:04:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229759AbhFWTEu (ORCPT ); Wed, 23 Jun 2021 15:04:50 -0400 Received: from mail-oo1-xc2f.google.com (mail-oo1-xc2f.google.com [IPv6:2607:f8b0:4864:20::c2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97DF7C061756 for ; Wed, 23 Jun 2021 12:02:31 -0700 (PDT) Received: by mail-oo1-xc2f.google.com with SMTP id k21-20020a4a2a150000b029024955603642so984146oof.8 for ; Wed, 23 Jun 2021 12:02:31 -0700 (PDT) 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=MRqftscF1FzfzzSjl5zFo7iO4VJxE2+eaqEj1NzMIwk=; b=N3zmO53vFPvwU+U7IahzduZVgdhRclf7RioMWOY+16NWHJ0+cf/uqdULwG4OvgCQzk Z6QN1tXNYwWWK9PuDVzuLkTlINpbkyhFYm6US7NUtvm7pzLLQV3daJvVqQnGZxOAjy0l jAnBACNa/mO2/NxRq+VFB9DvMh8xuTW6lKvZ86vb97EtPEi7hZv/zYhR+pd/cvohlto8 Pq8LEF2+gZaR0LjsQz1yiiPJsC/kP+mxmUZ1/1VRzEyQhxW8yW27q7qb6OeNRa4e6Pwm 5xUykPTFC1nvHZJ79TwbMEjjtMA45P1oAGfvzsW9OIoYtpz0Qj/tsyhCfORb8jz1hG9i KYag== 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=MRqftscF1FzfzzSjl5zFo7iO4VJxE2+eaqEj1NzMIwk=; b=eBFV7SOs0kM9Jvo4mOktI8OGERkCk21uh+cGN0W8Qa637GzZbytCj/C7ng5+78O/rA ZAHr56Oumleq1hokVhiiYbAKCruTJvhet1tTR/YY7XRMn84L83QKVXSmpa1EovaIvNYj s/PA1E216SJ6axO309BCz0qzclx9el8LuwLZ9OZXl2Zj5Y0iKgoeJ0hIkAh+4vsJom4k 0CezQOeEpYhFNP6r4pXbejMFQQbhVv4GysCzMWuc7M+MNafTyHIbNAcbgAxrCOCu2B1n 0bR8NiXLdqYEx3W6+hMOyR2GKHBa6RljGHSJoitPK3uD/PbhcSY5MnaQMjBueef71fXb UgIQ== X-Gm-Message-State: AOAM5322+pbSgZOlsOjQlbCxOca6nAgtP6yY3FriAzZNJfhmrQAjGqqs x0kvGcSg3aVyTbBJ9VCF/Tkipym3aGGti36kn3bwXA== X-Received: by 2002:a4a:6c0c:: with SMTP id q12mr1045468ooc.81.1624474950658; Wed, 23 Jun 2021 12:02:30 -0700 (PDT) MIME-Version: 1.0 References: <20210622175739.3610207-1-seanjc@google.com> <20210622175739.3610207-8-seanjc@google.com> <6f25273e-ad80-4d99-91df-1dd0c847af39@redhat.com> In-Reply-To: From: Jim Mattson Date: Wed, 23 Jun 2021 12:02:19 -0700 Message-ID: Subject: Re: [PATCH 07/54] KVM: x86: Alert userspace that KVM_SET_CPUID{,2} after KVM_RUN is broken To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm list , LKML , Yu Zhang , Maxim Levitsky Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 23, 2021 at 11:49 AM Paolo Bonzini wrote: > > On 23/06/21 20:11, Jim Mattson wrote: > > On Wed, Jun 23, 2021 at 10:11 AM Paolo Bonzini wrote: > >> Nah, that's not the philosophy. The philosophy is that covering all > >> possible ways for userspace to shoot itself in the foot is impossible. > >> > >> However, here we're talking about 2 lines of code (thanks also to your > >> patches that add last_vmentry_cpu for completely unrelated reasons) to > >> remove a whole set of bullet/foot encounters. > > > > What about the problems that arise when we have different CPUID tables > > for different vCPUs in the same VM? Can we just replace this > > hole-in-foot inducing ioctl with a KVM_VM_SET_CPUID ioctl on the VM > > level that has to be called before any vCPUs are created? > > Are there any KVM bugs that this can fix? The problem is that, unlike > this case, it would be effectively impossible to deprecate > KVM_SET_CPUID2 as a vcpu ioctl, so it would be hard to reap any benefits > in KVM. > > BTW, there is actually a theoretical usecase for KVM_SET_CPUID2 after > KVM_RUN, which is to test OSes against microcode updates that hide, > totally random example, the RTM bit. But it's still not worth keeping > it given 1) the bugs and complications in KVM, 2) if you really wanted > that kind of testing so hard, the fact that you can just create a new > vcpu file descriptor from scratch, possibly in cooperation with > userspace MSR filtering 3) AFAIK no one has done that anyway in 15 years. Though such a usecase may exist, I don't think it actually works today. For example, kvm_vcpu_after_set_cpuid() potentially changes the value of the guest IA32_PERF_GLOBAL_CTRL MSR.