Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp672622pxb; Wed, 18 Aug 2021 11:13:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3laIxAwqA2/lPKquHNz1mizc3JCJlz6BO7rSwbat79KyePUCmOLQoKIKzPN3oH3A0hK4i X-Received: by 2002:a17:906:3b50:: with SMTP id h16mr11176226ejf.140.1629310429957; Wed, 18 Aug 2021 11:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629310429; cv=none; d=google.com; s=arc-20160816; b=q+fJmhVNCXxmy6Bh9OV4Zo35WTYzdN7VIta9DyxMijnIUvhV2NnE5FdTPgSUdHiVvr jCPJtvl+cYl5luTv+fjaHpwxzUNkOx+KAXMU7A1ayX0RCgB0YuN+I/c3t0Rfuhwc14Eb cQtzFWg3cpIL+KukKIZzkPCHPLgwwA0hbWwWTuuWFmuEZ1k1IiEhoQi/4lZKskCnWyQE KZubROH1II9ft2OeWTPU8OQPvDdOdxXGsrcKgAtPMEYvaQ+wLVQTeeFxl6CONCbgLSHP G/rUi6VPw0A7qN80cv2SrChtpuRkHtqAPU/CgCHAZtOI8I43VTOpYZ4qE09TJIWO8+eR xbxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=K4GK/gSkcU3s6BhJqhvsXq6XiGfFkNPqxOUSWUeTU+Y=; b=xGYb/Sq0dSBdE5vcmlUJg2RxMfxq/Yt2GNhgoiyWQVFqdW6OcKI1WC8rI4ShkLDGDn Q7AfVLRLvn5ESvswBcRIsxMLKTkJTXj/Dr/yjYSxtzC7yvoGo/HM3ezm9Oq28KxGgGkU Z7GjfzRhaW6YJd/qasDKD9viVTlFxOkGPMPvJoR3xN7Qkhx5gR+ynn1aHfm3tCng2J/C EaaRClMqXHv1CFbj76+cZUKwFAlPzVs+DZBQwosHJ500I0qFBphf1VYGYnHpd+6xluIT bMELJoD/HMqpXd2h+/9dsk27SuMkm4gtE4pZgw8H6YCyeCTQAouqN3JQ+r9XSKA01KZy HI8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=HHeO2hei; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si705214ejd.313.2021.08.18.11.13.22; Wed, 18 Aug 2021 11:13:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=HHeO2hei; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230009AbhHRSKN (ORCPT + 99 others); Wed, 18 Aug 2021 14:10:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229533AbhHRSKL (ORCPT ); Wed, 18 Aug 2021 14:10:11 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EDD3C061764 for ; Wed, 18 Aug 2021 11:09:36 -0700 (PDT) Received: from zn.tnic (p200300ec2f0cc30025743e574fa309df.dip0.t-ipconnect.de [IPv6:2003:ec:2f0c:c300:2574:3e57:4fa3:9df]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 00FE41EC0541; Wed, 18 Aug 2021 20:09:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1629310171; 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:in-reply-to:in-reply-to: references:references; bh=K4GK/gSkcU3s6BhJqhvsXq6XiGfFkNPqxOUSWUeTU+Y=; b=HHeO2hei73zSSUU3tUUG07OOciBKumbQebHZn1QZREG4FbOoPa6VPDbTNR6TsA6vvrhFsn UkI6P4q2BT6QtTnEpf4ZJrpSaE5/20S+7LM3u4a1BryvF8HizMtzVYGsEqr5o8TdaU9xa0 fb4lgFRg6TEuzDEzzTkEGQXZAUb1tfE= Date: Wed, 18 Aug 2021 20:10:10 +0200 From: Borislav Petkov To: Thiago Macieira Cc: "Chang S. Bae" , luto@kernel.org, tglx@linutronix.de, mingo@kernel.org, x86@kernel.org, len.brown@intel.com, dave.hansen@intel.com, jing2.liu@intel.com, ravi.v.shankar@intel.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v9 12/26] x86/fpu/xstate: Use feature disable (XFD) to protect dynamic user state Message-ID: References: <20210730145957.7927-1-chang.seok.bae@intel.com> <3181031.RqgVF4sTRC@tjmaciei-mobl5> <4493449.UzBjrsCbmA@tjmaciei-mobl5> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <4493449.UzBjrsCbmA@tjmaciei-mobl5> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 18, 2021 at 10:58:42AM -0700, Thiago Macieira wrote: > That tells me what the CPU supports, not what the kernel does. By > omitting the "xfd" entry in /proc/cpuinfo, we are assuming that all > kernels with "amxtile" also implicitly support xfd. That is a valid > assumption. What relevance does the fact have for userspace whether the kernel supports XFD or not? IOW, userspace cares about AMX and the other features which are supposed to use XFD - not how those features are implemented: whether with faulting or with pre-allocation or whatever. > Many applications need to determine which plugins and code paths to > enable before getting the data that will tell them what to do. It's > entirely possible for them to never need to run the AMX instructions, > so they may wish to defer the request to allocate the XSAVE state > until they have read their input data. > > It's indeed possible that the allocation then fails and the > application be unable to continue. But OOM conditions are unlikely, so > it may be an acceptable price to pay. In fact, by *not* allocating the > extra state for every thread in the current process, it may avoid the > OOM. And? That doesn't conflict with my suggestion. It goes and asks the kernel what it supports and then requests the buffers. > Sorry, that's not what I meant. I was going to request an extra API, a third > call. We'd have: > - get current state > - set new state > - get available bits to set Yes, this should have been the API from the very beginning. Of course you need to be able to query what bits can be set at all. > ... > Now, if we are going to have this API any way, it might be a good > idea to combine the two getters in one by adding a second pointer > parameter. Yeah, I'll get to that patch in the coming days and have a look. So far, it only makes sense to have a querying API too so that we can provide support for more "fat" features. Unless Intel folks decide to stop using XSAVE for that - it was a bad idea in the first place anyway, TBH - but it's not like hw people listen to sw folk so... -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette