1. 22 Nov, 2023 1 commit
    • Uros Bizjak's avatar
      x86/hyperv: Use atomic_try_cmpxchg() to micro-optimize hv_nmi_unknown() · 18286883
      Uros Bizjak authored
      Use atomic_try_cmpxchg() instead of atomic_cmpxchg(*ptr, old, new) == old
      in hv_nmi_unknown(). On x86 the CMPXCHG instruction returns success in
      the ZF flag, so this change saves a compare after CMPXCHG. The generated
      asm code improves from:
      
        3e:	65 8b 15 00 00 00 00 	mov    %gs:0x0(%rip),%edx
        45:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
        4a:	f0 0f b1 15 00 00 00 	lock cmpxchg %edx,0x0(%rip)
        51:	00
        52:	83 f8 ff             	cmp    $0xffffffff,%eax
        55:	0f 95 c0             	setne  %al
      
      to:
      
        3e:	65 8b 15 00 00 00 00 	mov    %gs:0x0(%rip),%edx
        45:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
        4a:	f0 0f b1 15 00 00 00 	lock cmpxchg %edx,0x0(%rip)
        51:	00
        52:	0f 95 c0             	setne  %al
      
      No functional change intended.
      
      Cc: "K. Y. Srinivasan" <kys@microsoft.com>
      Cc: Haiyang Zhang <haiyangz@microsoft.com>
      Cc: Wei Liu <wei.liu@kernel.org>
      Cc: Dexuan Cui <decui@microsoft.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Signed-off-by: default avatarUros Bizjak <ubizjak@gmail.com>
      Reviewed-by: default avatarMichael Kelley <mhklinux@outlook.com>
      Link: https://lore.kernel.org/r/20231114170038.381634-1-ubizjak@gmail.comSigned-off-by: default avatarWei Liu <wei.liu@kernel.org>
      Message-ID: <20231114170038.381634-1-ubizjak@gmail.com>
      18286883
  2. 12 Nov, 2023 1 commit
    • Saurabh Sengar's avatar
      x86/hyperv: Fix the detection of E820_TYPE_PRAM in a Gen2 VM · 7e8037b0
      Saurabh Sengar authored
      A Gen2 VM doesn't support legacy PCI/PCIe, so both raw_pci_ops and
      raw_pci_ext_ops are NULL, and pci_subsys_init() -> pcibios_init()
      doesn't call pcibios_resource_survey() -> e820__reserve_resources_late();
      as a result, any emulated persistent memory of E820_TYPE_PRAM (12) via
      the kernel parameter memmap=nn[KMG]!ss is not added into iomem_resource
      and hence can't be detected by register_e820_pmem().
      
      Fix this by directly calling e820__reserve_resources_late() in
      hv_pci_init(), which is called from arch_initcall(pci_arch_init).
      
      It's ok to move a Gen2 VM's e820__reserve_resources_late() from
      subsys_initcall(pci_subsys_init) to arch_initcall(pci_arch_init) because
      the code in-between doesn't depend on the E820 resources.
      e820__reserve_resources_late() depends on e820__reserve_resources(),
      which has been called earlier from setup_arch().
      
      For a Gen-2 VM, the new hv_pci_init() also adds any memory of
      E820_TYPE_PMEM (7) into iomem_resource, and acpi_nfit_register_region() ->
      acpi_nfit_insert_resource() -> region_intersects() returns
      REGION_INTERSECTS, so the memory of E820_TYPE_PMEM won't get added twice.
      
      Changed the local variable "int gen2vm" to "bool gen2vm".
      Signed-off-by: default avatarSaurabh Sengar <ssengar@linux.microsoft.com>
      Signed-off-by: default avatarDexuan Cui <decui@microsoft.com>
      Signed-off-by: default avatarWei Liu <wei.liu@kernel.org>
      Message-ID: <1699691867-9827-1-git-send-email-ssengar@linux.microsoft.com>
      7e8037b0
  3. 10 Nov, 2023 1 commit
  4. 30 Oct, 2023 1 commit
  5. 28 Oct, 2023 15 commits
  6. 27 Oct, 2023 15 commits
  7. 26 Oct, 2023 6 commits