]> Git Repo - linux.git/commitdiff
Merge tag 'kvmarm-6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm...
authorPaolo Bonzini <[email protected]>
Mon, 20 Feb 2023 11:12:42 +0000 (06:12 -0500)
committerPaolo Bonzini <[email protected]>
Mon, 20 Feb 2023 11:12:42 +0000 (06:12 -0500)
KVM/arm64 updates for 6.3

 - Provide a virtual cache topology to the guest to avoid
   inconsistencies with migration on heterogenous systems. Non secure
   software has no practical need to traverse the caches by set/way in
   the first place.

 - Add support for taking stage-2 access faults in parallel. This was an
   accidental omission in the original parallel faults implementation,
   but should provide a marginal improvement to machines w/o FEAT_HAFDBS
   (such as hardware from the fruit company).

 - A preamble to adding support for nested virtualization to KVM,
   including vEL2 register state, rudimentary nested exception handling
   and masking unsupported features for nested guests.

 - Fixes to the PSCI relay that avoid an unexpected host SVE trap when
   resuming a CPU when running pKVM.

 - VGIC maintenance interrupt support for the AIC

 - Improvements to the arch timer emulation, primarily aimed at reducing
   the trap overhead of running nested.

 - Add CONFIG_USERFAULTFD to the KVM selftests config fragment in the
   interest of CI systems.

 - Avoid VM-wide stop-the-world operations when a vCPU accesses its own
   redistributor.

 - Serialize when toggling CPACR_EL1.SMEN to avoid unexpected exceptions
   in the host.

 - Aesthetic and comment/kerneldoc fixes

 - Drop the vestiges of the old Columbia mailing list and add [Oliver]
   as co-maintainer

This also drags in arm64's 'for-next/sme2' branch, because both it and
the PSCI relay changes touch the EL2 initialization code.

1  2 
MAINTAINERS
arch/arm64/kvm/guest.c
arch/arm64/kvm/vgic/vgic-v3.c
arch/x86/include/asm/kvm_host.h
tools/testing/selftests/kvm/aarch64/page_fault_test.c

diff --combined MAINTAINERS
index fb1471cb5ed3dc1b1b8582e6ba3ace5a35c767ea,9c2f78f8c383e5d8f0675331ca826f20cd2c81ef..233ded73ff036d3600514736ea4d95050dcf0725
@@@ -383,7 -383,7 +383,7 @@@ ACPI COMPONENT ARCHITECTURE (ACPICA
  M:    Robert Moore <[email protected]>
  M:    "Rafael J. Wysocki" <[email protected]>
  L:    [email protected]
 -L:    devel@acpica.org
 +L:    [email protected].org
  S:    Supported
  W:    https://acpica.org/
  W:    https://github.com/acpica/acpica/
@@@ -1097,12 -1097,14 +1097,12 @@@ S:   Maintaine
  F:    drivers/dma/ptdma/
  
  AMD SEATTLE DEVICE TREE SUPPORT
 -M:    Brijesh Singh <[email protected]>
  M:    Suravee Suthikulpanit <[email protected]>
  M:    Tom Lendacky <[email protected]>
  S:    Supported
  F:    arch/arm64/boot/dts/amd/
  
  AMD XGBE DRIVER
 -M:    Tom Lendacky <[email protected]>
  M:    "Shyam Sundar S K" <[email protected]>
  L:    [email protected]
  S:    Supported
@@@ -2211,9 -2213,6 +2211,9 @@@ L:      [email protected]
  S:    Maintained
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git
  X:    drivers/media/i2c/
 +F:    arch/arm64/boot/dts/freescale/
 +X:    arch/arm64/boot/dts/freescale/fsl-*
 +X:    arch/arm64/boot/dts/freescale/qoriq-*
  N:    imx
  N:    mxs
  
@@@ -2452,14 -2451,11 +2452,14 @@@ F:   drivers/rtc/rtc-mt7622.
  
  ARM/Mediatek SoC support
  M:    Matthias Brugger <[email protected]>
 +R:    AngeloGioacchino Del Regno <[email protected]>
 +L:    [email protected]
  L:    [email protected] (moderated for non-subscribers)
  L:    [email protected] (moderated for non-subscribers)
  S:    Maintained
  W:    https://mtk.wiki.kernel.org/
 -C:    irc://chat.freenode.net/linux-mediatek
 +C:    irc://irc.libera.chat/linux-mediatek
 +F:    arch/arm/boot/dts/mt2*
  F:    arch/arm/boot/dts/mt6*
  F:    arch/arm/boot/dts/mt7*
  F:    arch/arm/boot/dts/mt8*
@@@ -2467,7 -2463,7 +2467,7 @@@ F:      arch/arm/mach-mediatek
  F:    arch/arm64/boot/dts/mediatek/
  F:    drivers/soc/mediatek/
  N:    mtk
 -N:    mt[678]
 +N:    mt[2678]
  K:    mediatek
  
  ARM/Mediatek USB3 PHY DRIVER
@@@ -3771,6 -3767,7 +3771,6 @@@ F:      net/bluetooth
  
  BONDING DRIVER
  M:    Jay Vosburgh <[email protected]>
 -M:    Veaceslav Falico <[email protected]>
  M:    Andy Gospodarek <[email protected]>
  L:    [email protected]
  S:    Supported
@@@ -6951,7 -6948,7 +6951,7 @@@ F:      drivers/gpu/drm/atmel-hlcdc
  DRM DRIVERS FOR BRIDGE CHIPS
  M:    Andrzej Hajda <[email protected]>
  M:    Neil Armstrong <[email protected]>
 -M:    Robert Foss <robert.foss@linaro.org>
 +M:    Robert Foss <rfoss@kernel.org>
  R:    Laurent Pinchart <[email protected]>
  R:    Jonas Karlman <[email protected]>
  R:    Jernej Skrabec <[email protected]>
@@@ -7619,6 -7616,7 +7619,6 @@@ S:      Maintaine
  F:    drivers/firmware/efi/test/
  
  EFI VARIABLE FILESYSTEM
 -M:    Matthew Garrett <[email protected]>
  M:    Jeremy Kerr <[email protected]>
  M:    Ard Biesheuvel <[email protected]>
  L:    [email protected]
@@@ -7897,11 -7895,7 +7897,11 @@@ F:    include/linux/extcon
  
  EXTRA BOOT CONFIG
  M:    Masami Hiramatsu <[email protected]>
 +L:    [email protected]
 +L:    [email protected]
 +Q:    https://patchwork.kernel.org/project/linux-trace-kernel/list/
  S:    Maintained
 +T:    git git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
  F:    Documentation/admin-guide/bootconfig.rst
  F:    fs/proc/bootconfig.c
  F:    include/linux/bootconfig.h
@@@ -8474,16 -8468,16 +8474,16 @@@ F:   fs/fscache
  F:    include/linux/fscache*.h
  
  FSCRYPT: FILE SYSTEM LEVEL ENCRYPTION SUPPORT
 +M:    Eric Biggers <[email protected]>
  M:    Theodore Y. Ts'o <[email protected]>
  M:    Jaegeuk Kim <[email protected]>
 -M:    Eric Biggers <[email protected]>
  L:    [email protected]
  S:    Supported
  Q:    https://patchwork.kernel.org/project/linux-fscrypt/list/
 -T:    git git://git.kernel.org/pub/scm/fs/fscrypt/fscrypt.git
 +T:    git https://git.kernel.org/pub/scm/fs/fscrypt/linux.git
  F:    Documentation/filesystems/fscrypt.rst
  F:    fs/crypto/
 -F:    include/linux/fscrypt*.h
 +F:    include/linux/fscrypt.h
  F:    include/uapi/linux/fscrypt.h
  
  FSI SUBSYSTEM
@@@ -8526,10 -8520,10 +8526,10 @@@ F:   include/linux/fsnotify*.
  FSVERITY: READ-ONLY FILE-BASED AUTHENTICITY PROTECTION
  M:    Eric Biggers <[email protected]>
  M:    Theodore Y. Ts'o <[email protected]>
 -L:    [email protected]
 +L:    [email protected]
  S:    Supported
 -Q:    https://patchwork.kernel.org/project/linux-fscrypt/list/
 -T:    git git://git.kernel.org/pub/scm/fs/fscrypt/fscrypt.git fsverity
 +Q:    https://patchwork.kernel.org/project/fsverity/list/
 +T:    git https://git.kernel.org/pub/scm/fs/fsverity/linux.git
  F:    Documentation/filesystems/fsverity.rst
  F:    fs/verity/
  F:    include/linux/fsverity.h
@@@ -8577,7 -8571,6 +8577,7 @@@ F:      kernel/trace/fgraph.
  F:    arch/*/*/*/*ftrace*
  F:    arch/*/*/*ftrace*
  F:    include/*/ftrace.h
 +F:    samples/ftrace
  
  FUNGIBLE ETHERNET DRIVERS
  M:    Dimitris Michailidis <[email protected]>
@@@ -9306,7 -9299,7 +9306,7 @@@ F:      net/dsa/tag_hellcreek.
  
  HISILICON DMA DRIVER
  M:    Zhou Wang <[email protected]>
 -M:    Jie Hai <haijie1@hisilicon.com>
 +M:    Jie Hai <haijie1@huawei.com>
  L:    [email protected]
  S:    Maintained
  F:    drivers/dma/hisi_dma.c
@@@ -11362,13 -11355,12 +11362,12 @@@ F:        virt/kvm/
  
  KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64)
  M:    Marc Zyngier <[email protected]>
