Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8604350ybi; Thu, 6 Jun 2019 15:41:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwN/EZgSWDiZb4WQOqrxv9zsh4kWlK7UzfeIsjobC/I+niMql9V0a1xQSvMIHFvGOXVqaTx X-Received: by 2002:a63:cc4b:: with SMTP id q11mr133801pgi.43.1559860900453; Thu, 06 Jun 2019 15:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559860900; cv=none; d=google.com; s=arc-20160816; b=xV6HiiUk0gkS8sO+3sl10H/npABz7jSUJlY7VujsewbS2p16ItASnHZSUmvMNoXkux rZPUjqjWFnRTEwV39E09LQEizSQlJnws+i3kPQRmOW0k/quddPJH70PKJih98arzDQ3Z t2pjwA9c7yFJT4PNhFS30xWNNqC6wiTQqClU9oqXEYOwRtfshM8B1wjZn6ThEKin6E1L t48r00xHMjJk0v7mRpE2Rc39eHkdP+vGvLo4PkI+/TftPzUX359y46eFxK6srHhn8MfR jAg9q4KaRdzW/GRonVFcDamypjm1wGuJO7MFTJkUofFW9NgoymqLAS7H6NlF+CPlIv6o P2Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=XJNu7sen3MKt/5bh7xDkzC+qT4zLIA/t3Gj09QiyowI=; b=V/xTdneMF692ZPH74g60r8Xaw0TZ1FuobVOyXDILz7FLXFoe63qrQojlKplCytd9lx NfCVBNVElN9we6FrEnAOESJs7+Nzr0WdhYGcTjCjDvHWTzARqlTD+yQdNgsl5+kOiepw Ucsb70eS9m8sdH2UzNYOOk7xHvABaB2RS4QpgCTHSSeZfD72bsAc1SZzDroZpi3E6KbG HB5SlrkmVY44tOmALR4OX/B+Wcvb9O/PfxK1p+aMgxZvaC+OF2P81vGwhG9P1TVjVU0I DIdT7e8pDSWUrHHMYJCiUKIEY7huhfFplvEi68P6bWppLRZN8teVPqszClqfJ+GQPvrk lS/Q== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i94si270308plb.255.2019.06.06.15.41.24; Thu, 06 Jun 2019 15:41:40 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729106AbfFFWS6 (ORCPT + 99 others); Thu, 6 Jun 2019 18:18:58 -0400 Received: from mga18.intel.com ([134.134.136.126]:41329 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726837AbfFFWS6 (ORCPT ); Thu, 6 Jun 2019 18:18:58 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2019 15:18:57 -0700 X-ExtLoop1: 1 Received: from yyu32-desk1.sc.intel.com ([143.183.136.147]) by orsmga004.jf.intel.com with ESMTP; 06 Jun 2019 15:18:56 -0700 Message-ID: <93ee5b103b8261d2b50de89f8658d133639a9af5.camel@intel.com> Subject: Re: [PATCH v7 04/27] x86/fpu/xstate: Introduce XSAVES system states From: Yu-cheng Yu To: Dave Hansen , Andy Lutomirski Cc: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin Date: Thu, 06 Jun 2019 15:10:55 -0700 In-Reply-To: <4effb749-0cdc-6a49-6352-7b2d4aa7d866@intel.com> References: <20190606200646.3951-1-yu-cheng.yu@intel.com> <20190606200646.3951-5-yu-cheng.yu@intel.com> <0a2f8b9b-b96b-06c8-bae0-b78b2ca3b727@intel.com> <5EE146A8-6C8C-4C5D-B7C0-AB8AD1012F1E@amacapital.net> <4effb749-0cdc-6a49-6352-7b2d4aa7d866@intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2019-06-06 at 15:08 -0700, Dave Hansen wrote: > > On 6/6/19 3:04 PM, Andy Lutomirski wrote: > > > But, that seems broken. If we have supervisor state, we can't > > > always defer the load until return to userspace, so we'll never?? > > > have TIF_NEED_FPU_LOAD. That would certainly be true for > > > cet_kernel_state. > > > > Ugh. I was sort of imagining that we would treat supervisor state > > completely separately from user state. But can you maybe give > examples of exactly what you mean? > > > > > It seems like we actually need three classes of XSAVE states: 1. > > > User state > > > > This is FPU, XMM, etc, right? > > Yep. > > > > 2. Supervisor state that affects user mode > > > > User CET? > > Yep. > > > > 3. Supervisor state that affects kernel mode > > > > Like supervisor CET? If we start doing supervisor shadow stack, the > > context switches will be real fun. We may need to handle this in > > asm. > > Yeah, that's what I was thinking. > > I have the feeling Yu-cheng's patches don't comprehend this since > Sebastian's patches went in after he started working on shadow stacks. > > > Where does PKRU fit in? Maybe we can treat it as #3? > > I thought Sebastian added specific PKRU handling to make it always > eager. It's actually user state that affect kernel mode. :) For CET user states, we need to restore before making changes. If they are not being changed (i.e. signal handling and syscalls), then they are restored only before going back to user-mode. For CET kernel states, we only need to make small changes in the way similar to the PKRU handling, right? We'll address it when sending CET kernel-mode patches. I will put in more comments as suggested by Dave in earlier emails. Yu-cheng