Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1004933imm; Wed, 19 Sep 2018 10:20:34 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZzZ6RNTvbSoPD7pZcVSYsApsBMaC+LtnVjzOqf6gftd2ePk9AItrv0IIMpfTzuuv8+jNFl X-Received: by 2002:a62:2744:: with SMTP id n65-v6mr37472934pfn.125.1537377634083; Wed, 19 Sep 2018 10:20:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537377634; cv=none; d=google.com; s=arc-20160816; b=0PpCPUehKKtBYA037SOcxoeU1XbUE8g1lAFBQafzdZ8kxMNt6nA0k3XHJKg2kc4ZEN deA/aOambKDlbHffaMJdb1f1LREQcVdojpgFCOXtCjQcRYCuVuxiTphth5mMVUB3ziiw zVTMuKwQ+vEwFX8hJYTYKQyKBk6HUzGFtOdWnra1dTR2j/BGgbU7/+xdMXLoJMNYOVRs 9A4LTLfC9oDDRal0NA27m9EhF7oo7gZ/FsPUsNc0gGYA2FVQ5C4DYlZUsU9uFwyQi38A UUbseO+ie6S77zFHQgqlgb7eEkaMD8v6//NFWgElLhFv7o67JBYMcQ9EaGoKjLBen5ck KzgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=a/DdtP+S8GZzwdztspqL+9e1D4pCROoV4o27K7IHQws=; b=sHvXcpEiv16Cq/DrIKETiSFG6mgC3+rPLbiKpwlEr7yN9ENKRXUba0b7K0gBXq4YmF VWoXqchRd5QqXsZKNp0aCLf1tRVVv/KPJCLU4m2l5IIcTRimnRzr8n8FO0N1A4b4Pwn3 Qgju4yathcpvafBxD5zIZXL7w5WN8Y45/w8F9UcXTEWGL6ekXIUfHIh0KOqjwWkJSFLf q5h/baF59rkx7G7wg0qhqavcy4kF6l5WnSFAcKQAi1YbJgpxyeTg/8VZVerdR+SR5oDM 8AvjX2Bq9UyaCk9yP447dRN3Yogk0d5g3C0qtviwtt2okwhr5Ysx+CneDMEdhPCxZ6Bk O0ag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33-v6si21123845pgm.94.2018.09.19.10.20.18; Wed, 19 Sep 2018 10:20:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732929AbeISW6m (ORCPT + 99 others); Wed, 19 Sep 2018 18:58:42 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:33059 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728339AbeISW6m (ORCPT ); Wed, 19 Sep 2018 18:58:42 -0400 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1g2g8f-0006l2-Ka; Wed, 19 Sep 2018 19:19:45 +0200 Date: Wed, 19 Sep 2018 19:19:45 +0200 From: Sebastian Andrzej Siewior To: Paolo Bonzini Cc: Rik van Riel , linux-kernel@vger.kernel.org, x86@kernel.org, Andy Lutomirski , Radim =?utf-8?B?S3LEjW3DocWZ?= , kvm@vger.kernel.org, "Jason A. Donenfeld" Subject: Re: [RFC PATCH 04/10 v2 ] x86/fpu: eager switch PKRU state Message-ID: <20180919171945.rd7dni7mih4yrh7r@linutronix.de> References: <20180918142701.atfb4ul45k7tl6ew@linutronix.de> <7e9a13f3-93f5-fe4a-20d2-f4f9407bd43b@redhat.com> <83e271e1298d603c1105dd0dbea32d67da9cf1fa.camel@surriel.com> <36e8493f-f994-e885-8fe6-2f0d4a9904a1@redhat.com> <20180918160419.2zeru6xnufxixcax@linutronix.de> <11aa7d0f4ba36eff8b61a5dc1bd35ee5195fd576.camel@surriel.com> <20180919165719.iepvc7tg6aabp5mm@linutronix.de> <099b9f82-e162-c91a-bc51-aa1ac0cd50aa@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <099b9f82-e162-c91a-bc51-aa1ac0cd50aa@redhat.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-09-19 19:00:34 [+0200], Paolo Bonzini wrote: > On 19/09/2018 18:57, Sebastian Andrzej Siewior wrote: > > On 2018-09-19 07:55:51 [+0200], Paolo Bonzini wrote: > >> A kthread can do use_mm/unuse_mm. > > > > indeed. The FPU struct for the kernel thread isn't valid / does not > > contain the expected PKRU value. So loading the pkru value from the > > struct FPU does not work as expected. We could set it to 0 for a kernel > > thread so we don't end up with a random value. > > If we want to get this usecase working then we would have to move pkru > > value from FPU to mm_struct and consider it in use_mm(). Do we want > > this? > > As a start, I think keeping it in the FPU struct but loading it > unconditionally will work. kthreads will not obey PKU but it will be > better already. Are you saying I should load the uninitialized value for kthreads or load 0 to have in a known state? > I honestly don't know if PKRU should be per-mm, I don't know mm very > well despite my brilliant observation above. :) Now that I have qemu machine with PKRU I would need to figure out how this works. So unless I am mistaken mm is per task and the FPU is per thread. And since the FPU struct isn't initialized for kthreads, we should end up with 0. But setting to 0 if not used sounds good. > Paolo Sebastian