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 X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 796F3C2D0E4 for ; Tue, 24 Nov 2020 18:35:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1480920637 for ; Tue, 24 Nov 2020 18:35:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404270AbgKXSfV (ORCPT ); Tue, 24 Nov 2020 13:35:21 -0500 Received: from mail-ej1-f65.google.com ([209.85.218.65]:44471 "EHLO mail-ej1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390718AbgKXSfT (ORCPT ); Tue, 24 Nov 2020 13:35:19 -0500 Received: by mail-ej1-f65.google.com with SMTP id k9so15125819ejc.11 for ; Tue, 24 Nov 2020 10:35:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=02zyVIZESHQBccfGArgKEYjRejMAdJsOe44mFAYJcQU=; b=A3tOceFvUr7GL88O5JpLkj9VvF2nHIwp9JBf+L/LAaKK3fJPPA3VYN6S+BnaAhzrLc nTH1lI1fJAu+12TUwjmNew0O+Gr71TgC6ofS/CZFx/Wc6fmSbFS6TN3a39HpGKdnpr1m HpuepVqSQ+Vn6YrhqStYz9h37TSqQoQAxB2BxlpQ8WkqQPTAhiSCCug4PPrQjGuxaO8C 4oQq3Ytelxw2nloEa6g5co7uIdy8THghWhGIRGJjeqATKAUHtELtJNtN+AKD8uq+G7An iadWSrMakO4RSpgEtowYwOvFSleX00CuR5BfK+/ZAadScre4NhXuuWXhcKv6CwMegb6u CD0Q== X-Gm-Message-State: AOAM533fUmlbUcstQ/QuT11cGFb4AEraWEM7QgtytWdCNkVueTpBjmyf 8ZMv7nF0cSAIuP81Dw63RFEIGja6nqdKRm3utbU= X-Google-Smtp-Source: ABdhPJz7q44nigsvJWkTLUNxZV5uuGyLBmOdtoJx+It6cKroBZsj74spoBKK5HiHnuC8Q5poZfEFFIt1uptnrqMFPns= X-Received: by 2002:a17:906:578b:: with SMTP id k11mr5466043ejq.330.1606242918760; Tue, 24 Nov 2020 10:35:18 -0800 (PST) MIME-Version: 1.0 References: <20201119233257.2939-1-chang.seok.bae@intel.com> <20201119233257.2939-15-chang.seok.bae@intel.com> In-Reply-To: From: Len Brown Date: Tue, 24 Nov 2020 13:35:07 -0500 Message-ID: Subject: Re: [PATCH v2 14/22] x86/fpu/xstate: Inherit dynamic user state when used in the parent To: Andy Lutomirski Cc: "Chang S. Bae" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , X86 ML , Len Brown , Dave Hansen , "Liu, Jing2" , "Ravi V. Shankar" , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 20, 2020 at 12:08 AM Andy Lutomirski wrote: > > On Thu, Nov 19, 2020 at 3:37 PM Chang S. Bae wrote: > > > > When a new task is created, the kernel copies all the states from the > > parent. If the parent already has any dynamic user state in use, the new > > task has to expand the XSAVE buffer to save them. Also, disable the > > associated first-use fault. > > This seems like a mistake. If init uses AMX for some misguided > reason, ever task on the whole system will end up with AMX state > allocated. Andy, you are right -- the child can (and should) start with the un-expanded context switch buffer, and as a result XFD should be armed to fire on the child's first access to TMM hardware. TMM registers are scratchpad, they will never be used to pass globals, say, from parent to child thread. Further, they are volatile and caller saved. The callee can assume they are empty -- so even by virtue of being in a fork system call, that state is already gone. thanks, Len Brown, Intel Open Source Technology Center