+ M:    Oliver Upton <[email protected]>
  R:    James Morse <[email protected]>
  R:    Suzuki K Poulose <[email protected]>
- R:    Oliver Upton <[email protected]>
  R:    Zenghui Yu <[email protected]>
  L:    [email protected] (moderated for non-subscribers)
  L:    [email protected]
- L:    [email protected] (deprecated, moderated for non-subscribers)
  S:    Maintained
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git
  F:    arch/arm64/include/asm/kvm*
@@@ -14608,6 -14600,7 +14607,6 @@@ F:   tools/testing/selftests/net/ipsec.
  
  NETWORKING [IPv4/IPv6]
  M:    "David S. Miller" <[email protected]>
 -M:    Hideaki YOSHIFUJI <[email protected]>
  M:    David Ahern <[email protected]>
  L:    [email protected]
  S:    Maintained
@@@ -14640,6 -14633,7 +14639,6 @@@ F:   net/netfilter/xt_SECMARK.
  F:    net/netlabel/
  
  NETWORKING [MPTCP]
 -M:    Mat Martineau <[email protected]>
  M:    Matthieu Baerts <[email protected]>
  L:    [email protected]
  L:    [email protected]
@@@ -15664,7 -15658,7 +15663,7 @@@ OPENRISC ARCHITECTUR
  M:    Jonas Bonn <[email protected]>
  M:    Stefan Kristiansson <[email protected]>
  M:    Stafford Horne <[email protected]>
 -L:    [email protected].org
 +L:    [email protected].org
  S:    Maintained
  W:    http://openrisc.io
  T:    git https://github.com/openrisc/linux.git
@@@ -15755,12 -15749,6 +15754,12 @@@ S: Maintaine
  W:    https://wireless.wiki.kernel.org/en/users/Drivers/p54
  F:    drivers/net/wireless/intersil/p54/
  
 +PACKET SOCKETS
 +M:    Willem de Bruijn <[email protected]>
 +S:    Maintained
 +F:    include/uapi/linux/if_packet.h
 +F:    net/packet/af_packet.c
 +
  PACKING
  M:    Vladimir Oltean <[email protected]>
  L:    [email protected]
@@@ -17249,7 -17237,7 +17248,7 @@@ F:   Documentation/devicetree/bindings/ne
  F:    drivers/net/wwan/qcom_bam_dmux.c
  
  QUALCOMM CAMERA SUBSYSTEM DRIVER
 -M:    Robert Foss <robert.foss@linaro.org>
 +M:    Robert Foss <rfoss@kernel.org>
  M:    Todor Tomov <[email protected]>
  L:    [email protected]
  S:    Maintained
@@@ -17329,7 -17317,7 +17328,7 @@@ F:   drivers/dma/qcom/hidma
  
  QUALCOMM I2C CCI DRIVER
  M:    Loic Poulain <[email protected]>
 -M:    Robert Foss <robert.foss@linaro.org>
 +M:    Robert Foss <rfoss@kernel.org>
  L:    [email protected]
  L:    [email protected]
  S:    Maintained
@@@ -17968,7 -17956,6 +17967,7 @@@ M:   Albert Ou <[email protected]
  L:    [email protected]
  S:    Supported
  Q:    https://patchwork.kernel.org/project/linux-riscv/list/
 +C:    irc://irc.libera.chat/riscv
  P:    Documentation/riscv/patch-acceptance.rst
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git
  F:    arch/riscv/
@@@ -18690,9 -18677,9 +18689,9 @@@ F:   drivers/target
  F:    include/target/
  
  SCTP PROTOCOL
 -M:    Vlad Yasevich <[email protected]>
  M:    Neil Horman <[email protected]>
  M:    Marcelo Ricardo Leitner <[email protected]>
 +M:    Xin Long <[email protected]>
  L:    [email protected]
  S:    Maintained
  W:    http://lksctp.sourceforge.net
  S:    Orphan
  F:    sound/soc/uniphier/
  
 +SOCKET TIMESTAMPING
 +M:    Willem de Bruijn <[email protected]>
 +S:    Maintained
 +F:    Documentation/networking/timestamping.rst
 +F:    include/uapi/linux/net_tstamp.h
 +F:    tools/testing/selftests/net/so_txtime.c
 +
  SOEKRIS NET48XX LED SUPPORT
  M:    Chris Boot <[email protected]>
  S:    Maintained
