Skip to content
Snippets Groups Projects
  1. Jun 26, 2023
  2. Mar 22, 2023
    • Roger Pau Monne's avatar
      ACPI: processor: Fix evaluating _PDC method when running as Xen dom0 · 073828e9
      Roger Pau Monne authored
      
      In ACPI systems, the OS can direct power management, as opposed to the
      firmware.  This OS-directed Power Management is called OSPM.  Part of
      telling the firmware that the OS going to direct power management is
      making ACPI "_PDC" (Processor Driver Capabilities) calls.  These _PDC
      methods must be evaluated for every processor object.  If these _PDC
      calls are not completed for every processor it can lead to
      inconsistency and later failures in things like the CPU frequency
      driver.
      
      In a Xen system, the dom0 kernel is responsible for system-wide power
      management.  The dom0 kernel is in charge of OSPM.  However, the
      number of CPUs available to dom0 can be different than the number of
      CPUs physically present on the system.
      
      This leads to a problem: the dom0 kernel needs to evaluate _PDC for
      all the processors, but it can't always see them.
      
      In dom0 kernels, ignore the existing ACPI method for determining if a
      processor is physically present because it might not be accurate.
      Instead, ask the hypervisor for this information.
      
      Fix this by introducing a custom function to use when running as Xen
      dom0 in order to check whether a processor object matches a CPU that's
      online.  Such checking is done using the existing information fetched
      by the Xen pCPU subsystem, extending it to also store the ACPI ID.
      
      This ensures that _PDC method gets evaluated for all physically online
      CPUs, regardless of the number of CPUs made available to dom0.
      
      Fixes: 5d554a7b ("ACPI: processor: add internal processor_physically_present()")
      Signed-off-by: default avatarRoger Pau Monné <roger.pau@citrix.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      073828e9
  3. Mar 14, 2023
  4. Feb 13, 2023
  5. Jan 27, 2023
  6. Dec 15, 2022
  7. Dec 05, 2022
  8. Oct 10, 2022
  9. Aug 12, 2022
  10. Aug 01, 2022
  11. Jun 06, 2022
  12. Jun 01, 2022
  13. May 27, 2022
  14. May 19, 2022
  15. May 11, 2022
    • Christoph Hellwig's avatar
      swiotlb-xen: fix DMA_ATTR_NO_KERNEL_MAPPING on arm · 566fb90e
      Christoph Hellwig authored
      
      swiotlb-xen uses very different ways to allocate coherent memory on x86
      vs arm.  On the former it allocates memory from the page allocator, while
      on the later it reuses the dma-direct allocator the handles the
      complexities of non-coherent DMA on arm platforms.
      
      Unfortunately the complexities of trying to deal with the two cases in
      the swiotlb-xen.c code lead to a bug in the handling of
      DMA_ATTR_NO_KERNEL_MAPPING on arm.  With the DMA_ATTR_NO_KERNEL_MAPPING
      flag the coherent memory allocator does not actually allocate coherent
      memory, but just a DMA handle for some memory that is DMA addressable
      by the device, but which does not have to have a kernel mapping.  Thus
      dereferencing the return value will lead to kernel crashed and memory
      corruption.
      
      Fix this by using the dma-direct allocator directly for arm, which works
      perfectly fine because on arm swiotlb-xen is only used when the domain is
      1:1 mapped, and then simplifying the remaining code to only cater for the
      x86 case with DMA coherent device.
      
      Reported-by: default avatarRahul Singh <Rahul.Singh@arm.com>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarRahul Singh <rahul.singh@arm.com>
      Reviewed-by: default avatarStefano Stabellini <sstabellini@kernel.org>
      Tested-by: default avatarRahul Singh <rahul.singh@arm.com>
      566fb90e
  16. Apr 18, 2022
  17. Mar 16, 2022
  18. Mar 07, 2022
    • Juergen Gross's avatar
      xen/gnttab: fix gnttab_end_foreign_access() without page specified · 42baefac
      Juergen Gross authored
      
      gnttab_end_foreign_access() is used to free a grant reference and
      optionally to free the associated page. In case the grant is still in
      use by the other side processing is being deferred. This leads to a
      problem in case no page to be freed is specified by the caller: the
      caller doesn't know that the page is still mapped by the other side
      and thus should not be used for other purposes.
      
      The correct way to handle this situation is to take an additional
      reference to the granted page in case handling is being deferred and
      to drop that reference when the grant reference could be freed
      finally.
      
      This requires that there are no users of gnttab_end_foreign_access()
      left directly repurposing the granted page after the call, as this
      might result in clobbered data or information leaks via the not yet
      freed grant reference.
      
      This is part of CVE-2022-23041 / XSA-396.
      
      Reported-by: default avatarSimon Gaiser <simon@invisiblethingslab.com>
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarJan Beulich <jbeulich@suse.com>
      ---
      V4:
      - expand comment in header
      V5:
      - get page ref in case of kmalloc() failure, too
      42baefac
    • Juergen Gross's avatar
      xen: remove gnttab_query_foreign_access() · 1dbd11ca
      Juergen Gross authored
      
      Remove gnttab_query_foreign_access(), as it is unused and unsafe to
      use.
      
      All previous use cases assumed a grant would not be in use after
      gnttab_query_foreign_access() returned 0. This information is useless
      in best case, as it only refers to a situation in the past, which could
      have changed already.
      
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarJan Beulich <jbeulich@suse.com>
      1dbd11ca
    • Juergen Gross's avatar
      xen/grant-table: add gnttab_try_end_foreign_access() · 6b1775f2
      Juergen Gross authored
      
      Add a new grant table function gnttab_try_end_foreign_access(), which
      will remove and free a grant if it is not in use.
      
      Its main use case is to either free a grant if it is no longer in use,
      or to take some other action if it is still in use. This other action
      can be an error exit, or (e.g. in the case of blkfront persistent grant
      feature) some special handling.
      
      This is CVE-2022-23036, CVE-2022-23038 / part of XSA-396.
      
      Reported-by: default avatarDemi Marie Obenour <demi@invisiblethingslab.com>
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarJan Beulich <jbeulich@suse.com>
      ---
      V2:
      - new patch
      V4:
      - add comments to header (Jan Beulich)
      6b1775f2
  19. Feb 03, 2022
  20. Jan 06, 2022
    • Oleksandr Tyshchenko's avatar
      xen/unpopulated-alloc: Add mechanism to use Xen resource · d1a928ea
      Oleksandr Tyshchenko authored
      
      The main reason of this change is that unpopulated-alloc
      code cannot be used in its current form on Arm, but there
      is a desire to reuse it to avoid wasting real RAM pages
      for the grant/foreign mappings.
      
      The problem is that system "iomem_resource" is used for
      the address space allocation, but the really unallocated
      space can't be figured out precisely by the domain on Arm
      without hypervisor involvement. For example, not all device
      I/O regions are known by the time domain starts creating
      grant/foreign mappings. And following the advise from
      "iomem_resource" we might end up reusing these regions by
      a mistake. So, the hypervisor which maintains the P2M for
      the domain is in the best position to provide unused regions
      of guest physical address space which could be safely used
      to create grant/foreign mappings.
      
      Introduce new helper arch_xen_unpopulated_init() which purpose
      is to create specific Xen resource based on the memory regions
      provided by the hypervisor to be used as unused space for Xen
      scratch pages. If arch doesn't define arch_xen_unpopulated_init()
      the default "iomem_resource" will be used.
      
      Update the arguments list of allocate_resource() in fill_list()
      to always allocate a region from the hotpluggable range
      (maximum possible addressable physical memory range for which
      the linear mapping could be created). If arch doesn't define
      arch_get_mappable_range() the default range (0,-1) will be used.
      
      The behaviour on x86 won't be changed by current patch as both
      arch_xen_unpopulated_init() and arch_get_mappable_range()
      are not implemented for it.
      
      Also fallback to allocate xenballooned pages (balloon out RAM
      pages) if we do not have any suitable resource to work with
      (target_resource is invalid) and as the result we won't be able
      to provide unpopulated pages on a request.
      
      Signed-off-by: default avatarOleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
      Reviewed-by: default avatarStefano Stabellini <sstabellini@kernel.org>
      Link: https://lore.kernel.org/r/1639080336-26573-5-git-send-email-olekstysh@gmail.com
      
      
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      d1a928ea
    • Oleksandr Tyshchenko's avatar
      xen/balloon: Bring alloc(free)_xenballooned_pages helpers back · 9dd060af
      Oleksandr Tyshchenko authored
      
      This patch rolls back some of the changes introduced by commit
      121f2fac "xen/balloon: rename alloc/free_xenballooned_pages"
      in order to make possible to still allocate xenballooned pages
      if CONFIG_XEN_UNPOPULATED_ALLOC is enabled.
      
      On Arm the unpopulated pages will be allocated on top of extended
      regions provided by Xen via device-tree (the subsequent patches
      will add required bits to support unpopulated-alloc feature on Arm).
      The problem is that extended regions feature has been introduced
      into Xen quite recently (during 4.16 release cycle). So this
      effectively means that Linux must only use unpopulated-alloc on Arm
      if it is running on "new Xen" which advertises these regions.
      But, it will only be known after parsing the "hypervisor" node
      at boot time, so before doing that we cannot assume anything.
      
      In order to keep working if CONFIG_XEN_UNPOPULATED_ALLOC is enabled
      and the extended regions are not advertised (Linux is running on
      "old Xen", etc) we need the fallback to alloc_xenballooned_pages().
      
      This way we wouldn't reduce the amount of memory usable (wasting
      RAM pages) for any of the external mappings anymore (and eliminate
      XSA-300) with "new Xen", but would be still functional ballooning
      out RAM pages with "old Xen".
      
      Also rename alloc(free)_xenballooned_pages to xen_alloc(free)_ballooned_pages
      and make xen_alloc(free)_unpopulated_pages static inline in xen.h
      if CONFIG_XEN_UNPOPULATED_ALLOC is disabled.
      
      Signed-off-by: default avatarOleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
      Reviewed-by: default avatarStefano Stabellini <sstabellini@kernel.org>
      Link: https://lore.kernel.org/r/1639080336-26573-4-git-send-email-olekstysh@gmail.com
      
      
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      9dd060af
    • Jan Beulich's avatar
      xen/x86: obtain upper 32 bits of video frame buffer address for Dom0 · 335e4dd6
      Jan Beulich authored
      
      The hypervisor has been supplying this information for a couple of major
      releases. Make use of it. The need to set a flag in the capabilities
      field also points out that the prior setting of that field from the
      hypervisor interface's gbl_caps one was wrong, so that code gets deleted
      (there's also no equivalent of this in native boot code).
      
      Signed-off-by: default avatarJan Beulich <jbeulich@suse.com>
      Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      
      Link: https://lore.kernel.org/r/a3df8bf3-d044-b7bb-3383-cd5239d6d4af@suse.com
      
      
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      335e4dd6
  21. Dec 16, 2021
    • Juergen Gross's avatar
      xen/console: harden hvc_xen against event channel storms · fe415186
      Juergen Gross authored
      
      The Xen console driver is still vulnerable for an attack via excessive
      number of events sent by the backend. Fix that by using a lateeoi event
      channel.
      
      For the normal domU initial console this requires the introduction of
      bind_evtchn_to_irq_lateeoi() as there is no xenbus device available
      at the time the event channel is bound to the irq.
      
      As the decision whether an interrupt was spurious or not requires to
      test for bytes having been read from the backend, move sending the
      event into the if statement, as sending an event without having found
      any bytes to be read is making no sense at all.
      
      This is part of XSA-391
      
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarJan Beulich <jbeulich@suse.com>
      ---
      V2:
      - slightly adapt spurious irq detection (Jan Beulich)
      V3:
      - fix spurious irq detection (Jan Beulich)
      fe415186
Loading