Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp843421ybt; Tue, 7 Jul 2020 01:27:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyY6CAG3tkCdtEN9g5VPWssiqxuSYyJKB/dfuOSOA5be0ABNd01mkb4RZnEx/Ri1rljzVSg X-Received: by 2002:a50:ec8f:: with SMTP id e15mr58668303edr.70.1594110436638; Tue, 07 Jul 2020 01:27:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594110436; cv=none; d=google.com; s=arc-20160816; b=K/h4PNLu4T02VX702vOlge/Ty+si0aMteoJjB+AjIjPN6yTI27Ykz6xwQBou9GTNXn zQAbTsalLDqfh8D374mtC7kOOsJMrTZ/3L1SKH6GhrLWuqNbse417r2QTt/JZjgo4aiZ Do/256r7fk/+iOWHGnkdj2lJnp0EotyA63Jy7m23G8thEslrwHSvUGqA5IzjC0pKJaUL T09tlE4/A44UL3aDzmAPodUR6R12OSSDZ8sKlbmKRmQ3EucifsgShqG05SsS0OboOMC1 kx64CtwKOqwFaWEL/ZI3WVbOWYZ2nQrytawRxCBxC8bDUN0IIISzr05t7F3c4inUOLy+ aaDg== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=y8HDsVksiBm8RPWKGEJQ3BryeKT2vpbJX/VBfCjX3Ns=; b=HPVuyG07LOJC9ISLactBJEzHjjnhlWLHeo3W7TYRfyxsilC7Iaj2N2AklrqUyzpS6T U8i7VcuPvKbMpFp4ZU+ydPmjxgWtEye5OOQIkCxe4P+a2Cb4awtJ55BXX1yIL8IIit98 q4Wq1KPI6/1KxjQq5sTzvnPiJz7qht+z4Zt1p+q11X1ucUpZ5FekMxm7aFemzFLZqoN8 ljefHcGp+e7k7nBWywP/gfmXkJyxJt9ZJpAiDR23dMNKUmuGAYjithhzsN5F4gurZk1X a4aJhX/GTWMV+5bLTIoTe4t7OrU3li6goOQpAtD+9Iz67nBOrRiabCFjFlzkJ5DWzVh1 kFsQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z4si1097220edr.144.2020.07.07.01.26.53; Tue, 07 Jul 2020 01:27:16 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727097AbgGGI0Z (ORCPT + 99 others); Tue, 7 Jul 2020 04:26:25 -0400 Received: from mga03.intel.com ([134.134.136.65]:12658 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725825AbgGGI0Z (ORCPT ); Tue, 7 Jul 2020 04:26:25 -0400 IronPort-SDR: cRGmLJiX0n/Do3G8nzfMU81smu2WkWmGfWAv48X2BjUyilnUXHYkiT832cwVz+smWIXiZ+Vryf GJaZxrfGcb8w== X-IronPort-AV: E=McAfee;i="6000,8403,9674"; a="147567898" X-IronPort-AV: E=Sophos;i="5.75,323,1589266800"; d="scan'208";a="147567898" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2020 01:26:24 -0700 IronPort-SDR: AydWLUVT46cugw3UxVmdM8M0jl+24qxMomY1k50gvYxuYrKgvAo9aIvxqNZlcAxTBVup3TJqGw WzOWEh+yRwqA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,323,1589266800"; d="scan'208";a="283376128" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.152]) by orsmga006.jf.intel.com with ESMTP; 07 Jul 2020 01:26:24 -0700 Date: Tue, 7 Jul 2020 01:26:24 -0700 From: Sean Christopherson To: Paolo Bonzini Cc: Maxim Levitsky , kvm@vger.kernel.org, "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , linux-kernel@vger.kernel.org, Joerg Roedel , Thomas Gleixner , Wanpeng Li , "H. Peter Anvin" , Borislav Petkov , Vitaly Kuznetsov , Ingo Molnar , Jim Mattson Subject: Re: [PATCH] kvm: x86: rewrite kvm_spec_ctrl_valid_bits Message-ID: <20200707082624.GB7417@linux.intel.com> References: <20200702174455.282252-1-mlevitsk@redhat.com> <20200702181606.GF3575@linux.intel.com> <3793ae0da76fe00036ed0205b5ad8f1653f58ef2.camel@redhat.com> <20200707061105.GH5208@linux.intel.com> <7c1d9bbe-5f59-5b86-01e9-43c929b24218@redhat.com> <20200707081444.GA7417@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Tue, Jul 07, 2020 at 10:17:14AM +0200, Paolo Bonzini wrote: > On 07/07/20 10:14, Sean Christopherson wrote: > >>> One oddity with this whole thing is that by passing through the MSR, KVM is > >>> allowing the guest to write bits it doesn't know about, which is definitely > >>> not normal. It also means the guest could write bits that the host VMM > >>> can't. > >> That's true. However, the main purpose of the kvm_spec_ctrl_valid_bits > >> check is to ensure that host-initiated writes are valid; this way, you > >> don't get a #GP on the next vmentry's WRMSR to MSR_IA32_SPEC_CTRL. > >> Checking the guest CPUID bit is not even necessary. > > Right, what I'm saying is that rather than try and decipher specs to > > determine what bits are supported, just throw the value at hardware and > > go from there. That's effectively what we end up doing for the guest writes > > anyways. > > Yes, it would prevent the #GP. > > > Actually, the current behavior will break migration if there are ever legal > > bits that KVM doesn't recognize, e.g. guest writes a value that KVM doesn't > > allow and then migration fails when the destination tries to stuff the value > > into KVM. > > Yes, unfortunately migration would also be broken if the target (and the > guest CPUID) is an older CPU. But that's not something we can fix > without trapping all writes which would be unacceptably slow. Ah, true, the guest would need to be setting bits that weren't enumerated to it.