@@@ -21730,7 -21710,6 +21729,7 @@@ F:   include/uapi/linux/uvcvideo.
  
  USB WEBCAM GADGET
  M:    Laurent Pinchart <[email protected]>
 +M:    Daniel Scally <[email protected]>
  L:    [email protected]
  S:    Maintained
  F:    drivers/usb/gadget/function/*uvc*
@@@ -21766,13 -21745,6 +21765,13 @@@ T: git git://linuxtv.org/media_tree.gi
  F:    Documentation/admin-guide/media/zr364xx*
  F:    drivers/staging/media/deprecated/zr364xx/
  
 +USER DATAGRAM PROTOCOL (UDP)
 +M:    Willem de Bruijn <[email protected]>
 +S:    Maintained
 +F:    include/linux/udp.h
 +F:    net/ipv4/udp.c
 +F:    net/ipv6/udp.c
 +
  USER-MODE LINUX (UML)
  M:    Richard Weinberger <[email protected]>
  M:    Anton Ivanov <[email protected]>
diff --combined arch/arm64/kvm/guest.c
index cf4c495a4321332b7bc5a1979fc84d3084da355e,63643c98e6c3dd59b2e382bd924ba56f6524ca45..07444fa2288887ec6f8455045fada76d02e77862
@@@ -24,6 -24,7 +24,7 @@@
  #include <asm/fpsimd.h>
  #include <asm/kvm.h>
  #include <asm/kvm_emulate.h>
+ #include <asm/kvm_nested.h>
  #include <asm/sigcontext.h>
  
  #include "trace.h"
@@@ -253,6 -254,11 +254,11 @@@ static int set_core_reg(struct kvm_vcp
                        if (!vcpu_el1_is_32bit(vcpu))
                                return -EINVAL;
                        break;
+               case PSR_MODE_EL2h:
+               case PSR_MODE_EL2t:
+                       if (!vcpu_has_nv(vcpu))
+                               return -EINVAL;
+                       fallthrough;
                case PSR_MODE_EL0t:
                case PSR_MODE_EL1t:
                case PSR_MODE_EL1h:
@@@ -1079,7 -1085,7 +1085,7 @@@ long kvm_vm_ioctl_mte_copy_tags(struct 
  
                        /* uaccess failed, don't leave stale tags */
                        if (num_tags != MTE_GRANULES_PER_PAGE)
 -                              mte_clear_page_tags(page);
 +                              mte_clear_page_tags(maddr);
                        set_page_mte_tagged(page);
  
                        kvm_release_pfn_dirty(pfn);
index 684bdfaad4a9de9b10bbb6e80be54a7c8a994318,9d63149d9e5312db7e2f48369ad0f186b2d40fac..469d816f356f3fe94b021f5e2fd14ea91310f114
@@@ -3,6 -3,7 +3,7 @@@
  #include <linux/irqchip/arm-gic-v3.h>
  #include <linux/irq.h>
  #include <linux/irqdomain.h>
+ #include <linux/kstrtox.h>
  #include <linux/kvm.h>
  #include <linux/kvm_host.h>
  #include <kvm/arm_vgic.h>
@@@ -339,7 -340,7 +340,7 @@@ retry
        if (status) {
                /* clear consumed data */
                val &= ~(1 << bit_nr);
 -              ret = kvm_write_guest_lock(kvm, ptr, &val, 1);
 +              ret = vgic_write_guest_lock(kvm, ptr, &val, 1);
                if (ret)
                        return ret;
        }
   * The deactivation of the doorbell interrupt will trigger the
   * unmapping of the associated vPE.
   */
 -static void unmap_all_vpes(struct vgic_dist *dist)
 +static void unmap_all_vpes(struct kvm *kvm)
  {
 -      struct irq_desc *desc;
 +      struct vgic_dist *dist = &kvm->arch.vgic;
        int i;
  
 -      for (i = 0; i < dist->its_vm.nr_vpes; i++) {
 -              desc = irq_to_desc(dist->its_vm.vpes[i]->irq);
 -              irq_domain_deactivate_irq(irq_desc_get_irq_data(desc));
 -      }
 +      for (i = 0; i < dist->its_vm.nr_vpes; i++)
 +              free_irq(dist->its_vm.vpes[i]->irq, kvm_get_vcpu(kvm, i));
  }
  
 -static void map_all_vpes(struct vgic_dist *dist)
 +static void map_all_vpes(struct kvm *kvm)
  {
 -      struct irq_desc *desc;
 +      struct vgic_dist *dist = &kvm->arch.vgic;
        int i;
  
 -      for (i = 0; i < dist->its_vm.nr_vpes; i++) {
 -              desc = irq_to_desc(dist->its_vm.vpes[i]->irq);
 -              irq_domain_activate_irq(irq_desc_get_irq_data(desc), false);
 -      }
 +      for (i = 0; i < dist->its_vm.nr_vpes; i++)
 +              WARN_ON(vgic_v4_request_vpe_irq(kvm_get_vcpu(kvm, i),
 +                                              dist->its_vm.vpes[i]->irq));
  }
  
  /**
@@@ -391,7 -395,7 +392,7 @@@ int vgic_v3_save_pending_tables(struct 
         * and enabling of the doorbells have already been done.
         */
        if (kvm_vgic_global_state.has_gicv4_1) {
 -              unmap_all_vpes(dist);
 +              unmap_all_vpes(kvm);
                vlpi_avail = true;
        }
  
                else
                        val &= ~(1 << bit_nr);
  
 -              ret = kvm_write_guest_lock(kvm, ptr, &val, 1);
 +              ret = vgic_write_guest_lock(kvm, ptr, &val, 1);
                if (ret)
                        goto out;
        }
  
  out:
        if (vlpi_avail)
 -              map_all_vpes(dist);
 +              map_all_vpes(kvm);
  
        return ret;
  }
