Skip to content

Commit 5fabc48

Browse files
committed
Merge branch 'kvm-updates/3.1' of git://git.kernel.org/pub/scm/virt/kvm/kvm
* 'kvm-updates/3.1' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (143 commits) KVM: IOMMU: Disable device assignment without interrupt remapping KVM: MMU: trace mmio page fault KVM: MMU: mmio page fault support KVM: MMU: reorganize struct kvm_shadow_walk_iterator KVM: MMU: lockless walking shadow page table KVM: MMU: do not need atomicly to set/clear spte KVM: MMU: introduce the rules to modify shadow page table KVM: MMU: abstract some functions to handle fault pfn KVM: MMU: filter out the mmio pfn from the fault pfn KVM: MMU: remove bypass_guest_pf KVM: MMU: split kvm_mmu_free_page KVM: MMU: count used shadow pages on prepareing path KVM: MMU: rename 'pt_write' to 'emulate' KVM: MMU: cleanup for FNAME(fetch) KVM: MMU: optimize to handle dirty bit KVM: MMU: cache mmio info on page fault path KVM: x86: introduce vcpu_mmio_gva_to_gpa to cleanup the code KVM: MMU: do not update slot bitmap if spte is nonpresent KVM: MMU: fix walking shadow page table KVM guest: KVM Steal time registration ...
2 parents c61264f + 3f68b03 commit 5fabc48

102 files changed

Lines changed: 12429 additions & 3788 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/kernel-parameters.txt‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,10 +1159,6 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
11591159
for all guests.
11601160
Default is 1 (enabled) if in 64bit or 32bit-PAE mode
11611161

1162-
kvm-intel.bypass_guest_pf=
1163-
[KVM,Intel] Disables bypassing of guest page faults
1164-
on Intel chips. Default is 1 (enabled)
1165-
11661162
kvm-intel.ept= [KVM,Intel] Disable extended page tables
11671163
(virtualized MMU) support on capable Intel chips.
11681164
Default is 1 (enabled)
@@ -1737,6 +1733,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
17371733
no-kvmapf [X86,KVM] Disable paravirtualized asynchronous page
17381734
fault handling.
17391735

1736+
no-steal-acc [X86,KVM] Disable paravirtualized steal time accounting.
1737+
steal time is computed, but won't influence scheduler
1738+
behaviour
1739+
17401740
nolapic [X86-32,APIC] Do not enable or use the local APIC.
17411741

17421742
nolapic_timer [X86-32,APIC] Do not use the local APIC timer.

‎Documentation/virtual/kvm/api.txt‎

Lines changed: 164 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,19 @@ KVM_CHECK_EXTENSION ioctl() to determine the value for max_vcpus at run-time.
180180
If the KVM_CAP_NR_VCPUS does not exist, you should assume that max_vcpus is 4
181181
cpus max.
182182

183+
On powerpc using book3s_hv mode, the vcpus are mapped onto virtual
184+
threads in one or more virtual CPU cores. (This is because the
185+
hardware requires all the hardware threads in a CPU core to be in the
186+
same partition.) The KVM_CAP_PPC_SMT capability indicates the number
187+
of vcpus per virtual core (vcore). The vcore id is obtained by
188+
dividing the vcpu id by the number of vcpus per vcore. The vcpus in a
189+
given vcore will always be in the same physical core as each other
190+
(though that might be a different physical core from time to time).
191+
Userspace can control the threading (SMT) mode of the guest by its
192+
allocation of vcpu ids. For example, if userspace wants
193+
single-threaded guest vcpus, it should make all vcpu ids be a multiple
194+
of the number of vcpus per vcore.
195+
183196
4.8 KVM_GET_DIRTY_LOG (vm ioctl)
184197

185198
Capability: basic
@@ -1143,15 +1156,10 @@ Assigns an IRQ to a passed-through device.
11431156

