From patchwork Wed Mar 22 20:14:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 73666 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2561380wrt; Wed, 22 Mar 2023 13:45:03 -0700 (PDT) X-Google-Smtp-Source: AK7set9t3pftsHR0bytw7a6oCDvurqIoDNtTiwWwHpwjOfcQYeIIZN5k2++dA72Rtn2V9Slnn0K4 X-Received: by 2002:a17:902:e5c5:b0:19a:c65d:f90 with SMTP id u5-20020a170902e5c500b0019ac65d0f90mr4613185plf.44.1679517903549; Wed, 22 Mar 2023 13:45:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679517903; cv=none; d=google.com; s=arc-20160816; b=wQbN21IzwIAGix+6RYDA7+0ZNhIo3TLW3wSZS5QS/a1DLHZG1c8kqNhhB3mTkx7ilc wMOXyam8cTvq48TgVUzAgzMHbnAyqkQeO0qRTOTLdiB6MDau0/DSM9A/CqkymXWiXV7h dgOeEFND25apDzYeoth9K3/IEFs43DlUS3yrJkxECq4+TtbK3gpGTW/oQ0G38quOwQvE qzF1ZLLfvbHyV0y8Umq8AHIxts3i/i9N6vf4snWwyuOdoQqqAdjXPDRYHiJ2QpCxUaWP Te8UtAAqsWLHDNzQ7CttwHpNpFNkYVpZtlB0eQLjq2vOsVAlCPknKSNf0N+WljVG35nJ UJvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=SirrcNGjJd8qTjAXCDvK74Q1/5ugn2H17xCJeG7U+EU=; b=t+jgtreUUwfVUFlJNtYhL08r54rIGqpDFkd3UmNFVJJTHAC9FVqkt/mnCSBHfiNXWF dk6O0qA/DuNlvw4xKIG+qpld4L4l3uSs5UT65LiRx996UAPfjc9RlB0e55EePAubFViA JL/iGO9XCkw0oPHmZR5y19jgU3/ZKDRXw+3sUuYR/cDCtqabd6bHhQswxdv525LQSMwS eJyeOjgcdvlOxj56fKSlVnC+AoNRXvCns6hHQnigHq3BW+gN3kthYBjcSl11g7qkyScV 31mQnixRst7Z0ZXcgOcdbghi36/aC9rCXW0EKa1nNSmfTsI0DqBuKZrvwp8Mm2I6st1G GI0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=EK2bXwKI; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h192-20020a636cc9000000b0050be88ec962si16293532pgc.41.2023.03.22.13.44.51; Wed, 22 Mar 2023 13:45:03 -0700 (PDT) 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=@linutronix.de header.s=2020 header.b=EK2bXwKI; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229903AbjCVUa5 (ORCPT + 99 others); Wed, 22 Mar 2023 16:30:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232184AbjCVUaf (ORCPT ); Wed, 22 Mar 2023 16:30:35 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C8359BE02; Wed, 22 Mar 2023 13:21:21 -0700 (PDT) Date: Wed, 22 Mar 2023 20:14:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1679516094; h=from:from:sender:sender:reply-to: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; bh=SirrcNGjJd8qTjAXCDvK74Q1/5ugn2H17xCJeG7U+EU=; b=EK2bXwKIuBrIFIyiuVsD4FsEkC7iw4wDCVqXwscPPG8E88RmrBzl2PAQKm+0J99EPF2qBO Ktnl/A1wNR0OgRh7RDHZL58+xkrgRfoDSgvOJB0BTk7gYMBzq6BsqsyVC1QzGcbrS26u4G lmv57IeQcieLRbDkI8+LGKBwPcurE+47ayvli/cfHrjxVcezQI7LydFYAZdFZOZ/XITDWy 6QWvlzkz0ECdysMmIJXUSAoGyC5UYv0ImikCU+puVLjVVink3YLkcSZFKwlgv979k2K/3+ NyLakfyYbC5I7faC/vpWTA6pNv7wIjMD/GXpAP/0jxrkFqZIJtZav8PeLf220g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1679516094; h=from:from:sender:sender:reply-to: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; bh=SirrcNGjJd8qTjAXCDvK74Q1/5ugn2H17xCJeG7U+EU=; b=gEyJXRudKj3AaKqfgECyCtxD2sdhOQemQhQHrOP2E1zqtDjEnW2HJcAV+vq20IxQKVLoWQ C9Pxf6yTjobGFEDA== From: "tip-bot2 for Chang S. Bae" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/fpu] Documentation/x86: Add the AMX enabling example Cc: "Chang S. Bae" , Dave Hansen , Thiago Macieira , Bagas Sanjaya , Tony Luck , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <167951609373.5837.2925763899751490246.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761102165054905644?= X-GMAIL-MSGID: =?utf-8?q?1761102165054905644?= The following commit has been merged into the x86/fpu branch of tip: Commit-ID: 7f9daaf59e14d62b29b6f4ca743e17bf96ff42ae Gitweb: https://git.kernel.org/tip/7f9daaf59e14d62b29b6f4ca743e17bf96ff42ae Author: Chang S. Bae AuthorDate: Fri, 20 Jan 2023 16:18:59 -08:00 Committer: Dave Hansen CommitterDate: Wed, 22 Mar 2023 13:07:58 -07:00 Documentation/x86: Add the AMX enabling example Explain steps to enable the dynamic feature with a code example. Signed-off-by: Chang S. Bae Signed-off-by: Dave Hansen Reviewed-by: Thiago Macieira Reviewed-by: Bagas Sanjaya Reviewed-by: Tony Luck Link: https://lore.kernel.org/all/20230121001900.14900-4-chang.seok.bae%40intel.com --- Documentation/x86/xstate.rst | 55 +++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+) diff --git a/Documentation/x86/xstate.rst b/Documentation/x86/xstate.rst index e954e79..23b1c9f 100644 --- a/Documentation/x86/xstate.rst +++ b/Documentation/x86/xstate.rst @@ -80,6 +80,61 @@ the handler allocates a larger xstate buffer for the task so the large state can be context switched. In the unlikely cases that the allocation fails, the kernel sends SIGSEGV. +AMX TILE_DATA enabling example +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Below is the example of how userspace applications enable +TILE_DATA dynamically: + + 1. The application first needs to query the kernel for AMX + support:: + + #include + #include + #include + #include + + #ifndef ARCH_GET_XCOMP_SUPP + #define ARCH_GET_XCOMP_SUPP 0x1021 + #endif + + #ifndef ARCH_XCOMP_TILECFG + #define ARCH_XCOMP_TILECFG 17 + #endif + + #ifndef ARCH_XCOMP_TILEDATA + #define ARCH_XCOMP_TILEDATA 18 + #endif + + #define MASK_XCOMP_TILE ((1 << ARCH_XCOMP_TILECFG) | \ + (1 << ARCH_XCOMP_TILEDATA)) + + unsigned long features; + long rc; + + ... + + rc = syscall(SYS_arch_prctl, ARCH_GET_XCOMP_SUPP, &features); + + if (!rc && (features & MASK_XCOMP_TILE) == MASK_XCOMP_TILE) + printf("AMX is available.\n"); + + 2. After that, determining support for AMX, an application must + explicitly ask permission to use it:: + + #ifndef ARCH_REQ_XCOMP_PERM + #define ARCH_REQ_XCOMP_PERM 0x1023 + #endif + + ... + + rc = syscall(SYS_arch_prctl, ARCH_REQ_XCOMP_PERM, ARCH_XCOMP_TILEDATA); + + if (!rc) + printf("AMX is ready for use.\n"); + +Note this example does not include the sigaltstack preparation. + Dynamic features in signal frames ---------------------------------