From patchwork Wed Oct 13 14:55:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12556103 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47424C433EF for ; Wed, 13 Oct 2021 14:55:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B89D6113D for ; Wed, 13 Oct 2021 14:55:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235716AbhJMO5b (ORCPT ); Wed, 13 Oct 2021 10:57:31 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:35330 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230474AbhJMO5a (ORCPT ); Wed, 13 Oct 2021 10:57:30 -0400 Message-ID: <20211013142847.120153383@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1634136926; 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; bh=AwjCE+xbKu/H5GJ4tKzEriYfUyjYPMqyOA9GgccpEN8=; b=vGvtj7QOjQxo5JpHwUyhU4pbIugKHK/XCLwe/n5ttBjM4l7SyJ4xlA65Ko1ZUzEv2awVaX fNM0l8D7Pfpu7M/+rAZzAwjoP98CGmA8edZe/wLJ1cQt9zEc8GA2zPPDDH5L9H+ir4sMKL kC9MvJymn4TCJ8KcQeSVHxSCKL42hC/0fnKsZhUo/gtD0S/xXZOJl3M9r1HXDlTD7W8XqI zs2Yqv4QIoOQCCDWRQ3Ogl3oRsl+It6yiREA+syBHDb51KOm9hJW9XxKWbcPo3ww1yUXFo Ms+p95wPzHa57Xelx1Z8LErhG0XrzhmX3VNRj3tGHohqEySn0ygZxRju1AeGJw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1634136926; 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; bh=AwjCE+xbKu/H5GJ4tKzEriYfUyjYPMqyOA9GgccpEN8=; b=dfJTIxlxXgOfDJZqaymmk0A+YhfOFQsw2pQpmINKe4CUs0Q9Q/7deoSNvAk5KK2VeWXnf+ dV+spq7ZDAV7gzDQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, "Chang S. Bae" , Dave Hansen , Arjan van de Ven , kvm@vger.kernel.org, Paolo Bonzini Subject: [patch 00/21] x86/fpu: Move register state into a container struct (part 2) MIME-Version: 1.0 Date: Wed, 13 Oct 2021 16:55:25 +0200 (CEST) Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This is the second part of the effort to support AMX. The first part can be found here: https://lore.kernel.org/r/20211011215813.558681373@linutronix.de With AMX the FPU register state buffer which is part of task_struct::thread::fpu is not going to be extended unconditionally for all tasks on an AMX enabled system as that would waste minimum 8K per task. AMX provides a mechanism to trap on first use. That trap will be utilized to allocate a larger register state buffer when the task (process) has permissions to use it. The default buffer task_struct will only carry states up to AVX512. The original approach was to just allocate new register buffer, but that's not the right abstraction. The current series creates a container which carries information about the fpstate buffer, i.e. feature bits (user and kernel) and sizes (user and kernel). That allows all relevant code pathes to retrieve the required information from fpstate which avoids conditionals and lets the code just use this instead of reading it from the various global variables which provide this information today. The series is first introducing the new structure and then converting all usage sites over to it. After that it adds feature and size information and converts the affected code over to use that. This series is based on: git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git x86/fpu-1 and also available from git: git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git x86/fpu-2 The full series with part 3 and 4 on top is available here: git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git x86/fpu Thanks, tglx --- include/asm/fpu/api.h | 5 + include/asm/fpu/signal.h | 2 include/asm/fpu/types.h | 42 +++++++++++--- include/asm/fpu/xstate.h | 13 ---- include/asm/processor.h | 9 +-- include/asm/trace/fpu.h | 4 - kernel/fpu/context.h | 2 kernel/fpu/core.c | 140 +++++++++++++++++++++++++++-------------------- kernel/fpu/init.c | 16 ++++- kernel/fpu/internal.h | 7 +- kernel/fpu/regset.c | 28 ++++----- kernel/fpu/signal.c | 70 +++++++++++++---------- kernel/fpu/xstate.c | 56 ++++++++++++------ kernel/fpu/xstate.h | 24 ++++++-- kernel/process.c | 2 kvm/x86.c | 18 ++---- math-emu/fpu_aux.c | 2 math-emu/fpu_entry.c | 4 - math-emu/fpu_system.h | 2 19 files changed, 266 insertions(+), 180 deletions(-)