linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Paolo Bonzini <pbonzini@redhat.com>, KVM <kvm@vger.kernel.org>
Cc: Emanuele Giuseppe Esposito <eesposit@redhat.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>,
	Sean Christopherson <seanjc@google.com>
Subject: linux-next: manual merge of the kvm tree with Linus tree
Date: Thu, 22 Apr 2021 14:29:24 +1000	[thread overview]
Message-ID: <20210422142924.222f7216@canb.auug.org.au> (raw)

[-- Attachment #1: Type: text/plain, Size: 6761 bytes --]

Hi all,

Today's linux-next merge of the kvm tree got a conflict in:

  Documentation/virt/kvm/api.rst

between commit:

  b318e8decf6b ("KVM: x86: Protect userspace MSR filter with SRCU, and set atomically-ish")

from Linus tree and commit:

  24e7475f931a ("doc/virt/kvm: move KVM_CAP_PPC_MULTITCE in section 8")

from the kvm tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc Documentation/virt/kvm/api.rst
index 245d80581f15,fd4a84911355..000000000000
--- a/Documentation/virt/kvm/api.rst
+++ b/Documentation/virt/kvm/api.rst
@@@ -3690,31 -3692,105 +3693,107 @@@ which is the maximum number of possibl
  
  Queues an SMI on the thread's vcpu.
  
- 4.97 KVM_CAP_PPC_MULTITCE
- -------------------------
+ 4.97 KVM_X86_SET_MSR_FILTER
+ ----------------------------
  
- :Capability: KVM_CAP_PPC_MULTITCE
- :Architectures: ppc
- :Type: vm
+ :Capability: KVM_X86_SET_MSR_FILTER
+ :Architectures: x86
+ :Type: vm ioctl
+ :Parameters: struct kvm_msr_filter
+ :Returns: 0 on success, < 0 on error
  
- This capability means the kernel is capable of handling hypercalls
- H_PUT_TCE_INDIRECT and H_STUFF_TCE without passing those into the user
- space. This significantly accelerates DMA operations for PPC KVM guests.
- User space should expect that its handlers for these hypercalls
- are not going to be called if user space previously registered LIOBN
- in KVM (via KVM_CREATE_SPAPR_TCE or similar calls).
+ ::
  
- In order to enable H_PUT_TCE_INDIRECT and H_STUFF_TCE use in the guest,
- user space might have to advertise it for the guest. For example,
- IBM pSeries (sPAPR) guest starts using them if "hcall-multi-tce" is
- present in the "ibm,hypertas-functions" device-tree property.
+   struct kvm_msr_filter_range {
+   #define KVM_MSR_FILTER_READ  (1 << 0)
+   #define KVM_MSR_FILTER_WRITE (1 << 1)
+ 	__u32 flags;
+ 	__u32 nmsrs; /* number of msrs in bitmap */
+ 	__u32 base;  /* MSR index the bitmap starts at */
+ 	__u8 *bitmap; /* a 1 bit allows the operations in flags, 0 denies */
+   };
  
- The hypercalls mentioned above may or may not be processed successfully
- in the kernel based fast path. If they can not be handled by the kernel,
- they will get passed on to user space. So user space still has to have
- an implementation for these despite the in kernel acceleration.
+   #define KVM_MSR_FILTER_MAX_RANGES 16
+   struct kvm_msr_filter {
+   #define KVM_MSR_FILTER_DEFAULT_ALLOW (0 << 0)
+   #define KVM_MSR_FILTER_DEFAULT_DENY  (1 << 0)
+ 	__u32 flags;
+ 	struct kvm_msr_filter_range ranges[KVM_MSR_FILTER_MAX_RANGES];
+   };
  
- This capability is always enabled.
+ flags values for ``struct kvm_msr_filter_range``:
+ 
+ ``KVM_MSR_FILTER_READ``
+ 
+   Filter read accesses to MSRs using the given bitmap. A 0 in the bitmap
+   indicates that a read should immediately fail, while a 1 indicates that
+   a read for a particular MSR should be handled regardless of the default
+   filter action.
+ 
+ ``KVM_MSR_FILTER_WRITE``
+ 
+   Filter write accesses to MSRs using the given bitmap. A 0 in the bitmap
+   indicates that a write should immediately fail, while a 1 indicates that
+   a write for a particular MSR should be handled regardless of the default
+   filter action.
+ 
+ ``KVM_MSR_FILTER_READ | KVM_MSR_FILTER_WRITE``
+ 
+   Filter both read and write accesses to MSRs using the given bitmap. A 0
+   in the bitmap indicates that both reads and writes should immediately fail,
+   while a 1 indicates that reads and writes for a particular MSR are not
+   filtered by this range.
+ 
+ flags values for ``struct kvm_msr_filter``:
+ 
+ ``KVM_MSR_FILTER_DEFAULT_ALLOW``
+ 
+   If no filter range matches an MSR index that is getting accessed, KVM will
+   fall back to allowing access to the MSR.
+ 
+ ``KVM_MSR_FILTER_DEFAULT_DENY``
+ 
+   If no filter range matches an MSR index that is getting accessed, KVM will
+   fall back to rejecting access to the MSR. In this mode, all MSRs that should
+   be processed by KVM need to explicitly be marked as allowed in the bitmaps.
+ 
+ This ioctl allows user space to define up to 16 bitmaps of MSR ranges to
+ specify whether a certain MSR access should be explicitly filtered for or not.
+ 
+ If this ioctl has never been invoked, MSR accesses are not guarded and the
+ default KVM in-kernel emulation behavior is fully preserved.
+ 
+ Calling this ioctl with an empty set of ranges (all nmsrs == 0) disables MSR
+ filtering. In that mode, ``KVM_MSR_FILTER_DEFAULT_DENY`` is invalid and causes
+ an error.
+ 
+ As soon as the filtering is in place, every MSR access is processed through
+ the filtering except for accesses to the x2APIC MSRs (from 0x800 to 0x8ff);
+ x2APIC MSRs are always allowed, independent of the ``default_allow`` setting,
+ and their behavior depends on the ``X2APIC_ENABLE`` bit of the APIC base
+ register.
+ 
+ If a bit is within one of the defined ranges, read and write accesses are
+ guarded by the bitmap's value for the MSR index if the kind of access
+ is included in the ``struct kvm_msr_filter_range`` flags.  If no range
+ cover this particular access, the behavior is determined by the flags
+ field in the kvm_msr_filter struct: ``KVM_MSR_FILTER_DEFAULT_ALLOW``
+ and ``KVM_MSR_FILTER_DEFAULT_DENY``.
+ 
+ Each bitmap range specifies a range of MSRs to potentially allow access on.
+ The range goes from MSR index [base .. base+nmsrs]. The flags field
+ indicates whether reads, writes or both reads and writes are filtered
+ by setting a 1 bit in the bitmap for the corresponding MSR index.
+ 
+ If an MSR access is not permitted through the filtering, it generates a
+ #GP inside the guest. When combined with KVM_CAP_X86_USER_SPACE_MSR, that
+ allows user space to deflect and potentially handle various MSR accesses
+ into user space.
+ 
 -If a vCPU is in running state while this ioctl is invoked, the vCPU may
 -experience inconsistent filtering behavior on MSR accesses.
++Note, invoking this ioctl with a vCPU is running is inherently racy.  However,
++KVM does guarantee that vCPUs will see either the previous filter or the new
++filter, e.g. MSRs with identical settings in both the old and new filter will
++have deterministic behavior.
  
  4.98 KVM_CREATE_SPAPR_TCE_64
  ----------------------------

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

             reply	other threads:[~2021-04-22  4:29 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22  4:29 Stephen Rothwell [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-10-10  1:31 linux-next: manual merge of the kvm tree with Linus' tree Stephen Rothwell
2022-07-13  6:02 Stephen Rothwell
2022-07-13  6:09 ` Paolo Bonzini
2022-06-09  0:33 Stephen Rothwell
2022-05-13  3:53 Stephen Rothwell
2022-03-30 23:42 Stephen Rothwell
2020-12-17  2:56 Stephen Rothwell
2020-04-02  2:36 Stephen Rothwell
2020-04-02  8:15 ` Paolo Bonzini
2020-04-02 10:44 ` Paolo Bonzini
2020-01-24  2:57 Stephen Rothwell
2019-05-17  1:16 Stephen Rothwell
2019-05-17  1:10 Stephen Rothwell
2019-05-17  1:04 Stephen Rothwell
2019-03-04  2:50 Stephen Rothwell
2018-10-18  2:37 Stephen Rothwell
2018-08-15  4:24 Stephen Rothwell
2018-08-15  4:20 Stephen Rothwell
2018-08-06  5:21 Stephen Rothwell
2018-06-04  7:04 Stephen Rothwell
2018-02-05  2:06 Stephen Rothwell
2018-02-05  1:06 Stephen Rothwell
2018-02-01  1:55 Stephen Rothwell
2018-02-01 10:47 ` Christoffer Dall
2018-02-01 13:22   ` Stephen Rothwell
2018-02-01 14:05     ` Christoffer Dall
2018-02-01 14:21     ` Paolo Bonzini
2018-02-01 15:22       ` Radim Krčmář
2018-02-01 15:30         ` Paolo Bonzini
2018-02-02  0:20         ` Stephen Rothwell
2018-02-02 17:22           ` Radim Krčmář
2018-01-25 21:07 Stephen Rothwell
2018-01-17  3:48 Stephen Rothwell
2018-01-17 11:45 ` Thomas Gleixner
2018-01-17 12:17   ` Paolo Bonzini
2018-01-17 12:23     ` Thomas Gleixner
2018-01-17 12:35       ` Paolo Bonzini
2018-01-17 12:37         ` Thomas Gleixner
2018-01-17 12:43       ` Stephen Rothwell
2018-01-17 12:53         ` Thomas Gleixner
2018-01-29  4:02           ` Stephen Rothwell
2018-01-29 10:35             ` Paolo Bonzini
2017-08-25  4:34 Stephen Rothwell
2017-09-04  6:04 ` Stephen Rothwell
2016-07-27  4:50 Stephen Rothwell
2015-05-25  7:25 Stephen Rothwell
2015-05-25 14:11 ` Paolo Bonzini
2015-02-09  6:11 Stephen Rothwell
2015-02-02  5:05 Stephen Rothwell
2015-02-02  5:03 Stephen Rothwell
2013-03-01  2:51 Stephen Rothwell
2013-02-07  3:20 Stephen Rothwell
2013-02-02  5:52 Stephen Rothwell
2012-09-12  4:33 Stephen Rothwell
2012-07-06  5:12 Stephen Rothwell
2010-05-13  3:43 Stephen Rothwell
2010-01-27  1:57 Stephen Rothwell
2010-01-27 16:38 ` Marcelo Tosatti
2009-11-06  0:21 Stephen Rothwell
2009-07-01  4:57 Stephen Rothwell
2009-07-01  7:10 ` Davide Libenzi
2009-07-01  7:32   ` Avi Kivity
2009-07-01 12:30     ` Gregory Haskins
2009-07-01 15:11       ` Davide Libenzi
2009-07-01 12:31     ` Gregory Haskins

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=20210422142924.222f7216@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=eesposit@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.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;
as well as URLs for NNTP newsgroup(s).