11441157
struct kvm_assigned_irq {
11451158
__u32 assigned_dev_id;
1146-
__u32 host_irq;
1159+
__u32 host_irq; /* ignored (legacy field) */
11471160
__u32 guest_irq;
11481161
__u32 flags;
11491162
union {
1150-
struct {
1151-
__u32 addr_lo;
1152-
__u32 addr_hi;
1153-
__u32 data;
1154-
} guest_msi;
11551163
__u32 reserved[12];
11561164
};
11571165
};
@@ -1239,8 +1247,10 @@ Type: vm ioctl
12391247
Parameters: struct kvm_assigned_msix_nr (in)
12401248
Returns: 0 on success, -1 on error
12411249

1242-
Set the number of MSI-X interrupts for an assigned device. This service can
1243-
only be called once in the lifetime of an assigned device.
1250+
Set the number of MSI-X interrupts for an assigned device. The number is
1251+
reset again by terminating the MSI-X assignment of the device via
1252+
KVM_DEASSIGN_DEV_IRQ. Calling this service more than once at any earlier
1253+
point will fail.
12441254

12451255
struct kvm_assigned_msix_nr {
12461256
__u32 assigned_dev_id;
@@ -1291,6 +1301,135 @@ Returns the tsc frequency of the guest. The unit of the return value is
12911301
KHz. If the host has unstable tsc this ioctl returns -EIO instead as an
12921302
error.
12931303

1304+
4.56 KVM_GET_LAPIC
1305+
1306+
Capability: KVM_CAP_IRQCHIP
1307+
Architectures: x86
1308+
Type: vcpu ioctl
1309+
Parameters: struct kvm_lapic_state (out)
1310+
Returns: 0 on success, -1 on error
1311+
1312+
#define KVM_APIC_REG_SIZE 0x400
1313+
struct kvm_lapic_state {
1314+
char regs[KVM_APIC_REG_SIZE];
1315+
};
1316+
1317+
Reads the Local APIC registers and copies them into the input argument. The
1318+
data format and layout are the same as documented in the architecture manual.
1319+
1320+
4.57 KVM_SET_LAPIC
1321+
1322+
Capability: KVM_CAP_IRQCHIP
1323+
Architectures: x86
1324+
Type: vcpu ioctl
1325+
Parameters: struct kvm_lapic_state (in)
1326+
Returns: 0 on success, -1 on error
1327+
1328+
#define KVM_APIC_REG_SIZE 0x400
1329+
struct kvm_lapic_state {
1330+
char regs[KVM_APIC_REG_SIZE];
1331+
};
1332+
1333+
Copies the input argument into the the Local APIC registers. The data format
1334+
and layout are the same as documented in the architecture manual.
1335+
1336+
4.58 KVM_IOEVENTFD
1337+
1338+
Capability: KVM_CAP_IOEVENTFD
1339+
Architectures: all
1340+
Type: vm ioctl
1341+
Parameters: struct kvm_ioeventfd (in)
1342+
Returns: 0 on success, !0 on error
1343+
1344+
This ioctl attaches or detaches an ioeventfd to a legal pio/mmio address
1345+
within the guest. A guest write in the registered address will signal the
1346+
provided event instead of triggering an exit.
1347+
1348+
struct kvm_ioeventfd {
1349+
__u64 datamatch;
1350+
__u64 addr; /* legal pio/mmio address */
1351+
__u32 len; /* 1, 2, 4, or 8 bytes */
1352+
__s32 fd;
1353+
__u32 flags;
1354+
__u8 pad[36];
1355+
};
1356+
1357+
The following flags are defined:
1358+
1359+
#define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch)
1360+
#define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio)
1361+
#define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign)
1362+
1363+
If datamatch flag is set, the event will be signaled only if the written value
1364+
to the registered address is equal to datamatch in struct kvm_ioeventfd.
1365+
1366+
4.62 KVM_CREATE_SPAPR_TCE
1367+
1368+
Capability: KVM_CAP_SPAPR_TCE
1369+
Architectures: powerpc
1370+
Type: vm ioctl
1371+
Parameters: struct kvm_create_spapr_tce (in)
1372+
Returns: file descriptor for manipulating the created TCE table
1373+
1374+
This creates a virtual TCE (translation control entry) table, which
1375+
is an IOMMU for PAPR-style virtual I/O. It is used to translate
1376+
logical addresses used in virtual I/O into guest physical addresses,
1377+
and provides a scatter/gather capability for PAPR virtual I/O.
1378+
1379+
/* for KVM_CAP_SPAPR_TCE */
1380+
struct kvm_create_spapr_tce {
1381+
__u64 liobn;
1382+
__u32 window_size;
1383+
};
1384+
1385+
The liobn field gives the logical IO bus number for which to create a
1386+
TCE table. The window_size field specifies the size of the DMA window
1387+
which this TCE table will translate - the table will contain one 64
1388+
bit TCE entry for every 4kiB of the DMA window.
1389+
1390+
When the guest issues an H_PUT_TCE hcall on a liobn for which a TCE
1391+
table has been created using this ioctl(), the kernel will handle it
1392+
in real mode, updating the TCE table. H_PUT_TCE calls for other
1393+
liobns will cause a vm exit and must be handled by userspace.
1394+
1395+
The return value is a file descriptor which can be passed to mmap(2)
1396+
to map the created TCE table into userspace. This lets userspace read
1397+
the entries written by kernel-handled H_PUT_TCE calls, and also lets
1398+
userspace update the TCE table directly which is useful in some
1399+
circumstances.
1400+
1401+
4.63 KVM_ALLOCATE_RMA
1402+
1403+
Capability: KVM_CAP_PPC_RMA
1404+
Architectures: powerpc
1405+
Type: vm ioctl
1406+
Parameters: struct kvm_allocate_rma (out)
1407+
Returns: file descriptor for mapping the allocated RMA
1408+
1409+
This allocates a Real Mode Area (RMA) from the pool allocated at boot
1410+
time by the kernel. An RMA is a physically-contiguous, aligned region
1411+
of memory used on older POWER processors to provide the memory which
1412+
will be accessed by real-mode (MMU off) accesses in a KVM guest.
1413+
POWER processors support a set of sizes for the RMA that usually
1414+
includes 64MB, 128MB, 256MB and some larger powers of two.
1415+
1416+
/* for KVM_ALLOCATE_RMA */
1417+
struct kvm_allocate_rma {
1418+
__u64 rma_size;
1419+
};
1420+
1421+
The return value is a file descriptor which can be passed to mmap(2)
1422+
to map the allocated RMA into userspace. The mapped area can then be
1423+
passed to the KVM_SET_USER_MEMORY_REGION ioctl to establish it as the
1424+
RMA for a virtual machine. The size of the RMA in bytes (which is
1425+
fixed at host kernel boot time) is returned in the rma_size field of
1426+
the argument structure.
1427+
1428+
The KVM_CAP_PPC_RMA capability is 1 or 2 if the KVM_ALLOCATE_RMA ioctl
1429+
is supported; 2 if the processor requires all virtual machines to have
1430+
an RMA, or 1 if the processor can use an RMA but doesn't require it,
1431+
because it supports the Virtual RMA (VRMA) facility.
1432+
12941433
5. The kvm_run structure
12951434

12961435
Application code obtains a pointer to the kvm_run structure by
@@ -1473,6 +1612,23 @@ Userspace can now handle the hypercall and when it's done modify the gprs as
14731612
necessary. Upon guest entry all guest GPRs will then be replaced by the values
14741613
in this struct.
14751614

1615+
/* KVM_EXIT_PAPR_HCALL */
1616+
struct {
1617+
__u64 nr;
1618+
__u64 ret;
1619+
__u64 args[9];
1620+
} papr_hcall;
1621+
1622+
This is used on 64-bit PowerPC when emulating a pSeries partition,
1623+
e.g. with the 'pseries' machine type in qemu. It occurs when the
1624+
guest does a hypercall using the 'sc 1' instruction. The 'nr' field
1625+
contains the hypercall number (from the guest R3), and 'args' contains
1626+
the arguments (from the guest R4 - R12). Userspace should put the
1627+
return code in 'ret' and any extra returned values in args[].
1628+
The possible hypercalls are defined in the Power Architecture Platform
1629+
Requirements (PAPR) document available from www.power.org (free
1630+
developer registration required to access it).
1631+
14761632
/* Fix the size of the union. */
14771633
char padding[256];
14781634
};

