Skip to content

Commit beaeb4f

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull kvm fixes from Paolo Bonzini: "ARM: - fix fault on page table writes during instruction fetch s390: - doc improvement x86: - The obvious patches are always the ones that turn out to be completely broken. /me hangs his head in shame" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: Revert "KVM: Check the allocation of pv cpu mask" KVM: arm64: Remove S1PTW check from kvm_vcpu_dabt_iswrite() KVM: arm64: Assume write fault on S1PTW permission fault on instruction fetch docs: kvm: add documentation for KVM_CAP_S390_DIAG318
2 parents a311283 + 32251b0 commit beaeb4f

File tree

5 files changed

+37
-25
lines changed

5 files changed

+37
-25
lines changed

Documentation/virt/kvm/api.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6173,3 +6173,23 @@ specific interfaces must be consistent, i.e. if one says the feature
61736173
is supported, than the other should as well and vice versa. For arm64
61746174
see Documentation/virt/kvm/devices/vcpu.rst "KVM_ARM_VCPU_PVTIME_CTRL".
61756175
For x86 see Documentation/virt/kvm/msr.rst "MSR_KVM_STEAL_TIME".
6176+
6177+
8.25 KVM_CAP_S390_DIAG318
6178+
-------------------------
6179+
6180+
:Architectures: s390
6181+
6182+
This capability enables a guest to set information about its control program
6183+
(i.e. guest kernel type and version). The information is helpful during
6184+
system/firmware service events, providing additional data about the guest
6185+
environments running on the machine.
6186+
6187+
The information is associated with the DIAGNOSE 0x318 instruction, which sets
6188+
an 8-byte value consisting of a one-byte Control Program Name Code (CPNC) and
6189+
a 7-byte Control Program Version Code (CPVC). The CPNC determines what
6190+
environment the control program is running in (e.g. Linux, z/VM...), and the
6191+
CPVC is used for information specific to OS (e.g. Linux version, Linux
6192+
distribution...)
6193+
6194+
If this capability is available, then the CPNC and CPVC can be synchronized
6195+
between KVM and userspace via the sync regs mechanism (KVM_SYNC_DIAG318).

arch/arm64/include/asm/kvm_emulate.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,15 +298,15 @@ static __always_inline int kvm_vcpu_dabt_get_rd(const struct kvm_vcpu *vcpu)
298298
return (kvm_vcpu_get_esr(vcpu) & ESR_ELx_SRT_MASK) >> ESR_ELx_SRT_SHIFT;
299299
}
300300

301-
static __always_inline bool kvm_vcpu_dabt_iss1tw(const struct kvm_vcpu *vcpu)
301+
static __always_inline bool kvm_vcpu_abt_iss1tw(const struct kvm_vcpu *vcpu)
302302
{
303303
return !!(kvm_vcpu_get_esr(vcpu) & ESR_ELx_S1PTW);
304304
}
305305

306+
/* Always check for S1PTW *before* using this. */
306307
static __always_inline bool kvm_vcpu_dabt_iswrite(const struct kvm_vcpu *vcpu)
307308
{
308-
return !!(kvm_vcpu_get_esr(vcpu) & ESR_ELx_WNR) ||
309-
kvm_vcpu_dabt_iss1tw(vcpu); /* AF/DBM update */
309+
return kvm_vcpu_get_esr(vcpu) & ESR_ELx_WNR;
310310
}
311311

312312
static inline bool kvm_vcpu_dabt_is_cm(const struct kvm_vcpu *vcpu)
@@ -335,6 +335,11 @@ static inline bool kvm_vcpu_trap_is_iabt(const struct kvm_vcpu *vcpu)
335335
return kvm_vcpu_trap_get_class(vcpu) == ESR_ELx_EC_IABT_LOW;
336336
}
337337

