Skip to content

Commit 4d6fe79

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull more kvm updates from Paolo Bonzini: "New x86 features: - Guest API and guest kernel support for SEV live migration - SEV and SEV-ES intra-host migration Bugfixes and cleanups for x86: - Fix misuse of gfn-to-pfn cache when recording guest steal time / preempted status - Fix selftests on APICv machines - Fix sparse warnings - Fix detection of KVM features in CPUID - Cleanups for bogus writes to MSR_KVM_PV_EOI_EN - Fixes and cleanups for MSR bitmap handling - Cleanups for INVPCID - Make x86 KVM_SOFT_MAX_VCPUS consistent with other architectures Bugfixes for ARM: - Fix finalization of host stage2 mappings - Tighten the return value of kvm_vcpu_preferred_target() - Make sure the extraction of ESR_ELx.EC is limited to architected bits" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (34 commits) KVM: SEV: unify cgroup cleanup code for svm_vm_migrate_from KVM: x86: move guest_pv_has out of user_access section KVM: x86: Drop arbitrary KVM_SOFT_MAX_VCPUS KVM: Move INVPCID type check from vmx and svm to the common kvm_handle_invpcid() KVM: VMX: Add a helper function to retrieve the GPR index for INVPCID, INVVPID, and INVEPT KVM: nVMX: Clean up x2APIC MSR handling for L2 KVM: VMX: Macrofy the MSR bitmap getters and setters KVM: nVMX: Handle dynamic MSR intercept toggling KVM: nVMX: Query current VMCS when determining if MSR bitmaps are in use KVM: x86: Don't update vcpu->arch.pv_eoi.msr_val when a bogus value was written to MSR_KVM_PV_EOI_EN KVM: x86: Rename kvm_lapic_enable_pv_eoi() KVM: x86: Make sure KVM_CPUID_FEATURES really are KVM_CPUID_FEATURES KVM: x86: Add helper to consolidate core logic of SET_CPUID{2} flows kvm: mmu: Use fast PF path for access tracking of huge pages when possible KVM: x86/mmu: Properly dereference rcu-protected TDP MMU sptep iterator KVM: x86: inhibit APICv when KVM_GUESTDBG_BLOCKIRQ active kvm: x86: Convert return type of *is_valid_rdpmc_ecx() to bool KVM: x86: Fix recording of guest steal time / preempted status selftest: KVM: Add intra host migration tests selftest: KVM: Add open sev dev helper ...
2 parents d4fa09e + 84886c2 commit 4d6fe79

File tree

49 files changed

+1088
-370
lines changed

Some content is hidden

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

49 files changed

+1088
-370
lines changed

Documentation/virt/kvm/api.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6911,6 +6911,20 @@ MAP_SHARED mmap will result in an -EINVAL return.
69116911
When enabled the VMM may make use of the ``KVM_ARM_MTE_COPY_TAGS`` ioctl to
69126912
perform a bulk copy of tags to/from the guest.
69136913

6914+
7.29 KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM
6915+
-------------------------------------
6916+
6917+
Architectures: x86 SEV enabled
6918+
Type: vm
6919+
Parameters: args[0] is the fd of the source vm
6920+
Returns: 0 on success
6921+
6922+
This capability enables userspace to migrate the encryption context from the VM
6923+
indicated by the fd to the VM this is called on.
6924+
6925+
This is intended to support intra-host migration of VMs between userspace VMMs,
6926+
upgrading the VMM process without interrupting the guest.
6927+
69146928
8. Other capabilities.
69156929
======================
69166930

arch/arm64/include/asm/esr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
#define ESR_ELx_EC_MAX (0x3F)
6969

7070
#define ESR_ELx_EC_SHIFT (26)
71+
#define ESR_ELx_EC_WIDTH (6)
7172
#define ESR_ELx_EC_MASK (UL(0x3F) << ESR_ELx_EC_SHIFT)
7273
#define ESR_ELx_EC(esr) (((esr) & ESR_ELx_EC_MASK) >> ESR_ELx_EC_SHIFT)
7374

arch/arm64/include/asm/kvm_host.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ struct kvm_vcpu_stat {
584584
u64 exits;
585585
};
586586

587-
int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init);
587+
void kvm_vcpu_preferred_target(struct kvm_vcpu_init *init);
588588
unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu);
589589
int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices);
590590
int kvm_arm_get_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg);

arch/arm64/kvm/arm.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,12 +1389,9 @@ long kvm_arch_vm_ioctl(struct file *filp,
13891389
return kvm_vm_ioctl_set_device_addr(kvm, &dev_addr);
13901390
}
13911391
case KVM_ARM_PREFERRED_TARGET: {
1392-
int err;
13931392
struct kvm_vcpu_init init;
13941393

1395-
err = kvm_vcpu_preferred_target(&init);
1396-
if (err)
1397-
return err;
1394+
kvm_vcpu_preferred_target(&init);
13981395

13991396
if (copy_to_user(argp, &init, sizeof(init)))
14001397
return -EFAULT;

arch/arm64/kvm/guest.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -869,13 +869,10 @@ u32 __attribute_const__ kvm_target_cpu(void)
869869
return KVM_ARM_TARGET_GENERIC_V8;
870870
}
871871

