Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp466519pxm; Wed, 2 Mar 2022 02:04:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJykI/NERjyeadkiR+bHJGlAAxL7hW8wnaEvjDdQVLbzPTZYKulL7Nz/ZN4V4d5LJB5KeP64 X-Received: by 2002:a17:902:ce8a:b0:14f:fd0e:e4a4 with SMTP id f10-20020a170902ce8a00b0014ffd0ee4a4mr30457190plg.47.1646215491506; Wed, 02 Mar 2022 02:04:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646215491; cv=none; d=google.com; s=arc-20160816; b=KMvvgIIucOSgLl8DZIEBWubeKd+gNOz7wFlcA8Lkd4yDvpcHUTKECo9ijg7jBGVp53 mIaLWGpKHfk2lGZgU/8VCToTJwurWkABipLY1/U4hJHEKqAQ2t1U757DHN9WkyHN3ccd CMQedcWU2hIEojCxrvwM2Fjh1Soa9+mljZfYJvbD9JqCUU8iAUQN/aOGoNJ2Ft3w/RFf gRj2Ec5lDLs/V7RCMCOUNWBd1//gDvWJ7/cZItLmiMOm9v29vFlt3XsBdVaj4FAQbbzS pkuKxKMGahK/K1pyseVcutY6p3hcakBIv8C1YSWNYRbnBbcxgD5tdwm2FCOkkAkqjj7g HQHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=UnhjscoVXwV58qxo7/KqdtLFU4F0yTvnAGVTxy5/ZzA=; b=RcU7MDhGm1aV9cYywhCtaVT24jw5ypSJUcFqX9yDi83zphF6oDuKqCjx366mfx7I/q etQmeRCFEuTA/ADOgoj/K8S4GHOXDmLAXjVcu51bXOmSDH2lwmlQhXo/A1Dxiko1bNrO t7aw7diKbMkN4mPFl9SXBh+5/JqUmDQNhHH8kX4srmCUBKF+Wd0jRdqKjrXrkBoYClPO dui2R6sX57s0vZ1sY5eZJbwhLW7/odVI2OotCPnapSYidGh8sRpO1xUiBDNT6O5Drs14 joMlOGdC/yrQahsf929FiQvT2jpJcX3rxMqn9tSAkJPyXSAx9RFUvH/OnyXHoQZB0T9C 4+xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XFSPj90L; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x15-20020a63170f000000b003755941ead9si15070975pgl.460.2022.03.02.02.04.36; Wed, 02 Mar 2022 02:04:51 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=XFSPj90L; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236184AbiCAU1B (ORCPT + 99 others); Tue, 1 Mar 2022 15:27:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239207AbiCAUYf (ORCPT ); Tue, 1 Mar 2022 15:24:35 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1956540938 for ; Tue, 1 Mar 2022 12:22:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646166137; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UnhjscoVXwV58qxo7/KqdtLFU4F0yTvnAGVTxy5/ZzA=; b=XFSPj90LsCqMl1F+OjWK36l9np/y8CsP2sPJulr9b5iQWRvSSUqQneG8a49p1TyLorYs0j t8zz+YXD7d6TgcGeVP3AXoazS2QCI9FdrF0IW5AUsdsthd0wOtuerKe2KeD/sqxYALEAt7 DvEsPGk0WA/QGrxFDke8buPSZ6WXlAA= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-621-oiAd0L95NbmGjt5-nGBZ-Q-1; Tue, 01 Mar 2022 15:22:16 -0500 X-MC-Unique: oiAd0L95NbmGjt5-nGBZ-Q-1 Received: by mail-wm1-f70.google.com with SMTP id r206-20020a1c44d7000000b00380e36c6d34so1170723wma.4 for ; Tue, 01 Mar 2022 12:22:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=UnhjscoVXwV58qxo7/KqdtLFU4F0yTvnAGVTxy5/ZzA=; b=4OvQI5rTm5ARdJ3dVB2N/t1QuqgE9A6ApCzIsU2UhnB8glBaCoiAGtac9ILAsTjjgs 7nFjPpHYBcCm9dw8zNqjYtYLsjZvCamcKxv2zkM3q+RpousdAQ0JdYK5riBmxztyLiRU mWMUj9yvvpSSErkwAmfXwb0TkaOUaRtRs000L701d1MhMZX7sf6tvTVmaxICC28viDA/ Hb7yWbaXw2Sk25nekw8ekSRa7oY/DGEo7hIXv2Lv8qDSZqv0DRgqrdF8BaOn/zY4npQj vEs5RW+7tT5imqw3kFaYpRyMhLmUhHBaRSdIPNYp35KMTDwiqmCaOVn/codrvVGRxHHw QXDw== X-Gm-Message-State: AOAM532rnrK8bfsQBN+KEASTbsm6s82+MESaDbeMMqWKas4XcJjYdxY6 8Y1J2GiKTQNKZOPUfmA7T7IkRfM6X04CEODpu2ZwAe9CW0Jej9gds27MGf02p/yCD6lGk3pultb B78wHGCISKRT6owRVR6Q5pmsW X-Received: by 2002:adf:a319:0:b0:1ef:7cc6:d03 with SMTP id c25-20020adfa319000000b001ef7cc60d03mr14982536wrb.411.1646166135156; Tue, 01 Mar 2022 12:22:15 -0800 (PST) X-Received: by 2002:adf:a319:0:b0:1ef:7cc6:d03 with SMTP id c25-20020adfa319000000b001ef7cc60d03mr14982524wrb.411.1646166134945; Tue, 01 Mar 2022 12:22:14 -0800 (PST) Received: from ?IPV6:2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e? ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.googlemail.com with ESMTPSA id u6-20020a05600c19c600b0034f5032b042sm3663786wmq.46.2022.03.01.12.22.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Mar 2022 12:22:14 -0800 (PST) Message-ID: <5f2b7b93-d4c9-1d59-14df-6e8b2366ca8a@redhat.com> Date: Tue, 1 Mar 2022 21:22:10 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH AUTOSEL 5.16 07/28] x86/kvm/fpu: Limit guest user_xfeatures to supported bits of XCR0 Content-Language: en-US To: Sasha Levin , linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Leonardo Bras , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, chang.seok.bae@intel.com, luto@kernel.org, kvm@vger.kernel.org References: <20220301201344.18191-1-sashal@kernel.org> <20220301201344.18191-7-sashal@kernel.org> From: Paolo Bonzini In-Reply-To: <20220301201344.18191-7-sashal@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 3/1/22 21:13, Sasha Levin wrote: > diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c > index d28829403ed08..6ac01f9828530 100644 > --- a/arch/x86/kernel/fpu/xstate.c > +++ b/arch/x86/kernel/fpu/xstate.c > @@ -1563,7 +1563,10 @@ static int fpstate_realloc(u64 xfeatures, unsigned int ksize, > fpregs_restore_userregs(); > > newfps->xfeatures = curfps->xfeatures | xfeatures; > - newfps->user_xfeatures = curfps->user_xfeatures | xfeatures; > + > + if (!guest_fpu) > + newfps->user_xfeatures = curfps->user_xfeatures | xfeatures; > + > newfps->xfd = curfps->xfd & ~xfeatures; > > curfps = fpu_install_fpstate(fpu, newfps); > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c > index bf18679757c70..875dce4aa2d28 100644 > --- a/arch/x86/kvm/cpuid.c > +++ b/arch/x86/kvm/cpuid.c > @@ -276,6 +276,8 @@ static void kvm_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu) > vcpu->arch.guest_supported_xcr0 = > cpuid_get_supported_xcr0(vcpu->arch.cpuid_entries, vcpu->arch.cpuid_nent); > > + vcpu->arch.guest_fpu.fpstate->user_xfeatures = vcpu->arch.guest_supported_xcr0; > + > kvm_update_pv_runtime(vcpu); > > vcpu->arch.maxphyaddr = cpuid_query_maxphyaddr(vcpu); Leonardo, was this also buggy in 5.16? (I should have asked for a Fixes tag...). Paolo