Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4577741pxb; Thu, 14 Oct 2021 07:58:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7t2n5ca5htuEPTrLTDQv9jbrDlOmAYSw5xcUdZ/ZJo/e7Wi8g/9fWq/fqb661CZ7hzwCf X-Received: by 2002:a05:6402:4d1:: with SMTP id n17mr9521998edw.337.1634223483846; Thu, 14 Oct 2021 07:58:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634223483; cv=none; d=google.com; s=arc-20160816; b=Tjo8aB79S0IYLIRdCxHWdVLSiU5NavyXzfgmVuSQGQu7ckzbcAU+5LP5EBzhEY/1rn Hikb1P35um/4gbZ4b79HKjt18DU2mXXf9CLCQwC+bnnh/oHCjwf1FOFCMdhKrWe0qQoo OlmkDPK94fWuvdMXsoouC3Kkst3H7RgLjDSxkeeQJVukR4wsf+3aEsL/vPXDP3cwY/1v xsign97tuL9jPvYyTzB6UN57kd/wDMALYvOfjVtMMdD4j6mY9YSA5LmHC72iK/mZkqSX Ax2sliyMP5Tu0HEH66a1I/N/UPRA8i6wEL/BSNlu+w5yUflMTVqmuiBOqeEyljBu/uzx NJ3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=J704+ZpmNiG6G+UV4gpbHRzSAjI0YA9l6NLka/xr/hM=; b=SibfeuVju66h6dCQrwt+cTWR8AF/Fda+e8Nj270KT7vKh51lF5Dme1ccGzluUI1GMP fZjz3Q/6pFfag6TbVKEAeR98mdSV2RQcBTnOKaxxurMy47MvaomyOBjV+8kWcnFANE9l V1IqydZRZCna5MUTeiqdTJk7Up2+VWafK1sM4BIo/T+3pPpU1DhVIP8u3dqga3F9WV06 YYzikIboKQ2iC9AbBP96f73Cbkv9ny9KfoMO3TwCg6D5eet75FYUSyhM+6o9+C3V7f0p 8jP5PCYXncYiPuTO6P6VYD1WquTI/ADKSI+qcPVDDIwhL9aNG6yL8l17fBBb9OQx1CS1 dWXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="4XDFt/me"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=1JT1nsyY; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ci22si3872876ejb.240.2021.10.14.07.57.39; Thu, 14 Oct 2021 07:58:03 -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=@linutronix.de header.s=2020 header.b="4XDFt/me"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=1JT1nsyY; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231840AbhJNOZl (ORCPT + 99 others); Thu, 14 Oct 2021 10:25:41 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:42922 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230030AbhJNOZl (ORCPT ); Thu, 14 Oct 2021 10:25:41 -0400 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1634221415; 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: in-reply-to:in-reply-to:references:references; bh=J704+ZpmNiG6G+UV4gpbHRzSAjI0YA9l6NLka/xr/hM=; b=4XDFt/meAmEBqm2bXsSOvDvyeCn7FSTkyTiJP66ZC7rw4BltuOrBvoYSkya9pThKCN7S0Q wUTx/D3oknBz3lXPGIrx6EcIro1ftGRrLmXT8y0JOZ8VxNM/GBGr2JOybwG32kBoB8ejUK brf2Dmzo+n5A9YZzYksICGsf4fScM5MU9z8rr8cZZP91SjbW8bWSPFdfiS/4IuQKLLs7oo tEKtDgTwer/rEFF4WSkjwlHo04Uo32icxKy7gwVbnGElsmyyTFt6eHIcym81Xbi90Q8AF/ RuWtmtqkCkjRPClhuORlNsFvcGunfLB3OfVj9phCO56UgPkvbzYXUU3vyO6PWg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1634221415; 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: in-reply-to:in-reply-to:references:references; bh=J704+ZpmNiG6G+UV4gpbHRzSAjI0YA9l6NLka/xr/hM=; b=1JT1nsyY6wMrFXLqEVVa6oy17JxPi1RepbaCts8WFUOt/rePuWTvfp7zPLQ+tw1YVmFEaK 1DSVP9v4mKpc7BCQ== To: Paolo Bonzini , "Liu, Jing2" , LKML Cc: "x86@kernel.org" , "Bae, Chang Seok" , Dave Hansen , Arjan van de Ven , "kvm@vger.kernel.org" , "Nakajima, Jun" , Jing Liu , "seanjc@google.com" , Andrew Cooper Subject: Re: [patch 13/31] x86/fpu: Move KVMs FPU swapping to FPU core In-Reply-To: <0a5aa9d3-e0d4-266e-5e25-021a5ea9c611@redhat.com> References: <871r4p9fyh.ffs@tglx> <875ytz7q2u.ffs@tglx> <0a5aa9d3-e0d4-266e-5e25-021a5ea9c611@redhat.com> Date: Thu, 14 Oct 2021 16:23:34 +0200 Message-ID: <87tuhj65y1.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 14 2021 at 14:26, Paolo Bonzini wrote: > On 14/10/21 14:23, Thomas Gleixner wrote: >>> In principle I don't like it very much; it would be nicer to say "you >>> enable it for QEMU itself via arch_prctl(ARCH_SET_STATE_ENABLE), and for >>> the guests via ioctl(KVM_SET_CPUID2)". But I can see why you want to >>> keep things simple, so it's not a strong objection at all. >> Errm. >> >> qemu() >> read_config() >> if (dynamic_features_passthrough()) >> request_permission(feature) <- prctl(ARCH_SET_STATE_ENABLE) >> >> create_vcpu_threads() >> .... >> >> vcpu_thread() >> kvm_ioctl(ENABLE_DYN_FEATURE, feature) <- KVM ioctl >> >> That's what I lined out, right? >> > > I meant prctl for QEMU-in-user-mode vs. ioctl QEMU-in-guest-mode (i.e. > no prctl if only the guest uses it). But anyway it's just abstract > "beauty", let's stick to simple. :) It's not about simple. It's about correctness in the first place. The prctl() is process wide and grants permission. If that permission is not granted, e.g. by a seccomp rule, then the vCPU threads cannot use it either. We are _not_ making exceptions for KVM just because it's KVM. Trying to pretend that the usermode thread does not need it is just illusion. The kernel representation of that very usermode vCPU thread must have a large fpstate. It still can have XFD set, but that's a detail. So what you are trying to sell me has nothing to do with beauty at all except when your definition of beauty originates from a tunnel of horrors. Thanks, tglx