Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp1069367rdb; Wed, 1 Nov 2023 10:21:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPLN58FSZ/bxz4ZAlxdNhFLE/6p+NiSjLfLpe3rREcR2PLuEuhNVvHu35rGqTBgnVMsFjK X-Received: by 2002:a05:6a20:3941:b0:181:8654:8272 with SMTP id r1-20020a056a20394100b0018186548272mr511233pzg.2.1698859283412; Wed, 01 Nov 2023 10:21:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698859283; cv=none; d=google.com; s=arc-20160816; b=n0572brCAqXmZ/vQUDI3/QRI5HbTS3EcrC7s6K8IRY1hXhmTq0SsIde37W89qD1Y/W YjmE+RXJ5oCUfBSZfMV+D/pUgqaAn9D+cb6Cn/a7W2DlJrgqOaRjBdZuZtPlWTGo64Lb YEfg2ZZxucnGZe9KVXimTOiv61vUvEWgyzt8V+QetR6JfUgrvSKn+vIwkwEJethBJVnb W3g6rzSbMpSazCGqeHaTEGKK6MpvsscGzsMGzKuNB3OIPPZxRDxkukn+pex2HP6VsoTY 1FZjA3VlOl4llqIogRVxML5rxNgpmehfJXftr0xpZHvcgag7oY/YLC3thLW7qUtWI1JS 4fqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=TDeMHyg6nuM6uHT2NhRlyelK+fI/RFOQGU6FtIWq+2I=; fh=pR2rhvSqJrTOV84+w/PzL7nqZS1SdTRWWwXac2vx21o=; b=S0DpHS/SASo/440r5qhu7uBS2A405u0H8NtGL051ZZ5Susyu6hFbhS31DXPeN3Aigc t6udJLN6FzEvVp9e8dMDlohvG1mPfdYlQB6++23Fd1nghKnjeTmNeg921nT3JCH8Ktwv 3QuuNafv6PxyeXQ0cX0nIPr7knR+4cbK4qtdVWlwG5YPMA8ias8mTuKYzy2fNXNGK0Ye peYL39raVneWQA10jFT09OxkyEW6dODneE3Y8CZQIJo0LMIE33zVCBIYjFX0V0eA49hP W44SBFUdr00iRWlzhD3zxt+x64zFtjVBlLRk8iZMVptt6WiLnH3sTJu2OjJsq3tB1pYM k2lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=nuXm2Koc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id e13-20020a656bcd000000b005b874265d1fsi284318pgw.513.2023.11.01.10.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 10:21:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=nuXm2Koc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id EBAD580459BD; Wed, 1 Nov 2023 10:21:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344715AbjKARVI (ORCPT + 99 others); Wed, 1 Nov 2023 13:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344690AbjKARVH (ORCPT ); Wed, 1 Nov 2023 13:21:07 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FF2F129 for ; Wed, 1 Nov 2023 10:20:56 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5a7cc433782so525647b3.3 for ; Wed, 01 Nov 2023 10:20:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698859256; x=1699464056; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=TDeMHyg6nuM6uHT2NhRlyelK+fI/RFOQGU6FtIWq+2I=; b=nuXm2KocmpbxdbmXC+RtU7wGzmV0XtSzPB/k+4qzCth2TwazsSLX7PN0/rZ1zlQZJD VKcmWJfjCrCvn7AfEI+stBdTXKzpnOdUiE6YUNPl2ApjjBkUqj9z4lAffMcU+Xlszani lvauQkrJI4j4WtxHeYS1QguZYRIDohvpgZuzMWEUGZRaTMepGNdsg5piEJF3syRCRDvJ aoDVKgQtahhFcz7fNT55NBQH0JxS6YJF0vXBDLxOQRsplMLRsiWzBF8Emlz7aOIfRfpn HUDkKaEu8xhFAeUXZjG+QQLtuIppMrGplUvRq8OJf9DLLZAZ00IntUyx7XzikS8vx4sF gpIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698859256; x=1699464056; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TDeMHyg6nuM6uHT2NhRlyelK+fI/RFOQGU6FtIWq+2I=; b=pmBDEXuvG2F+AFAEJXmg4gmu4yV7BqLIQNTfIO2XiwxCSHtvA0w/osdyZFjVhWMMon iEePpyPqXPjdQAB6ez56XhSqXSkNdh/A5JmCeVwt7JtbfCqXlpYc0727w6JYdk1KzjYp 9cJgd5Xwu4mtrpIAwAUXcMfoLmjPuYkjjgBfpk2ovrsv9OhNOqR+rWum7P8imu6gmH7O jRYrj7CzjLqgoswTVNul08gKcek1TqGMTFXrJtMyYQwhBAHZU41ZF2Tj/EhjEUmB6rmW XLx0g1TYbJm11Y5aSGkBmefsiKfKsnx97AvS7Ojp06lekVja2HdVxb+mAmqE/+1tXkdF DW+g== X-Gm-Message-State: AOJu0YwYI6Wp5QaIOhlvpFjyiiSairScdR6pszSeZVxR9fEsfDnMwFmi +0Z0O0H5n9imLzRkPGEZC7JNrWfxESA= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:7702:0:b0:d9a:6007:223a with SMTP id s2-20020a257702000000b00d9a6007223amr319245ybc.8.1698859255708; Wed, 01 Nov 2023 10:20:55 -0700 (PDT) Date: Wed, 1 Nov 2023 10:20:54 -0700 In-Reply-To: <5c5eb1cc92d05fb7717fe3480aeb7b20e7842d05.camel@redhat.com> Mime-Version: 1.0 References: <20230914063325.85503-1-weijiang.yang@intel.com> <20230914063325.85503-13-weijiang.yang@intel.com> <5c5eb1cc92d05fb7717fe3480aeb7b20e7842d05.camel@redhat.com> Message-ID: Subject: Re: [PATCH v6 12/25] KVM: x86: Refresh CPUID on write to guest MSR_IA32_XSS From: Sean Christopherson To: Maxim Levitsky Cc: Yang Weijiang , pbonzini@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, dave.hansen@intel.com, peterz@infradead.org, chao.gao@intel.com, rick.p.edgecombe@intel.com, john.allen@amd.com, Zhang Yi Z Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 01 Nov 2023 10:21:21 -0700 (PDT) On Tue, Oct 31, 2023, Maxim Levitsky wrote: > On Thu, 2023-09-14 at 02:33 -0400, Yang Weijiang wrote: > > @@ -312,6 +313,17 @@ static u64 vcpu_get_supported_xcr0(struct kvm_vcpu *vcpu) > > return (best->eax | ((u64)best->edx << 32)) & kvm_caps.supported_xcr0; > > } > > > > +static u64 vcpu_get_supported_xss(struct kvm_vcpu *vcpu) > > +{ > > + struct kvm_cpuid_entry2 *best; > > + > > + best = kvm_find_cpuid_entry_index(vcpu, 0xd, 1); > > + if (!best) > > + return 0; > > + > > + return (best->ecx | ((u64)best->edx << 32)) & kvm_caps.supported_xss; > > +} > > Same question as one for patch that added vcpu_get_supported_xcr0() > Why to have per vCPU supported XSS if we assume that all CPUs have the same > CPUID? > > I mean I am not against supporting hybrid CPU models, but KVM currently doesn't > support this and this creates illusion that it does. KVM does "support" hybrid vCPU models in the sense that KVM has allow hybrid models since forever. There are definite things that won't work, e.g. not all relevant CPUID bits are captured in kvm_mmu_page_role, and so KVM will incorrectly share page tables across vCPUs that are technically incompatible. But for many features, heterogenous vCPU models do Just Work as far as KVM is concerned. There likely isn't a real world kernel that supports heterogenous feature sets for things like XSS and XCR0, but that's a guest software limitation, not a limitation of KVM's CPU virtualization. As with many things, KVM's ABI is to let userspace shoot themselves in the foot.