Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4754127ybb; Tue, 7 Apr 2020 13:53:16 -0700 (PDT) X-Google-Smtp-Source: APiQypJSoNKcF/Jo701gEJqRLG4mc0Kstc0FElAMGo/sAJyQKJZkfE4JswB47sMLtu5TMBlnsYDC X-Received: by 2002:aca:c6d1:: with SMTP id w200mr43155oif.43.1586292796431; Tue, 07 Apr 2020 13:53:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586292796; cv=none; d=google.com; s=arc-20160816; b=JOqwfefo67NRDeZsCpRMVFqf1eNBEZ84PcCgujy1/4MIspuhgyUjv1l5CZxSLegPAO bfhph+FIS5XuIiAJYnflFYsQ05Y2rijxiYZomUKgcKd6SyAXIryV/NHKmemFPSD5PBvB jI3MnD/dC0Mcyt39sa6wqqMP7njqWW/yExE4t08qCdUfRBFo0nfiHoI+i6DbLt7c5zrI 2YA3c5lhZ7lsvD8U0RweaXwiLl+8EmnhyQU25sI5AX7SKwUiLn8EYV9+mlgC069D3HTs hKGLtgIsOz+11pivF4K2Lk4mQIv4kBAvH8J/ckCHoNGVFRCwDHxR0rAJDHWyQLrKAKHM dQ9g== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=lh4sEdCLn8yyKnv2ihUERe5IA2+XsyUMwTJh9Tv7VC4=; b=zUfbk8ScXG0++eKpj4D7iF7dDckzHUVRpKAN8nO0iskf46qEI1Tv29y30j/MFzVbXK GfRxTZNLgRmt9X76RivXI2Q/jEr1ItDnt/wTLOeQMuTNakIQiXVRm4oQ7aAS3/zd9p1t 1Mh/RwGKNAUjehJ3jynrtJ+kHKTfB8XMV0pli3if4TqCixphaYL6eYp5JOUwXqeeVLqs SV9pEURcfmu/FtnUrhmmKRgrqdy7sdsgWsqDX6IgERPaOL22TgMsDQndmwnOn/Lg4+fD Lb/Kz87FmTUB7xlJROBpm4hJUrpCp6x4b8c4JVcfxhEuitKfUNslkfrdssJM10C9SZF0 cBkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=uNwdKYbJ; 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 a7si1611563oop.8.2020.04.07.13.53.02; Tue, 07 Apr 2020 13:53:16 -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=uNwdKYbJ; 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 S1726504AbgDGUvW (ORCPT + 99 others); Tue, 7 Apr 2020 16:51:22 -0400 Received: from merlin.infradead.org ([205.233.59.134]:33518 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726370AbgDGUvW (ORCPT ); Tue, 7 Apr 2020 16:51:22 -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-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=lh4sEdCLn8yyKnv2ihUERe5IA2+XsyUMwTJh9Tv7VC4=; b=uNwdKYbJS/3gcAD7AScVS2Ri2s wWs84Rnl2Q/J2zVDi1SjuWf0i3EqN2Ny0ZqFCaEqX2nc5AMlCGGDfPoCSe8AF4aU+q/KrW/+SjlDA 8VDoFbNdRczApwiraJ3tjw+Mmi4DUp25CiRcEtDrBCQfc4iHAlTWMf/EW0JVZMBeerGUTKftEWqxA lGVoe3Gy49bVGPAXKyxFvVM+x/rB63pSmpYCJ3hnFh3BmThY3ANmkAjwNu1mPM+4ubpjESpIuijxI mzdg6L+DEfOV1s3uenbN8OrixipVOn+2VYvoxbTm3+/pHemVjml0QRNSdQ3aqqbkX4eBeSsKkz3Mr KPUMpaRw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLvBF-0002B5-W8; Tue, 07 Apr 2020 20:50:46 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id C300D982F1A; Tue, 7 Apr 2020 22:50:42 +0200 (CEST) Date: Tue, 7 Apr 2020 22:50:42 +0200 From: Peter Zijlstra To: Nadav Amit Cc: Thomas Gleixner , LKML , hch@infradead.org, Sean Christopherson , mingo , bp , hpa@zytor.com, x86 , "Kenneth R. Crudup" , Jessica Yu , Rasmus Villemoes , Paolo Bonzini , 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: <20200407205042.GT2452@worktop.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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <90B32DAE-0BB5-4455-8F73-C43037695E7C@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 07, 2020 at 01:27:45PM -0700, Nadav Amit wrote: > > On Apr 7, 2020, at 12:38 PM, Peter Zijlstra wrote: > > > > On Tue, Apr 07, 2020 at 11:55:21AM -0700, Nadav Amit wrote: > >>> On Apr 7, 2020, at 4:02 AM, Peter Zijlstra wrote: > >>> > >>> Since we now have infrastructure to analyze module text, disallow > >>> modules that write to CRn and DRn registers. > >> > >> Assuming the kernel is built without CONFIG_PARAVIRT, what is the right way > >> for out-of-tree modules to write to CRs? Let’s say CR2? > > > > Most of them there is no real justification for ever writing to. CR2 I > > suppose we can have an exception for given a sane rationale for why > > you'd need to rewrite the fault address. > > For the same reason that KVM writes to CR2 - to restore CR2 before entering > a guest, since CR2 not architecturally loaded from the VMCS. I suspect there > are additional use-cases which are not covered by the kernel interfaces. So I'm not much of a virt guy (clearly), and *groan*, that's horrible. I'll go make an exception for CR2.