Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1857276rwd; Thu, 15 Jun 2023 17:17:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ45h34BExgQ0JZLhD604PJJFSv5IwPyzPgoynayZODTmtYfz+vLhpjEsNf9gDxC1ApunWZK X-Received: by 2002:a17:902:c106:b0:1af:d9d2:a234 with SMTP id 6-20020a170902c10600b001afd9d2a234mr585956pli.3.1686874651500; Thu, 15 Jun 2023 17:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686874651; cv=none; d=google.com; s=arc-20160816; b=DKu1VPQM7OcwRj4mtfG5d0qjjHaDkAnQYnZkmjvsEqsKVSwfHd04P+tKp0/SyOCPhN s+IiHvWi1sreYluwg8jL714GU/Fv7KoWkbIr3doOf68jhXBZNDJM4Vexdvq/yXsMkEve h2fbKeO7e/A2JnFArmz66cgjXze/fsGEGZs5ryjBT8vjlAahpi3D5KjbECU+FheHSju8 mLyBvFeH0eVAQzaFTavRK2kh2oSMF9JIDwihcQmsCyRKdTGzTP5KLpKcl+r6BI2ljDaF iLUrZkZmo4Vnis9b3R8hoJN/21l6Fm8U0kQ0Gc6Pdhp+VK67f4eDCCg61jnNNWVLETFR +4bQ== 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=O1j1/CGdS8c+h0DXj7uvf0ZGWib7G67HcFTSIHLIPys=; b=FzR1lQIG+mUBXc1+84wJZ3Ne7U7MrVmSTOJ4yp8MVYG2q5YhtitF3B17X7gEiPalMB 0V7atUblecy9Va7M6s8kAHWzUf/yrUinsce4OyTjkx+E27DldWuOcaxtynF3t8rOG9Th RGBIzedT+EBUDasaMd3M7kmUQwFBC39SXKk1fuwoEObEM0tjR5zRKVeYgeh78NgGp5yl kcpKydXTgxKVj3n949ZR95pFJk3Kq3RxwHvcVJAAAlxfl7libLZWlyUuQBOeAPvrzxyd cOcqWuGSlJ01kCQXEEbtuk3LJgnJ3sZKFtWyVdagIkGbITlAy3NwNV3wW54cwevIDxkC TM6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=LzTSgFZ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j4-20020a170903028400b001b1a240b107si13765817plr.221.2023.06.15.17.17.08; Thu, 15 Jun 2023 17:17:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=LzTSgFZ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231332AbjFOXqD (ORCPT + 99 others); Thu, 15 Jun 2023 19:46:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbjFOXqA (ORCPT ); Thu, 15 Jun 2023 19:46:00 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE42F2953 for ; Thu, 15 Jun 2023 16:45:59 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-bc9483b506fso81259276.0 for ; Thu, 15 Jun 2023 16:45:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686872759; x=1689464759; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=O1j1/CGdS8c+h0DXj7uvf0ZGWib7G67HcFTSIHLIPys=; b=LzTSgFZ5bxxAUUiLZtvC+xclv52Icp8UqayoRrFg2nyTH65UyUnq4epTBd2OnueVbn V88w/rVi5XSi2kuLTX5LlFb3sR1kj7qXQV1owJjt+eZFJxsbIQSVbeANDTQop3jHBv7K WQXPwQVrtelf4I0ELMJWuXVmHX18uUr4oZ4h7f3c5DZUKKcWDbcl3YUnxxifWbGIFagS R+0bLK34KsX1qIXN/HnJzicM5JtUwMdhySyrtLOyD4qYqafjMO32wz0dHPQJx1CUkgtH 4HlBeM4RKT6pQMR2zR/tqdrXu6Q2y1+io6IpcbZP9tJQvU7OnG30UKQMhOey2ZSjM8wO D//w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686872759; x=1689464759; 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=O1j1/CGdS8c+h0DXj7uvf0ZGWib7G67HcFTSIHLIPys=; b=T6QHsnl1EBNznLzxGzCeWe7I1kUNwFGkwLljctLpmmq4LVyUaJ+/vJCHsoAdynbDqj 6p2E3dbbvYv9pbCYhVbJGuYo8NGTT0YX6VHEp4OuhW6UIPhFwBQSjav8eMEM0ml9spjw YBPFjp5opu9jaRWUyi5fUrKz69PbxQ79R7yIO3torcKRyu2AdyQVGl7QWRJ8ag29pTEX yREFlGZPA7C10gMaWZ1YSuyTysjoVdE/uw7HWwQdsvF6FIdm2eW5yUdV7fm1KQwfekBS LVJulxO1jIFmKwfKi5FluTGFBLswrH8FQ8uIUTtC81+dNMB3StO+egIRL4+l9DsUaYND pmFg== X-Gm-Message-State: AC+VfDxZC0oZoFxvfesg4+Xzrz60i0AtYDwnFIIaLFzOJgpjRcP+siKv 0Vy0Ev7VsCY0w+9+y+/KGcsCifHq2Ag= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:d08:0:b0:bc5:117e:d4a8 with SMTP id 8-20020a250d08000000b00bc5117ed4a8mr12050ybn.13.1686872758986; Thu, 15 Jun 2023 16:45:58 -0700 (PDT) Date: Thu, 15 Jun 2023 16:45:57 -0700 In-Reply-To: <6e1e9de9-8def-46c3-a238-c1b4ef52e331@intel.com> Mime-Version: 1.0 References: <20230511040857.6094-1-weijiang.yang@intel.com> <20230511040857.6094-8-weijiang.yang@intel.com> <23169e5f-9793-9486-fd5f-287e3317b837@intel.com> <6e1e9de9-8def-46c3-a238-c1b4ef52e331@intel.com> Message-ID: Subject: Re: [PATCH v3 07/21] KVM:x86: Refresh CPUID on write to guest MSR_IA32_XSS From: Sean Christopherson To: Weijiang Yang Cc: Chao Gao , pbonzini@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, peterz@infradead.org, rppt@kernel.org, binbin.wu@linux.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=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 31, 2023, Weijiang Yang wrote: > > On 5/30/2023 8:08 PM, Chao Gao wrote: > > > > > --- a/arch/x86/kvm/x86.c > > > > > +++ b/arch/x86/kvm/x86.c > > > > > @@ -3776,8 +3776,10 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) > > > > > */ > > > > > if (data & ~kvm_caps.supported_xss) > > > > Shouldn't we check against the supported value of _this_ guest? similar to > > > > guest_supported_xcr0. > > > I don't think it requires an extra variable to serve per guest purpose. > > > > > > For guest XSS settings, now we don't add extra constraints like XCR0, thus > > QEMU can impose constraints by configuring guest CPUID.0xd.1 to indicate > > certain supervisor state components cannot be managed by XSAVES, even > > though KVM supports them. IOW, guests may differ in the supported values > > for the IA32_XSS MSR. > > OK, will change this part to align with xcr0 settings. Thanks! Please write KVM-Unit-Tests to verify KVM correctly handles the various MSRs related to CET, e.g. a test_cet_msrs() subtest in msr.c would do nicely. Hmm, though testing the combinations of CPUID bits will require multiple x86/unittests.cfg entries. Might be time to split up msr.c into a library and then multiple tests.