‎Documentation/virtual/kvm/mmu.txt‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ Shadow pages contain the following information:
165165
Contains the value of efer.nxe for which the page is valid.
166166
role.cr0_wp:
167167
Contains the value of cr0.wp for which the page is valid.
168+
role.smep_andnot_wp:
169+
Contains the value of cr4.smep && !cr0.wp for which the page is valid
170+
(pages for which this is true are different from other pages; see the
171+
treatment of cr0.wp=0 below).
168172
gfn:
169173
Either the guest page table containing the translations shadowed by this
170174
page, or the base page frame for linear translations. See role.direct.
@@ -317,6 +321,20 @@ on fault type:
317321

318322
(user write faults generate a #PF)
319323

324+
In the first case there is an additional complication if CR4.SMEP is
325+
enabled: since we've turned the page into a kernel page, the kernel may now
326+
execute it. We handle this by also setting spte.nx. If we get a user
327+
fetch or read fault, we'll change spte.u=1 and spte.nx=gpte.nx back.
328+
329+
To prevent an spte that was converted into a kernel page with cr0.wp=0
330+
from being written by the kernel after cr0.wp has changed to 1, we make
331+
the value of cr0.wp part of the page role. This means that an spte created
332+
with one value of cr0.wp cannot be used when cr0.wp has a different value -
333+
it will simply be missed by the shadow page lookup code. A similar issue
334+
exists when an spte created with cr0.wp=0 and cr4.smep=0 is used after
335+
changing cr4.smep to 1. To avoid this, the value of !cr0.wp && cr4.smep
336+
is also made a part of the page role.
337+
320338
Large pages
321339
===========
322340

‎Documentation/virtual/kvm/msr.txt‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,37 @@ MSR_KVM_ASYNC_PF_EN: 0x4b564d02
185185

186186
Currently type 2 APF will be always delivered on the same vcpu as
187187
type 1 was, but guest should not rely on that.
188+
189+
MSR_KVM_STEAL_TIME: 0x4b564d03
190+
191+
data: 64-byte alignment physical address of a memory area which must be
192+
in guest RAM, plus an enable bit in bit 0. This memory is expected to
193+
hold a copy of the following structure:
194+
195+
struct kvm_steal_time {
196+
__u64 steal;
197+
__u32 version;
198+
__u32 flags;
199+
__u32 pad[12];
200+
}
201+
202+
whose data will be filled in by the hypervisor periodically. Only one
203+
write, or registration, is needed for each VCPU. The interval between
204+
updates of this structure is arbitrary and implementation-dependent.
205+
The hypervisor may update this structure at any time it sees fit until
206+
anything with bit0 == 0 is written to it. Guest is required to make sure
207+
this structure is initialized to zero.
208+
209+
Fields have the following meanings:
210+
211+
version: a sequence counter. In other words, guest has to check
212+
this field before and after grabbing time information and make
213+
sure they are both equal and even. An odd version indicates an
214+
in-progress update.
215+
216+
flags: At this point, always zero. May be used to indicate
217+
changes in this structure in the future.
218+
219+
steal: the amount of time in which this vCPU did not run, in
220+
nanoseconds. Time during which the vcpu is idle, will not be
221+
reported as steal time.

0 commit comments

Comments
 (0)