338+
static inline bool kvm_vcpu_trap_is_exec_fault(const struct kvm_vcpu *vcpu)
339+
{
340+
return kvm_vcpu_trap_is_iabt(vcpu) && !kvm_vcpu_abt_iss1tw(vcpu);
341+
}
342+
338343
static __always_inline u8 kvm_vcpu_trap_get_fault(const struct kvm_vcpu *vcpu)
339344
{
340345
return kvm_vcpu_get_esr(vcpu) & ESR_ELx_FSC;
@@ -372,6 +377,9 @@ static __always_inline int kvm_vcpu_sys_get_rt(struct kvm_vcpu *vcpu)
372377

373378
static inline bool kvm_is_write_fault(struct kvm_vcpu *vcpu)
374379
{
380+
if (kvm_vcpu_abt_iss1tw(vcpu))
381+
return true;
382+
375383
if (kvm_vcpu_trap_is_iabt(vcpu))
376384
return false;
377385

arch/arm64/kvm/hyp/include/hyp/switch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ static inline bool fixup_guest_exit(struct kvm_vcpu *vcpu, u64 *exit_code)
449449
kvm_vcpu_trap_get_fault_type(vcpu) == FSC_FAULT &&
450450
kvm_vcpu_dabt_isvalid(vcpu) &&
451451
!kvm_vcpu_abt_issea(vcpu) &&
452-
!kvm_vcpu_dabt_iss1tw(vcpu);
452+
!kvm_vcpu_abt_iss1tw(vcpu);
453453

454454
if (valid) {
455455
int ret = __vgic_v2_perform_cpuif_access(vcpu);

arch/arm64/kvm/mmu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,7 +1849,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
18491849
struct kvm_s2_mmu *mmu = vcpu->arch.hw_mmu;
18501850

18511851
write_fault = kvm_is_write_fault(vcpu);
1852-
exec_fault = kvm_vcpu_trap_is_iabt(vcpu);
1852+
exec_fault = kvm_vcpu_trap_is_exec_fault(vcpu);
18531853
VM_BUG_ON(write_fault && exec_fault);
18541854

18551855
if (fault_status == FSC_PERM && !write_fault && !exec_fault) {
@@ -2131,7 +2131,7 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu)
21312131
goto out;
21322132
}
21332133

2134-
if (kvm_vcpu_dabt_iss1tw(vcpu)) {
2134+
if (kvm_vcpu_abt_iss1tw(vcpu)) {
21352135
kvm_inject_dabt(vcpu, kvm_vcpu_get_hfar(vcpu));
21362136
ret = 1;
21372137
goto out_unlock;

arch/x86/kernel/kvm.c

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ static void __init kvm_guest_init(void)
652652
}
653653

654654
if (pv_tlb_flush_supported()) {
655+
pv_ops.mmu.flush_tlb_others = kvm_flush_tlb_others;
655656
pv_ops.mmu.tlb_remove_table = tlb_remove_table;
656657
pr_info("KVM setup pv remote TLB flush\n");
657658
}
@@ -764,14 +765,6 @@ static __init int activate_jump_labels(void)
764765
}
765766
arch_initcall(activate_jump_labels);
766767

767-
static void kvm_free_pv_cpu_mask(void)
768-
{
769-
unsigned int cpu;
770-
771-
for_each_possible_cpu(cpu)
772-
free_cpumask_var(per_cpu(__pv_cpu_mask, cpu));
773-
}
774-
775768
static __init int kvm_alloc_cpumask(void)
776769
{
777770
int cpu;
@@ -790,20 +783,11 @@ static __init int kvm_alloc_cpumask(void)
790783

791784
if (alloc)
792785
for_each_possible_cpu(cpu) {
793-
if (!zalloc_cpumask_var_node(
794-
per_cpu_ptr(&__pv_cpu_mask, cpu),
795-
GFP_KERNEL, cpu_to_node(cpu))) {
796-
goto zalloc_cpumask_fail;
797-
}
786+
zalloc_cpumask_var_node(per_cpu_ptr(&__pv_cpu_mask, cpu),
787+
GFP_KERNEL, cpu_to_node(cpu));
798788
}
799789

800-
apic->send_IPI_mask_allbutself = kvm_send_ipi_mask_allbutself;
801-
pv_ops.mmu.flush_tlb_others = kvm_flush_tlb_others;
802790
return 0;
803-
804-
zalloc_cpumask_fail:
805-
kvm_free_pv_cpu_mask();
806-
return -ENOMEM;
807791
}
808792
arch_initcall(kvm_alloc_cpumask);
809793

0 commit comments

Comments
 (0)