Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp158880pxv; Wed, 7 Jul 2021 23:07:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzb1XWyA/QrLvNG213JDty/oxDjzZfUuSHtIftnuo7BylaBpGccf/AuLqmlTRkzPiJZfBQ1 X-Received: by 2002:a92:de05:: with SMTP id x5mr20046845ilm.260.1625724470079; Wed, 07 Jul 2021 23:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625724470; cv=none; d=google.com; s=arc-20160816; b=rQ8ysGLY092hoc943tOLda2EFeyQuIK7mq9niCr6OBEUqYzcwE7/4YqsuoVRD2+dcR yWORPwXKRQo4In5B7Hggh/oEacM+RI929ZX5gXkTcLYYHi41j5u9uZDKUhOgVCk9D6Is 5xQN8A+CYFFzR1eumlcxbfCPf1usJbWtmIF410TX2crIwWhXPs+zCWpjBvVv67GVOBMD 0kQDr+OlnxbuPYPvTaR1jNQxeMlfIBTlJjhGPvdQtVkLKTUemXUBPM+hoyj/543/OBYG ReQZ9C9RlKnRaCRcXyHJbTpLhVTUBqMCMvpt/VVG2LgO+CvLHycrN9fn4yi703jJDRWr Ywig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:in-reply-to:date:references:subject:cc:to :from:dkim-signature; bh=wCYV9rADVa/Zk0J+SdK18xNcB21VXuhcx5+1Vv01yS4=; b=LXFnJ5KyznIkmfC40g4LN1xkxC4ihGVfX7FxKpVOXHv5lnBjXyXZWfWenp57ZUhbzb brQJr+tauiX8GF/CBJ6FTiqqxGd49AnvI5v3BIuKBygPjBzrRefdWcltQilNR8sBFL8R Yc0StKNZfwtwhplHIv7LjltMg/CG3xPKQZ6z5WLNCk8/GnIav/ShrHKlA2LEStv9YfxO mLRc6AEOs3LqyXoo3ltR0UVR5f3PtDKfLWzZrG8FgOvt9GdSXKv5whA2dHaqp+TiSawy D6uL09ONfGPYWppLTQRY7AnXfycoEKdmOKMFfD2ov1R7prQSiP1w4w0obnpIut+n7GgJ wZPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cD2Hy1Sm; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f10si1409933jam.46.2021.07.07.23.07.26; Wed, 07 Jul 2021 23:07:50 -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=@redhat.com header.s=mimecast20190719 header.b=cD2Hy1Sm; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229701AbhGHGIP (ORCPT + 99 others); Thu, 8 Jul 2021 02:08:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33423 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbhGHGIL (ORCPT ); Thu, 8 Jul 2021 02:08:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625724329; 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=wCYV9rADVa/Zk0J+SdK18xNcB21VXuhcx5+1Vv01yS4=; b=cD2Hy1Sm+sBhybszw0y6pb2UrWMR6Dk3HLQhQkzy4bvTN/JQyQly/8+15tFf3el+DCCgOT 2fcx+1rr/DnDWIcddxPje3yN7wuw7ZuQV5Od+DWXfKG3Kz36yE8rGQ5xEXlQKvEGX+iIzt +cS5xXGdwYZNv9iXV6L0ryITSylvOMY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-91-9-DnYDoaOMCTGRYBVNbyrA-1; Thu, 08 Jul 2021 02:05:25 -0400 X-MC-Unique: 9-DnYDoaOMCTGRYBVNbyrA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 509EB18D6A2A; Thu, 8 Jul 2021 06:05:20 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-115-5.ams2.redhat.com [10.36.115.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D14654450; Thu, 8 Jul 2021 06:05:17 +0000 (UTC) From: Florian Weimer To: Dave Hansen Cc: libc-alpha@sourceware.org, linux-api@vger.kernel.org, x86@kernel.org, linux-arch@vger.kernel.org, "H.J. Lu" , linux-kernel@vger.kernel.org Subject: Re: x86 CPU features detection for applications (and AMX) References: <87tulo39ms.fsf@oldenburg.str.redhat.com> Date: Thu, 08 Jul 2021 08:05:16 +0200 In-Reply-To: (Dave Hansen's message of "Wed, 23 Jun 2021 08:32:09 -0700") Message-ID: <878s2hz6g3.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Dave Hansen: > On 6/23/21 8:04 AM, Florian Weimer wrote: >> https://www.gnu.org/software/libc/manual/html_node/X86.html > ... >> Previously kernel developers have expressed dismay that we didn't >> coordinate the interface with them. This is why I want raise this now. > > This looks basically like someone dumped a bunch of CPUID bit values and > exposed them to applications without considering whether applications > would ever need them. For instance, why would an app ever care about: > > PKS =E2=80=93 Protection keys for supervisor-mode pages. > > And how could glibc ever give applications accurate information about > whether PKS "is supported by the operating system"? It just plain > doesn't know, or at least only knows from a really weak ABI like > /proc/cpuinfo. glibc is expected to mask these bits for CPU_FEATURE_USABLE because they have unknown semantics (to glibc). They are still exposed via HAS_CPU_FEATURE. I argued against HAS_CPU_FEATURE because the mere presence of this interface will introduce application bugs because application really must use CPU_FEATURE_USABLE instead. I wanted to go with a curated set of bits, but we couldn't get consensus around that. Curiously, the present interface can expose changing CPU state (if the kernel updates some fixed memory region accordingly), my preferred interface would not have supported that. > It also doesn't seem to tell applications what they want which is, "can > I, the application, *use* this feature?" CPU_FEATURE_USABLE is supposed to be that interface. Thanks, Florian