Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp395353ybb; Wed, 8 Apr 2020 01:56:17 -0700 (PDT) X-Google-Smtp-Source: APiQypINkaaqvlwvHHpHGuw09p0lDqooYivXuon8sBI/v4r4SMdXtmo9qg70RVjJWfkKcXoYElbc X-Received: by 2002:aca:5b09:: with SMTP id p9mr1670760oib.57.1586336177454; Wed, 08 Apr 2020 01:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586336177; cv=none; d=google.com; s=arc-20160816; b=euyBH2nlXl98bLwaLKZuG/2DWhc2DNvDxDMJGomvbvL3LUm3hj8UMhzGknPiLJmJPe Wn1hij4ZfS1lMJTtfzikwYV59ARud2gtlmh/ilfXmZaYMv9P5z1vxaYu47FIjJXW30rv EUU0V7h4t18NEcBTQoN3QILK0KGRPPvoQhtI57y2wi2ZxggHRIWP2pge+P0wKyMfpNlz Zi76q1hxJV5wBxi96mS7ciqfH+ceYPFM1YuEOyFeJ+hXpzzxG3xx/fb362FkglNC3//2 9QgM+qtd6NPjJJABAlam84/hFKGIob7RfVCoWAj7jiJdU8Lz9pRLdiStjWjPC5gLzBnP rj3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ERtUtaPypgnb+NtH656JmA67c7oy6LtzFhZvEl2iRIo=; b=Aky4F2b0z6+miM48LXXyfjH7qODrNmBj7Sc7Uy0/OePD2/nYKJTa9LVoU55ja2SzCl he/klPtEXjerQxguMFfv5XI1/YVVbbhRCLqgtVApISFzIo6OxZIcBQZDgCUkB71BdKUW Pc6gTPJ3wBhjdEAyNYPWI5kQiv/sBMC9ezyaad/fjNZru8LSg8VqY4/tKfoS4MD87dhR gCmBBiheWUsc3TXGOuad+4Pce9o9Tvgvxx45gD4Wq6JZBUCYI5Qnm6qIccA2jUUnlxTE Z7sBm3l2n86P9GiFEYExnolFaJBc4xZ+q5HPJLNYiitQx7soOLEmJ9Z+hSVGyoeeI6J8 DLjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="c9Blg/NL"; 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 z29si2536109ood.32.2020.04.08.01.56.03; Wed, 08 Apr 2020 01:56:17 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="c9Blg/NL"; 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 S1726964AbgDHIqh (ORCPT + 99 others); Wed, 8 Apr 2020 04:46:37 -0400 Received: from merlin.infradead.org ([205.233.59.134]:39886 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726670AbgDHIqg (ORCPT ); Wed, 8 Apr 2020 04:46:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ERtUtaPypgnb+NtH656JmA67c7oy6LtzFhZvEl2iRIo=; b=c9Blg/NLRKYBVKyS1BhH0EquxA FhT/oPKkfekeF3BKL2FB897OjmSUwfAkbUwqI9MrIyTGPxPn0VgI+sa1+GTAw9mhNnkfJQh3bbgLA +58ZX5H4ykLrh/1dYrvbINIkl2lJGSK6OdVaUtekMsDPyJvVPJq8G/HhNrEPGYoCDadXprcrZDXZm U/mmgbZhj6Y+wHoz0zDGRQzji36KeCLqmhcs2OccuhtbPWYER3tzpX1vP8dhuMp7jp13Oyt1u7iAu hWoeG3pm+6PDLcPAoxrFTm+Rn7sToPUY4AfnsdJ4EA3hjXKgy2HYuKt1N5/ueji8mG4K+jS7qm3jq APT3GBSQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jM6LP-0006Ff-TL; Wed, 08 Apr 2020 08:46:00 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 1EF53304DB2; Wed, 8 Apr 2020 10:45:58 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0B9612BB00AA0; Wed, 8 Apr 2020 10:45:58 +0200 (CEST) Date: Wed, 8 Apr 2020 10:45:58 +0200 From: Peter Zijlstra To: Paolo Bonzini Cc: Nadav Amit , Thomas Gleixner , LKML , hch@infradead.org, Sean Christopherson , mingo , bp , hpa@zytor.com, x86 , "Kenneth R. Crudup" , Jessica Yu , Rasmus Villemoes , Fenghua Yu , Xiaoyao Li , Thomas Hellstrom , Tony Luck , Steven Rostedt , Greg Kroah-Hartman , jannh@google.com, keescook@chromium.org, David.Laight@aculab.com, Doug Covelli , mhiramat@kernel.org Subject: Re: [PATCH 4/4] x86,module: Detect CRn and DRn manipulation Message-ID: <20200408084558.GP20713@hirez.programming.kicks-ass.net> References: <20200407110236.930134290@infradead.org> <20200407111007.429362016@infradead.org> <10ABBCEE-A74D-4100-99D9-05B4C1758FF6@gmail.com> <20200407193853.GP2452@worktop.programming.kicks-ass.net> <90B32DAE-0BB5-4455-8F73-C43037695E7C@gmail.com> <20200407205042.GT2452@worktop.programming.kicks-ass.net> <96C2F23A-D6F4-4A04-82B6-284788C5D2CC@gmail.com> <20200407212754.GU2452@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 08, 2020 at 12:12:14AM +0200, Paolo Bonzini wrote: > On 07/04/20 23:27, Peter Zijlstra wrote: > > On Tue, Apr 07, 2020 at 02:22:11PM -0700, Nadav Amit wrote: > >> Anyhow, I do not think it is the only use-case which is not covered by your > >> patches (even considering CRs/DRs alone). For example, there is no kernel > >> function to turn on CR4.VMXE, which is required to run hypervisors on x86. > > That needs an exported function; there is no way we'll allow random > > writes to CR4, there's too much dodgy stuff in there. > > native_write_cr4 and pv_ops (through which you can do write_cr4) are > both exported, and so is cpu_tlbstate which is used by __cr4_set_bits > and friends. Am I missing something glaringly obvious? cpu_tlbstate is going away, but yes, native_write_cr4() is the right interface to use, or rather the cr4_{set,clear,toggle}_bits() things are. That gives us control over which CR4 bits are available, and, a possible means of arbitrating that VMX bit.