872-
int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init)
872+
void kvm_vcpu_preferred_target(struct kvm_vcpu_init *init)
873873
{
874874
u32 target = kvm_target_cpu();
875875

876-
if (target < 0)
877-
return -ENODEV;
878-
879876
memset(init, 0, sizeof(*init));
880877

881878
/*
@@ -885,8 +882,6 @@ int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init)
885882
* target type.
886883
*/
887884
init->target = (__u32)target;
888-
889-
return 0;
890885
}
891886

892887
int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)

arch/arm64/kvm/hyp/hyp-entry.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
el1_sync: // Guest trapped into EL2
4545

4646
mrs x0, esr_el2
47-
lsr x0, x0, #ESR_ELx_EC_SHIFT
47+
ubfx x0, x0, #ESR_ELx_EC_SHIFT, #ESR_ELx_EC_WIDTH
4848
cmp x0, #ESR_ELx_EC_HVC64
4949
ccmp x0, #ESR_ELx_EC_HVC32, #4, ne
5050
b.ne el1_trap

arch/arm64/kvm/hyp/nvhe/host.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ SYM_FUNC_END(__host_hvc)
141141
.L__vect_start\@:
142142
stp x0, x1, [sp, #-16]!
143143
mrs x0, esr_el2
144-
lsr x0, x0, #ESR_ELx_EC_SHIFT
144+
ubfx x0, x0, #ESR_ELx_EC_SHIFT, #ESR_ELx_EC_WIDTH
145145
cmp x0, #ESR_ELx_EC_HVC64
146146
b.eq __host_hvc
147147
b __host_exit

arch/arm64/kvm/hyp/nvhe/setup.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static int finalize_host_mappings_walker(u64 addr, u64 end, u32 level,
178178

179179
phys = kvm_pte_to_phys(pte);
180180
if (!addr_is_memory(phys))
181-
return 0;
181+
return -EINVAL;
182182

183183
/*
184184
* Adjust the host stage-2 mappings to match the ownership attributes
@@ -207,8 +207,18 @@ static int finalize_host_mappings(void)
207207
.cb = finalize_host_mappings_walker,
208208
.flags = KVM_PGTABLE_WALK_LEAF,
209209
};
210+
int i, ret;
211+
212+
for (i = 0; i < hyp_memblock_nr; i++) {
213+
struct memblock_region *reg = &hyp_memory[i];
214+
u64 start = (u64)hyp_phys_to_virt(reg->base);
215+
216+
ret = kvm_pgtable_walk(&pkvm_pgtable, start, reg->size, &walker);
217+
if (ret)
218+
return ret;
219+
}
210220

211-
return kvm_pgtable_walk(&pkvm_pgtable, 0, BIT(pkvm_pgtable.ia_bits), &walker);
221+
return 0;
212222
}
213223

214224
void __noreturn __pkvm_init_finalise(void)

arch/arm64/kvm/hyp/nvhe/sys_regs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ bool kvm_handle_pvm_sysreg(struct kvm_vcpu *vcpu, u64 *exit_code)
474474
return true;
475475
}
476476

477-
/**
477+
/*
478478
* Handler for protected VM restricted exceptions.
479479
*
480480
* Inject an undefined exception into the guest and return true to indicate that

arch/x86/include/asm/kvm_host.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#define __KVM_HAVE_ARCH_VCPU_DEBUGFS
3939

4040
#define KVM_MAX_VCPUS 1024
41-
#define KVM_SOFT_MAX_VCPUS 710
4241

4342
/*
4443
* In x86, the VCPU ID corresponds to the APIC ID, and APIC IDs
@@ -725,6 +724,7 @@ struct kvm_vcpu_arch {
725724

726725
int cpuid_nent;
727726
struct kvm_cpuid_entry2 *cpuid_entries;
727+
u32 kvm_cpuid_base;
728728

729729
u64 reserved_gpa_bits;
730730
int maxphyaddr;
@@ -748,7 +748,7 @@ struct kvm_vcpu_arch {
748748
u8 preempted;
749749
u64 msr_val;
750750
u64 last_steal;
751-
struct gfn_to_pfn_cache cache;
751+
struct gfn_to_hva_cache cache;
752752
} st;
753753

754754
u64 l1_tsc_offset;
@@ -1034,6 +1034,7 @@ struct kvm_x86_msr_filter {
10341034
#define APICV_INHIBIT_REASON_IRQWIN 3
10351035
#define APICV_INHIBIT_REASON_PIT_REINJ 4
10361036
#define APICV_INHIBIT_REASON_X2APIC 5
1037+
#define APICV_INHIBIT_REASON_BLOCKIRQ 6
10371038

10381039
struct kvm_arch {
10391040
unsigned long n_used_mmu_pages;
@@ -1476,6 +1477,7 @@ struct kvm_x86_ops {
14761477
int (*mem_enc_reg_region)(struct kvm *kvm, struct kvm_enc_region *argp);
14771478
int (*mem_enc_unreg_region)(struct kvm *kvm, struct kvm_enc_region *argp);
14781479
int (*vm_copy_enc_context_from)(struct kvm *kvm, unsigned int source_fd);
1480+
int (*vm_move_enc_context_from)(struct kvm *kvm, unsigned int source_fd);
14791481

14801482
int (*get_msr_feature)(struct kvm_msr_entry *entry);
14811483

0 commit comments

Comments
 (0)