From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C353EB64DB for ; Thu, 15 Jun 2023 23:46:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240102AbjFOXqE (ORCPT ); Thu, 15 Jun 2023 19:46:04 -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-Google-Smtp-Source: ACHHUZ6LzMHzbPy7MHoIXxldNV8tox62l/uAktJMqu1F8P0e185bL4dBqGBRrc+1S2ty0MyQtLPnD8ZlBwE= 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" 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.