Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Aug 01, 2024
  2. Jul 31, 2024
  3. Jul 28, 2024
    • Linus Torvalds's avatar
      minmax: add a few more MIN_T/MAX_T users · 4477b39c
      Linus Torvalds authored
      Commit 3a7e02c0 ("minmax: avoid overly complicated constant
      expressions in VM code") added the simpler MIN_T/MAX_T macros in order
      to avoid some excessive expansion from the rather complicated regular
      min/max macros.
      
      The complexity of those macros stems from two issues:
      
       (a) trying to use them in situations that require a C constant
           expression (in static initializers and for array sizes)
      
       (b) the type sanity checking
      
      and MIN_T/MAX_T avoids both of these issues.
      
      Now, in the whole (long) discussion about all this, it was pointed out
      that the whole type sanity checking is entirely unnecessary for
      min_t/max_t which get a fixed type that the comparison is done in.
      
      But that still leaves min_t/max_t unnecessarily complicated due to
      worries about the C constant expression case.
      
      However, it turns out that there really aren't very many cases that use
      min_t/max_t for this, and we can just force-convert those.
      
      This does exactly that.
      
      Which in turn will then a...
      4477b39c
  4. Jul 26, 2024
  5. Jul 25, 2024
    • Will Deacon's avatar
      arm64: mm: Fix lockless walks with static and dynamic page-table folding · 36639013
      Will Deacon authored
      Lina reports random oopsen originating from the fast GUP code when
      16K pages are used with 4-level page-tables, the fourth level being
      folded at runtime due to lack of LPA2.
      
      In this configuration, the generic implementation of
      p4d_offset_lockless() will return a 'p4d_t *' corresponding to the
      'pgd_t' allocated on the stack of the caller, gup_fast_pgd_range().
      This is normally fine, but when the fourth level of page-table is folded
      at runtime, pud_offset_lockless() will offset from the address of the
      'p4d_t' to calculate the address of the PUD in the same page-table page.
      This results in a stray stack read when the 'p4d_t' has been allocated
      on the stack and can send the walker into the weeds.
      
      Fix the problem by providing our own definition of p4d_offset_lockless()
      when CONFIG_PGTABLE_LEVELS <= 4 which returns the real page-table
      pointer rather than the address of the local stack variable.
      
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/50360968-13fb-4e6f-8f52-1725b3177215@asahilina.net
      Fixes: 0dd4f60a
      
       ("arm64: mm: Add support for folding PUDs at runtime")
      Reported-by: default avatarAsahi Lina <lina@asahilina.net>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Link: https://lore.kernel.org/r/20240725090345.28461-1-will@kernel.org
      
      
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      36639013
    • Luca Ceresoli's avatar
      of: remove internal arguments from of_property_for_each_u32() · 9722c3b6
      Luca Ceresoli authored
      
      The of_property_for_each_u32() macro needs five parameters, two of which
      are primarily meant as internal variables for the macro itself (in the
      for() clause). Yet these two parameters are used by a few drivers, and this
      can be considered misuse or at least bad practice.
      
      Now that the kernel uses C11 to build, these two parameters can be avoided
      by declaring them internally, thus changing this pattern:
      
        struct property *prop;
        const __be32 *p;
        u32 val;
      
        of_property_for_each_u32(np, "xyz", prop, p, val) { ... }
      
      to this:
      
        u32 val;
      
        of_property_for_each_u32(np, "xyz", val) { ... }
      
      However two variables cannot be declared in the for clause even with C11,
      so declare one struct that contain the two variables we actually need. As
      the variables inside this struct are not meant to be used by users of this
      macro, give the struct instance the noticeable name "_it" so it is visible
      during code reviews, helping to avoid new code to use it directly.
      
      Most usages are trivially converted as they do not use those two
      parameters, as expected. The non-trivial cases are:
      
       - drivers/clk/clk.c, of_clk_get_parent_name(): easily doable anyway
       - drivers/clk/clk-si5351.c, si5351_dt_parse(): this is more complex as the
         checks had to be replicated in a different way, making code more verbose
         and somewhat uglier, but I refrained from a full rework to keep as much
         of the original code untouched having no hardware to test my changes
      
      All the changes have been build tested. The few for which I have the
      hardware have been runtime-tested too.
      
      Reviewed-by: Andre Przywara <andre.przywara@arm.com> # drivers/clk/sunxi/clk-simple-gates.c, drivers/clk/sunxi/clk-sun8i-bus-gates.c
      Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> # drivers/gpio/gpio-brcmstb.c
      Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> # drivers/irqchip/irq-atmel-aic-common.c
      Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> # drivers/iio/adc/ti_am335x_adc.c
      Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> # drivers/pwm/pwm-samsung.c
      Acked-by: Richard Leitner <richard.leitner@linux.dev> # drivers/usb/misc/usb251xb.c
      Acked-by: Mark Brown <broonie@kernel.org> # sound/soc/codecs/arizona.c
      Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com> # sound/soc/codecs/arizona.c
      Acked-by: Michael Ellerman <mpe@ellerman.id.au> # arch/powerpc/sysdev/xive/spapr.c
      Acked-by: Stephen Boyd <sboyd@kernel.org> # clk
      Signed-off-by: default avatarLuca Ceresoli <luca.ceresoli@bootlin.com>
      Acked-by: default avatarLee Jones <lee@kernel.org>
      Link: https://lore.kernel.org/r/20240724-of_property_for_each_u32-v3-1-bea82ce429e2@bootlin.com
      
      
      Signed-off-by: default avatarRob Herring (Arm) <robh@kernel.org>
      9722c3b6
    • Roger Pau Monne's avatar
      x86/xen: fix memblock_reserve() usage on PVH · 4c006734
      Roger Pau Monne authored
      The current usage of memblock_reserve() in init_pvh_bootparams() is done before
      the .bss is zeroed, and that used to be fine when
      memblock_reserved_init_regions implicitly ended up in the .meminit.data
      section.  However after commit 73db3abd memblock_reserved_init_regions
      ends up in the .bss section, thus breaking it's usage before the .bss is
      cleared.
      
      Move and rename the call to xen_reserve_extra_memory() so it's done in the
      x86_init.oem.arch_setup hook, which gets executed after the .bss has been
      zeroed, but before calling e820__memory_setup().
      
      Fixes: 73db3abd
      
       ("init/modpost: conditionally check section mismatch to __meminit*")
      Signed-off-by: default avatarRoger Pau Monné <roger.pau@citrix.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Message-ID: <20240725073116.14626-3-roger.pau@citrix.com>
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      4c006734
    • Roger Pau Monne's avatar
      x86/xen: move xen_reserve_extra_memory() · fc05ea89
      Roger Pau Monne authored
      
      In preparation for making the function static.
      
      No functional change.
      
      Signed-off-by: default avatarRoger Pau Monné <roger.pau@citrix.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Message-ID: <20240725073116.14626-2-roger.pau@citrix.com>
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      fc05ea89
  6. Jul 24, 2024
  7. Jul 23, 2024