public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Nadav Amit <nadav.amit@gmail.com>, Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	LKML <linux-kernel@vger.kernel.org>, <hch@infradead.org>,
	Sean Christopherson <sean.j.christopherson@intel.com>,
	mingo <mingo@redhat.com>, bp <bp@alien8.de>, <hpa@zytor.com>,
	x86 <x86@kernel.org>, "Kenneth R. Crudup" <kenny@panix.com>,
	Jessica Yu <jeyu@kernel.org>,
	Rasmus Villemoes <rasmus.villemoes@prevas.dk>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	Fenghua Yu <fenghua.yu@intel.com>,
	Xiaoyao Li <xiaoyao.li@intel.com>,
	Thomas Hellstrom <thellstrom@vmware.com>,
	Tony Luck <tony.luck@intel.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	<jannh@google.com>, <keescook@chromium.org>,
	<David.Laight@aculab.com>, Doug Covelli <dcovelli@vmware.com>,
	<mhiramat@kernel.org>
Subject: Re: [PATCH 4/4] x86,module: Detect CRn and DRn manipulation
Date: Wed, 8 Apr 2020 00:15:02 +0100	[thread overview]
Message-ID: <04f4fc03-95cd-df2e-e93d-e9c4fa221ae4@citrix.com> (raw)
In-Reply-To: <96C2F23A-D6F4-4A04-82B6-284788C5D2CC@gmail.com>

On 07/04/2020 22:22, Nadav Amit wrote:
>> On Apr 7, 2020, at 1:50 PM, Peter Zijlstra <peterz@infradead.org> wrote:
>>
>> On Tue, Apr 07, 2020 at 01:27:45PM -0700, Nadav Amit wrote:
>>>> On Apr 7, 2020, at 12:38 PM, Peter Zijlstra <peterz@infradead.org> wrote:
>>>>
>>>> On Tue, Apr 07, 2020 at 11:55:21AM -0700, Nadav Amit wrote:
>>>>>> On Apr 7, 2020, at 4:02 AM, Peter Zijlstra <peterz@infradead.org> 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.
> Clearly you are not a virt guy if you think that this is the horrible part
> in x86 virtualization ;-)

Very definitely seconded :)

> 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.

How about taking this opportunity to see if there is a way to improve on
the status quo for co-existing hypervisor modules?

ISTR there are a large number of hoops to jump through if you're not
sure if anything else in the system is using VMX, going as far as
needing to do a full VMXON/VMXOFF cycle each context.

Enabling CR4.VMXE might want to be done proactively by the kernel. 
Amongst other things, it gives protection against stray INIT IPIs in the
system, although the interaction with SMX (tboot / trenchboot) wants
considering carefully.

