Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1161745pxb; Tue, 8 Feb 2022 10:36:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4NuKd+UWuQnqL8oqVINQcVbahw/D7yvFBWsHfjDcJY4MnbFOgBFKMm+vEXoIQtzeSXlL+ X-Received: by 2002:a17:906:2ed1:: with SMTP id s17mr4929075eji.174.1644345376284; Tue, 08 Feb 2022 10:36:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644345376; cv=none; d=google.com; s=arc-20160816; b=ZQ6HYC2lV8/YnWEsedl3feaY5RWpYDfWMORy9CmA90N/hbrnPBNQN6uiIT3nEGJIZr k1KO5xzSdWEKkeq7Nc5iBy0JDXl2ttEc3eQCKT02mT03qu68jiJl2aaELGha+fqB6Io4 UHEJUxz1o/NRp2xttTCvHt4K2ZGxN1aPVLKfMfTl2rQ4RrdWMtqp7Ymn1ItLPWjvkJlm Zhs15spUuC95NkIocZuhXbev+xGwjYhDDeXCHEIe/cHxZLqly2diJpuV9DoQu1RZ0pg+ KIU8hUtQnMyE4B6atzuE5CEOSyOboJJwbd7SYW+0RVoaoVMFVBfm3h9FweFoBRjx2fpr sVgQ== 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=APAIHIfLKDR39mYklb+NvCddkgGL2qEPzPydIttXeMI=; b=acEmtvM1dRX2Jgl/D/YdTJpPSIqdLJYVkifbVVWP9/YMr2jj+V6tEZ4cX2aGOJcDj7 +9D+UKRmvBoczot1GanieQqmqru7sjAlpZJB9KeTTlMryYlrM3nsiPLWhseB4kogQvlH Na1ZB7mVcgMa4WvAQer665T+ml3iRkkzFIobYmc6tFKFDh0D29fofvM0aCy2Ui6qnbal j7uuJLwl173SbpLHC9KqTHau4hSYyYV9Qfp0WAl6mZecyNgC37gm2w9wXd5LutGLDIiv Wdr6faCcn5LaoaMz5aji5qRpoOeWRobJ6vOSKh+RM1eiMHvlMynJ4Jxe/GNW/4puJ8Ld 0CNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LvceHLO6; 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 25si9800853ejh.573.2022.02.08.10.35.50; Tue, 08 Feb 2022 10:36:16 -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=LvceHLO6; 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 S232157AbiBGVAh (ORCPT + 99 others); Mon, 7 Feb 2022 16:00:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231605AbiBGVA0 (ORCPT ); Mon, 7 Feb 2022 16:00:26 -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 AE2ECC06109E for ; Mon, 7 Feb 2022 13:00:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644267624; 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=APAIHIfLKDR39mYklb+NvCddkgGL2qEPzPydIttXeMI=; b=LvceHLO6iYgZ/WXpyG+2QsHIzrvv1gD7Xh6pGsC95BAg8Vy3cGeZGXAy45Gy4XxoCYkQ9z epbtfV2VjG98B+R7ABFHI28/336WKN/kEuD8Kvur5XBgjSyBef7BHCXJCvsHBCRoWSKYA2 XN29ki17Ti1EXKCAlh+k7a/yABL/c/M= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-601-9x2S6K6NMySjab6IdKKTag-1; Mon, 07 Feb 2022 16:00:23 -0500 X-MC-Unique: 9x2S6K6NMySjab6IdKKTag-1 Received: by mail-ed1-f69.google.com with SMTP id en7-20020a056402528700b00404aba0a6ffso8516139edb.5 for ; Mon, 07 Feb 2022 13:00:23 -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=APAIHIfLKDR39mYklb+NvCddkgGL2qEPzPydIttXeMI=; b=lbP8O+V8EOX3GqM+T5eNCN94GyYQdjjRoRontBuhn/uYnURIOxjJDXlYd4acFsk6bR G12/d5pXKhRL3b8Z5OixUjskItPMEElGF7f7GV/ik/bU56N6xiMt3y1b/9Hlfv2Gd6A0 XCalxqbNyP1hAQDT4TQ7NL0NjWSo4oXmO6H7ZcBHbHpMu2yShaDg1uzF35RfAh8hFFVd VQEGsDn8mjN0gsHjVOO2C66W5aTzbnAeB6CYOijbXoD0n+Eku0DHVLBlqRi+rM7XA/ib k6QsUFdQhUebN4rcnmqwn9gz5RqaGPG7R0fdLdsB87x/Spx5W57bjX14V7DFIZj9t2Z1 hG3w== X-Gm-Message-State: AOAM530j5BDDQRsIvA/OCVvEKgRK/JSI3Vh26+15uhzE4zLpzB2LXrcg Xq3iFur2zP4d6wHiRejDxMKJu+6sgdG2fqiXP+2nvRCKcHh4nx96Ie5bpOreIcPylnf1HxJMv1j uYpdwiw7vb6czEvyE8XqilkDf X-Received: by 2002:aa7:d949:: with SMTP id l9mr1313615eds.348.1644267622109; Mon, 07 Feb 2022 13:00:22 -0800 (PST) X-Received: by 2002:aa7:d949:: with SMTP id l9mr1313584eds.348.1644267621881; Mon, 07 Feb 2022 13:00:21 -0800 (PST) Received: from ?IPV6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.googlemail.com with ESMTPSA id a19sm2238528ejt.7.2022.02.07.13.00.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Feb 2022 13:00:21 -0800 (PST) Message-ID: <8bf8ba96-94a8-663a-ccbf-ffeab087c370@redhat.com> Date: Mon, 7 Feb 2022 22:00:14 +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 v1 1/2] x86/kvm/fpu: Mask guest fpstate->xfeatures with guest_supported_xcr0 Content-Language: en-US To: Leonardo Bras Soares Passos Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220205081658.562208-1-leobras@redhat.com> <20220205081658.562208-2-leobras@redhat.com> From: Paolo Bonzini In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 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,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 2/7/22 21:24, Leonardo Bras Soares Passos wrote: >> With this patch, >> we have to reason about the effect of calling KVM_SET_CPUID2 twice calls >> back to back. I think an "&=" would be wrong in that case. > > So, you suggest something like this ? > > vcpu->arch.guest_fpu.fpstate->xfeatures = > fpu_user_cfg.default_features & vcpu->arch.guest_supported_xcr0; > Yes, but you need to change user_xfeatures instead of xfeatures. KVM_GET_XSAVE and KVM_SET_XSAVE will take it into account automatically: - KVM_GET_XSAVE: fpu_copy_guest_fpstate_to_uabi -> __copy_xstate_to_uabi_buf - KVM_SET_XSAVE: fpu_copy_uabi_to_guest_fpstate -> copy_uabi_from_kernel_to_xstate -> copy_uabi_to_xstate -> validate_user_xstate_buffer Paolo