@@@ -584,25 -588,25 +585,25 @@@ DEFINE_STATIC_KEY_FALSE(vgic_v3_cpuif_t
  
  static int __init early_group0_trap_cfg(char *buf)
  {
-       return strtobool(buf, &group0_trap);
+       return kstrtobool(buf, &group0_trap);
  }
  early_param("kvm-arm.vgic_v3_group0_trap", early_group0_trap_cfg);
  
  static int __init early_group1_trap_cfg(char *buf)
  {
-       return strtobool(buf, &group1_trap);
+       return kstrtobool(buf, &group1_trap);
  }
  early_param("kvm-arm.vgic_v3_group1_trap", early_group1_trap_cfg);
  
  static int __init early_common_trap_cfg(char *buf)
  {
-       return strtobool(buf, &common_trap);
+       return kstrtobool(buf, &common_trap);
  }
  early_param("kvm-arm.vgic_v3_common_trap", early_common_trap_cfg);
  
  static int __init early_gicv4_enable(char *buf)
  {
-       return strtobool(buf, &gicv4_enable);
+       return kstrtobool(buf, &gicv4_enable);
  }
  early_param("kvm-arm.vgic_v4_enable", early_gicv4_enable);
  
index 792a6037047adf27cb6d13c9be5a89e63ad8b24a,5024ba7fe8b2b282c7f29f3aece62e2f53cab5a9..808c292ad3f4935b50864d1287fd7a7941432c55
  #define INVALID_PAGE (~(hpa_t)0)
  #define VALID_PAGE(x) ((x) != INVALID_PAGE)
  
- #define INVALID_GPA (~(gpa_t)0)
  /* KVM Hugepage definitions for x86 */
  #define KVM_MAX_HUGEPAGE_LEVEL        PG_LEVEL_1G
  #define KVM_NR_PAGE_SIZES     (KVM_MAX_HUGEPAGE_LEVEL - PG_LEVEL_4K + 1)
@@@ -514,7 -512,6 +512,7 @@@ struct kvm_pmc 
  #define MSR_ARCH_PERFMON_PERFCTR_MAX  (MSR_ARCH_PERFMON_PERFCTR0 + KVM_INTEL_PMC_MAX_GENERIC - 1)
  #define MSR_ARCH_PERFMON_EVENTSEL_MAX (MSR_ARCH_PERFMON_EVENTSEL0 + KVM_INTEL_PMC_MAX_GENERIC - 1)
  #define KVM_PMC_MAX_FIXED     3
 +#define MSR_ARCH_PERFMON_FIXED_CTR_MAX        (MSR_ARCH_PERFMON_FIXED_CTR0 + KVM_PMC_MAX_FIXED - 1)
  #define KVM_AMD_PMC_MAX_GENERIC       6
  struct kvm_pmu {
        unsigned nr_arch_gp_counters;
@@@ -679,11 -676,6 +677,11 @@@ struct kvm_vcpu_hv 
        } nested;
  };
  
 +struct kvm_hypervisor_cpuid {
 +      u32 base;
 +      u32 limit;
 +};
 +
  /* Xen HVM per vcpu emulation context */
  struct kvm_vcpu_xen {
        u64 hypercall_rip;
        struct hrtimer timer;
        int poll_evtchn;
        struct timer_list poll_timer;
 +      struct kvm_hypervisor_cpuid cpuid;
  };
  
  struct kvm_queued_exception {
@@@ -833,7 -824,7 +831,7 @@@ struct kvm_vcpu_arch 
  
        int cpuid_nent;
        struct kvm_cpuid_entry2 *cpuid_entries;
 -      u32 kvm_cpuid_base;
 +      struct kvm_hypervisor_cpuid kvm_cpuid;
  
        u64 reserved_gpa_bits;
        int maxphyaddr;
@@@ -1029,30 -1020,19 +1027,30 @@@ struct kvm_arch_memory_slot 
  };
  
  /*
 - * We use as the mode the number of bits allocated in the LDR for the
 - * logical processor ID.  It happens that these are all powers of two.
 - * This makes it is very easy to detect cases where the APICs are
 - * configured for multiple modes; in that case, we cannot use the map and
 - * hence cannot use kvm_irq_delivery_to_apic_fast either.
 + * Track the mode of the optimized logical map, as the rules for decoding the
 + * destination vary per mode.  Enabling the optimized logical map requires all
 + * software-enabled local APIs to be in the same mode, each addressable APIC to
 + * be mapped to only one MDA, and each MDA to map to at most one APIC.
   */
 -#define KVM_APIC_MODE_XAPIC_CLUSTER          4
 -#define KVM_APIC_MODE_XAPIC_FLAT             8
 -#define KVM_APIC_MODE_X2APIC                16
 +enum kvm_apic_logical_mode {
 +      /* All local APICs are software disabled. */
 +      KVM_APIC_MODE_SW_DISABLED,
 +      /* All software enabled local APICs in xAPIC cluster addressing mode. */
 +      KVM_APIC_MODE_XAPIC_CLUSTER,
 +      /* All software enabled local APICs in xAPIC flat addressing mode. */
 +      KVM_APIC_MODE_XAPIC_FLAT,
 +      /* All software enabled local APICs in x2APIC mode. */
 +      KVM_APIC_MODE_X2APIC,
 +      /*
 +       * Optimized map disabled, e.g. not all local APICs in the same logical
 +       * mode, same logical ID assigned to multiple APICs, etc.
 +       */
 +      KVM_APIC_MODE_MAP_DISABLED,
 +};
  
  struct kvm_apic_map {
        struct rcu_head rcu;
 -      u8 mode;
 +      enum kvm_apic_logical_mode logical_mode;
        u32 max_apic_id;
        union {
                struct kvm_lapic *xapic_flat_map[8];
@@@ -1152,18 -1132,6 +1150,18 @@@ struct kvm_x86_msr_filter 
        struct msr_bitmap_range ranges[16];
  };
  
 +struct kvm_x86_pmu_event_filter {
 +      __u32 action;
 +      __u32 nevents;
 +      __u32 fixed_counter_bitmap;
 +      __u32 flags;
 +      __u32 nr_includes;
 +      __u32 nr_excludes;
 +      __u64 *includes;
 +      __u64 *excludes;
 +      __u64 events[];
 +};
 +
  enum kvm_apicv_inhibit {
  
        /********************************************************************/
         */
        APICV_INHIBIT_REASON_BLOCKIRQ,
  
 +      /*
 +       * APICv is disabled because not all vCPUs have a 1:1 mapping between
 +       * APIC ID and vCPU, _and_ KVM is not applying its x2APIC hotplug hack.
 +       */
 +      APICV_INHIBIT_REASON_PHYSICAL_ID_ALIASED,
 +
        /*
         * For simplicity, the APIC acceleration is inhibited
         * first time either APIC ID or APIC base are changed by the guest
         * AVIC is disabled because SEV doesn't support it.
         */
        APICV_INHIBIT_REASON_SEV,
 +
 +      /*
 +       * AVIC is disabled because not all vCPUs with a valid LDR have a 1:1
 +       * mapping between logical ID and vCPU.
 +       */
 +      APICV_INHIBIT_REASON_LOGICAL_ID_ALIASED,
  };
  
  struct kvm_arch {
        struct kvm_apic_map __rcu *apic_map;
        atomic_t apic_map_dirty;
  
 -      /* Protects apic_access_memslot_enabled and apicv_inhibit_reasons */
 -      struct rw_semaphore apicv_update_lock;
 -
        bool apic_access_memslot_enabled;
 +      bool apic_access_memslot_inhibited;
 +
 +      /* Protects apicv_inhibit_reasons */
 +      struct rw_semaphore apicv_update_lock;
        unsigned long apicv_inhibit_reasons;
  
        gpa_t wall_clock;
        u32 bsp_vcpu_id;
  
        u64 disabled_quirks;
 -      int cpu_dirty_logging_count;
  
        enum kvm_irqchip_mode irqchip_mode;
        u8 nr_reserved_ioapic_pins;
        /* Guest can access the SGX PROVISIONKEY. */
        bool sgx_provisioning_allowed;
  
 -      struct kvm_pmu_event_filter __rcu *pmu_event_filter;
 +      struct kvm_x86_pmu_event_filter __rcu *pmu_event_filter;
        struct task_struct *nx_huge_page_recovery_thread;
  
  #ifdef CONFIG_X86_64
@@@ -1644,8 -1600,6 +1642,8 @@@ struct kvm_x86_ops 
        void (*enable_irq_window)(struct kvm_vcpu *vcpu);
        void (*update_cr8_intercept)(struct kvm_vcpu *vcpu, int tpr, int irr);
        bool (*check_apicv_inhibit_reasons)(enum kvm_apicv_inhibit reason);
 +      const unsigned long required_apicv_inhibits;
 +      bool allow_apicv_in_x2apic_without_x2apic_virtualization;
        void (*refresh_apicv_exec_ctrl)(struct kvm_vcpu *vcpu);
        void (*hwapic_irr_update)(struct kvm_vcpu *vcpu, int max_irr);
        void (*hwapic_isr_update)(int isr);
@@@ -2020,7 -1974,7 +2018,7 @@@ gpa_t kvm_mmu_gva_to_gpa_system(struct 
  
  bool kvm_apicv_activated(struct kvm *kvm);
  bool kvm_vcpu_apicv_activated(struct kvm_vcpu *vcpu);
 -void kvm_vcpu_update_apicv(struct kvm_vcpu *vcpu);
 +void __kvm_vcpu_update_apicv(struct kvm_vcpu *vcpu);
  void __kvm_set_or_clear_apicv_inhibit(struct kvm *kvm,
                                      enum kvm_apicv_inhibit reason, bool set);
  void kvm_set_or_clear_apicv_inhibit(struct kvm *kvm,
@@@ -2092,11 -2046,14 +2090,11 @@@ enum 
        TASK_SWITCH_GATE = 3,
  };
  
 -#define HF_GIF_MASK           (1 << 0)
 -#define HF_NMI_MASK           (1 << 3)
 -#define HF_IRET_MASK          (1 << 4)
 -#define HF_GUEST_MASK         (1 << 5) /* VCPU is in guest-mode */
 +#define HF_GUEST_MASK         (1 << 0) /* VCPU is in guest-mode */
  
  #ifdef CONFIG_KVM_SMM
 -#define HF_SMM_MASK           (1 << 6)
 -#define HF_SMM_INSIDE_NMI_MASK        (1 << 7)
 +#define HF_SMM_MASK           (1 << 1)
 +#define HF_SMM_INSIDE_NMI_MASK        (1 << 2)
  
  # define __KVM_VCPU_MULTIPLE_ADDRESS_SPACE
  # define KVM_ADDRESS_SPACE_NUM 2
index 54680dc5887fae044306040c127e5c9ff099ea7b,513b20bec3c27ef5ad1f2831c8e8148731eae1cc..df10f1ffa20d9b69fd9445f847669a3f1f101840
@@@ -237,11 -237,6 +237,11 @@@ static void guest_check_s1ptw_wr_in_dir
        GUEST_SYNC(CMD_CHECK_S1PTW_WR_IN_DIRTY_LOG);
  }
  
 +static void guest_check_no_s1ptw_wr_in_dirty_log(void)
 +{
 +      GUEST_SYNC(CMD_CHECK_NO_S1PTW_WR_IN_DIRTY_LOG);
 +}
 +
  static void guest_exec(void)
  {
        int (*code)(void) = (int (*)(void))TEST_EXEC_GVA;
@@@ -309,7 -304,7 +309,7 @@@ static struct uffd_args 
  
  /* Returns true to continue the test, and false if it should be skipped. */
  static int uffd_generic_handler(int uffd_mode, int uffd, struct uffd_msg *msg,
 -                              struct uffd_args *args, bool expect_write)
 +                              struct uffd_args *args)
  {
        uint64_t addr = msg->arg.pagefault.address;
        uint64_t flags = msg->arg.pagefault.flags;
  
        TEST_ASSERT(uffd_mode == UFFDIO_REGISTER_MODE_MISSING,
                    "The only expected UFFD mode is MISSING");
 -      ASSERT_EQ(!!(flags & UFFD_PAGEFAULT_FLAG_WRITE), expect_write);
        ASSERT_EQ(addr, (uint64_t)args->hva);
  
        pr_debug("uffd fault: addr=%p write=%d\n",
        return 0;
  }
  
 -static int uffd_pt_write_handler(int mode, int uffd, struct uffd_msg *msg)
 -{
 -      return uffd_generic_handler(mode, uffd, msg, &pt_args, true);
 -}
 -
 -static int uffd_data_write_handler(int mode, int uffd, struct uffd_msg *msg)
 +static int uffd_pt_handler(int mode, int uffd, struct uffd_msg *msg)
  {
 -      return uffd_generic_handler(mode, uffd, msg, &data_args, true);
 +      return uffd_generic_handler(mode, uffd, msg, &pt_args);
  }
  
 -static int uffd_data_read_handler(int mode, int uffd, struct uffd_msg *msg)
 +static int uffd_data_handler(int mode, int uffd, struct uffd_msg *msg)
  {
 -      return uffd_generic_handler(mode, uffd, msg, &data_args, false);
 +      return uffd_generic_handler(mode, uffd, msg, &data_args);
  }
  
  static void setup_uffd_args(struct userspace_mem_region *region,
@@@ -470,12 -471,9 +470,12 @@@ static bool handle_cmd(struct kvm_vm *v
  {
        struct userspace_mem_region *data_region, *pt_region;
        bool continue_test = true;
 +      uint64_t pte_gpa, pte_pg;
  
        data_region = vm_get_mem_region(vm, MEM_REGION_TEST_DATA);
        pt_region = vm_get_mem_region(vm, MEM_REGION_PT);
 +      pte_gpa = addr_hva2gpa(vm, virt_get_pte_hva(vm, TEST_GVA));
 +      pte_pg = (pte_gpa - pt_region->region.guest_phys_addr) / getpagesize();
  
        if (cmd == CMD_SKIP_TEST)
                continue_test = false;
                TEST_ASSERT(check_write_in_dirty_log(vm, data_region, 0),
                            "Missing write in dirty log");
        if (cmd & CMD_CHECK_S1PTW_WR_IN_DIRTY_LOG)
 -              TEST_ASSERT(check_write_in_dirty_log(vm, pt_region, 0),
 +              TEST_ASSERT(check_write_in_dirty_log(vm, pt_region, pte_pg),
                            "Missing s1ptw write in dirty log");
        if (cmd & CMD_CHECK_NO_WRITE_IN_DIRTY_LOG)
                TEST_ASSERT(!check_write_in_dirty_log(vm, data_region, 0),
                            "Unexpected write in dirty log");
        if (cmd & CMD_CHECK_NO_S1PTW_WR_IN_DIRTY_LOG)
 -              TEST_ASSERT(!check_write_in_dirty_log(vm, pt_region, 0),
 +              TEST_ASSERT(!check_write_in_dirty_log(vm, pt_region, pte_pg),
                            "Unexpected s1ptw write in dirty log");
  
        return continue_test;
@@@ -799,7 -797,7 +799,7 @@@ static void help(char *name
        .expected_events        = { .uffd_faults = _uffd_faults, },             \
  }
  
 -#define TEST_DIRTY_LOG(_access, _with_af, _test_check)                                \
 +#define TEST_DIRTY_LOG(_access, _with_af, _test_check, _pt_check)             \
  {                                                                             \
        .name                   = SCAT3(dirty_log, _access, _with_af),          \
        .data_memslot_flags     = KVM_MEM_LOG_DIRTY_PAGES,                      \
        .guest_prepare          = { _PREPARE(_with_af),                         \
                                    _PREPARE(_access) },                        \
        .guest_test             = _access,                                      \
 -      .guest_test_check       = { _CHECK(_with_af), _test_check,              \
 -                                  guest_check_s1ptw_wr_in_dirty_log},         \
 +      .guest_test_check       = { _CHECK(_with_af), _test_check, _pt_check }, \
        .expected_events        = { 0 },                                        \
  }
  
  #define TEST_UFFD_AND_DIRTY_LOG(_access, _with_af, _uffd_data_handler,                \
 -                              _uffd_faults, _test_check)                      \
 +                              _uffd_faults, _test_check, _pt_check)           \
  {                                                                             \
        .name                   = SCAT3(uffd_and_dirty_log, _access, _with_af), \
        .data_memslot_flags     = KVM_MEM_LOG_DIRTY_PAGES,                      \
                                    _PREPARE(_access) },                        \
        .guest_test             = _access,                                      \
        .mem_mark_cmd           = CMD_HOLE_DATA | CMD_HOLE_PT,                  \
 -      .guest_test_check       = { _CHECK(_with_af), _test_check },            \
 +      .guest_test_check       = { _CHECK(_with_af), _test_check, _pt_check }, \
        .uffd_data_handler      = _uffd_data_handler,                           \
 -      .uffd_pt_handler        = uffd_pt_write_handler,                        \
 +      .uffd_pt_handler        = uffd_pt_handler,                              \
        .expected_events        = { .uffd_faults = _uffd_faults, },             \
  }
  
  #define TEST_RO_MEMSLOT(_access, _mmio_handler, _mmio_exits)                  \
  {                                                                             \
 -      .name                   = SCAT3(ro_memslot, _access, _with_af),         \
 +      .name                   = SCAT2(ro_memslot, _access),                   \
        .data_memslot_flags     = KVM_MEM_READONLY,                             \
 +      .pt_memslot_flags       = KVM_MEM_READONLY,                             \
        .guest_prepare          = { _PREPARE(_access) },                        \
        .guest_test             = _access,                                      \
        .mmio_handler           = _mmio_handler,                                \
  {                                                                             \
        .name                   = SCAT2(ro_memslot_no_syndrome, _access),       \
        .data_memslot_flags     = KVM_MEM_READONLY,                             \
 +      .pt_memslot_flags       = KVM_MEM_READONLY,                             \
        .guest_test             = _access,                                      \
        .fail_vcpu_run_handler  = fail_vcpu_run_mmio_no_syndrome_handler,       \
        .expected_events        = { .fail_vcpu_runs = 1 },                      \
  #define TEST_RO_MEMSLOT_AND_DIRTY_LOG(_access, _mmio_handler, _mmio_exits,    \
                                      _test_check)                              \
  {                                                                             \
 -      .name                   = SCAT3(ro_memslot, _access, _with_af),         \
 +      .name                   = SCAT2(ro_memslot, _access),                   \
        .data_memslot_flags     = KVM_MEM_READONLY | KVM_MEM_LOG_DIRTY_PAGES,   \
 -      .pt_memslot_flags       = KVM_MEM_LOG_DIRTY_PAGES,                      \
 +      .pt_memslot_flags       = KVM_MEM_READONLY | KVM_MEM_LOG_DIRTY_PAGES,   \
        .guest_prepare          = { _PREPARE(_access) },                        \
        .guest_test             = _access,                                      \
        .guest_test_check       = { _test_check },                              \
  {                                                                             \
        .name                   = SCAT2(ro_memslot_no_syn_and_dlog, _access),   \
        .data_memslot_flags     = KVM_MEM_READONLY | KVM_MEM_LOG_DIRTY_PAGES,   \
 -      .pt_memslot_flags       = KVM_MEM_LOG_DIRTY_PAGES,                      \
 +      .pt_memslot_flags       = KVM_MEM_READONLY | KVM_MEM_LOG_DIRTY_PAGES,   \
        .guest_test             = _access,                                      \
        .guest_test_check       = { _test_check },                              \
        .fail_vcpu_run_handler  = fail_vcpu_run_mmio_no_syndrome_handler,       \
  {                                                                             \
        .name                   = SCAT2(ro_memslot_uffd, _access),              \
        .data_memslot_flags     = KVM_MEM_READONLY,                             \
 +      .pt_memslot_flags       = KVM_MEM_READONLY,                             \
        .mem_mark_cmd           = CMD_HOLE_DATA | CMD_HOLE_PT,                  \
        .guest_prepare          = { _PREPARE(_access) },                        \
        .guest_test             = _access,                                      \
        .uffd_data_handler      = _uffd_data_handler,                           \
 -      .uffd_pt_handler        = uffd_pt_write_handler,                        \
 +      .uffd_pt_handler        = uffd_pt_handler,                              \
        .mmio_handler           = _mmio_handler,                                \
        .expected_events        = { .mmio_exits = _mmio_exits,                  \
                                    .uffd_faults = _uffd_faults },              \
  {                                                                             \
        .name                   = SCAT2(ro_memslot_no_syndrome, _access),       \
        .data_memslot_flags     = KVM_MEM_READONLY,                             \
 +      .pt_memslot_flags       = KVM_MEM_READONLY,                             \
        .mem_mark_cmd           = CMD_HOLE_DATA | CMD_HOLE_PT,                  \
        .guest_test             = _access,                                      \
        .uffd_data_handler      = _uffd_data_handler,                           \
 -      .uffd_pt_handler        = uffd_pt_write_handler,                        \
 +      .uffd_pt_handler        = uffd_pt_handler,                      \
        .fail_vcpu_run_handler  = fail_vcpu_run_mmio_no_syndrome_handler,       \
        .expected_events        = { .fail_vcpu_runs = 1,                        \
                                    .uffd_faults = _uffd_faults },              \
@@@ -938,51 -933,44 +938,51 @@@ static struct test_desc tests[] = 
         * (S1PTW).
         */
        TEST_UFFD(guest_read64, with_af, CMD_HOLE_DATA | CMD_HOLE_PT,
 -                uffd_data_read_handler, uffd_pt_write_handler, 2),
 -      /* no_af should also lead to a PT write. */
 +                uffd_data_handler, uffd_pt_handler, 2),
        TEST_UFFD(guest_read64, no_af, CMD_HOLE_DATA | CMD_HOLE_PT,
 -                uffd_data_read_handler, uffd_pt_write_handler, 2),
 -      /* Note how that cas invokes the read handler. */
 +                uffd_data_handler, uffd_pt_handler, 2),
        TEST_UFFD(guest_cas, with_af, CMD_HOLE_DATA | CMD_HOLE_PT,
 -                uffd_data_read_handler, uffd_pt_write_handler, 2),
 +                uffd_data_handler, uffd_pt_handler, 2),
        /*
         * Can't test guest_at with_af as it's IMPDEF whether the AF is set.
         * The S1PTW fault should still be marked as a write.
         */
        TEST_UFFD(guest_at, no_af, CMD_HOLE_DATA | CMD_HOLE_PT,
 -                uffd_data_read_handler, uffd_pt_write_handler, 1),
 +                uffd_no_handler, uffd_pt_handler, 1),
        TEST_UFFD(guest_ld_preidx, with_af, CMD_HOLE_DATA | CMD_HOLE_PT,
 -                uffd_data_read_handler, uffd_pt_write_handler, 2),
 +                uffd_data_handler, uffd_pt_handler, 2),
        TEST_UFFD(guest_write64, with_af, CMD_HOLE_DATA | CMD_HOLE_PT,
 -                uffd_data_write_handler, uffd_pt_write_handler, 2),
 +                uffd_data_handler, uffd_pt_handler, 2),
        TEST_UFFD(guest_dc_zva, with_af, CMD_HOLE_DATA | CMD_HOLE_PT,
 -                uffd_data_write_handler, uffd_pt_write_handler, 2),
 +                uffd_data_handler, uffd_pt_handler, 2),
        TEST_UFFD(guest_st_preidx, with_af, CMD_HOLE_DATA | CMD_HOLE_PT,
 -                uffd_data_write_handler, uffd_pt_write_handler, 2),
 +                uffd_data_handler, uffd_pt_handler, 2),
        TEST_UFFD(guest_exec, with_af, CMD_HOLE_DATA | CMD_HOLE_PT,
 -                uffd_data_read_handler, uffd_pt_write_handler, 2),
 +                uffd_data_handler, uffd_pt_handler, 2),
  
        /*
         * Try accesses when the data and PT memory regions are both
         * tracked for dirty logging.
         */
 -      TEST_DIRTY_LOG(guest_read64, with_af, guest_check_no_write_in_dirty_log),
 -      /* no_af should also lead to a PT write. */
 -      TEST_DIRTY_LOG(guest_read64, no_af, guest_check_no_write_in_dirty_log),
 -      TEST_DIRTY_LOG(guest_ld_preidx, with_af, guest_check_no_write_in_dirty_log),
 -      TEST_DIRTY_LOG(guest_at, no_af, guest_check_no_write_in_dirty_log),
 -      TEST_DIRTY_LOG(guest_exec, with_af, guest_check_no_write_in_dirty_log),
 -      TEST_DIRTY_LOG(guest_write64, with_af, guest_check_write_in_dirty_log),
 -      TEST_DIRTY_LOG(guest_cas, with_af, guest_check_write_in_dirty_log),
 -      TEST_DIRTY_LOG(guest_dc_zva, with_af, guest_check_write_in_dirty_log),
 -      TEST_DIRTY_LOG(guest_st_preidx, with_af, guest_check_write_in_dirty_log),
 +      TEST_DIRTY_LOG(guest_read64, with_af, guest_check_no_write_in_dirty_log,
 +                     guest_check_s1ptw_wr_in_dirty_log),
 +      TEST_DIRTY_LOG(guest_read64, no_af, guest_check_no_write_in_dirty_log,
 +                     guest_check_no_s1ptw_wr_in_dirty_log),
 +      TEST_DIRTY_LOG(guest_ld_preidx, with_af,
 +                     guest_check_no_write_in_dirty_log,
 +                     guest_check_s1ptw_wr_in_dirty_log),
 +      TEST_DIRTY_LOG(guest_at, no_af, guest_check_no_write_in_dirty_log,
 +                     guest_check_no_s1ptw_wr_in_dirty_log),
 +      TEST_DIRTY_LOG(guest_exec, with_af, guest_check_no_write_in_dirty_log,
 +                     guest_check_s1ptw_wr_in_dirty_log),
 +      TEST_DIRTY_LOG(guest_write64, with_af, guest_check_write_in_dirty_log,
 +                     guest_check_s1ptw_wr_in_dirty_log),
 +      TEST_DIRTY_LOG(guest_cas, with_af, guest_check_write_in_dirty_log,
 +                     guest_check_s1ptw_wr_in_dirty_log),
 +      TEST_DIRTY_LOG(guest_dc_zva, with_af, guest_check_write_in_dirty_log,
 +                     guest_check_s1ptw_wr_in_dirty_log),
 +      TEST_DIRTY_LOG(guest_st_preidx, with_af, guest_check_write_in_dirty_log,
 +                     guest_check_s1ptw_wr_in_dirty_log),
  
        /*
         * Access when the data and PT memory regions are both marked for
         * fault, and nothing in the dirty log.  Any S1PTW should result in
         * a write in the dirty log and a userfaultfd write.
         */
 -      TEST_UFFD_AND_DIRTY_LOG(guest_read64, with_af, uffd_data_read_handler, 2,
 -                              guest_check_no_write_in_dirty_log),
 -      /* no_af should also lead to a PT write. */
 -      TEST_UFFD_AND_DIRTY_LOG(guest_read64, no_af, uffd_data_read_handler, 2,
 -                              guest_check_no_write_in_dirty_log),
 -      TEST_UFFD_AND_DIRTY_LOG(guest_ld_preidx, with_af, uffd_data_read_handler,
 -                              2, guest_check_no_write_in_dirty_log),
 -      TEST_UFFD_AND_DIRTY_LOG(guest_at, with_af, 0, 1,
 -                              guest_check_no_write_in_dirty_log),
 -      TEST_UFFD_AND_DIRTY_LOG(guest_exec, with_af, uffd_data_read_handler, 2,
 -                              guest_check_no_write_in_dirty_log),
 -      TEST_UFFD_AND_DIRTY_LOG(guest_write64, with_af, uffd_data_write_handler,
 -                              2, guest_check_write_in_dirty_log),
 -      TEST_UFFD_AND_DIRTY_LOG(guest_cas, with_af, uffd_data_read_handler, 2,
 -                              guest_check_write_in_dirty_log),
 -      TEST_UFFD_AND_DIRTY_LOG(guest_dc_zva, with_af, uffd_data_write_handler,
 -                              2, guest_check_write_in_dirty_log),
 +      TEST_UFFD_AND_DIRTY_LOG(guest_read64, with_af,
 +                              uffd_data_handler, 2,
 +                              guest_check_no_write_in_dirty_log,
 +                              guest_check_s1ptw_wr_in_dirty_log),
 +      TEST_UFFD_AND_DIRTY_LOG(guest_read64, no_af,
 +                              uffd_data_handler, 2,
 +                              guest_check_no_write_in_dirty_log,
 +                              guest_check_no_s1ptw_wr_in_dirty_log),
 +      TEST_UFFD_AND_DIRTY_LOG(guest_ld_preidx, with_af,
 +                              uffd_data_handler,
 +                              2, guest_check_no_write_in_dirty_log,
 +                              guest_check_s1ptw_wr_in_dirty_log),
 +      TEST_UFFD_AND_DIRTY_LOG(guest_at, with_af, uffd_no_handler, 1,
 +                              guest_check_no_write_in_dirty_log,
 +                              guest_check_s1ptw_wr_in_dirty_log),
 +      TEST_UFFD_AND_DIRTY_LOG(guest_exec, with_af,
 +                              uffd_data_handler, 2,
 +                              guest_check_no_write_in_dirty_log,
 +                              guest_check_s1ptw_wr_in_dirty_log),
 +      TEST_UFFD_AND_DIRTY_LOG(guest_write64, with_af,
 +                              uffd_data_handler,
 +                              2, guest_check_write_in_dirty_log,
 +                              guest_check_s1ptw_wr_in_dirty_log),
 +      TEST_UFFD_AND_DIRTY_LOG(guest_cas, with_af,
 +                              uffd_data_handler, 2,
 +                              guest_check_write_in_dirty_log,
 +                              guest_check_s1ptw_wr_in_dirty_log),
 +      TEST_UFFD_AND_DIRTY_LOG(guest_dc_zva, with_af,
 +                              uffd_data_handler,
 +                              2, guest_check_write_in_dirty_log,
 +                              guest_check_s1ptw_wr_in_dirty_log),
        TEST_UFFD_AND_DIRTY_LOG(guest_st_preidx, with_af,
 -                              uffd_data_write_handler, 2,
 -                              guest_check_write_in_dirty_log),
 -
 +                              uffd_data_handler, 2,
 +                              guest_check_write_in_dirty_log,
 +                              guest_check_s1ptw_wr_in_dirty_log),
        /*
 -       * Try accesses when the data memory region is marked read-only
 +       * Access when both the PT and data regions are marked read-only
         * (with KVM_MEM_READONLY). Writes with a syndrome result in an
         * MMIO exit, writes with no syndrome (e.g., CAS) result in a
         * failed vcpu run, and reads/execs with and without syndroms do
        TEST_RO_MEMSLOT_NO_SYNDROME(guest_st_preidx),
  
        /*
 -       * Access when both the data region is both read-only and marked
 +       * The PT and data regions are both read-only and marked
         * for dirty logging at the same time. The expected result is that
         * for writes there should be no write in the dirty log. The
         * readonly handling is the same as if the memslot was not marked
                                                  guest_check_no_write_in_dirty_log),
  
        /*
 -       * Access when the data region is both read-only and punched with
 +       * The PT and data regions are both read-only and punched with
         * holes tracked with userfaultfd.  The expected result is the
         * union of both userfaultfd and read-only behaviors. For example,
         * write accesses result in a userfaultfd write fault and an MMIO
         * no userfaultfd write fault. Reads result in userfaultfd getting
         * triggered.
         */
 -      TEST_RO_MEMSLOT_AND_UFFD(guest_read64, 0, 0,
 -                               uffd_data_read_handler, 2),
 -      TEST_RO_MEMSLOT_AND_UFFD(guest_ld_preidx, 0, 0,
 -                               uffd_data_read_handler, 2),
 -      TEST_RO_MEMSLOT_AND_UFFD(guest_at, 0, 0,
 -                               uffd_no_handler, 1),
 -      TEST_RO_MEMSLOT_AND_UFFD(guest_exec, 0, 0,
 -                               uffd_data_read_handler, 2),
 +      TEST_RO_MEMSLOT_AND_UFFD(guest_read64, 0, 0, uffd_data_handler, 2),
 +      TEST_RO_MEMSLOT_AND_UFFD(guest_ld_preidx, 0, 0, uffd_data_handler, 2),
 +      TEST_RO_MEMSLOT_AND_UFFD(guest_at, 0, 0, uffd_no_handler, 1),
 +      TEST_RO_MEMSLOT_AND_UFFD(guest_exec, 0, 0, uffd_data_handler, 2),
        TEST_RO_MEMSLOT_AND_UFFD(guest_write64, mmio_on_test_gpa_handler, 1,
 -                               uffd_data_write_handler, 2),
 -      TEST_RO_MEMSLOT_NO_SYNDROME_AND_UFFD(guest_cas,
 -                                           uffd_data_read_handler, 2),
 -      TEST_RO_MEMSLOT_NO_SYNDROME_AND_UFFD(guest_dc_zva,
 -                                           uffd_no_handler, 1),
 -      TEST_RO_MEMSLOT_NO_SYNDROME_AND_UFFD(guest_st_preidx,
 -                                           uffd_no_handler, 1),
 +                               uffd_data_handler, 2),
 +      TEST_RO_MEMSLOT_NO_SYNDROME_AND_UFFD(guest_cas, uffd_data_handler, 2),
 +      TEST_RO_MEMSLOT_NO_SYNDROME_AND_UFFD(guest_dc_zva, uffd_no_handler, 1),
 +      TEST_RO_MEMSLOT_NO_SYNDROME_AND_UFFD(guest_st_preidx, uffd_no_handler, 1),
  
        { 0 }
  };
@@@ -1112,8 -1093,6 +1112,6 @@@ int main(int argc, char *argv[]
        enum vm_mem_backing_src_type src_type;
        int opt;
  
-       setbuf(stdout, NULL);
        src_type = DEFAULT_VM_MEM_SRC;
  
        while ((opt = getopt(argc, argv, "hm:s:")) != -1) {
This page took 0.171573 seconds and 4 git commands to generate.