~Andrew

  parent reply	other threads:[~2020-04-07 23:15 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-07 11:02 [PATCH 0/4] x86/module: Out-of-tree module decode and sanitize Peter Zijlstra
2020-04-07 11:02 ` [PATCH 1/4] module: Expose load_info to arch module loader code Peter Zijlstra
2020-04-07 16:52   ` Kees Cook
2020-04-07 11:02 ` [PATCH 2/4] module: Convert module_finalize() to load_info Peter Zijlstra
2020-04-07 16:53   ` Kees Cook
2020-04-07 11:02 ` [PATCH 3/4] x86,module: Detect VMX vs SLD conflicts Peter Zijlstra
2020-04-07 14:35   ` Greg KH
2020-04-07 14:44     ` Paolo Bonzini
2020-04-07 14:55       ` Greg KH
2020-04-07 14:49     ` Steven Rostedt
2020-04-07 15:24     ` Peter Zijlstra
2020-04-07 15:28       ` Paolo Bonzini
2020-04-07 15:44       ` Greg KH
2020-04-07 16:51   ` Masami Hiramatsu
2020-04-07 17:16     ` Andrew Cooper
2020-04-07 23:59       ` Masami Hiramatsu
2020-04-08  7:25     ` Masami Hiramatsu
2020-04-07 18:26   ` kbuild test robot
2020-04-07 21:25   ` David Laight
2020-04-07 23:15     ` Kees Cook
2020-04-08  2:10   ` Xiaoyao Li
2020-04-08  8:09   ` Masami Hiramatsu
2020-04-08  9:56     ` Peter Zijlstra
2020-04-08 10:15       ` Andrew Cooper
2020-04-10 11:25       ` Masami Hiramatsu
2020-04-07 11:02 ` [PATCH 4/4] x86,module: Detect CRn and DRn manipulation Peter Zijlstra
2020-04-07 17:01   ` Kees Cook
2020-04-07 18:13     ` Peter Zijlstra
2020-04-07 18:49       ` Kees Cook
2020-04-07 18:55   ` Nadav Amit
2020-04-07 19:38     ` Peter Zijlstra
2020-04-07 20:27       ` Nadav Amit
2020-04-07 20:50         ` Peter Zijlstra
2020-04-07 21:22           ` Nadav Amit
2020-04-07 21:27             ` Peter Zijlstra
2020-04-07 22:12               ` Paolo Bonzini
2020-04-07 23:51                 ` Nadav Amit
2020-04-08  8:45                 ` Peter Zijlstra
2020-04-08  5:18               ` Christoph Hellwig
2020-04-07 23:15             ` Andrew Cooper [this message]
2020-04-08  0:22               ` Paolo Bonzini
2020-04-08  8:37                 ` Peter Zijlstra
2020-04-08  9:52                 ` Andrew Cooper
2020-04-07 21:48   ` Steven Rostedt
2020-04-08  5:58     ` Jan Kiszka
2020-04-08  8:03       ` Paolo Bonzini
2020-04-08  8:58         ` Jan Kiszka
2020-04-08  9:04           ` Paolo Bonzini
2020-04-08 10:45             ` Jan Kiszka
2020-04-08  8:51       ` Peter Zijlstra
2020-04-08  8:59         ` Jan Kiszka
2020-04-08  9:25           ` David Laight
2020-04-08 11:13             ` Jan Kiszka
2020-04-08 11:17               ` David Laight
2020-04-08  9:13         ` Peter Zijlstra
2020-04-08 10:50           ` Jan Kiszka
2020-04-08 13:27   ` Steven Rostedt
2020-04-08 15:44     ` Peter Zijlstra
2020-04-08 15:46       ` Christoph Hellwig
2020-04-08 16:02         ` Sean Christopherson
2020-04-08 16:15         ` Paolo Bonzini
2020-04-09  8:56           ` Peter Zijlstra
2020-04-09 10:13             ` Nadav Amit
2020-04-09 21:13               ` Thomas Gleixner
2020-04-09 22:18                 ` Steven Rostedt
2020-04-10  5:37                   ` Nadav Amit
2020-04-08 15:54       ` Jessica Yu
2020-04-07 17:23 ` [PATCH 0/4] x86/module: Out-of-tree module decode and sanitize Andrew Cooper
2020-04-07 19:41   ` Peter Zijlstra
2020-04-07 20:11     ` Andrew Cooper
2020-04-07 20:45       ` Peter Zijlstra
2020-04-07 21:21         ` Andrew Cooper
2020-04-07 20:21     ` Andrew Cooper
2020-04-07 20:48       ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=04f4fc03-95cd-df2e-e93d-e9c4fa221ae4@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=David.Laight@aculab.com \
    --cc=bp@alien8.de \
    --cc=dcovelli@vmware.com \
    --cc=fenghua.yu@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@infradead.org \
    --cc=hpa@zytor.com \
    --cc=jannh@google.com \
    --cc=jeyu@kernel.org \
    --cc=keescook@chromium.org \
    --cc=kenny@panix.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=nadav.amit@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rasmus.villemoes@prevas.dk \
    --cc=rostedt@goodmis.org \
    --cc=sean.j.christopherson@intel.com \
    --cc=tglx@linutronix.de \
    --cc=thellstrom@vmware.com \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    --cc=xiaoyao.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox