Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1490433ybb; Thu, 9 Apr 2020 03:14:32 -0700 (PDT) X-Google-Smtp-Source: APiQypKveSgcuIuGNb2H9hz/PTvedD6sVk9bUX1ZiY4HFZNXrfXi1aAQfp7RYEdHIrLXUlc8kejh X-Received: by 2002:a9d:4ee:: with SMTP id 101mr8828453otm.301.1586427272495; Thu, 09 Apr 2020 03:14:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586427272; cv=none; d=google.com; s=arc-20160816; b=ZtK78mnHqxbv7ITpVqVBZXq11BbJ5fbFoYBLkO8qttRXDCkt26ohakxoOQbqRdGitH UUqng4UbXPvNZMHWlVy9uKPG6DQMLyhePAogezCPDHTSV59A+lhvJ4O/WFeX32vaDu6z DroAfacTV/aAfUNxki+m1arICuuo7INIk+Zw0l9m/3QR0f7La3OcwW77J7oswq5ioNLg xpj+9c3ZddO/ZB0x37qX6B9UjYX79nrppvVCWyMoONTr5w4KwAc3LnYPhwq0xRoq3MyU brN1HBdgMeJS3Rd1S9qVGYRTcIiQnaF+uLYUckCUjKkr4LlcgFRsEMBEO4/4fKb1bArS wfaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=ynCLdXpG84c0FE+/5wf/U/eBy3GytSF4CZpZ1T22Cf8=; b=ejLbIGNp+VoKrdxyFfdlKdG+Doe7KFZ+dGZgcgg1fxoTnkVumqKqbTlLnD9b55VvNB wW2RbU5pyghkqkeKU0vV+AnoJwP0F8BnZe1hi7vcKD23opQCb4WzX0sODvZoeo4BRJ+g 4n/tVObJsPX0zRQv6uTR0/czv8DBFEXdr/lVTJFpfjaCqRXenSIVr9ray7eKOfuEN4zl vyb3DpoALd7TD5Qt2VeRlx+qGnql15/Ls4dixmRC3ijiW3THhmm0K73+2+9sXz7KBaLI t3A+6jq7buDzT3N7ojbNbg18GmWjMU2sWRzxphGRlwkFKxskmCGzxrhZGWINLk3KtX7e /ihA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jBPoT5am; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si3962912oti.16.2020.04.09.03.14.18; Thu, 09 Apr 2020 03:14:32 -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=pass header.i=@gmail.com header.s=20161025 header.b=jBPoT5am; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726626AbgDIKNf (ORCPT + 99 others); Thu, 9 Apr 2020 06:13:35 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44964 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725783AbgDIKNf (ORCPT ); Thu, 9 Apr 2020 06:13:35 -0400 Received: by mail-pg1-f193.google.com with SMTP id n13so3341349pgp.11 for ; Thu, 09 Apr 2020 03:13:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ynCLdXpG84c0FE+/5wf/U/eBy3GytSF4CZpZ1T22Cf8=; b=jBPoT5amth9HgrQf+FQdjhKLXAp03ruY0tki/CRjYxyBOLw/qyvHdJNgFd+MqDzucu 04T/6iEjpgyvsK0+0iEPWPsv1bxapUsUrIzQPWhATJu0yvXxgZZ9VFBWi5/u7Qgfjd+I wphZuUxKl8PauGqwmywD26rQEQbcF8BfZf7IReu6jMl76LOS8Sx13ivU756wiLZ7XezL sJTBOKjrcEqZxeHmnAOZ47jG/F8+Kg7lBFDqS8J4VAPXta0kUJfKVsLOQq3W8we6B/HN 9TjBhpVw3PQQFkr6gpEMMUM2YYSRBnquyDuxULhvc+TqhdR6ZBAgUhsQQalzv+jt2YLi jvKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ynCLdXpG84c0FE+/5wf/U/eBy3GytSF4CZpZ1T22Cf8=; b=gGZ4Y1E7pTCjA4QNWWBL70ZYyuLXTf+egqZkgf4z1QaisnJltpGU+wkokY53dUo+tb vCR9fnGQUeQ70rZiOG51TTCfr3tQP/MahTeTnOQ+fhtbpbQ+OnTeKsCCbxeHHUQaZ/3d ep33ZopkHXfXFpd3wvmEWq0vg3r2JeZQTkqnd69Tw7oc4l2LKstUt4+Cy9HQIyaUa6QL QhZYeR1a7IQFJvld9aQdAR+BL8XXPNBh7EpwnDz06rWP5fwbP2fq3VcpEyR7XNAAoFQd UN+9/v1RAp58Hn7ZsSh4vsZ4hA7Zy0tJJm6sfus0ci42KhcUa+YFiQjOlYKfIiKYdnCN s0rw== X-Gm-Message-State: AGi0PuYmas8gRbrIP0KonCmTEbX3rWoA4hgAVhDZILeF7vnLBhGKX/a0 uWxGlv+Sm23YNxWKv0kzHhk= X-Received: by 2002:aa7:96f8:: with SMTP id i24mr12398415pfq.321.1586427214602; Thu, 09 Apr 2020 03:13:34 -0700 (PDT) Received: from ?IPv6:2601:647:4700:9b2:b5b9:a7a3:5d7d:5415? ([2601:647:4700:9b2:b5b9:a7a3:5d7d:5415]) by smtp.gmail.com with ESMTPSA id z6sm17509552pgg.39.2020.04.09.03.13.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Apr 2020 03:13:33 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH 4/4] x86,module: Detect CRn and DRn manipulation From: Nadav Amit In-Reply-To: <20200409085632.GB20713@hirez.programming.kicks-ass.net> Date: Thu, 9 Apr 2020 03:13:30 -0700 Cc: Paolo Bonzini , Christoph Hellwig , Steven Rostedt , Thomas Gleixner , LKML , Sean Christopherson , mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, kenny@panix.com, jeyu@kernel.org, rasmus.villemoes@prevas.dk, fenghua.yu@intel.com, xiaoyao.li@intel.com, thellstrom@vmware.com, tony.luck@intel.com, gregkh@linuxfoundation.org, jannh@google.com, keescook@chromium.org, David.Laight@aculab.com, dcovelli@vmware.com, mhiramat@kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <9A25271A-71F7-4EA1-9D1C-23B53E35C281@gmail.com> References: <20200407110236.930134290@infradead.org> <20200407111007.429362016@infradead.org> <20200408092726.7c2bda01@gandalf.local.home> <20200408154419.GP20730@hirez.programming.kicks-ass.net> <20200408154602.GA24869@infradead.org> <2b0dc69c-f7f9-985d-fc40-8b7bbd927e4f@redhat.com> <20200409085632.GB20713@hirez.programming.kicks-ass.net> To: Peter Zijlstra X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Apr 9, 2020, at 1:56 AM, Peter Zijlstra = wrote: >=20 > On Wed, Apr 08, 2020 at 06:15:48PM +0200, Paolo Bonzini wrote: >> On 08/04/20 17:46, Christoph Hellwig wrote: >=20 >>> Scanning all modules seems safer. While we're at it - can be move = the >>> kvm bits using VMX to be always in the core kernel and just forbid >>> modules from using those instructions entirely? >>=20 >> I suppose we could use PVOPS-style patching for the more >> performance-critical cases, but VMREAD/VMWRITE does not seem like a >> particularly bad thing to allow modules and VMLAUNCH/VMRESUME have = very >> peculiar calling conventions around them. >>=20 >> However, I wouldn't mind it if VMCLEAR/VMPTRLD and the associated = kdump >> cleanup code were moved to core kernel code. >=20 > Speaking with my virt ignorance hat on, how impossible is it to = provide > generic/useful VMLAUNCH/VMRESUME wrappers? >=20 > Because a lot of what happens around VMEXIT/VMENTER is very much like > the userspace entry crud, as per that series from Thomas that fixes = all > that. And surely we don't need various broken copies of that in all = the > out-of-tree hypervisors. >=20 > Also, I suppose if you have this, we no longer need to excempt CR2. It depends on what you mean by =E2=80=9CVMLAUNCH/VMRESUME=E2=80=9D. If = you only consider the instructions themselves, as Sean did in vmx_vmenter() and vmx_vmexit(), there is no problem. Even if you consider saving the general purpose registers as done in __vmx_vcpu_run() - that=E2=80=99s relatively easy. I think that anything that is greater than that, for instance vmx_vcpu_run(), would require more thought and effort. KVM = data-structures, specifically kvm_vcpu and friends, would need to be broken into general = and KVM specific structures. I am really not sure that the end result would = be much better than using KVM user-space interfaces. I can ask someone from the VMware hypervisor developers to provide = VMware point-of-view, but it would help to know when do you plan to make such a change take, and whether there would be some transition stage. Adapting = a hypervisor to use different low-level interfaces would require quite = some development & testing effort.